|
@@ -6,30 +6,54 @@ Template.projects.helpers({
|
|
|
|
|
|
|
|
Template.projectForm.onRendered(function() {
|
|
Template.projectForm.onRendered(function() {
|
|
|
new Clipboard('.btn.clipboard');
|
|
new Clipboard('.btn.clipboard');
|
|
|
|
|
+ Session.set('vars', []);
|
|
|
|
|
+ $('.variables input').val('');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
Template.projectForm.events({
|
|
Template.projectForm.events({
|
|
|
'submit .new-project': function (event) {
|
|
'submit .new-project': function (event) {
|
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
|
- var form = event.target;
|
|
|
|
|
|
|
+ var form = event.target,
|
|
|
|
|
+ variables = Session.get('vars'),
|
|
|
|
|
+ callback = function(errors, result) {
|
|
|
|
|
+
|
|
|
|
|
+ if( errors ) {
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Session.set('projectToEdit', undefined);
|
|
|
|
|
+ Session.set('vars', []);
|
|
|
|
|
+ $('.new-project input').val('');
|
|
|
|
|
+ $('.new-project textarea').val('');
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
if( form.id.value ) {
|
|
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 = '';
|
|
|
|
|
|
|
+ Meteor.call('editProject',
|
|
|
|
|
+ form.id.value,
|
|
|
|
|
+ form.label.value,
|
|
|
|
|
+ form.git_url.value,
|
|
|
|
|
+ form.public_url.value,
|
|
|
|
|
+ form.commands.value,
|
|
|
|
|
+ form.run.value,
|
|
|
|
|
+ variables,
|
|
|
|
|
+ callback);
|
|
|
} else {
|
|
} else {
|
|
|
- Meteor.call('addProject', form.label.value, form.git_url.value, form.public_url.value, form.commands.value);
|
|
|
|
|
|
|
+ Meteor.call('addProject',
|
|
|
|
|
+ form.label.value,
|
|
|
|
|
+ form.git_url.value,
|
|
|
|
|
+ form.public_url.value,
|
|
|
|
|
+ form.commands.value,
|
|
|
|
|
+ form.run.value,
|
|
|
|
|
+ variables,
|
|
|
|
|
+ callback);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- Session.set('projectToEdit', undefined);
|
|
|
|
|
- form.label.value = '';
|
|
|
|
|
- form.git_url.value = '';
|
|
|
|
|
- form.public_url.value = '';
|
|
|
|
|
- form.commands.value = '';
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
'click .cancel': function(event) {
|
|
'click .cancel': function(event) {
|
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
Session.set('projectToEdit', undefined);
|
|
Session.set('projectToEdit', undefined);
|
|
|
|
|
+ Session.set('vars', []);
|
|
|
|
|
+ $('.variables input').val('');
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
'click .trash': function(event) {
|
|
'click .trash': function(event) {
|
|
@@ -37,7 +61,9 @@ Template.projectForm.events({
|
|
|
|
|
|
|
|
Meteor.call('deleteProject', Session.get('projectToEdit')._id);
|
|
Meteor.call('deleteProject', Session.get('projectToEdit')._id);
|
|
|
Session.set('projectToEdit', undefined);
|
|
Session.set('projectToEdit', undefined);
|
|
|
|
|
+ Session.set('vars', []);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
Template.projectForm.helpers({
|
|
Template.projectForm.helpers({
|
|
@@ -51,6 +77,69 @@ Template.projectForm.helpers({
|
|
|
|
|
|
|
|
deployLink: function() {
|
|
deployLink: function() {
|
|
|
return Meteor.absoluteUrl('deploy?token=XXXX&project_id=' + Session.get('projectToEdit')._id);
|
|
return Meteor.absoluteUrl('deploy?token=XXXX&project_id=' + Session.get('projectToEdit')._id);
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ vars: function() {
|
|
|
|
|
+ return Session.get('vars');
|
|
|
|
|
+ }
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+Template.variables.events({
|
|
|
|
|
+ 'click .remove': function(event) {
|
|
|
|
|
+ event.preventDefault();
|
|
|
|
|
+ var variable = Template.currentData().name
|
|
|
|
|
+ vars = Session.get('vars');
|
|
|
|
|
+
|
|
|
|
|
+ vars = _.filter(vars, function(object) {
|
|
|
|
|
+ return object.name !== variable;
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Session.set('vars', vars);
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ 'click .add': function(event) {
|
|
|
|
|
+ event.preventDefault();
|
|
|
|
|
+ var instance = Template.instance(),
|
|
|
|
|
+ name = instance.$('.name').val(),
|
|
|
|
|
+ value = instance.$('.value').val();
|
|
|
|
|
+
|
|
|
|
|
+ var variables = Session.get('vars');
|
|
|
|
|
+ variables.push({name: name, value: value});
|
|
|
|
|
+ Session.set('vars', variables);
|
|
|
|
|
+ Session.set('variables.active', undefined);
|
|
|
|
|
+ instance.$('.name').val(undefined);
|
|
|
|
|
+ instance.$('.value').val(undefined);
|
|
|
|
|
+ }
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+Template.variables.helpers({
|
|
|
|
|
+ action: function() {
|
|
|
|
|
+ return Template.currentData() ? 'remove' : 'add';
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ logo: function() {
|
|
|
|
|
+ return Template.currentData() ? 'minus' : 'plus';
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ active: function() {
|
|
|
|
|
+ var data = Template.currentData(),
|
|
|
|
|
+ active = data && data.name && data.value;
|
|
|
|
|
+
|
|
|
|
|
+ return active || Session.get('variables.active') ? '' : 'disabled';
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ readonly: function() {
|
|
|
|
|
+ return Template.currentData() ? 'readonly' : '';
|
|
|
|
|
+ }
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+Template.variables.events({
|
|
|
|
|
+ 'keyup .name, keyup .value': function(event) {
|
|
|
|
|
+ var instance = Template.instance(),
|
|
|
|
|
+ name = instance.$('.name').val(),
|
|
|
|
|
+ value = instance.$('.value').val();
|
|
|
|
|
+
|
|
|
|
|
+ Session.set('variables.active', name && value);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -59,6 +148,7 @@ Template.project.events({
|
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
|
return Meteor.call('getProject', this._id, function(error, result) {
|
|
return Meteor.call('getProject', this._id, function(error, result) {
|
|
|
Session.set('projectToEdit', result);
|
|
Session.set('projectToEdit', result);
|
|
|
|
|
+ Session.set('vars', result.variables || []);
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|