Update angular to 1.6

This commit is contained in:
Denis 2018-02-28 17:55:56 +05:00
parent 1911fd3b75
commit 49c315f7cd
27 changed files with 209 additions and 199 deletions

View File

@ -90,10 +90,10 @@ app.run(['$rootScope', '$window', '$couchPotato', '$injector', '$state', '$http'
$rootScope.refreshInfo = function (cb) {
if (typeof cb != 'function') cb = function () { }
$http.get('/info').success(function (info) {
$rootScope.semaphore = info;
$http.get('/info').then(function (info) {
$rootScope.semaphore = info.data;
cb();
}).error(function () {
}).catch(function () {
cb(true);
});
}

View File

@ -6,7 +6,8 @@ define(function () {
}
$scope.checkUpdate = function () {
$http.get('/upgrade').success(function (upgrade) {
$http.get('/upgrade').then(function (response) {
var upgrade = response.data;
if (!upgrade) return;
if (upgrade.updateBody) {
@ -25,10 +26,10 @@ define(function () {
scope: $scope
});
$http.post('/upgrade').success(function () {
$http.post('/upgrade').then(function () {
$scope.upgraded = true;
$scope.pollUpgrade(upgradeModal, 0);
}).error(function () {
}).catch(function () {
swal('Error upgrading', arguments, 'error');
});
}

View File

@ -3,18 +3,18 @@ define(['controllers/projects/edit'], function () {
$scope.projects = [];
$scope.refresh = function ($lastEvents=true) {
$http.get('/projects').success(function (projects) {
$scope.projects = projects;
$http.get('/projects').then(function (response) {
$scope.projects = response.data;
});
if ($lastEvents == true) {
$eventsURL = '/events/last'
$eventsURL = '/events/last';
} else {
$eventsURL = '/events'
$eventsURL = '/events';
}
$http.get($eventsURL).success(function (events) {
$scope.events = events;
$http.get($eventsURL).then(function (response) {
$scope.events = response.data;
});
}
@ -23,10 +23,10 @@ define(['controllers/projects/edit'], function () {
templateUrl: '/tpl/projects/add.html'
}).result.then(function (project) {
$http.post('/projects', project)
.success(function () {
.then(function () {
$scope.refresh();
}).error(function (data, status) {
swal('Error', 'Could not create project: ' + status, 'error');
}).catch(function (response) {
swal('Error', 'Could not create project: ' + response.status, 'error');
});
});
}

View File

@ -15,21 +15,21 @@ define(function () {
$http.post('/auth/login', {
auth: user.auth,
password: pwd
}).success(function (data, status) {
}).then(function (response) {
$scope.status = "Login Successful";
window.location = document.baseURI;
}).error(function (data, status) {
if (status == 400) {
}).catch(function (response) {
if (response.status === 400) {
// Login Failed
$scope.status = data.message;
if (!data.message) {
$scope.status = "Invalid login"
$scope.status = response.data.message;
if (!response.data.message) {
$scope.status = "Invalid login";
}
return;
}
$scope.status = status + ' Request Failed. Try again later.';
$scope.status = response.status + ' Request Failed. Try again later.';
});
}
}]);

View File

@ -2,33 +2,33 @@ define(['controllers/projects/taskRunner'], function() {
app.registerController('ProjectDashboardCtrl', ['$scope', '$http', 'Project', '$uibModal', '$rootScope', function($scope, $http, Project, $modal, $rootScope) {
$scope.refreshEvents = function($lastEvents=true) {
var $eventsURL;
if ($lastEvents == true) {
$eventsURL = '/events/last'
$eventsURL = '/events/last';
} else {
$eventsURL = '/events'
$eventsURL = '/events';
}
$http.get(Project.getURL() + $eventsURL).success(function(events) {
$scope.events = events;
$http.get(Project.getURL() + $eventsURL).then(function(events) {
$scope.events = events.data;
events.forEach(function(evt) {
events.data.forEach(function(evt) {
evt.createdFormatted = moment(evt.created).format('DD/M/YY HH:mm')
})
});
});
}
$scope.reload = function($lastEvents=true) {
var $tasksURL;
if ($lastEvents == true) {
$tasksURL = '/tasks/last'
$tasksURL = '/tasks/last';
} else {
$tasksURL = '/tasks'
$tasksURL = '/tasks';
}
$http.get(Project.getURL() + $tasksURL).success(function(tasks) {
$scope.tasks = tasks;
$http.get(Project.getURL() + $tasksURL).then(function(tasks) {
$scope.tasks = tasks.data;
$scope.tasks.forEach(function(t) {
if (t.created) {

View File

@ -5,9 +5,9 @@ define(function () {
$scope.alert_chat = Project.alert_chat;
$scope.save = function (name, alert, alert_chat) {
$http.put(Project.getURL(), { name: name, alert: alert, alert_chat: alert_chat}).success(function () {
$http.put(Project.getURL(), { name: name, alert: alert, alert_chat: alert_chat}).then(function () {
swal('Saved', 'Project settings saved.', 'success');
}).error(function () {
}).catch(function () {
swal('Error', 'Project settings were not saved', 'error');
});
}
@ -21,9 +21,9 @@ define(function () {
confirmButtonColor: "#DD6B55",
confirmButtonText: 'Yes, DELETE'
}, function () {
$http.delete(Project.getURL()).success(function () {
$http.delete(Project.getURL()).then(function () {
$state.go('dashboard');
}).error(function () {
}).catch(function () {
swal('error', 'could not delete project!', 'error');
});
});

View File

@ -1,15 +1,16 @@
define(function () {
app.registerController('ProjectEnvironmentCtrl', ['$scope', '$http', '$uibModal', 'Project', '$rootScope', function ($scope, $http, $modal, Project, $rootScope) {
$scope.reload = function () {
$http.get(Project.getURL() + '/environment?sort=name&order=asc').success(function (environment) {
$scope.environment = environment;
$http.get(Project.getURL() + '/environment?sort=name&order=asc').then(function (environment) {
$scope.environment = environment.data;
});
}
$scope.remove = function (environment) {
$http.delete(Project.getURL() + '/environment/' + environment.id).success(function () {
$http.delete(Project.getURL() + '/environment/' + environment.id).then(function () {
$scope.reload();
}).error(function (d) {
}).catch(function (response) {
var d = response.data;
if (!(d && d.inUse)) {
swal('error', 'could not delete environment..', 'error');
return;
@ -23,9 +24,9 @@ define(function () {
confirmButtonColor: "#DD6B55",
confirmButtonText: 'Mark as removed'
}, function () {
$http.delete(Project.getURL() + '/environment/' + environment.id + '?setRemoved=1').success(function () {
$http.delete(Project.getURL() + '/environment/' + environment.id + '?setRemoved=1').then(function () {
$scope.reload();
}).error(function () {
}).catch(function () {
swal('error', 'could not delete environment..', 'error');
});
});
@ -43,10 +44,10 @@ define(function () {
scope: scope
}).result.then(function (env) {
$http.post(Project.getURL() + '/environment', env.environment)
.success(function () {
.then(function () {
$scope.reload();
}).error(function (_, status) {
swal('Error', 'Environment not added: ' + status, 'error');
}).catch(function (response) {
swal('Error', 'Environment not added: ' + response.status, 'error');
});
});
}
@ -64,10 +65,10 @@ define(function () {
}
$http.put(Project.getURL() + '/environment/' + env.id, opts.environment)
.success(function () {
.then(function () {
$scope.reload();
}).error(function (_, status) {
swal('Error', 'Environment not updated: ' + status, 'error');
}).catch(function (response) {
swal('Error', 'Environment not updated: ' + response.status, 'error');
});
});
}

View File

@ -1,15 +1,16 @@
define(function () {
app.registerController('ProjectInventoryCtrl', ['$scope', '$http', '$uibModal', 'Project', '$rootScope', function ($scope, $http, $modal, Project, $rootScope) {
$scope.reload = function () {
$http.get(Project.getURL() + '/inventory?sort=name&order=asc').success(function (inventory) {
$scope.inventory = inventory;
$http.get(Project.getURL() + '/inventory?sort=name&order=asc').then(function (inventory) {
$scope.inventory = inventory.data;
});
}
$scope.remove = function (inventory) {
$http.delete(Project.getURL() + '/inventory/' + inventory.id).success(function () {
$http.delete(Project.getURL() + '/inventory/' + inventory.id).then(function () {
$scope.reload();
}).error(function (d) {
}).catch(function (response) {
var d = response.data;
if (!(d && d.inUse)) {
swal('error', 'could not delete inventory..', 'error');
return;
@ -23,9 +24,9 @@ define(function () {
confirmButtonColor: "#DD6B55",
confirmButtonText: 'Mark as removed'
}, function () {
$http.delete(Project.getURL() + '/inventory/' + inventory.id + '?setRemoved=1').success(function () {
$http.delete(Project.getURL() + '/inventory/' + inventory.id + '?setRemoved=1').then(function () {
$scope.reload();
}).error(function () {
}).catch(function () {
swal('error', 'could not delete inventory..', 'error');
});
});
@ -42,10 +43,10 @@ define(function () {
scope: scope
}).result.then(function (inventory) {
$http.post(Project.getURL() + '/inventory', inventory.inventory)
.success(function () {
.then(function () {
$scope.reload();
}).error(function (_, status) {
swal('Error', 'Inventory not added: ' + status, 'error');
}).catch(function (response) {
swal('Error', 'Inventory not added: ' + response.status, 'error');
});
});
});
@ -67,10 +68,10 @@ define(function () {
}
$http.put(Project.getURL() + '/inventory/' + inventory.id, opts.inventory)
.success(function () {
.then(function () {
$scope.reload();
}).error(function (_, status) {
swal('Error', 'Inventory not updated: ' + status, 'error');
}).catch(function (response) {
swal('Error', 'Inventory not updated: ' + response.status, 'error');
});
});
});
@ -86,10 +87,10 @@ define(function () {
}).result.then(function (v) {
inventory.inventory = v;
$http.put(Project.getURL() + '/inventory/' + inventory.id, inventory)
.success(function () {
.then(function () {
$scope.reload();
}).error(function (_, status) {
swal('Error', 'Inventory not updated: ' + status, 'error');
}).catch(function (response) {
swal('Error', 'Inventory not updated: ' + response.status, 'error');
});
});
}
@ -97,8 +98,8 @@ define(function () {
$scope.getKeys = function (cb) {
if (typeof cb != 'function') cb = function () {}
$http.get(Project.getURL() + '/keys?type=ssh').success(function (keys) {
cb(keys);
$http.get(Project.getURL() + '/keys?type=ssh').then(function (keys) {
cb(keys.data);
});
}

View File

@ -1,15 +1,17 @@
define(function () {
app.registerController('ProjectKeysCtrl', ['$scope', '$http', '$uibModal', 'Project', '$rootScope', function ($scope, $http, $modal, Project, $rootScope) {
$scope.reload = function () {
$http.get(Project.getURL() + '/keys?sort=name&order=asc').success(function (keys) {
$scope.keys = keys;
$http.get(Project.getURL() + '/keys?sort=name&order=asc').then(function (keys) {
$scope.keys = keys.data;
});
}
$scope.remove = function (key) {
$http.delete(Project.getURL() + '/keys/' + key.id).success(function () {
$http.delete(Project.getURL() + '/keys/' + key.id).then(function () {
$scope.reload();
}).error(function (d) {
}).catch(function (response) {
var d = response.data;
if (!(d && d.inUse)) {
swal('error', 'could not delete key..', 'error');
return;
@ -23,9 +25,9 @@ define(function () {
confirmButtonColor: "#DD6B55",
confirmButtonText: 'Mark as removed'
}, function () {
$http.delete(Project.getURL() + '/keys/' + key.id + '?setRemoved=1').success(function () {
$http.delete(Project.getURL() + '/keys/' + key.id + '?setRemoved=1').then(function () {
$scope.reload();
}).error(function () {
}).catch(function () {
swal('error', 'could not remove key..', 'error');
});
});
@ -36,10 +38,10 @@ define(function () {
$modal.open({
templateUrl: '/tpl/projects/keys/add.html'
}).result.then(function (opts) {
$http.post(Project.getURL() + '/keys', opts.key).success(function () {
$http.post(Project.getURL() + '/keys', opts.key).then(function () {
$scope.reload();
}).error(function (_, status) {
swal('error', 'could not add key:' + status, 'error');
}).catch(function (response) {
swal('error', 'could not add key:' + response.status, 'error');
});
});
}
@ -59,10 +61,10 @@ define(function () {
}
$http.put(Project.getURL() + '/keys/' + key.id, opts.key)
.success(function () {
.then(function () {
$scope.reload();
}).error(function (_, status) {
swal('Error', 'could not update key:' + status, 'error');
}).catch(function (response) {
swal('Error', 'could not update key:' + response.status, 'error');
});
});
}

View File

@ -1,11 +1,11 @@
define(function () {
app.registerController('ProjectRepositoriesCtrl', ['$scope', '$http', 'Project', '$uibModal', '$rootScope', function ($scope, $http, Project, $modal, $rootScope) {
$scope.reload = function () {
$http.get(Project.getURL() + '/keys?type=ssh&sort=name&order=asc').success(function (keys) {
$scope.sshKeys = keys;
$http.get(Project.getURL() + '/keys?type=ssh&sort=name&order=asc').then(function (keys) {
$scope.sshKeys = keys.data;
$http.get(Project.getURL() + '/repositories?sort=name&order=asc').success(function (repos) {
repos.forEach(function (repo) {
$http.get(Project.getURL() + '/repositories?sort=name&order=asc').then(function (repos) {
repos.data.forEach(function (repo) {
for (var i = 0; i < keys.length; i++) {
if (repo.ssh_key_id == keys[i].id) {
repo.ssh_key = keys[i];
@ -14,15 +14,16 @@ define(function () {
}
});
$scope.repositories = repos;
$scope.repositories = repos.data;
});
});
}
$scope.remove = function (repo) {
$http.delete(Project.getURL() + '/repositories/' + repo.id).success(function () {
$http.delete(Project.getURL() + '/repositories/' + repo.id).then(function () {
$scope.reload();
}).error(function (d) {
}).then(function (response) {
var d = response.data;
if (!(d && d.templatesUse)) {
swal('error', 'could not delete repository..', 'error');
return;
@ -36,9 +37,9 @@ define(function () {
confirmButtonColor: "#DD6B55",
confirmButtonText: 'Mark as removed'
}, function () {
$http.delete(Project.getURL() + '/repositories/' + repo.id + '?setRemoved=1').success(function () {
$http.delete(Project.getURL() + '/repositories/' + repo.id + '?setRemoved=1').then(function () {
$scope.reload();
}).error(function () {
}).catch(function () {
swal('error', 'could not delete repository..', 'error');
});
});
@ -58,10 +59,10 @@ define(function () {
return $scope.remove(repo);
}
$http.put(Project.getURL() + '/repositories/' + repo.id, opts.repo).success(function () {
$http.put(Project.getURL() + '/repositories/' + repo.id, opts.repo).then(function () {
$scope.reload();
}).error(function (_, status) {
swal('Error', 'Repository not updated: ' + status, 'error');
}).catch(function (response) {
swal('Error', 'Repository not updated: ' + response.status, 'error');
});
});
}
@ -75,10 +76,10 @@ define(function () {
scope: scope
}).result.then(function (repo) {
$http.post(Project.getURL() + '/repositories', repo.repo)
.success(function () {
.then(function () {
$scope.reload();
}).error(function (_, status) {
swal('Error', 'Repository not added: ' + status, 'error');
}).catch(function (response) {
swal('Error', 'Repository not added: ' + response.status, 'error');
});
});
}

View File

@ -10,10 +10,10 @@ define(function () {
if (dryRun) {
params.dry_run = true;
}
$http.post(Project.getURL() + '/tasks', params).success(function (t) {
$scope.$close(t);
}).error(function (_, status) {
swal('Error', 'error launching task: HTTP ' + status, 'error');
$http.post(Project.getURL() + '/tasks', params).then(function (t) {
$scope.$close(t.data);
}).catch(function (response) {
swal('Error', 'error launching task: HTTP ' + response.status, 'error');
});
}
}]);
@ -60,10 +60,10 @@ define(function () {
$scope.reload = function () {
$http.get($scope.project.getURL() + '/tasks/' + $scope.task.id + '/output')
.success(function (output) {
logData = output;
.then(function (output) {
logData = output.data;
var out = [];
output.forEach(function (o) {
output.data.forEach(function (o) {
var pre = '';
if (!$scope.raw) pre = moment(o.time).format('HH:mm:ss') + ': ';
@ -74,19 +74,19 @@ define(function () {
});
if ($scope.task.user_id) {
$http.get('/users/' + $scope.task.user_id)
.success(function (output) {
$scope.task.user_name = output.name;
.then(function (output) {
$scope.task.user_name = output.data.name;
});
}
}
$scope.remove = function () {
$http.delete($scope.project.getURL() + '/tasks/' + $scope.task.id)
.success(function () {
.then(function () {
$scope.$close();
}).error(function () {
}).catch(function () {
swal("Error", 'Could not delete task', 'error');
})
});
}
$scope.$watch('raw', function () {

View File

@ -1,38 +1,38 @@
define(['controllers/projects/taskRunner'], function () {
app.registerController('ProjectTemplatesCtrl', ['$scope', '$http', '$uibModal', 'Project', '$rootScope', '$window', function ($scope, $http, $modal, Project, $rootScope, $window) {
$http.get(Project.getURL() + '/keys?type=ssh').success(function (keys) {
$scope.sshKeys = keys;
$http.get(Project.getURL() + '/keys?type=ssh').then(function (keys) {
$scope.sshKeys = keys.data;
$scope.sshKeysAssoc = {};
keys.forEach(function (k) {
keys.data.forEach(function (k) {
if (k.removed) k.name = '[removed] - ' + k.name;
$scope.sshKeysAssoc[k.id] = k;
});
});
$http.get(Project.getURL() + '/inventory').success(function (inv) {
$scope.inventory = inv;
$http.get(Project.getURL() + '/inventory').then(function (inv) {
$scope.inventory = inv.data;
$scope.inventoryAssoc = {};
inv.forEach(function (i) {
inv.data.forEach(function (i) {
if (i.removed) i.name = '[removed] - ' + i.name;
$scope.inventoryAssoc[i.id] = i;
});
});
$http.get(Project.getURL() + '/repositories').success(function (repos) {
$scope.repos = repos;
$http.get(Project.getURL() + '/repositories').then(function (repos) {
$scope.repos = repos.data;
$scope.reposAssoc = {};
repos.forEach(function (i) {
repos.data.forEach(function (i) {
if (i.removed) i.name = '[removed] - ' + i.name;
$scope.reposAssoc[i.id] = i;
});
});
$http.get(Project.getURL() + '/environment').success(function (env) {
$scope.environment = env;
$http.get(Project.getURL() + '/environment').then(function (env) {
$scope.environment = env.data;
$scope.environmentAssoc = {};
env.forEach(function (i) {
env.data.forEach(function (i) {
if (i.removed) i.name = '[removed] - ' + i.name;
$scope.environmentAssoc[i.id] = i;
@ -56,7 +56,8 @@ define(['controllers/projects/taskRunner'], function () {
}
$scope.reload = function () {
$http.get(Project.getURL() + '/templates?sort=alias&order=asc').success(function (templates) {
$http.get(Project.getURL() + '/templates?sort=alias&order=asc').then(function (response) {
var templates = response.data;
var hiddenTemplates = getHiddenTemplates();
for (var i = 0; i < templates.length; i++) {
var template = templates[i];
@ -69,9 +70,9 @@ define(['controllers/projects/taskRunner'], function () {
}
$scope.remove = function (template) {
$http.delete(Project.getURL() + '/templates/' + template.id).success(function () {
$http.delete(Project.getURL() + '/templates/' + template.id).then(function () {
$scope.reload();
}).error(function () {
}).catch(function () {
swal('error', 'could not delete template..', 'error');
});
}
@ -88,10 +89,10 @@ define(['controllers/projects/taskRunner'], function () {
scope: scope
}).result.then(function (opts) {
var tpl = opts.template;
$http.post(Project.getURL() + '/templates', tpl).success(function () {
$http.post(Project.getURL() + '/templates', tpl).then(function () {
$scope.reload();
}).error(function (_, status) {
swal('error', 'could not add template:' + status, 'error');
}).catch(function (response) {
swal('error', 'could not add template:' + response.status, 'error');
});
});
}
@ -113,10 +114,10 @@ define(['controllers/projects/taskRunner'], function () {
}
var tpl = opts.template;
$http.put(Project.getURL() + '/templates/' + template.id, tpl).success(function () {
$http.put(Project.getURL() + '/templates/' + template.id, tpl).then(function () {
$scope.reload();
}).error(function (_, status) {
swal('error', 'could not add template:' + status, 'error');
}).catch(function (response) {
swal('error', 'could not add template:' + response.status, 'error');
});
}).closed.then(function () {
$scope.reload();
@ -192,10 +193,10 @@ define(['controllers/projects/taskRunner'], function () {
scope: scope
}).result.then(function (opts) {
var tpl = opts.template;
$http.post(Project.getURL() + '/templates', tpl).success(function () {
$http.post(Project.getURL() + '/templates', tpl).then(function () {
$scope.reload();
}).error(function (_, status) {
swal('error', 'could not add template:' + status, 'error');
}).catch(function (response) {
swal('error', 'could not add template:' + response.status, 'error');
});
});
}

View File

@ -1,7 +1,8 @@
define(function () {
app.registerController('ProjectUsersCtrl', ['$scope', '$http', 'Project', '$uibModal', '$rootScope', function ($scope, $http, Project, $modal, $rootScope) {
$scope.reload = function () {
$http.get(Project.getURL() + '/users?sort=name&order=asc').success(function (users) {
$http.get(Project.getURL() + '/users?sort=name&order=asc').then(function (response) {
var users = response.data;
$scope.project_user = null;
$scope.users = users;
@ -15,15 +16,16 @@ define(function () {
}
$scope.remove = function (user) {
$http.delete(Project.getURL() + '/users/' + user.id).success(function () {
$http.delete(Project.getURL() + '/users/' + user.id).then(function () {
$scope.reload();
}).error(function () {
}).catch(function () {
swal('error', 'could not delete user..', 'error');
});
}
$scope.addUser = function () {
$http.get('/users').success(function (users) {
$http.get('/users').then(function (response) {
var users = response.data;
$scope.users.forEach(function (u) {
for (var i = 0; i < users.length; i++) {
if (u.id == users[i].id) {
@ -41,10 +43,10 @@ define(function () {
scope: scope
}).result.then(function (user) {
$http.post(Project.getURL() + '/users', user)
.success(function () {
.then(function () {
$scope.reload();
}).error(function (_, status) {
swal('Error', 'User not added: ' + status, 'error');
}).catch(function (response) {
swal('Error', 'User not added: ' + response.status, 'error');
});
});
});
@ -56,16 +58,16 @@ define(function () {
var numAdmins = 0;
this.users.forEach(function (user) {
user.admin && numAdmins++
})
user.admin && numAdmins++;
});
if (user.admin && numAdmins == 1) {
swal('Administrator Required', 'There must be at least one administrator on the project', 'error');
return
return;
}
verb(Project.getURL() + '/users/' + user.id + '/admin').success(function () {
verb(Project.getURL() + '/users/' + user.id + '/admin').then(function () {
$scope.reload();
});
}

View File

@ -62,7 +62,7 @@ define([
$scope.removeTask = function (task) {
task.delete($scope.playbook, task.data.job)
.success(function () {
.then(function () {
$scope.status = 'Task Deleted';
for (var i = 0; i < $scope.tasks.tasks.length; i++) {
@ -72,8 +72,8 @@ define([
}
}
})
.error(function (data, status) {
$scope.status = 'Task Failed to Delete ('+status+'): '+data;
.catch(function (response) {
$scope.status = 'Task Failed to Delete ('+response.status+'): '+response.data;
});
}

View File

@ -6,17 +6,17 @@ define(function () {
$scope.updatePassword = function (pwd) {
$http.post('/users/' + $scope.user.id + '/password', {
password: pwd
}).success(function () {
}).then(function () {
swal('OK', 'User profile & password were updated.');
}).error(function (_, status) {
swal('Error', 'Setting password failed, API responded with HTTP ' + status, 'error');
}).catch(function (response) {
swal('Error', 'Setting password failed, API responded with HTTP ' + response.status, 'error');
});
}
$scope.updateUser = function () {
var pwd = $scope.user.password;
$http.put('/users/' + $scope.user.id, $scope.user).success(function () {
$http.put('/users/' + $scope.user.id, $scope.user).then(function () {
if ($rootScope.user.id == $scope.user.id) {
$rootScope.user = $scope.user;
}
@ -27,16 +27,16 @@ define(function () {
}
swal('OK', 'User has been updated!');
}).error(function (_, status) {
swal('Error', 'User profile could not be updated: ' + status, 'error');
}).catch(function (response) {
swal('Error', 'User profile could not be updated: ' + response.status, 'error');
});
}
$scope.deleteUser = function () {
$http.delete('/users/' + $scope.user.id).success(function () {
$http.delete('/users/' + $scope.user.id).then(function () {
$state.go('users.list');
}).error(function (_, status) {
swal('Error', 'User could not be deleted! ' + status, 'error');
}).catch(function (response) {
swal('Error', 'User could not be deleted! ' + response.status, 'error');
});
}
}]);

View File

@ -1,7 +1,7 @@
define(function () {
app.registerController('UsersCtrl', ['$scope', '$http', '$uibModal', '$rootScope', function ($scope, $http, $modal, $rootScope) {
$http.get('/users').success(function (users) {
$scope.users = users;
$http.get('/users').then(function (response) {
$scope.users = response.users;
});
$scope.addUser = function () {
@ -11,17 +11,18 @@ define(function () {
$modal.open({
templateUrl: '/tpl/users/add.html',
scope: scope
}).result.then(function (_user) {
$http.post('/users', _user).success(function (user) {
$scope.users.push(user);
}).result.then(function (_response) {
var _user = _response.data;
$http.post('/users', _user).then(function (response) {
$scope.users.push(response.user);
$http.post('/users/' + user.id + '/password', {
$http.post('/users/' + response.user.id + '/password', {
password: _user.password
}).error(function (_, status) {
swal('Error', 'Setting password failed, API responded with HTTP ' + status, 'error');
}).catch(function (errorResponse) {
swal('Error', 'Setting password failed, API responded with HTTP ' + errorResponse.status, 'error');
});
}).error(function (_, status) {
swal('Error', 'API responded with HTTP ' + status, 'error');
}).error(function (response) {
swal('Error', 'API responded with HTTP ' + response.status, 'error');
});
});
}

View File

@ -28,12 +28,12 @@ define(['app', 'factories/host'], function (app) {
var self = this;
$http.get('/playbook/'+playbook.data._id+'/hostgroup/'+this.data._id+'/hosts')
.success(function (data) {
.then(function (response) {
self.hosts = [];
for (var i = 0; i < data.length; i++) {
for (var i = 0; i < response.data.length; i++) {
var g = new Host();
g.data = data[i];
g.data = response.data[i];
self.hosts.push(g);
}

View File

@ -26,27 +26,27 @@ define(['app'], function (app) {
var self = this;
$http.get('/playbook/'+this.id)
.success(function (data, status) {
self.data = data;
.then(function (response) {
self.data = response.data;
cb();
})
.error(function (data, status) {
cb(data, status);
})
.then(function (response) {
cb(response.data, response.status);
});
}
Playbook.prototype.getHostGroups = function (cb) {
$http.get('/playbook/'+this.data._id+'/hosts')
.success(function (data, status) {
.then(function (response) {
self.hosts = data;
self.hosts = response.data;
cb();
})
.error(function (data, status) {
cb(data, status);
})
.error(function (response) {
cb(response.data, response.status);
});
}
return Playbook;
}])
})
}]);
});

View File

@ -18,7 +18,7 @@ app.config(function ($stateProvider, $urlRouterProvider, $locationProvider, $cou
public: true,
templateUrl: '/tpl/auth/logout.html',
controller: ['$http', '$rootScope', '$state', function ($http, $rootScope, $state) {
$http.post('/auth/logout').success(function () {
$http.post('/auth/logout').then(function () {
$rootScope.refreshUser();
$state.go('auth.login');
});

View File

@ -12,9 +12,9 @@ app.config(function ($stateProvider, $couchPotatoProvider) {
var d = $q.defer();
$http.get('/project/' + params.project_id)
.success(function (project) {
d.resolve(new ProjectFactory(project));
}).error(function () {
.then(function (project) {
d.resolve(new ProjectFactory(project.data));
}).catch(function () {
d.resolve(false);
});

View File

@ -6,12 +6,12 @@ define([
var self = this;
self.get = function(playbook, cb) {
$http.get('/playbook/'+playbook.data._id+'/hostgroups').success(function(data) {
$http.get('/playbook/'+playbook.data._id+'/hostgroups').then(function(response) {
self.hostgroups = [];
for (var i = 0; i < data.length; i++) {
for (var i = 0; i < response.data.length; i++) {
var g = new HostGroup();
g.data = data[i];
g.data = response.data[i];
g.getHosts(playbook);
self.hostgroups.push(g);

View File

@ -5,8 +5,8 @@ define([
var self = this;
self.getIdentities = function(cb) {
$http.get('/identities').success(function(data) {
self.identities = data;
$http.get('/identities').then(function(response) {
self.identities = response.data;
cb();
});

View File

@ -6,12 +6,12 @@ define([
var self = this;
self.get = function(playbook, cb) {
$http.get('/playbook/'+playbook.data._id+'/jobs').success(function(data) {
$http.get('/playbook/'+playbook.data._id+'/jobs').then(function(response) {
self.jobs = [];
for (var i = 0; i < data.length; i++) {
for (var i = 0; i < response.data.length; i++) {
var job = new Job();
job.data = data[i];
job.data = response.data[i];
self.jobs.push(job);
}

View File

@ -5,8 +5,8 @@ define([
var self = this;
self.getPlaybooks = function(cb) {
$http.get('/playbooks').success(function(data) {
$rootScope.playbooks = self.playbooks = data;
$http.get('/playbooks').then(function(response) {
$rootScope.playbooks = self.playbooks = response.data;
cb();
});

View File

@ -6,12 +6,12 @@ define([
var self = this;
self.get = function(playbook, cb) {
$http.get('/playbook/'+playbook.data._id+'/tasks').success(function(data) {
$http.get('/playbook/'+playbook.data._id+'/tasks').then(function(response) {
self.tasks = [];
for (var i = 0; i < data.length; i++) {
for (var i = 0; i < response.data.length; i++) {
var task = new Task();
task.data = data[i];
task.data = response.data[i];
self.tasks.push(task);
}

View File

@ -5,8 +5,8 @@ define([
var self = this;
self.getUser = function(cb) {
$http.get('/profile').success(function(data) {
$rootScope.user = self.user = data.user;
$http.get('/profile').then(function(response) {
$rootScope.user = self.user = response.data.user;
cb();
});

View File

@ -5,8 +5,8 @@ define([
var self = this;
self.getUsers = function(cb) {
$http.get('/users').success(function(data) {
self.users = data;
$http.get('/users').then(function(response) {
self.users = response.data;
cb();
});