fix(storidge): update 9 - add drive button will now change only for the concerned drive

storidge-standalone
baron_l 2019-04-28 23:02:39 +02:00
parent 15e384b585
commit 2c576f83b3
4 changed files with 10 additions and 5 deletions

View File

@ -88,9 +88,9 @@
</td> </td>
<td> <td>
<button ng-if="item.Status === 'available'" type="button" class="btn btn-sm btn-primary btn-datatable" <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"> ng-click="$ctrl.addAction(item, $index)" button-spinner="$ctrl.additionInProgress[$index]" 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-hide="$ctrl.additionInProgress[$index]"><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> <span ng-show="$ctrl.additionInProgress[$index]">Addition in progress...</span>
</button> </button>
</td> </td>
</tr> </tr>

View File

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

View File

@ -18,6 +18,7 @@
rescan-action="rescanAction" rescan-action="rescanAction"
add-action="addAction" add-action="addAction"
action-in-progress="state.actionInProgress" action-in-progress="state.actionInProgress"
addition-in-progress="state.additionInProgress"
></storidge-drives-datatable> ></storidge-drives-datatable>
</div> </div>
</div> </div>

View File

@ -3,10 +3,12 @@ angular.module('extension.storidge')
function ($scope, $state, Notifications, StoridgeDriveService) { function ($scope, $state, Notifications, StoridgeDriveService) {
$scope.state = { $scope.state = {
additionInProgress: [],
actionInProgress: false actionInProgress: false
}; };
$scope.addAction = function (drive) { $scope.addAction = function (drive, idx) {
$scope.state.additionInProgress[idx] = true;
$scope.state.actionInProgress = true; $scope.state.actionInProgress = true;
StoridgeDriveService.add(drive.Device, drive.Node) StoridgeDriveService.add(drive.Device, drive.Node)
.then(function success() { .then(function success() {
@ -17,6 +19,7 @@ function ($scope, $state, Notifications, StoridgeDriveService) {
Notifications.error('Failure', err, 'Unable to add drive'); Notifications.error('Failure', err, 'Unable to add drive');
}) })
.finally(function final() { .finally(function final() {
$scope.state.additionInProgress[idx] = false;
$scope.state.actionInProgress = false; $scope.state.actionInProgress = false;
}); });
}; };