feat: application shell, localized texts and user preferences (M3, part 1)
The pages built so far now live inside the shell of the mockups instead of the M0 placeholder, every interface text comes from Resources/it-IT, and each user keeps their own look and start page. - Shell: top bar, collapsible side menu with fly-out sub-menus, status bar and tabs that keep each page alive (page type and route values per tab, so a tab never shows another page); at most 12 tabs, least-used clean tab evicted. - One shortcut table with Alt variants for the combinations browsers keep (Ctrl+W, Ctrl+Tab, Ctrl+N); command palette for pages and commands. - ITexts over embedded JSON; tests forbid literal texts in .razor components and check that every key used exists. - User settings in sys_user_settings / user_settings; theme written on the server; profile page with live preview, start page, sessions and shortcuts. - Home, coming-soon pages for later milestones, localized sign-in and error pages; ADR 0020; wiki, CHANGELOG, STATUS and data model updated. Refs #25 #26 #31 #33 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1c30054e3d
commit
cf6f849cc1
72 files changed
+5785
-259
No files matched your search
@@ -7,6 +7,33 @@ un'immagine `gitea.encke-hake.ts.net/balbosoft/khaemhat:X.Y.Z`.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
M3 — Framework UI, prima parte: la shell dell'applicazione, i testi localizzati e le preferenze dell'utente.
|
||||
|
||||
### Added
|
||||
- Shell (mockup 004, 007, 013): barra superiore con marchio e versione, cambio azienda per gli account di istanza,
|
||||
ricerca, recenti, notifiche, tema rapido, aiuto e menu utente; menu laterale per sezioni con voci filtrate da
|
||||
licenza e permessi, compresso a sole icone con sottomenu a comparsa (`Ctrl+B`, stato ricordato per utente,
|
||||
compresso sotto i 1100 px); barra di stato con azienda, esercizio, utente, latenza, cache e versione.
|
||||
- Schede tenute in vita: ogni pagina aperta resta com'era passando da una scheda all'altra, pallino delle modifiche,
|
||||
conferma alla chiusura, massimo 12 schede (si chiude la meno usata senza modifiche) (ADR 0020).
|
||||
- Scorciatoie da tastiera in un'unica tabella, con le varianti `Alt+W`, `Alt+PagGiù`/`Alt+PagSu`, `Alt+N` per le
|
||||
combinazioni che i browser tengono per sé; ricerca rapida `Ctrl+K` di pagine e comandi; `F1` apre la pagina wiki
|
||||
della maschera.
|
||||
- Testi dell'interfaccia in `Resources/it-IT/*.json` letti da `ITexts`, formati italiani per importi e date; test che
|
||||
vietano i testi letterali nei componenti e controllano che ogni chiave esista.
|
||||
- *Il mio profilo*: aspetto (tema automatico, chiaro, scuro, alto contrasto; otto accenti; densità; dimensione del
|
||||
testo; menu; numeri tabellari, animazioni ridotte, suggerimenti, evidenza della riga) con anteprima dal vivo,
|
||||
pagina iniziale, sessioni attive con chiusura, elenco delle scorciatoie.
|
||||
- Preferenze salvate per utente in `sys_user_settings` (account di istanza) e `user_settings` (utenti aziendali); il
|
||||
tema è già nella pagina inviata dal server.
|
||||
- Home con licenza, moduli, azienda e aree disponibili; le aree delle prossime versioni aprono una pagina che dice
|
||||
con quale milestone arrivano.
|
||||
- Token, temi e classi dei mockup in `css/tokens.css` e `css/components.css`, sprite di icone proprie, stampa sempre
|
||||
in chiaro.
|
||||
|
||||
### Changed
|
||||
- Pagine di accesso, errori e riconnessione con i testi localizzati e i colori del tema.
|
||||
|
||||
## [0.2.0] - 2026-11-11
|
||||
|
||||
M2 — Sistema e sicurezza. L'istanza si avvia da sola, crea super utente e prima azienda, e si entra con password e
|
||||
|
||||
@@ -385,6 +385,7 @@ Migrazioni applicate in ordine:
|
||||
- `core` 20261111009 `create_sys_security_audit` (M20261111_009_CreateSysSecurityAudit)
|
||||
- `core` 20261111010 `create_sys_scheduler` (M20261111_010_CreateSysScheduler)
|
||||
- `core` 20261111011 `create_sys_notifications` (M20261111_011_CreateSysNotifications)
|
||||
- `core` 20261111012 `create_sys_user_settings` (M20261111_012_CreateSysUserSettings)
|
||||
|
||||
#### `schema_version`
|
||||
|
||||
@@ -640,6 +641,22 @@ Chiave primaria: `module`, `version`.
|
||||
|
||||
- indice unico `ux_sys_settings_key` su `key`
|
||||
|
||||
#### `sys_user_settings`
|
||||
|
||||
| Colonna | Tipo | Null | Default | Note |
|
||||
|---|---|---|---|---|
|
||||
| `id` | Int64 | no | | chiave primaria, identity |
|
||||
| `user_id` | Int64 | no | | |
|
||||
| `key` | String(200) | no | | |
|
||||
| `value` | Text | sì | | |
|
||||
| `created_at` | DateTimeUtc | no | | |
|
||||
| `created_by` | String(100) | sì | | |
|
||||
| `updated_at` | DateTimeUtc | sì | | |
|
||||
| `updated_by` | String(100) | sì | | |
|
||||
| `row_version` | Int64 | no | `1` | |
|
||||
|
||||
- indice unico `ux_sys_user_settings_user_id_key` su `user_id`, `key`
|
||||
|
||||
#### `sys_users`
|
||||
|
||||
| Colonna | Tipo | Null | Default | Note |
|
||||
@@ -683,6 +700,7 @@ Migrazioni applicate in ordine:
|
||||
- `core` 20261111003 `create_roles` (M20261111_003_CreateRoles)
|
||||
- `core` 20261111004 `create_audit_log` (M20261111_004_CreateAuditLog)
|
||||
- `core` 20261111005 `create_notifications` (M20261111_005_CreateNotifications)
|
||||
- `core` 20261111006 `create_user_settings` (M20261111_006_CreateUserSettings)
|
||||
|
||||
#### `audit_log`
|
||||
|
||||
@@ -821,6 +839,22 @@ Chiave primaria: `module`, `version`.
|
||||
- indice `ix_user_sessions_user_id` su `user_id`
|
||||
- indice unico `ux_user_sessions_token_hash` su `token_hash`
|
||||
|
||||
#### `user_settings`
|
||||
|
||||
| Colonna | Tipo | Null | Default | Note |
|
||||
|---|---|---|---|---|
|
||||
| `id` | Int64 | no | | chiave primaria, identity |
|
||||
| `user_id` | Int64 | no | | |
|
||||
| `key` | String(200) | no | | |
|
||||
| `value` | Text | sì | | |
|
||||
| `created_at` | DateTimeUtc | no | | |
|
||||
| `created_by` | String(100) | sì | | |
|
||||
| `updated_at` | DateTimeUtc | sì | | |
|
||||
| `updated_by` | String(100) | sì | | |
|
||||
| `row_version` | Int64 | no | `1` | |
|
||||
|
||||
- indice unico `ux_user_settings_user_id_key` su `user_id`, `key`
|
||||
|
||||
#### `users`
|
||||
|
||||
| Colonna | Tipo | Null | Default | Note |
|
||||
|
||||
+14
-7
@@ -3,16 +3,18 @@
|
||||
> Punto di ripresa per ogni sessione. Aggiornare a fine sessione.
|
||||
|
||||
**Ultimo aggiornamento:** 2026-11-11
|
||||
**Milestone corrente:** M2 — Sistema e sicurezza, completata nel ramo `feat/15-sistema-e-sicurezza` (PR verso `main`);
|
||||
il tag `v0.2.0` si crea dopo il merge.
|
||||
**Prossimo passo:** M3 — Interfaccia (issue #25-#36): layout, navigazione e componenti sopra le pagine di accesso di M2.
|
||||
Da recuperare: misure di riferimento su PostgreSQL in `docs/DATA-MODEL.md` §6.1; pagina di cambio password con
|
||||
indicatore di robustezza (mockup 003) in M3.
|
||||
**Milestone corrente:** M3 — Framework UI, nel ramo `feat/25-interfaccia`. Fatti: shell (#26), testi localizzati
|
||||
(#33), preferenze e profilo per aspetto, pagina iniziale e sessioni (#31, in parte), base dei temi (#25, in parte).
|
||||
**Prossimo passo:** il resto di M3: profilo con dati personali e password/2FA (#31), componenti `Kh*` (#27), toolbar e
|
||||
intestazione documento (#29), griglie e radar (#28), dashboard a widget (#30), ricerca, aiuto e notifiche (#32),
|
||||
allegati ed esportazioni (#34), chiusura (#36). #35 attende i PNG dall'utente.
|
||||
Da recuperare: misure di riferimento su PostgreSQL in `docs/DATA-MODEL.md` §6.1; indicatore di robustezza della
|
||||
password (mockup 003).
|
||||
|
||||
## Fatto
|
||||
|
||||
- Specifica normativa in `docs/SPEC.md`; `CLAUDE.md` con emendamenti E1-E6.
|
||||
- ADR 0001-0019.
|
||||
- ADR 0001-0020.
|
||||
- Mockup in `docs/mockups/` (22 in alta risoluzione + galleria, 88 miniature, `mockup.css`, indice).
|
||||
- Icone in `assets/`; deploy in `deploy/` (compose Unraid, `.env.example`, template Unraid).
|
||||
- Documentazione tecnica: `ARCHITECTURE.md`, `DATA-MODEL.md` (provvisorio, sarà generato), `MODULES.md`, `API.md`,
|
||||
@@ -30,7 +32,7 @@ indicatore di robustezza (mockup 003) in M3.
|
||||
(AES-256-GCM, formato `khs1`), `tools/Khaemhat.DataModelTool` e gli script `new-migration.sh` e
|
||||
`gen-datamodel.sh`; ADR 0018. Test: 106 test dello strato dati verdi su SQLite in locale e su PostgreSQL 16 e 17 in CI
|
||||
(in locale Docker non è disponibile).
|
||||
- **M2 (`v0.2.0`, PR da aprire):** avvio da variabili con elenco degli errori, migrazioni all'avvio, super utente e
|
||||
- **M2 (chiusa, `v0.2.0`, PR #118):** avvio da variabili con elenco degli errori, migrazioni all'avvio, super utente e
|
||||
prima azienda; account di istanza e aziendali, password con storico e blocco, sessioni nel database, TOTP con codici
|
||||
di recupero, pagine di accesso (mockup 001-003); ruoli, permessi e attributi di autorizzazione; licenze firmate,
|
||||
codici di attivazione, modalità test, `tools/Khaemhat.LicenseTool`; DataProtection nel database cifrata; cache
|
||||
@@ -38,6 +40,11 @@ indicatore di robustezza (mockup 003) in M3.
|
||||
job di sistema; storico dei record; aziende con stati e contesto (`X-Company`); header di sicurezza; ADR 0019.
|
||||
Test: 180 verdi in locale, più 21 di PostgreSQL saltati senza Docker (girano in CI). La chiave privata delle licenze è fuori dal
|
||||
repository (`Khaemhat-private/khaemhat-license.khkey`) e va conservata dal titolare.
|
||||
- **M3 (in corso, `feat/25-interfaccia`):** shell con barra superiore, menu comprimibile con sottomenu a comparsa,
|
||||
schede tenute in vita (massimo 12), barra di stato; scorciatoie con varianti `Alt`; ricerca di pagine e comandi;
|
||||
testi in `Resources/it-IT/*.json` con test anti-testo-letterale; preferenze utente in `sys_user_settings` e
|
||||
`user_settings`; *Il mio profilo* (aspetto con anteprima dal vivo, pagina iniziale, sessioni, scorciatoie); home e
|
||||
pagine "in arrivo"; ADR 0020. Test: 215 verdi in locale, 21 di PostgreSQL saltati.
|
||||
- Su Gitea: etichette, milestone M0-M14, 114 issue con checklist, progetti *Khaemhat 1.0 — Sviluppo* (M0-M13)
|
||||
e *Khaemhat 1.1+ — Fase 2* (M14). Numerazione: M0 #1-#6 e #114, M1 #7-#14, M2 #15-#24, M3 #25-#36,
|
||||
M4 #37-#46, M5 #47-#54, M6 #55-#61, M7 #62-#68, M8 #69-#73, M9 #74-#81, M10 #82-#87, M11 #88-#91,
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# ADR 0020 - Shell dell'interfaccia: schede, testi, preferenze, scorciatoie
|
||||
|
||||
- **Stato:** accettata
|
||||
- **Data:** 2026-11-11
|
||||
- **Modifica:** SPEC §1.9, §10.2, §10.5, §10.6, §10.8, §11.12; milestone M3, issue #25, #26, #31, #33
|
||||
|
||||
## Contesto
|
||||
|
||||
M3 costruisce la shell (barra superiore, menu comprimibile, schede, barra di stato), i testi localizzati e le
|
||||
preferenze utente. La specifica fissa il risultato visivo (mockup 004, 007, 008, 013) ma lascia aperti alcuni punti
|
||||
tecnici; altri si scontrano con il browser o con Blazor. Questo ADR fissa le scelte.
|
||||
|
||||
## Decisione
|
||||
|
||||
1. **Schede tenute in vita.** Ogni indirizzo aperto diventa una scheda (`TabService`, massimo 12). La scheda conserva
|
||||
il **tipo di pagina e una copia dei parametri di rotta** (`RouteData` passato in cascata da `Routes.razor`), non il
|
||||
`Body` del layout: `Body` disegna sempre la pagina corrente, quindi tutte le schede avrebbero mostrato l'ultima.
|
||||
Il layout disegna un pannello per scheda e nasconde quelli inattivi (`hidden`), così passando da una scheda
|
||||
all'altra lo stato della pagina resta. La stessa pagina con un'altra query (`/profilo?scheda=sessioni`) riusa la
|
||||
scheda. Alla tredicesima si chiude la scheda meno usata **senza modifiche**; se tutte hanno modifiche l'apertura
|
||||
è rifiutata con un avviso. Il titolo del browser lo scrive il layout dalla scheda attiva; `KhPageTitle` imposta
|
||||
solo il titolo della scheda.
|
||||
2. **Scorciatoie riservate dal browser.** `Ctrl+W`, `Ctrl+Tab` e `Ctrl+N` restano dei browser, che non le passano alla
|
||||
pagina. Si tengono come da specifica e si aggiungono `Alt+W`, `Alt+PagGiù` / `Alt+PagSu` e `Alt+N`, che arrivano
|
||||
sempre. Le scorciatoie sono un'unica tabella (`KeyboardShortcuts.All`) usata dal gestore JavaScript, dalla
|
||||
ricerca e dalla scheda *Scorciatoie* del profilo; un test controlla che ogni combinazione sia unica.
|
||||
3. **Testi in JSON incorporati.** I testi stanno in `src/Khaemhat.Web/Resources/<cultura>/*.json`, risorse incorporate
|
||||
lette da `JsonTextProvider` (`ITexts`). Gli oggetti annidati danno chiavi puntate (`Shell.Menu.Parties`), la
|
||||
proprietà `_` dà il testo all'oggetto che ha anche figli, una chiave definita due volte è un errore all'avvio, una
|
||||
chiave mancante si vede come `[chiave]`. Niente `.resx`: il JSON si legge e si confronta meglio nelle revisioni e
|
||||
non richiede generatori. Due test lo fanno rispettare: nessun testo letterale nei componenti `.razor` (testo fra i
|
||||
tag e attributi `title`, `placeholder`, `alt`, `aria-label`, `label`) e ogni chiave usata nel codice esiste.
|
||||
4. **Preferenze per utente nel database del proprietario.** `UserSettingsService` salva coppie chiave/valore in
|
||||
`sys_user_settings` per gli account di istanza e in `user_settings` per gli utenti aziendali (valore massimo 64 KB,
|
||||
chiave massimo 200 caratteri). `UserPreferences` legge e scrive l'insieme tipizzato (tema, accento, densità,
|
||||
dimensione testo, numeri tabellari, animazioni, suggerimenti, evidenza riga, menu, pagina iniziale) e scarta i
|
||||
valori non validi; la pagina iniziale accetta solo percorsi locali.
|
||||
5. **Tema scritto dal server.** Le preferenze diventano attributi `data-*` sull'elemento `<html>` già nella risposta
|
||||
del server (`App.razor`), così la prima pagina ha i colori giusti; il cambio dal profilo o dalla barra superiore li
|
||||
aggiorna dal vivo con `khaemhat.applyRoot`. Prima dell'accesso vale `data-theme="auto"`, che segue il sistema. Il
|
||||
profilo mostra ogni scelta subito (anteprima) e la conserva solo con **Salva**; chiudendo la scheda senza salvare
|
||||
torna l'aspetto salvato.
|
||||
6. **Aree non ancora costruite.** Il menu mostra le aree concesse da licenza e permessi anche se arrivano con
|
||||
milestone successive; aprono una pagina che dice con quale milestone arrivano (`MenuItem.Milestone`). Quando una
|
||||
pagina vera esiste, la sua rotta prende il posto di quella generica e la milestone si toglie dal catalogo.
|
||||
|
||||
## Conseguenze
|
||||
|
||||
- Le pagine aperte restano in memoria nel circuito finché la scheda è aperta: il limite di 12 schede tiene il
|
||||
consumo sotto controllo.
|
||||
- Una pagina che usa parametri da query li riceve anche quando è nascosta e cambia la query di un'altra scheda con
|
||||
lo stesso nome di parametro: i nomi dei parametri da query vanno scelti specifici della pagina.
|
||||
- Aggiungere un testo vuol dire aggiungere una chiave al JSON; i test falliscono se manca.
|
||||
+24
-4
@@ -1,6 +1,6 @@
|
||||
# Design UI
|
||||
|
||||
> **Stato:** bozza · **Ultima revisione:** 2026-11-10 · **Versione software:** non ancora rilasciata (milestone M3)
|
||||
> **Stato:** in corso · **Ultima revisione:** 2026-11-11 · **Versione software:** 0.3.0 in sviluppo (milestone M3)
|
||||
> **Pagina per chi sviluppa** · **Specifica:** SPEC §10 (in particolare §10.1, §10.6, §10.7, §10.8), Appendice A
|
||||
|
||||
Questa pagina è il riferimento visivo per chi sviluppa l'interfaccia di Khaemhat: come si usano i mockup, i token di
|
||||
@@ -154,6 +154,20 @@ radar, `Ctrl+Invio` apre, creazione al volo; `KhGrid` con colonne tipizzate, ord
|
||||
server, virtualizzazione, selezione multipla, editing inline, riga dei totali, layout colonne salvato, export,
|
||||
evidenziazioni, menu di riga.
|
||||
|
||||
## File CSS
|
||||
|
||||
| File | Contenuto |
|
||||
|---|---|
|
||||
| `css/tokens.css` | token `--kh-*` di `mockup.css`, temi (automatico, chiaro, scuro, alto contrasto), accenti, densità, dimensioni del testo; generato da `mockup.css` |
|
||||
| `css/components.css` | classi dei mockup (shell, toolbar, pannelli, campi, griglie, badge, dialoghi…), riprese da `mockup.css` |
|
||||
| `css/interactive.css` | ciò che i mockup statici non hanno: reset dei pulsanti, focus, suggerimenti, menu a comparsa, schede, notifiche a scomparsa, interruttori `data-*` |
|
||||
| `css/print.css` | stampa sempre in chiaro, shell nascosta |
|
||||
| `app.css` | pagine costruite finora (accesso, home, profilo, messaggi) |
|
||||
|
||||
Gli attributi sull'elemento `<html>` comandano l'aspetto: `data-theme` (`auto`, `light`, `dark`, `high-contrast`),
|
||||
`data-accent`, `data-density`, `data-text-size` (`100`, `110`, `120`), `data-tabular`, `data-motion`,
|
||||
`data-tooltips`, `data-row-hover`. Il server li scrive dalle preferenze dell'utente; il profilo li cambia dal vivo.
|
||||
|
||||
## Shell
|
||||
|
||||
- Griglia: barra superiore 46 px, area centrale, barra di stato 24 px; menu 228 px (60 px compresso).
|
||||
@@ -162,7 +176,9 @@ evidenziazioni, menu di riga.
|
||||
- **Menu**: sezioni in maiuscoletto (`.sec`), voce attiva su `--kh-accent-soft`; compresso: solo icone 20 px, barretta
|
||||
d'accento a sinistra della voce attiva, sottomenu in `.flyout` (min 190 px, ombra grande). Pulsante **Comprimi
|
||||
menu** tratteggiato in fondo. Sotto 1100 px parte compresso; stato salvato per utente.
|
||||
- **Schede** (`.wtab`): altezza 30 px, massimo 260 px di larghezza, pallino `--kh-warn` se modificata.
|
||||
- **Schede** (`.wtab`): altezza 30 px, massimo 260 px di larghezza, pallino `--kh-warn` se modificata. Ogni pagina
|
||||
imposta il titolo della sua scheda con `<KhPageTitle Text="..." Icon="..." />` e segnala le modifiche con il
|
||||
`KhTab` in cascata (`Tab?.SetModified(true)`).
|
||||
- **Barra di stato**: testo 11.5 px, pallino `--kh-ok` per la connessione.
|
||||
|
||||
Dettagli d'uso in [Interfaccia e scorciatoie](Interfaccia-e-scorciatoie).
|
||||
@@ -212,8 +228,12 @@ dal testo. Nessuna libreria di icone esterna. L'icona dell'applicazione è descr
|
||||
- **Focus sempre visibile**, etichette collegate ai campi (`<label for>`), contrasto **AA** (AAA nel tema alto
|
||||
contrasto), tutto operabile da tastiera.
|
||||
- Desktop-first, usabile da tablet a partire da **768 px**.
|
||||
- **Testi**: nessun testo hard-coded nei componenti (verificato da un test di architettura); `ITexts` risolve chiavi
|
||||
come `Sales.Invoice.Title` da `Resources/it-IT/*.json`.
|
||||
- **Testi**: nessun testo hard-coded nei componenti; `ITexts` (iniettato in ogni componente come `T`) risolve chiavi
|
||||
come `Shell.Menu.Parties` da `src/Khaemhat.Web/Resources/it-IT/*.json` (risorse incorporate). Gli oggetti annidati
|
||||
danno le chiavi puntate, la proprietà `_` dà il testo all'oggetto che ha figli, una chiave doppia blocca l'avvio e
|
||||
una mancante appare come `[chiave]`. Uso: `@T["Pages.Profile.Title"]`, `@T.Format("Pages.Home.Coming", "M4")`,
|
||||
`T.Money(1234.5m)`, `T.Date(...)`. Due test lo garantiscono: nessun testo letterale fra i tag e negli attributi
|
||||
`title`, `placeholder`, `alt`, `aria-label`, `label` dei `.razor`, e ogni chiave usata esiste (ADR 0020).
|
||||
- **Formati**: `CultureInfo("it-IT")` per numeri, importi e date; date memorizzate in UTC e mostrate nel fuso
|
||||
`Europe/Rome`.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Interfaccia e scorciatoie
|
||||
|
||||
> **Stato:** bozza · **Ultima revisione:** 2026-11-10 · **Versione software:** non ancora rilasciata (milestone M3)
|
||||
> **Stato:** in corso · **Ultima revisione:** 2026-11-11 · **Versione software:** 0.3.0 in sviluppo (milestone M3)
|
||||
> **Modulo di licenza:** CORE · **Specifica:** SPEC §10.2, §10.4, §10.5, §10.7, §17 (aiuto in app)
|
||||
|
||||
Questa pagina descrive come è fatta la finestra di Khaemhat e come ci si muove: barra superiore, menu laterale,
|
||||
@@ -66,6 +66,9 @@ Si passa da uno stato all'altro con il pulsante **Comprimi menu** in fondo al me
|
||||
**ricordato per utente** (anche fra dispositivi diversi); sotto i 1100 px di larghezza della finestra il menu parte
|
||||
compresso. Lo stato iniziale si sceglie anche in [Preferenze utente](Preferenze-utente).
|
||||
|
||||
Le aree che arrivano con le prossime versioni sono già nel menu, se la licenza e i permessi le concedono: aprendole
|
||||
compare una pagina che dice con quale milestone arrivano e quali voci conterranno.
|
||||
|
||||

|
||||
*Mockup 007 — dashboard con il menu compresso a sole icone e accento Turchese (anteprima ridotta).*
|
||||
|
||||
@@ -76,9 +79,13 @@ Le schede restano "vive": passando da una all'altra non si perde nulla di quanto
|
||||
|
||||
- Un **pallino arancione** accanto al titolo indica modifiche non salvate.
|
||||
- Chiudendo una scheda con modifiche non salvate Khaemhat chiede conferma.
|
||||
- Si possono tenere aperte al massimo **12 schede**; il comportamento all'apertura della tredicesima sarà definito in
|
||||
sviluppo.
|
||||
- `Ctrl+W` chiude la scheda attiva, `Ctrl+Tab` passa alla successiva; il pulsante `+` apre una nuova scheda.
|
||||
- Si possono tenere aperte al massimo **12 schede**. Aprendone una tredicesima si chiude da sola quella usata meno di
|
||||
recente fra quelle **senza modifiche**; se tutte hanno modifiche da salvare, Khaemhat lo dice e non apre la nuova.
|
||||
- Aprire una pagina già aperta porta alla sua scheda invece di crearne un'altra.
|
||||
- `Ctrl+W` (o `Alt+W`) chiude la scheda attiva, `Ctrl+Tab` (o `Alt+PagGiù`) passa alla successiva,
|
||||
`Ctrl+Maiusc+Tab` (o `Alt+PagSu`) alla precedente; il pulsante `+` apre la ricerca per aprire una nuova pagina.
|
||||
Molti browser tengono per sé `Ctrl+W` e `Ctrl+Tab`: le varianti con `Alt` funzionano sempre.
|
||||
- Il titolo della finestra del browser segue la scheda attiva.
|
||||
|
||||
## Barra di stato
|
||||
|
||||
@@ -91,6 +98,10 @@ e la **versione** del software con il commit (es. `v1.0.0 (a3f9c1e)`).
|
||||

|
||||
*Mockup 009 — ricerca "rossi": risultati raggruppati per clienti, articoli, documenti, contabilità e azioni (anteprima ridotta).*
|
||||
|
||||
> **In questa versione** la ricerca trova le **pagine** del menu e i **comandi** (tema, menu, profilo, sessioni,
|
||||
> scorciatoie); clienti, articoli e documenti si aggiungono con le milestone che li introducono. Il prefisso `>`
|
||||
> mostra solo i comandi.
|
||||
|
||||
Premi `Ctrl+K` (o fai clic sulla casella di ricerca) e digita. I risultati arrivano mentre scrivi, raggruppati per
|
||||
tipo: **clienti e fornitori**, **articoli**, **documenti**, **registrazioni e conti** contabili, **azioni** (ad
|
||||
esempio *Nuova fattura per Rossi Impianti*, *Registra incasso*, *Scheda cliente a 360°*).
|
||||
@@ -254,9 +265,10 @@ sviluppo e documentate qui.
|
||||
| `Ctrl+K` | ricerca globale | ovunque |
|
||||
| `F1` | aiuto della maschera corrente | ovunque |
|
||||
| `Ctrl+B` | comprime / espande il menu laterale | ovunque |
|
||||
| `Ctrl+W` | chiude la scheda attiva | ovunque |
|
||||
| `Ctrl+Tab` | passa alla scheda successiva | ovunque |
|
||||
| `Ctrl+N` | nuovo record / documento | maschere e radar |
|
||||
| `Ctrl+W` o `Alt+W` | chiude la scheda attiva | ovunque |
|
||||
| `Ctrl+Tab` o `Alt+PagGiù` | passa alla scheda successiva | ovunque |
|
||||
| `Ctrl+Maiusc+Tab` o `Alt+PagSu` | passa alla scheda precedente | ovunque |
|
||||
| `Ctrl+N` o `Alt+N` | nuovo record / documento | maschere e radar |
|
||||
| `Ctrl+S` | salva | maschere |
|
||||
| `Esc` | annulla le modifiche / chiude la finestra aperta | maschere, finestre |
|
||||
| `Ctrl+Canc` | elimina il record (se ammesso) | maschere |
|
||||
@@ -274,8 +286,8 @@ sviluppo e documentate qui.
|
||||
| `T`, `F`, `+`, `-` | oggi, fine mese, giorno dopo/prima | campi data |
|
||||
| `=` | calcolo inline (`=10*3`) | campi numerici |
|
||||
|
||||
Le scorciatoie personali si potranno adattare nelle preferenze utente (§11.12 della specifica); l'interfaccia di
|
||||
personalizzazione sarà definita in sviluppo.
|
||||
L'elenco è anche in **Il mio profilo → Scorciatoie** ([Preferenze utente](Preferenze-utente)). Le varianti con `Alt`
|
||||
esistono perché i browser non passano alla pagina `Ctrl+W`, `Ctrl+Tab` e `Ctrl+N` (ADR 0020).
|
||||
|
||||
## Permessi e licenza
|
||||
|
||||
@@ -289,6 +301,7 @@ un permesso negato.
|
||||
amministratore.
|
||||
- **Ho chiuso una scheda per sbaglio.** Se c'erano modifiche non salvate Khaemhat ti ha chiesto conferma; il
|
||||
documento salvato si ritrova con **Recenti** o con `Ctrl+K`.
|
||||
- **`Ctrl+W` chiude il browser invece della scheda.** È il browser che tiene per sé la combinazione: usa `Alt+W`.
|
||||
- **Il menu si è compresso da solo.** Sotto i 1100 px di larghezza il menu parte compresso; allarga la finestra o
|
||||
premi `Ctrl+B`.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Preferenze utente (Il mio profilo)
|
||||
|
||||
> **Stato:** bozza · **Ultima revisione:** 2026-11-10 · **Versione software:** non ancora rilasciata (milestone M3)
|
||||
> **Stato:** in corso · **Ultima revisione:** 2026-11-11 · **Versione software:** 0.3.0 in sviluppo (milestone M3)
|
||||
> **Modulo di licenza:** CORE · **Specifica:** SPEC §7.3, §10.6, §11.12 (preferenze), §12 (Il mio profilo)
|
||||
|
||||
**Il mio profilo** raccoglie tutto ciò che riguarda te come utente: aspetto dell'interfaccia (tema, colore di
|
||||
@@ -9,25 +9,29 @@ salvati e notifiche. Ogni utente può modificare il proprio profilo senza permes
|
||||
|
||||
## Dove si trova
|
||||
|
||||
Menu utente in alto a destra (iniziali e nome) → **Il mio profilo**. Il percorso mostrato nella maschera è
|
||||
*Utente → Preferenze*.
|
||||
Menu utente in alto a destra (iniziali e nome) → **Il mio profilo**, **Aspetto e colori** o **Sessioni attive**;
|
||||
oppure `Ctrl+K` e il comando corrispondente. L'indirizzo è `/profilo`, con `?scheda=aspetto`, `pagina-iniziale`,
|
||||
`sessioni` o `scorciatoie` per aprire direttamente una scheda.
|
||||
|
||||

|
||||
*Mockup 008 — scheda Aspetto con tema Scuro (notturno) e accento Ocra selezionati; a destra l'anteprima dal vivo.*
|
||||
|
||||
## Schede della maschera
|
||||
|
||||
| Scheda | Contenuto |
|
||||
|---|---|
|
||||
| **Aspetto** | tema, colore di accento, densità, dimensione testo, menu laterale, suggerimenti, animazioni |
|
||||
| **Dati personali** | nome, e-mail e altri dati del tuo utente |
|
||||
| **Password e 2FA** | cambio password, attivazione della verifica in due passaggi |
|
||||
| **Sessioni** | dispositivi collegati con il tuo utente (il numero accanto al titolo indica quante sono) |
|
||||
| **Pagina iniziale** | cosa aprire all'accesso, dashboard sì/no |
|
||||
| **Layout salvati** | filtri e disposizioni di colonne memorizzati nei radar e nelle griglie |
|
||||
| **Notifiche** | quali notifiche ricevere e il riepilogo via e-mail |
|
||||
| Scheda | Contenuto | Disponibile |
|
||||
|---|---|---|
|
||||
| **Aspetto** | tema, colore di accento, densità, dimensione testo, menu laterale, suggerimenti, animazioni | 0.3.0 |
|
||||
| **Pagina iniziale** | cosa aprire all'accesso, dashboard sì/no | 0.3.0 |
|
||||
| **Sessioni** | dispositivi collegati con il tuo utente, chiusura | 0.3.0 |
|
||||
| **Scorciatoie** | l'elenco delle scorciatoie da tastiera | 0.3.0 |
|
||||
| **Dati personali** | nome, e-mail e altri dati del tuo utente | prossima parte di M3 |
|
||||
| **Password e 2FA** | cambio password, attivazione della verifica in due passaggi | prossima parte di M3 |
|
||||
| **Layout salvati** | filtri e disposizioni di colonne memorizzati nei radar e nelle griglie | con le griglie (M3) |
|
||||
| **Notifiche** | quali notifiche ricevere e il riepilogo via e-mail | con le notifiche (M3) |
|
||||
|
||||
In alto a destra: **Ripristina** (torna ai valori predefiniti) e **Salva**.
|
||||
In alto a destra: **Valori predefiniti**, **Annulla le modifiche** e **Salva**. Ogni scelta si vede **subito** sulla
|
||||
pagina; solo **Salva** la conserva. Finché non salvi, la scheda mostra il pallino delle modifiche; chiudendola senza
|
||||
salvare torna l'aspetto di prima.
|
||||
|
||||
## Aspetto
|
||||
|
||||
@@ -35,12 +39,13 @@ In alto a destra: **Ripristina** (torna ai valori predefiniti) e **Salva**.
|
||||
|
||||
| Tema | Descrizione |
|
||||
|---|---|
|
||||
| **Chiaro** | sfondo chiaro, barra superiore scura (predefinito) |
|
||||
| **Automatico** | segue l'impostazione chiaro/scuro del sistema operativo (predefinito) |
|
||||
| **Chiaro** | sfondo chiaro, barra superiore scura |
|
||||
| **Scuro (notturno)** | sfondi scuri e colori attenuati, per lavorare con poca luce |
|
||||
| **Automatico** | segue l'impostazione chiaro/scuro del sistema operativo |
|
||||
| **Alto contrasto** | contrasto massimo per chi ha esigenze visive (livello AAA) |
|
||||
|
||||
Prima dell'accesso (pagina di login) vale il tema del sistema operativo. Le **stampe e i PDF sono sempre in tema
|
||||
Prima dell'accesso (pagina di login) vale il tema del sistema operativo. Dopo l'accesso il tema scelto è già nella
|
||||
pagina che arriva dal server, senza lampeggi. Le **stampe e i PDF sono sempre in tema
|
||||
chiaro**, qualunque sia il tema scelto.
|
||||
|
||||
Il cambio tema rapido (sole/luna) nella barra superiore passa tra chiaro e scuro senza aprire il profilo.
|
||||
@@ -68,9 +73,9 @@ I valori esatti dei colori sono nella pagina [Design UI](Design-UI).
|
||||
| Impostazione | Valori |
|
||||
|---|---|
|
||||
| **Densità** | *Comoda* (righe da 30 px, predefinita) o *Compatta* (righe da 26 px, testo e spaziature più piccoli): con la compatta in una griglia stanno più righe |
|
||||
| **Dimensione testo** | *Normale* (13 px) e altre misure che saranno definite in sviluppo |
|
||||
| **Menu laterale** | *Espanso (ricorda l'ultimo stato)* o compresso all'avvio |
|
||||
| **Carattere numerico tabellare** | cifre di larghezza fissa negli importi, così le colonne restano allineate |
|
||||
| **Dimensione testo** | *100%* (13 px, predefinita), *110%*, *120%* |
|
||||
| **Menu laterale** | *Automatico* (compresso sotto i 1100 px, poi ricorda l'ultimo stato), *Espanso*, *Compresso* |
|
||||
| **Numeri tabellari** | cifre di larghezza fissa negli importi, così le colonne restano allineate (attivo) |
|
||||
|
||||
Interruttori:
|
||||
|
||||
@@ -78,8 +83,8 @@ Interruttori:
|
||||
- **Evidenzia riga sotto il cursore nelle griglie**.
|
||||
- **Animazioni ridotte** — riduce transizioni e movimenti.
|
||||
|
||||
Il riquadro **Anteprima** a destra mostra subito l'effetto delle scelte su una toolbar, alcuni campi, una griglia e
|
||||
i badge di stato (*Bozza*, *Confermato*, *Emessa*, *Attenzione*, *Scartata*).
|
||||
Al posto del riquadro **Anteprima** del mockup, l'anteprima è la pagina stessa: ogni scelta si applica subito a
|
||||
tutta l'interfaccia.
|
||||
|
||||
## Dati personali
|
||||
|
||||
@@ -99,15 +104,17 @@ non si cambiano da qui: li assegna un amministratore ([Utenti e permessi](Utenti
|
||||
|
||||
## Sessioni
|
||||
|
||||
Elenco delle sessioni aperte con il tuo utente: dispositivo, indirizzo IP, data di inizio e ultima attività. Puoi
|
||||
**chiudere** (revocare) una sessione che non riconosci. Un accesso da un **nuovo dispositivo** genera una notifica
|
||||
Elenco delle sessioni aperte con il tuo utente: dispositivo (browser e sistema), indirizzo IP, azienda, data di
|
||||
accesso e ultima attività; la sessione da cui stai lavorando è segnata come *Questa sessione*. Puoi **chiudere**
|
||||
(revocare) una sessione che non riconosci, o **chiuderle tutte tranne questa**: il dispositivo dovrà accedere di
|
||||
nuovo alla richiesta successiva. Un accesso da un **nuovo dispositivo** genera una notifica
|
||||
di sicurezza. Le sessioni scadono dopo un periodo di inattività (scadenza scorrevole) e contano nel numero di utenti
|
||||
contemporanei previsto dalla licenza.
|
||||
|
||||
## Pagina iniziale
|
||||
|
||||
- **All'accesso apri**: *Dashboard*, *ultima scheda aperta*, un *radar* (ad esempio Clienti), la *prima nota*,
|
||||
l'*agenda*…
|
||||
- **All'accesso apri**: *la pagina iniziale*, *le schede aperte l'ultima volta* (si riapre quella attiva), oppure
|
||||
*una pagina a scelta* fra quelle del menu che puoi aprire.
|
||||
- **Mostra la dashboard**: sì/no. Vedi [Dashboard](Dashboard).
|
||||
|
||||
## Layout salvati
|
||||
@@ -125,8 +132,9 @@ obbligatorie saranno definiti in sviluppo. Vedi anche
|
||||
|
||||
## Dove sono salvate le preferenze
|
||||
|
||||
Le preferenze sono salvate **nel database dell'azienda** e valgono su ogni dispositivo da cui accedi. Le preferenze
|
||||
esistono su tre livelli:
|
||||
Le preferenze sono salvate **nel database**, non nel browser, e valgono su ogni dispositivo da cui accedi: per gli
|
||||
utenti aziendali nel database dell'azienda (tabella `user_settings`), per gli account di istanza (super utente,
|
||||
amministratori) nel database di sistema (`sys_user_settings`). Le preferenze esistono su tre livelli:
|
||||
|
||||
| Livello | Esempi | Chi le cambia |
|
||||
|---|---|---|
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
using System.Collections.Frozen;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Khaemhat.Application.Localization;
|
||||
|
||||
/// <summary>
|
||||
/// The texts of the interface (SPEC §1.9, §10.8): keys such as <c>Shell.Menu.Home</c> resolved from
|
||||
/// <c>Resources/<culture>/*.json</c>. Components never contain literal texts; they ask this service.
|
||||
/// </summary>
|
||||
public interface ITexts
|
||||
{
|
||||
/// <summary>The culture of the texts and of number and date formats.</summary>
|
||||
CultureInfo Culture { get; }
|
||||
|
||||
/// <summary>The text of a key; a missing key gives <c>[key]</c>, visible in the page and caught by the tests.</summary>
|
||||
/// <param name="key">The key, <c>Area.Entity.Text</c>.</param>
|
||||
/// <returns>The text.</returns>
|
||||
string this[string key] { get; }
|
||||
|
||||
/// <summary>The text of a key with <see cref="string.Format(IFormatProvider, string, object[])"/> placeholders filled in the culture.</summary>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="args">The values for <c>{0}</c>, <c>{1}</c>...</param>
|
||||
/// <returns>The text.</returns>
|
||||
string Format(string key, params object?[] args);
|
||||
|
||||
/// <summary>Whether a key exists.</summary>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <returns><see langword="true"/> when it has a text.</returns>
|
||||
bool Contains(string key);
|
||||
|
||||
/// <summary>Every key, for the tests and the documentation.</summary>
|
||||
IReadOnlyCollection<string> Keys { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the texts from JSON files. Nested objects become dotted keys: <c>{"Shell": {"Menu": {"Home": "Home"}}}</c>
|
||||
/// gives <c>Shell.Menu.Home</c>; the property <c>_</c> gives a text to an object that also has children. The file
|
||||
/// name is not part of the key; two files defining the same key are an error.
|
||||
/// </summary>
|
||||
public sealed class JsonTextProvider : ITexts
|
||||
{
|
||||
/// <summary>The prefix of the embedded resources holding the texts: <c>texts/it-IT/Shell.json</c>.</summary>
|
||||
public const string ResourcePrefix = "texts/";
|
||||
|
||||
private readonly FrozenDictionary<string, string> _texts;
|
||||
|
||||
/// <summary>Creates the provider from JSON documents.</summary>
|
||||
/// <param name="culture">The culture.</param>
|
||||
/// <param name="documents">The documents, by name (used in error messages).</param>
|
||||
public JsonTextProvider(CultureInfo culture, IEnumerable<KeyValuePair<string, string>> documents)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(culture);
|
||||
ArgumentNullException.ThrowIfNull(documents);
|
||||
Culture = culture;
|
||||
var texts = new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
foreach (var (name, json) in documents)
|
||||
{
|
||||
using var document = JsonDocument.Parse(json, new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip, AllowTrailingCommas = true });
|
||||
if (document.RootElement.ValueKind != JsonValueKind.Object)
|
||||
{
|
||||
throw new InvalidDataException($"The texts file {name} must contain an object.");
|
||||
}
|
||||
|
||||
Flatten(document.RootElement, string.Empty, name, texts);
|
||||
}
|
||||
|
||||
_texts = texts.ToFrozenDictionary(StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public CultureInfo Culture { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<string> Keys => _texts.Keys;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string this[string key] => key is not null && _texts.TryGetValue(key, out var text) ? text : "[" + key + "]";
|
||||
|
||||
/// <summary>Loads the texts of a culture from the embedded resources of an assembly (<see cref="ResourcePrefix"/>).</summary>
|
||||
/// <param name="assembly">The assembly, usually the web project.</param>
|
||||
/// <param name="culture">The culture, for example <c>it-IT</c>.</param>
|
||||
/// <returns>The provider.</returns>
|
||||
public static JsonTextProvider FromAssembly(Assembly assembly, CultureInfo culture)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(assembly);
|
||||
ArgumentNullException.ThrowIfNull(culture);
|
||||
var prefix = ResourcePrefix + culture.Name + "/";
|
||||
var documents = new List<KeyValuePair<string, string>>();
|
||||
foreach (var resource in assembly.GetManifestResourceNames().Order(StringComparer.Ordinal))
|
||||
{
|
||||
var name = resource.Replace('\\', '/');
|
||||
if (!name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) || !name.EndsWith(".json", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
using var stream = assembly.GetManifestResourceStream(resource)!;
|
||||
using var reader = new StreamReader(stream);
|
||||
documents.Add(new(name, reader.ReadToEnd()));
|
||||
}
|
||||
|
||||
if (documents.Count == 0)
|
||||
{
|
||||
throw new InvalidOperationException($"No texts for {culture.Name} in {assembly.GetName().Name}.");
|
||||
}
|
||||
|
||||
return new JsonTextProvider(culture, documents);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Format(string key, params object?[] args) => string.Format(Culture, this[key], args);
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Contains(string key) => key is not null && _texts.ContainsKey(key);
|
||||
|
||||
private static void Flatten(JsonElement element, string prefix, string file, Dictionary<string, string> texts)
|
||||
{
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
// "_" gives a text to the object itself: {"Menu": {"Parties": {"_": "Anagrafiche", "Customers": "Clienti"}}}.
|
||||
var key = property.Name == "_" && prefix.Length > 0 ? prefix : prefix.Length == 0 ? property.Name : prefix + "." + property.Name;
|
||||
switch (property.Value.ValueKind)
|
||||
{
|
||||
case JsonValueKind.Object:
|
||||
Flatten(property.Value, key, file, texts);
|
||||
break;
|
||||
case JsonValueKind.String:
|
||||
if (!texts.TryAdd(key, property.Value.GetString()!))
|
||||
{
|
||||
throw new InvalidDataException($"The text {key} is defined twice ({file}).");
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new InvalidDataException($"The text {key} in {file} must be a string or an object.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Number, money and date formats of the interface, in the culture of <see cref="ITexts"/> (SPEC §10.8).</summary>
|
||||
public static class TextFormats
|
||||
{
|
||||
/// <summary>An amount in euro: <c>€ 1.234,50</c>.</summary>
|
||||
/// <param name="texts">The texts.</param>
|
||||
/// <param name="amount">The amount.</param>
|
||||
/// <returns>The text.</returns>
|
||||
public static string Money(this ITexts texts, decimal amount)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(texts);
|
||||
return "€ " + amount.ToString("#,##0.00", texts.Culture);
|
||||
}
|
||||
|
||||
/// <summary>A number with a fixed count of decimals: <c>1.234,5</c>.</summary>
|
||||
/// <param name="texts">The texts.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="decimals">The decimals.</param>
|
||||
/// <returns>The text.</returns>
|
||||
public static string Number(this ITexts texts, decimal value, int decimals = 0)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(texts);
|
||||
return value.ToString("N" + decimals.ToString(CultureInfo.InvariantCulture), texts.Culture);
|
||||
}
|
||||
|
||||
/// <summary>A date: <c>13/10/2026</c>.</summary>
|
||||
/// <param name="texts">The texts.</param>
|
||||
/// <param name="date">The date.</param>
|
||||
/// <returns>The text.</returns>
|
||||
public static string Date(this ITexts texts, DateOnly date)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(texts);
|
||||
return date.ToString("dd/MM/yyyy", texts.Culture);
|
||||
}
|
||||
|
||||
/// <summary>A date and time in the given time zone: <c>13/10/2026 14:05</c>.</summary>
|
||||
/// <param name="texts">The texts.</param>
|
||||
/// <param name="utc">The moment, in UTC.</param>
|
||||
/// <param name="zone">The time zone of the user.</param>
|
||||
/// <returns>The text.</returns>
|
||||
public static string DateTime(this ITexts texts, DateTime utc, TimeZoneInfo zone)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(texts);
|
||||
ArgumentNullException.ThrowIfNull(zone);
|
||||
var local = TimeZoneInfo.ConvertTimeFromUtc(System.DateTime.SpecifyKind(utc, DateTimeKind.Utc), zone);
|
||||
return local.ToString("dd/MM/yyyy HH:mm", texts.Culture);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace Khaemhat.Application.Preferences;
|
||||
|
||||
/// <summary>The colour theme (SPEC §10.6). <see cref="Auto"/> follows the operating system.</summary>
|
||||
public enum ThemeMode
|
||||
{
|
||||
/// <summary>Follows the operating system.</summary>
|
||||
Auto = 0,
|
||||
|
||||
/// <summary>Light.</summary>
|
||||
Light = 1,
|
||||
|
||||
/// <summary>Dark ("notturno").</summary>
|
||||
Dark = 2,
|
||||
|
||||
/// <summary>High contrast (AAA).</summary>
|
||||
HighContrast = 3,
|
||||
}
|
||||
|
||||
/// <summary>The row height and spacing of lists and forms.</summary>
|
||||
public enum Density
|
||||
{
|
||||
/// <summary>The default spacing.</summary>
|
||||
Comfortable = 0,
|
||||
|
||||
/// <summary>Shorter rows and smaller gaps.</summary>
|
||||
Compact = 1,
|
||||
}
|
||||
|
||||
/// <summary>What the user sees after signing in (SPEC §10.3).</summary>
|
||||
public enum StartPage
|
||||
{
|
||||
/// <summary>The dashboard.</summary>
|
||||
Dashboard = 0,
|
||||
|
||||
/// <summary>The tab that was active at the last sign-out.</summary>
|
||||
LastTab = 1,
|
||||
|
||||
/// <summary>A page chosen by the user (<see cref="UserPreferences.StartPath"/>).</summary>
|
||||
Page = 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The interface preferences of a user (SPEC §10.6, mockup 008), stored as key/value pairs in <c>user_settings</c>
|
||||
/// (company users) or <c>sys_user_settings</c> (instance accounts).
|
||||
/// </summary>
|
||||
public sealed record UserPreferences
|
||||
{
|
||||
/// <summary>The eight accents of <c>mockup.css</c>; <c>nilo</c> is the default.</summary>
|
||||
public static readonly IReadOnlyList<string> Accents = ["nilo", "lapislazzuli", "malachite", "turchese", "ocra", "corniola", "ametista", "grafite"];
|
||||
|
||||
/// <summary>The text sizes offered, in percent of the base size.</summary>
|
||||
public static readonly IReadOnlyList<int> TextSizes = [100, 110, 120];
|
||||
|
||||
/// <summary>The preferences of a new user.</summary>
|
||||
public static UserPreferences Default { get; } = new();
|
||||
|
||||
/// <summary>The theme.</summary>
|
||||
public ThemeMode Theme { get; init; } = ThemeMode.Auto;
|
||||
|
||||
/// <summary>The accent, one of <see cref="Accents"/>.</summary>
|
||||
public string Accent { get; init; } = "nilo";
|
||||
|
||||
/// <summary>The density.</summary>
|
||||
public Density Density { get; init; } = Density.Comfortable;
|
||||
|
||||
/// <summary>The text size in percent, one of <see cref="TextSizes"/>.</summary>
|
||||
public int TextSize { get; init; } = 100;
|
||||
|
||||
/// <summary>Whether numbers use tabular figures everywhere (grids always do).</summary>
|
||||
public bool TabularNumbers { get; init; } = true;
|
||||
|
||||
/// <summary>Whether animations and transitions are turned off.</summary>
|
||||
public bool ReducedMotion { get; init; }
|
||||
|
||||
/// <summary>Whether tooltips appear on hover.</summary>
|
||||
public bool Tooltips { get; init; } = true;
|
||||
|
||||
/// <summary>Whether the grid row under the pointer is highlighted.</summary>
|
||||
public bool RowHover { get; init; } = true;
|
||||
|
||||
/// <summary>Whether the side menu is collapsed; <see langword="null"/> lets the window width decide (collapsed under 1100 px).</summary>
|
||||
public bool? MenuCollapsed { get; init; }
|
||||
|
||||
/// <summary>Whether the dashboard is shown on the home page.</summary>
|
||||
public bool ShowDashboard { get; init; } = true;
|
||||
|
||||
/// <summary>The page opened after signing in.</summary>
|
||||
public StartPage StartPage { get; init; } = StartPage.Dashboard;
|
||||
|
||||
/// <summary>The address opened when <see cref="StartPage"/> is <see cref="Preferences.StartPage.Page"/>.</summary>
|
||||
public string? StartPath { get; init; }
|
||||
|
||||
/// <summary>The value of <c>data-theme</c> on the root element.</summary>
|
||||
public string ThemeAttribute => ThemeName(Theme);
|
||||
|
||||
/// <summary>The value of <c>data-density</c> on the root element.</summary>
|
||||
public string DensityAttribute => Density == Density.Compact ? "compact" : "comfortable";
|
||||
|
||||
/// <summary>The attribute value of a theme.</summary>
|
||||
/// <param name="theme">The theme.</param>
|
||||
/// <returns><c>auto</c>, <c>light</c>, <c>dark</c> or <c>high-contrast</c>.</returns>
|
||||
public static string ThemeName(ThemeMode theme) => theme switch
|
||||
{
|
||||
ThemeMode.Light => "light",
|
||||
ThemeMode.Dark => "dark",
|
||||
ThemeMode.HighContrast => "high-contrast",
|
||||
_ => "auto",
|
||||
};
|
||||
|
||||
/// <summary>Reads a theme name; unknown values give <see cref="ThemeMode.Auto"/>.</summary>
|
||||
/// <param name="value">The name.</param>
|
||||
/// <returns>The theme.</returns>
|
||||
public static ThemeMode ParseTheme(string? value) => value switch
|
||||
{
|
||||
"light" => ThemeMode.Light,
|
||||
"dark" => ThemeMode.Dark,
|
||||
"high-contrast" => ThemeMode.HighContrast,
|
||||
_ => ThemeMode.Auto,
|
||||
};
|
||||
|
||||
/// <summary>Reads the preferences from stored values; missing or invalid values keep the default.</summary>
|
||||
/// <param name="values">The stored values by key.</param>
|
||||
/// <returns>The preferences.</returns>
|
||||
public static UserPreferences FromSettings(IReadOnlyDictionary<string, string?> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(values);
|
||||
var d = Default;
|
||||
return new UserPreferences
|
||||
{
|
||||
Theme = values.TryGetValue(PreferenceKeys.Theme, out var theme) ? ParseTheme(theme) : d.Theme,
|
||||
Accent = values.TryGetValue(PreferenceKeys.Accent, out var accent) && accent is not null && Accents.Contains(accent) ? accent : d.Accent,
|
||||
Density = values.TryGetValue(PreferenceKeys.Density, out var density) && density == "compact" ? Density.Compact : d.Density,
|
||||
TextSize = values.TryGetValue(PreferenceKeys.TextSize, out var size)
|
||||
&& int.TryParse(size, NumberStyles.None, CultureInfo.InvariantCulture, out var s) && TextSizes.Contains(s) ? s : d.TextSize,
|
||||
TabularNumbers = Bool(values, PreferenceKeys.TabularNumbers) ?? d.TabularNumbers,
|
||||
ReducedMotion = Bool(values, PreferenceKeys.ReducedMotion) ?? d.ReducedMotion,
|
||||
Tooltips = Bool(values, PreferenceKeys.Tooltips) ?? d.Tooltips,
|
||||
RowHover = Bool(values, PreferenceKeys.RowHover) ?? d.RowHover,
|
||||
MenuCollapsed = Bool(values, PreferenceKeys.MenuCollapsed),
|
||||
ShowDashboard = Bool(values, PreferenceKeys.ShowDashboard) ?? d.ShowDashboard,
|
||||
StartPage = values.TryGetValue(PreferenceKeys.StartPage, out var start)
|
||||
? start switch
|
||||
{
|
||||
"last-tab" => StartPage.LastTab,
|
||||
"page" => StartPage.Page,
|
||||
_ => StartPage.Dashboard,
|
||||
}
|
||||
: d.StartPage,
|
||||
StartPath = values.TryGetValue(PreferenceKeys.StartPath, out var path) && IsLocalPath(path) ? path : null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The values to store.</summary>
|
||||
/// <returns>The values by key; <see langword="null"/> removes the key.</returns>
|
||||
public IReadOnlyDictionary<string, string?> ToSettings() => new Dictionary<string, string?>(StringComparer.Ordinal)
|
||||
{
|
||||
[PreferenceKeys.Theme] = ThemeAttribute,
|
||||
[PreferenceKeys.Accent] = Accents.Contains(Accent) ? Accent : Default.Accent,
|
||||
[PreferenceKeys.Density] = DensityAttribute,
|
||||
[PreferenceKeys.TextSize] = TextSize.ToString(CultureInfo.InvariantCulture),
|
||||
[PreferenceKeys.TabularNumbers] = Text(TabularNumbers),
|
||||
[PreferenceKeys.ReducedMotion] = Text(ReducedMotion),
|
||||
[PreferenceKeys.Tooltips] = Text(Tooltips),
|
||||
[PreferenceKeys.RowHover] = Text(RowHover),
|
||||
[PreferenceKeys.MenuCollapsed] = MenuCollapsed is { } collapsed ? Text(collapsed) : null,
|
||||
[PreferenceKeys.ShowDashboard] = Text(ShowDashboard),
|
||||
[PreferenceKeys.StartPage] = StartPage switch
|
||||
{
|
||||
StartPage.LastTab => "last-tab",
|
||||
StartPage.Page => "page",
|
||||
_ => "dashboard",
|
||||
},
|
||||
[PreferenceKeys.StartPath] = IsLocalPath(StartPath) ? StartPath : null,
|
||||
};
|
||||
|
||||
/// <summary>Whether an address is a path inside the application (no scheme, no host): the start page cannot leave the site.</summary>
|
||||
/// <param name="path">The address.</param>
|
||||
/// <returns><see langword="true"/> for <c>/something</c>.</returns>
|
||||
public static bool IsLocalPath(string? path) =>
|
||||
path is { Length: > 0 and <= 400 }
|
||||
&& path[0] == '/'
|
||||
&& (path.Length == 1 || (path[1] != '/' && path[1] != '\\'))
|
||||
&& !path.Contains("://", StringComparison.Ordinal);
|
||||
|
||||
private static bool? Bool(IReadOnlyDictionary<string, string?> values, string key) =>
|
||||
values.TryGetValue(key, out var value)
|
||||
? value switch
|
||||
{
|
||||
"true" => true,
|
||||
"false" => false,
|
||||
_ => null,
|
||||
}
|
||||
: null;
|
||||
|
||||
private static string Text(bool value) => value ? "true" : "false";
|
||||
}
|
||||
|
||||
/// <summary>The keys of <see cref="UserPreferences"/> in <c>user_settings</c>.</summary>
|
||||
public static class PreferenceKeys
|
||||
{
|
||||
/// <summary>Theme.</summary>
|
||||
public const string Theme = "ui.theme";
|
||||
|
||||
/// <summary>Accent.</summary>
|
||||
public const string Accent = "ui.accent";
|
||||
|
||||
/// <summary>Density.</summary>
|
||||
public const string Density = "ui.density";
|
||||
|
||||
/// <summary>Text size.</summary>
|
||||
public const string TextSize = "ui.text-size";
|
||||
|
||||
/// <summary>Tabular numbers.</summary>
|
||||
public const string TabularNumbers = "ui.tabular-numbers";
|
||||
|
||||
/// <summary>Reduced motion.</summary>
|
||||
public const string ReducedMotion = "ui.reduced-motion";
|
||||
|
||||
/// <summary>Tooltips.</summary>
|
||||
public const string Tooltips = "ui.tooltips";
|
||||
|
||||
/// <summary>Row highlight in grids.</summary>
|
||||
public const string RowHover = "ui.row-hover";
|
||||
|
||||
/// <summary>Menu state.</summary>
|
||||
public const string MenuCollapsed = "ui.menu-collapsed";
|
||||
|
||||
/// <summary>Dashboard on or off.</summary>
|
||||
public const string ShowDashboard = "home.show-dashboard";
|
||||
|
||||
/// <summary>Start page.</summary>
|
||||
public const string StartPage = "home.start-page";
|
||||
|
||||
/// <summary>Start address.</summary>
|
||||
public const string StartPath = "home.start-path";
|
||||
|
||||
/// <summary>The open tabs at the last sign-out (JSON array of addresses).</summary>
|
||||
public const string OpenTabs = "ui.open-tabs";
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
using Khaemhat.Application.Security;
|
||||
using Khaemhat.Core.Instance;
|
||||
using Khaemhat.Data;
|
||||
using Khaemhat.Data.Querying;
|
||||
|
||||
namespace Khaemhat.Application.Preferences;
|
||||
|
||||
/// <summary>
|
||||
/// Reads and writes the preferences of the signed-in user (SPEC §10.6). Instance accounts keep theirs in the system
|
||||
/// database, so they follow them in every company; company users keep them in the company database.
|
||||
/// </summary>
|
||||
/// <param name="factory">Opens the databases.</param>
|
||||
public sealed class UserSettingsService(IUnitOfWorkFactory factory)
|
||||
{
|
||||
/// <summary>The longest value accepted (dashboard and grid layouts are JSON).</summary>
|
||||
public const int MaxValueLength = 64 * 1024;
|
||||
|
||||
/// <summary>Reads every preference of the actor.</summary>
|
||||
/// <param name="actor">The signed-in user.</param>
|
||||
/// <param name="cancellationToken">Cancellation.</param>
|
||||
/// <returns>The values by key; empty for the instance itself.</returns>
|
||||
public async Task<IReadOnlyDictionary<string, string?>> GetAllAsync(Actor actor, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(actor);
|
||||
if (Owner(actor) is not { } owner)
|
||||
{
|
||||
return new Dictionary<string, string?>(StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
await using var unitOfWork = await factory.CreateAsync(owner.Scope, cancellationToken).ConfigureAwait(false);
|
||||
IReadOnlyList<UserSettingRecord> rows = owner.Scope.IsSystem
|
||||
? await ListAsync<SystemUserSetting>(unitOfWork, owner.UserId, cancellationToken).ConfigureAwait(false)
|
||||
: await ListAsync<UserSetting>(unitOfWork, owner.UserId, cancellationToken).ConfigureAwait(false);
|
||||
return rows.ToDictionary(r => r.Key, r => r.Value, StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
/// <summary>Reads one preference.</summary>
|
||||
/// <param name="actor">The signed-in user.</param>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="cancellationToken">Cancellation.</param>
|
||||
/// <returns>The value, or <see langword="null"/>.</returns>
|
||||
public async Task<string?> GetAsync(Actor actor, string key, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(key);
|
||||
var all = await GetAllAsync(actor, cancellationToken).ConfigureAwait(false);
|
||||
return all.TryGetValue(key, out var value) ? value : null;
|
||||
}
|
||||
|
||||
/// <summary>Writes one preference; <see langword="null"/> removes it.</summary>
|
||||
/// <param name="actor">The signed-in user.</param>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="cancellationToken">Cancellation.</param>
|
||||
/// <returns>A task.</returns>
|
||||
public Task SetAsync(Actor actor, string key, string? value, CancellationToken cancellationToken = default) =>
|
||||
SetManyAsync(actor, new Dictionary<string, string?>(StringComparer.Ordinal) { [key] = value }, cancellationToken);
|
||||
|
||||
/// <summary>Writes several preferences in one transaction; <see langword="null"/> values remove the key.</summary>
|
||||
/// <param name="actor">The signed-in user.</param>
|
||||
/// <param name="values">The values by key.</param>
|
||||
/// <param name="cancellationToken">Cancellation.</param>
|
||||
/// <returns>A task.</returns>
|
||||
public async Task SetManyAsync(Actor actor, IReadOnlyDictionary<string, string?> values, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(actor);
|
||||
ArgumentNullException.ThrowIfNull(values);
|
||||
foreach (var (key, value) in values)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(key) || key.Length > 200)
|
||||
{
|
||||
throw new ValidationFailedException("settings.key_invalid");
|
||||
}
|
||||
|
||||
if (value is { Length: > MaxValueLength })
|
||||
{
|
||||
throw new ValidationFailedException("settings.value_too_long");
|
||||
}
|
||||
}
|
||||
|
||||
if (Owner(actor) is not { } owner || values.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await using var unitOfWork = await factory.CreateAsync(owner.Scope, cancellationToken).ConfigureAwait(false);
|
||||
await unitOfWork.InTransactionAsync(
|
||||
ct => owner.Scope.IsSystem
|
||||
? WriteAsync<SystemUserSetting>(unitOfWork, owner.UserId, values, ct)
|
||||
: WriteAsync<UserSetting>(unitOfWork, owner.UserId, values, ct),
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>Reads the interface preferences.</summary>
|
||||
/// <param name="actor">The signed-in user.</param>
|
||||
/// <param name="cancellationToken">Cancellation.</param>
|
||||
/// <returns>The preferences, with defaults for what was never set.</returns>
|
||||
public async Task<UserPreferences> GetPreferencesAsync(Actor actor, CancellationToken cancellationToken = default) =>
|
||||
UserPreferences.FromSettings(await GetAllAsync(actor, cancellationToken).ConfigureAwait(false));
|
||||
|
||||
/// <summary>Writes the interface preferences.</summary>
|
||||
/// <param name="actor">The signed-in user.</param>
|
||||
/// <param name="preferences">The preferences.</param>
|
||||
/// <param name="cancellationToken">Cancellation.</param>
|
||||
/// <returns>A task.</returns>
|
||||
public Task SavePreferencesAsync(Actor actor, UserPreferences preferences, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(preferences);
|
||||
return SetManyAsync(actor, preferences.ToSettings(), cancellationToken);
|
||||
}
|
||||
|
||||
private static (DatabaseScope Scope, long UserId)? Owner(Actor actor) => actor switch
|
||||
{
|
||||
{ SystemUserId: { } id } => (DatabaseScope.System, id),
|
||||
{ CompanyUserId: { } id, CompanyCode: { } code } => (DatabaseScope.Company(code), id),
|
||||
_ => null,
|
||||
};
|
||||
|
||||
private static async Task<IReadOnlyList<T>> ListAsync<T>(IUnitOfWork unitOfWork, long userId, CancellationToken cancellationToken)
|
||||
where T : UserSettingRecord, new() =>
|
||||
(await unitOfWork.Repository<T, long>().ListAsync(Query.For<T>().Where(s => s.UserId == userId), cancellationToken).ConfigureAwait(false)).Items;
|
||||
|
||||
private static async Task WriteAsync<T>(IUnitOfWork unitOfWork, long userId, IReadOnlyDictionary<string, string?> values, CancellationToken cancellationToken)
|
||||
where T : UserSettingRecord, new()
|
||||
{
|
||||
var repository = unitOfWork.Repository<T, long>();
|
||||
var existing = (await ListAsync<T>(unitOfWork, userId, cancellationToken).ConfigureAwait(false)).ToDictionary(r => r.Key, StringComparer.Ordinal);
|
||||
foreach (var (key, value) in values)
|
||||
{
|
||||
if (existing.TryGetValue(key, out var row))
|
||||
{
|
||||
if (value is null)
|
||||
{
|
||||
await repository.DeleteAsync(row.Id, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else if (!string.Equals(row.Value, value, StringComparison.Ordinal))
|
||||
{
|
||||
row.Value = value;
|
||||
await repository.UpdateAsync(row, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
else if (value is not null)
|
||||
{
|
||||
await repository.InsertAsync(new T { UserId = userId, Key = key, Value = value }, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Khaemhat.Core.Entities;
|
||||
|
||||
namespace Khaemhat.Core.Instance;
|
||||
|
||||
/// <summary>
|
||||
/// One preference of one user (SPEC §10.6): theme, accent, menu state, dashboard layout, grid layouts... The value is
|
||||
/// a string, usually JSON for structured preferences.
|
||||
/// </summary>
|
||||
public abstract class UserSettingRecord : Entity<long>
|
||||
{
|
||||
/// <summary>The user the preference belongs to.</summary>
|
||||
public long UserId { get; set; }
|
||||
|
||||
/// <summary>The key, for example <c>ui.theme</c> or <c>grid.parties.columns</c>.</summary>
|
||||
public string Key { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>The value.</summary>
|
||||
public string? Value { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>A preference of an instance account (<c>sys_user_settings</c>): it follows the account in every company.</summary>
|
||||
public sealed class SystemUserSetting : UserSettingRecord;
|
||||
|
||||
/// <summary>A preference of a company user (<c>user_settings</c>).</summary>
|
||||
public sealed class UserSetting : UserSettingRecord;
|
||||
@@ -95,3 +95,14 @@ public sealed class NotificationMap : EntityMap<Notification>
|
||||
NotificationColumns.Configure(this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Map of <see cref="UserSetting"/> to <c>user_settings</c>.</summary>
|
||||
public sealed class UserSettingMap : EntityMap<UserSetting>
|
||||
{
|
||||
/// <summary>Creates the map.</summary>
|
||||
public UserSettingMap()
|
||||
{
|
||||
ToTable("user_settings");
|
||||
Map(x => x.Key).MaxLength(200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Khaemhat.Data.Migrations;
|
||||
using Khaemhat.Data.Schema;
|
||||
|
||||
namespace Khaemhat.Data.CompanyDatabase.Migrations;
|
||||
|
||||
/// <summary>The interface preferences of the company users (SPEC §10.6).</summary>
|
||||
[Migration(20261111_006, "create_user_settings")]
|
||||
public sealed class M20261111_006_CreateUserSettings : IMigration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void Up(ISchemaBuilder schema)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(schema);
|
||||
schema.CreateTable("user_settings", t =>
|
||||
{
|
||||
t.Id();
|
||||
t.Int64("user_id").NotNull();
|
||||
t.String("key", 200).NotNull();
|
||||
t.Text("value");
|
||||
t.AuditColumns();
|
||||
t.Unique("ux_user_settings_user_id_key", "user_id", "key");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Khaemhat.Data.Migrations;
|
||||
using Khaemhat.Data.Schema;
|
||||
|
||||
namespace Khaemhat.Data.SystemDatabase.Migrations;
|
||||
|
||||
/// <summary>The interface preferences of the instance accounts (SPEC §10.6).</summary>
|
||||
[Migration(20261111_012, "create_sys_user_settings", Target = MigrationTarget.System)]
|
||||
public sealed class M20261111_012_CreateSysUserSettings : IMigration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void Up(ISchemaBuilder schema)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(schema);
|
||||
schema.CreateTable("sys_user_settings", t =>
|
||||
{
|
||||
t.Id();
|
||||
t.Int64("user_id").NotNull();
|
||||
t.String("key", 200).NotNull();
|
||||
t.Text("value");
|
||||
t.AuditColumns();
|
||||
t.Unique("ux_sys_user_settings_user_id_key", "user_id", "key");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -27,3 +27,14 @@ public sealed class SystemSettingMap : EntityMap<SystemSetting>
|
||||
Map(x => x.Key).MaxLength(200);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Map of <see cref="SystemUserSetting"/> to <c>sys_user_settings</c>.</summary>
|
||||
public sealed class SystemUserSettingMap : EntityMap<SystemUserSetting>
|
||||
{
|
||||
/// <summary>Creates the map.</summary>
|
||||
public SystemUserSettingMap()
|
||||
{
|
||||
ToTable("sys_user_settings");
|
||||
Map(x => x.Key).MaxLength(200);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
<html lang="it" @attributes="RootAttributes">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
@@ -10,6 +10,10 @@
|
||||
<link rel="icon" href="icon.svg" type="image/svg+xml" />
|
||||
<link rel="apple-touch-icon" href="icon-256.png" />
|
||||
<ResourcePreloader />
|
||||
<link rel="stylesheet" href="@Assets["css/tokens.css"]" />
|
||||
<link rel="stylesheet" href="@Assets["css/components.css"]" />
|
||||
<link rel="stylesheet" href="@Assets["css/interactive.css"]" />
|
||||
<link rel="stylesheet" href="@Assets["css/print.css"]" />
|
||||
<link rel="stylesheet" href="@Assets["app.css"]" />
|
||||
<link rel="stylesheet" href="@Assets["Khaemhat.Web.styles.css"]" />
|
||||
@* No <ImportMap />: it is an inline script, and the content security policy allows none (no JS modules yet). *@
|
||||
@@ -20,6 +24,7 @@
|
||||
<Routes @rendermode="PageRenderMode" />
|
||||
<ReconnectModal />
|
||||
<script src="@Assets["_framework/blazor.web.js"]"></script>
|
||||
<script src="@Assets["js/khaemhat.js"]"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -28,6 +33,21 @@
|
||||
[CascadingParameter]
|
||||
private HttpContext HttpContext { get; set; } = default!;
|
||||
|
||||
private IReadOnlyDictionary<string, object> RootAttributes { get; set; } = new Dictionary<string, object>();
|
||||
|
||||
// The sign-in pages are static server-rendered forms (they set the cookie); everything else is interactive.
|
||||
private IComponentRenderMode? PageRenderMode => HttpContext.AcceptsInteractiveRouting() ? InteractiveServer : null;
|
||||
|
||||
[Inject]
|
||||
private UserSettingsService Settings { get; set; } = default!;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
// The theme of the signed-in user is written on the server, so the first paint already has the right colours;
|
||||
// before sign-in the system theme applies (data-theme="auto").
|
||||
var actor = SessionCookie.ActorOf(HttpContext.User);
|
||||
var preferences = actor is null ? null : await Settings.GetPreferencesAsync(actor, HttpContext.RequestAborted);
|
||||
RootAttributes = ThemeService.RootAttributes(preferences).ToDictionary(a => a.Key, a => (object)a.Value);
|
||||
}
|
||||
}
|
||||
@@ -2,25 +2,25 @@
|
||||
@using Khaemhat.Core.Common
|
||||
@inject ProductVersion Version
|
||||
|
||||
@* Mockups 001-003: brand panel on the left, the form on the right. Texts move to the it-IT resources in M3. *@
|
||||
@* Mockups 001-003: brand panel on the left, the form on the right. *@
|
||||
<div class="kh-auth">
|
||||
<aside class="brand">
|
||||
<aside class="side">
|
||||
<div class="brand-top">
|
||||
<img class="mark" src="icon.svg" alt="" width="56" height="56" />
|
||||
<h2>Khaemhat</h2>
|
||||
<p>Gestionale ERP + CRM per PMI italiane: documenti, magazzino, contabilità e fatturazione elettronica in un'unica applicazione web.</p>
|
||||
<h2>@T["Common.ProductName"]</h2>
|
||||
<p>@T["Auth.Brand.Tagline"]</p>
|
||||
</div>
|
||||
<ul class="features">
|
||||
<li><strong>Contabilità italiana completa</strong> prima nota, IVA, registri, bilancio CEE</li>
|
||||
<li><strong>Fatturazione elettronica</strong> SDI, conservazione, bollo, autofatture</li>
|
||||
<li><strong>CRM</strong> lead, opportunità, attività, campagne</li>
|
||||
<li><strong>Più aziende</strong> un database per azienda, backup integrati</li>
|
||||
<li><strong>@T["Auth.Brand.Feature1Title"]</strong> @T["Auth.Brand.Feature1Text"]</li>
|
||||
<li><strong>@T["Auth.Brand.Feature2Title"]</strong> @T["Auth.Brand.Feature2Text"]</li>
|
||||
<li><strong>@T["Auth.Brand.Feature3Title"]</strong> @T["Auth.Brand.Feature3Text"]</li>
|
||||
<li><strong>@T["Auth.Brand.Feature4Title"]</strong> @T["Auth.Brand.Feature4Text"]</li>
|
||||
</ul>
|
||||
</aside>
|
||||
<main class="panel">
|
||||
<main class="form-side">
|
||||
<section class="card">
|
||||
@Body
|
||||
</section>
|
||||
<footer>Khaemhat @Version.Version · <a href="https://gitea.encke-hake.ts.net/BalboSoft/Khaemhat/wiki">Documentazione</a></footer>
|
||||
<footer>@T.Format("Auth.Brand.Footer", Version.Version) · <a href="@HelpLinks.DefaultBaseUrl">@T["Common.Documentation"]</a></footer>
|
||||
</main>
|
||||
</div>
|
||||
@@ -1,9 +1,281 @@
|
||||
@inherits LayoutComponentBase
|
||||
@using System.Text.Json
|
||||
@using Khaemhat.Application.Preferences
|
||||
@implements IAsyncDisposable
|
||||
@inject ShellSession Session
|
||||
@inject TabService Tabs
|
||||
@inject ThemeService Theme
|
||||
@inject KeyboardShortcutService Shortcuts
|
||||
@inject ToastService Toasts
|
||||
@inject DialogService Dialogs
|
||||
@inject NavigationManager Navigation
|
||||
@inject IJSRuntime Js
|
||||
|
||||
@Body
|
||||
@* The shell of SPEC §10.2 (mockups 004, 007, 013): top bar, collapsible menu, tab area, status bar. Every page opened
|
||||
becomes a tab; its component stays alive while the tab is open (hidden when another tab is active), so going back
|
||||
to a tab finds it as it was left. *@
|
||||
<PageTitle>@ActiveTitle · @T["Common.ProductName"]</PageTitle>
|
||||
<a class="skip" href="#kh-main">@T["Shell.SkipToContent"]</a>
|
||||
<div class="app @(_collapsed ? "collapsed" : null)">
|
||||
<TopBar OnSearch="() => _searchOpen = true" OnHelp="OpenHelpAsync" />
|
||||
<KhSideMenu Collapsed="_collapsed" OnToggle="ToggleMenuAsync" />
|
||||
<main class="main" id="kh-main">
|
||||
<div class="tabs-strip" role="tablist" aria-label="@T["Shell.Tabs.Label"]">
|
||||
@foreach (var tab in Tabs.Tabs)
|
||||
{
|
||||
var active = tab == Tabs.Active;
|
||||
var item = MenuCatalog.Find(tab.Path);
|
||||
var title = TitleOf(tab, item);
|
||||
<div class="wtab @(active ? "active" : null)" @key="tab.Id" role="presentation">
|
||||
<a class="tt" role="tab" href="@tab.Url.TrimStart('/')" aria-selected="@active" aria-controls="@("pane-" + tab.Id)" title="@title">
|
||||
@title
|
||||
</a>
|
||||
@if (tab.IsModified)
|
||||
{
|
||||
<span class="mod" title="@T["Shell.Tabs.Modified"]" aria-label="@T["Shell.Tabs.Modified"]">●</span>
|
||||
}
|
||||
<button type="button" class="x" aria-label="@T.Format("Shell.Tabs.Close", title)" title="@T["Shell.Tabs.CloseHint"]"
|
||||
@onclick="() => CloseTabAsync(tab)"><KhIcon Name="x" Class="sm" /></button>
|
||||
</div>
|
||||
}
|
||||
<button type="button" class="wtab add" aria-label="@T["Shell.Tabs.New"]" title="@T["Shell.Tabs.New"]" @onclick="() => _searchOpen = true">
|
||||
<KhIcon Name="plus" Class="sm" />
|
||||
</button>
|
||||
</div>
|
||||
@foreach (var tab in Tabs.Tabs)
|
||||
{
|
||||
<div class="tabpane" id="@("pane-" + tab.Id)" role="tabpanel" hidden="@(tab != Tabs.Active)" @key="tab.Id">
|
||||
<CascadingValue Value="tab" IsFixed="true">
|
||||
<div class="content">@tab.Content</div>
|
||||
</CascadingValue>
|
||||
</div>
|
||||
}
|
||||
</main>
|
||||
<KhStatusBar />
|
||||
</div>
|
||||
<KhCommandPalette Open="_searchOpen" OpenChanged="open => _searchOpen = open" OnToggleMenu="ToggleMenuAsync" />
|
||||
<KhToastHost />
|
||||
<KhDialogHost />
|
||||
|
||||
<div id="blazor-error-ui" data-nosnippet>
|
||||
Si è verificato un errore imprevisto.
|
||||
<a href="." class="reload">Ricarica</a>
|
||||
@T["Shell.Error.Unexpected"]
|
||||
<a href="." class="reload">@T["Shell.Error.Reload"]</a>
|
||||
<span class="dismiss">×</span>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private bool _collapsed;
|
||||
private bool _searchOpen;
|
||||
private bool _unloadGuard;
|
||||
private string _savedTabs = string.Empty;
|
||||
private bool _startHandled;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await Session.EnsureLoadedAsync();
|
||||
_collapsed = Session.Preferences.MenuCollapsed ?? false;
|
||||
Tabs.Changed += OnTabsChanged;
|
||||
Session.Changed += OnSessionChanged;
|
||||
Shortcuts.ShellPressed += OnShortcutAsync;
|
||||
}
|
||||
|
||||
/// <summary>The page being shown and its route values, given by <c>Routes.razor</c>.</summary>
|
||||
[CascadingParameter]
|
||||
public RouteData? Route { get; set; }
|
||||
|
||||
private string ActiveTitle => Tabs.Active is { } tab ? TitleOf(tab, MenuCatalog.Find(tab.Path)) : T["Shell.Tabs.Untitled"];
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
var url = "/" + Navigation.ToBaseRelativePath(Navigation.Uri);
|
||||
if (Tabs.Open(url, Route is null ? Body : PageOf(Route)) == TabOpenResult.Refused)
|
||||
{
|
||||
Toasts.Show(ToastKind.Warning, T["Shell.Tabs.LimitTitle"], T.Format("Shell.Tabs.LimitText", TabService.MaxTabs));
|
||||
if (Tabs.Active is { } active)
|
||||
{
|
||||
Navigation.NavigateTo(active.Url.TrimStart('/'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (!firstRender)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await Shortcuts.StartAsync();
|
||||
if (Session.Preferences.MenuCollapsed is null && await Js.InvokeAsync<int>("khaemhat.viewportWidth") < 1100)
|
||||
{
|
||||
_collapsed = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
await ApplyStartPageAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ValueTask DisposeAsync()
|
||||
{
|
||||
Tabs.Changed -= OnTabsChanged;
|
||||
Session.Changed -= OnSessionChanged;
|
||||
Shortcuts.ShellPressed -= OnShortcutAsync;
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
|
||||
// Body always draws the current page; a tab needs its own page, so it keeps the page type and a copy of the route values.
|
||||
private static RenderFragment PageOf(RouteData route)
|
||||
{
|
||||
var type = route.PageType;
|
||||
var values = route.RouteValues.ToArray();
|
||||
return builder =>
|
||||
{
|
||||
builder.OpenComponent(0, type);
|
||||
foreach (var (name, value) in values)
|
||||
{
|
||||
builder.AddComponentParameter(1, name, value);
|
||||
}
|
||||
|
||||
builder.CloseComponent();
|
||||
};
|
||||
}
|
||||
|
||||
private string TitleOf(KhTab tab, MenuItem? item) =>
|
||||
tab.Title ?? (item is not null && item.Href.Equals(tab.Path, StringComparison.OrdinalIgnoreCase) ? T[item.Key] : T["Shell.Tabs.Untitled"]);
|
||||
|
||||
// After sign-in the home page may give way to the start page chosen in the preferences (SPEC §10.3).
|
||||
private async Task ApplyStartPageAsync()
|
||||
{
|
||||
if (_startHandled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_startHandled = true;
|
||||
if (Tabs.Tabs.Count != 1 || Tabs.Active?.Path != "/")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var preferences = Session.Preferences;
|
||||
string? target = null;
|
||||
if (preferences.StartPage == StartPage.Page && preferences.StartPath is { } path)
|
||||
{
|
||||
target = path;
|
||||
}
|
||||
else if (preferences.StartPage == StartPage.LastTab && await Session.ReadSettingAsync(PreferenceKeys.OpenTabs) is { } json)
|
||||
{
|
||||
target = ReadActiveTab(json);
|
||||
}
|
||||
|
||||
if (target is not null && UserPreferences.IsLocalPath(target) && TabService.PathOf(target) != "/")
|
||||
{
|
||||
Navigation.NavigateTo(target.TrimStart('/'));
|
||||
}
|
||||
}
|
||||
|
||||
private static string? ReadActiveTab(string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var document = JsonDocument.Parse(json);
|
||||
return document.RootElement.TryGetProperty("active", out var active) ? active.GetString() : null;
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ToggleMenuAsync()
|
||||
{
|
||||
_collapsed = !_collapsed;
|
||||
await Session.SavePreferencesAsync(Session.Preferences with { MenuCollapsed = _collapsed });
|
||||
}
|
||||
|
||||
private async Task CloseTabAsync(KhTab tab)
|
||||
{
|
||||
if (tab.IsModified)
|
||||
{
|
||||
var title = TitleOf(tab, MenuCatalog.Find(tab.Path));
|
||||
var confirmed = await Dialogs.ConfirmAsync(new ConfirmRequest(
|
||||
T["Shell.Tabs.CloseModifiedTitle"], T.Format("Shell.Tabs.CloseModifiedText", title), T["Shell.Tabs.CloseModifiedConfirm"], T["Common.Cancel"], Danger: true));
|
||||
if (!confirmed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Tabs.Close(tab) is { } next)
|
||||
{
|
||||
Navigation.NavigateTo(next.TrimStart('/'));
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OpenHelpAsync()
|
||||
{
|
||||
var path = TabService.PathOf(Navigation.ToBaseRelativePath(Navigation.Uri));
|
||||
await Js.InvokeVoidAsync("khaemhat.openWindow", HelpLinks.UrlFor(HelpLinks.DefaultBaseUrl, path));
|
||||
}
|
||||
|
||||
private async Task OnShortcutAsync(string command)
|
||||
{
|
||||
await InvokeAsync(async () =>
|
||||
{
|
||||
switch (command)
|
||||
{
|
||||
case KeyboardShortcuts.Commands.ToggleMenu:
|
||||
await ToggleMenuAsync();
|
||||
break;
|
||||
case KeyboardShortcuts.Commands.Search:
|
||||
_searchOpen = true;
|
||||
break;
|
||||
case KeyboardShortcuts.Commands.Help:
|
||||
await OpenHelpAsync();
|
||||
break;
|
||||
case KeyboardShortcuts.Commands.CloseTab when Tabs.Active is { } active:
|
||||
await CloseTabAsync(active);
|
||||
break;
|
||||
case KeyboardShortcuts.Commands.NextTab when Tabs.Neighbour(1) is { } next:
|
||||
Navigation.NavigateTo(next.Url.TrimStart('/'));
|
||||
break;
|
||||
case KeyboardShortcuts.Commands.PreviousTab when Tabs.Neighbour(-1) is { } previous:
|
||||
Navigation.NavigateTo(previous.Url.TrimStart('/'));
|
||||
break;
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
private void OnSessionChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
private void OnTabsChanged() => _ = InvokeAsync(async () =>
|
||||
{
|
||||
StateHasChanged();
|
||||
if (Tabs.HasModified != _unloadGuard)
|
||||
{
|
||||
_unloadGuard = Tabs.HasModified;
|
||||
await Js.InvokeVoidAsync("khaemhat.setUnloadGuard", _unloadGuard);
|
||||
}
|
||||
|
||||
await SaveTabsAsync();
|
||||
});
|
||||
|
||||
// The open tabs and the active one, for the "last tab" start page.
|
||||
private async Task SaveTabsAsync()
|
||||
{
|
||||
var json = JsonSerializer.Serialize(new { active = Tabs.Active?.Url, tabs = Tabs.Tabs.Select(t => t.Url).ToArray() });
|
||||
if (json == _savedTabs)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_savedTabs = json;
|
||||
await Session.SaveSettingAsync(PreferenceKeys.OpenTabs, json);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#blazor-error-ui {
|
||||
color-scheme: light only;
|
||||
background: lightyellow;
|
||||
background: #FADEDC;
|
||||
color: #1E2733;
|
||||
bottom: 0;
|
||||
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
|
||||
box-sizing: border-box;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script type="module" src="@Assets["Components/Layout/ReconnectModal.razor.js"]"></script>
|
||||
<script type="module" src="@Assets["Components/Layout/ReconnectModal.razor.js"]"></script>
|
||||
|
||||
<dialog id="components-reconnect-modal" data-nosnippet>
|
||||
<div class="components-reconnect-container">
|
||||
@@ -7,25 +7,25 @@
|
||||
<div></div>
|
||||
</div>
|
||||
<p class="components-reconnect-first-attempt-visible">
|
||||
Rejoining the server...
|
||||
@T["Shell.Reconnect.First"]
|
||||
</p>
|
||||
<p class="components-reconnect-repeated-attempt-visible">
|
||||
Rejoin failed... trying again in <span id="components-seconds-to-next-attempt"></span> seconds.
|
||||
@T["Shell.Reconnect.Repeated"] <span id="components-seconds-to-next-attempt"></span> @T["Shell.Reconnect.Seconds"]
|
||||
</p>
|
||||
<p class="components-reconnect-failed-visible">
|
||||
Failed to rejoin.<br />Please retry or reload the page.
|
||||
@T["Shell.Reconnect.Failed"]<br />@T["Shell.Reconnect.FailedHint"]
|
||||
</p>
|
||||
<button id="components-reconnect-button" class="components-reconnect-failed-visible">
|
||||
Retry
|
||||
@T["Shell.Reconnect.Retry"]
|
||||
</button>
|
||||
<p class="components-pause-visible">
|
||||
The session has been paused by the server.
|
||||
@T["Shell.Reconnect.Paused"]
|
||||
</p>
|
||||
<p class="components-resume-failed-visible">
|
||||
Failed to resume the session.<br />Please retry or reload the page.
|
||||
@T["Shell.Reconnect.ResumeFailed"]<br />@T["Shell.Reconnect.FailedHint"]
|
||||
</p>
|
||||
<button id="components-resume-button" class="components-pause-visible components-resume-failed-visible">
|
||||
Resume
|
||||
@T["Shell.Reconnect.Resume"]
|
||||
</button>
|
||||
</div>
|
||||
</dialog>
|
||||
@@ -1,12 +1,11 @@
|
||||
@page "/accesso-negato"
|
||||
@attribute [ExcludeFromInteractiveRouting]
|
||||
@layout AuthLayout
|
||||
<KhPageTitle Text="@T["Pages.AccessDenied.PageTitle"]" />
|
||||
|
||||
<PageTitle>Khaemhat · accesso negato</PageTitle>
|
||||
|
||||
<main class="kh-construction">
|
||||
<section class="hero">
|
||||
<h1>Accesso negato</h1>
|
||||
<p class="lead">Il tuo profilo non ha il permesso per questa pagina, oppure il modulo non è compreso nella licenza.</p>
|
||||
<ul class="links"><li><a href="/">Torna alla pagina iniziale</a></li></ul>
|
||||
</section>
|
||||
</main>
|
||||
<div class="kh-message">
|
||||
<KhIcon Name="lock" Class="lg" />
|
||||
<h1>@T["Pages.AccessDenied.Title"]</h1>
|
||||
<p class="lead">@T["Pages.AccessDenied.Lead"]</p>
|
||||
<a class="btn" href="./">@T["Common.BackHome"]</a>
|
||||
</div>
|
||||
@@ -0,0 +1,76 @@
|
||||
@page "/anagrafiche/{*Rest}"
|
||||
@page "/crm/{*Rest}"
|
||||
@page "/vendite/{*Rest}"
|
||||
@page "/acquisti/{*Rest}"
|
||||
@page "/magazzino/{*Rest}"
|
||||
@page "/contabilita/{*Rest}"
|
||||
@page "/scadenzario/{*Rest}"
|
||||
@page "/fatturazione-elettronica/{*Rest}"
|
||||
@page "/cespiti/{*Rest}"
|
||||
@page "/servizi/{*Rest}"
|
||||
@page "/canali/{*Rest}"
|
||||
@page "/report/{*Rest}"
|
||||
@page "/tabelle/{*Rest}"
|
||||
@page "/automazioni/{*Rest}"
|
||||
@page "/amministrazione/{*Rest}"
|
||||
@attribute [Authorize]
|
||||
@inject ShellSession Session
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
@* The menu shows every area the licence and the permissions allow (SPEC §10.2); the areas of later milestones land
|
||||
here, which says when they arrive and what they will hold. Each real page replaces its route as it is built. *@
|
||||
<KhPageTitle Text="@Title" Icon="@(Area?.Icon)" />
|
||||
|
||||
@if (Area is null || !Session.CanSee(Area))
|
||||
{
|
||||
<div class="kh-message">
|
||||
<KhIcon Name="lock" Class="lg" />
|
||||
<h1>@T["Pages.AccessDenied.Title"]</h1>
|
||||
<p class="lead">@T["Pages.AccessDenied.Lead"]</p>
|
||||
<a class="btn" href="./">@T["Common.BackHome"]</a>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="kh-message">
|
||||
<KhIcon Name="@Area.Icon" Class="lg" />
|
||||
<h1>@Title</h1>
|
||||
<p class="lead">@(Area.Milestone is { } milestone ? T.Format("Pages.ComingSoon.Lead", milestone) : T["Pages.ComingSoon.LeadUnknown"])</p>
|
||||
@if (Area.Children.Count > 0)
|
||||
{
|
||||
<p class="muted">@T["Pages.ComingSoon.Areas"]</p>
|
||||
<ul class="kh-chips">
|
||||
@foreach (var child in Area.Children)
|
||||
{
|
||||
<li class="chip">@T[child.Key]</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
<div class="kh-actions">
|
||||
<a class="btn" href="./">@T["Common.BackHome"]</a>
|
||||
<a class="btn ghost" href="@(HelpLinks.DefaultBaseUrl + "Roadmap")" target="_blank" rel="noopener">@T["Pages.ComingSoon.Roadmap"]</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
/// <summary>The rest of the address, after the area.</summary>
|
||||
[Parameter]
|
||||
public string? Rest { get; set; }
|
||||
|
||||
private MenuItem? Area { get; set; }
|
||||
|
||||
private MenuItem? Entry { get; set; }
|
||||
|
||||
private string Title => Entry is null ? T["Pages.ComingSoon.Title"] : T[Entry.Key];
|
||||
|
||||
// A tab keeps its page alive and has one address, so the address is read once.
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await Session.EnsureLoadedAsync();
|
||||
var path = "/" + Navigation.ToBaseRelativePath(Navigation.Uri).Split('?', '#')[0];
|
||||
Area = MenuCatalog.FindArea(path);
|
||||
Entry = MenuCatalog.Find(path);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,21 @@
|
||||
@page "/Error"
|
||||
@attribute [ExcludeFromInteractiveRouting]
|
||||
@layout AuthLayout
|
||||
@using System.Diagnostics
|
||||
|
||||
@* The error code shown to people is the trace id, the same one written in the log (SPEC §9.5). *@
|
||||
<PageTitle>Khaemhat · errore</PageTitle>
|
||||
<PageTitle>@T["Pages.Error.PageTitle"] · @T["Common.ProductName"]</PageTitle>
|
||||
|
||||
<main class="kh-construction">
|
||||
<section class="hero">
|
||||
<h1>Si è verificato un errore</h1>
|
||||
<p class="lead">La richiesta non è stata completata. Se il problema si ripete, comunica all'amministratore il codice qui sotto.</p>
|
||||
@if (!string.IsNullOrEmpty(TraceId))
|
||||
{
|
||||
<p class="build">Codice errore: <code>@TraceId</code></p>
|
||||
}
|
||||
<ul class="links"><li><a href="/">Torna alla pagina iniziale</a></li></ul>
|
||||
</section>
|
||||
</main>
|
||||
<div class="kh-message">
|
||||
<KhIcon Name="alert" Class="lg" />
|
||||
<h1>@T["Pages.Error.Title"]</h1>
|
||||
<p class="lead">@T["Pages.Error.Lead"]</p>
|
||||
@if (!string.IsNullOrEmpty(TraceId))
|
||||
{
|
||||
<p class="muted">@T["Pages.Error.Code"] <code>@TraceId</code></p>
|
||||
}
|
||||
<a class="btn" href="./">@T["Common.BackHome"]</a>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[CascadingParameter]
|
||||
|
||||
@@ -1,42 +1,102 @@
|
||||
@page "/"
|
||||
@attribute [Authorize]
|
||||
@using Khaemhat.Application.Licensing
|
||||
@using Khaemhat.Core.Common
|
||||
@inject ProductVersion Version
|
||||
@inject ILicenseGate Licenses
|
||||
@using Khaemhat.Application.Modules
|
||||
@inject ShellSession Session
|
||||
@inject TimeProvider Clock
|
||||
|
||||
@* Placeholder until the shell of M3 (SPEC §20): who is signed in, in which company, with which licence. Texts move to
|
||||
the it-IT resources with the localization of M3. *@
|
||||
<PageTitle>Khaemhat</PageTitle>
|
||||
@* The home page of SPEC §10.2 until the widget dashboard of mockup 004 (issue #30): who is signed in, the licence,
|
||||
the company and the areas the user can open, with the milestone of those still to come. *@
|
||||
<KhPageTitle Text="@T["Pages.Home.Title"]" Icon="home" />
|
||||
|
||||
<main class="kh-construction">
|
||||
<section class="hero">
|
||||
<img class="mark" src="icon.svg" alt="" width="96" height="96" />
|
||||
<h1>Khaemhat <span class="ver">v @Version.MajorMinor</span></h1>
|
||||
<AuthorizeView>
|
||||
<p class="lead">Benvenuto, <strong>@context.User.FindFirst(SessionCookie.DisplayNameClaim)?.Value</strong>
|
||||
(@LevelLabel(context.User.FindFirst(SessionCookie.LevelClaim)?.Value))
|
||||
@if (context.User.FindFirst(SessionCookie.CompanyClaim)?.Value is { } company)
|
||||
{
|
||||
<span> · azienda <strong>@company</strong></span>
|
||||
}
|
||||
</p>
|
||||
</AuthorizeView>
|
||||
<p class="state">Accesso, utenti, ruoli, licenze e log sono pronti; le schermate di lavoro arrivano con l'interfaccia della milestone 3.
|
||||
Licenza: @(Licenses.Current.Kind == LicenseKind.Trial ? "prova" : Licenses.Current.Licensee) · moduli @string.Join(", ", Licenses.Current.Modules.Order())</p>
|
||||
<form method="post" action="/logout" class="links">
|
||||
<AntiforgeryToken />
|
||||
<button type="submit" class="kh-btn ghost">Esci</button>
|
||||
</form>
|
||||
<p class="build">Versione @Version.Full</p>
|
||||
</section>
|
||||
</main>
|
||||
<div class="phead">
|
||||
<div>
|
||||
<h1>@Greeting</h1>
|
||||
<div class="sub">@T.Format("Pages.Home.Today", Today)</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cols cols-3 kh-home-tiles">
|
||||
<div class="tile acc">
|
||||
<div class="t"><KhIcon Name="key" Class="sm" /> @T["Pages.Home.LicenseTile"]</div>
|
||||
<div class="v">@(License.Kind == LicenseKind.Trial ? T["Pages.Home.LicenseTrial"] : T["Pages.Home.LicenseFull"])</div>
|
||||
<div class="d">@LicenseDetail</div>
|
||||
</div>
|
||||
<div class="tile">
|
||||
<div class="t"><KhIcon Name="layers" Class="sm" /> @T["Pages.Home.ModulesTile"]</div>
|
||||
<div class="v">@T.Format("Pages.Home.ModulesText", License.Modules.Count, ModuleRegistry.Default.Modules.Count)</div>
|
||||
<div class="d">@(License.Modules.Count == 0 ? T["Pages.Home.ModulesNone"] : string.Join(" · ", License.Modules.Order(StringComparer.Ordinal)))</div>
|
||||
</div>
|
||||
<div class="tile">
|
||||
<div class="t"><KhIcon Name="building" Class="sm" /> @T["Pages.Home.CompanyTile"]</div>
|
||||
<div class="v">@(Session.Company?.Name ?? T["Pages.Home.CompanyNone"])</div>
|
||||
<div class="d">@Session.Company?.Code</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="panel" aria-labelledby="kh-home-areas">
|
||||
<div class="ph"><KhIcon Name="grid" /> <span id="kh-home-areas">@T["Pages.Home.AreasTitle"]</span></div>
|
||||
<div class="pb">
|
||||
<p class="muted">@T["Pages.Home.AreasHint"]</p>
|
||||
<div class="kh-areas">
|
||||
@foreach (var area in Areas)
|
||||
{
|
||||
<a class="kh-area" href="@area.Href.TrimStart('/')">
|
||||
<span class="ico-box"><KhIcon Name="@area.Icon" /></span>
|
||||
<span class="grow">@T[area.Key]</span>
|
||||
@if (area.Milestone is { } milestone)
|
||||
{
|
||||
<span class="badge gray">@T.Format("Pages.Home.Coming", milestone)</span>
|
||||
}
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="callout info"><KhIcon Name="info" /> <span>@T["Pages.Home.DashboardSoon"]</span></div>
|
||||
|
||||
@code {
|
||||
private static string LevelLabel(string? level) => level switch
|
||||
private LicenseState License => Session.Licenses.Current;
|
||||
|
||||
private IEnumerable<MenuItem> Areas =>
|
||||
MenuCatalog.Sections.SelectMany(s => s.Items).Where(i => i.Href != "/" && Session.CanSee(i));
|
||||
|
||||
private string Today => Clock.GetLocalNow().ToString("dddd d MMMM yyyy", T.Culture);
|
||||
|
||||
private string Greeting
|
||||
{
|
||||
"SuperUser" => "super utente",
|
||||
"Administrator" => "amministratore",
|
||||
_ => "utente",
|
||||
};
|
||||
get
|
||||
{
|
||||
var key = Clock.GetLocalNow().Hour switch
|
||||
{
|
||||
< 13 => "Pages.Home.Greeting",
|
||||
< 18 => "Pages.Home.GreetingAfternoon",
|
||||
_ => "Pages.Home.GreetingEvening",
|
||||
};
|
||||
return T.Format(key, FirstName);
|
||||
}
|
||||
}
|
||||
|
||||
private string FirstName => Session.DisplayName.Split(' ', StringSplitOptions.RemoveEmptyEntries).FirstOrDefault() ?? Session.DisplayName;
|
||||
|
||||
private string LicenseDetail
|
||||
{
|
||||
get
|
||||
{
|
||||
var parts = new List<string>();
|
||||
if (License.Licensee is { Length: > 0 } licensee)
|
||||
{
|
||||
parts.Add(T.Format("Pages.Home.LicenseLicensee", licensee));
|
||||
}
|
||||
|
||||
parts.Add(License.DaysLeft(Clock.GetUtcNow().UtcDateTime) is { } days
|
||||
? T.Format("Pages.Home.LicenseDaysLeft", days)
|
||||
: T["Pages.Home.LicenseUnlimited"]);
|
||||
return string.Join(" · ", parts);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override Task OnInitializedAsync() => Session.EnsureLoadedAsync();
|
||||
}
|
||||
@@ -12,10 +12,10 @@
|
||||
@inject NavigationManager Navigation
|
||||
@inject TimeProvider Clock
|
||||
|
||||
<PageTitle>Accedi · Khaemhat</PageTitle>
|
||||
<PageTitle>@T["Auth.Login.Title"] · @T["Common.ProductName"]</PageTitle>
|
||||
|
||||
<h1>Accedi</h1>
|
||||
<p class="sub">Scegli l'azienda e inserisci le credenziali.</p>
|
||||
<h1>@T["Auth.Login.Title"]</h1>
|
||||
<p class="sub">@T["Auth.Login.Subtitle"]</p>
|
||||
|
||||
@foreach (var message in Errors)
|
||||
{
|
||||
@@ -23,24 +23,24 @@
|
||||
}
|
||||
|
||||
<EditForm Model="Input" method="post" FormName="login" OnSubmit="SubmitAsync" class="kh-form">
|
||||
<label for="company">Azienda</label>
|
||||
<label for="company">@T["Auth.Login.Company"]</label>
|
||||
<InputSelect id="company" @bind-Value="Input.CompanyCode">
|
||||
<option value="">Nessuna (account di istanza)</option>
|
||||
<option value="">@T["Auth.Login.NoCompany"]</option>
|
||||
@foreach (var company in AvailableCompanies)
|
||||
{
|
||||
<option value="@company.Code">@company.Name (@company.Code)</option>
|
||||
<option value="@company.Code">@T.Format("Auth.Login.CompanyOption", company.Name, company.Code)</option>
|
||||
}
|
||||
</InputSelect>
|
||||
|
||||
<label for="user">Nome utente</label>
|
||||
<label for="user">@T["Auth.Login.UserName"]</label>
|
||||
<InputText id="user" @bind-Value="Input.UserName" autocomplete="username" autofocus required />
|
||||
|
||||
<label for="password">Password</label>
|
||||
<label for="password">@T["Auth.Login.Password"]</label>
|
||||
<InputText id="password" type="password" @bind-Value="Input.Password" autocomplete="current-password" required />
|
||||
|
||||
<label class="check"><InputCheckbox @bind-Value="Input.Remember" /> Ricordami su questo dispositivo</label>
|
||||
<label class="check"><InputCheckbox @bind-Value="Input.Remember" /> @T["Auth.Login.Remember"]</label>
|
||||
|
||||
<button type="submit" class="kh-btn primary">Accedi</button>
|
||||
<button type="submit" class="kh-btn primary">@T["Auth.Login.Submit"]</button>
|
||||
</EditForm>
|
||||
|
||||
@if (TrialNotice is not null)
|
||||
@@ -77,11 +77,11 @@
|
||||
var license = Licenses.Current;
|
||||
if (license.Kind == LicenseKind.Trial)
|
||||
{
|
||||
TrialNotice = $"Licenza in modalità prova: restano {license.DaysLeft(Clock.GetUtcNow().UtcDateTime)} giorni, con i moduli Base e Contabilità e {license.MaxConcurrentUsers} utenti collegati.";
|
||||
TrialNotice = T.Format("Auth.Login.Trial", license.DaysLeft(Clock.GetUtcNow().UtcDateTime), license.MaxConcurrentUsers);
|
||||
}
|
||||
else if (license.Status != LicenseStatus.Valid)
|
||||
{
|
||||
TrialNotice = "La licenza è scaduta: rivolgiti all'amministratore.";
|
||||
TrialNotice = T["Auth.Login.Expired"];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
Input.Password = null;
|
||||
if (!result.Succeeded || result.Cookie is null)
|
||||
{
|
||||
Errors = LoginFlow.Messages(result.Error);
|
||||
Errors = LoginFlow.Messages(T, Policy, result.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
@inject NavigationManager Navigation
|
||||
@inject TimeProvider Clock
|
||||
|
||||
<PageTitle>Cambio password · Khaemhat</PageTitle>
|
||||
<PageTitle>@T["Auth.PasswordChange.PageTitle"] · @T["Common.ProductName"]</PageTitle>
|
||||
|
||||
<h1>Scegli una nuova password</h1>
|
||||
<p class="sub">Al primo accesso, o dopo una password provvisoria, serve una password personale.</p>
|
||||
<h1>@T["Auth.PasswordChange.Title"]</h1>
|
||||
<p class="sub">@T["Auth.PasswordChange.Subtitle"]</p>
|
||||
|
||||
@foreach (var message in Errors)
|
||||
{
|
||||
@@ -18,22 +18,22 @@
|
||||
}
|
||||
|
||||
<EditForm Model="Input" method="post" FormName="password-change" OnSubmit="SubmitAsync" class="kh-form">
|
||||
<label for="current">Password attuale o provvisoria</label>
|
||||
<label for="current">@T["Auth.PasswordChange.Current"]</label>
|
||||
<InputText id="current" type="password" @bind-Value="Input.Current" autocomplete="current-password" autofocus required />
|
||||
|
||||
<label for="new">Nuova password</label>
|
||||
<label for="new">@T["Auth.PasswordChange.New"]</label>
|
||||
<InputText id="new" type="password" @bind-Value="Input.New" autocomplete="new-password" required />
|
||||
|
||||
<label for="confirm">Ripeti la nuova password</label>
|
||||
<label for="confirm">@T["Auth.PasswordChange.Confirm"]</label>
|
||||
<InputText id="confirm" type="password" @bind-Value="Input.Confirm" autocomplete="new-password" required />
|
||||
|
||||
<ul class="kh-rules">
|
||||
<li>Almeno @Policy.MinimumLength caratteri</li>
|
||||
<li>Almeno tre tipi tra minuscole, maiuscole, cifre e simboli</li>
|
||||
<li>Diversa dal nome utente e dalle ultime @Policy.HistorySize password</li>
|
||||
<li>@T.Format("Auth.PasswordChange.RuleLength", Policy.MinimumLength)</li>
|
||||
<li>@T["Auth.PasswordChange.RuleKinds"]</li>
|
||||
<li>@T.Format("Auth.PasswordChange.RuleHistory", Policy.HistorySize)</li>
|
||||
</ul>
|
||||
|
||||
<button type="submit" class="kh-btn primary">Salva e continua</button>
|
||||
<button type="submit" class="kh-btn primary">@T["Auth.PasswordChange.Submit"]</button>
|
||||
</EditForm>
|
||||
|
||||
@code {
|
||||
@@ -70,7 +70,7 @@
|
||||
|
||||
if (!string.Equals(Input.New, Input.Confirm, StringComparison.Ordinal))
|
||||
{
|
||||
Errors = ["Le due nuove password non coincidono."];
|
||||
Errors = [T["Auth.PasswordChange.Mismatch"]];
|
||||
Clear();
|
||||
return;
|
||||
}
|
||||
@@ -79,7 +79,7 @@
|
||||
Clear();
|
||||
if (!result.Succeeded || result.Cookie is null)
|
||||
{
|
||||
Errors = LoginFlow.Messages(result.Error);
|
||||
Errors = LoginFlow.Messages(T, Policy, result.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
@inject NavigationManager Navigation
|
||||
@inject TimeProvider Clock
|
||||
|
||||
<PageTitle>Verifica in due passaggi · Khaemhat</PageTitle>
|
||||
<PageTitle>@T["Auth.Totp.Title"] · @T["Common.ProductName"]</PageTitle>
|
||||
|
||||
<h1>Verifica in due passaggi</h1>
|
||||
<p class="sub">Inserisci il codice a 6 cifre dell'app di autenticazione.</p>
|
||||
<h1>@T["Auth.Totp.Title"]</h1>
|
||||
<p class="sub">@T["Auth.Totp.Subtitle"]</p>
|
||||
|
||||
@foreach (var message in Errors)
|
||||
{
|
||||
@@ -18,15 +18,15 @@
|
||||
}
|
||||
|
||||
<EditForm Model="Input" method="post" FormName="totp" OnSubmit="SubmitAsync" class="kh-form">
|
||||
<label for="code">Codice</label>
|
||||
<label for="code">@T["Auth.Totp.Code"]</label>
|
||||
<InputText id="code" class="otp" @bind-Value="Input.Code" inputmode="numeric" autocomplete="one-time-code" maxlength="20" autofocus required />
|
||||
<div class="row">
|
||||
<button type="submit" class="kh-btn primary">Verifica</button>
|
||||
<span class="hint">Oppure un codice di recupero (XXXX-XXXX)</span>
|
||||
<button type="submit" class="kh-btn primary">@T["Auth.Totp.Submit"]</button>
|
||||
<span class="hint">@T["Auth.Totp.RecoveryHint"]</span>
|
||||
</div>
|
||||
</EditForm>
|
||||
|
||||
<div class="kh-alert info">Il codice cambia ogni 30 secondi. L'autenticazione a due fattori è obbligatoria per amministratori e super utente.</div>
|
||||
<div class="kh-alert info">@T["Auth.Totp.Info"]</div>
|
||||
|
||||
@code {
|
||||
[CascadingParameter]
|
||||
@@ -64,7 +64,7 @@
|
||||
Input.Code = null;
|
||||
if (!result.Succeeded || result.Cookie is null)
|
||||
{
|
||||
Errors = LoginFlow.Messages(result.Error);
|
||||
Errors = LoginFlow.Messages(T, Policy, result.Error);
|
||||
if (result.Error == SecurityErrors.AccountLocked)
|
||||
{
|
||||
SessionCookie.Clear(HttpContext);
|
||||
|
||||
@@ -7,24 +7,24 @@
|
||||
@inject NavigationManager Navigation
|
||||
@inject TimeProvider Clock
|
||||
|
||||
<PageTitle>Configura la verifica in due passaggi · Khaemhat</PageTitle>
|
||||
<PageTitle>@T["Auth.TotpSetup.PageTitle"] · @T["Common.ProductName"]</PageTitle>
|
||||
|
||||
@if (RecoveryCodes is not null)
|
||||
{
|
||||
<h1>Codici di recupero</h1>
|
||||
<p class="sub">Conservali in un luogo sicuro: ognuno vale una volta sola, al posto del codice dell'app, se perdi il telefono. Non verranno mostrati di nuovo.</p>
|
||||
<h1>@T["Auth.TotpSetup.RecoveryTitle"]</h1>
|
||||
<p class="sub">@T["Auth.TotpSetup.RecoveryText"]</p>
|
||||
<ul class="kh-codes">
|
||||
@foreach (var recovery in RecoveryCodes)
|
||||
{
|
||||
<li><code>@recovery</code></li>
|
||||
}
|
||||
</ul>
|
||||
<a class="kh-btn primary" href="@NextUrl">Ho salvato i codici, continua</a>
|
||||
<a class="kh-btn primary" href="@NextUrl">@T["Auth.TotpSetup.RecoveryDone"]</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<h1>Configura la verifica in due passaggi</h1>
|
||||
<p class="sub">Aggiungi l'account a un'app di autenticazione (Google Authenticator, Microsoft Authenticator, Aegis, 2FAS...) e inserisci il primo codice.</p>
|
||||
<h1>@T["Auth.TotpSetup.Title"]</h1>
|
||||
<p class="sub">@T["Auth.TotpSetup.Subtitle"]</p>
|
||||
|
||||
@foreach (var message in Errors)
|
||||
{
|
||||
@@ -34,17 +34,17 @@ else
|
||||
@if (Setup is not null)
|
||||
{
|
||||
<dl class="kh-secret">
|
||||
<dt>Chiave da inserire nell'app</dt>
|
||||
<dt>@T["Auth.TotpSetup.Secret"]</dt>
|
||||
<dd><code>@Grouped(Setup.Secret)</code></dd>
|
||||
<dt>Sul telefono</dt>
|
||||
<dd><a href="@Setup.ProvisioningUri">Apri nell'app di autenticazione</a></dd>
|
||||
<dt>@T["Auth.TotpSetup.Phone"]</dt>
|
||||
<dd><a href="@Setup.ProvisioningUri">@T["Auth.TotpSetup.OpenInApp"]</a></dd>
|
||||
</dl>
|
||||
}
|
||||
|
||||
<EditForm Model="Input" method="post" FormName="totp-setup" OnSubmit="SubmitAsync" class="kh-form">
|
||||
<label for="code">Primo codice dell'app</label>
|
||||
<label for="code">@T["Auth.TotpSetup.FirstCode"]</label>
|
||||
<InputText id="code" class="otp" @bind-Value="Input.Code" inputmode="numeric" autocomplete="one-time-code" maxlength="6" autofocus required />
|
||||
<button type="submit" class="kh-btn primary">Attiva</button>
|
||||
<button type="submit" class="kh-btn primary">@T["Auth.TotpSetup.Submit"]</button>
|
||||
</EditForm>
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ else
|
||||
Input.Code = null;
|
||||
if (!result.Succeeded || result.Cookie is null || codes is null)
|
||||
{
|
||||
Errors = LoginFlow.Messages(result.Error);
|
||||
Errors = LoginFlow.Messages(T, Policy, result.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
@page "/not-found"
|
||||
@layout MainLayout
|
||||
<KhPageTitle Text="@T["Pages.NotFound.PageTitle"]" />
|
||||
|
||||
<PageTitle>Khaemhat · pagina non trovata</PageTitle>
|
||||
|
||||
<main class="kh-construction">
|
||||
<section class="hero">
|
||||
<h1>Pagina non trovata</h1>
|
||||
<p class="lead">L'indirizzo richiesto non esiste.</p>
|
||||
<ul class="links"><li><a href="/">Torna alla pagina iniziale</a></li></ul>
|
||||
</section>
|
||||
</main>
|
||||
<div class="kh-message">
|
||||
<KhIcon Name="search" Class="lg" />
|
||||
<h1>@T["Pages.NotFound.Title"]</h1>
|
||||
<p class="lead">@T["Pages.NotFound.Lead"]</p>
|
||||
<a class="btn" href="./">@T["Common.BackHome"]</a>
|
||||
</div>
|
||||
@@ -0,0 +1,393 @@
|
||||
@page "/profilo"
|
||||
@attribute [Authorize]
|
||||
@using System.Globalization
|
||||
@using Khaemhat.Application.Preferences
|
||||
@using Khaemhat.Application.Security
|
||||
@using Khaemhat.Web.Security
|
||||
@implements IAsyncDisposable
|
||||
@inject ShellSession Session
|
||||
@inject ThemeService Theme
|
||||
@inject ToastService Toasts
|
||||
@inject DialogService Dialogs
|
||||
@inject SessionStore Sessions
|
||||
@inject AuthenticationStateProvider Authentication
|
||||
|
||||
@* "Il mio profilo" (SPEC §10.6, §11.12, mockup 008). Every change is shown at once on the page (preview) and kept only
|
||||
with Save; leaving the page without saving puts the saved preferences back. *@
|
||||
<KhPageTitle Text="@T["Pages.Profile.Title"]" Icon="user" />
|
||||
|
||||
<div class="phead">
|
||||
<div>
|
||||
<h1>@T["Pages.Profile.Title"]</h1>
|
||||
<div class="sub">@T["Pages.Profile.Subtitle"]</div>
|
||||
</div>
|
||||
<div class="grow"></div>
|
||||
@if (_section is AppearanceSection or StartSection)
|
||||
{
|
||||
<div class="toolbar">
|
||||
<button type="button" class="btn ghost" @onclick="DefaultsAsync">@T["Pages.Profile.Defaults"]</button>
|
||||
<button type="button" class="btn" disabled="@(!IsModified)" @onclick="UndoAsync"><KhIcon Name="undo" /> @T["Pages.Profile.Undo"]</button>
|
||||
<button type="button" class="btn primary" disabled="@(!IsModified)" @onclick="SaveAsync"><KhIcon Name="save" /> @T["Pages.Profile.Save"]</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<section class="panel">
|
||||
<div class="tabs i" role="tablist">
|
||||
@foreach (var (id, icon, key) in Sections)
|
||||
{
|
||||
<a class="tab @(id == _section ? "active" : null)" role="tab" aria-selected="@(id == _section)" href="@("profilo?scheda=" + id)">
|
||||
<KhIcon Name="@icon" /> @T[key]
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
|
||||
@switch (_section)
|
||||
{
|
||||
case AppearanceSection:
|
||||
<div class="fgroups">
|
||||
<fieldset class="fgroup wide">
|
||||
<legend class="fgh"><KhIcon Name="contrast" /> @T["Pages.Profile.Theme"]</legend>
|
||||
<div class="kh-choices">
|
||||
@foreach (var theme in Enum.GetValues<ThemeMode>())
|
||||
{
|
||||
<button type="button" class="themecard @(Draft.Theme == theme ? "on" : null)" aria-pressed="@(Draft.Theme == theme)"
|
||||
@onclick="() => ChangeAsync(Draft with { Theme = theme })">
|
||||
<span class="pv kh-pv-@UserPreferences.ThemeName(theme)" aria-hidden="true">
|
||||
<span class="tb"></span><span class="sb"></span>
|
||||
<span class="ct"><i></i><i></i><i></i></span>
|
||||
</span>
|
||||
<span class="lbl">
|
||||
@if (Draft.Theme == theme)
|
||||
{
|
||||
<KhIcon Name="check-circle" Class="sm" />
|
||||
}
|
||||
@T["Pages.Profile.Theme." + theme]
|
||||
@if (theme == ThemeMode.Auto)
|
||||
{
|
||||
<span class="muted">@T["Pages.Profile.Theme.AutoHint"]</span>
|
||||
}
|
||||
</span>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fgroup wide">
|
||||
<legend class="fgh"><KhIcon Name="palette" /> @T["Pages.Profile.Accent"]</legend>
|
||||
<div class="swatches kh-choices">
|
||||
@foreach (var accent in UserPreferences.Accents)
|
||||
{
|
||||
<button type="button" class="sw @(Draft.Accent == accent ? "on" : null)" aria-pressed="@(Draft.Accent == accent)"
|
||||
@onclick="() => ChangeAsync(Draft with { Accent = accent })">
|
||||
<span class="c kh-acc-@accent" aria-hidden="true"><i></i></span>
|
||||
<span class="n">
|
||||
@if (Draft.Accent == accent)
|
||||
{
|
||||
<KhIcon Name="check" Class="sm" />
|
||||
}
|
||||
@T["Pages.Profile.Accent." + accent]
|
||||
</span>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fgroup">
|
||||
<legend class="fgh"><KhIcon Name="columns" /> @T["Pages.Profile.Density"]</legend>
|
||||
<div class="kh-seg" role="radiogroup" aria-label="@T["Pages.Profile.Density"]">
|
||||
@foreach (var density in Enum.GetValues<Density>())
|
||||
{
|
||||
<button type="button" role="radio" class="@(Draft.Density == density ? "on" : null)" aria-checked="@(Draft.Density == density)"
|
||||
@onclick="() => ChangeAsync(Draft with { Density = density })">@T["Pages.Profile.Density." + density]</button>
|
||||
}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fgroup">
|
||||
<legend class="fgh"><KhIcon Name="edit" /> @T["Pages.Profile.TextSize"]</legend>
|
||||
<div class="kh-seg" role="radiogroup" aria-label="@T["Pages.Profile.TextSize"]">
|
||||
@foreach (var size in UserPreferences.TextSizes)
|
||||
{
|
||||
<button type="button" role="radio" class="@(Draft.TextSize == size ? "on" : null)" aria-checked="@(Draft.TextSize == size)"
|
||||
@onclick="() => ChangeAsync(Draft with { TextSize = size })">@T.Format("Pages.Profile.TextSize.Value", size)</button>
|
||||
}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fgroup">
|
||||
<legend class="fgh"><KhIcon Name="sidebar" /> @T["Pages.Profile.Menu"]</legend>
|
||||
<div class="kh-seg" role="radiogroup" aria-label="@T["Pages.Profile.Menu"]">
|
||||
@foreach (var (value, key) in MenuChoices)
|
||||
{
|
||||
<button type="button" role="radio" class="@(Draft.MenuCollapsed == value ? "on" : null)" aria-checked="@(Draft.MenuCollapsed == value)"
|
||||
@onclick="() => ChangeAsync(Draft with { MenuCollapsed = value })">@T[key]</button>
|
||||
}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fgroup wide">
|
||||
<legend class="fgh"><KhIcon Name="settings" /> @T["Pages.Profile.Options"]</legend>
|
||||
<div class="kh-switches">
|
||||
<KhSwitchRow Label="@T["Pages.Profile.Options.TabularNumbers"]" Hint="@T["Pages.Profile.Options.TabularNumbersHint"]"
|
||||
Value="Draft.TabularNumbers" ValueChanged="v => ChangeAsync(Draft with { TabularNumbers = v })" />
|
||||
<KhSwitchRow Label="@T["Pages.Profile.Options.ReducedMotion"]" Hint="@T["Pages.Profile.Options.ReducedMotionHint"]"
|
||||
Value="Draft.ReducedMotion" ValueChanged="v => ChangeAsync(Draft with { ReducedMotion = v })" />
|
||||
<KhSwitchRow Label="@T["Pages.Profile.Options.Tooltips"]" Hint="@T["Pages.Profile.Options.TooltipsHint"]"
|
||||
Value="Draft.Tooltips" ValueChanged="v => ChangeAsync(Draft with { Tooltips = v })" />
|
||||
<KhSwitchRow Label="@T["Pages.Profile.Options.RowHover"]" Hint="@T["Pages.Profile.Options.RowHoverHint"]"
|
||||
Value="Draft.RowHover" ValueChanged="v => ChangeAsync(Draft with { RowHover = v })" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="callout info kh-inset"><KhIcon Name="info" /> <span>@T["Pages.Profile.Preview"]</span></div>
|
||||
break;
|
||||
|
||||
case StartSection:
|
||||
<div class="fgroups">
|
||||
<fieldset class="fgroup wide">
|
||||
<legend class="fgh"><KhIcon Name="home" /> @T["Pages.Profile.Start"]</legend>
|
||||
<div class="kh-radios" role="radiogroup" aria-label="@T["Pages.Profile.Start"]">
|
||||
@foreach (var start in Enum.GetValues<StartPage>())
|
||||
{
|
||||
<label class="chk">
|
||||
<input type="radio" name="kh-start" checked="@(Draft.StartPage == start)"
|
||||
@onchange="() => ChangeAsync(Draft with { StartPage = start })" />
|
||||
@T["Pages.Profile.Start." + start]
|
||||
</label>
|
||||
}
|
||||
</div>
|
||||
@if (Draft.StartPage == StartPage.Page)
|
||||
{
|
||||
<div class="f kh-pick">
|
||||
<label for="kh-start-path">@T["Pages.Profile.Start.PagePick"]</label>
|
||||
<select id="kh-start-path" class="kh-input" value="@Draft.StartPath"
|
||||
@onchange="e => ChangeAsync(Draft with { StartPath = e.Value as string })">
|
||||
@foreach (var item in StartChoices)
|
||||
{
|
||||
<option value="@item.Href">@T[item.Key]</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
}
|
||||
<KhSwitchRow Label="@T["Pages.Profile.Start.ShowDashboard"]" Value="Draft.ShowDashboard"
|
||||
ValueChanged="v => ChangeAsync(Draft with { ShowDashboard = v })" />
|
||||
</fieldset>
|
||||
</div>
|
||||
break;
|
||||
|
||||
case SessionsSection:
|
||||
<div class="pb">
|
||||
<p class="muted">@T["Pages.Profile.Sessions.Intro"]</p>
|
||||
<table class="kh-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">@T["Pages.Profile.Sessions.Device"]</th>
|
||||
<th scope="col">@T["Pages.Profile.Sessions.Address"]</th>
|
||||
<th scope="col">@T["Pages.Profile.Sessions.Company"]</th>
|
||||
<th scope="col">@T["Pages.Profile.Sessions.SignedIn"]</th>
|
||||
<th scope="col">@T["Pages.Profile.Sessions.LastSeen"]</th>
|
||||
<th scope="col"><span class="sr-only">@T["Pages.Profile.Sessions.Revoke"]</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in _sessions)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<KhIcon Name="monitor" Class="sm" /> @DeviceOf(item.UserAgent)
|
||||
@if (item.Id == _currentSessionId)
|
||||
{
|
||||
<span class="badge green">@T["Pages.Profile.Sessions.Current"]</span>
|
||||
}
|
||||
</td>
|
||||
<td class="mono">@item.IpAddress</td>
|
||||
<td>@(item.CompanyCode ?? T["Pages.Profile.Sessions.InstanceAccount"])</td>
|
||||
<td class="kh-nowrap">@T.DateTime(item.CreatedAt, TimeZoneInfo.Local)</td>
|
||||
<td class="kh-nowrap">@T.DateTime(item.LastSeenAt, TimeZoneInfo.Local)</td>
|
||||
<td>
|
||||
@if (item.Id != _currentSessionId)
|
||||
{
|
||||
<button type="button" class="btn danger" @onclick="() => RevokeAsync(item)"><KhIcon Name="logout" /> @T["Pages.Profile.Sessions.Revoke"]</button>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
@if (_sessions.Any(s => s.Id != _currentSessionId))
|
||||
{
|
||||
<div><button type="button" class="btn danger" @onclick="RevokeOthersAsync"><KhIcon Name="logout" /> @T["Pages.Profile.Sessions.RevokeOthers"]</button></div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="muted">@T["Pages.Profile.Sessions.None"]</p>
|
||||
}
|
||||
</div>
|
||||
break;
|
||||
|
||||
default:
|
||||
<div class="pb">
|
||||
@foreach (var scope in Enum.GetValues<ShortcutScope>())
|
||||
{
|
||||
<h2 class="kh-h2">@T["Pages.Profile.Shortcuts." + scope]</h2>
|
||||
<table class="kh-table">
|
||||
<thead><tr><th scope="col">@T["Pages.Profile.Shortcuts.Keys"]</th><th scope="col">@T["Pages.Profile.Shortcuts.Action"]</th></tr></thead>
|
||||
<tbody>
|
||||
@foreach (var shortcut in KeyboardShortcuts.All.Where(s => s.Scope == scope))
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@foreach (var keys in shortcut.Keys)
|
||||
{
|
||||
<kbd>@keys</kbd>
|
||||
}
|
||||
</td>
|
||||
<td>@T[shortcut.TextKey]</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
<p class="muted">@T["Pages.Profile.Shortcuts.BrowserNote"]</p>
|
||||
</div>
|
||||
break;
|
||||
}
|
||||
</section>
|
||||
|
||||
@code {
|
||||
private const string AppearanceSection = "aspetto";
|
||||
private const string StartSection = "pagina-iniziale";
|
||||
private const string ShortcutsSection = "scorciatoie";
|
||||
private const string SessionsSection = "sessioni";
|
||||
|
||||
private static readonly (string Id, string Icon, string Key)[] Sections =
|
||||
[
|
||||
(AppearanceSection, "palette", "Pages.Profile.Tabs.Appearance"),
|
||||
(StartSection, "home", "Pages.Profile.Tabs.Start"),
|
||||
(SessionsSection, "monitor", "Pages.Profile.Tabs.Sessions"),
|
||||
(ShortcutsSection, "keyboard", "Pages.Profile.Tabs.Shortcuts"),
|
||||
];
|
||||
|
||||
private static readonly (bool? Value, string Key)[] MenuChoices =
|
||||
[
|
||||
(null, "Pages.Profile.Menu.Auto"),
|
||||
(false, "Pages.Profile.Menu.Expanded"),
|
||||
(true, "Pages.Profile.Menu.Collapsed"),
|
||||
];
|
||||
|
||||
private string _section = AppearanceSection;
|
||||
private IReadOnlyList<SessionSummary> _sessions = [];
|
||||
private SessionOwner? _owner;
|
||||
private long _currentSessionId;
|
||||
|
||||
/// <summary>The section: <c>aspetto</c>, <c>pagina-iniziale</c>, <c>sessioni</c>, <c>scorciatoie</c>.</summary>
|
||||
[SupplyParameterFromQuery(Name = "scheda")]
|
||||
public string? Section { get; set; }
|
||||
|
||||
/// <summary>The tab of the page, to show the modified mark.</summary>
|
||||
[CascadingParameter]
|
||||
public KhTab? Tab { get; set; }
|
||||
|
||||
private UserPreferences Draft { get; set; } = UserPreferences.Default;
|
||||
|
||||
private bool IsModified => Draft != Session.Preferences;
|
||||
|
||||
private IEnumerable<MenuItem> StartChoices => MenuCatalog.All.Where(i => i.Milestone is null && Session.CanSee(i));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await Session.EnsureLoadedAsync();
|
||||
Draft = Session.Preferences;
|
||||
var user = (await Authentication.GetAuthenticationStateAsync()).User;
|
||||
_owner = SessionCookie.OwnerOf(user);
|
||||
_ = long.TryParse(user.FindFirst(SessionCookie.SessionIdClaim)?.Value, NumberStyles.None, CultureInfo.InvariantCulture, out _currentSessionId);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
_section = Sections.Any(s => s.Id == Section) ? Section! : AppearanceSection;
|
||||
if (_section == SessionsSection)
|
||||
{
|
||||
await LoadSessionsAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadSessionsAsync() =>
|
||||
_sessions = _owner is null ? [] : await Sessions.ListAsync(_owner);
|
||||
|
||||
private async Task RevokeAsync(SessionSummary item)
|
||||
{
|
||||
if (_owner is null || !await Dialogs.ConfirmAsync(new(T["Pages.Profile.Sessions.RevokeTitle"], T["Pages.Profile.Sessions.RevokeText"],
|
||||
T["Pages.Profile.Sessions.Revoke"], T["Common.Cancel"], Danger: true)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await Sessions.RevokeAsync(_owner, item.Id, "user");
|
||||
Toasts.Show(ToastKind.Success, T["Pages.Profile.Sessions.Revoked"]);
|
||||
await LoadSessionsAsync();
|
||||
}
|
||||
|
||||
private async Task RevokeOthersAsync()
|
||||
{
|
||||
if (_owner is null || !await Dialogs.ConfirmAsync(new(T["Pages.Profile.Sessions.RevokeTitle"], T["Pages.Profile.Sessions.RevokeOthersText"],
|
||||
T["Pages.Profile.Sessions.RevokeOthers"], T["Common.Cancel"], Danger: true)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var count = await Sessions.RevokeAllAsync(_owner, "user", _currentSessionId);
|
||||
Toasts.Show(ToastKind.Success, T.Format("Pages.Profile.Sessions.RevokedMany", count));
|
||||
await LoadSessionsAsync();
|
||||
}
|
||||
|
||||
// A short name of the browser and system from the user agent: enough to recognise a device, not a full parser.
|
||||
private static readonly (string Marker, string Name)[] Browsers = [("Edg/", "Edge"), ("OPR/", "Opera"), ("Firefox/", "Firefox"), ("Chrome/", "Chrome"), ("Safari/", "Safari")];
|
||||
private static readonly string[] Systems = ["Windows", "Android", "iPhone", "iPad", "Mac OS", "Linux"];
|
||||
|
||||
private string DeviceOf(string? userAgent)
|
||||
{
|
||||
var browser = userAgent is null ? null : Browsers.FirstOrDefault(b => userAgent.Contains(b.Marker, StringComparison.Ordinal)).Name;
|
||||
var system = userAgent is null ? null : Systems.FirstOrDefault(s => userAgent.Contains(s, StringComparison.Ordinal));
|
||||
return browser is null && system is null
|
||||
? T["Pages.Profile.Sessions.Unknown"]
|
||||
: string.Join(" · ", new[] { browser, system }.Where(x => x is not null));
|
||||
}
|
||||
|
||||
private async Task ChangeAsync(UserPreferences next)
|
||||
{
|
||||
if (next.StartPage == StartPage.Page && !UserPreferences.IsLocalPath(next.StartPath))
|
||||
{
|
||||
next = next with { StartPath = StartChoices.FirstOrDefault()?.Href ?? "/" };
|
||||
}
|
||||
|
||||
Draft = next;
|
||||
Tab?.SetModified(IsModified);
|
||||
await Theme.PreviewAsync(Draft);
|
||||
}
|
||||
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
await Theme.ApplyAsync(Draft);
|
||||
Draft = Session.Preferences;
|
||||
Tab?.SetModified(false);
|
||||
Toasts.Show(ToastKind.Success, T["Pages.Profile.Saved"], T["Pages.Profile.SavedText"]);
|
||||
}
|
||||
|
||||
private Task UndoAsync() => ChangeAsync(Session.Preferences);
|
||||
|
||||
private Task DefaultsAsync() => ChangeAsync(UserPreferences.Default);
|
||||
|
||||
/// <inheritdoc />
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
// Closing the tab without saving: the page goes back to the saved look.
|
||||
if (IsModified)
|
||||
{
|
||||
await Theme.PreviewAsync(Session.Preferences);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
<Router AppAssembly="typeof(Program).Assembly" NotFoundPage="typeof(Pages.NotFound)">
|
||||
<Router AppAssembly="typeof(Program).Assembly" NotFoundPage="typeof(Pages.NotFound)">
|
||||
<Found Context="routeData">
|
||||
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)">
|
||||
<NotAuthorized>
|
||||
<RedirectToLogin />
|
||||
</NotAuthorized>
|
||||
</AuthorizeRouteView>
|
||||
@* The layout keeps a page alive for each tab, so it needs the page and its parameters, not only the body. *@
|
||||
<CascadingValue Value="routeData">
|
||||
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)">
|
||||
<NotAuthorized>
|
||||
<RedirectToLogin />
|
||||
</NotAuthorized>
|
||||
</AuthorizeRouteView>
|
||||
</CascadingValue>
|
||||
<FocusOnNavigate RouteData="routeData" Selector="h1" />
|
||||
</Found>
|
||||
</Router>
|
||||
@@ -0,0 +1,46 @@
|
||||
@inject ShellSession Session
|
||||
|
||||
@* The company of the session (SPEC §10.2). Instance accounts choose it from the list: the choice is posted to
|
||||
/session/company, which updates the session and reloads the application in the new company. *@
|
||||
@if (Session.SwitchableCompanies.Count > 0)
|
||||
{
|
||||
<div class="pop">
|
||||
<button type="button" class="company" aria-haspopup="menu" aria-expanded="@Open" @onclick="() => OpenChanged.InvokeAsync(!Open)">
|
||||
<KhIcon Name="building" />
|
||||
<span>@(Session.Company?.Name ?? T["Shell.Company.None"])</span>
|
||||
<KhIcon Name="chevron-down" Class="sm" />
|
||||
</button>
|
||||
@if (Open)
|
||||
{
|
||||
<div class="popmenu left" role="menu">
|
||||
<div class="fh">@T["Shell.Company.Switch"]</div>
|
||||
@foreach (var company in Session.SwitchableCompanies)
|
||||
{
|
||||
<form method="post" action="session/company">
|
||||
<AntiforgeryToken />
|
||||
<input type="hidden" name="code" value="@company.Code" />
|
||||
<button type="submit" role="menuitem" class="mi @(company.Code == Session.Company?.Code ? "on" : null)">
|
||||
<KhIcon Name="building" />
|
||||
<span class="grow">@company.Name</span>
|
||||
<span class="k">@company.Code</span>
|
||||
</button>
|
||||
</form>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
else if (Session.Company is { } company)
|
||||
{
|
||||
<div class="company" title="@company.Code"><KhIcon Name="building" /><span>@company.Name</span></div>
|
||||
}
|
||||
|
||||
@code {
|
||||
/// <summary>Whether the list is open.</summary>
|
||||
[Parameter]
|
||||
public bool Open { get; set; }
|
||||
|
||||
/// <summary>Opens or closes the list.</summary>
|
||||
[Parameter]
|
||||
public EventCallback<bool> OpenChanged { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
@inject ShellSession Session
|
||||
@inject NavigationManager Navigation
|
||||
@inject ThemeService Theme
|
||||
|
||||
@* The global search of SPEC §10.2 (Ctrl+K, mockup 009). Today it finds pages of the menu and commands (prefix >);
|
||||
records (parties, items, documents with #, people with @) join as their modules arrive, through
|
||||
GlobalSearchService. Arrows move, Enter opens, Escape closes. *@
|
||||
@if (Open)
|
||||
{
|
||||
<div class="overlay" @onclick="CloseAsync">
|
||||
<div class="dialog palette" role="dialog" aria-modal="true" aria-label="@T["Shell.Search.Title"]" @onclick:stopPropagation="true">
|
||||
<div class="pin">
|
||||
<KhIcon Name="search" Class="lg" />
|
||||
<input @ref="_input" class="palette-input" type="search" placeholder="@T["Shell.Search.Placeholder"]" aria-label="@T["Shell.Search.Title"]"
|
||||
aria-controls="kh-palette-hits" aria-activedescendant="@(Hits.Count > 0 ? "kh-hit-" + _selected : null)"
|
||||
value="@_query" @oninput="OnInput" @onkeydown="OnKeyDownAsync" autocomplete="off" />
|
||||
<span class="kbdhint"><kbd>@T["Shell.Keys.Escape"]</kbd></span>
|
||||
</div>
|
||||
<div id="kh-palette-hits" role="listbox" class="hits">
|
||||
@if (Hits.Count == 0)
|
||||
{
|
||||
<div class="grp">@T["Shell.Search.NoResults"]</div>
|
||||
}
|
||||
@{
|
||||
string? group = null;
|
||||
var index = 0;
|
||||
}
|
||||
@foreach (var hit in Hits)
|
||||
{
|
||||
if (hit.Group != group)
|
||||
{
|
||||
group = hit.Group;
|
||||
<div class="grp">@T[group]</div>
|
||||
}
|
||||
|
||||
var i = index++;
|
||||
<button type="button" id="@("kh-hit-" + i)" role="option" aria-selected="@(i == _selected)" class="hit @(i == _selected ? "on" : null)"
|
||||
@onclick="() => RunAsync(hit)" @onmouseover="() => _selected = i">
|
||||
<KhIcon Name="@hit.Icon" />
|
||||
<span>@hit.Title</span>
|
||||
@if (hit.Hint is not null)
|
||||
{
|
||||
<span class="k">@hit.Hint</span>
|
||||
}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
<div class="df palette-foot">
|
||||
<span class="kbdhint"><kbd>↑</kbd><kbd>↓</kbd> @T["Shell.Search.Move"]</span>
|
||||
<span class="kbdhint"><kbd>↵</kbd> @T["Shell.Search.Open"]</span>
|
||||
<span class="kbdhint"><kbd>></kbd> @T["Shell.Search.Commands"]</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
private sealed record Hit(string Group, string Icon, string Title, string? Hint, Func<Task> Run);
|
||||
|
||||
private ElementReference _input;
|
||||
private string _query = string.Empty;
|
||||
private int _selected;
|
||||
private bool _focus;
|
||||
|
||||
/// <summary>Whether the search is open.</summary>
|
||||
[Parameter]
|
||||
public bool Open { get; set; }
|
||||
|
||||
/// <summary>Opens or closes it.</summary>
|
||||
[Parameter]
|
||||
public EventCallback<bool> OpenChanged { get; set; }
|
||||
|
||||
/// <summary>Collapses or expands the menu (command).</summary>
|
||||
[Parameter]
|
||||
public EventCallback OnToggleMenu { get; set; }
|
||||
|
||||
private List<Hit> Hits { get; set; } = [];
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (Open && !_focus && Hits.Count == 0)
|
||||
{
|
||||
_query = string.Empty;
|
||||
_selected = 0;
|
||||
_focus = true;
|
||||
Hits = Search(_query);
|
||||
}
|
||||
else if (!Open)
|
||||
{
|
||||
Hits = [];
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (_focus && Open)
|
||||
{
|
||||
_focus = false;
|
||||
await _input.FocusAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnInput(ChangeEventArgs e)
|
||||
{
|
||||
_query = e.Value?.ToString() ?? string.Empty;
|
||||
_selected = 0;
|
||||
Hits = Search(_query);
|
||||
}
|
||||
|
||||
private async Task OnKeyDownAsync(KeyboardEventArgs e)
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
case "ArrowDown":
|
||||
_selected = Hits.Count == 0 ? 0 : (_selected + 1) % Hits.Count;
|
||||
break;
|
||||
case "ArrowUp":
|
||||
_selected = Hits.Count == 0 ? 0 : (_selected - 1 + Hits.Count) % Hits.Count;
|
||||
break;
|
||||
case "Enter" when Hits.Count > 0:
|
||||
await RunAsync(Hits[Math.Min(_selected, Hits.Count - 1)]);
|
||||
break;
|
||||
case "Escape":
|
||||
await CloseAsync();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RunAsync(Hit hit)
|
||||
{
|
||||
await CloseAsync();
|
||||
await hit.Run();
|
||||
}
|
||||
|
||||
private Task CloseAsync()
|
||||
{
|
||||
Hits = [];
|
||||
return OpenChanged.InvokeAsync(false);
|
||||
}
|
||||
|
||||
private List<Hit> Search(string query)
|
||||
{
|
||||
var text = query.Trim();
|
||||
var commandsOnly = text.StartsWith('>');
|
||||
if (commandsOnly)
|
||||
{
|
||||
text = text[1..].Trim();
|
||||
}
|
||||
|
||||
var hits = new List<Hit>();
|
||||
if (!commandsOnly)
|
||||
{
|
||||
foreach (var item in MenuCatalog.All.Where(Session.CanSee))
|
||||
{
|
||||
var title = T[item.Key];
|
||||
var area = MenuCatalog.FindArea(item.Href);
|
||||
var label = area is not null && area != item ? T[area.Key] + " · " + title : title;
|
||||
if (Matches(label, text))
|
||||
{
|
||||
hits.Add(new Hit("Shell.Search.Pages", item.Icon, label, null, () => Go(item.Href)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var command in Commands())
|
||||
{
|
||||
if (Matches(command.Title, text))
|
||||
{
|
||||
hits.Add(command);
|
||||
}
|
||||
}
|
||||
|
||||
return [.. hits.Take(30)];
|
||||
}
|
||||
|
||||
private IEnumerable<Hit> Commands()
|
||||
{
|
||||
yield return new Hit("Shell.Search.CommandsGroup", "moon", T["Shell.Commands.ToggleTheme"], null, () => Theme.ToggleDarkAsync());
|
||||
yield return new Hit("Shell.Search.CommandsGroup", "sidebar", T["Shell.Commands.ToggleMenu"], KeyboardShortcuts.KeysOf(KeyboardShortcuts.Commands.ToggleMenu),
|
||||
() => OnToggleMenu.InvokeAsync());
|
||||
yield return new Hit("Shell.Search.CommandsGroup", "palette", T["Shell.Commands.Appearance"], null, () => Go("/profilo?scheda=aspetto"));
|
||||
yield return new Hit("Shell.Search.CommandsGroup", "user", T["Shell.Commands.Profile"], null, () => Go("/profilo"));
|
||||
yield return new Hit("Shell.Search.CommandsGroup", "monitor", T["Shell.User.Sessions"], null, () => Go("/profilo?scheda=sessioni"));
|
||||
yield return new Hit("Shell.Search.CommandsGroup", "keyboard", T["Shell.Commands.Shortcuts"], null, () => Go("/profilo?scheda=scorciatoie"));
|
||||
}
|
||||
|
||||
private Task Go(string href)
|
||||
{
|
||||
Navigation.NavigateTo(href.TrimStart('/'));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private static bool Matches(string title, string text) =>
|
||||
text.Length == 0 || text.Split(' ', StringSplitOptions.RemoveEmptyEntries).All(word => title.Contains(word, StringComparison.CurrentCultureIgnoreCase));
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
@using Khaemhat.Core.Common
|
||||
@implements IDisposable
|
||||
@inject ShellSession Session
|
||||
@inject NavigationManager Navigation
|
||||
@inject ProductVersion Version
|
||||
|
||||
@* The side menu of SPEC §10.2 (mockups 004, 007, 013). Expanded: icon and text, sub-entries of the active module.
|
||||
Collapsed to 60 px: icons only, the name as tooltip, sub-entries in a pop-up on hover or keyboard focus. *@
|
||||
<nav class="sidebar" aria-label="@T["Shell.Menu.Label"]">
|
||||
<div class="navscroll">
|
||||
@foreach (var section in Sections)
|
||||
{
|
||||
<div class="sec">@T[section.Key]</div>
|
||||
<div class="nav">
|
||||
@foreach (var item in section.Items)
|
||||
{
|
||||
var active = item == _activeArea;
|
||||
var children = item.Children.Where(Session.CanSee).ToList();
|
||||
<div class="item">
|
||||
<a href="@Href(item)" class="@(active ? "active" : null)" aria-current="@(active && _path == item.Href ? "page" : null)"
|
||||
title="@(Collapsed ? T[item.Key] : null)">
|
||||
<KhIcon Name="@item.Icon" />
|
||||
<span>@T[item.Key]</span>
|
||||
</a>
|
||||
@if (Collapsed && children.Count > 0)
|
||||
{
|
||||
<div class="flyout" role="group" aria-label="@T[item.Key]">
|
||||
<div class="fh">@T[item.Key]</div>
|
||||
@foreach (var child in children)
|
||||
{
|
||||
<a class="fi @(child == _activeItem ? "on" : null)" href="@Href(child)">@T[child.Key]</a>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@if (active && !Collapsed && children.Count > 0)
|
||||
{
|
||||
<div class="nav sub">
|
||||
@foreach (var child in children)
|
||||
{
|
||||
<a href="@Href(child)" class="@(child == _activeItem ? "active" : null)" aria-current="@(child == _activeItem ? "page" : null)">
|
||||
<span>@T[child.Key]</span>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<button type="button" class="toggle" aria-expanded="@(!Collapsed)" aria-keyshortcuts="Control+B" @onclick="OnToggle"
|
||||
title="@(Collapsed ? ExpandLabel : null)">
|
||||
<KhIcon Name="@(Collapsed ? "chevron-right" : "chevron-left")" />
|
||||
<span>@(Collapsed ? ExpandLabel : T["Shell.Menu.Collapse"])</span>
|
||||
</button>
|
||||
<div class="foot">
|
||||
@T.Format("Shell.Menu.Footer", Version.Version)<br />
|
||||
@T.Format("Shell.Menu.FiscalYear", DateTime.Today.Year)
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@code {
|
||||
private string _path = "/";
|
||||
private MenuItem? _activeArea;
|
||||
private MenuItem? _activeItem;
|
||||
|
||||
/// <summary>Whether the menu is collapsed to icons.</summary>
|
||||
[Parameter]
|
||||
public bool Collapsed { get; set; }
|
||||
|
||||
/// <summary>Collapses or expands the menu.</summary>
|
||||
[Parameter]
|
||||
public EventCallback OnToggle { get; set; }
|
||||
|
||||
private string ExpandLabel => T["Shell.Menu.Expand"];
|
||||
|
||||
private IEnumerable<MenuSection> Sections =>
|
||||
MenuCatalog.Sections
|
||||
.Select(s => new MenuSection(s.Key, [.. s.Items.Where(Session.CanSee)]))
|
||||
.Where(s => s.Items.Count > 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
Navigation.LocationChanged += OnLocationChanged;
|
||||
Session.Changed += OnSessionChanged;
|
||||
Locate(Navigation.Uri);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
Navigation.LocationChanged -= OnLocationChanged;
|
||||
Session.Changed -= OnSessionChanged;
|
||||
}
|
||||
|
||||
private void OnLocationChanged(object? sender, LocationChangedEventArgs e)
|
||||
{
|
||||
Locate(e.Location);
|
||||
_ = InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private void OnSessionChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
private void Locate(string uri)
|
||||
{
|
||||
_path = TabService.PathOf(Navigation.ToBaseRelativePath(uri));
|
||||
_activeArea = MenuCatalog.FindArea(_path);
|
||||
_activeItem = MenuCatalog.Find(_path);
|
||||
}
|
||||
|
||||
private static string Href(MenuItem item) => item.Href == "/" ? "./" : item.Href.TrimStart('/');
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
@using System.Diagnostics
|
||||
@using Khaemhat.Core.Caching
|
||||
@using Khaemhat.Core.Common
|
||||
@implements IDisposable
|
||||
@inject ShellSession Session
|
||||
@inject ProductVersion Version
|
||||
@inject ICacheProvider Cache
|
||||
@inject IJSRuntime Js
|
||||
|
||||
@* The status bar of SPEC §10.2: company, fiscal year, user and level, connection and latency, cache, full version.
|
||||
The warehouse joins in M6 with the warehouses table. Latency is the round trip of the circuit, every 30 s. *@
|
||||
<footer class="statusbar" aria-label="@T["Shell.Status.Label"]">
|
||||
<span class="item">@(Session.Company?.Name ?? T["Shell.Company.None"])</span>
|
||||
<span class="item">@T.Format("Shell.Menu.FiscalYear", DateTime.Today.Year)</span>
|
||||
<span class="item">@Session.DisplayName · @T[Session.LevelKey]</span>
|
||||
<span class="sp"></span>
|
||||
<span class="item" title="@T["Shell.Status.ConnectionHint"]">
|
||||
<span class="live @(_latency is null ? "warn" : null)"></span>
|
||||
@(_latency is { } ms ? T.Format("Shell.Status.Connected", ms) : T["Shell.Status.Connecting"])
|
||||
</span>
|
||||
<span class="item">@(Cache.IsDistributed ? T["Shell.Status.Redis"] : T["Shell.Status.LocalCache"])</span>
|
||||
<span class="item" title="@Version.Full">@T.Format("Shell.Status.Version", Version.Version, ShortRevision)</span>
|
||||
</footer>
|
||||
|
||||
@code {
|
||||
private long? _latency;
|
||||
private Timer? _timer;
|
||||
|
||||
private string ShortRevision => Version.Revision.Length > 7 ? Version.Revision[..7] : Version.Revision;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnInitialized() => Session.Changed += OnChanged;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnAfterRender(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
_timer = new Timer(_ => _ = InvokeAsync(MeasureAsync), null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
Session.Changed -= OnChanged;
|
||||
_timer?.Dispose();
|
||||
}
|
||||
|
||||
private void OnChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
private async Task MeasureAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var watch = Stopwatch.StartNew();
|
||||
await Js.InvokeAsync<bool>("khaemhat.ping");
|
||||
_latency = watch.ElapsedMilliseconds;
|
||||
}
|
||||
catch (JSDisconnectedException)
|
||||
{
|
||||
_latency = null;
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
_latency = null;
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
@using Khaemhat.Application.Notifications
|
||||
@using Khaemhat.Application.Preferences
|
||||
@using Khaemhat.Core.Common
|
||||
@implements IDisposable
|
||||
@inject ShellSession Session
|
||||
@inject ThemeService Theme
|
||||
@inject TabService Tabs
|
||||
@inject NavigationManager Navigation
|
||||
@inject ProductVersion Version
|
||||
@inject NotificationDispatcher Notifications
|
||||
|
||||
@* The dark top bar of SPEC §10.2 (mockups 004, 007): brand, company, search, new, recent, notifications, quick theme,
|
||||
help, user menu. Only one pop-up is open at a time; clicking outside closes it. *@
|
||||
<header class="topbar">
|
||||
<div class="brand">
|
||||
<a href="/" title="@T["Shell.TopBar.Home"]">
|
||||
<span class="mark"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="icons/sprite.svg#brand"></use></svg></span>
|
||||
<span class="txt">@T["Common.ProductName"]</span>
|
||||
</a>
|
||||
<span class="ver">@Version.MajorMinor</span>
|
||||
</div>
|
||||
|
||||
<CompanySwitcher Open="@(_open == Popup.Company)" OpenChanged="open => Toggle(Popup.Company, open)" />
|
||||
|
||||
<button type="button" class="gsearch" @onclick="OnSearch" aria-keyshortcuts="Control+K">
|
||||
<KhIcon Name="search" />
|
||||
<span class="ph">@T["Shell.TopBar.SearchPlaceholder"]</span>
|
||||
<kbd>@T["Shell.TopBar.SearchKeys"]</kbd>
|
||||
</button>
|
||||
|
||||
<div class="right">
|
||||
<div class="pop">
|
||||
<button type="button" class="tbtn" aria-haspopup="menu" aria-expanded="@(_open == Popup.Recent)" aria-label="@T["Shell.TopBar.Recent"]"
|
||||
@onclick="() => Toggle(Popup.Recent)">
|
||||
<KhIcon Name="history" /><span class="tip">@T["Shell.TopBar.Recent"]</span>
|
||||
</button>
|
||||
@if (_open == Popup.Recent)
|
||||
{
|
||||
<div class="popmenu" role="menu">
|
||||
<div class="fh">@T["Shell.TopBar.Recent"]</div>
|
||||
@if (Tabs.Recent.Count == 0)
|
||||
{
|
||||
<div class="mi muted">@T["Shell.TopBar.NoRecent"]</div>
|
||||
}
|
||||
@foreach (var url in Tabs.Recent)
|
||||
{
|
||||
var item = MenuCatalog.Find(TabService.PathOf(url));
|
||||
<a class="mi" role="menuitem" href="@Relative(url)" @onclick="Close">
|
||||
<KhIcon Name="@(item?.Icon ?? "file")" />
|
||||
<span class="grow">@(item is null ? url : T[item.Key])</span>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="pop">
|
||||
<button type="button" class="tbtn" aria-haspopup="menu" aria-expanded="@(_open == Popup.Notifications)"
|
||||
aria-label="@T.Format("Shell.TopBar.NotificationsCount", _unread.Count)" @onclick="ToggleNotificationsAsync">
|
||||
<KhIcon Name="bell" />
|
||||
@if (_unread.Count > 0)
|
||||
{
|
||||
<span class="dot"></span>
|
||||
}
|
||||
<span class="tip">@T["Shell.TopBar.Notifications"]</span>
|
||||
</button>
|
||||
@if (_open == Popup.Notifications)
|
||||
{
|
||||
<div class="popmenu notif" role="menu">
|
||||
<div class="fh">@T["Shell.TopBar.Notifications"]</div>
|
||||
@if (_unread.Count == 0)
|
||||
{
|
||||
<div class="mi muted">@T["Shell.TopBar.NoNotifications"]</div>
|
||||
}
|
||||
@foreach (var n in _unread)
|
||||
{
|
||||
<a class="mi" role="menuitem" href="@(n.Link is { } link && UserPreferences.IsLocalPath(link) ? link.TrimStart('/') : "#")" @onclick="Close">
|
||||
<KhIcon Name="@SeverityIcon(n.Severity)" />
|
||||
<span class="grow"><b>@n.Title</b>@if (n.Body is not null) {<br /><span class="muted small">@n.Body</span>}</span>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<button type="button" class="tbtn" aria-label="@ThemeLabel" @onclick="Theme.ToggleDarkAsync">
|
||||
<KhIcon Name="@(Session.Preferences.Theme == ThemeMode.Dark ? "sun" : "moon")" /><span class="tip">@ThemeLabel</span>
|
||||
</button>
|
||||
|
||||
<button type="button" class="tbtn" aria-label="@T["Shell.TopBar.Help"]" aria-keyshortcuts="F1" @onclick="OnHelp">
|
||||
<KhIcon Name="help" /><span class="tip">@T["Shell.TopBar.Help"] <kbd>@KeyboardShortcuts.KeysOf(KeyboardShortcuts.Commands.Help)</kbd></span>
|
||||
</button>
|
||||
|
||||
<UserMenu Open="@(_open == Popup.User)" OpenChanged="open => Toggle(Popup.User, open)" />
|
||||
</div>
|
||||
</header>
|
||||
@if (_open is not null)
|
||||
{
|
||||
<div class="scrim" @onclick="Close"></div>
|
||||
}
|
||||
|
||||
@code {
|
||||
private enum Popup
|
||||
{
|
||||
Company,
|
||||
Recent,
|
||||
Notifications,
|
||||
User,
|
||||
}
|
||||
|
||||
private Popup? _open;
|
||||
private IReadOnlyList<(string Title, string? Body, string? Link, Khaemhat.Core.Instance.NotificationSeverity Severity)> _unread = [];
|
||||
|
||||
/// <summary>Opens the global search.</summary>
|
||||
[Parameter]
|
||||
public EventCallback OnSearch { get; set; }
|
||||
|
||||
/// <summary>Opens the help of the page.</summary>
|
||||
[Parameter]
|
||||
public EventCallback OnHelp { get; set; }
|
||||
|
||||
private string ThemeLabel => Session.Preferences.Theme == ThemeMode.Dark ? T["Shell.TopBar.ThemeLight"] : T["Shell.TopBar.ThemeDark"];
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Session.Changed += OnChanged;
|
||||
Tabs.Changed += OnChanged;
|
||||
await LoadNotificationsAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
Session.Changed -= OnChanged;
|
||||
Tabs.Changed -= OnChanged;
|
||||
}
|
||||
|
||||
private void OnChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
private void Toggle(Popup popup, bool? open = null) => _open = (open ?? _open != popup) ? popup : null;
|
||||
|
||||
private void Close() => _open = null;
|
||||
|
||||
private async Task ToggleNotificationsAsync()
|
||||
{
|
||||
Toggle(Popup.Notifications);
|
||||
if (_open == Popup.Notifications)
|
||||
{
|
||||
await LoadNotificationsAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadNotificationsAsync()
|
||||
{
|
||||
if (Session.Actor is not { } actor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (actor.SystemUserId is { } systemUser)
|
||||
{
|
||||
_unread = [.. (await Notifications.UnreadForInstanceAsync(systemUser)).Select(n => (n.Title, n.Body, n.Link, n.Severity))];
|
||||
}
|
||||
else if (actor is { CompanyCode: { } company, CompanyUserId: { } user })
|
||||
{
|
||||
_unread = [.. (await Notifications.UnreadForUserAsync(company, user)).Select(n => (n.Title, n.Body, n.Link, n.Severity))];
|
||||
}
|
||||
}
|
||||
|
||||
private static string Relative(string url) => url.TrimStart('/');
|
||||
|
||||
private static string SeverityIcon(Khaemhat.Core.Instance.NotificationSeverity severity) => severity switch
|
||||
{
|
||||
Khaemhat.Core.Instance.NotificationSeverity.Error => "x-circle",
|
||||
Khaemhat.Core.Instance.NotificationSeverity.Warning => "alert",
|
||||
Khaemhat.Core.Instance.NotificationSeverity.Success => "check-circle",
|
||||
_ => "info",
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
@inject ShellSession Session
|
||||
|
||||
@* The user box of the top bar (mockup 004): initials, name, level; the menu opens the profile and signs out. *@
|
||||
<div class="pop">
|
||||
<button type="button" class="userbox" aria-haspopup="menu" aria-expanded="@Open" @onclick="() => OpenChanged.InvokeAsync(!Open)">
|
||||
<span class="avatar" aria-hidden="true">@Session.Initials</span>
|
||||
<span class="who">
|
||||
<span class="nm">@Session.DisplayName</span><br />
|
||||
<span class="rl">@T[Session.LevelKey]</span>
|
||||
</span>
|
||||
<KhIcon Name="chevron-down" Class="sm" />
|
||||
</button>
|
||||
@if (Open)
|
||||
{
|
||||
<div class="popmenu" role="menu">
|
||||
<div class="fh">@Session.DisplayName</div>
|
||||
<a class="mi" role="menuitem" href="profilo" @onclick="() => OpenChanged.InvokeAsync(false)"><KhIcon Name="user" /><span class="grow">@T["Shell.User.Profile"]</span></a>
|
||||
<a class="mi" role="menuitem" href="profilo?scheda=aspetto" @onclick="() => OpenChanged.InvokeAsync(false)"><KhIcon Name="palette" /><span class="grow">@T["Shell.User.Appearance"]</span></a>
|
||||
<a class="mi" role="menuitem" href="profilo?scheda=sessioni" @onclick="() => OpenChanged.InvokeAsync(false)"><KhIcon Name="monitor" /><span class="grow">@T["Shell.User.Sessions"]</span></a>
|
||||
<hr />
|
||||
<form method="post" action="logout">
|
||||
<AntiforgeryToken />
|
||||
<button type="submit" role="menuitem" class="mi"><KhIcon Name="logout" /><span class="grow">@T["Shell.User.SignOut"]</span></button>
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
/// <summary>Whether the menu is open.</summary>
|
||||
[Parameter]
|
||||
public bool Open { get; set; }
|
||||
|
||||
/// <summary>Opens or closes the menu.</summary>
|
||||
[Parameter]
|
||||
public EventCallback<bool> OpenChanged { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
@implements IDisposable
|
||||
@inject DialogService Dialogs
|
||||
|
||||
@* The confirmation dialog of SPEC §10.7 (KhConfirm): modal, Escape cancels, the cancelling button has the focus. *@
|
||||
@if (Dialogs.Current is { } request)
|
||||
{
|
||||
<div class="overlay" @onkeydown="OnKeyDown">
|
||||
<div class="dialog confirm" role="alertdialog" aria-modal="true" aria-labelledby="kh-confirm-title" aria-describedby="kh-confirm-text">
|
||||
<div class="dh"><KhIcon Name="@(request.Danger ? "alert" : "help")" /><span id="kh-confirm-title" class="grow">@request.Title</span></div>
|
||||
<div class="db" id="kh-confirm-text">@request.Text</div>
|
||||
<div class="df">
|
||||
<button type="button" class="btn" @ref="_cancel" @onclick="() => Dialogs.Answer(false)">@request.CancelText</button>
|
||||
<button type="button" class="btn @(request.Danger ? "danger" : "primary")" @onclick="() => Dialogs.Answer(true)">@request.ConfirmText</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
private ElementReference _cancel;
|
||||
private bool _focus;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnInitialized() => Dialogs.Changed += OnChanged;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose() => Dialogs.Changed -= OnChanged;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (_focus && Dialogs.Current is not null)
|
||||
{
|
||||
_focus = false;
|
||||
await _cancel.FocusAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnChanged()
|
||||
{
|
||||
_focus = Dialogs.Current is not null;
|
||||
_ = InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private void OnKeyDown(KeyboardEventArgs e)
|
||||
{
|
||||
if (e.Key == "Escape")
|
||||
{
|
||||
Dialogs.Answer(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
@* An icon of icons/sprite.svg (SPEC §10.8). Decorative: the text next to it, or the tooltip, carries the meaning. *@
|
||||
<svg class="i @Class" aria-hidden="true" focusable="false"><use href="@("icons/sprite.svg#" + Name)"></use></svg>
|
||||
|
||||
@code {
|
||||
/// <summary>The symbol id in the sprite.</summary>
|
||||
[Parameter, EditorRequired]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>Extra classes: <c>lg</c>, <c>sm</c>.</summary>
|
||||
[Parameter]
|
||||
public string? Class { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
@* Sets the title of the tab that holds the page (SPEC §10.2); the layout writes the browser title from the active
|
||||
tab. Outside a tab (sign-in pages) it writes the browser title itself. *@
|
||||
@if (Tab is null)
|
||||
{
|
||||
<PageTitle>@Text · @T["Common.ProductName"]</PageTitle>
|
||||
}
|
||||
|
||||
@code {
|
||||
/// <summary>The tab of the page, given by the tab host.</summary>
|
||||
[CascadingParameter]
|
||||
public KhTab? Tab { get; set; }
|
||||
|
||||
/// <summary>The title.</summary>
|
||||
[Parameter, EditorRequired]
|
||||
public string Text { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>The icon of the tab, or <see langword="null"/> for the menu icon.</summary>
|
||||
[Parameter]
|
||||
public string? Icon { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnParametersSet() => Tab?.SetTitle(Text, Icon);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
@* An on/off option with its label and a short explanation (mockup 008). The whole row is the switch. *@
|
||||
<button type="button" class="kh-switch-row" role="switch" aria-checked="@Value" @onclick="() => ValueChanged.InvokeAsync(!Value)">
|
||||
<span class="grow">
|
||||
<span class="t">@Label</span>
|
||||
@if (!string.IsNullOrEmpty(Hint))
|
||||
{
|
||||
<span class="s">@Hint</span>
|
||||
}
|
||||
</span>
|
||||
<span class="switch @(Value ? "on" : null)" aria-hidden="true"></span>
|
||||
</button>
|
||||
|
||||
@code {
|
||||
/// <summary>The label.</summary>
|
||||
[Parameter, EditorRequired]
|
||||
public string Label { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>The explanation under the label.</summary>
|
||||
[Parameter]
|
||||
public string? Hint { get; set; }
|
||||
|
||||
/// <summary>Whether the option is on.</summary>
|
||||
[Parameter]
|
||||
public bool Value { get; set; }
|
||||
|
||||
/// <summary>Raised with the new value.</summary>
|
||||
[Parameter]
|
||||
public EventCallback<bool> ValueChanged { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
@implements IDisposable
|
||||
@inject ToastService Toasts
|
||||
|
||||
@* The toasts of SPEC §10.7, bottom right, announced to screen readers. Each one goes away after six seconds. *@
|
||||
<div class="toasts" role="status" aria-live="polite">
|
||||
@foreach (var toast in Toasts.Toasts)
|
||||
{
|
||||
<div class="toast @KindClass(toast.Kind)" @key="toast.Id">
|
||||
<KhIcon Name="@KindIcon(toast.Kind)" />
|
||||
<div class="grow">
|
||||
<div class="tt">@toast.Title</div>
|
||||
@if (toast.Text is not null)
|
||||
{
|
||||
<div class="muted">@toast.Text</div>
|
||||
}
|
||||
</div>
|
||||
<button type="button" title="@T["Common.Close"]" aria-label="@T["Common.Close"]" @onclick="() => Toasts.Dismiss(toast.Id)"><KhIcon Name="x" Class="sm" /></button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private readonly HashSet<Guid> _timed = [];
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnInitialized() => Toasts.Changed += OnChanged;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose() => Toasts.Changed -= OnChanged;
|
||||
|
||||
private void OnChanged()
|
||||
{
|
||||
foreach (var toast in Toasts.Toasts.Where(t => _timed.Add(t.Id)))
|
||||
{
|
||||
_ = DismissLaterAsync(toast.Id);
|
||||
}
|
||||
|
||||
_ = InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task DismissLaterAsync(Guid id)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(6));
|
||||
_timed.Remove(id);
|
||||
await InvokeAsync(() => Toasts.Dismiss(id));
|
||||
}
|
||||
|
||||
private static string KindClass(ToastKind kind) => kind switch
|
||||
{
|
||||
ToastKind.Success => "ok",
|
||||
ToastKind.Warning => "warn",
|
||||
ToastKind.Error => "err",
|
||||
_ => string.Empty,
|
||||
};
|
||||
|
||||
private static string KindIcon(ToastKind kind) => kind switch
|
||||
{
|
||||
ToastKind.Success => "check-circle",
|
||||
ToastKind.Warning => "alert",
|
||||
ToastKind.Error => "x-circle",
|
||||
_ => "info",
|
||||
};
|
||||
}
|
||||
@@ -13,3 +13,9 @@
|
||||
@using Khaemhat.Web.Components.Layout
|
||||
@using Khaemhat.Core.Security
|
||||
@using Khaemhat.Web.Security
|
||||
@using Khaemhat.Application.Localization
|
||||
@using Khaemhat.Application.Preferences
|
||||
@using Khaemhat.Web.Shell
|
||||
@using Khaemhat.Web.Components.Shell
|
||||
@using Khaemhat.Web.Components.Ui
|
||||
@inject ITexts T
|
||||
@@ -1,4 +1,5 @@
|
||||
using Khaemhat.Application.Configuration;
|
||||
using Khaemhat.Application.Instance;
|
||||
using Khaemhat.Application.Security;
|
||||
using Khaemhat.Core.Common;
|
||||
using Khaemhat.Infrastructure.Logging;
|
||||
@@ -89,6 +90,12 @@ public static class KhaemhatApp
|
||||
}
|
||||
|
||||
app.UseSecurityHeaders();
|
||||
|
||||
// Numbers, dates and texts in Italian (SPEC §10.8); a circuit keeps the culture of the request that opened it.
|
||||
app.UseRequestLocalization(new RequestLocalizationOptions()
|
||||
.SetDefaultCulture(KhaemhatServices.ItalianCulture.Name)
|
||||
.AddSupportedCultures(KhaemhatServices.ItalianCulture.Name)
|
||||
.AddSupportedUICultures(KhaemhatServices.ItalianCulture.Name));
|
||||
app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
|
||||
app.MapHealthEndpoints();
|
||||
app.UseStartingPage();
|
||||
@@ -101,6 +108,7 @@ public static class KhaemhatApp
|
||||
|
||||
app.MapStaticAssets();
|
||||
app.MapSignOut();
|
||||
app.MapCompanySwitch();
|
||||
app.MapRazorComponents<App>()
|
||||
.AddInteractiveServerRenderMode();
|
||||
|
||||
@@ -122,6 +130,35 @@ public static class KhaemhatApp
|
||||
}
|
||||
}
|
||||
|
||||
// POST /session/company: an instance account chooses the company of its session (top bar, SPEC §10.2). The page
|
||||
// is reloaded, so the new circuit starts in the new company.
|
||||
private static void MapCompanySwitch(this IEndpointRouteBuilder endpoints) =>
|
||||
endpoints.MapPost("/session/company", async (HttpContext context, SessionStore sessions, CompanyContextResolver companies, IAntiforgery antiforgery) =>
|
||||
{
|
||||
if (!await antiforgery.IsRequestValidAsync(context).ConfigureAwait(false))
|
||||
{
|
||||
return Results.BadRequest();
|
||||
}
|
||||
|
||||
var actor = SessionCookie.ActorOf(context.User);
|
||||
var cookie = SessionCookie.Read(context);
|
||||
var form = await context.Request.ReadFormAsync(context.RequestAborted).ConfigureAwait(false);
|
||||
var code = form["code"].ToString();
|
||||
if (actor is not { IsInstanceAccount: true } || cookie is null || string.IsNullOrWhiteSpace(code))
|
||||
{
|
||||
return Results.Forbid();
|
||||
}
|
||||
|
||||
var result = await companies.ResolveAsync(actor, code, context.RequestAborted).ConfigureAwait(false);
|
||||
if (result.Access != CompanyAccess.Granted || result.Company is null)
|
||||
{
|
||||
return Results.Redirect("/");
|
||||
}
|
||||
|
||||
await sessions.SetCompanyAsync(cookie, result.Company.Code, context.RequestAborted).ConfigureAwait(false);
|
||||
return Results.Redirect("/");
|
||||
});
|
||||
|
||||
// POST /logout: closes the session and removes the cookie; a form with the antiforgery token posts here.
|
||||
private static void MapSignOut(this IEndpointRouteBuilder endpoints) =>
|
||||
endpoints.MapPost("/logout", async (HttpContext context, SignInService signIn, IAntiforgery antiforgery) =>
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
using System.Globalization;
|
||||
using Khaemhat.Application.Audit;
|
||||
using Khaemhat.Application.Configuration;
|
||||
using Khaemhat.Application.Instance;
|
||||
using Khaemhat.Application.Jobs;
|
||||
using Khaemhat.Application.Licensing;
|
||||
using Khaemhat.Application.Localization;
|
||||
using Khaemhat.Application.Modules;
|
||||
using Khaemhat.Application.Notifications;
|
||||
using Khaemhat.Application.Preferences;
|
||||
using Khaemhat.Application.Security;
|
||||
using Khaemhat.Core.Caching;
|
||||
using Khaemhat.Core.Logging;
|
||||
@@ -21,6 +24,7 @@ using Khaemhat.Infrastructure.Licensing;
|
||||
using Khaemhat.Infrastructure.Logging;
|
||||
using Khaemhat.Infrastructure.Security;
|
||||
using Khaemhat.Web.Security;
|
||||
using Khaemhat.Web.Shell;
|
||||
|
||||
namespace Khaemhat.Web.Hosting;
|
||||
|
||||
@@ -30,6 +34,9 @@ namespace Khaemhat.Web.Hosting;
|
||||
/// </summary>
|
||||
internal static class KhaemhatServices
|
||||
{
|
||||
/// <summary>The culture of the interface and of number and date formats (SPEC §10.8).</summary>
|
||||
internal static readonly CultureInfo ItalianCulture = CultureInfo.GetCultureInfo("it-IT");
|
||||
|
||||
/// <summary>Registers every service of the instance.</summary>
|
||||
/// <param name="services">The container.</param>
|
||||
/// <param name="options">The validated variables.</param>
|
||||
@@ -127,6 +134,16 @@ internal static class KhaemhatServices
|
||||
services.AddSingleton<IScheduledJob, LogRetentionJob>();
|
||||
services.AddSingleton<JobScheduler>();
|
||||
services.AddHostedService<JobSchedulerService>();
|
||||
|
||||
// Interface (SPEC §10): texts, preferences and the per-circuit state of the shell.
|
||||
services.AddSingleton<ITexts>(JsonTextProvider.FromAssembly(typeof(KhaemhatServices).Assembly, ItalianCulture));
|
||||
services.AddSingleton<UserSettingsService>();
|
||||
services.AddScoped<ShellSession>();
|
||||
services.AddScoped<ThemeService>();
|
||||
services.AddScoped<TabService>();
|
||||
services.AddScoped<KeyboardShortcutService>();
|
||||
services.AddScoped<ToastService>();
|
||||
services.AddScoped<DialogService>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,8 +178,8 @@ internal static class KhaemhatMiddleware
|
||||
|
||||
return context.Response.WriteAsync(
|
||||
"<!DOCTYPE html><html lang=\"it\"><head><meta charset=\"utf-8\">" + refresh +
|
||||
"<title>Khaemhat</title><link rel=\"stylesheet\" href=\"/app.css\"></head><body><main class=\"kh-construction\"><section class=\"hero\">" +
|
||||
"<img class=\"mark\" src=\"/icon.svg\" alt=\"\" width=\"96\" height=\"96\"><h1>Khaemhat</h1><p class=\"state\">" + WebUtility.HtmlEncode(message) +
|
||||
"<title>Khaemhat</title><link rel=\"stylesheet\" href=\"/app.css\"></head><body><main class=\"kh-unavailable\"><section>" +
|
||||
"<img class=\"mark\" src=\"/icon.svg\" alt=\"\" width=\"96\" height=\"96\"><h1>Khaemhat</h1><p>" + WebUtility.HtmlEncode(message) +
|
||||
"</p></section></main></body></html>",
|
||||
context.RequestAborted);
|
||||
}
|
||||
|
||||
@@ -17,4 +17,10 @@
|
||||
<InternalsVisibleTo Include="Khaemhat.Web.Tests" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Interface texts (SPEC §10.8): Resources/<culture>/*.json, read by JsonTextProvider as texts/<culture>/<file>. -->
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources/**/*.json" LogicalName="texts/%(RecursiveDir)%(Filename)%(Extension)" />
|
||||
<Content Remove="Resources/**/*.json" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"Auth": {
|
||||
"Brand": {
|
||||
"Tagline": "Gestionale ERP + CRM per PMI italiane: documenti, magazzino, contabilità e fatturazione elettronica in un'unica applicazione web.",
|
||||
"Feature1Title": "Contabilità italiana completa",
|
||||
"Feature1Text": "prima nota, IVA, registri, bilancio CEE",
|
||||
"Feature2Title": "Fatturazione elettronica",
|
||||
"Feature2Text": "SDI, conservazione, bollo, autofatture",
|
||||
"Feature3Title": "CRM",
|
||||
"Feature3Text": "lead, opportunità, attività, campagne",
|
||||
"Feature4Title": "Più aziende",
|
||||
"Feature4Text": "un database per azienda, backup integrati",
|
||||
"Footer": "Khaemhat {0}"
|
||||
},
|
||||
"Login": {
|
||||
"Title": "Accedi",
|
||||
"Subtitle": "Scegli l'azienda e inserisci le credenziali.",
|
||||
"Company": "Azienda",
|
||||
"NoCompany": "Nessuna (account di istanza)",
|
||||
"CompanyOption": "{0} ({1})",
|
||||
"UserName": "Nome utente",
|
||||
"Password": "Password",
|
||||
"Remember": "Ricordami su questo dispositivo",
|
||||
"Submit": "Accedi",
|
||||
"Trial": "Licenza in modalità prova: restano {0} giorni, con i moduli Base e Contabilità e {1} utenti collegati.",
|
||||
"Expired": "La licenza è scaduta: rivolgiti all'amministratore."
|
||||
},
|
||||
"PasswordChange": {
|
||||
"PageTitle": "Cambio password",
|
||||
"Title": "Scegli una nuova password",
|
||||
"Subtitle": "Al primo accesso, o dopo una password provvisoria, serve una password personale.",
|
||||
"Current": "Password attuale o provvisoria",
|
||||
"New": "Nuova password",
|
||||
"Confirm": "Ripeti la nuova password",
|
||||
"RuleLength": "Almeno {0} caratteri",
|
||||
"RuleKinds": "Almeno tre tipi tra minuscole, maiuscole, cifre e simboli",
|
||||
"RuleHistory": "Diversa dal nome utente e dalle ultime {0} password",
|
||||
"Mismatch": "Le due nuove password non coincidono.",
|
||||
"Submit": "Salva e continua"
|
||||
},
|
||||
"Totp": {
|
||||
"Title": "Verifica in due passaggi",
|
||||
"Subtitle": "Inserisci il codice a 6 cifre dell'app di autenticazione.",
|
||||
"Code": "Codice",
|
||||
"Submit": "Verifica",
|
||||
"RecoveryHint": "Oppure un codice di recupero (XXXX-XXXX)",
|
||||
"Info": "Il codice cambia ogni 30 secondi. L'autenticazione a due fattori è obbligatoria per amministratori e super utente."
|
||||
},
|
||||
"TotpSetup": {
|
||||
"PageTitle": "Configura la verifica in due passaggi",
|
||||
"RecoveryTitle": "Codici di recupero",
|
||||
"RecoveryText": "Conservali in un luogo sicuro: ognuno vale una volta sola, al posto del codice dell'app, se perdi il telefono. Non verranno mostrati di nuovo.",
|
||||
"RecoveryDone": "Ho salvato i codici, continua",
|
||||
"Title": "Configura la verifica in due passaggi",
|
||||
"Subtitle": "Aggiungi l'account a un'app di autenticazione (Google Authenticator, Microsoft Authenticator, Aegis, 2FAS...) e inserisci il primo codice.",
|
||||
"Secret": "Chiave da inserire nell'app",
|
||||
"Phone": "Sul telefono",
|
||||
"OpenInApp": "Apri nell'app di autenticazione",
|
||||
"FirstCode": "Primo codice dell'app",
|
||||
"Submit": "Attiva"
|
||||
},
|
||||
"Errors": {
|
||||
"invalid_credentials": "Azienda, utente o password non corretti.",
|
||||
"account_locked": "Troppi tentativi non riusciti: l'account è bloccato per 15 minuti.",
|
||||
"account_disabled": "L'account è disattivato: rivolgiti all'amministratore.",
|
||||
"temporary_password_expired": "La password provvisoria è scaduta: chiedine una nuova all'amministratore.",
|
||||
"password_too_short": "La nuova password è troppo corta: servono almeno {0} caratteri.",
|
||||
"password_too_simple": "La nuova password deve contenere almeno tre tipi di carattere tra minuscole, maiuscole, cifre e simboli.",
|
||||
"password_contains_user_name": "La nuova password non può contenere il nome utente.",
|
||||
"password_reused": "La nuova password è uguale a una delle ultime {1}.",
|
||||
"current_password_wrong": "La password attuale non è corretta.",
|
||||
"totp_invalid": "Codice non valido: controlla l'ora del telefono e riprova.",
|
||||
"rate_limited": "Troppi tentativi: riprova tra un minuto.",
|
||||
"concurrent_users_exceeded": "È stato raggiunto il numero massimo di utenti collegati previsto dalla licenza.",
|
||||
"company_unavailable": "L'azienda è in manutenzione o non è disponibile.",
|
||||
"license_limit_reached": "La licenza non consente altri accessi di questo tipo.",
|
||||
"recovery_token_invalid": "Il collegamento di recupero non è valido, è già stato usato o è scaduto.",
|
||||
"level_too_low": "Il tuo livello di accesso non consente questa operazione.",
|
||||
"permission_denied": "Il tuo profilo non ha il permesso per questa operazione.",
|
||||
"module_not_licensed": "Il modulo non è compreso nella licenza.",
|
||||
"Other": "Accesso non riuscito."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"Common": {
|
||||
"ProductName": "Khaemhat",
|
||||
"Close": "Chiudi",
|
||||
"Cancel": "Annulla",
|
||||
"Save": "Salva",
|
||||
"Reset": "Ripristina",
|
||||
"Yes": "Sì",
|
||||
"No": "No",
|
||||
"Back": "Indietro",
|
||||
"Continue": "Continua",
|
||||
"BackHome": "Torna alla pagina iniziale",
|
||||
"Loading": "Caricamento…",
|
||||
"Saved": "Salvato",
|
||||
"On": "Attivo",
|
||||
"Off": "Disattivo",
|
||||
"Documentation": "Documentazione"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
{
|
||||
"Pages": {
|
||||
"Home": {
|
||||
"Title": "Home",
|
||||
"Greeting": "Buongiorno, {0}",
|
||||
"GreetingAfternoon": "Buon pomeriggio, {0}",
|
||||
"GreetingEvening": "Buonasera, {0}",
|
||||
"Today": "Oggi è {0}",
|
||||
"LicenseTile": "Licenza",
|
||||
"LicenseTrial": "Prova",
|
||||
"LicenseFull": "Attiva",
|
||||
"LicenseDaysLeft": "restano {0} giorni",
|
||||
"LicenseLicensee": "intestata a {0}",
|
||||
"ModulesTile": "Moduli attivi",
|
||||
"ModulesText": "{0} su {1}",
|
||||
"CompanyTile": "Azienda",
|
||||
"CompanyNone": "nessuna azienda scelta",
|
||||
"AreasTitle": "Aree disponibili",
|
||||
"AreasHint": "Le aree si attivano con la licenza e i permessi; quelle segnate arrivano nelle prossime versioni.",
|
||||
"Coming": "in arrivo con {0}",
|
||||
"DashboardSoon": "La dashboard a widget personalizzabile (KPI, da fare oggi, scadenze, fatturato…) arriva con la prossima parte di questa versione.",
|
||||
"Subtitle": "{0}",
|
||||
"LicenseUnlimited": "senza scadenza",
|
||||
"ModulesNone": "nessun modulo",
|
||||
"Open": "Apri"
|
||||
},
|
||||
"ComingSoon": {
|
||||
"Title": "In arrivo",
|
||||
"Lead": "Questa sezione arriva con la milestone {0}.",
|
||||
"LeadUnknown": "Questa sezione non è ancora disponibile.",
|
||||
"Roadmap": "Vedi la tabella di marcia",
|
||||
"Back": "Torna alla pagina iniziale",
|
||||
"Areas": "Cosa conterrà"
|
||||
},
|
||||
"NotFound": {
|
||||
"PageTitle": "Pagina non trovata",
|
||||
"Title": "Pagina non trovata",
|
||||
"Lead": "L'indirizzo richiesto non esiste."
|
||||
},
|
||||
"AccessDenied": {
|
||||
"PageTitle": "Accesso negato",
|
||||
"Title": "Accesso negato",
|
||||
"Lead": "Il tuo profilo non ha il permesso per questa pagina, oppure il modulo non è compreso nella licenza."
|
||||
},
|
||||
"Error": {
|
||||
"PageTitle": "Errore",
|
||||
"Title": "Si è verificato un errore",
|
||||
"Lead": "La richiesta non è stata completata. Se il problema si ripete, comunica all'amministratore il codice qui sotto.",
|
||||
"Code": "Codice errore:"
|
||||
},
|
||||
"Profile": {
|
||||
"Title": "Il mio profilo",
|
||||
"Subtitle": "Aspetto, pagina iniziale e scorciatoie da tastiera. Le scelte valgono solo per il tuo account.",
|
||||
"Tabs": {
|
||||
"Appearance": "Aspetto",
|
||||
"Start": "Pagina iniziale",
|
||||
"Shortcuts": "Scorciatoie",
|
||||
"Sessions": "Sessioni"
|
||||
},
|
||||
"Theme": {
|
||||
"_": "Tema",
|
||||
"Auto": "Automatico",
|
||||
"AutoHint": "segue il sistema",
|
||||
"Light": "Chiaro",
|
||||
"Dark": "Scuro",
|
||||
"HighContrast": "Alto contrasto"
|
||||
},
|
||||
"Accent": {
|
||||
"_": "Colore di accento",
|
||||
"nilo": "Nilo",
|
||||
"lapislazzuli": "Lapislazzuli",
|
||||
"malachite": "Malachite",
|
||||
"turchese": "Turchese",
|
||||
"ocra": "Ocra",
|
||||
"corniola": "Corniola",
|
||||
"ametista": "Ametista",
|
||||
"grafite": "Grafite"
|
||||
},
|
||||
"Density": {
|
||||
"_": "Densità",
|
||||
"Comfortable": "Comoda",
|
||||
"Compact": "Compatta"
|
||||
},
|
||||
"TextSize": {
|
||||
"_": "Dimensione del testo",
|
||||
"Value": "{0}%"
|
||||
},
|
||||
"Menu": {
|
||||
"_": "Menu laterale",
|
||||
"Auto": "Automatico",
|
||||
"Expanded": "Espanso",
|
||||
"Collapsed": "Compresso"
|
||||
},
|
||||
"Options": {
|
||||
"_": "Opzioni",
|
||||
"TabularNumbers": "Numeri tabellari",
|
||||
"TabularNumbersHint": "cifre della stessa larghezza, allineate in colonna",
|
||||
"ReducedMotion": "Animazioni ridotte",
|
||||
"ReducedMotionHint": "niente transizioni e movimenti",
|
||||
"Tooltips": "Suggerimenti",
|
||||
"TooltipsHint": "descrizione dei pulsanti al passaggio del mouse",
|
||||
"RowHover": "Evidenzia la riga",
|
||||
"RowHoverHint": "colora la riga delle griglie sotto il puntatore"
|
||||
},
|
||||
"Preview": "Le modifiche si vedono subito; Salva le conserva per i prossimi accessi.",
|
||||
"Save": "Salva",
|
||||
"Undo": "Annulla le modifiche",
|
||||
"Defaults": "Valori predefiniti",
|
||||
"Saved": "Preferenze salvate",
|
||||
"SavedText": "Le scelte valgono da ora e ai prossimi accessi.",
|
||||
"Start": {
|
||||
"_": "All'accesso apri",
|
||||
"Dashboard": "La pagina iniziale",
|
||||
"LastTab": "Le schede aperte l'ultima volta",
|
||||
"Page": "Una pagina a scelta",
|
||||
"PagePick": "Pagina",
|
||||
"ShowDashboard": "Mostra la dashboard nella pagina iniziale"
|
||||
},
|
||||
"Shortcuts": {
|
||||
"Shell": "Applicazione",
|
||||
"Page": "Pagina",
|
||||
"Keys": "Tasti",
|
||||
"Action": "Azione",
|
||||
"BrowserNote": "Alcuni browser riservano Ctrl+W, Ctrl+Tab e Ctrl+N: per questo ci sono anche Alt+W, Alt+PagGiù/PagSu e Alt+N."
|
||||
},
|
||||
"Sessions": {
|
||||
"Intro": "I dispositivi da cui hai effettuato l'accesso e che non sono ancora scaduti. Se non riconosci una sessione, chiudila e cambia la password.",
|
||||
"Device": "Dispositivo",
|
||||
"Address": "Indirizzo",
|
||||
"Company": "Azienda",
|
||||
"SignedIn": "Accesso",
|
||||
"LastSeen": "Ultima attività",
|
||||
"Current": "Questa sessione",
|
||||
"Unknown": "Browser sconosciuto",
|
||||
"InstanceAccount": "istanza",
|
||||
"Revoke": "Chiudi",
|
||||
"RevokeOthers": "Chiudi tutte le altre",
|
||||
"RevokeTitle": "Chiudere la sessione?",
|
||||
"RevokeText": "Il dispositivo dovrà accedere di nuovo.",
|
||||
"RevokeOthersText": "Tutti gli altri dispositivi dovranno accedere di nuovo.",
|
||||
"Revoked": "Sessione chiusa",
|
||||
"RevokedMany": "Sessioni chiuse: {0}",
|
||||
"None": "Nessuna altra sessione attiva."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
{
|
||||
"Shell": {
|
||||
"SkipToContent": "Vai al contenuto",
|
||||
"Level": {
|
||||
"SuperUser": "Super utente",
|
||||
"Administrator": "Amministratore",
|
||||
"User": "Utente"
|
||||
},
|
||||
"Keys": {
|
||||
"Escape": "Esc"
|
||||
},
|
||||
"TopBar": {
|
||||
"Home": "Pagina iniziale",
|
||||
"SearchPlaceholder": "Cerca clienti, articoli, documenti…",
|
||||
"SearchKeys": "Ctrl K",
|
||||
"Recent": "Recenti",
|
||||
"NoRecent": "Nessuna pagina aperta di recente",
|
||||
"Notifications": "Notifiche",
|
||||
"NotificationsCount": "Notifiche: {0} non lette",
|
||||
"NoNotifications": "Nessuna notifica da leggere",
|
||||
"ThemeDark": "Passa al tema scuro",
|
||||
"ThemeLight": "Passa al tema chiaro",
|
||||
"Help": "Aiuto della pagina"
|
||||
},
|
||||
"Company": {
|
||||
"None": "Nessuna azienda",
|
||||
"Switch": "Cambia azienda"
|
||||
},
|
||||
"User": {
|
||||
"Profile": "Il mio profilo",
|
||||
"Appearance": "Aspetto e colori",
|
||||
"Sessions": "Sessioni attive",
|
||||
"SignOut": "Esci"
|
||||
},
|
||||
"Menu": {
|
||||
"Label": "Menu principale",
|
||||
"Collapse": "Comprimi menu",
|
||||
"Expand": "Espandi menu",
|
||||
"Footer": "Khaemhat {0}",
|
||||
"FiscalYear": "Esercizio {0}",
|
||||
"Section": {
|
||||
"Main": "Principale",
|
||||
"Operations": "Operativo",
|
||||
"System": "Sistema"
|
||||
},
|
||||
"Home": "Home",
|
||||
"Parties": {
|
||||
"_": "Anagrafiche",
|
||||
"Customers": "Clienti",
|
||||
"Suppliers": "Fornitori",
|
||||
"Contacts": "Contatti",
|
||||
"Items": "Articoli",
|
||||
"PriceLists": "Listini",
|
||||
"Categories": "Categorie"
|
||||
},
|
||||
"Crm": {
|
||||
"_": "CRM",
|
||||
"Dashboard": "Cruscotto CRM",
|
||||
"Leads": "Lead",
|
||||
"Pipeline": "Pipeline",
|
||||
"Agenda": "Agenda",
|
||||
"Tickets": "Ticket",
|
||||
"Campaigns": "Campagne"
|
||||
},
|
||||
"Sales": {
|
||||
"_": "Vendite",
|
||||
"Quotes": "Preventivi",
|
||||
"Orders": "Ordini clienti",
|
||||
"DeliveryNotes": "DDT",
|
||||
"Invoices": "Fatture",
|
||||
"CreditNotes": "Note di credito"
|
||||
},
|
||||
"Purchases": {
|
||||
"_": "Acquisti",
|
||||
"Orders": "Ordini fornitori",
|
||||
"Receipts": "Ricevimenti merce",
|
||||
"Invoices": "Fatture passive"
|
||||
},
|
||||
"Inventory": {
|
||||
"_": "Magazzino",
|
||||
"Stock": "Giacenze",
|
||||
"Entries": "Movimenti",
|
||||
"StockTake": "Inventario",
|
||||
"Reorder": "Proposte di riordino"
|
||||
},
|
||||
"Ledger": {
|
||||
"_": "Contabilità",
|
||||
"Journal": "Prima nota",
|
||||
"Accounts": "Piano dei conti",
|
||||
"VatRegisters": "Registri IVA",
|
||||
"VatSettlement": "Liquidazione IVA",
|
||||
"Statements": "Bilancio"
|
||||
},
|
||||
"Finance": {
|
||||
"_": "Scadenzario",
|
||||
"OpenItems": "Scadenze",
|
||||
"Remittances": "Distinte RiBa e SEPA",
|
||||
"Dunning": "Solleciti",
|
||||
"Reconciliation": "Riconciliazione bancaria"
|
||||
},
|
||||
"EInvoicing": {
|
||||
"_": "Fatt. elettronica",
|
||||
"Dashboard": "Cruscotto SDI",
|
||||
"Channels": "Canali di trasmissione",
|
||||
"StampDuty": "Bollo virtuale",
|
||||
"IntentDeclarations": "Dichiarazioni d'intento"
|
||||
},
|
||||
"Assets": {
|
||||
"_": "Cespiti",
|
||||
"Register": "Registro cespiti",
|
||||
"Depreciation": "Ammortamenti"
|
||||
},
|
||||
"Services": {
|
||||
"_": "Servizi",
|
||||
"Contracts": "Contratti di assistenza",
|
||||
"Interventions": "Interventi"
|
||||
},
|
||||
"Channels": {
|
||||
"_": "Canali e-commerce",
|
||||
"Orders": "Ordini dei canali"
|
||||
},
|
||||
"Reports": "Report",
|
||||
"CompanyTables": {
|
||||
"_": "Tabelle azienda",
|
||||
"Profile": "Profilo azienda",
|
||||
"FiscalYears": "Esercizi e periodi",
|
||||
"TaxCodes": "Codici IVA",
|
||||
"Payments": "Pagamenti"
|
||||
},
|
||||
"Automation": {
|
||||
"_": "Automazioni",
|
||||
"Rules": "Regole",
|
||||
"Procedures": "Procedure"
|
||||
},
|
||||
"Admin": {
|
||||
"_": "Amministrazione",
|
||||
"Companies": "Aziende",
|
||||
"Users": "Utenti",
|
||||
"Roles": "Ruoli",
|
||||
"Licenses": "Licenze e moduli",
|
||||
"Jobs": "Attività programmate",
|
||||
"Log": "Log",
|
||||
"Status": "Stato del sistema"
|
||||
}
|
||||
},
|
||||
"Tabs": {
|
||||
"Label": "Schede aperte",
|
||||
"New": "Nuova scheda: cerca una pagina",
|
||||
"Untitled": "Pagina",
|
||||
"Modified": "Modifiche non salvate",
|
||||
"Close": "Chiudi la scheda {0}",
|
||||
"CloseHint": "Chiudi (Alt+W)",
|
||||
"LimitTitle": "Troppe schede aperte",
|
||||
"LimitText": "Si possono tenere aperte al massimo {0} schede e tutte hanno modifiche da salvare: chiudine una per aprirne un'altra.",
|
||||
"CloseModifiedTitle": "Chiudere senza salvare?",
|
||||
"CloseModifiedText": "La scheda «{0}» ha modifiche non salvate: chiudendola andranno perse.",
|
||||
"CloseModifiedConfirm": "Chiudi senza salvare"
|
||||
},
|
||||
"Status": {
|
||||
"Label": "Barra di stato",
|
||||
"Connected": "Connesso · {0} ms",
|
||||
"Connecting": "Connessione…",
|
||||
"ConnectionHint": "Tempo di andata e ritorno della connessione con il server",
|
||||
"Redis": "Redis attivo",
|
||||
"LocalCache": "Cache locale",
|
||||
"Version": "v{0} ({1})"
|
||||
},
|
||||
"Search": {
|
||||
"Title": "Ricerca globale",
|
||||
"Placeholder": "Cerca una pagina o un comando (> per i comandi)",
|
||||
"NoResults": "Nessun risultato",
|
||||
"Pages": "Pagine",
|
||||
"CommandsGroup": "Comandi",
|
||||
"Move": "sposta",
|
||||
"Open": "apri",
|
||||
"Commands": "comandi"
|
||||
},
|
||||
"Commands": {
|
||||
"ToggleTheme": "Cambia tema chiaro/scuro",
|
||||
"ToggleMenu": "Comprimi o espandi il menu",
|
||||
"Appearance": "Preferenze: aspetto e colori",
|
||||
"Profile": "Il mio profilo",
|
||||
"Shortcuts": "Scorciatoie da tastiera"
|
||||
},
|
||||
"Shortcuts": {
|
||||
"Search": "Ricerca globale",
|
||||
"ToggleMenu": "Comprimi o espandi il menu",
|
||||
"Help": "Aiuto della pagina",
|
||||
"CloseTab": "Chiudi la scheda",
|
||||
"NextTab": "Scheda successiva",
|
||||
"PreviousTab": "Scheda precedente",
|
||||
"Save": "Salva",
|
||||
"New": "Nuovo",
|
||||
"Print": "Stampa",
|
||||
"Delete": "Elimina",
|
||||
"Lookup": "Ricerca nel campo",
|
||||
"Radar": "Radar",
|
||||
"PreviousRecord": "Record precedente",
|
||||
"NextRecord": "Record successivo",
|
||||
"Balance": "Quadra la registrazione"
|
||||
},
|
||||
"Error": {
|
||||
"Unexpected": "Si è verificato un errore imprevisto.",
|
||||
"Reload": "Ricarica"
|
||||
},
|
||||
"Reconnect": {
|
||||
"First": "Riconnessione al server…",
|
||||
"Repeated": "Riconnessione non riuscita: nuovo tentativo tra",
|
||||
"Seconds": "secondi.",
|
||||
"Failed": "Impossibile ricollegarsi al server.",
|
||||
"FailedHint": "Riprova o ricarica la pagina.",
|
||||
"Retry": "Riprova",
|
||||
"Paused": "La sessione è stata sospesa dal server.",
|
||||
"ResumeFailed": "Impossibile riprendere la sessione.",
|
||||
"Resume": "Riprendi"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using Khaemhat.Application.Localization;
|
||||
using Khaemhat.Application.Security;
|
||||
using Khaemhat.Core.Security;
|
||||
|
||||
@@ -40,30 +41,25 @@ public static class LoginFlow
|
||||
? url
|
||||
: "/";
|
||||
|
||||
/// <summary>The Italian message of an error code (several codes may be joined by commas).</summary>
|
||||
/// <summary>The messages of error codes (several codes may be joined by commas), from the texts <c>Auth.Errors.*</c>.</summary>
|
||||
/// <param name="texts">The texts.</param>
|
||||
/// <param name="policy">The password policy, for the numbers in the messages.</param>
|
||||
/// <param name="error">The code(s).</param>
|
||||
/// <returns>The messages.</returns>
|
||||
public static IReadOnlyList<string> Messages(string? error) =>
|
||||
string.IsNullOrEmpty(error) ? [] : [.. error.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Select(Message)];
|
||||
|
||||
private static string Message(string code) => code switch
|
||||
public static IReadOnlyList<string> Messages(ITexts texts, SecurityPolicyOptions policy, string? error)
|
||||
{
|
||||
SecurityErrors.InvalidCredentials => "Azienda, utente o password non corretti.",
|
||||
SecurityErrors.AccountLocked => "Troppi tentativi non riusciti: l'account è bloccato per 15 minuti.",
|
||||
SecurityErrors.AccountDisabled => "L'account è disattivato: rivolgiti all'amministratore.",
|
||||
SecurityErrors.TemporaryPasswordExpired => "La password provvisoria è scaduta: chiedine una nuova all'amministratore.",
|
||||
SecurityErrors.PasswordTooShort => "La nuova password è troppo corta: servono almeno 10 caratteri.",
|
||||
SecurityErrors.PasswordTooSimple => "La nuova password deve contenere almeno tre tipi di carattere tra minuscole, maiuscole, cifre e simboli.",
|
||||
SecurityErrors.PasswordContainsUserName => "La nuova password non può contenere il nome utente.",
|
||||
SecurityErrors.PasswordReused => "La nuova password è uguale a una delle ultime cinque.",
|
||||
SecurityErrors.CurrentPasswordWrong => "La password attuale non è corretta.",
|
||||
SecurityErrors.TotpInvalid => "Codice non valido: controlla l'ora del telefono e riprova.",
|
||||
SecurityErrors.RateLimited => "Troppi tentativi: riprova tra un minuto.",
|
||||
SecurityErrors.ConcurrentUsersExceeded => "È stato raggiunto il numero massimo di utenti collegati previsto dalla licenza.",
|
||||
SecurityErrors.CompanyUnavailable => "L'azienda è in manutenzione o non è disponibile.",
|
||||
SecurityErrors.LicenseLimitReached => "La licenza non consente altri accessi di questo tipo.",
|
||||
_ => "Accesso non riuscito.",
|
||||
};
|
||||
ArgumentNullException.ThrowIfNull(texts);
|
||||
ArgumentNullException.ThrowIfNull(policy);
|
||||
return string.IsNullOrEmpty(error)
|
||||
? []
|
||||
: [.. error.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Select(code => Message(texts, policy, code))];
|
||||
}
|
||||
|
||||
private static string Message(ITexts texts, SecurityPolicyOptions policy, string code)
|
||||
{
|
||||
var key = "Auth.Errors." + code;
|
||||
return texts.Contains(key) ? texts.Format(key, policy.MinimumLength, policy.HistorySize) : texts["Auth.Errors.Other"];
|
||||
}
|
||||
|
||||
private static string Carry(string? returnUrl) =>
|
||||
SafeReturnUrl(returnUrl) is var url && url != "/" ? "?returnUrl=" + Uri.EscapeDataString(url) : string.Empty;
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
namespace Khaemhat.Web.Shell;
|
||||
|
||||
/// <summary>The weight of a toast.</summary>
|
||||
public enum ToastKind
|
||||
{
|
||||
/// <summary>Information.</summary>
|
||||
Info = 0,
|
||||
|
||||
/// <summary>Done.</summary>
|
||||
Success = 1,
|
||||
|
||||
/// <summary>Attention.</summary>
|
||||
Warning = 2,
|
||||
|
||||
/// <summary>Failure.</summary>
|
||||
Error = 3,
|
||||
}
|
||||
|
||||
/// <summary>A short message in the bottom right corner (SPEC §10.7 <c>KhToast</c>).</summary>
|
||||
/// <param name="Id">The identifier.</param>
|
||||
/// <param name="Kind">The weight.</param>
|
||||
/// <param name="Title">The title.</param>
|
||||
/// <param name="Text">The text, or <see langword="null"/>.</param>
|
||||
public sealed record Toast(Guid Id, ToastKind Kind, string Title, string? Text);
|
||||
|
||||
/// <summary>Shows toasts; <c>KhToastHost</c> in the layout renders them and removes them after a few seconds.</summary>
|
||||
public sealed class ToastService
|
||||
{
|
||||
private readonly List<Toast> _toasts = [];
|
||||
|
||||
/// <summary>Raised when toasts appear or go.</summary>
|
||||
public event Action? Changed;
|
||||
|
||||
/// <summary>The toasts on screen.</summary>
|
||||
public IReadOnlyList<Toast> Toasts => _toasts;
|
||||
|
||||
/// <summary>Shows a toast.</summary>
|
||||
/// <param name="kind">The weight.</param>
|
||||
/// <param name="title">The title.</param>
|
||||
/// <param name="text">The text.</param>
|
||||
/// <returns>The toast.</returns>
|
||||
public Toast Show(ToastKind kind, string title, string? text = null)
|
||||
{
|
||||
var toast = new Toast(Guid.NewGuid(), kind, title, text);
|
||||
_toasts.Add(toast);
|
||||
if (_toasts.Count > 5)
|
||||
{
|
||||
_toasts.RemoveAt(0);
|
||||
}
|
||||
|
||||
Changed?.Invoke();
|
||||
return toast;
|
||||
}
|
||||
|
||||
/// <summary>Removes a toast.</summary>
|
||||
/// <param name="id">The toast.</param>
|
||||
public void Dismiss(Guid id)
|
||||
{
|
||||
if (_toasts.RemoveAll(t => t.Id == id) > 0)
|
||||
{
|
||||
Changed?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A question that needs a yes or no (SPEC §10.7 <c>KhConfirm</c>).</summary>
|
||||
/// <param name="Title">The title.</param>
|
||||
/// <param name="Text">The question.</param>
|
||||
/// <param name="ConfirmText">The text of the confirming button.</param>
|
||||
/// <param name="CancelText">The text of the cancelling button.</param>
|
||||
/// <param name="Danger">Whether confirming destroys something (red button).</param>
|
||||
public sealed record ConfirmRequest(string Title, string Text, string ConfirmText, string CancelText, bool Danger = false);
|
||||
|
||||
/// <summary>Asks confirmations; <c>KhDialogHost</c> in the layout shows them one at a time.</summary>
|
||||
public sealed class DialogService
|
||||
{
|
||||
private TaskCompletionSource<bool>? _pending;
|
||||
|
||||
/// <summary>Raised when a question appears or is answered.</summary>
|
||||
public event Action? Changed;
|
||||
|
||||
/// <summary>The question on screen, or <see langword="null"/>.</summary>
|
||||
public ConfirmRequest? Current { get; private set; }
|
||||
|
||||
/// <summary>Asks a question and waits for the answer.</summary>
|
||||
/// <param name="request">The question.</param>
|
||||
/// <returns><see langword="true"/> when the user confirms.</returns>
|
||||
public Task<bool> ConfirmAsync(ConfirmRequest request)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(request);
|
||||
_pending?.TrySetResult(false);
|
||||
_pending = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
Current = request;
|
||||
Changed?.Invoke();
|
||||
return _pending.Task;
|
||||
}
|
||||
|
||||
/// <summary>Called by the dialog with the answer.</summary>
|
||||
/// <param name="confirmed">The answer.</param>
|
||||
public void Answer(bool confirmed)
|
||||
{
|
||||
var pending = _pending;
|
||||
_pending = null;
|
||||
Current = null;
|
||||
Changed?.Invoke();
|
||||
pending?.TrySetResult(confirmed);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
namespace Khaemhat.Web.Shell;
|
||||
|
||||
/// <summary>
|
||||
/// The wiki page of each part of the application (SPEC §17: F1 and "?" open the page of the screen). The address is
|
||||
/// the deepest prefix that matches; anything unknown opens the wiki home.
|
||||
/// </summary>
|
||||
public static class HelpLinks
|
||||
{
|
||||
/// <summary>The wiki of the project, used when no other address is configured.</summary>
|
||||
public const string DefaultBaseUrl = "https://gitea.encke-hake.ts.net/BalboSoft/Khaemhat/wiki/";
|
||||
|
||||
private static readonly (string Prefix, string Page)[] Pages =
|
||||
[
|
||||
("/anagrafiche/articoli", "Articoli-e-listini"),
|
||||
("/anagrafiche/listini", "Articoli-e-listini"),
|
||||
("/anagrafiche", "Anagrafiche"),
|
||||
("/crm", "CRM"),
|
||||
("/vendite", "Vendite"),
|
||||
("/acquisti", "Acquisti"),
|
||||
("/magazzino", "Magazzino"),
|
||||
("/contabilita/liquidazione-iva", "IVA"),
|
||||
("/contabilita/registri-iva", "IVA"),
|
||||
("/contabilita", "Contabilita"),
|
||||
("/scadenzario", "Scadenzario"),
|
||||
("/fatturazione-elettronica", "Fatturazione-elettronica"),
|
||||
("/cespiti", "Cespiti"),
|
||||
("/servizi", "Servizi"),
|
||||
("/canali", "Canali-e-commerce"),
|
||||
("/report", "Report"),
|
||||
("/tabelle", "Tabelle-azienda"),
|
||||
("/automazioni", "Automazioni"),
|
||||
("/amministrazione/licenze", "Licenze-e-moduli"),
|
||||
("/amministrazione/log", "Log"),
|
||||
("/amministrazione/attivita", "Attivita-programmate"),
|
||||
("/amministrazione/stato", "Stato-sistema"),
|
||||
("/amministrazione/utenti", "Utenti-e-permessi"),
|
||||
("/amministrazione/ruoli", "Utenti-e-permessi"),
|
||||
("/amministrazione", "Istanza-e-database"),
|
||||
("/profilo", "Preferenze-utente"),
|
||||
("/", "Dashboard"),
|
||||
];
|
||||
|
||||
/// <summary>The wiki page of a path.</summary>
|
||||
/// <param name="path">The path, without query.</param>
|
||||
/// <returns>The page name, for example <c>Anagrafiche</c>.</returns>
|
||||
public static string PageFor(string path)
|
||||
{
|
||||
var p = TabService.PathOf(path);
|
||||
foreach (var (prefix, page) in Pages)
|
||||
{
|
||||
if (prefix == "/" ? p == "/" : p.Equals(prefix, StringComparison.OrdinalIgnoreCase) || p.StartsWith(prefix + "/", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return page;
|
||||
}
|
||||
}
|
||||
|
||||
return "Home";
|
||||
}
|
||||
|
||||
/// <summary>The address of the help of a path.</summary>
|
||||
/// <param name="baseUrl">The wiki address, ending with a slash.</param>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>The address.</returns>
|
||||
public static string UrlFor(string baseUrl, string path) => baseUrl + PageFor(path);
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
namespace Khaemhat.Web.Shell;
|
||||
|
||||
/// <summary>Who handles a shortcut.</summary>
|
||||
public enum ShortcutScope
|
||||
{
|
||||
/// <summary>The shell (menu, tabs, search, help).</summary>
|
||||
Shell = 0,
|
||||
|
||||
/// <summary>The active page (save, new, print, radar...).</summary>
|
||||
Page = 1,
|
||||
}
|
||||
|
||||
/// <summary>A keyboard shortcut of SPEC §10.5.7.</summary>
|
||||
/// <param name="Id">The command.</param>
|
||||
/// <param name="Keys">The combinations, as the browser script writes them (<c>Ctrl+S</c>, <c>F9</c>, <c>Alt+W</c>).</param>
|
||||
/// <param name="TextKey">The text key of the description.</param>
|
||||
/// <param name="Scope">Who handles it.</param>
|
||||
public sealed record Shortcut(string Id, IReadOnlyList<string> Keys, string TextKey, ShortcutScope Scope);
|
||||
|
||||
/// <summary>
|
||||
/// The shortcut table of SPEC §10.5.7. Browsers keep some combinations for themselves (Ctrl+W, Ctrl+Tab, Ctrl+N
|
||||
/// in a normal window): each of those has an <c>Alt</c> alternative that always works (ADR 0020).
|
||||
/// </summary>
|
||||
public static class KeyboardShortcuts
|
||||
{
|
||||
/// <summary>Command ids.</summary>
|
||||
public static class Commands
|
||||
{
|
||||
/// <summary>Collapse or expand the menu.</summary>
|
||||
public const string ToggleMenu = "shell.menu";
|
||||
|
||||
/// <summary>Global search.</summary>
|
||||
public const string Search = "shell.search";
|
||||
|
||||
/// <summary>Help of the page.</summary>
|
||||
public const string Help = "shell.help";
|
||||
|
||||
/// <summary>Close the active tab.</summary>
|
||||
public const string CloseTab = "shell.tab.close";
|
||||
|
||||
/// <summary>Next tab.</summary>
|
||||
public const string NextTab = "shell.tab.next";
|
||||
|
||||
/// <summary>Previous tab.</summary>
|
||||
public const string PreviousTab = "shell.tab.previous";
|
||||
|
||||
/// <summary>Save.</summary>
|
||||
public const string Save = "page.save";
|
||||
|
||||
/// <summary>New record.</summary>
|
||||
public const string New = "page.new";
|
||||
|
||||
/// <summary>Print.</summary>
|
||||
public const string Print = "page.print";
|
||||
|
||||
/// <summary>Lookup of the field.</summary>
|
||||
public const string Lookup = "page.lookup";
|
||||
|
||||
/// <summary>Radar of the page.</summary>
|
||||
public const string Radar = "page.radar";
|
||||
|
||||
/// <summary>Cancel.</summary>
|
||||
public const string Cancel = "page.cancel";
|
||||
|
||||
/// <summary>Previous record.</summary>
|
||||
public const string PreviousRecord = "page.record.previous";
|
||||
|
||||
/// <summary>Next record.</summary>
|
||||
public const string NextRecord = "page.record.next";
|
||||
|
||||
/// <summary>Balance the journal entry.</summary>
|
||||
public const string Balance = "page.balance";
|
||||
|
||||
/// <summary>Delete.</summary>
|
||||
public const string Delete = "page.delete";
|
||||
}
|
||||
|
||||
/// <summary>The table.</summary>
|
||||
public static IReadOnlyList<Shortcut> All { get; } =
|
||||
[
|
||||
new(Commands.Search, ["Ctrl+K"], "Shell.Shortcuts.Search", ShortcutScope.Shell),
|
||||
new(Commands.ToggleMenu, ["Ctrl+B"], "Shell.Shortcuts.ToggleMenu", ShortcutScope.Shell),
|
||||
new(Commands.Help, ["F1"], "Shell.Shortcuts.Help", ShortcutScope.Shell),
|
||||
new(Commands.CloseTab, ["Ctrl+W", "Alt+W"], "Shell.Shortcuts.CloseTab", ShortcutScope.Shell),
|
||||
new(Commands.NextTab, ["Ctrl+Tab", "Alt+PageDown"], "Shell.Shortcuts.NextTab", ShortcutScope.Shell),
|
||||
new(Commands.PreviousTab, ["Ctrl+Shift+Tab", "Alt+PageUp"], "Shell.Shortcuts.PreviousTab", ShortcutScope.Shell),
|
||||
new(Commands.Save, ["Ctrl+S"], "Shell.Shortcuts.Save", ShortcutScope.Page),
|
||||
new(Commands.New, ["Ctrl+N", "Alt+N"], "Shell.Shortcuts.New", ShortcutScope.Page),
|
||||
new(Commands.Print, ["Ctrl+P"], "Shell.Shortcuts.Print", ShortcutScope.Page),
|
||||
new(Commands.Delete, ["Ctrl+Delete"], "Shell.Shortcuts.Delete", ShortcutScope.Page),
|
||||
new(Commands.Lookup, ["F4"], "Shell.Shortcuts.Lookup", ShortcutScope.Page),
|
||||
new(Commands.Radar, ["F9"], "Shell.Shortcuts.Radar", ShortcutScope.Page),
|
||||
new(Commands.PreviousRecord, ["Ctrl+ArrowUp"], "Shell.Shortcuts.PreviousRecord", ShortcutScope.Page),
|
||||
new(Commands.NextRecord, ["Ctrl+ArrowDown"], "Shell.Shortcuts.NextRecord", ShortcutScope.Page),
|
||||
new(Commands.Balance, ["Ctrl+D"], "Shell.Shortcuts.Balance", ShortcutScope.Page),
|
||||
];
|
||||
|
||||
/// <summary>The shortcut of a command.</summary>
|
||||
/// <param name="id">The command.</param>
|
||||
/// <returns>The shortcut, or <see langword="null"/>.</returns>
|
||||
public static Shortcut? Find(string id) => All.FirstOrDefault(s => s.Id == id);
|
||||
|
||||
/// <summary>The first combination of a command, for tooltips (<c>Ctrl+S</c>).</summary>
|
||||
/// <param name="id">The command.</param>
|
||||
/// <returns>The combination, or an empty string.</returns>
|
||||
public static string KeysOf(string id) => Find(id)?.Keys[0] ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Receives the shortcuts from the browser script and hands them out: the shell handles its own, the active page
|
||||
/// subscribes to <see cref="PagePressed"/> for the rest. Escape is not intercepted (inputs and dialogs need it).
|
||||
/// </summary>
|
||||
/// <param name="js">The browser.</param>
|
||||
public sealed class KeyboardShortcutService(IJSRuntime js) : IAsyncDisposable
|
||||
{
|
||||
private DotNetObjectReference<KeyboardShortcutService>? _self;
|
||||
|
||||
/// <summary>A shell command was pressed.</summary>
|
||||
public event Func<string, Task>? ShellPressed;
|
||||
|
||||
/// <summary>A page command was pressed; the active page handles it.</summary>
|
||||
public event Func<string, Task>? PagePressed;
|
||||
|
||||
/// <summary>Starts listening in the browser.</summary>
|
||||
/// <returns>A task.</returns>
|
||||
public async Task StartAsync()
|
||||
{
|
||||
_self ??= DotNetObjectReference.Create(this);
|
||||
var combos = KeyboardShortcuts.All.SelectMany(s => s.Keys).Distinct(StringComparer.Ordinal).ToArray();
|
||||
await js.InvokeVoidAsync("khaemhat.startShortcuts", _self, combos).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>Called by the browser script.</summary>
|
||||
/// <param name="combo">The combination pressed.</param>
|
||||
/// <returns>A task.</returns>
|
||||
[JSInvokable]
|
||||
public async Task OnShortcut(string combo)
|
||||
{
|
||||
var shortcut = KeyboardShortcuts.All.FirstOrDefault(s => s.Keys.Contains(combo, StringComparer.Ordinal));
|
||||
if (shortcut is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var handler = shortcut.Scope == ShortcutScope.Shell ? ShellPressed : PagePressed;
|
||||
if (handler is not null)
|
||||
{
|
||||
await handler(shortcut.Id).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
if (_self is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await js.InvokeVoidAsync("khaemhat.stopShortcuts").ConfigureAwait(false);
|
||||
}
|
||||
catch (JSDisconnectedException)
|
||||
{
|
||||
// The circuit is gone together with the page.
|
||||
}
|
||||
|
||||
_self.Dispose();
|
||||
_self = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
using Khaemhat.Application.Modules;
|
||||
|
||||
namespace Khaemhat.Web.Shell;
|
||||
|
||||
/// <summary>Who may see a menu entry besides module and permission.</summary>
|
||||
public enum MenuAudience
|
||||
{
|
||||
/// <summary>Everybody with the module and the permission.</summary>
|
||||
Everyone = 0,
|
||||
|
||||
/// <summary>Only instance accounts (super user and administrators).</summary>
|
||||
InstanceAccounts = 1,
|
||||
}
|
||||
|
||||
/// <summary>An entry of the side menu (SPEC §10.2).</summary>
|
||||
/// <param name="Key">The text key of the label (<c>Shell.Menu.*</c>) and the identity of the entry.</param>
|
||||
/// <param name="Icon">The icon in <c>icons/sprite.svg</c>.</param>
|
||||
/// <param name="Href">The address.</param>
|
||||
/// <param name="Module">The licence module that must be active.</param>
|
||||
/// <param name="Permission">The permission needed, or <see langword="null"/>.</param>
|
||||
/// <param name="Milestone">The milestone that delivers the page, shown while it is not there yet (<c>M4</c>...); <see langword="null"/> once delivered.</param>
|
||||
/// <param name="Audience">Who may see it.</param>
|
||||
public sealed record MenuItem(string Key, string Icon, string Href, string Module, string? Permission, string? Milestone,
|
||||
MenuAudience Audience = MenuAudience.Everyone)
|
||||
{
|
||||
/// <summary>The sub-entries shown under the active module or in the pop-up of the collapsed menu.</summary>
|
||||
public IReadOnlyList<MenuItem> Children { get; init; } = [];
|
||||
|
||||
/// <summary>Whether an address belongs to this entry or to one of its children.</summary>
|
||||
/// <param name="path">The path, without query.</param>
|
||||
/// <returns><see langword="true"/> when it matches.</returns>
|
||||
public bool Matches(string path) =>
|
||||
Href == "/" ? path == "/" : path.Equals(Href, StringComparison.OrdinalIgnoreCase) || path.StartsWith(Href + "/", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>A titled group of the side menu.</summary>
|
||||
/// <param name="Key">The text key of the title.</param>
|
||||
/// <param name="Items">The entries.</param>
|
||||
public sealed record MenuSection(string Key, IReadOnlyList<MenuItem> Items);
|
||||
|
||||
/// <summary>
|
||||
/// The side menu of SPEC §10.2, in its order: Home; Anagrafiche, CRM, Vendite, Acquisti, Magazzino, Contabilità,
|
||||
/// Scadenzario, Fatturazione elettronica, Cespiti, Servizi, Canali e-commerce, Report; Tabelle azienda,
|
||||
/// Automazioni, Amministrazione. Entries appear only with the licensed module and the permission.
|
||||
/// </summary>
|
||||
public static class MenuCatalog
|
||||
{
|
||||
/// <summary>The sections.</summary>
|
||||
public static IReadOnlyList<MenuSection> Sections { get; } =
|
||||
[
|
||||
new("Shell.Menu.Section.Main",
|
||||
[
|
||||
new("Shell.Menu.Home", "home", "/", ModuleCodes.Core, null, null),
|
||||
]),
|
||||
new("Shell.Menu.Section.Operations",
|
||||
[
|
||||
Area("Shell.Menu.Parties", "users", "/anagrafiche", ModuleCodes.Core, "parties.party.read", "M4",
|
||||
("Shell.Menu.Parties.Customers", "clienti"), ("Shell.Menu.Parties.Suppliers", "fornitori"), ("Shell.Menu.Parties.Contacts", "contatti"),
|
||||
("Shell.Menu.Parties.Items", "articoli"), ("Shell.Menu.Parties.PriceLists", "listini"), ("Shell.Menu.Parties.Categories", "categorie")),
|
||||
Area("Shell.Menu.Crm", "target", "/crm", ModuleCodes.Crm, "crm.lead.read", "M11",
|
||||
("Shell.Menu.Crm.Dashboard", "cruscotto"), ("Shell.Menu.Crm.Leads", "lead"), ("Shell.Menu.Crm.Pipeline", "pipeline"),
|
||||
("Shell.Menu.Crm.Agenda", "agenda"), ("Shell.Menu.Crm.Tickets", "ticket"), ("Shell.Menu.Crm.Campaigns", "campagne")),
|
||||
Area("Shell.Menu.Sales", "cart", "/vendite", ModuleCodes.Core, "sales.invoice.read", "M5",
|
||||
("Shell.Menu.Sales.Quotes", "preventivi"), ("Shell.Menu.Sales.Orders", "ordini"), ("Shell.Menu.Sales.DeliveryNotes", "ddt"),
|
||||
("Shell.Menu.Sales.Invoices", "fatture"), ("Shell.Menu.Sales.CreditNotes", "note-credito")),
|
||||
Area("Shell.Menu.Purchases", "truck", "/acquisti", ModuleCodes.Core, "purchases.order.read", "M6",
|
||||
("Shell.Menu.Purchases.Orders", "ordini"), ("Shell.Menu.Purchases.Receipts", "ricevimenti"), ("Shell.Menu.Purchases.Invoices", "fatture")),
|
||||
Area("Shell.Menu.Inventory", "box", "/magazzino", ModuleCodes.Core, "inventory.stock.read", "M6",
|
||||
("Shell.Menu.Inventory.Stock", "giacenze"), ("Shell.Menu.Inventory.Entries", "movimenti"), ("Shell.Menu.Inventory.StockTake", "inventario"),
|
||||
("Shell.Menu.Inventory.Reorder", "riordino")),
|
||||
Area("Shell.Menu.Ledger", "book", "/contabilita", ModuleCodes.Accounting, "ledger.entry.read", "M7",
|
||||
("Shell.Menu.Ledger.Journal", "prima-nota"), ("Shell.Menu.Ledger.Accounts", "piano-dei-conti"), ("Shell.Menu.Ledger.VatRegisters", "registri-iva"),
|
||||
("Shell.Menu.Ledger.VatSettlement", "liquidazione-iva"), ("Shell.Menu.Ledger.Statements", "bilancio")),
|
||||
Area("Shell.Menu.Finance", "coins", "/scadenzario", ModuleCodes.Finance, "finance.schedule.read", "M9",
|
||||
("Shell.Menu.Finance.OpenItems", "scadenze"), ("Shell.Menu.Finance.Remittances", "distinte"), ("Shell.Menu.Finance.Dunning", "solleciti"),
|
||||
("Shell.Menu.Finance.Reconciliation", "riconciliazione")),
|
||||
Area("Shell.Menu.EInvoicing", "file-check", "/fatturazione-elettronica", ModuleCodes.EInvoicing, "einvoice.document.read", "M8",
|
||||
("Shell.Menu.EInvoicing.Dashboard", "cruscotto"), ("Shell.Menu.EInvoicing.Channels", "canali"), ("Shell.Menu.EInvoicing.StampDuty", "bollo"),
|
||||
("Shell.Menu.EInvoicing.IntentDeclarations", "dichiarazioni-intento")),
|
||||
Area("Shell.Menu.Assets", "building", "/cespiti", ModuleCodes.Assets, "assets.asset.read", "M10",
|
||||
("Shell.Menu.Assets.Register", "registro"), ("Shell.Menu.Assets.Depreciation", "ammortamenti")),
|
||||
Area("Shell.Menu.Services", "wrench", "/servizi", ModuleCodes.Services, null, "M12",
|
||||
("Shell.Menu.Services.Contracts", "contratti"), ("Shell.Menu.Services.Interventions", "interventi")),
|
||||
Area("Shell.Menu.Channels", "globe", "/canali", ModuleCodes.Channels, null, "M12",
|
||||
("Shell.Menu.Channels.Orders", "ordini")),
|
||||
Area("Shell.Menu.Reports", "chart", "/report", ModuleCodes.Reports, "reports.report.read", "M13"),
|
||||
]),
|
||||
new("Shell.Menu.Section.System",
|
||||
[
|
||||
Area("Shell.Menu.CompanyTables", "layers", "/tabelle", ModuleCodes.Core, "company.settings.read", "M4",
|
||||
("Shell.Menu.CompanyTables.Profile", "profilo-azienda"), ("Shell.Menu.CompanyTables.FiscalYears", "esercizi"),
|
||||
("Shell.Menu.CompanyTables.TaxCodes", "codici-iva"), ("Shell.Menu.CompanyTables.Payments", "pagamenti")),
|
||||
Area("Shell.Menu.Automation", "zap", "/automazioni", ModuleCodes.Automation, null, "M12",
|
||||
("Shell.Menu.Automation.Rules", "regole"), ("Shell.Menu.Automation.Procedures", "procedure")),
|
||||
Area("Shell.Menu.Admin", "shield", "/amministrazione", ModuleCodes.Core, null, "M13",
|
||||
MenuAudience.InstanceAccounts,
|
||||
("Shell.Menu.Admin.Companies", "aziende"), ("Shell.Menu.Admin.Users", "utenti"), ("Shell.Menu.Admin.Roles", "ruoli"),
|
||||
("Shell.Menu.Admin.Licenses", "licenze"), ("Shell.Menu.Admin.Jobs", "attivita"), ("Shell.Menu.Admin.Log", "log"),
|
||||
("Shell.Menu.Admin.Status", "stato")),
|
||||
]),
|
||||
];
|
||||
|
||||
/// <summary>Every entry with its children, in menu order.</summary>
|
||||
public static IEnumerable<MenuItem> All => Sections.SelectMany(s => s.Items).SelectMany(i => i.Children.Prepend(i));
|
||||
|
||||
/// <summary>The entry that best matches an address: the deepest one whose address is a prefix.</summary>
|
||||
/// <param name="path">The path, without query.</param>
|
||||
/// <returns>The entry, or <see langword="null"/>.</returns>
|
||||
public static MenuItem? Find(string path) =>
|
||||
All.Where(i => i.Matches(path)).OrderByDescending(i => i.Href.Length).FirstOrDefault();
|
||||
|
||||
/// <summary>The top-level entry an address belongs to.</summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>The entry, or <see langword="null"/>.</returns>
|
||||
public static MenuItem? FindArea(string path) =>
|
||||
Sections.SelectMany(s => s.Items).Where(i => i.Matches(path)).OrderByDescending(i => i.Href.Length).FirstOrDefault();
|
||||
|
||||
private static MenuItem Area(string key, string icon, string href, string module, string? permission, string? milestone,
|
||||
params (string Key, string Slug)[] children) =>
|
||||
Area(key, icon, href, module, permission, milestone, MenuAudience.Everyone, children);
|
||||
|
||||
private static MenuItem Area(string key, string icon, string href, string module, string? permission, string? milestone, MenuAudience audience,
|
||||
params (string Key, string Slug)[] children) =>
|
||||
new(key, icon, href, module, permission, milestone, audience)
|
||||
{
|
||||
Children = [.. children.Select(c => new MenuItem(c.Key, icon, href + "/" + c.Slug, module, permission, milestone, audience))],
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
using Khaemhat.Application.Licensing;
|
||||
using Khaemhat.Application.Preferences;
|
||||
using Khaemhat.Application.Security;
|
||||
using Khaemhat.Core.Instance;
|
||||
using Khaemhat.Core.Security;
|
||||
using Khaemhat.Data.Companies;
|
||||
using Khaemhat.Web.Security;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
|
||||
namespace Khaemhat.Web.Shell;
|
||||
|
||||
/// <summary>
|
||||
/// What the shell needs to know about the signed-in user, loaded once per circuit: the actor, the display name, the
|
||||
/// company, the effective permissions and the interface preferences. Components read it; preference changes go
|
||||
/// through <see cref="SavePreferencesAsync"/> so every part of the shell is told (<see cref="Changed"/>).
|
||||
/// </summary>
|
||||
/// <param name="authentication">The signed-in user.</param>
|
||||
/// <param name="permissions">Effective permissions.</param>
|
||||
/// <param name="companies">The company registry.</param>
|
||||
/// <param name="licenses">The licence.</param>
|
||||
/// <param name="settings">The user preferences store.</param>
|
||||
public sealed class ShellSession(
|
||||
AuthenticationStateProvider authentication,
|
||||
PermissionService permissions,
|
||||
ICompanyRegistry companies,
|
||||
ILicenseGate licenses,
|
||||
UserSettingsService settings) : IDisposable
|
||||
{
|
||||
private readonly SemaphoreSlim _load = new(1, 1);
|
||||
private bool _loaded;
|
||||
|
||||
/// <summary>Raised after the preferences or the permissions change.</summary>
|
||||
public event Action? Changed;
|
||||
|
||||
/// <summary>The signed-in user, or <see langword="null"/>.</summary>
|
||||
public Actor? Actor { get; private set; }
|
||||
|
||||
/// <summary>The name shown in the top bar.</summary>
|
||||
public string DisplayName { get; private set; } = string.Empty;
|
||||
|
||||
/// <summary>The company the session works in.</summary>
|
||||
public Company? Company { get; private set; }
|
||||
|
||||
/// <summary>The companies an instance account may switch to (empty for company users).</summary>
|
||||
public IReadOnlyList<Company> SwitchableCompanies { get; private set; } = [];
|
||||
|
||||
/// <summary>The effective permissions.</summary>
|
||||
public EffectivePermissions Permissions { get; private set; } = EffectivePermissions.None;
|
||||
|
||||
/// <summary>The interface preferences.</summary>
|
||||
public UserPreferences Preferences { get; private set; } = UserPreferences.Default;
|
||||
|
||||
/// <summary>The licence.</summary>
|
||||
public ILicenseGate Licenses => licenses;
|
||||
|
||||
/// <summary>The initials of the user for the avatar.</summary>
|
||||
public string Initials => InitialsOf(DisplayName);
|
||||
|
||||
/// <summary>Loads everything once; later calls return at once.</summary>
|
||||
/// <param name="cancellationToken">Cancellation.</param>
|
||||
/// <returns>A task.</returns>
|
||||
public async Task EnsureLoadedAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (_loaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await _load.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
if (_loaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var state = await authentication.GetAuthenticationStateAsync().ConfigureAwait(false);
|
||||
Actor = SessionCookie.ActorOf(state.User);
|
||||
DisplayName = state.User.FindFirst(SessionCookie.DisplayNameClaim)?.Value ?? Actor?.UserName ?? string.Empty;
|
||||
if (Actor is not null)
|
||||
{
|
||||
Permissions = await permissions.GetAsync(Actor, cancellationToken).ConfigureAwait(false);
|
||||
Preferences = await settings.GetPreferencesAsync(Actor, cancellationToken).ConfigureAwait(false);
|
||||
var all = await companies.ListAsync(cancellationToken).ConfigureAwait(false);
|
||||
Company = Actor.CompanyCode is { } code ? all.FirstOrDefault(c => string.Equals(c.Code, code, StringComparison.OrdinalIgnoreCase)) : null;
|
||||
SwitchableCompanies = Actor.IsInstanceAccount ? [.. all.Where(c => c.Status != CompanyStatus.Disabled).OrderBy(c => c.Name, StringComparer.CurrentCulture)] : [];
|
||||
}
|
||||
|
||||
_loaded = true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_load.Release();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Whether a menu entry is visible: licensed module, permission and audience.</summary>
|
||||
/// <param name="item">The entry.</param>
|
||||
/// <returns><see langword="true"/> when the user may see it.</returns>
|
||||
public bool CanSee(MenuItem item)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(item);
|
||||
if (Actor is null || !licenses.IsModuleActive(item.Module))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.Audience == MenuAudience.InstanceAccounts && !Actor.IsInstanceAccount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return item.Permission is null || Permissions.Allows(item.Permission);
|
||||
}
|
||||
|
||||
/// <summary>Saves new preferences and tells the shell.</summary>
|
||||
/// <param name="preferences">The preferences.</param>
|
||||
/// <param name="cancellationToken">Cancellation.</param>
|
||||
/// <returns>A task.</returns>
|
||||
public async Task SavePreferencesAsync(UserPreferences preferences, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(preferences);
|
||||
Preferences = preferences;
|
||||
if (Actor is not null)
|
||||
{
|
||||
await settings.SavePreferencesAsync(Actor, preferences, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Changed?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>Saves one setting of the user (open tabs, layouts...).</summary>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="value">The value, or <see langword="null"/> to remove it.</param>
|
||||
/// <param name="cancellationToken">Cancellation.</param>
|
||||
/// <returns>A task.</returns>
|
||||
public Task SaveSettingAsync(string key, string? value, CancellationToken cancellationToken = default) =>
|
||||
Actor is null ? Task.CompletedTask : settings.SetAsync(Actor, key, value, cancellationToken);
|
||||
|
||||
/// <summary>Reads one setting of the user.</summary>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="cancellationToken">Cancellation.</param>
|
||||
/// <returns>The value, or <see langword="null"/>.</returns>
|
||||
public Task<string?> ReadSettingAsync(string key, CancellationToken cancellationToken = default) =>
|
||||
Actor is null ? Task.FromResult<string?>(null) : settings.GetAsync(Actor, key, cancellationToken);
|
||||
|
||||
/// <summary>The level of the user as a text key (<c>Shell.Level.*</c>).</summary>
|
||||
public string LevelKey => Actor?.Level switch
|
||||
{
|
||||
UserLevel.SuperUser => "Shell.Level.SuperUser",
|
||||
UserLevel.Administrator => "Shell.Level.Administrator",
|
||||
_ => "Shell.Level.User",
|
||||
};
|
||||
|
||||
/// <summary>Up to two initials of a name: <c>Alberto Balbo</c> gives <c>AB</c>.</summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <returns>The initials, upper case.</returns>
|
||||
public static string InitialsOf(string? name)
|
||||
{
|
||||
var parts = (name ?? string.Empty).Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
var initials = parts.Length switch
|
||||
{
|
||||
0 => "?",
|
||||
1 => parts[0][..Math.Min(2, parts[0].Length)],
|
||||
_ => string.Concat(parts[0][0], parts[^1][0]),
|
||||
};
|
||||
return initials.ToUpperInvariant();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose() => _load.Dispose();
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Khaemhat.Web.Shell;
|
||||
|
||||
/// <summary>
|
||||
/// One open page of the tab area (SPEC §10.2). The page component stays alive while the tab is open: the layout keeps
|
||||
/// rendering its content, hidden when another tab is active.
|
||||
/// </summary>
|
||||
public sealed class KhTab
|
||||
{
|
||||
private readonly TabService _owner;
|
||||
|
||||
internal KhTab(TabService owner, string path, string url)
|
||||
{
|
||||
_owner = owner;
|
||||
Path = path;
|
||||
Url = url;
|
||||
Id = Guid.NewGuid().ToString("N")[..12];
|
||||
}
|
||||
|
||||
/// <summary>A stable identifier, used as render key.</summary>
|
||||
public string Id { get; }
|
||||
|
||||
/// <summary>The path that identifies the tab (without query).</summary>
|
||||
public string Path { get; }
|
||||
|
||||
/// <summary>The full address last shown in the tab (with query).</summary>
|
||||
public string Url { get; internal set; }
|
||||
|
||||
/// <summary>The title set by the page; <see langword="null"/> uses the menu label.</summary>
|
||||
public string? Title { get; private set; }
|
||||
|
||||
/// <summary>The icon set by the page; <see langword="null"/> uses the menu icon.</summary>
|
||||
public string? Icon { get; private set; }
|
||||
|
||||
/// <summary>Whether the page has unsaved changes (orange dot, warning on close).</summary>
|
||||
public bool IsModified { get; private set; }
|
||||
|
||||
/// <summary>The page content.</summary>
|
||||
public RenderFragment? Content { get; internal set; }
|
||||
|
||||
/// <summary>When the tab was last activated, to choose which one to drop past the limit.</summary>
|
||||
public long LastUsed { get; internal set; }
|
||||
|
||||
/// <summary>Sets the title shown in the tab.</summary>
|
||||
/// <param name="title">The title.</param>
|
||||
/// <param name="icon">The icon, or <see langword="null"/>.</param>
|
||||
public void SetTitle(string? title, string? icon = null)
|
||||
{
|
||||
if (Title == title && Icon == icon)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Title = title;
|
||||
Icon = icon;
|
||||
_owner.Notify();
|
||||
}
|
||||
|
||||
/// <summary>Marks the page as modified or saved.</summary>
|
||||
/// <param name="modified">Whether there are unsaved changes.</param>
|
||||
public void SetModified(bool modified)
|
||||
{
|
||||
if (IsModified == modified)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IsModified = modified;
|
||||
_owner.Notify();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>What happened when an address was opened.</summary>
|
||||
public enum TabOpenResult
|
||||
{
|
||||
/// <summary>A tab already open was activated.</summary>
|
||||
Activated = 0,
|
||||
|
||||
/// <summary>A new tab was opened.</summary>
|
||||
Opened = 1,
|
||||
|
||||
/// <summary>A new tab was opened and the least recently used unmodified tab was closed to stay within the limit.</summary>
|
||||
OpenedAndEvicted = 2,
|
||||
|
||||
/// <summary>The limit is reached and every tab has unsaved changes: nothing was opened.</summary>
|
||||
Refused = 3,
|
||||
}
|
||||
|
||||
/// <summary>The open tabs of a circuit (SPEC §10.2): at most <see cref="MaxTabs"/>, one active.</summary>
|
||||
public sealed class TabService
|
||||
{
|
||||
/// <summary>The largest number of open tabs.</summary>
|
||||
public const int MaxTabs = 12;
|
||||
|
||||
/// <summary>The largest number of recent addresses kept for the "recent" menu.</summary>
|
||||
public const int MaxRecent = 10;
|
||||
|
||||
private readonly List<KhTab> _tabs = [];
|
||||
private readonly List<string> _recent = [];
|
||||
private long _clock;
|
||||
|
||||
/// <summary>Raised when tabs open, close, change title or state.</summary>
|
||||
public event Action? Changed;
|
||||
|
||||
/// <summary>The open tabs, in order.</summary>
|
||||
public IReadOnlyList<KhTab> Tabs => _tabs;
|
||||
|
||||
/// <summary>The active tab.</summary>
|
||||
public KhTab? Active { get; private set; }
|
||||
|
||||
/// <summary>The addresses opened most recently, newest first.</summary>
|
||||
public IReadOnlyList<string> Recent => _recent;
|
||||
|
||||
/// <summary>Whether any tab has unsaved changes.</summary>
|
||||
public bool HasModified => _tabs.Exists(t => t.IsModified);
|
||||
|
||||
/// <summary>The path of an address: no query, no fragment, no trailing slash.</summary>
|
||||
/// <param name="url">The address relative to the base (<c>anagrafiche/clienti?x=1</c>) or absolute path.</param>
|
||||
/// <returns>The path, starting with <c>/</c>.</returns>
|
||||
public static string PathOf(string url)
|
||||
{
|
||||
var path = (url ?? string.Empty).Split('?', '#')[0];
|
||||
path = "/" + path.Trim('/');
|
||||
return path;
|
||||
}
|
||||
|
||||
/// <summary>Opens or activates the tab of an address with the page content.</summary>
|
||||
/// <param name="url">The address.</param>
|
||||
/// <param name="content">The page content.</param>
|
||||
/// <returns>What happened.</returns>
|
||||
public TabOpenResult Open(string url, RenderFragment? content)
|
||||
{
|
||||
var path = PathOf(url);
|
||||
var normalized = path + QueryOf(url);
|
||||
var existing = _tabs.Find(t => string.Equals(t.Path, path, StringComparison.OrdinalIgnoreCase));
|
||||
TabOpenResult result;
|
||||
if (existing is not null)
|
||||
{
|
||||
existing.Url = normalized;
|
||||
existing.Content = content ?? existing.Content;
|
||||
result = TabOpenResult.Activated;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = TabOpenResult.Opened;
|
||||
if (_tabs.Count >= MaxTabs)
|
||||
{
|
||||
var victim = _tabs.Where(t => !t.IsModified && t != Active).MinBy(t => t.LastUsed);
|
||||
if (victim is null)
|
||||
{
|
||||
return TabOpenResult.Refused;
|
||||
}
|
||||
|
||||
_tabs.Remove(victim);
|
||||
result = TabOpenResult.OpenedAndEvicted;
|
||||
}
|
||||
|
||||
existing = new KhTab(this, path, normalized) { Content = content };
|
||||
var at = Active is null ? _tabs.Count : _tabs.IndexOf(Active) + 1;
|
||||
_tabs.Insert(at, existing);
|
||||
}
|
||||
|
||||
existing.LastUsed = ++_clock;
|
||||
Active = existing;
|
||||
_recent.RemoveAll(r => string.Equals(PathOf(r), path, StringComparison.OrdinalIgnoreCase));
|
||||
_recent.Insert(0, normalized);
|
||||
if (_recent.Count > MaxRecent)
|
||||
{
|
||||
_recent.RemoveRange(MaxRecent, _recent.Count - MaxRecent);
|
||||
}
|
||||
|
||||
Notify();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>Closes a tab.</summary>
|
||||
/// <param name="tab">The tab.</param>
|
||||
/// <returns>The address to show next when the closed tab was active, otherwise <see langword="null"/>.</returns>
|
||||
public string? Close(KhTab tab)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(tab);
|
||||
var index = _tabs.IndexOf(tab);
|
||||
if (index < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
_tabs.RemoveAt(index);
|
||||
string? next = null;
|
||||
if (tab == Active)
|
||||
{
|
||||
Active = null;
|
||||
var neighbour = _tabs.Count == 0 ? null : _tabs[Math.Min(index, _tabs.Count - 1)];
|
||||
next = neighbour?.Url ?? "/";
|
||||
}
|
||||
|
||||
Notify();
|
||||
return next;
|
||||
}
|
||||
|
||||
/// <summary>The tab after (or before) the active one, cycling.</summary>
|
||||
/// <param name="step">+1 for the next, -1 for the previous.</param>
|
||||
/// <returns>The tab, or <see langword="null"/> with fewer than two tabs.</returns>
|
||||
public KhTab? Neighbour(int step)
|
||||
{
|
||||
if (_tabs.Count < 2 || Active is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var index = _tabs.IndexOf(Active);
|
||||
return _tabs[((index + step) % _tabs.Count + _tabs.Count) % _tabs.Count];
|
||||
}
|
||||
|
||||
/// <summary>Finds the tab of an address.</summary>
|
||||
/// <param name="url">The address.</param>
|
||||
/// <returns>The tab, or <see langword="null"/>.</returns>
|
||||
public KhTab? Find(string url)
|
||||
{
|
||||
var path = PathOf(url);
|
||||
return _tabs.Find(t => string.Equals(t.Path, path, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
internal void Notify() => Changed?.Invoke();
|
||||
|
||||
private static string QueryOf(string url)
|
||||
{
|
||||
var index = (url ?? string.Empty).IndexOf('?', StringComparison.Ordinal);
|
||||
return index < 0 ? string.Empty : url![index..].Split('#')[0];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using System.Globalization;
|
||||
using Khaemhat.Application.Preferences;
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
namespace Khaemhat.Web.Shell;
|
||||
|
||||
/// <summary>
|
||||
/// Applies the interface preferences of SPEC §10.6 to the root element: <c>data-theme</c>, <c>data-accent</c>,
|
||||
/// <c>data-density</c>, <c>data-text-size</c> and the switches. The first page render writes them on the server
|
||||
/// (<c>App.razor</c>); changes made in the session are applied at once through the browser script.
|
||||
/// </summary>
|
||||
/// <param name="js">The browser.</param>
|
||||
/// <param name="session">The shell session.</param>
|
||||
public sealed class ThemeService(IJSRuntime js, ShellSession session)
|
||||
{
|
||||
/// <summary>The root attributes of some preferences.</summary>
|
||||
/// <param name="preferences">The preferences; <see langword="null"/> before sign-in (system theme).</param>
|
||||
/// <returns>The attributes by name.</returns>
|
||||
public static IReadOnlyDictionary<string, string> RootAttributes(UserPreferences? preferences)
|
||||
{
|
||||
var p = preferences ?? UserPreferences.Default;
|
||||
return new Dictionary<string, string>(StringComparer.Ordinal)
|
||||
{
|
||||
["data-theme"] = p.ThemeAttribute,
|
||||
["data-accent"] = p.Accent,
|
||||
["data-density"] = p.DensityAttribute,
|
||||
["data-text-size"] = p.TextSize.ToString(CultureInfo.InvariantCulture),
|
||||
["data-tabular"] = p.TabularNumbers ? "on" : "off",
|
||||
["data-motion"] = p.ReducedMotion ? "reduced" : "full",
|
||||
["data-tooltips"] = p.Tooltips ? "on" : "off",
|
||||
["data-row-hover"] = p.RowHover ? "on" : "off",
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Applies preferences to the page without saving them (live preview).</summary>
|
||||
/// <param name="preferences">The preferences.</param>
|
||||
/// <returns>A task.</returns>
|
||||
public async Task PreviewAsync(UserPreferences preferences)
|
||||
{
|
||||
try
|
||||
{
|
||||
await js.InvokeVoidAsync("khaemhat.applyRoot", RootAttributes(preferences)).ConfigureAwait(false);
|
||||
}
|
||||
catch (JSDisconnectedException)
|
||||
{
|
||||
// The page was closed.
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Applies and saves preferences.</summary>
|
||||
/// <param name="preferences">The preferences.</param>
|
||||
/// <returns>A task.</returns>
|
||||
public async Task ApplyAsync(UserPreferences preferences)
|
||||
{
|
||||
await PreviewAsync(preferences).ConfigureAwait(false);
|
||||
await session.SavePreferencesAsync(preferences).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>The quick switch of the top bar: dark when the current theme is light or automatic, light otherwise.</summary>
|
||||
/// <returns>A task.</returns>
|
||||
public Task ToggleDarkAsync()
|
||||
{
|
||||
var current = session.Preferences;
|
||||
var next = current.Theme is ThemeMode.Dark ? ThemeMode.Light : ThemeMode.Dark;
|
||||
return ApplyAsync(current with { Theme = next });
|
||||
}
|
||||
}
|
||||
@@ -1,82 +1,135 @@
|
||||
/* Khaemhat: minimal styles of M0. The full token set (tokens.css from docs/mockups/mockup.css) arrives in M3. */
|
||||
:root {
|
||||
--kh-font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
|
||||
--kh-brand: #C8962E;
|
||||
--kh-brand-deep: #8B6318;
|
||||
--kh-topbar: #17243A;
|
||||
--kh-bg: #F3F5F8;
|
||||
--kh-err: #C2453A;
|
||||
}
|
||||
/* Khaemhat: styles of the pages built so far, on top of css/tokens.css and css/components.css. Colours come from the
|
||||
tokens, so every page follows the theme, the accent and the text size of the user. */
|
||||
|
||||
/* Without data-accent (a page rendered before the preferences are known) the default accent applies. */
|
||||
:root:not([data-accent]) { --kh-accent: #1F5FA8; --kh-accent-strong: #174A85; --kh-accent-soft: #E3ECF8; --kh-accent-text: #174A85; }
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
html, body { margin: 0; height: 100%; }
|
||||
body { font-family: var(--kh-font); font-size: 13px; background: var(--kh-bg); -webkit-font-smoothing: antialiased; }
|
||||
body { font-family: var(--kh-font); font-size: var(--kh-fs); background: var(--kh-bg); color: var(--kh-text); -webkit-font-smoothing: antialiased; }
|
||||
|
||||
.kh-construction { min-height: 100vh; display: grid; place-items: center; padding: 32px;
|
||||
background: radial-gradient(1200px 600px at 20% 10%, #243A5E 0%, #17243A 55%, #0F1826 100%); color: #E8EDF5; }
|
||||
.kh-construction .hero { max-width: 560px; text-align: center; }
|
||||
.kh-construction .mark { width: 96px; height: 96px; border-radius: 22px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
|
||||
.kh-construction h1 { font-size: 40px; letter-spacing: -.8px; margin: 26px 0 8px; font-weight: 650; }
|
||||
.kh-construction h1 .ver { font-size: 15px; font-weight: 600; color: var(--kh-brand); vertical-align: middle; margin-left: 6px; }
|
||||
.kh-construction .lead { font-size: 15px; color: #B8C5DA; line-height: 1.5; margin: 0; }
|
||||
.kh-construction .state { margin: 22px auto 0; padding: 12px 16px; border-radius: 10px; font-size: 13px; color: #D5DEEB;
|
||||
background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); }
|
||||
.kh-construction .links { list-style: none; padding: 0; margin: 22px 0 0; display: flex; gap: 18px; justify-content: center; }
|
||||
.kh-construction a { color: #F0C86A; text-decoration: none; font-weight: 600; }
|
||||
.kh-construction a:hover { text-decoration: underline; }
|
||||
.kh-construction .build { margin-top: 28px; font-size: 11.5px; color: #8391A3; font-variant-numeric: tabular-nums; }
|
||||
|
||||
#blazor-error-ui { background: #FADEDC; color: #1E2733; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
|
||||
#blazor-error-ui { background: var(--kh-err-soft); color: var(--kh-err-text); bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
|
||||
display: none; left: 0; padding: .6rem 1.25rem .7rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
|
||||
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
|
||||
|
||||
/* Sign-in pages (mockups 001-003): brand panel on the left, form card on the right. */
|
||||
.kh-auth { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 52%) 1fr; color: #1E2733; }
|
||||
.kh-auth .brand { display: flex; flex-direction: column; justify-content: space-between; padding: 48px 44px 36px; color: #E8EDF5;
|
||||
/* ---- the page shown while the instance starts or is in maintenance (Middleware, without the theme files) ---- */
|
||||
.kh-unavailable { min-height: 100vh; display: grid; place-items: center; padding: 32px; text-align: center; color: #E8EDF5;
|
||||
background: radial-gradient(1200px 600px at 20% 10%, #243A5E 0%, #17243A 55%, #0F1826 100%); font-family: "Segoe UI", system-ui, sans-serif; }
|
||||
.kh-unavailable section { max-width: 560px; }
|
||||
.kh-unavailable img { border-radius: 22px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
|
||||
.kh-unavailable h1 { font-size: 36px; margin: 22px 0 8px; font-weight: 650; }
|
||||
.kh-unavailable p { margin: 0; padding: 12px 16px; border-radius: 10px; color: #D5DEEB; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); }
|
||||
|
||||
/* ---- messages: not found, access denied, error, coming soon ---- */
|
||||
.kh-message { max-width: 560px; margin: 48px auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
|
||||
.kh-message > svg.i.lg { width: 40px; height: 40px; color: var(--kh-accent); }
|
||||
.kh-message h1 { font-size: var(--kh-fs-xl); margin: 4px 0 0; font-weight: 650; }
|
||||
.kh-message .lead { color: var(--kh-text-2); line-height: 1.5; margin: 0; }
|
||||
.kh-auth .kh-message { margin: 0 auto; }
|
||||
.kh-chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
|
||||
.kh-actions { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
|
||||
.muted { color: var(--kh-text-3); }
|
||||
|
||||
/* ---- home ---- */
|
||||
.kh-areas { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
|
||||
.kh-area { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--kh-border); border-radius: var(--kh-radius-lg);
|
||||
color: var(--kh-text); text-decoration: none; background: var(--kh-surface); }
|
||||
.kh-area:hover { border-color: var(--kh-accent); background: var(--kh-row-hover); }
|
||||
.kh-area .ico-box { width: 30px; height: 30px; }
|
||||
.kh-area .grow { font-weight: 500; }
|
||||
|
||||
/* ---- profile (mockup 008) ---- */
|
||||
fieldset.fgroup { margin: 0; padding: 0; min-width: 0; }
|
||||
fieldset.fgroup > legend.fgh { float: left; width: 100%; }
|
||||
fieldset.fgroup > legend + * { clear: both; }
|
||||
fieldset.fgroup > :not(legend) { margin: 10px 11px; }
|
||||
.kh-choices { display: flex; flex-wrap: wrap; gap: 10px; }
|
||||
button.themecard { padding: 0; text-align: left; color: var(--kh-text); background: var(--kh-surface); }
|
||||
.themecard .pv .tb { display: block; } .themecard .pv .sb { display: block; } .themecard .pv .ct { background: var(--pv-bg); }
|
||||
.themecard .pv .tb { background: var(--pv-top); } .themecard .pv .sb { background: var(--pv-side); border-right: 1px solid var(--pv-line); }
|
||||
.themecard .pv .ct i { background: var(--pv-line); } .themecard .pv .ct i:first-child { width: 60%; background: var(--kh-accent); }
|
||||
.themecard .lbl .muted { margin-left: auto; font-size: 11px; }
|
||||
.kh-pv-light { --pv-top: #17243A; --pv-side: #FFFFFF; --pv-bg: #F3F5F8; --pv-line: #DDE3EA; }
|
||||
.kh-pv-dark { --pv-top: #0E131A; --pv-side: #171C23; --pv-bg: #12161C; --pv-line: #2E3744; }
|
||||
.kh-pv-auto { --pv-top: #17243A; --pv-side: #FFFFFF; --pv-bg: linear-gradient(135deg, #F3F5F8 50%, #12161C 50%); --pv-line: #9AA6B4; }
|
||||
.kh-pv-high-contrast { --pv-top: #000000; --pv-side: #FFFFFF; --pv-bg: #FFFFFF; --pv-line: #000000; }
|
||||
button.sw { text-align: left; color: var(--kh-text); }
|
||||
.sw .c.kh-acc-nilo { background: #1F5FA8; } .sw .c.kh-acc-lapislazzuli { background: #3F51B5; } .sw .c.kh-acc-malachite { background: #1E8E5A; }
|
||||
.sw .c.kh-acc-turchese { background: #0F8A96; } .sw .c.kh-acc-ocra { background: #C27A1A; } .sw .c.kh-acc-corniola { background: #C2453A; }
|
||||
.sw .c.kh-acc-ametista { background: #7E57C2; } .sw .c.kh-acc-grafite { background: #4B5563; }
|
||||
.kh-seg { display: inline-flex; border: 1px solid var(--kh-border-strong); border-radius: var(--kh-radius); overflow: hidden; align-self: flex-start; }
|
||||
.kh-seg button { border: 0; border-right: 1px solid var(--kh-border); background: var(--kh-surface); color: var(--kh-text-2); font: inherit; font-size: 12.5px;
|
||||
padding: 6px 12px; cursor: pointer; }
|
||||
.kh-seg button:last-child { border-right: 0; }
|
||||
.kh-seg button.on { background: var(--kh-accent-soft); color: var(--kh-accent-text); font-weight: 600; }
|
||||
.kh-switches { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 4px 16px; }
|
||||
.kh-switch-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 4px; border: 0; border-bottom: 1px solid var(--kh-border);
|
||||
background: transparent; font: inherit; color: var(--kh-text); text-align: left; cursor: pointer; }
|
||||
.kh-switch-row .t { display: block; font-weight: 500; }
|
||||
.kh-switch-row .s { display: block; font-size: var(--kh-fs-sm); color: var(--kh-text-3); }
|
||||
.kh-radios { display: flex; flex-direction: column; gap: 2px; }
|
||||
.kh-radios .chk { cursor: pointer; }
|
||||
.kh-pick { max-width: 360px; }
|
||||
.kh-input { height: 30px; border: 1px solid var(--kh-border-strong); border-radius: var(--kh-radius); background: var(--kh-input); color: var(--kh-text);
|
||||
padding: 0 8px; font: inherit; }
|
||||
.kh-inset { margin: 0 14px 14px; }
|
||||
.kh-h2 { font-size: var(--kh-fs-lg); font-weight: 600; margin: 6px 0 0; }
|
||||
.kh-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
|
||||
.kh-table th { text-align: left; font-weight: 600; color: var(--kh-text-2); font-size: var(--kh-fs-sm); padding: 6px 10px; border-bottom: 1px solid var(--kh-border-strong); }
|
||||
.kh-table td { padding: 7px 10px; border-bottom: 1px solid var(--kh-border); vertical-align: middle; }
|
||||
.kh-table td kbd + kbd { margin-left: 6px; }
|
||||
.kh-table .badge { margin-left: 6px; }
|
||||
.kh-nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
|
||||
/* The heading focused after navigation (FocusOnNavigate) is not a control: no focus ring. */
|
||||
h1[tabindex="-1"]:focus { outline: none; box-shadow: none; }
|
||||
|
||||
/* ---- sign-in pages (mockups 001-003): brand panel on the left, form card on the right ---- */
|
||||
.kh-auth { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 52%) 1fr; color: var(--kh-text); }
|
||||
.kh-auth .side { display: flex; flex-direction: column; justify-content: space-between; padding: 48px 44px 36px; color: #E8EDF5;
|
||||
background: radial-gradient(1100px 620px at 15% 0%, #243A5E 0%, #17243A 55%, #0F1826 100%); }
|
||||
.kh-auth .brand .mark { border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
|
||||
.kh-auth .brand h2 { font-size: 30px; letter-spacing: -.5px; margin: 18px 0 10px; font-weight: 650; }
|
||||
.kh-auth .brand p { max-width: 460px; color: #B8C5DA; font-size: 14px; line-height: 1.5; margin: 0; }
|
||||
.kh-auth .side .mark { border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
|
||||
.kh-auth .side h2 { font-size: 30px; letter-spacing: -.5px; margin: 18px 0 10px; font-weight: 650; }
|
||||
.kh-auth .side p { max-width: 460px; color: #B8C5DA; font-size: 14px; line-height: 1.5; margin: 0; }
|
||||
.kh-auth .features { list-style: none; margin: 32px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
|
||||
.kh-auth .features li { padding: 10px 12px; border-radius: 8px; font-size: 11.5px; color: #B8C5DA; line-height: 1.4;
|
||||
background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .09); }
|
||||
.kh-auth .features strong { display: block; color: #E8EDF5; font-weight: 600; margin-bottom: 2px; }
|
||||
.kh-auth .panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 24px; background: var(--kh-bg); }
|
||||
.kh-auth .form-side { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 24px; background: var(--kh-bg); }
|
||||
.kh-auth .card { width: 100%; max-width: 380px; }
|
||||
.kh-auth h1 { font-size: 20px; margin: 0 0 4px; font-weight: 650; }
|
||||
.kh-auth .sub { color: #5B6776; margin: 0 0 18px; line-height: 1.45; }
|
||||
.kh-auth footer { margin-top: 28px; font-size: 11.5px; color: #8A95A3; }
|
||||
.kh-auth footer a { color: #1F5FA8; text-decoration: none; }
|
||||
.kh-auth .sub { color: var(--kh-text-2); margin: 0 0 18px; line-height: 1.45; }
|
||||
.kh-auth footer { margin-top: 28px; font-size: 11.5px; color: var(--kh-text-3); }
|
||||
.kh-auth footer a { color: var(--kh-accent-text); text-decoration: none; }
|
||||
|
||||
.kh-form { display: flex; flex-direction: column; gap: 4px; }
|
||||
.kh-form label { font-size: 11.5px; font-weight: 600; color: #5B6776; margin-top: 8px; }
|
||||
.kh-form label { font-size: 11.5px; font-weight: 600; color: var(--kh-text-2); margin-top: 8px; }
|
||||
.kh-form input[type=text], .kh-form input[type=password], .kh-form input:not([type]), .kh-form select {
|
||||
height: 32px; padding: 0 10px; border: 1px solid #C5CDD7; border-radius: 6px; background: #FFF; font: inherit; color: inherit; }
|
||||
.kh-form input:focus, .kh-form select:focus { outline: 2px solid #1F5FA8; outline-offset: -1px; border-color: #1F5FA8; }
|
||||
.kh-form .check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: #1E2733; margin-top: 12px; }
|
||||
height: 32px; padding: 0 10px; border: 1px solid var(--kh-border-strong); border-radius: 6px; background: var(--kh-input); font: inherit; color: inherit; }
|
||||
.kh-form input:focus, .kh-form select:focus { outline: 2px solid var(--kh-accent); outline-offset: -1px; border-color: var(--kh-accent); }
|
||||
.kh-form .check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--kh-text); margin-top: 12px; }
|
||||
.kh-form .otp { height: 44px; font-size: 22px; letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; }
|
||||
.kh-form .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
|
||||
.kh-form .row .kh-btn { margin-top: 0; }
|
||||
.kh-form .hint { font-size: 11.5px; color: #8A95A3; }
|
||||
.kh-form .hint { font-size: 11.5px; color: var(--kh-text-3); }
|
||||
.kh-btn { display: inline-flex; align-items: center; justify-content: center; height: 32px; padding: 0 14px; margin-top: 16px; border-radius: 6px;
|
||||
border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
|
||||
.kh-btn.primary { background: #1F5FA8; color: #FFF; align-self: flex-start; }
|
||||
.kh-btn.primary:hover { background: #174A85; }
|
||||
.kh-btn.ghost { background: transparent; color: #F0C86A; border-color: rgba(240, 200, 106, .5); }
|
||||
.kh-btn.primary { background: var(--kh-accent); color: #FFF; align-self: flex-start; }
|
||||
.kh-btn.primary:hover { background: var(--kh-accent-strong); }
|
||||
.kh-alert { padding: 10px 12px; border-radius: 6px; margin: 12px 0; line-height: 1.45; font-size: 12.5px; }
|
||||
.kh-alert.err { background: #FADEDC; color: #9E362D; }
|
||||
.kh-alert.warn { background: #FBEFD9; color: #8B5511; margin-top: 20px; }
|
||||
.kh-alert.info { background: #E3ECF8; color: #174A85; margin-top: 20px; }
|
||||
.kh-rules { margin: 10px 0 0; padding-left: 18px; color: #5B6776; font-size: 11.5px; line-height: 1.6; }
|
||||
.kh-alert.err { background: var(--kh-err-soft); color: var(--kh-err-text); }
|
||||
.kh-alert.warn { background: var(--kh-warn-soft); color: var(--kh-warn-text); margin-top: 20px; }
|
||||
.kh-alert.info { background: var(--kh-info-soft); color: var(--kh-info-text); margin-top: 20px; }
|
||||
.kh-rules { margin: 10px 0 0; padding-left: 18px; color: var(--kh-text-2); font-size: 11.5px; line-height: 1.6; }
|
||||
.kh-secret { margin: 0 0 6px; }
|
||||
.kh-secret dt { font-size: 11.5px; font-weight: 600; color: #5B6776; margin-top: 8px; }
|
||||
.kh-secret dt { font-size: 11.5px; font-weight: 600; color: var(--kh-text-2); margin-top: 8px; }
|
||||
.kh-secret dd { margin: 4px 0 0; }
|
||||
.kh-secret code { font-size: 15px; letter-spacing: 1px; word-break: break-all; }
|
||||
.kh-codes { list-style: none; padding: 0; margin: 0 0 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
|
||||
.kh-codes code { display: block; padding: 6px 8px; background: #FFF; border: 1px solid #DDE3EA; border-radius: 6px; text-align: center; font-size: 14px; }
|
||||
.kh-codes code { display: block; padding: 6px 8px; background: var(--kh-surface); border: 1px solid var(--kh-border); border-radius: 6px; text-align: center; font-size: 14px; }
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.kh-auth { grid-template-columns: 1fr; }
|
||||
.kh-auth .brand { padding: 24px; }
|
||||
.kh-auth .side { padding: 24px; }
|
||||
.kh-auth .features { display: none; }
|
||||
.cols-3 { grid-template-columns: 1fr; }
|
||||
}
|
||||
@@ -0,0 +1,406 @@
|
||||
/* Khaemhat component classes (SPEC §10.1 rule 1): the classes of docs/mockups/mockup.css with the same semantic
|
||||
names, used by the Kh* Razor components. Interaction states the static mockups do not need (real buttons,
|
||||
hover, focus, disabled, hidden tabs) are in interactive.css. */
|
||||
*{box-sizing:border-box} html,body{margin:0;height:100%}
|
||||
body{font-family:var(--kh-font);font-size:var(--kh-fs);color:var(--kh-text);background:var(--kh-bg);-webkit-font-smoothing:antialiased;line-height:1.35}
|
||||
.num{font-variant-numeric:tabular-nums;text-align:right}
|
||||
.mono{font-family:var(--kh-mono)}
|
||||
.muted{color:var(--kh-text-2)} .faint{color:var(--kh-text-3)} .small{font-size:var(--kh-fs-sm)} .b{font-weight:600}
|
||||
.ok{color:var(--kh-ok)} .err{color:var(--kh-err)} .warn{color:var(--kh-warn)} .accent{color:var(--kh-accent-text)}
|
||||
svg.i{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round;flex:none;vertical-align:-3px}
|
||||
svg.i.lg{width:20px;height:20px} svg.i.sm{width:13px;height:13px}
|
||||
|
||||
/* ---- app shell ---- */
|
||||
.app{display:grid;grid-template-rows:var(--kh-topbar-h) 1fr var(--kh-status-h);grid-template-columns:var(--kh-sidebar-w) 1fr;height:100vh;overflow:hidden}
|
||||
.topbar{grid-column:1/3;background:var(--kh-topbar);color:var(--kh-topbar-text);display:flex;align-items:center;padding:0 12px;gap:10px}
|
||||
.brand{display:flex;align-items:center;gap:9px;width:calc(var(--kh-sidebar-w) - 12px);font-weight:600;letter-spacing:.2px;font-size:14.5px}
|
||||
.brand .mark{width:28px;height:28px;border-radius:7px;background:linear-gradient(145deg,var(--kh-brand) 0%,var(--kh-brand-deep) 100%);display:grid;place-items:center}
|
||||
.brand .mark svg{width:18px;height:18px;fill:#FFF8E6}
|
||||
.brand .ver{font-weight:400;color:var(--kh-topbar-muted);font-size:11px;margin-left:2px}
|
||||
.company{display:flex;align-items:center;gap:8px;padding:5px 10px;border-radius:6px;background:rgba(255,255,255,.08);font-weight:500}
|
||||
.company svg.i{color:var(--kh-topbar-muted)}
|
||||
.gsearch{flex:1;max-width:520px;margin:0 auto;display:flex;align-items:center;gap:8px;background:rgba(255,255,255,.1);border:1px solid rgba(255,255,255,.12);padding:6px 10px;border-radius:7px;color:var(--kh-topbar-muted)}
|
||||
.gsearch kbd{margin-left:auto;font:11px var(--kh-mono);background:rgba(255,255,255,.12);padding:1px 6px;border-radius:4px;color:var(--kh-topbar-muted)}
|
||||
.topbar .right{display:flex;align-items:center;gap:6px;margin-left:auto}
|
||||
.tbtn{position:relative;display:grid;place-items:center;width:32px;height:32px;border-radius:7px;color:var(--kh-topbar-text);opacity:.85}
|
||||
.tbtn:hover{background:rgba(255,255,255,.1)}
|
||||
.tbtn .dot{position:absolute;top:6px;right:6px;width:8px;height:8px;border-radius:50%;background:var(--kh-err);border:2px solid var(--kh-topbar)}
|
||||
.avatar{width:30px;height:30px;border-radius:50%;background:var(--kh-accent);color:#fff;display:grid;place-items:center;font-weight:600;font-size:12px}
|
||||
.userbox{display:flex;align-items:center;gap:8px;padding:3px 8px 3px 4px;border-radius:8px;background:rgba(255,255,255,.06)}
|
||||
.userbox .nm{font-size:12.5px;font-weight:500;line-height:1.1} .userbox .rl{font-size:10.5px;color:var(--kh-topbar-muted)}
|
||||
|
||||
.sidebar{background:var(--kh-sidebar);border-right:1px solid var(--kh-border);display:flex;flex-direction:column;overflow:hidden}
|
||||
.sidebar .sec{padding:12px 14px 4px;font-size:10.5px;font-weight:600;letter-spacing:.6px;text-transform:uppercase;color:var(--kh-text-3)}
|
||||
.nav{display:flex;flex-direction:column;gap:1px;padding:4px 8px}
|
||||
.nav a{display:flex;align-items:center;gap:10px;padding:7px 10px;border-radius:7px;color:var(--kh-text-2);text-decoration:none;font-weight:500}
|
||||
.nav a svg.i{color:var(--kh-text-3)}
|
||||
.nav a:hover{background:var(--kh-surface-3);color:var(--kh-text)}
|
||||
.nav a.active{background:var(--kh-accent-soft);color:var(--kh-accent-text)} .nav a.active svg.i{color:var(--kh-accent)}
|
||||
.nav a .cnt{margin-left:auto;font-size:11px;background:var(--kh-surface-3);color:var(--kh-text-2);padding:1px 7px;border-radius:10px}
|
||||
.nav a.active .cnt{background:var(--kh-accent);color:#fff}
|
||||
.nav.sub a{padding:5px 10px 5px 36px;font-weight:400;font-size:12.5px}
|
||||
.sidebar .foot{margin-top:auto;padding:10px 14px;border-top:1px solid var(--kh-border);font-size:11.5px;color:var(--kh-text-3)}
|
||||
|
||||
.main{display:flex;flex-direction:column;min-width:0;overflow:hidden}
|
||||
.tabs-strip{height:var(--kh-tabs-h);display:flex;align-items:flex-end;gap:2px;padding:0 8px;background:var(--kh-surface-3);border-bottom:1px solid var(--kh-border)}
|
||||
.wtab{display:flex;align-items:center;gap:8px;height:30px;padding:0 12px;border-radius:7px 7px 0 0;border:1px solid transparent;border-bottom:none;color:var(--kh-text-2);font-size:12.5px;max-width:260px;white-space:nowrap}
|
||||
.wtab.active{background:var(--kh-surface);border-color:var(--kh-border);color:var(--kh-text);font-weight:500;position:relative;top:1px}
|
||||
.wtab .x{color:var(--kh-text-3);font-size:14px;line-height:1} .wtab .mod{color:var(--kh-warn)}
|
||||
.wtab.add{color:var(--kh-text-3);padding:0 8px}
|
||||
.content{flex:1;overflow:auto;padding:var(--kh-gap);display:flex;flex-direction:column;gap:var(--kh-gap)}
|
||||
.content.scroll{overflow:auto}
|
||||
.statusbar{grid-column:1/3;background:var(--kh-surface);border-top:1px solid var(--kh-border);display:flex;align-items:center;gap:18px;padding:0 12px;font-size:11.5px;color:var(--kh-text-2)}
|
||||
.statusbar .sp{flex:1} .statusbar .live{display:inline-block;width:7px;height:7px;border-radius:50%;background:var(--kh-ok);margin-right:5px}
|
||||
|
||||
/* ---- page header & toolbar ---- */
|
||||
.phead{display:flex;align-items:center;gap:14px;flex-wrap:wrap}
|
||||
.phead h1{font-size:var(--kh-fs-xl);font-weight:600;margin:0;letter-spacing:-.2px}
|
||||
.phead .sub{color:var(--kh-text-2)}
|
||||
.crumbs{font-size:12px;color:var(--kh-text-3)} .crumbs b{color:var(--kh-text-2);font-weight:500}
|
||||
.toolbar{display:flex;align-items:center;gap:6px;background:var(--kh-surface);border:1px solid var(--kh-border);border-radius:var(--kh-radius-lg);padding:6px 8px;box-shadow:var(--kh-shadow);flex-wrap:wrap}
|
||||
.toolbar .sep{width:1px;height:22px;background:var(--kh-border);margin:0 4px}
|
||||
.toolbar .grow{flex:1}
|
||||
.btn{display:inline-flex;align-items:center;gap:6px;height:30px;padding:0 11px;border-radius:var(--kh-radius);border:1px solid var(--kh-border);background:var(--kh-surface);color:var(--kh-text);font:500 12.5px var(--kh-font);white-space:nowrap}
|
||||
.btn svg.i{color:var(--kh-text-2)} .btn:hover{background:var(--kh-surface-2)}
|
||||
.btn.primary{background:var(--kh-accent);border-color:var(--kh-accent);color:#fff} .btn.primary svg.i{color:#fff}
|
||||
.btn.ghost{border-color:transparent;background:transparent} .btn.danger{color:var(--kh-err)} .btn.danger svg.i{color:var(--kh-err)}
|
||||
.btn.sm{height:26px;padding:0 8px;font-size:12px} .btn.icon{padding:0;width:30px;justify-content:center}
|
||||
.btn.disabled{opacity:.45}
|
||||
.btn .kbd{font:10.5px var(--kh-mono);color:var(--kh-text-3);margin-left:2px}
|
||||
.seg{display:inline-flex;border:1px solid var(--kh-border);border-radius:var(--kh-radius);overflow:hidden}
|
||||
.seg span{padding:5px 10px;font-size:12px;color:var(--kh-text-2);border-right:1px solid var(--kh-border)} .seg span:last-child{border-right:0}
|
||||
.seg span.on{background:var(--kh-accent-soft);color:var(--kh-accent-text);font-weight:500}
|
||||
|
||||
/* ---- panels & layout ---- */
|
||||
.panel{background:var(--kh-surface);border:1px solid var(--kh-border);border-radius:var(--kh-radius-lg);box-shadow:var(--kh-shadow);display:flex;flex-direction:column;min-width:0}
|
||||
.panel>.ph{display:flex;align-items:center;gap:10px;padding:9px 14px;border-bottom:1px solid var(--kh-border);font-weight:600;font-size:13px}
|
||||
.panel>.ph .grow{flex:1} .panel>.ph .lnk{font-weight:500;color:var(--kh-accent-text);font-size:12px}
|
||||
.panel>.pb{padding:12px 14px;display:flex;flex-direction:column;gap:10px}
|
||||
.panel>.pb.tight{padding:0}
|
||||
.row{display:flex;gap:var(--kh-gap);align-items:stretch;min-width:0} .row>*{min-width:0} .grow{flex:1}
|
||||
.cols{display:grid;gap:var(--kh-gap)} .cols-2{grid-template-columns:1fr 1fr} .cols-3{grid-template-columns:repeat(3,1fr)} .cols-4{grid-template-columns:repeat(4,1fr)}
|
||||
.split{display:grid;grid-template-columns:320px 1fr;gap:var(--kh-gap);min-height:0;flex:1}
|
||||
.fill{flex:1;min-height:0}
|
||||
|
||||
/* ---- form ---- */
|
||||
.form{display:grid;grid-template-columns:repeat(12,1fr);gap:8px 12px;padding:12px 14px}
|
||||
.form.plain{padding:0}
|
||||
.f{display:flex;flex-direction:column;gap:3px;min-width:0}
|
||||
.f label{font-size:11.5px;color:var(--kh-text-2);font-weight:500;display:flex;gap:4px;align-items:center}
|
||||
.f label .req{color:var(--kh-err)}
|
||||
.f .in{height:30px;border:1px solid var(--kh-border-strong);border-radius:var(--kh-radius);background:var(--kh-input);padding:0 9px;display:flex;align-items:center;gap:7px;color:var(--kh-text);overflow:hidden;white-space:nowrap}
|
||||
.f .in.ro{background:var(--kh-input-ro);border-color:var(--kh-border);color:var(--kh-text-2)}
|
||||
.f .in.focus{border-color:var(--kh-accent);box-shadow:0 0 0 3px var(--kh-accent-soft)}
|
||||
.f .in.err{border-color:var(--kh-err);box-shadow:0 0 0 3px var(--kh-err-soft)}
|
||||
.f .in .ph{color:var(--kh-text-3)} .f .in .desc{color:var(--kh-text-2);overflow:hidden;text-overflow:ellipsis}
|
||||
.f .in .code{font-family:var(--kh-mono);font-size:12px;font-weight:600;color:var(--kh-accent-text)}
|
||||
.f .in .lk{margin-left:auto;display:flex;gap:2px;color:var(--kh-text-3)} .f .in .lk svg.i{width:14px;height:14px}
|
||||
.f .in.ta{height:auto;min-height:56px;align-items:flex-start;padding:6px 9px;white-space:normal;line-height:1.4}
|
||||
.f .hint{font-size:11px;color:var(--kh-text-3)} .f .hint.err{color:var(--kh-err)}
|
||||
.c1{grid-column:span 1}.c2{grid-column:span 2}.c3{grid-column:span 3}.c4{grid-column:span 4}.c5{grid-column:span 5}.c6{grid-column:span 6}.c7{grid-column:span 7}.c8{grid-column:span 8}.c9{grid-column:span 9}.c10{grid-column:span 10}.c12{grid-column:span 12}
|
||||
.chk{display:flex;align-items:center;gap:7px;height:30px;font-size:12.5px}
|
||||
.bx{width:15px;height:15px;border:1px solid var(--kh-border-strong);border-radius:4px;background:var(--kh-input);display:grid;place-items:center;flex:none}
|
||||
.bx.on{background:var(--kh-accent);border-color:var(--kh-accent)} .bx.on svg{width:10px;height:10px;stroke:#fff;stroke-width:3;fill:none}
|
||||
.switch{width:34px;height:18px;border-radius:10px;background:var(--kh-border-strong);position:relative;display:inline-block;vertical-align:middle}
|
||||
.switch::after{content:"";position:absolute;top:2px;left:2px;width:14px;height:14px;border-radius:50%;background:#fff}
|
||||
.switch.on{background:var(--kh-accent)} .switch.on::after{left:18px}
|
||||
.fieldset{border:1px solid var(--kh-border);border-radius:var(--kh-radius-lg);padding:10px 12px 12px;position:relative;margin-top:6px}
|
||||
.fieldset>legend{font-size:11.5px;font-weight:600;color:var(--kh-text-2);padding:0 6px;text-transform:uppercase;letter-spacing:.4px}
|
||||
|
||||
/* ---- tabs (in-page) ---- */
|
||||
.tabs{display:flex;gap:2px;border-bottom:1px solid var(--kh-border);padding:0 10px}
|
||||
.tab{padding:9px 12px;font-size:12.5px;color:var(--kh-text-2);border-bottom:2px solid transparent;margin-bottom:-1px;display:flex;gap:6px;align-items:center}
|
||||
.tab.active{color:var(--kh-accent-text);border-color:var(--kh-accent);font-weight:600}
|
||||
.tab .n{font-size:10.5px;background:var(--kh-surface-3);color:var(--kh-text-2);padding:0 6px;border-radius:9px}
|
||||
.tab .k{font:10px var(--kh-mono);color:var(--kh-text-3)}
|
||||
|
||||
/* ---- grid ---- */
|
||||
.grid{width:100%;border-collapse:separate;border-spacing:0;font-size:12.5px}
|
||||
.grid th{position:sticky;top:0;background:var(--kh-surface-2);color:var(--kh-text-2);font-weight:600;font-size:11.5px;text-align:left;padding:0 10px;height:32px;border-bottom:1px solid var(--kh-border);white-space:nowrap}
|
||||
.grid th.num{text-align:right}
|
||||
.grid th .srt{color:var(--kh-accent);margin-left:3px}
|
||||
.grid td{padding:0 10px;height:var(--kh-row-h);border-bottom:1px solid var(--kh-border);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:380px}
|
||||
.grid tr:nth-child(even) td{background:var(--kh-row-alt)}
|
||||
.grid tr.sel td{background:var(--kh-row-sel)}
|
||||
.grid tr.hl td{background:var(--kh-warn-soft)}
|
||||
.grid tr.edit td{background:var(--kh-surface)}
|
||||
.grid td.ed{box-shadow:inset 0 0 0 2px var(--kh-accent);background:var(--kh-input)!important}
|
||||
.grid td.code{font-family:var(--kh-mono);font-size:12px;color:var(--kh-accent-text);font-weight:600}
|
||||
.grid td.txt{white-space:normal}
|
||||
.grid tfoot td{background:var(--kh-surface-2);font-weight:600;border-top:2px solid var(--kh-border);height:32px}
|
||||
.grid .chkc{width:28px;text-align:center;padding:0}
|
||||
.grid .chkc .bx{margin:0 auto}
|
||||
.grid td.desc-row{color:var(--kh-text-2);font-style:italic}
|
||||
.gridwrap{overflow:auto;flex:1;min-height:0}
|
||||
.gridfoot{display:flex;align-items:center;gap:14px;padding:7px 12px;border-top:1px solid var(--kh-border);font-size:12px;color:var(--kh-text-2);background:var(--kh-surface-2);border-radius:0 0 var(--kh-radius-lg) var(--kh-radius-lg)} .gridfoot>span:first-child{flex:1;min-width:0}
|
||||
.pager{display:inline-flex;gap:2px;margin-left:auto} .pager span{padding:2px 8px;border-radius:5px} .pager span.on{background:var(--kh-accent);color:#fff}
|
||||
.filters{display:flex;gap:8px;align-items:center;flex-wrap:wrap;padding:10px 12px;border-bottom:1px solid var(--kh-border)}
|
||||
.filters .f{flex-direction:row;align-items:center;gap:6px} .filters .f label{white-space:nowrap} .filters .f .in{height:28px;min-width:120px}
|
||||
.chip{display:inline-flex;align-items:center;gap:5px;padding:3px 9px;border-radius:14px;background:var(--kh-accent-soft);color:var(--kh-accent-text);font-size:12px;font-weight:500}
|
||||
.chip .x{opacity:.7}
|
||||
|
||||
/* ---- badges ---- */
|
||||
.badge{display:inline-flex;align-items:center;gap:5px;padding:2px 8px;border-radius:12px;font-size:11px;font-weight:600;line-height:1.5;white-space:nowrap}
|
||||
.badge::before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor}
|
||||
.badge.gray{background:var(--kh-surface-3);color:var(--kh-text-2)}
|
||||
.badge.blue{background:var(--kh-info-soft);color:var(--kh-info-text)}
|
||||
.badge.green{background:var(--kh-ok-soft);color:var(--kh-ok-text)}
|
||||
.badge.amber{background:var(--kh-warn-soft);color:var(--kh-warn-text)}
|
||||
.badge.red{background:var(--kh-err-soft);color:var(--kh-err-text)}
|
||||
.badge.accent{background:var(--kh-accent-soft);color:var(--kh-accent-text)}
|
||||
|
||||
/* ---- tiles / KPI ---- */
|
||||
.tile{background:var(--kh-surface);border:1px solid var(--kh-border);border-radius:var(--kh-radius-lg);padding:12px 14px;box-shadow:var(--kh-shadow);display:flex;flex-direction:column;gap:4px;position:relative;overflow:hidden}
|
||||
.tile .t{font-size:11.5px;color:var(--kh-text-2);font-weight:500;display:flex;align-items:center;gap:6px}
|
||||
.tile .v{font-size:22px;font-weight:600;letter-spacing:-.4px;font-variant-numeric:tabular-nums}
|
||||
.tile .d{font-size:11.5px;color:var(--kh-text-3)} .tile .d b{font-weight:600}
|
||||
.tile .spark{position:absolute;right:12px;bottom:10px;width:90px;height:30px}
|
||||
.tile .spark polyline{fill:none;stroke:var(--kh-accent);stroke-width:1.8}
|
||||
.tile .spark polygon{fill:var(--kh-accent-soft)}
|
||||
.tile.warn{border-left:3px solid var(--kh-warn)} .tile.err{border-left:3px solid var(--kh-err)} .tile.ok{border-left:3px solid var(--kh-ok)} .tile.acc{border-left:3px solid var(--kh-accent)}
|
||||
|
||||
/* ---- misc ---- */
|
||||
.callout{display:flex;gap:10px;padding:10px 12px;border-radius:var(--kh-radius-lg);border:1px solid var(--kh-border);background:var(--kh-surface-2);font-size:12.5px;align-items:flex-start}
|
||||
.callout.info{background:var(--kh-info-soft);border-color:transparent} .callout.warn{background:var(--kh-warn-soft);border-color:transparent} .callout.err{background:var(--kh-err-soft);border-color:transparent} .callout.ok{background:var(--kh-ok-soft);border-color:transparent}
|
||||
.callout svg.i{margin-top:1px}
|
||||
.kv{display:grid;grid-template-columns:auto 1fr;gap:4px 14px;font-size:12.5px} .kv dt{color:var(--kh-text-2)} .kv dd{margin:0;font-weight:500}
|
||||
.list{display:flex;flex-direction:column} .list .li{display:flex;align-items:center;gap:10px;padding:8px 14px;border-bottom:1px solid var(--kh-border);font-size:12.5px} .list .li:last-child{border-bottom:0}
|
||||
.list .li .grow{flex:1;min-width:0} .list .li .t{font-weight:500} .list .li .s{color:var(--kh-text-3);font-size:11.5px}
|
||||
.ico-box{width:30px;height:30px;border-radius:8px;display:grid;place-items:center;background:var(--kh-accent-soft);color:var(--kh-accent-text)}
|
||||
.ico-box.warn{background:var(--kh-warn-soft);color:var(--kh-warn)} .ico-box.err{background:var(--kh-err-soft);color:var(--kh-err)} .ico-box.ok{background:var(--kh-ok-soft);color:var(--kh-ok)}
|
||||
.bar{height:8px;border-radius:4px;background:var(--kh-surface-3);overflow:hidden} .bar i{display:block;height:100%;background:var(--kh-accent);border-radius:4px}
|
||||
.bar.ok i{background:var(--kh-ok)} .bar.warn i{background:var(--kh-warn)} .bar.err i{background:var(--kh-err)}
|
||||
.totals{display:grid;grid-template-columns:auto auto;gap:4px 18px;font-size:12.5px;justify-content:end;align-content:start}
|
||||
.totals span:nth-child(odd){color:var(--kh-text-2);text-align:right} .totals span:nth-child(even){text-align:right;font-variant-numeric:tabular-nums;min-width:100px}
|
||||
.totals .big{font-size:17px;font-weight:600;border-top:1px solid var(--kh-border);padding-top:5px}
|
||||
.totals .big+span{font-size:17px;font-weight:600;border-top:1px solid var(--kh-border);padding-top:5px}
|
||||
.kbdhint{display:inline-flex;gap:3px;align-items:center;font:10.5px var(--kh-mono);color:var(--kh-text-3)} .kbdhint kbd{border:1px solid var(--kh-border-strong);border-bottom-width:2px;padding:0 4px;border-radius:3px;background:var(--kh-surface)}
|
||||
.steps{display:flex;align-items:center;gap:0;padding:4px 0}
|
||||
.step{display:flex;align-items:center;gap:8px;color:var(--kh-text-3);font-size:12.5px}
|
||||
.step .n{width:24px;height:24px;border-radius:50%;border:1px solid var(--kh-border-strong);display:grid;place-items:center;font-size:12px;font-weight:600}
|
||||
.step.done .n{background:var(--kh-ok);border-color:var(--kh-ok);color:#fff} .step.on .n{background:var(--kh-accent);border-color:var(--kh-accent);color:#fff} .step.on{color:var(--kh-text);font-weight:600}
|
||||
.step .ln{width:60px;height:1px;background:var(--kh-border-strong);margin:0 10px}
|
||||
|
||||
/* ---- overlay / dialog ---- */
|
||||
.overlay{position:fixed;inset:0;background:rgba(10,14,20,.45);display:grid;place-items:start center;padding-top:80px;z-index:10}
|
||||
.dialog{background:var(--kh-surface);border:1px solid var(--kh-border);border-radius:12px;box-shadow:var(--kh-shadow-lg);width:860px;max-width:94vw;display:flex;flex-direction:column;overflow:hidden}
|
||||
.dialog .dh{display:flex;align-items:center;gap:10px;padding:12px 16px;border-bottom:1px solid var(--kh-border);font-weight:600;font-size:14px}
|
||||
.dialog .dh .grow{flex:1}
|
||||
.dialog .db{padding:14px 16px;display:flex;flex-direction:column;gap:10px}
|
||||
.dialog .df{display:flex;gap:8px;padding:12px 16px;border-top:1px solid var(--kh-border);background:var(--kh-surface-2);justify-content:flex-end}
|
||||
.palette{width:640px;padding:0}
|
||||
.palette .pin{display:flex;align-items:center;gap:10px;padding:12px 16px;border-bottom:1px solid var(--kh-border);font-size:15px}
|
||||
.palette .pin .ph{color:var(--kh-text-3)}
|
||||
.palette .grp{padding:6px 10px 2px;font-size:10.5px;text-transform:uppercase;letter-spacing:.5px;color:var(--kh-text-3);font-weight:600}
|
||||
.palette .hit{display:flex;align-items:center;gap:10px;padding:7px 12px;border-radius:7px;margin:0 6px}
|
||||
.palette .hit.on{background:var(--kh-accent-soft)} .palette .hit .k{margin-left:auto;font:10.5px var(--kh-mono);color:var(--kh-text-3)}
|
||||
|
||||
/* ---- kanban ---- */
|
||||
.kanban{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(230px,1fr);gap:10px;flex:1;min-height:0;overflow:auto}
|
||||
.kcol{background:var(--kh-surface-3);border-radius:var(--kh-radius-lg);display:flex;flex-direction:column;min-height:0}
|
||||
.kcol .kh{display:flex;align-items:center;gap:8px;padding:10px 12px;font-weight:600;font-size:12.5px}
|
||||
.kcol .kh .n{margin-left:auto;font-size:11px;color:var(--kh-text-2);background:var(--kh-surface);padding:1px 7px;border-radius:9px}
|
||||
.kcol .kh .sum{font-size:11px;color:var(--kh-text-3);font-weight:400}
|
||||
.kcol .kb{display:flex;flex-direction:column;gap:8px;padding:0 8px 8px;overflow:auto}
|
||||
.card{background:var(--kh-surface);border:1px solid var(--kh-border);border-radius:8px;padding:9px 10px;box-shadow:var(--kh-shadow);display:flex;flex-direction:column;gap:5px}
|
||||
.card .ct{font-weight:600;font-size:12.5px} .card .badge{align-self:flex-start} .card .cs{color:var(--kh-text-2);font-size:11.5px}
|
||||
.card .cf{display:flex;align-items:center;gap:6px;font-size:11px;color:var(--kh-text-3)} .card .cf .amt{margin-left:auto;font-weight:600;color:var(--kh-text)}
|
||||
.mini-av{width:20px;height:20px;border-radius:50%;background:var(--kh-accent-soft);color:var(--kh-accent-text);display:grid;place-items:center;font-size:9.5px;font-weight:700}
|
||||
|
||||
/* ---- timeline ---- */
|
||||
.timeline{display:flex;flex-direction:column;gap:0;padding:4px 0}
|
||||
.tl{display:grid;grid-template-columns:22px 1fr;gap:10px;padding:6px 0;position:relative}
|
||||
.tl::before{content:"";position:absolute;left:10px;top:28px;bottom:-8px;width:1px;background:var(--kh-border)} .tl:last-child::before{display:none}
|
||||
.tl .dotn{width:22px;height:22px;border-radius:50%;background:var(--kh-accent-soft);color:var(--kh-accent-text);display:grid;place-items:center} .tl .dotn svg.i{width:12px;height:12px}
|
||||
.tl .tt{font-size:12.5px} .tl .tt b{font-weight:600} .tl .ts{font-size:11px;color:var(--kh-text-3)}
|
||||
|
||||
/* ---- tree ---- */
|
||||
.tree{font-size:12.5px} .tree .tn{display:flex;align-items:center;gap:6px;height:28px;padding:0 8px;border-radius:5px;white-space:nowrap}
|
||||
.tree .tn.sel{background:var(--kh-accent-soft);color:var(--kh-accent-text);font-weight:600}
|
||||
.tree .tn .tw{color:var(--kh-text-3);width:12px;font-size:10px} .tree .tn .cd{font-family:var(--kh-mono);font-size:11.5px;color:var(--kh-text-2);min-width:64px}
|
||||
.tree .tn .bal{margin-left:auto;font-variant-numeric:tabular-nums;color:var(--kh-text-2)}
|
||||
.lv1{padding-left:8px} .lv2{padding-left:26px} .lv3{padding-left:44px} .lv4{padding-left:62px}
|
||||
|
||||
/* ---- calendar ---- */
|
||||
.cal{display:grid;grid-template-columns:52px repeat(5,1fr);border:1px solid var(--kh-border);border-radius:var(--kh-radius-lg);overflow:hidden;background:var(--kh-surface);align-self:flex-start;width:100%}
|
||||
.cal .ch{background:var(--kh-surface-2);border-bottom:1px solid var(--kh-border);border-right:1px solid var(--kh-border);padding:8px;font-size:12px;font-weight:600;text-align:center}
|
||||
.cal .ch .d{font-size:18px;font-weight:600;display:block} .cal .ch.today .d{color:var(--kh-accent)}
|
||||
.cal .ct{border-right:1px solid var(--kh-border);border-bottom:1px solid var(--kh-border);font-size:10.5px;color:var(--kh-text-3);text-align:right;padding:3px 6px;height:44px}
|
||||
.cal .cc{border-right:1px solid var(--kh-border);border-bottom:1px solid var(--kh-border);height:44px;position:relative}
|
||||
.ev{position:absolute;left:3px;right:3px;border-radius:5px;padding:4px 6px;font-size:11px;line-height:1.25;border-left:3px solid var(--kh-accent);background:var(--kh-accent-soft);color:var(--kh-accent-text);overflow:hidden}
|
||||
.ev.g{border-color:var(--kh-ok);background:var(--kh-ok-soft);color:var(--kh-ok-text)} .ev.a{border-color:var(--kh-warn);background:var(--kh-warn-soft);color:var(--kh-warn-text)} .ev.r{border-color:var(--kh-err);background:var(--kh-err-soft);color:var(--kh-err-text)}
|
||||
|
||||
/* ---- swatches ---- */
|
||||
.swatches{display:flex;gap:10px;flex-wrap:wrap}
|
||||
.sw{width:112px;border:2px solid var(--kh-border);border-radius:10px;padding:8px;display:flex;flex-direction:column;gap:6px;background:var(--kh-surface)}
|
||||
.sw.on{border-color:var(--kh-accent)} .sw .c{height:34px;border-radius:6px;display:flex;align-items:flex-end;padding:4px} .sw .c i{display:block;width:40%;height:6px;border-radius:3px;background:rgba(255,255,255,.75)}
|
||||
.sw .n{font-size:12px;font-weight:500;display:flex;align-items:center;gap:5px}
|
||||
.themecard{border:2px solid var(--kh-border);border-radius:10px;overflow:hidden;width:200px}
|
||||
.themecard.on{border-color:var(--kh-accent)}
|
||||
.themecard .pv{height:92px;display:grid;grid-template-columns:40px 1fr;grid-template-rows:14px 1fr}
|
||||
.themecard .pv .tb{grid-column:1/3} .themecard .pv .sb{} .themecard .pv .ct{padding:6px;display:flex;flex-direction:column;gap:4px} .themecard .pv .ct i{display:block;height:6px;border-radius:3px}
|
||||
.themecard .lbl{padding:7px 10px;font-size:12px;font-weight:500;display:flex;align-items:center;gap:6px;border-top:1px solid var(--kh-border)}
|
||||
|
||||
/* ---- login ---- */
|
||||
.login{height:100vh;display:grid;grid-template-columns:1.1fr 1fr}
|
||||
.login .hero{background:radial-gradient(1200px 600px at 20% 10%, #243A5E 0%, #17243A 55%, #0F1826 100%);color:#E8EDF5;padding:56px;display:flex;flex-direction:column;position:relative;overflow:hidden}
|
||||
.login .hero .mark{width:56px;height:56px;border-radius:14px;background:linear-gradient(145deg,var(--kh-brand),var(--kh-brand-deep));display:grid;place-items:center;box-shadow:0 10px 30px rgba(0,0,0,.35)} .login .hero .mark svg{width:34px;height:34px;fill:#FFF8E6}
|
||||
.login .hero h1{font-size:40px;letter-spacing:-.8px;margin:26px 0 8px;font-weight:650}
|
||||
.login .hero p{font-size:15px;color:#B8C5DA;max-width:440px;line-height:1.5;margin:0}
|
||||
.login .hero .feats{margin-top:auto;display:grid;grid-template-columns:1fr 1fr;gap:12px;max-width:560px}
|
||||
.login .hero .feat{background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.1);border-radius:10px;padding:12px;font-size:12.5px;display:flex;gap:9px;align-items:flex-start;color:#D5DEEB} .login .hero .feat svg.i{color:var(--kh-brand);margin-top:1px}
|
||||
.login .hero .glyph{position:absolute;right:-60px;bottom:-40px;width:420px;height:420px;opacity:.06;fill:#fff}
|
||||
.login .side{display:grid;place-items:center;background:var(--kh-bg)}
|
||||
.login .box{width:400px;display:flex;flex-direction:column;gap:14px}
|
||||
.login .box h2{margin:0;font-size:22px;font-weight:600} .login .box .s{color:var(--kh-text-2);font-size:13px;margin-top:-8px}
|
||||
|
||||
/* =========================================================================
|
||||
v2 — toolbar a sole icone, intestazione documento, gruppi di campi,
|
||||
menu comprimibile, widget dashboard, tooltip, pannello allegati
|
||||
========================================================================= */
|
||||
.toolbar.icons{gap:2px;padding:5px 6px}
|
||||
.toolbar.icons .grp{display:flex;gap:2px;align-items:center}
|
||||
.toolbar.icons .sep{margin:0 5px}
|
||||
.ib{position:relative;display:grid;place-items:center;width:32px;height:32px;border-radius:7px;color:var(--kh-text-2);border:1px solid transparent}
|
||||
.ib svg.i{width:18px;height:18px}
|
||||
.ib:hover{background:var(--kh-surface-3);color:var(--kh-text)}
|
||||
.ib.primary{background:var(--kh-accent);color:#fff;border-color:var(--kh-accent)}
|
||||
.ib.danger{color:var(--kh-err)} .ib.disabled{opacity:.35} .ib.on{background:var(--kh-accent-soft);color:var(--kh-accent-text)}
|
||||
.ib .cnt{position:absolute;top:-3px;right:-3px;min-width:15px;height:15px;border-radius:8px;background:var(--kh-err);color:#fff;font-size:9.5px;font-weight:700;display:grid;place-items:center;padding:0 3px;border:2px solid var(--kh-surface)}
|
||||
.ctx{display:inline-flex;align-items:center;gap:6px;height:30px;padding:0 10px 0 8px;border-radius:7px;border:1px solid var(--kh-border);background:var(--kh-surface);font:500 12.5px var(--kh-font);color:var(--kh-text);white-space:nowrap}
|
||||
.ctx svg.i{width:16px;height:16px;color:var(--kh-accent)}
|
||||
.ctx.primary{background:var(--kh-accent);border-color:var(--kh-accent);color:#fff} .ctx.primary svg.i{color:#fff}
|
||||
.ctx.ok{border-color:var(--kh-ok);color:var(--kh-ok)} .ctx.ok svg.i{color:var(--kh-ok)}
|
||||
.ctx.warn{border-color:var(--kh-warn);color:var(--kh-warn)} .ctx.warn svg.i{color:var(--kh-warn)}
|
||||
.ctx.danger{color:var(--kh-err)} .ctx.danger svg.i{color:var(--kh-err)}
|
||||
.tip{position:absolute;top:38px;left:50%;transform:translateX(-50%);background:#1E2733;color:#fff;font:11.5px var(--kh-font);padding:5px 8px;border-radius:6px;white-space:nowrap;box-shadow:var(--kh-shadow-lg);z-index:5;display:flex;gap:8px;align-items:center}
|
||||
.tip kbd{font:10px var(--kh-mono);background:rgba(255,255,255,.15);padding:1px 5px;border-radius:3px}
|
||||
.tip::before{content:"";position:absolute;top:-5px;left:50%;margin-left:-5px;border:5px solid transparent;border-top:0;border-bottom-color:#1E2733}
|
||||
|
||||
/* intestazione documento */
|
||||
.dochead{display:grid;grid-template-columns:minmax(260px,1.05fr) minmax(320px,1.7fr) minmax(290px,.95fr);gap:0;background:var(--kh-surface);border:1px solid var(--kh-border);border-radius:var(--kh-radius-lg);box-shadow:var(--kh-shadow);overflow:hidden}
|
||||
.dochead>div{padding:12px 16px;min-width:0}
|
||||
.dochead>div+div{border-left:1px solid var(--kh-border)}
|
||||
.dochead .kind{display:flex;align-items:center;gap:10px}
|
||||
.dochead .kind .kb{width:40px;height:40px;border-radius:10px;display:grid;place-items:center;background:var(--kh-accent-soft);color:var(--kh-accent-text)} .dochead .kind .kb svg.i{width:22px;height:22px}
|
||||
.dochead .kind .kl{font-size:11.5px;color:var(--kh-text-2);font-weight:500;text-transform:uppercase;letter-spacing:.4px}
|
||||
.dochead .kind .kn{font-size:19px;font-weight:650;letter-spacing:-.2px;font-variant-numeric:tabular-nums;line-height:1.15}
|
||||
.dochead .meta{display:flex;flex-wrap:wrap;gap:6px 10px;margin-top:9px;font-size:12px;color:var(--kh-text-2);align-items:center}
|
||||
.dochead .meta b{color:var(--kh-text);font-weight:500}
|
||||
.dochead .party{display:flex;gap:11px;align-items:flex-start}
|
||||
.dochead .party .av{width:40px;height:40px;border-radius:10px;background:var(--kh-surface-3);color:var(--kh-text-2);display:grid;place-items:center;font-weight:700;font-size:13px;flex:none}
|
||||
.dochead .party .pn{font-size:15px;font-weight:600;display:flex;align-items:center;gap:8px}
|
||||
.dochead .party .pn .code{font:600 11.5px var(--kh-mono);color:var(--kh-accent-text);background:var(--kh-accent-soft);padding:1px 6px;border-radius:5px}
|
||||
.dochead .party .ps{font-size:12px;color:var(--kh-text-2);margin-top:2px}
|
||||
.dochead .chips{display:flex;flex-wrap:wrap;gap:5px;margin-top:8px}
|
||||
.ichip{display:inline-flex;align-items:center;gap:5px;padding:2px 8px 2px 6px;border-radius:6px;background:var(--kh-surface-3);font-size:11.5px;color:var(--kh-text-2);white-space:nowrap}
|
||||
.ichip svg.i{width:13px;height:13px;color:var(--kh-text-3)} .ichip b{color:var(--kh-text);font-weight:500}
|
||||
.ichip.acc{background:var(--kh-accent-soft);color:var(--kh-accent-text)} .ichip.acc svg.i{color:var(--kh-accent)}
|
||||
.ichip.warn{background:var(--kh-warn-soft);color:var(--kh-warn)} .ichip.warn svg.i{color:var(--kh-warn)}
|
||||
.ichip.err{background:var(--kh-err-soft);color:var(--kh-err)} .ichip.err svg.i{color:var(--kh-err)}
|
||||
.dochead .tot{display:flex;flex-direction:column;align-items:flex-end;gap:2px;text-align:right}
|
||||
.dochead .tot .tl{font-size:11.5px;color:var(--kh-text-2);text-transform:uppercase;letter-spacing:.4px;font-weight:500;white-space:nowrap}
|
||||
.dochead .tot .tv{font-size:24px;font-weight:650;letter-spacing:-.4px;font-variant-numeric:tabular-nums;line-height:1.1}
|
||||
.dochead .tot .ts{font-size:12px;color:var(--kh-text-2);display:flex;gap:10px;margin-top:4px}
|
||||
.dochead .tot .ts b{color:var(--kh-text);font-weight:500;font-variant-numeric:tabular-nums}
|
||||
|
||||
/* schede con icone */
|
||||
.tabs.i .tab{gap:7px;padding:9px 11px}
|
||||
.tabs.i .tab svg.i{width:15px;height:15px;color:var(--kh-text-3)} .tabs.i .tab.active svg.i{color:var(--kh-accent)}
|
||||
|
||||
/* gruppi di campi */
|
||||
.fgroups{display:grid;grid-template-columns:repeat(auto-fit,minmax(300px,1fr));gap:12px;padding:12px 14px}
|
||||
.fgroup{border:1px solid var(--kh-border);border-radius:var(--kh-radius-lg);background:var(--kh-surface-2);overflow:hidden}
|
||||
.fgroup .fgh{display:flex;align-items:center;gap:7px;padding:7px 11px;font-size:11.5px;font-weight:600;color:var(--kh-text-2);text-transform:uppercase;letter-spacing:.4px;border-bottom:1px solid var(--kh-border);background:var(--kh-surface)}
|
||||
.fgroup .fgh svg.i{width:14px;height:14px;color:var(--kh-accent)}
|
||||
.fgroup .form{padding:10px 11px 11px;gap:7px 10px}
|
||||
.fgroup.wide{grid-column:1/-1}
|
||||
|
||||
/* menu comprimibile */
|
||||
.app.collapsed{grid-template-columns:60px 1fr} .app.collapsed .sidebar{overflow:visible;z-index:7}
|
||||
.app.collapsed .brand{width:48px;gap:0} .app.collapsed .brand span.txt,.app.collapsed .brand .ver{display:none}
|
||||
.app.collapsed .sidebar .sec{display:none}
|
||||
.app.collapsed .nav a{justify-content:center;padding:8px 0} .app.collapsed .nav a span{display:none} .app.collapsed .nav a .cnt{display:none}
|
||||
.app.collapsed .nav.sub{display:none} .app.collapsed .sidebar .foot{display:none}
|
||||
.app.collapsed .nav a svg.i{width:20px;height:20px}
|
||||
.app.collapsed .nav a.active{position:relative} .app.collapsed .nav a.active::after{content:"";position:absolute;left:-8px;top:8px;bottom:8px;width:3px;border-radius:2px;background:var(--kh-accent)}
|
||||
.sidebar .toggle{display:flex;align-items:center;gap:8px;padding:8px 12px;margin:4px 8px 6px;border-radius:7px;color:var(--kh-text-3);font-size:12px;border:1px dashed var(--kh-border)}
|
||||
.app.collapsed .sidebar .toggle{justify-content:center;margin:4px 8px} .app.collapsed .sidebar .toggle span{display:none}
|
||||
.nav a .flyout{display:none}
|
||||
.app.collapsed .nav a.active .flyout{display:block;position:absolute;left:58px;top:0;background:var(--kh-surface);border:1px solid var(--kh-border);border-radius:9px;box-shadow:var(--kh-shadow-lg);padding:6px;min-width:190px;z-index:6}
|
||||
.flyout .fh{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.4px;color:var(--kh-text-3);padding:4px 8px}
|
||||
.flyout div.fi{padding:6px 8px;border-radius:6px;font-size:12.5px;color:var(--kh-text)} .flyout div.fi.on{background:var(--kh-accent-soft);color:var(--kh-accent-text)}
|
||||
|
||||
/* dashboard widget */
|
||||
.wgrid{display:grid;grid-template-columns:repeat(12,1fr);gap:var(--kh-gap);grid-auto-rows:minmax(60px,auto)}
|
||||
.w3{grid-column:span 3} .w4{grid-column:span 4} .w6{grid-column:span 6} .w8{grid-column:span 8} .w12{grid-column:span 12}
|
||||
.widget{background:var(--kh-surface);border:1px solid var(--kh-border);border-radius:var(--kh-radius-lg);box-shadow:var(--kh-shadow);display:flex;flex-direction:column;min-width:0;position:relative}
|
||||
.widget .wh{display:flex;align-items:center;gap:8px;padding:8px 12px;border-bottom:1px solid var(--kh-border);font-weight:600;font-size:12.5px}
|
||||
.widget .wh svg.i{width:15px;height:15px;color:var(--kh-accent)}
|
||||
.widget .wh .grow{flex:1} .widget .wh .wa{display:flex;gap:2px;color:var(--kh-text-3)} .widget .wh .wa svg.i{color:var(--kh-text-3);width:14px;height:14px}
|
||||
.widget .wb{padding:10px 12px;display:flex;flex-direction:column;gap:8px;flex:1} .widget .wb.tight{padding:0}
|
||||
.widget.editing{outline:2px dashed var(--kh-accent);outline-offset:3px}
|
||||
.widget.editing .wh .drag{cursor:grab;color:var(--kh-accent)}
|
||||
.widget.off{opacity:.45}
|
||||
.chk-row{display:flex;align-items:center;gap:9px;padding:8px 10px;border-bottom:1px solid var(--kh-border);font-size:12.5px}
|
||||
.chk-row:last-child{border-bottom:0}
|
||||
.chk-row .t{flex:1;min-width:0} .chk-row .t .s{font-size:11.5px;color:var(--kh-text-3)} .chk-row.done .t{text-decoration:line-through;color:var(--kh-text-3)}
|
||||
.deadline{display:grid;grid-template-columns:44px 1fr auto;gap:10px;align-items:center;padding:7px 10px;border-bottom:1px solid var(--kh-border)}
|
||||
.deadline:last-child{border-bottom:0}
|
||||
.deadline .dd{text-align:center;border-radius:7px;background:var(--kh-surface-3);padding:3px 0;line-height:1.1} .deadline .dd b{display:block;font-size:15px} .deadline .dd span{font-size:10px;text-transform:uppercase;color:var(--kh-text-3)}
|
||||
.deadline .dd.hot{background:var(--kh-err-soft);color:var(--kh-err)} .deadline .dd.hot span{color:var(--kh-err)}
|
||||
.deadline .dd.warm{background:var(--kh-warn-soft);color:var(--kh-warn)} .deadline .dd.warm span{color:var(--kh-warn)}
|
||||
.deadline .dt{font-size:12.5px;font-weight:500} .deadline .ds{font-size:11.5px;color:var(--kh-text-3)}
|
||||
|
||||
/* side drawer (personalizza, dettagli log, allegati) */
|
||||
.drawer{position:fixed;top:var(--kh-topbar-h);right:0;bottom:var(--kh-status-h);width:420px;background:var(--kh-surface);border-left:1px solid var(--kh-border);box-shadow:var(--kh-shadow-lg);display:flex;flex-direction:column;z-index:8}
|
||||
.drawer .dh{display:flex;align-items:center;gap:8px;padding:12px 16px;border-bottom:1px solid var(--kh-border);font-weight:600;font-size:14px} .drawer .dh .grow{flex:1}
|
||||
.drawer .db{padding:12px 16px;display:flex;flex-direction:column;gap:10px;overflow:auto;flex:1}
|
||||
.drawer .df{display:flex;gap:8px;padding:12px 16px;border-top:1px solid var(--kh-border);background:var(--kh-surface-2);justify-content:flex-end}
|
||||
|
||||
/* allegati */
|
||||
.att{display:grid;grid-template-columns:36px 1fr auto;gap:10px;align-items:center;padding:8px 12px;border-bottom:1px solid var(--kh-border)}
|
||||
.att:last-child{border-bottom:0}
|
||||
.att .ft{width:36px;height:36px;border-radius:8px;display:grid;place-items:center;font:700 10px var(--kh-mono);color:#fff}
|
||||
.att .ft.pdf{background:#C2453A} .att .ft.xml{background:#1F5FA8} .att .ft.xlsx{background:#1E8E5A} .att .ft.img{background:#7E57C2} .att .ft.doc{background:#0F8A96} .att .ft.zip{background:#4B5563} .att .ft.csv{background:#C27A1A}
|
||||
.att .an{font-size:12.5px;font-weight:500} .att .as{font-size:11.5px;color:var(--kh-text-3)}
|
||||
.att .ac{display:flex;gap:2px}
|
||||
|
||||
/* log */
|
||||
.loglvl{font:600 10.5px var(--kh-mono);padding:1px 6px;border-radius:4px}
|
||||
.loglvl.DBG{background:var(--kh-surface-3);color:var(--kh-text-3)} .loglvl.INF{background:var(--kh-info-soft);color:var(--kh-info)} .loglvl.WRN{background:var(--kh-warn-soft);color:var(--kh-warn)} .loglvl.ERR{background:var(--kh-err-soft);color:var(--kh-err)} .loglvl.CRT{background:var(--kh-err);color:#fff}
|
||||
.secnav{display:flex;flex-direction:column;gap:1px;padding:6px}
|
||||
.secnav div{display:flex;align-items:center;gap:8px;padding:6px 9px;border-radius:6px;font-size:12.5px;color:var(--kh-text-2)}
|
||||
.secnav div.on{background:var(--kh-accent-soft);color:var(--kh-accent-text);font-weight:600}
|
||||
.secnav div .n{margin-left:auto;font-size:11px;color:var(--kh-text-3)} .secnav div .n.err{color:var(--kh-err);font-weight:600}
|
||||
.codebox{font:12px var(--kh-mono);background:var(--kh-surface-3);border-radius:7px;padding:10px 12px;white-space:pre-wrap;line-height:1.5;color:var(--kh-text)}
|
||||
|
||||
/* licenze */
|
||||
.modcard{border:1px solid var(--kh-border);border-radius:var(--kh-radius-lg);padding:12px 14px;display:flex;flex-direction:column;gap:8px;background:var(--kh-surface)}
|
||||
.modcard .mh{display:flex;align-items:center;gap:9px;font-weight:600;font-size:13px}
|
||||
.modcard .mh .ico-box{width:32px;height:32px}
|
||||
.modcard .md{font-size:12px;color:var(--kh-text-2);line-height:1.4}
|
||||
.modcard .mf{display:flex;align-items:center;gap:8px;margin-top:auto;font-size:11.5px;color:var(--kh-text-3)}
|
||||
.modcard.on{border-color:var(--kh-ok)} .modcard.off{opacity:.75}
|
||||
|
||||
/* stampa anteprima */
|
||||
.paper{background:#fff;color:#1E2733;width:794px;min-height:600px;margin:0 auto;box-shadow:0 8px 30px rgba(0,0,0,.25);padding:40px 44px;font-size:12px;font-family:var(--kh-font);border-radius:2px}
|
||||
.paper table{width:100%;border-collapse:collapse} .paper th{text-align:left;font-size:10.5px;text-transform:uppercase;letter-spacing:.3px;border-bottom:1.5px solid #1E2733;padding:6px 4px} .paper td{padding:5px 4px;border-bottom:1px solid #E1E5EB;vertical-align:top}
|
||||
.paper .num{text-align:right}
|
||||
|
||||
/* sidebar brand text wrapper */
|
||||
.brand span.txt{display:inline}
|
||||
|
||||
/* wizard verticale */
|
||||
.vsteps{display:flex;flex-direction:column;gap:0;padding:6px 0}
|
||||
.vstep{display:grid;grid-template-columns:26px 1fr;gap:10px;padding:8px 10px;position:relative;font-size:12.5px;color:var(--kh-text-3)}
|
||||
.vstep::before{content:"";position:absolute;left:22px;top:34px;bottom:-6px;width:1px;background:var(--kh-border)} .vstep:last-child::before{display:none}
|
||||
.vstep .n{width:24px;height:24px;border-radius:50%;border:1px solid var(--kh-border-strong);display:grid;place-items:center;font-size:12px;font-weight:600;background:var(--kh-surface)}
|
||||
.vstep.done .n{background:var(--kh-ok);border-color:var(--kh-ok);color:#fff} .vstep.on .n{background:var(--kh-accent);border-color:var(--kh-accent);color:#fff} .vstep.on{color:var(--kh-text);font-weight:600}
|
||||
.vstep .vs{font-size:11.5px;color:var(--kh-text-3);font-weight:400;margin-top:2px}
|
||||
|
||||
/* stat strip */
|
||||
.strip{display:flex;gap:0;background:var(--kh-surface);border:1px solid var(--kh-border);border-radius:var(--kh-radius-lg);overflow:hidden}
|
||||
.strip>div{flex:1;padding:9px 14px;border-right:1px solid var(--kh-border);display:flex;flex-direction:column;gap:1px} .strip>div:last-child{border-right:0}
|
||||
.strip .sl{font-size:11px;color:var(--kh-text-3);text-transform:uppercase;letter-spacing:.4px;font-weight:500} .strip .sv{font-size:16px;font-weight:600;font-variant-numeric:tabular-nums}
|
||||
.strip .sv.err{color:var(--kh-err)} .strip .sv.ok{color:var(--kh-ok)} .strip .sv.warn{color:var(--kh-warn)}
|
||||
@@ -0,0 +1,142 @@
|
||||
/* Khaemhat interaction states (SPEC §10.8): what the static mockups do not show. Real <button> and <a> elements
|
||||
take the look of the mockup classes; keyboard focus is always visible; preferences of §10.6 that are not colours
|
||||
(tooltips, animations, tabular numbers, row highlight) are switched by attributes on the root element. */
|
||||
|
||||
/* ---- buttons and links that look like the mockup classes ---- */
|
||||
button.ib, button.tbtn, button.btn, button.ctx, button.wtab, button.tab, button.chip, button.sw, button.themecard,
|
||||
button.userbox, button.company, button.gsearch, button.toggle, button.li, button.hit, button.fi, a.ib, a.btn, a.ctx {
|
||||
font: inherit; color: inherit; cursor: pointer; text-align: left; text-decoration: none;
|
||||
}
|
||||
button.ib, button.tbtn { background: transparent; padding: 0; }
|
||||
button.ib { color: var(--kh-text-2); }
|
||||
button.ib.primary { background: var(--kh-accent); color: #fff; }
|
||||
button.tbtn { border: 0; color: var(--kh-topbar-text); }
|
||||
button.btn { font: 500 12.5px var(--kh-font); }
|
||||
button.ctx { font: 500 12.5px var(--kh-font); }
|
||||
button.wtab { background: transparent; font-size: 12.5px; }
|
||||
button.wtab.active { background: var(--kh-surface); }
|
||||
button.tab { background: transparent; border-top: 0; border-left: 0; border-right: 0; font-size: 12.5px; }
|
||||
button.chip { border: 0; }
|
||||
button.userbox, button.company { border: 0; color: var(--kh-topbar-text); }
|
||||
button.gsearch { font-size: var(--kh-fs); cursor: text; }
|
||||
button.toggle { background: transparent; width: calc(100% - 16px); font-size: 12px; color: var(--kh-text-3); }
|
||||
button[disabled], .ib.disabled, .btn.disabled, .ctx.disabled { cursor: default; pointer-events: none; }
|
||||
.btn:hover, .ctx:hover { border-color: var(--kh-border-strong); }
|
||||
.btn.primary:hover, .ctx.primary:hover, .ib.primary:hover { background: var(--kh-accent-strong); border-color: var(--kh-accent-strong); color: #fff; }
|
||||
.wtab:hover:not(.active) { background: rgba(127, 127, 127, .08); color: var(--kh-text); }
|
||||
.wtab .x { border-radius: 4px; display: grid; place-items: center; width: 16px; height: 16px; }
|
||||
.wtab .x:hover { background: var(--kh-surface-3); color: var(--kh-text); }
|
||||
.tab:hover:not(.active) { color: var(--kh-text); }
|
||||
.nav a { cursor: pointer; }
|
||||
a { color: var(--kh-accent-text); }
|
||||
|
||||
/* ---- keyboard focus: always visible ---- */
|
||||
:focus { outline: none; }
|
||||
:focus-visible { outline: none; box-shadow: var(--kh-focus); border-radius: var(--kh-radius); }
|
||||
.f .in:focus-within, input.in:focus, select.in:focus, textarea.in:focus { border-color: var(--kh-accent); box-shadow: 0 0 0 3px var(--kh-accent-soft); }
|
||||
.skip { position: absolute; left: 8px; top: -40px; z-index: 50; background: var(--kh-accent); color: #fff; padding: 6px 12px; border-radius: 6px; }
|
||||
.skip:focus { top: 8px; }
|
||||
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
|
||||
|
||||
/* ---- form controls rendered as real inputs inside .f ---- */
|
||||
input.in, select.in, textarea.in { font: inherit; width: 100%; height: 30px; border: 1px solid var(--kh-border-strong); border-radius: var(--kh-radius);
|
||||
background: var(--kh-input); color: var(--kh-text); padding: 0 9px; }
|
||||
textarea.in { height: auto; min-height: 56px; padding: 6px 9px; line-height: 1.4; resize: vertical; }
|
||||
input.in[readonly], select.in[disabled], textarea.in[readonly] { background: var(--kh-input-ro); border-color: var(--kh-border); color: var(--kh-text-2); }
|
||||
input.in.err, select.in.err, textarea.in.err, .f .in.invalid { border-color: var(--kh-err); box-shadow: 0 0 0 3px var(--kh-err-soft); }
|
||||
.f .in input { border: 0; outline: 0; background: transparent; font: inherit; color: inherit; flex: 1; min-width: 0; height: 100%; padding: 0; }
|
||||
.f .in input.code { font-family: var(--kh-mono); font-size: 12px; font-weight: 600; color: var(--kh-accent-text); flex: none; width: 9ch; }
|
||||
button.switch { border: 0; padding: 0; cursor: pointer; }
|
||||
button.bx { padding: 0; cursor: pointer; }
|
||||
.validation { display: flex; flex-direction: column; gap: 3px; }
|
||||
|
||||
/* ---- tooltips (.tip inside .ib) ---- */
|
||||
.ib .tip, .tbtn .tip { display: none; pointer-events: none; }
|
||||
.ib:hover .tip, .ib:focus-visible .tip, .tbtn:hover .tip, .tbtn:focus-visible .tip { display: flex; }
|
||||
.tbtn .tip { top: 40px; }
|
||||
:root[data-tooltips="off"] .tip { display: none !important; }
|
||||
|
||||
/* ---- pop-up menus (user menu, company switcher, toolbar overflow, row menu) ---- */
|
||||
.pop { position: relative; }
|
||||
.popmenu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 220px; z-index: 20; background: var(--kh-surface); color: var(--kh-text);
|
||||
border: 1px solid var(--kh-border); border-radius: 9px; box-shadow: var(--kh-shadow-lg); padding: 6px; display: flex; flex-direction: column; gap: 1px; }
|
||||
.popmenu.left { left: 0; right: auto; }
|
||||
.popmenu .fh { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--kh-text-3); padding: 6px 8px 4px; }
|
||||
.popmenu .mi { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 6px; font: inherit; font-size: 12.5px; color: var(--kh-text);
|
||||
background: transparent; border: 0; text-align: left; cursor: pointer; text-decoration: none; width: 100%; }
|
||||
.popmenu .mi svg.i { color: var(--kh-text-3); }
|
||||
.popmenu .mi:hover, .popmenu .mi.on { background: var(--kh-accent-soft); color: var(--kh-accent-text); }
|
||||
.popmenu .mi .k { margin-left: auto; font: 10.5px var(--kh-mono); color: var(--kh-text-3); }
|
||||
.popmenu .mi .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
||||
.popmenu hr { border: 0; border-top: 1px solid var(--kh-border); margin: 5px 2px; }
|
||||
.popmenu form { margin: 0; }
|
||||
.scrim { position: fixed; inset: 0; z-index: 15; background: transparent; }
|
||||
|
||||
/* ---- shell behaviour ---- */
|
||||
.app .sidebar .navscroll { overflow-y: auto; overflow-x: hidden; flex: 1; min-height: 0; padding-bottom: 6px; }
|
||||
.app.collapsed .sidebar .navscroll { overflow: visible; }
|
||||
.nav .item { position: relative; }
|
||||
.nav .item .flyout { display: none; }
|
||||
.app.collapsed .nav .item:hover .flyout, .app.collapsed .nav .item:focus-within .flyout {
|
||||
display: block; position: absolute; left: 52px; top: 0; background: var(--kh-surface); border: 1px solid var(--kh-border); border-radius: 9px;
|
||||
box-shadow: var(--kh-shadow-lg); padding: 6px; min-width: 190px; z-index: 30; }
|
||||
/* a bridge over the gap, so the pointer can reach the flyout without closing it */
|
||||
.app.collapsed .nav .item .flyout::before { content: ""; position: absolute; left: -10px; top: 0; bottom: 0; width: 10px; }
|
||||
.flyout a.fi { display: block; padding: 6px 8px; border-radius: 6px; font-size: 12.5px; color: var(--kh-text); text-decoration: none; font-weight: 400; }
|
||||
.flyout a.fi:hover, .flyout a.fi.on { background: var(--kh-accent-soft); color: var(--kh-accent-text); }
|
||||
.nav.sub { padding: 0 0 4px 30px; }
|
||||
|
||||
/* ---- dialogs and command palette ---- */
|
||||
.overlay { z-index: 40; }
|
||||
.dialog.confirm { width: 440px; }
|
||||
.dialog.confirm .db p { margin: 0; line-height: 1.5; }
|
||||
.palette .palette-input { flex: 1; border: 0; outline: 0; background: transparent; font: inherit; font-size: 15px; color: var(--kh-text); min-width: 0; }
|
||||
.palette .palette-input::-webkit-search-cancel-button { display: none; }
|
||||
.palette .hits { max-height: min(60vh, 460px); overflow-y: auto; padding: 4px 0 8px; }
|
||||
.palette button.hit { width: calc(100% - 12px); border: 0; background: transparent; font: inherit; color: var(--kh-text); text-align: left; cursor: pointer; }
|
||||
.content kbd { font: 10.5px var(--kh-mono); border: 1px solid var(--kh-border-strong); border-bottom-width: 2px; padding: 0 5px; border-radius: 4px;
|
||||
background: var(--kh-surface-2); color: var(--kh-text-2); }
|
||||
.tabs-strip { overflow: hidden; }
|
||||
.wtab { flex: 0 1 auto; min-width: 0; overflow: hidden; }
|
||||
.wtab .tt { overflow: hidden; text-overflow: ellipsis; color: inherit; text-decoration: none; }
|
||||
.wtab button.x { appearance: none; border: 0; padding: 0; background: transparent; color: var(--kh-text-3); cursor: pointer; }
|
||||
a.tab { text-decoration: none; }
|
||||
.btn:disabled, .btn[disabled] { opacity: .5; cursor: default; pointer-events: none; }
|
||||
.wtab button.x:hover { background: var(--kh-surface-3); color: var(--kh-text); }
|
||||
.tabpane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
|
||||
.tabpane[hidden] { display: none; }
|
||||
.statusbar .item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
|
||||
.statusbar .live.off { background: var(--kh-err); }
|
||||
.statusbar .live.warn { background: var(--kh-warn); }
|
||||
.topbar .company .code { font: 600 11px var(--kh-mono); color: var(--kh-topbar-muted); }
|
||||
.brand .mark svg { stroke: none; }
|
||||
.brand .mark svg rect { fill: #FFF8E6; }
|
||||
.brand a { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 9px; }
|
||||
.topbar .tbtn svg.i { width: 18px; height: 18px; }
|
||||
|
||||
/* ---- root preferences ---- */
|
||||
:root[data-tabular="on"] body { font-variant-numeric: tabular-nums; }
|
||||
:root[data-row-hover="on"] .grid tbody tr:hover td { background: var(--kh-row-hover); }
|
||||
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after {
|
||||
animation: none !important; transition: none !important; scroll-behavior: auto !important; }
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
* { animation-duration: .01ms !important; transition-duration: .01ms !important; }
|
||||
}
|
||||
.app, .sidebar, .wtab, .nav a, .btn, .ib, .ctx { transition: background-color .12s ease, color .12s ease, border-color .12s ease; }
|
||||
.app { transition: grid-template-columns .15s ease; }
|
||||
|
||||
/* ---- toasts ---- */
|
||||
.toasts { position: fixed; right: 16px; bottom: calc(var(--kh-status-h) + 12px); z-index: 40; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
|
||||
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--kh-surface); color: var(--kh-text); border: 1px solid var(--kh-border);
|
||||
border-left: 3px solid var(--kh-accent); border-radius: 9px; box-shadow: var(--kh-shadow-lg); padding: 10px 12px; font-size: 12.5px; }
|
||||
.toast.ok { border-left-color: var(--kh-ok); } .toast.warn { border-left-color: var(--kh-warn); } .toast.err { border-left-color: var(--kh-err); }
|
||||
.toast .grow { flex: 1; min-width: 0; } .toast .tt { font-weight: 600; }
|
||||
.toast button { background: transparent; border: 0; color: var(--kh-text-3); cursor: pointer; padding: 0; }
|
||||
|
||||
/* ---- tablets (>= 768 px): the shell stays usable ---- */
|
||||
@media (max-width: 1099px) {
|
||||
.userbox .who { display: none; }
|
||||
}
|
||||
@media (max-width: 899px) {
|
||||
.gsearch .ph { display: none; }
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/* Khaemhat print styles (SPEC §10.6): prints are always light, whatever theme the user chose. The shell (top bar,
|
||||
menu, tabs, status bar, toolbars) is not printed; only the active page content is. */
|
||||
@media print {
|
||||
:root, :root[data-theme] {
|
||||
color-scheme: light;
|
||||
--kh-bg: #FFFFFF; --kh-surface: #FFFFFF; --kh-surface-2: #FFFFFF; --kh-surface-3: #F3F5F8;
|
||||
--kh-border: #C5CDD7; --kh-border-strong: #8A95A3;
|
||||
--kh-text: #000000; --kh-text-2: #333333; --kh-text-3: #555555;
|
||||
--kh-input: #FFFFFF; --kh-input-ro: #FFFFFF; --kh-row-alt: #FFFFFF; --kh-row-sel: #FFFFFF;
|
||||
--kh-shadow: none; --kh-shadow-lg: none;
|
||||
--kh-ok-text: #1E8E5A; --kh-warn-text: #8B5511; --kh-err-text: #C2453A; --kh-info-text: #1F5FA8;
|
||||
}
|
||||
@page { size: A4; margin: 14mm 12mm; }
|
||||
html, body { height: auto; background: #FFFFFF; color: #000000; }
|
||||
.app { display: block; height: auto; overflow: visible; }
|
||||
.topbar, .sidebar, .tabs-strip, .statusbar, .toolbar, .toasts, .skip, .no-print, #blazor-error-ui, .popmenu, .scrim, .drawer, .overlay { display: none !important; }
|
||||
.main, .content, .tabpane:not([hidden]) { display: block; overflow: visible; padding: 0; }
|
||||
.tabpane[hidden] { display: none !important; }
|
||||
.panel, .widget, .tile, .dochead, .fgroup { box-shadow: none; break-inside: avoid; }
|
||||
.grid th { position: static; }
|
||||
.grid tr { break-inside: avoid; }
|
||||
a { color: inherit; text-decoration: none; }
|
||||
.paper { box-shadow: none; width: auto; padding: 0; margin: 0; }
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/* Khaemhat design tokens (SPEC §10.1 rule 2, §10.6). Born from docs/mockups/mockup.css: same names and values.
|
||||
Added only where needed: the automatic and high-contrast themes, text sizes, readable status texts on dark
|
||||
backgrounds (--kh-*-text), focus ring and colour scheme. The root element carries data-theme, data-accent,
|
||||
data-density, data-text-size (ThemeService). */
|
||||
:root{
|
||||
--kh-font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
|
||||
--kh-mono: "JetBrains Mono", "Cascadia Mono", "DejaVu Sans Mono", monospace;
|
||||
--kh-fs: 13px; --kh-fs-sm: 11.5px; --kh-fs-lg: 15px; --kh-fs-xl: 20px;
|
||||
--kh-radius: 6px; --kh-radius-lg: 10px;
|
||||
--kh-topbar-h: 46px; --kh-tabs-h: 36px; --kh-status-h: 24px; --kh-sidebar-w: 228px;
|
||||
--kh-gap: 12px; --kh-row-h: 30px;
|
||||
--kh-shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
|
||||
--kh-shadow-lg: 0 12px 32px rgba(16,24,40,.22);
|
||||
/* brand */
|
||||
--kh-brand: #C8962E; --kh-brand-deep: #8B6318; --kh-papyrus: #F1E6C8;
|
||||
/* semantic */
|
||||
--kh-ok: #1E8E5A; --kh-ok-soft: #DDF3E6; --kh-warn: #C27A1A; --kh-warn-soft: #FBEFD9;
|
||||
--kh-err: #C2453A; --kh-err-soft: #FADEDC; --kh-info: #1F5FA8; --kh-info-soft: #E3ECF8;
|
||||
/* added: status texts (darker or lighter than the status colour where the theme needs it) */
|
||||
--kh-ok-text: #1E8E5A; --kh-warn-text: #9A6013; --kh-err-text: #C2453A; --kh-info-text: #1F5FA8;
|
||||
/* added: keyboard focus */
|
||||
--kh-focus: 0 0 0 3px var(--kh-accent-soft), 0 0 0 1px var(--kh-accent);
|
||||
}
|
||||
/* ---- accents (per user) ---- */
|
||||
:root[data-accent="nilo"] { --kh-accent:#1F5FA8; --kh-accent-strong:#174A85; --kh-accent-soft:#E3ECF8; --kh-accent-text:#174A85; }
|
||||
:root[data-accent="lapislazzuli"]{ --kh-accent:#3F51B5; --kh-accent-strong:#303F9F; --kh-accent-soft:#E6E9F7; --kh-accent-text:#303F9F; }
|
||||
:root[data-accent="malachite"] { --kh-accent:#1E8E5A; --kh-accent-strong:#167347; --kh-accent-soft:#DDF3E6; --kh-accent-text:#167347; }
|
||||
:root[data-accent="turchese"] { --kh-accent:#0F8A96; --kh-accent-strong:#0B6D77; --kh-accent-soft:#D9F0F2; --kh-accent-text:#0B6D77; }
|
||||
:root[data-accent="ocra"] { --kh-accent:#C27A1A; --kh-accent-strong:#9A6013; --kh-accent-soft:#FBEFD9; --kh-accent-text:#8B5511; }
|
||||
:root[data-accent="corniola"] { --kh-accent:#C2453A; --kh-accent-strong:#9E362D; --kh-accent-soft:#FADEDC; --kh-accent-text:#9E362D; }
|
||||
:root[data-accent="ametista"] { --kh-accent:#7E57C2; --kh-accent-strong:#65449C; --kh-accent-soft:#ECE4F8; --kh-accent-text:#65449C; }
|
||||
:root[data-accent="grafite"] { --kh-accent:#4B5563; --kh-accent-strong:#374151; --kh-accent-soft:#E5E7EB; --kh-accent-text:#374151; }
|
||||
/* ---- light theme (also the automatic theme on a light system) ---- */
|
||||
:root, :root[data-theme="light"], :root[data-theme="auto"]{
|
||||
color-scheme: light;
|
||||
--kh-bg:#F3F5F8; --kh-surface:#FFFFFF; --kh-surface-2:#F8FAFC; --kh-surface-3:#EEF2F6;
|
||||
--kh-border:#DDE3EA; --kh-border-strong:#C5CDD7;
|
||||
--kh-text:#1E2733; --kh-text-2:#5B6776; --kh-text-3:#8A95A3;
|
||||
--kh-topbar:#17243A; --kh-topbar-text:#E8EDF5; --kh-topbar-muted:#9FB0C8;
|
||||
--kh-sidebar:#FFFFFF; --kh-input:#FFFFFF; --kh-input-ro:#F3F5F8;
|
||||
--kh-row-alt:#FAFBFD; --kh-row-hover:#F1F5FB; --kh-row-sel: var(--kh-accent-soft);
|
||||
}
|
||||
/* ---- dark theme ---- */
|
||||
:root[data-theme="dark"]{
|
||||
color-scheme: dark;
|
||||
--kh-bg:#12161C; --kh-surface:#1B2028; --kh-surface-2:#20262F; --kh-surface-3:#262D37;
|
||||
--kh-border:#2E3744; --kh-border-strong:#3C4756;
|
||||
--kh-text:#E7ECF2; --kh-text-2:#A5B0BD; --kh-text-3:#73808F;
|
||||
--kh-topbar:#0E131A; --kh-topbar-text:#E7ECF2; --kh-topbar-muted:#8391A3;
|
||||
--kh-sidebar:#171C23; --kh-input:#12161C; --kh-input-ro:#1B2028;
|
||||
--kh-row-alt:#1E242D; --kh-row-hover:#252D38; --kh-row-sel:#24354D;
|
||||
--kh-ok-soft:#163B2A; --kh-warn-soft:#3E2E13; --kh-err-soft:#44201D; --kh-info-soft:#1C2F4A;
|
||||
--kh-ok-text:#8ADBB1; --kh-warn-text:#F0C27A; --kh-err-text:#F0A39B; --kh-info-text:#8DB8EE;
|
||||
--kh-shadow: 0 1px 2px rgba(0,0,0,.4);
|
||||
--kh-shadow-lg: 0 12px 32px rgba(0,0,0,.6);
|
||||
}
|
||||
:root[data-theme="dark"][data-accent="nilo"] { --kh-accent:#4C8EDB; --kh-accent-strong:#6AA3E6; --kh-accent-soft:#1C2F4A; --kh-accent-text:#8DB8EE; }
|
||||
:root[data-theme="dark"][data-accent="lapislazzuli"]{ --kh-accent:#7986CB; --kh-accent-strong:#9FA8DA; --kh-accent-soft:#232A4D; --kh-accent-text:#AAB3E6; }
|
||||
:root[data-theme="dark"][data-accent="malachite"] { --kh-accent:#3DBB7E; --kh-accent-strong:#62CC97; --kh-accent-soft:#163B2A; --kh-accent-text:#8ADBB1; }
|
||||
:root[data-theme="dark"][data-accent="turchese"] { --kh-accent:#30B4C1; --kh-accent-strong:#5BC8D3; --kh-accent-soft:#143A3E; --kh-accent-text:#8EDBE3; }
|
||||
:root[data-theme="dark"][data-accent="ocra"] { --kh-accent:#E09A3A; --kh-accent-strong:#EBB266; --kh-accent-soft:#3E2E13; --kh-accent-text:#F0C27A; }
|
||||
:root[data-theme="dark"][data-accent="corniola"] { --kh-accent:#E0665A; --kh-accent-strong:#EA8A80; --kh-accent-soft:#44201D; --kh-accent-text:#F0A39B; }
|
||||
:root[data-theme="dark"][data-accent="ametista"] { --kh-accent:#A98BE0; --kh-accent-strong:#BFA8EA; --kh-accent-soft:#2E2345; --kh-accent-text:#CBB8F0; }
|
||||
:root[data-theme="dark"][data-accent="grafite"] { --kh-accent:#9CA3AF; --kh-accent-strong:#B9C0CC; --kh-accent-soft:#2A3038; --kh-accent-text:#C9D0DA; }
|
||||
/* ---- automatic theme on a dark system: the dark values again ---- */
|
||||
@media (prefers-color-scheme: dark){
|
||||
:root[data-theme="auto"]{
|
||||
color-scheme: dark;
|
||||
--kh-bg:#12161C; --kh-surface:#1B2028; --kh-surface-2:#20262F; --kh-surface-3:#262D37;
|
||||
--kh-border:#2E3744; --kh-border-strong:#3C4756;
|
||||
--kh-text:#E7ECF2; --kh-text-2:#A5B0BD; --kh-text-3:#73808F;
|
||||
--kh-topbar:#0E131A; --kh-topbar-text:#E7ECF2; --kh-topbar-muted:#8391A3;
|
||||
--kh-sidebar:#171C23; --kh-input:#12161C; --kh-input-ro:#1B2028;
|
||||
--kh-row-alt:#1E242D; --kh-row-hover:#252D38; --kh-row-sel:#24354D;
|
||||
--kh-ok-soft:#163B2A; --kh-warn-soft:#3E2E13; --kh-err-soft:#44201D; --kh-info-soft:#1C2F4A;
|
||||
--kh-ok-text:#8ADBB1; --kh-warn-text:#F0C27A; --kh-err-text:#F0A39B; --kh-info-text:#8DB8EE;
|
||||
--kh-shadow: 0 1px 2px rgba(0,0,0,.4);
|
||||
--kh-shadow-lg: 0 12px 32px rgba(0,0,0,.6);
|
||||
}
|
||||
:root[data-theme="auto"][data-accent="nilo"] { --kh-accent:#4C8EDB; --kh-accent-strong:#6AA3E6; --kh-accent-soft:#1C2F4A; --kh-accent-text:#8DB8EE; }
|
||||
:root[data-theme="auto"][data-accent="lapislazzuli"]{ --kh-accent:#7986CB; --kh-accent-strong:#9FA8DA; --kh-accent-soft:#232A4D; --kh-accent-text:#AAB3E6; }
|
||||
:root[data-theme="auto"][data-accent="malachite"] { --kh-accent:#3DBB7E; --kh-accent-strong:#62CC97; --kh-accent-soft:#163B2A; --kh-accent-text:#8ADBB1; }
|
||||
:root[data-theme="auto"][data-accent="turchese"] { --kh-accent:#30B4C1; --kh-accent-strong:#5BC8D3; --kh-accent-soft:#143A3E; --kh-accent-text:#8EDBE3; }
|
||||
:root[data-theme="auto"][data-accent="ocra"] { --kh-accent:#E09A3A; --kh-accent-strong:#EBB266; --kh-accent-soft:#3E2E13; --kh-accent-text:#F0C27A; }
|
||||
:root[data-theme="auto"][data-accent="corniola"] { --kh-accent:#E0665A; --kh-accent-strong:#EA8A80; --kh-accent-soft:#44201D; --kh-accent-text:#F0A39B; }
|
||||
:root[data-theme="auto"][data-accent="ametista"] { --kh-accent:#A98BE0; --kh-accent-strong:#BFA8EA; --kh-accent-soft:#2E2345; --kh-accent-text:#CBB8F0; }
|
||||
:root[data-theme="auto"][data-accent="grafite"] { --kh-accent:#9CA3AF; --kh-accent-strong:#B9C0CC; --kh-accent-soft:#2A3038; --kh-accent-text:#C9D0DA; }
|
||||
}
|
||||
/* ---- high contrast (AAA): black on white, strong borders; every accent becomes a dark blue ---- */
|
||||
:root[data-theme="high-contrast"]{
|
||||
color-scheme: light;
|
||||
--kh-bg:#FFFFFF; --kh-surface:#FFFFFF; --kh-surface-2:#FFFFFF; --kh-surface-3:#F0F0F0;
|
||||
--kh-border:#1A1A1A; --kh-border-strong:#000000;
|
||||
--kh-text:#000000; --kh-text-2:#1A1A1A; --kh-text-3:#333333;
|
||||
--kh-topbar:#000000; --kh-topbar-text:#FFFFFF; --kh-topbar-muted:#E0E0E0;
|
||||
--kh-sidebar:#FFFFFF; --kh-input:#FFFFFF; --kh-input-ro:#F0F0F0;
|
||||
--kh-row-alt:#FFFFFF; --kh-row-hover:#E8EEF8; --kh-row-sel:#D6E2F5;
|
||||
--kh-ok:#0B5A36; --kh-ok-soft:#E6F4EC; --kh-warn:#6B4100; --kh-warn-soft:#FFF1D6;
|
||||
--kh-err:#8E1B12; --kh-err-soft:#FCE4E2; --kh-info:#0B3D91; --kh-info-soft:#E3ECF8;
|
||||
--kh-ok-text:#0B5A36; --kh-warn-text:#6B4100; --kh-err-text:#8E1B12; --kh-info-text:#0B3D91;
|
||||
--kh-shadow: none; --kh-shadow-lg: 0 0 0 2px #000000;
|
||||
--kh-focus: 0 0 0 3px #FFD400, 0 0 0 5px #000000;
|
||||
}
|
||||
:root[data-theme="high-contrast"][data-accent]{ --kh-accent:#0B3D91; --kh-accent-strong:#062A66; --kh-accent-soft:#D6E2F5; --kh-accent-text:#062A66; }
|
||||
/* density */
|
||||
:root[data-density="compact"]{ --kh-row-h:26px; --kh-fs:12.5px; --kh-gap:8px; }
|
||||
/* text size (added: SPEC §10.6 "dimensione testo") */
|
||||
:root[data-text-size="110"]{ --kh-fs:14.3px; --kh-fs-sm:12.6px; --kh-fs-lg:16.5px; --kh-fs-xl:22px; }
|
||||
:root[data-text-size="120"]{ --kh-fs:15.6px; --kh-fs-sm:13.8px; --kh-fs-lg:18px; --kh-fs-xl:24px; }
|
||||
:root[data-density="compact"][data-text-size="110"]{ --kh-fs:13.8px; }
|
||||
:root[data-density="compact"][data-text-size="120"]{ --kh-fs:15px; }
|
||||
@@ -0,0 +1,91 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<!-- Khaemhat icons (SPEC §10.8): original 24x24 stroke icons drawn in the style of the mockups; the stroke
|
||||
width, caps and colour come from the svg.i class. Use: <svg class="i"><use href="icons/sprite.svg#home"/></svg>. -->
|
||||
<symbol id="brand" viewBox="0 0 24 24"><rect x="3" y="3" width="8" height="8" rx="2"/><rect x="13" y="3" width="8" height="8" rx="2"/><rect x="3" y="13" width="8" height="8" rx="2"/><rect x="13" y="13" width="8" height="8" rx="2"/></symbol>
|
||||
<symbol id="home" viewBox="0 0 24 24"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9v11h5v-6h4v6h5V9"/></symbol>
|
||||
<symbol id="users" viewBox="0 0 24 24"><circle cx="9" cy="8" r="3.5"/><path d="M2.5 20c.6-3.6 3.2-5.5 6.5-5.5s5.9 1.9 6.5 5.5"/><path d="M15.5 4.8a3.5 3.5 0 0 1 0 6.4"/><path d="M18 14.8c2 .8 3.2 2.5 3.5 5.2"/></symbol>
|
||||
<symbol id="user" viewBox="0 0 24 24"><circle cx="12" cy="8" r="4"/><path d="M4 21c.8-4.2 4-6.5 8-6.5s7.2 2.3 8 6.5"/></symbol>
|
||||
<symbol id="target" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5"/><circle cx="12" cy="12" r="1.5"/></symbol>
|
||||
<symbol id="cart" viewBox="0 0 24 24"><path d="M2.5 3.5h2.8l2.4 11.2a1.5 1.5 0 0 0 1.5 1.2h8.6a1.5 1.5 0 0 0 1.5-1.1L21 7.5H6.2"/><circle cx="9.5" cy="20" r="1.3"/><circle cx="17.5" cy="20" r="1.3"/></symbol>
|
||||
<symbol id="truck" viewBox="0 0 24 24"><path d="M2.5 5.5h11v10h-11z"/><path d="M13.5 9h4.2l3.3 3.6v2.9h-7.5"/><circle cx="6.5" cy="17.5" r="2"/><circle cx="17" cy="17.5" r="2"/></symbol>
|
||||
<symbol id="box" viewBox="0 0 24 24"><path d="M12 2.8 20.5 7v10L12 21.2 3.5 17V7z"/><path d="M3.5 7 12 11.2 20.5 7"/><path d="M12 11.2v10"/></symbol>
|
||||
<symbol id="book" viewBox="0 0 24 24"><path d="M5 4.5A1.5 1.5 0 0 1 6.5 3H19v15H6.5A1.5 1.5 0 0 0 5 19.5z"/><path d="M5 19.5A1.5 1.5 0 0 0 6.5 21H19v-3"/><path d="M9 7.5h6"/></symbol>
|
||||
<symbol id="coins" viewBox="0 0 24 24"><ellipse cx="12" cy="6" rx="7.5" ry="3"/><path d="M4.5 6v6c0 1.7 3.4 3 7.5 3s7.5-1.3 7.5-3V6"/><path d="M4.5 12v6c0 1.7 3.4 3 7.5 3s7.5-1.3 7.5-3v-6"/></symbol>
|
||||
<symbol id="file-check" viewBox="0 0 24 24"><path d="M14 2.5H6.5A1.5 1.5 0 0 0 5 4v16a1.5 1.5 0 0 0 1.5 1.5h11A1.5 1.5 0 0 0 19 20V7.5z"/><path d="M14 2.5v5h5"/><path d="m9 14.5 2 2 4-4"/></symbol>
|
||||
<symbol id="file" viewBox="0 0 24 24"><path d="M14 2.5H6.5A1.5 1.5 0 0 0 5 4v16a1.5 1.5 0 0 0 1.5 1.5h11A1.5 1.5 0 0 0 19 20V7.5z"/><path d="M14 2.5v5h5"/><path d="M8.5 13h7M8.5 17h5"/></symbol>
|
||||
<symbol id="building" viewBox="0 0 24 24"><path d="M4 21V4.5A1.5 1.5 0 0 1 5.5 3h8A1.5 1.5 0 0 1 15 4.5V21"/><path d="M15 9h3.5A1.5 1.5 0 0 1 20 10.5V21"/><path d="M2.5 21h19"/><path d="M8 7.5h3M8 11.5h3M8 15.5h3"/></symbol>
|
||||
<symbol id="wrench" viewBox="0 0 24 24"><path d="M14.7 6.3a4.5 4.5 0 0 1 5.6-1.1l-3 3 .6 2 2 .6 3-3a4.5 4.5 0 0 1-6 6l-7.4 7.4a2.1 2.1 0 0 1-3-3l7.4-7.4a4.5 4.5 0 0 1 .8-4.5z"/></symbol>
|
||||
<symbol id="globe" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M3 12h18"/><path d="M12 3c2.5 2.6 3.8 5.6 3.8 9s-1.3 6.4-3.8 9c-2.5-2.6-3.8-5.6-3.8-9S9.5 5.6 12 3z"/></symbol>
|
||||
<symbol id="chart" viewBox="0 0 24 24"><path d="M3.5 20.5h17"/><path d="M6.5 17v-5M11 17V7M15.5 17v-8M20 17V4"/></symbol>
|
||||
<symbol id="layers" viewBox="0 0 24 24"><path d="M12 3 21 7.5 12 12 3 7.5z"/><path d="m3 12 9 4.5 9-4.5"/><path d="m3 16.5 9 4.5 9-4.5"/></symbol>
|
||||
<symbol id="zap" viewBox="0 0 24 24"><path d="M13 2.5 4.5 13.5H12l-1 8 8.5-11H12z"/></symbol>
|
||||
<symbol id="shield" viewBox="0 0 24 24"><path d="M12 2.8 19.5 5.5v6c0 4.6-3.1 8.2-7.5 9.7-4.4-1.5-7.5-5.1-7.5-9.7v-6z"/></symbol>
|
||||
<symbol id="shield-check" viewBox="0 0 24 24"><path d="M12 2.8 19.5 5.5v6c0 4.6-3.1 8.2-7.5 9.7-4.4-1.5-7.5-5.1-7.5-9.7v-6z"/><path d="m8.8 12 2.2 2.2 4.2-4.4"/></symbol>
|
||||
<symbol id="search" viewBox="0 0 24 24"><circle cx="11" cy="11" r="6.5"/><path d="m16 16 4.5 4.5"/></symbol>
|
||||
<symbol id="plus" viewBox="0 0 24 24"><path d="M12 5v14M5 12h14"/></symbol>
|
||||
<symbol id="minus" viewBox="0 0 24 24"><path d="M5 12h14"/></symbol>
|
||||
<symbol id="x" viewBox="0 0 24 24"><path d="M6 6l12 12M18 6 6 18"/></symbol>
|
||||
<symbol id="check" viewBox="0 0 24 24"><path d="m4.5 12.5 4.8 4.8L19.5 7"/></symbol>
|
||||
<symbol id="history" viewBox="0 0 24 24"><path d="M3.5 12a8.5 8.5 0 1 0 2.5-6"/><path d="M3.5 4v4.5H8"/><path d="M12 7.5V12l3 2"/></symbol>
|
||||
<symbol id="clock" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3.2 2"/></symbol>
|
||||
<symbol id="bell" viewBox="0 0 24 24"><path d="M6 16.5V11a6 6 0 0 1 12 0v5.5l1.5 2h-15z"/><path d="M10 20.5a2.2 2.2 0 0 0 4 0"/></symbol>
|
||||
<symbol id="moon" viewBox="0 0 24 24"><path d="M19.5 14.5A8 8 0 0 1 9.5 4.5a8 8 0 1 0 10 10z"/></symbol>
|
||||
<symbol id="sun" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4"/><path d="M12 2.5v2M12 19.5v2M4.6 4.6 6 6M18 18l1.4 1.4M2.5 12h2M19.5 12h2M4.6 19.4 6 18M18 6l1.4-1.4"/></symbol>
|
||||
<symbol id="contrast" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M12 3v18a9 9 0 0 0 0-18z" fill="currentColor"/></symbol>
|
||||
<symbol id="monitor" viewBox="0 0 24 24"><rect x="2.5" y="4" width="19" height="13" rx="1.5"/><path d="M8 21h8M12 17v4"/></symbol>
|
||||
<symbol id="help" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M9.5 9.3a2.6 2.6 0 0 1 5 1c0 1.7-2.5 2.3-2.5 4"/><path d="M12 17.3h.01"/></symbol>
|
||||
<symbol id="info" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M12 11v6"/><path d="M12 7.5h.01"/></symbol>
|
||||
<symbol id="alert" viewBox="0 0 24 24"><path d="M10.3 4 2.6 17.5A2 2 0 0 0 4.3 20.5h15.4a2 2 0 0 0 1.7-3L13.7 4a2 2 0 0 0-3.4 0z"/><path d="M12 9.5v4"/><path d="M12 16.8h.01"/></symbol>
|
||||
<symbol id="alert-circle" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M12 7.5v5.5"/><path d="M12 16.5h.01"/></symbol>
|
||||
<symbol id="check-circle" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="m8 12.3 2.8 2.8L16.2 9.5"/></symbol>
|
||||
<symbol id="x-circle" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="m9 9 6 6M15 9l-6 6"/></symbol>
|
||||
<symbol id="chevron-down" viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></symbol>
|
||||
<symbol id="chevron-up" viewBox="0 0 24 24"><path d="m6 15 6-6 6 6"/></symbol>
|
||||
<symbol id="chevron-left" viewBox="0 0 24 24"><path d="m15 6-6 6 6 6"/></symbol>
|
||||
<symbol id="chevron-right" viewBox="0 0 24 24"><path d="m9 6 6 6-6 6"/></symbol>
|
||||
<symbol id="chevrons-left" viewBox="0 0 24 24"><path d="m11 6-6 6 6 6M18 6l-6 6 6 6"/></symbol>
|
||||
<symbol id="chevrons-right" viewBox="0 0 24 24"><path d="m6 6 6 6-6 6M13 6l6 6-6 6"/></symbol>
|
||||
<symbol id="more" viewBox="0 0 24 24"><circle cx="5.5" cy="12" r="1.2"/><circle cx="12" cy="12" r="1.2"/><circle cx="18.5" cy="12" r="1.2"/></symbol>
|
||||
<symbol id="menu" viewBox="0 0 24 24"><path d="M4 6.5h16M4 12h16M4 17.5h16"/></symbol>
|
||||
<symbol id="settings" viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.6 1.6 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.6 1.6 0 0 0-2.7 1.1v.3a2 2 0 1 1-4 0v-.1a1.6 1.6 0 0 0-2.7-1.1l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1A1.6 1.6 0 0 0 3.6 15H3.3a2 2 0 1 1 0-4h.1A1.6 1.6 0 0 0 4.5 8.3l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.6 1.6 0 0 0 1.8.3h0A1.6 1.6 0 0 0 10 4.3V4a2 2 0 1 1 4 0v.1a1.6 1.6 0 0 0 1 1.5 1.6 1.6 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.6 1.6 0 0 0-.3 1.8v0a1.6 1.6 0 0 0 1.5 1h.3a2 2 0 1 1 0 4h-.1a1.6 1.6 0 0 0-1.6 1z"/></symbol>
|
||||
<symbol id="palette" viewBox="0 0 24 24"><path d="M12 3a9 9 0 0 0 0 18c1.2 0 1.8-.8 1.8-1.7 0-.5-.2-.9-.5-1.2-.3-.4-.5-.8-.5-1.3 0-.9.8-1.7 1.7-1.7H16a5 5 0 0 0 5-5C21 6.3 17 3 12 3z"/><circle cx="7.5" cy="11" r="1"/><circle cx="10" cy="7" r="1"/><circle cx="14.5" cy="7" r="1"/></symbol>
|
||||
<symbol id="logout" viewBox="0 0 24 24"><path d="M9.5 20.5H5A1.5 1.5 0 0 1 3.5 19V5A1.5 1.5 0 0 1 5 3.5h4.5"/><path d="m15.5 16.5 4.5-4.5-4.5-4.5"/><path d="M20 12H9.5"/></symbol>
|
||||
<symbol id="save" viewBox="0 0 24 24"><path d="M5 3.5h11.5l4 4V19a1.5 1.5 0 0 1-1.5 1.5H5A1.5 1.5 0 0 1 3.5 19V5A1.5 1.5 0 0 1 5 3.5z"/><path d="M7.5 3.5v5h8v-5"/><path d="M7.5 20.5v-6h9v6"/></symbol>
|
||||
<symbol id="undo" viewBox="0 0 24 24"><path d="M9 14.5 4 9.5l5-5"/><path d="M4 9.5h10.5a5.5 5.5 0 0 1 0 11H11"/></symbol>
|
||||
<symbol id="refresh" viewBox="0 0 24 24"><path d="M20.5 11.5A8.5 8.5 0 0 0 5.8 6.2L3.5 8.5"/><path d="M3.5 3.5v5h5"/><path d="M3.5 12.5a8.5 8.5 0 0 0 14.7 5.3l2.3-2.3"/><path d="M20.5 20.5v-5h-5"/></symbol>
|
||||
<symbol id="trash" viewBox="0 0 24 24"><path d="M3.5 6.5h17"/><path d="M8.5 6.5V4.5A1.5 1.5 0 0 1 10 3h4a1.5 1.5 0 0 1 1.5 1.5v2"/><path d="M6 6.5l1 13a1.5 1.5 0 0 0 1.5 1.5h7a1.5 1.5 0 0 0 1.5-1.5l1-13"/><path d="M10 11v6M14 11v6"/></symbol>
|
||||
<symbol id="copy" viewBox="0 0 24 24"><rect x="8.5" y="8.5" width="12" height="12" rx="1.5"/><path d="M15.5 8.5V5A1.5 1.5 0 0 0 14 3.5H5A1.5 1.5 0 0 0 3.5 5v9A1.5 1.5 0 0 0 5 15.5h3.5"/></symbol>
|
||||
<symbol id="printer" viewBox="0 0 24 24"><path d="M6.5 9V3.5h11V9"/><path d="M6.5 17.5H5A1.5 1.5 0 0 1 3.5 16v-5.5A1.5 1.5 0 0 1 5 9h14a1.5 1.5 0 0 1 1.5 1.5V16a1.5 1.5 0 0 1-1.5 1.5h-1.5"/><path d="M6.5 14h11v6.5h-11z"/></symbol>
|
||||
<symbol id="mail" viewBox="0 0 24 24"><rect x="2.5" y="4.5" width="19" height="15" rx="1.5"/><path d="m3 6 9 7 9-7"/></symbol>
|
||||
<symbol id="download" viewBox="0 0 24 24"><path d="M12 3.5v12"/><path d="m7 10.5 5 5 5-5"/><path d="M4 20.5h16"/></symbol>
|
||||
<symbol id="upload" viewBox="0 0 24 24"><path d="M12 15.5v-12"/><path d="m7 8.5 5-5 5 5"/><path d="M4 20.5h16"/></symbol>
|
||||
<symbol id="paperclip" viewBox="0 0 24 24"><path d="m20.5 11.5-8.4 8.4a5.3 5.3 0 0 1-7.5-7.5l8.4-8.4a3.5 3.5 0 0 1 5 5l-8.4 8.4a1.8 1.8 0 0 1-2.5-2.5l7.7-7.7"/></symbol>
|
||||
<symbol id="link" viewBox="0 0 24 24"><path d="M10 13.5a4.5 4.5 0 0 0 6.4.4l3-3a4.5 4.5 0 0 0-6.4-6.4l-1.7 1.7"/><path d="M14 10.5a4.5 4.5 0 0 0-6.4-.4l-3 3a4.5 4.5 0 0 0 6.4 6.4l1.7-1.7"/></symbol>
|
||||
<symbol id="external" viewBox="0 0 24 24"><path d="M14 3.5h6.5V10"/><path d="M20.5 3.5 11 13"/><path d="M18 14v5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 4 19V8a1.5 1.5 0 0 1 1.5-1.5H10"/></symbol>
|
||||
<symbol id="edit" viewBox="0 0 24 24"><path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L8 18l-4 1 1-4z"/><path d="m14.5 5.5 3 3"/></symbol>
|
||||
<symbol id="eye" viewBox="0 0 24 24"><path d="M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12z"/><circle cx="12" cy="12" r="3"/></symbol>
|
||||
<symbol id="lock" viewBox="0 0 24 24"><rect x="4.5" y="10.5" width="15" height="10" rx="1.5"/><path d="M8 10.5V7.5a4 4 0 0 1 8 0v3"/></symbol>
|
||||
<symbol id="key" viewBox="0 0 24 24"><circle cx="8" cy="15" r="4.5"/><path d="m11.2 11.8 8.8-8.8"/><path d="m16.5 6.5 2.5 2.5"/><path d="m14.5 8.5 2 2"/></symbol>
|
||||
<symbol id="star" viewBox="0 0 24 24"><path d="m12 3 2.8 5.7 6.2.9-4.5 4.4 1.1 6.2L12 17.3l-5.6 2.9 1.1-6.2L3 9.6l6.2-.9z"/></symbol>
|
||||
<symbol id="columns" viewBox="0 0 24 24"><rect x="3.5" y="4" width="17" height="16" rx="1.5"/><path d="M9.2 4v16M14.8 4v16"/></symbol>
|
||||
<symbol id="filter" viewBox="0 0 24 24"><path d="M3.5 4.5h17l-6.5 8v6l-4 2v-8z"/></symbol>
|
||||
<symbol id="sort" viewBox="0 0 24 24"><path d="M7 4v16M3.5 16.5 7 20l3.5-3.5"/><path d="M17 20V4M13.5 7.5 17 4l3.5 3.5"/></symbol>
|
||||
<symbol id="calendar" viewBox="0 0 24 24"><rect x="3.5" y="5" width="17" height="15.5" rx="1.5"/><path d="M3.5 10h17M8 3v4M16 3v4"/></symbol>
|
||||
<symbol id="folder" viewBox="0 0 24 24"><path d="M3.5 6.5A1.5 1.5 0 0 1 5 5h4.5l2 2.5H19a1.5 1.5 0 0 1 1.5 1.5v9.5A1.5 1.5 0 0 1 19 20H5a1.5 1.5 0 0 1-1.5-1.5z"/></symbol>
|
||||
<symbol id="grip" viewBox="0 0 24 24"><circle cx="9" cy="6" r="1"/><circle cx="15" cy="6" r="1"/><circle cx="9" cy="12" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="9" cy="18" r="1"/><circle cx="15" cy="18" r="1"/></symbol>
|
||||
<symbol id="layout" viewBox="0 0 24 24"><rect x="3.5" y="3.5" width="17" height="17" rx="1.5"/><path d="M3.5 9.5h17M9.5 9.5v11"/></symbol>
|
||||
<symbol id="grid" viewBox="0 0 24 24"><rect x="3.5" y="3.5" width="7" height="7" rx="1"/><rect x="13.5" y="3.5" width="7" height="7" rx="1"/><rect x="3.5" y="13.5" width="7" height="7" rx="1"/><rect x="13.5" y="13.5" width="7" height="7" rx="1"/></symbol>
|
||||
<symbol id="list" viewBox="0 0 24 24"><path d="M9 6h11.5M9 12h11.5M9 18h11.5"/><path d="M4 6h.01M4 12h.01M4 18h.01"/></symbol>
|
||||
<symbol id="activity" viewBox="0 0 24 24"><path d="M2.5 12h4l3-8 5 16 3-8h4"/></symbol>
|
||||
<symbol id="database" viewBox="0 0 24 24"><ellipse cx="12" cy="5.5" rx="8" ry="3"/><path d="M4 5.5v13c0 1.7 3.6 3 8 3s8-1.3 8-3v-13"/><path d="M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3"/></symbol>
|
||||
<symbol id="server" viewBox="0 0 24 24"><rect x="3" y="3.5" width="18" height="7" rx="1.5"/><rect x="3" y="13.5" width="18" height="7" rx="1.5"/><path d="M7 7h.01M7 17h.01"/></symbol>
|
||||
<symbol id="send" viewBox="0 0 24 24"><path d="M21 3 10.5 13.5"/><path d="M21 3 14.5 21l-4-7.5L3 9.5z"/></symbol>
|
||||
<symbol id="euro" viewBox="0 0 24 24"><path d="M18 6.5A7 7 0 0 0 7 11.9 7 7 0 0 0 18 17.5"/><path d="M4 10h9M4 14h9"/></symbol>
|
||||
<symbol id="pin" viewBox="0 0 24 24"><path d="M12 21s-6.5-6.2-6.5-11a6.5 6.5 0 0 1 13 0c0 4.8-6.5 11-6.5 11z"/><circle cx="12" cy="10" r="2.5"/></symbol>
|
||||
<symbol id="phone" viewBox="0 0 24 24"><path d="M20.5 16.6v2.8a1.9 1.9 0 0 1-2 1.9A18.7 18.7 0 0 1 2.7 5.5a1.9 1.9 0 0 1 1.9-2h2.8a1.9 1.9 0 0 1 1.9 1.6c.1.9.4 1.8.7 2.7a1.9 1.9 0 0 1-.4 2L8.4 11a15 15 0 0 0 4.6 4.6l1.2-1.2a1.9 1.9 0 0 1 2-.4c.9.3 1.8.6 2.7.7a1.9 1.9 0 0 1 1.6 1.9z"/></symbol>
|
||||
<symbol id="tag" viewBox="0 0 24 24"><path d="M3.5 12.6V4.5a1 1 0 0 1 1-1h8.1l8.4 8.4a1.5 1.5 0 0 1 0 2.1l-7 7a1.5 1.5 0 0 1-2.1 0z"/><circle cx="8" cy="8" r="1.3"/></symbol>
|
||||
<symbol id="command" viewBox="0 0 24 24"><path d="M9 6v12M15 6v12M6 9h12M6 15h12"/><path d="M9 6a3 3 0 1 0-3 3M15 6a3 3 0 1 1 3 3M9 18a3 3 0 1 1-3-3M15 18a3 3 0 1 0 3-3"/></symbol>
|
||||
<symbol id="keyboard" viewBox="0 0 24 24"><rect x="2.5" y="5.5" width="19" height="13" rx="1.5"/><path d="M6 9.5h.01M9.5 9.5h.01M13 9.5h.01M16.5 9.5h.01M6 13h.01M18 13h.01M8 15.5h8"/></symbol>
|
||||
<symbol id="sidebar" viewBox="0 0 24 24"><rect x="3.5" y="4" width="17" height="16" rx="1.5"/><path d="M9.5 4v16"/></symbol>
|
||||
<symbol id="radar" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5"/><path d="M12 12 18.5 5.8"/></symbol>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 14 KiB |
@@ -0,0 +1,99 @@
|
||||
// Khaemhat browser interop (SPEC §1.1: JavaScript only as minimal interop, no framework, no bundler).
|
||||
// Everything lives under window.khaemhat; .NET calls these functions through IJSRuntime.
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
let shortcutTarget = null;
|
||||
let shortcutCombos = new Set();
|
||||
let unloadGuard = false;
|
||||
|
||||
// The combination of a key event in the form used by KeyboardShortcuts.cs: "Ctrl+Shift+K", "F9", "Alt+1", "Escape".
|
||||
function comboOf(e) {
|
||||
let key;
|
||||
if (/^Key[A-Z]$/.test(e.code)) key = e.code.substring(3);
|
||||
else if (/^Digit[0-9]$/.test(e.code)) key = e.code.substring(5);
|
||||
else if (e.key === " ") key = "Space";
|
||||
else key = e.key;
|
||||
if (key === "Control" || key === "Alt" || key === "Shift" || key === "Meta") return null;
|
||||
let combo = "";
|
||||
if (e.ctrlKey || e.metaKey) combo += "Ctrl+";
|
||||
if (e.altKey) combo += "Alt+";
|
||||
if (e.shiftKey) combo += "Shift+";
|
||||
return combo + key;
|
||||
}
|
||||
|
||||
function onKeyDown(e) {
|
||||
if (!shortcutTarget || e.isComposing) return;
|
||||
const combo = comboOf(e);
|
||||
if (!combo || !shortcutCombos.has(combo)) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
shortcutTarget.invokeMethodAsync("OnShortcut", combo).catch(function () { /* circuit gone */ });
|
||||
}
|
||||
|
||||
function onBeforeUnload(e) {
|
||||
if (!unloadGuard) return;
|
||||
e.preventDefault();
|
||||
e.returnValue = "";
|
||||
}
|
||||
|
||||
window.khaemhat = {
|
||||
// Sets (or removes, with null) attributes of the root element: data-theme, data-accent, data-density...
|
||||
applyRoot: function (attributes) {
|
||||
const root = document.documentElement;
|
||||
for (const name in attributes) {
|
||||
const value = attributes[name];
|
||||
if (value === null || value === undefined) root.removeAttribute(name);
|
||||
else root.setAttribute(name, value);
|
||||
}
|
||||
},
|
||||
|
||||
// Registers the .NET object that receives the shortcuts, and the combinations it wants.
|
||||
startShortcuts: function (target, combos) {
|
||||
shortcutTarget = target;
|
||||
shortcutCombos = new Set(combos);
|
||||
document.removeEventListener("keydown", onKeyDown, true);
|
||||
document.addEventListener("keydown", onKeyDown, true);
|
||||
},
|
||||
|
||||
stopShortcuts: function () {
|
||||
shortcutTarget = null;
|
||||
document.removeEventListener("keydown", onKeyDown, true);
|
||||
},
|
||||
|
||||
// Asks the browser to confirm leaving the page while a tab has unsaved changes.
|
||||
setUnloadGuard: function (on) {
|
||||
unloadGuard = !!on;
|
||||
window.removeEventListener("beforeunload", onBeforeUnload);
|
||||
if (unloadGuard) window.addEventListener("beforeunload", onBeforeUnload);
|
||||
},
|
||||
|
||||
// The window width, to collapse the menu under 1100 px when the user never chose.
|
||||
viewportWidth: function () {
|
||||
return window.innerWidth;
|
||||
},
|
||||
|
||||
// Round trip for the latency shown in the status bar.
|
||||
ping: function () {
|
||||
return true;
|
||||
},
|
||||
|
||||
// Moves the focus to the first element matching a selector.
|
||||
focus: function (selector) {
|
||||
const element = document.querySelector(selector);
|
||||
if (element) {
|
||||
element.focus();
|
||||
if (typeof element.select === "function") element.select();
|
||||
}
|
||||
},
|
||||
|
||||
print: function () {
|
||||
window.print();
|
||||
},
|
||||
|
||||
// Opens an address (the wiki help) in a new window, without giving it access to this one.
|
||||
openWindow: function (url) {
|
||||
window.open(url, "_blank", "noopener");
|
||||
}
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,125 @@
|
||||
using System.Globalization;
|
||||
using Khaemhat.Application.Localization;
|
||||
using Khaemhat.Application.Preferences;
|
||||
|
||||
namespace Khaemhat.Application.Tests;
|
||||
|
||||
/// <summary>The texts of the interface (SPEC §1.9, §10.8) and the user preferences (SPEC §10.6, §11.12).</summary>
|
||||
[TestClass]
|
||||
public sealed class LocalizationAndPreferencesTests
|
||||
{
|
||||
private static readonly CultureInfo Italian = CultureInfo.GetCultureInfo("it-IT");
|
||||
|
||||
[TestMethod]
|
||||
public void Texts_FlattenNestedObjects_AndUnderscoreNamesTheParent()
|
||||
{
|
||||
var texts = Provider(("a.json", """{"Shell": {"Menu": {"Home": "Home", "Parties": {"_": "Anagrafiche", "Customers": "Clienti"}}}}"""));
|
||||
|
||||
Assert.AreEqual("Home", texts["Shell.Menu.Home"]);
|
||||
Assert.AreEqual("Anagrafiche", texts["Shell.Menu.Parties"]);
|
||||
Assert.AreEqual("Clienti", texts["Shell.Menu.Parties.Customers"]);
|
||||
Assert.HasCount(3, texts.Keys);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Texts_MissingKeysAreVisible()
|
||||
{
|
||||
var texts = Provider(("a.json", """{"A": "a"}"""));
|
||||
|
||||
Assert.AreEqual("[B.C]", texts["B.C"]);
|
||||
Assert.IsFalse(texts.Contains("B.C"));
|
||||
Assert.IsTrue(texts.Contains("A"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Texts_RefuseAKeyDefinedTwice_AcrossFiles()
|
||||
{
|
||||
var error = Assert.ThrowsExactly<InvalidDataException>(() => Provider(("a.json", """{"A": {"B": "1"}}"""), ("b.json", """{"A": {"B": "2"}}""")));
|
||||
|
||||
StringAssert.Contains(error.Message, "A.B");
|
||||
StringAssert.Contains(error.Message, "b.json");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Texts_RefuseValuesThatAreNotStrings()
|
||||
{
|
||||
Assert.ThrowsExactly<InvalidDataException>(() => Provider(("a.json", """{"A": 3}""")));
|
||||
Assert.ThrowsExactly<InvalidDataException>(() => Provider(("a.json", """["A"]""")));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Texts_FormatInTheCulture()
|
||||
{
|
||||
var texts = Provider(("a.json", """{"Total": "Totale {0:N2}", "Days": "restano {0} giorni"}"""));
|
||||
|
||||
Assert.AreEqual("Totale 1.234,50", texts.Format("Total", 1234.5m));
|
||||
Assert.AreEqual("restano 7 giorni", texts.Format("Days", 7));
|
||||
Assert.AreEqual("€ 1.234,50", texts.Money(1234.5m));
|
||||
Assert.AreEqual("13/10/2026", texts.Date(new DateOnly(2026, 10, 13)));
|
||||
Assert.AreEqual("1.235", texts.Number(1234.5m));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Preferences_RoundTripThroughSettings()
|
||||
{
|
||||
var preferences = new UserPreferences
|
||||
{
|
||||
Theme = ThemeMode.HighContrast,
|
||||
Accent = "malachite",
|
||||
Density = Density.Compact,
|
||||
TextSize = 120,
|
||||
TabularNumbers = false,
|
||||
ReducedMotion = true,
|
||||
Tooltips = false,
|
||||
RowHover = false,
|
||||
MenuCollapsed = true,
|
||||
ShowDashboard = false,
|
||||
StartPage = StartPage.Page,
|
||||
StartPath = "/anagrafiche/clienti",
|
||||
};
|
||||
|
||||
var back = UserPreferences.FromSettings(preferences.ToSettings());
|
||||
|
||||
Assert.AreEqual(preferences, back);
|
||||
Assert.AreEqual("high-contrast", back.ThemeAttribute);
|
||||
Assert.AreEqual("compact", back.DensityAttribute);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Preferences_IgnoreUnknownOrUnsafeValues()
|
||||
{
|
||||
var settings = new Dictionary<string, string?>(StringComparer.Ordinal)
|
||||
{
|
||||
[PreferenceKeys.Theme] = "neon",
|
||||
[PreferenceKeys.Accent] = "<script>",
|
||||
[PreferenceKeys.TextSize] = "300",
|
||||
[PreferenceKeys.TabularNumbers] = "forse",
|
||||
[PreferenceKeys.StartPage] = "page",
|
||||
[PreferenceKeys.StartPath] = "https://example.com/",
|
||||
};
|
||||
|
||||
var preferences = UserPreferences.FromSettings(settings);
|
||||
|
||||
Assert.AreEqual(UserPreferences.Default.Theme, preferences.Theme);
|
||||
Assert.AreEqual(UserPreferences.Default.Accent, preferences.Accent);
|
||||
Assert.AreEqual(UserPreferences.Default.TextSize, preferences.TextSize);
|
||||
Assert.AreEqual(UserPreferences.Default.TabularNumbers, preferences.TabularNumbers);
|
||||
Assert.IsNull(preferences.StartPath);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("/", true)]
|
||||
[DataRow("/anagrafiche/clienti", true)]
|
||||
[DataRow("/profilo?scheda=aspetto", true)]
|
||||
[DataRow("//evil.example", false)]
|
||||
[DataRow("/\\evil.example", false)]
|
||||
[DataRow("https://evil.example", false)]
|
||||
[DataRow("anagrafiche", false)]
|
||||
[DataRow("", false)]
|
||||
[DataRow(null, false)]
|
||||
public void Preferences_StartPathMustBeLocal(string? path, bool local) =>
|
||||
Assert.AreEqual(local, UserPreferences.IsLocalPath(path));
|
||||
|
||||
private static JsonTextProvider Provider(params (string Name, string Json)[] documents) =>
|
||||
new(Italian, documents.Select(d => new KeyValuePair<string, string>(d.Name, d.Json)));
|
||||
}
|
||||
@@ -70,8 +70,8 @@ public sealed class MappingTests
|
||||
string[] expected =
|
||||
[
|
||||
"sys_companies", "sys_data_protection_keys", "sys_job_locks", "sys_job_runs", "sys_license_activations", "sys_licenses", "sys_log",
|
||||
"sys_notifications", "sys_roles_templates", "sys_scheduled_tasks", "sys_security_audit", "sys_sessions", "sys_settings", "sys_users",
|
||||
"audit_log", "notifications", "role_permissions", "roles", "user_permission_overrides", "user_roles", "user_sessions", "users",
|
||||
"sys_notifications", "sys_roles_templates", "sys_scheduled_tasks", "sys_security_audit", "sys_sessions", "sys_settings", "sys_user_settings", "sys_users",
|
||||
"audit_log", "notifications", "role_permissions", "roles", "user_permission_overrides", "user_roles", "user_sessions", "user_settings", "users",
|
||||
];
|
||||
CollectionAssert.AreEquivalent(expected, registry.Maps.Select(m => m.Table).ToArray());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Khaemhat.Application.Preferences;
|
||||
using Khaemhat.Web.Shell;
|
||||
|
||||
namespace Khaemhat.Web.Tests.Shell;
|
||||
|
||||
/// <summary>
|
||||
/// The rule of SPEC §1.9 and issue #33: components contain no literal interface texts, every text comes from
|
||||
/// <c>Resources/it-IT/*.json</c>, and every key the code asks for exists.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public sealed partial class LocalizationRulesTests
|
||||
{
|
||||
// Words allowed as they are: the product name and the names of things that are not translated.
|
||||
private static readonly HashSet<string> Allowed = new(StringComparer.Ordinal) { "Khaemhat" };
|
||||
|
||||
[TestMethod]
|
||||
public void Components_ContainNoLiteralTexts()
|
||||
{
|
||||
var problems = new List<string>();
|
||||
foreach (var file in ComponentFiles())
|
||||
{
|
||||
foreach (var text in LiteralTexts(File.ReadAllText(file)))
|
||||
{
|
||||
problems.Add(Path.GetRelativePath(Repository.Root, file) + ": " + text);
|
||||
}
|
||||
}
|
||||
|
||||
Assert.IsEmpty(problems, "Texts belong in Resources/it-IT/*.json:\n" + string.Join('\n', problems));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TheCheck_FindsLiteralTexts_AndLetsTheRestThrough()
|
||||
{
|
||||
const string page = """
|
||||
@page "/x"
|
||||
@inject Foo Bar
|
||||
@* A comment with words is fine. *@
|
||||
<h1>@T["Pages.X.Title"]</h1>
|
||||
<p class="lead">Testo scritto a mano</p>
|
||||
<button title="Chiudi" aria-label="@T["Common.Close"]">@T.Format("Pages.X.Count", items.Count(i => i > 0))</button>
|
||||
<img alt="" src="x.svg" />
|
||||
<span>@(a ? T["A"] : T["B"]) · @Model.Name</span>
|
||||
<input placeholder="Cerca" />
|
||||
@foreach (var item in Items.Where(i => i.Level > 2))
|
||||
{
|
||||
<li>@item.Name</li>
|
||||
}
|
||||
<span>× ● Khaemhat @Session.Company?.Code @if (n.Body is not null) {<br />}</span>
|
||||
@code {
|
||||
private string Text => "Un testo nel codice";
|
||||
}
|
||||
""";
|
||||
|
||||
var found = LiteralTexts(page).ToList();
|
||||
|
||||
CollectionAssert.AreEquivalent(new[] { "Testo scritto a mano", "title=\"Chiudi\"", "placeholder=\"Cerca\"" }, found);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EveryTextKeyInTheCode_Exists()
|
||||
{
|
||||
var missing = new List<string>();
|
||||
foreach (var file in Directory.EnumerateFiles(Path.Combine(Repository.Root, "src", "Khaemhat.Web"), "*.*", SearchOption.AllDirectories)
|
||||
.Where(f => (f.EndsWith(".razor", StringComparison.Ordinal) || f.EndsWith(".cs", StringComparison.Ordinal)) && !Repository.IsBuildOutput(f)))
|
||||
{
|
||||
foreach (Match match in KeyPattern().Matches(File.ReadAllText(file)))
|
||||
{
|
||||
var key = match.Groups[1].Value;
|
||||
if (!key.EndsWith('.') && !ShellTests.Texts.Contains(key))
|
||||
{
|
||||
missing.Add(Path.GetFileName(file) + ": " + key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.IsEmpty(missing, string.Join('\n', missing));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void KeysBuiltFromValues_Exist()
|
||||
{
|
||||
var keys = new List<string>();
|
||||
keys.AddRange(Enum.GetValues<ThemeMode>().Select(v => "Pages.Profile.Theme." + v));
|
||||
keys.AddRange(Enum.GetValues<Density>().Select(v => "Pages.Profile.Density." + v));
|
||||
keys.AddRange(Enum.GetValues<StartPage>().Select(v => "Pages.Profile.Start." + v));
|
||||
keys.AddRange(Enum.GetValues<ShortcutScope>().Select(v => "Pages.Profile.Shortcuts." + v));
|
||||
keys.AddRange(UserPreferences.Accents.Select(a => "Pages.Profile.Accent." + a));
|
||||
|
||||
Assert.IsEmpty(keys.Where(k => !ShellTests.Texts.Contains(k)).ToList());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TextFiles_AvoidCharactersGiteaFlagsAsAmbiguous()
|
||||
{
|
||||
var folder = Path.Combine(Repository.Root, "src", "Khaemhat.Web", "Resources");
|
||||
foreach (var file in Directory.EnumerateFiles(folder, "*.json", SearchOption.AllDirectories))
|
||||
{
|
||||
var text = File.ReadAllText(file);
|
||||
foreach (var c in new[] { '–', '×', '−', '›' })
|
||||
{
|
||||
Assert.DoesNotContain(c.ToString(), text, Path.GetFileName(file) + " contains U+" + ((int)c).ToString("X4", System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static IEnumerable<string> ComponentFiles() =>
|
||||
Directory.EnumerateFiles(Path.Combine(Repository.Root, "src", "Khaemhat.Web", "Components"), "*.razor", SearchOption.AllDirectories)
|
||||
.Where(f => !Repository.IsBuildOutput(f));
|
||||
|
||||
/// <summary>The literal texts of a component: text between tags and text attributes, once code and expressions are removed.</summary>
|
||||
/// <param name="razor">The component source.</param>
|
||||
/// <returns>The texts found.</returns>
|
||||
internal static IEnumerable<string> LiteralTexts(string razor)
|
||||
{
|
||||
var markup = CommentPattern().Replace(razor, string.Empty);
|
||||
var code = markup.IndexOf("@code", StringComparison.Ordinal);
|
||||
if (code >= 0)
|
||||
{
|
||||
markup = markup[..code];
|
||||
}
|
||||
|
||||
var lines = markup.Split('\n').Select(l => CodeLinePattern().IsMatch(l) ? string.Empty : l);
|
||||
markup = StripExpressions(string.Join('\n', lines));
|
||||
|
||||
foreach (Match attribute in AttributePattern().Matches(markup))
|
||||
{
|
||||
if (HasWords(attribute.Groups[2].Value))
|
||||
{
|
||||
yield return attribute.Groups[1].Value + "=\"" + attribute.Groups[2].Value + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Match node in TextNodePattern().Matches(markup))
|
||||
{
|
||||
var text = node.Groups[1].Value.Trim();
|
||||
if (HasWords(text))
|
||||
{
|
||||
yield return text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool HasWords(string text)
|
||||
{
|
||||
var words = WordPattern().Matches(EntityPattern().Replace(text, " ")).Select(m => m.Value).Where(w => !Allowed.Contains(w));
|
||||
return words.Any();
|
||||
}
|
||||
|
||||
// Removes Razor expressions: @T["..."], @T.Format(...), @(...), @item.Name, @Model.Items[0].Text...
|
||||
private static string StripExpressions(string text)
|
||||
{
|
||||
var result = new StringBuilder(text.Length);
|
||||
var i = 0;
|
||||
while (i < text.Length)
|
||||
{
|
||||
if (text[i] != '@' || i + 1 >= text.Length)
|
||||
{
|
||||
result.Append(text[i++]);
|
||||
continue;
|
||||
}
|
||||
|
||||
i++;
|
||||
if (text[i] == '(')
|
||||
{
|
||||
i = SkipBalanced(text, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
var start = i;
|
||||
while (i < text.Length && (char.IsLetterOrDigit(text[i]) || text[i] == '_'))
|
||||
{
|
||||
i++;
|
||||
while (i < text.Length && text[i] is '[' or '(')
|
||||
{
|
||||
i = SkipBalanced(text, i);
|
||||
}
|
||||
|
||||
// Member access, also null-conditional (?.) and null-forgiving (!.).
|
||||
if (i + 2 < text.Length && text[i] is '?' or '!' && text[i + 1] == '.' && char.IsLetter(text[i + 2]))
|
||||
{
|
||||
i += 2;
|
||||
}
|
||||
else if (i + 1 < text.Length && text[i] == '.' && char.IsLetter(text[i + 1]))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// @if (...) { ... } written inside a line of markup: the condition is code.
|
||||
if (text.AsSpan(start, i - start) is "if" or "foreach" or "for" or "while" or "switch")
|
||||
{
|
||||
while (i < text.Length && text[i] == ' ')
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i < text.Length && text[i] == '(')
|
||||
{
|
||||
i = SkipBalanced(text, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
private static int SkipBalanced(string text, int start)
|
||||
{
|
||||
var depth = 0;
|
||||
var quote = '\0';
|
||||
for (var i = start; i < text.Length; i++)
|
||||
{
|
||||
var c = text[i];
|
||||
if (quote != '\0')
|
||||
{
|
||||
if (c == '\\')
|
||||
{
|
||||
i++;
|
||||
}
|
||||
else if (c == quote)
|
||||
{
|
||||
quote = '\0';
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '"' or '\'':
|
||||
quote = c;
|
||||
break;
|
||||
case '(' or '[' or '{':
|
||||
depth++;
|
||||
break;
|
||||
case ')' or ']' or '}':
|
||||
depth--;
|
||||
if (depth == 0)
|
||||
{
|
||||
return i + 1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return text.Length;
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"@\*.*?\*@", RegexOptions.Singleline)]
|
||||
private static partial Regex CommentPattern();
|
||||
|
||||
// Lines of C#: directives, control flow, braces, local declarations and assignments inside code blocks.
|
||||
[GeneratedRegex(@"^\s*(@(page|inject|using|attribute|layout|implements|inherits|namespace|rendermode|typeparam|foreach|for|if|switch|while|else)\b|@\{|\{|\}|(else|case|default|break|var|if|foreach|return)\b|[a-z_][A-Za-z0-9_.]*\s*(=[^=>]|\+\+|--)|(string|int|bool|long)\??\s)")]
|
||||
private static partial Regex CodeLinePattern();
|
||||
|
||||
[GeneratedRegex("\\b(title|placeholder|alt|aria-label|label)=\"([^\"]*)\"")]
|
||||
private static partial Regex AttributePattern();
|
||||
|
||||
[GeneratedRegex(@">([^<>]+)<")]
|
||||
private static partial Regex TextNodePattern();
|
||||
|
||||
[GeneratedRegex(@"\p{L}{2,}")]
|
||||
private static partial Regex WordPattern();
|
||||
|
||||
[GeneratedRegex(@"&[a-zA-Z]+;|&#\d+;")]
|
||||
private static partial Regex EntityPattern();
|
||||
|
||||
[GeneratedRegex("\"((?:Shell|Pages|Auth|Common)\\.[A-Za-z0-9_.]+)\"")]
|
||||
private static partial Regex KeyPattern();
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using Khaemhat.Application.Preferences;
|
||||
using Khaemhat.Application.Security;
|
||||
using Khaemhat.Core.Security;
|
||||
using Khaemhat.Web.Tests.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Khaemhat.Web.Tests.Shell;
|
||||
|
||||
/// <summary>The preferences are kept per user: instance accounts in the system database, company users in their company (issue #31).</summary>
|
||||
[TestClass]
|
||||
public sealed class PreferencesStoreTests
|
||||
{
|
||||
[TestMethod]
|
||||
public async Task Preferences_AreSavedPerUser_InTheRightDatabase()
|
||||
{
|
||||
var (app, _, company) = await TestInstance.StartAsync(CancellationToken.None);
|
||||
await using (app)
|
||||
{
|
||||
var settings = app.Services.GetRequiredService<UserSettingsService>();
|
||||
var root = new Actor(TestInstance.SuperUser, UserLevel.SuperUser, 1, null, null);
|
||||
var companyUser = new Actor("mario", UserLevel.Standard, null, 1, company);
|
||||
var otherCompanyUser = new Actor("lucia", UserLevel.Standard, null, 2, company);
|
||||
|
||||
Assert.AreEqual(UserPreferences.Default, await settings.GetPreferencesAsync(root));
|
||||
|
||||
var dark = UserPreferences.Default with { Theme = ThemeMode.Dark, Accent = "ametista", MenuCollapsed = true };
|
||||
await settings.SavePreferencesAsync(root, dark);
|
||||
await settings.SavePreferencesAsync(companyUser, UserPreferences.Default with { Density = Density.Compact });
|
||||
|
||||
Assert.AreEqual(dark, await settings.GetPreferencesAsync(root));
|
||||
Assert.AreEqual(Density.Compact, (await settings.GetPreferencesAsync(companyUser)).Density);
|
||||
Assert.AreEqual(ThemeMode.Auto, (await settings.GetPreferencesAsync(companyUser)).Theme, "Users do not share preferences.");
|
||||
Assert.AreEqual(UserPreferences.Default, await settings.GetPreferencesAsync(otherCompanyUser));
|
||||
|
||||
// A saved value can be changed and removed.
|
||||
await settings.SetAsync(root, PreferenceKeys.OpenTabs, "{\"active\":\"/\"}");
|
||||
Assert.AreEqual("{\"active\":\"/\"}", await settings.GetAsync(root, PreferenceKeys.OpenTabs));
|
||||
await settings.SetAsync(root, PreferenceKeys.OpenTabs, null);
|
||||
Assert.IsNull(await settings.GetAsync(root, PreferenceKeys.OpenTabs));
|
||||
|
||||
// Limits: the key is short, the value at most 64 KB.
|
||||
await Assert.ThrowsExactlyAsync<ValidationFailedException>(() => settings.SetAsync(root, new string('k', 201), "x"));
|
||||
await Assert.ThrowsExactlyAsync<ValidationFailedException>(() => settings.SetAsync(root, "ui.big", new string('x', UserSettingsService.MaxValueLength + 1)));
|
||||
await app.StopAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace Khaemhat.Web.Tests.Shell;
|
||||
|
||||
/// <summary>The repository the tests run from, to read sources, wiki pages and assets.</summary>
|
||||
internal static class Repository
|
||||
{
|
||||
private static readonly Lazy<string> RootPath = new(() =>
|
||||
{
|
||||
for (var folder = new DirectoryInfo(AppContext.BaseDirectory); folder is not null; folder = folder.Parent)
|
||||
{
|
||||
if (File.Exists(Path.Combine(folder.FullName, "Khaemhat.sln")))
|
||||
{
|
||||
return folder.FullName;
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Khaemhat.sln not found above " + AppContext.BaseDirectory);
|
||||
});
|
||||
|
||||
/// <summary>The folder holding <c>Khaemhat.sln</c>.</summary>
|
||||
public static string Root => RootPath.Value;
|
||||
|
||||
/// <summary>Whether a file is under <c>bin/</c> or <c>obj/</c>.</summary>
|
||||
/// <param name="path">The file.</param>
|
||||
/// <returns><see langword="true"/> for build output.</returns>
|
||||
public static bool IsBuildOutput(string path)
|
||||
{
|
||||
var parts = path.Replace('\\', '/').Split('/');
|
||||
return parts.Contains("bin") || parts.Contains("obj");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
using System.Globalization;
|
||||
using Khaemhat.Application.Localization;
|
||||
using Khaemhat.Application.Preferences;
|
||||
using Khaemhat.Application.Security;
|
||||
using Khaemhat.Web.Hosting;
|
||||
using Khaemhat.Web.Shell;
|
||||
|
||||
namespace Khaemhat.Web.Tests.Shell;
|
||||
|
||||
/// <summary>The shell of SPEC §10.2: tabs, menu, shortcuts and help (issues #25, #26).</summary>
|
||||
[TestClass]
|
||||
public sealed class ShellTests
|
||||
{
|
||||
internal static readonly ITexts Texts = JsonTextProvider.FromAssembly(typeof(KhaemhatApp).Assembly, CultureInfo.GetCultureInfo("it-IT"));
|
||||
|
||||
[TestMethod]
|
||||
public void Tabs_OpenOncePerPath_AndKeepTheLatestAddress()
|
||||
{
|
||||
var tabs = new TabService();
|
||||
|
||||
Assert.AreEqual(TabOpenResult.Opened, tabs.Open("/anagrafiche/clienti", null));
|
||||
Assert.AreEqual(TabOpenResult.Opened, tabs.Open("profilo", null));
|
||||
Assert.AreEqual(TabOpenResult.Activated, tabs.Open("/profilo?scheda=sessioni", null));
|
||||
|
||||
Assert.HasCount(2, tabs.Tabs);
|
||||
Assert.AreEqual("/profilo", tabs.Active!.Path);
|
||||
Assert.AreEqual("/profilo?scheda=sessioni", tabs.Active.Url);
|
||||
Assert.AreEqual("/profilo?scheda=sessioni", tabs.Recent[0]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Tabs_AtTheLimit_CloseTheLeastUsedUnmodifiedTab()
|
||||
{
|
||||
var tabs = new TabService();
|
||||
for (var i = 0; i < TabService.MaxTabs; i++)
|
||||
{
|
||||
tabs.Open("/p" + i.ToString(CultureInfo.InvariantCulture), null);
|
||||
}
|
||||
|
||||
tabs.Find("/p0")!.SetModified(true);
|
||||
tabs.Open("/p1", null);
|
||||
|
||||
Assert.AreEqual(TabOpenResult.OpenedAndEvicted, tabs.Open("/nuova", null));
|
||||
Assert.HasCount(TabService.MaxTabs, tabs.Tabs);
|
||||
Assert.IsNotNull(tabs.Find("/p0"), "A tab with unsaved changes is never closed for room.");
|
||||
Assert.IsNotNull(tabs.Find("/p1"), "A tab used recently stays.");
|
||||
Assert.IsNull(tabs.Find("/p2"), "The least recently used tab goes.");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Tabs_AtTheLimit_WithEveryTabModified_RefuseANewOne()
|
||||
{
|
||||
var tabs = new TabService();
|
||||
for (var i = 0; i < TabService.MaxTabs; i++)
|
||||
{
|
||||
tabs.Open("/p" + i.ToString(CultureInfo.InvariantCulture), null);
|
||||
tabs.Active!.SetModified(true);
|
||||
}
|
||||
|
||||
Assert.AreEqual(TabOpenResult.Refused, tabs.Open("/nuova", null));
|
||||
Assert.HasCount(TabService.MaxTabs, tabs.Tabs);
|
||||
Assert.IsTrue(tabs.HasModified);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Tabs_ClosingTheActiveTab_ShowsANeighbour()
|
||||
{
|
||||
var tabs = new TabService();
|
||||
tabs.Open("/a", null);
|
||||
tabs.Open("/b", null);
|
||||
tabs.Open("/c", null);
|
||||
tabs.Open("/b", null);
|
||||
|
||||
// The tab after the closed one takes its place (the layout then navigates there).
|
||||
var next = tabs.Close(tabs.Active!);
|
||||
|
||||
Assert.AreEqual("/c", next);
|
||||
Assert.HasCount(2, tabs.Tabs);
|
||||
Assert.IsNull(tabs.Find("/b"));
|
||||
tabs.Open(next!, null);
|
||||
Assert.IsNull(tabs.Close(tabs.Find("/a")!), "Closing a tab in the background moves nothing.");
|
||||
Assert.AreEqual("/c", tabs.Active!.Path);
|
||||
Assert.AreEqual("/", tabs.Close(tabs.Active), "Closing the last tab goes back to the home page.");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("/anagrafiche/clienti", "Shell.Menu.Parties.Customers", "Shell.Menu.Parties")]
|
||||
[DataRow("/anagrafiche/clienti/42", "Shell.Menu.Parties.Customers", "Shell.Menu.Parties")]
|
||||
[DataRow("/contabilita", "Shell.Menu.Ledger", "Shell.Menu.Ledger")]
|
||||
[DataRow("/", "Shell.Menu.Home", "Shell.Menu.Home")]
|
||||
public void Menu_FindsTheDeepestEntry(string path, string entry, string area)
|
||||
{
|
||||
Assert.AreEqual(entry, MenuCatalog.Find(path)?.Key);
|
||||
Assert.AreEqual(area, MenuCatalog.FindArea(path)?.Key);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Menu_FollowsTheOrderOfTheSpecification_AndEveryEntryHasTextAndIcon()
|
||||
{
|
||||
string[] order =
|
||||
[
|
||||
"Shell.Menu.Home", "Shell.Menu.Parties", "Shell.Menu.Crm", "Shell.Menu.Sales", "Shell.Menu.Purchases", "Shell.Menu.Inventory",
|
||||
"Shell.Menu.Ledger", "Shell.Menu.Finance", "Shell.Menu.EInvoicing", "Shell.Menu.Assets", "Shell.Menu.Services", "Shell.Menu.Channels",
|
||||
"Shell.Menu.Reports", "Shell.Menu.CompanyTables", "Shell.Menu.Automation", "Shell.Menu.Admin",
|
||||
];
|
||||
CollectionAssert.AreEqual(order, MenuCatalog.Sections.SelectMany(s => s.Items).Select(i => i.Key).ToArray());
|
||||
|
||||
var sprite = File.ReadAllText(Path.Combine(Repository.Root, "src", "Khaemhat.Web", "wwwroot", "icons", "sprite.svg"));
|
||||
foreach (var item in MenuCatalog.All)
|
||||
{
|
||||
Assert.IsTrue(Texts.Contains(item.Key), item.Key);
|
||||
StringAssert.Contains(sprite, "id=\"" + item.Icon + "\"", item.Key);
|
||||
}
|
||||
|
||||
Assert.AreEqual(MenuCatalog.All.Count(), MenuCatalog.All.Select(i => i.Href).Distinct(StringComparer.Ordinal).Count(), "Addresses are unique.");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Help_EveryMenuEntryOpensAnExistingWikiPage()
|
||||
{
|
||||
foreach (var item in MenuCatalog.All.Append(new MenuItem("x", "x", "/profilo", "CORE", null, null)))
|
||||
{
|
||||
var page = HelpLinks.PageFor(item.Href);
|
||||
Assert.IsTrue(File.Exists(Path.Combine(Repository.Root, "docs", "wiki", page + ".md")), item.Href + " -> " + page);
|
||||
}
|
||||
|
||||
Assert.AreEqual("Articoli-e-listini", HelpLinks.PageFor("/anagrafiche/articoli/12?x=1"));
|
||||
Assert.AreEqual(HelpLinks.DefaultBaseUrl + "IVA", HelpLinks.UrlFor(HelpLinks.DefaultBaseUrl, "/contabilita/registri-iva"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Shortcuts_AreUnique_AndDescribed()
|
||||
{
|
||||
var combos = KeyboardShortcuts.All.SelectMany(s => s.Keys).ToList();
|
||||
Assert.HasCount(combos.Distinct(StringComparer.Ordinal).Count(), combos, "A key combination belongs to one command.");
|
||||
foreach (var shortcut in KeyboardShortcuts.All)
|
||||
{
|
||||
Assert.IsTrue(Texts.Contains(shortcut.TextKey), shortcut.TextKey);
|
||||
}
|
||||
|
||||
// Browsers keep Ctrl+W, Ctrl+Tab and Ctrl+N for themselves: each has an alternative that reaches the page.
|
||||
Assert.Contains("Alt+W", KeyboardShortcuts.Find(KeyboardShortcuts.Commands.CloseTab)!.Keys);
|
||||
Assert.Contains("Alt+PageDown", KeyboardShortcuts.Find(KeyboardShortcuts.Commands.NextTab)!.Keys);
|
||||
Assert.Contains("Alt+N", KeyboardShortcuts.Find(KeyboardShortcuts.Commands.New)!.Keys);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Theme_WritesEveryRootAttribute()
|
||||
{
|
||||
var attributes = ThemeService.RootAttributes(new UserPreferences { Theme = ThemeMode.Dark, Accent = "ocra", TextSize = 110, ReducedMotion = true });
|
||||
|
||||
Assert.AreEqual("dark", attributes["data-theme"]);
|
||||
Assert.AreEqual("ocra", attributes["data-accent"]);
|
||||
Assert.AreEqual("110", attributes["data-text-size"]);
|
||||
Assert.AreEqual("reduced", attributes["data-motion"]);
|
||||
Assert.AreEqual("auto", ThemeService.RootAttributes(null)["data-theme"]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SignInMessages_ExistForEveryErrorCode()
|
||||
{
|
||||
var codes = typeof(SecurityErrors).GetFields().Where(f => f.IsLiteral).Select(f => (string)f.GetRawConstantValue()!).ToList();
|
||||
Assert.IsNotEmpty(codes);
|
||||
foreach (var code in codes)
|
||||
{
|
||||
Assert.IsTrue(Texts.Contains("Auth.Errors." + code), code);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user