cf5056d9c0
* 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>
52 lines
1.5 KiB
JavaScript
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();
|
|
},
|
|
]);
|