diff --git a/app/src/api/cmd.ts b/app/src/api/cmd.ts index 427efd5a..a0b2cbaa 100644 --- a/app/src/api/cmd.ts +++ b/app/src/api/cmd.ts @@ -90,7 +90,8 @@ export type Cmd = | "RestartContainer" | "RestartChildSwarmContainers" | "GetSignedInUserDetails" - | "UpdateAwsInstanceType"; + | "UpdateAwsInstanceType" + | "GetInstanceType"; interface CmdData { cmd: Cmd; diff --git a/app/src/api/swarm.ts b/app/src/api/swarm.ts index 3536a5ec..22ccfb82 100644 --- a/app/src/api/swarm.ts +++ b/app/src/api/swarm.ts @@ -340,3 +340,11 @@ export async function update_aws_instance_type({ instance_type, }); } + +export async function get_swarm_instance_type({ + instance_id, +}: { + instance_id: string; +}) { + return await swarmCmd("GetInstanceType", { instance_id }); +} diff --git a/src/bin/super/superapp/src/ViewNodes.svelte b/src/bin/super/superapp/src/ViewNodes.svelte index 9378978b..6b585e78 100644 --- a/src/bin/super/superapp/src/ViewNodes.svelte +++ b/src/bin/super/superapp/src/ViewNodes.svelte @@ -11,6 +11,7 @@ update_child_swarm_containers, get_aws_instance_types, update_aws_instance_type, + get_swarm_instance_type, } from "../../../../../app/src/api/swarm"; import { Button, @@ -29,7 +30,6 @@ SelectItem, } from "carbon-components-svelte"; import type { Remote } from "./types/types"; - import { extract_instance_type } from "./utils"; let loading = true; let selectedRowIds = []; @@ -98,12 +98,21 @@ } } - function get_current_service_details() { + async function get_current_service_details() { for (let i = 0; i < $remotes.length; i++) { const remote = $remotes[i]; if (remote.host === remote.host) { node = { ...remote }; - current_instance_type = extract_instance_type(remote.ec2); + try { + const response = await get_swarm_instance_type({ + instance_id: remote.ec2_instance_id, + }); + if (response.success) { + current_instance_type = response.data.instance_type; + } + } catch (error) { + console.log("ERORR GETTING SWARM INSTANCE TYPE: ", error); + } return; } } @@ -157,7 +166,7 @@ await getAwsInstanceType(); - get_current_service_details(); + await get_current_service_details(); }); function findContainer(node_name: string) { diff --git a/src/bin/super/util.rs b/src/bin/super/util.rs index 5eb0df2d..e25f7f3a 100644 --- a/src/bin/super/util.rs +++ b/src/bin/super/util.rs @@ -167,7 +167,7 @@ pub fn get_child_base_route(host: String) -> Result { return Ok(format!("https://app.{}/api", host)); - // return Ok(format!("http://{}/api", host.unwrap())); + // return Ok(format!("http://{}/api", host)); } pub async fn get_child_swarm_containers(