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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import {Component, Input, OnDestroy, OnInit} from '@angular/core';
import {Job, JobExecution} from "../../../model/job";
import {Subscription} from "rxjs";
import {JobsService} from "../../../services/jobs.service";
import {FormControl, FormGroup} from "@angular/forms";
import {ConfigurationService} from "../../../env/configuration.service";
import {faCheckCircle, faCopy, faList, faSave, faStickyNote} from "@fortawesome/free-solid-svg-icons";
import {AlertService} from "../../../services/alert.service";
@Component({
selector: 'app-execution-detail',
templateUrl: './execution-detail.component.html',
styleUrls: ['./execution-detail.component.scss']
})
export class ExecutionDetailComponent implements OnInit, OnDestroy {
@Input() job: Job;
private jobDetail$: Subscription;
public jobDetail: JobExecution;
noteFormGroup: FormGroup;
public faSave = faSave;
public faList = faList;
public faCheckCircle = faCheckCircle;
public faStickyNote = faStickyNote;
public faCopy = faCopy;
constructor(
private configService: ConfigurationService,
private jobService: JobsService,
private alertService: AlertService
) {
this.noteFormGroup = new FormGroup({
notes: new FormControl(),
id: new FormControl()
});
}
ngOnInit() {
this.jobDetail$ = this.jobService.getJob(this.job.jobspec_id).subscribe((j: JobExecution) => {
if (j) {
this.jobDetail = j;
this.noteFormGroup.get('notes').setValue(j.notes);
this.noteFormGroup.get('id').setValue(j.id);
}
});
}
copyToClipboard(text: string): void {
const selBox = document.createElement('textarea');
selBox.style.position = 'fixed';
selBox.style.left = '0';
selBox.style.top = '0';
selBox.style.opacity = '0';
selBox.value = text;
document.body.appendChild(selBox);
selBox.focus();
selBox.select();
document.execCommand('copy');
document.body.removeChild(selBox);
}
getTaskStatusBgClass(status: string) {
switch (status) {
case 'ERROR':
return 'badge-danger';
case 'SUCCESS':
return 'badge-success';
default:
return 'badge-info';
}
}
canAcceptArchive(status: string, archiveStatus: string): boolean {
//console.log(status, archiveStatus);
if (status === 'QA_READY' || status === 'QA_MANUAL' || archiveStatus === 'ARCHIVE_ERROR') {
return true;
} else {
return false;
}
}
getConfigRootDataDirectory(): string {
return this.configService.config.rootDataDirectory;
}
getConfigWebLogBaseUrl(): string {
return this.configService.config.weblogbaseurl;
}
updateNotes() {
this.alertService.info('Saving Notes');
let notes = this.noteFormGroup.get('notes').value;
let id = this.noteFormGroup.get('id').value;
this.jobService.updateNotes(id, notes).subscribe(response => {
this.alertService.success('Notes Saved');
},
error => {
this.alertService.error('Notes did not save. ' + error);
});
}
acceptQa() {
this.performQa(this.job.job_id, 'accept');
}
rejectQa() {
let yesno = confirm("Are you sure you want to reject this image?");
if (yesno) {
this.performQa(this.job.job_id, 'reject');
}
}
performQa(id: number, status: string) {
//console.log(status + 'ing QA');
let newStatus;
if (status == 'accept' && (this.job.job_status === 'QA_READY' || this.job.job_status === 'QA_MANUAL')) {
newStatus = 'QA_ACCEPTED';
} else if (status == 'reject' && (this.job.job_status === 'QA_READY' || this.job.job_status === 'QA_MANUAL')) {
newStatus = 'QA_REJECTED';
}
if (['QA_ACCEPTED', 'QA_MANUAL_ACCEPTED', 'QA_REJECTED', 'QA_MANUAL_REJECTED'].indexOf(newStatus) > -1) {
this.jobService.updateJobStatus(this.job.job_id, newStatus, this.jobDetail.queueName).subscribe(response => {
// this.hideDetails();
});
}
};
ngOnDestroy(): void {
if (this.jobDetail$) {
this.jobDetail$.unsubscribe();
}
}
}