2018-02-01 12:27:52 +00:00
|
|
|
angular.module('portainer.docker')
|
2018-10-28 09:27:06 +00:00
|
|
|
.controller('NetworksController', ['$scope', '$state', 'NetworkService', 'Notifications', 'HttpRequestHelper', 'EndpointProvider',
|
|
|
|
function ($scope, $state, NetworkService, Notifications, HttpRequestHelper, EndpointProvider) {
|
2016-09-14 04:28:38 +00:00
|
|
|
|
2017-12-06 11:04:02 +00:00
|
|
|
$scope.removeAction = function (selectedItems) {
|
|
|
|
var actionCount = selectedItems.length;
|
|
|
|
angular.forEach(selectedItems, function (network) {
|
2018-05-06 07:15:57 +00:00
|
|
|
HttpRequestHelper.setPortainerAgentTargetHeader(network.NodeName);
|
2017-12-06 11:04:02 +00:00
|
|
|
NetworkService.remove(network.Id)
|
|
|
|
.then(function success() {
|
|
|
|
Notifications.success('Network successfully removed', network.Name);
|
|
|
|
var index = $scope.networks.indexOf(network);
|
|
|
|
$scope.networks.splice(index, 1);
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to remove network');
|
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
--actionCount;
|
|
|
|
if (actionCount === 0) {
|
|
|
|
$state.reload();
|
|
|
|
}
|
|
|
|
});
|
2016-06-02 05:34:03 +00:00
|
|
|
});
|
|
|
|
};
|
2015-12-21 02:07:57 +00:00
|
|
|
|
2018-10-28 09:27:06 +00:00
|
|
|
$scope.offlineMode = false;
|
|
|
|
|
2017-06-01 08:14:55 +00:00
|
|
|
function initView() {
|
2018-06-11 13:13:19 +00:00
|
|
|
NetworkService.networks(true, true, true)
|
2017-09-19 14:58:30 +00:00
|
|
|
.then(function success(data) {
|
|
|
|
$scope.networks = data;
|
2018-10-28 09:27:06 +00:00
|
|
|
$scope.offlineMode = EndpointProvider.offlineMode();
|
2017-09-19 14:58:30 +00:00
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
2016-10-08 01:59:58 +00:00
|
|
|
$scope.networks = [];
|
2017-09-19 14:58:30 +00:00
|
|
|
Notifications.error('Failure', err, 'Unable to retrieve networks');
|
2016-06-02 05:34:03 +00:00
|
|
|
});
|
|
|
|
}
|
2016-08-10 06:20:18 +00:00
|
|
|
|
2017-06-01 08:14:55 +00:00
|
|
|
initView();
|
2016-06-02 05:34:03 +00:00
|
|
|
}]);
|