1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-30 02:39:41 +02:00
portainer/app/integrations/storidge/views/nodes/inspect/nodeController.js
Chaim Lev-Ari cf5056d9c0
chore(project): add prettier for code format (#3645)
* chore(project): install prettier and lint-staged

* chore(project): apply prettier to html too

* chore(project): git ignore eslintcache

* chore(project): add a comment about format script

* chore(prettier): update printWidth

* chore(prettier): remove useTabs option

* chore(prettier): add HTML validation

* refactor(prettier): fix closing tags

* feat(prettier): define angular parser for html templates

* style(prettier): run prettier on codebase

Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>
2020-04-11 09:54:53 +12:00

117 lines
3.3 KiB
JavaScript

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);
},
});
};
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();
},
]);