diff --git a/horizon/static/angular/widget.module.js b/horizon/static/angular/widget.module.js index 9b501639d7..a403d077f4 100644 --- a/horizon/static/angular/widget.module.js +++ b/horizon/static/angular/widget.module.js @@ -1,22 +1,28 @@ (function () { - 'use strict'; + 'use strict'; - angular.module('hz.widgets', [ - 'hz.widget.form', - 'hz.widget.help-panel', - 'hz.widget.wizard', - 'hz.widget.table', - 'hz.widget.modal', - 'hz.widget.modal-wait-spinner', - 'hz.framework.bind-scope', - 'hz.framework.workflow', - 'hz.widget.transfer-table', - 'hz.widget.charts', - 'hz.widget.action-list', - 'hz.widget.metadata-tree', - 'hz.widget.metadata-display', - 'hz.framework.validators' - ]) - .constant('basePath', '/static/angular/'); + angular + .module('hz.widgets', [ + 'hz.widget.form', + 'hz.widget.help-panel', + 'hz.widget.wizard', + 'hz.widget.table', + 'hz.widget.modal', + 'hz.widget.modal-wait-spinner', + 'hz.framework.bind-scope', + 'hz.framework.workflow', + 'hz.widget.transfer-table', + 'hz.widget.charts', + 'hz.widget.action-list', + 'hz.widget.metadata-tree', + 'hz.widget.metadata-display', + 'hz.framework.validators' + ]) + .config(config); + + function config($provide, $windowProvider) { + var path = $windowProvider.$get().STATIC_URL + 'angular/'; + $provide.constant('basePath', path); + } })(); diff --git a/horizon/static/horizon/js/angular/services/hz.api.service.js b/horizon/static/horizon/js/angular/services/hz.api.service.js index b3fb47369d..99af477e98 100644 --- a/horizon/static/horizon/js/angular/services/hz.api.service.js +++ b/horizon/static/horizon/js/angular/services/hz.api.service.js @@ -16,7 +16,7 @@ limitations under the License. /*global angular*/ (function () { 'use strict'; - function ApiService($http, $log) { + function ApiService($http, $log, webroot) { var httpCall = function (method, url, data, config) { if (!angular.isDefined(config)) { @@ -24,7 +24,7 @@ limitations under the License. } // url and method are always provided config.method = method; - config.url = url; + config.url = webroot + url; if (angular.isDefined(data)) { config.data = data; } @@ -56,5 +56,10 @@ limitations under the License. } angular.module('hz.api.service', []) - .service('apiService', ['$http', '$log', ApiService]); + .config(config) + .service('apiService', ['$http', '$log', 'webroot', ApiService]); + + function config($provide, $windowProvider) { + $provide.constant('webroot', $windowProvider.$get().WEBROOT); + } }()); diff --git a/horizon/static/horizon/js/horizon.heattop.js b/horizon/static/horizon/js/horizon.heattop.js index e7fcfe11c5..b33915cf51 100644 --- a/horizon/static/horizon/js/horizon.heattop.js +++ b/horizon/static/horizon/js/horizon.heattop.js @@ -247,7 +247,7 @@ if ($(container).length){ var width = $(container).width(), height = 500, stack_id = $("#stack_id").data("stack_id"), - ajax_url = '/project/stacks/get_d3_data/' + stack_id + '/', + ajax_url = WEBROOT + 'project/stacks/get_d3_data/' + stack_id + '/', graph = $("#d3_data").data("d3_data"), force = d3.layout.force() .nodes(graph.nodes) diff --git a/horizon/templates/horizon/_scripts.html b/horizon/templates/horizon/_scripts.html index 363f9ac468..fe91e9eabc 100644 --- a/horizon/templates/horizon/_scripts.html +++ b/horizon/templates/horizon/_scripts.html @@ -9,7 +9,10 @@ {% comment %} Compress jQuery, Angular, Plugins, Bootstrap, Hogan.js and Horizon-specific JS. {% endcomment %} {% compress js %} - + diff --git a/openstack_dashboard/context_processors.py b/openstack_dashboard/context_processors.py index d58fc360db..cb0dc04e82 100644 --- a/openstack_dashboard/context_processors.py +++ b/openstack_dashboard/context_processors.py @@ -53,4 +53,7 @@ def openstack(request): region in available_regions]} context['regions'] = regions + # Adding webroot access + context['WEBROOT'] = getattr(settings, "WEBROOT", "/") + return context diff --git a/openstack_dashboard/dashboards/project/images/images/tables.py b/openstack_dashboard/dashboards/project/images/images/tables.py index 53742e6364..6cfd7b4ec3 100644 --- a/openstack_dashboard/dashboards/project/images/images/tables.py +++ b/openstack_dashboard/dashboards/project/images/images/tables.py @@ -60,22 +60,20 @@ class LaunchImage(tables.LinkAction): class LaunchImageNG(LaunchImage): name = "launch_image_ng" verbose_name = _("Launch") + url = "horizon:project:images:index" classes = ("btn-launch") ajax = False - def __init__(self, - attrs={ - "ng-controller": "LaunchInstanceModalCtrl" - }, - **kwargs): + def __init__(self, attrs=None, **kwargs): kwargs['preempt'] = True super(LaunchImage, self).__init__(attrs, **kwargs) def get_link_url(self, datum): imageId = self.table.get_object_id(datum) - clickValue = "openLaunchInstanceWizard({successUrl: " +\ - "'/project/images/', imageId: '%s'})" % (imageId) - self.attrs['ng-click'] = clickValue + url = reverse(self.url) + ngclick = "openLaunchInstanceWizard({successUrl: '%s', imageId: '%s'})" + self.attrs.update({"ng-controller": "LaunchInstanceModalCtrl", + "ng-click": ngclick % (url, imageId)}) return "javascript:void(0);" diff --git a/openstack_dashboard/dashboards/project/instances/tables.py b/openstack_dashboard/dashboards/project/instances/tables.py index e82b38bbf1..1a221bffa5 100644 --- a/openstack_dashboard/dashboards/project/instances/tables.py +++ b/openstack_dashboard/dashboards/project/instances/tables.py @@ -349,19 +349,17 @@ class LaunchLink(tables.LinkAction): class LaunchLinkNG(LaunchLink): name = "launch-ng" + url = "horizon:project:instances:index" verbose_name = _("Launch Instance NG") ajax = False classes = ("btn-launch") - def __init__(self, - attrs={ - "ng-controller": "LaunchInstanceModalCtrl", - "ng-click": "openLaunchInstanceWizard(" + - "{successUrl: '/project/instances/'})" - }, - **kwargs): - kwargs['preempt'] = True - super(LaunchLink, self).__init__(attrs, **kwargs) + def get_default_attrs(self): + url = urlresolvers.reverse(self.url) + ngclick = "openLaunchInstanceWizard({ successUrl: '%s' })" % url + self.attrs.update({'ng-controller': 'LaunchInstanceModalCtrl', + 'ng-click': ngclick}) + return super(LaunchLinkNG, self).get_default_attrs() def get_link_url(self, datum=None): return "javascript:void(0);" diff --git a/openstack_dashboard/dashboards/project/network_topology/templates/network_topology/index.html b/openstack_dashboard/dashboards/project/network_topology/templates/network_topology/index.html index efcc228cb0..9ffa137351 100644 --- a/openstack_dashboard/dashboards/project/network_topology/templates/network_topology/index.html +++ b/openstack_dashboard/dashboards/project/network_topology/templates/network_topology/index.html @@ -29,7 +29,8 @@
{% if launch_instance_allowed %} {% if show_ng_launch %} - {% if instance_quota_exceeded %}{% trans "Launch Instance (Quota exceeded)"%}{% else %}{% trans "Launch Instance"%}{% endif %} + {% url 'horizon:project:network_topology:index' as networkUrl %} + {% if instance_quota_exceeded %}{% trans "Launch Instance (Quota exceeded)"%}{% else %}{% trans "Launch Instance"%}{% endif %} {% endif %} {% if instance_quota_exceeded %}{% trans "Launch Instance (Quota exceeded)"%}{% else %}{% trans "Launch Instance"%}{% endif %} {% endif %} diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py index 06c5b7bd3e..93c9d4a7c9 100644 --- a/openstack_dashboard/settings.py +++ b/openstack_dashboard/settings.py @@ -315,6 +315,7 @@ POLICY_CHECK_FUNCTION = policy_backend.check # Add HORIZON_CONFIG to the context information for offline compression COMPRESS_OFFLINE_CONTEXT = { + 'WEBROOT': WEBROOT, 'STATIC_URL': STATIC_URL, 'HORIZON_CONFIG': HORIZON_CONFIG, } diff --git a/openstack_dashboard/static/dashboard/dashboard.module.js b/openstack_dashboard/static/dashboard/dashboard.module.js index 66f12f49b9..fd30c7d01c 100644 --- a/openstack_dashboard/static/dashboard/dashboard.module.js +++ b/openstack_dashboard/static/dashboard/dashboard.module.js @@ -4,8 +4,12 @@ var module = angular.module('hz.dashboard', [ 'hz.dashboard.launch-instance', 'hz.dashboard.workflow' - ]); + ]) + .config(config); - module.constant('dashboardBasePath', '/static/dashboard/'); + function config($provide, $windowProvider) { + var path = $windowProvider.$get().STATIC_URL + 'dashboard/'; + $provide.constant('dashboardBasePath', path); + } })(); diff --git a/openstack_dashboard/static/dashboard/dashboard.module.spec.js b/openstack_dashboard/static/dashboard/dashboard.module.spec.js index b72b7b8bbf..cf0b6d5b05 100644 --- a/openstack_dashboard/static/dashboard/dashboard.module.spec.js +++ b/openstack_dashboard/static/dashboard/dashboard.module.spec.js @@ -24,10 +24,12 @@ describe('hz.dashboard:constant:dashboardBasePath', function () { var dashboardBasePath; + var staticUrl; beforeEach(module('hz.dashboard')); beforeEach(inject(function ($injector) { dashboardBasePath = $injector.get('dashboardBasePath'); + staticUrl = $injector.get('$window').STATIC_URL; })); it('should be defined', function () { @@ -35,7 +37,7 @@ }); it('should equal to "/static/dashboard/"', function () { - expect(dashboardBasePath).toEqual('/static/dashboard/'); + expect(dashboardBasePath).toEqual(staticUrl + 'dashboard/'); }); }); diff --git a/openstack_dashboard/static/dashboard/launch-instance/security-groups/security-groups.js b/openstack_dashboard/static/dashboard/launch-instance/security-groups/security-groups.js index b74152918d..d48bb518aa 100644 --- a/openstack_dashboard/static/dashboard/launch-instance/security-groups/security-groups.js +++ b/openstack_dashboard/static/dashboard/launch-instance/security-groups/security-groups.js @@ -11,7 +11,8 @@ */ module.controller('LaunchInstanceSecurityGroupsCtrl', [ 'launchInstanceModel', - function (launchInstanceModel) { + '$window', + function (launchInstanceModel, $window) { var ctrl = this; ctrl.label = { @@ -37,8 +38,8 @@ displayedAllocated: [] }; - ctrl.tableDetails = - '/static/dashboard/launch-instance/security-groups/security-group-details.html'; + ctrl.tableDetails = $window.STATIC_URL + + 'dashboard/launch-instance/security-groups/security-group-details.html'; ctrl.tableHelp = { noneAllocText: gettext('Select one or more security groups from the available groups below.'), diff --git a/openstack_dashboard/static/dashboard/launch-instance/source/source.js b/openstack_dashboard/static/dashboard/launch-instance/source/source.js index 64dc33374d..92a6bfe1bd 100644 --- a/openstack_dashboard/static/dashboard/launch-instance/source/source.js +++ b/openstack_dashboard/static/dashboard/launch-instance/source/source.js @@ -63,6 +63,7 @@ 'decodeFilter', 'diskFormatFilter', 'gbFilter', + '$window', LaunchInstanceSourceCtrl ]); @@ -72,7 +73,8 @@ dateFilter, decodeFilter, diskFormatFilter, - gbFilter) { + gbFilter, + $window) { $scope.label = { title: gettext('Instance Details'), @@ -134,8 +136,8 @@ $scope.tableData = {}; $scope.helpText = {}; $scope.maxInstanceCount = 1; - $scope.sourceDetails = - '/static/dashboard/launch-instance/source/source-details.html'; + $scope.sourceDetails = $window.STATIC_URL + + 'dashboard/launch-instance/source/source-details.html'; var selection = $scope.selection = $scope.model.newInstanceSpec.source; diff --git a/openstack_dashboard/templates/jasmine/jasmine.html b/openstack_dashboard/templates/jasmine/jasmine.html index 727fa3921a..c92ac1f951 100644 --- a/openstack_dashboard/templates/jasmine/jasmine.html +++ b/openstack_dashboard/templates/jasmine/jasmine.html @@ -5,6 +5,10 @@ Jasmine Spec Runner +