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