Merge "Connection Manager"
[dlux.git] / src / app / node / nodes.js
1 angular.module('dlux.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   $stateProvider.state('node', {
14     url: '/node',
15     abstract: true,
16     templateUrl: 'node/root.tpl.html'
17   });
18
19   $stateProvider.state('node.index', {
20     url: '/index',
21     views: {
22       '': {
23         templateUrl: 'node/index.tpl.html',
24         controller: function ($scope, SwitchSvc) {
25           $scope.svc = SwitchSvc;
26
27           $scope.gridOptions = {
28             data: 'data["nodeProperties"]',
29             selectedItems: [],
30             enableRowSelection: true,
31             showSelectionCheckbox: true,
32             selectWithCheckboxOnly: true,
33             columnDefs: [
34               {
35                 field: 'properties.description.value', displayName: 'Node Name'
36               },
37               {
38                 field: 'node.id', displayName: 'Node ID'
39               },
40               {
41                 field: 'properties.macAddress.value', displayName: 'MAC Address'
42               }
43             ]
44           };
45
46           $scope.$watch(
47             function () {
48               return SwitchSvc.data;
49             },
50             function (data) {
51               $scope.data = data;
52           });
53         }
54       }
55     }
56   });
57
58
59   $stateProvider.state('node.detail', {
60     url: '/{nodeType}/{nodeId}/detail',
61     views: {
62       '': {
63         templateUrl: 'node/detail.tpl.html',
64         controller: function ($scope, $stateParams, SwitchSvc) {
65           SwitchSvc.nodeUrl(null, $stateParams.nodeType, $stateParams.nodeId).get().then(
66             function (data) {
67               $scope.data = data;
68             });
69
70           // Filter function to remove ports with id 0
71           $scope.portNotNull = function (property) {
72             return property.nodeconnector.id !== "0";
73           };
74         }
75       }
76     }
77   });
78 });