mirror of https://github.com/portainer/portainer
25 lines
584 B
JavaScript
25 lines
584 B
JavaScript
angular.module('portainer.services')
|
|
.factory('NodeService', ['$q', 'Node', function NodeServiceFactory($q, Node) {
|
|
'use strict';
|
|
var service = {};
|
|
|
|
service.nodes = function(id) {
|
|
var deferred = $q.defer();
|
|
|
|
Node.query({}).$promise
|
|
.then(function success(data) {
|
|
var nodes = data.map(function (item) {
|
|
return new NodeViewModel(item);
|
|
});
|
|
deferred.resolve(nodes);
|
|
})
|
|
.catch(function error(err) {
|
|
deferred.reject({ msg: 'Unable to retrieve nodes', err: err });
|
|
});
|
|
|
|
return deferred.promise;
|
|
};
|
|
|
|
return service;
|
|
}]);
|