2017-02-10 14:11:36 +13:00
|
|
|
angular.module('portainer.services')
|
|
|
|
.factory('NetworkService', ['$q', 'Network', function NetworkServiceFactory($q, Network) {
|
|
|
|
'use strict';
|
|
|
|
var service = {};
|
|
|
|
|
|
|
|
service.getNetworks = function() {
|
|
|
|
return Network.query({}).$promise;
|
|
|
|
};
|
|
|
|
|
|
|
|
service.filterGlobalNetworks = function(networks) {
|
|
|
|
return networks.filter(function (network) {
|
|
|
|
if (network.Scope === 'global') {
|
|
|
|
return network;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-03-31 22:12:58 +02:00
|
|
|
service.filterSwarmModeAttachableNetworks = function(networks) {
|
|
|
|
return networks.filter(function (network) {
|
|
|
|
if (network.Scope === 'swarm' && network.Attachable === true) {
|
|
|
|
return network;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-02-10 14:11:36 +13:00
|
|
|
service.addPredefinedLocalNetworks = function(networks) {
|
2017-05-23 20:56:10 +02:00
|
|
|
networks.push({Scope: 'local', Name: 'bridge'});
|
|
|
|
networks.push({Scope: 'local', Name: 'host'});
|
|
|
|
networks.push({Scope: 'local', Name: 'none'});
|
2017-02-10 14:11:36 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
return service;
|
|
|
|
}]);
|