Assign image keyname and pubkey at vnf level
[ccsdk/apps.git] / sdnr / wireless-transport / code-Carbon-SR1 / apps / dlux / dlux-web / src / common / general / common.general.services.js
1 define(['common/general/common.general.module'], function(general) {
2
3   general.factory('GeneralRestangular', function(Restangular, ENV) {
4     return Restangular.withConfig(function(RestangularConfig) {
5       RestangularConfig.setBaseUrl(ENV.baseURL);
6     });
7   });
8
9
10   general.factory('SwitchSvc', function (GeneralRestangular) {
11     var svc = {
12       base: function (container) {
13         container = container || 'default';
14         return GeneralRestangular.one('controller/nb/v2').one('switchmanager', container);
15       },
16       data: null
17     };
18
19     svc.delete = function(node) {
20     /* console.log(node);
21       return svc.nodeUrl('default', node.node.type, node.node.id).remove();*/
22     };
23
24     // URL for nodes
25     svc.nodesUrl = function (container) {
26       return svc.base(container).all('nodes');
27     };
28
29     // URL for a node
30     svc.nodeUrl = function (container, type, id) {
31       return svc.base(container).one('node', type).one(id);
32     };
33
34     svc.getAll = function (container) {
35       return svc.nodesUrl(container).getList();
36     };
37
38     svc.getConnectorProperties = function (container, type, id) {
39       return svc.nodeUrl(container, type, id).get();
40     };
41
42     svc.itemData = function (i) {
43       return {
44         state: 'node.detail',
45         name: i.properties.description.value !== 'None' ? i.properties.description.value : i.node.type + '/' + i.node.id,
46         params: {nodeId: i.node.id, nodeType: i.node.type}
47       };
48     };
49
50     svc.itemsData = function (data_) {
51       var data = [];
52
53       angular.forEach(data_.nodeProperties, function (value, key) {
54         data.push(svc.itemData(value));
55       });
56
57       return data;
58     };
59
60     return svc;
61   });
62 });
63