Merge "Fix ports tab at Launch Instance dialog"
This commit is contained in:
commit
b4554a1951
@ -27,12 +27,18 @@
|
|||||||
.controller('LaunchInstanceNetworkPortController', LaunchInstanceNetworkPortController);
|
.controller('LaunchInstanceNetworkPortController', LaunchInstanceNetworkPortController);
|
||||||
|
|
||||||
LaunchInstanceNetworkPortController.$inject = [
|
LaunchInstanceNetworkPortController.$inject = [
|
||||||
|
'$scope',
|
||||||
'horizon.dashboard.project.workflow.launch-instance.basePath',
|
'horizon.dashboard.project.workflow.launch-instance.basePath',
|
||||||
'launchInstanceModel',
|
'launchInstanceModel',
|
||||||
'horizon.framework.widgets.action-list.button-tooltip.row-warning.service'
|
'horizon.framework.widgets.action-list.button-tooltip.row-warning.service'
|
||||||
];
|
];
|
||||||
|
|
||||||
function LaunchInstanceNetworkPortController(basePath, launchInstanceModel, tooltipService) {
|
function LaunchInstanceNetworkPortController(
|
||||||
|
$scope,
|
||||||
|
basePath,
|
||||||
|
launchInstanceModel,
|
||||||
|
tooltipService
|
||||||
|
) {
|
||||||
var ctrl = this;
|
var ctrl = this;
|
||||||
|
|
||||||
ctrl.portStatuses = {
|
ctrl.portStatuses = {
|
||||||
@ -54,6 +60,20 @@
|
|||||||
'virtio-forwarder': gettext('Virtio Forwarder')
|
'virtio-forwarder': gettext('Virtio Forwarder')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ctrl.ports = [];
|
||||||
|
|
||||||
|
var portsWatcher = $scope.$watchCollection(function() {
|
||||||
|
return launchInstanceModel.ports;
|
||||||
|
}, function (newValue, oldValue, scope) {
|
||||||
|
var ctrl = scope.ctrl;
|
||||||
|
ctrl.ports = newValue;
|
||||||
|
ctrl.isPortsObjGenerated = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.$on('$destroy', function() {
|
||||||
|
portsWatcher();
|
||||||
|
});
|
||||||
|
|
||||||
function getPortStatus(status) {
|
function getPortStatus(status) {
|
||||||
return ctrl.portStatuses[status];
|
return ctrl.portStatuses[status];
|
||||||
}
|
}
|
||||||
@ -62,12 +82,11 @@
|
|||||||
return ctrl.portAdminStates[state];
|
return ctrl.portAdminStates[state];
|
||||||
}
|
}
|
||||||
|
|
||||||
var portsArr = launchInstanceModel.ports;
|
|
||||||
ctrl.portsObj = {};
|
ctrl.portsObj = {};
|
||||||
ctrl.isPortsObjGenerated = false;
|
ctrl.isPortsObjGenerated = false;
|
||||||
|
|
||||||
function getNameOrID(id) {
|
function getNameOrID(id) {
|
||||||
ctrl.portsObj = ctrl.getPortsObj(portsArr);
|
ctrl.portsObj = ctrl.getPortsObj(ctrl.ports);
|
||||||
var port = ctrl.portsObj[id];
|
var port = ctrl.portsObj[id];
|
||||||
return ctrl.nameOrID(port);
|
return ctrl.nameOrID(port);
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,15 @@
|
|||||||
beforeEach(module('horizon.dashboard.project.workflow.launch-instance'));
|
beforeEach(module('horizon.dashboard.project.workflow.launch-instance'));
|
||||||
|
|
||||||
describe('LaunchInstanceNetworkPortController', function() {
|
describe('LaunchInstanceNetworkPortController', function() {
|
||||||
var ctrl;
|
var ctrl, scope;
|
||||||
var port = {name: 'test_name', id: 'test_id'};
|
var port = {name: 'test_name', id: 'test_id'};
|
||||||
|
|
||||||
beforeEach(inject(function($controller) {
|
beforeEach(inject(function($controller, $rootScope) {
|
||||||
|
scope = $rootScope.$new();
|
||||||
|
|
||||||
|
// Track calls to $watchCollection
|
||||||
|
spyOn(scope, '$watchCollection').and.callThrough();
|
||||||
|
|
||||||
var model = {
|
var model = {
|
||||||
newInstanceSpec: {
|
newInstanceSpec: {
|
||||||
ports: ['port-a']
|
ports: ['port-a']
|
||||||
@ -35,7 +40,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ctrl = $controller('LaunchInstanceNetworkPortController',
|
ctrl = $controller('LaunchInstanceNetworkPortController',
|
||||||
{ launchInstanceModel: model });
|
{ $scope:scope, launchInstanceModel: model });
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('has correct ports statuses', function() {
|
it('has correct ports statuses', function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user