Semaphore/public/js/controllers/playbook/hosts.js
Matej Kramny 0f180756ab Auth page
- Restructuring & co
2016-03-18 22:03:28 +00:00

58 lines
1.4 KiB
JavaScript

define([
'services/hostgroups',
'factories/hostgroup',
'factories/host'
], function () {
app.registerController('PlaybookHostsCtrl', ['$scope', '$state', 'hostgroups', 'Host', function($scope, $state, hostgroups, Host) {
$scope.hostgroups = hostgroups;
hostgroups.get($scope.playbook, function () {
});
$scope.add = function () {
$('#addHostGroup').modal('show');
}
$scope.showAddHost = function (hostgroup) {
if (hostgroup.showingAdd) {
hostgroup.showingAdd = false;
} else {
hostgroup.showingAdd = true;
hostgroup.newHost = new Host();
}
}
$scope.deleteHostGroup = function (hostgroup) {
hostgroup.delete($scope.playbook);
hostgroups.get($scope.playbook, function () {
});
}
$scope.deleteHost = function (hostgroup, host) {
host.delete($scope.playbook, hostgroup);
hostgroup.getHosts($scope.playbook);
}
$scope.addHost = function (hostgroup) {
hostgroup.newHost.add($scope.playbook, hostgroup);
hostgroup.getHosts($scope.playbook);
$scope.showAddHost(hostgroup);
}
}]);
app.registerController('AddHostGroupCtrl', ['$scope', 'HostGroup', 'hostgroups', function($scope, HostGroup, hostgroups) {
$scope.hostgroup = new HostGroup();
$scope.add = function () {
$('#addHostGroup').modal('hide');
$scope.hostgroup.add($scope.playbook);
hostgroups.get($scope.playbook, function () {
});
}
}]);
});