diff --git a/packages/playground/src/dashboard/components/create_farm.vue b/packages/playground/src/dashboard/components/create_farm.vue index 8408706c8e..938e6d253b 100644 --- a/packages/playground/src/dashboard/components/create_farm.vue +++ b/packages/playground/src/dashboard/components/create_farm.vue @@ -71,18 +71,21 @@ export default { required: true, }, }, - setup(props) { + + setup(props, context) { const showDialogue = ref(false); const isCreating = ref(false); const gridStore = useGrid(); const valid = ref(false); + async function createFarm() { try { isCreating.value = true; await gridStore.grid.farms.create({ name: props.name }); createCustomToast("Farm created successfully.", ToastType.success); - notifyDelaying(); showDialogue.value = false; + context.emit("farm-created"); + notifyDelaying(); } catch (error) { console.log(error); createCustomToast("Failed to create farm.", ToastType.danger); diff --git a/packages/playground/src/dashboard/components/user_farms.vue b/packages/playground/src/dashboard/components/user_farms.vue index e1ac3aa7dc..a0db6ea05f 100644 --- a/packages/playground/src/dashboard/components/user_farms.vue +++ b/packages/playground/src/dashboard/components/user_farms.vue @@ -139,7 +139,7 @@ import { type Farm, SortBy, SortOrder } from "@threefold/gridproxy_client"; import { jsPDF } from "jspdf"; import { debounce } from "lodash"; import { StrKey } from "stellar-sdk"; -import { ref } from "vue"; +import { ref, watch } from "vue"; import { gridProxyClient } from "@/clients"; import CardDetails from "@/components/node_details_cards/card_details.vue"; @@ -164,11 +164,26 @@ export default { CardDetails, AddIP, }, - setup(_, context) { + props: { + reloadFarms: { + type: Boolean, + }, + }, + + setup(props, context) { const gridStore = useGrid(); const profile = useProfileManager().profile; const twinId = profile!.twinId; const search = ref(); + watch( + () => props.reloadFarms, + async () => { + setTimeout(async () => { + await getUserFarms(); + }, 30000); + }, + ); + const headers = [ { title: "Farm ID", @@ -213,6 +228,7 @@ export default { const reloadFarms = debounce(getUserFarms, 20000); async function getUserFarms() { + loading.value = true; try { const { data, count } = await gridProxyClient.farms.list({ retCount: true, @@ -333,6 +349,7 @@ export default { } context.expose({ getFarmsNames, reloadFarms }); + return { gridStore, headers, diff --git a/packages/playground/src/dashboard/farms_view.vue b/packages/playground/src/dashboard/farms_view.vue index cdf5a66441..08108e2440 100644 --- a/packages/playground/src/dashboard/farms_view.vue +++ b/packages/playground/src/dashboard/farms_view.vue @@ -5,8 +5,8 @@ Farms - - + + @@ -27,9 +27,11 @@ export default { }, setup() { const name = ref(""); + const farmsReload = ref(false); return { name, + farmsReload, }; }, };