"...lm-evaluation-harness.git" did not exist on "fcfc0c6044480d4caccdcbcfd1c221eb48fcccef"
Pipelines.svelte 16.3 KB
Newer Older
Timothy J. Baek's avatar
Timothy J. Baek committed
1
2
3
<script lang="ts">
	import { v4 as uuidv4 } from 'uuid';

4
5
	import { toast } from 'svelte-sonner';
	import { models } from '$lib/stores';
6
	import { getContext, onMount, tick } from 'svelte';
Timothy J. Baek's avatar
Timothy J. Baek committed
7
8
	import type { Writable } from 'svelte/store';
	import type { i18n as i18nType } from 'i18next';
9
10
11
12
	import {
		getPipelineValves,
		getPipelineValvesSpec,
		updatePipelineValves,
Timothy J. Baek's avatar
Timothy J. Baek committed
13
		getPipelines,
14
		getModels,
Timothy J. Baek's avatar
Timothy J. Baek committed
15
16
		getPipelinesList,
		downloadPipeline,
Timothy J. Baek's avatar
Timothy J. Baek committed
17
18
		deletePipeline,
		uploadPipeline
19
	} from '$lib/apis';
20

Timothy J. Baek's avatar
Timothy J. Baek committed
21
	import Spinner from '$lib/components/common/Spinner.svelte';
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
22
	import Switch from '$lib/components/common/Switch.svelte';
Timothy J. Baek's avatar
Timothy J. Baek committed
23

Timothy J. Baek's avatar
Timothy J. Baek committed
24
25
26
27
	const i18n: Writable<i18nType> = getContext('i18n');

	export let saveHandler: Function;

Timothy J. Baek's avatar
Timothy J. Baek committed
28
	let downloading = false;
Timothy J. Baek's avatar
Timothy J. Baek committed
29
30
31
	let uploading = false;

	let pipelineFiles;
Timothy J. Baek's avatar
Timothy J. Baek committed
32

33
34
35
	let PIPELINES_LIST = null;
	let selectedPipelinesUrlIdx = '';

Timothy J. Baek's avatar
Timothy J. Baek committed
36
	let pipelines = null;
37

Timothy J. Baek's avatar
Timothy J. Baek committed
38
	let valves = null;
39
40
41
	let valves_spec = null;
	let selectedPipelineIdx = null;

Timothy J. Baek's avatar
Timothy J. Baek committed
42
43
	let pipelineDownloadUrl = '';

44
45
	const updateHandler = async () => {
		const pipeline = pipelines[selectedPipelineIdx];
Timothy J. Baek's avatar
Timothy J. Baek committed
46

Timothy J. Baek's avatar
Timothy J. Baek committed
47
		if (pipeline && (pipeline?.valves ?? false)) {
Timothy J. Baek's avatar
Timothy J. Baek committed
48
49
50
51
			for (const property in valves_spec.properties) {
				if (valves_spec.properties[property]?.type === 'array') {
					valves[property] = valves[property].split(',').map((v) => v.trim());
				}
52
53
			}

Timothy J. Baek's avatar
Timothy J. Baek committed
54
55
56
57
58
59
60
61
			const res = await updatePipelineValves(
				localStorage.token,
				pipeline.id,
				valves,
				selectedPipelinesUrlIdx
			).catch((error) => {
				toast.error(error);
			});
Timothy J. Baek's avatar
Timothy J. Baek committed
62

63
			if (res) {
SimonOriginal's avatar
SimonOriginal committed
64
				toast.success($i18n.t('Valves updated successfully'));
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
65
				setPipelines();
Timothy J. Baek's avatar
Timothy J. Baek committed
66
				models.set(await getModels(localStorage.token));
67
68
69
				saveHandler();
			}
		} else {
SimonOriginal's avatar
SimonOriginal committed
70
			toast.error($i18n.t('No valves to update'));
71
72
		}
	};
Timothy J. Baek's avatar
Timothy J. Baek committed
73

Timothy J. Baek's avatar
Timothy J. Baek committed
74
	const getValves = async (idx) => {
75
76
77
		valves = null;
		valves_spec = null;

Timothy J. Baek's avatar
Timothy J. Baek committed
78
79
80
81
82
83
84
85
86
87
		valves_spec = await getPipelineValvesSpec(
			localStorage.token,
			pipelines[idx].id,
			selectedPipelinesUrlIdx
		);
		valves = await getPipelineValves(
			localStorage.token,
			pipelines[idx].id,
			selectedPipelinesUrlIdx
		);
88

Timothy J. Baek's avatar
Timothy J. Baek committed
89
90
91
92
		for (const property in valves_spec.properties) {
			if (valves_spec.properties[property]?.type === 'array') {
				valves[property] = valves[property].join(',');
			}
93
		}
Timothy J. Baek's avatar
Timothy J. Baek committed
94
95
	};

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
96
	const setPipelines = async () => {
97
98
99
100
		pipelines = null;
		valves = null;
		valves_spec = null;

Timothy J. Baek's avatar
fix  
Timothy J. Baek committed
101
		if (PIPELINES_LIST.length > 0) {
Timothy J. Baek's avatar
Timothy J. Baek committed
102
			console.log(selectedPipelinesUrlIdx);
Timothy J. Baek's avatar
fix  
Timothy J. Baek committed
103
			pipelines = await getPipelines(localStorage.token, selectedPipelinesUrlIdx);
104

Timothy J. Baek's avatar
fix  
Timothy J. Baek committed
105
106
107
108
109
110
			if (pipelines.length > 0) {
				selectedPipelineIdx = 0;
				await getValves(selectedPipelineIdx);
			}
		} else {
			pipelines = [];
111
		}
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
112
113
	};

Timothy J. Baek's avatar
Timothy J. Baek committed
114
115
116
117
118
119
120
121
122
123
124
125
	const addPipelineHandler = async () => {
		downloading = true;
		const res = await downloadPipeline(
			localStorage.token,
			pipelineDownloadUrl,
			selectedPipelinesUrlIdx
		).catch((error) => {
			toast.error(error);
			return null;
		});

		if (res) {
SimonOriginal's avatar
SimonOriginal committed
126
			toast.success($i18n.t('Pipeline downloaded successfully'));
Timothy J. Baek's avatar
Timothy J. Baek committed
127
128
129
130
131
132
133
			setPipelines();
			models.set(await getModels(localStorage.token));
		}

		downloading = false;
	};

Timothy J. Baek's avatar
Timothy J. Baek committed
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
	const uploadPipelineHandler = async () => {
		uploading = true;

		if (pipelineFiles && pipelineFiles.length !== 0) {
			const file = pipelineFiles[0];

			console.log(file);

			const res = await uploadPipeline(localStorage.token, file, selectedPipelinesUrlIdx).catch(
				(error) => {
					console.log(error);
					toast.error('Something went wrong :/');
					return null;
				}
			);

			if (res) {
SimonOriginal's avatar
SimonOriginal committed
151
				toast.success($i18n.t('Pipeline downloaded successfully'));
Timothy J. Baek's avatar
Timothy J. Baek committed
152
153
154
155
				setPipelines();
				models.set(await getModels(localStorage.token));
			}
		} else {
SimonOriginal's avatar
SimonOriginal committed
156
			toast.error($i18n.t('No file selected'));
Timothy J. Baek's avatar
Timothy J. Baek committed
157
158
159
160
161
162
163
164
165
166
167
168
		}

		pipelineFiles = null;
		const pipelineUploadInputElement = document.getElementById('pipeline-upload-input');

		if (pipelineUploadInputElement) {
			pipelineUploadInputElement.value = null;
		}

		uploading = false;
	};

Timothy J. Baek's avatar
Timothy J. Baek committed
169
170
171
172
173
174
175
176
177
178
179
	const deletePipelineHandler = async () => {
		const res = await deletePipeline(
			localStorage.token,
			pipelines[selectedPipelineIdx].id,
			selectedPipelinesUrlIdx
		).catch((error) => {
			toast.error(error);
			return null;
		});

		if (res) {
SimonOriginal's avatar
SimonOriginal committed
180
			toast.success($i18n.t('Pipeline deleted successfully'));
Timothy J. Baek's avatar
Timothy J. Baek committed
181
182
183
184
185
			setPipelines();
			models.set(await getModels(localStorage.token));
		}
	};

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
186
	onMount(async () => {
187
		PIPELINES_LIST = await getPipelinesList(localStorage.token);
Timothy J. Baek's avatar
fix  
Timothy J. Baek committed
188
		console.log(PIPELINES_LIST);
189
190

		if (PIPELINES_LIST.length > 0) {
Timothy J. Baek's avatar
Timothy J. Baek committed
191
			selectedPipelinesUrlIdx = PIPELINES_LIST[0]['idx'].toString();
192
193
		}

Timothy J. Baek's avatar
Timothy J. Baek committed
194
		await setPipelines();
Timothy J. Baek's avatar
Timothy J. Baek committed
195
196
197
198
199
200
	});
</script>

<form
	class="flex flex-col h-full justify-between space-y-3 text-sm"
	on:submit|preventDefault={async () => {
201
		updateHandler();
Timothy J. Baek's avatar
Timothy J. Baek committed
202
203
	}}
>
Timothy J. Baek's avatar
Timothy J. Baek committed
204
	<div class="overflow-y-scroll scrollbar-hidden h-full">
205
		{#if PIPELINES_LIST !== null}
Timothy J. Baek's avatar
Timothy J. Baek committed
206
207
			<div class="flex w-full justify-between mb-2">
				<div class=" self-center text-sm font-semibold">
208
					{$i18n.t('Manage Pipelines')}
Timothy J. Baek's avatar
Timothy J. Baek committed
209
210
				</div>
			</div>
211
212
213

			{#if PIPELINES_LIST.length > 0}
				<div class="space-y-1">
Timothy J. Baek's avatar
Timothy J. Baek committed
214
					<div class="flex gap-2">
215
						<div class="flex-1">
Timothy J. Baek's avatar
Timothy J. Baek committed
216
217
							<select
								class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
218
219
								bind:value={selectedPipelinesUrlIdx}
								placeholder={$i18n.t('Select a pipeline url')}
220
221
								on:change={async () => {
									await tick();
222
									await setPipelines();
223
								}}
Timothy J. Baek's avatar
Timothy J. Baek committed
224
							>
225
226
227
228
229
								<option value="" selected disabled class="bg-gray-100 dark:bg-gray-700"
									>{$i18n.t('Select a pipeline url')}</option
								>

								{#each PIPELINES_LIST as pipelines, idx}
Timothy J. Baek's avatar
Timothy J. Baek committed
230
									<option value={pipelines.idx.toString()} class="bg-gray-100 dark:bg-gray-700"
231
										>{pipelines.url}</option
232
									>
Timothy J. Baek's avatar
Timothy J. Baek committed
233
234
235
								{/each}
							</select>
						</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
236
					</div>
237
				</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
238

Timothy J. Baek's avatar
Timothy J. Baek committed
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
				<div class=" my-2">
					<div class=" mb-2 text-sm font-medium">
						{$i18n.t('Upload Pipeline')}
					</div>
					<div class="flex w-full">
						<div class="flex-1 mr-2">
							<input
								id="pipelines-upload-input"
								bind:files={pipelineFiles}
								type="file"
								accept=".py"
								hidden
							/>

							<button
								class="w-full text-sm font-medium py-2 bg-transparent hover:bg-gray-100 border border-dashed dark:border-gray-800 dark:hover:bg-gray-850 text-center rounded-xl"
								type="button"
								on:click={() => {
									document.getElementById('pipelines-upload-input')?.click();
								}}
							>
								{#if pipelineFiles}
									{pipelineFiles.length > 0 ? `${pipelineFiles.length}` : ''} pipeline(s) selected.
								{:else}
									{$i18n.t('Click here to select a py file.')}
								{/if}
							</button>
						</div>
						<button
							class="px-2.5 bg-gray-100 hover:bg-gray-200 text-gray-800 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-100 rounded-lg transition"
							on:click={() => {
								uploadPipelineHandler();
							}}
							disabled={uploading}
							type="button"
						>
							{#if uploading}
								<div class="self-center">
									<svg
										class=" w-4 h-4"
										viewBox="0 0 24 24"
										fill="currentColor"
										xmlns="http://www.w3.org/2000/svg"
									>
										<style>
											.spinner_ajPY {
												transform-origin: center;
												animation: spinner_AtaB 0.75s infinite linear;
											}

											@keyframes spinner_AtaB {
												100% {
													transform: rotate(360deg);
												}
											}
										</style>
										<path
											d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"
											opacity=".25"
										/>
										<path
											d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z"
											class="spinner_ajPY"
										/>
									</svg>
								</div>
							{:else}
								<svg
									xmlns="http://www.w3.org/2000/svg"
									viewBox="0 0 16 16"
									fill="currentColor"
									class="size-4"
								>
									<path
										d="M7.25 10.25a.75.75 0 0 0 1.5 0V4.56l2.22 2.22a.75.75 0 1 0 1.06-1.06l-3.5-3.5a.75.75 0 0 0-1.06 0l-3.5 3.5a.75.75 0 0 0 1.06 1.06l2.22-2.22v5.69Z"
									/>
									<path
										d="M3.5 9.75a.75.75 0 0 0-1.5 0v1.5A2.75 2.75 0 0 0 4.75 14h6.5A2.75 2.75 0 0 0 14 11.25v-1.5a.75.75 0 0 0-1.5 0v1.5c0 .69-.56 1.25-1.25 1.25h-6.5c-.69 0-1.25-.56-1.25-1.25v-1.5Z"
									/>
								</svg>
							{/if}
						</button>
					</div>
				</div>

Timothy J. Baek's avatar
Timothy J. Baek committed
324
325
326
				<div class=" my-2">
					<div class=" mb-2 text-sm font-medium">
						{$i18n.t('Install from Github URL')}
Timothy J. Baek's avatar
Timothy J. Baek committed
327
					</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
					<div class="flex w-full">
						<div class="flex-1 mr-2">
							<input
								class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
								placeholder={$i18n.t('Enter Github Raw URL')}
								bind:value={pipelineDownloadUrl}
							/>
						</div>
						<button
							class="px-2.5 bg-gray-100 hover:bg-gray-200 text-gray-800 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-100 rounded-lg transition"
							on:click={() => {
								addPipelineHandler();
							}}
							disabled={downloading}
							type="button"
						>
							{#if downloading}
								<div class="self-center">
									<svg
										class=" w-4 h-4"
										viewBox="0 0 24 24"
										fill="currentColor"
										xmlns="http://www.w3.org/2000/svg"
									>
										<style>
											.spinner_ajPY {
												transform-origin: center;
												animation: spinner_AtaB 0.75s infinite linear;
											}

											@keyframes spinner_AtaB {
												100% {
													transform: rotate(360deg);
												}
											}
										</style>
										<path
											d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"
											opacity=".25"
										/>
										<path
											d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z"
											class="spinner_ajPY"
										/>
									</svg>
								</div>
							{:else}
Timothy J. Baek's avatar
Timothy J. Baek committed
375
376
								<svg
									xmlns="http://www.w3.org/2000/svg"
Timothy J. Baek's avatar
Timothy J. Baek committed
377
378
379
									viewBox="0 0 16 16"
									fill="currentColor"
									class="w-4 h-4"
Timothy J. Baek's avatar
Timothy J. Baek committed
380
381
								>
									<path
Timothy J. Baek's avatar
Timothy J. Baek committed
382
										d="M8.75 2.75a.75.75 0 0 0-1.5 0v5.69L5.03 6.22a.75.75 0 0 0-1.06 1.06l3.5 3.5a.75.75 0 0 0 1.06 0l3.5-3.5a.75.75 0 0 0-1.06-1.06L8.75 8.44V2.75Z"
Timothy J. Baek's avatar
Timothy J. Baek committed
383
384
									/>
									<path
Timothy J. Baek's avatar
Timothy J. Baek committed
385
										d="M3.5 9.75a.75.75 0 0 0-1.5 0v1.5A2.75 2.75 0 0 0 4.75 14h6.5A2.75 2.75 0 0 0 14 11.25v-1.5a.75.75 0 0 0-1.5 0v1.5c0 .69-.56 1.25-1.25 1.25h-6.5c-.69 0-1.25-.56-1.25-1.25v-1.5Z"
Timothy J. Baek's avatar
Timothy J. Baek committed
386
387
									/>
								</svg>
Timothy J. Baek's avatar
Timothy J. Baek committed
388
389
390
							{/if}
						</button>
					</div>
391
392
393
394
395
396
397
398

					<div class="mt-2 text-xs text-gray-500">
						<span class=" font-semibold dark:text-gray-200">Warning:</span> Pipelines are a plugin
						system with arbitrary code execution —
						<span class=" font-medium dark:text-gray-400"
							>don't fetch random pipelines from sources you don't trust.</span
						>
					</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
399
400
				</div>

Timothy J. Baek's avatar
Timothy J. Baek committed
401
				<hr class=" dark:border-gray-800 my-3 w-full" />
Timothy J. Baek's avatar
Timothy J. Baek committed
402

Timothy J. Baek's avatar
Timothy J. Baek committed
403
404
405
406
407
408
				{#if pipelines !== null}
					{#if pipelines.length > 0}
						<div class="flex w-full justify-between mb-2">
							<div class=" self-center text-sm font-semibold">
								{$i18n.t('Pipelines Valves')}
							</div>
409
						</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
						<div class="space-y-1">
							{#if pipelines.length > 0}
								<div class="flex gap-2">
									<div class="flex-1">
										<select
											class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
											bind:value={selectedPipelineIdx}
											placeholder={$i18n.t('Select a pipeline')}
											on:change={async () => {
												await tick();
												await getValves(selectedPipelineIdx);
											}}
										>
											{#each pipelines as pipeline, idx}
												<option value={idx} class="bg-gray-100 dark:bg-gray-700"
													>{pipeline.name} ({pipeline.type ?? 'pipe'})</option
												>
											{/each}
										</select>
									</div>

									<button
										class="px-2.5 bg-gray-100 hover:bg-gray-200 text-gray-800 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-100 rounded-lg transition"
										on:click={() => {
											deletePipelineHandler();
435
										}}
Timothy J. Baek's avatar
Timothy J. Baek committed
436
										type="button"
437
									>
Timothy J. Baek's avatar
Timothy J. Baek committed
438
439
440
441
442
443
444
445
446
447
448
449
450
										<svg
											xmlns="http://www.w3.org/2000/svg"
											viewBox="0 0 16 16"
											fill="currentColor"
											class="w-4 h-4"
										>
											<path
												fill-rule="evenodd"
												d="M5 3.25V4H2.75a.75.75 0 0 0 0 1.5h.3l.815 8.15A1.5 1.5 0 0 0 5.357 15h5.285a1.5 1.5 0 0 0 1.493-1.35l.815-8.15h.3a.75.75 0 0 0 0-1.5H11v-.75A2.25 2.25 0 0 0 8.75 1h-1.5A2.25 2.25 0 0 0 5 3.25Zm2.25-.75a.75.75 0 0 0-.75.75V4h3v-.75a.75.75 0 0 0-.75-.75h-1.5ZM6.05 6a.75.75 0 0 1 .787.713l.275 5.5a.75.75 0 0 1-1.498.075l-.275-5.5A.75.75 0 0 1 6.05 6Zm3.9 0a.75.75 0 0 1 .712.787l-.275 5.5a.75.75 0 0 1-1.498-.075l.275-5.5a.75.75 0 0 1 .786-.711Z"
												clip-rule="evenodd"
											/>
										</svg>
									</button>
451
								</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
452
							{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
453

Timothy J. Baek's avatar
Timothy J. Baek committed
454
455
456
457
458
459
460
461
462
							<div class="space-y-1">
								{#if pipelines[selectedPipelineIdx].valves}
									{#if valves}
										{#each Object.keys(valves_spec.properties) as property, idx}
											<div class=" py-0.5 w-full justify-between">
												<div class="flex w-full justify-between">
													<div class=" self-center text-xs font-medium">
														{valves_spec.properties[property].title}
													</div>
463

Timothy J. Baek's avatar
Timothy J. Baek committed
464
465
466
467
468
469
470
471
472
473
474
475
476
													<button
														class="p-1 px-3 text-xs flex rounded transition"
														type="button"
														on:click={() => {
															valves[property] = (valves[property] ?? null) === null ? '' : null;
														}}
													>
														{#if (valves[property] ?? null) === null}
															<span class="ml-2 self-center"> {$i18n.t('None')} </span>
														{:else}
															<span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
														{/if}
													</button>
477
478
												</div>

Timothy J. Baek's avatar
Timothy J. Baek committed
479
												{#if (valves[property] ?? null) !== null}
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
480
481
													<!-- {valves[property]} -->
													<div class="flex mt-0.5 mb-1.5 space-x-2">
Timothy J. Baek's avatar
Timothy J. Baek committed
482
														<div class=" flex-1">
Timothy J. Baek's avatar
fix  
Timothy J. Baek committed
483
															{#if valves_spec.properties[property]?.enum ?? null}
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
484
485
486
487
																<select
																	class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
																	bind:value={valves[property]}
																>
Timothy J. Baek's avatar
fix  
Timothy J. Baek committed
488
																	{#each valves_spec.properties[property].enum as option}
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
489
490
491
492
493
																		<option value={option} selected={option === valves[property]}>
																			{option}
																		</option>
																	{/each}
																</select>
Timothy J. Baek's avatar
fix  
Timothy J. Baek committed
494
															{:else if (valves_spec.properties[property]?.type ?? null) === 'boolean'}
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
495
496
497
498
499
500
501
502
503
504
505
506
507
																<div class="flex justify-between items-center">
																	<div class="text-xs text-gray-500">
																		{valves[property] ? 'Enabled' : 'Disabled'}
																	</div>

																	<div class=" pr-2">
																		<Switch bind:state={valves[property]} />
																	</div>
																</div>
															{:else}
																<input
																	class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
																	type="text"
Timothy J. Baek's avatar
fix  
Timothy J. Baek committed
508
																	placeholder={valves_spec.properties[property].title}
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
509
510
511
512
513
																	bind:value={valves[property]}
																	autocomplete="off"
																	required
																/>
															{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
514
														</div>
515
													</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
516
517
518
519
520
521
												{/if}
											</div>
										{/each}
									{:else}
										<Spinner className="size-5" />
									{/if}
522
								{:else}
Timothy J. Baek's avatar
Timothy J. Baek committed
523
									<div>No valves</div>
524
								{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
525
526
527
528
529
530
531
532
533
							</div>
						</div>
					{:else if pipelines.length === 0}
						<div>Pipelines Not Detected</div>
					{/if}
				{:else}
					<div class="flex justify-center">
						<div class="my-auto">
							<Spinner className="size-4" />
534
535
536
						</div>
					</div>
				{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
537
			{:else}
SimonOriginal's avatar
SimonOriginal committed
538
				<div>{$i18n.t('Pipelines Not Detected')}</div>
539
			{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
540
		{:else}
541
			<div class="flex justify-center h-full">
Timothy J. Baek's avatar
Timothy J. Baek committed
542
543
544
				<div class="my-auto">
					<Spinner className="size-6" />
				</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
545
			</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
546
		{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
547
	</div>
548

Timothy J. Baek's avatar
Timothy J. Baek committed
549
550
551
552
553
	<div class="flex justify-end pt-3 text-sm font-medium">
		<button
			class=" px-4 py-2 bg-emerald-700 hover:bg-emerald-800 text-gray-100 transition rounded-lg"
			type="submit"
		>
SimonOriginal's avatar
SimonOriginal committed
554
			{$i18n.t('Save')}
Timothy J. Baek's avatar
Timothy J. Baek committed
555
556
557
		</button>
	</div>
</form>