mirror of
https://github.com/semaphoreui/semaphore.git
synced 2025-01-22 16:20:44 +01:00
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
|
define(['app', 'factories/host'], function (app) {
|
||
|
app.registerFactory('HostGroup', ['$http', 'Host', function ($http, Host) {
|
||
|
var HostGroup = function (id) {
|
||
|
if (!id) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
this.id = id;
|
||
|
}
|
||
|
|
||
|
HostGroup.prototype.save = function (playbook) {
|
||
|
return $http.put('/playbook/'+playbook.data._id+'/hostgroup/'+this.data._id, this.data);
|
||
|
}
|
||
|
|
||
|
HostGroup.prototype.add = function (playbook) {
|
||
|
return $http.post('/playbook/'+playbook.data._id+'/hostgroups', this.data);
|
||
|
}
|
||
|
|
||
|
HostGroup.prototype.delete = function (playbook) {
|
||
|
return $http.delete('/playbook/'+playbook.data._id+'/hostgroup/'+this.data._id);
|
||
|
}
|
||
|
|
||
|
HostGroup.prototype.get = function (playbook) {
|
||
|
return $http.get('/playbook/'+playbook.data._id+'/hostgroup/'+this.id);
|
||
|
}
|
||
|
|
||
|
HostGroup.prototype.getHosts = function (playbook) {
|
||
|
var self = this;
|
||
|
|
||
|
$http.get('/playbook/'+playbook.data._id+'/hostgroup/'+this.data._id+'/hosts')
|
||
|
.success(function (data) {
|
||
|
self.hosts = [];
|
||
|
|
||
|
for (var i = 0; i < data.length; i++) {
|
||
|
var g = new Host();
|
||
|
g.data = data[i];
|
||
|
|
||
|
self.hosts.push(g);
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
return HostGroup;
|
||
|
}])
|
||
|
})
|