From 118626c8752bee7b05c4e0b668852e1aba2416f1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 21 Apr 2023 15:04:52 +0200 Subject: Implement runner in client side --- .../app/+admin/system/runners/runner-list/index.ts | 1 + .../runners/runner-list/runner-list.component.html | 61 +++++++++++++++++ .../runners/runner-list/runner-list.component.ts | 76 ++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 client/src/app/+admin/system/runners/runner-list/index.ts create mode 100644 client/src/app/+admin/system/runners/runner-list/runner-list.component.html create mode 100644 client/src/app/+admin/system/runners/runner-list/runner-list.component.ts (limited to 'client/src/app/+admin/system/runners/runner-list') diff --git a/client/src/app/+admin/system/runners/runner-list/index.ts b/client/src/app/+admin/system/runners/runner-list/index.ts new file mode 100644 index 000000000..5c12bb6d6 --- /dev/null +++ b/client/src/app/+admin/system/runners/runner-list/index.ts @@ -0,0 +1 @@ +export * from './runner-list.component' diff --git a/client/src/app/+admin/system/runners/runner-list/runner-list.component.html b/client/src/app/+admin/system/runners/runner-list/runner-list.component.html new file mode 100644 index 000000000..606eb9afd --- /dev/null +++ b/client/src/app/+admin/system/runners/runner-list/runner-list.component.html @@ -0,0 +1,61 @@ +

+ + + Remote runners + + + + + Runner registration tokens + +

+ + + + + + Name + Description + IP + Last contact + Created + + + + + + + + + + {{ runner.name }} + + {{ runner.description }} + + {{ runner.ip }} + + {{ runner.lastContact | date: 'short' }} + + {{ runner.createdAt | date: 'short' }} + + + + + + +
+ No remote runners found. +
+ + +
+
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 @@ +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 { Runner } from '@shared/models' +import { RunnerService } from '../runner.service' + +@Component({ + selector: 'my-runner-list', + templateUrl: './runner-list.component.html' +}) +export class RunnerListComponent extends RestTable implements OnInit { + runners: Runner[] = [] + totalRecords = 0 + + sort: SortMeta = { field: 'createdAt', order: -1 } + pagination: RestPagination = { count: this.rowsPerPage, start: 0 } + + actions: DropdownAction[][] = [] + + constructor ( + private runnerService: RunnerService, + private notifier: Notifier, + private confirmService: ConfirmService + ) { + super() + } + + ngOnInit () { + this.actions = [ + [ + { + label: $localize`Remove`, + handler: runer => this.deleteRunner(runer) + } + ] + ] + + this.initialize() + } + + getIdentifier () { + return 'RunnerListComponent' + } + + async deleteRunner (runner: Runner) { + const res = await this.confirmService.confirm( + $localize`Do you really want to delete this runner? It won't be able to process jobs anymore.`, + $localize`Remove ${runner.name}` + ) + + if (res === false) return + + this.runnerService.deleteRunner(runner) + .subscribe({ + next: () => { + this.reloadData() + this.notifier.success($localize`Runner removed.`) + }, + + error: err => this.notifier.error(err.message) + }) + } + + protected reloadDataInternal () { + this.runnerService.listRunners({ pagination: this.pagination, sort: this.sort }) + .subscribe({ + next: resultList => { + this.runners = resultList.data + this.totalRecords = resultList.total + }, + + error: err => this.notifier.error(err.message) + }) + } +} -- cgit v1.2.3