Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import {Component, Input, OnDestroy, OnInit} from '@angular/core';
import {Job, JobSpec} from "../../model/job";
import {Subscription} from "rxjs";
import {JobsService} from "../../services/jobs.service";
import {verticleSlide} from "../../animations";
import {AlertService} from "../../services/alert.service";
import {Location, LocationStrategy, PathLocationStrategy} from '@angular/common';
import {faCaretDown, faCaretUp} from "@fortawesome/free-solid-svg-icons";
@Component({
selector: 'app-jobspec',
providers: [Location, {provide: LocationStrategy, useClass: PathLocationStrategy}],
templateUrl: './jobspec.component.html',
styleUrls: ['./jobspec.component.scss'],
animations: [verticleSlide]
})
export class JobspecComponent implements OnInit, OnDestroy {
@Input() job: Job;
detailsExposed: boolean = false;
public jobspec$: Subscription;
public jobspec: JobSpec;
public faCaretDown = faCaretDown;
public faCaretUp = faCaretUp;
constructor(private jobService: JobsService, private alertService: AlertService, private location: Location) {
}
ngOnInit() {
}
/**
* is this component being shown in its root tab, or included into another tab for details
* this is used to change the UI and click behaviors in the template
*/
isHomePath(): boolean {
return !!this.location.path(false).match(/jobs/);
}
toggleDetails(): void {
if (this.detailsExposed) {
this.detailsExposed = false;
} else {
this.showDetails();
}
}
showDetails(): void {
this.detailsExposed = true;
this.jobspec$ = this.jobService.getJobSpec(this.job.jobspec_id).subscribe((js: JobSpec) => {
if (js) {
this.jobspec = js;
} else {
this.alertService.error('Job Spec could not be retrieved');
}
});
}
getJobStatusClass(status: string) {
switch (status) {
case 'ERROR':
return 'badge-danger';
case 'QA_REJECTED':
return 'badge-secondary';
case 'PROCESSING':
return 'badge-primary';
case 'QA_READY':
return 'badge-success';
case 'QA_ACCEPTED':
return 'badge-info';
case 'QA_MANUAL':
return 'badge-warning';
default:
return 'border border-info text-info';
}
}
ngOnDestroy(): void {
if (this.jobspec$) {
this.jobspec$.unsubscribe();
}
}
}