diff --git a/openstack_dashboard/dashboards/identity/static/dashboard/identity/domains/domains.service.js b/openstack_dashboard/dashboards/identity/static/dashboard/identity/domains/domains.service.js index 177994d142..3eb4db9c58 100644 --- a/openstack_dashboard/dashboards/identity/static/dashboard/identity/domains/domains.service.js +++ b/openstack_dashboard/dashboards/identity/static/dashboard/identity/domains/domains.service.js @@ -23,7 +23,8 @@ '$q', 'horizon.app.core.openstack-service-api.keystone', 'horizon.app.core.openstack-service-api.policy', - 'horizon.app.core.openstack-service-api.settings' + 'horizon.app.core.openstack-service-api.settings', + 'horizon.app.core.detailRoute' ]; /* @@ -36,7 +37,7 @@ * but do not need to be restricted to such use. Each exposed function * is documented below. */ - function domainService($q, keystone, policy, settingsService) { + function domainService($q, keystone, policy, settingsService, detailRoute) { return { getDetailsPath: getDetailsPath, getDomainPromise: getDomainPromise, @@ -52,7 +53,7 @@ * view. */ function getDetailsPath(item) { - return 'project/ngdetails/OS::Keystone::Domain/' + item.id; + return detailRoute + 'OS::Keystone::Domain/' + item.id; } /* diff --git a/openstack_dashboard/dashboards/identity/static/dashboard/identity/domains/domains.service.spec.js b/openstack_dashboard/dashboards/identity/static/dashboard/identity/domains/domains.service.spec.js index 4db1f12947..f4cdd573a8 100644 --- a/openstack_dashboard/dashboards/identity/static/dashboard/identity/domains/domains.service.spec.js +++ b/openstack_dashboard/dashboards/identity/static/dashboard/identity/domains/domains.service.spec.js @@ -15,15 +15,16 @@ "use strict"; describe('domain service', function() { - var service, $scope; + var service, $scope, detailRoute; beforeEach(module('horizon.dashboard.identity.domains')); beforeEach(inject(function($injector) { service = $injector.get('horizon.dashboard.identity.domains.service'); + detailRoute = $injector.get('horizon.app.core.detailRoute'); })); it("getDetailsPath creates urls using the item's ID", function() { var myItem = {id: "1234"}; - expect(service.getDetailsPath(myItem)).toBe('project/ngdetails/OS::Keystone::Domain/1234'); + expect(service.getDetailsPath(myItem)).toBe(detailRoute + 'OS::Keystone::Domain/1234'); }); describe('listDomains', function() { diff --git a/openstack_dashboard/dashboards/identity/static/dashboard/identity/users/users.service.js b/openstack_dashboard/dashboards/identity/static/dashboard/identity/users/users.service.js index df0fbf817d..34907d12d1 100644 --- a/openstack_dashboard/dashboards/identity/static/dashboard/identity/users/users.service.js +++ b/openstack_dashboard/dashboards/identity/static/dashboard/identity/users/users.service.js @@ -21,14 +21,15 @@ userService.$inject = [ '$q', - 'horizon.app.core.openstack-service-api.keystone' + 'horizon.app.core.openstack-service-api.keystone', + 'horizon.app.core.detailRoute' ]; /* * @ngdoc factory * @name horizon.dashboard.identity.users.service */ - function userService($q, keystone) { + function userService($q, keystone, detailRoute) { return { getDetailsPath: getDetailsPath, getUserPromise: getUserPromise, @@ -43,7 +44,7 @@ * Given an user object, returns the relative path to the details view. */ function getDetailsPath(item) { - return 'project/ngdetails/OS::Keystone::User/' + item.id; + return detailRoute + 'OS::Keystone::User/' + item.id; } /* diff --git a/openstack_dashboard/dashboards/identity/static/dashboard/identity/users/users.service.spec.js b/openstack_dashboard/dashboards/identity/static/dashboard/identity/users/users.service.spec.js index 8963f958a6..70749e9f90 100644 --- a/openstack_dashboard/dashboards/identity/static/dashboard/identity/users/users.service.spec.js +++ b/openstack_dashboard/dashboards/identity/static/dashboard/identity/users/users.service.spec.js @@ -17,19 +17,20 @@ "use strict"; describe('Identity user service', function() { - var service, keystone, scope, $q; + var service, keystone, scope, $q, detailRoute; beforeEach(module('horizon.dashboard.identity.users')); beforeEach(inject(function($injector, _$q_) { service = $injector.get('horizon.dashboard.identity.users.service'); keystone = $injector.get('horizon.app.core.openstack-service-api.keystone'); + detailRoute = $injector.get('horizon.app.core.detailRoute'); scope = $injector.get('$rootScope').$new(); $q = _$q_; })); it("getDetailsPath creates proper url", function() { var item = {id: 614}; - expect(service.getDetailsPath(item)).toBe('project/ngdetails/OS::Keystone::User/614'); + expect(service.getDetailsPath(item)).toBe(detailRoute + 'OS::Keystone::User/614'); }); describe('getUsersPromise', function() { diff --git a/openstack_dashboard/static/app/core/core-constants.module.js b/openstack_dashboard/static/app/core/core-constants.module.js new file mode 100644 index 0000000000..73aab2c4f3 --- /dev/null +++ b/openstack_dashboard/static/app/core/core-constants.module.js @@ -0,0 +1,32 @@ +/* + * (c) Copyright 2016 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +(function () { + 'use strict'; + + /** + * @ngdoc overview + * @name horizon.app.core.constants + * @description + * + * # horizon.app.core.constants + * + * This module hosts constants used by configuration blocks. + */ + angular + .module('horizon.app.core.constants', []) + .constant('horizon.app.core.detailRoute', 'ngdetails/'); + +})(); diff --git a/openstack_dashboard/static/app/core/core.module.js b/openstack_dashboard/static/app/core/core.module.js index eebfb5c317..867835659b 100644 --- a/openstack_dashboard/static/app/core/core.module.js +++ b/openstack_dashboard/static/app/core/core.module.js @@ -32,6 +32,7 @@ angular .module('horizon.app.core', [ 'horizon.app.core.conf', + 'horizon.app.core.constants', 'horizon.app.core.cloud-services', 'horizon.app.core.flavors', 'horizon.app.core.images', @@ -47,13 +48,19 @@ // becomes available. For now there is no volumes module. .constant('horizon.app.core.volumes.resourceType', VOLUME_RESOURCE_TYPE); - config.$inject = ['$provide', '$windowProvider', '$routeProvider']; + config.$inject = [ + '$provide', + '$windowProvider', + '$routeProvider', + 'horizon.app.core.detailRoute' + ]; - function config($provide, $windowProvider, $routeProvider) { + function config($provide, $windowProvider, $routeProvider, detailRoute) { var path = $windowProvider.$get().STATIC_URL + 'app/core/'; $provide.constant('horizon.app.core.basePath', path); + $routeProvider - .when('/project/ngdetails/:type/:path*', { + .when('/' + detailRoute + ':type/:path*', { templateUrl: $windowProvider.$get().STATIC_URL + 'framework/widgets/details/routed-details-view.html' }); diff --git a/openstack_dashboard/static/app/core/images/images.module.js b/openstack_dashboard/static/app/core/images/images.module.js index b3a91dcf91..40b5e5ced6 100644 --- a/openstack_dashboard/static/app/core/images/images.module.js +++ b/openstack_dashboard/static/app/core/images/images.module.js @@ -277,7 +277,8 @@ config.$inject = [ '$provide', '$windowProvider', - '$routeProvider' + '$routeProvider', + 'horizon.app.core.detailRoute' ]; /** @@ -288,7 +289,7 @@ * @description Routes used by this module. * @returns {undefined} Returns nothing */ - function config($provide, $windowProvider, $routeProvider) { + function config($provide, $windowProvider, $routeProvider, detailRoute) { var path = $windowProvider.$get().STATIC_URL + 'app/core/images/'; $provide.constant('horizon.app.core.images.basePath', path); @@ -309,7 +310,7 @@ }); function goToAngularDetails(params) { - return 'project/ngdetails/OS::Glance::Image/' + params.id; + return detailRoute + 'OS::Glance::Image/' + params.id; } } diff --git a/openstack_dashboard/static/app/core/images/images.service.js b/openstack_dashboard/static/app/core/images/images.service.js index 0fd30abc7b..9caf04b255 100644 --- a/openstack_dashboard/static/app/core/images/images.service.js +++ b/openstack_dashboard/static/app/core/images/images.service.js @@ -23,7 +23,8 @@ '$filter', 'horizon.app.core.openstack-service-api.glance', 'horizon.app.core.openstack-service-api.userSession', - 'horizon.app.core.images.transitional-statuses' + 'horizon.app.core.images.transitional-statuses', + 'horizon.app.core.detailRoute' ]; /* @@ -36,7 +37,7 @@ * but do not need to be restricted to such use. Each exposed function * is documented below. */ - function imageService($filter, glance, userSession, transitionalStatuses) { + function imageService($filter, glance, userSession, transitionalStatuses, detailRoute) { var version; return { @@ -56,7 +57,7 @@ * view. */ function getDetailsPath(item) { - return 'project/ngdetails/OS::Glance::Image/' + item.id; + return detailRoute + 'OS::Glance::Image/' + item.id; } /* diff --git a/openstack_dashboard/static/app/core/images/images.service.spec.js b/openstack_dashboard/static/app/core/images/images.service.spec.js index e7b9e70cc5..a537fe3c2e 100644 --- a/openstack_dashboard/static/app/core/images/images.service.spec.js +++ b/openstack_dashboard/static/app/core/images/images.service.spec.js @@ -17,15 +17,16 @@ "use strict"; describe('images service', function() { - var service; + var service, detailRoute; beforeEach(module('horizon.app.core.images')); beforeEach(inject(function($injector) { service = $injector.get('horizon.app.core.images.service'); + detailRoute = $injector.get('horizon.app.core.detailRoute'); })); it("getDetailsPath creates urls using the item's ID", function() { var myItem = {id: "1234"}; - expect(service.getDetailsPath(myItem)).toBe('project/ngdetails/OS::Glance::Image/1234'); + expect(service.getDetailsPath(myItem)).toBe(detailRoute + 'OS::Glance::Image/1234'); }); describe('imageType', function() {