2014-08-25 21:41:05 +02:00
|
|
|
define(['app'], function (app) {
|
|
|
|
app.registerFactory('Job', ['$http', function ($http) {
|
|
|
|
var Job = function (id) {
|
|
|
|
if (!id) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.id = id;
|
|
|
|
}
|
|
|
|
|
2014-08-25 21:55:38 +02:00
|
|
|
Job.prototype.save = function (playbook) {
|
|
|
|
return $http.put('/playbook/'+playbook.data._id+'/job/'+this.data._id, this.data);
|
2014-08-25 21:41:05 +02:00
|
|
|
}
|
|
|
|
|
2014-08-25 21:55:38 +02:00
|
|
|
Job.prototype.add = function (playbook) {
|
|
|
|
return $http.post('/playbook/'+playbook.data._id+'/jobs', this.data);
|
2014-08-25 21:41:05 +02:00
|
|
|
}
|
|
|
|
|
2014-08-25 21:55:38 +02:00
|
|
|
Job.prototype.delete = function (playbook) {
|
|
|
|
return $http.delete('/playbook/'+playbook.data._id+'/job/'+this.data._id);
|
2014-08-25 21:41:05 +02:00
|
|
|
}
|
|
|
|
|
2014-08-25 21:55:38 +02:00
|
|
|
Job.prototype.get = function (playbook) {
|
|
|
|
return $http.get('/playbook/'+playbook.data._id+'/job/'+this.id);
|
2014-08-25 21:41:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Job;
|
|
|
|
}])
|
|
|
|
})
|