Improvements to enroll-node service

- Rename the modal function to enrollNode which better desribes its role
- The enrollNode function returns a promise that when successfully
resolved will contain the newly enrolled node. This change can be
used to support more efficient UI updates.

Change-Id: Id8f46cf85b6a1adb65c87d3c10729aea123241e7
This commit is contained in:
Peter Piela 2017-01-27 12:30:00 -05:00
parent 6bc5cf3f95
commit ed87e4f117
3 changed files with 5 additions and 12 deletions

View File

@ -74,15 +74,8 @@
ironic.createNode(ctrl.node).then( ironic.createNode(ctrl.node).then(
function(response) { function(response) {
$log.info("create node response = " + JSON.stringify(response)); $log.info("create node response = " + JSON.stringify(response));
$uibModalInstance.close();
$rootScope.$emit(ironicEvents.ENROLL_NODE_SUCCESS); $rootScope.$emit(ironicEvents.ENROLL_NODE_SUCCESS);
if (ctrl.moveNodeToManageableState) { $uibModalInstance.close(response.data);
$log.info("Setting node provision state");
ironic.setNodeProvisionState(response.data.uuid, 'manage');
}
},
function() {
// No additional error processing for now
}); });
$log.debug("<< EnrollNodeController.submit()"); $log.debug("<< EnrollNodeController.submit()");
}; };

View File

@ -28,16 +28,16 @@
function enrollNodeService($uibModal, basePath) { function enrollNodeService($uibModal, basePath) {
var service = { var service = {
modal: modal enrollNode: enrollNode
}; };
function modal() { function enrollNode() {
var options = { var options = {
controller: 'EnrollNodeController as ctrl', controller: 'EnrollNodeController as ctrl',
backdrop: 'static', backdrop: 'static',
templateUrl: basePath + '/base-node/base-node.html' templateUrl: basePath + '/base-node/base-node.html'
}; };
return $uibModal.open(options); return $uibModal.open(options).result;
} }
return service; return service;

View File

@ -181,7 +181,7 @@
} }
function enrollNode() { function enrollNode() {
enrollNodeService.modal(); enrollNodeService.enrollNode();
} }
function editNode(node) { function editNode(node) {