feat(storidge): update 8 - add drive

storidge-standalone
baron_l 2019-04-26 16:44:34 +02:00
parent c78d3223e8
commit 83868a63d3
3 changed files with 35 additions and 0 deletions

View File

@ -10,6 +10,10 @@
<button type="button" class="btn btn-sm btn-primary" ng-click="$ctrl.rescanAction()">
<i class="fa fa-sync space-right" aria-hidden="true"></i>Rescan drives
</button>
<button type="button" class="btn btn-sm btn-primary"
ng-disabled="$ctrl.state.selectedItemCount === 0" ng-click="$ctrl.addAction($ctrl.state.selectedItems)">
<i class="fa fa-plus space-right" aria-hidden="true"></i>Add to storage pool
</button>
</div>
<div class="searchBar">
<i class="fa fa-search searchIcon" aria-hidden="true"></i>
@ -20,6 +24,10 @@
<thead>
<tr>
<th>
<span class="md-checkbox">
<input id="select_all" type="checkbox" ng-model="$ctrl.state.selectAll" ng-change="$ctrl.selectAll()" />
<label for="select_all"></label>
</span>
<a ng-click="$ctrl.changeOrderBy('Id')">
Id
<i class="fa fa-sort-alpha-down" aria-hidden="true" ng-if="$ctrl.state.orderBy === 'Id' && !$ctrl.state.reverseOrder"></i>
@ -73,6 +81,10 @@
<tbody>
<tr dir-paginate="item in ($ctrl.state.filteredDataSet = ($ctrl.dataset | filter:$ctrl.state.textFilter | orderBy:$ctrl.state.orderBy:$ctrl.state.reverseOrder | itemsPerPage: $ctrl.state.paginatedItemLimit))" ng-class="{active: item.Checked}">
<td>
<span class="md-checkbox">
<input id="select_{{ $index }}" type="checkbox" ng-model="item.Checked" ng-change="$ctrl.selectItem(item)" ng-disabled="item.Status === 'normal'"/>
<label for="select_{{ $index }}"></label>
</span>
<a ui-sref="storidge.drives.drive({id: item.Id})"> {{ item.Id }}</a>
</td>
<td>{{ item.Node }}</td>

View File

@ -16,6 +16,7 @@
dataset="drives" table-key="storidge_drives"
order-by="Id"
rescan-action="rescanAction"
add-action="addAction"
></storidge-drives-datatable>
</div>
</div>

View File

@ -2,6 +2,28 @@ angular.module('extension.storidge')
.controller('StoridgeDrivesController', ['$scope', '$state', 'Notifications', 'StoridgeDriveService',
function ($scope, $state, Notifications, StoridgeDriveService) {
$scope.addAction = function (selectedItems) {
var actionCount = selectedItems.length;
selectedItems = selectedItems.filter(function (item) {
return item.Status === 'available';
});
angular.forEach(selectedItems, function (drive) {
StoridgeDriveService.add(drive.Device, drive.Node)
.then(function success() {
Notifications.success('Drive ' + drive.Device + ' successfully added on node ' + drive.Node);
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to add drive');
})
.finally(function final() {
--actionCount;
if (actionCount === 0) {
$state.reload();
}
});
});
};
$scope.rescanAction = function () {
StoridgeDriveService.rescan()
.then(function sucess() {