Connection Manager
[dlux.git] / src / app / connection_manager / connection_manager.js
1 angular.module('dlux.connection_manager', [])
2
3 .config(function ($stateProvider) {
4   $stateProvider.state('connection_manager', {
5     abstract: true,
6     url: '/connection_manager',
7     templateUrl: 'connection_manager/root.tpl.html'
8   });
9
10   $stateProvider.state('connection_manager.index', {
11     url: '/index',
12     templateUrl: 'connection_manager/index.tpl.html',
13     views: {
14       '': {
15         templateUrl: 'connection_manager/index.tpl.html',
16         controller: function ($scope, ConnectionManagerSvc) {
17           $scope.svc = ConnectionManagerSvc;
18
19           $scope.gridOptions = {
20             data: 'data["node"]',
21             selectedItems: [],
22             enableRowSelection: true,
23             showSelectionCheckbox: true,
24             selectWithCheckboxOnly: true,
25             columnDefs: [
26               {
27                 field: 'id', displayName: 'ID',
28               },
29               {
30                 field: 'type', displayName: 'Type',
31               }
32             ]
33           };
34
35           $scope.$watch(
36             function () {
37               return ConnectionManagerSvc.data;
38             },
39             function (data) {
40               $scope.data = data;
41             }
42           );
43         }
44       }
45     }
46   });
47
48   $stateProvider.state('connection_manager.discover', {
49     url: '/discover',
50     views: {
51       '': {
52         templateUrl: 'connection_manager/discover.tpl.html',
53         controller: function ($scope, SwitchSvc, ConnectionManagerSvc) {
54           $scope.nodePort = 6633;
55
56           $scope.doDiscover = function () {
57             ConnectionManagerSvc.discover($scope.nodeId, $scope.nodeAddress, $scope.nodePort).then(
58               function () {
59                 $scope.$state.go('connection_manager.index');
60               },
61               function (error) {
62                 $scope.error = error.data;
63               }
64             );
65           };
66         }
67       }
68     }
69   });
70 });