Skip to content

Commit

Permalink
feat: hide search box if not available & provide max_depth (#48)
Browse files Browse the repository at this point in the history
* fix: adapt m3u8 on IOS (close alist-org/alist#3061)

* feat: hide search box if not available

* feat: provide max_depth when update indexes
  • Loading branch information
xhofe committed Jan 18, 2023
1 parent 149184c commit 0bada10
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/lang/en/indexes.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"build": "Build indexes",
"rebuild": "Rebuild indexes",
"paths_to_update": "Paths to update",
"max_depth": "Max depth",
"update": "Update indexes",
"obj_count": "Object count",
"last_done_time": "Last done time",
Expand Down
42 changes: 22 additions & 20 deletions src/pages/home/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,29 @@ export const Header = () => {
</HStack>
<HStack class="header-right" spacing="$2">
<Show when={objStore.state === State.Folder}>
<HStack
bg="$neutral4"
w="$32"
p="$2"
rounded="$md"
justifyContent="space-between"
border="2px solid transparent"
cursor="pointer"
_hover={{
borderColor: "$info6",
}}
onClick={() => {
bus.emit("tool", "search")
}}
>
<Icon as={BsSearch} />
<HStack>
<Kbd>Ctrl</Kbd>
<Kbd>K</Kbd>
<Show when={getSetting("search_index") !== "none"}>
<HStack
bg="$neutral4"
w="$32"
p="$2"
rounded="$md"
justifyContent="space-between"
border="2px solid transparent"
cursor="pointer"
_hover={{
borderColor: "$info6",
}}
onClick={() => {
bus.emit("tool", "search")
}}
>
<Icon as={BsSearch} />
<HStack>
<Kbd>Ctrl</Kbd>
<Kbd>K</Kbd>
</HStack>
</HStack>
</HStack>
</Show>
<Layout />
</Show>
</HStack>
Expand Down
41 changes: 35 additions & 6 deletions src/pages/manage/indexes/indexes.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import {
Badge,
Button,
createDisclosure,
Heading,
HStack,
Icon,
Input,
Modal,
ModalBody,
ModalCloseButton,
ModalContent,
ModalFooter,
ModalHeader,
ModalOverlay,
Text,
Textarea,
useColorModeValue,
Expand Down Expand Up @@ -70,16 +79,22 @@ const Indexes = () => {
}

let updatePathsRef: HTMLTextAreaElement
let updateMaxDepthRef: HTMLInputElement
const [updateLoading, updateReq] = useFetch(updateIndex)
const update = async () => {
let updatePaths: string[] = []
if (updatePathsRef.value) {
updatePaths = updatePathsRef.value.split("\n")
}
const resp = await updateReq(updatePaths)
let updateMaxDepth = 20
if (updateMaxDepthRef.value) {
updateMaxDepth = parseInt(updateMaxDepthRef.value)
}
const resp = await updateReq(updatePaths, updateMaxDepth)
handleRespWithNotifySuccess(resp)
refreshProgress()
}
const { isOpen, onOpen, onClose } = createDisclosure()
return (
<VStack spacing="$2" w="$full" alignItems="start">
<Heading>{t("manage.sidemenu.settings")}</Heading>
Expand Down Expand Up @@ -156,11 +171,25 @@ const Indexes = () => {
{t(`indexes.${progress()?.is_done ? "rebuild" : "build"}`)}
</Button>
</HStack>
<Heading>{t("indexes.paths_to_update")}</Heading>
<Textarea ref={updatePathsRef!}></Textarea>
<Button onClick={[update, undefined]} loading={updateLoading()}>
{t(`indexes.update`)}
</Button>
<Button onClick={onOpen}>{t(`indexes.update`)}</Button>
<Modal opened={isOpen()} onClose={onClose}>
<ModalOverlay />
<ModalContent>
<ModalCloseButton />
<ModalHeader>{t(`indexes.update`)}</ModalHeader>
<ModalBody>
<Heading>{t("indexes.paths_to_update")}</Heading>
<Textarea ref={updatePathsRef!}></Textarea>
<Heading>{t("indexes.max_depth")}</Heading>
<Input value={20} type="number" ref={updateMaxDepthRef!} />
</ModalBody>
<ModalFooter>
<Button onClick={[update, undefined]} loading={updateLoading()}>
{t(`indexes.update`)}
</Button>
</ModalFooter>
</ModalContent>
</Modal>
</VStack>
)
}
Expand Down

0 comments on commit 0bada10

Please sign in to comment.