Merge "Fix ports tab at Launch Instance dialog"
This commit is contained in:
commit
b4554a1951
@ -27,12 +27,18 @@
|
||||
.controller('LaunchInstanceNetworkPortController', LaunchInstanceNetworkPortController);
|
||||
|
||||
LaunchInstanceNetworkPortController.$inject = [
|
||||
'$scope',
|
||||
'horizon.dashboard.project.workflow.launch-instance.basePath',
|
||||
'launchInstanceModel',
|
||||
'horizon.framework.widgets.action-list.button-tooltip.row-warning.service'
|
||||
];
|
||||
|
||||
function LaunchInstanceNetworkPortController(basePath, launchInstanceModel, tooltipService) {
|
||||
function LaunchInstanceNetworkPortController(
|
||||
$scope,
|
||||
basePath,
|
||||
launchInstanceModel,
|
||||
tooltipService
|
||||
) {
|
||||
var ctrl = this;
|
||||
|
||||
ctrl.portStatuses = {
|
||||
@ -54,6 +60,20 @@
|
||||
'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) {
|
||||
return ctrl.portStatuses[status];
|
||||
}
|
||||
@ -62,12 +82,11 @@
|
||||
return ctrl.portAdminStates[state];
|
||||
}
|
||||
|
||||
var portsArr = launchInstanceModel.ports;
|
||||
ctrl.portsObj = {};
|
||||
ctrl.isPortsObjGenerated = false;
|
||||
|
||||
function getNameOrID(id) {
|
||||
ctrl.portsObj = ctrl.getPortsObj(portsArr);
|
||||
ctrl.portsObj = ctrl.getPortsObj(ctrl.ports);
|
||||
var port = ctrl.portsObj[id];
|
||||
return ctrl.nameOrID(port);
|
||||
}
|
||||
|
@ -23,10 +23,15 @@
|
||||
beforeEach(module('horizon.dashboard.project.workflow.launch-instance'));
|
||||
|
||||
describe('LaunchInstanceNetworkPortController', function() {
|
||||
var ctrl;
|
||||
var ctrl, scope;
|
||||
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 = {
|
||||
newInstanceSpec: {
|
||||
ports: ['port-a']
|
||||
@ -35,7 +40,7 @@
|
||||
};
|
||||
|
||||
ctrl = $controller('LaunchInstanceNetworkPortController',
|
||||
{ launchInstanceModel: model });
|
||||
{ $scope:scope, launchInstanceModel: model });
|
||||
}));
|
||||
|
||||
it('has correct ports statuses', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user