diff --git a/awx/ui/client/lib/components/truncate/truncate.directive.js b/awx/ui/client/lib/components/truncate/truncate.directive.js index a2aa6b14ab..8cc3df8bef 100644 --- a/awx/ui/client/lib/components/truncate/truncate.directive.js +++ b/awx/ui/client/lib/components/truncate/truncate.directive.js @@ -22,6 +22,16 @@ function AtTruncateController (strings) { 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 = { popover: { text: vm.strings.get('truncate.DEFAULT'), @@ -32,16 +42,6 @@ function AtTruncateController (strings) { 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']; diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index d57ffa44ee..e1667e6fb8 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -114,6 +114,9 @@ angular .constant('AngularScheduler.useTimezone', true) .constant('AngularScheduler.showUTCField', true) .constant('$timezones.definitions.location', urlPrefix + 'lib/angular-tz-extensions/tz/data') + .config(['$locationProvider', function($locationProvider) { + $locationProvider.hashPrefix(''); + }]) .config(['$logProvider', function($logProvider) { $logProvider.debugEnabled($ENV['ng-debug'] || false); }]) @@ -176,7 +179,7 @@ angular LoadConfig, Store, pendoService, Prompt, Rest, Wait, ProcessErrors, $state, GetBasePath, ConfigService, FeaturesService, $filter, SocketService, AppStrings, $transitions) { - + $rootScope.$state = $state; $rootScope.$state.matches = function(stateName) { return $state.current.name.search(stateName) > 0; diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/groups/edit/groups-edit.route.js b/awx/ui/client/src/inventories-hosts/inventories/related/groups/edit/groups-edit.route.js index 77f3f33653..0fbdd763c7 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/groups/edit/groups-edit.route.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/groups/edit/groups-edit.route.js @@ -19,7 +19,7 @@ export default { }, resolve: { 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]); }] } }; diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/edit/standard-host-edit.route.js b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/edit/standard-host-edit.route.js index 53fb28d48f..432037658f 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/edit/standard-host-edit.route.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/edit/standard-host-edit.route.js @@ -19,9 +19,7 @@ export default { }, resolve: { host: ['$stateParams', 'HostsService', function($stateParams, HostsService) { - return HostsService.get({ id: $stateParams.host_id }).then(function(res) { - return res.data.results[0]; - }); + return HostsService.get({ id: $stateParams.host_id }).then((response) => response.data.results[0]); }] } }; diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related/nested-groups/host-nested-groups.route.js b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related/nested-groups/host-nested-groups.route.js index 4600eecb63..7f3a82a493 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related/nested-groups/host-nested-groups.route.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related/nested-groups/host-nested-groups.route.js @@ -58,9 +58,7 @@ export default { ], host: ['$stateParams', 'HostsService', function($stateParams, HostsService) { if($stateParams.host_id){ - return HostsService.get({ id: $stateParams.host_id }).then(function(res) { - return res.data.results[0]; - }); + return HostsService.get({ id: $stateParams.host_id }).then((res) => res.data.results[0]); } }], inventoryData: ['InventoriesService', '$stateParams', 'host', function(InventoriesService, $stateParams, host) { diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js index 9819795f29..943acefb3a 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js @@ -322,8 +322,8 @@ export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition', } else { params.source = null; } - SourcesService.post(params).then(function(res){ - let inventory_source_id = res.data.id; + SourcesService.post(params).then((response) => { + let inventory_source_id = response.data.id; $state.go('^.edit', {inventory_source_id: inventory_source_id}, {reload: true}); }); }; diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/edit/sources-edit.route.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/edit/sources-edit.route.js index 4560a1f6ba..c73c7840b4 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/edit/sources-edit.route.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/edit/sources-edit.route.js @@ -21,13 +21,11 @@ export default { }, resolve: { 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) { return InventoriesService.inventorySourcesOptions($stateParams.inventory_id) - .then(function(res) { - return res.data; - }); + .then((response) => response.data); }] } }; diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/sources-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/sources-list.controller.js index 6561fe6fc9..0d806bb4e3 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/sources-list.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/sources-list.controller.js @@ -47,7 +47,7 @@ let path = GetBasePath('inventory') + $stateParams.inventory_id + '/inventory_sources'; qs.search(path, $state.params[`${list.iterator}_search`]) - .then(function(searchResponse) { + .then((searchResponse)=> { $scope[`${list.iterator}_dataset`] = searchResponse.data; $scope[list.name] = $scope[`${list.iterator}_dataset`].results; _.forEach($scope[list.name], buildStatusIndicators); diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/sources-list.route.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/sources-list.route.js index 3d4d99546d..c9d9882581 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/sources-list.route.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/list/sources-list.route.js @@ -40,7 +40,7 @@ export default { }, resolve: { 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', (list, qs, $stateParams, GetBasePath, $interpolate, $rootScope) => { diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/sources/sources.service.js b/awx/ui/client/src/inventories-hosts/inventories/related/sources/sources.service.js index 10ec28da54..ce3ff77c0f 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/sources/sources.service.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/sources/sources.service.js @@ -1,137 +1,137 @@ export default - ['$rootScope', 'Rest', 'GetBasePath', 'ProcessErrors', 'Wait', function($rootScope, Rest, GetBasePath, ProcessErrors, Wait){ - return { - stringifyParams: function(params){ - return _.reduce(params, (result, value, key) => { - return result + key + '=' + value + '&'; - }, ''); - }, - // cute abstractions via fn.bind() - url: function(){ - return ''; - }, - error: function(data, status) { - ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', - msg: 'Call to ' + this.url + '. GET returned: ' + status }); - }, - success: function(data){ - return data; - }, - // HTTP methods - get: function(params){ - Wait('start'); - this.url = GetBasePath('inventory_sources') + '?' + this.stringifyParams(params); - Rest.setUrl(this.url); - return Rest.get() - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) - .finally(Wait('stop')); - }, - post: function(inventory_source){ - Wait('start'); - this.url = GetBasePath('inventory_sources'); - Rest.setUrl(this.url); - return Rest.post(inventory_source) - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) - .finally(Wait('stop')); - }, - put: function(inventory_source){ - Wait('start'); - this.url = GetBasePath('inventory_sources') + inventory_source.id; - Rest.setUrl(this.url); - return Rest.put(inventory_source) - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) - .finally(Wait('stop')); - }, - delete: function(id){ - Wait('start'); - this.url = GetBasePath('inventory_sources') + id; - Rest.setUrl(this.url); - return Rest.destroy() - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) - .finally(Wait('stop')); - }, - options: function(){ - this.url = GetBasePath('inventory_sources'); - Rest.setUrl(this.url); - return Rest.options() - .then(this.then.bind(this)) - .catch(this.catch.bind(this)); - }, - getCredential: function(id){ - Wait('start'); - this.url = GetBasePath('credentials') + id; - Rest.setUrl(this.url); - return Rest.get() - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) - .finally(Wait('stop')); - }, - getInventorySource: function(params){ - Wait('start'); - this.url = GetBasePath('inventory_sources') + '?' + this.stringifyParams(params); - Rest.setUrl(this.url); - return Rest.get() - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) - .finally(Wait('stop')); - }, - putInventorySource: function(params, url){ - Wait('start'); - this.url = url; - Rest.setUrl(this.url); - return Rest.put(params) - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) - .finally(Wait('stop')); - }, - // these relationship setters could be consolidated, but verbosity makes the operation feel more clear @ controller level - associateGroup: function(group, target){ - Wait('start'); - this.url = GetBasePath('groups') + target + '/children/'; - Rest.setUrl(this.url); - return Rest.post(group) - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) - .finally(Wait('stop')); - }, - disassociateGroup: function(group, parent){ - Wait('start'); - this.url = GetBasePath('groups') + parent + '/children/'; - Rest.setUrl(this.url); - return Rest.post({id: group, disassociate: 1}) - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) - .finally(Wait('stop')); - }, - promote: function(group, inventory){ - Wait('start'); - this.url = GetBasePath('inventory') + inventory + '/groups/'; - Rest.setUrl(this.url); - return Rest.post({id: group, disassociate: 1}) - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) - .finally(Wait('stop')); - }, - encodeGroupBy(source, group_by){ - source = source && source.value ? source.value : ''; - if(source === 'ec2'){ - 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; - } +['$rootScope', 'Rest', 'GetBasePath', 'ProcessErrors', 'Wait', function($rootScope, Rest, GetBasePath, ProcessErrors, Wait){ + return { + stringifyParams: function(params){ + return _.reduce(params, (result, value, key) => { + return result + key + '=' + value + '&'; + }, ''); + }, + // cute abstractions via fn.bind() + url: function(){ + return ''; + }, + error: function(data, status) { + ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', + msg: 'Call to ' + this.url + '. GET returned: ' + status }); + }, + success: function(data){ + return data; + }, + // HTTP methods + get: function(params){ + Wait('start'); + this.url = GetBasePath('inventory_sources') + '?' + this.stringifyParams(params); + Rest.setUrl(this.url); + return Rest.get() + .then(this.success.bind(this)) + .catch(this.error.bind(this)) + .finally(Wait('stop')); + }, + post: function(inventory_source){ + Wait('start'); + this.url = GetBasePath('inventory_sources'); + Rest.setUrl(this.url); + return Rest.post(inventory_source) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) + .finally(Wait('stop')); + }, + put: function(inventory_source){ + Wait('start'); + this.url = GetBasePath('inventory_sources') + inventory_source.id; + Rest.setUrl(this.url); + return Rest.put(inventory_source) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) + .finally(Wait('stop')); + }, + delete: function(id){ + Wait('start'); + this.url = GetBasePath('inventory_sources') + id; + Rest.setUrl(this.url); + return Rest.destroy() + .then(this.success.bind(this)) + .catch(this.error.bind(this)) + .finally(Wait('stop')); + }, + options: function(){ + this.url = GetBasePath('inventory_sources'); + Rest.setUrl(this.url); + return Rest.options() + .then(this.success.bind(this)) + .catch(this.error.bind(this)); + }, + getCredential: function(id){ + Wait('start'); + this.url = GetBasePath('credentials') + id; + Rest.setUrl(this.url); + return Rest.get() + .then(this.success.bind(this)) + .catch(this.error.bind(this)) + .finally(Wait('stop')); + }, + getInventorySource: function(params){ + Wait('start'); + this.url = GetBasePath('inventory_sources') + '?' + this.stringifyParams(params); + Rest.setUrl(this.url); + return Rest.get() + .then(this.success.bind(this)) + .catch(this.error.bind(this)) + .finally(Wait('stop')); + }, + putInventorySource: function(params, url){ + Wait('start'); + this.url = url; + Rest.setUrl(this.url); + return Rest.put(params) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) + .finally(Wait('stop')); + }, + // these relationship setters could be consolidated, but verbosity makes the operation feel more clear @ controller level + associateGroup: function(group, target){ + Wait('start'); + this.url = GetBasePath('groups') + target + '/children/'; + Rest.setUrl(this.url); + return Rest.post(group) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) + .finally(Wait('stop')); + }, + disassociateGroup: function(group, parent){ + Wait('start'); + this.url = GetBasePath('groups') + parent + '/children/'; + Rest.setUrl(this.url); + return Rest.post({id: group, disassociate: 1}) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) + .finally(Wait('stop')); + }, + promote: function(group, inventory){ + Wait('start'); + this.url = GetBasePath('inventory') + inventory + '/groups/'; + Rest.setUrl(this.url); + return Rest.post({id: group, disassociate: 1}) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) + .finally(Wait('stop')); + }, + encodeGroupBy(source, group_by){ + source = source && source.value ? source.value : ''; + if(source === 'ec2'){ + 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; + } + } + }; +}]; \ No newline at end of file diff --git a/awx/ui/client/src/inventories-hosts/shared/groups.service.js b/awx/ui/client/src/inventories-hosts/shared/groups.service.js index 9ad4b0dcf6..caf31eca2f 100644 --- a/awx/ui/client/src/inventories-hosts/shared/groups.service.js +++ b/awx/ui/client/src/inventories-hosts/shared/groups.service.js @@ -23,8 +23,8 @@ export default this.url = GetBasePath('groups') + '?' + this.stringifyParams(params); Rest.setUrl(this.url); return Rest.get() - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); }, post: function(group){ @@ -32,8 +32,8 @@ export default this.url = GetBasePath('groups'); Rest.setUrl(this.url); return Rest.post(group) - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); }, put: function(group){ @@ -41,8 +41,8 @@ export default this.url = GetBasePath('groups') + group.id; Rest.setUrl(this.url); return Rest.put(group) - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); }, delete: function(id){ @@ -50,8 +50,8 @@ export default this.url = GetBasePath('groups') + id; Rest.setUrl(this.url); return Rest.destroy() - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); }, getCredential: function(id){ @@ -59,8 +59,8 @@ export default this.url = GetBasePath('credentials') + id; Rest.setUrl(this.url); return Rest.get() - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); }, getInventorySource: function(params){ @@ -68,8 +68,8 @@ export default this.url = GetBasePath('inventory_sources') + '?' + this.stringifyParams(params); Rest.setUrl(this.url); return Rest.get() - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); }, putInventorySource: function(params, url){ @@ -77,8 +77,8 @@ export default this.url = url; Rest.setUrl(this.url); return Rest.put(params) - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); }, // 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/'; Rest.setUrl(this.url); return Rest.post(group) - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); }, disassociateGroup: function(group, parent){ @@ -96,8 +96,8 @@ export default this.url = GetBasePath('groups') + parent + '/children/'; Rest.setUrl(this.url); return Rest.post({id: group, disassociate: 1}) - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); }, associateHost: function(host, target){ @@ -105,8 +105,8 @@ export default this.url = GetBasePath('groups') + target + '/hosts/'; Rest.setUrl(this.url); return Rest.post(host) - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); }, disassociateHost: function(host, group){ @@ -114,8 +114,8 @@ export default this.url = GetBasePath('groups') + group + '/hosts/'; Rest.setUrl(this.url); return Rest.post({id: host, disassociate: 1}) - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); }, promote: function(group, inventory){ @@ -123,8 +123,8 @@ export default this.url = GetBasePath('inventory') + inventory + '/groups/'; Rest.setUrl(this.url); return Rest.post({id: group, disassociate: 1}) - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); } }; diff --git a/awx/ui/client/src/inventories-hosts/shared/hosts.service.js b/awx/ui/client/src/inventories-hosts/shared/hosts.service.js index 38d5047fdb..9f074d2628 100644 --- a/awx/ui/client/src/inventories-hosts/shared/hosts.service.js +++ b/awx/ui/client/src/inventories-hosts/shared/hosts.service.js @@ -30,8 +30,8 @@ this.url = GetBasePath('hosts') + '?' + this.stringifyParams(params); Rest.setUrl(this.url); return Rest.get() - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); }, post: function(host){ @@ -39,8 +39,8 @@ this.url = GetBasePath('hosts'); Rest.setUrl(this.url); return Rest.post(host) - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); }, put: function(host){ @@ -48,8 +48,8 @@ this.url = GetBasePath('hosts') + host.id; Rest.setUrl(this.url); return Rest.put(host) - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); }, delete: function(id){ @@ -57,8 +57,8 @@ this.url = GetBasePath('hosts') + id; Rest.setUrl(this.url); return Rest.destroy() - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); } }; diff --git a/awx/ui/client/src/inventories-hosts/shared/inventories.service.js b/awx/ui/client/src/inventories-hosts/shared/inventories.service.js index 8b85be3ea2..3cd069c4c2 100644 --- a/awx/ui/client/src/inventories-hosts/shared/inventories.service.js +++ b/awx/ui/client/src/inventories-hosts/shared/inventories.service.js @@ -25,8 +25,8 @@ this.url = GetBasePath('inventory') + id; Rest.setUrl(this.url); return Rest.get() - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); }, getBreadcrumbs: function(groups){ @@ -36,8 +36,8 @@ }).join(''); Rest.setUrl(this.url); return Rest.get() - .then(this.then.bind(this)) - .catch(this.catch.bind(this)) + .then(this.success.bind(this)) + .catch(this.error.bind(this)) .finally(Wait('stop')); }, rootHostsUrl: function(id){ @@ -60,22 +60,22 @@ this.url = GetBasePath('inventory') + inventoryId + '/inventory_sources'; Rest.setUrl(this.url); return Rest.options() - .then(this.then.bind(this)) - .catch(this.catch.bind(this)); + .then(this.success.bind(this)) + .catch(this.error.bind(this)); }, updateInventorySourcesGet: function(inventoryId) { this.url = GetBasePath('inventory') + inventoryId + '/update_inventory_sources'; Rest.setUrl(this.url); return Rest.get() - .then(this.then.bind(this)) - .catch(this.catch.bind(this)); + .then(this.success.bind(this)) + .catch(this.error.bind(this)); }, getHost: function(inventoryId, hostId) { this.url = GetBasePath('inventory') + inventoryId + '/hosts?id=' + hostId; Rest.setUrl(this.url); return Rest.get() - .then(this.then.bind(this)) - .catch(this.catch.bind(this)); + .then(this.success.bind(this)) + .catch(this.error.bind(this)); } }; }]; diff --git a/awx/ui/client/src/job-results/host-event/host-event.route.js b/awx/ui/client/src/job-results/host-event/host-event.route.js index bb456bad6c..e0a32ad7e4 100644 --- a/awx/ui/client/src/job-results/host-event/host-event.route.js +++ b/awx/ui/client/src/job-results/host-event/host-event.route.js @@ -19,8 +19,7 @@ var hostEventModal = { hostEvent: ['jobResultsService', '$stateParams', function(jobResultsService, $stateParams) { return jobResultsService.getRelatedJobEvents($stateParams.id, { id: $stateParams.eventId - }).then(function(res) { - return res.data.results[0]; }); + }).then((response) => response.data.results[0]); }] }, onExit: function() { diff --git a/awx/ui/client/src/job-results/job-results.service.js b/awx/ui/client/src/job-results/job-results.service.js index 53bc34a9ae..8846620f73 100644 --- a/awx/ui/client/src/job-results/job-results.service.js +++ b/awx/ui/client/src/job-results/job-results.service.js @@ -239,8 +239,8 @@ function ($q, Prompt, $filter, Wait, Rest, $state, ProcessErrors, InitiatePlaybo url = url + id + '/job_events/?' + this.stringifyParams(params); Rest.setUrl(url); return Rest.get() - .then(({data}) => { - return data; + .then((response) => { + return response; }) .catch(({data, status}) => { ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', diff --git a/awx/ui/client/src/job-submission/job-submission.controller.js b/awx/ui/client/src/job-submission/job-submission.controller.js index f273012bfe..f79a927539 100644 --- a/awx/ui/client/src/job-submission/job-submission.controller.js +++ b/awx/ui/client/src/job-submission/job-submission.controller.js @@ -179,26 +179,26 @@ export default if ($scope.has_other_prompts) { Rest.options() - .success(options => { + .then(options => { 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 initialChoice = getChoiceFromValue(choices, initialValue); $scope.other_prompt_data.job_type_options = choices; $scope.other_prompt_data.job_type = initialChoice; } 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 initialChoice = getChoiceFromValue(choices, initialValue); $scope.other_prompt_data.verbosity_options = choices; $scope.other_prompt_data.verbosity = initialChoice; } }) - .error((err, status) => { - ProcessErrors($scope, err, status, null, { + .catch((error) => { + ProcessErrors($scope, error.data, error.status, null, { 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 Rest.setUrl(GetBasePath('credential_types')); Rest.get() - .success(function (credentialTypeData) { + .then( (response) => { + let credentialTypeData = response.data; let credential_types = {}; $scope.credentialTypeOptions = []; credentialTypeData.results.forEach((credentialType => { @@ -273,6 +274,9 @@ export default } })); $scope.credential_types = credential_types; + }) + .catch( (error) => { + console.log(error); }); // Figure out which step the user needs to start on @@ -296,7 +300,8 @@ export default // Go out and get some of the job details like inv, cred, name Rest.setUrl(GetBasePath('jobs') + $scope.submitJobId); Rest.get() - .success(function (jobResultData) { + .then( (response) => { + let jobResultData = response.data; $scope.job_template_data = { name: jobResultData.name }; diff --git a/awx/ui/client/src/license/checkLicense.factory.js b/awx/ui/client/src/license/checkLicense.factory.js index 8fcd2bbd2e..04a658fa82 100644 --- a/awx/ui/client/src/license/checkLicense.factory.js +++ b/awx/ui/client/src/license/checkLicense.factory.js @@ -21,8 +21,8 @@ export default var data = license; data.eula_accepted = eula; return Rest.post(JSON.stringify(data)) - .success(function(res){ - return res; + .then((response) =>{ + return response.data; }) .catch(({res, status}) => { ProcessErrors($rootScope, res, status, null, {hdr: 'Error!', diff --git a/awx/ui/client/src/notifications/notification-templates-list/list.controller.js b/awx/ui/client/src/notifications/notification-templates-list/list.controller.js index 3208c1bc22..599e17bb67 100644 --- a/awx/ui/client/src/notifications/notification-templates-list/list.controller.js +++ b/awx/ui/client/src/notifications/notification-templates-list/list.controller.js @@ -141,7 +141,10 @@ }); } - }); + }) + .catch( (error) => { + console.log(error); + }) }, 5000); } }; diff --git a/awx/ui/client/src/notifications/shared/notification-list-init.factory.js b/awx/ui/client/src/notifications/shared/notification-list-init.factory.js index 195fb2033c..65c65ce1ee 100644 --- a/awx/ui/client/src/notifications/shared/notification-list-init.factory.js +++ b/awx/ui/client/src/notifications/shared/notification-list-init.factory.js @@ -71,10 +71,10 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices', var notifier_url = url + id + column; Rest.setUrl(notifier_url); Rest.get() - .success( function(data, i, j, obj) { - var type = (obj.url.indexOf('success')>0) ? "notification_templates_success" : "notification_templates_error"; - if (data.results) { - _.forEach(data.results, function(result){ + .then(function(response) { + var type = (url.indexOf('success')>0) ? "notification_templates_success" : "notification_templates_error"; + if (response.data.results) { + _.forEach(response.data.results, function(result){ _.forEach(scope.notifications, function(notification){ if(notification.id === result.id){ notification[type] = true; diff --git a/awx/ui/client/src/organizations/linkout/controllers/organizations-job-templates.controller.js b/awx/ui/client/src/organizations/linkout/controllers/organizations-job-templates.controller.js index 2854855211..8673874890 100644 --- a/awx/ui/client/src/organizations/linkout/controllers/organizations-job-templates.controller.js +++ b/awx/ui/client/src/organizations/linkout/controllers/organizations-job-templates.controller.js @@ -84,17 +84,17 @@ export default ['$scope', '$rootScope', $scope.copyTemplate = function(id) { Wait('start'); TemplateCopyService.get(id) - .success(function(res){ - TemplateCopyService.set(res) - .success(function(res){ - Wait('stop'); - if(res.type && res.type === 'job_template') { - $state.go('templates.editJobTemplate', {job_template_id: res.id}, {reload: true}); - } - }); + .then((data) => { + TemplateCopyService.set(data.results) + .then((results) => { + Wait('stop'); + if(results.type && results.type === 'job_template') { + $state.go('templates.editJobTemplate', {job_template_id: results.id}, {reload: true}); + } + }); }) - .catch(({res, status}) => { - ProcessErrors($rootScope, res, status, null, {hdr: 'Error!', + .catch(({data, status}) => { + ProcessErrors($rootScope, data, status, null, {hdr: 'Error!', msg: 'Call failed. Return status: '+ status}); }); diff --git a/awx/ui/client/src/scheduler/main.js b/awx/ui/client/src/scheduler/main.js index 3c72575373..735dd3b804 100644 --- a/awx/ui/client/src/scheduler/main.js +++ b/awx/ui/client/src/scheduler/main.js @@ -61,7 +61,7 @@ export default ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){ let path = `${GetBasePath('job_templates')}${$stateParams.id}`; Rest.setUrl(path); - return Rest.get(path).then((res) => res.data); + return Rest.get(path).then(response => response.data) }], UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q', function(Rest, GetBasePath, $stateParams, $q) { @@ -152,7 +152,7 @@ export default ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){ let path = `${GetBasePath('workflow_job_templates')}${$stateParams.id}`; Rest.setUrl(path); - return Rest.get(path).then((res) => res.data); + return Rest.get(path).then(response => response.data) }], UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q', function(Rest, GetBasePath, $stateParams, $q) { @@ -242,7 +242,7 @@ export default ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){ let path = `${GetBasePath('projects')}${$stateParams.id}`; Rest.setUrl(path); - return Rest.get(path).then((res) => res.data); + return Rest.get(path).then(response => response.data) }], UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q', function(Rest, GetBasePath, $stateParams, $q) { diff --git a/awx/ui/client/src/scheduler/schedulerAdd.controller.js b/awx/ui/client/src/scheduler/schedulerAdd.controller.js index 91dde4352a..9485315078 100644 --- a/awx/ui/client/src/scheduler/schedulerAdd.controller.js +++ b/awx/ui/client/src/scheduler/schedulerAdd.controller.js @@ -27,7 +27,7 @@ export default ['$filter', '$state', '$stateParams', 'AddSchedule', 'Wait', /* * This is a workaround for the angular-scheduler library inserting `ll` into fields after an - * invalid entry and never unsetting them. Presumably null is being truncated down to 2 chars + * invalid entry and never unsetting them. Presumably null is being truncated down to 2 chars * in that case. * * Because this same problem exists in the edit mode and because there's no inheritence, this diff --git a/awx/ui/client/src/shared/rbacUiControl.js b/awx/ui/client/src/shared/rbacUiControl.js index 84d053c5b6..2085f9cde9 100644 --- a/awx/ui/client/src/shared/rbacUiControl.js +++ b/awx/ui/client/src/shared/rbacUiControl.js @@ -22,8 +22,7 @@ export default if (data.actions.POST) { canAddVal.resolve({canAdd: true, options: data}); } else { - canAddVal.reject(false); - } + canAddVal.resolve({canAdd: false}) } Wait("stop"); }); diff --git a/awx/ui/client/src/shared/socket/socket.service.js b/awx/ui/client/src/shared/socket/socket.service.js index f520fbcbe9..3b7a60e9ab 100644 --- a/awx/ui/client/src/shared/socket/socket.service.js +++ b/awx/ui/client/src/shared/socket/socket.service.js @@ -34,6 +34,7 @@ export default self.socket.onopen = function () { $log.debug("Websocket connection opened. Socket readyState: " + self.socket.readyState); socketPromise.resolve(); + console.log('promise resolved, and readyState: '+ self.readyState); self.checkStatus(); if(needsResubscribing){ self.subscribe(self.getLast()); @@ -116,6 +117,7 @@ export default if(this.socket){ this.socket.close(); delete this.socket; + console.log("Socket deleted: "+this.socket); } }, subscribe: function(state){ diff --git a/awx/ui/client/src/templates/copy-template/template-copy.service.js b/awx/ui/client/src/templates/copy-template/template-copy.service.js index 8282facadc..d4ac1e8adf 100644 --- a/awx/ui/client/src/templates/copy-template/template-copy.service.js +++ b/awx/ui/client/src/templates/copy-template/template-copy.service.js @@ -12,11 +12,9 @@ var defaultUrl = GetBasePath('job_templates') + '?id=' + id; Rest.setUrl(defaultUrl); return Rest.get() - .success(function(res){ - return res; - }) - .catch(({res, status}) => { - ProcessErrors($rootScope, res, status, null, {hdr: 'Error!', + .then(response => response) + .catch((error) => { + ProcessErrors($rootScope, error.response, error.status, null, {hdr: 'Error!', msg: 'Call to '+ defaultUrl + ' failed. Return status: '+ status}); }); }, @@ -25,25 +23,25 @@ return Rest.get(); }, 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); - return Rest.post(data); + return Rest.post(response.data); }); }, - set: function(data){ + set: function(results){ var defaultUrl = GetBasePath('job_templates'); var self = this; Rest.setUrl(defaultUrl); - var name = this.buildName(data.results[0].name); - data.results[0].name = name + ' @ ' + moment().format('h:mm:ss a'); // 2:49:11 pm - return Rest.post(data.results[0]) - .success(function(job_template_res){ + var name = this.buildName(results[0].name); + results[0].name = name + ' @ ' + moment().format('h:mm:ss a'); // 2:49:11 pm + return Rest.post(results[0]) + .then((response) => { // also copy any associated survey_spec - if (data.results[0].summary_fields.survey){ - return self.copySurvey(data.results[0], job_template_res).success( () => job_template_res); + if (results[0].summary_fields.survey){ + return self.copySurvey(results[0], response.data).then( () => response.data); } - else{ - return job_template_res; + else { + return response.data; } }) .catch(({res, status}) => { diff --git a/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js b/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js index 441cc5ce68..9f639b2172 100644 --- a/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js +++ b/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js @@ -98,7 +98,8 @@ export default jobTemplateLoadFinished(); } }) - .error(function (ret,status_code) { + .catch( (error) => { + console.log(error); if (status_code === 403) { /* user doesn't have access to see the project, no big deal. */ $scope.disablePlaybookBecausePermissionDenied = true; @@ -142,7 +143,10 @@ export default $q.all(promises) .then(function(){ Wait('stop'); - }); + }) + .catch( (error) => { + console.log(error); + }) } } }); @@ -423,7 +427,6 @@ export default $scope.$emit('jobTemplateLoaded', master); }); - } }); diff --git a/awx/ui/client/src/templates/list/templates-list.controller.js b/awx/ui/client/src/templates/list/templates-list.controller.js index f9fefeb2b2..cce220f91c 100644 --- a/awx/ui/client/src/templates/list/templates-list.controller.js +++ b/awx/ui/client/src/templates/list/templates-list.controller.js @@ -202,17 +202,21 @@ export default ['$scope', '$rootScope', if(template.type && template.type === 'job_template') { Wait('start'); TemplateCopyService.get(template.id) - .success(function(res){ - TemplateCopyService.set(res) - .success(function(res){ + .then(function(response){ + TemplateCopyService.set(response.data.results) + .then(function(results){ Wait('stop'); - if(res.type && res.type === 'job_template') { - $state.go('templates.editJobTemplate', {job_template_id: res.id}, {reload: true}); + if(results.type && results.type === 'job_template') { + $state.go('templates.editJobTemplate', {job_template_id: results.id}, {reload: true}); } - }); - }) - .catch(({res, status}) => { - ProcessErrors($rootScope, res, status, null, {hdr: 'Error!', + }) + .catch((error)=> { + console.log(error); + }) + }) + .catch((error) => { + console.log(error); + ProcessErrors($rootScope, error, status, null, {hdr: 'Error!', msg: 'Call failed. Return status: '+ status}); }); } diff --git a/awx/ui/npm-debug.log.1254872885 b/awx/ui/npm-debug.log.1254872885 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/awx/ui/npm-debug.log.3063400582 b/awx/ui/npm-debug.log.3063400582 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/awx/ui/package.json b/awx/ui/package.json index 4525ecea47..955c855c1c 100644 --- a/awx/ui/package.json +++ b/awx/ui/package.json @@ -32,7 +32,7 @@ "production": "webpack --config build/webpack.production.js" }, "devDependencies": { - "angular-mocks": "~1.4.14", + "angular-mocks": "~1.6.6", "axios": "^0.16.2", "babel-core": "^6.26.0", "babel-istanbul": "^0.12.2", @@ -95,14 +95,13 @@ "angular": "~1.6.6", "angular-breadcrumb": "git+https://git@github.com/ansible/angular-breadcrumb#0.4.1", "angular-codemirror": "git+https://git@github.com/ansible/angular-codemirror#1.0.4", - "angular-cookies": "~1.4.14", + "angular-cookies": "~1.6.6", "angular-drag-and-drop-lists": "git+https://git@github.com/ansible/angular-drag-and-drop-lists#1.4.0", "angular-duration-format": "^1.0.1", "angular-gettext": "^2.3.5", "angular-md5": "^0.1.8", "angular-moment": "^0.10.1", - "angular-resource": "~1.4.14", - "angular-sanitize": "~1.4.14", + "angular-sanitize": "~1.6.6", "angular-scheduler": "git+https://git@github.com/ansible/angular-scheduler#0.1.1", "angular-tz-extensions": "git+https://git@github.com/ansible/angular-tz-extensions#0.3.13", "babel-polyfill": "^6.26.0", diff --git a/npm-debug.log.1381475670 b/npm-debug.log.1381475670 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/npm-debug.log.2251662136 b/npm-debug.log.2251662136 new file mode 100644 index 0000000000..e69de29bb2