windmill-components 1.13.0
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/LICENSE +661 -0
- package/common.d.ts +29 -0
- package/components/ArgInfo.svelte +48 -0
- package/components/ArgInput.svelte +277 -0
- package/components/AutosizedTextarea.svelte +34 -0
- package/components/Badge.svelte +12 -0
- package/components/Button.svelte +82 -0
- package/components/ButtonAndDropdown.svelte +25 -0
- package/components/CenteredPage.svelte +5 -0
- package/components/ChevronButton.svelte +21 -0
- package/components/DisplayResult.svelte +101 -0
- package/components/Dropdown.svelte +108 -0
- package/components/Editor.svelte +370 -0
- package/components/FieldHeader.svelte +21 -0
- package/components/FlowBuilder.svelte +202 -0
- package/components/FlowEditor.svelte +95 -0
- package/components/FlowPreview.svelte +141 -0
- package/components/FlowStatusViewer.svelte +137 -0
- package/components/GroupModal.svelte +90 -0
- package/components/IconedResourceType.svelte +32 -0
- package/components/InviteGlobalUser.svelte +56 -0
- package/components/InviteUser.svelte +48 -0
- package/components/ItemPicker.svelte +58 -0
- package/components/JobStatus.svelte +38 -0
- package/components/Modal.svelte +94 -0
- package/components/ModuleStep.svelte +64 -0
- package/components/Multiselect.svelte +327 -0
- package/components/ObjectResourceInput.svelte +62 -0
- package/components/ObjectTypeNarrowing.svelte +25 -0
- package/components/PageHeader.svelte +29 -0
- package/components/Password.svelte +45 -0
- package/components/Path.svelte +129 -0
- package/components/RadioButton.svelte +117 -0
- package/components/Required.svelte +11 -0
- package/components/ResourceEditor.svelte +260 -0
- package/components/ResourcePicker.svelte +21 -0
- package/components/ResourceTypePicker.svelte +71 -0
- package/components/RunForm.svelte +127 -0
- package/components/SchemaEditor.svelte +221 -0
- package/components/SchemaForm.svelte +166 -0
- package/components/SchemaModal.svelte +160 -0
- package/components/SchemaViewer.svelte +76 -0
- package/components/ScriptBuilder.svelte +293 -0
- package/components/ScriptEditor.svelte +669 -0
- package/components/ScriptPicker.svelte +110 -0
- package/components/ScriptSchema.svelte +71 -0
- package/components/ShareModal.svelte +135 -0
- package/components/SharedBadge.svelte +54 -0
- package/components/StringTypeNarrowing.svelte +101 -0
- package/components/Switch.svelte +61 -0
- package/components/TableCustom.svelte +39 -0
- package/components/TableSimple.svelte +66 -0
- package/components/Tabs.svelte +21 -0
- package/components/Tooltip.svelte +93 -0
- package/components/VariableEditor.svelte +159 -0
- package/components/icons/DbIcon.svelte +12 -0
- package/components/icons/Mail.svelte +62 -0
- package/components/icons/Mysql.svelte +77 -0
- package/components/icons/PostgresIcon.svelte +57 -0
- package/components/icons/Slack.svelte +26 -0
- package/gen/core/ApiError.d.ts +8 -0
- package/gen/core/ApiRequestOptions.d.ts +13 -0
- package/gen/core/ApiResult.d.ts +7 -0
- package/gen/core/CancelablePromise.d.ts +26 -0
- package/gen/core/OpenAPI.d.ts +16 -0
- package/gen/core/request.d.ts +13 -0
- package/gen/index.d.ts +59 -0
- package/gen/models/AuditLog.d.ts +32 -0
- package/gen/models/CompletedJob.d.ts +48 -0
- package/gen/models/ContextualVariable.d.ts +5 -0
- package/gen/models/CreateResource.d.ts +6 -0
- package/gen/models/CreateVariable.d.ts +6 -0
- package/gen/models/CreateWorkspace.d.ts +6 -0
- package/gen/models/EditResource.d.ts +5 -0
- package/gen/models/EditResourceType.d.ts +4 -0
- package/gen/models/EditSchedule.d.ts +7 -0
- package/gen/models/EditVariable.d.ts +6 -0
- package/gen/models/EditWorkspaceUser.d.ts +3 -0
- package/gen/models/Flow.d.ts +13 -0
- package/gen/models/FlowModule.d.ts +6 -0
- package/gen/models/FlowModuleValue.d.ts +10 -0
- package/gen/models/FlowPreview.d.ts +7 -0
- package/gen/models/FlowStatus.d.ts +6 -0
- package/gen/models/FlowStatusModule.d.ts +15 -0
- package/gen/models/FlowValue.d.ts +5 -0
- package/gen/models/GlobalUserInfo.d.ts +14 -0
- package/gen/models/Group.d.ts +6 -0
- package/gen/models/InputTransform.d.ts +12 -0
- package/gen/models/Job.d.ts +11 -0
- package/gen/models/ListableVariable.d.ts +8 -0
- package/gen/models/Login.d.ts +4 -0
- package/gen/models/MainArgSignature.d.ts +14 -0
- package/gen/models/NewSchedule.d.ts +9 -0
- package/gen/models/NewToken.d.ts +4 -0
- package/gen/models/NewUser.d.ts +5 -0
- package/gen/models/Preview.d.ts +13 -0
- package/gen/models/QueuedJob.d.ts +47 -0
- package/gen/models/Resource.d.ts +8 -0
- package/gen/models/ResourceType.d.ts +6 -0
- package/gen/models/Schedule.d.ts +13 -0
- package/gen/models/Script.d.ts +29 -0
- package/gen/models/ScriptArgs.d.ts +1 -0
- package/gen/models/TruncatedToken.d.ts +7 -0
- package/gen/models/User.d.ts +10 -0
- package/gen/models/UserWorkspaceList.d.ts +8 -0
- package/gen/models/WorkerPing.d.ts +8 -0
- package/gen/models/Workspace.d.ts +6 -0
- package/gen/models/WorkspaceInvite.d.ts +5 -0
- package/gen/services/AdminService.d.ts +35 -0
- package/gen/services/AuditService.d.ts +37 -0
- package/gen/services/FlowService.d.ts +82 -0
- package/gen/services/GranularAclService.d.ts +42 -0
- package/gen/services/GroupService.d.ts +94 -0
- package/gen/services/JobService.d.ts +217 -0
- package/gen/services/ResourceService.d.ts +116 -0
- package/gen/services/ScheduleService.d.ts +73 -0
- package/gen/services/ScriptService.d.ts +165 -0
- package/gen/services/SettingsService.d.ts +15 -0
- package/gen/services/UserService.d.ts +211 -0
- package/gen/services/VariableService.d.ts +66 -0
- package/gen/services/WorkerService.d.ts +15 -0
- package/gen/services/WorkspaceService.d.ts +137 -0
- package/infer.d.ts +2 -0
- package/lib/components/ArgInfo.svelte.d.ts +16 -0
- package/lib/components/ArgInput.svelte.d.ts +37 -0
- package/lib/components/AutosizedTextarea.svelte.d.ts +19 -0
- package/lib/components/Badge.svelte.d.ts +20 -0
- package/lib/components/Button.svelte.d.ts +23 -0
- package/lib/components/ButtonAndDropdown.svelte.d.ts +23 -0
- package/lib/components/CenteredPage.svelte.d.ts +23 -0
- package/lib/components/ChevronButton.svelte.d.ts +19 -0
- package/lib/components/DisplayResult.svelte.d.ts +16 -0
- package/lib/components/Dropdown.svelte.d.ts +22 -0
- package/lib/components/Editor.svelte.d.ts +38 -0
- package/lib/components/FieldHeader.svelte.d.ts +23 -0
- package/lib/components/FlowBuilder.svelte.d.ts +18 -0
- package/lib/components/FlowEditor.svelte.d.ts +19 -0
- package/lib/components/FlowPreview.svelte.d.ts +21 -0
- package/lib/components/FlowStatusViewer.svelte.d.ts +18 -0
- package/lib/components/GroupModal.svelte.d.ts +17 -0
- package/lib/components/IconedResourceType.svelte.d.ts +19 -0
- package/lib/components/InviteGlobalUser.svelte.d.ts +19 -0
- package/lib/components/InviteUser.svelte.d.ts +19 -0
- package/lib/components/ItemPicker.svelte.d.ts +24 -0
- package/lib/components/JobStatus.svelte.d.ts +17 -0
- package/lib/components/Modal.svelte.d.ts +28 -0
- package/lib/components/ModuleStep.svelte.d.ts +26 -0
- package/lib/components/Multiselect.svelte.d.ts +33 -0
- package/lib/components/ObjectResourceInput.svelte.d.ts +17 -0
- package/lib/components/ObjectTypeNarrowing.svelte.d.ts +16 -0
- package/lib/components/PageHeader.svelte.d.ts +20 -0
- package/lib/components/Password.svelte.d.ts +18 -0
- package/lib/components/Path.svelte.d.ts +26 -0
- package/lib/components/RadioButton.svelte.d.ts +21 -0
- package/lib/components/Required.svelte.d.ts +17 -0
- package/lib/components/ResourceEditor.svelte.d.ts +22 -0
- package/lib/components/ResourcePicker.svelte.d.ts +17 -0
- package/lib/components/ResourceTypePicker.svelte.d.ts +19 -0
- package/lib/components/RunForm.svelte.d.ts +22 -0
- package/lib/components/SchemaEditor.svelte.d.ts +22 -0
- package/lib/components/SchemaForm.svelte.d.ts +23 -0
- package/lib/components/SchemaModal.svelte.d.ts +44 -0
- package/lib/components/SchemaViewer.svelte.d.ts +17 -0
- package/lib/components/ScriptBuilder.svelte.d.ts +20 -0
- package/lib/components/ScriptEditor.svelte.d.ts +28 -0
- package/lib/components/ScriptPicker.svelte.d.ts +21 -0
- package/lib/components/ScriptSchema.svelte.d.ts +22 -0
- package/lib/components/ShareModal.svelte.d.ts +21 -0
- package/lib/components/SharedBadge.svelte.d.ts +17 -0
- package/lib/components/StringTypeNarrowing.svelte.d.ts +18 -0
- package/lib/components/Switch.svelte.d.ts +31 -0
- package/lib/components/TableCustom.svelte.d.ts +25 -0
- package/lib/components/TableSimple.svelte.d.ts +24 -0
- package/lib/components/Tabs.svelte.d.ts +20 -0
- package/lib/components/Tooltip.svelte.d.ts +20 -0
- package/lib/components/VariableEditor.svelte.d.ts +21 -0
- package/lib/components/icons/DbIcon.svelte.d.ts +17 -0
- package/lib/components/icons/Mail.svelte.d.ts +17 -0
- package/lib/components/icons/Mysql.svelte.d.ts +17 -0
- package/lib/components/icons/PostgresIcon.svelte.d.ts +17 -0
- package/lib/components/icons/Slack.svelte.d.ts +17 -0
- package/package.json +110 -0
- package/stores.d.ts +19 -0
- package/utils.d.ts +60 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script>import { faCalendar, faCircle, faClock, faHourglassHalf, faTimes } from '@fortawesome/free-solid-svg-icons';
|
|
2
|
+
import { displayDate, forLater } from '../../utils';
|
|
3
|
+
import Icon from 'svelte-awesome';
|
|
4
|
+
import { check } from 'svelte-awesome/icons';
|
|
5
|
+
const SMALL_ICON_SCALE = 0.7;
|
|
6
|
+
export let job;
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
{#if job && 'success' in job && job.success}
|
|
10
|
+
<Icon class="text-green-600" data={check} scale={SMALL_ICON_SCALE} />
|
|
11
|
+
<span class="mx-2">Succeeded</span>
|
|
12
|
+
<div>
|
|
13
|
+
<Icon class="text-gray-700" data={faHourglassHalf} scale={SMALL_ICON_SCALE} /><span class="mx-2"
|
|
14
|
+
>Job ran in {job.duration}
|
|
15
|
+
s</span
|
|
16
|
+
>
|
|
17
|
+
</div>
|
|
18
|
+
{:else if job && 'success' in job}
|
|
19
|
+
<Icon class="text-red-700" data={faTimes} scale={SMALL_ICON_SCALE} />
|
|
20
|
+
<span class="mx-2">Failed</span>
|
|
21
|
+
<div>
|
|
22
|
+
<Icon class="text-gray-700" data={faHourglassHalf} scale={SMALL_ICON_SCALE} /><span class="mx-2"
|
|
23
|
+
>Job ran in {job.duration}
|
|
24
|
+
s</span
|
|
25
|
+
>
|
|
26
|
+
</div>
|
|
27
|
+
{:else if job && 'running' in job && job.running}
|
|
28
|
+
<Icon class="text-yellow-500" data={faCircle} scale={SMALL_ICON_SCALE} />
|
|
29
|
+
<span class="mx-2">Running</span>
|
|
30
|
+
{:else if job && 'running' in job && 'scheduled_for' in job && job.scheduled_for && forLater(job.scheduled_for)}
|
|
31
|
+
<Icon class="text-gray-700" data={faCalendar} scale={SMALL_ICON_SCALE} />
|
|
32
|
+
<span class="mx-2">Scheduled for {displayDate(job.scheduled_for)}</span>
|
|
33
|
+
{:else if job && 'running' in job}
|
|
34
|
+
<Icon class="text-gray-700" data={faClock} scale={SMALL_ICON_SCALE} />
|
|
35
|
+
<span class="mx-2">Queued</span>
|
|
36
|
+
{:else}
|
|
37
|
+
<Icon class="text-gray-200" data={faCircle} scale={SMALL_ICON_SCALE} />
|
|
38
|
+
{/if}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from 'svelte';
|
|
2
|
+
export let open = false;
|
|
3
|
+
export let z = 'z-30';
|
|
4
|
+
const dispatch = createEventDispatcher();
|
|
5
|
+
export function closeModal() {
|
|
6
|
+
open = false;
|
|
7
|
+
dispatch('close');
|
|
8
|
+
}
|
|
9
|
+
export function openModal() {
|
|
10
|
+
open = true;
|
|
11
|
+
dispatch('open');
|
|
12
|
+
}
|
|
13
|
+
function handleKeyUp(event) {
|
|
14
|
+
const key = event.key || event.keyCode;
|
|
15
|
+
if (key === 27 || key === 'Escape' || key === 'Esc') {
|
|
16
|
+
if (open) {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
closeModal();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<svelte:window on:keyup={handleKeyUp} />
|
|
25
|
+
|
|
26
|
+
<div class="blurred-background z-0 {open ? '' : 'hidden'}" />
|
|
27
|
+
|
|
28
|
+
<div class="fixed top-0 w-screen h-screen {open ? '' : 'hidden'} {z}">
|
|
29
|
+
<div
|
|
30
|
+
class="fixed right-0 flex flex-col w-3/4 sm:w-2/3 lg:w-1/2 h-screen border border-gray-300 shadow-xl"
|
|
31
|
+
>
|
|
32
|
+
{#if open}
|
|
33
|
+
<div class="flex flex-row justify-between p-2 bg-white border-b border-gray-200">
|
|
34
|
+
<button
|
|
35
|
+
on:click={() => {
|
|
36
|
+
open = false
|
|
37
|
+
closeModal()
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
<svg
|
|
41
|
+
class="w-6 h-6"
|
|
42
|
+
fill="none"
|
|
43
|
+
stroke="currentColor"
|
|
44
|
+
viewBox="0 0 24 24"
|
|
45
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
46
|
+
>
|
|
47
|
+
<path
|
|
48
|
+
stroke-linecap="round"
|
|
49
|
+
stroke-linejoin="round"
|
|
50
|
+
stroke-width="2"
|
|
51
|
+
d="M6 18L18 6M6 6l12 12"
|
|
52
|
+
/>
|
|
53
|
+
</svg>
|
|
54
|
+
</button>
|
|
55
|
+
<p class="font-semibold text-gray-800"><slot name="title" /></p>
|
|
56
|
+
<div />
|
|
57
|
+
</div>
|
|
58
|
+
<div class="flex flex-col bg-gray-50 pt-3 px-6 grow overflow-y-auto">
|
|
59
|
+
<slot name="content" />
|
|
60
|
+
</div>
|
|
61
|
+
<div class="flex flex-col bg-white border-gray-200 p-2">
|
|
62
|
+
<div class="flex flex-row justify-between p-2 ">
|
|
63
|
+
<button
|
|
64
|
+
on:click={() => {
|
|
65
|
+
closeModal()
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
<svg
|
|
69
|
+
class="w-6 h-6"
|
|
70
|
+
fill="none"
|
|
71
|
+
stroke="currentColor"
|
|
72
|
+
viewBox="0 0 24 24"
|
|
73
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
74
|
+
>
|
|
75
|
+
<path
|
|
76
|
+
stroke-linecap="round"
|
|
77
|
+
stroke-linejoin="round"
|
|
78
|
+
stroke-width="2"
|
|
79
|
+
d="M6 18L18 6M6 6l12 12"
|
|
80
|
+
/>
|
|
81
|
+
</svg>
|
|
82
|
+
</button>
|
|
83
|
+
<span class="mr-4"><slot name="submission"> </slot></span>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
{/if}
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<style>
|
|
91
|
+
.blurred-background {
|
|
92
|
+
/* @apply absolute sm:top-6 lg:top-8 left-28 sm:left-40 md:left-48; */ /* If we wanted to make the navbars visible */ position: fixed; top: 0px; left: 0px; --tw-bg-opacity: 1; background-color: rgb(156 163 175 / var(--tw-bg-opacity)); opacity: 0.75; width: 100vw; height: 100vh;
|
|
93
|
+
z-index: 1;
|
|
94
|
+
}</style>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script>import SchemaForm from './SchemaForm.svelte';
|
|
2
|
+
import ScriptPicker from './ScriptPicker.svelte';
|
|
3
|
+
import { emptySchema, loadSchema as UloadSchema } from '../../utils';
|
|
4
|
+
import FlowPreview from './FlowPreview.svelte';
|
|
5
|
+
export let flow;
|
|
6
|
+
export let i;
|
|
7
|
+
export let mod;
|
|
8
|
+
export let args = {};
|
|
9
|
+
export let schemas = [];
|
|
10
|
+
export let schemaForms = [];
|
|
11
|
+
export async function loadSchema() {
|
|
12
|
+
if (mod.value.path) {
|
|
13
|
+
let schema = await UloadSchema(mod.value.path);
|
|
14
|
+
if (JSON.stringify(Object.keys(schema?.properties ?? {}).sort()) !=
|
|
15
|
+
JSON.stringify(Object.keys(mod.input_transform).sort())) {
|
|
16
|
+
let it = {};
|
|
17
|
+
Object.keys(schema?.properties ?? {}).map((x) => (it[x] = {
|
|
18
|
+
type: 'static',
|
|
19
|
+
value: ''
|
|
20
|
+
}));
|
|
21
|
+
schemaForms[i]?.setArgs(it);
|
|
22
|
+
}
|
|
23
|
+
schemas[i] = schema ?? emptySchema();
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
schemaForms[i]?.setArgs({});
|
|
27
|
+
schemas[i] = emptySchema();
|
|
28
|
+
}
|
|
29
|
+
schemas = schemas;
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<li class="flex flex-row flex-shrink max-w-full mx-auto mt-20">
|
|
34
|
+
<div class="bg-white border border-gray xl-rounded shadow-lg w-full max-w-3xl mx-4 md:mx-auto">
|
|
35
|
+
<div
|
|
36
|
+
class="flex items-center justify-between flex-wra px-4 py-5 border-b border-gray-200 sm:px-6"
|
|
37
|
+
>
|
|
38
|
+
<h3 class="text-lg leading-6 font-medium text-gray-900">Step {i + 1}</h3>
|
|
39
|
+
<button
|
|
40
|
+
class="text-xs default-button-secondary max-h-6 place-self-end"
|
|
41
|
+
on:click={() => {
|
|
42
|
+
flow.value.modules.splice(i, 1)
|
|
43
|
+
schemas.splice(i, 1)
|
|
44
|
+
schemaForms.splice(i, 1)
|
|
45
|
+
flow = flow
|
|
46
|
+
}}
|
|
47
|
+
>Remove this step
|
|
48
|
+
</button>
|
|
49
|
+
</div>
|
|
50
|
+
<div class="p-10">
|
|
51
|
+
<h2 class="mb-4">Step script</h2>
|
|
52
|
+
<ScriptPicker allowHub={true} bind:scriptPath={mod.value.path} on:select={loadSchema} />
|
|
53
|
+
<div class="my-4" />
|
|
54
|
+
<h2 class="mb-4">Step inputs</h2>
|
|
55
|
+
<SchemaForm
|
|
56
|
+
bind:this={schemaForms[i]}
|
|
57
|
+
inputTransform={true}
|
|
58
|
+
schema={schemas[i]}
|
|
59
|
+
bind:args={mod.input_transform}
|
|
60
|
+
/>
|
|
61
|
+
<FlowPreview {flow} {i} bind:args {schemas} />
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</li>
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
import { onMount } from 'svelte'
|
|
4
|
+
import { fly } from 'svelte/transition'
|
|
5
|
+
export let id = ''
|
|
6
|
+
export let value = []
|
|
7
|
+
export let readonly = false
|
|
8
|
+
export let placeholder = ''
|
|
9
|
+
|
|
10
|
+
let input,
|
|
11
|
+
inputValue,
|
|
12
|
+
options = [],
|
|
13
|
+
activeOption,
|
|
14
|
+
showOptions = false,
|
|
15
|
+
selected = {},
|
|
16
|
+
first = true,
|
|
17
|
+
slot
|
|
18
|
+
const iconClearPath =
|
|
19
|
+
'M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'
|
|
20
|
+
|
|
21
|
+
onMount(() => {
|
|
22
|
+
slot.querySelectorAll('option').forEach((o) => {
|
|
23
|
+
o.selected && !value.includes(o.value) && (value = [...value, o.value])
|
|
24
|
+
options = [...options, { value: o.value, name: o.textContent }]
|
|
25
|
+
})
|
|
26
|
+
value &&
|
|
27
|
+
(selected = options.reduce(
|
|
28
|
+
(obj, op) => (value.includes(op.value) ? { ...obj, [op.value]: op } : obj),
|
|
29
|
+
{}
|
|
30
|
+
))
|
|
31
|
+
first = false
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
$: if (!first) value = Object.values(selected).map((o) => o.value)
|
|
35
|
+
$: filtered = options.filter((o) =>
|
|
36
|
+
inputValue ? o.name.toLowerCase().includes(inputValue.toLowerCase()) : o
|
|
37
|
+
)
|
|
38
|
+
$: if ((activeOption && !filtered.includes(activeOption)) || (!activeOption && inputValue))
|
|
39
|
+
activeOption = filtered[0]
|
|
40
|
+
|
|
41
|
+
function add(token) {
|
|
42
|
+
if (!readonly) selected[token.value] = token
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function remove(value) {
|
|
46
|
+
if (!readonly) {
|
|
47
|
+
const { [value]: val, ...rest } = selected
|
|
48
|
+
selected = rest
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function optionsVisibility(show) {
|
|
53
|
+
if (readonly) return
|
|
54
|
+
if (typeof show === 'boolean') {
|
|
55
|
+
showOptions = show
|
|
56
|
+
show && input.focus()
|
|
57
|
+
} else {
|
|
58
|
+
showOptions = !showOptions
|
|
59
|
+
}
|
|
60
|
+
if (!showOptions) {
|
|
61
|
+
activeOption = undefined
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function handleKeyup(e) {
|
|
66
|
+
if (e.keyCode === 13) {
|
|
67
|
+
Object.keys(selected).includes(activeOption.value)
|
|
68
|
+
? remove(activeOption.value)
|
|
69
|
+
: add(activeOption)
|
|
70
|
+
inputValue = ''
|
|
71
|
+
}
|
|
72
|
+
if ([38, 40].includes(e.keyCode)) {
|
|
73
|
+
// up and down arrows
|
|
74
|
+
const increment = e.keyCode === 38 ? -1 : 1
|
|
75
|
+
const calcIndex = filtered.indexOf(activeOption) + increment
|
|
76
|
+
activeOption =
|
|
77
|
+
calcIndex < 0
|
|
78
|
+
? filtered[filtered.length - 1]
|
|
79
|
+
: calcIndex === filtered.length
|
|
80
|
+
? filtered[0]
|
|
81
|
+
: filtered[calcIndex]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function handleBlur(e) {
|
|
86
|
+
optionsVisibility(false)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function handleTokenClick(e) {
|
|
90
|
+
if (e.target.closest('.token-remove')) {
|
|
91
|
+
e.stopPropagation()
|
|
92
|
+
remove(e.target.closest('.token').dataset.id)
|
|
93
|
+
} else if (e.target.closest('.remove-all')) {
|
|
94
|
+
selected = []
|
|
95
|
+
inputValue = ''
|
|
96
|
+
} else {
|
|
97
|
+
optionsVisibility(true)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function handleOptionMousedown(e) {
|
|
102
|
+
const value = e.target.dataset.value
|
|
103
|
+
if (selected[value]) {
|
|
104
|
+
remove(value)
|
|
105
|
+
} else {
|
|
106
|
+
add(options.filter((o) => o.value === value)[0])
|
|
107
|
+
input.focus()
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
</script>
|
|
111
|
+
|
|
112
|
+
<div class="multiselect" class:readonly>
|
|
113
|
+
<div class="tokens" class:showOptions on:click={handleTokenClick}>
|
|
114
|
+
{#each Object.values(selected) as s}
|
|
115
|
+
<div class="token" data-id={s.value}>
|
|
116
|
+
<span>{s.name}</span>
|
|
117
|
+
{#if !readonly}
|
|
118
|
+
<div class="token-remove" title="Remove {s.name}">
|
|
119
|
+
<svg
|
|
120
|
+
class="icon-clear"
|
|
121
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
122
|
+
width="18"
|
|
123
|
+
height="18"
|
|
124
|
+
viewBox="0 0 24 24"
|
|
125
|
+
>
|
|
126
|
+
<path d={iconClearPath} />
|
|
127
|
+
</svg>
|
|
128
|
+
</div>
|
|
129
|
+
{/if}
|
|
130
|
+
</div>
|
|
131
|
+
{/each}
|
|
132
|
+
<div class="actions">
|
|
133
|
+
{#if !readonly}
|
|
134
|
+
<input
|
|
135
|
+
{id}
|
|
136
|
+
autocomplete="off"
|
|
137
|
+
bind:value={inputValue}
|
|
138
|
+
bind:this={input}
|
|
139
|
+
on:keyup={handleKeyup}
|
|
140
|
+
on:blur={handleBlur}
|
|
141
|
+
{placeholder}
|
|
142
|
+
/>
|
|
143
|
+
<div class="remove-all" title="Remove All" class:hidden={!Object.keys(selected).length}>
|
|
144
|
+
<svg
|
|
145
|
+
class="icon-clear"
|
|
146
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
147
|
+
width="18"
|
|
148
|
+
height="18"
|
|
149
|
+
viewBox="0 0 24 24"
|
|
150
|
+
>
|
|
151
|
+
<path d={iconClearPath} />
|
|
152
|
+
</svg>
|
|
153
|
+
</div>
|
|
154
|
+
<svg
|
|
155
|
+
class="dropdown-arrow"
|
|
156
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
157
|
+
width="18"
|
|
158
|
+
height="18"
|
|
159
|
+
viewBox="0 0 18 18"><path d="M5 8l4 4 4-4z" /></svg
|
|
160
|
+
>
|
|
161
|
+
{/if}
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
<select bind:this={slot} type="multiple" class="hidden"><slot /></select>
|
|
166
|
+
|
|
167
|
+
{#if showOptions}
|
|
168
|
+
<ul
|
|
169
|
+
class="options"
|
|
170
|
+
transition:fly={{ duration: 200, y: 5 }}
|
|
171
|
+
on:mousedown|preventDefault={handleOptionMousedown}
|
|
172
|
+
>
|
|
173
|
+
{#each filtered as option}
|
|
174
|
+
<li
|
|
175
|
+
class:selected={selected[option.value]}
|
|
176
|
+
class:active={activeOption === option}
|
|
177
|
+
data-value={option.value}
|
|
178
|
+
>
|
|
179
|
+
{option.name}
|
|
180
|
+
</li>
|
|
181
|
+
{/each}
|
|
182
|
+
</ul>
|
|
183
|
+
{/if}
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<style>
|
|
187
|
+
.multiselect {
|
|
188
|
+
background-color: white;
|
|
189
|
+
border-bottom: 1px solid hsl(0, 0%, 70%);
|
|
190
|
+
position: relative;
|
|
191
|
+
}
|
|
192
|
+
.multiselect:not(.readonly):hover {
|
|
193
|
+
border-bottom-color: hsl(0, 0%, 50%);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.tokens {
|
|
197
|
+
align-items: center;
|
|
198
|
+
display: flex;
|
|
199
|
+
flex-wrap: wrap;
|
|
200
|
+
position: relative;
|
|
201
|
+
}
|
|
202
|
+
.tokens::after {
|
|
203
|
+
background: none repeat scroll 0 0 transparent;
|
|
204
|
+
bottom: -1px;
|
|
205
|
+
content: '';
|
|
206
|
+
display: block;
|
|
207
|
+
height: 2px;
|
|
208
|
+
left: 50%;
|
|
209
|
+
position: absolute;
|
|
210
|
+
background: hsl(45, 100%, 51%);
|
|
211
|
+
transition: width 0.3s ease 0s, left 0.3s ease 0s;
|
|
212
|
+
width: 0;
|
|
213
|
+
}
|
|
214
|
+
.tokens.showOptions::after {
|
|
215
|
+
width: 100%;
|
|
216
|
+
left: 0;
|
|
217
|
+
}
|
|
218
|
+
.token {
|
|
219
|
+
align-items: center;
|
|
220
|
+
background-color: hsl(214, 17%, 92%);
|
|
221
|
+
border-radius: 1.25rem;
|
|
222
|
+
display: flex;
|
|
223
|
+
margin: 0.25rem 0.5rem 0.25rem 0;
|
|
224
|
+
max-height: 1.3rem;
|
|
225
|
+
padding: 0.25rem 0.5rem 0.25rem 0.5rem;
|
|
226
|
+
transition: background-color 0.3s;
|
|
227
|
+
white-space: nowrap;
|
|
228
|
+
}
|
|
229
|
+
.token:hover {
|
|
230
|
+
background-color: hsl(214, 15%, 88%);
|
|
231
|
+
}
|
|
232
|
+
.readonly .token {
|
|
233
|
+
color: hsl(0, 0%, 40%);
|
|
234
|
+
}
|
|
235
|
+
.token-remove,
|
|
236
|
+
.remove-all {
|
|
237
|
+
align-items: center;
|
|
238
|
+
background-color: hsl(214, 15%, 55%);
|
|
239
|
+
border-radius: 50%;
|
|
240
|
+
color: hsl(214, 17%, 92%);
|
|
241
|
+
display: flex;
|
|
242
|
+
justify-content: center;
|
|
243
|
+
height: 1.25rem;
|
|
244
|
+
margin-left: 0.25rem;
|
|
245
|
+
min-width: 1.25rem;
|
|
246
|
+
}
|
|
247
|
+
.token-remove:hover,
|
|
248
|
+
.remove-all:hover {
|
|
249
|
+
background-color: hsl(215, 21%, 43%);
|
|
250
|
+
cursor: pointer;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.actions {
|
|
254
|
+
align-items: center;
|
|
255
|
+
display: flex;
|
|
256
|
+
flex: 1;
|
|
257
|
+
min-width: 15rem;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
input {
|
|
261
|
+
border: none;
|
|
262
|
+
font-size: 1.5rem;
|
|
263
|
+
line-height: 1.5rem;
|
|
264
|
+
margin: 0;
|
|
265
|
+
outline: none;
|
|
266
|
+
padding: 0;
|
|
267
|
+
width: 100%;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.dropdown-arrow path {
|
|
271
|
+
fill: hsl(0, 0%, 70%);
|
|
272
|
+
}
|
|
273
|
+
.multiselect:hover .dropdown-arrow path {
|
|
274
|
+
fill: hsl(0, 0%, 50%);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.icon-clear path {
|
|
278
|
+
fill: white;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.options {
|
|
282
|
+
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1), 0px -2px 4px rgba(0, 0, 0, 0.1);
|
|
283
|
+
left: 0;
|
|
284
|
+
list-style: none;
|
|
285
|
+
-webkit-margin-after: 0;
|
|
286
|
+
margin-block-end: 0;
|
|
287
|
+
-webkit-margin-before: 0;
|
|
288
|
+
margin-block-start: 0;
|
|
289
|
+
max-height: 70vh;
|
|
290
|
+
overflow: auto;
|
|
291
|
+
-webkit-padding-start: 0;
|
|
292
|
+
padding-inline-start: 0;
|
|
293
|
+
position: absolute;
|
|
294
|
+
top: calc(100% + 1px);
|
|
295
|
+
width: 100%;
|
|
296
|
+
}
|
|
297
|
+
li {
|
|
298
|
+
background-color: white;
|
|
299
|
+
cursor: pointer;
|
|
300
|
+
padding: 0.5rem;
|
|
301
|
+
}
|
|
302
|
+
li:last-child {
|
|
303
|
+
border-bottom-left-radius: 0.2rem;
|
|
304
|
+
border-bottom-right-radius: 0.2rem;
|
|
305
|
+
}
|
|
306
|
+
li:not(.selected):hover {
|
|
307
|
+
background-color: hsl(214, 17%, 92%);
|
|
308
|
+
}
|
|
309
|
+
li.selected {
|
|
310
|
+
background-color: hsl(232, 54%, 41%);
|
|
311
|
+
color: white;
|
|
312
|
+
}
|
|
313
|
+
li.selected:nth-child(even) {
|
|
314
|
+
background-color: hsl(232, 50%, 45%);
|
|
315
|
+
color: white;
|
|
316
|
+
}
|
|
317
|
+
li.active {
|
|
318
|
+
background-color: hsl(214, 17%, 88%);
|
|
319
|
+
}
|
|
320
|
+
li.selected.active,
|
|
321
|
+
li.selected:hover {
|
|
322
|
+
background-color: hsl(232, 48%, 50%);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.hidden {
|
|
326
|
+
display: none;
|
|
327
|
+
}</style>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script>import { ResourceService } from '../../gen';
|
|
2
|
+
import ResourcePicker from './ResourcePicker.svelte';
|
|
3
|
+
import { workspaceStore } from '../../stores';
|
|
4
|
+
import SchemaForm from './SchemaForm.svelte';
|
|
5
|
+
import RadioButton from './RadioButton.svelte';
|
|
6
|
+
export let format;
|
|
7
|
+
export let value;
|
|
8
|
+
function isString(value) {
|
|
9
|
+
return typeof value === 'string' || value instanceof String;
|
|
10
|
+
}
|
|
11
|
+
let path = isString(value) && value.length >= '$res:'.length ? value.substr('$res:'.length) : undefined;
|
|
12
|
+
let args = {};
|
|
13
|
+
if (!isString(value) && value) {
|
|
14
|
+
console.log(value);
|
|
15
|
+
args = value;
|
|
16
|
+
}
|
|
17
|
+
let schema = undefined;
|
|
18
|
+
let isValid = true;
|
|
19
|
+
let resourceTypeName = '';
|
|
20
|
+
async function loadSchema(format) {
|
|
21
|
+
resourceTypeName = format.substring('resource-'.length);
|
|
22
|
+
schema = (await ResourceService.getResourceType({ workspace: $workspaceStore, path: resourceTypeName })).schema;
|
|
23
|
+
}
|
|
24
|
+
let option = isString(value) || value == undefined ? 'resource' : 'raw';
|
|
25
|
+
$: {
|
|
26
|
+
if (option == 'resource') {
|
|
27
|
+
value = `$res:${path}`;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
value = args;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
$: format.startsWith('resource-') && loadSchema(format);
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<div class="max-w-lg">
|
|
37
|
+
<RadioButton
|
|
38
|
+
options={[
|
|
39
|
+
[`Resource (${resourceTypeName})`, 'resource'],
|
|
40
|
+
[`Raw object value`, 'raw']
|
|
41
|
+
]}
|
|
42
|
+
small={true}
|
|
43
|
+
bind:value={option}
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
<div class="mt-1" />
|
|
47
|
+
{#if option == 'resource'}
|
|
48
|
+
<ResourcePicker
|
|
49
|
+
bind:value={path}
|
|
50
|
+
resourceType={format.split('-').length > 1 ? format.substring('resource-'.length) : undefined}
|
|
51
|
+
/>
|
|
52
|
+
{:else}
|
|
53
|
+
<div class="border rounded p-5">
|
|
54
|
+
<h2 class="mb-5">
|
|
55
|
+
Object of <a target="_blank" href="/resources">resource type</a>
|
|
56
|
+
{resourceTypeName}
|
|
57
|
+
</h2>
|
|
58
|
+
{#if !isString(args)}
|
|
59
|
+
<SchemaForm {schema} bind:isValid bind:args />
|
|
60
|
+
{/if}
|
|
61
|
+
</div>
|
|
62
|
+
{/if}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script>import RadioButton from './RadioButton.svelte';
|
|
2
|
+
import ResourceTypePicker from './ResourceTypePicker.svelte';
|
|
3
|
+
export let format;
|
|
4
|
+
let kind = format?.startsWith('resource') ? 'resource' : 'none';
|
|
5
|
+
let resource = format?.startsWith('resource-')
|
|
6
|
+
? format.substring('resource-'.length)
|
|
7
|
+
: undefined;
|
|
8
|
+
$: format =
|
|
9
|
+
kind == 'resource' ? (resource != undefined ? `resource-${resource}` : 'resource') : undefined;
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<RadioButton
|
|
13
|
+
label="Kind"
|
|
14
|
+
small={true}
|
|
15
|
+
options={[
|
|
16
|
+
['None', 'none'],
|
|
17
|
+
['Resource Type', 'resource']
|
|
18
|
+
]}
|
|
19
|
+
bind:value={kind}
|
|
20
|
+
/>
|
|
21
|
+
|
|
22
|
+
{#if kind == 'resource'}
|
|
23
|
+
<div class="mt-1" />
|
|
24
|
+
<ResourceTypePicker bind:value={resource} />
|
|
25
|
+
{/if}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script>import Tooltip from './Tooltip.svelte';
|
|
2
|
+
export let title;
|
|
3
|
+
export let tooltip = '';
|
|
4
|
+
export let primary = true;
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div class="flex flex-col sm:flex-row justify-between mt-4 mb-2">
|
|
8
|
+
{#if primary}
|
|
9
|
+
<h1>
|
|
10
|
+
{title}
|
|
11
|
+
{#if tooltip}
|
|
12
|
+
<Tooltip>{tooltip}</Tooltip>
|
|
13
|
+
{/if}
|
|
14
|
+
</h1>
|
|
15
|
+
{:else}
|
|
16
|
+
<h2>
|
|
17
|
+
{title}
|
|
18
|
+
{#if tooltip}
|
|
19
|
+
<Tooltip>{tooltip}</Tooltip>
|
|
20
|
+
{/if}
|
|
21
|
+
</h2>
|
|
22
|
+
{/if}
|
|
23
|
+
|
|
24
|
+
{#if $$slots.default}
|
|
25
|
+
<div class="my-2 sm:ml-4">
|
|
26
|
+
<slot />
|
|
27
|
+
</div>
|
|
28
|
+
{/if}
|
|
29
|
+
</div>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script>// @ts-nocheck
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
export let password;
|
|
4
|
+
export let label = 'password';
|
|
5
|
+
export let placeholder = '******';
|
|
6
|
+
onMount(() => {
|
|
7
|
+
const passwordToggle = document.querySelector('.js-password-toggle');
|
|
8
|
+
if (passwordToggle) {
|
|
9
|
+
passwordToggle.addEventListener('change', function () {
|
|
10
|
+
const password = document.querySelector('.js-password'), passwordLabel = document.querySelector('.js-password-label');
|
|
11
|
+
if (password.type === 'password') {
|
|
12
|
+
password.type = 'text';
|
|
13
|
+
passwordLabel.innerHTML = 'hide';
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
password.type = 'password';
|
|
17
|
+
passwordLabel.innerHTML = 'show';
|
|
18
|
+
}
|
|
19
|
+
password.focus();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
throw Error('Password component is undefined');
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<label class="block text-gray-700" for="password"> {label} </label>
|
|
29
|
+
<div class="relative w-full">
|
|
30
|
+
<div class="absolute inset-y-0 right-0 flex items-center px-2">
|
|
31
|
+
<input class="hidden js-password-toggle" id="toggle" type="checkbox" />
|
|
32
|
+
<label
|
|
33
|
+
class="bg-gray-300 hover:bg-gray-400 rounded px-2 py-1 text-sm text-gray-600 font-mono cursor-pointer js-password-label"
|
|
34
|
+
for="toggle">show</label
|
|
35
|
+
>
|
|
36
|
+
</div>
|
|
37
|
+
<input
|
|
38
|
+
class="block w-full py-2 px-2 border rounded-md border-gray-300 shadow-sm; focus:ring focus:ring-indigo-100 focus:ring-opacity-50 text-sm js-password h-12"
|
|
39
|
+
id="password"
|
|
40
|
+
type="password"
|
|
41
|
+
bind:value={password}
|
|
42
|
+
autocomplete="off"
|
|
43
|
+
{placeholder}
|
|
44
|
+
/>
|
|
45
|
+
</div>
|