mirror of
https://github.com/open-webui/computer.git
synced 2026-11-25 23:00:55 -05:00
refac
This commit is contained in:
1 parent
d372634ebe
commit
3385bf8a1b
19 files changed
+1148
-171
No files matched your search
@@ -48,7 +48,7 @@
|
||||
// Revert
|
||||
conn.enabled = !newVal;
|
||||
connections = [...connections];
|
||||
toast.error('Failed to update connection');
|
||||
toast.error($t('connections.failedToUpdate'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import Icon from './Icon.svelte';
|
||||
import { appVersion, lastSeenVersion, showChangelog } from '$lib/stores';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
import { t } from '$lib/i18n';
|
||||
|
||||
type ChangelogEntry = { title: string; content: string; raw: string };
|
||||
type VersionData = { date: string; [section: string]: string | ChangelogEntry[] };
|
||||
@@ -61,10 +62,10 @@
|
||||
<Modal onclose={handleClose} class="w-full max-w-3xl mx-4 md:mx-0 flex flex-col max-h-[52vh]">
|
||||
<div class="flex items-center gap-3 px-4 pt-4 pb-2 shrink-0">
|
||||
<div class="min-w-0 flex-1">
|
||||
<h2 class="text-sm font-medium text-gray-900 dark:text-white">What's New</h2>
|
||||
<h2 class="text-sm font-medium text-gray-900 dark:text-white">{$t('changelog.whatsNew')}</h2>
|
||||
{#if $appVersion}
|
||||
<p class="mt-0.5 text-[11px] text-gray-400 dark:text-gray-600">
|
||||
Release Notes
|
||||
{$t('changelog.releaseNotes')}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -138,18 +139,18 @@
|
||||
</div>
|
||||
{:else if error}
|
||||
<div class="flex flex-col items-center justify-center py-16 gap-2 text-center">
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400">Couldn't load release notes.</p>
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400">{$t('changelog.loadError')}</p>
|
||||
<button
|
||||
class="rounded-lg bg-gray-100 px-3 py-1.5 text-xs font-medium text-gray-600 hover:text-gray-900 dark:bg-white/6 dark:text-gray-400 dark:hover:text-white transition-colors duration-75"
|
||||
onclick={() => (error = false)}
|
||||
>
|
||||
Retry
|
||||
{$t('changelog.retry')}
|
||||
</button>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="flex flex-col items-center justify-center py-16 gap-3">
|
||||
<Spinner size={16} />
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-600">Loading release notes...</span>
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-600">{$t('changelog.loading')}</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -159,7 +160,7 @@
|
||||
class="text-[13px] text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors duration-100"
|
||||
onclick={handleClose}
|
||||
>
|
||||
Done
|
||||
{$t('changelog.done')}
|
||||
</button>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="text-[11px] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 transition-colors"
|
||||
>v{$latestVersion} available</a
|
||||
>{$t('about.updateAvailable', { version: $latestVersion })}</a
|
||||
>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -44,11 +44,11 @@
|
||||
href="https://github.com/open-webui/computer/blob/main/LICENSE"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="underline hover:text-gray-700 dark:hover:text-gray-300">Open Use License</a
|
||||
class="underline hover:text-gray-700 dark:hover:text-gray-300">{$t('about.licenseName')}</a
|
||||
>
|
||||
|
||||
<br />
|
||||
Copyright © 2026 Open WebUI Inc. All rights reserved.
|
||||
{$t('about.copyright')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ config: { 'notifications.webhook_url': webhookUrl.trim() || null } })
|
||||
});
|
||||
toast.success('Webhook URL saved');
|
||||
toast.success($t('general.webhookUrlSaved'));
|
||||
} catch {
|
||||
toast.error('Failed to save webhook URL');
|
||||
toast.error($t('general.webhookUrlSaveFailed'));
|
||||
} finally {
|
||||
webhookLoading = false;
|
||||
}
|
||||
@@ -48,7 +48,7 @@
|
||||
if (permission === 'granted') {
|
||||
notificationsEnabled.set(true);
|
||||
} else {
|
||||
toast.error('Browser notification permission denied');
|
||||
toast.error($t('general.notificationPermissionDenied'));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -88,28 +88,28 @@
|
||||
</select>
|
||||
|
||||
<!-- Notifications -->
|
||||
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">Notifications</h3>
|
||||
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">{$t('general.notifications')}</h3>
|
||||
|
||||
<div class="flex flex-col gap-2.5">
|
||||
<!-- Browser notifications toggle -->
|
||||
<label class="flex items-center justify-between cursor-pointer">
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400">Browser notifications</span>
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('general.browserNotifications')}</span>
|
||||
<ToggleSwitch value={$notificationsEnabled} onchange={() => toggleNotifications()} />
|
||||
</label>
|
||||
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
|
||||
Show OS-level notifications when a task completes and the tab is not focused.
|
||||
{$t('general.browserNotificationsDesc')}
|
||||
</p>
|
||||
|
||||
<!-- Sound toggle -->
|
||||
<label class="flex items-center justify-between cursor-pointer">
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400">Notification sound</span>
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('general.notificationSound')}</span>
|
||||
<ToggleSwitch value={$notificationSound} onchange={(v) => notificationSound.set(v)} />
|
||||
</label>
|
||||
|
||||
<!-- Webhook URL -->
|
||||
<div class="mt-1">
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="webhook-url">
|
||||
Webhook URL
|
||||
{$t('general.webhookUrl')}
|
||||
</label>
|
||||
<div class="flex gap-1.5 mt-1">
|
||||
<input
|
||||
@@ -124,29 +124,29 @@
|
||||
onclick={saveWebhookUrl}
|
||||
disabled={webhookLoading}
|
||||
>
|
||||
Save
|
||||
{$t('settings.save')}
|
||||
</button>
|
||||
</div>
|
||||
<p class="text-[11px] text-gray-400 dark:text-gray-600 mt-1">
|
||||
Supports Slack, Discord, Teams, and generic JSON webhooks.
|
||||
{$t('general.webhookUrlHint')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if $session?.role === 'admin'}
|
||||
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">Updates</h3>
|
||||
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">{$t('general.updates')}</h3>
|
||||
<label class="flex items-center justify-between cursor-pointer">
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400">Update notifications</span>
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('general.updateNotifications')}</span>
|
||||
<ToggleSwitch value={$showUpdateToastPref} onchange={(v) => showUpdateToastPref.set(v)} />
|
||||
</label>
|
||||
<p class="text-[11px] text-gray-400 dark:text-gray-600 mt-1">
|
||||
Show a toast when a new version of cptr is available.
|
||||
{$t('general.updateNotificationsDesc')}
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">Message queue</h3>
|
||||
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">{$t('general.messageQueue')}</h3>
|
||||
<div class="flex gap-1">
|
||||
{#each [{ value: 'queue' as StreamingBehavior, label: 'Queue' }, { value: 'interrupt' as StreamingBehavior, label: 'Interrupt' }] as opt}
|
||||
{#each [{ value: 'queue' as StreamingBehavior, label: $t('general.queue') }, { value: 'interrupt' as StreamingBehavior, label: $t('general.interrupt') }] as opt}
|
||||
<button
|
||||
class="flex items-center gap-1.5 h-7 px-2.5 rounded-lg text-xs transition-colors duration-100
|
||||
{$streamingBehavior === opt.value
|
||||
@@ -160,8 +160,8 @@
|
||||
</div>
|
||||
<p class="text-[11px] text-gray-400 dark:text-gray-600 mt-1">
|
||||
{$streamingBehavior === 'queue'
|
||||
? 'Messages sent during generation are queued and sent after completion.'
|
||||
: 'Sending a message cancels the current generation.'}
|
||||
? $t('general.queueDesc')
|
||||
: $t('general.interruptDesc')}
|
||||
</p>
|
||||
|
||||
<div class="mt-auto pt-6 flex justify-end">
|
||||
|
||||
@@ -10,20 +10,21 @@
|
||||
} from '$lib/stores/keybindings';
|
||||
import type { ActionId } from '$lib/stores/keybindings';
|
||||
import KeyPill from '../KeyPill.svelte';
|
||||
import { t } from '$lib/i18n';
|
||||
|
||||
/** Action descriptions for the second line. */
|
||||
const ACTION_DESCRIPTIONS: Record<ActionId, string> = {
|
||||
newFile: 'Open a new untitled file',
|
||||
newTerminal: 'Open a new terminal session',
|
||||
newChat: 'Start a new AI chat',
|
||||
closeTab: 'Close the active tab',
|
||||
nextTab: 'Switch to the next tab',
|
||||
prevTab: 'Switch to the previous tab',
|
||||
quickOpen: 'Search and open files quickly',
|
||||
openSettings: 'Open the settings panel',
|
||||
toggleSplit: 'Toggle split editor view',
|
||||
toggleSidebar: 'Show or hide the sidebar'
|
||||
};
|
||||
const ACTION_DESCRIPTIONS: Record<ActionId, string> = $derived({
|
||||
newFile: $t('keyboard.newFile'),
|
||||
newTerminal: $t('keyboard.newTerminal'),
|
||||
newChat: $t('keyboard.newChat'),
|
||||
closeTab: $t('keyboard.closeTab'),
|
||||
nextTab: $t('keyboard.nextTab'),
|
||||
prevTab: $t('keyboard.prevTab'),
|
||||
quickOpen: $t('keyboard.quickOpen'),
|
||||
openSettings: $t('keyboard.openSettings'),
|
||||
toggleSplit: $t('keyboard.toggleSplit'),
|
||||
toggleSidebar: $t('keyboard.toggleSidebar')
|
||||
});
|
||||
|
||||
let recordingAction = $state<ActionId | null>(null);
|
||||
|
||||
@@ -77,18 +78,18 @@
|
||||
|
||||
<div class="flex flex-col min-h-full">
|
||||
<div class="flex items-center justify-between mb-3">
|
||||
<h2 class="text-sm font-medium text-gray-900 dark:text-white">Keyboard Shortcuts</h2>
|
||||
<h2 class="text-sm font-medium text-gray-900 dark:text-white">{$t('keyboard.title')}</h2>
|
||||
<button
|
||||
class="text-[10px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-100"
|
||||
onclick={resetKeybindings}>Reset defaults</button
|
||||
onclick={resetKeybindings}>{$t('keyboard.resetDefaults')}</button
|
||||
>
|
||||
</div>
|
||||
|
||||
<!-- Column headers -->
|
||||
<div class="flex items-center gap-2 mb-0.5 px-1">
|
||||
<span class="flex-1 text-[10px] font-medium text-gray-400 dark:text-gray-600">Command</span>
|
||||
<span class="flex-1 text-[10px] font-medium text-gray-400 dark:text-gray-600">{$t('keyboard.command')}</span>
|
||||
<span class="w-[140px] text-[10px] font-medium text-gray-400 dark:text-gray-600 text-right"
|
||||
>Keybinding</span
|
||||
>{$t('keyboard.keybinding')}</span
|
||||
>
|
||||
</div>
|
||||
|
||||
@@ -110,7 +111,7 @@
|
||||
|
||||
<div class="w-[140px] flex items-center justify-end shrink-0">
|
||||
{#if isRecording}
|
||||
<span class="recording-indicator">Press keys…</span>
|
||||
<span class="recording-indicator">{$t('keyboard.pressKeys')}</span>
|
||||
{:else if chord}
|
||||
<button
|
||||
class="cursor-pointer"
|
||||
@@ -122,7 +123,7 @@
|
||||
{:else}
|
||||
<button
|
||||
class="text-[10px] text-gray-500 dark:text-gray-600 cursor-pointer hover:text-gray-400 transition-colors duration-75"
|
||||
onclick={() => startRecording(actionId)}>Unassigned</button
|
||||
onclick={() => startRecording(actionId)}>{$t('keyboard.unassigned')}</button
|
||||
>
|
||||
{/if}
|
||||
|
||||
@@ -138,7 +139,7 @@
|
||||
</div>
|
||||
|
||||
<p class="text-[10px] text-gray-400 dark:text-gray-600 mt-3">
|
||||
Click a binding to rebind. Press <kbd class="kbd-inline">Esc</kbd> to cancel.
|
||||
{$t('keyboard.rebindHint')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -33,19 +33,19 @@
|
||||
|
||||
const isAdmin = $derived($session?.role === 'admin');
|
||||
|
||||
const personalTabs: { id: Tab; label: string; icon: string }[] = [
|
||||
{ id: 'general', label: 'General', icon: 'settings' },
|
||||
{ id: 'keyboard', label: 'Keyboard', icon: 'terminal' },
|
||||
{ id: 'account', label: 'Account', icon: 'user' },
|
||||
{ id: 'about', label: 'About', icon: 'info' }
|
||||
];
|
||||
const personalTabs: { id: Tab; label: string; icon: string }[] = $derived([
|
||||
{ id: 'general', label: $t('settings.general'), icon: 'settings' },
|
||||
{ id: 'keyboard', label: $t('settings.keyboard'), icon: 'terminal' },
|
||||
{ id: 'account', label: $t('settings.account'), icon: 'user' },
|
||||
{ id: 'about', label: $t('settings.about'), icon: 'info' }
|
||||
]);
|
||||
|
||||
const adminTabs: { id: Tab; label: string; icon: string }[] = [
|
||||
{ id: 'users', label: 'Users', icon: 'user' },
|
||||
{ id: 'connections', label: 'Connections', icon: 'plug' },
|
||||
{ id: 'models', label: 'Models', icon: 'cube' },
|
||||
{ id: 'admin_settings', label: 'Configuration', icon: 'shield' }
|
||||
];
|
||||
const adminTabs: { id: Tab; label: string; icon: string }[] = $derived([
|
||||
{ id: 'users', label: $t('admin.users'), icon: 'user' },
|
||||
{ id: 'connections', label: $t('admin.connections'), icon: 'plug' },
|
||||
{ id: 'models', label: $t('admin.models'), icon: 'cube' },
|
||||
{ id: 'admin_settings', label: $t('settings.configuration'), icon: 'shield' }
|
||||
]);
|
||||
</script>
|
||||
|
||||
<Modal
|
||||
@@ -80,7 +80,7 @@
|
||||
|
||||
<!-- Admin section -->
|
||||
{#if isAdmin}
|
||||
<span class="hidden md:block text-[10px] text-gray-400 dark:text-gray-600 px-2 mt-2 mb-0.5">Admin</span>
|
||||
<span class="hidden md:block text-[10px] text-gray-400 dark:text-gray-600 px-2 mt-2 mb-0.5">{$t('sidebar.admin')}</span>
|
||||
|
||||
{#each adminTabs as tab}
|
||||
<button
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
import type { AutomationData, AutomationForm } from '$lib/apis/automations';
|
||||
import { createAutomation, updateAutomation } from '$lib/apis/automations';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { t } from '$lib/i18n';
|
||||
|
||||
interface Props {
|
||||
automation?: AutomationData | null;
|
||||
@@ -49,7 +50,7 @@
|
||||
);
|
||||
|
||||
let selectedWsName = $derived(
|
||||
$workspaceList.find((w) => w.path === workspace)?.name || workspace.split('/').pop() || 'Select workspace'
|
||||
$workspaceList.find((w) => w.path === workspace)?.name || workspace.split('/').pop() || $t('automationModal.selectWorkspace')
|
||||
);
|
||||
|
||||
async function handleSubmit() {
|
||||
@@ -75,7 +76,7 @@
|
||||
onsave(result);
|
||||
onclose();
|
||||
} catch (e: any) {
|
||||
toast.error(e.message || 'Failed to save automation');
|
||||
toast.error(e.message || $t('automationModal.failedToSave'));
|
||||
} finally {
|
||||
saving = false;
|
||||
}
|
||||
@@ -90,7 +91,7 @@
|
||||
class="w-full text-lg bg-transparent outline-none placeholder:text-gray-300 dark:placeholder:text-gray-700 text-gray-900 dark:text-white"
|
||||
type="text"
|
||||
bind:value={name}
|
||||
placeholder="Automation title"
|
||||
placeholder={$t('automationModal.titlePlaceholder')}
|
||||
/>
|
||||
<button
|
||||
class="shrink-0 ml-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors"
|
||||
@@ -102,13 +103,13 @@
|
||||
|
||||
<!-- Prompt -->
|
||||
<div class="px-5 pb-2">
|
||||
<div class="mb-1 text-[11px] text-gray-400 dark:text-gray-500">Instructions</div>
|
||||
<div class="mb-1 text-[11px] text-gray-400 dark:text-gray-500">{$t('automationModal.instructions')}</div>
|
||||
<textarea
|
||||
class="w-full text-xs bg-transparent outline-none placeholder:text-gray-300 dark:placeholder:text-gray-700 text-gray-700 dark:text-gray-300 resize-none"
|
||||
bind:value={prompt}
|
||||
rows={8}
|
||||
style="min-height: 12rem;"
|
||||
placeholder="Enter prompt here..."
|
||||
placeholder={$t('automationModal.promptPlaceholder')}
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
@@ -142,7 +143,7 @@
|
||||
type="button"
|
||||
onclick={onclose}
|
||||
>
|
||||
Cancel
|
||||
{$t('automationModal.cancel')}
|
||||
</button>
|
||||
<button
|
||||
class="px-3.5 py-1.5 text-xs bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition-colors rounded-full disabled:opacity-50"
|
||||
@@ -150,7 +151,7 @@
|
||||
onclick={handleSubmit}
|
||||
disabled={saving || !name.trim() || !prompt.trim() || !modelId || !workspace}
|
||||
>
|
||||
{saving ? 'Saving...' : automation ? 'Save' : 'Create'}
|
||||
{saving ? $t('automationModal.saving') : automation ? $t('automationModal.save') : $t('automationModal.createBtn')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
type AutomationRunData
|
||||
} from '$lib/apis/automations';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { t } from '$lib/i18n';
|
||||
|
||||
interface Props {
|
||||
automationId?: string;
|
||||
@@ -50,7 +51,7 @@
|
||||
items = res.items;
|
||||
total = res.total;
|
||||
} catch (e: any) {
|
||||
toast.error(e.message || 'Failed to load automations');
|
||||
toast.error(e.message || $t('automations.failedToLoad'));
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
@@ -62,7 +63,7 @@
|
||||
detail = await getAutomationById(id);
|
||||
runs = await getAutomationRuns(id);
|
||||
} catch (e: any) {
|
||||
toast.error(e.message || 'Failed to load automation');
|
||||
toast.error(e.message || $t('automations.failedToLoadOne'));
|
||||
} finally {
|
||||
detailLoading = false;
|
||||
}
|
||||
@@ -86,28 +87,28 @@
|
||||
items = items.map((i) => (i.id === a.id ? updated : i));
|
||||
if (detail?.id === a.id) detail = updated;
|
||||
} catch (e: any) {
|
||||
toast.error(e.message || 'Failed to toggle');
|
||||
toast.error(e.message || $t('automations.failedToToggle'));
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(a: AutomationData) {
|
||||
if (!confirm(`Delete "${a.name}"?`)) return;
|
||||
if (!confirm($t('automations.deleteConfirm', { name: a.name }))) return;
|
||||
try {
|
||||
await deleteAutomation(a.id);
|
||||
items = items.filter((i) => i.id !== a.id);
|
||||
if (detail?.id === a.id) goto('/automations');
|
||||
toast.success('Deleted');
|
||||
toast.success($t('automations.deleted'));
|
||||
} catch (e: any) {
|
||||
toast.error(e.message || 'Failed to delete');
|
||||
toast.error(e.message || $t('automations.failedToDelete'));
|
||||
}
|
||||
}
|
||||
|
||||
async function handleRunNow(a: AutomationData) {
|
||||
try {
|
||||
await runAutomation(a.id);
|
||||
toast.success(`"${a.name}" triggered`);
|
||||
toast.success($t('automations.triggered', { name: a.name }));
|
||||
} catch (e: any) {
|
||||
toast.error(e.message || 'Failed to run');
|
||||
toast.error(e.message || $t('automations.failedToRun'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,9 +154,9 @@
|
||||
const updated = await generateWebhook(detail.id);
|
||||
detail = updated;
|
||||
items = items.map((i) => (i.id === updated.id ? updated : i));
|
||||
toast.success('Webhook enabled');
|
||||
toast.success($t('automations.webhookEnabled'));
|
||||
} catch (e: any) {
|
||||
toast.error(e.message || 'Failed to generate webhook');
|
||||
toast.error(e.message || $t('automations.failedToGenerateWebhook'));
|
||||
} finally {
|
||||
webhookLoading = false;
|
||||
}
|
||||
@@ -168,9 +169,9 @@
|
||||
const updated = await deleteWebhook(detail.id);
|
||||
detail = updated;
|
||||
items = items.map((i) => (i.id === updated.id ? updated : i));
|
||||
toast.success('Webhook disabled');
|
||||
toast.success($t('automations.webhookDisabled'));
|
||||
} catch (e: any) {
|
||||
toast.error(e.message || 'Failed to revoke webhook');
|
||||
toast.error(e.message || $t('automations.failedToRevokeWebhook'));
|
||||
} finally {
|
||||
webhookLoading = false;
|
||||
}
|
||||
@@ -198,7 +199,7 @@
|
||||
<button
|
||||
class="flex items-center justify-center w-7 h-7 rounded-md text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors duration-100"
|
||||
onclick={() => sidebarOpen.set(true)}
|
||||
title="Toggle sidebar"
|
||||
title={$t('automations.toggleSidebar')}
|
||||
>
|
||||
<Icon name="sidebar-expand" size={14} />
|
||||
</button>
|
||||
@@ -208,7 +209,7 @@
|
||||
onclick={() => goto('/automations')}
|
||||
>
|
||||
<Icon name="chevron-left" size={12} />
|
||||
<span>Automations</span>
|
||||
<span>{$t('automations.title')}</span>
|
||||
</button>
|
||||
<span class="text-gray-300 dark:text-gray-600">/</span>
|
||||
<span class="text-xs text-gray-900 dark:text-white truncate">{detail.name}</span>
|
||||
@@ -218,21 +219,21 @@
|
||||
<button
|
||||
class="flex items-center justify-center w-5 h-5 rounded text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-75"
|
||||
onclick={() => handleRunNow(detail!)}
|
||||
title="Run now"
|
||||
title={$t('automations.runNow')}
|
||||
>
|
||||
<Icon name="play" size={11} />
|
||||
</button>
|
||||
<button
|
||||
class="flex items-center justify-center w-5 h-5 rounded text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-75"
|
||||
onclick={() => { editingAutomation = detail; showModal = true; }}
|
||||
title="Edit"
|
||||
title={$t('automationModal.save')}
|
||||
>
|
||||
<Icon name="pencil" size={11} />
|
||||
</button>
|
||||
<button
|
||||
class="flex items-center justify-center w-5 h-5 rounded text-gray-400 hover:text-red-500 transition-colors duration-75"
|
||||
onclick={() => handleDelete(detail!)}
|
||||
title="Delete"
|
||||
title={$t('admin.delete')}
|
||||
>
|
||||
<Icon name="trash" size={11} />
|
||||
</button>
|
||||
@@ -244,30 +245,30 @@
|
||||
<!-- Info rows -->
|
||||
<div class="border-b border-gray-200 dark:border-white/6">
|
||||
<div class="flex items-center h-7 px-3">
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-500 w-20 shrink-0">Status</span>
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-500 w-20 shrink-0">{$t('automations.status')}</span>
|
||||
<div class="flex items-center gap-1.5">
|
||||
<span class="w-1.5 h-1.5 rounded-full {detail.is_active ? 'bg-emerald-500' : 'bg-gray-400'}"></span>
|
||||
<span class="text-xs text-gray-700 dark:text-gray-300">{detail.is_active ? 'Active' : 'Paused'}</span>
|
||||
<span class="text-xs text-gray-700 dark:text-gray-300">{detail.is_active ? $t('automations.active') : $t('automations.paused')}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center h-7 px-3">
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-500 w-20 shrink-0">Schedule</span>
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-500 w-20 shrink-0">{$t('automations.schedule')}</span>
|
||||
<span class="text-xs text-gray-700 dark:text-gray-300">{parseFrequency(detail.rrule)}</span>
|
||||
</div>
|
||||
<div class="flex items-center h-7 px-3">
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-500 w-20 shrink-0">Model</span>
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-500 w-20 shrink-0">{$t('automations.model')}</span>
|
||||
<span class="text-[11px] text-gray-500 dark:text-gray-400 font-mono">{detail.model_id}</span>
|
||||
</div>
|
||||
<div class="flex items-center h-7 px-3">
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-500 w-20 shrink-0">Next run</span>
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-500 w-20 shrink-0">{$t('automations.nextRun')}</span>
|
||||
<span class="text-xs text-gray-700 dark:text-gray-300">{formatTime(detail.next_run_at)}</span>
|
||||
</div>
|
||||
<div class="flex items-center h-7 px-3">
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-500 w-20 shrink-0">Last run</span>
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-500 w-20 shrink-0">{$t('automations.lastRun')}</span>
|
||||
<span class="text-xs text-gray-700 dark:text-gray-300">{formatTime(detail.last_run_at)}</span>
|
||||
</div>
|
||||
<div class="flex items-center min-h-[1.75rem] px-3">
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-500 w-20 shrink-0">Webhook</span>
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-500 w-20 shrink-0">{$t('automations.webhook')}</span>
|
||||
{#if detail.webhook_url}
|
||||
<div class="flex items-center gap-1.5 min-w-0 flex-1">
|
||||
<span class="text-[11px] text-gray-500 dark:text-gray-400 font-mono truncate">...?token={detail.webhook_url.split('token=')[1]?.slice(0, 12)}...</span>
|
||||
@@ -275,20 +276,20 @@
|
||||
class="text-[11px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-75 shrink-0"
|
||||
onclick={copyWebhookUrl}
|
||||
>
|
||||
{webhookCopied ? 'Copied!' : 'Copy'}
|
||||
{webhookCopied ? $t('automations.copied') : $t('automations.copy')}
|
||||
</button>
|
||||
</div>
|
||||
{:else if detail.has_webhook}
|
||||
<!-- Webhook enabled, URL not available -->
|
||||
<div class="flex items-center gap-1.5">
|
||||
<span class="text-[11px] text-gray-700 dark:text-gray-300">Enabled</span>
|
||||
<span class="text-[11px] text-gray-700 dark:text-gray-300">{$t('automations.enabled')}</span>
|
||||
<span class="text-gray-300 dark:text-gray-600">·</span>
|
||||
<button
|
||||
class="text-[11px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-75"
|
||||
onclick={handleGenerateWebhook}
|
||||
disabled={webhookLoading}
|
||||
>
|
||||
Regenerate
|
||||
{$t('automations.regenerate')}
|
||||
</button>
|
||||
<span class="text-gray-300 dark:text-gray-600">·</span>
|
||||
<button
|
||||
@@ -296,7 +297,7 @@
|
||||
onclick={handleRevokeWebhook}
|
||||
disabled={webhookLoading}
|
||||
>
|
||||
Disable
|
||||
{$t('automations.disable')}
|
||||
</button>
|
||||
</div>
|
||||
{:else}
|
||||
@@ -305,7 +306,7 @@
|
||||
onclick={handleGenerateWebhook}
|
||||
disabled={webhookLoading}
|
||||
>
|
||||
Enable
|
||||
{$t('automations.enable')}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -313,7 +314,7 @@
|
||||
|
||||
<!-- Prompt -->
|
||||
<div class="border-b border-gray-200 dark:border-white/6 px-3 py-2">
|
||||
<div class="text-[11px] text-gray-400 dark:text-gray-500 mb-1">Prompt</div>
|
||||
<div class="text-[11px] text-gray-400 dark:text-gray-500 mb-1">{$t('automations.prompt')}</div>
|
||||
<div class="text-xs text-gray-700 dark:text-gray-300 whitespace-pre-wrap font-mono leading-relaxed max-h-32 overflow-y-auto">
|
||||
{detail.prompt}
|
||||
</div>
|
||||
@@ -321,9 +322,9 @@
|
||||
|
||||
<!-- Runs -->
|
||||
<div class="px-3 py-2">
|
||||
<div class="text-[11px] text-gray-400 dark:text-gray-500 mb-1">Runs</div>
|
||||
<div class="text-[11px] text-gray-400 dark:text-gray-500 mb-1">{$t('automations.runs')}</div>
|
||||
{#if runs.length === 0}
|
||||
<div class="text-[11px] text-gray-400 dark:text-gray-600 py-2">No runs yet</div>
|
||||
<div class="text-[11px] text-gray-400 dark:text-gray-600 py-2">{$t('automations.noRuns')}</div>
|
||||
{:else}
|
||||
{#each runs as run}
|
||||
<div class="flex items-center gap-2 h-7 text-xs">
|
||||
@@ -340,7 +341,7 @@
|
||||
setTimeout(() => openChatTab(run.chat_id!), 300);
|
||||
}}
|
||||
>
|
||||
view chat →
|
||||
{$t('automations.viewChat')}
|
||||
</button>
|
||||
{/if}
|
||||
{#if run.error}
|
||||
@@ -360,12 +361,12 @@
|
||||
<button
|
||||
class="flex items-center justify-center w-7 h-7 rounded-md text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors duration-100"
|
||||
onclick={() => sidebarOpen.set(true)}
|
||||
title="Toggle sidebar"
|
||||
title={$t('automations.toggleSidebar')}
|
||||
>
|
||||
<Icon name="sidebar-expand" size={14} />
|
||||
</button>
|
||||
{/if}
|
||||
<span class="text-xs text-gray-900 dark:text-white">Automations</span>
|
||||
<span class="text-xs text-gray-900 dark:text-white">{$t('automations.title')}</span>
|
||||
{#if total > 0}
|
||||
<span class="text-[11px] text-gray-400 dark:text-gray-600">{total}</span>
|
||||
{/if}
|
||||
@@ -376,14 +377,14 @@
|
||||
bind:value={statusFilter}
|
||||
onchange={loadList}
|
||||
>
|
||||
<option value="all">All</option>
|
||||
<option value="active">Active</option>
|
||||
<option value="paused">Paused</option>
|
||||
<option value="all">{$t('automations.all')}</option>
|
||||
<option value="active">{$t('automations.active')}</option>
|
||||
<option value="paused">{$t('automations.paused')}</option>
|
||||
</select>
|
||||
<button
|
||||
class="flex items-center justify-center w-5 h-5 rounded text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-75"
|
||||
onclick={() => { editingAutomation = null; showModal = true; }}
|
||||
title="New automation"
|
||||
title={$t('automations.newAutomation')}
|
||||
>
|
||||
<Icon name="plus" size={13} />
|
||||
</button>
|
||||
@@ -396,7 +397,7 @@
|
||||
<input
|
||||
type="text"
|
||||
class="flex-1 border-none outline-none bg-transparent text-xs text-gray-900 dark:text-white placeholder:text-gray-400"
|
||||
placeholder="Filter..."
|
||||
placeholder={$t('automations.filter')}
|
||||
bind:value={searchQuery}
|
||||
oninput={loadList}
|
||||
/>
|
||||
@@ -416,14 +417,14 @@
|
||||
{:else if items.length === 0}
|
||||
<div class="flex flex-col items-center justify-center py-12 gap-2">
|
||||
<p class="text-xs text-gray-400 dark:text-gray-600">
|
||||
{searchQuery ? 'No matches' : 'No automations yet'}
|
||||
{searchQuery ? $t('automations.noMatches') : $t('automations.noAutomations')}
|
||||
</p>
|
||||
{#if !searchQuery}
|
||||
<button
|
||||
class="text-xs text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 px-3 py-1 rounded-lg bg-gray-100 dark:bg-white/6 transition-colors duration-75"
|
||||
onclick={() => { editingAutomation = null; showModal = true; }}
|
||||
>
|
||||
Create automation
|
||||
{$t('automations.create')}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -448,7 +449,7 @@
|
||||
<button
|
||||
class="flex items-center justify-center w-5 h-5 rounded text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-75"
|
||||
onclick={() => handleRunNow(a)}
|
||||
title="Run now"
|
||||
title={$t('automations.runNow')}
|
||||
>
|
||||
<Icon name="play" size={11} />
|
||||
</button>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { tick } from 'svelte';
|
||||
import { chatModels } from '$lib/stores/chat';
|
||||
import DropdownMenu from '../DropdownMenu.svelte';
|
||||
import { t } from '$lib/i18n';
|
||||
|
||||
interface Props {
|
||||
selectedModel: string;
|
||||
@@ -52,8 +53,8 @@
|
||||
>
|
||||
<span class="truncate max-w-[160px]"
|
||||
>{$chatModels.length === 0
|
||||
? 'No models available'
|
||||
: $chatModels.find((m) => m.id === selectedModel)?.name || 'Select model'}</span
|
||||
? $t('modelSelector.noModels')
|
||||
: $chatModels.find((m) => m.id === selectedModel)?.name || $t('modelSelector.selectModel')}</span
|
||||
>
|
||||
{#if $chatModels.length > 0}
|
||||
<svg
|
||||
@@ -96,7 +97,7 @@
|
||||
<input
|
||||
bind:this={searchInputEl}
|
||||
bind:value={search}
|
||||
placeholder="Search..."
|
||||
placeholder={$t('modelSelector.search')}
|
||||
class="w-full bg-transparent text-[11px] text-gray-500 dark:text-gray-400 placeholder:text-gray-300 dark:placeholder:text-gray-600 outline-none"
|
||||
onkeydown={(e) => {
|
||||
if (e.key === 'Escape') open = false;
|
||||
@@ -105,7 +106,7 @@
|
||||
</div>
|
||||
{/snippet}
|
||||
{#snippet empty()}
|
||||
<div class="px-3 py-1.5 text-[11px] text-gray-400 dark:text-gray-500 text-center">No matches</div>
|
||||
<div class="px-3 py-1.5 text-[11px] text-gray-400 dark:text-gray-500 text-center">{$t('modelSelector.noMatches')}</div>
|
||||
{/snippet}
|
||||
</DropdownMenu>
|
||||
{/if}
|
||||
Reference in new issue
Block a user