feat(manager): notification bell, sign-in/venue/print settings, log download (platform-v2 2.6f)
- Bell in the header: /api/platform/notifications with unread count, live via
the new LiveProvider (one createLiveClient connection) on platform_notification
and reconnect; mark read / all; warning+critical pop a toast.
- Settings: Sign-in card (manager/waiter/device modes, require username, one
session per manager/waiter, username autofill) replaces the dead v1
security.login_method card; new "Venue & language" tab (language, time zone);
print alert threshold in Printing. Tab labels are i18n keys.
- Technical > Log files: list + download of the daily logs (owner-level).
Backend: GET /api/system/logs, /api/system/logs/{date} (core.settings.manage),
error system.log_not_found.
- Setup wizard asks staff language and time zone (setup/init stores them).
- @xenia/ui theme helpers (applyTheme, getStoredTheme); the manager stays light
until phase 6 converts the older pages (owner decision 2026-11-14).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -68,5 +68,8 @@
|
||||
"catalog": {
|
||||
"unknown_category": "Δεν υπάρχει η κατηγορία {{category_id}}.",
|
||||
"primary_not_listed": "Η κύρια κατηγορία ({{category_id}}) πρέπει να είναι μία από τις κατηγορίες του προϊόντος."
|
||||
},
|
||||
"system": {
|
||||
"log_not_found": "Δεν υπάρχει αρχείο καταγραφής για {{date}}."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,5 +283,84 @@
|
||||
"waiting": "Σε αναμονή"
|
||||
},
|
||||
"order": "Παραγγελία #{{id}}"
|
||||
},
|
||||
"notifications": {
|
||||
"bell": "Ειδοποιήσεις",
|
||||
"bellUnread_one": "Ειδοποιήσεις: {{count}} αδιάβαστη",
|
||||
"bellUnread_other": "Ειδοποιήσεις: {{count}} αδιάβαστες",
|
||||
"title": "Ειδοποιήσεις",
|
||||
"empty": "Τίποτα καινούργιο. Εδώ εμφανίζονται ειδοποιήσεις για την άδεια, την εκτύπωση και την υποστήριξη.",
|
||||
"markAll": "Όλες διαβασμένες",
|
||||
"times_one": "{{count}} φορά",
|
||||
"times_other": "{{count}} φορές"
|
||||
},
|
||||
"settings": {
|
||||
"saved": "Αποθηκεύτηκε",
|
||||
"tabs": {
|
||||
"app-info": "Γενικά",
|
||||
"venue": "Κατάστημα & γλώσσα",
|
||||
"security": "Σύνδεση & ασφάλεια",
|
||||
"operation": "Λειτουργία",
|
||||
"colours": "Εμφάνιση",
|
||||
"print-fonts": "Εκτύπωση",
|
||||
"fiscal": "Ταμειακή",
|
||||
"development": "Developer"
|
||||
},
|
||||
"mode": {
|
||||
"password": "Κωδικός",
|
||||
"pin": "PIN",
|
||||
"tap": "Επιλογή ονόματος",
|
||||
"none": "Χωρίς σύνδεση"
|
||||
},
|
||||
"session": {
|
||||
"off": "Επιτρέπεται σε πολλές συσκευές",
|
||||
"refuse_new": "Άρνηση δεύτερης σύνδεσης",
|
||||
"end_old": "Αποσύνδεση της παλιότερης"
|
||||
},
|
||||
"signIn": {
|
||||
"title": "Σύνδεση",
|
||||
"intro": "Πώς κάθε εφαρμογή ρωτά ποιος είναι ο χρήστης. Οι αλλαγές ισχύουν από την επόμενη σύνδεση.",
|
||||
"manager": "Οι υπεύθυνοι συνδέονται στη διαχείριση με",
|
||||
"managerTip": "Με PIN, οι υπεύθυνοι βάζουν το ίδιο PIN που χρησιμοποιούν για ξεκλείδωμα και εγκρίσεις. Κάθε υπεύθυνος χρειάζεται PIN.",
|
||||
"autofill": "Συμπλήρωση ονόματος χρήστη όταν υπάρχει ένας μόνο υπεύθυνος",
|
||||
"autofillHint": "Η σελίδα σύνδεσης ζητά τότε μόνο τον κωδικό ή το PIN.",
|
||||
"waiter": "Οι σερβιτόροι συνδέονται στην εφαρμογή τους με",
|
||||
"waiterTapWarning": "Η «Επιλογή ονόματος» λειτουργεί μόνο σε συζευγμένες συσκευές. Από τα δικά τους κινητά οι σερβιτόροι δεν μπορούν να συνδεθούν έτσι.",
|
||||
"requireUsername": "Οι σερβιτόροι γράφουν το όνομα χρήστη τους",
|
||||
"requireUsernameHint": "Αντί να επιλέγουν το όνομά τους από τη λίστα.",
|
||||
"device": "Στις συζευγμένες συσκευές (οθόνη κουζίνας, ταμείο πάγκου) το προσωπικό συνδέεται με",
|
||||
"deviceHint": "Κάθε συσκευή μπορεί να έχει δική της επιλογή στη σελίδα Συσκευές.",
|
||||
"singleManager": "Μία σύνδεση ανά υπεύθυνο",
|
||||
"singleWaiter": "Μία σύνδεση ανά σερβιτόρο",
|
||||
"singleTip": "Όταν κάποιος είναι ήδη συνδεδεμένος σε άλλη συσκευή: επιτρέπονται και οι δύο, απορρίπτεται η νέα σύνδεση ή αποσυνδέεται η παλιότερη."
|
||||
},
|
||||
"venue": {
|
||||
"title": "Κατάστημα",
|
||||
"language": "Γλώσσα",
|
||||
"languageHint": "Για όσους δεν έχουν διαλέξει δική τους, και για τα εκτυπωμένα δελτία και τις αναφορές.",
|
||||
"timezone": "Ζώνη ώρας",
|
||||
"timezoneHint": "Όλες οι ώρες εμφανίζονται σε αυτή. Η ώρα εκεί τώρα: {{time}}."
|
||||
},
|
||||
"print": {
|
||||
"title": "Ειδοποιήσεις εκτύπωσης",
|
||||
"alert": "Ειδοποίηση των υπευθύνων όταν ένα δελτίο δεν τυπώνεται",
|
||||
"alertHint": "Όσο συνεχίζει να ξαναδοκιμάζει. Ένα δελτίο που εγκαταλείπεται οριστικά αναφέρεται πάντα.",
|
||||
"never": "Μόνο όταν εγκαταλειφθεί",
|
||||
"after_one": "Μετά από {{count}} αποτυχία",
|
||||
"after_other": "Μετά από {{count}} αποτυχίες"
|
||||
}
|
||||
},
|
||||
"logs": {
|
||||
"tab": "Αρχεία καταγραφής",
|
||||
"intro": "Τα ημερήσια αρχεία καταγραφής του συστήματος, που κρατιούνται 30 ημέρες. Η υποστήριξη μπορεί να ζητήσει το αρχείο της ημέρας που κάτι πήγε στραβά. Οι ημέρες είναι σε ώρα UTC.",
|
||||
"empty": "Δεν υπάρχουν αρχεία ακόμα",
|
||||
"current": "(γράφεται ακόμα)",
|
||||
"size": "{{size}} KB",
|
||||
"download": "Λήψη"
|
||||
},
|
||||
"setup": {
|
||||
"language": "Γλώσσα προσωπικού",
|
||||
"timezone": "Ζώνη ώρας",
|
||||
"languageHint": "Η γλώσσα των οθονών του προσωπικού (ο καθένας μπορεί να διαλέξει τη δική του) και των εκτυπωμένων δελτίων και αναφορών."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,5 +68,8 @@
|
||||
"catalog": {
|
||||
"unknown_category": "There is no category {{category_id}}.",
|
||||
"primary_not_listed": "The main category ({{category_id}}) must be one of the product's categories."
|
||||
},
|
||||
"system": {
|
||||
"log_not_found": "There is no log file for {{date}}."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,5 +283,84 @@
|
||||
"waiting": "Waiting"
|
||||
},
|
||||
"order": "Order #{{id}}"
|
||||
},
|
||||
"notifications": {
|
||||
"bell": "Notifications",
|
||||
"bellUnread_one": "Notifications: {{count}} unread",
|
||||
"bellUnread_other": "Notifications: {{count}} unread",
|
||||
"title": "Notifications",
|
||||
"empty": "Nothing new. Licence, printing and support alerts show up here.",
|
||||
"markAll": "Mark all as read",
|
||||
"times_one": "{{count}} time",
|
||||
"times_other": "{{count}} times"
|
||||
},
|
||||
"settings": {
|
||||
"saved": "Saved",
|
||||
"tabs": {
|
||||
"app-info": "General",
|
||||
"venue": "Venue & language",
|
||||
"security": "Sign-in & security",
|
||||
"operation": "Operation",
|
||||
"colours": "Appearance",
|
||||
"print-fonts": "Printing",
|
||||
"fiscal": "Fiscal device",
|
||||
"development": "Developer"
|
||||
},
|
||||
"mode": {
|
||||
"password": "Password",
|
||||
"pin": "PIN",
|
||||
"tap": "Tap your name",
|
||||
"none": "No sign-in"
|
||||
},
|
||||
"session": {
|
||||
"off": "Allowed on several devices",
|
||||
"refuse_new": "Refuse a second sign-in",
|
||||
"end_old": "Sign out the older one"
|
||||
},
|
||||
"signIn": {
|
||||
"title": "Sign-in",
|
||||
"intro": "How each app asks people who they are. Changes apply to the next sign-in.",
|
||||
"manager": "Managers sign in to this dashboard with",
|
||||
"managerTip": "With PIN, managers type the same PIN they use to unlock the screen and to approve actions. Every manager needs a PIN.",
|
||||
"autofill": "Fill in the username when there is only one manager",
|
||||
"autofillHint": "The sign-in page then only asks for the password or PIN.",
|
||||
"waiter": "Waiters sign in to the waiter app with",
|
||||
"waiterTapWarning": "\"Tap your name\" works only on paired devices. On their own phones, waiters can't sign in this way.",
|
||||
"requireUsername": "Waiters type their username",
|
||||
"requireUsernameHint": "Instead of picking their name from the list.",
|
||||
"device": "On paired devices (kitchen display, counter POS), staff sign in with",
|
||||
"deviceHint": "Each device can choose its own on the Devices page.",
|
||||
"singleManager": "One session per manager",
|
||||
"singleWaiter": "One session per waiter",
|
||||
"singleTip": "When someone is already signed in on another device: allow both, refuse the new sign-in, or sign out the older one."
|
||||
},
|
||||
"venue": {
|
||||
"title": "Venue",
|
||||
"language": "Language",
|
||||
"languageHint": "For staff who haven't chosen their own, and for printed tickets and reports.",
|
||||
"timezone": "Time zone",
|
||||
"timezoneHint": "Every time is shown in it. The time there now: {{time}}."
|
||||
},
|
||||
"print": {
|
||||
"title": "Print alerts",
|
||||
"alert": "Tell managers when a ticket fails to print",
|
||||
"alertHint": "While it keeps retrying. A ticket that is finally given up is always reported.",
|
||||
"never": "Only when it is given up",
|
||||
"after_one": "After {{count}} failed attempt",
|
||||
"after_other": "After {{count}} failed attempts"
|
||||
}
|
||||
},
|
||||
"logs": {
|
||||
"tab": "Log files",
|
||||
"intro": "The system's daily log files, kept for 30 days. Support may ask for the file of the day something went wrong. Days are in UTC.",
|
||||
"empty": "No log files yet",
|
||||
"current": "(still being written)",
|
||||
"size": "{{size}} KB",
|
||||
"download": "Download"
|
||||
},
|
||||
"setup": {
|
||||
"language": "Staff language",
|
||||
"timezone": "Time zone",
|
||||
"languageHint": "The language of staff screens (each person can choose their own) and of printed tickets and reports."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,3 +22,4 @@ export { Field, Input, Textarea, Select } from './components/Field.jsx'
|
||||
export { Switch } from './components/Switch.jsx'
|
||||
export { UiLabelsProvider, DEFAULT_LABELS } from './components/labels.js'
|
||||
export { cx } from './internal/cx.js'
|
||||
export { THEMES, THEME_STORAGE_KEY, applyTheme, getStoredTheme } from './theme.js'
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// The colour theme of an app (plan step 2.6f): light | dark | system (follows the OS).
|
||||
// tokens.css reads it from data-theme on <html>. The choice is per device (localStorage),
|
||||
// like a screen setting, not per user. No React here.
|
||||
//
|
||||
// applyTheme(getStoredTheme()) at startup
|
||||
// applyTheme('dark', { save: true }) when the user picks one
|
||||
//
|
||||
// The manager offers the choice only once its older pages use the tokens (phase 6): until
|
||||
// then it always applies 'light' (decided 2026-11-14), so a saved choice waits unused.
|
||||
|
||||
export const THEMES = ['light', 'dark', 'system']
|
||||
export const THEME_STORAGE_KEY = 'xenia_theme'
|
||||
|
||||
const browserStorage = () => { try { return globalThis.localStorage ?? null } catch { return null } }
|
||||
|
||||
/** The saved theme, or 'light'. */
|
||||
export function getStoredTheme(storage = browserStorage()) {
|
||||
try {
|
||||
const v = storage?.getItem(THEME_STORAGE_KEY)
|
||||
return THEMES.includes(v) ? v : 'light'
|
||||
} catch {
|
||||
return 'light'
|
||||
}
|
||||
}
|
||||
|
||||
/** Set data-theme on the root element (and save it when asked). Unknown values become 'light'. */
|
||||
export function applyTheme(theme, { root = globalThis.document?.documentElement, storage = browserStorage(), save = false } = {}) {
|
||||
const t = THEMES.includes(theme) ? theme : 'light'
|
||||
root?.setAttribute('data-theme', t)
|
||||
if (save) {
|
||||
try { storage?.setItem(THEME_STORAGE_KEY, t) } catch { /* private mode: not remembered */ }
|
||||
}
|
||||
return t
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { test } from 'node:test'
|
||||
import { applyTheme, getStoredTheme, THEME_STORAGE_KEY } from '../src/theme.js'
|
||||
|
||||
const memory = () => { const m = new Map(); return { getItem: k => m.get(k) ?? null, setItem: (k, v) => m.set(k, v) } }
|
||||
const element = () => { const a = {}; return { setAttribute: (k, v) => { a[k] = v }, attrs: a } }
|
||||
|
||||
test('stored theme: light unless a known one is saved', () => {
|
||||
const s = memory()
|
||||
assert.equal(getStoredTheme(s), 'light')
|
||||
s.setItem(THEME_STORAGE_KEY, 'neon')
|
||||
assert.equal(getStoredTheme(s), 'light')
|
||||
s.setItem(THEME_STORAGE_KEY, 'system')
|
||||
assert.equal(getStoredTheme(s), 'system')
|
||||
assert.equal(getStoredTheme({ getItem: () => { throw new Error('blocked') } }), 'light')
|
||||
})
|
||||
|
||||
test('applyTheme sets data-theme and saves only when asked', () => {
|
||||
const s = memory()
|
||||
const root = element()
|
||||
assert.equal(applyTheme('dark', { root, storage: s }), 'dark')
|
||||
assert.equal(root.attrs['data-theme'], 'dark')
|
||||
assert.equal(getStoredTheme(s), 'light')
|
||||
applyTheme('dark', { root, storage: s, save: true })
|
||||
assert.equal(getStoredTheme(s), 'dark')
|
||||
assert.equal(applyTheme('bogus', { root, storage: s }), 'light')
|
||||
})
|
||||
Reference in New Issue
Block a user