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
|
import { SortMeta } from 'primeng/api'
import { Component, OnInit } from '@angular/core'
import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core'
import { DropdownAction } from '@app/shared/shared-main'
import { RunnerJob } from '@shared/models'
import { RunnerJobFormatted, RunnerService } from '../runner.service'
@Component({
selector: 'my-runner-job-list',
templateUrl: './runner-job-list.component.html'
})
export class RunnerJobListComponent extends RestTable <RunnerJob> implements OnInit {
runnerJobs: RunnerJobFormatted[] = []
totalRecords = 0
sort: SortMeta = { field: 'createdAt', order: -1 }
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
actions: DropdownAction<RunnerJob>[][] = []
constructor (
private runnerService: RunnerService,
private notifier: Notifier,
private confirmService: ConfirmService
) {
super()
}
ngOnInit () {
this.actions = [
[
{
label: $localize`Cancel this job`,
handler: job => this.cancelJob(job)
}
]
]
this.initialize()
}
getIdentifier () {
return 'RunnerJobListComponent'
}
async cancelJob (job: RunnerJob) {
const res = await this.confirmService.confirm(
$localize`Do you really want to cancel this job? Children won't be processed.`,
$localize`Cancel job`
)
if (res === false) return
this.runnerService.cancelJob(job)
.subscribe({
next: () => {
this.reloadData()
this.notifier.success($localize`Job cancelled.`)
},
error: err => this.notifier.error(err.message)
})
}
protected reloadDataInternal () {
this.runnerService.listRunnerJobs({ pagination: this.pagination, sort: this.sort, search: this.search })
.subscribe({
next: resultList => {
this.runnerJobs = resultList.data
this.totalRecords = resultList.total
},
error: err => this.notifier.error(err.message)
})
}
}
|