diff --git a/frontend/src/lib/components/ArgInput.svelte b/frontend/src/lib/components/ArgInput.svelte index 11923668ad..e1fff2b3d9 100644 --- a/frontend/src/lib/components/ArgInput.svelte +++ b/frontend/src/lib/components/ArgInput.svelte @@ -20,7 +20,6 @@ import type { SchemaProperty } from '$lib/common' import SimpleEditor from './SimpleEditor.svelte' import autosize from 'svelte-autosize' - import * as autosizeLib from 'autosize' import Toggle from './Toggle.svelte' import Password from './Password.svelte' import type VariableEditor from './VariableEditor.svelte' @@ -296,6 +295,7 @@ {#if properties && Object.keys(properties).length > 0}
diff --git a/frontend/src/lib/components/FlowMetadata.svelte b/frontend/src/lib/components/FlowMetadata.svelte index 34ba78acf5..747a5da817 100644 --- a/frontend/src/lib/components/FlowMetadata.svelte +++ b/frontend/src/lib/components/FlowMetadata.svelte @@ -11,11 +11,15 @@ faUser, faBarsStaggered } from '@fortawesome/free-solid-svg-icons' + import ScheduleEditor from './ScheduleEditor.svelte' export let job: Job const SMALL_ICON_SCALE = 0.7 + let scheduleEditor: ScheduleEditor + +
@@ -46,9 +50,10 @@ {:else if job && job.schedule_path} Triggered by the schedule: {job.schedule_path}Triggered by the schedule: {/if} diff --git a/frontend/src/lib/components/Path.svelte b/frontend/src/lib/components/Path.svelte index 2859bc541c..a584106f90 100644 --- a/frontend/src/lib/components/Path.svelte +++ b/frontend/src/lib/components/Path.svelte @@ -10,7 +10,6 @@ } from '$lib/gen' import { GroupService } from '$lib/gen' import { superadmin, userStore, workspaceStore } from '$lib/stores' - import { sleep } from '$lib/utils' import { createEventDispatcher } from 'svelte' import Required from './Required.svelte' import { Button, Drawer, DrawerContent } from './common' @@ -28,6 +27,7 @@ export let path = '' export let error = '' export let disabled = false + export let checkInitialPathExistence = false export let kind: PathKind @@ -105,7 +105,10 @@ clearTimeout(validateTimeout) } validateTimeout = setTimeout(async () => { - if ((path == '' || path != initialPath) && (await pathExists(path, kind))) { + if ( + (path == '' || checkInitialPathExistence || path != initialPath) && + (await pathExists(path, kind)) + ) { error = 'path already used' } else if (meta && validateName(meta)) { error = '' diff --git a/frontend/src/lib/components/RadioButton.svelte b/frontend/src/lib/components/RadioButton.svelte index ba75f9e078..646e163443 100644 --- a/frontend/src/lib/components/RadioButton.svelte +++ b/frontend/src/lib/components/RadioButton.svelte @@ -2,6 +2,7 @@ export let label = '' export let options: [string | { title: string; desc: string }, any][] export let value: any + export let disabled = false import { createEventDispatcher } from 'svelte' import Tooltip from './Tooltip.svelte' @@ -19,6 +20,7 @@ {val === value ? '!bg-blue-50 !border-blue-500' : ''}" > + export function load() { + return { + stuff: { title: 'New Schedule' } + } + } + + + + + + + + {#if edit} +
+ { + await ScheduleService.setScheduleEnabled({ + path: initialPath, + workspace: $workspaceStore ?? '', + requestBody: { enabled: e.detail } + }) + sendUserToast(`${e.detail ? 'enabled' : 'disabled'} schedule ${initialPath}`) + }} + /> +
+ {/if} + +
+
+ {#if !edit} + Path + +
+ {/if} + +

+ Schedule + Schedules use CRON syntax. Seconds are mandatory. +

+ + +

Runnable

+ {#if !edit} +

+ Pick a script or flow to be triggered by the schedule +

+ + {:else} + + Once a schedule is created, the runnable path cannot be changed. However, when renaming a + script or a flow, the runnable path will automatically update itself. + +
+ + {/if} +
+ Arguments + + {#if runnable} + {#if runnable?.schema && runnable.schema.properties && Object.keys(runnable.schema.properties).length > 0} + + {:else} +
+ This {is_flow ? 'flow' : 'script'} takes no argument +
+ {/if} + {:else} +
+ Pick a {is_flow ? 'flow' : 'script'} and fill its argument here +
+ {/if} +
+
+ + diff --git a/frontend/src/lib/components/ScriptPicker.svelte b/frontend/src/lib/components/ScriptPicker.svelte index d1c5aa1442..6f469a81d4 100644 --- a/frontend/src/lib/components/ScriptPicker.svelte +++ b/frontend/src/lib/components/ScriptPicker.svelte @@ -10,6 +10,7 @@ import RadioButton from './RadioButton.svelte' import { Button, Drawer, DrawerContent } from './common' import HighlightCode from './HighlightCode.svelte' + import FlowPathViewer from './flows/content/FlowPathViewer.svelte' export let initialPath: string | undefined = undefined export let scriptPath: string | undefined = undefined @@ -17,9 +18,11 @@ export let allowHub = false export let itemKind: 'hub' | 'script' | 'flow' = allowHub ? 'hub' : 'script' export let kind: Script.kind = Script.kind.SCRIPT + export let disabled = false let items: { value: string; label: string }[] = [] let drawerViewer: Drawer + let drawerFlowViewer: Drawer let code: string = '' let lang: 'deno' | 'python3' | 'go' | 'bash' | undefined @@ -53,41 +56,64 @@ $: itemKind && $workspaceStore && loadItems() -
- {#if options.length > 1} -
- -
- {/if} - - + {:else} + - -
- {/if} -
-

Arguments

- {#if runnable} - {#if runnable?.schema && runnable.schema.properties && Object.keys(runnable.schema.properties).length > 0} - - {:else} -
- This {is_flow ? 'flow' : 'script'} takes no argument -
- {/if} - {:else} -
- Pick a {is_flow ? 'flow' : 'script'} and fill its argument here -
- {/if} -
-

- Schedule - Schedules use CRON syntax. Seconds are mandatory. -

- - {#if edit} -

Enable

- { - await ScheduleService.setScheduleEnabled({ - path: initialPath, - workspace: $workspaceStore ?? '', - requestBody: { enabled: e.detail } - }) - sendUserToast(`${e.detail ? 'enabled' : 'disabled'} schedule ${initialPath}`) - }} - /> - {/if} -
- diff --git a/frontend/src/routes/schedules.svelte b/frontend/src/routes/schedules.svelte index 76562a4fa2..3c92036120 100644 --- a/frontend/src/routes/schedules.svelte +++ b/frontend/src/routes/schedules.svelte @@ -13,7 +13,6 @@ import PageHeader from '$lib/components/PageHeader.svelte' import TableCustom from '$lib/components/TableCustom.svelte' import Dropdown from '$lib/components/Dropdown.svelte' - import { goto } from '$app/navigation' import ShareModal from '$lib/components/ShareModal.svelte' import SharedBadge from '$lib/components/SharedBadge.svelte' import { @@ -31,6 +30,7 @@ import { Badge, Button, Skeleton } from '$lib/components/common' import Popover from '$lib/components/Popover.svelte' import { Icon } from 'svelte-awesome' + import ScheduleEditor from '$lib/components/ScheduleEditor.svelte' type ScheduleW = Schedule & { canWrite: boolean } @@ -64,11 +64,15 @@ loadSchedules() } } + let scheduleEditor: ScheduleEditor + - +
{#if loading} @@ -92,8 +96,9 @@ {#each schedules as { path, error, edited_by, edited_at, schedule, offset_, enabled, script_path, is_flow, extra_perms, canWrite }} {path} @@ -176,7 +181,7 @@ icon: faEdit, disabled: !canWrite, action: () => { - goto(`/schedule/add?edit=${path}&isFlow=${is_flow}`) + scheduleEditor?.openEdit(path, is_flow) } }, { diff --git a/frontend/src/routes/scripts/get/[...hash].svelte b/frontend/src/routes/scripts/get/[...hash].svelte index 5209bd933d..d994d289fa 100644 --- a/frontend/src/routes/scripts/get/[...hash].svelte +++ b/frontend/src/routes/scripts/get/[...hash].svelte @@ -36,7 +36,6 @@ import ShareModal from '$lib/components/ShareModal.svelte' import { superadmin, userStore, workspaceStore } from '$lib/stores' import SharedBadge from '$lib/components/SharedBadge.svelte' - import SvelteMarkdown from 'svelte-markdown' import SchemaViewer from '$lib/components/SchemaViewer.svelte' import CenteredPage from '$lib/components/CenteredPage.svelte' import { onDestroy } from 'svelte' @@ -57,6 +56,7 @@ import RunForm from '$lib/components/RunForm.svelte' import { goto } from '$app/navigation' import Popover from '$lib/components/Popover.svelte' + import ScheduleEditor from '$lib/components/ScheduleEditor.svelte' let userSettings: UserSettings let script: Script | undefined @@ -163,8 +163,11 @@ sendUserToast(`Could not create job: ${err.body}`, true) } } + let scheduleEditor: ScheduleEditor + + {#if script} @@ -279,7 +282,7 @@ Share