From 1891ba3d685305dab527bf1697d4b6a4b2612e38 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Sun, 7 Jun 2026 15:09:02 +0200 Subject: [PATCH] clean exemple/navigation to a minimal working example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - index.html: fix title and typo, add missing #error div - config.json: replace project-specific keys with generic api_url - core/menu.js: remove Voltalis mock data, leave commented usage pattern - dashboard.js: move logic to init(), Custom Element is a plain shell - dashboard.css: add real styles, remove placeholder comment - manifest.json: drop unused version field - config.yml: fix web/vendor comment → sources/vendor Co-Authored-By: Claude Sonnet 4.6 Signed-off-by: GnomeZworc --- exemple/navigation/config.yml | 2 +- exemple/navigation/sources/config.json | 4 +- exemple/navigation/sources/core/menu.js | 45 ++++--------------- exemple/navigation/sources/index.html | 7 +-- .../sources/pages/dashboard/dashboard.css | 17 ++++++- .../sources/pages/dashboard/dashboard.js | 8 ++++ .../sources/pages/dashboard/index.html | 2 +- .../sources/pages/dashboard/manifest.json | 7 ++- template/sources/components.lock.json | 1 + 9 files changed, 43 insertions(+), 50 deletions(-) create mode 100644 template/sources/components.lock.json diff --git a/exemple/navigation/config.yml b/exemple/navigation/config.yml index 5d2a320..1febc2d 100644 --- a/exemple/navigation/config.yml +++ b/exemple/navigation/config.yml @@ -22,7 +22,7 @@ components: repo: https://git.g3e.fr/syonad/syn-side-nav ref: main -# Vendor libraries — downloaded into web/vendor/ at build time (gitignored). +# Vendor libraries — downloaded into sources/vendor/ at build time (gitignored). # Components import them via relative paths, never via components.json. # path: restrict download to a subdirectory of the repo (optional). # dest: destination under web/ (default: vendor/). diff --git a/exemple/navigation/sources/config.json b/exemple/navigation/sources/config.json index bf6e218..d67ec5d 100644 --- a/exemple/navigation/sources/config.json +++ b/exemple/navigation/sources/config.json @@ -1,5 +1,3 @@ { - "netbox_url": "http://netbox.local", - "netbox_token": "your-token-here", - "agent_url": "http://127.0.0.1:8080" + "api_url": "http://localhost:8080" } diff --git a/exemple/navigation/sources/core/menu.js b/exemple/navigation/sources/core/menu.js index 0a2adad..2b11b8e 100644 --- a/exemple/navigation/sources/core/menu.js +++ b/exemple/navigation/sources/core/menu.js @@ -1,37 +1,10 @@ -// Dynamic menu loader. -// Fetches data for groups declared with empty children in navigation.json -// and injects them into side-nav after it is ready. -// +// Dynamic menu loader — injects children into named groups in the side-nav. // Imported non-blocking from index.html — does not delay routing. -// Replace MOCK_* with real api-client calls when the backend is ready. - -// ── Mock data ──────────────────────────────────────────────────────────────── - -const MOCK_ACCOUNTS = [ - { id: 'tresorerie', name: 'Trésorerie' }, - { id: 'charges', name: 'Charges' }, - { id: 'produits', name: 'Produits' }, - { id: 'fournisseurs', name: 'Fournisseurs' }, -] - -async function fetchAccounts() { - // TODO: replace with real call - // const api = document.querySelector('api-client') - // return await api.finance.list('/accounts') - await new Promise(r => setTimeout(r, 500)) // simulate network latency - return MOCK_ACCOUNTS -} - -// ── Injection ──────────────────────────────────────────────────────────────── - -const nav = document.querySelector('side-nav') -if (!nav) throw new Error('menu.js: side-nav not found in DOM') - -await nav.ready - -const accounts = await fetchAccounts() -nav.setGroupChildren('Comptes', accounts.map(a => ({ - label: a.name, - href: `#/account?id=${a.id}`, - icon: 'account', -}))) +// +// Example: populate a group declared in config.yml. +// +// const nav = document.querySelector('side-nav') +// await nav.ready +// nav.setGroupChildren('Mon Groupe', [ +// { label: 'Item A', href: '#/item-a', icon: 'folder' }, +// ]) diff --git a/exemple/navigation/sources/index.html b/exemple/navigation/sources/index.html index 73731c9..b8dd774 100644 --- a/exemple/navigation/sources/index.html +++ b/exemple/navigation/sources/index.html @@ -3,7 +3,7 @@ - two — dashboard + Navigation — Syn exemple