Skip to content

Commit

Permalink
Merge pull request #332 from stakwork/render-swarm-number
Browse files Browse the repository at this point in the history
feat: render swarm number
  • Loading branch information
Evanfeenstra authored Oct 4, 2024
2 parents ac9975b + 917242c commit c00129e
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 c00129e

Please sign in to comment.