[web] host index page

This commit is contained in:
core 2023-09-26 09:42:02 -04:00
parent c077c828ac
commit cddf4820b5
Signed by: core
GPG Key ID: FDBF740DADDCEECF
2 changed files with 46 additions and 1 deletions

View File

@ -83,6 +83,13 @@
"api": "Unable to contact the server. Try again later." "api": "Unable to contact the server. Try again later."
} }
}, },
"hosts": {
"name": "Name",
"role": "Role",
"lastseen": "Last Seen",
"actions": "Actions",
"ipaddr": "IP Address"
},
"roles": { "roles": {
"create": "Add", "create": "Add",
"explain": "Roles control how hosts, lighthouses, and relays communicate through firewall rules.", "explain": "Roles control how hosts, lighthouses, and relays communicate through firewall rules.",

View File

@ -6,7 +6,8 @@
import {Logger, logSetup} from "$lib/logger"; import {Logger, logSetup} from "$lib/logger";
import type {APIError} from "$lib/auth.ts"; import type {APIError} from "$lib/auth.ts";
import {PUBLIC_BASE_URL} from "$env/static/public"; import {PUBLIC_BASE_URL} from "$env/static/public";
import {Configuration, NetworksApi} from "$lib/api"; import {Configuration, HostsApi, NetworksApi, RolesApi} from "$lib/api";
import type {Host} from "$lib/api/models/Host.ts";
import AdminLayout from "$components/AdminLayout.svelte"; import AdminLayout from "$components/AdminLayout.svelte";
let loading = true; let loading = true;
@ -14,6 +15,8 @@
let error = ''; let error = '';
$: currentlyLoading = $isLoading || loading; $: currentlyLoading = $isLoading || loading;
let hosts: Host[] = [];
logSetup(); logSetup();
let logger = new Logger("hosts/+page.svelte"); let logger = new Logger("hosts/+page.svelte");
@ -63,6 +66,14 @@
return; return;
} }
const hostsApi = new HostsApi(configuration);
hosts = (await hostsApi.hostsList({
filterIsLighthouse: false,
filterIsRelay: false
})).data!;
console.log(hosts);
loading = false; loading = false;
}) })
</script> </script>
@ -74,5 +85,32 @@
<LoadingWrapper isLoading={currentlyLoading} isError={isError} error={error}> <LoadingWrapper isLoading={currentlyLoading} isError={isError} error={error}>
<AdminLayout selected="hosts"> <AdminLayout selected="hosts">
<h3>{$t("common.page.hosts")}</h3> <h3>{$t("common.page.hosts")}</h3>
<table class="table table-dark table-hover">
<thead>
<tr>
<th scope="col">{$t("hosts.name")}</th>
<th scope="col">{$t("hosts.lastseen")}</th>
<th scope="col">{$t("hosts.ipaddr")}</th>
<th scope="col">{$t("hosts.role")}</th>
<th scope="col">{$t("hosts.actions")}</th>
</tr>
</thead>
<tbody>
{#each hosts as host}
{#if !(host.isLighthouse || host.isRelay)}
<tr>
<td>{host.name}</td>
<td>{host.metadata?.lastSeenAt}</td>
<td>{host.ipAddress}</td>
<td>{host.roleID}</td>
<td>
</td>
</tr>
{/if}
{/each}
</tbody>
</table>
</AdminLayout> </AdminLayout>
</LoadingWrapper> </LoadingWrapper>