Update URL routing
This updates the URL routing so URLs include all IDs of the resource hierarchy. This makes it much easier to create links in pages and to obtain the information for parent resources. Partially-Implements: blueprint horizon-lbaas-v2-ui Change-Id: I6cdfb5446362e854da6a18eb16420d9121329ab9
This commit is contained in:
parent
b16542e6a0
commit
900d73820e
@ -39,62 +39,22 @@
|
||||
|
||||
function HealthMonitorDetailController(api, $routeParams) {
|
||||
var ctrl = this;
|
||||
ctrl.healthmonitor = {};
|
||||
ctrl.pool = {};
|
||||
ctrl.listener = {};
|
||||
ctrl.loadbalancer = {};
|
||||
|
||||
var healthmonitorID = $routeParams.healthmonitorId;
|
||||
|
||||
init();
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
function init() {
|
||||
api.getHealthMonitor(healthmonitorID).success(healthMonitorSuccess);
|
||||
api.getHealthMonitor($routeParams.healthmonitorId).success(set('healthmonitor'));
|
||||
api.getPool($routeParams.poolId).success(set('pool'));
|
||||
api.getListener($routeParams.listenerId).success(set('listener'));
|
||||
api.getLoadBalancer($routeParams.loadbalancerId).success(set('loadbalancer'));
|
||||
}
|
||||
|
||||
function healthMonitorSuccess(response) {
|
||||
ctrl.healthmonitor = response;
|
||||
|
||||
if (ctrl.healthmonitor.hasOwnProperty('pools') &&
|
||||
ctrl.healthmonitor.pools.length > 0) {
|
||||
getPoolDetails(ctrl.healthmonitor.pools[0].id);
|
||||
}
|
||||
}
|
||||
|
||||
function getPoolDetails(poolId) {
|
||||
api.getPool(poolId).success(poolSuccess);
|
||||
}
|
||||
|
||||
function poolSuccess(response) {
|
||||
ctrl.pool = response;
|
||||
|
||||
if (ctrl.pool.hasOwnProperty('listeners') &&
|
||||
ctrl.pool.listeners.length > 0) {
|
||||
getListenerDetails(ctrl.pool.listeners[0].id);
|
||||
}
|
||||
}
|
||||
|
||||
function getListenerDetails(listenerId) {
|
||||
api.getListener(listenerId).success(listenerSuccess);
|
||||
}
|
||||
|
||||
function listenerSuccess(response) {
|
||||
ctrl.listener = response;
|
||||
|
||||
if (ctrl.listener.hasOwnProperty('loadbalancers') &&
|
||||
ctrl.listener.loadbalancers.length > 0) {
|
||||
getLoadBalancerDetails(ctrl.listener.loadbalancers[0].id);
|
||||
}
|
||||
}
|
||||
|
||||
function getLoadBalancerDetails(loadbalancerId) {
|
||||
api.getLoadBalancer(loadbalancerId).success(loadbalancerSuccess);
|
||||
}
|
||||
|
||||
function loadbalancerSuccess(response) {
|
||||
ctrl.loadbalancer = response;
|
||||
function set(property) {
|
||||
return angular.bind(null, function setProp(property, value) {
|
||||
ctrl[property] = value;
|
||||
}, property);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,36 +17,12 @@
|
||||
'use strict';
|
||||
|
||||
describe('LBaaS v2 Healthmonitor Detail Controller', function() {
|
||||
var controller, lbaasv2API, healthmonitor, pool, listener, loadbalancer;
|
||||
var lbaasv2API, ctrl;
|
||||
|
||||
function fakeHealthMonitorAPI() {
|
||||
function fakeAPI() {
|
||||
return {
|
||||
success: function(callback) {
|
||||
callback(healthmonitor);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function fakePoolAPI() {
|
||||
return {
|
||||
success: function(callback) {
|
||||
callback(pool);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function fakeListenerAPI() {
|
||||
return {
|
||||
success: function(callback) {
|
||||
callback(listener);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function fakeLoadBalancerAPI() {
|
||||
return {
|
||||
success: function(callback) {
|
||||
callback(loadbalancer);
|
||||
callback('foo');
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -61,60 +37,30 @@
|
||||
|
||||
beforeEach(inject(function($injector) {
|
||||
lbaasv2API = $injector.get('horizon.app.core.openstack-service-api.lbaasv2');
|
||||
controller = $injector.get('$controller');
|
||||
spyOn(lbaasv2API, 'getHealthMonitor').and.callFake(fakeHealthMonitorAPI);
|
||||
spyOn(lbaasv2API, 'getPool').and.callFake(fakePoolAPI);
|
||||
spyOn(lbaasv2API, 'getListener').and.callFake(fakeListenerAPI);
|
||||
spyOn(lbaasv2API, 'getLoadBalancer').and.callFake(fakeLoadBalancerAPI);
|
||||
spyOn(lbaasv2API, 'getHealthMonitor').and.callFake(fakeAPI);
|
||||
spyOn(lbaasv2API, 'getPool').and.callFake(fakeAPI);
|
||||
spyOn(lbaasv2API, 'getListener').and.callFake(fakeAPI);
|
||||
spyOn(lbaasv2API, 'getLoadBalancer').and.callFake(fakeAPI);
|
||||
var controller = $injector.get('$controller');
|
||||
ctrl = controller('HealthMonitorDetailController', {
|
||||
$routeParams: {
|
||||
loadbalancerId: 'loadbalancerId',
|
||||
listenerId: 'listenerId',
|
||||
poolId: 'poolId',
|
||||
healthmonitorId: 'healthmonitorId'
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
function createController() {
|
||||
return controller('HealthMonitorDetailController', {
|
||||
api: lbaasv2API,
|
||||
$routeParams: { healthmonitorId: 'healthmonitorId' }
|
||||
});
|
||||
}
|
||||
|
||||
it('should invoke lbaasv2 apis', function() {
|
||||
healthmonitor = { id: 'healthmonitorId', pools: [{id: 'poolId'}] };
|
||||
pool = { id: 'poolId', listeners: [{id: 'listenerId'}] };
|
||||
listener = { id: 'listenerId', loadbalancers: [{id: 'loadbalancerId'}] };
|
||||
loadbalancer = { id: 'loadbalancerId' };
|
||||
createController();
|
||||
expect(lbaasv2API.getHealthMonitor).toHaveBeenCalledWith('healthmonitorId');
|
||||
expect(lbaasv2API.getPool).toHaveBeenCalledWith('poolId');
|
||||
expect(lbaasv2API.getListener).toHaveBeenCalledWith('listenerId');
|
||||
expect(lbaasv2API.getLoadBalancer).toHaveBeenCalledWith('loadbalancerId');
|
||||
});
|
||||
|
||||
it('should not invoke the getPool, getListener or getLoadBalancer lbaasv2 api', function() {
|
||||
healthmonitor = { id: 'healthmonitorId', pools: [] };
|
||||
createController();
|
||||
expect(lbaasv2API.getHealthMonitor).toHaveBeenCalledWith('healthmonitorId');
|
||||
expect(lbaasv2API.getPool).not.toHaveBeenCalled();
|
||||
expect(lbaasv2API.getListener).not.toHaveBeenCalled();
|
||||
expect(lbaasv2API.getLoadBalancer).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not invoke the getListener or getLoadBalancer lbaasv2 api', function() {
|
||||
healthmonitor = { id: 'healthmonitorId', pools: [{id: 'poolId'}] };
|
||||
pool = { id: 'poolId', listeners: [] };
|
||||
createController();
|
||||
expect(lbaasv2API.getHealthMonitor).toHaveBeenCalledWith('healthmonitorId');
|
||||
expect(lbaasv2API.getPool).toHaveBeenCalledWith('poolId');
|
||||
expect(lbaasv2API.getListener).not.toHaveBeenCalled();
|
||||
expect(lbaasv2API.getLoadBalancer).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not invoke getLoadBalancer lbaasv2 api', function() {
|
||||
healthmonitor = { id: 'healthmonitorId', pools: [{id: 'poolId'}] };
|
||||
pool = { id: 'poolId', listeners: [{id: 'listenerId'}] };
|
||||
listener = { id: 'listenerId', loadbalancers: [] };
|
||||
createController();
|
||||
expect(lbaasv2API.getHealthMonitor).toHaveBeenCalledWith('healthmonitorId');
|
||||
expect(lbaasv2API.getPool).toHaveBeenCalledWith('poolId');
|
||||
expect(lbaasv2API.getListener).toHaveBeenCalledWith('listenerId');
|
||||
expect(lbaasv2API.getLoadBalancer).not.toHaveBeenCalled();
|
||||
expect(ctrl.loadbalancer).toBe('foo');
|
||||
expect(ctrl.listener).toBe('foo');
|
||||
expect(ctrl.pool).toBe('foo');
|
||||
expect(ctrl.healthmonitor).toBe('foo');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -2,9 +2,9 @@
|
||||
<div class='page-header'>
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="project/ngloadbalancersv2/"><translate>Load Balancers</translate></a></li>
|
||||
<li><a href="project/ngloadbalancersv2/detail/{$ ::ctrl.loadbalancer.id $}">{$ ::(ctrl.loadbalancer.name || ctrl.loadbalancer.id) $}</a></li>
|
||||
<li><a href="project/ngloadbalancersv2/listeners/detail/{$ ::ctrl.listener.id $}">{$ ::(ctrl.listener.name || ctrl.listener.id) $}</a></li>
|
||||
<li><a href="project/ngloadbalancersv2/pools/detail/{$ ::ctrl.pool.id $}">{$ ::(ctrl.pool.name || ctrl.pool.id) $}</a></li>
|
||||
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}">{$ ::(ctrl.loadbalancer.name || ctrl.loadbalancer.id) $}</a></li>
|
||||
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}">{$ ::(ctrl.listener.name || ctrl.listener.id) $}</a></li>
|
||||
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}/pools/{$ ::ctrl.pool.id $}">{$ ::(ctrl.pool.name || ctrl.pool.id) $}</a></li>
|
||||
<li class="active">{$ ::(ctrl.healthmonitor.name || ctrl.healthmonitor.id) $}</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
@ -54,27 +54,32 @@
|
||||
];
|
||||
|
||||
function config($provide, $windowProvider, $routeProvider) {
|
||||
var href = '/project/ngloadbalancersv2/';
|
||||
var basePath = $windowProvider.$get().STATIC_URL + 'dashboard/project/lbaasv2/';
|
||||
$provide.constant('horizon.dashboard.project.lbaasv2.basePath', basePath);
|
||||
|
||||
var loadbalancers = '/project/ngloadbalancersv2';
|
||||
var listener = loadbalancers + '/:loadbalancerId/listeners/:listenerId';
|
||||
var pool = listener + '/pools/:poolId';
|
||||
var member = pool + '/members/:memberId';
|
||||
var healthmonitor = pool + '/healthmonitors/:healthmonitorId';
|
||||
|
||||
$routeProvider
|
||||
.when(href, {
|
||||
.when(loadbalancers, {
|
||||
templateUrl: basePath + 'loadbalancers/table.html'
|
||||
})
|
||||
.when(href + 'detail/:loadbalancerId', {
|
||||
.when(loadbalancers + '/:loadbalancerId', {
|
||||
templateUrl: basePath + 'loadbalancers/detail.html'
|
||||
})
|
||||
.when(href + 'listeners/detail/:listenerId', {
|
||||
.when(listener, {
|
||||
templateUrl: basePath + 'listeners/detail.html'
|
||||
})
|
||||
.when(href + 'pools/detail/:poolId', {
|
||||
.when(pool, {
|
||||
templateUrl: basePath + 'pools/detail.html'
|
||||
})
|
||||
.when(href + 'pools/:poolId/members/detail/:memberId', {
|
||||
.when(member, {
|
||||
templateUrl: basePath + 'members/detail.html'
|
||||
})
|
||||
.when(href + 'healthmonitors/detail/:healthmonitorId', {
|
||||
.when(healthmonitor, {
|
||||
templateUrl: basePath + 'healthmonitors/detail.html'
|
||||
});
|
||||
}
|
||||
|
@ -95,45 +95,36 @@
|
||||
});
|
||||
|
||||
it('should route URLs', function () {
|
||||
var href = '/project/ngloadbalancersv2/';
|
||||
var routes = [
|
||||
[
|
||||
href,
|
||||
{
|
||||
templateUrl: basePath + 'loadbalancers/table.html'
|
||||
}
|
||||
],
|
||||
[
|
||||
href + 'detail/:loadbalancerId',
|
||||
{
|
||||
templateUrl: basePath + 'loadbalancers/detail.html'
|
||||
}
|
||||
],
|
||||
[
|
||||
href + 'listeners/detail/:listenerId',
|
||||
{
|
||||
templateUrl: basePath + 'listeners/detail.html'
|
||||
}
|
||||
],
|
||||
[
|
||||
href + 'pools/detail/:poolId',
|
||||
{
|
||||
templateUrl: basePath + 'pools/detail.html'
|
||||
}
|
||||
],
|
||||
[
|
||||
href + 'pools/:poolId/members/detail/:memberId',
|
||||
{
|
||||
templateUrl: basePath + 'members/detail.html'
|
||||
}
|
||||
],
|
||||
[
|
||||
href + 'healthmonitors/detail/:healthmonitorId',
|
||||
{
|
||||
templateUrl: basePath + 'healthmonitors/detail.html'
|
||||
}
|
||||
]
|
||||
];
|
||||
var loadbalancers = '/project/ngloadbalancersv2';
|
||||
var listener = loadbalancers + '/:loadbalancerId/listeners/:listenerId';
|
||||
var pool = listener + '/pools/:poolId';
|
||||
var member = pool + '/members/:memberId';
|
||||
var healthmonitor = pool + '/healthmonitors/:healthmonitorId';
|
||||
var routes = [[
|
||||
loadbalancers, {
|
||||
templateUrl: basePath + 'loadbalancers/table.html'
|
||||
}
|
||||
], [
|
||||
loadbalancers + '/:loadbalancerId', {
|
||||
templateUrl: basePath + 'loadbalancers/detail.html'
|
||||
}
|
||||
], [
|
||||
listener, {
|
||||
templateUrl: basePath + 'listeners/detail.html'
|
||||
}
|
||||
], [
|
||||
pool, {
|
||||
templateUrl: basePath + 'pools/detail.html'
|
||||
}
|
||||
], [
|
||||
member, {
|
||||
templateUrl: basePath + 'members/detail.html'
|
||||
}
|
||||
], [
|
||||
healthmonitor, {
|
||||
templateUrl: basePath + 'healthmonitors/detail.html'
|
||||
}
|
||||
]];
|
||||
|
||||
expect($routeProvider.when.calls.count()).toBe(6);
|
||||
angular.forEach($routeProvider.when.calls.all(), function(call, i) {
|
||||
|
@ -39,34 +39,20 @@
|
||||
|
||||
function ListenerDetailController(api, $routeParams) {
|
||||
var ctrl = this;
|
||||
ctrl.listener = {};
|
||||
ctrl.loadbalancer = {};
|
||||
|
||||
var listenerID = $routeParams.listenerId;
|
||||
|
||||
init();
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
function init() {
|
||||
api.getListener(listenerID).success(listenerSuccess);
|
||||
api.getListener($routeParams.listenerId).success(set('listener'));
|
||||
api.getLoadBalancer($routeParams.loadbalancerId).success(set('loadbalancer'));
|
||||
}
|
||||
|
||||
function listenerSuccess(response) {
|
||||
ctrl.listener = response;
|
||||
|
||||
if (ctrl.listener.hasOwnProperty('loadbalancers') &&
|
||||
ctrl.listener.loadbalancers.length > 0) {
|
||||
getLoadBalancerDetails(ctrl.listener.loadbalancers[0].id);
|
||||
}
|
||||
}
|
||||
|
||||
function getLoadBalancerDetails(loadbalancerId) {
|
||||
api.getLoadBalancer(loadbalancerId).success(loadbalancerSuccess);
|
||||
}
|
||||
|
||||
function loadbalancerSuccess(response) {
|
||||
ctrl.loadbalancer = response;
|
||||
function set(property) {
|
||||
return angular.bind(null, function setProp(property, value) {
|
||||
ctrl[property] = value;
|
||||
}, property);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,12 +17,12 @@
|
||||
'use strict';
|
||||
|
||||
describe('LBaaS v2 Listener Detail Controller', function() {
|
||||
var controller, lbaasv2API, listener;
|
||||
var lbaasv2API, ctrl;
|
||||
|
||||
function fakeAPI() {
|
||||
return {
|
||||
success: function(callback) {
|
||||
callback(listener);
|
||||
callback('foo');
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -37,29 +37,22 @@
|
||||
|
||||
beforeEach(inject(function($injector) {
|
||||
lbaasv2API = $injector.get('horizon.app.core.openstack-service-api.lbaasv2');
|
||||
controller = $injector.get('$controller');
|
||||
spyOn(lbaasv2API, 'getListener').and.callFake(fakeAPI);
|
||||
spyOn(lbaasv2API, 'getLoadBalancer').and.callFake(fakeAPI);
|
||||
var controller = $injector.get('$controller');
|
||||
ctrl = controller('ListenerDetailController', {
|
||||
$routeParams: {
|
||||
loadbalancerId: 'loadbalancerId',
|
||||
listenerId: 'listenerId'
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
function createController() {
|
||||
return controller('ListenerDetailController', {
|
||||
api: lbaasv2API,
|
||||
$routeParams: { listenerId: '1234' }
|
||||
});
|
||||
}
|
||||
|
||||
it('should invoke lbaasv2 apis', function() {
|
||||
listener = { id: '1234', loadbalancers: [{id: '5678'}] };
|
||||
createController();
|
||||
expect(lbaasv2API.getListener).toHaveBeenCalledWith('1234');
|
||||
expect(lbaasv2API.getLoadBalancer).toHaveBeenCalledWith('5678');
|
||||
});
|
||||
|
||||
it('should not invoke getLoadBalancer lbaasv2 api', function() {
|
||||
listener = { id: '1234', loadbalancers: [] };
|
||||
createController();
|
||||
expect(lbaasv2API.getListener).toHaveBeenCalledWith('1234');
|
||||
expect(lbaasv2API.getListener).toHaveBeenCalledWith('listenerId');
|
||||
expect(lbaasv2API.getLoadBalancer).toHaveBeenCalledWith('loadbalancerId');
|
||||
expect(ctrl.loadbalancer).toBe('foo');
|
||||
expect(ctrl.listener).toBe('foo');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div class='page-header'>
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="project/ngloadbalancersv2/"><translate>Load Balancers</translate></a></li>
|
||||
<li><a href="project/ngloadbalancersv2/detail/{$ ::ctrl.loadbalancer.id $}">{$ ::(ctrl.loadbalancer.name || ctrl.loadbalancer.id) $}</a></li>
|
||||
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}">{$ ::(ctrl.loadbalancer.name || ctrl.loadbalancer.id) $}</a></li>
|
||||
<li class="active">{$ ::(ctrl.listener.name || ctrl.listener.id) $}</li>
|
||||
</ol>
|
||||
<p ng-if="::ctrl.listener.description">{$ ::ctrl.listener.description $}</p>
|
||||
@ -37,7 +37,7 @@
|
||||
<dt translate>Default Pool ID</dt>
|
||||
<dd>
|
||||
<div ng-if="ctrl.listener.default_pool_id">
|
||||
<a ng-href="project/ngloadbalancersv2/pools/detail/{$ ::ctrl.listener.default_pool_id $}">{$ ::ctrl.listener.default_pool_id $}</a>
|
||||
<a ng-href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}/pools/{$ ::ctrl.listener.default_pool_id $}">{$ ::ctrl.listener.default_pool_id $}</a>
|
||||
</div>
|
||||
<div ng-if="!ctrl.listener.default_pool_id">
|
||||
{$ 'None' | translate $}
|
||||
|
@ -46,15 +46,14 @@
|
||||
ctrl.src = [];
|
||||
ctrl.checked = {};
|
||||
ctrl.batchActions = batchActions;
|
||||
|
||||
var loadbalancerId = $routeParams.loadbalancerId;
|
||||
ctrl.loadbalancerId = $routeParams.loadbalancerId;
|
||||
|
||||
init();
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
function init() {
|
||||
api.getListeners(loadbalancerId).success(success);
|
||||
api.getListeners(ctrl.loadbalancerId).success(success);
|
||||
}
|
||||
|
||||
function success(response) {
|
||||
|
@ -68,7 +68,7 @@
|
||||
duration="200">
|
||||
</span>
|
||||
</td>
|
||||
<td class="rsp-p1"><a ng-href="project/ngloadbalancersv2/listeners/detail/{$ ::item.id $}">{$ ::(item.name || item.id) $}</a></td>
|
||||
<td class="rsp-p1"><a ng-href="project/ngloadbalancersv2/{$ ::table.loadbalancerId $}/listeners/{$ ::item.id $}">{$ ::(item.name || item.id) $}</a></td>
|
||||
<td class="rsp-p1">{$ ::item.description | noValue $}</td>
|
||||
<td class="rsp-p1">{$ ::item.protocol$}</td>
|
||||
<td class="rsp-p1">{$ ::item.protocol_port$}</td>
|
||||
|
@ -78,7 +78,7 @@
|
||||
}
|
||||
|
||||
function onCreate(response) {
|
||||
$location.path('project/ngloadbalancersv2/detail/' + response.data.id);
|
||||
$location.path('project/ngloadbalancersv2/' + response.data.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@
|
||||
it('should redirect after create', function() {
|
||||
spyOn($location, 'path').and.callThrough();
|
||||
actions[0].service.perform();
|
||||
expect($location.path).toHaveBeenCalledWith('project/ngloadbalancersv2/detail/1');
|
||||
expect($location.path).toHaveBeenCalledWith('project/ngloadbalancersv2/1');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -40,19 +40,16 @@
|
||||
*/
|
||||
|
||||
function LoadBalancerDetailController(api, rowActions, $routeParams) {
|
||||
|
||||
var ctrl = this;
|
||||
ctrl.loadbalancer = null;
|
||||
ctrl.actions = rowActions.actions;
|
||||
|
||||
var loadbalancerId = $routeParams.loadbalancerId;
|
||||
ctrl.actions = rowActions.actions;
|
||||
|
||||
init();
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
function init() {
|
||||
api.getLoadBalancer(loadbalancerId).success(success);
|
||||
api.getLoadBalancer($routeParams.loadbalancerId).success(success);
|
||||
}
|
||||
|
||||
function success(response) {
|
||||
|
@ -71,7 +71,7 @@
|
||||
duration="200">
|
||||
</span>
|
||||
</td>
|
||||
<td class="rsp-p1"><a ng-href="project/ngloadbalancersv2/detail/{$ ::item.id $}">{$ ::(item.name || item.id) $}</a></td>
|
||||
<td class="rsp-p1"><a ng-href="project/ngloadbalancersv2/{$ ::item.id $}">{$ ::(item.name || item.id) $}</a></td>
|
||||
<td class="rsp-p1">{$ ::item.description | noValue $}</td>
|
||||
<td class="rsp-p1">{$ ::item.operating_status | operatingStatus $}</td>
|
||||
<td class="rsp-p1">{$ ::item.provisioning_status | provisioningStatus $}</td>
|
||||
|
@ -39,58 +39,22 @@
|
||||
|
||||
function MemberDetailController(api, $routeParams) {
|
||||
var ctrl = this;
|
||||
ctrl.member = {};
|
||||
ctrl.pool = {};
|
||||
ctrl.listener = {};
|
||||
ctrl.loadbalancer = {};
|
||||
|
||||
var poolID = $routeParams.poolId;
|
||||
var memberID = $routeParams.memberId;
|
||||
|
||||
init();
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
function init() {
|
||||
api.getMember(poolID, memberID).success(memberSuccess);
|
||||
api.getMember($routeParams.poolId, $routeParams.memberId).success(set('member'));
|
||||
api.getPool($routeParams.poolId).success(set('pool'));
|
||||
api.getListener($routeParams.listenerId).success(set('listener'));
|
||||
api.getLoadBalancer($routeParams.loadbalancerId).success(set('loadbalancer'));
|
||||
}
|
||||
|
||||
function memberSuccess(response) {
|
||||
ctrl.member = response;
|
||||
getPoolDetails(poolID);
|
||||
}
|
||||
|
||||
function getPoolDetails(poolId) {
|
||||
api.getPool(poolId).success(poolSuccess);
|
||||
}
|
||||
|
||||
function poolSuccess(response) {
|
||||
ctrl.pool = response;
|
||||
if (ctrl.pool.hasOwnProperty('listeners') &&
|
||||
ctrl.pool.listeners.length > 0) {
|
||||
getListenerDetails(ctrl.pool.listeners[0].id);
|
||||
}
|
||||
}
|
||||
|
||||
function getListenerDetails(listenerId) {
|
||||
api.getListener(listenerId).success(listenerSuccess);
|
||||
}
|
||||
|
||||
function listenerSuccess(response) {
|
||||
ctrl.listener = response;
|
||||
|
||||
if (ctrl.listener.hasOwnProperty('loadbalancers') &&
|
||||
ctrl.listener.loadbalancers.length > 0) {
|
||||
getLoadBalancerDetails(ctrl.listener.loadbalancers[0].id);
|
||||
}
|
||||
}
|
||||
|
||||
function getLoadBalancerDetails(loadbalancerId) {
|
||||
api.getLoadBalancer(loadbalancerId).success(loadbalancerSuccess);
|
||||
}
|
||||
|
||||
function loadbalancerSuccess(response) {
|
||||
ctrl.loadbalancer = response;
|
||||
function set(property) {
|
||||
return angular.bind(null, function setProp(property, value) {
|
||||
ctrl[property] = value;
|
||||
}, property);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,36 +17,12 @@
|
||||
'use strict';
|
||||
|
||||
describe('LBaaS v2 Member Detail Controller', function() {
|
||||
var controller, lbaasv2API, member, pool, listener, loadbalancer;
|
||||
var lbaasv2API, ctrl;
|
||||
|
||||
function fakeMemberAPI() {
|
||||
function fakeAPI() {
|
||||
return {
|
||||
success: function(callback) {
|
||||
callback(member);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function fakePoolAPI() {
|
||||
return {
|
||||
success: function(callback) {
|
||||
callback(pool);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function fakeListenerAPI() {
|
||||
return {
|
||||
success: function(callback) {
|
||||
callback(listener);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function fakeLoadBalancerAPI() {
|
||||
return {
|
||||
success: function(callback) {
|
||||
callback(loadbalancer);
|
||||
callback('foo');
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -60,50 +36,31 @@
|
||||
beforeEach(module('horizon.dashboard.project.lbaasv2'));
|
||||
|
||||
beforeEach(inject(function($injector) {
|
||||
member = { id: '5678' };
|
||||
lbaasv2API = $injector.get('horizon.app.core.openstack-service-api.lbaasv2');
|
||||
controller = $injector.get('$controller');
|
||||
spyOn(lbaasv2API, 'getMember').and.callFake(fakeMemberAPI);
|
||||
spyOn(lbaasv2API, 'getPool').and.callFake(fakePoolAPI);
|
||||
spyOn(lbaasv2API, 'getListener').and.callFake(fakeListenerAPI);
|
||||
spyOn(lbaasv2API, 'getLoadBalancer').and.callFake(fakeLoadBalancerAPI);
|
||||
spyOn(lbaasv2API, 'getMember').and.callFake(fakeAPI);
|
||||
spyOn(lbaasv2API, 'getPool').and.callFake(fakeAPI);
|
||||
spyOn(lbaasv2API, 'getListener').and.callFake(fakeAPI);
|
||||
spyOn(lbaasv2API, 'getLoadBalancer').and.callFake(fakeAPI);
|
||||
var controller = $injector.get('$controller');
|
||||
ctrl = controller('MemberDetailController', {
|
||||
$routeParams: {
|
||||
loadbalancerId: 'loadbalancerId',
|
||||
listenerId: 'listenerId',
|
||||
poolId: 'poolId',
|
||||
memberId: 'memberId'
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
function createController() {
|
||||
return controller('MemberDetailController', {
|
||||
api: lbaasv2API,
|
||||
$routeParams: { poolId: 'poolId', memberId: 'memberId' }
|
||||
});
|
||||
}
|
||||
|
||||
it('should invoke lbaasv2 apis', function() {
|
||||
pool = { id: 'poolId', listeners: [{id: 'listenerId'}] };
|
||||
listener = { id: 'listenerId', loadbalancers: [{id: 'loadbalancerId'}] };
|
||||
loadbalancer = { id: 'loadbalancerId' };
|
||||
createController();
|
||||
expect(lbaasv2API.getMember).toHaveBeenCalledWith('poolId', 'memberId');
|
||||
expect(lbaasv2API.getMember).toHaveBeenCalledWith('poolId','memberId');
|
||||
expect(lbaasv2API.getPool).toHaveBeenCalledWith('poolId');
|
||||
expect(lbaasv2API.getListener).toHaveBeenCalledWith('listenerId');
|
||||
expect(lbaasv2API.getLoadBalancer).toHaveBeenCalledWith('loadbalancerId');
|
||||
});
|
||||
|
||||
it('should not invoke the getListener or getLoadBalancer lbaasv2 api', function() {
|
||||
pool = { id: 'poolId', listeners: [] };
|
||||
createController();
|
||||
expect(lbaasv2API.getMember).toHaveBeenCalledWith('poolId', 'memberId');
|
||||
expect(lbaasv2API.getPool).toHaveBeenCalledWith('poolId');
|
||||
expect(lbaasv2API.getListener).not.toHaveBeenCalled();
|
||||
expect(lbaasv2API.getLoadBalancer).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not invoke getLoadBalancer lbaasv2 api', function() {
|
||||
pool = { id: 'poolId', listeners: [{id: 'listenerId'}] };
|
||||
listener = { id: 'listenerId', loadbalancers: [] };
|
||||
createController();
|
||||
expect(lbaasv2API.getMember).toHaveBeenCalledWith('poolId', 'memberId');
|
||||
expect(lbaasv2API.getPool).toHaveBeenCalledWith('poolId');
|
||||
expect(lbaasv2API.getListener).toHaveBeenCalledWith('listenerId');
|
||||
expect(lbaasv2API.getLoadBalancer).not.toHaveBeenCalled();
|
||||
expect(ctrl.loadbalancer).toBe('foo');
|
||||
expect(ctrl.listener).toBe('foo');
|
||||
expect(ctrl.pool).toBe('foo');
|
||||
expect(ctrl.member).toBe('foo');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -2,9 +2,9 @@
|
||||
<div class='page-header'>
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="project/ngloadbalancersv2/"><translate>Load Balancers</translate></a></li>
|
||||
<li><a href="project/ngloadbalancersv2/detail/{$ ::ctrl.loadbalancer.id $}">{$ ::(ctrl.loadbalancer.name || ctrl.loadbalancer.id) $}</a></li>
|
||||
<li><a href="project/ngloadbalancersv2/listeners/detail/{$ ::ctrl.listener.id $}">{$ ::(ctrl.listener.name || ctrl.listener.id) $}</a></li>
|
||||
<li><a href="project/ngloadbalancersv2/pools/detail/{$ ::ctrl.pool.id $}">{$ ::(ctrl.pool.name || ctrl.pool.id) $}</a></li>
|
||||
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}">{$ ::(ctrl.loadbalancer.name || ctrl.loadbalancer.id) $}</a></li>
|
||||
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}">{$ ::(ctrl.listener.name || ctrl.listener.id) $}</a></li>
|
||||
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}/pools/{$ ::ctrl.pool.id $}">{$ ::(ctrl.pool.name || ctrl.pool.id) $}</a></li>
|
||||
<li class="active">{$ ::(ctrl.member.name || ctrl.member.id) $}</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
@ -43,16 +43,16 @@
|
||||
ctrl.items = [];
|
||||
ctrl.src = [];
|
||||
ctrl.checked = {};
|
||||
|
||||
var poolID = $routeParams.poolId;
|
||||
ctrl.pool_id = poolID;
|
||||
ctrl.loadbalancerId = $routeParams.loadbalancerId;
|
||||
ctrl.listenerId = $routeParams.listenerId;
|
||||
ctrl.poolId = $routeParams.poolId;
|
||||
|
||||
init();
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
function init() {
|
||||
api.getMembers(poolID).success(success);
|
||||
api.getMembers(ctrl.poolId).success(success);
|
||||
}
|
||||
|
||||
function success(response) {
|
||||
|
@ -60,7 +60,7 @@
|
||||
ng-model="selected[item.id].checked"
|
||||
hz-select="item">
|
||||
</td>
|
||||
<td class="rsp-p1"><a ng-href="project/ngloadbalancersv2/pools/{$ ::table.pool_id $}/members/detail/{$ ::item.id $}">{$ ::item.id $}</a></td>
|
||||
<td class="rsp-p1"><a ng-href="project/ngloadbalancersv2/{$ ::table.loadbalancerId $}/listeners/{$ ::table.listenerId $}/pools/{$ ::table.poolId $}/members/{$ ::item.id $}">{$ ::item.id $}</a></td>
|
||||
<td class="rsp-p1">{$ ::item.address $}</td>
|
||||
<td class="rsp-p1">{$ ::item.protocol_port $}</td>
|
||||
<td class="rsp-p1">{$ ::item.weight $}</td>
|
||||
|
@ -41,52 +41,27 @@
|
||||
|
||||
function PoolDetailController(api, $routeParams, gettext) {
|
||||
var ctrl = this;
|
||||
ctrl.pool = {};
|
||||
ctrl.listener = {};
|
||||
ctrl.loadbalancer = {};
|
||||
ctrl.lb_algorithm_mappings = {
|
||||
|
||||
ctrl.loadBalancerAlgorithm = {
|
||||
'ROUND_ROBIN': gettext('Round Robin'),
|
||||
'LEAST_CONNECTIONS': gettext('Least Connections'),
|
||||
'SOURCE_IP': gettext('Source IP')
|
||||
};
|
||||
|
||||
var poolId = $routeParams.poolId;
|
||||
|
||||
init();
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
function init() {
|
||||
api.getPool(poolId).success(poolSuccess);
|
||||
api.getPool($routeParams.poolId).success(set('pool'));
|
||||
api.getListener($routeParams.listenerId).success(set('listener'));
|
||||
api.getLoadBalancer($routeParams.loadbalancerId).success(set('loadbalancer'));
|
||||
}
|
||||
|
||||
function poolSuccess(response) {
|
||||
ctrl.pool = response;
|
||||
if (ctrl.pool.hasOwnProperty('listeners') &&
|
||||
ctrl.pool.listeners.length > 0) {
|
||||
getListenerDetails(ctrl.pool.listeners[0].id);
|
||||
}
|
||||
}
|
||||
|
||||
function getListenerDetails(listenerId) {
|
||||
api.getListener(listenerId).success(listenerSuccess);
|
||||
}
|
||||
|
||||
function listenerSuccess(response) {
|
||||
ctrl.listener = response;
|
||||
|
||||
if (ctrl.listener.hasOwnProperty('loadbalancers') &&
|
||||
ctrl.listener.loadbalancers.length > 0) {
|
||||
getLoadBalancerDetails(ctrl.listener.loadbalancers[0].id);
|
||||
}
|
||||
}
|
||||
|
||||
function getLoadBalancerDetails(loadbalancerId) {
|
||||
api.getLoadBalancer(loadbalancerId).success(loadbalancerSuccess);
|
||||
}
|
||||
|
||||
function loadbalancerSuccess(response) {
|
||||
ctrl.loadbalancer = response;
|
||||
function set(property) {
|
||||
return angular.bind(null, function setProp(property, value) {
|
||||
ctrl[property] = value;
|
||||
}, property);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,83 +17,50 @@
|
||||
'use strict';
|
||||
|
||||
describe('LBaaS v2 Pool Detail Controller', function() {
|
||||
var controller, lbaasv2API, gettextService, pool, listener, loadbalancer;
|
||||
var lbaasv2API, ctrl;
|
||||
|
||||
function fakePoolAPI() {
|
||||
function fakeAPI() {
|
||||
return {
|
||||
success: function(callback) {
|
||||
callback(pool);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function fakeListenerAPI() {
|
||||
return {
|
||||
success: function(callback) {
|
||||
callback(listener);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function fakeLoadBalancerAPI() {
|
||||
return {
|
||||
success: function(callback) {
|
||||
callback(loadbalancer);
|
||||
callback('foo');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
///////////////////////
|
||||
|
||||
beforeEach(module('horizon.framework.util.http'));
|
||||
beforeEach(module('horizon.framework.util'));
|
||||
beforeEach(module('horizon.framework.widgets.toast'));
|
||||
beforeEach(module('horizon.framework.conf'));
|
||||
beforeEach(module('horizon.app.core.openstack-service-api'));
|
||||
beforeEach(module('horizon.dashboard.project.lbaasv2'));
|
||||
beforeEach(module('horizon.framework.util.i18n'));
|
||||
|
||||
beforeEach(inject(function($injector) {
|
||||
gettextService = $injector.get('horizon.framework.util.i18n.gettext');
|
||||
lbaasv2API = $injector.get('horizon.app.core.openstack-service-api.lbaasv2');
|
||||
controller = $injector.get('$controller');
|
||||
spyOn(lbaasv2API, 'getPool').and.callFake(fakePoolAPI);
|
||||
spyOn(lbaasv2API, 'getListener').and.callFake(fakeListenerAPI);
|
||||
spyOn(lbaasv2API, 'getLoadBalancer').and.callFake(fakeLoadBalancerAPI);
|
||||
spyOn(lbaasv2API, 'getPool').and.callFake(fakeAPI);
|
||||
spyOn(lbaasv2API, 'getListener').and.callFake(fakeAPI);
|
||||
spyOn(lbaasv2API, 'getLoadBalancer').and.callFake(fakeAPI);
|
||||
var controller = $injector.get('$controller');
|
||||
ctrl = controller('PoolDetailController', {
|
||||
$routeParams: {
|
||||
loadbalancerId: 'loadbalancerId',
|
||||
listenerId: 'listenerId',
|
||||
poolId: 'poolId'
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
function createController() {
|
||||
return controller('PoolDetailController', {
|
||||
api: lbaasv2API,
|
||||
$routeParams: { poolId: 'poolId' },
|
||||
gettext: gettextService
|
||||
});
|
||||
}
|
||||
|
||||
it('should invoke lbaasv2 apis', function() {
|
||||
pool = { id: 'poolId', listeners: [{id: 'listenerId'}] };
|
||||
listener = { id: 'listenerId', loadbalancers: [{id: 'loadbalancerId'}] };
|
||||
loadbalancer = { id: 'loadbalancerId' };
|
||||
createController();
|
||||
expect(lbaasv2API.getPool).toHaveBeenCalledWith('poolId');
|
||||
expect(lbaasv2API.getListener).toHaveBeenCalledWith('listenerId');
|
||||
expect(lbaasv2API.getLoadBalancer).toHaveBeenCalledWith('loadbalancerId');
|
||||
expect(ctrl.loadbalancer).toBe('foo');
|
||||
expect(ctrl.listener).toBe('foo');
|
||||
expect(ctrl.pool).toBe('foo');
|
||||
});
|
||||
|
||||
it('should not invoke the getListener or getLoadBalancer lbaasv2 api', function() {
|
||||
pool = { id: 'poolId', listeners: [] };
|
||||
createController();
|
||||
expect(lbaasv2API.getPool).toHaveBeenCalledWith('poolId');
|
||||
expect(lbaasv2API.getListener).not.toHaveBeenCalled();
|
||||
expect(lbaasv2API.getLoadBalancer).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not invoke getLoadBalancer lbaasv2 api', function() {
|
||||
pool = { id: 'poolId', listeners: [{id: 'listenerId'}] };
|
||||
listener = { id: 'listenerId', loadbalancers: [] };
|
||||
createController();
|
||||
expect(lbaasv2API.getPool).toHaveBeenCalledWith('poolId');
|
||||
expect(lbaasv2API.getListener).toHaveBeenCalledWith('listenerId');
|
||||
expect(lbaasv2API.getLoadBalancer).not.toHaveBeenCalled();
|
||||
it('should define mapping for the load balancer algorithm', function() {
|
||||
expect(ctrl.loadBalancerAlgorithm).toBeDefined();
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -2,8 +2,8 @@
|
||||
<div class='page-header'>
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="project/ngloadbalancersv2/"><translate>Load Balancers</translate></a></li>
|
||||
<li><a href="project/ngloadbalancersv2/detail/{$ ::ctrl.loadbalancer.id $}">{$ ::(ctrl.loadbalancer.name || ctrl.loadbalancer.id) $}</a></li>
|
||||
<li><a href="project/ngloadbalancersv2/listeners/detail/{$ ::ctrl.listener.id $}">{$ ::(ctrl.listener.name || ctrl.listener.id) $}</a></li>
|
||||
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}">{$ ::(ctrl.loadbalancer.name || ctrl.loadbalancer.id) $}</a></li>
|
||||
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}">{$ ::(ctrl.listener.name || ctrl.listener.id) $}</a></li>
|
||||
<li class="active">{$ ::(ctrl.pool.name || ctrl.pool.id) $}</li>
|
||||
</ol>
|
||||
<p ng-if="::ctrl.pool.description">{$ ::ctrl.pool.description $}</p>
|
||||
@ -30,7 +30,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<dt translate>Load Balancer Algorithm</dt>
|
||||
<dd>{$ ctrl.pool.lb_algorithm | decode:ctrl.lb_algorithm_mappings $}</dd>
|
||||
<dd>{$ ctrl.pool.lb_algorithm | decode:ctrl.loadBalancerAlgorithm $}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt translate>Session Persistence</dt>
|
||||
@ -47,7 +47,7 @@
|
||||
<dt translate>Health Monitor ID</dt>
|
||||
<dd>
|
||||
<div ng-if="ctrl.pool.healthmonitor_id">
|
||||
<a ng-href="project/ngloadbalancersv2/healthmonitors/detail/{$ ::ctrl.pool.healthmonitor_id $}">{$ ::ctrl.pool.healthmonitor_id $}</a>
|
||||
<a ng-href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}/pools/{$ ::ctrl.pool.id $}/healthmonitors/{$ ::ctrl.pool.healthmonitor_id $}">{$ ::ctrl.pool.healthmonitor_id $}</a>
|
||||
</div>
|
||||
<div ng-if="!ctrl.pool.healthmonitor_id">
|
||||
{$ 'None' | translate $}
|
||||
|
Loading…
Reference in New Issue
Block a user