mirror of https://github.com/portainer/portainer
feat(storidge): update 8 - add drive
parent
c78d3223e8
commit
83868a63d3
|
@ -10,6 +10,10 @@
|
||||||
<button type="button" class="btn btn-sm btn-primary" ng-click="$ctrl.rescanAction()">
|
<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
|
<i class="fa fa-sync space-right" aria-hidden="true"></i>Rescan drives
|
||||||
</button>
|
</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>
|
||||||
<div class="searchBar">
|
<div class="searchBar">
|
||||||
<i class="fa fa-search searchIcon" aria-hidden="true"></i>
|
<i class="fa fa-search searchIcon" aria-hidden="true"></i>
|
||||||
|
@ -20,6 +24,10 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<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')">
|
<a ng-click="$ctrl.changeOrderBy('Id')">
|
||||||
Id
|
Id
|
||||||
<i class="fa fa-sort-alpha-down" aria-hidden="true" ng-if="$ctrl.state.orderBy === 'Id' && !$ctrl.state.reverseOrder"></i>
|
<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>
|
<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}">
|
<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>
|
<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>
|
<a ui-sref="storidge.drives.drive({id: item.Id})"> {{ item.Id }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ item.Node }}</td>
|
<td>{{ item.Node }}</td>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
dataset="drives" table-key="storidge_drives"
|
dataset="drives" table-key="storidge_drives"
|
||||||
order-by="Id"
|
order-by="Id"
|
||||||
rescan-action="rescanAction"
|
rescan-action="rescanAction"
|
||||||
|
add-action="addAction"
|
||||||
></storidge-drives-datatable>
|
></storidge-drives-datatable>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,6 +2,28 @@ angular.module('extension.storidge')
|
||||||
.controller('StoridgeDrivesController', ['$scope', '$state', 'Notifications', 'StoridgeDriveService',
|
.controller('StoridgeDrivesController', ['$scope', '$state', 'Notifications', 'StoridgeDriveService',
|
||||||
function ($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 () {
|
$scope.rescanAction = function () {
|
||||||
StoridgeDriveService.rescan()
|
StoridgeDriveService.rescan()
|
||||||
.then(function sucess() {
|
.then(function sucess() {
|
||||||
|
|
Loading…
Reference in New Issue