feat(storidge): update 9 - disable add drive button when action is in progress

storidge-standalone
baron_l 2019-04-28 22:11:41 +02:00
parent c6f083cd6f
commit 15e384b585
4 changed files with 16 additions and 4 deletions

View File

@ -87,8 +87,10 @@
<span class="label label-{{ item.Status|drivestatusbadge }}">{{ item.Status|capitalize }}</span>
</td>
<td>
<button ng-if="item.Status === 'available'" type="button" class="btn btn-sm btn-primary btn-datatable" ng-click="$ctrl.addAction(item)">
<i class="fa fa-plus space-right" aria-hidden="true"></i>Add to storage pool
<button ng-if="item.Status === 'available'" type="button" class="btn btn-sm btn-primary btn-datatable"
ng-click="$ctrl.addAction(item)" button-spinner="$ctrl.actionInProgress" ng-disabled="$ctrl.actionInProgress">
<span ng-hide="$ctrl.actionInProgress"><i class="fa fa-plus space-right" aria-hidden="true"></i>Add to storage pool</span>
<span ng-show="$ctrl.actionInProgress">Addition in progress...</span>
</button>
</td>
</tr>

View File

@ -10,6 +10,7 @@ angular.module('extension.storidge').component('storidgeDrivesDatatable', {
reverseOrder: '<',
removeAction: '<',
addAction: '<',
rescanAction: '<'
rescanAction: '<',
actionInProgress: '<'
}
});

View File

@ -17,6 +17,7 @@
order-by="Id"
rescan-action="rescanAction"
add-action="addAction"
action-in-progress="state.actionInProgress"
></storidge-drives-datatable>
</div>
</div>

View File

@ -2,7 +2,12 @@ angular.module('extension.storidge')
.controller('StoridgeDrivesController', ['$scope', '$state', 'Notifications', 'StoridgeDriveService',
function ($scope, $state, Notifications, StoridgeDriveService) {
$scope.state = {
actionInProgress: false
};
$scope.addAction = function (drive) {
$scope.state.actionInProgress = true;
StoridgeDriveService.add(drive.Device, drive.Node)
.then(function success() {
Notifications.success('Drive ' + drive.Device + ' successfully added on node ' + drive.Node);
@ -10,6 +15,9 @@ function ($scope, $state, Notifications, StoridgeDriveService) {
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to add drive');
})
.finally(function final() {
$scope.state.actionInProgress = false;
});
};