Skip to content

Commit

Permalink
Update rill-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaHegde committed Dec 10, 2024
1 parent 97ac340 commit 1a46aca
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 14 deletions.
20 changes: 18 additions & 2 deletions web-local/src/routes/(viz)/explore/[name]/+layout.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getUpdatedUrlForExploreState } from "@rilldata/web-common/features/dashboards/url-state/getUpdatedUrlForExploreState";
import { fetchExploreSpec } from "@rilldata/web-common/features/explores/selectors";
import { runtime } from "@rilldata/web-common/runtime-client/runtime-store";
import { error } from "@sveltejs/kit";
Expand All @@ -11,13 +12,28 @@ export const load = async ({ params, depends }) => {
depends(exploreName, "explore");

try {
const { explore, metricsView, defaultExplorePreset } =
await fetchExploreSpec(instanceId, exploreName);
const {
explore,
metricsView,
defaultExplorePreset,
initExploreState,
initLoadedOutsideOfURL,
} = await fetchExploreSpec(instanceId, exploreName);
const initUrlSearch = initLoadedOutsideOfURL
? getUpdatedUrlForExploreState(
explore.explore?.state?.validSpec ?? {},
defaultExplorePreset,
initExploreState,
new URLSearchParams(),
)
: "";

return {
explore,
metricsView,
defaultExplorePreset,
initExploreState,
initUrlSearch,
};
} catch (e) {
console.error(e);
Expand Down
12 changes: 9 additions & 3 deletions web-local/src/routes/(viz)/explore/[name]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
metricsView,
explore,
defaultExplorePreset,
initExploreState,
initUrlSearch,
partialExploreState,
loaded,
urlSearchForPartial,
errors,
exploreName,
} = data);
$: if (errors?.length) {
setTimeout(() => {
Expand All @@ -36,7 +39,6 @@
resetSelectedMockUserAfterNavigate(queryClient);
$: exploreName = explore.meta?.name?.name as string;
$: metricsViewName = metricsView?.meta?.name?.name as string;
$: ({ instanceId } = $runtime);
Expand Down Expand Up @@ -85,9 +87,13 @@
{#key exploreName}
<StateManagersProvider {metricsViewName} {exploreName}>
<DashboardURLStateSync
{metricsViewName}
{exploreName}
{defaultExplorePreset}
{initExploreState}
{initUrlSearch}
{partialExploreState}
{loaded}
{urlSearchForPartial}
>
<DashboardThemeProvider>
<Dashboard {metricsViewName} {exploreName} />
Expand Down
29 changes: 20 additions & 9 deletions web-local/src/routes/(viz)/explore/[name]/+page.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
import { convertURLToExploreState } from "@rilldata/web-common/features/dashboards/url-state/convertPresetToExploreState";
import { getUpdatedUrlForExploreState } from "@rilldata/web-common/features/dashboards/url-state/getUpdatedUrlForExploreState";

export const load = async ({ url, parent, params }) => {
const { explore, metricsView, defaultExplorePreset } = await parent();
const { name: exploreName } = params;
const metricsViewSpec = metricsView.metricsView?.state?.validSpec;
const exploreSpec = explore.explore?.state?.validSpec;

const { partialExploreState, loaded, errors } = convertURLToExploreState(
exploreName,
undefined,
url.searchParams,
metricsViewSpec,
exploreSpec,
defaultExplorePreset,
);
const { partialExploreState, loadedOutsideOfURL, errors } =
convertURLToExploreState(
exploreName,
undefined,
url.searchParams,
metricsViewSpec,
exploreSpec,
defaultExplorePreset,
);
const urlSearchForPartial = loadedOutsideOfURL
? getUpdatedUrlForExploreState(
exploreSpec,
defaultExplorePreset,
partialExploreState,
url.searchParams,
)
: url.searchParams.toString();

return {
partialExploreState,
loaded,
urlSearchForPartial,
errors,
exploreName,
};
};

0 comments on commit 1a46aca

Please sign in to comment.