diff options
author | Chocobozzz <me@florianbigard.com> | 2023-04-21 15:04:52 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2023-05-09 08:57:34 +0200 |
commit | 118626c8752bee7b05c4e0b668852e1aba2416f1 (patch) | |
tree | 6407bdcde3496c6a2480313f0958653aa15bab87 /client/src/app/+admin/system/runners/runner-list | |
parent | e592df48c73aa9262b04d23b3319de49b6caf95d (diff) | |
download | PeerTube-118626c8752bee7b05c4e0b668852e1aba2416f1.tar.gz PeerTube-118626c8752bee7b05c4e0b668852e1aba2416f1.tar.zst PeerTube-118626c8752bee7b05c4e0b668852e1aba2416f1.zip |
Implement runner in client side
Diffstat (limited to 'client/src/app/+admin/system/runners/runner-list')
3 files changed, 138 insertions, 0 deletions
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 @@ | |||
1 | <h1 class="d-flex justify-content-between"> | ||
2 | <span class="text-nowrap me-2"> | ||
3 | <my-global-icon iconName="codesandbox" aria-hidden="true"></my-global-icon> | ||
4 | <ng-container i18n>Remote runners</ng-container> | ||
5 | </span> | ||
6 | |||
7 | <a routerLink="/admin/system/runners/registration-tokens-list" class="peertube-button-link peertube-button-icon grey-button"> | ||
8 | <my-global-icon iconName="cog" aria-hidden="true"></my-global-icon> | ||
9 | <ng-container i18n>Runner registration tokens</ng-container> | ||
10 | </a> | ||
11 | </h1> | ||
12 | |||
13 | <p-table | ||
14 | [value]="runners" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start" | ||
15 | [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order" | ||
16 | [lazy]="true" (onLazyLoad)="loadLazy($event)" | ||
17 | [showCurrentPageReport]="true" i18n-currentPageReportTemplate | ||
18 | currentPageReportTemplate="Showing {{'{first}'}} to {{'{last}'}} of {{'{totalRecords}'}} remote runners" | ||
19 | > | ||
20 | <ng-template pTemplate="header"> | ||
21 | <tr> | ||
22 | <th style="width: 120px;"></th> | ||
23 | <th i18n>Name</th> | ||
24 | <th i18n>Description</th> | ||
25 | <th i18n>IP</th> | ||
26 | <th i18n>Last contact</th> | ||
27 | <th style="width: 150px;" i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th> | ||
28 | </tr> | ||
29 | </ng-template> | ||
30 | |||
31 | <ng-template pTemplate="body" let-runner> | ||
32 | <tr> | ||
33 | <td class="action-cell"> | ||
34 | <my-action-dropdown | ||
35 | placement="bottom-right top-right left auto" container="body" | ||
36 | i18n-label label="Actions" [actions]="actions" [entry]="runner" | ||
37 | ></my-action-dropdown> | ||
38 | </td> | ||
39 | |||
40 | <td>{{ runner.name }}</td> | ||
41 | |||
42 | <td>{{ runner.description }}</td> | ||
43 | |||
44 | <td>{{ runner.ip }}</td> | ||
45 | |||
46 | <td>{{ runner.lastContact | date: 'short' }}</td> | ||
47 | |||
48 | <td>{{ runner.createdAt | date: 'short' }}</td> | ||
49 | </tr> | ||
50 | </ng-template> | ||
51 | |||
52 | <ng-template pTemplate="emptymessage"> | ||
53 | <tr> | ||
54 | <td colspan="6"> | ||
55 | <div class="no-results"> | ||
56 | <ng-container i18n>No remote runners found.</ng-container> | ||
57 | </div> | ||
58 | </td> | ||
59 | </tr> | ||
60 | </ng-template> | ||
61 | </p-table> | ||
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 @@ | |||
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' | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-runner-list', | ||
10 | templateUrl: './runner-list.component.html' | ||
11 | }) | ||
12 | export 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 | } | ||