Merge "Eliminate unnecessary event handling code"
This commit is contained in:
commit
e9648b7e9d
@ -28,11 +28,18 @@
|
||||
|
||||
function createPortService($uibModal, basePath) {
|
||||
var service = {
|
||||
modal: modal
|
||||
createPort: createPort
|
||||
};
|
||||
return service;
|
||||
|
||||
function modal(node) {
|
||||
/**
|
||||
* @description Launch a modal dialog that will guide the user
|
||||
* in creating a new port
|
||||
*
|
||||
* @param {object} node - Node to which the port will be associated
|
||||
* @return {promise} Object describing the created port
|
||||
*/
|
||||
function createPort(node) {
|
||||
var options = {
|
||||
controller: 'CreatePortController as ctrl',
|
||||
backdrop: 'static',
|
||||
|
@ -28,10 +28,10 @@
|
||||
|
||||
function editNodeService($uibModal, basePath) {
|
||||
var service = {
|
||||
modal: modal
|
||||
editNode: editNode
|
||||
};
|
||||
|
||||
function modal(node) {
|
||||
function editNode(node) {
|
||||
var options = {
|
||||
controller: 'EditNodeController as ctrl',
|
||||
backdrop: 'static',
|
||||
@ -42,7 +42,7 @@
|
||||
},
|
||||
templateUrl: basePath + '/base-node/base-node.html'
|
||||
};
|
||||
return $uibModal.open(options);
|
||||
return $uibModal.open(options).result;
|
||||
}
|
||||
|
||||
return service;
|
||||
|
@ -28,10 +28,17 @@
|
||||
|
||||
function editPortService($uibModal, basePath) {
|
||||
var service = {
|
||||
modal: modal
|
||||
editPort: editPort
|
||||
};
|
||||
|
||||
function modal(port, node) {
|
||||
/**
|
||||
* @description: Edit a specified port
|
||||
*
|
||||
* @param {object} port - Port to be edited
|
||||
* @param {object} node - Node to which the port is attached
|
||||
* @return {promise} Promise containing the updated port
|
||||
*/
|
||||
function editPort(port, node) {
|
||||
var options = {
|
||||
controller: 'EditPortController as ctrl',
|
||||
backdrop: 'static',
|
||||
|
@ -31,6 +31,12 @@
|
||||
enrollNode: enrollNode
|
||||
};
|
||||
|
||||
/**
|
||||
* @description Launch a modal dialog that will guide the user
|
||||
* in enrolling a new node
|
||||
*
|
||||
* @return {promise} Object describing the enrolled node
|
||||
*/
|
||||
function enrollNode() {
|
||||
var options = {
|
||||
controller: 'EnrollNodeController as ctrl',
|
||||
|
@ -45,7 +45,6 @@
|
||||
'horizon.app.core.openstack-service-api.ironic',
|
||||
'horizon.dashboard.admin.ironic.events',
|
||||
'horizon.framework.widgets.modal.deleteModalService',
|
||||
'horizon.dashboard.admin.ironic.create-port.service',
|
||||
'horizon.dashboard.admin.ironic.clean-node.service',
|
||||
'$q',
|
||||
'$rootScope'
|
||||
@ -54,12 +53,10 @@
|
||||
function actions(ironic,
|
||||
ironicEvents,
|
||||
deleteModalService,
|
||||
createPortService,
|
||||
cleanNodeService,
|
||||
$q,
|
||||
$rootScope) {
|
||||
var service = {
|
||||
createPort: createPort,
|
||||
deleteNode: deleteNode,
|
||||
deletePort: deletePort,
|
||||
setPowerState: setPowerState,
|
||||
@ -178,10 +175,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function createPort(node) {
|
||||
return createPortService.modal(node);
|
||||
}
|
||||
|
||||
function deletePort(ports) {
|
||||
var context = {
|
||||
labels: {
|
||||
|
@ -24,14 +24,13 @@
|
||||
|
||||
IronicNodeDetailsController.$inject = [
|
||||
'$scope',
|
||||
'$rootScope',
|
||||
'$location',
|
||||
'horizon.framework.widgets.toast.service',
|
||||
'horizon.app.core.openstack-service-api.ironic',
|
||||
'horizon.dashboard.admin.ironic.events',
|
||||
'horizon.dashboard.admin.ironic.actions',
|
||||
'horizon.dashboard.admin.ironic.basePath',
|
||||
'horizon.dashboard.admin.ironic.edit-node.service',
|
||||
'horizon.dashboard.admin.ironic.create-port.service',
|
||||
'horizon.dashboard.admin.ironic.edit-port.service',
|
||||
'horizon.dashboard.admin.ironic.maintenance.service',
|
||||
'horizon.dashboard.admin.ironic.node-state-transition.service',
|
||||
@ -39,14 +38,13 @@
|
||||
];
|
||||
|
||||
function IronicNodeDetailsController($scope,
|
||||
$rootScope,
|
||||
$location,
|
||||
toastService,
|
||||
ironic,
|
||||
ironicEvents,
|
||||
actions,
|
||||
basePath,
|
||||
editNodeService,
|
||||
createPortService,
|
||||
editPortService,
|
||||
maintenanceService,
|
||||
nodeStateTransitionService,
|
||||
@ -94,31 +92,6 @@
|
||||
|
||||
$scope.isDefined = angular.isDefined;
|
||||
|
||||
var editNodeHandler =
|
||||
$rootScope.$on(ironicEvents.EDIT_NODE_SUCCESS,
|
||||
function() {
|
||||
init();
|
||||
});
|
||||
|
||||
var createPortHandler =
|
||||
$rootScope.$on(ironicEvents.CREATE_PORT_SUCCESS,
|
||||
function() {
|
||||
init();
|
||||
});
|
||||
|
||||
var deletePortHandler =
|
||||
$rootScope.$on(ironicEvents.DELETE_PORT_SUCCESS,
|
||||
function() {
|
||||
init();
|
||||
$scope.$broadcast('hzTable:clearSelected');
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
editNodeHandler();
|
||||
createPortHandler();
|
||||
deletePortHandler();
|
||||
});
|
||||
|
||||
init();
|
||||
|
||||
/**
|
||||
@ -240,7 +213,9 @@
|
||||
* @return {void}
|
||||
*/
|
||||
function editNode() {
|
||||
editNodeService.modal(ctrl.node);
|
||||
editNodeService.editNode(ctrl.node).then(function() {
|
||||
ctrl.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -251,7 +226,9 @@
|
||||
* @return {void}
|
||||
*/
|
||||
function createPort() {
|
||||
ctrl.actions.createPort(ctrl.node);
|
||||
createPortService.createPort(ctrl.node).then(function() {
|
||||
ctrl.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -261,7 +238,7 @@
|
||||
* @return {void}
|
||||
*/
|
||||
function editPort(port) {
|
||||
editPortService.modal(port, ctrl.node).then(function() {
|
||||
editPortService.editPort(port, ctrl.node).then(function() {
|
||||
ctrl.refresh();
|
||||
});
|
||||
}
|
||||
@ -274,7 +251,9 @@
|
||||
* @return {void}
|
||||
*/
|
||||
function deletePort(ports) {
|
||||
actions.deletePort(ports);
|
||||
actions.deletePort(ports).then(function() {
|
||||
ctrl.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,12 +55,6 @@
|
||||
callback="ctrl.toggleConsoleMode">
|
||||
{$ ctrl.node.console_enabled ? 'Disable console' : 'Enable console' | translate $}
|
||||
</action>
|
||||
<action button-type="menu-item"
|
||||
disabled="isDefined(ctrl.nodeValidationMap.console)
|
||||
&& ctrl.nodeValidationMap.console.result===false"
|
||||
callback="ctrl.toggleConsoleMode">
|
||||
{$ ctrl.node.console_enabled ? 'Disable console' : 'Enable console' | translate $}
|
||||
</action>
|
||||
</menu>
|
||||
</action-list>
|
||||
</div>
|
||||
|
@ -22,29 +22,25 @@
|
||||
.controller('IronicNodeListController', IronicNodeListController);
|
||||
|
||||
IronicNodeListController.$inject = [
|
||||
'$scope',
|
||||
'$rootScope',
|
||||
'$q',
|
||||
'horizon.framework.widgets.toast.service',
|
||||
'horizon.app.core.openstack-service-api.ironic',
|
||||
'horizon.dashboard.admin.ironic.events',
|
||||
'horizon.dashboard.admin.ironic.actions',
|
||||
'horizon.dashboard.admin.ironic.maintenance.service',
|
||||
'horizon.dashboard.admin.ironic.enroll-node.service',
|
||||
'horizon.dashboard.admin.ironic.edit-node.service',
|
||||
'horizon.dashboard.admin.ironic.create-port.service',
|
||||
'horizon.dashboard.admin.ironic.node-state-transition.service'
|
||||
];
|
||||
|
||||
function IronicNodeListController($scope,
|
||||
$rootScope,
|
||||
$q,
|
||||
function IronicNodeListController($q,
|
||||
toastService,
|
||||
ironic,
|
||||
ironicEvents,
|
||||
actions,
|
||||
maintenanceService,
|
||||
enrollNodeService,
|
||||
editNodeService,
|
||||
createPortService,
|
||||
nodeStateTransitionService) {
|
||||
var ctrl = this;
|
||||
|
||||
@ -55,6 +51,8 @@
|
||||
|
||||
ctrl.enrollNode = enrollNode;
|
||||
ctrl.editNode = editNode;
|
||||
ctrl.deleteNode = deleteNode;
|
||||
ctrl.createPort = createPort;
|
||||
ctrl.refresh = refresh;
|
||||
ctrl.getNodeStateTransitions = getNodeStateTransitions;
|
||||
|
||||
@ -95,41 +93,6 @@
|
||||
}
|
||||
];
|
||||
|
||||
// Listen for the creation of new nodes, and update the node list
|
||||
var enrollNodeHandler =
|
||||
$rootScope.$on(ironicEvents.ENROLL_NODE_SUCCESS,
|
||||
function() {
|
||||
init();
|
||||
});
|
||||
|
||||
var deleteNodeHandler = $rootScope.$on(ironicEvents.DELETE_NODE_SUCCESS,
|
||||
function() {
|
||||
init();
|
||||
});
|
||||
|
||||
var editNodeHandler = $rootScope.$on(ironicEvents.EDIT_NODE_SUCCESS,
|
||||
function() {
|
||||
init();
|
||||
});
|
||||
|
||||
var createPortHandler = $rootScope.$on(ironicEvents.CREATE_PORT_SUCCESS,
|
||||
function() {
|
||||
init();
|
||||
});
|
||||
|
||||
var deletePortHandler = $rootScope.$on(ironicEvents.DELETE_PORT_SUCCESS,
|
||||
function() {
|
||||
init();
|
||||
});
|
||||
|
||||
$scope.$on('destroy', function() {
|
||||
enrollNodeHandler();
|
||||
deleteNodeHandler();
|
||||
editNodeHandler();
|
||||
createPortHandler();
|
||||
deletePortHandler();
|
||||
});
|
||||
|
||||
init();
|
||||
|
||||
// RETRIVE NODES AND PORTS
|
||||
@ -162,11 +125,29 @@
|
||||
}
|
||||
|
||||
function enrollNode() {
|
||||
enrollNodeService.enrollNode();
|
||||
enrollNodeService.enrollNode().then(function() {
|
||||
ctrl.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
function editNode(node) {
|
||||
editNodeService.modal(node);
|
||||
editNodeService.editNode(node).then(function() {
|
||||
ctrl.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
function deleteNode(nodes) {
|
||||
actions.deleteNode(nodes).then(
|
||||
function() {
|
||||
ctrl.refresh();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function createPort(node) {
|
||||
createPortService.createPort(node).then(function() {
|
||||
ctrl.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
|
@ -29,7 +29,7 @@
|
||||
<action-list uib-dropdown class="pull-right">
|
||||
<action button-type="split-button"
|
||||
action-classes="'btn btn-default btn-sm'"
|
||||
callback="table.actions.deleteNode"
|
||||
callback="table.deleteNode"
|
||||
item="tCtrl.selected"
|
||||
disabled="tCtrl.selected.length === 0">
|
||||
<span class="fa fa-trash"></span>
|
||||
@ -165,14 +165,14 @@
|
||||
{$ ::'Maintenance off' | translate $}
|
||||
</action>
|
||||
<action button-type="menu-item"
|
||||
callback="table.actions.deleteNode"
|
||||
callback="table.deleteNode"
|
||||
disabled="!(node.provision_state === 'available' || node.provision_state === 'nostate' || node.provision_state === 'manageable' || node.provision_state === 'enroll')"
|
||||
item="[node]">
|
||||
<span class="fa fa-trash"></span>
|
||||
{$ ::'Delete node' | translate $}
|
||||
</action>
|
||||
<action button-type="menu-item"
|
||||
callback="table.actions.createPort"
|
||||
callback="table.createPort"
|
||||
item="node">
|
||||
{$ ::'Create port' | translate $}
|
||||
</action>
|
||||
|
Loading…
Reference in New Issue
Block a user