windmill-components 1.13.27 → 1.22.42
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 +281 -0
- package/components/AppConnect.svelte.d.ts +22 -0
- package/components/ArgInput.svelte +32 -24
- package/components/ArgInput.svelte.d.ts +6 -1
- package/components/Button.svelte +16 -7
- package/components/CenteredModal.svelte +30 -0
- package/components/CenteredModal.svelte.d.ts +19 -0
- package/components/DisplayResult.svelte +52 -46
- package/components/Editor.svelte +69 -64
- package/components/Editor.svelte.d.ts +3 -1
- package/components/EditorBar.svelte +204 -0
- package/components/EditorBar.svelte.d.ts +23 -0
- package/components/FlowBuilder.svelte +57 -110
- package/components/FlowBuilder.svelte.d.ts +0 -2
- package/components/FlowEditor.svelte +183 -65
- package/components/FlowEditor.svelte.d.ts +4 -4
- package/components/FlowJobResult.svelte +23 -0
- package/components/FlowJobResult.svelte.d.ts +17 -0
- package/components/FlowPreview.svelte +17 -28
- package/components/FlowPreview.svelte.d.ts +7 -1
- package/components/FlowStatusViewer.svelte +55 -25
- package/components/FlowStatusViewer.svelte.d.ts +1 -1
- package/components/FlowViewer.svelte +136 -0
- package/components/FlowViewer.svelte.d.ts +24 -0
- package/components/IconedResourceType.svelte +6 -4
- package/components/JobStatus.svelte +1 -1
- package/components/Modal.svelte +5 -3
- package/components/ModuleStep.svelte +129 -56
- package/components/ModuleStep.svelte.d.ts +4 -8
- package/components/ObjectResourceInput.svelte +0 -1
- package/components/Path.svelte +55 -9
- package/components/Path.svelte.d.ts +2 -0
- package/components/RadioButton.svelte +1 -1
- package/components/RadioButtonV2.svelte +33 -0
- package/components/RadioButtonV2.svelte.d.ts +20 -0
- package/components/ResourceEditor.svelte +19 -15
- package/components/ResourcePicker.svelte +2 -2
- package/components/ResourcePicker.svelte.d.ts +2 -2
- package/components/RunForm.svelte +2 -3
- package/components/SchemaForm.svelte +119 -121
- package/components/SchemaForm.svelte.d.ts +6 -4
- package/components/SchemaModal.svelte +1 -1
- package/components/SchemaModal.svelte.d.ts +1 -1
- package/components/SchemaViewer.svelte +1 -1
- package/components/ScriptBuilder.svelte +43 -62
- package/components/ScriptEditor.svelte +12 -189
- package/components/ScriptPicker.svelte +7 -18
- package/components/ScriptPicker.svelte.d.ts +1 -0
- package/components/Switch.svelte.d.ts +2 -2
- package/components/Toggle.svelte +34 -0
- package/components/Toggle.svelte.d.ts +28 -0
- package/components/Tooltip.svelte +53 -80
- package/components/Tooltip.svelte.d.ts +1 -5
- package/components/VariableEditor.svelte +11 -2
- package/components/flows/CopyFirstStepSchema.svelte +10 -0
- package/components/flows/CopyFirstStepSchema.svelte.d.ts +14 -0
- package/components/flows/DynamicInputHelpBox.svelte +72 -0
- package/components/flows/DynamicInputHelpBox.svelte.d.ts +14 -0
- package/components/flows/FlowInputs.svelte +27 -0
- package/components/flows/FlowInputs.svelte.d.ts +19 -0
- package/components/flows/FlowModuleHeader.svelte +92 -0
- package/components/flows/FlowModuleHeader.svelte.d.ts +22 -0
- package/components/flows/flowStore.d.ts +17 -0
- package/components/flows/flowStore.js +161 -0
- package/components/flows/pickers/FlowScriptPicker.svelte +11 -0
- package/components/flows/pickers/FlowScriptPicker.svelte.d.ts +22 -0
- package/components/flows/pickers/PickHubScript.svelte +30 -0
- package/components/flows/pickers/PickHubScript.svelte.d.ts +18 -0
- package/components/flows/pickers/PickScript.svelte +38 -0
- package/components/flows/pickers/PickScript.svelte.d.ts +18 -0
- package/components/flows/utils.d.ts +17 -0
- package/components/flows/utils.js +143 -0
- package/components/propertyPicker/ObjectViewer.svelte +113 -0
- package/components/propertyPicker/ObjectViewer.svelte.d.ts +21 -0
- package/components/propertyPicker/OverlayPropertyPicker.svelte +69 -0
- package/components/propertyPicker/OverlayPropertyPicker.svelte.d.ts +21 -0
- package/components/propertyPicker/PropPicker.svelte +24 -0
- package/components/propertyPicker/PropPicker.svelte.d.ts +18 -0
- package/components/propertyPicker/WarningMessage.svelte +43 -0
- package/components/propertyPicker/WarningMessage.svelte.d.ts +16 -0
- package/components/propertyPicker/utils.d.ts +2 -0
- package/components/propertyPicker/utils.js +40 -0
- package/gen/core/ApiError.d.ts +3 -1
- package/gen/core/ApiError.js +3 -1
- package/gen/core/OpenAPI.js +1 -1
- package/gen/core/request.js +2 -2
- package/gen/index.d.ts +4 -0
- package/gen/index.js +1 -0
- package/gen/models/CompletedJob.d.ts +3 -1
- package/gen/models/CompletedJob.js +1 -0
- package/gen/models/CreateResource.d.ts +1 -0
- package/gen/models/CreateVariable.d.ts +2 -0
- package/gen/models/FlowModule.d.ts +2 -0
- package/gen/models/FlowModuleValue.d.ts +14 -2
- package/gen/models/FlowModuleValue.js +7 -0
- package/gen/models/FlowStatusModule.d.ts +6 -0
- package/gen/models/ListableVariable.d.ts +2 -0
- package/gen/models/OpenFlow.d.ts +7 -0
- package/gen/models/OpenFlow.js +4 -0
- package/gen/models/QueuedJob.d.ts +2 -1
- package/gen/models/QueuedJob.js +1 -0
- package/gen/models/Resource.d.ts +1 -0
- package/gen/models/Script.d.ts +1 -0
- package/gen/models/SlackToken.d.ts +8 -0
- package/gen/models/SlackToken.js +4 -0
- package/gen/models/TokenResponse.d.ts +6 -0
- package/gen/models/TokenResponse.js +4 -0
- package/gen/services/AdminService.d.ts +6 -2
- package/gen/services/AuditService.d.ts +24 -8
- package/gen/services/FlowService.d.ts +50 -10
- package/gen/services/FlowService.js +26 -0
- package/gen/services/GranularAclService.d.ts +6 -2
- package/gen/services/GroupService.d.ts +18 -6
- package/gen/services/JobService.d.ts +167 -46
- package/gen/services/JobService.js +26 -2
- package/gen/services/OauthService.d.ts +104 -0
- package/gen/services/OauthService.js +133 -0
- package/gen/services/ResourceService.d.ts +39 -7
- package/gen/services/ResourceService.js +30 -0
- package/gen/services/ScheduleService.d.ts +36 -6
- package/gen/services/ScheduleService.js +30 -0
- package/gen/services/ScriptService.d.ts +77 -19
- package/gen/services/ScriptService.js +31 -1
- package/gen/services/UserService.d.ts +49 -11
- package/gen/services/UserService.js +17 -0
- package/gen/services/VariableService.d.ts +19 -4
- package/gen/services/VariableService.js +15 -0
- package/gen/services/WorkerService.d.ts +6 -2
- package/gen/services/WorkspaceService.d.ts +29 -24
- package/gen/services/WorkspaceService.js +8 -23
- package/logout.js +10 -3
- package/package.json +52 -23
- package/script_helpers.d.ts +4 -0
- package/script_helpers.js +70 -0
- package/scripts.d.ts +2 -1
- package/scripts.js +5 -5
- package/stores.d.ts +7 -0
- package/stores.js +12 -0
- package/utils.d.ts +28 -1
- package/utils.js +206 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
<script context="module">"use strict";
|
|
2
|
+
const apiTokenApps = {
|
|
3
|
+
airtable: {
|
|
4
|
+
img: 'airtable_connect.png',
|
|
5
|
+
instructions: 'Click on the top-right avatar -> Account -> Api'
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script>import IconedResourceType from './IconedResourceType.svelte';
|
|
11
|
+
import PageHeader from './PageHeader.svelte';
|
|
12
|
+
import { workspaceStore, userStore, oauthStore } from '../stores';
|
|
13
|
+
import { faMinus, faPlus } from '@fortawesome/free-solid-svg-icons';
|
|
14
|
+
import { OauthService, ResourceService, VariableService } from '../gen';
|
|
15
|
+
import { createEventDispatcher, onMount } from 'svelte';
|
|
16
|
+
import Modal from './Modal.svelte';
|
|
17
|
+
import Icon from 'svelte-awesome';
|
|
18
|
+
import Path from './Path.svelte';
|
|
19
|
+
import Password from './Password.svelte';
|
|
20
|
+
import { sendUserToast, truncateRev } from '../utils';
|
|
21
|
+
let manual = false;
|
|
22
|
+
let value = '';
|
|
23
|
+
let valueToken;
|
|
24
|
+
let connects = {};
|
|
25
|
+
let connectsManual = [];
|
|
26
|
+
let scopes = [];
|
|
27
|
+
let path;
|
|
28
|
+
let modal;
|
|
29
|
+
let resource_type = '';
|
|
30
|
+
let step = 1;
|
|
31
|
+
let no_back = false;
|
|
32
|
+
let pathError = '';
|
|
33
|
+
export function open() {
|
|
34
|
+
step = 1;
|
|
35
|
+
value = '';
|
|
36
|
+
resource_type = '';
|
|
37
|
+
no_back = false;
|
|
38
|
+
modal.openModal();
|
|
39
|
+
}
|
|
40
|
+
export function openFromOauth(rt) {
|
|
41
|
+
resource_type = rt;
|
|
42
|
+
value = $oauthStore?.access_token;
|
|
43
|
+
valueToken = $oauthStore;
|
|
44
|
+
$oauthStore = undefined;
|
|
45
|
+
manual = false;
|
|
46
|
+
step = 3;
|
|
47
|
+
no_back = true;
|
|
48
|
+
modal.openModal();
|
|
49
|
+
}
|
|
50
|
+
async function loadConnects() {
|
|
51
|
+
connects = await OauthService.listOAuthConnects();
|
|
52
|
+
}
|
|
53
|
+
async function loadResources() {
|
|
54
|
+
const availableRts = await ResourceService.listResourceTypeNames({
|
|
55
|
+
workspace: $workspaceStore
|
|
56
|
+
});
|
|
57
|
+
connectsManual = Object.entries(apiTokenApps).filter(([key, _]) => availableRts.includes(key));
|
|
58
|
+
}
|
|
59
|
+
async function next() {
|
|
60
|
+
if (step < 3 && manual) {
|
|
61
|
+
step += 1;
|
|
62
|
+
}
|
|
63
|
+
else if (step == 1 && !manual) {
|
|
64
|
+
window.location.href = `/api/oauth/connect/${resource_type}?scopes=${scopes.join('+')}`;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
let exists = await VariableService.existsVariable({
|
|
68
|
+
workspace: $workspaceStore,
|
|
69
|
+
path
|
|
70
|
+
});
|
|
71
|
+
if (exists) {
|
|
72
|
+
throw Error(`Variable at path ${path} already exists. Delete it or pick another path`);
|
|
73
|
+
}
|
|
74
|
+
exists = await ResourceService.existsResource({
|
|
75
|
+
workspace: $workspaceStore,
|
|
76
|
+
path
|
|
77
|
+
});
|
|
78
|
+
if (exists) {
|
|
79
|
+
throw Error(`Resource at path ${path} already exists. Delete it or pick another path`);
|
|
80
|
+
}
|
|
81
|
+
let account = undefined;
|
|
82
|
+
if (valueToken.refresh_token != undefined && valueToken.expires_in != undefined) {
|
|
83
|
+
account = Number(await OauthService.createAccount({
|
|
84
|
+
workspace: $workspaceStore,
|
|
85
|
+
requestBody: {
|
|
86
|
+
refresh_token: valueToken.refresh_token,
|
|
87
|
+
expires_in: valueToken.expires_in,
|
|
88
|
+
owner: path.split('/').slice(0, 2).join('/'),
|
|
89
|
+
client: resource_type
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
await VariableService.createVariable({
|
|
94
|
+
workspace: $workspaceStore,
|
|
95
|
+
requestBody: {
|
|
96
|
+
path,
|
|
97
|
+
value,
|
|
98
|
+
is_secret: true,
|
|
99
|
+
description: `OAuth token for ${resource_type}`,
|
|
100
|
+
is_oauth: true,
|
|
101
|
+
account: account
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
await ResourceService.createResource({
|
|
105
|
+
workspace: $workspaceStore,
|
|
106
|
+
requestBody: {
|
|
107
|
+
resource_type,
|
|
108
|
+
path,
|
|
109
|
+
value: { token: `$var:${path}` },
|
|
110
|
+
description: `OAuth token for ${resource_type}`,
|
|
111
|
+
is_oauth: true
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
dispatch('refresh');
|
|
115
|
+
sendUserToast(`App token set at resource and variable path: ${path}`);
|
|
116
|
+
modal.closeModal();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function back() {
|
|
120
|
+
if (step > 1) {
|
|
121
|
+
step -= 1;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const dispatch = createEventDispatcher();
|
|
125
|
+
$: {
|
|
126
|
+
if ($workspaceStore) {
|
|
127
|
+
loadResources();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
onMount(() => {
|
|
131
|
+
loadConnects();
|
|
132
|
+
});
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<Modal
|
|
136
|
+
bind:this={modal}
|
|
137
|
+
on:close={() => {
|
|
138
|
+
dispatch('close')
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
<div slot="title">Connect an app</div>
|
|
142
|
+
<div slot="content">
|
|
143
|
+
{#if step == 1}
|
|
144
|
+
<PageHeader title="OAuth apps" />
|
|
145
|
+
<div class="grid sm:grid-cols-2 md:grid-cols-3 gap-x-2 gap-y-1 items-center mb-2">
|
|
146
|
+
{#each Object.entries(connects) as [key, values]}
|
|
147
|
+
<button
|
|
148
|
+
class="px-4 h-8 {key == resource_type ? 'item-button-selected' : 'item-button'}"
|
|
149
|
+
on:click={() => {
|
|
150
|
+
manual = false
|
|
151
|
+
resource_type = key
|
|
152
|
+
scopes = values
|
|
153
|
+
dispatch('click')
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
<IconedResourceType name={key} after={true} />
|
|
157
|
+
</button>
|
|
158
|
+
{/each}
|
|
159
|
+
</div>
|
|
160
|
+
<PageHeader title="scopes" primary={false} />
|
|
161
|
+
{#if !manual && resource_type != ''}
|
|
162
|
+
{#each scopes as v}
|
|
163
|
+
<div class="flex flex-row max-w-md">
|
|
164
|
+
<input type="text" bind:value={v} />
|
|
165
|
+
<button
|
|
166
|
+
class="default-button-secondary mx-6"
|
|
167
|
+
on:click={() => {
|
|
168
|
+
scopes = scopes.filter((el) => el != v)
|
|
169
|
+
}}><Icon data={faMinus} class="mb-1" /></button
|
|
170
|
+
>
|
|
171
|
+
</div>
|
|
172
|
+
{/each}
|
|
173
|
+
<button
|
|
174
|
+
class="default-button-secondary mt-1"
|
|
175
|
+
on:click={() => {
|
|
176
|
+
scopes = scopes.concat('')
|
|
177
|
+
}}>Add item <Icon data={faPlus} class="mb-1" /></button
|
|
178
|
+
><span class="ml-2">{(scopes ?? []).length} item(s)</span>
|
|
179
|
+
{:else}
|
|
180
|
+
<p class="italic text-sm">Pick an oauth app and customize the scopes here</p>
|
|
181
|
+
{/if}
|
|
182
|
+
<PageHeader title="API token apps" />
|
|
183
|
+
<div class="grid sm:grid-cols-2 md:grid-cols-3 gap-x-2 gap-y-1 items-center mb-2">
|
|
184
|
+
{#each connectsManual as [key, instructions]}
|
|
185
|
+
<button
|
|
186
|
+
class="px-4 h-8 {key == resource_type ? 'item-button-selected' : 'item-button'}"
|
|
187
|
+
on:click={() => {
|
|
188
|
+
manual = true
|
|
189
|
+
resource_type = key
|
|
190
|
+
dispatch('click')
|
|
191
|
+
}}
|
|
192
|
+
>
|
|
193
|
+
<IconedResourceType name={key} after={true} />
|
|
194
|
+
</button>
|
|
195
|
+
{/each}
|
|
196
|
+
</div>
|
|
197
|
+
{:else if step == 2}
|
|
198
|
+
{#if manual}
|
|
199
|
+
<PageHeader title="Instructions" />
|
|
200
|
+
<div>
|
|
201
|
+
{apiTokenApps[resource_type].instructions}
|
|
202
|
+
</div>
|
|
203
|
+
{#if apiTokenApps[resource_type].img}
|
|
204
|
+
<div class="mt-4">
|
|
205
|
+
<img alt="connect" src={apiTokenApps[resource_type].img} />
|
|
206
|
+
</div>
|
|
207
|
+
{/if}
|
|
208
|
+
<div class="mt-4">
|
|
209
|
+
<Password bind:password={value} label="Paste token here" />
|
|
210
|
+
</div>
|
|
211
|
+
{/if}
|
|
212
|
+
{:else}
|
|
213
|
+
<Path
|
|
214
|
+
bind:error={pathError}
|
|
215
|
+
bind:path
|
|
216
|
+
initialPath={`u/${$userStore?.username ?? ''}/my_${resource_type}`}
|
|
217
|
+
kind="resource"
|
|
218
|
+
/>
|
|
219
|
+
<ul class="mt-10 bg-white">
|
|
220
|
+
<li>
|
|
221
|
+
1. A secret variable containing the token <span class="font-bold"
|
|
222
|
+
>{truncateRev(value, 5, '*****')}</span
|
|
223
|
+
>
|
|
224
|
+
will be stored at
|
|
225
|
+
<span class="font-mono">{path}</span>. You can refer to this variable anywhere this token
|
|
226
|
+
is required.
|
|
227
|
+
</li>
|
|
228
|
+
<li class="mt-4">
|
|
229
|
+
2. A resource with a unique token field will be stored at <span class="font-mono"
|
|
230
|
+
>{path}</span
|
|
231
|
+
>
|
|
232
|
+
and refer to the secret variable <span class="font-mono">{path}</span> as its token (using
|
|
233
|
+
variable templating
|
|
234
|
+
<span class="font-mono">`$var:${path}`</span>). You can refer to this resource anywhere
|
|
235
|
+
this token is required. A script can use the resource type
|
|
236
|
+
<span class="font-mono">{resource_type}</span> as a type parameter to restrict the kind of
|
|
237
|
+
tokens it accepts to this app.
|
|
238
|
+
</li>
|
|
239
|
+
</ul>
|
|
240
|
+
{/if}
|
|
241
|
+
</div>
|
|
242
|
+
<div slot="submission">
|
|
243
|
+
{#if step > 1 && !no_back}
|
|
244
|
+
<button class="default-button px-4 py-2 font-semibold" on:click={back}>Back</button>
|
|
245
|
+
{/if}
|
|
246
|
+
<button
|
|
247
|
+
class="default-button px-4 py-2 font-semibold"
|
|
248
|
+
class:default-button-disabled={(step == 1 && resource_type == '') ||
|
|
249
|
+
(step == 2 && value == '') ||
|
|
250
|
+
(step == 3 && pathError != '')}
|
|
251
|
+
on:click={next}
|
|
252
|
+
>
|
|
253
|
+
{step == 3 ? 'Connect' : 'Next'}
|
|
254
|
+
</button>
|
|
255
|
+
</div>
|
|
256
|
+
</Modal>
|
|
257
|
+
|
|
258
|
+
<style>
|
|
259
|
+
.item-button {
|
|
260
|
+
padding-top: 0.25rem;
|
|
261
|
+
padding-bottom: 0.25rem;
|
|
262
|
+
border-width: 1px;
|
|
263
|
+
border-radius: 0.125rem
|
|
264
|
+
}
|
|
265
|
+
.item-button-selected {
|
|
266
|
+
padding-top: 0.25rem;
|
|
267
|
+
padding-bottom: 0.25rem;
|
|
268
|
+
border-width: 1px;
|
|
269
|
+
--tw-border-opacity: 1;
|
|
270
|
+
border-color: rgb(59 130 246 / var(--tw-border-opacity));
|
|
271
|
+
--tw-bg-opacity: 1;
|
|
272
|
+
background-color: rgb(239 246 255 / var(--tw-bg-opacity));
|
|
273
|
+
border-radius: 0.125rem
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.selected:hover {
|
|
277
|
+
border-radius: 0.375rem;
|
|
278
|
+
border-width: 1px;
|
|
279
|
+
border-color: rgb(156 163 175 / var(--tw-border-opacity));
|
|
280
|
+
--tw-border-opacity: 0.5
|
|
281
|
+
}</style>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
open?: (() => void) | undefined;
|
|
5
|
+
openFromOauth?: ((rt: string) => void) | undefined;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
close: CustomEvent<any>;
|
|
9
|
+
click: CustomEvent<any>;
|
|
10
|
+
} & {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {};
|
|
14
|
+
};
|
|
15
|
+
export declare type AppConnectProps = typeof __propDef.props;
|
|
16
|
+
export declare type AppConnectEvents = typeof __propDef.events;
|
|
17
|
+
export declare type AppConnectSlots = typeof __propDef.slots;
|
|
18
|
+
export default class AppConnect extends SvelteComponentTyped<AppConnectProps, AppConnectEvents, AppConnectSlots> {
|
|
19
|
+
get open(): () => void;
|
|
20
|
+
get openFromOauth(): (rt: string) => void;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -7,6 +7,8 @@ import ResourcePicker from './ResourcePicker.svelte';
|
|
|
7
7
|
import ObjectTypeNarrowing from './ObjectTypeNarrowing.svelte';
|
|
8
8
|
import ObjectResourceInput from './ObjectResourceInput.svelte';
|
|
9
9
|
import FieldHeader from './FieldHeader.svelte';
|
|
10
|
+
import { createEventDispatcher } from 'svelte';
|
|
11
|
+
import { setInputCat as computeInputCat } from '../utils';
|
|
10
12
|
export let label = '';
|
|
11
13
|
export let value;
|
|
12
14
|
export let defaultValue = undefined;
|
|
@@ -15,7 +17,7 @@ export let format = '';
|
|
|
15
17
|
export let contentEncoding = '';
|
|
16
18
|
export let type = undefined;
|
|
17
19
|
export let required = false;
|
|
18
|
-
export let pattern;
|
|
20
|
+
export let pattern = undefined;
|
|
19
21
|
export let valid = required ? false : true;
|
|
20
22
|
export let minRows = 1;
|
|
21
23
|
export let maxRows = 10;
|
|
@@ -24,12 +26,14 @@ export let disabled = false;
|
|
|
24
26
|
export let editableSchema = false;
|
|
25
27
|
export let itemsType = undefined;
|
|
26
28
|
export let displayHeader = true;
|
|
29
|
+
export let numberAsString = false;
|
|
27
30
|
let seeEditable = enum_ != undefined || pattern != undefined;
|
|
31
|
+
const dispatch = createEventDispatcher();
|
|
28
32
|
$: minHeight = `${1 + minRows * 1.2}em`;
|
|
29
33
|
$: maxHeight = maxRows ? `${1 + maxRows * 1.2}em` : `auto`;
|
|
30
34
|
$: validateInput(pattern, value);
|
|
31
35
|
let error = '';
|
|
32
|
-
let rawValue;
|
|
36
|
+
let rawValue = undefined;
|
|
33
37
|
$: {
|
|
34
38
|
if (rawValue) {
|
|
35
39
|
try {
|
|
@@ -41,8 +45,9 @@ $: {
|
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
47
|
$: {
|
|
44
|
-
if (
|
|
48
|
+
if (inputCat === 'object') {
|
|
45
49
|
evalValueToRaw();
|
|
50
|
+
validateInput(pattern, value);
|
|
46
51
|
}
|
|
47
52
|
if (defaultValue) {
|
|
48
53
|
let stringified = JSON.stringify(defaultValue, null, 4);
|
|
@@ -55,7 +60,9 @@ $: {
|
|
|
55
60
|
}
|
|
56
61
|
}
|
|
57
62
|
export function evalValueToRaw() {
|
|
58
|
-
|
|
63
|
+
if (value) {
|
|
64
|
+
rawValue = JSON.stringify(value, null, 4);
|
|
65
|
+
}
|
|
59
66
|
}
|
|
60
67
|
function fileChanged(e, cb) {
|
|
61
68
|
let t = e.target;
|
|
@@ -71,7 +78,7 @@ function fileChanged(e, cb) {
|
|
|
71
78
|
}
|
|
72
79
|
}
|
|
73
80
|
function validateInput(pattern, v) {
|
|
74
|
-
if (required && v == undefined) {
|
|
81
|
+
if (required && (v == undefined || v == null)) {
|
|
75
82
|
error = 'This field is required';
|
|
76
83
|
valid = false;
|
|
77
84
|
}
|
|
@@ -100,6 +107,7 @@ $: {
|
|
|
100
107
|
value = defaultValue;
|
|
101
108
|
}
|
|
102
109
|
}
|
|
110
|
+
export let inputCat = computeInputCat(type, format, itemsType?.type, enum_, contentEncoding);
|
|
103
111
|
</script>
|
|
104
112
|
|
|
105
113
|
<div class="flex flex-col w-full">
|
|
@@ -156,17 +164,18 @@ $: {
|
|
|
156
164
|
</div>
|
|
157
165
|
</div>
|
|
158
166
|
<div class="container">
|
|
159
|
-
{#if
|
|
167
|
+
{#if inputCat == 'number' && !numberAsString}
|
|
160
168
|
<input
|
|
161
169
|
{disabled}
|
|
162
170
|
type="number"
|
|
163
171
|
class={valid
|
|
164
172
|
? ''
|
|
165
173
|
: 'border border-red-700 border-opacity-30 focus:border-red-700 focus:border-opacity-30 bg-red-100'}
|
|
166
|
-
placeholder={defaultValue}
|
|
174
|
+
placeholder={defaultValue ?? ''}
|
|
167
175
|
bind:value
|
|
176
|
+
on:input={() => dispatch('input', { value, isRaw: true })}
|
|
168
177
|
/>
|
|
169
|
-
{:else if
|
|
178
|
+
{:else if inputCat == 'boolean'}
|
|
170
179
|
<input
|
|
171
180
|
{disabled}
|
|
172
181
|
type="checkbox"
|
|
@@ -178,12 +187,12 @@ $: {
|
|
|
178
187
|
{#if type == 'boolean' && value == undefined}
|
|
179
188
|
<span> Not set</span>
|
|
180
189
|
{/if}
|
|
181
|
-
{:else if
|
|
190
|
+
{:else if inputCat == 'list'}
|
|
182
191
|
{#each value ?? [] as v}
|
|
183
192
|
<div class="flex flex-row max-w-md">
|
|
184
|
-
{#if itemsType
|
|
193
|
+
{#if itemsType?.type == 'number'}
|
|
185
194
|
<input type="number" bind:value={v} />
|
|
186
|
-
{:else if itemsType
|
|
195
|
+
{:else if itemsType?.type == 'string' && itemsType?.contentEncoding == 'base64'}
|
|
187
196
|
<input
|
|
188
197
|
type="file"
|
|
189
198
|
class="my-6"
|
|
@@ -213,49 +222,50 @@ $: {
|
|
|
213
222
|
value = value.concat('')
|
|
214
223
|
}}>Add item <Icon data={faPlus} class="mb-1" /></button
|
|
215
224
|
><span class="ml-2">{(value ?? []).length} item(s)</span>
|
|
216
|
-
{:else if
|
|
225
|
+
{:else if inputCat == 'resource-object'}
|
|
217
226
|
<ObjectResourceInput {format} bind:value />
|
|
218
|
-
{:else if
|
|
227
|
+
{:else if inputCat == 'object'}
|
|
219
228
|
<textarea
|
|
220
229
|
{disabled}
|
|
221
230
|
style="min-height: {minHeight}; max-height: {maxHeight}"
|
|
222
231
|
class="col-span-10 {valid
|
|
223
232
|
? ''
|
|
224
233
|
: 'border border-red-700 border-opacity-30 focus:border-red-700 focus:border-opacity-30 bg-red-100'}"
|
|
225
|
-
placeholder={JSON.stringify(defaultValue, null, 4)}
|
|
234
|
+
placeholder={defaultValue ? JSON.stringify(defaultValue, null, 4) : ''}
|
|
226
235
|
bind:value={rawValue}
|
|
227
236
|
/>
|
|
228
|
-
{:else if
|
|
237
|
+
{:else if inputCat == 'enum'}
|
|
229
238
|
<select {disabled} class="px-6" bind:value>
|
|
230
|
-
{#each enum_ as e}
|
|
239
|
+
{#each enum_ ?? [] as e}
|
|
231
240
|
<option>{e}</option>
|
|
232
241
|
{/each}
|
|
233
242
|
</select>
|
|
234
|
-
{:else if
|
|
243
|
+
{:else if inputCat == 'date'}
|
|
235
244
|
<input class="inline-block" type="datetime-local" bind:value />
|
|
236
|
-
{:else if
|
|
245
|
+
{:else if inputCat == 'base64'}
|
|
237
246
|
<input
|
|
238
247
|
type="file"
|
|
239
248
|
class="my-6"
|
|
240
249
|
on:change={(x) => fileChanged(x, (val) => (value = val))}
|
|
241
250
|
multiple={false}
|
|
242
251
|
/>
|
|
243
|
-
{:else if
|
|
252
|
+
{:else if inputCat == 'resource-string'}
|
|
244
253
|
<ResourcePicker
|
|
245
254
|
bind:value
|
|
246
255
|
resourceType={format.split('-').length > 1
|
|
247
256
|
? format.substring('resource-'.length)
|
|
248
257
|
: undefined}
|
|
249
258
|
/>
|
|
250
|
-
{:else}
|
|
259
|
+
{:else if inputCat == 'string'}
|
|
251
260
|
<textarea
|
|
252
261
|
{disabled}
|
|
253
262
|
style="height: {minHeight}; max-height: {maxHeight}"
|
|
254
263
|
class="col-span-10 {valid
|
|
255
264
|
? ''
|
|
256
265
|
: 'border border-red-700 border-opacity-30 focus:border-red-700 focus:border-opacity-30 bg-red-100'}"
|
|
257
|
-
placeholder={defaultValue}
|
|
266
|
+
placeholder={defaultValue ?? ''}
|
|
258
267
|
bind:value
|
|
268
|
+
on:input={() => dispatch('input', { rawValue: value, isRaw: false })}
|
|
259
269
|
/>
|
|
260
270
|
{/if}
|
|
261
271
|
{#if !required}
|
|
@@ -264,9 +274,7 @@ $: {
|
|
|
264
274
|
{disabled}
|
|
265
275
|
class="default-button-secondary items-center leading-4 py-0 my-px px-1 float-right"
|
|
266
276
|
on:click={() => (value = undefined)}
|
|
267
|
-
>Reset<Tooltip
|
|
268
|
-
>Reset to default value
|
|
269
|
-
</Tooltip></button
|
|
277
|
+
>Reset<Tooltip>Reset to default value</Tooltip></button
|
|
270
278
|
>
|
|
271
279
|
</div>
|
|
272
280
|
{/if}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { type InputCat } from '../utils';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
label?: string | undefined;
|
|
@@ -9,7 +10,7 @@ declare const __propDef: {
|
|
|
9
10
|
contentEncoding?: string | undefined;
|
|
10
11
|
type?: string | undefined;
|
|
11
12
|
required?: boolean | undefined;
|
|
12
|
-
pattern
|
|
13
|
+
pattern?: undefined | string;
|
|
13
14
|
valid?: boolean | undefined;
|
|
14
15
|
minRows?: number | undefined;
|
|
15
16
|
maxRows?: number | undefined;
|
|
@@ -21,9 +22,13 @@ declare const __propDef: {
|
|
|
21
22
|
contentEncoding?: "base64" | undefined;
|
|
22
23
|
} | undefined;
|
|
23
24
|
displayHeader?: boolean | undefined;
|
|
25
|
+
numberAsString?: boolean | undefined;
|
|
24
26
|
evalValueToRaw?: (() => void) | undefined;
|
|
27
|
+
inputCat?: InputCat | undefined;
|
|
25
28
|
};
|
|
26
29
|
events: {
|
|
30
|
+
input: CustomEvent<any>;
|
|
31
|
+
} & {
|
|
27
32
|
[evt: string]: CustomEvent<any>;
|
|
28
33
|
};
|
|
29
34
|
slots: {};
|
package/components/Button.svelte
CHANGED
|
@@ -49,32 +49,41 @@ const dispatch = createEventDispatcher();
|
|
|
49
49
|
</button>
|
|
50
50
|
|
|
51
51
|
<style>
|
|
52
|
-
.delete,
|
|
52
|
+
.delete,
|
|
53
|
+
.archive {
|
|
53
54
|
background-color: transparent
|
|
54
55
|
}
|
|
55
|
-
.delete:hover,
|
|
56
|
+
.delete:hover,
|
|
57
|
+
.archive:hover {
|
|
56
58
|
--tw-bg-opacity: 1;
|
|
57
59
|
background-color: rgb(220 38 38 / var(--tw-bg-opacity))
|
|
58
60
|
}
|
|
59
|
-
.delete,
|
|
61
|
+
.delete,
|
|
62
|
+
.archive {
|
|
60
63
|
font-weight: 400;
|
|
61
64
|
--tw-text-opacity: 1;
|
|
62
65
|
color: rgb(220 38 38 / var(--tw-text-opacity))
|
|
63
66
|
}
|
|
64
|
-
.delete:hover,
|
|
67
|
+
.delete:hover,
|
|
68
|
+
.archive:hover {
|
|
65
69
|
--tw-text-opacity: 1;
|
|
66
70
|
color: rgb(255 255 255 / var(--tw-text-opacity))
|
|
67
71
|
}
|
|
68
|
-
.delete,
|
|
72
|
+
.delete,
|
|
73
|
+
.archive {
|
|
69
74
|
border-radius: 0.25rem;
|
|
70
75
|
--tw-border-opacity: 1;
|
|
71
76
|
border-color: rgb(220 38 38 / var(--tw-border-opacity))
|
|
72
77
|
}
|
|
73
|
-
.delete:hover,
|
|
78
|
+
.delete:hover,
|
|
79
|
+
.archive:hover {
|
|
74
80
|
border-color: transparent
|
|
75
81
|
}
|
|
76
82
|
|
|
77
|
-
.edit:hover,
|
|
83
|
+
.edit:hover,
|
|
84
|
+
.play:hover,
|
|
85
|
+
.list:hover,
|
|
86
|
+
.share:hover {
|
|
78
87
|
--tw-bg-opacity: 1;
|
|
79
88
|
background-color: rgb(59 130 246 / var(--tw-bg-opacity));
|
|
80
89
|
--tw-text-opacity: 1;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script>import { SettingsService } from '../gen';
|
|
2
|
+
export let subtitle = undefined;
|
|
3
|
+
export let title = 'Welcome to Windmill (beta)';
|
|
4
|
+
let version = '';
|
|
5
|
+
SettingsService.backendVersion().then((x) => {
|
|
6
|
+
version = x;
|
|
7
|
+
});
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<div class="flex justify-center min-h-screen bg-gray-50 pt-10">
|
|
11
|
+
<div class="w-10/12 md:w-7/12 lg:w-6/12 xl:4/12 m-auto">
|
|
12
|
+
<h1 class="justify-center text-center font-medium pb-2 text-gray-700">
|
|
13
|
+
{title}
|
|
14
|
+
</h1>
|
|
15
|
+
{#if subtitle}
|
|
16
|
+
<p class="justify-center text-center font-medium pb-2 text-gray-700 text-xs">
|
|
17
|
+
{subtitle}
|
|
18
|
+
</p>
|
|
19
|
+
{/if}
|
|
20
|
+
<div class="border rounded-md py-12 px-16 shadow-md bg-white">
|
|
21
|
+
<slot />
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<!-- empty row to make the form a little bit above vertical centering-->
|
|
25
|
+
<div class="py-12" />
|
|
26
|
+
</div>
|
|
27
|
+
<div class="absolute top-0 right-0 text-2xs text-gray-500 italic px-3 py-1">
|
|
28
|
+
windmill.dev backend v. <span class="font-mono">{version}</span>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
subtitle?: string | undefined;
|
|
5
|
+
title?: string | undefined;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {
|
|
11
|
+
default: {};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare type CenteredModalProps = typeof __propDef.props;
|
|
15
|
+
export declare type CenteredModalEvents = typeof __propDef.events;
|
|
16
|
+
export declare type CenteredModalSlots = typeof __propDef.slots;
|
|
17
|
+
export default class CenteredModal extends SvelteComponentTyped<CenteredModalProps, CenteredModalEvents, CenteredModalSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|