-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from ilittlebig/develop
Add settings for the integration functionality
- Loading branch information
Showing
51 changed files
with
959 additions
and
43 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,110 @@ | ||
<script module> | ||
export let settingsDialog = $state({ open: false }); | ||
</script> | ||
|
||
<script lang="ts"> | ||
import { onMount, onDestroy, type Component } from "svelte"; | ||
import { superForm } from "sveltekit-superforms"; | ||
import { zodClient } from "sveltekit-superforms/adapters"; | ||
import { addHotkey, removeHotkey } from "$lib/services/hotkeys-service"; | ||
import { settingsSchema } from "$lib/schemas/settings"; | ||
import { settingsLoaded, settingsStore } from "$lib/stores/settings-store.svelte"; | ||
import { loadSettings, saveSettings } from "$lib/services/settings-service.svelte"; | ||
import { Separator } from "$lib/components/ui/separator"; | ||
import { ScrollArea } from "$lib/components/ui/scroll-area"; | ||
import * as Dialog from "$lib/components/ui/dialog"; | ||
import * as Tabs from "$lib/components/ui/tabs"; | ||
import Sidebar from "$lib/components/settings/sidebar.svelte"; | ||
import AccountSettingsPage from "$lib/components/settings/account-settings-page.svelte"; | ||
import NotificationsPage from "$lib/components/settings/notifications-page.svelte"; | ||
import PrivacyPage from "$lib/components/settings/privacy-page.svelte"; | ||
import PreferencesPage from "$lib/components/settings/preferences-page.svelte"; | ||
import IntegrationPage from "$lib/components/settings/integration-page.svelte"; | ||
import SecurityPage from "$lib/components/settings/security-page.svelte"; | ||
import BillingPage from "$lib/components/settings/billing-page.svelte"; | ||
interface Page { | ||
name: string; | ||
label: string; | ||
icon: string; | ||
page: Component<any, {}, any>; | ||
} | ||
let currentTab: string | undefined = $state(undefined); | ||
const form = superForm(settingsStore, { | ||
dataType: "json", | ||
SPA: true, | ||
resetForm: false, | ||
validators: zodClient(settingsSchema), | ||
}); | ||
const { | ||
form: formData, | ||
enhance, | ||
allErrors, | ||
submit | ||
} = form; | ||
const pages: Page[] = [ | ||
{ name: "account-settings", label: "Account Settings", icon: "fa-user", page: AccountSettingsPage }, | ||
{ name: "notifications", label: "Notifications", icon: "fa-bell", page: NotificationsPage }, | ||
{ name: "privacy", label: "Privacy", icon: "fa-lock", page: PrivacyPage }, | ||
{ name: "preferences", label: "Preferences", icon: "fa-cog", page: PreferencesPage }, | ||
{ name: "integration", label: "Integration", icon: "fa-link", page: IntegrationPage }, | ||
{ name: "security", label: "Security", icon: "fa-shield", page: SecurityPage }, | ||
{ name: "billing", label: "Billing", icon: "fa-money-bill", page: BillingPage }, | ||
]; | ||
const onValueChange = async (value: string) => { | ||
submit(); | ||
if ($allErrors.length > 0) return; | ||
currentTab = value; | ||
} | ||
const onOpenChange = async (value: boolean) => { | ||
submit(); | ||
if ($allErrors.length > 0) return; | ||
settingsDialog.open = value; | ||
await saveSettings($formData); | ||
} | ||
onMount(async () => { | ||
addHotkey("meta+,", () => settingsDialog.open = true); | ||
if (settingsLoaded.value) return; | ||
await loadSettings(); | ||
formData.set(settingsStore); | ||
}); | ||
onDestroy(() => removeHotkey("meta+,")); | ||
</script> | ||
|
||
<Dialog.Root controlledOpen bind:open={settingsDialog.open} {onOpenChange}> | ||
<Dialog.Content class="max-w-[800px] max-h-[650px] h-full flex flex-col px-0 pt-6 pb-0 gap-0"> | ||
<Dialog.Header class="h-fit px-6"> | ||
<Dialog.Title>Settings</Dialog.Title> | ||
<div class="-mx-6"> | ||
<Separator class="mt-4" /> | ||
</div> | ||
</Dialog.Header> | ||
<ScrollArea class="h-full" scrollHideDelay={0}> | ||
<form method="POST" use:enhance> | ||
<Tabs.Root | ||
controlledValue | ||
{onValueChange} | ||
value={currentTab ?? pages[0].name} | ||
class="flex gap-x-4 h-full pb-6 px-6 pt-4" | ||
> | ||
<Sidebar {pages} /> | ||
<div class="ml-52 w-full"> | ||
{#each pages as { name, page: Page }} | ||
<Tabs.Content value={name} class="w-full"> | ||
<Page {form} {formData} /> | ||
</Tabs.Content> | ||
{/each} | ||
</div> | ||
</Tabs.Root> | ||
</form> | ||
</ScrollArea> | ||
</Dialog.Content> | ||
</Dialog.Root> |
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 was deleted.
Oops, something went wrong.
File renamed without changes.
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,3 @@ | ||
<div class="flex h-full"> | ||
account settings | ||
</div> |
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,3 @@ | ||
<div class="flex h-full"> | ||
billing | ||
</div> |
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,135 @@ | ||
<script lang="ts"> | ||
import type { SuperForm } from "sveltekit-superforms"; | ||
import type { SettingsSchema } from "$lib/schemas/settings"; | ||
import { Input } from "$lib/components/ui/input"; | ||
import { Label } from "$lib/components/ui/label"; | ||
import { Separator } from "$lib/components/ui/separator"; | ||
import * as Select from "$lib/components/ui/select"; | ||
import * as Form from "$lib/components/ui/form"; | ||
interface SelectType { | ||
value: string; | ||
label: string; | ||
} | ||
interface Props { | ||
form: SuperForm<SettingsSchema>; | ||
formData: SvelteStore<SettingsSchema>; | ||
} | ||
const captchaSolvers = [ | ||
{ value: "cap-solver", label: "CapSolver" }, | ||
{ value: "anti-captcha", label: "Anti-Captcha" }, | ||
{ value: "2-captcha", label: "2Captcha" }, | ||
{ value: "death-by-captcha", label: "Death by Captcha" }, | ||
{ value: "zennolab-captcha", label: "ZennoLab Captcha" }, | ||
{ value: "image-typerz", label: "ImageTyperz" }, | ||
{ value: "az-captcha", label: "AZcaptcha" }, | ||
{ value: "best-captcha-solver", label: "Best Captcha Solver" }, | ||
{ value: "resolve-captcha", label: "ResolveCaptcha" }, | ||
{ value: "captcha-solutions", label: "CaptchaSolutions" }, | ||
]; | ||
let { form, formData }: Props = $props(); | ||
const selectedCaptcha = $derived( | ||
$formData.integration.captcha_solver | ||
? captchaSolvers.find((captcha: SelectType) => captcha.value === $formData.integration.captcha_solver)?.label | ||
: "Select a captcha solver" | ||
); | ||
</script> | ||
|
||
<div class="flex flex-col gap-y-6 h-full"> | ||
<Form.Field name="integration.captcha_solver" {form}> | ||
<Form.Control> | ||
{#snippet children({ props })} | ||
<div class="flex w-full flex-col gap-1.5"> | ||
<Form.Label>Captcha Solver</Form.Label> | ||
<Select.Root type="single" bind:value={$formData.integration.captcha_solver}> | ||
<Select.Trigger {...props}>{selectedCaptcha}</Select.Trigger> | ||
<Select.Content> | ||
{#each captchaSolvers as captchaSolver} | ||
<Select.Item value={captchaSolver.value}>{captchaSolver.label}</Select.Item> | ||
{/each} | ||
</Select.Content> | ||
</Select.Root> | ||
<p class="text-muted-foreground text-sm">Required for solving captchas on supported websites.</p> | ||
</div> | ||
{/snippet} | ||
</Form.Control> | ||
<Form.FieldErrors /> | ||
</Form.Field> | ||
{#if !!$formData.integration.captcha_solver} | ||
<Form.Field name="integration.captcha_solver_api_key" {form}> | ||
<Form.Control> | ||
{#snippet children({ props })} | ||
<div class="flex w-full flex-col gap-1.5"> | ||
<Form.Label>Captcha API Key</Form.Label> | ||
<Input {...props} bind:value={$formData.integration.captcha_solver_api_key} /> | ||
</div> | ||
{/snippet} | ||
</Form.Control> | ||
<Form.FieldErrors /> | ||
</Form.Field> | ||
{/if} | ||
<Separator /> | ||
<Form.Field name="integration.request_delay" {form}> | ||
<Form.Control> | ||
{#snippet children({ props })} | ||
<div class="flex w-full flex-col gap-1.5"> | ||
<Form.Label>Request Delay</Form.Label> | ||
<Input {...props} placeholder="3000" bind:value={$formData.integration.request_delay} /> | ||
<p class="text-muted-foreground text-sm">Configure the delay (in milliseconds) between automated actions.</p> | ||
</div> | ||
{/snippet} | ||
</Form.Control> | ||
<Form.FieldErrors /> | ||
</Form.Field> | ||
<Form.Field name="integration.entry_limit" {form}> | ||
<Form.Control> | ||
{#snippet children({ props })} | ||
<div class="flex w-full flex-col gap-1.5"> | ||
<Form.Label>Entry Limit</Form.Label> | ||
<Input {...props} placeholder="10" bind:value={$formData.integration.entry_limit} /> | ||
<p class="text-muted-foreground text-sm">Sets the maximum number of entries/tasks to process per request.</p> | ||
</div> | ||
{/snippet} | ||
</Form.Control> | ||
<Form.FieldErrors /> | ||
</Form.Field> | ||
<Separator /> | ||
<Form.Field name="integration.imap_email" {form}> | ||
<Form.Control> | ||
{#snippet children({ props })} | ||
<div class="flex w-full flex-col gap-1.5"> | ||
<Form.Label>IMAP Email</Form.Label> | ||
<Input {...props} type="email" bind:value={$formData.integration.imap_email} /> | ||
</div> | ||
{/snippet} | ||
</Form.Control> | ||
<Form.FieldErrors /> | ||
</Form.Field> | ||
<Form.Field name="integration.imap_password" {form}> | ||
<Form.Control> | ||
{#snippet children({ props })} | ||
<div class="flex w-full flex-col gap-1.5"> | ||
<Form.Label>IMAP Password</Form.Label> | ||
<Input {...props} type="password" bind:value={$formData.integration.imap_password} /> | ||
</div> | ||
{/snippet} | ||
</Form.Control> | ||
<Form.FieldErrors /> | ||
</Form.Field> | ||
<Separator /> | ||
<Form.Field name="integration.webhook" {form}> | ||
<Form.Control> | ||
{#snippet children({ props })} | ||
<div class="flex w-full flex-col gap-1.5"> | ||
<Form.Label>Webhook</Form.Label> | ||
<Input {...props} bind:value={$formData.integration.webhook} /> | ||
<p class="text-muted-foreground text-sm">Configure a URL for handling webhook events.</p> | ||
</div> | ||
{/snippet} | ||
</Form.Control> | ||
<Form.FieldErrors /> | ||
</Form.Field> | ||
</div> |
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,3 @@ | ||
<div class="flex h-full"> | ||
notifications | ||
</div> |
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,3 @@ | ||
<div class="flex h-full"> | ||
preferences | ||
</div> |
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,3 @@ | ||
<div class="flex h-full"> | ||
privacy | ||
</div> |
Oops, something went wrong.