mirror of
https://github.com/Febbweiss/ProjectDeployer.git
synced 2026-03-04 22:25:38 +00:00
Feature: use service to manage collection
This commit is contained in:
@@ -68,10 +68,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="git_url" class="col-sm-2 control-label">
|
<label for="git_url" class="col-sm-2 control-label">
|
||||||
<i class="fa fa-fw fa-github fa-2x" title="Git URL"></i>
|
<i class="fa fa-fw fa-github fa-2x" title="Git clone URL"></i>
|
||||||
</label>
|
</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input type="url" class="form-control" name="git_url" placeholder="Git URL" value="{{project.git_url}}" required/>
|
<input type="url" class="form-control" name="git_url" placeholder="Git clone URL" value="{{project.git_url}}" required/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
@@ -1,11 +1,47 @@
|
|||||||
Projects = new Mongo.Collection('projects');
|
Projects = new Mongo.Collection('projects');
|
||||||
|
|
||||||
|
ProjectService = {
|
||||||
|
insert: function(label, git_url, public_url, commands, callback) {
|
||||||
|
Projects.insert({
|
||||||
|
label: label,
|
||||||
|
git_url: git_url,
|
||||||
|
public_url: public_url,
|
||||||
|
commands: commands
|
||||||
|
}, callback);
|
||||||
|
},
|
||||||
|
|
||||||
|
update: function(id, label, git_url, public_url ,commands) {
|
||||||
|
Projects.update(
|
||||||
|
id,
|
||||||
|
{ $set: {
|
||||||
|
label: label,
|
||||||
|
git_url: git_url,
|
||||||
|
public_url: public_url,
|
||||||
|
commands: commands
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
delete: function(id) {
|
||||||
|
Projects.remove(id);
|
||||||
|
},
|
||||||
|
|
||||||
|
get: function(id) {
|
||||||
|
return Projects.findOne({_id: id});
|
||||||
|
},
|
||||||
|
|
||||||
|
list: function() {
|
||||||
|
return Projects.find({}, {sort: {label: 1}});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (Meteor.isClient) {
|
if (Meteor.isClient) {
|
||||||
Meteor.subscribe('projects');
|
Meteor.subscribe('projects');
|
||||||
|
|
||||||
Template.management.helpers({
|
Template.management.helpers({
|
||||||
projects: function () {
|
projects: function () {
|
||||||
return Projects.find({}, {sort: {label: 1}});
|
return ProjectService.list();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -17,7 +53,6 @@ if (Meteor.isClient) {
|
|||||||
'submit .new-project': function (event) {
|
'submit .new-project': function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var form = event.target;
|
var form = event.target;
|
||||||
console.log('handled', form.id.value);
|
|
||||||
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);
|
Meteor.call('editProject',form.id.value, form.label.value, form.git_url.value, form.public_url.value, form.commands.value);
|
||||||
form.id.value = '';
|
form.id.value = '';
|
||||||
@@ -79,38 +114,22 @@ if (Meteor.isServer) {
|
|||||||
|
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
listProjects: function() {
|
listProjects: function() {
|
||||||
return Projects.find({}, {sort: {label: 1}});
|
return ProjectService.list();
|
||||||
},
|
},
|
||||||
|
|
||||||
getProject: function(id) {
|
getProject: function(id) {
|
||||||
return Projects.findOne({_id: id});
|
return ProjectService.get(id);
|
||||||
},
|
},
|
||||||
|
|
||||||
addProject: function(label, git_url, public_url ,commands) {
|
addProject: function(label, git_url, public_url ,commands) {
|
||||||
console.log('addProjects', arguments);
|
ProjectService.insert(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) {
|
editProject: function(id, label, git_url, public_url ,commands) {
|
||||||
console.log('editProjects', arguments);
|
ProjectService.update(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) {
|
deleteProject: function(id) {
|
||||||
Projects.remove(id);
|
ProjectService.delete(id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user