actually adding the files to the initial commit
[vid.git] / vid / src / main / webapp / app / vid / scripts / controller / detailsDialogController.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 "use strict";
22
23 var detailsDialogController = function($scope, $http, $timeout, $log,
24         MsoService, DetailsService, UtilityService) {
25
26     $scope.isDialogVisible = false;
27     $scope.summaryControl = {};
28     $scope.detailsControl = {};
29
30     $scope.$on("showComponentDetails", function(event, request) {
31
32         $scope.log = "";
33         $scope.isSpinnerVisible = true;
34         $scope.isErrorVisible = false;
35         $scope.isDialogVisible = true;
36         $scope.popup.isVisible = true;
37
38         DetailsService.initializeComponent(request.componentId);
39
40         $scope.componentName = DetailsService.getComponentDisplayName();
41
42         $scope.summaryControl.setList(DetailsService.getSummaryList());
43
44         $scope.detailsControl.setList(DetailsService.getDetailsList());
45
46         UtilityService.setHttpErrorHandler(function(response) {
47             showError("System failure", UtilityService
48                     .getHttpErrorMessage(response));
49         });
50
51         MsoService.getOrchestrationRequests(
52                 DetailsService.getMsoFilterString(), handleGetResponse);
53     });
54
55     var handleGetResponse = function(response) {
56         $scope.isSpinnerVisible = false;
57         try {
58             $scope.log = MsoService
59                     .getFormattedGetOrchestrationRequestsResponse(response);
60         } catch (error) {
61             $scope.log = MsoService.getFormattedCommonResponse(response);
62             MsoService.showResponseContentError(error, showError);
63         }
64     }
65
66     $scope.close = function() {
67         $scope.isDialogVisible = false;
68         $scope.popup.isVisible = false;
69     }
70
71     var showError = function(summary, details) {
72         var message = summary;
73         if (UtilityService.hasContents(details)) {
74             message += " (" + details + ")";
75         }
76         $scope.isSpinnerVisible = false;
77         $scope.isErrorVisible = true;
78         $scope.error = message;
79     }
80 }
81
82 app.controller("detailsDialogController", [ "$scope", "$http", "$timeout",
83         "$log", "MsoService", "DetailsService", "UtilityService",
84         detailsDialogController ]);