Remove useless register implementation part 2 (DLUX internal Modules)
[dlux.git] / modules / node-resources / src / main / resources / node / nodes.services.js
1 /*\r
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 define(['app/node/nodes.module'],function(node) {\r
10 \r
11   node.factory('nodeConnectorFactory', function() {\r
12     var factory = {};\r
13 \r
14     factory.getActiveFlow = function(flowTable, index) {\r
15       var flow = flowTable[index];\r
16       var activeFlow = flow['opendaylight-flow-table-statistics:flow-table-statistics']['opendaylight-flow-table-statistics:active-flows'];\r
17 \r
18       return (activeFlow > 0);\r
19     };\r
20     return factory;\r
21   });\r
22 \r
23   node.factory('NodeRestangular', function(Restangular, ENV) {\r
24     return Restangular.withConfig(function(RestangularConfig) {\r
25       RestangularConfig.setBaseUrl(ENV.getBaseURL("MD_SAL"));\r
26     });\r
27   });\r
28 \r
29   node.factory('NodeInventorySvc', function(NodeRestangular) {\r
30     var svc = {\r
31       base: function() {\r
32         return NodeRestangular.one('restconf').one('operational').one('opendaylight-inventory:nodes');\r
33       },\r
34       data : null\r
35     };\r
36 \r
37     svc.getCurrentData = function() {\r
38       return svc.data;\r
39     };\r
40 \r
41     svc.getAllNodes = function() {\r
42       svc.data = svc.base().getList();\r
43       return svc.data;\r
44     };\r
45 \r
46     svc.getNode = function(node) {\r
47       return svc.base().one('node', node).get();\r
48     };\r
49 \r
50     return svc;\r
51   });\r
52 \r
53 });\r