Init wiki: Architecture
+100
@@ -0,0 +1,100 @@
|
||||
# Architecture
|
||||
|
||||
## Structure du projet
|
||||
|
||||
```
|
||||
Planification/
|
||||
├── manifest.json # Manifest V3 (Chrome) + gecko_settings (Firefox)
|
||||
├── background.js # Service worker (~1 350 lignes)
|
||||
├── viewer.html # Interface principale
|
||||
├── viewer.js # Logique (~9 300 lignes)
|
||||
├── viewer.css # Styles + thèmes clair/sombre
|
||||
├── icons/ # icon16, icon48, icon128
|
||||
├── README.md
|
||||
├── LICENSE # MIT
|
||||
└── CHANGELOG.md
|
||||
```
|
||||
|
||||
## Composants principaux
|
||||
|
||||
### `background.js` — Service worker (Manifest V3)
|
||||
Worker de fond responsable de :
|
||||
- Récupération de la session EasyVista (PHPSESSID)
|
||||
- Fetch du XML `calendar_block` (planning du jour pour les 8 techs)
|
||||
- Fetch des fiches détaillées (HTML)
|
||||
- Fetch du timeline JSON (texte action complet)
|
||||
- Détection contexte réseau (interne / externe via SSO)
|
||||
- Gestion du cache local (`chrome.storage.local`)
|
||||
- Nettoyage des vieux caches (cron)
|
||||
|
||||
### `viewer.js` — Interface principale
|
||||
- Parsing du XML calendar_block
|
||||
- Construction des cards / rows par tech
|
||||
- Timeline visuelle avec segments
|
||||
- Tooltips détaillés (épinglables, draggables)
|
||||
- 2 modes d'affichage (classique / horizontale)
|
||||
- Panel admin (Apparence / Équipe / EasyVista / Statuts / Diagnostics / À propos)
|
||||
- Module LOG unifié (debug toggle)
|
||||
- Handlers globaux d'erreur
|
||||
- `sendMessage` avec timeout
|
||||
|
||||
### `viewer.css`
|
||||
- Variables CSS (`:root`) pour thème clair / sombre
|
||||
- Layout grille (vue classique) + flex (vue horizontale)
|
||||
- Animations transitions douces
|
||||
- Media queries (compact 24" / breakpoint étroit)
|
||||
|
||||
## Flux principal
|
||||
|
||||
```
|
||||
Utilisateur clique sur l'icône
|
||||
└─> background.js : ouvre viewer.html
|
||||
└─> viewer.js : init()
|
||||
├─> readCache(date) -> render si dispo
|
||||
├─> findEasyVistaSession (via background)
|
||||
├─> fetchPlanningXml -> parseXML
|
||||
├─> Pour chaque intervention : fetchFiche + parseHtml
|
||||
├─> renderFromData() -> buildCard() x 8 techs
|
||||
└─> writeCache()
|
||||
```
|
||||
|
||||
## Stack technique
|
||||
|
||||
| Élément | Détail |
|
||||
|---|---|
|
||||
| Manifest | V3 |
|
||||
| Browser support | Chrome / Edge / Firefox 140+ |
|
||||
| Pas de framework | JS vanilla |
|
||||
| Pas de build step | les fichiers sont chargés tels quels |
|
||||
| Stockage | `chrome.storage.local` (cache + admin_config) + `localStorage` (préfs UI) |
|
||||
| Réseau | `fetch` avec credentials (cookies EV) |
|
||||
| Logs | console (préfixé + timestamp + version) |
|
||||
|
||||
## Fonctions clés (viewer.js)
|
||||
|
||||
| Fonction | Introduite | Rôle |
|
||||
|---|---|---|
|
||||
| `loadForDate` | v1.0.0 | Fetch + parse planning pour une date |
|
||||
| `buildCard` | v1.0.0 | Construit la card HTML d'un technicien |
|
||||
| `buildTooltipHTML` | v1.0.0 | HTML détaillé d'une intervention |
|
||||
| `pinTooltip` | v4.1.3 | Épingle un tooltip |
|
||||
| `bindTimelinePopover` | v4.2.3 | Lie segments timeline → popovers |
|
||||
| `_softUnpinPopup` | v4.3.3 | Désépinglage mou (popup reste visible) |
|
||||
| `initAppClock` | v5.0.0 | Horloge HH:MM topbar |
|
||||
| `initSessionTimer` | v5.0.0 | Compteur session EV (tick 1s) |
|
||||
| `_applyViewMode` | v2026.5.32 | Toggle vue classique/horizontale |
|
||||
| `positionTooltipAnchored` | v2026.5.34 | Positionnement tooltip (4 candidats) |
|
||||
| `LOG.error/warn/info` | v2026.5.38 | Logger unifié |
|
||||
| `_applyTextZoom` | v2026.5.39 | Zoom global du texte (slider Apparence) |
|
||||
|
||||
## Fonctions clés (background.js)
|
||||
|
||||
| Fonction | Rôle |
|
||||
|---|---|
|
||||
| `findEasyVistaSession` | Trouve l'onglet EV ouvert + extrait PHPSESSID |
|
||||
| `fetchPlanningXml` | Fetch XML calendar_block du planning |
|
||||
| `fetchFicheHtml` | Fetch HTML d'une fiche EV (avec retry SSO) |
|
||||
| `fetchTimelineApi` | Fetch JSON timeline d'une fiche (texte action complet) |
|
||||
| `fetchCurrentUser` | Identifie l'user EV connecté |
|
||||
| `detectNetworkContext` | Interne (etat-de-vaud.ch) ou externe (vd.ch) |
|
||||
| `evFetch` | Wrapper fetch avec headers EV (Referer, X-Requested-With) |
|
||||
Reference in New Issue
Block a user