1 define(['app/network/network.module', 'jquery', 'footable', 'app/network/network.services'], function(network, $) {
3 network.controller('NetworkCtrl', function($rootScope, $scope, $state) {
4 $rootScope['section_logo'] = 'logo_network';
5 $scope.isState = function(name) {
6 return $state.includes(name);
8 $scope.getText = function(text) { // firefox use textContent while chrome use innerText...
9 return text.innerText||text.textContent;
14 network.controller('StaticRouteCtrl', ['$scope', 'StaticRouteSvc', function ($scope, StaticRouteSvc) {
15 StaticRouteSvc.routesUrl(null).getList().then(
21 $('table').footable().on('click', '.row-delete', function(e) {
23 //get the footable object
24 var footable = $('table').data('footable');
26 //get the row we are wanting to delete
27 var row = $(this).parents('tr:first');
29 StaticRouteSvc.delete($scope.getText(row[0].cells[0]));
30 footable.removeRow(row);
36 network.controller('StaticRouteCreateCtrl', ['$scope', 'StaticRouteSvc', '$state', function ($scope, StaticRouteSvc, $state) {
37 $scope.submit = function () {
38 StaticRouteSvc.routeUrl(null, $scope.data.name).customPUT($scope.data).then(
40 $state.transitionTo('main.network.staticroutes', null, { location: true, inherit: true, relative: $state.$current, notify: true });
42 $scope.error = resp.data;
48 network.controller('StaticRouteEditCtrl', ['$scope', 'StaticRouteSvc', '$state', '$stateParams', function ($scope, StaticRouteSvc, $state, $stateParams) {
49 $scope.submit = function () {
50 console.log(StaticRouteSvc.routeUrl(null, $scope.data.name));
51 StaticRouteSvc.routeUrl(null, $scope.data.name).customPOST($scope.data).then(
53 $state.transitionTo('main.network.staticroutes', null, { location: true, inherit: true, relative: $state.$current, notify: true });
55 $scope.error = resp.data;
59 StaticRouteSvc.routeUrl(null, $stateParams.name).get().then(
66 network.controller('SubnetCtrl', ['$scope', 'SubnetSvc', function ($scope, SubnetSvc) {
67 SubnetSvc.subnetsUrl(null).getList().then(
73 $('table').footable().on('click', '.row-delete', function(e) {
76 //get the footable object
77 var footable = $('table').data('footable');
78 //get the row we are wanting to delete
79 var row = $(this).parents('tr:first');
81 SubnetSvc.delete($scope.getText(row[0].cells[0]));
82 footable.removeRow(row);
86 network.controller('SubnetCreateCtrl', ['$scope', 'SubnetSvc', '$state', function ($scope, SubnetSvc, $state) {
87 $scope.submit = function () {
88 SubnetSvc.subnetUrl(null, $scope.data.name).customPUT($scope.data).then(
90 $state.transitionTo('main.network.subnets', null, { location: true, inherit: true, relative: $state.$current, notify: true });
92 $scope.error = resp.data;
98 network.controller('SubnetEditCtrl', ['$scope', 'SubnetSvc', '$state', '$stateParams', function ($scope, SubnetSvc, $state, $stateParams) {
99 SubnetSvc.subnetUrl(null, $stateParams.name).get().then(
104 $scope.submit = function () {
105 SubnetSvc.subnetUrl(null, $scope.data.name).customPOST($scope.data).then(
107 $state.transitionTo('main.network.subnets', null, { location: true, inherit: true, relative: $state.$current, notify: true });
109 $scope.error = resp.data;