Merge "Create base-port module to support create and update operations"
This commit is contained in:
commit
771861ee39
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2016 Cray Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Controller used to support operations on an Ironic port
|
||||
*/
|
||||
angular
|
||||
.module('horizon.dashboard.admin.ironic')
|
||||
.controller('BasePortController', BasePortController);
|
||||
|
||||
BasePortController.$inject = [
|
||||
'$uibModalInstance',
|
||||
'ctrl'
|
||||
];
|
||||
|
||||
function BasePortController($uibModalInstance,
|
||||
ctrl) {
|
||||
ctrl.port = {
|
||||
address: null,
|
||||
extra: {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Cancel the modal
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
ctrl.cancel = function() {
|
||||
$uibModalInstance.dismiss('cancel');
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete a port metadata property
|
||||
*
|
||||
* @param {string} propertyName - Name of the property
|
||||
* @return {void}
|
||||
*/
|
||||
ctrl.deleteExtra = function(propertyName) {
|
||||
delete ctrl.port.extra[propertyName];
|
||||
};
|
||||
|
||||
/**
|
||||
* Check whether the specified port metadata property already exists
|
||||
*
|
||||
* @param {string} propertyName - Name of the metadata property
|
||||
* @return {boolean} True if the property already exists,
|
||||
* otherwise false
|
||||
*/
|
||||
ctrl.checkExtraUnique = function(propertyName) {
|
||||
return !(propertyName in ctrl.port.extra);
|
||||
};
|
||||
}
|
||||
})();
|
@ -6,7 +6,7 @@
|
||||
aria-label="Close">
|
||||
<span aria-hidden="true" class="fa fa-times"></span>
|
||||
</button>
|
||||
<h3 class="modal-title" translate>Create Port</h3>
|
||||
<h3 class="modal-title">{$ ctrl.modalTitle $}</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="CreatePortForm" name="CreatePortForm">
|
||||
@ -82,9 +82,8 @@
|
||||
</button>
|
||||
<button type="submit"
|
||||
ng-disabled="CreatePortForm.$invalid || ExtraForm.$invalid"
|
||||
ng-click="ctrl.createPort()"
|
||||
class="btn btn-primary"
|
||||
translate>
|
||||
Create Port
|
||||
ng-click="ctrl.submit()"
|
||||
class="btn btn-primary">
|
||||
{$ ctrl.submitButtonTitle $}
|
||||
</button>
|
||||
</div>
|
@ -25,36 +25,27 @@
|
||||
|
||||
CreatePortController.$inject = [
|
||||
'$rootScope',
|
||||
'$controller',
|
||||
'$uibModalInstance',
|
||||
'horizon.app.core.openstack-service-api.ironic',
|
||||
'horizon.dashboard.admin.ironic.events',
|
||||
'$log',
|
||||
'node'
|
||||
];
|
||||
|
||||
function CreatePortController($rootScope,
|
||||
$controller,
|
||||
$uibModalInstance,
|
||||
ironic,
|
||||
ironicEvents,
|
||||
$log,
|
||||
node) {
|
||||
var ctrl = this;
|
||||
|
||||
// Paramater object that defines the port to be created
|
||||
ctrl.port = {
|
||||
node_uuid: node.id,
|
||||
address: null,
|
||||
extra: {}
|
||||
};
|
||||
$controller('BasePortController',
|
||||
{ctrl: ctrl,
|
||||
$uibModalInstance: $uibModalInstance});
|
||||
|
||||
/**
|
||||
* Cancel the port creation process
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
ctrl.cancel = function() {
|
||||
$uibModalInstance.dismiss('cancel');
|
||||
};
|
||||
ctrl.modalTitle = gettext("Create Port");
|
||||
ctrl.submitButtonTitle = ctrl.modalTtile;
|
||||
|
||||
/**
|
||||
* Create the defined port
|
||||
@ -62,6 +53,7 @@
|
||||
* @return {void}
|
||||
*/
|
||||
ctrl.createPort = function() {
|
||||
ctrl.port.node_uuid = node.id;
|
||||
ironic.createPort(ctrl.port).then(
|
||||
function() {
|
||||
$uibModalInstance.close();
|
||||
@ -71,25 +63,8 @@
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete a port metadata property
|
||||
*
|
||||
* @param {string} propertyName - Name of the property
|
||||
* @return {void}
|
||||
*/
|
||||
ctrl.deleteExtra = function(propertyName) {
|
||||
delete ctrl.port.extra[propertyName];
|
||||
};
|
||||
|
||||
/**
|
||||
* Check whether the specified port metadata property already exists
|
||||
*
|
||||
* @param {string} propertyName - Name of the metadata property
|
||||
* @return {boolean} True if the property already exists,
|
||||
* otherwise false
|
||||
*/
|
||||
ctrl.checkExtraUnique = function(propertyName) {
|
||||
return !(propertyName in ctrl.port.extra);
|
||||
ctrl.submit = function() {
|
||||
ctrl.createPort();
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
@ -41,7 +41,7 @@
|
||||
return node;
|
||||
}
|
||||
},
|
||||
templateUrl: basePath + '/create-port/create-port.html'
|
||||
templateUrl: basePath + '/base-port/base-port.html'
|
||||
};
|
||||
return $uibModal.open(options);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user