Add externalNodes to node detail view

Instead of showing the node id with a clipboard that copies a possible
wrong port number, this commit adds the externalAddresses config to the
node detail view, so node operators can define which externalAddresses
should show up.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
Co-authored-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Sebastian Martinez
2023-11-06 14:34:18 +01:00
committed by Rūdolfs Ošiņš
co-authored by Rūdolfs Ošiņš
parent 38fbddeb21
commit 1add6958cb
6 changed files with 79 additions and 28 deletions
+19 -6
View File
@@ -2,7 +2,6 @@
import type { BaseUrl } from "@httpd-client";
import type { ProjectActivity } from "@app/views/nodes/router";
import { config } from "@app/lib/config";
import { isLocal, truncateId } from "@app/lib/utils";
import { loadProjects } from "@app/views/nodes/router";
@@ -15,6 +14,7 @@
export let baseUrl: BaseUrl;
export let nid: string;
export let externalAddresses: string[];
export let projectCount: number;
export let projectPageIndex: number;
export let projects: ProjectActivity[] = [];
@@ -107,11 +107,24 @@
{hostname}
</div>
<div class="info">
<div class="address">
{truncateId(nid)}@{baseUrl.hostname}
<Clipboard
small
text={`${nid}@${baseUrl.hostname}:${config.nodes.defaultNodePort}`} />
<div>
{#each externalAddresses as address}
<!-- If there are externalAddresses this is probably a remote node -->
<!-- in that case, we show all the defined externalAddresses as a listing -->
<div class="address">
{truncateId(nid)}@{address}
<Clipboard small text={`${nid}@${address}`} />
</div>
{:else}
<!-- else this is probably a local node -->
<!-- So we show only the nid -->
<div class="address layout-desktop">
{nid}<Clipboard small text={nid} />
</div>
<div class="address layout-mobile">
{truncateId(nid)}<Clipboard small text={nid} />
</div>
{/each}
</div>
<div class="version">
v{version}
+4 -1
View File
@@ -31,6 +31,7 @@ export interface NodesLoadedRoute {
baseUrl: BaseUrl;
projectPageIndex: number;
version: string;
externalAddresses: string[];
nid: string;
projects: ProjectActivity[];
projectCount: number;
@@ -96,8 +97,9 @@ export async function loadNodeRoute(
const api = new HttpdClient(params.baseUrl);
try {
const projectPageIndex = 0;
const [nodeInfo, { projects, total }] = await Promise.all([
const [nodeInfo, node, { projects, total }] = await Promise.all([
api.getNodeInfo(),
api.getNode(),
loadProjects(projectPageIndex, params.baseUrl),
]);
return {
@@ -106,6 +108,7 @@ export async function loadNodeRoute(
projectPageIndex: projectPageIndex + 1,
baseUrl: params.baseUrl,
nid: nodeInfo.node.id,
externalAddresses: node.config?.externalAddresses ?? [],
version: nodeInfo.version,
projects: projects,
projectCount: total,