Project

General

Profile

« Previous | Next » 

Revision 50672

added compatibility validation results component

View differences:

compatibility-validation-history.component.ts
8 8
import { AuthenticationService } from '../../services/authentication.service';
9 9
import { JobsOfUser, StoredJob } from '../../domain/typeScriptClasses';
10 10
import { ValidatorService } from '../../services/validator.service';
11
import { loadingUserJobs, loadingUserJobsError, noUserJobsFound } from '../../domain/shared-messages';
12
import { stat } from 'fs';
11 13

  
12 14
@Component ({
13 15
  selector: 'app-compatibility-validation-history',
......
16 18

  
17 19

  
18 20
export class CompatibilityValidationHistoryComponent  implements OnInit {
21
  userEmail: string;
22
  loadingMessage: string;
23
  errorMessage: string;
24
  infoMessage: string;
25
  successMessage: string;
26
  failureMessage: string;
27

  
19 28
  jobTypes: string[];
20 29
  jobsOfUser: JobsOfUser;
21 30
  jobs: StoredJob[];
......
35 44
  }
36 45

  
37 46
  loadTable() {
47
    //initialize
48
    // RESTORE IN THE END this.userEmail = this.authService.getUserEmail();
49
    this.userEmail = 'ant.lebesis@gmail.com';
50
    this.jobTypes = jobTypes;
51
    this.itemsPerPage = 10;
52
    this.currentPage = 1;
53
    this.currentFilter = 'all';
54
    this.chosenJobType = 'Compatibility Test';
55

  
38 56
    //call API and get all jobs:
39
    this.monitorService.getJobsOfUser('ant.lebesis@gmail.com',
40
                                      'Compatibility Test',
41
                                      '0',
42
                                      '10',
43
                                      '2018-02-01',
44
                                      '2018-02-28',
45
                                      'successful',
46
                                      true).subscribe(
47
      jobs => {this.jobsOfUser = jobs; console.log(jobs); console.log(this.jobsOfUser);},
48
      error => console.log(error.status),
49
      () => {
50
        this.jobTypes = jobTypes;
51
        this.totalPages = 10;
52

  
53
        //initialize
54
        this.itemsPerPage = 10;
55
        this.currentPage = 1;
56
        this.currentFilter = 'all';
57
        this.chosenJobType = '';
58
        this.storedJobs();
59
      }
60
    );
57
    this.getJobs();
61 58
  }
62 59

  
63 60

  
64 61
  filterJobs(filter: string){
65 62
    this.currentFilter = filter;
66 63
    console.log(`requesting ${this.currentFilter} jobs`);
67
    //call api to get filtered jobs
64
    this.getJobs();
68 65
  }
69 66

  
70 67
  getItemsPerPage(num: number){
71 68
    this.itemsPerPage = num;
69
    this.getJobs();
72 70
  }
73 71

  
74 72
  goToNextPage(){
75 73
    if(this.currentPage < this.totalPages) {
76
      //get page current-1 from the API
77
      //on success current--
78
      console.log(`Get me page ${this.currentPage + 1}!`);
74
      this.currentPage++;
75
      console.log(`Get me page ${this.currentPage}!`);
76
      this.getJobs();
79 77
    }
80 78
  }
81 79

  
82 80
  goToPreviousPage(){
83 81
    if(this.currentPage > 1) {
84
      //get page current-1 from the API
85
      //on success current--
86
      console.log(`Get me page ${this.currentPage - 1}!`);
82
      this.currentPage--;
83
      console.log(`Get me page ${this.currentPage}!`);
84
      this.getJobs();
87 85
    }
88 86
  }
89 87

  
......
103 101
      }
104 102
    );
105 103
  }
106
/* WAITING FOR API !
104

  
107 105
  getJobs() {
108
    this.monitorService.getJobsOfUser(this.authService.getUserEmail(),
109
                                      this.chosenJobType,
110
                                      this.currentPage,
111
                                      this.itemsPerPage,
112
                                     null,
113
                                     null,
114
                                      this.currentFilter,
115
                                     true).subscribe(
116
      jobs => this.jobsOfUser = jobs,
117
      error => console.log(error)
106
    this.loadingMessage = loadingUserJobs;
107
    this.errorMessage = '';
108
    this.infoMessage = '';
109
    this.successMessage = '';
110
    this.failureMessage = '';
111
    setTimeout( () => {
112
      this.monitorService.getJobsOfUser(this.userEmail,
113
                                        this.chosenJobType,
114
                                        (this.currentPage-1).toString(),
115
                                        this.itemsPerPage.toString(),
116
                                        '',
117
                                        '',
118
                                        this.currentFilter,
119
                                        true).subscribe(
120
        jobs => this.jobsOfUser = jobs,
121
        error => {
122
          console.log(`The API returned ${error.status}`);
123
          this.errorMessage = loadingUserJobsError;
124
        },
125
        () => {
126
          this.totalPages = Math.ceil(this.jobsOfUser.totalJobs / this.itemsPerPage);
127
          this.loadingMessage = '';
128
          this.errorMessage = '';
129
          if (!this.totalPages) {
130
            this.infoMessage = noUserJobsFound;
131
          }
132
          if (!this.jobsOfUser.jobs) {
133
            this.errorMessage = loadingUserJobsError;
134
          }
135
        }
136
      );
137
    },500);
138
  }
139

  
140
  getResultImage(status: string) {
141
    let assets = 'assets/imgs';
142
    if (status == 'successful') {
143
      return `${assets}/icon_colours-check.jpg`;
144
    } else if (status == 'failed') {
145
      return `${assets}/icon_colours-x.jpg`;
146
    } else {
147
      return `${assets}/icon_colours-question.jpg`;
148
    }
149
  }
150

  
151
  resubmitJob (id: string) {
152
    this.valService.reSubmitJobForValidation(id).subscribe(
153
      res => this.successMessage = `The job with id ${id} was successfully resubmitted`,
154
      error => {
155
        this.failureMessage = `Could not resubmit the job with id ${id}`;
156
        console.log(error);
157
      }
118 158
    );
119 159
  }
120
*/
121 160

  
122 161
}
123 162

  

Also available in: Unified diff