This repository has been archived by the owner on Feb 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
hosts-page.component.ts
73 lines (68 loc) · 2.08 KB
/
hosts-page.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { Component } from '@angular/core';
import { marker as TEXT } from '@biesbjerg/ngx-translate-extract-marker';
import { DeclarativeFormModalComponent } from '~/app/core/modals/declarative-form/declarative-form-modal.component';
import { DatatableColumn } from '~/app/shared/models/datatable-column.type';
import { NodesService, TokenReply } from '~/app/shared/services/api/nodes.service';
import { Host, OrchService } from '~/app/shared/services/api/orch.service';
import { DialogService } from '~/app/shared/services/dialog.service';
@Component({
selector: 'glass-hosts-page',
templateUrl: './hosts-page.component.html',
styleUrls: ['./hosts-page.component.scss']
})
export class HostsPageComponent {
loading = false;
firstLoadComplete = false;
data: Host[] = [];
columns: DatatableColumn[];
constructor(
private dialogService: DialogService,
private nodesService: NodesService,
private orchService: OrchService
) {
this.columns = [
{
name: TEXT('Hostname'),
prop: 'hostname',
sortable: true
},
{
name: TEXT('Address'),
prop: 'address',
sortable: true
}
];
}
loadData(): void {
this.loading = true;
this.orchService.hosts().subscribe((data) => {
this.data = data;
this.loading = this.firstLoadComplete = true;
});
}
onShowToken(): void {
this.nodesService.token().subscribe((res: TokenReply) => {
this.dialogService.open(DeclarativeFormModalComponent, undefined, {
width: '40%',
data: {
title: TEXT('Authentication Token'),
subtitle: TEXT(
'Use this token to authenticate a new node when adding it to the cluster.'
),
fields: [
{
type: 'text',
name: 'token',
value: res.token,
readonly: true,
hasCopyToClipboardButton: true,
class: 'glass-text-monospaced'
}
],
submitButtonVisible: false,
cancelButtonText: TEXT('Close')
}
});
});
}
}