This is an automated email from the ASF dual-hosted git repository. jcabrerizo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git
The following commit(s) were added to refs/heads/master by this push: new e1cf5a6 Display error modal on HA operation failure new 4385873 Merge pull request #311 from algairim/ha-improvements e1cf5a6 is described below commit e1cf5a6b1282eedba5b30a6c6a0f872eed1b6c4f Author: Mykola Mandra <mykola.man...@cloudsoft.io> AuthorDate: Thu Nov 18 16:05:38 2021 +0000 Display error modal on HA operation failure Signed-off-by: Mykola Mandra <mykola.man...@cloudsoft.io> --- .../home/app/views/about/about.controller.js | 29 ++++++++++++++++------ .../home/app/views/about/about.template.html | 22 +++++++++++++--- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/ui-modules/home/app/views/about/about.controller.js b/ui-modules/home/app/views/about/about.controller.js index 95a5113..6b675e7 100644 --- a/ui-modules/home/app/views/about/about.controller.js +++ b/ui-modules/home/app/views/about/about.controller.js @@ -81,6 +81,11 @@ export function aboutStateController($scope, $rootScope, $element, $q, $uibModal $scope.expectedNodeCounter = Object.keys($scope.states.nodes).length; $scope.template = 'haStatusTemplate'; + $scope.operations = { + REMOVE_TERMINATED_NODE: 'Remove', + REMOVE_ALL_TERMINATED_NODES: 'Remove terminated nodes' + }; + $scope.importPersistence = function () { $rootScope.$broadcast('open-persistence-importer'); } @@ -193,8 +198,8 @@ export function aboutStateController($scope, $rootScope, $element, $q, $uibModal }); errorModal.closed.then(() => { - console.log('closing, wipe errors') $scope.errors = []; + $scope.haManageErrors = []; }) } }); @@ -202,24 +207,34 @@ export function aboutStateController($scope, $rootScope, $element, $q, $uibModal $scope.removeNode = function (nodeId) { $scope.template = 'spinnerTemplate'; let removeNode = serverApi.removeHaTerminatedNode(nodeId); - removeNode.then(data => { + removeNode.then(() => { $scope.expectedNodeCounter--; - $scope.container.dispatchEvent(new CustomEvent('update-states', {})); + }).catch(error => { + $scope.haManageErrors.push({ + operationName: $scope.operations.REMOVE_TERMINATED_NODE, + message: get(error, 'data.message', 'Unknown error.'), + }); }); + $scope.container.dispatchEvent(new CustomEvent('update-states', {})); } $scope.removeAllTerminatedNodes = function () { $scope.template = 'spinnerTemplate'; let removeNodes = serverApi.removeHaTerminatedNodes(); - removeNodes.then(data => { + removeNodes.then(() => { Object.values($scope.states.nodes).forEach( ({ status }) => { if (status === "TERMINATED" || status === "FAILED") $scope.expectedNodeCounter--; }); - $scope.container.dispatchEvent(new CustomEvent('update-states', {})); + }).catch(error => { + $scope.haManageErrors.push({ + operationName: $scope.operations.REMOVE_ALL_TERMINATED_NODES, + message: get(error, 'data.message', 'Unknown error.'), + }); }); - } + $scope.container.dispatchEvent(new CustomEvent('update-states', {})); + }; - $element.bind('update-states', (event) => { + $element.bind('update-states', () => { let updateStates = serverApi.getHaStates(); updateStates.then(({ data }) => { if (Object.keys(data.nodes).length === $scope.expectedNodeCounter) { diff --git a/ui-modules/home/app/views/about/about.template.html b/ui-modules/home/app/views/about/about.template.html index fc29f01..d887b39 100644 --- a/ui-modules/home/app/views/about/about.template.html +++ b/ui-modules/home/app/views/about/about.template.html @@ -71,7 +71,7 @@ HA status <button ng-if="states.nodes[states.ownId].status === 'MASTER'" ng-click="removeAllTerminatedNodes()" class="btn btn-sm btn-default" - style="float: right;">Remove terminated nodes</button> + style="float: right;">{{operations.REMOVE_ALL_TERMINATED_NODES}}</button> </h2> <script type="text/ng-template" id="haManageErrorsModal.html"> @@ -80,7 +80,7 @@ </div> <div class="modal-body"> The following errors occurred while attempting to edit the node's properties: - <table class="table table-responsive table-bordered table-hover"> + <table ng-if="(errors | filter: {configName:'!!'}).length > 0" class="table table-responsive table-bordered table-hover"> <thead> <tr> <th scope="col">Property name</th> @@ -88,12 +88,26 @@ </tr> </thead> <tbody> - <tr ng-repeat="error in errors track by error.configName"> + <tr ng-repeat="error in errors | filter: {configName: '!!'} track by error.configName"> <td><code>{{error.configName}}</code></td> <td><em>{{error.message}}</em></td> </tr> </tbody> </table> + <table ng-if="(errors | filter: {operationName:'!!'}).length > 0" class="table table-responsive table-bordered table-hover"> + <thead> + <tr> + <th scope="col">Operation name</th> + <th scope="col">Error message</th> + </tr> + </thead> + <tbody> + <tr ng-repeat="error in errors | filter: {operationName: '!!'} track by error.operationName"> + <td><code>{{error.operationName}}</code></td> + <td><em>{{error.message}}</em></td> + </tr> + </tbody> + </table> </div> <div class="modal-footer"> <button class="btn btn-lg btn-success" type="button" ng-click="okClicked()">OK</button> @@ -123,7 +137,7 @@ ng-show="row == $index">Manage</button> <button class="btn btn-sm btn-default" style="float: right;" ng-if="(node.status === 'TERMINATED') && (states.nodes[states.ownId].status === 'MASTER')" - ng-click="removeNode(node.nodeId)" ng-show="row == $index">Remove</button> + ng-click="removeNode(node.nodeId)" ng-show="row == $index">{{operations.REMOVE_TERMINATED_NODE}}</button> <span ng-if="node.nodeId === states.ownId" class="label label-info">current</span> <span ng-if="node.status === 'MASTER'" class="label label-success">master</span><br> </td>