mirror of
https://github.com/portainer/portainer.git
synced 2025-08-04 13:25:26 +02:00
extension(storidge): add Storidge extension (#1581)
This commit is contained in:
parent
edadce359c
commit
7817d4bd0b
47 changed files with 2484 additions and 44 deletions
87
app/extensions/storidge/views/cluster/clusterController.js
Normal file
87
app/extensions/storidge/views/cluster/clusterController.js
Normal file
|
@ -0,0 +1,87 @@
|
|||
angular.module('extension.storidge')
|
||||
.controller('StoridgeClusterController', ['$q', '$scope', '$state', 'Notifications', 'StoridgeClusterService', 'StoridgeNodeService', 'StoridgeManager', 'ModalService',
|
||||
function ($q, $scope, $state, Notifications, StoridgeClusterService, StoridgeNodeService, StoridgeManager, ModalService) {
|
||||
|
||||
$scope.state = {
|
||||
shutdownInProgress: false,
|
||||
rebootInProgress: false
|
||||
};
|
||||
|
||||
$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();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$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();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function shutdownCluster() {
|
||||
Notifications.error('Not implemented', {}, 'Not implemented yet');
|
||||
$state.reload();
|
||||
}
|
||||
|
||||
function rebootCluster() {
|
||||
$scope.state.rebootInProgress = true;
|
||||
StoridgeClusterService.reboot()
|
||||
.then(function success(data) {
|
||||
Notifications.success('Cluster successfully rebooted');
|
||||
$state.reload();
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to reboot cluster');
|
||||
})
|
||||
.finally(function final() {
|
||||
$scope.state.rebootInProgress = false;
|
||||
});
|
||||
}
|
||||
|
||||
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');
|
||||
});
|
||||
}
|
||||
|
||||
StoridgeManager.init()
|
||||
.then(function success() {
|
||||
initView();
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to communicate with Storidge API');
|
||||
});
|
||||
}]);
|
Loading…
Add table
Add a link
Reference in a new issue