2020-04-10 21:54:53 +00:00
|
|
|
angular.module('portainer.integrations.storidge').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);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
2019-05-24 21:53:10 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
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');
|
|
|
|
});
|
|
|
|
}
|
2019-05-24 21:53:10 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
$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);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
2019-05-24 21:53:10 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
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');
|
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$state.reload();
|
|
|
|
});
|
|
|
|
}
|
2019-05-24 21:53:10 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
$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);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
2019-05-24 21:53:10 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
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');
|
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$state.reload();
|
|
|
|
});
|
|
|
|
}
|
2019-05-24 21:53:10 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
function initView() {
|
|
|
|
$scope.name = $transition$.params().name;
|
2019-05-24 21:53:10 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
StoridgeNodeService.node($scope.name)
|
|
|
|
.then(function success(data) {
|
|
|
|
$scope.node = data;
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to retrieve node details');
|
|
|
|
});
|
|
|
|
}
|
2019-05-24 21:53:10 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
initView();
|
|
|
|
},
|
|
|
|
]);
|