diff --git a/ironic_ui/static/dashboard/admin/ironic/create-port/create-port.service.js b/ironic_ui/static/dashboard/admin/ironic/create-port/create-port.service.js index e90f03e0..6551712e 100644 --- a/ironic_ui/static/dashboard/admin/ironic/create-port/create-port.service.js +++ b/ironic_ui/static/dashboard/admin/ironic/create-port/create-port.service.js @@ -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', diff --git a/ironic_ui/static/dashboard/admin/ironic/edit-node/edit-node.service.js b/ironic_ui/static/dashboard/admin/ironic/edit-node/edit-node.service.js index 18fc8ffc..854cdcc6 100644 --- a/ironic_ui/static/dashboard/admin/ironic/edit-node/edit-node.service.js +++ b/ironic_ui/static/dashboard/admin/ironic/edit-node/edit-node.service.js @@ -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; diff --git a/ironic_ui/static/dashboard/admin/ironic/edit-port/edit-port.service.js b/ironic_ui/static/dashboard/admin/ironic/edit-port/edit-port.service.js index 2d1dcb5f..9f209984 100644 --- a/ironic_ui/static/dashboard/admin/ironic/edit-port/edit-port.service.js +++ b/ironic_ui/static/dashboard/admin/ironic/edit-port/edit-port.service.js @@ -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', diff --git a/ironic_ui/static/dashboard/admin/ironic/enroll-node/enroll-node.service.js b/ironic_ui/static/dashboard/admin/ironic/enroll-node/enroll-node.service.js index 9e953808..77637696 100644 --- a/ironic_ui/static/dashboard/admin/ironic/enroll-node/enroll-node.service.js +++ b/ironic_ui/static/dashboard/admin/ironic/enroll-node/enroll-node.service.js @@ -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', diff --git a/ironic_ui/static/dashboard/admin/ironic/node-actions.service.js b/ironic_ui/static/dashboard/admin/ironic/node-actions.service.js index ab361ce0..c47f3e93 100755 --- a/ironic_ui/static/dashboard/admin/ironic/node-actions.service.js +++ b/ironic_ui/static/dashboard/admin/ironic/node-actions.service.js @@ -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: { diff --git a/ironic_ui/static/dashboard/admin/ironic/node-details/node-details.controller.js b/ironic_ui/static/dashboard/admin/ironic/node-details/node-details.controller.js index 530d5888..ebb4730e 100755 --- a/ironic_ui/static/dashboard/admin/ironic/node-details/node-details.controller.js +++ b/ironic_ui/static/dashboard/admin/ironic/node-details/node-details.controller.js @@ -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(); + }); } /** diff --git a/ironic_ui/static/dashboard/admin/ironic/node-details/node-details.html b/ironic_ui/static/dashboard/admin/ironic/node-details/node-details.html index 5ec06d2c..bacf7e98 100644 --- a/ironic_ui/static/dashboard/admin/ironic/node-details/node-details.html +++ b/ironic_ui/static/dashboard/admin/ironic/node-details/node-details.html @@ -55,12 +55,6 @@ callback="ctrl.toggleConsoleMode"> {$ ctrl.node.console_enabled ? 'Disable console' : 'Enable console' | translate $} - - {$ ctrl.node.console_enabled ? 'Disable console' : 'Enable console' | translate $} - diff --git a/ironic_ui/static/dashboard/admin/ironic/node-list/node-list.controller.js b/ironic_ui/static/dashboard/admin/ironic/node-list/node-list.controller.js index 871f66bd..7f3a6e34 100755 --- a/ironic_ui/static/dashboard/admin/ironic/node-list/node-list.controller.js +++ b/ironic_ui/static/dashboard/admin/ironic/node-list/node-list.controller.js @@ -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() { diff --git a/ironic_ui/static/dashboard/admin/ironic/node-list/node-list.html b/ironic_ui/static/dashboard/admin/ironic/node-list/node-list.html index 3bcddd6a..2060dcc5 100644 --- a/ironic_ui/static/dashboard/admin/ironic/node-list/node-list.html +++ b/ironic_ui/static/dashboard/admin/ironic/node-list/node-list.html @@ -29,7 +29,7 @@ @@ -165,14 +165,14 @@ {$ ::'Maintenance off' | translate $} {$ ::'Delete node' | translate $} {$ ::'Create port' | translate $}