portainer/app/integrations/storidge/views/nodes/inspect/nodeController.js

108 lines
3.0 KiB
JavaScript
Raw Normal View History

angular.module('portainer.integrations.storidge')
feat(integrations): storidge evolution (#2711) * feat(storidge): update storidge routes * feat(storidge): add new fields on profile create/edit * feat(storidge): add drives list and details view * feat(storidge): add node details / cordon / uncordon / remove * feat(storidge): add volume and snapshot details * feat(storidge): add snapshot creation on volume details * feat(storidge): add rescan drives button * refactor(storidge): move add / remove / put in / put ouf maintenance buttons for cluster nodes * style(storidge): change cluster / node icon color based on status * feat(storidge): profiles can enable snapshots without interval + interval in minutes * refactor(storidge): split cluster and node status badge filter * fix(storidge): error on volume IOPS update * fix(storidge): snapshot can now be created without comments * feat(storidge): remove snapshots panels when volume snapshots are disabled * fix(app): paginatedItemLimit now retrieved for datables extending GenericDatatableController * fix(storidge): addDrive is called with the good parameters * fix(storidge): update model and views for Storidge v2695 * refactor(storidge): webpack migration * fix(storidge): display modifications + fix js errors * feat(storidge): snapshots, profile and nodes evolution * fix(storidge): values for InterfaceDriver on profile create/edit * feat(storidge): v5 update without style (profile / statuses / volume) * fix(storidge): description tables on the same view have now the same fixed offset * fix(app): override rdash-ui select style * Revert "fix(app): override rdash-ui select style" This reverts commit e7248332611345dc803be83560282517c44c0646. * feat(storidge): wip on update 6 * feat(storidge): update 6 * feat(storidge): update 6 * feat(storidge): update 6 * feat(storidge): update 7 - node details + cluster views * fix(storidge): update 7 - profiles creation + volume details * fix(storidge): update 7 - profile create/edit interface type * feat(storidge): update 8 - add drive * feat(storidge): update 8 - UI refactors + cluster availability * fix(storidge): update 8 - revert cluster availability * feat(storidge): update 8 - node availability on swarm overview * feat(storidge): cluster condition badge * fix(storidge): update 9 - move add storage button + api profile filesystem kv to obj * feat(storidge): update 9 - disable add drive button when action is in progress * fix(storidge): update 9 - add drive button will now change only for the concerned drive * fix(storidge): update 10 - disable remove drive button when removal in progress * fix(api): update Storidge proxy creation process * refactor(api): update version number * feat(extensions): fix an issue with Storidge API URL * feat(storidge): force the use of a manager node
2019-05-24 21:53:10 +00:00
.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');
})
.finally(function final() {
$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: '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');
})
.finally(function final() {
$state.reload();
});
}
function initView() {
$scope.name = $transition$.params().name;
StoridgeNodeService.node($scope.name)
.then(function success(data) {
$scope.node = data;
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to retrieve node details');
});
}
initView();
}]);