aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.ts')
-rw-r--r--client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.ts76
1 files changed, 76 insertions, 0 deletions
diff --git a/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.ts b/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.ts
new file mode 100644
index 000000000..ea889f0f7
--- /dev/null
+++ b/client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.ts
@@ -0,0 +1,76 @@
1import { SortMeta } from 'primeng/api'
2import { Component, OnInit } from '@angular/core'
3import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core'
4import { DropdownAction } from '@app/shared/shared-main'
5import { RunnerJob } from '@shared/models'
6import { RunnerJobFormatted, RunnerService } from '../runner.service'
7
8@Component({
9 selector: 'my-runner-job-list',
10 templateUrl: './runner-job-list.component.html'
11})
12export class RunnerJobListComponent extends RestTable <RunnerJob> implements OnInit {
13 runnerJobs: RunnerJobFormatted[] = []
14 totalRecords = 0
15
16 sort: SortMeta = { field: 'createdAt', order: -1 }
17 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
18
19 actions: DropdownAction<RunnerJob>[][] = []
20
21 constructor (
22 private runnerService: RunnerService,
23 private notifier: Notifier,
24 private confirmService: ConfirmService
25 ) {
26 super()
27 }
28
29 ngOnInit () {
30 this.actions = [
31 [
32 {
33 label: $localize`Cancel this job`,
34 handler: job => this.cancelJob(job)
35 }
36 ]
37 ]
38
39 this.initialize()
40 }
41
42 getIdentifier () {
43 return 'RunnerJobListComponent'
44 }
45
46 async cancelJob (job: RunnerJob) {
47 const res = await this.confirmService.confirm(
48 $localize`Do you really want to cancel this job? Children won't be processed.`,
49 $localize`Cancel job`
50 )
51
52 if (res === false) return
53
54 this.runnerService.cancelJob(job)
55 .subscribe({
56 next: () => {
57 this.reloadData()
58 this.notifier.success($localize`Job cancelled.`)
59 },
60
61 error: err => this.notifier.error(err.message)
62 })
63 }
64
65 protected reloadDataInternal () {
66 this.runnerService.listRunnerJobs({ pagination: this.pagination, sort: this.sort, search: this.search })
67 .subscribe({
68 next: resultList => {
69 this.runnerJobs = resultList.data
70 this.totalRecords = resultList.total
71 },
72
73 error: err => this.notifier.error(err.message)
74 })
75 }
76}