Skip to content

Commit

Permalink
feat: more on dataset homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
drew-harris committed Sep 17, 2024
1 parent 3c3963f commit 1a6b934
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
5 changes: 4 additions & 1 deletion frontends/dashboard/src/components/MagicBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export const MagicBox = <D extends CreateQueryResult>(
props: MagicBoxProps<D>,
) => {
const children = createMemo(() => {
return props.children(props.query.data as NonNullable<D["data"]>);
if (props.query.data) {
return props.children(props.query.data as NonNullable<D["data"]>);
}
return <></>;
});

const skeletonHeight = createMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
useContext,
} from "solid-js";
import { ApiContext } from "../..";
import { GeneralServerSettings } from "./GeneralSettings";

export type DatasetConfig = DatasetConfigurationDTO & {
LLM_API_KEY?: string | null;
Expand Down
7 changes: 7 additions & 0 deletions frontends/dashboard/src/hooks/useTrieve.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { useContext } from "solid-js";
import { ApiContext } from "..";

export const useTrieve = () => {
const trieve = useContext(ApiContext);
return trieve;
};
34 changes: 32 additions & 2 deletions frontends/dashboard/src/pages/dataset/DatasetHomepage.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,43 @@
import { useContext } from "solid-js";
import { DatasetContext } from "../../contexts/DatasetContext";
import { createQuery } from "@tanstack/solid-query";
import { useTrieve } from "../../hooks/useTrieve";
import { MagicBox, MagicSuspense } from "../../components/MagicBox";

export const DatasetHomepage = () => {
const { datasetId } = useContext(DatasetContext);
const trieve = useTrieve();

const datasetQuery = createQuery(() => ({
queryKey: ["dataset", datasetId()],
queryFn: async () => {
return trieve.fetch("/api/dataset/{dataset_id}", "get", {
datasetId: datasetId(),
});
},
}));

const chunkCountQuery = createQuery(() => ({
queryKey: ["dataset-chunk-count", datasetId()],
queryFn: async () => {
return trieve.fetch("/api/dataset/usage/{dataset_id}", "get", {
datasetId: datasetId(),
});
},
}));

return (
<div class="p-4">
<div>Dataset Homepage</div>
<div class="m-3 bg-orange-700">ID: {datasetId()}</div>
<MagicSuspense skeletonHeight="36px" unstyled>
<div class="pb-2 text-lg font-medium">{datasetQuery.data?.name}</div>
</MagicSuspense>
<MagicSuspense>
<>
<div>Dataset ID: {datasetId()}</div>
<div>Created At: {datasetQuery.data?.created_at}</div>
<div>Chunk Count: {chunkCountQuery.data?.chunk_count}</div>
</>
</MagicSuspense>
</div>
);
};

0 comments on commit 1a6b934

Please sign in to comment.