mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 15:29:42 +02:00
feat(settings): add settings management (#906)
This commit is contained in:
parent
5e74a3993b
commit
c7e306841a
93 changed files with 1086 additions and 457 deletions
52
app/services/docker/networkService.js
Normal file
52
app/services/docker/networkService.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
angular.module('portainer.services')
|
||||
.factory('NetworkService', ['$q', 'Network', function NetworkServiceFactory($q, Network) {
|
||||
'use strict';
|
||||
var service = {};
|
||||
|
||||
service.networks = function() {
|
||||
return Network.query({}).$promise;
|
||||
};
|
||||
|
||||
service.retrieveSwarmNetworks = function() {
|
||||
var deferred = $q.defer();
|
||||
|
||||
service.networks()
|
||||
.then(function success(data) {
|
||||
var networks = data.filter(function (network) {
|
||||
if (network.Scope === 'swarm') {
|
||||
return network;
|
||||
}
|
||||
});
|
||||
deferred.resolve(networks);
|
||||
})
|
||||
.catch(function error(err) {
|
||||
deferred.reject({msg: 'Unable to retrieve networks', err: err});
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
service.filterGlobalNetworks = function(networks) {
|
||||
return networks.filter(function (network) {
|
||||
if (network.Scope === 'global') {
|
||||
return network;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
service.filterSwarmModeAttachableNetworks = function(networks) {
|
||||
return networks.filter(function (network) {
|
||||
if (network.Scope === 'swarm' && network.Attachable === true) {
|
||||
return network;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
service.addPredefinedLocalNetworks = function(networks) {
|
||||
networks.push({Scope: 'local', Name: 'bridge'});
|
||||
networks.push({Scope: 'local', Name: 'host'});
|
||||
networks.push({Scope: 'local', Name: 'none'});
|
||||
};
|
||||
|
||||
return service;
|
||||
}]);
|
Loading…
Add table
Add a link
Reference in a new issue