extension(storidge): support cluster shutdown (#1589)

pull/1602/head
Anthony Lapenna 2018-01-23 09:49:29 +01:00 committed by GitHub
parent 173ea372c2
commit 0d0072a50e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 6 deletions

View File

@ -40,5 +40,13 @@ angular.module('extension.storidge')
});
};
service.shutdown = function() {
return $http({
method: 'POST',
url: StoridgeManager.StoridgeAPIURL() + '/cluster/shutdown',
skipAuthorization: true
});
};
return service;
}]);

View File

@ -7,6 +7,10 @@ angular.module('extension.storidge')
return StoridgeCluster.reboot();
};
service.shutdown = function() {
return StoridgeCluster.shutdown();
};
service.info = function() {
var deferred = $q.defer();

View File

@ -37,12 +37,12 @@
<div class="form-group">
<div class="col-sm-12">
<button type="button" class="btn btn-danger btn-sm" ng-click="shutdownCluster()" ng-disabled="state.shutdownInProgress" button-spinner="state.shutdownInProgress">
<span ng-hide="state.updateInProgress"><i class="fa fa-power-off space-right" aria-hidden="true"></i> Shutdown the cluster</span>
<span ng-show="state.updateInProgress">Shutting down cluster...</span>
<span ng-hide="state.shutdownInProgress"><i class="fa fa-power-off space-right" aria-hidden="true"></i> Shutdown the cluster</span>
<span ng-show="state.shutdownInProgress">Shutting down cluster...</span>
</button>
<button type="button" class="btn btn-danger btn-sm" ng-click="rebootCluster()" ng-disabled="state.rebootInProgress" button-spinner="state.shutdownInProgress">
<span ng-hide="state.deleteInProgress"><i class="fa fa-refresh space-right" aria-hidden="true"></i> Reboot the cluster</span>
<span ng-show="state.deleteInProgress">Rebooting cluster...</span>
<span ng-hide="state.rebootInProgress"><i class="fa fa-refresh space-right" aria-hidden="true"></i> Reboot the cluster</span>
<span ng-show="state.rebootInProgress">Rebooting cluster...</span>
</button>
</div>
</div>

View File

@ -42,8 +42,18 @@ function ($q, $scope, $state, Notifications, StoridgeClusterService, StoridgeNod
};
function shutdownCluster() {
Notifications.error('Not implemented', {}, 'Not implemented yet');
$state.reload();
$scope.state.shutdownInProgress = true;
StoridgeClusterService.shutdown()
.then(function success(data) {
Notifications.success('Cluster successfully shutdown');
$state.go('dashboard');
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to shutdown cluster');
})
.finally(function final() {
$scope.state.shutdownInProgress = false;
});
}
function rebootCluster() {