[UI] Common class for results
[validation.git] / ui / src / main / webapp / app / BluvalUI / CommittedSubmissions / CommittedSubmissionsController.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('CommittedSubmissions');
18
19 app
20         .controller(
21                 'CommittedSubmissionsController',
22                 function($scope, restAPISvc, $interval, refreshPeriod,
23                         committedSubmissionsSvc, NgTableParams, appContext,
24                         $window) {
25
26                     $scope.getLayer = committedSubmissionsSvc.getLayer;
27                     $scope.getResultUrl = committedSubmissionsSvc.getResultUrl;
28                     $scope.mapResult = committedSubmissionsSvc.mapResult;
29
30                     initialize();
31
32                     function initialize() {
33                         restAPISvc.getRestAPI("/api/v1/submission/", function(
34                                 submissions) {
35                             $scope.submissions = submissions;
36                             var data = submissions;
37                             $scope.tableParams = new NgTableParams({
38                                 page : 1,
39                                 count : 5
40                             }, {
41                                 dataset : data
42                             });
43                         });
44                     }
45
46                     $scope.refreshCommittedSubmissions = function() {
47                         initialize();
48                     }
49
50                     $scope.getValidationResults = function(submission) {
51                         if (!submission.validationDbTestResult
52                                 || !submission.validationDbTestResult.timestamp
53                                 || !submission.validationDbTestResult.wrobotDbTestResults
54                                 || submission.validationDbTestResult.wrobotDbTestResults.length === 0) {
55                             return;
56                         }
57                         $window.location.href = appContext
58                                 + "/validationresults#?submissionId="
59                                 + submission.submissionId;
60                     }
61
62                     /*
63                      * $interval(function() {
64                      * $scope.refreshCommittedSubmissions(); }, refreshPeriod);
65                      */
66
67                 });