mirror of https://github.com/portainer/portainer
25 lines
589 B
JavaScript
25 lines
589 B
JavaScript
angular.module('portainer.agent')
|
|
.factory('AgentService', ['$q', 'Agent', function AgentServiceFactory($q, Agent) {
|
|
'use strict';
|
|
var service = {};
|
|
|
|
service.agents = function() {
|
|
var deferred = $q.defer();
|
|
|
|
Agent.query({}).$promise
|
|
.then(function success(data) {
|
|
var agents = data.map(function (item) {
|
|
return new AgentViewModel(item);
|
|
});
|
|
deferred.resolve(agents);
|
|
})
|
|
.catch(function error(err) {
|
|
deferred.reject({ msg: 'Unable to retrieve agents', err: err });
|
|
});
|
|
|
|
return deferred.promise;
|
|
};
|
|
|
|
return service;
|
|
}]);
|