8804de8b9d9974e4ae6ebd470100dbce48c6c76e
[validation.git] / ui / src / main / webapp / app / BluvalUI / ValidationResults / TestSuiteResults / TestSuiteResultsController.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('ValidationResults');
18 app.controller('TestSuiteResultsController', function($scope,
19         generalValidationResultsSvc) {
20
21     initialize();
22
23     function initialize() {
24         $scope.showTestSuitesResults = false;
25         $scope.wRobotTestResults = [];
26         $scope.selectedTestId = null;
27         $scope.selectedTest = null;
28         $scope.resultsLayers = [];
29         $scope.resultsLayerTestSuitesNames = [];
30         $scope.selectedRobotTestResult = [];
31         $scope.selectedLayer = [];
32         $scope.selectedTestSuiteName = [];
33
34         $scope.validationNexusTestResult = $scope.params;
35         $scope.wRobotTestResults = $scope.params.wRobotNexusTestResults;
36         if (generalValidationResultsSvc
37                 .mapResult($scope.validationNexusTestResult) === null) {
38             confirm("No data was found");
39         } else {
40             $scope.showTestSuitesResults = true;
41             angular.forEach($scope.wRobotTestResults, function(result) {
42                 $scope.resultsLayers.push(result.blueprintLayer);
43             });
44         }
45
46     }
47
48     $scope.selectedResultsLayerChange = function(selectedLayer) {
49         $scope.selectedTestId = null;
50         $scope.selectedTest = null;
51         $scope.resultsLayerTestSuitesNames = [];
52         $scope.robotTestResults = [];
53         $scope.selectedRobotTestResult = [];
54         $scope.selectedTestSuiteName = [];
55         var selectedLayerResult = [];
56         angular.forEach($scope.wRobotTestResults, function(result) {
57             if (result.blueprintLayer === selectedLayer) {
58                 selectedLayerResult = result;
59             }
60         });
61         $scope.robotTestResults = selectedLayerResult.robotTestResults;
62         angular.forEach($scope.robotTestResults, function(robotTestResult) {
63             $scope.resultsLayerTestSuitesNames.push(robotTestResult.name);
64         });
65     }
66
67     $scope.selectedTestSuitesNameChange = function(selectedTestSuiteName) {
68         if (!selectedTestSuiteName) {
69             return;
70         }
71         $scope.selectedTestId = null;
72         $scope.selectedTest = null;
73         angular.forEach($scope.robotTestResults, function(robotTestResult) {
74             if (robotTestResult.name.trim() === selectedTestSuiteName.trim()) {
75                 $scope.selectedRobotTestResult = robotTestResult;
76             }
77         });
78     }
79
80     $scope.setClickedTest = function(test) {
81         $scope.selectedTestId = test.id;
82         $scope.selectedTest = test;
83     }
84
85 });