Skip to content

Commit

Permalink
feat: render swarm number
Browse files Browse the repository at this point in the history
  • Loading branch information
tobi-bams committed Oct 4, 2024
1 parent ac9975b commit 917242c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/bin/super/superapp/src/Remotes.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import { remotes, tribes } from "./store";
import { onMount } from "svelte";
import type { Remote } from "./types/types";
import { splitHost } from "./utils/index";
import { getSwarmNumber, splitHost } from "./utils/index";
import { selectedNode } from "./store";
import {
create_new_swarm_ec2,
Expand Down Expand Up @@ -188,7 +188,11 @@
}
function remoterow(r: Remote) {
return { ...r, id: r.host };
let swarmNumber = "";
if (r.default_host) {
swarmNumber = getSwarmNumber(r.default_host);
}
return { ...r, id: r.host, number: swarmNumber };
}
async function handleSubmitAddSwarm() {
Expand Down Expand Up @@ -532,6 +536,7 @@
<DataTable
headers={[
{ key: "host", value: "Host" },
{ key: "number", value: "Number" },
{ key: "note", value: "Description" },
{ key: "ec2", value: "Instance" },
{ key: "tribes", value: "Tribes" },
Expand Down
1 change: 1 addition & 0 deletions src/bin/super/superapp/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ export interface Remote {
host: string;
note?: string;
ec2?: string;
default_host?: string;
}
11 changes: 11 additions & 0 deletions src/bin/super/superapp/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,14 @@ export function splitHost(hostFullPath: string) {
}
return "";
}

export function getSwarmNumber(default_host: string) {
// Regular expression to match the number in the string
const match = default_host.match(/\d+/);

if (match) {
return match[0];
} else {
return "";
}
}

0 comments on commit 917242c

Please sign in to comment.