2 * Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 var app = angular.module('ValidationResults');
19 app.factory('generalValidationResultsSvc', [ function() {
21 svc.getBlueprintLayers = function(wRobotNexusTestResults) {
23 angular.forEach(wRobotNexusTestResults,
24 function(wRobotNexusTestResult) {
25 if (wRobotNexusTestResult.blueprintLayer !== undefined) {
26 layers.push(wRobotNexusTestResult.blueprintLayer);
31 svc.mapResult = function(validationNexusTestResult) {
32 if (!validationNexusTestResult.timestamp) {
35 if (!validationNexusTestResult.wRobotNexusTestResults) {
38 if (validationNexusTestResult.wRobotNexusTestResults.length === 0) {
41 var resultExistence = false;
42 angular.forEach(validationNexusTestResult.wRobotNexusTestResults,
44 if (result.robotTestResults
45 && result.robotTestResults.length > 0) {
46 resultExistence = true;
49 if (resultExistence) {
50 if (validationNexusTestResult.result === true) {
57 svc.filterWithLayer = function(validationNexusTestResults, filterLayer) {
58 if (filterLayer === undefined || filterLayer === '') {
59 return validationNexusTestResults;
61 var filteredResults = [];
62 angular.forEach(validationNexusTestResults, function(
63 validationNexusTestResult) {
64 angular.forEach(validationNexusTestResult.wRobotNexusTestResults,
65 function(wRobotNexusTestResult) {
66 if (wRobotNexusTestResult.blueprintLayer.toLowerCase()
67 .includes(filterLayer.toLowerCase())) {
68 filteredResults.push(validationNexusTestResult);
72 return filteredResults;
74 svc.filterWithResult = function(validationNexusTestResults, filterResult) {
75 if (filterResult === undefined || filterResult === '') {
76 return validationNexusTestResults;
78 var filteredResults = [];
79 angular.forEach(validationNexusTestResults, function(
80 validationNexusTestResult) {
81 if (validationNexusTestResult.result === true
82 && 'success'.includes(filterResult.toLowerCase())) {
83 filteredResults.push(validationNexusTestResult);
84 } else if (validationNexusTestResult.result === false
85 && 'failure'.includes(filterResult.toLowerCase())) {
86 filteredResults.push(validationNexusTestResult);
89 return filteredResults;
91 svc.getLab = function(silo, silos) {
93 angular.forEach(silos, function(siloData) {
94 if (silo === siloData.silo) {
95 lab = siloData.lab.lab;