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