UI initial implementation.
[validation.git] / ui / src / main / webapp / resources / js / AECFindBySubmissionIdController.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 AECBlueprintValidationUIApp = angular
18         .module('BlueprintValidationUIManagement');
19
20 AECBlueprintValidationUIApp
21         .controller(
22                 'AECFindBySubmissionIdController',
23                 function($scope, restAPISvc) {
24
25                     initialize();
26
27                     function initialize() {
28                         $scope.results = [];
29                         restAPISvc
30                                 .getRestAPI(
31                                         "/api/submission/",
32                                         function(data) {
33                                             $scope.submissions = data;
34                                             $scope.submissionsForDisplay = [];
35                                             angular
36                                                     .forEach(
37                                                             $scope.submissions,
38                                                             function(
39                                                                     submissionData) {
40                                                                 var temp = "id: "
41                                                                         + submissionData.submissionId
42                                                                         + " blueprint: "
43                                                                         + submissionData.blueprintInstance.blueprint.blueprintName
44                                                                         + " version: "
45                                                                         + submissionData.blueprintInstance.version
46                                                                         + " layer: "
47                                                                         + submissionData.blueprintInstance.layer
48                                                                         + " lab: "
49                                                                         + submissionData.blueprintInstance.timeslot.lab
50                                                                         + " Start date and time: "
51                                                                         + submissionData.blueprintInstance.timeslot.startDateTime
52                                                                         + " duration: "
53                                                                         + submissionData.blueprintInstance.timeslot.duration;
54                                                                 $scope.submissionsForDisplay
55                                                                         .push(temp);
56                                                             });
57                                         });
58                     }
59                     $scope.selectedSubmissionChange = function(
60                             selectedSubmission) {
61                         $scope.results = [];
62                         var id = selectedSubmission.substring(
63                                 selectedSubmission.indexOf("id:") + 4,
64                                 selectedSubmission.indexOf("blueprint") - 1);
65                         restAPISvc.getRestAPI(
66                                 "/api/results/findBySubmissionId/" + id,
67                                 function(data) {
68                                     $scope.results = data;
69                                 });
70                     }
71
72                 });