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('GetLastRun');
18 app.controller('GetLastRunController',
20 function($scope, restAPISvc, $window, appContext) {
23 function initialize() {
24 $scope.loadingLabs = true;
25 $scope.loadingBlueprints = false;
26 $scope.loadingVersions = false;
28 restAPISvc.getRestAPI("/api/v1/lab/", function(data) {
29 angular.forEach(data, function(lab) {
30 $scope.labs.push(lab.lab);
32 $scope.loadingLabs = false;
36 $scope.selectedLabChange = function() {
37 $scope.loadingLabs = false;
38 $scope.loadingBlueprints = true;
39 $scope.loadingVersions = false;
40 $scope.blueprints = [];
43 $scope.optionals = [];
45 $scope.selectedBlueprint = {};
46 $scope.selectedVersion = {};
47 $scope.selectedLayer = {};
48 $scope.selectedOptional = {};
49 $scope.selectedOutcome = {};
50 restAPISvc.getRestAPI("/api/v1/results/getblueprintnamesoflab/"
51 + $scope.selectedLab, function(data) {
52 $scope.blueprints = data;
53 $scope.loadingBlueprints = false;
57 $scope.selectedBlueprintChange = function() {
58 if (!$scope.selectedLab) {
61 $scope.loadingLabs = false;
62 $scope.loadingBlueprints = false;
63 $scope.loadingVersions = true;
66 $scope.optionals = [];
68 $scope.selectedVersion = {};
69 $scope.selectedLayer = {};
70 $scope.selectedOptional = {};
71 $scope.selectedOutcome = {};
72 restAPISvc.getRestAPI("/api/v1/results/getblueprintversions/"
73 + $scope.selectedBlueprint + "/" + $scope.selectedLab,
75 $scope.versions = data;
76 $scope.loadingVersions = false;
80 $scope.selectedVersionChange = function() {
82 $scope.optionals = [];
84 $scope.selectedLayer = {};
85 $scope.selectedOptional = {};
86 $scope.selectedOutcome = {};
87 $scope.loadingLabs = false;
88 $scope.loadingBlueprints = false;
89 $scope.loadingVersions = false;
90 $scope.loadingResults = false;
91 $scope.layers = [ 'all', 'hardware', 'os', 'k8s', 'openstack' ];
94 $scope.selectedLayerChange = function() {
95 $scope.optionals = [];
97 $scope.selectedOptional = {};
98 $scope.selectedOutcome = {};
99 $scope.loadingLabs = false;
100 $scope.loadingBlueprints = false;
101 $scope.loadingVersions = false;
102 $scope.loadingResults = false;
103 $scope.optionals = [ 'true', 'false' ];
106 $scope.selectedOptionalChange = function() {
107 $scope.outcomes = [];
108 $scope.selectedOutcome = {};
109 $scope.loadingLabs = false;
110 $scope.loadingBlueprints = false;
111 $scope.loadingVersions = false;
112 $scope.loadingResults = false;
113 $scope.outcomes = [ 'SUCCESS', 'FAILURE' ];
116 $scope.selectedOutcomeChange = function() {
117 $scope.loadingLabs = false;
118 $scope.loadingBlueprints = false;
119 $scope.loadingVersions = false;
120 $scope.loadingResults = false;
123 $scope.get = function() {
124 if (!$scope.selectedLab || !$scope.selectedBlueprint
125 || !$scope.selectedVersion || !$scope.selectedLayer
126 || !$scope.selectedOptional || !$scope.selectedOutcome) {
127 confirm("You must specify all data fields");
131 if ($scope.selectedOutcome === 'SUCCESS') {
138 if ($scope.selectedLayer === 'all') {
141 layer = $scope.selectedLayer;
143 $window.location.href = appContext
144 + "/validationresults#?blueprintName="
145 + $scope.selectedBlueprint + "&" + "version="
146 + $scope.selectedVersion + "&" + "lab=" + $scope.selectedLab
147 + "&" + "allLayers=" + allLayers + "&" + "layer=" + layer + "&"
148 + "optional=" + $scope.selectedOptional + "&" + "outcome="