lazy load nits

This commit is contained in:
Ruben Fiszel
2025-06-30 00:07:35 +00:00
parent a5c4de0637
commit 53f615ca0b
2 changed files with 37 additions and 12 deletions
@@ -41,7 +41,6 @@
import PlotlyHtmlV2 from '../../components/display/PlotlyHtmlV2.svelte'
import AppScatterChart from '../../components/display/AppScatterChart.svelte'
import AppPieChart from '../../components/display/AppPieChart.svelte'
import AppTable from '../../components/display/table/AppTable.svelte'
import AppAggridTable from '../../components/display/table/AppAggridTable.svelte'
import AppText from '../../components/display/AppText.svelte'
import AppCodeInputComponent from '../../components/inputs/AppCodeInputComponent.svelte'
@@ -74,6 +73,7 @@
import AppUserResource from '../../components/inputs/AppUserResource.svelte'
import type { AppComponent } from './components'
import { Button } from '$lib/components/common'
import { Loader2 } from 'lucide-svelte'
interface Props {
component: AppComponent
@@ -235,15 +235,19 @@
{render}
/>
{:else if component.type === 'tablecomponent'}
<AppTable
configuration={component.configuration}
id={component.id}
customCss={component.customCss}
bind:initializing
componentInput={component.componentInput}
actionButtons={component.actionButtons}
{render}
/>
{#await import('$lib/components/apps/components/display/table/AppTable.svelte')}
<Loader2 />
{:then Module}
<Module.default
configuration={component.configuration}
id={component.id}
customCss={component.customCss}
bind:initializing
componentInput={component.componentInput}
actionButtons={component.actionButtons}
{render}
/>
{/await}
{:else if component.type === 'dbexplorercomponent'}
<AppDbExplorer
configuration={component.configuration}
@@ -4,19 +4,40 @@ import { get, writable } from "svelte/store";
export const resourceTypesStore = writable<string[] | undefined>(undefined)
let loading = false
export async function getResourceTypes() {
const rts = get(resourceTypesStore)
if (rts) {
return rts
} else {
if (loading) {
let counter = 0
while (loading) {
await new Promise(resolve => setTimeout(resolve, 50))
counter++
if (counter > 10) {
console.error('Resource types loading timeout')
break
}
}
if (!loading) {
return get(resourceTypesStore)
}
}
loading = true
let workspace = get(workspaceStore)
if (workspace){
if (workspace) {
try {
const nrts = await ResourceService.listResourceTypeNames({ workspace: workspace })
resourceTypesStore.set(nrts)
loading = false
return nrts
} catch (e) {
return ["error_fetching_names"]
loading = false
return ["error_fetching_names"]
}
} else {
return ['workspace_is_undefined']