feat: showing recipe list values

- add displaying for values in recipe list, with some editable fields except topping, string params, feed pattern/level

Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
pakintada@gmail.com 2026-03-04 13:28:14 +07:00
parent 4866674f26
commit dbb5ce466c
14 changed files with 640 additions and 37 deletions

View file

@ -11,14 +11,56 @@
import { auth } from '$lib/core/stores/auth';
import { get } from 'svelte/store';
import { connectToWebsocket } from '$lib/core/stores/websocketStore';
import * as adb from '$lib/core/adb/adb';
import { addNotification } from '$lib/core/stores/noti';
import { AdbDaemonWebUsbDeviceManager } from '@yume-chan/adb-daemon-webusb';
import AdbWebCredentialStore from '@yume-chan/adb-credential-web';
import { deviceCredentialManager } from '$lib/core/adb/deviceCredManager';
let { children } = $props();
onMount(() => {
async function tryAutoConnect() {
try {
if (!('usb' in navigator) || !AdbDaemonWebUsbDeviceManager.BROWSER) {
throw new Error('WebUSB not supported, try using fallback or different browser');
}
const devices = await AdbDaemonWebUsbDeviceManager.BROWSER.getDevices();
if (!devices || devices.length == 0) {
throw new Error('No device found');
}
if (devices.length > 1) {
throw new Error('Too many connected devices');
}
const device = devices[0];
const credStore = new AdbWebCredentialStore();
try {
await adb.connectDeviceByCred(device, credStore);
return true;
} catch (e: any) {
if (e.message === 'CREDENTIAL_EXPIRED') {
try {
await deviceCredentialManager.clearAllCredentials();
} catch (ignored) {}
}
return false;
}
} catch (e) {
console.error('error on auto connect brew page', e);
addNotification('ERROR:Failed to auto connect, please try again');
}
}
onMount(async () => {
let currentUser = get(auth);
console.log(`on mount layout current user: ${JSON.stringify(currentUser)}`);
// console.log(`on mount layout current user: ${JSON.stringify(currentUser)}`);
if (currentUser) {
connectToWebsocket();
await tryAutoConnect();
}
});
</script>

View file

@ -21,6 +21,7 @@
import { AdbDaemonWebUsbDeviceManager } from '@yume-chan/adb-daemon-webusb';
import AdbWebCredentialStore from '@yume-chan/adb-credential-web';
import { deviceCredentialManager } from '$lib/core/adb/deviceCredManager';
import { afterNavigate } from '$app/navigation';
const sourceDir = '/sdcard/coffeevending';
@ -36,8 +37,11 @@
let instance = adb.getAdbInstance();
recipeFromMachineLoading.set(true);
referenceFromPage.set('brew');
console.log('check instance', instance);
if (instance) {
console.log('instance passed!');
let dev_recipe = await adb.pull(`${sourceDir}/cfg/recipe_branch_dev.json`);
// console.log('dev recipe ok', dev_recipe);
if (dev_recipe) {
if (dev_recipe.length == 0) {
// case error, do last retry
@ -158,9 +162,7 @@
}
}
onMount(async () => {
// do auto connect
if (!adb.getAdbInstance()) await tryAutoConnect();
afterNavigate(async () => {
await startFetchRecipeFromMachine();
});

View file

@ -25,6 +25,7 @@
extractCookieOnNonBrowser,
setCookieOnNonBrowser
} from '$lib/helpers/cookie';
import { connectToWebsocket } from '$lib/core/stores/websocketStore';
let { children } = $props();
@ -48,6 +49,11 @@
});
return authStore.subscribe(async function (user) {
// console.log(`store get ${JSON.stringify(user)}`);
if (user != null) {
connectToWebsocket();
}
// reloading permissions
if (get(currentPermissions).length == 0 && user != null) {
// need update