Files
portainer/app/integrations/storidge/views/drives/drivesController.js
T
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

52 lines
1.5 KiB
JavaScript

angular.module('portainer.integrations.storidge').controller('StoridgeDrivesController', [
'$scope',
'$state',
'Notifications',
'StoridgeDriveService',
function ($scope, $state, Notifications, StoridgeDriveService) {
$scope.state = {
additionInProgress: [],
actionInProgress: false,
};
$scope.addAction = function (drive, idx) {
$scope.state.additionInProgress[idx] = true;
$scope.state.actionInProgress = true;
StoridgeDriveService.add(drive.Device, drive.Node)
.then(function success() {
Notifications.success('Drive ' + drive.Device + ' successfully added on node ' + drive.Node);
$state.reload();
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to add drive');
})
.finally(function final() {
$scope.state.additionInProgress[idx] = false;
$scope.state.actionInProgress = false;
});
};
$scope.rescanAction = function () {
StoridgeDriveService.rescan()
.then(function sucess() {
$state.reload();
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to scan drives');
});
};
function initView() {
StoridgeDriveService.drives()
.then(function success(data) {
$scope.drives = data;
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to retrieve drives');
});
}
initView();
},
]);