Merge "Add links to trunk parent and subports"
This commit is contained in:
commit
ff672a67c1
openstack_dashboard/static/app/core/trunks
@ -25,6 +25,7 @@
|
||||
'horizon.app.core.trunks.resourceType',
|
||||
'horizon.framework.conf.resource-type-registry.service',
|
||||
'horizon.app.core.openstack-service-api.userSession',
|
||||
'horizon.app.core.trunks.service',
|
||||
'$scope'
|
||||
];
|
||||
|
||||
@ -32,6 +33,7 @@
|
||||
trunkResourceTypeCode,
|
||||
registry,
|
||||
userSession,
|
||||
trunksService,
|
||||
$scope
|
||||
) {
|
||||
var ctrl = this;
|
||||
@ -52,7 +54,8 @@
|
||||
priority: 1, sortDefault: true},
|
||||
{id: 'segmentation_id', title: gettext('Segmentation ID'),
|
||||
priority: 1, sortDefault: true},
|
||||
{id: 'port_id', title: gettext('Port ID'), priority: 1}
|
||||
{id: 'port_id', title: gettext('Port ID'), priority: 1,
|
||||
urlFunction: trunksService.getPortDetailsPath}
|
||||
]
|
||||
};
|
||||
|
||||
|
@ -66,7 +66,8 @@
|
||||
})
|
||||
.append({
|
||||
id: 'port_id',
|
||||
priority: 1
|
||||
priority: 1,
|
||||
urlFunction: trunksService.getPortDetailsPath
|
||||
})
|
||||
.append({
|
||||
id: 'subport_count',
|
||||
|
@ -38,10 +38,16 @@
|
||||
* but do not need to be restricted to such use. Each exposed function
|
||||
* is documented below.
|
||||
*/
|
||||
function trunksService(neutron, userSession, detailRoute, $location, $window) {
|
||||
function trunksService(
|
||||
neutron,
|
||||
userSession,
|
||||
detailRoute,
|
||||
$location,
|
||||
$window) {
|
||||
|
||||
return {
|
||||
getDetailsPath: getDetailsPath,
|
||||
getPortDetailsPath: getPortDetailsPath,
|
||||
getTrunksPromise: getTrunksPromise,
|
||||
getTrunkPromise: getTrunkPromise
|
||||
};
|
||||
@ -62,6 +68,27 @@
|
||||
return detailsPath;
|
||||
}
|
||||
|
||||
/*
|
||||
* @ngdoc function
|
||||
* @name getPortDetailsPath
|
||||
* @param item {Object} - the trunk object or the relevant subport details
|
||||
* object
|
||||
* @description
|
||||
* Given a trunk object, returns back url for the trunk's parent port or
|
||||
* subport detail page, for example:
|
||||
* /project/networks/ports/uuid/detail
|
||||
*/
|
||||
function getPortDetailsPath(item) {
|
||||
// Note(lajos Katona): the $location.url() can give back /projct/trunks or
|
||||
// in case of calling from ngdetails page
|
||||
// /ngdetails/OS::Neutron::Trunk/uuid?nav=%2Fadmin%2Ftrunks%2F
|
||||
var isAdminFromLocation = $location.url().indexOf('admin') >= 1;
|
||||
|
||||
var dashboardUrl = isAdminFromLocation ? 'admin' : 'project';
|
||||
var webRoot = $window.WEBROOT;
|
||||
return webRoot + dashboardUrl + '/networks/ports/' + item.port_id + '/detail';
|
||||
}
|
||||
|
||||
/*
|
||||
* @ngdoc function
|
||||
* @name getTrunksPromise
|
||||
|
@ -87,5 +87,38 @@
|
||||
|
||||
});
|
||||
|
||||
describe('getDetailsPath', function() {
|
||||
|
||||
it('returns path for loading details for a given trunk', function() {
|
||||
var trunk = {id: 1};
|
||||
var path = service.getDetailsPath(trunk);
|
||||
expect(path).toMatch('ngdetails');
|
||||
expect(path).toMatch(trunk.id.toString());
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('getPortDetailsPath', function() {
|
||||
|
||||
it('returns url to port\'s detail page for non-admin user', function() {
|
||||
spyOn(_location_, 'url').and.returnValue('/project/trunks');
|
||||
|
||||
var trunk = {id: 1, port_id: 2};
|
||||
var path = service.getPortDetailsPath(trunk);
|
||||
expect(path).toMatch('detail');
|
||||
expect(path).toMatch(trunk.port_id.toString());
|
||||
});
|
||||
|
||||
it('returns url to port\'s detail page for admin user', function() {
|
||||
spyOn(_location_, 'url').and.returnValue('/admin/trunks');
|
||||
|
||||
var trunk = {id: 1, port_id: 2};
|
||||
var path = service.getPortDetailsPath(trunk);
|
||||
expect(path).toMatch('detail');
|
||||
expect(path).toMatch(trunk.port_id.toString());
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
})();
|
||||
|
Loading…
x
Reference in New Issue
Block a user