Fix any unhandled rejections

This commit is contained in:
Marliana Lara
2017-10-12 09:33:57 -04:00
parent b544922da1
commit cee81e9df6
32 changed files with 279 additions and 270 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

@@ -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);
}]) }])
@@ -176,7 +179,7 @@ angular
LoadConfig, Store, pendoService, Prompt, Rest, Wait, LoadConfig, Store, pendoService, Prompt, Rest, Wait,
ProcessErrors, $state, GetBasePath, ConfigService, FeaturesService, ProcessErrors, $state, GetBasePath, ConfigService, FeaturesService,
$filter, SocketService, AppStrings, $transitions) { $filter, SocketService, AppStrings, $transitions) {
$rootScope.$state = $state; $rootScope.$state = $state;
$rootScope.$state.matches = function(stateName) { $rootScope.$state.matches = function(stateName) {
return $state.current.name.search(stateName) > 0; return $state.current.name.search(stateName) > 0;

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

@@ -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

@@ -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

@@ -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

@@ -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()
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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)
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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)
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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()
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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()
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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()
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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()
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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)
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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)
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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})
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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})
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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

@@ -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()
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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)
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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)
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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()
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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()
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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()
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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)
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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)
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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})
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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)
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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})
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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})
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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()
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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)
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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)
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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()
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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()
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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()
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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()
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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()
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.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()
.then(this.then.bind(this)) .then(this.success.bind(this))
.catch(this.catch.bind(this)); .catch(this.error.bind(this));
} }
}; };
}]; }];

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

@@ -239,8 +239,8 @@ 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()
.then(({data}) => { .then((response) => {
return data; return response;
}) })
.catch(({data, status}) => { .catch(({data, status}) => {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',

View File

@@ -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,9 @@ export default
} }
})); }));
$scope.credential_types = credential_types; $scope.credential_types = credential_types;
})
.catch( (error) => {
console.log(error);
}); });
// Figure out which step the user needs to start on // 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 // 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
}; };

View File

@@ -21,8 +21,8 @@ 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;
}) })
.catch(({res, status}) => { .catch(({res, status}) => {
ProcessErrors($rootScope, res, status, null, {hdr: 'Error!', ProcessErrors($rootScope, res, status, null, {hdr: 'Error!',

View File

@@ -141,7 +141,10 @@
}); });
} }
}); })
.catch( (error) => {
console.log(error);
})
}, 5000); }, 5000);
} }
}; };

View File

@@ -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;

View File

@@ -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});
} }
}); });
}) })
.catch(({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

@@ -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

@@ -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 * 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. * in that case.
* *
* Because this same problem exists in the edit mode and because there's no inheritence, this * Because this same problem exists in the edit mode and because there's no inheritence, this

View File

@@ -22,8 +22,7 @@ export default
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

@@ -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!',
.catch(({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,25 +23,25 @@
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;
} }
}) })
.catch(({res, status}) => { .catch(({res, status}) => {

View File

@@ -98,7 +98,8 @@ export default
jobTemplateLoadFinished(); jobTemplateLoadFinished();
} }
}) })
.error(function (ret,status_code) { .catch( (error) => {
console.log(error);
if (status_code === 403) { if (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;
@@ -142,7 +143,10 @@ export default
$q.all(promises) $q.all(promises)
.then(function(){ .then(function(){
Wait('stop'); Wait('stop');
}); })
.catch( (error) => {
console.log(error);
})
} }
} }
}); });
@@ -423,7 +427,6 @@ export default
$scope.$emit('jobTemplateLoaded', master); $scope.$emit('jobTemplateLoaded', master);
}); });
} }
}); });

View File

@@ -202,17 +202,21 @@ 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((error)=> {
.catch(({res, status}) => { console.log(error);
ProcessErrors($rootScope, res, status, null, {hdr: 'Error!', })
})
.catch((error) => {
console.log(error);
ProcessErrors($rootScope, error, status, null, {hdr: 'Error!',
msg: 'Call failed. Return status: '+ status}); msg: 'Call failed. Return status: '+ status});
}); });
} }

View File

View File

View File

@@ -32,7 +32,7 @@
"production": "webpack --config build/webpack.production.js" "production": "webpack --config build/webpack.production.js"
}, },
"devDependencies": { "devDependencies": {
"angular-mocks": "~1.4.14", "angular-mocks": "~1.6.6",
"axios": "^0.16.2", "axios": "^0.16.2",
"babel-core": "^6.26.0", "babel-core": "^6.26.0",
"babel-istanbul": "^0.12.2", "babel-istanbul": "^0.12.2",
@@ -95,14 +95,13 @@
"angular": "~1.6.6", "angular": "~1.6.6",
"angular-breadcrumb": "git+https://git@github.com/ansible/angular-breadcrumb#0.4.1", "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-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-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-duration-format": "^1.0.1",
"angular-gettext": "^2.3.5", "angular-gettext": "^2.3.5",
"angular-md5": "^0.1.8", "angular-md5": "^0.1.8",
"angular-moment": "^0.10.1", "angular-moment": "^0.10.1",
"angular-resource": "~1.4.14", "angular-sanitize": "~1.6.6",
"angular-sanitize": "~1.4.14",
"angular-scheduler": "git+https://git@github.com/ansible/angular-scheduler#0.1.1", "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", "angular-tz-extensions": "git+https://git@github.com/ansible/angular-tz-extensions#0.3.13",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",

0
npm-debug.log.1381475670 Normal file
View File

0
npm-debug.log.2251662136 Normal file
View File