2024-03-31 15:57:56 +05:30
|
|
|
import { SaveButton } from "@/components/Common/SaveButton"
|
|
|
|
|
import { getSearchSettings, setSearchSettings } from "@/services/search"
|
|
|
|
|
import { SUPPORTED_SERACH_PROVIDERS } from "@/utils/search-provider"
|
|
|
|
|
import { useForm } from "@mantine/form"
|
2024-03-04 00:32:01 +05:30
|
|
|
import { useQuery, useQueryClient } from "@tanstack/react-query"
|
2024-12-01 00:23:17 +05:30
|
|
|
import { Select, Skeleton, Switch, InputNumber, Input } from "antd"
|
2024-03-24 12:43:43 +05:30
|
|
|
import { useTranslation } from "react-i18next"
|
2024-03-04 00:32:01 +05:30
|
|
|
|
|
|
|
|
export const SearchModeSettings = () => {
|
2024-03-24 21:00:00 +05:30
|
|
|
const { t } = useTranslation("settings")
|
2024-03-31 15:57:56 +05:30
|
|
|
|
|
|
|
|
const form = useForm({
|
|
|
|
|
initialValues: {
|
|
|
|
|
isSimpleInternetSearch: false,
|
|
|
|
|
searchProvider: "",
|
feat: Add localization support for visitSpecificWebsite label
This commit adds localization support for the "visitSpecificWebsite" label in the settings.json file for multiple languages. Now, the label can be translated into different languages, including Japanese, Chinese, English, Malayalam, Italian, Portuguese, Russian, French, and Spanish.
2024-06-22 16:55:02 +05:30
|
|
|
totalSearchResults: 0,
|
2024-12-01 00:23:17 +05:30
|
|
|
visitSpecificWebsite: false,
|
|
|
|
|
searxngURL: "",
|
|
|
|
|
searxngJSONMode: false
|
2024-03-31 15:57:56 +05:30
|
|
|
}
|
2024-03-04 00:32:01 +05:30
|
|
|
})
|
|
|
|
|
|
2024-03-31 15:57:56 +05:30
|
|
|
const { status } = useQuery({
|
|
|
|
|
queryKey: ["fetchSearchSettings"],
|
|
|
|
|
queryFn: async () => {
|
|
|
|
|
const data = await getSearchSettings()
|
|
|
|
|
form.setValues(data)
|
|
|
|
|
return data
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-03-04 00:32:01 +05:30
|
|
|
|
|
|
|
|
if (status === "pending" || status === "error") {
|
|
|
|
|
return <Skeleton active />
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2024-03-31 15:57:56 +05:30
|
|
|
<div>
|
|
|
|
|
<div className="mb-5">
|
|
|
|
|
<h2 className="text-base font-semibold leading-7 text-gray-900 dark:text-white">
|
|
|
|
|
{t("generalSettings.webSearch.heading")}
|
|
|
|
|
</h2>
|
|
|
|
|
<div className="border border-b border-gray-200 dark:border-gray-600 mt-3"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<form
|
|
|
|
|
onSubmit={form.onSubmit(async (values) => {
|
|
|
|
|
await setSearchSettings(values)
|
|
|
|
|
})}
|
|
|
|
|
className="space-y-4">
|
2024-04-11 00:08:20 +05:30
|
|
|
<div className="flex sm:flex-row flex-col space-y-4 sm:space-y-0 sm:justify-between">
|
2024-06-03 00:30:10 +05:30
|
|
|
<span className="text-gray-700 dark:text-neutral-50 ">
|
2024-03-31 15:57:56 +05:30
|
|
|
{t("generalSettings.webSearch.provider.label")}
|
|
|
|
|
</span>
|
2024-04-11 00:08:20 +05:30
|
|
|
<div>
|
|
|
|
|
<Select
|
|
|
|
|
placeholder={t("generalSettings.webSearch.provider.placeholder")}
|
|
|
|
|
showSearch
|
|
|
|
|
className="w-full mt-4 sm:mt-0 sm:w-[200px]"
|
|
|
|
|
options={SUPPORTED_SERACH_PROVIDERS}
|
|
|
|
|
filterOption={(input, option) =>
|
|
|
|
|
option!.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
|
|
|
|
|
option!.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
|
|
|
|
}
|
|
|
|
|
{...form.getInputProps("searchProvider")}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-03-31 15:57:56 +05:30
|
|
|
</div>
|
2024-12-01 00:23:17 +05:30
|
|
|
{form.values.searchProvider === "searxng" && (
|
|
|
|
|
<>
|
|
|
|
|
<div className="flex sm:flex-row flex-col space-y-4 sm:space-y-0 sm:justify-between">
|
|
|
|
|
<span className="text-gray-700 dark:text-neutral-50">
|
|
|
|
|
{t("generalSettings.webSearch.searxng.url.label")}
|
|
|
|
|
</span>
|
|
|
|
|
<div>
|
|
|
|
|
<Input
|
|
|
|
|
placeholder="https://searxng.example.com"
|
|
|
|
|
className="w-full mt-4 sm:mt-0 sm:w-[200px]"
|
|
|
|
|
required
|
|
|
|
|
{...form.getInputProps("searxngURL")}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2024-04-11 00:08:20 +05:30
|
|
|
<div className="flex sm:flex-row flex-col space-y-4 sm:space-y-0 sm:justify-between">
|
2024-06-03 00:30:10 +05:30
|
|
|
<span className="text-gray-700 dark:text-neutral-50 ">
|
2024-03-31 15:57:56 +05:30
|
|
|
{t("generalSettings.webSearch.searchMode.label")}
|
|
|
|
|
</span>
|
2024-04-11 00:08:20 +05:30
|
|
|
<div>
|
|
|
|
|
<Switch
|
feat: Add localization support for visitSpecificWebsite label
This commit adds localization support for the "visitSpecificWebsite" label in the settings.json file for multiple languages. Now, the label can be translated into different languages, including Japanese, Chinese, English, Malayalam, Italian, Portuguese, Russian, French, and Spanish.
2024-06-22 16:55:02 +05:30
|
|
|
className="mt-4 sm:mt-0"
|
2024-04-11 00:08:20 +05:30
|
|
|
{...form.getInputProps("isSimpleInternetSearch", {
|
|
|
|
|
type: "checkbox"
|
|
|
|
|
})}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-03-31 15:57:56 +05:30
|
|
|
</div>
|
2024-04-11 00:08:20 +05:30
|
|
|
<div className="flex sm:flex-row flex-col space-y-4 sm:space-y-0 sm:justify-between">
|
2024-06-03 00:30:10 +05:30
|
|
|
<span className="text-gray-700 dark:text-neutral-50 ">
|
2024-03-31 15:57:56 +05:30
|
|
|
{t("generalSettings.webSearch.totalSearchResults.label")}
|
|
|
|
|
</span>
|
2024-04-11 00:08:20 +05:30
|
|
|
<div>
|
|
|
|
|
<InputNumber
|
|
|
|
|
placeholder={t(
|
|
|
|
|
"generalSettings.webSearch.totalSearchResults.placeholder"
|
|
|
|
|
)}
|
|
|
|
|
{...form.getInputProps("totalSearchResults")}
|
|
|
|
|
className="!w-full mt-4 sm:mt-0 sm:w-[200px]"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-03-31 15:57:56 +05:30
|
|
|
</div>
|
2024-03-04 00:32:01 +05:30
|
|
|
|
feat: Add localization support for visitSpecificWebsite label
This commit adds localization support for the "visitSpecificWebsite" label in the settings.json file for multiple languages. Now, the label can be translated into different languages, including Japanese, Chinese, English, Malayalam, Italian, Portuguese, Russian, French, and Spanish.
2024-06-22 16:55:02 +05:30
|
|
|
<div className="flex sm:flex-row flex-col space-y-4 sm:space-y-0 sm:justify-between">
|
|
|
|
|
<span className="text-gray-700 dark:text-neutral-50 ">
|
|
|
|
|
{t("generalSettings.webSearch.visitSpecificWebsite.label")}
|
|
|
|
|
</span>
|
|
|
|
|
<div>
|
|
|
|
|
<Switch
|
|
|
|
|
className="mt-4 sm:mt-0"
|
|
|
|
|
{...form.getInputProps("visitSpecificWebsite", {
|
|
|
|
|
type: "checkbox"
|
|
|
|
|
})}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-03-31 15:57:56 +05:30
|
|
|
<div className="flex justify-end">
|
|
|
|
|
<SaveButton btnType="submit" />
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
2024-03-04 00:32:01 +05:30
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|