Merge pull request #472 from marshmalien/angular_upgrade_1_6_6

Upgrade to AngularJS v1.6.6
This commit is contained in:
Marliana Lara
2017-10-23 14:13:11 -04:00
committed by GitHub
115 changed files with 591 additions and 571 deletions

View File

@@ -22,6 +22,16 @@ function AtTruncateController (strings) {
vm.truncatedString = string.substring(0, maxlength); vm.truncatedString = string.substring(0, maxlength);
}; };
vm.copyToClipboard = () => {
vm.tooltip.popover.text = vm.strings.get('truncate.COPIED');
const textarea = el[0].getElementsByClassName('at-Truncate-textarea')[0];
textarea.value = string;
textarea.select();
document.execCommand('copy');
};
vm.tooltip = { vm.tooltip = {
popover: { popover: {
text: vm.strings.get('truncate.DEFAULT'), text: vm.strings.get('truncate.DEFAULT'),
@@ -32,16 +42,6 @@ function AtTruncateController (strings) {
click: vm.copyToClipboard click: vm.copyToClipboard
} }
}; };
vm.copyToClipboard = () => {
vm.tooltip.popover.text = vm.strings.get('truncate.COPIED');
const textarea = el[0].getElementsByClassName('at-Truncate-textarea')[0];
textarea.value = string;
textarea.select();
document.execCommand('copy');
};
} }
AtTruncateController.$inject = ['ComponentsStrings']; AtTruncateController.$inject = ['ComponentsStrings'];

View File

@@ -21,11 +21,11 @@ export default ['$scope', 'ListDefinition', 'Dataset', 'Wait', 'Rest', 'ProcessE
Wait('start'); Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
Rest.post({ "disassociate": true, "id": Number(userId) }) Rest.post({ "disassociate": true, "id": Number(userId) })
.success(function() { .then(() => {
Wait('stop'); Wait('stop');
$state.go('.', null, {reload: true}); $state.go('.', null, {reload: true});
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Could not disassociate user from role. Call to ' + url + ' failed. DELETE returned status: ' + status msg: 'Could not disassociate user from role. Call to ' + url + ' failed. DELETE returned status: ' + status
@@ -54,11 +54,11 @@ export default ['$scope', 'ListDefinition', 'Dataset', 'Wait', 'Rest', 'ProcessE
Wait('start'); Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
Rest.post({ "disassociate": true, "id": teamId }) Rest.post({ "disassociate": true, "id": teamId })
.success(function() { .then(() => {
Wait('stop'); Wait('stop');
$state.go('.', null, {reload: true}); $state.go('.', null, {reload: true});
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Could not disassociate team from role. Call to ' + url + ' failed. DELETE returned status: ' + status msg: 'Could not disassociate team from role. Call to ' + url + ' failed. DELETE returned status: ' + status

View File

@@ -53,11 +53,11 @@ export default
Rest.setUrl(url); Rest.setUrl(url);
Rest.post({ "disassociate": true, "id": entry.id }) Rest.post({ "disassociate": true, "id": entry.id })
.success(function() { .then(() => {
Wait('stop'); Wait('stop');
$state.go('.', null, { reload: true }); $state.go('.', null, { reload: true });
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($rootScope, data, status, null, { ProcessErrors($rootScope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to remove access. Call to ' + url + ' failed. DELETE returned status: ' + status msg: 'Failed to remove access. Call to ' + url + ' failed. DELETE returned status: ' + status

View File

@@ -114,6 +114,9 @@ angular
.constant('AngularScheduler.useTimezone', true) .constant('AngularScheduler.useTimezone', true)
.constant('AngularScheduler.showUTCField', true) .constant('AngularScheduler.showUTCField', true)
.constant('$timezones.definitions.location', urlPrefix + 'lib/angular-tz-extensions/tz/data') .constant('$timezones.definitions.location', urlPrefix + 'lib/angular-tz-extensions/tz/data')
.config(['$locationProvider', function($locationProvider) {
$locationProvider.hashPrefix('');
}])
.config(['$logProvider', function($logProvider) { .config(['$logProvider', function($logProvider) {
$logProvider.debugEnabled($ENV['ng-debug'] || false); $logProvider.debugEnabled($ENV['ng-debug'] || false);
}]) }])

View File

@@ -15,7 +15,7 @@ export default ['$rootScope', 'GetBasePath', 'ProcessErrors', '$q', '$http', 'Re
Rest.setUrl(url); Rest.setUrl(url);
Rest.options() Rest.options()
.success(function(data) { .then(({data}) => {
// Compare GET actions with PUT actions and flag discrepancies // Compare GET actions with PUT actions and flag discrepancies
// for disabling in the UI // for disabling in the UI
var getActions = data.actions.GET; var getActions = data.actions.GET;
@@ -35,7 +35,7 @@ export default ['$rootScope', 'GetBasePath', 'ProcessErrors', '$q', '$http', 'Re
deferred.resolve(returnData); deferred.resolve(returnData);
}) })
.error(function(error) { .catch(({error}) => {
deferred.reject(error); deferred.reject(error);
}); });
@@ -47,10 +47,10 @@ export default ['$rootScope', 'GetBasePath', 'ProcessErrors', '$q', '$http', 'Re
Rest.setUrl(url); Rest.setUrl(url);
Rest.patch(body) Rest.patch(body)
.success(function(data) { .then(({data}) => {
deferred.resolve(data); deferred.resolve(data);
}) })
.error(function(error) { .catch(({error}) => {
deferred.reject(error); deferred.reject(error);
}); });
@@ -61,10 +61,10 @@ export default ['$rootScope', 'GetBasePath', 'ProcessErrors', '$q', '$http', 'Re
var deferred = $q.defer(); var deferred = $q.defer();
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
deferred.resolve(data); deferred.resolve(data);
}) })
.error(function(error) { .catch(({error}) => {
deferred.reject(error); deferred.reject(error);
}); });

View File

@@ -99,11 +99,11 @@ export default ['Rest', 'Wait',
inputs: inputs, inputs: inputs,
injectors: injectors injectors: injectors
}) })
.success(function(data) { .then(({data}) => {
$state.go('credentialTypes.edit', { credential_type_id: data.id }, { reload: true }); $state.go('credentialTypes.edit', { credential_type_id: data.id }, { reload: true });
Wait('stop'); Wait('stop');
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, form, { ProcessErrors($scope, data, status, form, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to add new credential type. PUT returned status: ' + status msg: 'Failed to add new credential type. PUT returned status: ' + status

View File

@@ -173,11 +173,11 @@ export default ['Rest', 'Wait',
inputs: inputs, inputs: inputs,
injectors: injectors injectors: injectors
}) })
.success(function() { .then(() => {
$state.go($state.current, null, { reload: true }); $state.go($state.current, null, { reload: true });
Wait('stop'); Wait('stop');
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, form, { ProcessErrors($scope, data, status, form, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to add new credential type. PUT returned status: ' + status msg: 'Failed to add new credential type. PUT returned status: ' + status

View File

@@ -60,7 +60,7 @@ export default ['$rootScope', '$scope', 'Wait', 'CredentialTypesList',
var url = defaultUrl + id + '/'; var url = defaultUrl + id + '/';
Rest.setUrl(url); Rest.setUrl(url);
Rest.destroy() Rest.destroy()
.success(function() { .then(() => {
let reloadListStateParams = null; let reloadListStateParams = null;
@@ -75,7 +75,7 @@ export default ['$rootScope', '$scope', 'Wait', 'CredentialTypesList',
$state.go('.', reloadListStateParams, { reload: true }); $state.go('.', reloadListStateParams, { reload: true });
} }
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status

View File

@@ -51,7 +51,7 @@ export default
url = GetBasePath("credentials"); url = GetBasePath("credentials");
Rest.setUrl(url); Rest.setUrl(url);
Rest.post(data) Rest.post(data)
.success(function (data) { .then(({data}) => {
scope.addedItem = data.id; scope.addedItem = data.id;
Wait('stop'); Wait('stop');
@@ -63,7 +63,7 @@ export default
ReturnToCaller(1); ReturnToCaller(1);
} }
}) })
.error(function (data, status) { .catch(({data, status}) => {
Wait('stop'); Wait('stop');
// TODO: hopefully this conditional error handling will to away in a future versions. The reason why we cannot // TODO: hopefully this conditional error handling will to away in a future versions. The reason why we cannot
// simply pass this error to ProcessErrors is because it will actually match the form element 'ssh_key_unlock' and show // simply pass this error to ProcessErrors is because it will actually match the form element 'ssh_key_unlock' and show
@@ -83,11 +83,11 @@ export default
url = GetBasePath('credentials') + scope.id + '/'; url = GetBasePath('credentials') + scope.id + '/';
Rest.setUrl(url); Rest.setUrl(url);
Rest.put(data) Rest.put(data)
.success(function () { .then(() => {
Wait('stop'); Wait('stop');
$state.go($state.current, {}, {reload: true}); $state.go($state.current, {}, {reload: true});
}) })
.error(function (data, status) { .catch(({data, status}) => {
Wait('stop'); Wait('stop');
ProcessErrors(scope, data, status, form, { ProcessErrors(scope, data, status, form, {
hdr: i18n._('Error!'), hdr: i18n._('Error!'),

View File

@@ -85,7 +85,7 @@ export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', '
var url = defaultUrl + id + '/'; var url = defaultUrl + id + '/';
Rest.setUrl(url); Rest.setUrl(url);
Rest.destroy() Rest.destroy()
.success(function() { .then(() => {
let reloadListStateParams = null; let reloadListStateParams = null;
@@ -101,7 +101,7 @@ export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', '
} }
Wait('stop'); Wait('stop');
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status

View File

@@ -14,28 +14,28 @@ export default ['$scope', '$rootScope','Wait',
$scope.$on('ws-jobs', function () { $scope.$on('ws-jobs', function () {
Rest.setUrl(GetBasePath('dashboard')); Rest.setUrl(GetBasePath('dashboard'));
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
$scope.dashboardData = data; $scope.dashboardData = data;
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard host graph data: ' + status }); ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard host graph data: ' + status });
}); });
Rest.setUrl(GetBasePath("unified_jobs") + "?order_by=-finished&page_size=5&finished__isnull=false&type=workflow_job,job"); Rest.setUrl(GetBasePath("unified_jobs") + "?order_by=-finished&page_size=5&finished__isnull=false&type=workflow_job,job");
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
$scope.dashboardJobsListData = data.results; $scope.dashboardJobsListData = data.results;
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard jobs list: ' + status }); ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard jobs list: ' + status });
}); });
Rest.setUrl(GetBasePath("unified_job_templates") + "?order_by=-last_job_run&page_size=5&last_job_run__isnull=false&type=workflow_job_template,job_template"); Rest.setUrl(GetBasePath("unified_job_templates") + "?order_by=-last_job_run&page_size=5&last_job_run__isnull=false&type=workflow_job_template,job_template");
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
$scope.dashboardJobTemplatesListData = data.results; $scope.dashboardJobTemplatesListData = data.results;
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard jobs list: ' + status }); ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard jobs list: ' + status });
}); });
@@ -90,29 +90,29 @@ export default ['$scope', '$rootScope','Wait',
Wait('start'); Wait('start');
Rest.setUrl(GetBasePath('dashboard')); Rest.setUrl(GetBasePath('dashboard'));
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
$scope.dashboardData = data; $scope.dashboardData = data;
$scope.$emit('dashboardReady', data); $scope.$emit('dashboardReady', data);
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard: ' + status }); ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard: ' + status });
}); });
Rest.setUrl(GetBasePath("unified_jobs") + "?order_by=-finished&page_size=5&finished__isnull=false&type=workflow_job,job"); Rest.setUrl(GetBasePath("unified_jobs") + "?order_by=-finished&page_size=5&finished__isnull=false&type=workflow_job,job");
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
data = data.results; data = data.results;
$scope.$emit('dashboardJobsListReady', data); $scope.$emit('dashboardJobsListReady', data);
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard jobs list: ' + status }); ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard jobs list: ' + status });
}); });
Rest.setUrl(GetBasePath("unified_job_templates") + "?order_by=-last_job_run&page_size=5&last_job_run__isnull=false&type=workflow_job_template,job_template"); Rest.setUrl(GetBasePath("unified_job_templates") + "?order_by=-last_job_run&page_size=5&last_job_run__isnull=false&type=workflow_job_template,job_template");
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
data = data.results; data = data.results;
$scope.$emit('dashboardJobTemplatesListReady', data); $scope.$emit('dashboardJobTemplatesListReady', data);
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard job templates list: ' + status }); ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard job templates list: ' + status });
}); });
}; };

View File

@@ -239,11 +239,11 @@ function adhocController($q, $scope, $stateParams,
// Launch the adhoc job // Launch the adhoc job
Rest.setUrl(GetBasePath('inventory') + id + '/ad_hoc_commands/'); Rest.setUrl(GetBasePath('inventory') + id + '/ad_hoc_commands/');
Rest.post(data) Rest.post(data)
.success(function (data) { .then(({data}) => {
Wait('stop'); Wait('stop');
$state.go('adHocJobStdout', {id: data.id}); $state.go('adHocJobStdout', {id: data.id});
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, adhocForm, { ProcessErrors($scope, data, status, adhocForm, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to launch adhoc command. POST ' + msg: 'Failed to launch adhoc command. POST ' +

View File

@@ -10,10 +10,10 @@ export default [ '$scope', 'Empty', 'Wait', 'GetBasePath', 'Rest', 'ProcessError
url += "&order_by=-finished&page_size=5"; url += "&order_by=-finished&page_size=5";
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success( function(data) { .then(({data}) => {
$scope.generateTable(data, event); $scope.generateTable(data, event);
}) })
.error( function(data, status) { .catch(({data, status}) => {
ProcessErrors( $scope, data, status, null, { hdr: 'Error!', ProcessErrors( $scope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + ' failed. GET returned: ' + status msg: 'Call to ' + url + ' failed. GET returned: ' + status
}); });

View File

@@ -85,10 +85,10 @@ function InventoriesList($scope,
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
Rest.setUrl(url); Rest.setUrl(url);
Rest.destroy() Rest.destroy()
.success(function () { .then(() => {
Wait('stop'); Wait('stop');
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors( $scope, data, status, null, { hdr: 'Error!', ProcessErrors( $scope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status
}); });

View File

@@ -6,10 +6,10 @@ export default [ '$scope', 'Wait', 'Empty', 'Rest', 'ProcessErrors', '$state',
Wait('start'); Wait('start');
Rest.setUrl($scope.inventory.related.inventory_sources + '?order_by=-last_job_run&page_size=5'); Rest.setUrl($scope.inventory.related.inventory_sources + '?order_by=-last_job_run&page_size=5');
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
$scope.generateTable(data, event); $scope.generateTable(data, event);
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors( $scope, data, status, null, { hdr: 'Error!', ProcessErrors( $scope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + $scope.inventory.related.inventory_sources + ' failed. GET returned status: ' + status msg: 'Call to ' + $scope.inventory.related.inventory_sources + ' failed. GET returned status: ' + status
}); });

View File

@@ -19,7 +19,7 @@ export default {
}, },
resolve: { resolve: {
groupData: ['$stateParams', 'GroupsService', function($stateParams, GroupsService) { groupData: ['$stateParams', 'GroupsService', function($stateParams, GroupsService) {
return GroupsService.get({ id: $stateParams.group_id }).then(res => res.data.results[0]); return GroupsService.get({ id: $stateParams.group_id }).then(response => response.data.results[0]);
}] }]
} }
}; };

View File

@@ -19,9 +19,7 @@ export default {
}, },
resolve: { resolve: {
host: ['$stateParams', 'HostsService', function($stateParams, HostsService) { host: ['$stateParams', 'HostsService', function($stateParams, HostsService) {
return HostsService.get({ id: $stateParams.host_id }).then(function(res) { return HostsService.get({ id: $stateParams.host_id }).then((response) => response.data.results[0]);
return res.data.results[0];
});
}] }]
} }
}; };

View File

@@ -22,7 +22,7 @@ export default
var getNext = function(data, arr, resolve) { var getNext = function(data, arr, resolve) {
Rest.setUrl(data.next); Rest.setUrl(data.next);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
if (data.next) { if (data.next) {
getNext(data, arr.concat(data.results), resolve); getNext(data, arr.concat(data.results), resolve);
} else { } else {
@@ -35,7 +35,7 @@ export default
var seeMoreResolve = $q.defer(); var seeMoreResolve = $q.defer();
Rest.setUrl(`${scope[scope.$parent.list.iterator].related.groups}?order_by=id`); Rest.setUrl(`${scope[scope.$parent.list.iterator].related.groups}?order_by=id`);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
if (data.next) { if (data.next) {
getNext(data, data.results, seeMoreResolve); getNext(data, data.results, seeMoreResolve);
} else { } else {
@@ -65,11 +65,11 @@ export default
if(url) { if(url) {
Rest.setUrl(url); Rest.setUrl(url);
Rest.post({"disassociate": true, "id": host.id}) Rest.post({"disassociate": true, "id": host.id})
.success(function () { .then(() => {
Wait('stop'); Wait('stop');
$state.go('.', null, {reload: true}); $state.go('.', null, {reload: true});
}) })
.error(function (data, status) { .catch(({data, status}) => {
Wait('stop'); Wait('stop');
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Could not disassociate host from group. Call to ' + url + ' failed. DELETE returned status: ' + status }); msg: 'Could not disassociate host from group. Call to ' + url + ' failed. DELETE returned status: ' + status });

View File

@@ -58,9 +58,7 @@ export default {
], ],
host: ['$stateParams', 'HostsService', function($stateParams, HostsService) { host: ['$stateParams', 'HostsService', function($stateParams, HostsService) {
if($stateParams.host_id){ if($stateParams.host_id){
return HostsService.get({ id: $stateParams.host_id }).then(function(res) { return HostsService.get({ id: $stateParams.host_id }).then((res) => res.data.results[0]);
return res.data.results[0];
});
} }
}], }],
inventoryData: ['InventoriesService', '$stateParams', 'host', function(InventoriesService, $stateParams, host) { inventoryData: ['InventoriesService', '$stateParams', 'host', function(InventoriesService, $stateParams, host) {

View File

@@ -36,13 +36,13 @@ export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition',
Wait('start'); Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
$scope.inventory_files = data; $scope.inventory_files = data;
$scope.inventory_files.push("/ (project root)"); $scope.inventory_files.push("/ (project root)");
sync_inventory_file_select2(); sync_inventory_file_select2();
Wait('stop'); Wait('stop');
}) })
.error(function () { .catch(() => {
Alert('Cannot get inventory files', 'Unable to retrieve the list of inventory files for this project.', 'alert-info'); Alert('Cannot get inventory files', 'Unable to retrieve the list of inventory files for this project.', 'alert-info');
Wait('stop'); Wait('stop');
}); });
@@ -322,8 +322,8 @@ export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition',
} else { } else {
params.source = null; params.source = null;
} }
SourcesService.post(params).then(function(res){ SourcesService.post(params).then((response) => {
let inventory_source_id = res.data.id; let inventory_source_id = response.data.id;
$state.go('^.edit', {inventory_source_id: inventory_source_id}, {reload: true}); $state.go('^.edit', {inventory_source_id: inventory_source_id}, {reload: true});
}); });
}; };

View File

@@ -116,7 +116,7 @@ export default ['$state', '$stateParams', '$scope', 'ParseVariableString',
Wait('start'); Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
$scope.inventory_files = data; $scope.inventory_files = data;
$scope.inventory_files.push("/ (project root)"); $scope.inventory_files.push("/ (project root)");
@@ -131,7 +131,7 @@ export default ['$state', '$stateParams', '$scope', 'ParseVariableString',
sync_inventory_file_select2(); sync_inventory_file_select2();
Wait('stop'); Wait('stop');
}) })
.error(function () { .catch(() => {
Alert('Cannot get inventory files', 'Unable to retrieve the list of inventory files for this project.', 'alert-info'); Alert('Cannot get inventory files', 'Unable to retrieve the list of inventory files for this project.', 'alert-info');
Wait('stop'); Wait('stop');
}); });

View File

@@ -21,13 +21,11 @@ export default {
}, },
resolve: { resolve: {
inventorySourceData: ['$stateParams', 'SourcesService', function($stateParams, SourcesService) { inventorySourceData: ['$stateParams', 'SourcesService', function($stateParams, SourcesService) {
return SourcesService.get({id: $stateParams.inventory_source_id }).then(res => res.data.results[0]); return SourcesService.get({id: $stateParams.inventory_source_id }).then(response => response.data.results[0]);
}], }],
inventorySourcesOptions: ['InventoriesService', '$stateParams', function(InventoriesService, $stateParams) { inventorySourcesOptions: ['InventoriesService', '$stateParams', function(InventoriesService, $stateParams) {
return InventoriesService.inventorySourcesOptions($stateParams.inventory_id) return InventoriesService.inventorySourcesOptions($stateParams.inventory_id)
.then(function(res) { .then((response) => response.data);
return res.data;
});
}] }]
} }
}; };

View File

@@ -16,23 +16,23 @@ export default
Wait('start'); Wait('start');
Rest.setUrl(inventory_source.url); Rest.setUrl(inventory_source.url);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
// Check that we have access to cancelling an update // Check that we have access to cancelling an update
var url = (data.related.current_update) ? data.related.current_update : data.related.last_update; var url = (data.related.current_update) ? data.related.current_update : data.related.last_update;
url += 'cancel/'; url += 'cancel/';
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
if (data.can_cancel) { if (data.can_cancel) {
// Cancel the update process // Cancel the update process
Rest.setUrl(url); Rest.setUrl(url);
Rest.post() Rest.post()
.success(function () { .then(() => {
Wait('stop'); Wait('stop');
//Alert('Inventory Sync Cancelled', 'Request to cancel the sync process was submitted to the task manger. ' + //Alert('Inventory Sync Cancelled', 'Request to cancel the sync process was submitted to the task manger. ' +
// 'Click the <i class="fa fa-refresh fa-lg"></i> button to monitor the status.', 'alert-info'); // 'Click the <i class="fa fa-refresh fa-lg"></i> button to monitor the status.', 'alert-info');
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + ' failed. POST status: ' + status msg: 'Call to ' + url + ' failed. POST status: ' + status
}); });
@@ -42,13 +42,13 @@ export default
Wait('stop'); Wait('stop');
} }
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + ' failed. GET status: ' + status msg: 'Call to ' + url + ' failed. GET status: ' + status
}); });
}); });
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + inventory_source.url + ' failed. GET status: ' + status msg: 'Call to ' + inventory_source.url + ' failed. GET status: ' + status
}); });

View File

@@ -8,7 +8,7 @@ export default
scope[variable] = []; scope[variable] = [];
Rest.setUrl(GetBasePath('inventory_sources')); Rest.setUrl(GetBasePath('inventory_sources'));
Rest.options() Rest.options()
.success(function (data) { .then(({data}) => {
var i, choices = data.actions.GET.source.choices; var i, choices = data.actions.GET.source.choices;
for (i = 0; i < choices.length; i++) { for (i = 0; i < choices.length; i++) {
if (choices[i][0] !== 'file' && choices[i][0] !== "") { if (choices[i][0] !== 'file' && choices[i][0] !== "") {
@@ -21,7 +21,7 @@ export default
scope.cloudCredentialRequired = false; scope.cloudCredentialRequired = false;
scope.$emit('sourceTypeOptionsReady'); scope.$emit('sourceTypeOptionsReady');
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to retrieve options for inventory_sources.source. OPTIONS status: ' + status msg: 'Failed to retrieve options for inventory_sources.source. OPTIONS status: ' + status
}); });

View File

@@ -13,13 +13,13 @@ export default
Wait('start'); Wait('start');
Rest.setUrl(inventory_source.url); Rest.setUrl(inventory_source.url);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
// Get the ID from the correct summary field // Get the ID from the correct summary field
var update_id = (data.summary_fields.current_update) ? data.summary_fields.current_update.id : data.summary_fields.last_update.id; var update_id = (data.summary_fields.current_update) ? data.summary_fields.current_update.id : data.summary_fields.last_update.id;
$state.go('inventorySyncStdout', {id: update_id}); $state.go('inventorySyncStdout', {id: update_id});
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to retrieve inventory source: ' + inventory_source.url + msg: 'Failed to retrieve inventory source: ' + inventory_source.url +
' GET returned status: ' + status }); ' GET returned status: ' + status });

View File

@@ -47,7 +47,7 @@
let path = GetBasePath('inventory') + $stateParams.inventory_id + '/inventory_sources'; let path = GetBasePath('inventory') + $stateParams.inventory_id + '/inventory_sources';
qs.search(path, $state.params[`${list.iterator}_search`]) qs.search(path, $state.params[`${list.iterator}_search`])
.then(function(searchResponse) { .then((searchResponse)=> {
$scope[`${list.iterator}_dataset`] = searchResponse.data; $scope[`${list.iterator}_dataset`] = searchResponse.data;
$scope[list.name] = $scope[`${list.iterator}_dataset`].results; $scope[list.name] = $scope[`${list.iterator}_dataset`].results;
_.forEach($scope[list.name], buildStatusIndicators); _.forEach($scope[list.name], buildStatusIndicators);

View File

@@ -40,7 +40,7 @@ export default {
}, },
resolve: { resolve: {
inventorySourceOptions: ['SourcesService', (SourcesService) => { inventorySourceOptions: ['SourcesService', (SourcesService) => {
return SourcesService.options().then(res => res.data.actions.GET); return SourcesService.options().then(response => response.data.actions.GET);
}], }],
Dataset: ['SourcesListDefinition', 'QuerySet', '$stateParams', 'GetBasePath', '$interpolate', '$rootScope', Dataset: ['SourcesListDefinition', 'QuerySet', '$stateParams', 'GetBasePath', '$interpolate', '$rootScope',
(list, qs, $stateParams, GetBasePath, $interpolate, $rootScope) => { (list, qs, $stateParams, GetBasePath, $interpolate, $rootScope) => {

View File

@@ -1,137 +1,137 @@
export default export default
['$rootScope', 'Rest', 'GetBasePath', 'ProcessErrors', 'Wait', function($rootScope, Rest, GetBasePath, ProcessErrors, Wait){ ['$rootScope', 'Rest', 'GetBasePath', 'ProcessErrors', 'Wait', function($rootScope, Rest, GetBasePath, ProcessErrors, Wait){
return { return {
stringifyParams: function(params){ stringifyParams: function(params){
return _.reduce(params, (result, value, key) => { return _.reduce(params, (result, value, key) => {
return result + key + '=' + value + '&'; return result + key + '=' + value + '&';
}, ''); }, '');
}, },
// cute abstractions via fn.bind() // cute abstractions via fn.bind()
url: function(){ url: function(){
return ''; return '';
}, },
error: function(data, status) { error: function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + this.url + '. GET returned: ' + status }); msg: 'Call to ' + this.url + '. GET returned: ' + status });
}, },
success: function(data){ success: function(data){
return data; return data;
}, },
// HTTP methods // HTTP methods
get: function(params){ get: function(params){
Wait('start'); Wait('start');
this.url = GetBasePath('inventory_sources') + '?' + this.stringifyParams(params); this.url = GetBasePath('inventory_sources') + '?' + this.stringifyParams(params);
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.get() return Rest.get()
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
post: function(inventory_source){ post: function(inventory_source){
Wait('start'); Wait('start');
this.url = GetBasePath('inventory_sources'); this.url = GetBasePath('inventory_sources');
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.post(inventory_source) return Rest.post(inventory_source)
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
put: function(inventory_source){ put: function(inventory_source){
Wait('start'); Wait('start');
this.url = GetBasePath('inventory_sources') + inventory_source.id; this.url = GetBasePath('inventory_sources') + inventory_source.id;
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.put(inventory_source) return Rest.put(inventory_source)
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
delete: function(id){ delete: function(id){
Wait('start'); Wait('start');
this.url = GetBasePath('inventory_sources') + id; this.url = GetBasePath('inventory_sources') + id;
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.destroy() return Rest.destroy()
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
options: function(){ options: function(){
this.url = GetBasePath('inventory_sources'); this.url = GetBasePath('inventory_sources');
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.options() return Rest.options()
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)); .catch(this.error.bind(this));
}, },
getCredential: function(id){ getCredential: function(id){
Wait('start'); Wait('start');
this.url = GetBasePath('credentials') + id; this.url = GetBasePath('credentials') + id;
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.get() return Rest.get()
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
getInventorySource: function(params){ getInventorySource: function(params){
Wait('start'); Wait('start');
this.url = GetBasePath('inventory_sources') + '?' + this.stringifyParams(params); this.url = GetBasePath('inventory_sources') + '?' + this.stringifyParams(params);
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.get() return Rest.get()
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
putInventorySource: function(params, url){ putInventorySource: function(params, url){
Wait('start'); Wait('start');
this.url = url; this.url = url;
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.put(params) return Rest.put(params)
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
// these relationship setters could be consolidated, but verbosity makes the operation feel more clear @ controller level // these relationship setters could be consolidated, but verbosity makes the operation feel more clear @ controller level
associateGroup: function(group, target){ associateGroup: function(group, target){
Wait('start'); Wait('start');
this.url = GetBasePath('groups') + target + '/children/'; this.url = GetBasePath('groups') + target + '/children/';
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.post(group) return Rest.post(group)
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
disassociateGroup: function(group, parent){ disassociateGroup: function(group, parent){
Wait('start'); Wait('start');
this.url = GetBasePath('groups') + parent + '/children/'; this.url = GetBasePath('groups') + parent + '/children/';
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.post({id: group, disassociate: 1}) return Rest.post({id: group, disassociate: 1})
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
promote: function(group, inventory){ promote: function(group, inventory){
Wait('start'); Wait('start');
this.url = GetBasePath('inventory') + inventory + '/groups/'; this.url = GetBasePath('inventory') + inventory + '/groups/';
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.post({id: group, disassociate: 1}) return Rest.post({id: group, disassociate: 1})
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
encodeGroupBy(source, group_by){ encodeGroupBy(source, group_by){
source = source && source.value ? source.value : ''; source = source && source.value ? source.value : '';
if(source === 'ec2'){ if(source === 'ec2'){
return _.map(group_by, 'value').join(','); return _.map(group_by, 'value').join(',');
}
if(source === 'vmware'){
group_by = _.map(group_by, (i) => {return i.value;});
$("#inventory_source_group_by").siblings(".select2").first().find(".select2-selection__choice").each(function(optionIndex, option){
group_by.push(option.title);
});
group_by = (Array.isArray(group_by)) ? _.uniq(group_by).join() : "";
return group_by;
}
else {
return;
}
} }
}; if(source === 'vmware'){
}]; group_by = _.map(group_by, (i) => {return i.value;});
$("#inventory_source_group_by").siblings(".select2").first().find(".select2-selection__choice").each(function(optionIndex, option){
group_by.push(option.title);
});
group_by = (Array.isArray(group_by)) ? _.uniq(group_by).join() : "";
return group_by;
}
else {
return;
}
}
};
}];

View File

@@ -60,7 +60,7 @@ function SmartInventoryAdd($scope, $location,
Rest.setUrl(defaultUrl); Rest.setUrl(defaultUrl);
Rest.post(data) Rest.post(data)
.success(function(data) { .then(({data}) => {
const inventory_id = data.id, const inventory_id = data.id,
instance_group_url = data.related.instance_groups; instance_group_url = data.related.instance_groups;
@@ -77,7 +77,7 @@ function SmartInventoryAdd($scope, $location,
}); });
}); });
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, form, { ProcessErrors($scope, data, status, form, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to add new inventory. Post returned status: ' + status msg: 'Failed to add new inventory. Post returned status: ' + status

View File

@@ -77,7 +77,7 @@ function SmartInventoryEdit($scope, $location,
Rest.setUrl(defaultUrl + inventory_id + '/'); Rest.setUrl(defaultUrl + inventory_id + '/');
Rest.put(data) Rest.put(data)
.success(function() { .then(() => {
InstanceGroupsService.editInstanceGroups(instance_group_url, $scope.instance_groups) InstanceGroupsService.editInstanceGroups(instance_group_url, $scope.instance_groups)
.then(() => { .then(() => {
Wait('stop'); Wait('stop');
@@ -90,7 +90,7 @@ function SmartInventoryEdit($scope, $location,
}); });
}); });
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, form, { ProcessErrors($scope, data, status, form, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to update inventory. PUT returned status: ' + status msg: 'Failed to update inventory. PUT returned status: ' + status

View File

@@ -18,7 +18,7 @@ export default {
let ansibleFactsUrl = GetBasePath('hosts') + $stateParams.host_id + '/ansible_facts'; let ansibleFactsUrl = GetBasePath('hosts') + $stateParams.host_id + '/ansible_facts';
Rest.setUrl(ansibleFactsUrl); Rest.setUrl(ansibleFactsUrl);
return Rest.get() return Rest.get()
.success(function(data) { .then(({data}) => {
return data; return data;
}); });
} }

View File

@@ -23,8 +23,8 @@ export default
this.url = GetBasePath('groups') + '?' + this.stringifyParams(params); this.url = GetBasePath('groups') + '?' + this.stringifyParams(params);
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.get() return Rest.get()
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
post: function(group){ post: function(group){
@@ -32,8 +32,8 @@ export default
this.url = GetBasePath('groups'); this.url = GetBasePath('groups');
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.post(group) return Rest.post(group)
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
put: function(group){ put: function(group){
@@ -41,8 +41,8 @@ export default
this.url = GetBasePath('groups') + group.id; this.url = GetBasePath('groups') + group.id;
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.put(group) return Rest.put(group)
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
delete: function(id){ delete: function(id){
@@ -50,8 +50,8 @@ export default
this.url = GetBasePath('groups') + id; this.url = GetBasePath('groups') + id;
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.destroy() return Rest.destroy()
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
getCredential: function(id){ getCredential: function(id){
@@ -59,8 +59,8 @@ export default
this.url = GetBasePath('credentials') + id; this.url = GetBasePath('credentials') + id;
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.get() return Rest.get()
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
getInventorySource: function(params){ getInventorySource: function(params){
@@ -68,8 +68,8 @@ export default
this.url = GetBasePath('inventory_sources') + '?' + this.stringifyParams(params); this.url = GetBasePath('inventory_sources') + '?' + this.stringifyParams(params);
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.get() return Rest.get()
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
putInventorySource: function(params, url){ putInventorySource: function(params, url){
@@ -77,8 +77,8 @@ export default
this.url = url; this.url = url;
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.put(params) return Rest.put(params)
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
// these relationship setters could be consolidated, but verbosity makes the operation feel more clear @ controller level // these relationship setters could be consolidated, but verbosity makes the operation feel more clear @ controller level
@@ -87,8 +87,8 @@ export default
this.url = GetBasePath('groups') + target + '/children/'; this.url = GetBasePath('groups') + target + '/children/';
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.post(group) return Rest.post(group)
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
disassociateGroup: function(group, parent){ disassociateGroup: function(group, parent){
@@ -96,8 +96,8 @@ export default
this.url = GetBasePath('groups') + parent + '/children/'; this.url = GetBasePath('groups') + parent + '/children/';
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.post({id: group, disassociate: 1}) return Rest.post({id: group, disassociate: 1})
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
associateHost: function(host, target){ associateHost: function(host, target){
@@ -105,8 +105,8 @@ export default
this.url = GetBasePath('groups') + target + '/hosts/'; this.url = GetBasePath('groups') + target + '/hosts/';
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.post(host) return Rest.post(host)
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
disassociateHost: function(host, group){ disassociateHost: function(host, group){
@@ -114,8 +114,8 @@ export default
this.url = GetBasePath('groups') + group + '/hosts/'; this.url = GetBasePath('groups') + group + '/hosts/';
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.post({id: host, disassociate: 1}) return Rest.post({id: host, disassociate: 1})
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
promote: function(group, inventory){ promote: function(group, inventory){
@@ -123,8 +123,8 @@ export default
this.url = GetBasePath('inventory') + inventory + '/groups/'; this.url = GetBasePath('inventory') + inventory + '/groups/';
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.post({id: group, disassociate: 1}) return Rest.post({id: group, disassociate: 1})
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
} }
}; };

View File

@@ -30,8 +30,8 @@
this.url = GetBasePath('hosts') + '?' + this.stringifyParams(params); this.url = GetBasePath('hosts') + '?' + this.stringifyParams(params);
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.get() return Rest.get()
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
post: function(host){ post: function(host){
@@ -39,8 +39,8 @@
this.url = GetBasePath('hosts'); this.url = GetBasePath('hosts');
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.post(host) return Rest.post(host)
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
put: function(host){ put: function(host){
@@ -48,8 +48,8 @@
this.url = GetBasePath('hosts') + host.id; this.url = GetBasePath('hosts') + host.id;
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.put(host) return Rest.put(host)
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
delete: function(id){ delete: function(id){
@@ -57,8 +57,8 @@
this.url = GetBasePath('hosts') + id; this.url = GetBasePath('hosts') + id;
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.destroy() return Rest.destroy()
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
} }
}; };

View File

@@ -25,8 +25,8 @@
this.url = GetBasePath('inventory') + id; this.url = GetBasePath('inventory') + id;
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.get() return Rest.get()
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
getBreadcrumbs: function(groups){ getBreadcrumbs: function(groups){
@@ -36,8 +36,8 @@
}).join(''); }).join('');
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.get() return Rest.get()
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)) .catch(this.error.bind(this))
.finally(Wait('stop')); .finally(Wait('stop'));
}, },
rootHostsUrl: function(id){ rootHostsUrl: function(id){
@@ -60,22 +60,22 @@
this.url = GetBasePath('inventory') + inventoryId + '/inventory_sources'; this.url = GetBasePath('inventory') + inventoryId + '/inventory_sources';
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.options() return Rest.options()
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)); .catch(this.error.bind(this));
}, },
updateInventorySourcesGet: function(inventoryId) { updateInventorySourcesGet: function(inventoryId) {
this.url = GetBasePath('inventory') + inventoryId + '/update_inventory_sources'; this.url = GetBasePath('inventory') + inventoryId + '/update_inventory_sources';
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.get() return Rest.get()
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)); .catch(this.error.bind(this));
}, },
getHost: function(inventoryId, hostId) { getHost: function(inventoryId, hostId) {
this.url = GetBasePath('inventory') + inventoryId + '/hosts?id=' + hostId; this.url = GetBasePath('inventory') + inventoryId + '/hosts?id=' + hostId;
Rest.setUrl(this.url); Rest.setUrl(this.url);
return Rest.get() return Rest.get()
.success(this.success.bind(this)) .then(this.success.bind(this))
.error(this.error.bind(this)); .catch(this.error.bind(this));
} }
}; };
}]; }];

View File

@@ -19,7 +19,7 @@ export default ['Rest', 'Wait',
function init() { function init() {
Rest.setUrl(url); Rest.setUrl(url);
Rest.options() Rest.options()
.success(function(data) { .then(({data}) => {
if (!data.actions.POST) { if (!data.actions.POST) {
$state.go("^"); $state.go("^");
Alert('Permission Error', 'You do not have permission to add an inventory script.', 'alert-info'); Alert('Permission Error', 'You do not have permission to add an inventory script.', 'alert-info');
@@ -43,11 +43,11 @@ export default ['Rest', 'Wait',
organization: $scope.organization, organization: $scope.organization,
script: $scope.script script: $scope.script
}) })
.success(function() { .then(() => {
$state.go('inventoryScripts', null, { reload: true }); $state.go('inventoryScripts', null, { reload: true });
Wait('stop'); Wait('stop');
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, form, { ProcessErrors($scope, data, status, form, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to add new inventory script. POST returned status: ' + status msg: 'Failed to add new inventory script. POST returned status: ' + status

View File

@@ -59,11 +59,11 @@ export default ['Rest', 'Wait',
organization: $scope.organization, organization: $scope.organization,
script: $scope.script script: $scope.script
}) })
.success(function() { .then(() => {
$state.go('inventoryScripts', null, { reload: true }); $state.go('inventoryScripts', null, { reload: true });
Wait('stop'); Wait('stop');
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, form, { ProcessErrors($scope, data, status, form, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to add new inventory script. PUT returned status: ' + status msg: 'Failed to add new inventory script. PUT returned status: ' + status

View File

@@ -50,7 +50,7 @@ export default ['$rootScope', '$scope', 'Wait', 'InventoryScriptsList',
var url = defaultUrl + id + '/'; var url = defaultUrl + id + '/';
Rest.setUrl(url); Rest.setUrl(url);
Rest.destroy() Rest.destroy()
.success(function() { .then(() => {
let reloadListStateParams = null; let reloadListStateParams = null;
@@ -65,7 +65,7 @@ export default ['$rootScope', '$scope', 'Wait', 'InventoryScriptsList',
$state.go('.', reloadListStateParams, { reload: true }); $state.go('.', reloadListStateParams, { reload: true });
} }
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status

View File

@@ -19,8 +19,7 @@ var hostEventModal = {
hostEvent: ['jobResultsService', '$stateParams', function(jobResultsService, $stateParams) { hostEvent: ['jobResultsService', '$stateParams', function(jobResultsService, $stateParams) {
return jobResultsService.getRelatedJobEvents($stateParams.id, { return jobResultsService.getRelatedJobEvents($stateParams.id, {
id: $stateParams.eventId id: $stateParams.eventId
}).then(function(res) { }).then((response) => response.data.results[0]);
return res.data.results[0]; });
}] }]
}, },
onExit: function() { onExit: function() {

View File

@@ -76,7 +76,7 @@ export default {
Rest.setUrl(jobData.related.job_events + Rest.setUrl(jobData.related.job_events +
"?event=playbook_on_stats"); "?event=playbook_on_stats");
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
if(!data.results[0]){ if(!data.results[0]){
defer.resolve({val: { defer.resolve({val: {
ok: 0, ok: 0,
@@ -94,7 +94,7 @@ export default {
countFinished: true}); countFinished: true});
} }
}) })
.error(function() { .catch(() => {
defer.resolve({val: { defer.resolve({val: {
ok: 0, ok: 0,
skipped: 0, skipped: 0,
@@ -131,7 +131,7 @@ export default {
var getNext = function(data, arr, resolve) { var getNext = function(data, arr, resolve) {
Rest.setUrl(data.next); Rest.setUrl(data.next);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
if (data.next) { if (data.next) {
getNext(data, arr.concat(data.results), resolve); getNext(data, arr.concat(data.results), resolve);
} else { } else {
@@ -145,7 +145,7 @@ export default {
Rest.setUrl(GetBasePath('jobs') + $stateParams.id + '/labels/'); Rest.setUrl(GetBasePath('jobs') + $stateParams.id + '/labels/');
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
if (data.next) { if (data.next) {
getNext(data, data.results, seeMoreResolve); getNext(data, data.results, seeMoreResolve);
} else { } else {

View File

@@ -73,11 +73,11 @@ function ($q, Prompt, $filter, Wait, Rest, $state, ProcessErrors, InitiatePlaybo
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
val.resolve({results: data.results, val.resolve({results: data.results,
next: data.next}); next: data.next});
}) })
.error(function(obj, status) { .catch(({obj, status}) => {
ProcessErrors(null, obj, status, null, { ProcessErrors(null, obj, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: `Could not get job events. msg: `Could not get job events.
@@ -101,12 +101,12 @@ function ($q, Prompt, $filter, Wait, Rest, $state, ProcessErrors, InitiatePlaybo
Wait('start'); Wait('start');
Rest.setUrl(job.url); Rest.setUrl(job.url);
Rest.destroy() Rest.destroy()
.success(function() { .then(() => {
Wait('stop'); Wait('stop');
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
$state.go('jobs'); $state.go('jobs');
}) })
.error(function(obj, status) { .catch(({obj, status}) => {
Wait('stop'); Wait('stop');
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
ProcessErrors(null, obj, status, null, { ProcessErrors(null, obj, status, null, {
@@ -123,11 +123,11 @@ function ($q, Prompt, $filter, Wait, Rest, $state, ProcessErrors, InitiatePlaybo
var doCancel = function() { var doCancel = function() {
Rest.setUrl(job.url + 'cancel'); Rest.setUrl(job.url + 'cancel');
Rest.post({}) Rest.post({})
.success(function() { .then(() => {
Wait('stop'); Wait('stop');
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
}) })
.error(function(obj, status) { .catch(({obj, status}) => {
Wait('stop'); Wait('stop');
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
ProcessErrors(null, obj, status, null, { ProcessErrors(null, obj, status, null, {
@@ -150,7 +150,7 @@ function ($q, Prompt, $filter, Wait, Rest, $state, ProcessErrors, InitiatePlaybo
Wait('start'); Wait('start');
Rest.setUrl(job.url + 'cancel'); Rest.setUrl(job.url + 'cancel');
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
if (data.can_cancel === true) { if (data.can_cancel === true) {
doCancel(); doCancel();
} else { } else {
@@ -239,10 +239,10 @@ function ($q, Prompt, $filter, Wait, Rest, $state, ProcessErrors, InitiatePlaybo
url = url + id + '/job_events/?' + this.stringifyParams(params); url = url + id + '/job_events/?' + this.stringifyParams(params);
Rest.setUrl(url); Rest.setUrl(url);
return Rest.get() return Rest.get()
.success(function(data){ .then((response) => {
return data; return response;
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status }); msg: 'Call to ' + url + '. GET returned: ' + status });
}); });

View File

@@ -59,10 +59,10 @@
Wait('start'); Wait('start');
Rest.setUrl(GetBasePath('ad_hoc_commands') + new_job_id + '/'); Rest.setUrl(GetBasePath('ad_hoc_commands') + new_job_id + '/');
Rest.destroy() Rest.destroy()
.success(function() { .then(() => {
Wait('stop'); Wait('stop');
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, ProcessErrors(scope, data, status,
null, { hdr: 'Error!', null, { hdr: 'Error!',
msg: 'Call to ' + url + msg: 'Call to ' + url +
@@ -86,13 +86,13 @@
// Re-launch the adhoc job // Re-launch the adhoc job
Rest.setUrl(url); Rest.setUrl(url);
Rest.post(postData) Rest.post(postData)
.success(function (data) { .then(({data}) => {
Wait('stop'); Wait('stop');
if($location.path().replace(/^\//, '').split('/')[0] !== 'jobs') { if($location.path().replace(/^\//, '').split('/')[0] !== 'jobs') {
$state.go('adHocJobStdout', {id: data.id}); $state.go('adHocJobStdout', {id: data.id});
} }
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, { ProcessErrors(scope, data, status, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to launch adhoc command. POST ' + msg: 'Failed to launch adhoc command. POST ' +
@@ -133,7 +133,7 @@
url = GetBasePath('ad_hoc_commands') + id + '/relaunch/'; url = GetBasePath('ad_hoc_commands') + id + '/relaunch/';
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
new_job_id = data.id; new_job_id = data.id;
scope.passwords_needed_to_start = data.passwords_needed_to_start; scope.passwords_needed_to_start = data.passwords_needed_to_start;
@@ -148,7 +148,7 @@
scope.$emit('StartAdhocRun'); scope.$emit('StartAdhocRun');
} }
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to get job template details. GET returned status: ' + status }); msg: 'Failed to get job template details. GET returned status: ' + status });
}); });

View File

@@ -9,7 +9,7 @@ export default
if (!Empty(credential)) { if (!Empty(credential)) {
Rest.setUrl(GetBasePath('credentials')+credential); Rest.setUrl(GetBasePath('credentials')+credential);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
credentialTypesLookup() credentialTypesLookup()
.then(kinds => { .then(kinds => {
if(data.credential_type === kinds.Machine && data.inputs){ if(data.credential_type === kinds.Machine && data.inputs){
@@ -30,7 +30,7 @@ export default
}); });
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to get job template details. GET returned status: ' + status }); msg: 'Failed to get job template details. GET returned status: ' + status });
}); });

View File

@@ -20,7 +20,7 @@ export default
Rest.setUrl(survey_url); Rest.setUrl(survey_url);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
if(!Empty(data)){ if(!Empty(data)){
scope.survey_name = data.name; scope.survey_name = data.name;
scope.survey_description = data.description; scope.survey_description = data.description;
@@ -74,7 +74,7 @@ export default
return; return;
} }
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, { hdr: 'Error!', ProcessErrors(scope, data, status, { hdr: 'Error!',
msg: 'Failed to retrieve organization: ' + $stateParams.id + '. GET status: ' + status }); msg: 'Failed to retrieve organization: ' + $stateParams.id + '. GET status: ' + status });
}); });

View File

@@ -42,7 +42,7 @@ export default
Wait('start'); Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
if(params.updateAllSources) { if(params.updateAllSources) {
scope.$emit('StartTheUpdate', {}); scope.$emit('StartTheUpdate', {});
} }
@@ -63,7 +63,7 @@ export default
} }
} }
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to get inventory source ' + url + ' GET returned: ' + status }); msg: 'Failed to get inventory source ' + url + ' GET returned: ' + status });
}); });

View File

@@ -139,7 +139,7 @@ export default
Rest.setUrl(url); Rest.setUrl(url);
Rest.post(job_launch_data) Rest.post(job_launch_data)
.success(function(data) { .then(({data}) => {
Wait('stop'); Wait('stop');
var job = data.job || data.system_job || data.project_update || data.inventory_update || data.ad_hoc_command; var job = data.job || data.system_job || data.project_update || data.inventory_update || data.ad_hoc_command;
if(base !== 'portal' && Empty(data.system_job) || (base === 'home')){ if(base !== 'portal' && Empty(data.system_job) || (base === 'home')){
@@ -188,7 +188,7 @@ export default
$state.go('.', null, {reload: true}); $state.go('.', null, {reload: true});
} }
}) })
.error(function(data, status) { .catch(({data, status}) => {
let template_id = scope.job_template_id; let template_id = scope.job_template_id;
template_id = (template_id === undefined) ? "undefined" : i18n.sprintf("%d", template_id); template_id = (template_id === undefined) ? "undefined" : i18n.sprintf("%d", template_id);
ProcessErrors(scope, data, status, null, { hdr: i18n._('Error!'), ProcessErrors(scope, data, status, null, { hdr: i18n._('Error!'),
@@ -200,7 +200,7 @@ export default
var getExtraVars = function() { var getExtraVars = function() {
Rest.setUrl(vars_url); Rest.setUrl(vars_url);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
if(!Empty(data.extra_vars)){ if(!Empty(data.extra_vars)){
data.extra_vars = ToJSON('yaml', data.extra_vars, false); data.extra_vars = ToJSON('yaml', data.extra_vars, false);
$.each(data.extra_vars, function(key,value){ $.each(data.extra_vars, function(key,value){
@@ -209,7 +209,7 @@ export default
} }
buildData(); buildData();
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, { hdr: i18n._('Error!'), ProcessErrors(scope, data, status, { hdr: i18n._('Error!'),
msg: i18n._('Failed to retrieve job template extra variables.') }); msg: i18n._('Failed to retrieve job template extra variables.') });
}); });

View File

@@ -43,7 +43,7 @@ export default
Wait('start'); Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
project = data; project = data;
if (project.can_update) { if (project.can_update) {
if (project.passwords_needed_to_updated) { if (project.passwords_needed_to_updated) {
@@ -59,7 +59,7 @@ export default
'alert-danger'); 'alert-danger');
} }
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to lookup project ' + url + ' GET returned: ' + status }); msg: 'Failed to lookup project ' + url + ' GET returned: ' + status });
}); });

View File

@@ -152,7 +152,7 @@ export default
Wait('start'); Wait('start');
Rest.setUrl(launch_url); Rest.setUrl(launch_url);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
// Put all the data that we get back about the launch onto scope // Put all the data that we get back about the launch onto scope
angular.extend($scope, data); angular.extend($scope, data);
@@ -179,26 +179,26 @@ export default
if ($scope.has_other_prompts) { if ($scope.has_other_prompts) {
Rest.options() Rest.options()
.success(options => { .then(options => {
if ($scope.ask_job_type_on_launch) { if ($scope.ask_job_type_on_launch) {
let choices = getChoices(options, 'actions.POST.job_type.choices'); let choices = getChoices(options.data, 'actions.POST.job_type.choices');
let initialValue = _.get(data, 'defaults.job_type'); let initialValue = _.get(data, 'defaults.job_type');
let initialChoice = getChoiceFromValue(choices, initialValue); let initialChoice = getChoiceFromValue(choices, initialValue);
$scope.other_prompt_data.job_type_options = choices; $scope.other_prompt_data.job_type_options = choices;
$scope.other_prompt_data.job_type = initialChoice; $scope.other_prompt_data.job_type = initialChoice;
} }
if ($scope.ask_verbosity_on_launch) { if ($scope.ask_verbosity_on_launch) {
let choices = getChoices(options, 'actions.POST.verbosity.choices'); let choices = getChoices(options.data, 'actions.POST.verbosity.choices');
let initialValue = _.get(data, 'defaults.verbosity'); let initialValue = _.get(data, 'defaults.verbosity');
let initialChoice = getChoiceFromValue(choices, initialValue); let initialChoice = getChoiceFromValue(choices, initialValue);
$scope.other_prompt_data.verbosity_options = choices; $scope.other_prompt_data.verbosity_options = choices;
$scope.other_prompt_data.verbosity = initialChoice; $scope.other_prompt_data.verbosity = initialChoice;
} }
}) })
.error((err, status) => { .catch((error) => {
ProcessErrors($scope, err, status, null, { ProcessErrors($scope, error.data, error.status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: `Failed to get ${launch_url}. OPTIONS status: ${status}` msg: `Failed to get ${launch_url}. OPTIONS status: ${error.status}`
}); });
}); });
} }
@@ -260,7 +260,8 @@ export default
// Go out and get the credential types // Go out and get the credential types
Rest.setUrl(GetBasePath('credential_types')); Rest.setUrl(GetBasePath('credential_types'));
Rest.get() Rest.get()
.success(function (credentialTypeData) { .then( (response) => {
let credentialTypeData = response.data;
let credential_types = {}; let credential_types = {};
$scope.credentialTypeOptions = []; $scope.credentialTypeOptions = [];
credentialTypeData.results.forEach((credentialType => { credentialTypeData.results.forEach((credentialType => {
@@ -273,6 +274,12 @@ export default
} }
})); }));
$scope.credential_types = credential_types; $scope.credential_types = credential_types;
})
.catch(({data, status}) => {
ProcessErrors($scope, data, status, null, {
hdr: 'Error!',
msg: 'Failed to get credential types. GET status: ' + status
});
}); });
// Figure out which step the user needs to start on // Figure out which step the user needs to start on
@@ -296,7 +303,8 @@ export default
// Go out and get some of the job details like inv, cred, name // Go out and get some of the job details like inv, cred, name
Rest.setUrl(GetBasePath('jobs') + $scope.submitJobId); Rest.setUrl(GetBasePath('jobs') + $scope.submitJobId);
Rest.get() Rest.get()
.success(function (jobResultData) { .then( (response) => {
let jobResultData = response.data;
$scope.job_template_data = { $scope.job_template_data = {
name: jobResultData.name name: jobResultData.name
}; };
@@ -311,7 +319,7 @@ export default
} }
initiateModal(); initiateModal();
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', ProcessErrors($scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to get job details. GET returned status: ' + status }); msg: 'Failed to get job details. GET returned status: ' + status });
}); });
@@ -324,7 +332,7 @@ export default
} }
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', ProcessErrors($scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to get job template details. GET returned status: ' + status }); msg: 'Failed to get job template details. GET returned status: ' + status });
}); });

View File

@@ -46,7 +46,7 @@ export default
if (row.checked) { if (row.checked) {
row.success_class = 'success'; row.success_class = 'success';
} else { } else {
row.checked = true; row.checked = 1;
row.success_class = ''; row.success_class = '';
} }
$scope.$emit('inventorySelected', row); $scope.$emit('inventorySelected', row);

View File

@@ -42,7 +42,7 @@
Rest.setUrl(url); Rest.setUrl(url);
if (action_label === 'cancel') { if (action_label === 'cancel') {
Rest.post() Rest.post()
.success(function () { .then(() => {
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
if (callback) { if (callback) {
scope.$emit(callback, action_label); scope.$emit(callback, action_label);
@@ -52,7 +52,7 @@
Wait('stop'); Wait('stop');
} }
}) })
.error(function(obj, status) { .catch(({obj, status}) => {
Wait('stop'); Wait('stop');
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
if (status === 403) { if (status === 403) {
@@ -64,7 +64,7 @@
}); });
} else { } else {
Rest.destroy() Rest.destroy()
.success(function () { .then(() => {
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
if (callback) { if (callback) {
scope.$emit(callback, action_label); scope.$emit(callback, action_label);
@@ -81,7 +81,7 @@
Wait('stop'); Wait('stop');
} }
}) })
.error(function (obj, status) { .catch(({obj, status}) => {
Wait('stop'); Wait('stop');
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
if (status === 403) { if (status === 403) {
@@ -119,7 +119,7 @@
if (action_label === 'cancel') { if (action_label === 'cancel') {
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
if (data.can_cancel) { if (data.can_cancel) {
scope.$emit('CancelJob'); scope.$emit('CancelJob');
} }
@@ -127,7 +127,7 @@
scope.$emit('CancelNotAllowed'); scope.$emit('CancelNotAllowed');
} }
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url +
' failed. GET returned: ' + status }); ' failed. GET returned: ' + status });
}); });

View File

@@ -7,13 +7,13 @@ export default
Wait('start'); Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
InventoryUpdate({ InventoryUpdate({
scope: scope, scope: scope,
url: data.related.update url: data.related.update
}); });
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve inventory source: ' + ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to retrieve inventory source: ' +
url + ' GET returned: ' + status }); url + ' GET returned: ' + status });
}); });

View File

@@ -21,10 +21,10 @@ export default
var data = license; var data = license;
data.eula_accepted = eula; data.eula_accepted = eula;
return Rest.post(JSON.stringify(data)) return Rest.post(JSON.stringify(data))
.success(function(res){ .then((response) =>{
return res; return response.data;
}) })
.error(function(res, status){ .catch(({res, status}) => {
ProcessErrors($rootScope, res, status, null, {hdr: 'Error!', ProcessErrors($rootScope, res, status, null, {hdr: 'Error!',
msg: 'Call to '+ defaultUrl + ' failed. Return status: '+ status}); msg: 'Call to '+ defaultUrl + ' failed. Return status: '+ status});
}); });

View File

@@ -86,7 +86,7 @@ export default
$scope.submit = function(){ $scope.submit = function(){
Wait('start'); Wait('start');
CheckLicense.post($scope.newLicense.file, $scope.newLicense.eula) CheckLicense.post($scope.newLicense.file, $scope.newLicense.eula)
.success(function(){ .then(() => {
reset(); reset();
ConfigService.delete(); ConfigService.delete();
ConfigService.getConfig().then(function(config){ ConfigService.getConfig().then(function(config){

View File

@@ -139,7 +139,7 @@ export default ['$log', '$cookies', '$compile', '$rootScope',
scope.removeAuthorizationGetUser = scope.$on('AuthorizationGetUser', function() { scope.removeAuthorizationGetUser = scope.$on('AuthorizationGetUser', function() {
// Get all the profile/access info regarding the logged in user // Get all the profile/access info regarding the logged in user
Authorization.getUser() Authorization.getUser()
.success(function (data) { .then(({data}) => {
Authorization.setUserInfo(data); Authorization.setUserInfo(data);
Timer.init().then(function(timer){ Timer.init().then(function(timer){
$rootScope.sessionTimer = timer; $rootScope.sessionTimer = timer;
@@ -149,7 +149,7 @@ export default ['$log', '$cookies', '$compile', '$rootScope',
scope.$emit('AuthorizationGetLicense'); scope.$emit('AuthorizationGetLicense');
}); });
}) })
.error(function (data, status) { .catch(({data, status}) => {
Authorization.logout().then( () => { Authorization.logout().then( () => {
Wait('stop'); Wait('stop');
Alert('Error', 'Failed to access user information. GET returned status: ' + status, 'alert-danger', loginAgain); Alert('Error', 'Failed to access user information. GET returned status: ' + status, 'alert-danger', loginAgain);

View File

@@ -20,11 +20,11 @@ export default
var getManagementJobs = function(){ var getManagementJobs = function(){
Rest.setUrl(defaultUrl); Rest.setUrl(defaultUrl);
Rest.get() Rest.get()
.success(function(data){ .then(({data}) => {
$scope.mgmtCards = data.results; $scope.mgmtCards = data.results;
Wait('stop'); Wait('stop');
}) })
.error(function(data, status){ .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, {hdr: i18n._('Error!'), ProcessErrors($scope, data, status, null, {hdr: i18n._('Error!'),
msg: i18n.sprintf(i18n._('Call to %s failed. Return status: %d'), (defaultUrl === undefined) ? "undefined" : defaultUrl, status )}); msg: i18n.sprintf(i18n._('Call to %s failed. Return status: %d'), (defaultUrl === undefined) ? "undefined" : defaultUrl, status )});
}); });
@@ -128,13 +128,13 @@ export default
Rest.setUrl(defaultUrl); Rest.setUrl(defaultUrl);
Rest.post(data) Rest.post(data)
.success(function(data) { .then(({data}) => {
Wait('stop'); Wait('stop');
$("#prompt-for-days-facts").dialog("close"); $("#prompt-for-days-facts").dialog("close");
$("#configure-dialog").dialog('close'); $("#configure-dialog").dialog('close');
$state.go('managementJobStdout', {id: data.system_job}, {reload:true}); $state.go('managementJobStdout', {id: data.system_job}, {reload:true});
}) })
.error(function(data, status) { .catch(({data, status}) => {
let template_id = scope.job_template_id; let template_id = scope.job_template_id;
template_id = (template_id === undefined) ? "undefined" : i18n.sprintf("%d", template_id); template_id = (template_id === undefined) ? "undefined" : i18n.sprintf("%d", template_id);
ProcessErrors(scope, data, status, null, { hdr: i18n._('Error!'), ProcessErrors(scope, data, status, null, { hdr: i18n._('Error!'),
@@ -218,13 +218,13 @@ export default
Rest.setUrl(defaultUrl); Rest.setUrl(defaultUrl);
Rest.post(data) Rest.post(data)
.success(function(data) { .then(({data}) => {
Wait('stop'); Wait('stop');
$("#prompt-for-days").dialog("close"); $("#prompt-for-days").dialog("close");
// $("#configure-dialog").dialog('close'); // $("#configure-dialog").dialog('close');
$state.go('managementJobStdout', {id: data.system_job}, {reload:true}); $state.go('managementJobStdout', {id: data.system_job}, {reload:true});
}) })
.error(function(data, status) { .catch(({data, status}) => {
let template_id = scope.job_template_id; let template_id = scope.job_template_id;
template_id = (template_id === undefined) ? "undefined" : i18n.sprintf("%d", template_id); template_id = (template_id === undefined) ? "undefined" : i18n.sprintf("%d", template_id);
ProcessErrors(scope, data, status, null, { hdr: i18n._('Error!'), ProcessErrors(scope, data, status, null, { hdr: i18n._('Error!'),

View File

@@ -24,7 +24,7 @@ export default ['Rest', 'Wait', 'NotificationsFormObject',
function init() { function init() {
Rest.setUrl(GetBasePath('projects')); Rest.setUrl(GetBasePath('projects'));
Rest.options() Rest.options()
.success(function(data) { .then(({data}) => {
if (!data.actions.POST) { if (!data.actions.POST) {
$state.go("^"); $state.go("^");
Alert('Permission Error', 'You do not have permission to add a notification template.', 'alert-info'); Alert('Permission Error', 'You do not have permission to add a notification template.', 'alert-info');
@@ -48,10 +48,10 @@ export default ['Rest', 'Wait', 'NotificationsFormObject',
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
$scope.organization_name = data.name; $scope.organization_name = data.name;
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, form, { ProcessErrors($scope, data, status, form, {
hdr: 'Error!', hdr: 'Error!',
msg: `Failed to retrieve organization. GET status: ${status}` msg: `Failed to retrieve organization. GET status: ${status}`
@@ -213,11 +213,11 @@ export default ['Rest', 'Wait', 'NotificationsFormObject',
Wait('start'); Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
Rest.post(params) Rest.post(params)
.success(function() { .then(() => {
$state.go('notifications', {}, { reload: true }); $state.go('notifications', {}, { reload: true });
Wait('stop'); Wait('stop');
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, form, { ProcessErrors($scope, data, status, form, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to add new notifier. POST returned status: ' + status msg: 'Failed to add new notifier. POST returned status: ' + status

View File

@@ -59,7 +59,7 @@ export default ['Rest', 'Wait',
Wait('start'); Wait('start');
Rest.setUrl(url + id + '/'); Rest.setUrl(url + id + '/');
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
var fld; var fld;
for (fld in form.fields) { for (fld in form.fields) {
if (data[fld]) { if (data[fld]) {
@@ -144,7 +144,7 @@ export default ['Rest', 'Wait',
}); });
Wait('stop'); Wait('stop');
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, form, { ProcessErrors($scope, data, status, form, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to retrieve notification: ' + id + '. GET status: ' + status msg: 'Failed to retrieve notification: ' + id + '. GET status: ' + status
@@ -280,11 +280,11 @@ export default ['Rest', 'Wait',
Wait('start'); Wait('start');
Rest.setUrl(url + id + '/'); Rest.setUrl(url + id + '/');
Rest.put(params) Rest.put(params)
.success(function() { .then(() => {
$state.go('notifications', {}, { reload: true }); $state.go('notifications', {}, { reload: true });
Wait('stop'); Wait('stop');
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, form, { ProcessErrors($scope, data, status, form, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to add new notification template. POST returned status: ' + status msg: 'Failed to add new notification template. POST returned status: ' + status

View File

@@ -116,7 +116,7 @@
function retrieveStatus(id) { function retrieveStatus(id) {
setTimeout(function() { setTimeout(function() {
var url = GetBasePath('notifications') + id; let url = GetBasePath('notifications') + id;
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.then(function(res) { .then(function(res) {
@@ -141,7 +141,13 @@
}); });
} }
}); })
.catch(({data, status}) => {
ProcessErrors($scope, data, status, null, {
hdr: 'Error!',
msg: 'Failed to get ' + url + '. GET status: ' + status
});
});
}, 5000); }, 5000);
} }
}; };
@@ -164,7 +170,7 @@
var url = defaultUrl + id + '/'; var url = defaultUrl + id + '/';
Rest.setUrl(url); Rest.setUrl(url);
Rest.destroy() Rest.destroy()
.success(function() { .then(() => {
let reloadListStateParams = null; let reloadListStateParams = null;
@@ -180,7 +186,7 @@
} }
Wait('stop'); Wait('stop');
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status

View File

@@ -26,7 +26,7 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices',
Rest.setUrl($rootScope.current_user.related.admin_of_organizations); Rest.setUrl($rootScope.current_user.related.admin_of_organizations);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
scope.current_user_admin_orgs = data.results.map(i => i.name); scope.current_user_admin_orgs = data.results.map(i => i.name);
}); });
@@ -71,10 +71,10 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices',
var notifier_url = url + id + column; var notifier_url = url + id + column;
Rest.setUrl(notifier_url); Rest.setUrl(notifier_url);
Rest.get() Rest.get()
.success( function(data, i, j, obj) { .then(function(response) {
var type = (obj.url.indexOf('success')>0) ? "notification_templates_success" : "notification_templates_error"; var type = (url.indexOf('success')>0) ? "notification_templates_success" : "notification_templates_error";
if (data.results) { if (response.data.results) {
_.forEach(data.results, function(result){ _.forEach(response.data.results, function(result){
_.forEach(scope.notifications, function(notification){ _.forEach(scope.notifications, function(notification){
if(notification.id === result.id){ if(notification.id === result.id){
notification[type] = true; notification[type] = true;
@@ -86,7 +86,7 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices',
Wait('stop'); Wait('stop');
} }
}) })
.error( function(data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to update notification ' + data.id + ' PUT returned: ' + status }); msg: 'Failed to update notification ' + data.id + ' PUT returned: ' + status });
}); });

View File

@@ -39,7 +39,7 @@ export default ['Wait', 'ProcessErrors', 'Rest',
Wait('start'); Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
Rest.post(params) Rest.post(params)
.success( function(data) { .then(({data}) => {
if (callback) { if (callback) {
scope.$emit(callback, data.id); scope.$emit(callback, data.id);
notifier[column] = !notifier[column]; notifier[column] = !notifier[column];
@@ -47,7 +47,7 @@ export default ['Wait', 'ProcessErrors', 'Rest',
// Hide the working spinner // Hide the working spinner
Wait('stop'); Wait('stop');
}) })
.error( function(data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to update notification ' + data.id + ' PUT returned: ' + status }); msg: 'Failed to update notification ' + data.id + ' PUT returned: ' + status });
}); });

View File

@@ -12,7 +12,7 @@ export default ['$scope', '$rootScope', '$location', '$stateParams',
Rest.setUrl(GetBasePath('organizations')); Rest.setUrl(GetBasePath('organizations'));
Rest.options() Rest.options()
.success(function(data) { .then(({data}) => {
if (!data.actions.POST) { if (!data.actions.POST) {
$state.go("^"); $state.go("^");
Alert('Permission Error', 'You do not have permission to add an organization.', 'alert-info'); Alert('Permission Error', 'You do not have permission to add an organization.', 'alert-info');

View File

@@ -36,7 +36,7 @@ export default ['$scope', '$location', '$stateParams',
Wait('start'); Wait('start');
Rest.setUrl(defaultUrl + id + '/'); Rest.setUrl(defaultUrl + id + '/');
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
let fld; let fld;
$scope.organization_name = data.name; $scope.organization_name = data.name;
@@ -124,10 +124,10 @@ export default ['$scope', '$location', '$stateParams',
var url = defaultUrl + $stateParams.organization_id + '/' + set + '/'; var url = defaultUrl + $stateParams.organization_id + '/' + set + '/';
Rest.setUrl(url); Rest.setUrl(url);
Rest.post({ id: itm_id, disassociate: 1 }) Rest.post({ id: itm_id, disassociate: 1 })
.success(function() { .then(() => {
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
}) })
.error(function(data, status) { .catch(({data, status}) => {
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',

View File

@@ -24,7 +24,7 @@ export default ['$stateParams', '$scope', 'Rest', '$state',
Rest.setUrl(orgBase + $stateParams.organization_id); Rest.setUrl(orgBase + $stateParams.organization_id);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
$scope.organization_name = data.name; $scope.organization_name = data.name;
$scope.name = data.name; $scope.name = data.name;
$scope.org_id = data.id; $scope.org_id = data.id;
@@ -51,10 +51,10 @@ export default ['$stateParams', '$scope', 'Rest', '$state',
Rest.post({ Rest.post({
id: id, id: id,
disassociate: true disassociate: true
}).success(function() { }).then(() => {
$state.go('.', null, { reload: true }); $state.go('.', null, { reload: true });
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status

View File

@@ -28,7 +28,7 @@ export default ['$scope', '$rootScope', '$location',
$rootScope.flashMessage = null; $rootScope.flashMessage = null;
Rest.setUrl(orgBase + $stateParams.organization_id); Rest.setUrl(orgBase + $stateParams.organization_id);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
$scope.organization_name = data.name; $scope.organization_name = data.name;
$scope.name = data.name; $scope.name = data.name;
@@ -194,10 +194,10 @@ export default ['$scope', '$rootScope', '$location',
Wait('start'); Wait('start');
Rest.setUrl(inventory.related.inventory_sources + '?or__source=ec2&or__source=rax&order_by=-last_job_run&page_size=5'); Rest.setUrl(inventory.related.inventory_sources + '?or__source=ec2&or__source=rax&order_by=-last_job_run&page_size=5');
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
$scope.$emit('GroupSummaryReady', event, inventory, data); $scope.$emit('GroupSummaryReady', event, inventory, data);
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Call to ' + inventory.related.inventory_sources + ' failed. GET returned status: ' + status msg: 'Call to ' + inventory.related.inventory_sources + ' failed. GET returned status: ' + status
@@ -218,10 +218,10 @@ export default ['$scope', '$rootScope', '$location',
url += "&order_by=-finished&page_size=5"; url += "&order_by=-finished&page_size=5";
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
$scope.$emit('HostSummaryReady', event, data); $scope.$emit('HostSummaryReady', event, data);
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Call to ' + url + ' failed. GET returned: ' + status msg: 'Call to ' + url + ' failed. GET returned: ' + status

View File

@@ -34,7 +34,7 @@ export default ['$scope', '$rootScope',
$scope[list.name] = $scope[`${list.iterator}_dataset`].results; $scope[list.name] = $scope[`${list.iterator}_dataset`].results;
Rest.setUrl(orgBase + $stateParams.organization_id); Rest.setUrl(orgBase + $stateParams.organization_id);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
$scope.organization_name = data.name; $scope.organization_name = data.name;
$scope.name = data.name; $scope.name = data.name;
$scope.org_id = data.id; $scope.org_id = data.id;
@@ -84,17 +84,17 @@ export default ['$scope', '$rootScope',
$scope.copyTemplate = function(id) { $scope.copyTemplate = function(id) {
Wait('start'); Wait('start');
TemplateCopyService.get(id) TemplateCopyService.get(id)
.success(function(res){ .then((data) => {
TemplateCopyService.set(res) TemplateCopyService.set(data.results)
.success(function(res){ .then((results) => {
Wait('stop'); Wait('stop');
if(res.type && res.type === 'job_template') { if(results.type && results.type === 'job_template') {
$state.go('templates.editJobTemplate', {job_template_id: res.id}, {reload: true}); $state.go('templates.editJobTemplate', {job_template_id: results.id}, {reload: true});
} }
}); });
}) })
.error(function(res, status){ .catch(({data, status}) => {
ProcessErrors($rootScope, res, status, null, {hdr: 'Error!', ProcessErrors($rootScope, data, status, null, {hdr: 'Error!',
msg: 'Call failed. Return status: '+ status}); msg: 'Call failed. Return status: '+ status});
}); });

View File

@@ -99,7 +99,7 @@ export default ['$scope', '$rootScope', '$log', '$stateParams', 'Rest', 'Alert',
// Go out and get the organization // Go out and get the organization
Rest.setUrl(orgBase + $stateParams.organization_id); Rest.setUrl(orgBase + $stateParams.organization_id);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
$scope.organization_name = data.name; $scope.organization_name = data.name;
$scope.name = data.name; $scope.name = data.name;
$scope.org_id = data.id; $scope.org_id = data.id;
@@ -205,10 +205,10 @@ export default ['$scope', '$rootScope', '$log', '$stateParams', 'Rest', 'Alert',
// Refresh what we have in memory to insure we're accessing the most recent status record // Refresh what we have in memory to insure we're accessing the most recent status record
Rest.setUrl(project.url); Rest.setUrl(project.url);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
$scope.$emit('GoTojobResults', data); $scope.$emit('GoTojobResults', data);
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Project lookup failed. GET returned: ' + status msg: 'Project lookup failed. GET returned: ' + status
@@ -224,11 +224,11 @@ export default ['$scope', '$rootScope', '$log', '$stateParams', 'Rest', 'Alert',
// Cancel the project update process // Cancel the project update process
Rest.setUrl(url); Rest.setUrl(url);
Rest.post() Rest.post()
.success(function() { .then(() => {
Alert('SCM Update Cancel', 'Your request to cancel the update was submitted to the task manager.', 'alert-info'); Alert('SCM Update Cancel', 'Your request to cancel the update was submitted to the task manager.', 'alert-info');
$scope.refresh(); $scope.refresh();
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST status: ' + status }); ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST status: ' + status });
}); });
}); });
@@ -241,7 +241,7 @@ export default ['$scope', '$rootScope', '$log', '$stateParams', 'Rest', 'Alert',
var url = data.related.cancel; var url = data.related.cancel;
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
if (data.can_cancel) { if (data.can_cancel) {
$scope.$emit('Cancel_Update', url); $scope.$emit('Cancel_Update', url);
} else { } else {
@@ -249,7 +249,7 @@ export default ['$scope', '$rootScope', '$log', '$stateParams', 'Rest', 'Alert',
'Click the <em>Refresh</em> button to view the latest status.</div>', 'alert-info', null, null, null, null, true); 'Click the <em>Refresh</em> button to view the latest status.</div>', 'alert-info', null, null, null, null, true);
} }
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ' failed. GET status: ' + status }); ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ' failed. GET status: ' + status });
}); });
}); });
@@ -257,14 +257,14 @@ export default ['$scope', '$rootScope', '$log', '$stateParams', 'Rest', 'Alert',
$scope.cancelUpdate = function(id, name) { $scope.cancelUpdate = function(id, name) {
Rest.setUrl(GetBasePath("projects") + id); Rest.setUrl(GetBasePath("projects") + id);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
if (data.related.current_update) { if (data.related.current_update) {
Rest.setUrl(data.related.current_update); Rest.setUrl(data.related.current_update);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
$scope.$emit('Check_Cancel', data); $scope.$emit('Check_Cancel', data);
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Call to ' + data.related.current_update + ' failed. GET status: ' + status msg: 'Call to ' + data.related.current_update + ' failed. GET status: ' + status
@@ -275,7 +275,7 @@ export default ['$scope', '$rootScope', '$log', '$stateParams', 'Rest', 'Alert',
'button to view the latest status.</div>', 'alert-info', undefined, undefined, undefined, undefined, true); 'button to view the latest status.</div>', 'alert-info', undefined, undefined, undefined, undefined, true);
} }
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Call to get project failed. GET status: ' + status msg: 'Call to get project failed. GET status: ' + status

View File

@@ -30,7 +30,7 @@ export default ['$scope', '$stateParams', 'OrgTeamList', 'Rest', 'OrgTeamsDatase
Rest.setUrl(orgBase + $stateParams.organization_id); Rest.setUrl(orgBase + $stateParams.organization_id);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
$scope.organization_name = data.name; $scope.organization_name = data.name;
$scope.name = data.name; $scope.name = data.name;

View File

@@ -23,7 +23,7 @@ export default ['$stateParams', '$scope', 'OrgUserList','Rest', '$state',
Rest.setUrl(orgBase + $stateParams.organization_id); Rest.setUrl(orgBase + $stateParams.organization_id);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
$scope.organization_name = data.name; $scope.organization_name = data.name;
$scope.name = data.name; $scope.name = data.name;
$scope.org_id = data.id; $scope.org_id = data.id;
@@ -50,10 +50,10 @@ export default ['$stateParams', '$scope', 'OrgUserList','Rest', '$state',
Rest.post({ Rest.post({
id: id, id: id,
disassociate: true disassociate: true
}).success(function() { }).then(() => {
$state.go('.', null, { reload: true }); $state.go('.', null, { reload: true });
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status

View File

@@ -93,7 +93,7 @@ export default ['$stateParams', '$scope', '$rootScope',
Rest.setUrl($scope.current_url); Rest.setUrl($scope.current_url);
Rest.get() Rest.get()
.success((data) => $scope.organizations = data.results) .success((data) => $scope.organizations = data.results)
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Call to ' + defaultUrl + ' failed. DELETE returned status: ' + status msg: 'Call to ' + defaultUrl + ' failed. DELETE returned status: ' + status
@@ -143,7 +143,7 @@ export default ['$stateParams', '$scope', '$rootScope',
var url = defaultUrl + id + '/'; var url = defaultUrl + id + '/';
Rest.setUrl(url); Rest.setUrl(url);
Rest.destroy() Rest.destroy()
.success(function() { .then(() => {
Wait('stop'); Wait('stop');
let reloadListStateParams = null; let reloadListStateParams = null;
@@ -159,7 +159,7 @@ export default ['$stateParams', '$scope', '$rootScope',
$state.go('.', reloadListStateParams, { reload: true }); $state.go('.', reloadListStateParams, { reload: true });
} }
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status

View File

@@ -23,7 +23,7 @@ export default ['$scope', '$location', '$stateParams', 'GenerateForm',
$scope.canEditOrg = true; $scope.canEditOrg = true;
Rest.setUrl(GetBasePath('projects')); Rest.setUrl(GetBasePath('projects'));
Rest.options() Rest.options()
.success(function(data) { .then(({data}) => {
if (!data.actions.POST) { if (!data.actions.POST) {
$state.go("^"); $state.go("^");
Alert(i18n._('Permission Error'), i18n._('You do not have permission to add a project.'), 'alert-info'); Alert(i18n._('Permission Error'), i18n._('You do not have permission to add a project.'), 'alert-info');
@@ -99,11 +99,11 @@ export default ['$scope', '$location', '$stateParams', 'GenerateForm',
Wait('start'); Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
Rest.post(data) Rest.post(data)
.success(function(data) { .then(({data}) => {
$scope.addedItem = data.id; $scope.addedItem = data.id;
$state.go('projects.edit', { project_id: data.id }, { reload: true }); $state.go('projects.edit', { project_id: data.id }, { reload: true });
}) })
.error(function(data, status) { .catch(({data, status}) => {
Wait('stop'); Wait('stop');
ProcessErrors($scope, data, status, form, { hdr: i18n._('Error!'), ProcessErrors($scope, data, status, form, { hdr: i18n._('Error!'),
msg: i18n._('Failed to create new project. POST returned status: ') + status }); msg: i18n._('Failed to create new project. POST returned status: ') + status });

View File

@@ -85,7 +85,7 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest',
// Retrieve detail record and prepopulate the form // Retrieve detail record and prepopulate the form
Rest.setUrl(defaultUrl); Rest.setUrl(defaultUrl);
Rest.get({ params: { id: id } }) Rest.get({ params: { id: id } })
.success(function(data) { .then(({data}) => {
var fld, i; var fld, i;
for (fld in form.fields) { for (fld in form.fields) {
if (form.fields[fld].type === 'checkbox_group') { if (form.fields[fld].type === 'checkbox_group') {
@@ -152,7 +152,7 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest',
$scope.$emit('projectLoaded'); $scope.$emit('projectLoaded');
Wait('stop'); Wait('stop');
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, form, { hdr: i18n._('Error!'), ProcessErrors($scope, data, status, form, { hdr: i18n._('Error!'),
msg: i18n.sprintf(i18n._('Failed to retrieve project: %s. GET status: '), id) + status msg: i18n.sprintf(i18n._('Failed to retrieve project: %s. GET status: '), id) + status
}); });
@@ -214,11 +214,11 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest',
Rest.setUrl(defaultUrl); Rest.setUrl(defaultUrl);
Rest.put(params) Rest.put(params)
.success(function() { .then(() => {
Wait('stop'); Wait('stop');
$state.go($state.current, {}, { reload: true }); $state.go($state.current, {}, { reload: true });
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, form, { hdr: i18n._('Error!'), msg: i18n.sprintf(i18n._('Failed to update project: %s. PUT status: '), id) + status }); ProcessErrors($scope, data, status, form, { hdr: i18n._('Error!'), msg: i18n.sprintf(i18n._('Failed to update project: %s. PUT status: '), id) + status });
}); });
}; };
@@ -230,10 +230,10 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest',
$rootScope.flashMessage = null; $rootScope.flashMessage = null;
Rest.setUrl(url); Rest.setUrl(url);
Rest.post({ id: itm_id, disassociate: 1 }) Rest.post({ id: itm_id, disassociate: 1 })
.success(function() { .then(() => {
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
}) })
.error(function(data, status) { .catch(({data, status}) => {
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'), msg: i18n.sprintf(i18n._('Call to %s failed. POST returned status: '), url) + status }); ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'), msg: i18n.sprintf(i18n._('Call to %s failed. POST returned status: '), url) + status });
}); });

View File

@@ -26,7 +26,7 @@ export default
Rest.setUrl(GetBasePath('config')); Rest.setUrl(GetBasePath('config'));
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
var opts = [], i; var opts = [], i;
if (data.project_local_paths) { if (data.project_local_paths) {
for (i = 0; i < data.project_local_paths.length; i++) { for (i = 0; i < data.project_local_paths.length; i++) {
@@ -63,7 +63,7 @@ export default
} }
scope.$emit('pathsReady'); scope.$emit('pathsReady');
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to access API config. GET status: ' + status }); msg: 'Failed to access API config. GET status: ' + status });
}); });

View File

@@ -162,10 +162,10 @@ export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert',
// Refresh what we have in memory to insure we're accessing the most recent status record // Refresh what we have in memory to insure we're accessing the most recent status record
Rest.setUrl(project.url); Rest.setUrl(project.url);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
$scope.$emit('GoTojobResults', data); $scope.$emit('GoTojobResults', data);
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'), ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'),
msg: i18n._('Project lookup failed. GET returned: ') + status }); msg: i18n._('Project lookup failed. GET returned: ') + status });
}); });
@@ -179,7 +179,7 @@ export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert',
var url = defaultUrl + id + '/'; var url = defaultUrl + id + '/';
Rest.setUrl(url); Rest.setUrl(url);
Rest.destroy() Rest.destroy()
.success(function() { .then(() => {
let reloadListStateParams = null; let reloadListStateParams = null;
@@ -194,7 +194,7 @@ export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert',
$state.go('.', reloadListStateParams, {reload: true}); $state.go('.', reloadListStateParams, {reload: true});
} }
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'), ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'),
msg: i18n.sprintf(i18n._('Call to %s failed. DELETE returned status: '), url) + status }); msg: i18n.sprintf(i18n._('Call to %s failed. DELETE returned status: '), url) + status });
}) })
@@ -218,10 +218,10 @@ export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert',
// Cancel the project update process // Cancel the project update process
Rest.setUrl(url); Rest.setUrl(url);
Rest.post() Rest.post()
.success(function () { .then(() => {
Alert(i18n._('SCM Update Cancel'), i18n._('Your request to cancel the update was submitted to the task manager.'), 'alert-info'); Alert(i18n._('SCM Update Cancel'), i18n._('Your request to cancel the update was submitted to the task manager.'), 'alert-info');
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'), msg: i18n.sprintf(i18n._('Call to %s failed. POST status: '), url) + status }); ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'), msg: i18n.sprintf(i18n._('Call to %s failed. POST status: '), url) + status });
}); });
}); });
@@ -234,7 +234,7 @@ export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert',
var url = data.related.cancel; var url = data.related.cancel;
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
if (data.can_cancel) { if (data.can_cancel) {
$scope.$emit('Cancel_Update', url); $scope.$emit('Cancel_Update', url);
} else { } else {
@@ -242,7 +242,7 @@ export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert',
'Click the %sRefresh%s button to view the latest status.'), '<em>', '</em>') + '</div>', 'alert-info', null, null, null, null, true); 'Click the %sRefresh%s button to view the latest status.'), '<em>', '</em>') + '</div>', 'alert-info', null, null, null, null, true);
} }
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'), msg: i18n.sprintf(i18n._('Call to %s failed. GET status: '), url) + status }); ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'), msg: i18n.sprintf(i18n._('Call to %s failed. GET status: '), url) + status });
}); });
}); });
@@ -251,14 +251,14 @@ export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert',
project.pending_cancellation = true; project.pending_cancellation = true;
Rest.setUrl(GetBasePath("projects") + project.id); Rest.setUrl(GetBasePath("projects") + project.id);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
if (data.related.current_update) { if (data.related.current_update) {
Rest.setUrl(data.related.current_update); Rest.setUrl(data.related.current_update);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
$scope.$emit('Check_Cancel', data); $scope.$emit('Check_Cancel', data);
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'), ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'),
msg: i18n.sprintf(i18n._('Call to %s failed. GET status: '), data.related.current_update) + status }); msg: i18n.sprintf(i18n._('Call to %s failed. GET status: '), data.related.current_update) + status });
}); });
@@ -267,7 +267,7 @@ export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert',
'button to view the latest status.'), $filter('sanitize')(name), '<em>', '</em>') + '</div>', 'alert-info',undefined,undefined,undefined,undefined,true); 'button to view the latest status.'), $filter('sanitize')(name), '<em>', '</em>') + '</div>', 'alert-info',undefined,undefined,undefined,undefined,true);
} }
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'), ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'),
msg: i18n._('Call to get project failed. GET status: ') + status }); msg: i18n._('Call to get project failed. GET status: ') + status });
}); });

View File

@@ -38,7 +38,7 @@
* var url = GetBasePath('inventories') + $stateParams.id + '/'; * var url = GetBasePath('inventories') + $stateParams.id + '/';
* Rest.setUrl(url); * Rest.setUrl(url);
* Rest.get() * Rest.get()
* .success(function(data) { * .then(({data}) => {
* // review the data object and take action * // review the data object and take action
* }) * })
* .error(function(status, data) { * .error(function(status, data) {

View File

@@ -22,7 +22,7 @@ export default
Wait('start'); Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
Rest.destroy() Rest.destroy()
.success(function () { .then(() => {
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
scope.$emit(callback, id); scope.$emit(callback, id);
@@ -40,7 +40,7 @@ export default
$state.go('.', reloadListStateParams, {reload: true}); $state.go('.', reloadListStateParams, {reload: true});
} }
}) })
.error(function (data, status) { .catch(({data, status}) => {
try { try {
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
} }

View File

@@ -121,7 +121,7 @@ export default
// Get the existing record // Get the existing record
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
schedule = data; schedule = data;
try { try {
schedule.extra_data = JSON.parse(schedule.extra_data); schedule.extra_data = JSON.parse(schedule.extra_data);
@@ -141,7 +141,7 @@ export default
scope.$emit('ScheduleFound'); scope.$emit('ScheduleFound');
}) })
.error(function(data,status){ .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to retrieve schedule ' + id + ' GET returned: ' + status }); msg: 'Failed to retrieve schedule ' + id + ' GET returned: ' + status });
}); });

View File

@@ -35,7 +35,7 @@ export default
Rest.setUrl(url); Rest.setUrl(url);
if (mode === 'add') { if (mode === 'add') {
Rest.post(schedule) Rest.post(schedule)
.success(function(){ .then(() => {
if (callback) { if (callback) {
scope.$emit(callback); scope.$emit(callback);
} }
@@ -43,14 +43,14 @@ export default
Wait('stop'); Wait('stop');
} }
}) })
.error(function(data, status){ .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'POST to ' + url + ' returned: ' + status }); msg: 'POST to ' + url + ' returned: ' + status });
}); });
} }
else { else {
Rest.put(schedule) Rest.put(schedule)
.success(function(){ .then(() => {
if (callback) { if (callback) {
scope.$emit(callback, schedule); scope.$emit(callback, schedule);
} }
@@ -58,7 +58,7 @@ export default
Wait('stop'); Wait('stop');
} }
}) })
.error(function(data, status){ .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'POST to ' + url + ' returned: ' + status }); msg: 'POST to ' + url + ' returned: ' + status });
}); });

View File

@@ -12,11 +12,11 @@ export default
scope.removeScheduleFound = scope.$on('ScheduleFound', function(e, data) { scope.removeScheduleFound = scope.$on('ScheduleFound', function(e, data) {
data.enabled = (data.enabled) ? false : true; data.enabled = (data.enabled) ? false : true;
Rest.put(data) Rest.put(data)
.success( function() { .then(() => {
Wait('stop'); Wait('stop');
$state.go('.', null, {reload: true}); $state.go('.', null, {reload: true});
}) })
.error( function(data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to update schedule ' + id + ' PUT returned: ' + status }); msg: 'Failed to update schedule ' + id + ' PUT returned: ' + status });
}); });
@@ -27,10 +27,10 @@ export default
// Get the schedule // Get the schedule
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
scope.$emit('ScheduleFound', data); scope.$emit('ScheduleFound', data);
}) })
.error(function(data,status){ .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to retrieve schedule ' + id + ' GET returned: ' + status }); msg: 'Failed to retrieve schedule ' + id + ' GET returned: ' + status });
}); });

View File

@@ -61,7 +61,7 @@ export default
ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){ ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){
let path = `${GetBasePath('job_templates')}${$stateParams.id}`; let path = `${GetBasePath('job_templates')}${$stateParams.id}`;
Rest.setUrl(path); Rest.setUrl(path);
return Rest.get(path).then((res) => res.data); return Rest.get(path).then(response => response.data);
}], }],
UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q', UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',
function(Rest, GetBasePath, $stateParams, $q) { function(Rest, GetBasePath, $stateParams, $q) {
@@ -152,7 +152,7 @@ export default
ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){ ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){
let path = `${GetBasePath('workflow_job_templates')}${$stateParams.id}`; let path = `${GetBasePath('workflow_job_templates')}${$stateParams.id}`;
Rest.setUrl(path); Rest.setUrl(path);
return Rest.get(path).then((res) => res.data); return Rest.get(path).then(response => response.data);
}], }],
UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q', UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',
function(Rest, GetBasePath, $stateParams, $q) { function(Rest, GetBasePath, $stateParams, $q) {
@@ -242,7 +242,7 @@ export default
ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){ ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){
let path = `${GetBasePath('projects')}${$stateParams.id}`; let path = `${GetBasePath('projects')}${$stateParams.id}`;
Rest.setUrl(path); Rest.setUrl(path);
return Rest.get(path).then((res) => res.data); return Rest.get(path).then(response => response.data);
}], }],
UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q', UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',
function(Rest, GetBasePath, $stateParams, $q) { function(Rest, GetBasePath, $stateParams, $q) {

View File

@@ -750,10 +750,10 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
if (!options) { if (!options) {
Rest.setUrl(url); Rest.setUrl(url);
Rest.options() Rest.options()
.success(function(data) { .then(({data}) => {
withOptions(data); withOptions(data);
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { ProcessErrors(scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to get ' + url + '. OPTIONS status: ' + status msg: 'Failed to get ' + url + '. OPTIONS status: ' + status

View File

@@ -29,15 +29,15 @@ angular.module('ApiLoader', ['Utilities'])
return function () { return function () {
$http({ method: 'GET', url:'/api/', headers: { 'Authorization': "" } }) $http({ method: 'GET', url:'/api/', headers: { 'Authorization': "" } })
.success(function (data) { .then(({data}) => {
var base = data.current_version; var base = data.current_version;
$http({ method: 'GET', url:base, headers: { 'Authorization': "" } }) $http({ method: 'GET', url:base, headers: { 'Authorization': "" } })
.success(function (data) { .then(({data}) => {
data.base = base; data.base = base;
$rootScope.defaultUrls = data; $rootScope.defaultUrls = data;
Store('api', data); Store('api', data);
}) })
.error(function (data, status) { .catch(({data, status}) => {
$rootScope.defaultUrls = { $rootScope.defaultUrls = {
status: 'error' status: 'error'
}; };
@@ -47,7 +47,7 @@ angular.module('ApiLoader', ['Utilities'])
}); });
}); });
}) })
.error(function (data, status) { .catch(({data, status}) => {
$rootScope.defaultUrls = { $rootScope.defaultUrls = {
status: 'error' status: 'error'
}; };

View File

@@ -556,7 +556,7 @@ function(ConfigurationUtils, i18n, $rootScope) {
Rest.setUrl(`${basePath}` + query); Rest.setUrl(`${basePath}` + query);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
if (data.count === 1) { if (data.count === 1) {
scope[modelKey] = data.results[0].name; scope[modelKey] = data.results[0].name;
scope[modelName] = data.results[0].id; scope[modelName] = data.results[0].id;

View File

@@ -24,24 +24,24 @@ export default
method: 'GET', method: 'GET',
url: '/api/', url: '/api/',
}) })
.success(function(response) { .then(function({data}) {
if(response.custom_logo) { if(data.custom_logo) {
configSettings.custom_logo = true; configSettings.custom_logo = true;
$rootScope.custom_logo = response.custom_logo; $rootScope.custom_logo = data.custom_logo;
} else { } else {
configSettings.custom_logo = false; configSettings.custom_logo = false;
} }
if(response.custom_login_info) { if(data.custom_login_info) {
configSettings.custom_login_info = response.custom_login_info; configSettings.custom_login_info = data.custom_login_info;
$rootScope.custom_login_info = response.custom_login_info; $rootScope.custom_login_info = data.custom_login_info;
} else { } else {
configSettings.custom_login_info = false; configSettings.custom_login_info = false;
} }
configInit(); configInit();
}).error(function(error) { }).catch(({error}) => {
$log.debug(error); $log.debug(error);
configInit(); configInit();
}); });

View File

@@ -44,7 +44,7 @@ export default ['templateUrl', function(templateUrl) {
if($scope.currentSelection && $scope.currentSelection.id) { if($scope.currentSelection && $scope.currentSelection.id) {
$scope[list.name].forEach(function(row) { $scope[list.name].forEach(function(row) {
if (row.id === $scope.currentSelection.id) { if (row.id === $scope.currentSelection.id) {
row.checked = true; row.checked = 1;
} }
}); });
} }
@@ -71,7 +71,7 @@ export default ['templateUrl', function(templateUrl) {
if (row.checked) { if (row.checked) {
row.success_class = 'success'; row.success_class = 'success';
} else { } else {
row.checked = true; row.checked = 1;
row.success_class = ''; row.success_class = '';
} }
$scope.currentSelection = { $scope.currentSelection = {

View File

@@ -14,7 +14,7 @@ export default
if(Authorization.getUserInfo('is_superuser') !== true) { if(Authorization.getUserInfo('is_superuser') !== true) {
Rest.setUrl(GetBasePath('users') + $rootScope.current_user.id + '/admin_of_organizations'); Rest.setUrl(GetBasePath('users') + $rootScope.current_user.id + '/admin_of_organizations');
Rest.get({ params: { id: params.organization } }) Rest.get({ params: { id: params.organization } })
.success(function(data) { .then(({data}) => {
if(data.count && data.count > 0) { if(data.count && data.count > 0) {
deferred.resolve(true); deferred.resolve(true);
} }

View File

@@ -18,11 +18,11 @@ export default
Wait("start"); Wait("start");
Rest.options() Rest.options()
.success(function(data) { .then(({data}) => {
if (data.actions.POST) { if (data.actions.POST) {
canAddVal.resolve({canAdd: true, options: data}); canAddVal.resolve({canAdd: true, options: data});
} else { } else {
canAddVal.reject(false); canAddVal.resolve({canAdd: false});
} }
Wait("stop"); Wait("stop");
}); });

View File

@@ -34,6 +34,7 @@ export default
self.socket.onopen = function () { self.socket.onopen = function () {
$log.debug("Websocket connection opened. Socket readyState: " + self.socket.readyState); $log.debug("Websocket connection opened. Socket readyState: " + self.socket.readyState);
socketPromise.resolve(); socketPromise.resolve();
console.log('promise resolved, and readyState: '+ self.readyState);
self.checkStatus(); self.checkStatus();
if(needsResubscribing){ if(needsResubscribing){
self.subscribe(self.getLast()); self.subscribe(self.getLast());
@@ -116,6 +117,7 @@ export default
if(this.socket){ if(this.socket){
this.socket.close(); this.socket.close();
delete this.socket; delete this.socket;
console.log("Socket deleted: "+this.socket);
} }
}, },
subscribe: function(state){ subscribe: function(state){

View File

@@ -98,7 +98,7 @@ export default ['$log', '$rootScope', '$scope', '$state', '$stateParams', 'Proce
Rest.setUrl($scope.stdoutEndpoint + '?format=json&start_line=0&end_line=' + page_size); Rest.setUrl($scope.stdoutEndpoint + '?format=json&start_line=0&end_line=' + page_size);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
Wait('stop'); Wait('stop');
if (data.content) { if (data.content) {
api_complete = true; api_complete = true;
@@ -117,7 +117,7 @@ export default ['$log', '$rootScope', '$scope', '$state', '$stateParams', 'Proce
api_complete = true; api_complete = true;
} }
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', ProcessErrors($scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to retrieve stdout for job: ' + job_id + '. GET returned: ' + status }); msg: 'Failed to retrieve stdout for job: ' + job_id + '. GET returned: ' + status });
}); });
@@ -134,7 +134,7 @@ export default ['$log', '$rootScope', '$scope', '$state', '$stateParams', 'Proce
$('#stdoutMoreRowsBottom').fadeIn(); $('#stdoutMoreRowsBottom').fadeIn();
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success( function(data) { .then(({data}) => {
if ($('#pre-container-content').html() === "Waiting for results...") { if ($('#pre-container-content').html() === "Waiting for results...") {
$('#pre-container-content').html(data.content); $('#pre-container-content').html(data.content);
} else { } else {
@@ -152,7 +152,7 @@ export default ['$log', '$rootScope', '$scope', '$state', '$stateParams', 'Proce
} }
$('#stdoutMoreRowsBottom').fadeOut(400); $('#stdoutMoreRowsBottom').fadeOut(400);
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', ProcessErrors($scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to retrieve stdout for job: ' + job_id + '. GET returned: ' + status }); msg: 'Failed to retrieve stdout for job: ' + job_id + '. GET returned: ' + status });
}); });
@@ -166,11 +166,11 @@ export default ['$log', '$rootScope', '$scope', '$state', '$stateParams', 'Proce
'&end_line=' + (current_range.end + page_size); '&end_line=' + (current_range.end + page_size);
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function(data){ .then(({data}) => {
$('#pre-container-content').append(data.content); $('#pre-container-content').append(data.content);
current_range = data.range; current_range = data.range;
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', ProcessErrors($scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to retrieve stdout for job: ' + job_id + '. GET returned: ' + status }); msg: 'Failed to retrieve stdout for job: ' + job_id + '. GET returned: ' + status });
}); });

View File

@@ -13,7 +13,7 @@
callback = params.callback; callback = params.callback;
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
if (scope_var === 'inventory_source') { if (scope_var === 'inventory_source') {
scope.inventory = data.inventory; scope.inventory = data.inventory;
} }
@@ -25,7 +25,7 @@
scope.$emit(callback, data); scope.$emit(callback, data);
} }
}) })
.error(function(data, status) { .catch(({data, status}) => {
if (status === 403 && params.ignore_403) { if (status === 403 && params.ignore_403) {
return; return;
} }

View File

@@ -79,7 +79,7 @@ export function JobStdoutController ($rootScope, $scope, $state, $stateParams,
// of stdout jobs. // of stdout jobs.
Rest.setUrl(GetBasePath('base') + jobType + '/' + job_id + '/'); Rest.setUrl(GetBasePath('base') + jobType + '/' + job_id + '/');
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
$scope.job = data; $scope.job = data;
$scope.job_template_name = data.name; $scope.job_template_name = data.name;
$scope.created_by = data.summary_fields.created_by; $scope.created_by = data.summary_fields.created_by;
@@ -211,7 +211,7 @@ export function JobStdoutController ($rootScope, $scope, $state, $stateParams,
} }
} }
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: 'Error!', ProcessErrors($scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to retrieve job: ' + job_id + '. GET returned: ' + status }); msg: 'Failed to retrieve job: ' + job_id + '. GET returned: ' + status });
}); });

View File

@@ -11,7 +11,7 @@ export default ['$scope', '$rootScope', 'TeamForm', 'GenerateForm', 'Rest',
Rest.setUrl(GetBasePath('teams')); Rest.setUrl(GetBasePath('teams'));
Rest.options() Rest.options()
.success(function(data) { .then(({data}) => {
if (!data.actions.POST) { if (!data.actions.POST) {
$state.go("^"); $state.go("^");
Alert('Permission Error', 'You do not have permission to add a team.', 'alert-info'); Alert('Permission Error', 'You do not have permission to add a team.', 'alert-info');
@@ -43,13 +43,13 @@ export default ['$scope', '$rootScope', 'TeamForm', 'GenerateForm', 'Rest',
data[fld] = $scope[fld]; data[fld] = $scope[fld];
} }
Rest.post(data) Rest.post(data)
.success(function(data) { .then(({data}) => {
Wait('stop'); Wait('stop');
$rootScope.flashMessage = "New team successfully created!"; $rootScope.flashMessage = "New team successfully created!";
$rootScope.$broadcast("EditIndicatorChange", "users", data.id); $rootScope.$broadcast("EditIndicatorChange", "users", data.id);
$state.go('teams.edit', { team_id: data.id }, { reload: true }); $state.go('teams.edit', { team_id: data.id }, { reload: true });
}) })
.error(function(data, status) { .catch(({data, status}) => {
Wait('stop'); Wait('stop');
ProcessErrors($scope, data, status, form, { ProcessErrors($scope, data, status, form, {
hdr: 'Error!', hdr: 'Error!',

View File

@@ -19,7 +19,7 @@ export default ['$scope', '$rootScope', '$stateParams', 'TeamForm', 'Rest',
$scope.team_id = id; $scope.team_id = id;
Rest.setUrl(defaultUrl); Rest.setUrl(defaultUrl);
Wait('start'); Wait('start');
Rest.get(defaultUrl).success(function(data) { Rest.get(defaultUrl).then(({data}) => {
setScopeFields(data); setScopeFields(data);
$scope.organization_name = data.summary_fields.organization.name; $scope.organization_name = data.summary_fields.organization.name;
@@ -74,10 +74,10 @@ export default ['$scope', '$rootScope', '$stateParams', 'TeamForm', 'Rest',
if ($scope[form.name + '_form'].$valid) { if ($scope[form.name + '_form'].$valid) {
var data = processNewData(form.fields); var data = processNewData(form.fields);
Rest.setUrl(defaultUrl); Rest.setUrl(defaultUrl);
Rest.put(data).success(function() { Rest.put(data).then(() => {
$state.go($state.current, null, { reload: true }); $state.go($state.current, null, { reload: true });
}) })
.error(function(data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to retrieve user: ' + msg: 'Failed to retrieve user: ' +

View File

@@ -48,7 +48,7 @@ export default ['$scope', 'Rest', 'TeamList', 'Prompt',
var url = defaultUrl + id + '/'; var url = defaultUrl + id + '/';
Rest.setUrl(url); Rest.setUrl(url);
Rest.destroy() Rest.destroy()
.success(function() { .then(() => {
Wait('stop'); Wait('stop');
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
@@ -65,7 +65,7 @@ export default ['$scope', 'Rest', 'TeamList', 'Prompt',
$state.go('.', reloadListStateParams, { reload: true }); $state.go('.', reloadListStateParams, { reload: true });
} }
}) })
.error(function(data, status) { .catch(({data, status}) => {
Wait('stop'); Wait('stop');
$('#prompt-modal').modal('hide'); $('#prompt-modal').modal('hide');
ProcessErrors($scope, data, status, null, { ProcessErrors($scope, data, status, null, {

View File

@@ -12,11 +12,9 @@
var defaultUrl = GetBasePath('job_templates') + '?id=' + id; var defaultUrl = GetBasePath('job_templates') + '?id=' + id;
Rest.setUrl(defaultUrl); Rest.setUrl(defaultUrl);
return Rest.get() return Rest.get()
.success(function(res){ .then(response => response)
return res; .catch((error) => {
}) ProcessErrors($rootScope, error.response, error.status, null, {hdr: 'Error!',
.error(function(res, status){
ProcessErrors($rootScope, res, status, null, {hdr: 'Error!',
msg: 'Call to '+ defaultUrl + ' failed. Return status: '+ status}); msg: 'Call to '+ defaultUrl + ' failed. Return status: '+ status});
}); });
}, },
@@ -25,28 +23,28 @@
return Rest.get(); return Rest.get();
}, },
copySurvey: function(source, target){ copySurvey: function(source, target){
return this.getSurvey(source.related.survey_spec).success( (data) => { return this.getSurvey(source.related.survey_spec).then( (response) => {
Rest.setUrl(target.related.survey_spec); Rest.setUrl(target.related.survey_spec);
return Rest.post(data); return Rest.post(response.data);
}); });
}, },
set: function(data){ set: function(results){
var defaultUrl = GetBasePath('job_templates'); var defaultUrl = GetBasePath('job_templates');
var self = this; var self = this;
Rest.setUrl(defaultUrl); Rest.setUrl(defaultUrl);
var name = this.buildName(data.results[0].name); var name = this.buildName(results[0].name);
data.results[0].name = name + ' @ ' + moment().format('h:mm:ss a'); // 2:49:11 pm results[0].name = name + ' @ ' + moment().format('h:mm:ss a'); // 2:49:11 pm
return Rest.post(data.results[0]) return Rest.post(results[0])
.success(function(job_template_res){ .then((response) => {
// also copy any associated survey_spec // also copy any associated survey_spec
if (data.results[0].summary_fields.survey){ if (results[0].summary_fields.survey){
return self.copySurvey(data.results[0], job_template_res).success( () => job_template_res); return self.copySurvey(results[0], response.data).then( () => response.data);
} }
else{ else {
return job_template_res; return response.data;
} }
}) })
.error(function(res, status){ .catch(({res, status}) => {
ProcessErrors($rootScope, res, status, null, {hdr: 'Error!', ProcessErrors($rootScope, res, status, null, {hdr: 'Error!',
msg: 'Call to '+ defaultUrl + ' failed. Return status: '+ status}); msg: 'Call to '+ defaultUrl + ' failed. Return status: '+ status});
}); });

View File

@@ -146,7 +146,7 @@
url = GetBasePath('projects') + $scope.project + '/playbooks/'; url = GetBasePath('projects') + $scope.project + '/playbooks/';
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
var i, opts = []; var i, opts = [];
for (i = 0; i < data.length; i++) { for (i = 0; i < data.length; i++) {
opts.push(data[i]); opts.push(data[i]);
@@ -155,7 +155,7 @@
sync_playbook_select2(); sync_playbook_select2();
Wait('stop'); Wait('stop');
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, form, { hdr: 'Error!', ProcessErrors($scope, data, status, form, { hdr: 'Error!',
msg: 'Failed to get playbook list for ' + url + '. GET returned status: ' + status }); msg: 'Failed to get playbook list for ' + url + '. GET returned status: ' + status });
}); });
@@ -172,7 +172,7 @@
if (oldValue !== newValue && !Empty($scope.project)) { if (oldValue !== newValue && !Empty($scope.project)) {
Rest.setUrl(GetBasePath('projects') + $scope.project + '/'); Rest.setUrl(GetBasePath('projects') + $scope.project + '/');
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
var msg; var msg;
switch (data.status) { switch (data.status) {
case 'failed': case 'failed':
@@ -190,7 +190,7 @@
Alert('Warning', msg, 'alert-info alert-info--noTextTransform', null, null, null, null, true); Alert('Warning', msg, 'alert-info alert-info--noTextTransform', null, null, null, null, true);
} }
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, form, { hdr: 'Error!', ProcessErrors($scope, data, status, form, { hdr: 'Error!',
msg: 'Failed to get project ' + $scope.project + '. GET returned status: ' + status }); msg: 'Failed to get project ' + $scope.project + '. GET returned status: ' + status });
}); });
@@ -394,7 +394,7 @@
Rest.setUrl(GetBasePath("organizations")); Rest.setUrl(GetBasePath("organizations"));
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
orgDefer.resolve(data.results[0].id); orgDefer.resolve(data.results[0].id);
}); });
@@ -434,7 +434,7 @@
Rest.post({ name: $scope.survey_name, Rest.post({ name: $scope.survey_name,
description: $scope.survey_description, description: $scope.survey_description,
spec: $scope.survey_questions }) spec: $scope.survey_questions })
.success(function () { .then(() => {
Wait('stop'); Wait('stop');
}) })
.error(function (data, .error(function (data,

View File

@@ -81,7 +81,7 @@ export default
Wait('start'); Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
promises.push(Rest.get() promises.push(Rest.get()
.success(function (data) { .then(({data}) => {
$scope.disablePlaybookBecausePermissionDenied = false; $scope.disablePlaybookBecausePermissionDenied = false;
$scope.playbook_options = []; $scope.playbook_options = [];
var playbookNotFound = true; var playbookNotFound = true;
@@ -98,8 +98,8 @@ export default
jobTemplateLoadFinished(); jobTemplateLoadFinished();
} }
}) })
.error(function (ret,status_code) { .catch( (error) => {
if (status_code === 403) { if (error.status_code === 403) {
/* user doesn't have access to see the project, no big deal. */ /* user doesn't have access to see the project, no big deal. */
$scope.disablePlaybookBecausePermissionDenied = true; $scope.disablePlaybookBecausePermissionDenied = true;
} else { } else {
@@ -112,7 +112,7 @@ export default
Rest.setUrl(GetBasePath('projects') + $scope.project + '/'); Rest.setUrl(GetBasePath('projects') + $scope.project + '/');
promises.push(Rest.get() promises.push(Rest.get()
.success(function (data) { .then(({data}) => {
var msg; var msg;
switch (data.status) { switch (data.status) {
case 'failed': case 'failed':
@@ -130,7 +130,7 @@ export default
Alert('Warning', msg, 'alert-info alert-info--noTextTransform', null, null, null, null, true); Alert('Warning', msg, 'alert-info alert-info--noTextTransform', null, null, null, null, true);
} }
}) })
.error(function (data, status) { .catch(({data, status}) => {
if (status === 403) { if (status === 403) {
/* User doesn't have read access to the project, no problem. */ /* User doesn't have read access to the project, no problem. */
} else { } else {
@@ -142,6 +142,12 @@ export default
$q.all(promises) $q.all(promises)
.then(function(){ .then(function(){
Wait('stop'); Wait('stop');
})
.catch(({data, status}) => {
ProcessErrors($scope, data, status, null, {
hdr: 'Error!',
msg: 'Call failed. Returned status: ' + status
});
}); });
} }
} }
@@ -423,7 +429,6 @@ export default
$scope.$emit('jobTemplateLoaded', master); $scope.$emit('jobTemplateLoaded', master);
}); });
} }
}); });
@@ -539,7 +544,7 @@ export default
var getNext = function(data, arr, resolve) { var getNext = function(data, arr, resolve) {
Rest.setUrl(data.next); Rest.setUrl(data.next);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
if (data.next) { if (data.next) {
getNext(data, arr.concat(data.results), resolve); getNext(data, arr.concat(data.results), resolve);
} else { } else {
@@ -551,7 +556,7 @@ export default
Rest.setUrl(data.related.labels); Rest.setUrl(data.related.labels);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
if (data.next) { if (data.next) {
getNext(data, data.results, associatedLabelsDefer); getNext(data, data.results, associatedLabelsDefer);
} else { } else {
@@ -578,7 +583,7 @@ export default
Rest.setUrl(GetBasePath("organizations")); Rest.setUrl(GetBasePath("organizations"));
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
orgDefer.resolve(data.results[0].id); orgDefer.resolve(data.results[0].id);
}); });
@@ -722,10 +727,10 @@ export default
Rest.setUrl(defaultUrl + $state.params.job_template_id); Rest.setUrl(defaultUrl + $state.params.job_template_id);
Rest.put(data) Rest.put(data)
.success(function (data) { .then(({data}) => {
$scope.$emit('templateSaveSuccess', data); $scope.$emit('templateSaveSuccess', data);
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors($scope, data, status, form, { hdr: 'Error!', ProcessErrors($scope, data, status, form, { hdr: 'Error!',
msg: 'Failed to update job template. PUT returned status: ' + status }); msg: 'Failed to update job template. PUT returned status: ' + status });
}); });

View File

@@ -21,7 +21,7 @@ export default
var getNext = function(data, arr, resolve) { var getNext = function(data, arr, resolve) {
Rest.setUrl(data.next); Rest.setUrl(data.next);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
if (data.next) { if (data.next) {
getNext(data, arr.concat(data.results), resolve); getNext(data, arr.concat(data.results), resolve);
} else { } else {
@@ -34,7 +34,7 @@ export default
var seeMoreResolve = $q.defer(); var seeMoreResolve = $q.defer();
Rest.setUrl(scope[scope.$parent.list.iterator].related.labels); Rest.setUrl(scope[scope.$parent.list.iterator].related.labels);
Rest.get() Rest.get()
.success(function(data) { .then(({data}) => {
if (data.next) { if (data.next) {
getNext(data, data.results, seeMoreResolve); getNext(data, data.results, seeMoreResolve);
} else { } else {
@@ -71,11 +71,11 @@ export default
if(url) { if(url) {
Rest.setUrl(url); Rest.setUrl(url);
Rest.post({"disassociate": true, "id": label.id}) Rest.post({"disassociate": true, "id": label.id})
.success(function () { .then(() => {
Wait('stop'); Wait('stop');
$state.go('.', null, {reload: true}); $state.go('.', null, {reload: true});
}) })
.error(function (data, status) { .catch(({data, status}) => {
Wait('stop'); Wait('stop');
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Could not disassociate label from JT. Call to ' + url + ' failed. DELETE returned status: ' + status }); msg: 'Could not disassociate label from JT. Call to ' + url + ' failed. DELETE returned status: ' + status });

View File

@@ -202,17 +202,23 @@ export default ['$scope', '$rootScope',
if(template.type && template.type === 'job_template') { if(template.type && template.type === 'job_template') {
Wait('start'); Wait('start');
TemplateCopyService.get(template.id) TemplateCopyService.get(template.id)
.success(function(res){ .then(function(response){
TemplateCopyService.set(res) TemplateCopyService.set(response.data.results)
.success(function(res){ .then(function(results){
Wait('stop'); Wait('stop');
if(res.type && res.type === 'job_template') { if(results.type && results.type === 'job_template') {
$state.go('templates.editJobTemplate', {job_template_id: res.id}, {reload: true}); $state.go('templates.editJobTemplate', {job_template_id: results.id}, {reload: true});
} }
})
.catch(({data, status}) => {
ProcessErrors($scope, data, status, null, {
hdr: 'Error!',
msg: 'Call failed. Return status: ' + status
});
}); });
}) })
.error(function(res, status){ .catch(({data, status}) => {
ProcessErrors($rootScope, res, status, null, {hdr: 'Error!', ProcessErrors($rootScope, data, status, null, {hdr: 'Error!',
msg: 'Call failed. Return status: '+ status}); msg: 'Call failed. Return status: '+ status});
}); });
} }

View File

@@ -41,11 +41,11 @@ export default
Rest.setUrl(url); Rest.setUrl(url);
Rest.destroy() Rest.destroy()
.success(function () { .then(() => {
scope.$emit("SurveyDeleted"); scope.$emit("SurveyDeleted");
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, { hdr: 'Error!', ProcessErrors(scope, data, status, { hdr: 'Error!',
msg: 'Failed to delete survey. DELETE returned status: ' + status }); msg: 'Failed to delete survey. DELETE returned status: ' + status });
}); });

View File

@@ -31,7 +31,7 @@ export default
// Get the existing record // Get the existing record
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success(function (data) { .then(({data}) => {
if(!Empty(data)){ if(!Empty(data)){
ShowSurveyModal({ title: "Edit Survey", scope: scope, callback: 'DialogReady' }); ShowSurveyModal({ title: "Edit Survey", scope: scope, callback: 'DialogReady' });
scope.survey_name = data.name; scope.survey_name = data.name;
@@ -45,7 +45,7 @@ export default
} }
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to retrieve survey. GET returned status: ' + status }); msg: 'Failed to retrieve survey. GET returned status: ' + status });
}); });

View File

@@ -81,10 +81,10 @@ export default
Rest.setUrl(GetBasePath('workflow_job_templates') + id + '/survey_spec/'); Rest.setUrl(GetBasePath('workflow_job_templates') + id + '/survey_spec/');
} }
return Rest.post({name: scope.survey_name, description: scope.survey_description, spec: scope.survey_questions }) return Rest.post({name: scope.survey_name, description: scope.survey_description, spec: scope.survey_questions })
.success(function () { .then(() => {
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to add new survey. POST returned status: ' + status }); msg: 'Failed to add new survey. POST returned status: ' + status });
}); });
@@ -98,10 +98,10 @@ export default
Rest.setUrl(GetBasePath('workflow_job_templates') + id+ '/'); Rest.setUrl(GetBasePath('workflow_job_templates') + id+ '/');
} }
return Rest.patch({"survey_enabled": scope.survey_enabled}) return Rest.patch({"survey_enabled": scope.survey_enabled})
.success(function () { .then(() => {
}) })
.error(function (data, status) { .catch(({data, status}) => {
ProcessErrors(scope, data, status, form, { ProcessErrors(scope, data, status, form, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to save survey_enabled: GET status: ' + status msg: 'Failed to save survey_enabled: GET status: ' + status

Some files were not shown because too many files have changed in this diff Show More