[go: nahoru, domu]

Skip to content

Commit

Permalink
cleanup: make refresh a button and preserve click on chunk_count taki…
Browse files Browse the repository at this point in the history
…ng user to dataset/start
  • Loading branch information
skeptrunedev committed Jun 28, 2024
1 parent e687976 commit f5b33ef
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
33 changes: 20 additions & 13 deletions dashboard/src/components/DatasetOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ export const DatasetOverview = (props: DatasetOverviewProps) => {
return;
}

const currentUsage = usage();

fetch(`${api_host}/dataset/usage/${datasetId}`, {
method: "GET",
headers: {
Expand All @@ -147,7 +149,6 @@ export const DatasetOverview = (props: DatasetOverviewProps) => {
return response.json();
})
.then((newData) => {
const currentUsage = usage();
const prevCount = currentUsage[datasetId]?.chunk_count || 0;
const newCount: number = newData.chunk_count as number;
const countDifference = newCount - prevCount;
Expand All @@ -170,6 +171,7 @@ export const DatasetOverview = (props: DatasetOverviewProps) => {
? "removed"
: "added or removed"
} since last update.`,
timeout: 3000,
});
})
.catch((error) => {
Expand Down Expand Up @@ -285,24 +287,29 @@ export const DatasetOverview = (props: DatasetOverviewProps) => {
>
{datasetAndUsage.dataset.name}
</td>
<td class="whitespace-nowrap px-3 py-4 text-sm text-neutral-600">
<td
class="whitespace-nowrap px-3 py-4 text-sm text-neutral-600"
onClick={() => {
navigate(
`/dashboard/dataset/${datasetAndUsage.dataset.id}/start`,
);
}}
>
<span class="inline-flex items-center">
<div
onClick={() => {
navigate(
`/dashboard/dataset/${datasetAndUsage.dataset.id}/start`,
);
}}
>
<div>
{usage()[datasetAndUsage.dataset.id]?.chunk_count ??
datasetAndUsage.dataset_usage.chunk_count}{" "}
</div>
<TbReload
class="ml-2 cursor-pointer"
onClick={() => {
<button
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
reloadChunkCount(datasetAndUsage.dataset.id);
}}
/>
class="ml-2 hover:text-fuchsia-500"
>
<TbReload />
</button>
</span>
</td>
<td
Expand Down
9 changes: 7 additions & 2 deletions dashboard/src/pages/Dashboard/Dataset/DatasetStart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export const DatasetStart = () => {

if (response.ok) {
const data = (await response.json()) as unknown as DatasetUsageCount;
console.log("Got good repsonse", data);
return data;
} else {
createToast({
Expand Down Expand Up @@ -120,6 +119,7 @@ export const DatasetStart = () => {
? "removed"
: "added or removed"
} since last update.`,
timeout: 3000,
});
})
.catch((error) => {
Expand Down Expand Up @@ -295,7 +295,12 @@ export const DatasetStart = () => {
<div class="flex items-center space-x-3">
<p class="block text-sm font-medium">Chunk Count:</p>
<p class="w-fit text-sm">{usage()?.chunk_count || 0}</p>
<TbReload onClick={reloadChunkCount} />
<button
onClick={reloadChunkCount}
class="hover:text-fuchsia-500"
>
<TbReload />
</button>
</div>
<div class="flex items-center space-x-3">
<label class="block text-sm font-medium">tracking id:</label>
Expand Down

0 comments on commit f5b33ef

Please sign in to comment.