-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c3963f
commit 1a6b934
Showing
4 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |