mirror of https://github.com/portainer/portainer
31 lines
762 B
JavaScript
31 lines
762 B
JavaScript
angular.module('extension.storidge')
|
|
.factory('StoridgeNodeService', ['$q', 'StoridgeNodes', function StoridgeNodeServiceFactory($q, StoridgeNodes) {
|
|
'use strict';
|
|
var service = {};
|
|
|
|
service.nodes = function() {
|
|
var deferred = $q.defer();
|
|
|
|
StoridgeNodes.query()
|
|
.then(function success(response) {
|
|
var nodeData = response.data.nodes;
|
|
var nodes = [];
|
|
|
|
for (var key in nodeData) {
|
|
if (nodeData.hasOwnProperty(key)) {
|
|
nodes.push(new StoridgeNodeModel(key, nodeData[key]));
|
|
}
|
|
}
|
|
|
|
deferred.resolve(nodes);
|
|
})
|
|
.catch(function error(err) {
|
|
deferred.reject({ msg: 'Unable to retrieve Storidge profiles', err: err });
|
|
});
|
|
|
|
return deferred.promise;
|
|
};
|
|
|
|
return service;
|
|
}]);
|