Skip to content

Commit

Permalink
Merge pull request #2443 from threefoldtech/development_reduceListing…
Browse files Browse the repository at this point in the history
…Time

reduce listing deployments time
  • Loading branch information
xmonader authored Mar 17, 2024
2 parents 517f8d3 + 7e15e30 commit 43e222d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 19 deletions.
1 change: 0 additions & 1 deletion packages/grid_client/src/primitives/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ class Network {
events.emit("logs", `Loading network ${this.name}`);

if (await this.existOnNewNetwork()) {
await new Promise(f => setTimeout(f, 60000));
await this.loadNetworkFromContracts();
} else {
const network = await this.getNetwork();
Expand Down
23 changes: 16 additions & 7 deletions packages/playground/src/components/k8s_deployment_table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@
<AccessDeploymentAlert />

<InputTooltip tooltip="Didn't find your deployments in the list? Enable to show all deployments." inline>
<VSwitch inset color="primary" label="Show All Deployments" v-model="showAllDeployments" />
<VSwitch
inset
color="primary"
label="Show All Deployments"
@update:model-value="loadDeployments"
v-model="showAllDeployments"
/>
</InputTooltip>

<ListTable
Expand Down Expand Up @@ -141,7 +147,7 @@ import { getNodeHealthColor, NodeHealth } from "@/utils/get_nodes";
import { useProfileManager } from "../stores";
import { getGrid, updateGrid } from "../utils/grid";
import { markAsFromAnotherClient } from "../utils/helpers";
import { loadK8s, mergeLoadedDeployments } from "../utils/load_deployment";
import { type K8S, type LoadedDeployments, loadK8s, mergeLoadedDeployments } from "../utils/load_deployment";
const profileManager = useProfileManager();
const showDialog = ref(false);
const showEncryption = ref(false);
Expand All @@ -166,11 +172,14 @@ async function loadDeployments() {
const grid = await getGrid(profileManager.profile!, props.projectName);
const chunk1 = await loadK8s(grid!);
const chunk2 = await loadK8s(updateGrid(grid!, { projectName: props.projectName.toLowerCase() }));
const chunk3 = await loadK8s(updateGrid(grid!, { projectName: "" }));
chunk3.items = chunk3.items.map(i => {
return !i.projectName || i.projectName === "Kubernetes" ? markAsFromAnotherClient(i) : i;
});
let chunk3: LoadedDeployments<K8S> = { count: 0, items: [], failedDeployments: [] };
if (showAllDeployments.value) {
chunk3 = await loadK8s(updateGrid(grid!, { projectName: "" }));
chunk3.items = chunk3.items.map(i => {
return !i.projectName || i.projectName === "Kubernetes" ? markAsFromAnotherClient(i) : i;
});
}
const clusters = mergeLoadedDeployments(chunk1, chunk2, chunk3);
failedDeployments.value = clusters.failedDeployments;
Expand Down
30 changes: 19 additions & 11 deletions packages/playground/src/components/vm_deployment_table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@
tooltip="Didn't find your deployments in the list? Enable to show all deployments."
inline
>
<VSwitch inset color="primary" label="Show All Deployments" v-model="showAllDeployments" />
<VSwitch
inset
color="primary"
label="Show All Deployments"
v-model="showAllDeployments"
@update:model-value="loadDeployments"
/>
</InputTooltip>

<ListTable
Expand Down Expand Up @@ -155,7 +161,7 @@ import { getNodeHealthColor, NodeHealth } from "@/utils/get_nodes";
import { useProfileManager } from "../stores";
import { getGrid, updateGrid } from "../utils/grid";
import { markAsFromAnotherClient } from "../utils/helpers";
import { loadVms, mergeLoadedDeployments } from "../utils/load_deployment";
import { type LoadedDeployments, loadVms, mergeLoadedDeployments } from "../utils/load_deployment";
const profileManager = useProfileManager();
Expand Down Expand Up @@ -197,18 +203,20 @@ async function loadDeployments() {
if (chunk2.count > 0 && migrateGateways) {
await migrateModule(grid!.gateway);
}
let chunk3: LoadedDeployments<any[]> = { count: 0, items: [], failedDeployments: [] };
if (showAllDeployments.value) {
chunk3 =
props.projectName.toLowerCase() === ProjectName.VM.toLowerCase()
? await loadVms(updateGrid(grid!, { projectName: "" }))
: { count: 0, items: [], failedDeployments: [] };
if (chunk3.count > 0 && migrateGateways) {
await migrateModule(grid!.gateway);
}
const chunk3 =
props.projectName.toLowerCase() === ProjectName.VM.toLowerCase()
? await loadVms(updateGrid(grid!, { projectName: "" }))
: { count: 0, items: [], failedDeployments: [] };
if (chunk3.count > 0 && migrateGateways) {
await migrateModule(grid!.gateway);
chunk3.items = chunk3.items.map(markAsFromAnotherClient);
}
chunk3.items = chunk3.items.map(markAsFromAnotherClient);
const vms = mergeLoadedDeployments(chunk1, chunk2, chunk3 as any);
failedDeployments.value = vms.failedDeployments;
Expand Down

0 comments on commit 43e222d

Please sign in to comment.