Skip to content

Commit

Permalink
feat: stop index (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoYanZh authored Dec 5, 2022
1 parent da558d3 commit 6abf3db
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/lang/en/indexes.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
"rebuild": "Rebuild indexes",
"obj_count": "Object count",
"last_done_time": "Last done time",
"unknown": "Unknown",
"stop": "Stop",
"error": "Error"
}
18 changes: 17 additions & 1 deletion src/pages/manage/indexes/indexes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ const Indexes = () => {
const rebuild = async () => {
const resp = await rebuildReq()
handleRespWithNotifySuccess(resp)
refreshProgress()
}
const [stopBuildLoading, stopBuildReq] = useFetch(
(): PResp<Progress> => r.post("/admin/index/stop")
)
const stopBuild = async () => {
const resp = await stopBuildReq()
handleRespWithNotifySuccess(resp)
refreshProgress()
}
return (
<VStack spacing="$2" w="$full" alignItems="start">
Expand Down Expand Up @@ -114,7 +123,7 @@ const Indexes = () => {
<Text>
{t("indexes.last_done_time")}:
<Badge colorScheme="accent" ml="$2">
{formatDate(progress()!.last_done_time)}
{progress()!.last_done_time ? formatDate(progress()!.last_done_time) : t("indexes.unknown")}
</Badge>
</Text>
<Show when={progress()?.error}>
Expand All @@ -136,6 +145,13 @@ const Indexes = () => {
>
{t("global.refresh")}
</Button>
<Button
colorScheme="warning"
onClick={[stopBuild, undefined]}
loading={stopBuildLoading()}
>
{t("indexes.stop")}
</Button>
<Button onClick={[rebuild, undefined]} loading={reBuildLoading()}>
{t(`indexes.${progress()?.is_done ? "rebuild" : "build"}`)}
</Button>
Expand Down

0 comments on commit 6abf3db

Please sign in to comment.