diff --git a/public/html/projects/templates/add.pug b/public/html/projects/templates/add.pug index e9569f02c..e1651a650 100644 --- a/public/html/projects/templates/add.pug +++ b/public/html/projects/templates/add.pug @@ -44,15 +44,14 @@ hr .form-group - label.control-label.col-sm-4 Extra CLI Arguments (*MUST* be a JSON array!) + label.control-label.col-sm-4(uib-tooltip='*MUST* be a JSON array! Each argument must be an element of the array, for example: ["-i", "@myinventory.sh", "--private-key=/there/id_rsa", "-vvvv"]') Extra CLI Arguments .col-sm-6 div(ui-ace="{mode: 'json', workerPath: '/public/js/ace/'}" style="height: 100px" class="form-control" ng-model="task.environment") .form-group .col-sm-6.col-sm-offset-4 - .checkbox: label + .checkbox(uib-tooltip="Usually semaphore prepends arguments like `--private-key=/location/id_rsa` to make sure everything goes smoothly. This option is for special needs, where semaphore conflicts with one of your arguments."): label input(type="checkbox" ng-model="user.admin") | Override semaphore arguments - p.help-block Usually semaphore prepends arguments like `--private-key=/location/id_rsa` to make sure everything goes smoothly. This option is for special needs, where semaphore conflicts with one of your arguments. .modal-footer button.btn.btn-default.pull-left(ng-click="$dismiss()") Dismiss button.btn.btn-danger(ng-if="tpl.id" ng-click="$close({ remove: true })") remove diff --git a/public/js/app.js b/public/js/app.js index ae03c74c8..718eb2b76 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -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); }); } diff --git a/public/js/controllers/admin.js b/public/js/controllers/admin.js index c6da411c6..d67351c9f 100644 --- a/public/js/controllers/admin.js +++ b/public/js/controllers/admin.js @@ -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'); }); } diff --git a/public/js/controllers/dashboard.js b/public/js/controllers/dashboard.js index ca805d307..7095f8afb 100644 --- a/public/js/controllers/dashboard.js +++ b/public/js/controllers/dashboard.js @@ -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,12 +23,12 @@ 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'); }); - }); + }, function () {}); } $scope.refresh(); diff --git a/public/js/controllers/login.js b/public/js/controllers/login.js index 3a81a5789..6b04eddc3 100644 --- a/public/js/controllers/login.js +++ b/public/js/controllers/login.js @@ -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.'; }); } }]); diff --git a/public/js/controllers/projects/dashboard.js b/public/js/controllers/projects/dashboard.js index f1f0e3deb..39ff1a622 100644 --- a/public/js/controllers/projects/dashboard.js +++ b/public/js/controllers/projects/dashboard.js @@ -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) { @@ -64,7 +64,7 @@ define(['controllers/projects/taskRunner'], function() { size: 'lg' }).result.then(function() { $scope.reload(); - }); + }, function () {}); } }]); }); \ No newline at end of file diff --git a/public/js/controllers/projects/edit.js b/public/js/controllers/projects/edit.js index 5e49a3396..9d1dd4403 100644 --- a/public/js/controllers/projects/edit.js +++ b/public/js/controllers/projects/edit.js @@ -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'); }); }); diff --git a/public/js/controllers/projects/environment.js b/public/js/controllers/projects/environment.js index 05db9d864..eb7ca2824 100644 --- a/public/js/controllers/projects/environment.js +++ b/public/js/controllers/projects/environment.js @@ -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,12 +44,12 @@ 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'); }); - }); + }, function () {}); } $scope.editEnvironment = function (env) { @@ -64,12 +65,12 @@ 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'); }); - }); + }, function () {}); } $scope.reload(); diff --git a/public/js/controllers/projects/inventory.js b/public/js/controllers/projects/inventory.js index 14ddeca0c..496ac6db4 100644 --- a/public/js/controllers/projects/inventory.js +++ b/public/js/controllers/projects/inventory.js @@ -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,12 +43,12 @@ 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'); }); - }); + }, function () {}); }); } @@ -67,12 +68,12 @@ 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'); }); - }); + }, function () {}); }); } @@ -86,19 +87,19 @@ 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'); }); - }); + }, 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); }); } diff --git a/public/js/controllers/projects/keys.js b/public/js/controllers/projects/keys.js index 7f2ad647a..e0797583d 100644 --- a/public/js/controllers/projects/keys.js +++ b/public/js/controllers/projects/keys.js @@ -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,12 +38,12 @@ 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'); }); - }); + }, function () {}); } $scope.update = function (key) { @@ -59,12 +61,12 @@ 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'); }); - }); + }, function () {}); } $scope.reload(); diff --git a/public/js/controllers/projects/repositories.js b/public/js/controllers/projects/repositories.js index 247ad4bcc..8446b4839 100644 --- a/public/js/controllers/projects/repositories.js +++ b/public/js/controllers/projects/repositories.js @@ -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,12 +59,12 @@ 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'); }); - }); + }, function () {}); } $scope.add = function () { @@ -75,12 +76,12 @@ 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'); }); - }); + }, function () {}); } $scope.reload(); diff --git a/public/js/controllers/projects/taskRunner.js b/public/js/controllers/projects/taskRunner.js index b25e6ac78..1f510ea47 100644 --- a/public/js/controllers/projects/taskRunner.js +++ b/public/js/controllers/projects/taskRunner.js @@ -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 () { diff --git a/public/js/controllers/projects/templates.js b/public/js/controllers/projects/templates.js index 5c1170106..ac2d7a5cd 100644 --- a/public/js/controllers/projects/templates.js +++ b/public/js/controllers/projects/templates.js @@ -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,12 +89,12 @@ 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'); }); - }); + }, function () {}); } $scope.update = function (template) { @@ -104,21 +105,23 @@ define(['controllers/projects/taskRunner'], function () { scope.repositories = $scope.repos; scope.environment = $scope.environment; - $modal.open({ + var modal = $modal.open({ templateUrl: '/tpl/projects/templates/add.html', scope: scope - }).result.then(function (opts) { + }); + + modal.result.then(function (opts) { if (opts.remove) { return $scope.remove(template); } 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 () { + }, function() { $scope.reload(); }); } @@ -146,7 +149,7 @@ define(['controllers/projects/taskRunner'], function () { scope: scope, size: 'lg' }); - }) + }, function () {}); } $scope.showAll = function() { @@ -192,12 +195,12 @@ 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'); }); - }); + }, function () {}); } $scope.reload(); diff --git a/public/js/controllers/projects/users.js b/public/js/controllers/projects/users.js index 10b166c7a..d10e43c91 100644 --- a/public/js/controllers/projects/users.js +++ b/public/js/controllers/projects/users.js @@ -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,12 +43,12 @@ 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'); }); - }); + }, function () {}); }); } @@ -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(); }); } diff --git a/public/js/controllers/tasks.js b/public/js/controllers/tasks.js index 74fe3fd41..85ff930e5 100644 --- a/public/js/controllers/tasks.js +++ b/public/js/controllers/tasks.js @@ -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; }); } diff --git a/public/js/controllers/user.js b/public/js/controllers/user.js index 8f9dd38df..29817e4e3 100644 --- a/public/js/controllers/user.js +++ b/public/js/controllers/user.js @@ -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'); }); } }]); diff --git a/public/js/controllers/users.js b/public/js/controllers/users.js index 3600f5284..0c8f1b9eb 100644 --- a/public/js/controllers/users.js +++ b/public/js/controllers/users.js @@ -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,19 +11,20 @@ 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'); }); - }); + }, function () {}); } }]); }); diff --git a/public/js/factories/hostgroup.js b/public/js/factories/hostgroup.js index dfa960407..61a662188 100644 --- a/public/js/factories/hostgroup.js +++ b/public/js/factories/hostgroup.js @@ -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); } diff --git a/public/js/factories/playbook.js b/public/js/factories/playbook.js index 19f917917..16eb4a076 100644 --- a/public/js/factories/playbook.js +++ b/public/js/factories/playbook.js @@ -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; - }]) -}) \ No newline at end of file + }]); +}); \ No newline at end of file diff --git a/public/js/routes/auth.js b/public/js/routes/auth.js index 51c4b710a..b8d3ef9af 100644 --- a/public/js/routes/auth.js +++ b/public/js/routes/auth.js @@ -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'); }); diff --git a/public/js/routes/project.js b/public/js/routes/project.js index f7da3aba0..668df76c1 100644 --- a/public/js/routes/project.js +++ b/public/js/routes/project.js @@ -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); }); diff --git a/public/js/services/hostgroups.js b/public/js/services/hostgroups.js index 4f6b5cb13..5fc7bcb2c 100644 --- a/public/js/services/hostgroups.js +++ b/public/js/services/hostgroups.js @@ -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); diff --git a/public/js/services/identities.js b/public/js/services/identities.js index 00d8756f6..fc762c980 100644 --- a/public/js/services/identities.js +++ b/public/js/services/identities.js @@ -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(); }); diff --git a/public/js/services/jobs.js b/public/js/services/jobs.js index 8a3875969..9210ee769 100644 --- a/public/js/services/jobs.js +++ b/public/js/services/jobs.js @@ -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); } diff --git a/public/js/services/playbooks.js b/public/js/services/playbooks.js index 4fd1a930c..6cacc04f6 100644 --- a/public/js/services/playbooks.js +++ b/public/js/services/playbooks.js @@ -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(); }); diff --git a/public/js/services/tasks.js b/public/js/services/tasks.js index c87b0bd1a..37705fbcd 100644 --- a/public/js/services/tasks.js +++ b/public/js/services/tasks.js @@ -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); } diff --git a/public/js/services/user.js b/public/js/services/user.js index 2a551420c..4f3f375f6 100644 --- a/public/js/services/user.js +++ b/public/js/services/user.js @@ -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(); }); diff --git a/public/js/services/users.js b/public/js/services/users.js index 4560b424b..73620f7b5 100644 --- a/public/js/services/users.js +++ b/public/js/services/users.js @@ -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(); });