2020-04-10 21:54:53 +00:00
|
|
|
angular.module('portainer.integrations.storidge').controller('StoridgeClusterController', [
|
|
|
|
'$q',
|
|
|
|
'$scope',
|
|
|
|
'$state',
|
|
|
|
'Notifications',
|
|
|
|
'StoridgeClusterService',
|
|
|
|
'StoridgeNodeService',
|
|
|
|
'ModalService',
|
|
|
|
function ($q, $scope, $state, Notifications, StoridgeClusterService, StoridgeNodeService, ModalService) {
|
|
|
|
$scope.state = {
|
|
|
|
shutdownInProgress: false,
|
|
|
|
rebootInProgress: false,
|
|
|
|
};
|
2018-01-21 16:26:24 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
$scope.rebootCluster = function () {
|
|
|
|
ModalService.confirm({
|
|
|
|
title: 'Are you sure?',
|
|
|
|
message: 'All the nodes in the cluster will reboot during the process. Do you want to reboot the Storidge cluster?',
|
|
|
|
buttons: {
|
|
|
|
confirm: {
|
|
|
|
label: 'Reboot',
|
|
|
|
className: 'btn-danger',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
callback: function onConfirm(confirmed) {
|
|
|
|
if (!confirmed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rebootCluster();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
2018-01-21 16:26:24 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
function rebootCluster() {
|
|
|
|
$scope.state.rebootInProgress = true;
|
|
|
|
StoridgeClusterService.reboot().finally(function final() {
|
|
|
|
$scope.state.rebootInProgress = false;
|
|
|
|
Notifications.success('Cluster successfully rebooted');
|
|
|
|
$state.reload();
|
|
|
|
});
|
|
|
|
}
|
2018-01-21 16:26:24 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
$scope.shutdownCluster = function () {
|
|
|
|
ModalService.confirm({
|
|
|
|
title: 'Are you sure?',
|
|
|
|
message: 'All the nodes in the cluster will shutdown. Do you want to shutdown the Storidge cluster?',
|
|
|
|
buttons: {
|
|
|
|
confirm: {
|
|
|
|
label: 'Shutdown',
|
|
|
|
className: 'btn-danger',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
callback: function onConfirm(confirmed) {
|
|
|
|
if (!confirmed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
shutdownCluster();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
2019-05-24 21:53:10 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
function shutdownCluster() {
|
|
|
|
$scope.state.shutdownInProgress = true;
|
|
|
|
StoridgeClusterService.shutdown().finally(function final() {
|
|
|
|
$scope.state.shutdownInProgress = false;
|
|
|
|
Notifications.success('Cluster successfully shutdown');
|
|
|
|
$state.go('docker.dashboard');
|
|
|
|
});
|
|
|
|
}
|
2018-01-21 16:26:24 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
function initView() {
|
|
|
|
$q.all({
|
|
|
|
info: StoridgeClusterService.info(),
|
|
|
|
version: StoridgeClusterService.version(),
|
|
|
|
nodes: StoridgeNodeService.nodes(),
|
|
|
|
})
|
|
|
|
.then(function success(data) {
|
|
|
|
$scope.clusterInfo = data.info;
|
|
|
|
$scope.clusterVersion = data.version;
|
|
|
|
$scope.clusterNodes = data.nodes;
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to retrieve cluster information');
|
|
|
|
});
|
|
|
|
}
|
2018-01-21 16:26:24 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
initView();
|
|
|
|
},
|
|
|
|
]);
|