aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/system/runners/runner-list/runner-list.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin/system/runners/runner-list/runner-list.component.ts')
-rw-r--r--client/src/app/+admin/system/runners/runner-list/runner-list.component.ts76
1 files changed, 76 insertions, 0 deletions
diff --git a/client/src/app/+admin/system/runners/runner-list/runner-list.component.ts b/client/src/app/+admin/system/runners/runner-list/runner-list.component.ts
new file mode 100644
index 000000000..7566f967e
--- /dev/null
+++ b/client/src/app/+admin/system/runners/runner-list/runner-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 { Runner } from '@shared/models'
6import { RunnerService } from '../runner.service'
7
8@Component({
9 selector: 'my-runner-list',
10 templateUrl: './runner-list.component.html'
11})
12export class RunnerListComponent extends RestTable <Runner> implements OnInit {
13 runners: Runner[] = []
14 totalRecords = 0
15
16 sort: SortMeta = { field: 'createdAt', order: -1 }
17 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
18
19 actions: DropdownAction<Runner>[][] = []
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`Remove`,
34 handler: runer => this.deleteRunner(runer)
35 }
36 ]
37 ]
38
39 this.initialize()
40 }
41
42 getIdentifier () {
43 return 'RunnerListComponent'
44 }
45
46 async deleteRunner (runner: Runner) {
47 const res = await this.confirmService.confirm(
48 $localize`Do you really want to delete this runner? It won't be able to process jobs anymore.`,
49 $localize`Remove ${runner.name}`
50 )
51
52 if (res === false) return
53
54 this.runnerService.deleteRunner(runner)
55 .subscribe({
56 next: () => {
57 this.reloadData()
58 this.notifier.success($localize`Runner removed.`)
59 },
60
61 error: err => this.notifier.error(err.message)
62 })
63 }
64
65 protected reloadDataInternal () {
66 this.runnerService.listRunners({ pagination: this.pagination, sort: this.sort })
67 .subscribe({
68 next: resultList => {
69 this.runners = resultList.data
70 this.totalRecords = resultList.total
71 },
72
73 error: err => this.notifier.error(err.message)
74 })
75 }
76}