2016-06-14 02:13:52 +00:00
|
|
|
angular.module('network', [])
|
2016-07-07 00:44:58 +00:00
|
|
|
.controller('NetworkController', ['$scope', 'Network', 'Messages', '$state', '$stateParams', 'errorMsgFilter',
|
|
|
|
function ($scope, Network, Messages, $state, $stateParams, errorMsgFilter) {
|
2016-06-02 05:34:03 +00:00
|
|
|
|
|
|
|
$scope.disconnect = function disconnect(networkId, containerId) {
|
2016-07-07 00:44:58 +00:00
|
|
|
$('#loadingViewSpinner').show();
|
2016-06-02 05:34:03 +00:00
|
|
|
Network.disconnect({id: $stateParams.id}, {Container: containerId}, function (d) {
|
2016-07-07 00:44:58 +00:00
|
|
|
$('#loadingViewSpinner').hide();
|
2016-06-02 05:34:03 +00:00
|
|
|
Messages.send("Container disconnected", containerId);
|
|
|
|
$state.go('network', {id: $stateParams.id}, {reload: true});
|
|
|
|
}, function (e) {
|
2016-07-07 00:44:58 +00:00
|
|
|
$('#loadingViewSpinner').hide();
|
2016-06-02 05:34:03 +00:00
|
|
|
Messages.error("Failure", e.data);
|
2015-12-21 01:13:53 +00:00
|
|
|
});
|
2016-06-02 05:34:03 +00:00
|
|
|
};
|
2015-12-21 01:13:53 +00:00
|
|
|
|
2016-06-02 05:34:03 +00:00
|
|
|
$scope.remove = function remove(networkId) {
|
2016-07-07 00:44:58 +00:00
|
|
|
$('#loadingViewSpinner').show();
|
2016-06-02 05:34:03 +00:00
|
|
|
Network.remove({id: $stateParams.id}, function (d) {
|
2016-08-31 23:31:25 +00:00
|
|
|
var error = errorMsgFilter(d);
|
|
|
|
if (error) {
|
|
|
|
$('#loadingViewSpinner').hide();
|
|
|
|
Messages.send("Error", error);
|
|
|
|
} else {
|
|
|
|
$('#loadingViewSpinner').hide();
|
|
|
|
Messages.send("Network deleted", $stateParams.id);
|
|
|
|
$state.go('networks', {});
|
|
|
|
}
|
2016-06-02 05:34:03 +00:00
|
|
|
}, function (e) {
|
2016-07-07 00:44:58 +00:00
|
|
|
$('#loadingViewSpinner').hide();
|
2016-06-02 05:34:03 +00:00
|
|
|
Messages.error("Failure", e.data);
|
|
|
|
});
|
|
|
|
};
|
2015-12-21 01:13:53 +00:00
|
|
|
|
2016-07-07 00:44:58 +00:00
|
|
|
$('#loadingViewSpinner').show();
|
2016-06-02 05:34:03 +00:00
|
|
|
Network.get({id: $stateParams.id}, function (d) {
|
|
|
|
$scope.network = d;
|
2016-07-07 00:44:58 +00:00
|
|
|
$('#loadingViewSpinner').hide();
|
2016-06-02 05:34:03 +00:00
|
|
|
}, function (e) {
|
|
|
|
Messages.error("Failure", e.data);
|
2016-07-07 00:44:58 +00:00
|
|
|
$('#loadingViewSpinner').hide();
|
2016-06-02 05:34:03 +00:00
|
|
|
});
|
|
|
|
}]);
|