diff options
Diffstat (limited to 'client/src/app/+admin/system/runners/runner-registration-token-list')
3 files changed, 154 insertions, 0 deletions
diff --git a/client/src/app/+admin/system/runners/runner-registration-token-list/index.ts b/client/src/app/+admin/system/runners/runner-registration-token-list/index.ts new file mode 100644 index 000000000..8e77978b3 --- /dev/null +++ b/client/src/app/+admin/system/runners/runner-registration-token-list/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './runner-registration-token-list.component' | |||
diff --git a/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.html b/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.html new file mode 100644 index 000000000..2fd23e2fc --- /dev/null +++ b/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.html | |||
@@ -0,0 +1,65 @@ | |||
1 | <h1 class="d-flex justify-content-between"> | ||
2 | <span class="text-nowrap me-2"> | ||
3 | <my-global-icon iconName="cog" aria-hidden="true"></my-global-icon> | ||
4 | <ng-container i18n>Runner registration tokens</ng-container> | ||
5 | </span> | ||
6 | |||
7 | <div> | ||
8 | <a routerLink="/admin/system/runners/runners-list" class="peertube-button-link peertube-button-icon grey-button"> | ||
9 | <my-global-icon iconName="codesandbox" aria-hidden="true"></my-global-icon> | ||
10 | <ng-container i18n>Remote runners</ng-container> | ||
11 | </a> | ||
12 | </div> | ||
13 | </h1> | ||
14 | |||
15 | <p-table | ||
16 | [value]="registrationTokens" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start" | ||
17 | [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order" | ||
18 | [lazy]="true" (onLazyLoad)="loadLazy($event)" | ||
19 | [showCurrentPageReport]="true" i18n-currentPageReportTemplate | ||
20 | currentPageReportTemplate="Showing {{'{first}'}} to {{'{last}'}} of {{'{totalRecords}'}} registration tokens" | ||
21 | > | ||
22 | <ng-template pTemplate="header"> | ||
23 | <tr> | ||
24 | <th style="width: 120px;"></th> | ||
25 | <th i18n>Token</th> | ||
26 | <th style="width: 150px;" i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th> | ||
27 | <th style="width: 160px;" i18n>Associated runners</th> | ||
28 | </tr> | ||
29 | </ng-template> | ||
30 | |||
31 | <ng-template pTemplate="caption"> | ||
32 | <div class="caption"> | ||
33 | <div class="left-buttons"> | ||
34 | <my-button className="orange-button" i18n-label label="Generate token" icon="add" (click)="generateToken()"></my-button> | ||
35 | </div> | ||
36 | </div> | ||
37 | </ng-template> | ||
38 | |||
39 | <ng-template pTemplate="body" let-registrationToken> | ||
40 | <tr> | ||
41 | <td class="action-cell"> | ||
42 | <my-action-dropdown | ||
43 | placement="bottom-right top-right left auto" container="body" | ||
44 | i18n-label label="Actions" [actions]="actions" [entry]="registrationToken" | ||
45 | ></my-action-dropdown> | ||
46 | </td> | ||
47 | |||
48 | <td>{{ registrationToken.registrationToken }}</td> | ||
49 | |||
50 | <td>{{ registrationToken.createdAt | date: 'short' }}</td> | ||
51 | |||
52 | <td>{{ registrationToken.registeredRunnersCount }}</td> | ||
53 | </tr> | ||
54 | </ng-template> | ||
55 | |||
56 | <ng-template pTemplate="emptymessage"> | ||
57 | <tr> | ||
58 | <td colspan="4"> | ||
59 | <div class="no-results"> | ||
60 | <ng-container i18n>No registration token found for remote runners.</ng-container> | ||
61 | </div> | ||
62 | </td> | ||
63 | </tr> | ||
64 | </ng-template> | ||
65 | </p-table> | ||
diff --git a/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.ts b/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.ts new file mode 100644 index 000000000..f03aab189 --- /dev/null +++ b/client/src/app/+admin/system/runners/runner-registration-token-list/runner-registration-token-list.component.ts | |||
@@ -0,0 +1,88 @@ | |||
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 { RunnerRegistrationToken } from '@shared/models' | ||
6 | import { RunnerService } from '../runner.service' | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-runner-registration-token-list', | ||
10 | templateUrl: './runner-registration-token-list.component.html' | ||
11 | }) | ||
12 | export class RunnerRegistrationTokenListComponent extends RestTable <RunnerRegistrationToken> implements OnInit { | ||
13 | registrationTokens: RunnerRegistrationToken[] = [] | ||
14 | totalRecords = 0 | ||
15 | |||
16 | sort: SortMeta = { field: 'createdAt', order: -1 } | ||
17 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | ||
18 | |||
19 | actions: DropdownAction<RunnerRegistrationToken>[][] = [] | ||
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 this token`, | ||
34 | handler: token => this.removeToken(token) | ||
35 | } | ||
36 | ] | ||
37 | ] | ||
38 | |||
39 | this.initialize() | ||
40 | } | ||
41 | |||
42 | getIdentifier () { | ||
43 | return 'RunnerRegistrationTokenListComponent' | ||
44 | } | ||
45 | |||
46 | generateToken () { | ||
47 | this.runnerService.generateToken() | ||
48 | .subscribe({ | ||
49 | next: () => { | ||
50 | this.reloadData() | ||
51 | this.notifier.success($localize`Registration token generated.`) | ||
52 | }, | ||
53 | |||
54 | error: err => this.notifier.error(err.message) | ||
55 | }) | ||
56 | } | ||
57 | |||
58 | async removeToken (token: RunnerRegistrationToken) { | ||
59 | const res = await this.confirmService.confirm( | ||
60 | $localize`Do you really want to remove this registration token? All associated runners will also be removed.`, | ||
61 | $localize`Remove registration token` | ||
62 | ) | ||
63 | |||
64 | if (res === false) return | ||
65 | |||
66 | this.runnerService.removeToken(token) | ||
67 | .subscribe({ | ||
68 | next: () => { | ||
69 | this.reloadData() | ||
70 | this.notifier.success($localize`Registration token removed.`) | ||
71 | }, | ||
72 | |||
73 | error: err => this.notifier.error(err.message) | ||
74 | }) | ||
75 | } | ||
76 | |||
77 | protected reloadDataInternal () { | ||
78 | this.runnerService.listRegistrationTokens({ pagination: this.pagination, sort: this.sort }) | ||
79 | .subscribe({ | ||
80 | next: resultList => { | ||
81 | this.registrationTokens = resultList.data | ||
82 | this.totalRecords = resultList.total | ||
83 | }, | ||
84 | |||
85 | error: err => this.notifier.error(err.message) | ||
86 | }) | ||
87 | } | ||
88 | } | ||