Skip to content

Commit

Permalink
Merge pull request #644 from Senyoret1/data-api
Browse files Browse the repository at this point in the history
Improvements for how the manager gets the data
  • Loading branch information
jdknives authored Dec 17, 2020
2 parents e4ec693 + 461d26b commit 0a4acc0
Show file tree
Hide file tree
Showing 21 changed files with 317 additions and 328 deletions.
67 changes: 43 additions & 24 deletions static/skywire-manager-src/src/app/app.datatypes.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
// Most classes are based on the responses returned by the API, but
// sometimes with some extra fields which are calculated internally in the app.

export class Node {
tcp_addr: string;
label: string;
localPk: string;
tcpAddr: string;
ip: string;
port: string;
local_pk: string;
node_version: string;
app_protocol_version: string;
version: string;
apps: Application[];
transports: Transport[];
routes_count: number;
routesCount: number;
routes?: Route[];
label?: string;
online?: boolean;
seconds_online?: number;
secondsOnline?: number;
health?: HealthInfo;
dmsgServerPk?: string;
roundTripPing?: string;
Expand All @@ -26,35 +22,58 @@ export interface Application {
autostart: boolean;
port: number;
status: number;
args?: any[];
args: any[];
}

export interface Transport {
isUp: boolean;
id: string;
local_pk: string;
remote_pk: string;
localPk: string;
remotePk: string;
type: string;
log?: TransportLog;
is_up: boolean;
}

export interface TransportLog {
recv: number|null;
sent: number|null;
}

export interface Route {
key: number;
rule: string;
ruleSummary?: RouteRuleSummary;
appFields?: RouteAppRuleSumary;
forwardFields?: RouteForwardRuleSumary;
intermediaryForwardFields?: RouteForwardRuleSumary;
}

export interface RouteRuleSummary {
keepAlive: number;
ruleType: number;
keyRouteId: number;
}

interface RouteAppRuleSumary {
routeDescriptor: RouteDescriptor;
}

interface RouteForwardRuleSumary {
nextRid: number;
nextTid: string;
routeDescriptor?: RouteDescriptor;
}

interface RouteDescriptor {
dstPk: string;
srcPk: string;
dstPort: number;
srcPort: number;
}

export interface HealthInfo {
status?: number;
transport_discovery?: number;
route_finder?: number;
setup_node?: number;
uptime_tracker?: number;
address_resolver?: number;
status: number;
transportDiscovery: number;
routeFinder: number;
setupNode: number;
uptimeTracker: number;
addressResolver: number;
}

export class ProxyDiscoveryEntry {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
{{ node.label }}
</td>
<td>
{{ node.local_pk }}
{{ node.localPk }}
</td>
<td *ngIf="showDmsgInfo">
<app-labeled-element-text
Expand Down Expand Up @@ -214,7 +214,7 @@
</div>
<div class="list-row long-content">
<span class="title">{{ 'nodes.key' | translate }}</span>:
{{ node.local_pk }}
{{ node.localPk }}
</div>
<div class="list-row long-content" *ngIf="showDmsgInfo">
<span class="title">{{ 'nodes.dmsg-server' | translate }}</span>:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class NodeListComponent implements OnInit, OnDestroy {
hypervisorSortData = new SortingColumn(['isHypervisor'], 'nodes.hypervisor', SortingModes.Boolean);
stateSortData = new SortingColumn(['online'], 'nodes.state', SortingModes.Boolean);
labelSortData = new SortingColumn(['label'], 'nodes.label', SortingModes.Text);
keySortData = new SortingColumn(['local_pk'], 'nodes.key', SortingModes.Text);
keySortData = new SortingColumn(['localPk'], 'nodes.key', SortingModes.Text);
dmsgServerSortData = new SortingColumn(['dmsgServerPk'], 'nodes.dmsg-server', SortingModes.Text, ['dmsgServerPk_label']);
pingSortData = new SortingColumn(['roundTripPing'], 'nodes.ping', SortingModes.Number);

Expand Down Expand Up @@ -95,7 +95,7 @@ export class NodeListComponent implements OnInit, OnDestroy {
},
{
filterName: 'nodes.filter-dialog.key',
keyNameInElementsArray: 'local_pk',
keyNameInElementsArray: 'localPk',
type: FilterFieldTypes.TextInput,
maxlength: 66,
},
Expand Down Expand Up @@ -305,7 +305,7 @@ export class NodeListComponent implements OnInit, OnDestroy {
nodeStatusClass(node: Node, forDot: boolean): string {
switch (node.online) {
case true:
return this.nodesHealthInfo.get(node.local_pk).allServicesOk ?
return this.nodesHealthInfo.get(node.localPk).allServicesOk ?
(forDot ? 'dot-green' : 'green-text') :
(forDot ? 'dot-yellow online-warning' : 'yellow-text');
default:
Expand All @@ -321,7 +321,7 @@ export class NodeListComponent implements OnInit, OnDestroy {
nodeStatusText(node: Node, forTooltip: boolean): string {
switch (node.online) {
case true:
return this.nodesHealthInfo.get(node.local_pk).allServicesOk ?
return this.nodesHealthInfo.get(node.localPk).allServicesOk ?
('node.statuses.online' + (forTooltip ? '-tooltip' : '')) :
('node.statuses.partially-online' + (forTooltip ? '-tooltip' : ''));
default:
Expand Down Expand Up @@ -424,13 +424,15 @@ export class NodeListComponent implements OnInit, OnDestroy {
this.nodesToShow = null;
}

// Get the health status of each node.
this.nodesHealthInfo = new Map<string, HealthStatus>();
this.nodesToShow.forEach(node => {
this.nodesHealthInfo.set(node.local_pk, this.nodeService.getHealthStatus(node));
});
if (this.nodesToShow) {
// Get the health status of each node.
this.nodesHealthInfo = new Map<string, HealthStatus>();
this.nodesToShow.forEach(node => {
this.nodesHealthInfo.set(node.localPk, this.nodeService.getHealthStatus(node));
});

this.dataSource = this.nodesToShow;
this.dataSource = this.nodesToShow;
}
}

logout() {
Expand All @@ -457,7 +459,7 @@ export class NodeListComponent implements OnInit, OnDestroy {
const nodesData: NodeData[] = [];
this.dataSource.forEach(node => {
nodesData.push({
key: node.local_pk,
key: node.localPk,
label: node.label,
});
});
Expand Down Expand Up @@ -530,7 +532,7 @@ export class NodeListComponent implements OnInit, OnDestroy {

SelectOptionComponent.openDialog(this.dialog, options, 'common.options').afterClosed().subscribe((selectedOption: number) => {
if (selectedOption === 1) {
this.copySpecificTextToClipboard(node.local_pk);
this.copySpecificTextToClipboard(node.localPk);
} else if (this.showDmsgInfo) {
if (selectedOption === 2) {
this.copySpecificTextToClipboard(node.dmsgServerPk);
Expand All @@ -555,7 +557,7 @@ export class NodeListComponent implements OnInit, OnDestroy {
*/
copyToClipboard(node: Node) {
if (!this.showDmsgInfo) {
this.copySpecificTextToClipboard(node.local_pk);
this.copySpecificTextToClipboard(node.localPk);
} else {
const options: SelectableOption[] = [
{
Expand All @@ -570,7 +572,7 @@ export class NodeListComponent implements OnInit, OnDestroy {

SelectOptionComponent.openDialog(this.dialog, options, 'common.options').afterClosed().subscribe((selectedOption: number) => {
if (selectedOption === 1) {
this.copySpecificTextToClipboard(node.local_pk);
this.copySpecificTextToClipboard(node.localPk);
} else if (selectedOption === 2) {
this.copySpecificTextToClipboard(node.dmsgServerPk);
}
Expand All @@ -592,10 +594,10 @@ export class NodeListComponent implements OnInit, OnDestroy {
* Opens the modal window for changing the label of a node.
*/
showEditLabelDialog(node: Node) {
let labelInfo = this.storageService.getLabelInfo(node.local_pk);
let labelInfo = this.storageService.getLabelInfo(node.localPk);
if (!labelInfo) {
labelInfo = {
id: node.local_pk,
id: node.localPk,
label: '',
identifiedElementType: LabeledElementTypes.Node,
};
Expand All @@ -616,7 +618,7 @@ export class NodeListComponent implements OnInit, OnDestroy {

confirmationDialog.componentInstance.operationAccepted.subscribe(() => {
confirmationDialog.close();
this.storageService.setLocalNodesAsHidden([node.local_pk]);
this.storageService.setLocalNodesAsHidden([node.localPk]);
this.forceDataRefresh();
this.snackbarService.showDone('nodes.deleted');
});
Expand All @@ -640,7 +642,7 @@ export class NodeListComponent implements OnInit, OnDestroy {
const nodesToRemove: string[] = [];
this.filteredNodes.forEach(node => {
if (!node.online) {
nodesToRemove.push(node.local_pk);
nodesToRemove.push(node.localPk);
}
});

Expand All @@ -664,7 +666,7 @@ export class NodeListComponent implements OnInit, OnDestroy {
*/
open(node: Node) {
if (node.online) {
this.router.navigate(['nodes', node.local_pk]);
this.router.navigate(['nodes', node.localPk]);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { Component, AfterViewInit, OnDestroy, Input } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Router } from '@angular/router';
import { Subscription } from 'rxjs';
import { TranslateService } from '@ngx-translate/core';
Expand All @@ -13,8 +12,6 @@ import { NodeService } from 'src/app/services/node.service';
import { OperationError } from 'src/app/utils/operation-error';
import { processServiceError } from 'src/app/utils/errors';
import { SelectableOption, SelectOptionComponent } from 'src/app/components/layout/select-option/select-option.component';
import { ConfirmationData, ConfirmationComponent } from 'src/app/components/layout/confirmation/confirmation.component';
import { AppConfig } from 'src/app/app.config';
import { MenuOptionData } from 'src/app/components/layout/top-bar/top-bar.component';
import { UpdateComponent } from 'src/app/components/layout/update/update.component';
import { StorageService } from 'src/app/services/storage.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class AllAppsComponent implements OnInit, OnDestroy {
ngOnInit() {
// Get the node data from the parent page.
this.dataSubscription = NodeComponent.currentNode.subscribe((node: Node) => {
this.nodePK = node.local_pk;
this.nodePK = node.localPk;
this.apps = node.apps;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class AppsComponent implements OnInit, OnDestroy {
ngOnInit() {
// Get the node data from the parent page.
this.dataSubscription = NodeComponent.currentNode.subscribe((node: Node) => {
this.nodePK = node.local_pk;
this.nodePK = node.localPk;
this.apps = node.apps;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</span>
<span class="info-line">
<span class="title">{{ 'node.details.node-info.public-key' | translate }}&nbsp;</span>
<app-copy-to-clipboard-text text="{{ node.local_pk }}"></app-copy-to-clipboard-text>
<app-copy-to-clipboard-text text="{{ node.localPk }}"></app-copy-to-clipboard-text>
</span>
<span class="info-line">
<span class="title">{{ 'node.details.node-info.port' | translate }}&nbsp;</span>
Expand All @@ -27,7 +27,7 @@
</span>
<span class="info-line">
<span class="title">{{ 'node.details.node-info.node-version' | translate }}</span>
{{ node.build_info.version ? node.build_info.version : ('common.unknown' | translate) }}
{{ node.version ? node.version : ('common.unknown' | translate) }}
</span>
<span class="info-line">
<span class="title">{{ 'node.details.node-info.time.title' | translate }}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class NodeInfoContentComponent {
@Input() set nodeInfo(val: Node) {
this.node = val;
this.nodeHealthInfo = this.nodeService.getHealthStatus(val);
this.timeOnline = TimeUtils.getElapsedTime(val.seconds_online);
this.timeOnline = TimeUtils.getElapsedTime(val.secondsOnline);
}

node: Node;
Expand All @@ -34,10 +34,10 @@ export class NodeInfoContentComponent {
) { }

showEditLabelDialog() {
let labelInfo = this.storageService.getLabelInfo(this.node.local_pk);
let labelInfo = this.storageService.getLabelInfo(this.node.localPk);
if (!labelInfo) {
labelInfo = {
id: this.node.local_pk,
id: this.node.localPk,
label: '',
identifiedElementType: LabeledElementTypes.Node,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class AllRoutesComponent implements OnInit, OnDestroy {
ngOnInit() {
// Get the node data from the parent page.
this.dataSubscription = NodeComponent.currentNode.subscribe((node: Node) => {
this.nodePK = node.local_pk;
this.nodePK = node.localPk;
this.routes = node.routes;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class AllTransportsComponent implements OnInit, OnDestroy {
ngOnInit() {
// Get the node data from the parent page.
this.dataSubscription = NodeComponent.currentNode.subscribe((node: Node) => {
this.nodePK = node.local_pk;
this.nodePK = node.localPk;
this.transports = node.transports;
});
}
Expand Down
Loading

0 comments on commit 0a4acc0

Please sign in to comment.