mirror of https://github.com/portainer/portainer
25 lines
589 B
JavaScript
25 lines
589 B
JavaScript
import { SwarmViewModel } from '../models/swarm';
|
|
|
|
angular.module('portainer.docker')
|
|
.factory('SwarmService', ['$q', 'Swarm', function SwarmServiceFactory($q, Swarm) {
|
|
'use strict';
|
|
var service = {};
|
|
|
|
service.swarm = function() {
|
|
var deferred = $q.defer();
|
|
|
|
Swarm.get().$promise
|
|
.then(function success(data) {
|
|
var swarm = new SwarmViewModel(data);
|
|
deferred.resolve(swarm);
|
|
})
|
|
.catch(function error(err) {
|
|
deferred.reject({ msg: 'Unable to retrieve Swarm details', err: err });
|
|
});
|
|
|
|
return deferred.promise;
|
|
};
|
|
|
|
return service;
|
|
}]);
|