[UI] Ignore malformed results
[validation.git] / ui / src / main / webapp / app / BluvalUI / GetBasedOnDate / GetBasedOnDateController.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('GetBasedOnDate');
18 app.controller('GetBasedOnDateController', function($scope, restAPISvc,
19         $window, appContext, $filter) {
20
21     initialize();
22
23     function initialize() {
24         $scope.loadingLabs = true;
25         $scope.loadingBlueprints = false;
26         $scope.loadingVersions = false;
27         $scope.labs = [];
28         restAPISvc.getRestAPI("/api/v1/lab/", function(data) {
29             angular.forEach(data, function(lab) {
30                 $scope.labs.push(lab.lab);
31             });
32             $scope.loadingLabs = false;
33         });
34     }
35
36     $scope.selectedLabChange = function() {
37         $scope.loadingLabs = false;
38         $scope.loadingBlueprints = true;
39         $scope.loadingVersions = false;
40         $scope.blueprints = [];
41         $scope.versions = [];
42         $scope.selectedBlueprint = {};
43         $scope.selectedVersion = {};
44         restAPISvc.getRestAPI("/api/v1/results/getblueprintnamesoflab/"
45                 + $scope.selectedLab, function(data) {
46             $scope.blueprints = data;
47             $scope.loadingBlueprints = false;
48         });
49     }
50
51     $scope.selectedBlueprintChange = function() {
52         if (!$scope.selectedLab) {
53             return;
54         }
55         $scope.loadingLabs = false;
56         $scope.loadingBlueprints = false;
57         $scope.loadingVersions = true;
58         $scope.versions = [];
59         $scope.selectedVersion = {};
60         restAPISvc.getRestAPI("/api/v1/results/getblueprintversions/"
61                 + $scope.selectedBlueprint + "/" + $scope.selectedLab,
62                 function(data) {
63                     $scope.versions = data;
64                     $scope.loadingVersions = false;
65                 });
66     }
67
68     $scope.selectedVersionChange = function() {
69     }
70
71     $scope.get = function() {
72         if (!$scope.selectedLab || !$scope.selectedBlueprint
73                 || !$scope.selectedVersion || !$scope.selectedDate) {
74             confirm("You must specify all data fields");
75             return;
76         }
77         var selectedDate = $filter('date')($scope.selectedDate, "MM-dd-yyyy");
78
79         $window.location.href = appContext
80                 + "/validationresults#?blueprintName="
81                 + $scope.selectedBlueprint + "&" + "version="
82                 + $scope.selectedVersion + "&" + "lab=" + $scope.selectedLab
83                 + "&" + "date=" + selectedDate;
84     }
85
86 });