1 import { SortMeta } from 'primeng/api'
2 import { Component, OnInit } from '@angular/core'
3 import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core'
4 import { DropdownAction } from '@app/shared/shared-main'
5 import { Runner } from '@shared/models'
6 import { RunnerService } from '../runner.service'
9 selector: 'my-runner-list',
10 templateUrl: './runner-list.component.html'
12 export class RunnerListComponent extends RestTable <Runner> implements OnInit {
13 runners: Runner[] = []
16 sort: SortMeta = { field: 'createdAt', order: -1 }
17 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
19 actions: DropdownAction<Runner>[][] = []
22 private runnerService: RunnerService,
23 private notifier: Notifier,
24 private confirmService: ConfirmService
33 label: $localize`Remove`,
34 handler: runer => this.deleteRunner(runer)
43 return 'RunnerListComponent'
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}`
52 if (res === false) return
54 this.runnerService.deleteRunner(runner)
58 this.notifier.success($localize`Runner removed.`)
61 error: err => this.notifier.error(err.message)
65 protected reloadDataInternal () {
66 this.runnerService.listRunners({ pagination: this.pagination, sort: this.sort })
69 this.runners = resultList.data
70 this.totalRecords = resultList.total
73 error: err => this.notifier.error(err.message)