Merge "[RECV-94] Separate docker/robot invoking"
[validation.git] / ui / src / main / webapp / app / AECBlueprintValidationUI / GetBySubmissionId / AECGetBySubmissionIdController.js
1 /*
2  * Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 var app = angular.module('AECGetBySubmissionId');
18 app
19         .controller(
20                 'AECGetBySubmissionIdController',
21                 function($scope, restAPISvc) {
22
23                     initialize();
24
25                     function initialize() {
26                         $scope.loading = false;
27                         $scope.showResults = false;
28                         $scope.results = [];
29                         $scope.resultsLayers = [];
30                         $scope.resultsLayerTestSuitesNames = [];
31                         $scope.selectedRobotTestResult = [];
32                         restAPISvc
33                                 .getRestAPI(
34                                         "/api/submission/",
35                                         function(data) {
36                                             $scope.submissions = data;
37                                             $scope.submissionsForDisplay = [];
38                                             angular
39                                                     .forEach(
40                                                             $scope.submissions,
41                                                             function(
42                                                                     submissionData) {
43                                                                 if (submissionData.submissionStatus === "Completed") {
44                                                                     var temp = "id: "
45                                                                             + submissionData.submissionId
46                                                                             + " blueprint: "
47                                                                             + submissionData.blueprintInstanceForValidation.blueprint.blueprintName
48                                                                             + " version: "
49                                                                             + submissionData.blueprintInstanceForValidation.version
50                                                                             + " layer: "
51                                                                             + submissionData.blueprintInstanceForValidation.layer
52                                                                             + " lab: "
53                                                                             + submissionData.timeslot.lab.lab
54                                                                             + " Start date and time: "
55                                                                             + submissionData.timeslot.startDateTime
56                                                                     /*
57                                                                      * + "
58                                                                      * duration: " +
59                                                                      * submissionData.blueprintInstanceForValidation.timeslot.duration
60                                                                      */;
61                                                                     $scope.submissionsForDisplay
62                                                                             .push(temp);
63                                                                 }
64                                                             });
65                                         });
66                     }
67                     $scope.selectedSubmissionChange = function(
68                             selectedSubmission) {
69                         $scope.results = [];
70                         $scope.resultsLayers = [];
71                         $scope.resultsLayerTestSuitesNames = [];
72                         $scope.selectedRobotTestResult = [];
73                         $scope.loading = true;
74                         $scope.showResults = false;
75                         var id = selectedSubmission.substring(
76                                 selectedSubmission.indexOf("id:") + 4,
77                                 selectedSubmission.indexOf("blueprint") - 1);
78                         restAPISvc
79                                 .getRestAPI(
80                                         "/api/results/getBySubmissionId/" + id,
81                                         function(data) {
82                                             $scope.loading = false;
83                                             if (data !== undefined) {
84                                                 $scope.results = data;
85                                                 angular
86                                                         .forEach(
87                                                                 $scope.results,
88                                                                 function(result) {
89                                                                     $scope.resultsLayers
90                                                                             .push(result.blueprintLayer);
91                                                                 });
92                                                 $scope.showResults = true;
93                                             } else {
94                                                 confirm("Error when committing the submission");
95                                             }
96                                         });
97                     }
98
99                     $scope.selectedResultsLayerChange = function(selectedLayer) {
100                         $scope.resultsLayerTestSuitesNames = [];
101                         $scope.robotTestResults = [];
102                         $scope.selectedRobotTestResult = [];
103                         var selectedLayerResult = [];
104                         angular.forEach($scope.results, function(result) {
105                             if (result.blueprintLayer === selectedLayer) {
106                                 selectedLayerResult = result;
107                             }
108                         });
109                         $scope.robotTestResults = selectedLayerResult.robotTestResults;
110                         angular.forEach($scope.robotTestResults, function(
111                                 robotTestResult) {
112                             $scope.resultsLayerTestSuitesNames
113                                     .push(robotTestResult.name);
114                         });
115                     }
116
117                     $scope.selectedTestSuitesNameChange = function(
118                             selectedTestSuiteName) {
119                         angular
120                                 .forEach(
121                                         $scope.robotTestResults,
122                                         function(robotTestResult) {
123                                             if (robotTestResult.name.trim() === selectedTestSuiteName
124                                                     .trim()) {
125                                                 $scope.selectedRobotTestResult = robotTestResult;
126                                             }
127                                         });
128                     }
129
130                 });