Skip to content

Commit

Permalink
feat: get current swarm instance type from backend
Browse files Browse the repository at this point in the history
  • Loading branch information
tobi-bams committed Oct 18, 2024
1 parent 9b28388 commit 1fd5fc7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/src/api/cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export type Cmd =
| "RestartContainer"
| "RestartChildSwarmContainers"
| "GetSignedInUserDetails"
| "UpdateAwsInstanceType";
| "UpdateAwsInstanceType"
| "GetInstanceType";

interface CmdData {
cmd: Cmd;
Expand Down
8 changes: 8 additions & 0 deletions app/src/api/swarm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
17 changes: 13 additions & 4 deletions src/bin/super/superapp/src/ViewNodes.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 = [];
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -157,7 +166,7 @@
await getAwsInstanceType();
get_current_service_details();
await get_current_service_details();
});
function findContainer(node_name: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/bin/super/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub fn get_child_base_route(host: String) -> Result<String, Error> {

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(
Expand Down

0 comments on commit 1fd5fc7

Please sign in to comment.