|
@@ -7,12 +7,14 @@
|
|
import {
|
|
import {
|
|
getUserValvesSpecById as getToolUserValvesSpecById,
|
|
getUserValvesSpecById as getToolUserValvesSpecById,
|
|
getUserValvesById as getToolUserValvesById,
|
|
getUserValvesById as getToolUserValvesById,
|
|
- updateUserValvesById as updateToolUserValvesById
|
|
|
|
|
|
+ updateUserValvesById as updateToolUserValvesById,
|
|
|
|
+ getTools
|
|
} from '$lib/apis/tools';
|
|
} from '$lib/apis/tools';
|
|
import {
|
|
import {
|
|
getUserValvesSpecById as getFunctionUserValvesSpecById,
|
|
getUserValvesSpecById as getFunctionUserValvesSpecById,
|
|
getUserValvesById as getFunctionUserValvesById,
|
|
getUserValvesById as getFunctionUserValvesById,
|
|
- updateUserValvesById as updateFunctionUserValvesById
|
|
|
|
|
|
+ updateUserValvesById as updateFunctionUserValvesById,
|
|
|
|
+ getFunctions
|
|
} from '$lib/apis/functions';
|
|
} from '$lib/apis/functions';
|
|
|
|
|
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
|
@@ -112,77 +114,94 @@
|
|
$: if (selectedId) {
|
|
$: if (selectedId) {
|
|
getUserValves();
|
|
getUserValves();
|
|
}
|
|
}
|
|
-</script>
|
|
|
|
|
|
|
|
-<form
|
|
|
|
- class="flex flex-col h-full justify-between space-y-3 text-sm"
|
|
|
|
- on:submit|preventDefault={() => {
|
|
|
|
- submitHandler();
|
|
|
|
- dispatch('save');
|
|
|
|
- }}
|
|
|
|
->
|
|
|
|
- <div class="flex flex-col">
|
|
|
|
- <div class="space-y-1">
|
|
|
|
- <div class="flex gap-2">
|
|
|
|
- <div class="flex-1">
|
|
|
|
- <select
|
|
|
|
- class=" w-full rounded text-xs py-2 px-1 bg-transparent outline-none"
|
|
|
|
- bind:value={tab}
|
|
|
|
- placeholder="Select"
|
|
|
|
- >
|
|
|
|
- <option value="tools" class="bg-gray-100 dark:bg-gray-800">{$i18n.t('Tools')}</option>
|
|
|
|
- <option value="functions" class="bg-gray-100 dark:bg-gray-800"
|
|
|
|
- >{$i18n.t('Functions')}</option
|
|
|
|
- >
|
|
|
|
- </select>
|
|
|
|
- </div>
|
|
|
|
|
|
+ onMount(async () => {
|
|
|
|
+ loading = true;
|
|
|
|
|
|
- <div class="flex-1">
|
|
|
|
- <select
|
|
|
|
- class="w-full rounded py-2 px-1 text-xs bg-transparent outline-none"
|
|
|
|
- bind:value={selectedId}
|
|
|
|
- on:change={async () => {
|
|
|
|
- await tick();
|
|
|
|
- }}
|
|
|
|
- >
|
|
|
|
- {#if tab === 'tools'}
|
|
|
|
- <option value="" selected disabled class="bg-gray-100 dark:bg-gray-800"
|
|
|
|
- >{$i18n.t('Select a tool')}</option
|
|
|
|
- >
|
|
|
|
|
|
+ if ($functions.length === 0) {
|
|
|
|
+ functions.set(await getFunctions(localStorage.token));
|
|
|
|
+ }
|
|
|
|
+ if ($tools.length === 0) {
|
|
|
|
+ tools.set(await getTools(localStorage.token));
|
|
|
|
+ }
|
|
|
|
|
|
- {#each $tools as tool, toolIdx}
|
|
|
|
- <option value={tool.id} class="bg-gray-100 dark:bg-gray-800">{tool.name}</option>
|
|
|
|
- {/each}
|
|
|
|
- {:else if tab === 'functions'}
|
|
|
|
- <option value="" selected disabled class="bg-gray-100 dark:bg-gray-800"
|
|
|
|
- >{$i18n.t('Select a function')}</option
|
|
|
|
- >
|
|
|
|
|
|
+ loading = false;
|
|
|
|
+ });
|
|
|
|
+</script>
|
|
|
|
|
|
- {#each $functions as func, funcIdx}
|
|
|
|
- <option value={func.id} class="bg-gray-100 dark:bg-gray-800">{func.name}</option>
|
|
|
|
- {/each}
|
|
|
|
- {/if}
|
|
|
|
- </select>
|
|
|
|
|
|
+{#if !loading}
|
|
|
|
+ <form
|
|
|
|
+ class="flex flex-col h-full justify-between space-y-3 text-sm"
|
|
|
|
+ on:submit|preventDefault={() => {
|
|
|
|
+ submitHandler();
|
|
|
|
+ dispatch('save');
|
|
|
|
+ }}
|
|
|
|
+ >
|
|
|
|
+ <div class="flex flex-col">
|
|
|
|
+ <div class="space-y-1">
|
|
|
|
+ <div class="flex gap-2">
|
|
|
|
+ <div class="flex-1">
|
|
|
|
+ <select
|
|
|
|
+ class=" w-full rounded text-xs py-2 px-1 bg-transparent outline-none"
|
|
|
|
+ bind:value={tab}
|
|
|
|
+ placeholder="Select"
|
|
|
|
+ >
|
|
|
|
+ <option value="tools" class="bg-gray-100 dark:bg-gray-800">{$i18n.t('Tools')}</option>
|
|
|
|
+ <option value="functions" class="bg-gray-100 dark:bg-gray-800"
|
|
|
|
+ >{$i18n.t('Functions')}</option
|
|
|
|
+ >
|
|
|
|
+ </select>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div class="flex-1">
|
|
|
|
+ <select
|
|
|
|
+ class="w-full rounded py-2 px-1 text-xs bg-transparent outline-none"
|
|
|
|
+ bind:value={selectedId}
|
|
|
|
+ on:change={async () => {
|
|
|
|
+ await tick();
|
|
|
|
+ }}
|
|
|
|
+ >
|
|
|
|
+ {#if tab === 'tools'}
|
|
|
|
+ <option value="" selected disabled class="bg-gray-100 dark:bg-gray-800"
|
|
|
|
+ >{$i18n.t('Select a tool')}</option
|
|
|
|
+ >
|
|
|
|
+
|
|
|
|
+ {#each $tools as tool, toolIdx}
|
|
|
|
+ <option value={tool.id} class="bg-gray-100 dark:bg-gray-800">{tool.name}</option>
|
|
|
|
+ {/each}
|
|
|
|
+ {:else if tab === 'functions'}
|
|
|
|
+ <option value="" selected disabled class="bg-gray-100 dark:bg-gray-800"
|
|
|
|
+ >{$i18n.t('Select a function')}</option
|
|
|
|
+ >
|
|
|
|
+
|
|
|
|
+ {#each $functions as func, funcIdx}
|
|
|
|
+ <option value={func.id} class="bg-gray-100 dark:bg-gray-800">{func.name}</option>
|
|
|
|
+ {/each}
|
|
|
|
+ {/if}
|
|
|
|
+ </select>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
|
|
|
|
- {#if selectedId}
|
|
|
|
- <hr class="dark:border-gray-800 my-1 w-full" />
|
|
|
|
-
|
|
|
|
- <div class="my-2 text-xs">
|
|
|
|
- {#if !loading}
|
|
|
|
- <Valves
|
|
|
|
- {valvesSpec}
|
|
|
|
- bind:valves
|
|
|
|
- on:change={() => {
|
|
|
|
- debounceSubmitHandler();
|
|
|
|
- }}
|
|
|
|
- />
|
|
|
|
- {:else}
|
|
|
|
- <Spinner className="size-5" />
|
|
|
|
- {/if}
|
|
|
|
- </div>
|
|
|
|
- {/if}
|
|
|
|
- </div>
|
|
|
|
-</form>
|
|
|
|
|
|
+ {#if selectedId}
|
|
|
|
+ <hr class="dark:border-gray-800 my-1 w-full" />
|
|
|
|
+
|
|
|
|
+ <div class="my-2 text-xs">
|
|
|
|
+ {#if !loading}
|
|
|
|
+ <Valves
|
|
|
|
+ {valvesSpec}
|
|
|
|
+ bind:valves
|
|
|
|
+ on:change={() => {
|
|
|
|
+ debounceSubmitHandler();
|
|
|
|
+ }}
|
|
|
|
+ />
|
|
|
|
+ {:else}
|
|
|
|
+ <Spinner className="size-5" />
|
|
|
|
+ {/if}
|
|
|
|
+ </div>
|
|
|
|
+ {/if}
|
|
|
|
+ </div>
|
|
|
|
+ </form>
|
|
|
|
+{:else}
|
|
|
|
+ <Spinner className="size-6" />
|
|
|
|
+{/if}
|