windmill-components 1.21.0 → 1.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/AppConnect.svelte +93 -47
- package/components/AppConnect.svelte.d.ts +2 -2
- package/components/ArgInfo.svelte +0 -5
- package/components/ArgInput.svelte +91 -66
- package/components/ArgInput.svelte.d.ts +8 -3
- package/components/Button.svelte +4 -4
- package/components/CenteredPage.svelte +1 -1
- package/components/CollapseLink.svelte +12 -0
- package/components/CollapseLink.svelte.d.ts +19 -0
- package/components/CronInput.svelte +84 -0
- package/components/CronInput.svelte.d.ts +18 -0
- package/components/DisplayResult.svelte +23 -7
- package/components/Editor.svelte +144 -61
- package/components/Editor.svelte.d.ts +2 -0
- package/components/EditorBar.svelte +215 -0
- package/components/EditorBar.svelte.d.ts +23 -0
- package/components/FlowBuilder.svelte +151 -79
- package/components/FlowEditor.svelte +77 -130
- package/components/FlowEditor.svelte.d.ts +3 -2
- package/components/FlowJobResult.svelte +1 -1
- package/components/FlowPreview.svelte +18 -24
- package/components/FlowPreviewContent.svelte +68 -0
- package/components/FlowPreviewContent.svelte.d.ts +21 -0
- package/components/FlowStatusViewer.svelte +85 -37
- package/components/FlowStatusViewer.svelte.d.ts +3 -2
- package/components/FlowViewer.svelte +100 -26
- package/components/FlowViewer.svelte.d.ts +8 -3
- package/components/IconedResourceType.svelte +30 -5
- package/components/InputTransformForm.svelte +209 -0
- package/components/InputTransformForm.svelte.d.ts +26 -0
- package/components/InviteGlobalUser.svelte +2 -2
- package/components/InviteUser.svelte +2 -2
- package/components/JobStatus.svelte +32 -25
- package/components/Modal.svelte +47 -43
- package/components/ModuleStep.svelte +100 -54
- package/components/ObjectResourceInput.svelte +58 -38
- package/components/ObjectTypeNarrowing.svelte +4 -19
- package/components/Path.svelte +3 -3
- package/components/Path.svelte.d.ts +1 -1
- package/components/RadioButton.svelte +11 -96
- package/components/RadioButton.svelte.d.ts +4 -2
- package/components/ResourceEditor.svelte +5 -6
- package/components/ResourceEditor.svelte.d.ts +2 -2
- package/components/ResourcePicker.svelte +25 -2
- package/components/ResourcePicker.svelte.d.ts +3 -0
- package/components/ResourceTypePicker.svelte +17 -29
- package/components/ResourceTypePicker.svelte.d.ts +1 -0
- package/components/RunForm.svelte +14 -15
- package/components/RunForm.svelte.d.ts +1 -1
- package/components/SchemaEditor.svelte +87 -71
- package/components/SchemaEditor.svelte.d.ts +2 -0
- package/components/SchemaEditorProperty.svelte +11 -0
- package/components/SchemaEditorProperty.svelte.d.ts +17 -0
- package/components/SchemaForm.svelte +21 -127
- package/components/SchemaForm.svelte.d.ts +3 -4
- package/components/SchemaModal.svelte +20 -33
- package/components/SchemaModal.svelte.d.ts +1 -1
- package/components/SchemaViewer.svelte +5 -7
- package/components/ScriptBuilder.svelte +41 -44
- package/components/ScriptEditor.svelte +76 -248
- package/components/ScriptPicker.svelte +13 -26
- package/components/ScriptPicker.svelte.d.ts +1 -1
- package/components/ScriptSchema.svelte +0 -5
- package/components/ShareModal.svelte +1 -1
- package/components/SharedBadge.svelte +12 -10
- package/components/StringTypeNarrowing.svelte +8 -4
- package/components/StringTypeNarrowing.svelte.d.ts +1 -0
- package/components/TableCustom.svelte +7 -9
- package/components/TableSimple.svelte +1 -1
- package/components/Toggle.svelte +8 -10
- package/components/Toggle.svelte.d.ts +5 -11
- package/components/Tooltip.svelte +56 -82
- package/components/Tooltip.svelte.d.ts +1 -5
- package/components/VariableEditor.svelte +21 -6
- package/components/flows/CopyFirstStepSchema.svelte +7 -5
- package/components/flows/DynamicInputHelpBox.svelte +1 -1
- package/components/flows/FlowBox.svelte +3 -0
- package/components/flows/FlowBox.svelte.d.ts +23 -0
- package/components/flows/FlowBoxHeader.svelte +9 -0
- package/components/flows/FlowBoxHeader.svelte.d.ts +18 -0
- package/components/flows/FlowInput.svelte +20 -0
- package/components/flows/FlowInput.svelte.d.ts +14 -0
- package/components/flows/FlowInputs.svelte +7 -3
- package/components/flows/FlowModuleHeader.svelte +44 -41
- package/components/flows/FlowModuleHeader.svelte.d.ts +1 -1
- package/components/flows/FlowSettings.svelte +174 -0
- package/components/flows/FlowSettings.svelte.d.ts +21 -0
- package/components/flows/flowStore.d.ts +5 -2
- package/components/flows/flowStore.js +65 -9
- package/components/flows/pickers/FlowScriptPicker.svelte +6 -1
- package/components/flows/pickers/FlowScriptPicker.svelte.d.ts +1 -0
- package/components/flows/utils.d.ts +11 -11
- package/components/flows/utils.js +103 -63
- package/components/icons/AirtableIcon.svelte +17 -0
- package/components/icons/AirtableIcon.svelte.d.ts +17 -0
- package/components/icons/GCloudIcon.svelte +16 -0
- package/components/icons/GCloudIcon.svelte.d.ts +17 -0
- package/components/icons/GItlabIcon.svelte +16 -0
- package/components/icons/GItlabIcon.svelte.d.ts +17 -0
- package/components/icons/GSheetsIcon.svelte +16 -0
- package/components/icons/GSheetsIcon.svelte.d.ts +17 -0
- package/components/icons/GcalIcon.svelte +16 -0
- package/components/icons/GcalIcon.svelte.d.ts +17 -0
- package/components/icons/GdriveIcon.svelte +16 -0
- package/components/icons/GdriveIcon.svelte.d.ts +17 -0
- package/components/icons/GmailIcon.svelte +16 -0
- package/components/icons/GmailIcon.svelte.d.ts +17 -0
- package/components/icons/PostgresIcon.svelte +8 -49
- package/components/icons/Slack.svelte +9 -18
- package/components/icons/TogglIcon.svelte +59 -0
- package/components/icons/TogglIcon.svelte.d.ts +17 -0
- package/components/propertyPicker/ObjectViewer.svelte +35 -37
- package/components/propertyPicker/ObjectViewer.svelte.d.ts +1 -0
- package/components/propertyPicker/OverlayPropertyPicker.svelte +53 -53
- package/components/propertyPicker/OverlayPropertyPicker.svelte.d.ts +5 -2
- package/components/propertyPicker/PropPicker.svelte +13 -15
- package/components/propertyPicker/PropPicker.svelte.d.ts +1 -1
- package/components/propertyPicker/WarningMessage.svelte +14 -41
- package/components/propertyPicker/WarningMessage.svelte.d.ts +11 -8
- package/components/propertyPicker/utils.d.ts +1 -0
- package/components/propertyPicker/utils.js +25 -0
- package/gen/core/OpenAPI.js +1 -1
- package/gen/index.d.ts +12 -2
- package/gen/index.js +1 -2
- package/gen/models/CompletedJob.d.ts +1 -1
- package/gen/models/Flow.d.ts +3 -13
- package/gen/models/FlowMetadata.d.ts +9 -0
- package/gen/models/FlowMetadata.js +4 -0
- package/gen/models/FlowModuleValue.d.ts +5 -22
- package/gen/models/FlowModuleValue.js +1 -15
- package/gen/models/ForloopFlow.d.ts +8 -0
- package/gen/models/ForloopFlow.js +4 -0
- package/gen/models/InputTransform.d.ts +3 -12
- package/gen/models/InputTransform.js +1 -8
- package/gen/models/JavascriptTransform.d.ts +4 -0
- package/gen/models/JavascriptTransform.js +4 -0
- package/gen/models/MainArgSignature.d.ts +1 -1
- package/gen/models/NewSchedule.d.ts +1 -0
- package/gen/models/OpenFlow.d.ts +7 -0
- package/gen/models/OpenFlow.js +4 -0
- package/gen/models/OpenFlowWPath.d.ts +4 -0
- package/gen/models/OpenFlowWPath.js +4 -0
- package/gen/models/PathFlow.d.ts +4 -0
- package/gen/models/PathFlow.js +4 -0
- package/gen/models/PathScript.d.ts +4 -0
- package/gen/models/PathScript.js +4 -0
- package/gen/models/RawScript.d.ts +12 -0
- package/gen/models/RawScript.js +11 -0
- package/gen/models/Schedule.d.ts +1 -1
- package/gen/models/StaticTransform.d.ts +4 -0
- package/gen/models/StaticTransform.js +4 -0
- package/gen/models/TokenResponse.d.ts +3 -3
- package/gen/models/Usage.d.ts +5 -0
- package/gen/models/Usage.js +4 -0
- package/gen/models/User.d.ts +2 -0
- package/gen/schemas/$AuditLog.d.ts +32 -0
- package/gen/schemas/$AuditLog.js +35 -0
- package/gen/schemas/$CompletedJob.d.ts +98 -0
- package/gen/schemas/$CompletedJob.js +103 -0
- package/gen/schemas/$ContextualVariable.d.ts +16 -0
- package/gen/schemas/$ContextualVariable.js +19 -0
- package/gen/schemas/$CreateResource.d.ts +22 -0
- package/gen/schemas/$CreateResource.js +25 -0
- package/gen/schemas/$CreateVariable.d.ts +26 -0
- package/gen/schemas/$CreateVariable.js +29 -0
- package/gen/schemas/$CreateWorkspace.d.ts +20 -0
- package/gen/schemas/$CreateWorkspace.js +23 -0
- package/gen/schemas/$EditResource.d.ts +13 -0
- package/gen/schemas/$EditResource.js +16 -0
- package/gen/schemas/$EditResourceType.d.ts +10 -0
- package/gen/schemas/$EditResourceType.js +13 -0
- package/gen/schemas/$EditSchedule.d.ts +20 -0
- package/gen/schemas/$EditSchedule.js +23 -0
- package/gen/schemas/$EditVariable.d.ts +16 -0
- package/gen/schemas/$EditVariable.js +19 -0
- package/gen/schemas/$EditWorkspaceUser.d.ts +7 -0
- package/gen/schemas/$EditWorkspaceUser.js +10 -0
- package/gen/schemas/$Flow.d.ts +23 -0
- package/gen/schemas/$Flow.js +26 -0
- package/gen/schemas/$FlowMetadata.d.ts +31 -0
- package/gen/schemas/$FlowMetadata.js +34 -0
- package/gen/schemas/$FlowPreview.d.ts +80 -0
- package/gen/schemas/$FlowPreview.js +83 -0
- package/gen/schemas/$GlobalUserInfo.d.ts +26 -0
- package/gen/schemas/$GlobalUserInfo.js +29 -0
- package/gen/schemas/$Group.d.ts +23 -0
- package/gen/schemas/$Group.js +26 -0
- package/gen/schemas/$Job.d.ts +17 -0
- package/gen/schemas/$Job.js +20 -0
- package/gen/schemas/$ListableVariable.d.ts +35 -0
- package/gen/schemas/$ListableVariable.js +38 -0
- package/gen/schemas/$Login.d.ts +12 -0
- package/gen/schemas/$Login.js +15 -0
- package/gen/schemas/$MainArgSignature.d.ts +50 -0
- package/gen/schemas/$MainArgSignature.js +53 -0
- package/gen/schemas/$NewSchedule.d.ts +30 -0
- package/gen/schemas/$NewSchedule.js +33 -0
- package/gen/schemas/$NewToken.d.ts +11 -0
- package/gen/schemas/$NewToken.js +14 -0
- package/gen/schemas/$NewUser.d.ts +16 -0
- package/gen/schemas/$NewUser.js +19 -0
- package/gen/schemas/$Preview.d.ts +19 -0
- package/gen/schemas/$Preview.js +22 -0
- package/gen/schemas/$QueuedJob.d.ts +139 -0
- package/gen/schemas/$QueuedJob.js +144 -0
- package/gen/schemas/$Resource.d.ts +31 -0
- package/gen/schemas/$Resource.js +34 -0
- package/gen/schemas/$ResourceType.d.ts +17 -0
- package/gen/schemas/$ResourceType.js +20 -0
- package/gen/schemas/$Schedule.d.ts +47 -0
- package/gen/schemas/$Schedule.js +50 -0
- package/gen/schemas/$Script.d.ts +77 -0
- package/gen/schemas/$Script.js +80 -0
- package/gen/schemas/$ScriptArgs.d.ts +6 -0
- package/gen/schemas/$ScriptArgs.js +9 -0
- package/gen/schemas/$SlackToken.d.ts +24 -0
- package/gen/schemas/$SlackToken.js +27 -0
- package/gen/schemas/$TokenResponse.d.ts +23 -0
- package/gen/schemas/$TokenResponse.js +26 -0
- package/gen/schemas/$TruncatedToken.d.ts +25 -0
- package/gen/schemas/$TruncatedToken.js +28 -0
- package/gen/schemas/$Usage.d.ts +13 -0
- package/gen/schemas/$Usage.js +16 -0
- package/gen/schemas/$User.d.ts +42 -0
- package/gen/schemas/$User.js +45 -0
- package/gen/schemas/$UserWorkspaceList.d.ts +28 -0
- package/gen/schemas/$UserWorkspaceList.js +31 -0
- package/gen/schemas/$WorkerPing.d.ts +31 -0
- package/gen/schemas/$WorkerPing.js +34 -0
- package/gen/schemas/$Workspace.d.ts +19 -0
- package/gen/schemas/$Workspace.js +22 -0
- package/gen/schemas/$WorkspaceInvite.d.ts +16 -0
- package/gen/schemas/$WorkspaceInvite.js +19 -0
- package/gen/services/FlowService.d.ts +30 -16
- package/gen/services/FlowService.js +25 -0
- package/gen/services/JobService.d.ts +1 -1
- package/gen/services/ScriptService.d.ts +13 -8
- package/gen/services/WorkspaceService.d.ts +1 -1
- package/gen/services/WorkspaceService.js +1 -1
- package/infer.js +8 -1
- package/package.json +87 -15
- package/script_helpers.d.ts +1 -1
- package/script_helpers.js +7 -6
- package/sql.d.ts +89 -0
- package/sql.js +817 -0
- package/stores.d.ts +1 -1
- package/stores.js +0 -6
- package/utils.d.ts +26 -6
- package/utils.js +94 -7
- package/components/RadioButtonV2.svelte +0 -38
- package/components/RadioButtonV2.svelte.d.ts +0 -20
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
<script>import { ResourceService, ScriptService, VariableService } from '../gen';
|
|
2
|
+
import { getScriptByPath, loadHubScripts, sendUserToast } from '../utils';
|
|
3
|
+
import { faSearch } from '@fortawesome/free-solid-svg-icons';
|
|
4
|
+
import Icon from 'svelte-awesome';
|
|
5
|
+
import { hubScripts, workspaceStore } from '../stores';
|
|
6
|
+
import { Button } from 'flowbite-svelte';
|
|
7
|
+
import { Highlight } from 'svelte-highlight';
|
|
8
|
+
import { python, typescript } from 'svelte-highlight/languages';
|
|
9
|
+
import ItemPicker from './ItemPicker.svelte';
|
|
10
|
+
import Modal from './Modal.svelte';
|
|
11
|
+
import ResourceEditor from './ResourceEditor.svelte';
|
|
12
|
+
import VariableEditor from './VariableEditor.svelte';
|
|
13
|
+
export let lang;
|
|
14
|
+
export let editor;
|
|
15
|
+
export let websocketAlive;
|
|
16
|
+
let variablePicker;
|
|
17
|
+
let resourcePicker;
|
|
18
|
+
let scriptPicker;
|
|
19
|
+
let variableEditor;
|
|
20
|
+
let resourceEditor;
|
|
21
|
+
let codeViewer;
|
|
22
|
+
let codeLang = 'deno';
|
|
23
|
+
let codeContent = '';
|
|
24
|
+
async function loadVariables() {
|
|
25
|
+
let r = [];
|
|
26
|
+
const variables = (await VariableService.listVariable({ workspace: $workspaceStore ?? 'NO_W' })).map((x) => {
|
|
27
|
+
return { name: x.path, ...x };
|
|
28
|
+
});
|
|
29
|
+
const rvariables = await VariableService.listContextualVariables({
|
|
30
|
+
workspace: $workspaceStore ?? 'NO_W'
|
|
31
|
+
});
|
|
32
|
+
r = r.concat(variables).concat(rvariables);
|
|
33
|
+
return r;
|
|
34
|
+
}
|
|
35
|
+
async function loadScripts() {
|
|
36
|
+
const workspaceScripts = await ScriptService.listScripts({
|
|
37
|
+
workspace: $workspaceStore ?? 'NO_W'
|
|
38
|
+
});
|
|
39
|
+
await loadHubScripts();
|
|
40
|
+
const hubScripts_ = $hubScripts ?? [];
|
|
41
|
+
return workspaceScripts.concat(hubScripts_);
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<ItemPicker
|
|
46
|
+
bind:this={scriptPicker}
|
|
47
|
+
pickCallback={async (path, _) => {
|
|
48
|
+
const { language, content } = await getScriptByPath(path ?? '')
|
|
49
|
+
codeContent = content
|
|
50
|
+
codeLang = language
|
|
51
|
+
codeViewer.openModal()
|
|
52
|
+
}}
|
|
53
|
+
closeOnClick={false}
|
|
54
|
+
itemName="script"
|
|
55
|
+
extraField="summary"
|
|
56
|
+
loadItems={loadScripts}
|
|
57
|
+
/>
|
|
58
|
+
|
|
59
|
+
<Modal bind:this={codeViewer}>
|
|
60
|
+
<div slot="title">Code</div>
|
|
61
|
+
<div slot="content">
|
|
62
|
+
{#if codeLang == 'python3'}
|
|
63
|
+
<Highlight language={python} code={codeContent} />
|
|
64
|
+
{:else if codeLang == 'deno'}
|
|
65
|
+
<Highlight language={typescript} code={codeContent} />
|
|
66
|
+
{/if}
|
|
67
|
+
</div></Modal
|
|
68
|
+
>
|
|
69
|
+
|
|
70
|
+
<ItemPicker
|
|
71
|
+
bind:this={variablePicker}
|
|
72
|
+
pickCallback={(path, name) => {
|
|
73
|
+
if (!path) {
|
|
74
|
+
if (lang == 'deno') {
|
|
75
|
+
editor.insertAtCursor(`Deno.env.get('${name}')`)
|
|
76
|
+
} else {
|
|
77
|
+
if (!editor.getCode().includes('import os')) {
|
|
78
|
+
editor.insertAtBeginning('import os\n')
|
|
79
|
+
}
|
|
80
|
+
editor.insertAtCursor(`os.environ.get("${name}")`)
|
|
81
|
+
}
|
|
82
|
+
sendUserToast(`${name} inserted at cursor`)
|
|
83
|
+
} else {
|
|
84
|
+
if (lang == 'deno') {
|
|
85
|
+
if (!editor.getCode().includes('import * as wmill from')) {
|
|
86
|
+
editor.insertAtBeginning(
|
|
87
|
+
`import * as wmill from 'https://deno.land/x/windmill@v${__pkg__.version}/index.ts'\n`
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
editor.insertAtCursor(`(await wmill.getVariable('${path}'))`)
|
|
91
|
+
} else {
|
|
92
|
+
if (!editor.getCode().includes('import wmill')) {
|
|
93
|
+
editor.insertAtBeginning('import wmill\n')
|
|
94
|
+
}
|
|
95
|
+
editor.insertAtCursor(`wmill.get_variable("${path}")`)
|
|
96
|
+
}
|
|
97
|
+
sendUserToast(`${name} inserted at cursor`)
|
|
98
|
+
}
|
|
99
|
+
}}
|
|
100
|
+
itemName="Variable"
|
|
101
|
+
extraField="name"
|
|
102
|
+
loadItems={loadVariables}
|
|
103
|
+
>
|
|
104
|
+
<div slot="submission" class="flex flex-row">
|
|
105
|
+
<div class="text-xs mr-2 align-middle">
|
|
106
|
+
The variable you were looking for does not exist yet?
|
|
107
|
+
</div>
|
|
108
|
+
<button
|
|
109
|
+
class="default-button-secondary"
|
|
110
|
+
type="button"
|
|
111
|
+
on:click={() => {
|
|
112
|
+
variableEditor.initNew()
|
|
113
|
+
}}
|
|
114
|
+
>
|
|
115
|
+
Create a new variable
|
|
116
|
+
</button>
|
|
117
|
+
</div>
|
|
118
|
+
</ItemPicker>
|
|
119
|
+
|
|
120
|
+
<ItemPicker
|
|
121
|
+
bind:this={resourcePicker}
|
|
122
|
+
pickCallback={(path, _) => {
|
|
123
|
+
if (lang == 'deno') {
|
|
124
|
+
if (!editor.getCode().includes('import * as wmill from')) {
|
|
125
|
+
editor.insertAtBeginning(
|
|
126
|
+
`import * as wmill from 'https://deno.land/x/windmill@v${__pkg__.version}/index.ts'\n`
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
editor.insertAtCursor(`(await wmill.getResource('${path}'))`)
|
|
130
|
+
} else {
|
|
131
|
+
if (!editor.getCode().includes('import wmill')) {
|
|
132
|
+
editor.insertAtBeginning('import wmill\n')
|
|
133
|
+
}
|
|
134
|
+
editor.insertAtCursor(`wmill.get_resource("${path}")`)
|
|
135
|
+
}
|
|
136
|
+
sendUserToast(`${path} inserted at cursor`)
|
|
137
|
+
}}
|
|
138
|
+
itemName="Resource"
|
|
139
|
+
extraField="resource_type"
|
|
140
|
+
loadItems={async () =>
|
|
141
|
+
await ResourceService.listResource({ workspace: $workspaceStore ?? 'NO_W' })}
|
|
142
|
+
>
|
|
143
|
+
<div slot="submission" class="flex flex-row">
|
|
144
|
+
<div class="text-xs mr-2 align-middle">
|
|
145
|
+
The resource you were looking for does not exist yet?
|
|
146
|
+
</div>
|
|
147
|
+
<button
|
|
148
|
+
class="default-button-secondary"
|
|
149
|
+
type="button"
|
|
150
|
+
on:click={() => {
|
|
151
|
+
resourceEditor.initNew()
|
|
152
|
+
}}
|
|
153
|
+
>
|
|
154
|
+
Create a new resource
|
|
155
|
+
</button>
|
|
156
|
+
</div>
|
|
157
|
+
</ItemPicker>
|
|
158
|
+
|
|
159
|
+
<ResourceEditor bind:this={resourceEditor} on:refresh={resourcePicker.openModal} />
|
|
160
|
+
|
|
161
|
+
<VariableEditor bind:this={variableEditor} on:create={variablePicker.openModal} />
|
|
162
|
+
|
|
163
|
+
<div class="flex flex-row w-full">
|
|
164
|
+
<div class="flex flex-row w-full space-x-2 whitespace-nowrap">
|
|
165
|
+
<Button
|
|
166
|
+
size="xs"
|
|
167
|
+
color="alternative"
|
|
168
|
+
on:click={() => {
|
|
169
|
+
variablePicker.openModal()
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
<Icon data={faSearch} scale={0.7} class="mr-2" />
|
|
173
|
+
Variable picker
|
|
174
|
+
</Button>
|
|
175
|
+
|
|
176
|
+
<Button
|
|
177
|
+
size="xs"
|
|
178
|
+
color="alternative"
|
|
179
|
+
on:click={() => {
|
|
180
|
+
resourcePicker.openModal()
|
|
181
|
+
}}
|
|
182
|
+
>
|
|
183
|
+
<Icon data={faSearch} scale={0.7} class="mr-2" />
|
|
184
|
+
Resource picker
|
|
185
|
+
</Button>
|
|
186
|
+
|
|
187
|
+
<Button
|
|
188
|
+
size="xs"
|
|
189
|
+
color="alternative"
|
|
190
|
+
on:click={() => {
|
|
191
|
+
scriptPicker.openModal()
|
|
192
|
+
}}
|
|
193
|
+
>
|
|
194
|
+
<Icon data={faSearch} scale={0.7} class="mr-2" />
|
|
195
|
+
Script explorer
|
|
196
|
+
</Button>
|
|
197
|
+
</div>
|
|
198
|
+
<div class="flex flex-row-reverse w-full">
|
|
199
|
+
<Button
|
|
200
|
+
size="xs"
|
|
201
|
+
color="alternative"
|
|
202
|
+
on:click={() => {
|
|
203
|
+
editor.reloadWebsocket()
|
|
204
|
+
}}
|
|
205
|
+
>
|
|
206
|
+
Reload assistants (status:
|
|
207
|
+
{#if lang == 'deno'}
|
|
208
|
+
<span class={websocketAlive.deno ? 'text-green-600' : 'text-red-600'}>Deno</span>
|
|
209
|
+
{:else if lang == 'python3'}
|
|
210
|
+
<span class={websocketAlive.pyright ? 'text-green-600' : 'text-red-600'}>Pyright</span>
|
|
211
|
+
<span class={websocketAlive.black ? 'text-green-600' : 'text-red-600'}>Black</span>
|
|
212
|
+
{/if})
|
|
213
|
+
</Button>
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type Editor from './Editor.svelte';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
lang: 'python3' | 'deno';
|
|
6
|
+
editor: Editor;
|
|
7
|
+
websocketAlive: {
|
|
8
|
+
pyright: boolean;
|
|
9
|
+
black: boolean;
|
|
10
|
+
deno: boolean;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
events: {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {};
|
|
17
|
+
};
|
|
18
|
+
export declare type EditorBarProps = typeof __propDef.props;
|
|
19
|
+
export declare type EditorBarEvents = typeof __propDef.events;
|
|
20
|
+
export declare type EditorBarSlots = typeof __propDef.slots;
|
|
21
|
+
export default class EditorBar extends SvelteComponentTyped<EditorBarProps, EditorBarEvents, EditorBarSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -1,52 +1,102 @@
|
|
|
1
1
|
<script>import { goto } from '$app/navigation';
|
|
2
2
|
import { page } from '$app/stores';
|
|
3
|
-
import { FlowService,
|
|
4
|
-
import { clearPreviewResults,
|
|
5
|
-
import { sendUserToast, setQueryWithoutLoad } from '../utils';
|
|
6
|
-
import {
|
|
3
|
+
import { FlowService, ScheduleService } from '../gen';
|
|
4
|
+
import { clearPreviewResults, previewResults, workspaceStore } from '../stores';
|
|
5
|
+
import { encodeState, formatCron, loadHubScripts, pathIsEmpty, sendUserToast, setQueryWithoutLoad } from '../utils';
|
|
6
|
+
import { faPlay } from '@fortawesome/free-solid-svg-icons';
|
|
7
|
+
import { Breadcrumb, BreadcrumbItem, Button } from 'flowbite-svelte';
|
|
8
|
+
import { onDestroy, onMount } from 'svelte';
|
|
9
|
+
import Icon from 'svelte-awesome';
|
|
10
|
+
import { OFFSET } from './CronInput.svelte';
|
|
7
11
|
import FlowEditor from './FlowEditor.svelte';
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
12
|
+
import FlowPreviewContent from './FlowPreviewContent.svelte';
|
|
13
|
+
import { flowStore, mode } from './flows/flowStore';
|
|
14
|
+
import { flowToMode, jobsToResults } from './flows/utils';
|
|
10
15
|
import ScriptSchema from './ScriptSchema.svelte';
|
|
11
16
|
export let initialPath = '';
|
|
12
17
|
let pathError = '';
|
|
13
|
-
let
|
|
18
|
+
let scheduleArgs;
|
|
19
|
+
let scheduleEnabled;
|
|
20
|
+
let scheduleCron;
|
|
21
|
+
let previewOpen = false;
|
|
14
22
|
$: step = Number($page.url.searchParams.get('step')) || 1;
|
|
15
|
-
async function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
async function createSchedule(path) {
|
|
24
|
+
await ScheduleService.createSchedule({
|
|
25
|
+
workspace: $workspaceStore,
|
|
26
|
+
requestBody: {
|
|
27
|
+
path: path,
|
|
28
|
+
schedule: formatCron(scheduleCron),
|
|
29
|
+
offset: OFFSET,
|
|
30
|
+
script_path: path,
|
|
31
|
+
is_flow: true,
|
|
32
|
+
args: scheduleArgs,
|
|
33
|
+
enabled: scheduleEnabled
|
|
34
|
+
}
|
|
35
|
+
});
|
|
23
36
|
}
|
|
24
37
|
async function saveFlow() {
|
|
25
|
-
const
|
|
38
|
+
const flow = flowToMode($flowStore, $mode);
|
|
26
39
|
if (initialPath === '') {
|
|
27
40
|
await FlowService.createFlow({
|
|
28
41
|
workspace: $workspaceStore,
|
|
29
42
|
requestBody: {
|
|
30
|
-
path:
|
|
31
|
-
summary:
|
|
32
|
-
description:
|
|
33
|
-
value:
|
|
34
|
-
schema:
|
|
43
|
+
path: flow.path,
|
|
44
|
+
summary: flow.summary,
|
|
45
|
+
description: flow.description ?? '',
|
|
46
|
+
value: flow.value,
|
|
47
|
+
schema: flow.schema
|
|
35
48
|
}
|
|
36
49
|
});
|
|
50
|
+
if ($mode == 'pull') {
|
|
51
|
+
await createSchedule(flow.path);
|
|
52
|
+
}
|
|
37
53
|
}
|
|
38
54
|
else {
|
|
39
55
|
await FlowService.updateFlow({
|
|
40
56
|
workspace: $workspaceStore,
|
|
41
|
-
path:
|
|
57
|
+
path: initialPath,
|
|
42
58
|
requestBody: {
|
|
43
|
-
path:
|
|
44
|
-
summary:
|
|
45
|
-
description:
|
|
46
|
-
value:
|
|
47
|
-
schema:
|
|
59
|
+
path: flow.path,
|
|
60
|
+
summary: flow.summary,
|
|
61
|
+
description: flow.description ?? '',
|
|
62
|
+
value: flow.value,
|
|
63
|
+
schema: flow.schema
|
|
48
64
|
}
|
|
49
65
|
});
|
|
66
|
+
const scheduleExists = await ScheduleService.existsSchedule({
|
|
67
|
+
workspace: $workspaceStore ?? '',
|
|
68
|
+
path: initialPath
|
|
69
|
+
});
|
|
70
|
+
if (scheduleExists) {
|
|
71
|
+
const schedule = await ScheduleService.getSchedule({
|
|
72
|
+
workspace: $workspaceStore ?? '',
|
|
73
|
+
path: initialPath
|
|
74
|
+
});
|
|
75
|
+
if (schedule.path != flow.path ||
|
|
76
|
+
JSON.stringify(schedule.args) != JSON.stringify(scheduleArgs) ||
|
|
77
|
+
schedule.schedule != scheduleCron) {
|
|
78
|
+
await ScheduleService.updateSchedule({
|
|
79
|
+
workspace: $workspaceStore ?? '',
|
|
80
|
+
path: initialPath,
|
|
81
|
+
requestBody: {
|
|
82
|
+
schedule: formatCron(scheduleCron),
|
|
83
|
+
script_path: flow.path,
|
|
84
|
+
is_flow: true,
|
|
85
|
+
args: scheduleArgs
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
if (scheduleEnabled != schedule.enabled) {
|
|
90
|
+
await ScheduleService.setScheduleEnabled({
|
|
91
|
+
workspace: $workspaceStore ?? '',
|
|
92
|
+
path: flow.path,
|
|
93
|
+
requestBody: { enabled: scheduleEnabled }
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
await createSchedule(flow.path);
|
|
99
|
+
}
|
|
50
100
|
}
|
|
51
101
|
sendUserToast(`Success! flow saved at ${$flowStore.path}`);
|
|
52
102
|
goto(`/flows/get/${$flowStore.path}`);
|
|
@@ -55,46 +105,42 @@ async function changeStep(step) {
|
|
|
55
105
|
goto(`?step=${step}`);
|
|
56
106
|
}
|
|
57
107
|
flowStore.subscribe((flow) => {
|
|
58
|
-
|
|
108
|
+
if (flow) {
|
|
109
|
+
setQueryWithoutLoad($page.url, 'state', encodeState(flowToMode(flow, $mode)));
|
|
110
|
+
}
|
|
59
111
|
});
|
|
60
112
|
onMount(() => {
|
|
61
|
-
|
|
113
|
+
loadHubScripts();
|
|
62
114
|
clearPreviewResults();
|
|
63
115
|
});
|
|
116
|
+
onDestroy(() => {
|
|
117
|
+
//@ts-ignore
|
|
118
|
+
$flowStore = undefined;
|
|
119
|
+
});
|
|
64
120
|
</script>
|
|
65
121
|
|
|
66
|
-
<div class="flex flex-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<div class="justify-between flex flex-row
|
|
70
|
-
<
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
class="{step === 2
|
|
83
|
-
? 'default-button-disabled text-gray-700'
|
|
84
|
-
: 'default-button-secondary'} min-w-max ml-2"
|
|
85
|
-
on:click={() => {
|
|
86
|
-
changeStep(2)
|
|
87
|
-
}}>Step 2: UI customisation</button
|
|
88
|
-
>
|
|
89
|
-
</div>
|
|
122
|
+
<div class="flex flex-row w-full h-full justify-between">
|
|
123
|
+
<div class="flex flex-col max-w-screen-md mb-96 m-auto">
|
|
124
|
+
<!-- Nav between steps-->
|
|
125
|
+
<div class="justify-between flex flex-row w-full my-4">
|
|
126
|
+
<Breadcrumb>
|
|
127
|
+
<BreadcrumbItem>
|
|
128
|
+
<button on:click={() => changeStep(1)} class={step === 1 ? 'font-bold' : null}>
|
|
129
|
+
Flow Editor
|
|
130
|
+
</button>
|
|
131
|
+
</BreadcrumbItem>
|
|
132
|
+
<BreadcrumbItem>
|
|
133
|
+
<button on:click={() => changeStep(2)} class={step === 2 ? 'font-bold' : null}>
|
|
134
|
+
UI customisation
|
|
135
|
+
</button>
|
|
136
|
+
</BreadcrumbItem>
|
|
137
|
+
</Breadcrumb>
|
|
90
138
|
<div class="flex flex-row-reverse ml-2">
|
|
91
139
|
{#if step == 1}
|
|
92
140
|
<button
|
|
93
141
|
disabled={pathError != ''}
|
|
94
142
|
class="default-button px-6 max-h-8"
|
|
95
|
-
on:click={() =>
|
|
96
|
-
changeStep(step + 1)
|
|
97
|
-
}}
|
|
143
|
+
on:click={() => changeStep(2)}
|
|
98
144
|
>
|
|
99
145
|
Next
|
|
100
146
|
</button>
|
|
@@ -112,31 +158,57 @@ onMount(() => {
|
|
|
112
158
|
</div>
|
|
113
159
|
<div class="flex flex-row-reverse">
|
|
114
160
|
<span class="my-1 text-sm text-gray-500 italic">
|
|
115
|
-
{#if initialPath && initialPath != $flowStore
|
|
116
|
-
{$flowStore
|
|
161
|
+
{#if initialPath && initialPath != $flowStore?.path} {initialPath} → {/if}
|
|
162
|
+
{$flowStore?.path}
|
|
117
163
|
</span>
|
|
118
164
|
</div>
|
|
119
|
-
</div>
|
|
120
|
-
|
|
121
|
-
<!-- metadata -->
|
|
122
165
|
|
|
123
|
-
|
|
124
|
-
<FlowEditor bind:mode bind:pathError bind:initialPath />
|
|
125
|
-
{:else if step === 2}
|
|
126
|
-
<ScriptSchema
|
|
127
|
-
synchronizedHeader={false}
|
|
128
|
-
bind:summary={$flowStore.summary}
|
|
129
|
-
bind:description={$flowStore.description}
|
|
130
|
-
bind:schema={$flowStore.schema}
|
|
131
|
-
/>
|
|
132
|
-
{/if}
|
|
133
|
-
</div>
|
|
166
|
+
<!-- metadata -->
|
|
134
167
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
168
|
+
{#if $flowStore}
|
|
169
|
+
{#if step === 1}
|
|
170
|
+
<FlowEditor
|
|
171
|
+
bind:pathError
|
|
172
|
+
bind:initialPath
|
|
173
|
+
bind:scheduleEnabled
|
|
174
|
+
bind:scheduleCron
|
|
175
|
+
bind:scheduleArgs
|
|
176
|
+
/>
|
|
177
|
+
<Button
|
|
178
|
+
disabled={pathIsEmpty($flowStore.path)}
|
|
179
|
+
size="lg"
|
|
180
|
+
pill
|
|
181
|
+
on:click={() => (previewOpen = !previewOpen)}
|
|
182
|
+
class={`blue-button fixed bottom-10 right-10 ${previewOpen ? 'hidden' : ''}`}
|
|
183
|
+
>
|
|
184
|
+
Preview flow
|
|
185
|
+
{pathIsEmpty($flowStore.path) ? '(pick a name first!)' : ''}
|
|
139
186
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
187
|
+
<Icon data={faPlay} class="ml-2" />
|
|
188
|
+
</Button>
|
|
189
|
+
<div class={`relative h-screen w-1/3 ${previewOpen ? '' : 'hidden'}`}>
|
|
190
|
+
<div class="absolute top-0 h-full">
|
|
191
|
+
<div class="fixed border-l-2 right-0 h-screen w-1/3">
|
|
192
|
+
<FlowPreviewContent
|
|
193
|
+
bind:args={scheduleArgs}
|
|
194
|
+
on:close={() => (previewOpen = !previewOpen)}
|
|
195
|
+
on:change={(e) => {
|
|
196
|
+
previewResults.set(jobsToResults(e.detail))
|
|
197
|
+
}}
|
|
198
|
+
/>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
{:else if step === 2}
|
|
203
|
+
<ScriptSchema
|
|
204
|
+
synchronizedHeader={false}
|
|
205
|
+
bind:summary={$flowStore.summary}
|
|
206
|
+
bind:description={$flowStore.description}
|
|
207
|
+
bind:schema={$flowStore.schema}
|
|
208
|
+
/>
|
|
209
|
+
{/if}
|
|
210
|
+
{:else}
|
|
211
|
+
<p>Loading</p>
|
|
212
|
+
{/if}
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|