1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-02 12:25:22 +02:00
portainer/app/integrations/storidge/views/drives/inspect/driveController.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

55 lines
1.7 KiB
JavaScript

angular.module('portainer.integrations.storidge').controller('StoridgeDriveController', [
'$scope',
'$state',
'$transition$',
'Notifications',
'ModalService',
'StoridgeDriveService',
function ($scope, $state, $transition$, Notifications, ModalService, StoridgeDriveService) {
$scope.actionInProgress = false;
$scope.removeDrive = function () {
ModalService.confirm({
title: 'Are you sure?',
message: 'Do you want really want to remove this drive from the storage pool?',
buttons: {
confirm: {
label: 'Remove',
className: 'btn-danger',
},
},
callback: function onConfirm(confirmed) {
if (!confirmed) {
return;
}
$scope.actionInProgress = true;
StoridgeDriveService.remove($scope.drive.Id)
.then(function () {
Notifications.success('Success', 'Drive removed from storage pool');
$state.go('storidge.drives', {}, { reload: true });
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to remove drive from storage pool');
})
.finally(function final() {
$scope.actionInProgress = false;
});
},
});
};
function initView() {
$scope.id = $transition$.params().id;
StoridgeDriveService.drive($scope.id)
.then(function success(data) {
$scope.drive = data;
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to retrieve drive details');
});
}
initView();
},
]);