[VID-6] Initial rebase push
[vid.git] / vid-app-common / src / main / webapp / app / vid / scripts / controller / detailsDialogController.js
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * VID\r
4  * ================================================================================\r
5  * Copyright (C) 2017 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 detailsDialogController = function($scope, $http, $timeout, $log,\r
24         MsoService, DetailsService, UtilityService, COMPONENT, FIELD) {\r
25 \r
26     $scope.isDialogVisible = false;\r
27     $scope.summaryControl = {};\r
28     $scope.detailsControl = {};\r
29 \r
30     $scope.$on(COMPONENT.SHOW_COMPONENT_DETAILS, function(event, request) {\r
31 \r
32         $scope.log = "";\r
33         $scope.isSpinnerVisible = true;\r
34         $scope.isErrorVisible = false;\r
35         $scope.isDialogVisible = true;\r
36         $scope.popup.isVisible = true;\r
37 \r
38         DetailsService.initializeComponent(request.componentId);\r
39 \r
40         $scope.componentName = DetailsService.getComponentDisplayName();\r
41 \r
42         $scope.summaryControl.setList(DetailsService.getSummaryList());\r
43 \r
44         $scope.detailsControl.setList(DetailsService.getDetailsList());\r
45 \r
46         UtilityService.setHttpErrorHandler(function(response) {\r
47             showError(FIELD.ERROR.SYSTEM_FAILURE, UtilityService\r
48                     .getHttpErrorMessage(response));\r
49         });\r
50 \r
51         MsoService.getOrchestrationRequests(\r
52                 DetailsService.getMsoFilterString(), handleGetResponse);\r
53     });\r
54 \r
55     var handleGetResponse = function(response) {\r
56         $scope.isSpinnerVisible = false;\r
57         try {\r
58             $scope.log = MsoService\r
59                     .getFormattedGetOrchestrationRequestsResponse(response);\r
60         } catch (error) {\r
61             $scope.log = MsoService.getFormattedCommonResponse(response);\r
62             MsoService.showResponseContentError(error, showError);\r
63         }\r
64     }\r
65 \r
66     $scope.close = function() {\r
67         $scope.isDialogVisible = false;\r
68         $scope.popup.isVisible = false;\r
69     }\r
70 \r
71     var showError = function(summary, details) {\r
72         var message = summary;\r
73         if (UtilityService.hasContents(details)) {\r
74             message += " (" + details + ")";\r
75         }\r
76         $scope.isSpinnerVisible = false;\r
77         $scope.isErrorVisible = true;\r
78         $scope.error = message;\r
79     }\r
80 }\r
81 \r
82 appDS2.controller("detailsDialogController", [ "$scope", "$http", "$timeout",\r
83         "$log", "MsoService", "DetailsService", "UtilityService", "COMPONENT", "FIELD",\r
84         detailsDialogController ]);\r