diff --git a/horizon/static/horizon/js/angular/services/hz.api.cinder.js b/horizon/static/horizon/js/angular/services/hz.api.cinder.js index db232d45bb..1d9e0843c6 100644 --- a/horizon/static/horizon/js/angular/services/hz.api.cinder.js +++ b/horizon/static/horizon/js/angular/services/hz.api.cinder.js @@ -21,7 +21,7 @@ limitations under the License. * @name hz.api.cinderAPI * @description Provides direct access to Cinder APIs. */ - function CinderAPI(apiService) { + function CinderAPI(apiService, toastService) { // Volumes @@ -44,7 +44,7 @@ limitations under the License. var config = (params) ? {'params': params} : {}; return apiService.get('/api/cinder/volumes/', config) .error(function () { - horizon.alert('error', gettext('Unable to retrieve volumes.')); + toastService.add('error', gettext('Unable to retrieve volumes.')); }); }; @@ -70,7 +70,7 @@ limitations under the License. var config = (params) ? {'params': params} : {}; return apiService.get('/api/cinder/volumesnapshots/', config) .error(function () { - horizon.alert('error', + toastService.add('error', gettext('Unable to retrieve volume snapshots.')); }); }; @@ -79,5 +79,5 @@ limitations under the License. // Register it with the API module so that anybody using the // API module will have access to the Cinder APIs. angular.module('hz.api') - .service('cinderAPI', ['apiService', CinderAPI]); + .service('cinderAPI', ['apiService', 'toastService', CinderAPI]); }()); diff --git a/horizon/static/horizon/js/angular/services/hz.api.glance.js b/horizon/static/horizon/js/angular/services/hz.api.glance.js index fd0cbc2349..16d7d00264 100644 --- a/horizon/static/horizon/js/angular/services/hz.api.glance.js +++ b/horizon/static/horizon/js/angular/services/hz.api.glance.js @@ -21,7 +21,7 @@ limitations under the License. * @name hz.api.glanceAPI * @description Provides direct pass through to Glance with NO abstraction. */ - function GlanceAPI(apiService) { + function GlanceAPI(apiService, toastService) { // Images @@ -35,7 +35,7 @@ limitations under the License. this.getImage = function(id) { return apiService.get('/api/glance/images/' + id) .error(function () { - horizon.alert('error', gettext('Unable to retrieve image.')); + toastService.add('error', gettext('Unable to retrieve image.')); }); }; @@ -78,7 +78,7 @@ limitations under the License. var config = (params) ? { 'params' : params} : {}; return apiService.get('/api/glance/images/', config) .error(function () { - horizon.alert('error', gettext('Unable to retrieve images.')); + toastService.add('error', gettext('Unable to retrieve images.')); }); }; @@ -141,7 +141,7 @@ limitations under the License. var promise = apiService.get('/api/glance/metadefs/namespaces/', config); return suppressError ? promise : promise.error(function() { - horizon.alert('error', gettext('Unable to retrieve namespaces.')); + toastService.add('error', gettext('Unable to retrieve namespaces.')); }); }; @@ -151,6 +151,6 @@ limitations under the License. // API module will have access to the Glance APIs. angular.module('hz.api') - .service('glanceAPI', ['apiService', GlanceAPI]); + .service('glanceAPI', ['apiService', 'toastService', GlanceAPI]); }()); diff --git a/horizon/static/horizon/js/angular/services/hz.api.keystone.js b/horizon/static/horizon/js/angular/services/hz.api.keystone.js index be51f3ec0e..f0c7d35bd1 100644 --- a/horizon/static/horizon/js/angular/services/hz.api.keystone.js +++ b/horizon/static/horizon/js/angular/services/hz.api.keystone.js @@ -15,27 +15,27 @@ limitations under the License. */ (function () { 'use strict'; - function KeystoneAPI(apiService) { + function KeystoneAPI(apiService, toastService) { // Users this.getUsers = function(params) { var config = (params) ? {'params': params} : {}; return apiService.get('/api/keystone/users/', config) .error(function () { - horizon.alert('error', gettext('Unable to retrieve users')); + toastService.add('error', gettext('Unable to retrieve users')); }); }; this.createUser = function(newUser) { return apiService.post('/api/keystone/users/', newUser) .error(function () { - horizon.alert('error', gettext('Unable to create the user.')); + toastService.add('error', gettext('Unable to create the user.')); }); }; this.deleteUsers = function(user_ids) { return apiService.delete('/api/keystone/users/', user_ids) .error(function () { - horizon.alert('error', gettext('Unable to delete the users.')); + toastService.add('error', gettext('Unable to delete the users.')); }); }; @@ -69,7 +69,7 @@ limitations under the License. this.getCurrentUserSession = function(config) { return apiService.get('/api/keystone/user-session/', config) .error(function () { - horizon.alert('error', + toastService.add('error', gettext('Unable to retrieve the current user session.')); }); }; @@ -77,7 +77,7 @@ limitations under the License. this.getUser = function(user_id) { return apiService.get('/api/keystone/users/' + user_id) .error(function () { - horizon.alert('error', gettext('Unable to retrieve the user')); + toastService.add('error', gettext('Unable to retrieve the user')); }); }; @@ -85,14 +85,14 @@ limitations under the License. var url = '/api/keystone/users/' + updatedUser.id; return apiService.patch(url, updatedUser) .error(function () { - horizon.alert('error', gettext('Unable to edit the user.')); + toastService.add('error', gettext('Unable to edit the user.')); }); }; this.deleteUser = function(user_id) { return apiService.delete('/api/keystone/users/' + user_id) .error(function () { - horizon.alert('error', gettext('Unable to delete the user.')); + toastService.add('error', gettext('Unable to delete the user.')); }); }; @@ -100,28 +100,28 @@ limitations under the License. this.getRoles = function() { return apiService.get('/api/keystone/roles/') .error(function () { - horizon.alert('error', gettext('Unable to retrieve role')); + toastService.add('error', gettext('Unable to retrieve role')); }); }; this.createRole = function(newRole) { return apiService.post('/api/keystone/roles/', newRole) .error(function () { - horizon.alert('error', gettext('Unable to create the role.')); + toastService.add('error', gettext('Unable to create the role.')); }); }; this.deleteRoles = function(role_ids) { return apiService.delete('/api/keystone/roles/', role_ids) .error(function () { - horizon.alert('error', gettext('Unable to delete the roles.')); + toastService.add('error', gettext('Unable to delete the roles.')); }); }; this.getRole = function(role_id) { return apiService.get('/api/keystone/roles/' + role_id) .error(function () { - horizon.alert('error', gettext('Unable to retrieve the role')); + toastService.add('error', gettext('Unable to retrieve the role')); }); }; @@ -129,14 +129,14 @@ limitations under the License. var url = '/api/keystone/roles/' + updatedRole.id; return apiService.patch(url, updatedRole) .error(function () { - horizon.alert('error', gettext('Unable to edit the role.')); + toastService.add('error', gettext('Unable to edit the role.')); }); }; this.deleteRole = function(role_id) { return apiService.delete('/api/keystone/roles/' + role_id) .error(function () { - horizon.alert('error', gettext('Unable to delete the role.')); + toastService.add('error', gettext('Unable to delete the role.')); }); }; @@ -144,28 +144,28 @@ limitations under the License. this.getDomains = function() { return apiService.get('/api/keystone/domains/') .error(function () { - horizon.alert('error', gettext('Unable to retrieve domains')); + toastService.add('error', gettext('Unable to retrieve domains')); }); }; this.createDomain = function(newDomain) { return apiService.post('/api/keystone/domains/', newDomain) .error(function () { - horizon.alert('error', gettext('Unable to create the domain.')); + toastService.add('error', gettext('Unable to create the domain.')); }); }; this.deleteDomains = function(domain_ids) { return apiService.delete('/api/keystone/domains/', domain_ids) .error(function () { - horizon.alert('error', gettext('Unable to delete the domains.')); + toastService.add('error', gettext('Unable to delete the domains.')); }); }; this.getDomain = function(domain_id) { return apiService.get('/api/keystone/domains/' + domain_id) .error(function () { - horizon.alert('error', gettext('Unable to retrieve the domain')); + toastService.add('error', gettext('Unable to retrieve the domain')); }); }; @@ -173,14 +173,14 @@ limitations under the License. var url = '/api/keystone/domains/' + updatedDomain.id; return apiService.patch(url, updatedDomain) .error(function () { - horizon.alert('error', gettext('Unable to edit the domain.')); + toastService.add('error', gettext('Unable to edit the domain.')); }); }; this.deleteDomain = function(domain_id) { return apiService.delete('/api/keystone/domains/' + domain_id) .error(function () { - horizon.alert('error', gettext('Unable to delete the domain.')); + toastService.add('error', gettext('Unable to delete the domain.')); }); }; @@ -189,28 +189,28 @@ limitations under the License. var config = (params) ? {'params': params} : {}; return apiService.get('/api/keystone/projects/', config) .error(function () { - horizon.alert('error', gettext('Unable to retrieve projects')); + toastService.add('error', gettext('Unable to retrieve projects')); }); }; this.createProject = function(newProject) { return apiService.post('/api/keystone/projects/', newProject) .error(function () { - horizon.alert('error', gettext('Unable to create the project.')); + toastService.add('error', gettext('Unable to create the project.')); }); }; this.deleteProjects = function(project_ids) { return apiService.delete('/api/keystone/projects/', project_ids) .error(function () { - horizon.alert('error', gettext('Unable to delete the projects.')); + toastService.add('error', gettext('Unable to delete the projects.')); }); }; this.getProject = function(project_id) { return apiService.get('/api/keystone/projects/' + project_id) .error(function () { - horizon.alert('error', gettext('Unable to retrieve the project')); + toastService.add('error', gettext('Unable to retrieve the project')); }); }; @@ -218,14 +218,14 @@ limitations under the License. var url = '/api/keystone/projects/' + updatedProject.id; return apiService.patch(url, updatedProject) .error(function () { - horizon.alert('error', gettext('Unable to edit the project.')); + toastService.add('error', gettext('Unable to edit the project.')); }); }; this.deleteProject = function(project_id) { return apiService.delete('/api/keystone/projects/' + project_id) .error(function () { - horizon.alert('error', gettext('Unable to delete the project.')); + toastService.add('error', gettext('Unable to delete the project.')); }); }; @@ -233,7 +233,7 @@ limitations under the License. return apiService.delete('/api/keystone/projects/' + project_id + '/' + role_id + '/' + user_id) .error(function () { - horizon.alert('error', gettext('Unable to grant the role.')); + toastService.add('error', gettext('Unable to grant the role.')); }); }; @@ -247,13 +247,13 @@ limitations under the License. this.serviceCatalog = function(config) { return apiService.get('/api/keystone/svc-catalog/', config) .error(function () { - horizon.alert('error', gettext('Unable to fetch the service catalog.')); + toastService.add('error', gettext('Unable to fetch the service catalog.')); }); }; } angular.module('hz.api') - .service('keystoneAPI', ['apiService', KeystoneAPI]); + .service('keystoneAPI', ['apiService', 'toastService', KeystoneAPI]); /** * @ngdoc service diff --git a/horizon/static/horizon/js/angular/services/hz.api.neutron.js b/horizon/static/horizon/js/angular/services/hz.api.neutron.js index 5756cd9d3a..e71687ef66 100644 --- a/horizon/static/horizon/js/angular/services/hz.api.neutron.js +++ b/horizon/static/horizon/js/angular/services/hz.api.neutron.js @@ -21,7 +21,7 @@ * @name hz.api.NeutronAPI * @description Provides access to Neutron APIs. */ - function NeutronAPI(apiService) { + function NeutronAPI(apiService, toastService) { // Networks @@ -36,7 +36,7 @@ this.getNetworks = function() { return apiService.get('/api/neutron/networks/') .error(function () { - horizon.alert('error', gettext('Unable to retrieve networks.')); + toastService.add('error', gettext('Unable to retrieve networks.')); }); }; @@ -85,7 +85,7 @@ this.createNetwork = function(newNetwork) { return apiService.post('/api/neutron/networks/', newNetwork) .error(function () { - horizon.alert('error', gettext('Unable to create the network.')); + toastService.add('error', gettext('Unable to create the network.')); }); }; @@ -105,7 +105,7 @@ this.getSubnets = function(network_id) { return apiService.get('/api/neutron/subnets/', network_id) .error(function () { - horizon.alert('error', gettext('Unable to retrieve subnets.')); + toastService.add('error', gettext('Unable to retrieve subnets.')); }); }; @@ -169,7 +169,7 @@ this.createSubnet = function(newSubnet) { return apiService.post('/api/neutron/subnets/', newSubnet) .error(function () { - horizon.alert('error', gettext('Unable to create the subnet.')); + toastService.add('error', gettext('Unable to create the subnet.')); }); }; @@ -189,12 +189,12 @@ this.getPorts = function(network_id) { return apiService.get('/api/neutron/ports/', network_id) .error(function () { - horizon.alert('error', gettext('Unable to retrieve ports.')); + toastService.add('error', gettext('Unable to retrieve ports.')); }); }; } angular.module('hz.api') - .service('neutronAPI', ['apiService', NeutronAPI]); + .service('neutronAPI', ['apiService', 'toastService', NeutronAPI]); }()); diff --git a/horizon/static/horizon/js/angular/services/hz.api.nova.js b/horizon/static/horizon/js/angular/services/hz.api.nova.js index 47d9c7608d..478d1cad8d 100644 --- a/horizon/static/horizon/js/angular/services/hz.api.nova.js +++ b/horizon/static/horizon/js/angular/services/hz.api.nova.js @@ -22,7 +22,7 @@ limitations under the License. * @name hz.api.novaAPI * @description Provides access to Nova APIs. */ - function NovaAPI(apiService) { + function NovaAPI(apiService, toastService) { // Keypairs @@ -37,7 +37,7 @@ limitations under the License. this.getKeypairs = function() { return apiService.get('/api/nova/keypairs/') .error(function () { - horizon.alert('error', gettext('Unable to retrieve keypairs.')); + toastService.add('error', gettext('Unable to retrieve keypairs.')); }); }; @@ -59,9 +59,9 @@ limitations under the License. return apiService.post('/api/nova/keypairs/', newKeypair) .error(function () { if (angular.isDefined(newKeypair.public_key)) { - horizon.alert('error', gettext('Unable to import the keypair.')); + toastService.add('error', gettext('Unable to import the keypair.')); } else { - horizon.alert('error', gettext('Unable to create the keypair.')); + toastService.add('error', gettext('Unable to create the keypair.')); } }); }; @@ -79,7 +79,7 @@ limitations under the License. this.getAvailabilityZones = function() { return apiService.get('/api/nova/availzones/') .error(function () { - horizon.alert('error', + toastService.add('error', gettext('Unable to retrieve availability zones.')); }); }; @@ -118,7 +118,7 @@ limitations under the License. this.getLimits = function() { return apiService.get('/api/nova/limits/') .error(function () { - horizon.alert('error', gettext('Unable to retrieve limits.')); + toastService.add('error', gettext('Unable to retrieve limits.')); }); }; @@ -145,7 +145,7 @@ limitations under the License. this.createServer = function(newServer) { return apiService.post('/api/nova/servers/', newServer) .error(function () { - horizon.alert('error', gettext('Unable to create the server.')); + toastService.add('error', gettext('Unable to create the server.')); }); }; @@ -159,7 +159,7 @@ limitations under the License. this.getServer = function(id) { return apiService.get('/api/nova/servers/' + id) .error(function () { - horizon.alert('error', gettext('Unable to retrieve server.')); + toastService.add('error', gettext('Unable to retrieve server.')); }); }; @@ -189,7 +189,7 @@ limitations under the License. this.getExtensions = function(config) { return apiService.get('/api/nova/extensions/', config) .error(function () { - horizon.alert('error', gettext('Unable to retrieve extensions.')); + toastService.add('error', gettext('Unable to retrieve extensions.')); }); }; @@ -234,7 +234,7 @@ limitations under the License. } }) .error(function () { - horizon.alert('error', gettext('Unable to retrieve flavors.')); + toastService.add('error', gettext('Unable to retrieve flavors.')); }); }; @@ -252,7 +252,7 @@ limitations under the License. if (getExtras) { config.params.get_extras = 'true'; } return apiService.get('/api/nova/flavors/' + id, config) .error(function () { - horizon.alert('error', gettext('Unable to retrieve flavor.')); + toastService.add('error', gettext('Unable to retrieve flavor.')); }); }; @@ -266,13 +266,13 @@ limitations under the License. this.getFlavorExtraSpecs = function(id) { return apiService.get('/api/nova/flavors/' + id + '/extra-specs') .error(function () { - horizon.alert('error', gettext('Unable to retrieve flavor extra specs.')); + toastService.add('error', gettext('Unable to retrieve flavor extra specs.')); }); }; } angular.module('hz.api') - .service('novaAPI', ['apiService', NovaAPI]); + .service('novaAPI', ['apiService', 'toastService', NovaAPI]); /** * @ngdoc service diff --git a/horizon/static/horizon/js/angular/services/hz.api.policy.js b/horizon/static/horizon/js/angular/services/hz.api.policy.js index 1bb68213a8..3aed854062 100644 --- a/horizon/static/horizon/js/angular/services/hz.api.policy.js +++ b/horizon/static/horizon/js/angular/services/hz.api.policy.js @@ -20,7 +20,7 @@ limitations under the License. * @description Provides a direct pass through to the policy engine in * Horizon. */ - function PolicyService(apiService) { + function PolicyService(apiService, toastService) { /** * @name hz.api.policyAPI.check @@ -62,12 +62,11 @@ limitations under the License. this.check = function (policy_rules) { return apiService.post('/api/policy/', policy_rules) .error(function() { - horizon.alert('warning', gettext('Policy check failed.')); - horizon.autoDismissAlerts(); + toastService.add('warning', gettext('Policy check failed.')); }); }; } angular.module('hz.api') - .service('policyAPI', ['apiService', PolicyService]); + .service('policyAPI', ['apiService', 'toastService', PolicyService]); }()); diff --git a/horizon/static/horizon/js/angular/services/hz.api.security-group.js b/horizon/static/horizon/js/angular/services/hz.api.security-group.js index 62856d08d9..fe7d38746e 100644 --- a/horizon/static/horizon/js/angular/services/hz.api.security-group.js +++ b/horizon/static/horizon/js/angular/services/hz.api.security-group.js @@ -21,7 +21,7 @@ limitations under the License. * @name hz.api.SecurityGroup * @description Provides access to Security Groups */ - function SecurityGroup(apiService) { + function SecurityGroup(apiService, toastService) { /** * @name hz.api.SecurityGroup.list @@ -61,7 +61,7 @@ limitations under the License. this.query = function() { return apiService.get('/api/network/securitygroups/') .error(function () { - horizon.alert('error', gettext('Unable to retrieve security groups.')); + toastService.add('error', gettext('Unable to retrieve security groups.')); }); }; } @@ -70,6 +70,6 @@ limitations under the License. // API module will have access to the Security Group APIs. angular.module('hz.api') - .service('securityGroup', ['apiService', SecurityGroup]); + .service('securityGroup', ['apiService', 'toastService', SecurityGroup]); }()); diff --git a/openstack_dashboard/static/dashboard/launch-instance/keypair/keypair.js b/openstack_dashboard/static/dashboard/launch-instance/keypair/keypair.js index ca388eb6d1..503ac86c61 100644 --- a/openstack_dashboard/static/dashboard/launch-instance/keypair/keypair.js +++ b/openstack_dashboard/static/dashboard/launch-instance/keypair/keypair.js @@ -151,10 +151,11 @@ module.controller('LaunchInstanceCreateKeyPairCtrl', [ '$modalInstance', 'novaAPI', + 'toastService', LaunchInstanceCreateKeyPairCtrl ]); - function LaunchInstanceCreateKeyPairCtrl($modalInstance, novaAPI) { + function LaunchInstanceCreateKeyPairCtrl($modalInstance, novaAPI, toastService) { var ctrl = this; ctrl.labels = { @@ -174,7 +175,7 @@ $modalInstance.close(data); var successMsg = gettext('Successfully created key pair %(name)s'); - horizon.alert('success', interpolate(successMsg, { name: data.name }, true)); + toastService.add('success', interpolate(successMsg, { name: data.name }, true)); }); }; ctrl.cancel = function () { @@ -224,10 +225,11 @@ module.controller('LaunchInstanceImportKeyPairCtrl', [ '$modalInstance', 'novaAPI', + 'toastService', LaunchInstanceImportKeyPairCtrl ]); - function LaunchInstanceImportKeyPairCtrl($modalInstance, novaAPI) { + function LaunchInstanceImportKeyPairCtrl($modalInstance, novaAPI, toastService) { var ctrl = this; ctrl.labels = { @@ -248,7 +250,7 @@ $modalInstance.close(data); var successMsg = gettext('Successfully imported key pair %(name)s'); - horizon.alert('success', interpolate(successMsg, { name: data.name }, true)); + toastService.add('success', interpolate(successMsg, { name: data.name }, true)); }); }; ctrl.cancel = function () { diff --git a/openstack_dashboard/static/dashboard/launch-instance/keypair/keypair.spec.js b/openstack_dashboard/static/dashboard/launch-instance/keypair/keypair.spec.js index a8d5b7cdf0..79e923db52 100644 --- a/openstack_dashboard/static/dashboard/launch-instance/keypair/keypair.spec.js +++ b/openstack_dashboard/static/dashboard/launch-instance/keypair/keypair.spec.js @@ -101,6 +101,7 @@ beforeEach(module(function ($provide) { $provide.value('$modalInstance', {}); $provide.value('novaAPI', {}); + $provide.value('toastService', {}); })); beforeEach(module('hz.dashboard')); @@ -159,6 +160,7 @@ beforeEach(module(function ($provide) { $provide.value('$modalInstance', {}); $provide.value('novaAPI', {}); + $provide.value('toastService', {}); })); beforeEach(module('hz.dashboard'));