Provided initiale commit of refactored user interface
[dlux.git] / src / app / node / nodes.js
1 angular.module('console.node', [])
2
3 .controller('nodeCtrl', function($scope, SwitchSvc) {
4   $scope.ncpData = {};
5
6   // Fetch the node then fetch more info about each node
7   SwitchSvc.nodeUrl().getList().then(function(npData) {
8     $scope.npData = npData.nodeProperties;
9   });
10 })
11
12 .config(function ($stateProvider) {
13   var access = routingConfig.accessLevels;
14   $stateProvider.state('node', {
15     url: '/node',
16     abstract: true,
17     templateUrl: 'node/root.tpl.html'
18   });
19
20   $stateProvider.state('node.index', {
21     url: '/index',
22     access: access.admin,
23     views: {
24       '': {
25         templateUrl: 'node/index.tpl.html',
26         controller: ['$scope', 'SwitchSvc', function ($scope, SwitchSvc) {
27           $scope.selectAll = function() {
28             console.log($('input[id^=select-node-]'));
29             if($("#checkAll")[0].checked) {
30               $scope.numberSelectedItems = $('input[id^=select-node-]').length;
31             }
32             else {
33               $scope.numberSelectedItems = 0;
34             }
35             $('input[id^=select-node-]').each(function(i, el) {
36               el.checked = $("#checkAll")[0].checked;
37             });
38           };
39
40           $scope.unselect = function($event) {
41             if(!$event.target.checked) {
42               $("#checkAll")[0].checked = false;
43               $scope.numberSelectedItems--;
44             }
45             else {
46               $scope.numberSelectedItems++;
47             }
48           };
49           $scope.svc = SwitchSvc;
50           $scope.numberSelectedItems = 0;
51           SwitchSvc.getAll(null).then(function(data) {
52             $scope.data = data[0];
53           });
54           
55         }]
56       }
57     }
58   });
59
60
61   $stateProvider.state('node.detail', {
62     url: '/:nodeType/:nodeId/detail',
63     access: access.admin,
64     views: {
65       '': {
66         templateUrl: 'node/detail.tpl.html',
67         controller: ['$scope', '$stateParams', 'SwitchSvc', function ($scope, $stateParams, SwitchSvc) {
68           SwitchSvc.nodeUrl(null, $stateParams.nodeType, $stateParams.nodeId).get().then(
69             function (data) {
70               $scope.data = data;
71             });
72
73           // Filter function to remove ports with id 0
74           $scope.portNotNull = function (property) {
75             return property.nodeconnector.id !== "0";
76           };
77         }]
78       }
79     }
80   });
81 });