de5e9c007dcb100c4cdd7ba19dc117e3cac69c95
[vid.git] / vid-app-common / src / main / webapp / app / vid / scripts / services / detailsService.js
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * VID\r
4  * ================================================================================\r
5  * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ============LICENSE_END=========================================================\r
19  */\r
20 \r
21 "use strict";\r
22 \r
23 var DetailsService = function ($log, DataService, ComponentService, COMPONENT,\r
24                                FIELD, UtilityService) {\r
25 \r
26     var _this = this;\r
27 \r
28     var getSummaryList = function () {\r
29         var model = DataService.getModelInfo(COMPONENT.SERVICE);\r
30         switch (_this.componentId) {\r
31             case COMPONENT.NETWORK:\r
32             case COMPONENT.SERVICE:\r
33             case COMPONENT.VNF:\r
34             case COMPONENT.VF_MODULE:\r
35             case COMPONENT.VOLUME_GROUP:\r
36                 return [{\r
37                     name: FIELD.NAME.SUBSCRIBER_NAME,\r
38                     value: DataService.getSubscriberName()\r
39                 }, {\r
40                     name: FIELD.NAME.SERVICE_INSTANCE_ID,\r
41                     value: DataService.getServiceInstanceId()\r
42                 }, {\r
43                     name: FIELD.NAME.SERVICE_TYPE,\r
44                     value: DataService.getServiceType()\r
45                 }, {\r
46                     name: FIELD.NAME.MODEL_NAME,\r
47                     value: model.modelName\r
48                 }, {\r
49                     name: FIELD.NAME.MODEL_VERSION,\r
50                     value: model.modelVersion\r
51                 }];\r
52         }\r
53     };\r
54 \r
55     var getDetailsList = function () {\r
56         switch (_this.componentId) {\r
57             case COMPONENT.NETWORK:\r
58             case COMPONENT.SERVICE:\r
59             case COMPONENT.VNF:\r
60             case COMPONENT.VF_MODULE:\r
61             case COMPONENT.VOLUME_GROUP:\r
62                 var model = DataService.getModelInfo(_this.componentId);\r
63                 var metaData = ComponentService.getDisplayNames(ComponentService\r
64                     .getInventoryParameterList(_this.componentId, DataService\r
65                         .getInventoryItem(), false));\r
66                 if (model && !UtilityService.isObjectEmpty(model.modelName) && !UtilityService.isObjectEmpty(model.modelVersion)) {\r
67                     metaData = metaData.concat([\r
68                         {\r
69                             id: FIELD.NAME.MODEL_NAME,\r
70                             name: FIELD.NAME.MODEL_NAME,\r
71                             value: model.modelName\r
72                         }, {\r
73                             id: FIELD.NAME.MODEL_VERSION,\r
74                             name: FIELD.NAME.MODEL_VERSION,\r
75                             value: model.modelVersion\r
76                         }\r
77                     ]);\r
78                 }\r
79                 return metaData;\r
80         }\r
81     };\r
82 \r
83     var getMsoFilterString = function () {\r
84 \r
85         var instanceId = "";\r
86 \r
87         switch (_this.componentId) {\r
88             case COMPONENT.NETWORK:\r
89                 instanceId = DataService.getNetworkInstanceId();\r
90                 break;\r
91             case COMPONENT.SERVICE:\r
92                 instanceId = DataService.getServiceInstanceId();\r
93                 break;\r
94             case COMPONENT.VNF:\r
95                 instanceId = DataService.getVnfInstanceId();\r
96                 break;\r
97             case COMPONENT.VF_MODULE:\r
98                 instanceId = DataService.getVfModuleInstanceId();\r
99                 break;\r
100             case COMPONENT.VOLUME_GROUP:\r
101                 instanceId = DataService.getVolumeGroupInstanceId();\r
102         }\r
103 \r
104         return "filter=" + _this.componentId + "InstanceId:EQUALS:"\r
105             + instanceId;\r
106     };\r
107 \r
108     return {\r
109         initializeComponent: function (componentId) {\r
110             _this.componentId = ComponentService.initialize(componentId);\r
111         },\r
112         getComponentDisplayName: ComponentService.getComponentDisplayName,\r
113         getSummaryList: getSummaryList,\r
114         getDetailsList: getDetailsList,\r
115         getMsoFilterString: getMsoFilterString\r
116     }\r
117 }\r
118 \r
119 appDS2.factory("DetailsService", ["$log", "DataService", "ComponentService",\r
120     "COMPONENT", "FIELD", "UtilityService", DetailsService]);\r