Version 5.0.0 — Refonte topbar (horloge, menu admin)

- initAppClock : horloge HH:MM au milieu topbar
- initAdminMenu : menu admin caché (5 clics sur titre)
- initSessionTimer : compteur de session EV (tick 1s)
[code interpolé entre v4.3.0 et v5.0.9]
This commit is contained in:
2026-04-20 09:00:00 +02:00
parent f6d549d522
commit da91d74d85
5 changed files with 951 additions and 62 deletions
+32 -3
View File
@@ -85,7 +85,7 @@ async function fetchPlanningXml(origin, phpsessid, unixDate) {
`&day_start_hour=8` + `&day_start_hour=8` +
`&day_end_hour=19`; `&day_end_hour=19`;
console.log("[bg] fetchPlanningXml →", url.substring(0, 140)); console.log("[bg] fetchPlanningXml →", url.substring(0, 140));
const r = await fetch(url, { credentials: "include" }); const r = await evFetch(url, origin);
console.log("[bg] status =", r.status); console.log("[bg] status =", r.status);
if (!r.ok) { if (!r.ok) {
// v4.2 : classifier l'erreur HTTP pour que le viewer affiche le bon // v4.2 : classifier l'erreur HTTP pour que le viewer affiche le bon
@@ -100,6 +100,32 @@ async function fetchPlanningXml(origin, phpsessid, unixDate) {
return xml; return xml;
} }
/**
* v5.0.9 : wrapper autour de fetch() qui ajoute systématiquement les
* headers de sécurité attendus par EasyVista (Referer, Sec-Fetch-Site,
* X-Requested-With). Sans ces headers, EV renvoie soit un <script> de
* redirection (CSRF check), soit une page de login, même avec une session
* valide.
*
* Observé dans les captures réseau du navigateur :
* Referer: https://itsma.etat-de-vaud.ch/index.php?eventName=HelpDesk_PlanningItem
* Sec-Fetch-Site: same-origin
* X-Requested-With: XMLHttpRequest (parfois)
*
* @param {string} url - URL complète à fetcher
* @param {string} origin - origine EasyVista (pour construire le Referer)
* @param {object} [opts] - options fetch (method, body, headers supplémentaires)
*/
async function evFetch(url, origin, opts = {}) {
const defaultHeaders = {
"Referer": `${origin}/index.php?eventName=HelpDesk_PlanningItem`,
"X-Requested-With": "XMLHttpRequest"
};
const headers = Object.assign({}, defaultHeaders, opts.headers || {});
const fetchOpts = Object.assign({ credentials: "include" }, opts, { headers });
return await fetch(url, fetchOpts);
}
/** /**
* v4.2 : classifie un statut HTTP comme "session_expired" ou "ev_unreachable". * v4.2 : classifie un statut HTTP comme "session_expired" ou "ev_unreachable".
* - 401, 403, 404 → session_expired (EV renvoie souvent 404 au lieu de rediriger * - 401, 403, 404 → session_expired (EV renvoie souvent 404 au lieu de rediriger
@@ -118,7 +144,7 @@ function classifyHttpStatus(status) {
*/ */
async function fetchXhr2(origin, phpsessid, actionId) { async function fetchXhr2(origin, phpsessid, actionId) {
const url = `${origin}/planning_xhr_2.php?PHPSESSID=${encodeURIComponent(phpsessid)}&id=${encodeURIComponent(actionId)}`; const url = `${origin}/planning_xhr_2.php?PHPSESSID=${encodeURIComponent(phpsessid)}&id=${encodeURIComponent(actionId)}`;
const r = await fetch(url, { credentials: "include" }); const r = await evFetch(url, origin);
if (!r.ok) { if (!r.ok) {
const err = new Error("HTTP " + r.status); const err = new Error("HTTP " + r.status);
err.kind = classifyHttpStatus(r.status); err.kind = classifyHttpStatus(r.status);
@@ -131,7 +157,7 @@ async function fetchXhr2(origin, phpsessid, actionId) {
async function fetchFicheHtml(origin, phpsessid, formLink) { async function fetchFicheHtml(origin, phpsessid, formLink) {
const url = `${origin}/index.php?${formLink}&PHPSESSID=${encodeURIComponent(phpsessid)}`; const url = `${origin}/index.php?${formLink}&PHPSESSID=${encodeURIComponent(phpsessid)}`;
console.log("[bg] fetchFicheHtml →", url.substring(0, 120)); console.log("[bg] fetchFicheHtml →", url.substring(0, 120));
const r = await fetch(url, { credentials: "include" }); const r = await evFetch(url, origin);
if (!r.ok) { if (!r.ok) {
const err = new Error("HTTP " + r.status); const err = new Error("HTTP " + r.status);
err.kind = classifyHttpStatus(r.status); err.kind = classifyHttpStatus(r.status);
@@ -140,6 +166,9 @@ async function fetchFicheHtml(origin, phpsessid, formLink) {
} }
const html = await r.text(); const html = await r.text();
console.log("[bg] fiche status =", r.status, "| taille =", html.length); console.log("[bg] fiche status =", r.status, "| taille =", html.length);
if (html.length < 500) {
console.warn("[bg] ⚠ fiche très courte, contenu =", JSON.stringify(html));
}
return html; return html;
} }
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"manifest_version": 3, "manifest_version": 3,
"name": "Planification", "name": "Planification",
"version": "4.3.0", "version": "5.0.0",
"description": "Vue claire du planning EasyVista (itsma.etat-de-vaud.ch et itsma.vd.ch). v4.3.0 : (1) conflits horaires entre interventions d'un même tech affichés en rouge + ⚠. (2) Réservations disparues retirées directement (pas de re-fetch inutile). (3) Popups épinglés détachés : plusieurs peuvent coexister, ancrés au contenu (scrollent avec la page), auto-positionnés sans se marcher dessus (toast si pas de place), Échap pour tout fermer, Ctrl×2 pour fermer si un seul épinglé. Inclut v4.2.9.", "description": "Vue claire du planning EasyVista (itsma.etat-de-vaud.ch et itsma.vd.ch). v4.3.0 : (1) conflits horaires entre interventions d'un même tech affichés en rouge + ⚠. (2) Réservations disparues retirées directement (pas de re-fetch inutile). (3) Popups épinglés détachés : plusieurs peuvent coexister, ancrés au contenu (scrollent avec la page), auto-positionnés sans se marcher dessus (toast si pas de place), Échap pour tout fermer, Ctrl×2 pour fermer si un seul épinglé. Inclut v4.2.9.",
"permissions": [ "permissions": [
"activeTab", "activeTab",
+9 -7
View File
@@ -262,7 +262,7 @@ html, body {
background: rgba(255,255,255,0.15); background: rgba(255,255,255,0.15);
} }
/* Barre de progression pendant le rafraîchissement — v4.1.12 : texte /* Barre de progression pendant le rafraichissement — v4.1.12 : texte
toujours lisible, que la zone verte l'ait atteint ou non (utilise toujours lisible, que la zone verte l'ait atteint ou non (utilise
mix-blend-mode:difference pour inverser la couleur du texte là où la mix-blend-mode:difference pour inverser la couleur du texte là où la
barre verte est dessous). */ barre verte est dessous). */
@@ -438,7 +438,7 @@ html, body {
opacity: 0.9; opacity: 0.9;
} }
/* Bouton "Arrêter" (apparaît pendant un refresh manuel) */ /* Bouton "Arrêter" (apparaît pdt un refresh manuel) */
.btn-abort { .btn-abort {
background: var(--danger-soft); background: var(--danger-soft);
color: var(--danger); color: var(--danger);
@@ -909,10 +909,9 @@ html, body {
to { transform: rotate(360deg); } to { transform: rotate(360deg); }
} }
.intervention-v2.is-ghost { /* .intervention-v2.is-ghost : retirée en v4.3.3 — on ne barre plus les
opacity: 0.5; cartes. La gestion des tickets disparus se fait via _disappearStatus
text-decoration: line-through; (vert ✓/✓✓) ou _disappearRemove (retrait total). */
}
/* Ligne 1 : REF en titre centré gros gras */ /* Ligne 1 : REF en titre centré gros gras */
.iv-ref-header { .iv-ref-header {
@@ -1806,7 +1805,10 @@ body.modal-open {
───────────────────────────────────────────────────────────────────────── */ ───────────────────────────────────────────────────────────────────────── */
.tooltip.pinned-popup { .tooltip.pinned-popup {
position: absolute !important; /* override le fixed du .tooltip */ position: absolute !important; /* override le fixed du .tooltip */
z-index: 500; /* au-dessus du contenu, sous les modals (10000) */ /* v4.3.3 corr : les popups épinglées doivent passer DERRIÈRE la topbar
quand on scrolle (topbar sticky z-index 10). Donc on met 5 : au-dessus
du contenu normal, mais sous la topbar / bannières / modals. */
z-index: 5 !important;
opacity: 1 !important; opacity: 1 !important;
pointer-events: auto !important; pointer-events: auto !important;
/* Bordure plus visible pour distinguer du tooltip live */ /* Bordure plus visible pour distinguer du tooltip live */
+1 -1
View File
@@ -13,7 +13,7 @@
<button id="user-badge" class="user-badge hidden" <button id="user-badge" class="user-badge hidden"
type="button" aria-label="Utilisateur connecté" type="button" aria-label="Utilisateur connecté"
title="Utilisateur connecté"></button> title="Utilisateur connecté"></button>
<h1>Planification</h1> <h1 id="app-title">Planification</h1>
<div class="date-nav"> <div class="date-nav">
<button id="nav-prev" class="btn btn-nav" title="Jour précédent" aria-label="Jour précédent"></button> <button id="nav-prev" class="btn btn-nav" title="Jour précédent" aria-label="Jour précédent"></button>
<input type="date" id="date-picker" class="date-input"> <input type="date" id="date-picker" class="date-input">
+908 -50
View File
File diff suppressed because it is too large Load Diff