2018-01-21 16:26:24 +00:00
|
|
|
angular.module('extension.storidge')
|
2018-02-23 02:10:26 +00:00
|
|
|
.factory('StoridgeClusterService', ['$q', 'Storidge', function StoridgeClusterServiceFactory($q, Storidge) {
|
2018-01-21 16:26:24 +00:00
|
|
|
'use strict';
|
|
|
|
var service = {};
|
|
|
|
|
|
|
|
service.reboot = function() {
|
2018-02-23 02:10:26 +00:00
|
|
|
return Storidge.rebootCluster().$promise;
|
2018-01-21 16:26:24 +00:00
|
|
|
};
|
|
|
|
|
2018-01-23 08:49:29 +00:00
|
|
|
service.shutdown = function() {
|
2018-02-23 02:10:26 +00:00
|
|
|
return Storidge.shutdownCluster().$promise;
|
2018-01-23 08:49:29 +00:00
|
|
|
};
|
|
|
|
|
2018-01-21 16:26:24 +00:00
|
|
|
service.info = function() {
|
|
|
|
var deferred = $q.defer();
|
|
|
|
|
2018-02-23 02:10:26 +00:00
|
|
|
Storidge.getInfo().$promise
|
|
|
|
.then(function success(data) {
|
|
|
|
var info = new StoridgeInfoModel(data);
|
2018-01-21 16:26:24 +00:00
|
|
|
deferred.resolve(info);
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
deferred.reject({ msg: 'Unable to retrieve Storidge information', err: err });
|
|
|
|
});
|
|
|
|
|
|
|
|
return deferred.promise;
|
|
|
|
};
|
|
|
|
|
|
|
|
service.version = function() {
|
|
|
|
var deferred = $q.defer();
|
|
|
|
|
2018-02-23 02:10:26 +00:00
|
|
|
Storidge.getVersion().$promise
|
|
|
|
.then(function success(data) {
|
|
|
|
var version = data.version;
|
2018-01-21 16:26:24 +00:00
|
|
|
deferred.resolve(version);
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
deferred.reject({ msg: 'Unable to retrieve Storidge version', err: err });
|
|
|
|
});
|
|
|
|
|
|
|
|
return deferred.promise;
|
|
|
|
};
|
|
|
|
|
|
|
|
service.events = function() {
|
|
|
|
var deferred = $q.defer();
|
|
|
|
|
2018-02-23 02:10:26 +00:00
|
|
|
Storidge.queryEvents().$promise
|
|
|
|
.then(function success(data) {
|
|
|
|
var events = data.map(function(item) {
|
2018-01-21 16:26:24 +00:00
|
|
|
return new StoridgeEventModel(item);
|
|
|
|
});
|
|
|
|
deferred.resolve(events);
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
deferred.reject({ msg: 'Unable to retrieve Storidge events', err: err });
|
|
|
|
});
|
|
|
|
|
|
|
|
return deferred.promise;
|
|
|
|
};
|
|
|
|
|
|
|
|
return service;
|
|
|
|
}]);
|