diff --git a/app/extensions/storidge/components/nodes-datatable/storidgeNodesDatatable.html b/app/extensions/storidge/components/nodes-datatable/storidgeNodesDatatable.html index e9f3cef61..58f55a707 100644 --- a/app/extensions/storidge/components/nodes-datatable/storidgeNodesDatatable.html +++ b/app/extensions/storidge/components/nodes-datatable/storidgeNodesDatatable.html @@ -7,18 +7,23 @@
- - - +
+ +
+ + To add a node to this cluster, run the following command on your new node + + {{ $ctrl.addInfo }} + + Copy + + + + +
+
diff --git a/app/extensions/storidge/views/cluster/clusterController.js b/app/extensions/storidge/views/cluster/clusterController.js index 84c320e83..0bf2a1568 100644 --- a/app/extensions/storidge/views/cluster/clusterController.js +++ b/app/extensions/storidge/views/cluster/clusterController.js @@ -1,126 +1,12 @@ angular.module('extension.storidge') -.controller('StoridgeClusterController', ['$q', '$scope', '$state', 'clipboard', 'Notifications', 'StoridgeClusterService', 'StoridgeNodeService', 'ModalService', -function ($q, $scope, $state, clipboard, Notifications, StoridgeClusterService, StoridgeNodeService, ModalService) { +.controller('StoridgeClusterController', ['$q', '$scope', '$state', 'Notifications', 'StoridgeClusterService', 'StoridgeNodeService', 'ModalService', +function ($q, $scope, $state, Notifications, StoridgeClusterService, StoridgeNodeService, ModalService) { $scope.state = { shutdownInProgress: false, rebootInProgress: false }; - $scope.copyAddNodeCommand = function() { - clipboard.copyText($scope.addInfo); - $('#copyNotification').show(); - $('#copyNotification').fadeOut(2000); - }; - - $scope.removeAction = function(selectedItems) { - ModalService.confirm({ - title: 'Are you sure?', - message: 'Do you want really want to remove the nodes from the cluster?', - buttons: { - confirm: { - label: 'Remove', - className: 'btn-danger' - } - }, - callback: function onConfirm(confirmed) { - if(!confirmed) { return; } - remove(selectedItems); - } - }); - }; - - function remove(selectedItems) { - var actionCount = selectedItems.length; - angular.forEach(selectedItems, function (node) { - StoridgeNodeService.remove(node.Name) - .then(function success() { - Notifications.success('Node successfully removed', node.Name); - }) - .catch(function error(err) { - Notifications.error('Failure', err, 'Unable to remove node'); - }) - .finally(function final() { - --actionCount; - if (actionCount === 0) { - $state.reload(); - } - }); - }); - } - - $scope.cordonNodeAction = function(selectedItems) { - ModalService.confirm({ - title: 'Are you sure?', - message: 'Do you want really want to put the nodes in maintenance mode?', - buttons: { - confirm: { - label: 'Cordon', - className: 'btn-danger' - } - }, - callback: function onConfirm(confirmed) { - if(!confirmed) { return; } - cordonNode(selectedItems); - } - }); - }; - - function cordonNode(selectedItems) { - var actionCount = selectedItems.length; - angular.forEach(selectedItems, function (node) { - StoridgeNodeService.cordon(node.Name) - .then(function success() { - Notifications.success('Node successfully put in maintenance', node.Name); - }) - .catch(function error(err) { - Notifications.error('Failure', err, 'Unable to put node in maintenance mode'); - }) - .finally(function final() { - --actionCount; - if (actionCount === 0) { - $state.reload(); - } - }); - }); - } - - $scope.uncordonNodeAction = function(selectedItems) { - ModalService.confirm({ - title: 'Are you sure?', - message: 'Do you want really want to bring the nodes out of maintenance mode?', - buttons: { - confirm: { - label: 'Uncordon', - className: 'btn-danger' - } - }, - callback: function onConfirm(confirmed) { - if(!confirmed) { return; } - uncordonNode(selectedItems); - } - }); - }; - - function uncordonNode(selectedItems) { - var actionCount = selectedItems.length; - angular.forEach(selectedItems, function (node) { - StoridgeNodeService.uncordon(node.Name) - .then(function success() { - Notifications.success('Node successfully bringed back', node.Name); - }) - .catch(function error(err) { - Notifications.error('Failure', err, 'Unable to put node out of maintenance mode'); - }) - .finally(function final() { - --actionCount; - if (actionCount === 0) { - $state.reload(); - } - }); - }); - } - $scope.rebootCluster = function() { ModalService.confirm({ title: 'Are you sure?', @@ -179,14 +65,12 @@ function ($q, $scope, $state, clipboard, Notifications, StoridgeClusterService, $q.all({ info: StoridgeClusterService.info(), version: StoridgeClusterService.version(), - nodes: StoridgeNodeService.nodes(), - addInfo: StoridgeNodeService.add() + nodes: StoridgeNodeService.nodes() }) .then(function success(data) { $scope.clusterInfo = data.info; $scope.clusterVersion = data.version; $scope.clusterNodes = data.nodes; - $scope.addInfo = data.addInfo.content; }) .catch(function error(err) { Notifications.error('Failure', err, 'Unable to retrieve cluster information'); diff --git a/app/extensions/storidge/views/nodes/inspect/node.html b/app/extensions/storidge/views/nodes/inspect/node.html index 900c8e673..d1edbbc0b 100644 --- a/app/extensions/storidge/views/nodes/inspect/node.html +++ b/app/extensions/storidge/views/nodes/inspect/node.html @@ -9,7 +9,19 @@
- + + + + + diff --git a/app/extensions/storidge/views/nodes/inspect/nodeController.js b/app/extensions/storidge/views/nodes/inspect/nodeController.js index 453f7f9b7..47cb15acc 100644 --- a/app/extensions/storidge/views/nodes/inspect/nodeController.js +++ b/app/extensions/storidge/views/nodes/inspect/nodeController.js @@ -1,7 +1,88 @@ angular.module('extension.storidge') -.controller('StoridgeNodeController', ['$scope', '$state', '$transition$', 'Notifications', 'StoridgeNodeService', -function ($scope, $state, $transition$, Notifications, StoridgeNodeService) { +.controller('StoridgeNodeController', ['$scope', '$state', '$transition$', 'Notifications', 'StoridgeNodeService', 'ModalService', +function ($scope, $state, $transition$, Notifications, StoridgeNodeService, ModalService) { + $scope.removeNodeAction = function(selectedItems) { + ModalService.confirm({ + title: 'Are you sure?', + message: 'Do you want really want to remove the node from the cluster?', + buttons: { + confirm: { + label: 'Remove', + className: 'btn-danger' + } + }, + callback: function onConfirm(confirmed) { + if(!confirmed) { return; } + remove(selectedItems); + } + }); + }; + + function remove() { + StoridgeNodeService.remove($scope.node.Name) + .then(function success() { + Notifications.success('Node successfully removed', $scope.node.Name); + $state.go('storidge.cluster'); + }) + .catch(function error(err) { + Notifications.error('Failure', err, 'Unable to remove node'); + }); + } + + $scope.cordonNodeAction = function(selectedItems) { + ModalService.confirm({ + title: 'Are you sure?', + message: 'Do you want really want to put the node in maintenance mode?', + buttons: { + confirm: { + label: 'Enter maintenance', + className: 'btn-danger' + } + }, + callback: function onConfirm(confirmed) { + if(!confirmed) { return; } + cordonNode(selectedItems); + } + }); + }; + + function cordonNode() { + StoridgeNodeService.cordon($scope.node.Name) + .then(function success() { + Notifications.success('Node successfully put in maintenance'); + }) + .catch(function error(err) { + Notifications.error('Failure', err, 'Unable to put node in maintenance mode'); + }); + } + + $scope.uncordonNodeAction = function(selectedItems) { + ModalService.confirm({ + title: 'Are you sure?', + message: 'Do you want really want to bring the nodes out of maintenance mode?', + buttons: { + confirm: { + label: 'Exit maintenance', + className: 'btn-danger' + } + }, + callback: function onConfirm(confirmed) { + if(!confirmed) { return; } + uncordonNode(selectedItems); + } + }); + }; + + function uncordonNode() { + StoridgeNodeService.uncordon($scope.node.Name) + .then(function success() { + Notifications.success('Node successfully bringed back'); + }) + .catch(function error(err) { + Notifications.error('Failure', err, 'Unable to put node out of maintenance mode'); + }); + } function initView() { $scope.name = $transition$.params().name; diff --git a/app/portainer/services/notifications.js b/app/portainer/services/notifications.js index d1cd8eb80..1d212435b 100644 --- a/app/portainer/services/notifications.js +++ b/app/portainer/services/notifications.js @@ -17,6 +17,8 @@ angular.module('portainer.app') msg = e.data.details; } else if (e.data && e.data.message) { msg = e.data.message; + } else if (e.data && e.data.content) { + msg = e.data.content; } else if (e.message) { msg = e.message; } else if (e.err && e.err.data && e.err.data.message) {