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('GetBasedOnDate');
18 app.controller('GetBasedOnDateController', function($scope, restAPISvc,
19 $window, appContext, $filter) {
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 = [];
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;
51 $scope.selectedBlueprintChange = function() {
52 if (!$scope.selectedLab) {
55 $scope.loadingLabs = false;
56 $scope.loadingBlueprints = false;
57 $scope.loadingVersions = true;
59 $scope.selectedVersion = {};
60 restAPISvc.getRestAPI("/api/v1/results/getblueprintversions/"
61 + $scope.selectedBlueprint + "/" + $scope.selectedLab,
63 $scope.versions = data;
64 $scope.loadingVersions = false;
68 $scope.selectedVersionChange = function() {
71 $scope.get = function() {
72 if (!$scope.selectedLab || !$scope.selectedBlueprint
73 || !$scope.selectedVersion || !$scope.selectedDate) {
74 confirm("You must specify all data fields");
77 var selectedDate = $filter('date')($scope.selectedDate, "MM-dd-yyyy");
79 $window.location.href = appContext
80 + "/validationresults#?blueprintName="
81 + $scope.selectedBlueprint + "&" + "version="
82 + $scope.selectedVersion + "&" + "lab=" + $scope.selectedLab
83 + "&" + "date=" + selectedDate;