mirror of
https://git.j0bot.ch/admin_j0bot/ploxion-civ.git
synced 2026-11-29 06:12:08 +00:00
synchro du labo (0bf0da65) : app.blade.php, README.md
This commit is contained in:
parent
a08b26e401
commit
9c619ccd17
22
README.md
22
README.md
@ -1,3 +1,21 @@
|
|||||||
# ploxion-civ
|
# 🧭 Maintenant
|
||||||
|
|
||||||
PLOXION · Le dashboard de la zone, adapté à la situation : jauges (à jour, propre, solvable, approvisionné, installé), ce qui compte maintenant (retards, aujourd'hui, échéances, stock bas, runway), actions en un tap, modules installés, ajouter un module, zones. · fournit: civ, dashboard, zone, organisation, situation
|
Le dashboard de la zone, adapté à la situation : jauges (à jour, propre, solvable, approvisionné, installé), ce qui compte maintenant (retards, aujourd'hui, échéances, stock bas, runway), actions en un tap, modules installés, ajouter un module, zones.
|
||||||
|
|
||||||
|
| | |
|
||||||
|
| --- | --- |
|
||||||
|
| id | `civ` |
|
||||||
|
| fournit | `civ` `dashboard` `zone` `organisation` `situation` |
|
||||||
|
| bions qu'il nomme | `jOSApps` `jOSBions` `jOSCiv` `jOSPorts` `jOSPret` `jOSSituation` `jOSStore` `jOSZone` |
|
||||||
|
| fichiers | `app.blade.php` |
|
||||||
|
| dans le labo | `resources/views/ploxions/civ/` (dépôt `my_website2`) |
|
||||||
|
|
||||||
|
## Contribuer
|
||||||
|
|
||||||
|
- **Dans le xer** : https://labo.j0bot.ch/px/atelier?ploxion=civ — prends-le, modifie-le, vois-le tourner, « ⧗ envoyer le tsoin ».
|
||||||
|
- **Dans VS Code** : `xb prendre civ` (ou l'extension xerboxion › ⇩ Prendre), puis ⧗ Envoyer.
|
||||||
|
- Le chemin complet : https://labo.j0bot.ch/px/contribuer
|
||||||
|
|
||||||
|
Ce dépôt est un **miroir** du labo (synchronisé par `bin/ploxions-forge.mjs`, depuis le commit `0bf0da65`) : une modif se propose par un tsoin ou une branche du labo, pas directement ici.
|
||||||
|
|
||||||
|
© 2026 chill-tekk · ne pas nuire
|
||||||
|
|||||||
134
app.blade.php
Normal file
134
app.blade.php
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
{{-- PL0XI0N civ 🧭 — LE DASHBOARD DE LA ZONE, adapté à la situation (RS-7 11.09 : « un dashboard
|
||||||
|
adapté à la situation, pouvoir ajouter des modules au fil du temps, comme Factorio/Sims/Civ »).
|
||||||
|
Lit jOSSituation (jauges + cartes classées par urgence), agit sans ouvrir les modules (fait /
|
||||||
|
réglé / courses), les tuiles des modules installés, « ajouter un module ». Recalcule sur le bus
|
||||||
|
(ploxion.civ.*) et au retour au premier plan. Monté par le ploxion zone (après l'onboarding).
|
||||||
|
|
||||||
|
v0.2 (23.09, retour RS-7 : « des fois ils crashent, il faut ouvrir d'autres ploxions avant ») :
|
||||||
|
(1) ATTEND ses bions (jOSZone, jOSCiv, jOSStore) — l'attente du montage robuste (jOSPret, sinon jOSBions) si elle existe, sinon un poll
|
||||||
|
100 ms borné à 15 s — puis se rend ; passé le délai : « réessayer », JAMAIS un message définitif
|
||||||
|
(« cœur civ absent » = quand le ploxion montait avant que le parseur atteigne _civ_bions) ;
|
||||||
|
(2) plus jamais de .length sur undefined (situationSure + gardes) ; un rendu qui plante affiche
|
||||||
|
l'erreur + réessayer, ne fait plus tomber le montage (« PL0XI0N en panne au montage ») ;
|
||||||
|
(3) l'en-tête devient un SÉLECTEUR de zones (+ « gérer les zones » → ouvre zone), fil d'Ariane,
|
||||||
|
re-rendu sur l'event window xb:zone ; ?zone=<id> / ctx.params.zone ; (4) describe() : p1 zone
|
||||||
|
courante, p2 liste des zones (action entrer). Kill-switch : jOSZone.v02 (localStorage xb:zones:v02=off). --}}
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
var ID = 'civ';
|
||||||
|
function esc(s) { return window.jOSb.esc(s); }
|
||||||
|
function arr(a) { return Array.isArray(a) ? a : []; }
|
||||||
|
// attendre(noms, cb) : cb(true) dès que window[noms…] existent ; l'attente de jOSPret (montage robuste) — ou jOSBions — si elle existe (en parallèle
|
||||||
|
// d'un poll 100 ms de sécurité) ; cb(false) après window.XB_ATTENDRE_MS (défaut 15 s). Rend une fonction d'annulation.
|
||||||
|
function attendre(noms, cb) {
|
||||||
|
var fini = false, iv = null; function fin(ok) { if (fini) return; fini = true; if (iv) clearInterval(iv); cb(ok); }
|
||||||
|
function la() { for (var i = 0; i < noms.length; i++) if (!window[noms[i]]) return false; return true; }
|
||||||
|
if (la()) { fin(true); return function () {}; }
|
||||||
|
// NB : window.jOSBions est le moteur conceptuel de craft (sans attendre) ; l'API réelle est window.jOSPret (_apps_bion). Écrit sans « jOSXxx. »
|
||||||
|
// pour ne pas être listé comme bion attendu par PloxionAppController::bions (regex jOSXxx.)
|
||||||
|
try { var B = window.jOSPret; if (!(B && typeof B.attendre === 'function')) B = window.jOSBions; if (B && typeof B.attendre === 'function') { var r = B.attendre(noms); if (r && typeof r.then === 'function') r.then(function () { if (la()) fin(true); }, function () {}); } } catch (e) {}
|
||||||
|
var max = +window.XB_ATTENDRE_MS > 0 ? +window.XB_ATTENDRE_MS : 15000, t0 = Date.now();
|
||||||
|
iv = setInterval(function () { if (la()) fin(true); else if (Date.now() - t0 >= max) fin(false); }, 100);
|
||||||
|
return function () { fini = true; if (iv) clearInterval(iv); };
|
||||||
|
}
|
||||||
|
var BIONS = ['jOSStore', 'jOSZone', 'jOSCiv'];
|
||||||
|
function attente(container, msg, onRetry) {
|
||||||
|
container.innerHTML = '<div class="cv__wait" style="padding:26px 16px;text-align:center;opacity:.8;font:.86rem system-ui;line-height:1.5">' + msg + (onRetry ? '<br><button type="button" data-retry style="margin-top:10px;cursor:pointer;border:1px solid currentColor;background:transparent;color:inherit;border-radius:9px;padding:7px 12px;font:12px system-ui;min-height:36px">↻ réessayer</button>' : '') + '</div>';
|
||||||
|
var b = container.querySelector('[data-retry]'); if (b && onRetry) b.addEventListener('click', onRetry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- le vrai montage : tout est là ----
|
||||||
|
function monter(container, ctx) {
|
||||||
|
var C = window.jOSCiv, U = C.ui, J = window.jOSZone, v02 = J.v02 !== false && typeof J.chemin === 'function';
|
||||||
|
U.style(); container.classList.add('cv'); container.style.position = 'relative';
|
||||||
|
// épinglé sur ctx.zone (monté DANS le ploxion zone) sinon le dashboard SUIT la zone courante (fenêtre « Maintenant » seule)
|
||||||
|
var pin = (ctx && ctx.zone && ctx.zone.id) || null, Z = (pin && J.get(pin)) || J.current(), iv = null, offs = [], onClick = null, onChange = null;
|
||||||
|
// la zone vivante (le store a pu être rechargé) ; une zone stale n'est gardée que si le store est vide (transitoire)
|
||||||
|
function zoneActuelle() { var z = (pin && J.get(pin)) || J.current(); Z = z || ((Z && !J.all().length) ? Z : null); return Z; }
|
||||||
|
function ouvrirZone() { U.openModule('zone'); }
|
||||||
|
function vide() {
|
||||||
|
var zs = J.all();
|
||||||
|
container.innerHTML = U.zoneHd(null, 'Maintenant', '🧭', { selecteur: v02 }) + '<div class="cv__bd"><div class="cv__empty">' + (zs.length ? 'Aucune zone choisie. Choisis ta bulle de réel dans le menu ci-dessus.' : 'Aucune zone — commence par ton appart.') + '<br><button class="cv__btn" data-openzone style="margin-top:12px">🫧 ' + (zs.length ? 'gérer les zones' : 'créer ma première zone') + '</button></div></div>';
|
||||||
|
}
|
||||||
|
function render() {
|
||||||
|
try {
|
||||||
|
if (!zoneActuelle()) { vide(); return; }
|
||||||
|
var S = C.situationSure ? C.situationSure(Z) : C.situation(Z); var jauges = arr(S.jauges), cartes = arr(S.cartes), smod = arr(S.modules);
|
||||||
|
var h = U.zoneHd(Z, 'Maintenant', '🧭', { selecteur: v02 }) + (U.crumb ? U.crumb(Z) : '');
|
||||||
|
h += '<div class="cv__bd">';
|
||||||
|
if (S.erreur) h += '<div class="cv__empty">⚠ synthèse partielle : ' + esc(S.erreur) + '</div>';
|
||||||
|
if (jauges.length) h += '<div class="cv__jg">' + jauges.map(function (j) { var p = Math.round((+j.v || 0) * 100); return '<div><small>' + j.icon + ' ' + U.esc(j.label) + '</small><b>' + p + '%</b><div class="bar"><i class="' + (p < 40 ? 'lo' : '') + '" style="width:' + p + '%"></i></div></div>'; }).join('') + '</div>';
|
||||||
|
h += '<div class="cv__sec"><span>à faire maintenant</span><span>' + cartes.length + '</span></div>';
|
||||||
|
h += cartes.length ? cartes.slice(0, 30).map(function (c) {
|
||||||
|
var act = '';
|
||||||
|
if (c.act && c.act.done) act = '<button class="cv__btn sm ok" data-done="' + U.esc(c.act.done) + '">✓ fait</button>';
|
||||||
|
else if (c.act && c.act.fluxFait) act = '<button class="cv__btn sm ok" data-flux="' + U.esc(c.act.fluxFait[0]) + '" data-fid="' + U.esc(c.act.fluxFait[1]) + '">✓ réglé</button>';
|
||||||
|
else if (c.act && c.act.courses) act = '<button class="cv__btn sm" data-open="stock">🛒 courses</button>';
|
||||||
|
return '<div class="cv__row u' + (c.urgence | 0) + '" data-open="' + U.esc(c.module || '') + '"><span class="ic">' + (c.icon || '•') + '</span><div class="tx"><b>' + U.esc(c.titre) + '</b><small>' + U.esc(c.detail) + '</small></div>' + act + '</div>';
|
||||||
|
}).join('') : '<div class="cv__empty">Rien d\'urgent. ' + (smod.length ? 'Ajoute tes tâches, tes comptes et ton stock : le dashboard se remplit tout seul.' : 'Ajoute un module pour commencer.') + '</div>';
|
||||||
|
var mods = arr(C.modules.installes(Z)), dispo = arr(C.modules.disponibles(Z));
|
||||||
|
h += '<div class="cv__sec"><span>modules de ' + U.esc(Z.nom) + '</span><span>' + mods.length + '</span></div><div class="cv__grid">' + mods.map(function (m) { return '<button class="cv__tile" data-open="' + m.id + '"><span class="ic">' + m.icon + '</span><b>' + U.esc(m.nom) + '</b><small>' + U.esc(m.desc) + '</small></button>'; }).join('') + (dispo.length ? '<button class="cv__tile add" data-add><span class="ic">+</span><b>ajouter un module</b><small>' + dispo.length + ' disponibles</small></button>' : '') + '</div>';
|
||||||
|
var kids = arr(J.children(Z.id)), par = Z.parent ? J.get(Z.parent) : null;
|
||||||
|
h += '<div class="cv__sec"><span>zones</span>' + (v02 ? '<button class="cv__btn sm" data-openzone>🫧 toutes</button>' : '') + '</div><div class="cv__grid">' + (par ? '<button class="cv__tile" data-zone="' + U.esc(par.id) + '"><span class="ic">' + U.esc(par.icone) + '</span><b>⟵ ' + U.esc(par.nom) + '</b><small>zone mère</small></button>' : '') + kids.map(function (k) { return '<button class="cv__tile" data-zone="' + U.esc(k.id) + '"><span class="ic">' + U.esc(k.icone) + '</span><b>' + U.esc(k.nom) + '</b><small>' + U.esc(k.type) + '</small></button>'; }).join('') + '<button class="cv__tile add" data-newzone><span class="ic">🫧</span><b>nouvelle zone</b><small>sous-zone ou autre bulle</small></button></div>';
|
||||||
|
h += '</div>'; container.innerHTML = h;
|
||||||
|
} catch (e) {
|
||||||
|
// un rendu qui plante n'est plus définitif : l'erreur + réessayer (et le prochain event re-rend aussi)
|
||||||
|
attente(container, '⚠ dashboard en panne : ' + esc(e && e.message || e), render);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onClick = function (e) {
|
||||||
|
var b;
|
||||||
|
if ((b = e.target.closest('[data-done]'))) { e.stopPropagation(); try { C.taches(Z).done(b.getAttribute('data-done')); } catch (er) {} try { jOSiOS && jOSiOS.haptic && jOSiOS.haptic('success'); } catch (er2) {} render(); return; }
|
||||||
|
if ((b = e.target.closest('[data-flux]'))) { e.stopPropagation(); try { C.ledger(Z).fluxFait(b.getAttribute('data-flux'), b.getAttribute('data-fid')); } catch (er) {} render(); return; }
|
||||||
|
if ((b = e.target.closest('[data-zone]'))) { J.enter(b.getAttribute('data-zone')); return; }
|
||||||
|
if (e.target.closest('[data-openzone]')) { ouvrirZone(); return; }
|
||||||
|
if (e.target.closest('[data-newzone]')) { var Zc = zoneActuelle(); U.form(container, 'Nouvelle zone', [{ k: 'nom', label: 'nom', ph: 'la coloc, le club, la cave…' }, { k: 'type', label: 'type', type: 'chips', opts: Object.keys(J.TYPES), val: 'autre' }].concat(Zc ? [{ k: 'ou', label: 'où', type: 'chips', opts: [{ v: 'sous', l: 'dans ' + Zc.nom }, { v: 'top', l: 'à part' }], val: 'sous' }] : []), function (v) { var z = (J.creer || J.create)({ nom: v.nom || 'zone', type: v.type || 'autre', parent: Zc && v.ou === 'sous' ? Zc.id : null }); if (z) J.enter(z.id); }); return; }
|
||||||
|
if (e.target.closest('[data-add]')) { var d = arr(C.modules.disponibles(Z)); U.form(container, 'Ajouter un module', [{ k: 'm', label: 'module', type: 'chips', opts: d.map(function (m) { return { v: m.id, l: m.icon + ' ' + m.nom }; }), val: d[0] && d[0].id }], function (v) { if (v.m) { C.modules.installer(Z, v.m); render(); } }); return; }
|
||||||
|
if ((b = e.target.closest('[data-open]')) && b.getAttribute('data-open')) { U.openModule(b.getAttribute('data-open')); return; }
|
||||||
|
};
|
||||||
|
onChange = function (e) { var s = e.target.closest('[data-zsel]'); if (!s) return; var v = s.value; if (v === '__gerer') { s.value = Z ? Z.id : ''; ouvrirZone(); return; } if (v && (!Z || v !== Z.id)) J.enter(v); };
|
||||||
|
container.addEventListener('click', onClick); container.addEventListener('change', onChange);
|
||||||
|
// ?zone=<id> / ctx.params.zone → on entre dedans (comme le ploxion zone)
|
||||||
|
var want = (ctx && ctx.params && ctx.params.zone) || (function () { try { return new URLSearchParams(location.search).get('zone'); } catch (e) { return null; } })();
|
||||||
|
if (want && J.get(want) && !(Z && Z.id === want)) J.enter(want); // (les abonnements arrivent après : on rend explicitement)
|
||||||
|
render();
|
||||||
|
iv = setInterval(function () { if (document.visibilityState === 'visible') render(); }, 30000);
|
||||||
|
try { offs.push(J.on(function (ev) { if (ev !== 'presence') render(); })); } catch (e) {}
|
||||||
|
try { if (window.jOSPorts) offs.push(jOSPorts.on('*', function (p, topic) { if (/^ploxion\.civ\./.test(topic || '')) render(); })); } catch (e) {}
|
||||||
|
var onZone = function () { render(); };
|
||||||
|
try { window.addEventListener('xb:active', render); window.addEventListener('xb:zone', onZone); } catch (e) {}
|
||||||
|
return { unmount: function () { clearInterval(iv); offs.forEach(function (f) { try { f(); } catch (e) {} }); try { window.removeEventListener('xb:active', render); window.removeEventListener('xb:zone', onZone); } catch (e) {} try { container.removeEventListener('click', onClick); container.removeEventListener('change', onChange); } catch (e2) {} container.classList.remove('cv'); container.innerHTML = ''; } };
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- mount : synchrone (le contrat), le rendu arrive quand les bions sont là ----
|
||||||
|
function mount(container, ctx) {
|
||||||
|
var inst = null, mort = false, annule = null;
|
||||||
|
function go() {
|
||||||
|
if (mort) return;
|
||||||
|
if (annule) annule();
|
||||||
|
var deja = BIONS.every(function (n) { return !!window[n]; });
|
||||||
|
if (!deja) attente(container, '⏳ le cœur civ se charge…');
|
||||||
|
annule = attendre(BIONS, function (ok) {
|
||||||
|
if (mort) return;
|
||||||
|
if (!ok) { attente(container, '⏳ le cœur civ (jOSZone / jOSCiv) n\'est pas encore chargé sur cette page.', go); return; }
|
||||||
|
try { inst = monter(container, ctx) || null; }
|
||||||
|
catch (e) { inst = null; attente(container, '⚠ dashboard en panne au montage : ' + esc(e && e.message || e), go); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
go();
|
||||||
|
return { unmount: function () { mort = true; if (annule) annule(); if (inst) { try { inst.unmount(); } catch (e) {} } inst = null; container.classList.remove('cv'); container.innerHTML = ''; } };
|
||||||
|
}
|
||||||
|
function describe() {
|
||||||
|
var J = window.jOSZone, Z = J && J.current();
|
||||||
|
if (!Z || !window.jOSCiv) return { v: 1, id: ID, title: 'Maintenant', icon: '🧭', items: [{ p: 1, kind: 'text', label: 'zone', value: 'aucune' }] };
|
||||||
|
var S = jOSCiv.situationSure ? jOSCiv.situationSure(Z) : jOSCiv.situation(Z), cartes = arr(S.cartes), jauges = arr(S.jauges);
|
||||||
|
var it = [{ p: 1, kind: 'stat', label: 'zone', value: Z.nom }, { p: 1, kind: 'stat', label: 'à faire', value: cartes.length }];
|
||||||
|
jauges.slice(0, 3).forEach(function (j) { it.push({ p: 2, kind: 'gauge', label: j.label, value: Math.round((+j.v || 0) * 100), unit: '%', min: 0, max: 100 }); });
|
||||||
|
it.push({ p: 2, kind: 'list', label: 'maintenant', items: cartes.slice(0, 5).map(function (c) { return { label: c.icon + ' ' + c.titre, act: c.act && c.act.done ? { port: 'ploxion.taches.cmd', payload: { cmd: 'done', id: c.act.done } } : null }; }) });
|
||||||
|
var zs = []; try { zs = typeof J.arbre === 'function' ? J.arbre().map(function (e) { return e.zone; }) : J.all(); } catch (e) { zs = []; }
|
||||||
|
it.push({ p: 2, kind: 'list', label: 'zones', items: zs.slice(0, 7).map(function (x) { return { label: x.icone + ' ' + x.nom, value: x.id === Z.id ? 'ici' : '', act: { port: 'ploxion.zone.cmd', payload: { cmd: 'enter', id: x.id } } }; }) });
|
||||||
|
return { v: 1, id: ID, title: Z.nom, icon: Z.icone, items: it };
|
||||||
|
}
|
||||||
|
window.jOSApps = window.jOSApps || {}; window.jOSApps[ID] = { manifest: { id: ID, name: 'Maintenant', icon: '🧭' }, mount: mount, describe: describe };
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user