Feature: managing projects

This commit is contained in:
2015-10-19 08:07:20 +00:00
commit ee9cc9b002
11 changed files with 341 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
# This file contains information which helps Meteor properly upgrade your
# app when you run 'meteor update'. You should check it into version control
# with your project.
notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
notices-for-facebook-graph-api-2
1.2.0-standard-minifiers-package
1.2.0-meteor-platform-split
1.2.0-cordova-changes
1.2.0-breaking-changes

1
.meteor/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
local

7
.meteor/.id Normal file
View File

@@ -0,0 +1,7 @@
# This file contains a token that is unique to your project.
# Check it into your repository along with the rest of this directory.
# It can be used for purposes such as:
# - ensuring you don't accidentally deploy one app on top of another
# - providing package authors with aggregated statistics
1oqmnsh166tutx1vyzaml

21
.meteor/packages Normal file
View File

@@ -0,0 +1,21 @@
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
meteor-base # Packages every Meteor app needs to have
mobile-experience # Packages for a great mobile UX
mongo # The database Meteor supports right now
blaze-html-templates # Compile .html files into Meteor Blaze views
session # Client-side reactive dictionary for your app
jquery # Helpful client-side library
tracker # Meteor's client-side reactive programming library
standard-minifiers # JS/CSS minifiers run for production mode
es5-shim # ECMAScript 5 compatibility for older browsers.
ecmascript # Enable ECMAScript2015+ syntax in app code
insecure # Allow all DB writes from clients (for prototyping)
twbs:bootstrap-noglyph
fortawesome:fontawesome

2
.meteor/platforms Normal file
View File

@@ -0,0 +1,2 @@
server
browser

1
.meteor/release Normal file
View File

@@ -0,0 +1 @@
METEOR@1.2.0.4-logging.0

67
.meteor/versions Normal file
View File

@@ -0,0 +1,67 @@
autoupdate@1.2.4-logging
babel-compiler@5.8.24_1
babel-runtime@0.1.4
base64@1.0.4
binary-heap@1.0.4
blaze@2.1.3
blaze-html-templates@1.0.1
blaze-tools@1.0.4
boilerplate-generator@1.0.4
caching-compiler@1.0.0
caching-html-compiler@1.0.2
callback-hook@1.0.4
check@1.0.6
ddp@1.2.2
ddp-client@1.2.1
ddp-common@1.2.1
ddp-server@1.2.1
deps@1.0.9
diff-sequence@1.0.1
ecmascript@0.1.5
ecmascript-collections@0.1.6
ejson@1.0.7
es5-shim@4.1.13
fastclick@1.0.7
fortawesome:fontawesome@4.4.0
geojson-utils@1.0.4
hot-code-push@1.0.0
html-tools@1.0.5
htmljs@1.0.5
http@1.1.1
id-map@1.0.4
insecure@1.0.4
jquery@1.11.4
launch-screen@1.0.4
livedata@1.0.15
logging@1.0.8
meteor@1.1.9
meteor-base@1.0.1
minifiers@1.1.7
minimongo@1.0.10
mobile-experience@1.0.1
mobile-status-bar@1.0.6
mongo@1.1.2
mongo-id@1.0.1
npm-mongo@1.4.39_1
observe-sequence@1.0.7
ordered-dict@1.0.4
promise@0.5.0
random@1.0.4
reactive-dict@1.1.2
reactive-var@1.0.6
reload@1.1.4
retry@1.0.4
routepolicy@1.0.6
session@1.1.1
spacebars@1.0.7
spacebars-compiler@1.0.7
standard-minifiers@1.0.1
templating@1.1.4
templating-tools@1.0.0
tracker@1.0.9
twbs:bootstrap-noglyph@3.3.5
ui@1.0.8
underscore@1.0.4
url@1.0.5
webapp@1.2.2
webapp-hashing@1.0.5

1
README.md Normal file
View File

@@ -0,0 +1 @@
Work in progress

1
project-deployer.css Normal file
View File

@@ -0,0 +1 @@
/* CSS declarations go here */

119
project-deployer.html Normal file
View File

@@ -0,0 +1,119 @@
<head>
<title>project-deployer</title>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
Project deployer
</a>
</div>
</div>
</nav>
<div class="container-fluid">
<header>
</header>
<div class="row">
<div class="col-sm-6">
<h2>Register or edit a project</h2>
{{> projectForm}}
</div>
<div class="col-sm-6">
<h2>Your projects</h2>
<ul>
{{#each projects}}
{{> project}}
{{/each}}
</ul>
</div>
</div>
</div>
</body>
<template name="projectForm">
<form class="new-project form-horizontal">
<input type="hidden" name="id" value="{{project._id}}" />
<div class="form-group">
<label for="label" class="col-sm-2 control-label">
<i class="fa fa-fw fa-tag fa-2x" title="Label"></i>
</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="label" placeholder="Label" value="{{project.label}}" required/>
</div>
</div>
<div class="form-group">
<label for="git_url" class="col-sm-2 control-label">
<i class="fa fa-fw fa-github fa-2x" title="Git URL"></i>
</label>
<div class="col-sm-10">
<input type="url" class="form-control" name="git_url" placeholder="Git URL" value="{{project.git_url}}" required/>
</div>
</div>
<div class="form-group">
<label for="public_url" class="col-sm-2 control-label">
<i class="fa fa-fw fa-external-link fa-2x" title="Public URL"></i>
</label>
<div class="col-sm-10">
<input type="url" class="form-control" name="public_url" placeholder="Public URL" value="{{project.public_url}}" required/>
</div>
</div>
<div class="form-group">
<label for="commands" class="col-sm-2 control-label">
<i class="fa fa-fw fa-terminal fa-2x" title="Commands"></i>
</label>
<div class="col-sm-10">
<textarea class="form-control" cols="25" rows="5" placeholder="Commands" value="{{project.commands}}" name="commands"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">
<i class="fa fa-fw fa-floppy-o"></i>
</button>
<a href="#" class="btn btn-default cancel">
<i class="fa fa-fw fa-ban"></i>
</a>
<a href="#" class="btn btn-danger trash {{editionMode}}">
<i class="fa fa-fw fa-trash"></i>
</a>
</div>
</div>
{{#with project}}
<div class="form-group">
<label class="col-sm-2 control-label">
<i class="fa fa-fw fa-cog fa-2x" title="Link to provide to CI (Travis)"></i>
</label>
<div class="col-sm-10">
<div class="input-group">
<input type="text" class="form-control" disabled value="{{deployLink}}"/>
<div class="input-group-addon">
<i class="fa fa-fw fa-clipboard copy"></i>
</div>
</div>
</div>
</div>
{{/with}}
</form>
</template>
<template name="project">
<li>
{{label}}
<a href="{{public_url}}" target="_blank" title="Go to the deployed project">
<i class="fa fa-fw fa-external-link"></i>
</a>
<a href="{{git_url}}" target="_blank" title="Go to the Github repository">
<i class="fa fa-fw fa-github"></i>
</a>
<a href="#" class="edit" title="Edit the project">
<i class="fa fa-fw fa-pencil"></i>
</a>
</li>
</template>

109
project-deployer.js Normal file
View File

@@ -0,0 +1,109 @@
Projects = new Mongo.Collection('projects');
if (Meteor.isClient) {
Meteor.subscribe('projects');
Template.body.helpers({
projects: function () {
return Projects.find({}, {sort: {label: 1}});
}
});
Template.projectForm.events({
'submit .new-project': function (event) {
event.preventDefault();
var form = event.target;
if( form.id.value ) {
Meteor.call('editProject',form.id.value, form.label.value, form.git_url.value, form.public_url.value, form.commands.value);
form.id.value = '';
} else {
Meteor.call('addProject', form.label.value, form.git_url.value, form.public_url.value, form.commands.value);
}
Session.set('projectToEdit', undefined);
form.label.value = '';
form.git_url.value = '';
form.public_url.value = '';
form.commands.value = '';
},
'click .cancel': function(event) {
event.preventDefault();
Session.set('projectToEdit', undefined);
},
'click .trash': function(event) {
event.preventDefault();
Meteor.call('deleteProject', Session.get('projectToEdit')._id);
Session.set('projectToEdit', undefined);
}
});
Template.projectForm.helpers({
project: function() {
return Session.get('projectToEdit');
},
editionMode: function() {
return Session.get('projectToEdit') ? '' : 'hidden';
},
deployLink: function() {
return Meteor.absoluteUrl('/deploy?token=XXXX&project_id=' + Session.get('projectToEdit')._id);
}
});
Template.project.events({
'click .edit': function(event) {
event.preventDefault();
return Meteor.call('getProject', this._id, function(error, result) {
Session.set('projectToEdit', result);
});
},
});
}
if (Meteor.isServer) {
Meteor.publish('projects', function() {
return Projects.find({});
});
}
Meteor.methods({
listProjects: function() {
return Projects.find({}, {sort: {label: 1}});
},
getProject: function(id) {
return Projects.findOne({_id: id});
},
addProject: function(label, git_url, public_url ,commands) {
Projects.insert({
label: label,
git_url: git_url,
public_url: public_url,
commands: commands
})
},
editProject: function(id, label, git_url, public_url ,commands) {
Projects.update(
id,
{ $set: {
label: label,
git_url: git_url,
public_url: public_url,
commands: commands
}
}
);
},
deleteProject: function(id) {
Projects.remove(id);
}
});