[UI] Ignore malformed results
[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 = '';
27         $scope.selectedTest = '';
28         $scope.resultsLayers = [];
29         $scope.resultsLayerTestSuitesNames = [];
30         $scope.selectedRobotTestResult = '';
31         $scope.selectedLayer = '';
32         $scope.selectedTestSuiteName = '';
33         $scope.validationDbTestResult = $scope.params;
34         $scope.wrobotTestResults = $scope.params.wrobotDbTestResults;
35         if (generalValidationResultsSvc
36                 .mapResult($scope.validationDbTestResult) === null) {
37             confirm("No data was found");
38         } else {
39             $scope.showTestSuitesResults = true;
40             angular.forEach($scope.wrobotTestResults, function(result) {
41                 $scope.resultsLayers.push(result.layer);
42             });
43         }
44
45     }
46
47     $scope.selectedResultsLayerChange = function(selectedLayer) {
48         $scope.selectedTestId = null;
49         $scope.selectedTest = null;
50         $scope.resultsLayerTestSuitesNames = [];
51         $scope.robotTestResults = [];
52         $scope.selectedRobotTestResult = '';
53         $scope.selectedTestSuiteName = '';
54         var selectedLayerResult = [];
55         angular.forEach($scope.wrobotTestResults, function(result) {
56             if (result.layer === selectedLayer) {
57                 selectedLayerResult = result;
58             }
59         });
60         $scope.robotTestResults = angular
61                 .fromJson(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 = '';
72         $scope.selectedTest = '';
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 });