Add WEBROOT to ngdetails navigation
Default index URL for angular details page doesn't consider WEBROOT while building navigations. That is why refreshing details page or opening it in a new tab works perfectly when WEBROOT is "/" and fails for apache deployment where WEBROOT is "/dashboard/". This patch adds WEBROOT to index URL and builds a proper navigation. Closes-Bug: #1902821 Change-Id: Id609e5499cc8f53dbae36febc945568e45d291f3 (cherry picked from commitf7442851c4
) (cherry picked from commitcd4d3aa1a6
)
This commit is contained in:
parent
f6ef2e4e4e
commit
17d48024ec
|
@ -25,6 +25,7 @@
|
||||||
collapseAllNavigation: collapseAllNavigation,
|
collapseAllNavigation: collapseAllNavigation,
|
||||||
expandNavigationByUrl: expandNavigationByUrl,
|
expandNavigationByUrl: expandNavigationByUrl,
|
||||||
setBreadcrumb: setBreadcrumb,
|
setBreadcrumb: setBreadcrumb,
|
||||||
|
setAbsoluteURI: setAbsoluteURI,
|
||||||
isNavigationExists: isNavigationExists
|
isNavigationExists: isNavigationExists
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -107,6 +108,14 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set absolute uri */
|
||||||
|
function setAbsoluteURI(webroot, url) {
|
||||||
|
if (webroot.endsWith("/") && url.startsWith("/")) {
|
||||||
|
webroot = webroot.slice(0, -1);
|
||||||
|
}
|
||||||
|
return webroot + url;
|
||||||
|
}
|
||||||
|
|
||||||
/* check whether navigation exists from url */
|
/* check whether navigation exists from url */
|
||||||
function isNavigationExists(url) {
|
function isNavigationExists(url) {
|
||||||
return angular.element("a.openstack-panel[href='" + url + "']").length ? true : false;
|
return angular.element("a.openstack-panel[href='" + url + "']").length ? true : false;
|
||||||
|
|
|
@ -158,6 +158,13 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('setAbsoluteURI', function() {
|
||||||
|
it('sets absolute uri', function() {
|
||||||
|
var url = service.setAbsoluteURI('/dashboard/', '/project/images/');
|
||||||
|
expect(url).toBe('/dashboard/project/images/');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('isNavigationExists', function() {
|
describe('isNavigationExists', function() {
|
||||||
it('returns true if navigation for specified URL exists', function() {
|
it('returns true if navigation for specified URL exists', function() {
|
||||||
var result = service.isNavigationExists('/project/images/');
|
var result = service.isNavigationExists('/project/images/');
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
'horizon.framework.widgets.modal-wait-spinner.service',
|
'horizon.framework.widgets.modal-wait-spinner.service',
|
||||||
'$location',
|
'$location',
|
||||||
'$q',
|
'$q',
|
||||||
'$routeParams'
|
'$routeParams',
|
||||||
|
'$window'
|
||||||
];
|
];
|
||||||
|
|
||||||
function controller(
|
function controller(
|
||||||
|
@ -39,7 +40,8 @@
|
||||||
spinnerService,
|
spinnerService,
|
||||||
$location,
|
$location,
|
||||||
$q,
|
$q,
|
||||||
$routeParams
|
$routeParams,
|
||||||
|
$window
|
||||||
) {
|
) {
|
||||||
var ctrl = this;
|
var ctrl = this;
|
||||||
|
|
||||||
|
@ -69,6 +71,9 @@
|
||||||
|
|
||||||
// get defaultIndexUrl
|
// get defaultIndexUrl
|
||||||
var url = resourceType.getDefaultIndexUrl();
|
var url = resourceType.getDefaultIndexUrl();
|
||||||
|
// add webroot
|
||||||
|
var webroot = $window.WEBROOT;
|
||||||
|
url = navigationsService.setAbsoluteURI(webroot, url);
|
||||||
// if querystring has 'nav' parameter, overwrite the url
|
// if querystring has 'nav' parameter, overwrite the url
|
||||||
var query = $location.search();
|
var query = $location.search();
|
||||||
if (query.hasOwnProperty("nav")) {
|
if (query.hasOwnProperty("nav")) {
|
||||||
|
|
Loading…
Reference in New Issue