From e25881d016d28578b44bb9184b2f8c4e03272bba Mon Sep 17 00:00:00 2001 From: "pakintada@gmail.com" Date: Wed, 29 Apr 2026 17:41:36 +0700 Subject: [PATCH] feat: add ui block while brewing - fix case value show invalid after come back from brewing finish (topping not save) - add update machine status Signed-off-by: pakintada@gmail.com --- .../recipe-details/recipe-detail.svelte | 43 +++++++++---- .../components/recipe-editor-dialog.svelte | 17 +++++- src/lib/components/ui/item/index.ts | 34 +++++++++++ .../components/ui/item/item-actions.svelte | 20 ++++++ .../components/ui/item/item-content.svelte | 23 +++++++ .../ui/item/item-description.svelte | 23 +++++++ src/lib/components/ui/item/item-footer.svelte | 20 ++++++ src/lib/components/ui/item/item-group.svelte | 21 +++++++ src/lib/components/ui/item/item-header.svelte | 20 ++++++ src/lib/components/ui/item/item-media.svelte | 42 +++++++++++++ .../components/ui/item/item-separator.svelte | 19 ++++++ src/lib/components/ui/item/item-title.svelte | 20 ++++++ src/lib/components/ui/item/item.svelte | 61 +++++++++++++++++++ .../components/ui/separator/separator.svelte | 4 +- src/lib/core/handlers/adbPayloadHandler.ts | 2 + src/lib/core/stores/machineInfoStore.ts | 19 +++++- 16 files changed, 371 insertions(+), 17 deletions(-) create mode 100644 src/lib/components/ui/item/index.ts create mode 100644 src/lib/components/ui/item/item-actions.svelte create mode 100644 src/lib/components/ui/item/item-content.svelte create mode 100644 src/lib/components/ui/item/item-description.svelte create mode 100644 src/lib/components/ui/item/item-footer.svelte create mode 100644 src/lib/components/ui/item/item-group.svelte create mode 100644 src/lib/components/ui/item/item-header.svelte create mode 100644 src/lib/components/ui/item/item-media.svelte create mode 100644 src/lib/components/ui/item/item-separator.svelte create mode 100644 src/lib/components/ui/item/item-title.svelte create mode 100644 src/lib/components/ui/item/item.svelte diff --git a/src/lib/components/recipe-details/recipe-detail.svelte b/src/lib/components/recipe-details/recipe-detail.svelte index 445d547..4634d96 100644 --- a/src/lib/components/recipe-details/recipe-detail.svelte +++ b/src/lib/components/recipe-details/recipe-detail.svelte @@ -4,6 +4,9 @@ import Label from '$lib/components/ui/label/label.svelte'; import Input from '$lib/components/ui/input/input.svelte'; import Button from '$lib/components/ui/button/button.svelte'; + import Spinner from '$lib/components/ui/spinner/spinner.svelte'; + import { Badge } from '$lib/components/ui/badge/index'; + import * as Item from '$lib/components/ui/item/index'; import { createEventDispatcher, onDestroy, onMount } from 'svelte'; import RecipelistTable from './recipelist-table.svelte'; @@ -17,7 +20,7 @@ materialFromServerQuery } from '$lib/core/stores/recipeStore'; import { generateIcing } from '$lib/helpers/icingGen'; - import { machineInfoStore } from '$lib/core/stores/machineInfoStore'; + import { getMachineStatus, machineInfoStore } from '$lib/core/stores/machineInfoStore'; import MachineInfo from '../machine-info.svelte'; import { v4 as uuidv4 } from 'uuid'; import { addNotification } from '$lib/core/stores/noti'; @@ -212,13 +215,13 @@ {#if refPage === 'brew'}
- - + + {#if $machineInfoStore?.status == 'IDLE' || $machineInfoStore?.status == ''} + + {/if}
{/if} @@ -244,12 +247,26 @@ - + + + {#if $machineInfoStore?.status == 'IDLE' || $machineInfoStore?.status == ''} + + {:else} + + +
+
+ Machine is working. Please wait for a moment. +
+
+
+
+ {/if}
diff --git a/src/lib/components/recipe-editor-dialog.svelte b/src/lib/components/recipe-editor-dialog.svelte index 9e73037..1b47cd8 100644 --- a/src/lib/components/recipe-editor-dialog.svelte +++ b/src/lib/components/recipe-editor-dialog.svelte @@ -11,6 +11,8 @@ import { get } from 'svelte/store'; import * as Dialog from '$lib/components/ui/dialog/index'; + import Spinner from '$lib/components/ui/spinner/spinner.svelte'; + import { Badge } from '$lib/components/ui/badge/index'; import RecipeDetail from './recipe-details/recipe-detail.svelte'; import { MenuStatus, matchMenuStatus } from '$lib/core/types/menuStatus'; @@ -23,6 +25,7 @@ import { sendMessage } from '$lib/core/handlers/ws_messageSender'; import { auth } from '$lib/core/stores/auth'; import { departmentStore } from '$lib/core/stores/departments'; + import { getMachineStatus, machineInfoStore } from '$lib/core/stores/machineInfoStore'; const isDesktop = new MediaQuery('(min-width: 768px)'); @@ -227,6 +230,9 @@ console.log('sending brewing payload', ready_to_send_brew); + // save topping + latestRecipeToppingData.set(ready_to_send_brew[0]['ToppingSet']); + await sendToAndroid({ type: 'brew', payload: { @@ -285,7 +291,16 @@ > - Edit Recipe {productCode} + Edit Recipe {productCode} + + {#if $machineInfoStore?.status == 'IDLE' || $machineInfoStore?.status == ''} + Ready + {:else} + Brewing + {/if} + + Make changes to selected menu here. Click "save" when done or "test" for testing with connected machine diff --git a/src/lib/components/ui/item/index.ts b/src/lib/components/ui/item/index.ts new file mode 100644 index 0000000..168bc3e --- /dev/null +++ b/src/lib/components/ui/item/index.ts @@ -0,0 +1,34 @@ +import Root from "./item.svelte"; +import Group from "./item-group.svelte"; +import Separator from "./item-separator.svelte"; +import Header from "./item-header.svelte"; +import Footer from "./item-footer.svelte"; +import Content from "./item-content.svelte"; +import Title from "./item-title.svelte"; +import Description from "./item-description.svelte"; +import Actions from "./item-actions.svelte"; +import Media from "./item-media.svelte"; + +export { + Root, + Group, + Separator, + Header, + Footer, + Content, + Title, + Description, + Actions, + Media, + // + Root as Item, + Group as ItemGroup, + Separator as ItemSeparator, + Header as ItemHeader, + Footer as ItemFooter, + Content as ItemContent, + Title as ItemTitle, + Description as ItemDescription, + Actions as ItemActions, + Media as ItemMedia, +}; diff --git a/src/lib/components/ui/item/item-actions.svelte b/src/lib/components/ui/item/item-actions.svelte new file mode 100644 index 0000000..4f661a3 --- /dev/null +++ b/src/lib/components/ui/item/item-actions.svelte @@ -0,0 +1,20 @@ + + +
+ {@render children?.()} +
diff --git a/src/lib/components/ui/item/item-content.svelte b/src/lib/components/ui/item/item-content.svelte new file mode 100644 index 0000000..2649b79 --- /dev/null +++ b/src/lib/components/ui/item/item-content.svelte @@ -0,0 +1,23 @@ + + +
+ {@render children?.()} +
diff --git a/src/lib/components/ui/item/item-description.svelte b/src/lib/components/ui/item/item-description.svelte new file mode 100644 index 0000000..a15632b --- /dev/null +++ b/src/lib/components/ui/item/item-description.svelte @@ -0,0 +1,23 @@ + + +

a:hover]:text-primary line-clamp-2 font-normal [&>a]:underline [&>a]:underline-offset-4", + className + )} + {...restProps} +> + {@render children?.()} +

diff --git a/src/lib/components/ui/item/item-footer.svelte b/src/lib/components/ui/item/item-footer.svelte new file mode 100644 index 0000000..cd68c38 --- /dev/null +++ b/src/lib/components/ui/item/item-footer.svelte @@ -0,0 +1,20 @@ + + +
+ {@render children?.()} +
diff --git a/src/lib/components/ui/item/item-group.svelte b/src/lib/components/ui/item/item-group.svelte new file mode 100644 index 0000000..3e58e36 --- /dev/null +++ b/src/lib/components/ui/item/item-group.svelte @@ -0,0 +1,21 @@ + + +
+ {@render children?.()} +
diff --git a/src/lib/components/ui/item/item-header.svelte b/src/lib/components/ui/item/item-header.svelte new file mode 100644 index 0000000..e1116f4 --- /dev/null +++ b/src/lib/components/ui/item/item-header.svelte @@ -0,0 +1,20 @@ + + +
+ {@render children?.()} +
diff --git a/src/lib/components/ui/item/item-media.svelte b/src/lib/components/ui/item/item-media.svelte new file mode 100644 index 0000000..45def5a --- /dev/null +++ b/src/lib/components/ui/item/item-media.svelte @@ -0,0 +1,42 @@ + + + + +
+ {@render children?.()} +
diff --git a/src/lib/components/ui/item/item-separator.svelte b/src/lib/components/ui/item/item-separator.svelte new file mode 100644 index 0000000..992541c --- /dev/null +++ b/src/lib/components/ui/item/item-separator.svelte @@ -0,0 +1,19 @@ + + + diff --git a/src/lib/components/ui/item/item-title.svelte b/src/lib/components/ui/item/item-title.svelte new file mode 100644 index 0000000..c9a0f9b --- /dev/null +++ b/src/lib/components/ui/item/item-title.svelte @@ -0,0 +1,20 @@ + + +
+ {@render children?.()} +
diff --git a/src/lib/components/ui/item/item.svelte b/src/lib/components/ui/item/item.svelte new file mode 100644 index 0000000..6906163 --- /dev/null +++ b/src/lib/components/ui/item/item.svelte @@ -0,0 +1,61 @@ + + + + +{#if child} + {@render child({ props: mergedProps })} +{:else} +
+ {@render mergedProps.children?.()} +
+{/if} diff --git a/src/lib/components/ui/separator/separator.svelte b/src/lib/components/ui/separator/separator.svelte index f40999f..5fd8a42 100644 --- a/src/lib/components/ui/separator/separator.svelte +++ b/src/lib/components/ui/separator/separator.svelte @@ -14,7 +14,9 @@ bind:ref data-slot={dataSlot} class={cn( - "bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:min-h-full data-[orientation=vertical]:w-px", + "bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px", + // this is different in shadcn/ui but self-stretch breaks things for us + "data-[orientation=vertical]:h-full", className )} {...restProps} diff --git a/src/lib/core/handlers/adbPayloadHandler.ts b/src/lib/core/handlers/adbPayloadHandler.ts index 55e0a7b..465e052 100644 --- a/src/lib/core/handlers/adbPayloadHandler.ts +++ b/src/lib/core/handlers/adbPayloadHandler.ts @@ -1,3 +1,4 @@ +import { updateMachineStatus } from '../stores/machineInfoStore'; import { addNotification } from '../stores/noti'; type AdbPayload = { type: string; payload: any }; @@ -36,6 +37,7 @@ async function handleAdbPayload(raw_payload: string) { console.log('current state', curr, 'next state', next); addNotification('INFO:Machine Status Updated, ' + next); + updateMachineStatus(next); } break; case 'error': diff --git a/src/lib/core/stores/machineInfoStore.ts b/src/lib/core/stores/machineInfoStore.ts index 644dc90..e56b31e 100644 --- a/src/lib/core/stores/machineInfoStore.ts +++ b/src/lib/core/stores/machineInfoStore.ts @@ -1,4 +1,19 @@ import type { MachineInfo } from '$lib/models/machineInfo.model'; -import { writable } from 'svelte/store'; +import { get, writable } from 'svelte/store'; -export const machineInfoStore = writable(); +const machineInfoStore = writable(); + +function updateMachineStatus(new_status: string) { + let current = get(machineInfoStore); + if (current) { + current.status = new_status; + + machineInfoStore.set(current); + } +} + +function getMachineStatus() { + return get(machineInfoStore)?.status; +} + +export { machineInfoStore, updateMachineStatus, getMachineStatus };