lampson 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/chat.syn +1 -1
- package/hub.tpl.syn +55 -12
- package/lib/api.syn +178 -7
- package/lib/diagnose.syn +142 -0
- package/lib/loop.syn +14 -0
- package/lib/plugins.syn +6 -4
- package/lib/provider.syn +16 -13
- package/lib/runtime.syn +56 -0
- package/lib/schedule.syn +40 -2
- package/lib/teamrun.syn +42 -5
- package/lib/teams.syn +397 -24
- package/lib/workspaces.syn +58 -0
- package/lib/worktree.syn +108 -0
- package/package.json +1 -1
- package/plugins/example-hello/plugin.json +1 -0
- package/public/css/chat.css +9 -8
- package/public/css/hub.css +69 -16
- package/public/css/layout.css +12 -4
- package/public/css/login.css +1 -1
- package/public/css/mobile.css +2 -2
- package/public/css/panel.css +16 -7
- package/public/css/sidebar.css +1 -1
- package/public/css/teams.css +701 -55
- package/public/css/tokens.css +36 -12
- package/public/css/views.css +124 -0
- package/public/hub.html +17 -9
- package/public/index.html +3 -2
- package/public/js/app.js +2 -2
- package/public/js/approvals.js +1 -1
- package/public/js/core.js +5 -2
- package/public/js/flow.js +187 -0
- package/public/js/hub.js +131 -31
- package/public/js/navtabs.js +23 -0
- package/public/js/objdiag.js +90 -0
- package/public/js/objlive.js +393 -0
- package/public/js/panel.js +2 -1
- package/public/js/plugins-home.js +59 -0
- package/public/js/plugins.js +40 -18
- package/public/js/schedules.js +5 -0
- package/public/js/sidebar.js +6 -4
- package/public/js/tasks-home.js +104 -0
- package/public/js/teams-home.js +64 -15
- package/public/js/teams.js +927 -202
- package/public/js/terminal.js +8 -2
- package/public/js/workspaces.js +6 -3
- package/public/plugins-home.html +32 -0
- package/public/tasks-home.html +31 -0
- package/public/teams-home.html +5 -2
- package/public/teams.html +33 -46
- package/public/vendor/xterm-addon-webgl.js +2 -0
- package/web.syn +61 -8
package/public/js/sidebar.js
CHANGED
|
@@ -18,16 +18,18 @@ for (const s of document.querySelectorAll('.sec')) {
|
|
|
18
18
|
const pref = localStorage.getItem('lampson.sec.' + s.dataset.sec);
|
|
19
19
|
if (pref !== null) setSec(s.dataset.sec, pref === '1');
|
|
20
20
|
}
|
|
21
|
-
// plegar/desplegar: cerrado = barra angosta con su icono; preferencia por lado en localStorage
|
|
22
|
-
|
|
21
|
+
// plegar/desplegar: cerrado = barra angosta con su icono; preferencia por lado en localStorage.
|
|
22
|
+
// Sin preferencia arrancan plegados: el proyecto abre con la conversación sola y los paneles a un clic.
|
|
23
|
+
// Quien abre uno lo encuentra abierto la próxima vez (se guarda solo lo que la persona eligió)
|
|
24
|
+
function sideSet(which, closed, keep = true) {
|
|
23
25
|
document.body.classList.toggle(which + '-closed', closed);
|
|
24
26
|
const a = document.querySelector(which === 'l' ? 'aside:not(.right)' : 'aside.right'); if (a) a.classList.toggle('closed', closed);
|
|
25
|
-
try { localStorage.setItem('lampson.side.' + which, closed ? '1' : '0'); } catch (e) {}
|
|
27
|
+
if (keep) try { localStorage.setItem('lampson.side.' + which, closed ? '1' : '0'); } catch (e) {}
|
|
26
28
|
}
|
|
27
29
|
for (const which of ['l', 'r']) {
|
|
28
30
|
const a = document.querySelector(which === 'l' ? 'aside:not(.right)' : 'aside.right'); if (!a) continue;
|
|
29
31
|
a.querySelector('.fold').onclick = () => sideSet(which, true);
|
|
30
32
|
a.querySelector('.rail button').onclick = () => sideSet(which, false);
|
|
31
33
|
let pref = null; try { pref = localStorage.getItem('lampson.side.' + which); } catch (e) {}
|
|
32
|
-
if (pref
|
|
34
|
+
if (pref !== '0') sideSet(which, true, false);
|
|
33
35
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// tasks-home.js — tareas programadas de todos los proyectos (public/tasks-home.html, servido por el hub en /tareas).
|
|
2
|
+
// Lee GET /api/tasks-home (el schedules.json de cada workspace, también de los apagados) cada 5 s. Encender, apagar y
|
|
3
|
+
// correr van al workspace por el proxy del hub (/w/<slug>/api/schedules/…); si está apagado, primero se enciende.
|
|
4
|
+
const $ = (s) => document.querySelector(s);
|
|
5
|
+
const esc = (s) => String(s ?? '').replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
6
|
+
let data = [], busy = 0;
|
|
7
|
+
|
|
8
|
+
async function post(path, body) {
|
|
9
|
+
const r = await fetch(path, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
|
|
10
|
+
let d = {}; try { d = await r.json(); } catch (e) {}
|
|
11
|
+
if (r.status === 401) location.href = '/login';
|
|
12
|
+
return { ok: r.ok, data: d };
|
|
13
|
+
}
|
|
14
|
+
function setTheme(t) { document.documentElement.setAttribute('data-theme', t); try { localStorage.setItem('lampson.theme', t); } catch (e) {} $('#theme').textContent = t === 'dark' ? '☀' : '☾'; }
|
|
15
|
+
setTheme(document.documentElement.getAttribute('data-theme') || 'dark');
|
|
16
|
+
$('#theme').onclick = () => setTheme(document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark');
|
|
17
|
+
|
|
18
|
+
// el plan en palabras (lo mismo que describe_plan de lib/schedule.syn)
|
|
19
|
+
const DAY_NAMES = ['lunes', 'martes', 'miércoles', 'jueves', 'viernes', 'sábado', 'domingo'];
|
|
20
|
+
const pad2 = (n) => String(n).padStart(2, '0');
|
|
21
|
+
function describePlan(p, raw) {
|
|
22
|
+
if (!p) return raw || '';
|
|
23
|
+
const hhmm = pad2(p.hh) + ':' + pad2(p.mm);
|
|
24
|
+
if (p.kind === 'once') {
|
|
25
|
+
if (p.delay > 0) return 'una vez, en ' + (p.delay >= 3600 ? Math.floor(p.delay / 3600) + ' h' : Math.floor(p.delay / 60) + ' min');
|
|
26
|
+
if (p.rel) return 'una vez, ' + (p.rel === 'today' ? 'hoy' : 'mañana') + ' a las ' + hhmm;
|
|
27
|
+
return 'una vez, el ' + p.date + ' a las ' + hhmm;
|
|
28
|
+
}
|
|
29
|
+
if (p.kind === 'every') {
|
|
30
|
+
const s = p.seconds;
|
|
31
|
+
if (s >= 86400 && s % 86400 === 0) return 'cada ' + (s / 86400) + (s === 86400 ? ' día' : ' días');
|
|
32
|
+
if (s >= 3600 && s % 3600 === 0) return 'cada ' + (s / 3600) + ' h';
|
|
33
|
+
return 'cada ' + Math.floor(s / 60) + ' min';
|
|
34
|
+
}
|
|
35
|
+
if (p.kind === 'daily') return 'todos los días a las ' + hhmm;
|
|
36
|
+
return (p.days || []).map((d) => DAY_NAMES[d - 1]).join(', ') + ' a las ' + hhmm;
|
|
37
|
+
}
|
|
38
|
+
function describeAction(a) {
|
|
39
|
+
if (!a) return '';
|
|
40
|
+
if (a.type === 'objective') return 'rutina del equipo ' + a.team + ': ' + String(a.text || '').replace(/\s+/g, ' ');
|
|
41
|
+
if (a.type === 'plugin' || a.type === 'lamp') return 'plugin ' + (a.plugin || a.lamp) + '.' + a.tool;
|
|
42
|
+
if (a.type === 'bash') return '$ ' + a.command;
|
|
43
|
+
return (a.agent ? 'agente ' + a.agent + ': ' : 'agente: ') + String(a.prompt || '').replace(/\s+/g, ' ');
|
|
44
|
+
}
|
|
45
|
+
function fmtTs(ts) {
|
|
46
|
+
if (!ts) return '';
|
|
47
|
+
const d = new Date(ts * 1000), now = new Date(), hm = d.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' });
|
|
48
|
+
const day = (x) => new Date(x.getFullYear(), x.getMonth(), x.getDate()).getTime(), diff = Math.round((day(d) - day(now)) / 86400000);
|
|
49
|
+
if (diff === 0) return 'hoy ' + hm; if (diff === 1) return 'mañana ' + hm; if (diff === -1) return 'ayer ' + hm;
|
|
50
|
+
return d.toLocaleDateString(undefined, { weekday: 'short', day: 'numeric', month: 'short' }) + ' ' + hm;
|
|
51
|
+
}
|
|
52
|
+
const failed = (t) => String(t.last_status || '').startsWith('error');
|
|
53
|
+
|
|
54
|
+
function render() {
|
|
55
|
+
const withTasks = data.filter((w) => w.tasks.length), rest = data.filter((w) => !w.tasks.length);
|
|
56
|
+
if (!withTasks.length) {
|
|
57
|
+
$('#list').innerHTML = `<div class="vempty"><p><b>Todavía no hay tareas programadas.</b></p><p>Abrí un proyecto y pedíselo al agente, o programala vos:</p><div class="vpick">${data.map((w) => `<a href="/w/${esc(w.slug)}#tareas=nueva">${esc(w.name)}</a>`).join('')}</div></div>`;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// primero lo que falló, después lo encendido por próxima corrida, al final lo apagado
|
|
61
|
+
const order = (t) => (failed(t) && t.enabled ? 0 : t.running ? 1 : t.enabled ? 2 : 3);
|
|
62
|
+
$('#list').innerHTML = withTasks.map((w) => `
|
|
63
|
+
<section class="pblock">
|
|
64
|
+
<div class="projhead"><a href="/w/${esc(w.slug)}#tareas" class="pname">${esc(w.name)}</a><span class="ppath">${esc(w.path)}</span>
|
|
65
|
+
<span class="spacer"></span><span class="dot${w.alive ? ' on' : ''}" title="${w.alive ? 'activo' : 'apagado'}"></span><a class="open" href="/w/${esc(w.slug)}#tareas=nueva">+ tarea</a><a class="open" href="/w/${esc(w.slug)}#tareas">abrir →</a></div>
|
|
66
|
+
${w.tasks.slice().sort((a, b) => order(a) - order(b) || (a.next_run || 9e12) - (b.next_run || 9e12)).map((t) => `
|
|
67
|
+
<div class="taskrow${t.enabled ? '' : ' off'}">
|
|
68
|
+
<label class="sw" title="${t.enabled ? 'apagarla' : 'encenderla'}"><input type="checkbox" role="switch" data-toggle="${esc(w.slug)}|${esc(t.id)}" ${t.enabled ? 'checked' : ''}><span class="swt" aria-hidden="true"></span><span class="swl">${t.enabled ? 'encendida' : 'apagada'}</span></label>
|
|
69
|
+
<a class="tmain" href="${t.action && t.action.type === 'objective' ? `/w/${esc(w.slug)}/equipos/${encodeURIComponent(t.action.team)}/rutinas/${encodeURIComponent(t.id)}` : `/w/${esc(w.slug)}#tareas=${encodeURIComponent(t.id)}`}"><b>${esc(t.name)}</b><span class="tplan">${esc(describePlan(t.plan, t.when))}</span><span class="tact">${esc(describeAction(t.action))}</span></a>
|
|
70
|
+
<div class="tstate">
|
|
71
|
+
${t.running ? '<span class="st active">corriendo</span>' : failed(t) ? '<span class="st waiting">falló</span>' : t.last_status === 'ok' ? '<span class="st done">ok</span>' : ''}
|
|
72
|
+
<span class="twhen">${t.enabled && t.next_run ? 'próxima ' + esc(fmtTs(t.next_run)) : ''}${t.enabled && t.next_run && t.last_run ? '<br>' : ''}${t.last_run ? 'última ' + esc(fmtTs(t.last_run)) : ''}</span>
|
|
73
|
+
${failed(t) && t.last_summary ? `<span class="terr" title="${esc(t.last_summary)}">${esc(t.last_summary)}</span>` : ''}
|
|
74
|
+
</div>
|
|
75
|
+
<button data-run="${esc(w.slug)}|${esc(t.id)}" title="correrla ahora"${t.running ? ' disabled' : ''}>▶ correr</button>
|
|
76
|
+
</div>`).join('')}
|
|
77
|
+
</section>`).join('') +
|
|
78
|
+
(rest.length ? `<p class="others">Sin tareas: ${rest.map((w) => `<a href="/w/${esc(w.slug)}#tareas=nueva">${esc(w.name)}</a>`).join(' · ')}</p>` : '');
|
|
79
|
+
document.querySelectorAll('[data-toggle]').forEach((i) => (i.onchange = () => act(i.dataset.toggle, 'toggle', { enabled: i.checked }, i)));
|
|
80
|
+
document.querySelectorAll('[data-run]').forEach((b) => (b.onclick = () => { b.disabled = true; b.textContent = '⟳ arrancando…'; act(b.dataset.run, 'run', {}, b); }));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// encender/apagar/correr: el workspace atiende su API solo si está vivo; apagado, se enciende primero
|
|
84
|
+
async function act(key, what, extra, el) {
|
|
85
|
+
const [slug, id] = key.split('|'); const w = data.find((x) => x.slug === slug);
|
|
86
|
+
busy++;
|
|
87
|
+
try {
|
|
88
|
+
if (w && !w.alive) { const s = await post('/api/workspaces/start', { slug }); if (!s.ok || !s.data.ok) { el.title = 'el proyecto no arrancó'; return; } }
|
|
89
|
+
await post(`/w/${slug}/api/schedules/${what}`, { id, ...extra });
|
|
90
|
+
} finally { busy--; setTimeout(refresh, what === 'run' ? 1500 : 300); }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function refresh() {
|
|
94
|
+
try {
|
|
95
|
+
const r = await fetch('/api/tasks-home');
|
|
96
|
+
if (r.status === 401) { location.href = '/login'; return; }
|
|
97
|
+
data = (await r.json()).workspaces || [];
|
|
98
|
+
// no repintar mientras se espera la respuesta de un clic (el botón queda en «arrancando…»)
|
|
99
|
+
if (!busy) render();
|
|
100
|
+
$('#live').classList.remove('off');
|
|
101
|
+
} catch (e) { $('#live').classList.add('off'); }
|
|
102
|
+
}
|
|
103
|
+
refresh();
|
|
104
|
+
setInterval(refresh, 5000);
|
package/public/js/teams-home.js
CHANGED
|
@@ -5,6 +5,10 @@ const $ = (s) => document.querySelector(s);
|
|
|
5
5
|
const esc = (s) => String(s ?? '').replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
6
6
|
const STATUS = { active: 'trabajando', waiting: 'te espera', done: 'hecho', failed: 'falló', cancelled: 'cancelado', paused: 'sin presupuesto' };
|
|
7
7
|
const short = (slug) => slug.replace(/-[0-9a-f]{8}$/, '');
|
|
8
|
+
// la carpeta del usuario como ~ (igual que en el inicio): el nombre de usuario no aparece al compartir pantalla
|
|
9
|
+
const shortPath = (p) => String(p || '').replace(/^[a-z]:[\\/]users[\\/][^\\/]+/i, '~').replace(/^\/(home|Users)\/[^/]+/, '~');
|
|
10
|
+
// la página de un objetivo en su proyecto: dentro de su equipo, o la de un agente solo
|
|
11
|
+
const objUrl = (w, o) => '/w/' + esc(w.slug) + (o.team ? '/equipos/' + encodeURIComponent(o.team) + '/objetivos/' : '/objetivos/') + o.id;
|
|
8
12
|
let data = [];
|
|
9
13
|
|
|
10
14
|
async function post(path, body) {
|
|
@@ -26,7 +30,7 @@ function renderAttention() {
|
|
|
26
30
|
for (const o of w.objectives.filter((o) => o.status === 'waiting')) {
|
|
27
31
|
const ap = o.question_kind === 'approval'; const k = w.slug + ':' + o.id;
|
|
28
32
|
html += `<div class="ask ${ap ? 'approval' : ''}"><span class="who">${esc(short(w.slug))} · ${esc(o.agent)} ${ap ? 'pide aprobación' : 'pregunta'}</span>
|
|
29
|
-
<div class="q"><a class="ref" href="
|
|
33
|
+
<div class="q"><a class="ref" href="${objUrl(w, o)}">${esc(o.ref)}</a> ${esc(o.question)}</div>
|
|
30
34
|
<div class="acts">${ap ? `<input data-k="${esc(k)}" placeholder="nota (opcional)"><button class="ok" data-ok="${esc(k)}">Aprobar</button><button class="no" data-no="${esc(k)}">Denegar</button>`
|
|
31
35
|
: `<input data-k="${esc(k)}" placeholder="tu respuesta"><button class="primary" data-ans="${esc(k)}">Responder</button>`}</div></div>`;
|
|
32
36
|
}
|
|
@@ -49,25 +53,67 @@ function renderAttention() {
|
|
|
49
53
|
box.querySelectorAll('[data-qno]').forEach((b) => (b.onclick = () => q(b.dataset.qno, false)));
|
|
50
54
|
}
|
|
51
55
|
|
|
52
|
-
// ----------
|
|
56
|
+
// ---------- una tarjeta por equipo: quiénes son, qué están haciendo ahora y qué podés hacer vos ----------
|
|
57
|
+
// Revelación progresiva: el objetivo en curso en una oración (el texto completo está en la pantalla del equipo), los
|
|
58
|
+
// terminados plegados. Lo que espera una respuesta ya está arriba, en «lo que te espera».
|
|
59
|
+
const OPEN = ['waiting', 'active', 'paused'];
|
|
60
|
+
const doneOpen = new Set();
|
|
61
|
+
function firstSentence(t) {
|
|
62
|
+
const s = String(t || '').replace(/\s+/g, ' ').trim(), m = s.match(/^(.{20,}?[.:;!?])(\s|$)/);
|
|
63
|
+
const out = m ? m[1] : s;
|
|
64
|
+
return out.length > 150 ? out.slice(0, 147).replace(/\s+\S*$/, '') + '…' : out;
|
|
65
|
+
}
|
|
66
|
+
// texto a dos líneas como máximo, así las tarjetas vecinas quedan alineadas; si no entra (o hay más que la primera
|
|
67
|
+
// oración) dice «ver más» y el texto completo aparece en el lugar al pasar el mouse o con el foco
|
|
68
|
+
function clip(shown, full) {
|
|
69
|
+
const all = String(full ?? shown ?? '').replace(/\s+/g, ' ').trim();
|
|
70
|
+
return `<span class="clip"><span class="ct">${esc(shown)}</span><span class="cmore" aria-hidden="true">ver más</span><span class="cfull" role="tooltip">${esc(all.length > 600 ? all.slice(0, 597).replace(/\s+\S*$/, '') + '…' : all)}</span></span>`;
|
|
71
|
+
}
|
|
72
|
+
function markClipped(root) {
|
|
73
|
+
root.querySelectorAll('.clip').forEach((c) => {
|
|
74
|
+
const t = c.querySelector('.ct'), cut = t.scrollHeight > t.clientHeight + 1 || t.textContent !== c.querySelector('.cfull').textContent;
|
|
75
|
+
c.classList.toggle('cut', cut);
|
|
76
|
+
if (!c.closest('a')) c.tabIndex = cut ? 0 : -1;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function objLine(w, o) {
|
|
80
|
+
return `<a class="oline" href="${objUrl(w, o)}"><span class="st ${o.status}">${STATUS[o.status] || o.status}</span><span class="otext">${clip(firstSentence(o.text), o.text)}</span></a>`;
|
|
81
|
+
}
|
|
82
|
+
function teamCard(w, t) {
|
|
83
|
+
const mine = w.objectives.filter((o) => o.team === t.id);
|
|
84
|
+
const now = mine.filter((o) => OPEN.includes(o.status)).sort((a, b) => OPEN.indexOf(a.status) - OPEN.indexOf(b.status)), done = mine.filter((o) => !OPEN.includes(o.status));
|
|
85
|
+
const roles = t.roles && t.roles.length ? t.roles : null, key = w.slug + ':' + t.id;
|
|
86
|
+
return `<article class="tcard">
|
|
87
|
+
<div class="thead"><h2>${esc(t.name || t.id)}</h2><a class="tproj" href="/w/${esc(w.slug)}/equipos" title="${esc(shortPath(w.path))}"><span class="dot${w.alive ? ' on' : ''}"></span>${esc(w.name || short(w.slug))}</a></div>
|
|
88
|
+
<p class="tdesc">${t.description ? clip(t.description) : ''}</p>
|
|
89
|
+
<div class="roles">${roles ? roles.map((r, i) => `<span class="role${i === 0 ? ' lead' : ''}"${i === 0 ? ' title="lo lidera"' : ''}>${esc(r)}</span>`).join('') : `<span class="role">${t.members} agente${t.members === 1 ? '' : 's'}</span><span class="role lead">lo lidera ${esc(t.lead)}</span>`}</div>
|
|
90
|
+
<div class="tnow">${now.length ? now.map((o) => objLine(w, o) + (o.progress && o.status === 'active' ? `<p class="oprog">${clip(firstSentence(o.progress), o.progress)}</p>` : '')).join('') : '<p class="tidle">Nada en curso. Dale un objetivo y el equipo se reparte el trabajo.</p>'}</div>
|
|
91
|
+
<div class="tacts"><a class="btn${now.length ? '' : ' primary'}" href="/w/${esc(w.slug)}/equipos/${encodeURIComponent(t.id)}/objetivos/nuevo">Darle un objetivo</a><a class="lnk" href="/w/${esc(w.slug)}/equipos/${encodeURIComponent(t.id)}">Ver el equipo</a></div>
|
|
92
|
+
${done.length ? `<details class="tdone" data-key="${esc(key)}"${doneOpen.has(key) ? ' open' : ''}><summary>${done.length} objetivo${done.length === 1 ? '' : 's'} terminado${done.length === 1 ? '' : 's'}</summary>${done.map((o) => objLine(w, o)).join('')}</details>` : '<div class="tdone"></div>'}
|
|
93
|
+
</article>`;
|
|
94
|
+
}
|
|
95
|
+
let lastProjects = '';
|
|
53
96
|
function renderProjects() {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
97
|
+
const cards = data.flatMap((w) => w.teams.map((t) => teamCard(w, t)));
|
|
98
|
+
// objetivos de un agente solo (sin equipo) que siguen abiertos
|
|
99
|
+
const solo = data.flatMap((w) => w.objectives.filter((o) => !o.team && OPEN.includes(o.status)).map((o) => ({ w, o })));
|
|
100
|
+
const html = (cards.length ? `<div class="tgrid">${cards.join('')}</div>`
|
|
101
|
+
: `<div class="tinvite"><h2>Armá tu primer equipo</h2><p>Un equipo son agentes con roles —por ejemplo un CEO, un CTO y un desarrollador— que trabajan solos hacia un objetivo, se coordinan entre ellos y te consultan antes de lo irreversible.</p><button class="primary" data-new>+ equipo</button></div>`) +
|
|
102
|
+
(solo.length ? `<h3 class="solohead">Agentes con un objetivo</h3><div class="solo">${solo.map(({ w, o }) => `<div class="srow"><span class="swho">${esc(o.agent)} <span>en ${esc(w.name || short(w.slug))}</span></span>${objLine(w, o)}</div>`).join('')}</div>` : '');
|
|
103
|
+
// sin cambios no se rehace: si no, cada 4 s se cerraba el texto completo que estabas leyendo
|
|
104
|
+
if (html !== lastProjects) { $('#projects').innerHTML = html; lastProjects = html; markClipped($('#projects')); }
|
|
105
|
+
document.querySelectorAll('details.tdone').forEach((d) => (d.ontoggle = () => { if (d.open) doneOpen.add(d.dataset.key); else doneOpen.delete(d.dataset.key); markClipped(d); }));
|
|
106
|
+
const nb = document.querySelector('[data-new]'); if (nb) nb.onclick = () => $('#newTeam').onclick();
|
|
107
|
+
// el selector del formulario se rehace cada 4 s: sin esto perdía lo que la persona había elegido
|
|
108
|
+
const ws = $('#nWs'), cur = ws.value;
|
|
109
|
+
ws.innerHTML = data.map((w) => `<option value="${esc(w.slug)}">${esc(w.name || short(w.slug))} — ${esc(shortPath(w.path))}</option>`).join('');
|
|
110
|
+
if (cur) ws.value = cur;
|
|
67
111
|
}
|
|
68
112
|
|
|
69
113
|
// ---------- + equipo ----------
|
|
70
114
|
$('#newTeam').onclick = () => { $('#newBox').hidden = false; $('#nName').focus(); };
|
|
115
|
+
// /equipos?new=1 (el «+ equipo» del inicio) abre el formulario de una
|
|
116
|
+
if (new URLSearchParams(location.search).has('new')) $('#newTeam').onclick();
|
|
71
117
|
$('#nCancel').onclick = () => ($('#newBox').hidden = true);
|
|
72
118
|
$('#nName').onfocus = () => (document.querySelector('input[name=where][value=new]').checked = true);
|
|
73
119
|
$('#nWs').onfocus = () => (document.querySelector('input[name=where][value=ws]').checked = true);
|
|
@@ -93,3 +139,6 @@ async function refresh() {
|
|
|
93
139
|
}
|
|
94
140
|
refresh();
|
|
95
141
|
setInterval(refresh, 4000);
|
|
142
|
+
// al cambiar el ancho, un texto puede pasar a entrar (o dejar de entrar) en dos líneas
|
|
143
|
+
let clipRaf = 0;
|
|
144
|
+
addEventListener('resize', () => { cancelAnimationFrame(clipRaf); clipRaf = requestAnimationFrame(() => markClipped($('#projects'))); });
|