mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
Catch plaintext errors for creation and connection, implement network creation,
This commit is contained in:
parent
8a4be8b93a
commit
5f4641af67
4 changed files with 165 additions and 21 deletions
|
@ -3,10 +3,23 @@ angular.module('networks', []).config(['$routeProvider', function ($routeProvide
|
|||
templateUrl: 'app/components/networks/networks.html',
|
||||
controller: 'NetworksController'
|
||||
});
|
||||
}]).controller('NetworksController', ['$scope', 'Network', 'ViewSpinner', 'Messages',
|
||||
function ($scope, Network, ViewSpinner, Messages) {
|
||||
}]).controller('NetworksController', ['$scope', 'Network', 'ViewSpinner', 'Messages', '$route', 'errorMsgFilter',
|
||||
function ($scope, Network, ViewSpinner, Messages, $route, errorMsgFilter) {
|
||||
$scope.toggle = false;
|
||||
//$scope.predicate = '-Created';
|
||||
$scope.predicate = '-Created';
|
||||
$scope.createNetworkConfig = {
|
||||
"Name": '',
|
||||
"Driver": '',
|
||||
"IPAM": {
|
||||
"Config": [{
|
||||
"Subnet": '',
|
||||
"IPRange": '',
|
||||
"Gateway": ''
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$scope.removeAction = function () {
|
||||
ViewSpinner.spin();
|
||||
|
@ -21,7 +34,7 @@ angular.module('networks', []).config(['$routeProvider', function ($routeProvide
|
|||
if (network.Checked) {
|
||||
counter = counter + 1;
|
||||
Network.remove({id: network.Id}, function (d) {
|
||||
Messages.send("Network deleted", resource.Deleted);
|
||||
Messages.send("Network deleted", network.Id);
|
||||
var index = $scope.networks.indexOf(network);
|
||||
$scope.networks.splice(index, 1);
|
||||
complete();
|
||||
|
@ -34,17 +47,36 @@ angular.module('networks', []).config(['$routeProvider', function ($routeProvide
|
|||
};
|
||||
|
||||
$scope.toggleSelectAll = function () {
|
||||
angular.forEach($scope.images, function (i) {
|
||||
angular.forEach($scope.networks, function (i) {
|
||||
i.Checked = $scope.toggle;
|
||||
});
|
||||
};
|
||||
|
||||
ViewSpinner.spin();
|
||||
Network.query({}, function (d) {
|
||||
$scope.networks = d;
|
||||
ViewSpinner.stop();
|
||||
}, function (e) {
|
||||
Messages.error("Failure", e.data);
|
||||
ViewSpinner.stop();
|
||||
});
|
||||
$scope.addNetwork = function addNetwork(createNetworkConfig) {
|
||||
ViewSpinner.spin();
|
||||
Network.create(createNetworkConfig, function (d) {
|
||||
if (d.Id) {
|
||||
Messages.send("Network created", d.Id);
|
||||
} else {
|
||||
Messages.error('Failure', errorMsgFilter(d));
|
||||
}
|
||||
ViewSpinner.stop();
|
||||
fetchNetworks();
|
||||
}, function (e) {
|
||||
Messages.error("Failure", e.data);
|
||||
ViewSpinner.stop();
|
||||
});
|
||||
};
|
||||
|
||||
function fetchNetworks() {
|
||||
ViewSpinner.spin();
|
||||
Network.query({}, function (d) {
|
||||
$scope.networks = d;
|
||||
ViewSpinner.stop();
|
||||
}, function (e) {
|
||||
Messages.error("Failure", e.data);
|
||||
ViewSpinner.stop();
|
||||
});
|
||||
}
|
||||
fetchNetworks();
|
||||
}]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue