2016-06-14 14:13:52 +12:00
|
|
|
angular.module('network', [])
|
2016-09-02 15:25:20 +12:00
|
|
|
.controller('NetworkController', ['$scope', 'Network', 'Messages', '$state', '$stateParams',
|
|
|
|
function ($scope, Network, Messages, $state, $stateParams) {
|
2016-06-02 17:34:03 +12:00
|
|
|
|
|
|
|
$scope.disconnect = function disconnect(networkId, containerId) {
|
2016-07-07 12:44:58 +12:00
|
|
|
$('#loadingViewSpinner').show();
|
2016-06-02 17:34:03 +12:00
|
|
|
Network.disconnect({id: $stateParams.id}, {Container: containerId}, function (d) {
|
2016-07-07 12:44:58 +12:00
|
|
|
$('#loadingViewSpinner').hide();
|
2016-06-02 17:34:03 +12:00
|
|
|
Messages.send("Container disconnected", containerId);
|
|
|
|
$state.go('network', {id: $stateParams.id}, {reload: true});
|
|
|
|
}, function (e) {
|
2016-07-07 12:44:58 +12:00
|
|
|
$('#loadingViewSpinner').hide();
|
2016-09-02 17:59:32 +12:00
|
|
|
Messages.error("Failure", e, "Unable to disconnect container");
|
2015-12-20 19:13:53 -06:00
|
|
|
});
|
2016-06-02 17:34:03 +12:00
|
|
|
};
|
2015-12-20 19:13:53 -06:00
|
|
|
|
2016-06-02 17:34:03 +12:00
|
|
|
$scope.remove = function remove(networkId) {
|
2016-07-07 12:44:58 +12:00
|
|
|
$('#loadingViewSpinner').show();
|
2016-06-02 17:34:03 +12:00
|
|
|
Network.remove({id: $stateParams.id}, function (d) {
|
2016-09-01 12:20:19 +12:00
|
|
|
if (d.message) {
|
2016-09-01 11:31:25 +12:00
|
|
|
$('#loadingViewSpinner').hide();
|
2016-09-02 17:59:32 +12:00
|
|
|
Messages.send("Error", {}, d.message);
|
2016-09-01 11:31:25 +12:00
|
|
|
} else {
|
|
|
|
$('#loadingViewSpinner').hide();
|
2016-09-01 12:20:19 +12:00
|
|
|
Messages.send("Network removed", $stateParams.id);
|
2016-09-01 11:31:25 +12:00
|
|
|
$state.go('networks', {});
|
|
|
|
}
|
2016-06-02 17:34:03 +12:00
|
|
|
}, function (e) {
|
2016-07-07 12:44:58 +12:00
|
|
|
$('#loadingViewSpinner').hide();
|
2016-09-02 17:59:32 +12:00
|
|
|
Messages.error("Failure", e, "Unable to remove network");
|
2016-06-02 17:34:03 +12:00
|
|
|
});
|
|
|
|
};
|
2015-12-20 19:13:53 -06:00
|
|
|
|
2016-07-07 12:44:58 +12:00
|
|
|
$('#loadingViewSpinner').show();
|
2016-06-02 17:34:03 +12:00
|
|
|
Network.get({id: $stateParams.id}, function (d) {
|
|
|
|
$scope.network = d;
|
2016-07-07 12:44:58 +12:00
|
|
|
$('#loadingViewSpinner').hide();
|
2016-06-02 17:34:03 +12:00
|
|
|
}, function (e) {
|
2016-07-07 12:44:58 +12:00
|
|
|
$('#loadingViewSpinner').hide();
|
2016-09-02 17:59:32 +12:00
|
|
|
Messages.error("Failure", e, "Unable to retrieve network info");
|
2016-06-02 17:34:03 +12:00
|
|
|
});
|
|
|
|
}]);
|