Mise a jour automatique globale programmee par serveur

- planification crontab par serveur (hostauto.json) : toutes les stacks de la
  derniere analyse, une par une, hors exclues, arretees et stacks ayant leur
  propre planification (celle de la stack prime)
- attente d'une connexion occupee (30 min max), resultat par stack conserve
- API PUT /api/servers/{id}/auto {"schedule"} ; vue de fleet : servers[].auto
- interface : bouton horloge par serveur (dialogue de planification), badge,
  section Serveurs dans la vue "Mises a jour auto", statut bleu pendant l'execution

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LNfwm6UCYFyvNQNSF5i9Gy
This commit is contained in:
claude BotandClaude Opus 5.5 committed 2026-11-23 11:17:06 +01:00
1 parent ef259ae27a
commit eac873266c
10 files changed
+824 -109

No files matched your search

+282 -103
View File
@@ -1,7 +1,7 @@
// Mises a jour automatiques programmees (crontab) : badge, editeur dans le
// detail d'une stack et vue de suivi de toutes les programmations.
import { useEffect, useState } from "react";
import { api, type AutoInfo, type Me, type Scan, type Server, type Stack, type Target } from "./api";
// Mises a jour automatiques programmees (crontab) : par stack (detail de la
// stack) et globale par serveur (dialogue du serveur), badges et vue de suivi.
import { useEffect, useState, type ReactNode } from "react";
import { api, type AutoInfo, type HostAutoInfo, type Me, type Scan, type Server, type Stack, type Target } from "./api";
import { fmtDate, fmtRelative } from "./format";
import { CheckIcon, ClockIcon, RefreshIcon, WarningIcon } from "./icons";
@@ -13,6 +13,58 @@ export const AUTO_PRESETS: [string, string][] = [
];
const norm = (s: string) => s.trim().split(/\s+/).join(" ");
const base = (dir: string) => dir.split("/").pop() || dir;
/** Valide une planification cote serveur et renvoie ses prochaines executions. */
function useCronPreview(expr: string, active: boolean) {
const [preview, setPreview] = useState<{ next?: string[]; error?: string }>({});
useEffect(() => {
if (!active) return;
let live = true;
const h = setTimeout(() => {
api.cronPreview(expr).then(
(next) => live && setPreview({ next }),
(e: unknown) => live && setPreview({ error: e instanceof Error ? e.message : String(e) }),
);
}, 300);
return () => {
live = false;
clearTimeout(h);
};
}, [expr, active]);
return preview;
}
/** Planification predefinie ou expression crontab libre. */
function CronInputs({ expr, setExpr, children }: { expr: string; setExpr: (v: string) => void; children?: ReactNode }) {
const preset = AUTO_PRESETS.find(([p]) => p === norm(expr))?.[0] ?? "";
return (
<div className="auto-form">
<select value={preset} onChange={(e) => e.target.value && setExpr(e.target.value)} aria-label="Planification predefinie">
<option value="">Personnalisee</option>
{AUTO_PRESETS.map(([p, label]) => (
<option key={p} value={p}>
{label}
</option>
))}
</select>
<input className="mono" value={expr} onChange={(e) => setExpr(e.target.value)} placeholder="min heure jour mois jour-semaine" aria-label="Planification crontab" spellCheck={false} />
{children}
</div>
);
}
function CronPreview({ preview, tz }: { preview: { next?: string[]; error?: string }; tz?: string }) {
return (
<div className={`small-text auto-preview ${preview.error ? "error-text" : "muted"}`}>
{preview.error
? preview.error
: preview.next?.length
? `Prochaines executions : ${preview.next.map(fmtDate).join(", ")}${tz ? ` (heure ${tz})` : ""}`
: " "}
</div>
);
}
/** Badge (couleur sarcelle) a cote du nom d'une stack programmee. */
export function AutoBadge({ auto }: { auto: AutoInfo }) {
@@ -24,6 +76,16 @@ export function AutoBadge({ auto }: { auto: AutoInfo }) {
);
}
/** Badge a cote du nom d'un serveur a mise a jour globale programmee. */
export function HostAutoBadge({ auto }: { auto: HostAutoInfo }) {
const title = `Mise a jour globale programmee : ${auto.schedule}${auto.next ? `, prochaine le ${fmtDate(auto.next)}` : ""}`;
return (
<span className="auto-badge host" title={title} aria-label="Mise a jour globale programmee">
{auto.running ? <RefreshIcon size={12} className="spin" /> : <ClockIcon size={12} />}
</span>
);
}
/** Dernier resultat d'une execution programmee. */
export function AutoLast({ auto }: { auto: AutoInfo }) {
if (auto.pending) return <span className="auto-last muted">en attente (connexion occupee)</span>;
@@ -39,40 +101,51 @@ export function AutoLast({ auto }: { auto: AutoInfo }) {
);
}
/** Dernier resultat (ou execution en cours) d'une planification de serveur. */
export function HostAutoLast({ auto }: { auto: HostAutoInfo }) {
if (auto.running) {
return (
<span className="status-pill st-applying">
<RefreshIcon size={13} className="spin" /> Mise a jour en cours{auto.current ? ` : ${base(auto.current)}` : ""}
</span>
);
}
if (auto.pending) return <span className="auto-last muted">en attente</span>;
if (!auto.lastRun) return <span className="auto-last muted">jamais executee</span>;
const failed = (auto.results ?? []).filter((r) => !r.ok);
const title = failed.length ? failed.map((r) => `${r.name} : ${r.message}`).join("\n") : fmtDate(auto.lastRun);
return (
<span className={`auto-last ${auto.lastOk ? "ok" : "ko"}`} title={title}>
{auto.lastOk ? <CheckIcon size={13} /> : <WarningIcon size={13} />}
<span>
{fmtRelative(auto.lastRun)}
{auto.lastMessage ? ` : ${auto.lastMessage}` : ""}
</span>
</span>
);
}
interface EditorProps {
stack: Stack;
busy: boolean;
tz?: string;
/** Planification globale du serveur, remplacee par celle de la stack. */
hostSchedule?: string;
onSave: (schedule: string) => Promise<unknown>;
}
/** Case « Mise a jour automatique programmee » et sa planification crontab. */
export function AutoEditor({ stack, busy, tz, onSave }: EditorProps) {
export function AutoEditor({ stack, busy, tz, hostSchedule, onSave }: EditorProps) {
const current = stack.auto?.schedule ?? "";
const [on, setOn] = useState(!!current);
const [expr, setExpr] = useState(current || AUTO_PRESETS[0][0]);
const [preview, setPreview] = useState<{ next?: string[]; error?: string }>({});
const preview = useCronPreview(expr, on);
useEffect(() => {
setOn(!!current);
if (current) setExpr(current);
}, [current]);
useEffect(() => {
if (!on) return;
let live = true;
const h = setTimeout(() => {
api.cronPreview(expr).then(
(next) => live && setPreview({ next }),
(e: unknown) => live && setPreview({ error: e instanceof Error ? e.message : String(e) }),
);
}, 300);
return () => {
live = false;
clearTimeout(h);
};
}, [expr, on]);
if (stack.excluded) {
return (
<label className="check-row muted">
@@ -87,7 +160,6 @@ export function AutoEditor({ stack, busy, tz, onSave }: EditorProps) {
if (!v && current) void onSave(""); // desactivation immediate
};
const dirty = on && norm(expr) !== current;
const preset = AUTO_PRESETS.find(([p]) => p === norm(expr))?.[0] ?? "";
return (
<div className="auto-editor">
@@ -95,32 +167,22 @@ export function AutoEditor({ stack, busy, tz, onSave }: EditorProps) {
<input type="checkbox" checked={on} disabled={busy} onChange={(e) => toggle(e.target.checked)} />
<span>Mise a jour automatique programmee (pull, puis down + up -d seulement si une image a change)</span>
</label>
{hostSchedule && (
<div className="small-text muted auto-preview">
{current
? `Cette planification remplace, pour cette stack, celle du serveur (${hostSchedule}).`
: `Couverte par la planification du serveur (${hostSchedule}) ; une planification propre a la stack la remplacerait.`}
</div>
)}
{on && (
<div className="auto-form">
<select value={preset} onChange={(e) => e.target.value && setExpr(e.target.value)} aria-label="Planification predefinie">
<option value="">Personnalisee</option>
{AUTO_PRESETS.map(([p, label]) => (
<option key={p} value={p}>
{label}
</option>
))}
</select>
<input className="mono" value={expr} onChange={(e) => setExpr(e.target.value)} placeholder="min heure jour mois jour-semaine" aria-label="Planification crontab" spellCheck={false} />
<CronInputs expr={expr} setExpr={setExpr}>
<button className="primary" disabled={!dirty || busy || !!preview.error} onClick={() => void onSave(norm(expr))}>
<ClockIcon />
{current ? "Modifier" : "Programmer"}
</button>
</div>
)}
{on && (
<div className={`small-text ${preview.error ? "error-text" : "muted"}`}>
{preview.error
? preview.error
: preview.next?.length
? `Prochaines executions : ${preview.next.map(fmtDate).join(", ")}${tz ? ` (heure ${tz})` : ""}`
: " "}
</div>
</CronInputs>
)}
{on && <CronPreview preview={preview} tz={tz} />}
{stack.auto && (
<div className="small-text muted">
Derniere execution programmee : <AutoLast auto={stack.auto} />
@@ -130,6 +192,72 @@ export function AutoEditor({ stack, busy, tz, onSave }: EditorProps) {
);
}
interface HostDialogProps {
server: Server;
tz?: string;
onSave: (schedule: string) => void;
onClose: () => void;
}
/** Planification de la mise a jour globale d'un serveur. */
export function HostAutoDialog({ server, tz, onSave, onClose }: HostDialogProps) {
const current = server.auto?.schedule ?? "";
const [on, setOn] = useState(!!current);
const [expr, setExpr] = useState(current || AUTO_PRESETS[0][0]);
const preview = useCronPreview(expr, on);
useEffect(() => {
const onKey = (e: KeyboardEvent) => e.key === "Escape" && onClose();
window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
}, [onClose]);
const value = on ? norm(expr) : "";
const changed = value !== current;
const results = server.auto?.results ?? [];
return (
<div className="modal-backdrop" onClick={onClose}>
<div className="modal" role="dialog" aria-modal="true" aria-label="Mise a jour automatique du serveur" onClick={(e) => e.stopPropagation()}>
<h3>Mise a jour automatique : {server.name}</h3>
<div className="modal-text">
<p className="muted small-text">
A chaque echeance, les stacks du serveur sont mises a jour une par une (pull, puis down + up -d seulement si une image a change). Sont ignorees : les stacks exclues, les stacks arretees et les
stacks qui ont leur propre planification (celle de la stack prime).
</p>
<label className="check-row">
<input type="checkbox" checked={on} onChange={(e) => setOn(e.target.checked)} />
<span>Mettre a jour automatiquement toutes les stacks de ce serveur</span>
</label>
{on && <CronInputs expr={expr} setExpr={setExpr} />}
{on && <CronPreview preview={preview} tz={tz} />}
{server.auto && (
<div className="small-text">
Derniere execution : <HostAutoLast auto={server.auto} />
</div>
)}
{results.length > 0 && !server.auto?.running && (
<ul className="auto-results small-text">
{results.map((r) => (
<li key={`${r.target}:${r.dir}`} className={r.ok ? (r.skipped ? "muted" : "ok") : "ko"}>
{r.ok ? <CheckIcon size={12} /> : <WarningIcon size={12} />} <strong>{r.name}</strong> <span className="muted">({r.user})</span> : {r.message}
</li>
))}
</ul>
)}
</div>
<div className="modal-actions">
<span className="spacer" />
<button onClick={onClose}>Annuler</button>
<button className="primary" disabled={!changed || (on && !!preview.error)} onClick={() => onSave(value)}>
Enregistrer
</button>
</div>
</div>
</div>
);
}
interface Row {
server: Server;
target: Target;
@@ -144,86 +272,137 @@ interface PanelProps {
query: string;
tz?: string;
onDisable: (server: Server, target: Target, stack: Stack) => void;
onDisableHost: (server: Server) => void;
onEditHost: (server: Server) => void;
}
/** Espace de suivi : toutes les stacks programmees, triees par prochaine execution. */
export function AutoPanel({ me, servers, query, tz, onDisable }: PanelProps) {
const byNext = (a?: string, b?: string) => (a ?? "9").localeCompare(b ?? "9");
/** Espace de suivi : planifications des serveurs puis des stacks, triees par prochaine execution. */
export function AutoPanel({ me, servers, query, tz, onDisable, onDisableHost, onEditHost }: PanelProps) {
const q = query.trim().toLowerCase();
const hosts = servers.filter((s) => s.auto && (!q || s.name.toLowerCase().includes(q))).sort((a, b) => byNext(a.auto?.next, b.auto?.next));
const rows: Row[] = servers.flatMap((server) =>
server.targets.flatMap((target) => {
const scan = server.scans[target.id];
return (scan?.stacks ?? []).flatMap((stack) => (stack.auto ? [{ server, target, scan, stack, auto: stack.auto }] : []));
}),
);
const q = query.trim().toLowerCase();
const shown = rows
.filter((r) => !q || r.stack.name.toLowerCase().includes(q) || r.stack.dir.toLowerCase().includes(q) || r.server.name.toLowerCase().includes(q))
.sort((a, b) => (a.auto.next ?? "9").localeCompare(b.auto.next ?? "9"));
.sort((a, b) => byNext(a.auto.next, b.auto.next));
if (!rows.length) {
if (!rows.length && !servers.some((s) => s.auto)) {
return (
<p className="muted pad">
Aucune stack en mise a jour automatique. Pour en programmer une, ouvrir son detail et cocher « Mise a jour automatique programmee ».
Aucune mise a jour automatique. Pour une stack : ouvrir son detail et cocher « Mise a jour automatique programmee ». Pour tout un serveur : bouton horloge a cote de « Modifier ».
</p>
);
}
return (
<div className="auto-panel">
<p className="muted small-text">
{rows.length} stack{rows.length > 1 ? "s" : ""} programmee{rows.length > 1 ? "s" : ""}. Heures exprimees dans le fuseau du serveur stackwatch{tz ? ` (${tz})` : ""}.
</p>
<table className="services auto-table">
<thead>
<tr>
<th>Stack</th>
<th>Serveur</th>
<th>Planification</th>
<th>Prochaine</th>
<th>Derniere execution</th>
{me.admin && <th />}
</tr>
</thead>
<tbody>
{shown.map(({ server, target, scan, stack, auto }) => {
const running = scan.running && scan.task === "apply" && scan.current === stack.dir;
return (
<tr key={`${server.id}/${target.id}:${stack.dir}`}>
<td>
<strong>{stack.name}</strong>
<br />
<small className="muted">{stack.dir}</small>
</td>
<td>
{server.name}
{!server.enabled && <span className="muted"> (desactive)</span>}
<br />
<small className="muted">{target.user}</small>
</td>
<td>
<code>{auto.schedule}</code>
</td>
<td>{auto.next ? fmtDate(auto.next) : <span className="muted">jamais</span>}</td>
<td>
{running ? (
<span className="status-pill st-applying">
<RefreshIcon size={13} className="spin" /> Mise a jour en cours
</span>
) : (
<AutoLast auto={auto} />
)}
</td>
{me.admin && (
<td>
<button onClick={() => onDisable(server, target, stack)} disabled={running}>
Desactiver
</button>
</td>
)}
<p className="muted small-text">Heures exprimees dans le fuseau du serveur stackwatch{tz ? ` (${tz})` : ""}. La planification d'une stack prime sur celle de son serveur.</p>
{hosts.length > 0 && (
<>
<h4 className="auto-h">Serveurs (toutes les stacks, hors exclues, arretees et planifiees individuellement)</h4>
<table className="services auto-table">
<thead>
<tr>
<th>Serveur</th>
<th>Planification</th>
<th>Prochaine</th>
<th>Derniere execution</th>
{me.admin && <th />}
</tr>
);
})}
</tbody>
</table>
{shown.length === 0 && <p className="muted pad">Aucune programmation ne correspond a la recherche.</p>}
</thead>
<tbody>
{hosts.map((s) => (
<tr key={s.id}>
<td>
<strong>{s.name}</strong>
{!s.enabled && <span className="muted"> (desactive)</span>}
<br />
<small className="muted">{s.host}</small>
</td>
<td>
<code>{s.auto!.schedule}</code>
</td>
<td>{s.auto!.next ? fmtDate(s.auto!.next) : <span className="muted">jamais</span>}</td>
<td>
<HostAutoLast auto={s.auto!} />
</td>
{me.admin && (
<td className="auto-actions">
<button onClick={() => onEditHost(s)}>Modifier</button>
<button onClick={() => onDisableHost(s)}>Desactiver</button>
</td>
)}
</tr>
))}
</tbody>
</table>
</>
)}
{rows.length > 0 && (
<>
<h4 className="auto-h">Stacks</h4>
<table className="services auto-table">
<thead>
<tr>
<th>Stack</th>
<th>Serveur</th>
<th>Planification</th>
<th>Prochaine</th>
<th>Derniere execution</th>
{me.admin && <th />}
</tr>
</thead>
<tbody>
{shown.map(({ server, target, scan, stack, auto }) => {
const running = scan.running && scan.task === "apply" && scan.current === stack.dir;
return (
<tr key={`${server.id}/${target.id}:${stack.dir}`}>
<td>
<strong>{stack.name}</strong>
<br />
<small className="muted">{stack.dir}</small>
</td>
<td>
{server.name}
{!server.enabled && <span className="muted"> (desactive)</span>}
<br />
<small className="muted">{target.user}</small>
</td>
<td>
<code>{auto.schedule}</code>
</td>
<td>{auto.next ? fmtDate(auto.next) : <span className="muted">jamais</span>}</td>
<td>
{running ? (
<span className="status-pill st-applying">
<RefreshIcon size={13} className="spin" /> Mise a jour en cours
</span>
) : (
<AutoLast auto={auto} />
)}
</td>
{me.admin && (
<td>
<button onClick={() => onDisable(server, target, stack)} disabled={running}>
Desactiver
</button>
</td>
)}
</tr>
);
})}
</tbody>
</table>
{shown.length === 0 && <p className="muted pad">Aucune programmation ne correspond a la recherche.</p>}
</>
)}
</div>
);
}
+36 -5
View File
@@ -1,6 +1,6 @@
import { useMemo, useState } from "react";
import { api, type Me, type Fleet, type Scan, type Server, type Stack, type StackStatus, type Target } from "./api";
import { AutoBadge, AutoEditor, AutoPanel } from "./AutoUpdate";
import { AutoBadge, AutoEditor, AutoPanel, HostAutoBadge, HostAutoDialog } from "./AutoUpdate";
import { ConfirmDialog } from "./Dialogs";
import { fmtRelative, plural } from "./format";
import { ArrowUpIcon, BanIcon, CheckIcon, ChevronDownIcon, ChevronRightIcon, ClockIcon, EditIcon, KeyIcon, PlusIcon, RefreshIcon, SearchIcon, ServerIcon, WarningIcon } from "./icons";
@@ -30,6 +30,7 @@ export function FleetView({ me, fleet, current, run, onEdit, onAdd, onKey }: Pro
const [filter, setFilter] = useState<Filter>("all");
const [search, setSearch] = useState("");
const [applying, setApplying] = useState<{ server: Server; target: Target; stack: Stack } | null>(null);
const [hostAuto, setHostAuto] = useState<Server | null>(null);
const servers = useMemo(() => (current ? [current] : (fleet?.servers ?? [])), [current, fleet]);
@@ -84,7 +85,10 @@ export function FleetView({ me, fleet, current, run, onEdit, onAdd, onKey }: Pro
<div className="fleet">
<div className="head">
<div className="head-title">
<h2>{current ? current.name : "Tous les serveurs"}</h2>
<h2>
{current ? current.name : "Tous les serveurs"}
{current?.auto && <HostAutoBadge auto={current.auto} />}
</h2>
{current && (
<span className="muted">
{current.host}
@@ -135,13 +139,19 @@ export function FleetView({ me, fleet, current, run, onEdit, onAdd, onKey }: Pro
Modifier
</button>
)}
{me.admin && (
<button onClick={() => setHostAuto(current)} title="Mise a jour automatique de toutes les stacks du serveur">
<ClockIcon />
Mise a jour auto
</button>
)}
</>
)}
</div>
<div className="scroll">
{filter === "auto" ? (
<AutoPanel me={me} servers={servers} query={search} tz={fleet.tz} onDisable={(srv, t, st) => run(() => api.autoStack(srv.id, t.id, st.dir, ""))} />
<AutoPanel me={me} servers={servers} query={search} tz={fleet.tz} onDisable={(srv, t, st) => run(() => api.autoStack(srv.id, t.id, st.dir, ""))} onDisableHost={(srv) => run(() => api.autoServer(srv.id, ""))} onEditHost={setHostAuto} />
) : servers.map((s) => (
<ServerBlock
key={s.id}
@@ -155,6 +165,7 @@ export function FleetView({ me, fleet, current, run, onEdit, onAdd, onKey }: Pro
onApply={(target, stack) => setApplying({ server: s, target, stack })}
onExclude={(target, stack, on) => run(() => api.excludeStack(s.id, target.id, stack.dir, on))}
onAuto={(target, stack, schedule) => run(() => api.autoStack(s.id, target.id, stack.dir, schedule))}
onHostAuto={() => setHostAuto(s)}
tz={fleet.tz}
/>
))}
@@ -177,6 +188,19 @@ export function FleetView({ me, fleet, current, run, onEdit, onAdd, onKey }: Pro
</p>
</ConfirmDialog>
)}
{hostAuto && (
<HostAutoDialog
server={hostAuto}
tz={fleet.tz}
onClose={() => setHostAuto(null)}
onSave={(schedule) => {
const id = hostAuto.id;
setHostAuto(null);
run(() => api.autoServer(id, schedule));
}}
/>
)}
</div>
);
}
@@ -192,10 +216,11 @@ interface BlockProps {
onApply: (t: Target, s: Stack) => void;
onExclude: (t: Target, s: Stack, on: boolean) => void;
onAuto: (t: Target, s: Stack, schedule: string) => Promise<void>;
onHostAuto: () => void;
tz?: string;
}
function ServerBlock({ server, single, me, keep, filtering, onEdit, onCheck, onApply, onExclude, onAuto, tz }: BlockProps) {
function ServerBlock({ server, single, me, keep, filtering, onEdit, onCheck, onApply, onExclude, onAuto, onHostAuto, tz }: BlockProps) {
const scans = Object.values(server.scans);
const running = scans.some((s) => s.running);
const last = scans.map((s) => s.finished).filter(Boolean).sort().pop();
@@ -207,6 +232,7 @@ function ServerBlock({ server, single, me, keep, filtering, onEdit, onCheck, onA
<header className="server-head">
<ServerIcon size={18} />
<h3>{server.name}</h3>
{server.auto && <HostAutoBadge auto={server.auto} />}
<span className="muted">{server.host}</span>
{!server.enabled && <span className="pill">désactivé</span>}
{updates > 0 && <span className="pill warn">{plural(updates, "mise")} à jour</span>}
@@ -219,6 +245,11 @@ function ServerBlock({ server, single, me, keep, filtering, onEdit, onCheck, onA
<button className="icon-btn" onClick={() => onCheck()} disabled={running} aria-label={`Vérifier ${server.name}`} title="Vérifier ce serveur">
<RefreshIcon className={running ? "spin" : ""} />
</button>
{me.admin && (
<button className="icon-btn" onClick={onHostAuto} aria-label={`Mise a jour auto de ${server.name}`} title="Mise a jour automatique de toutes les stacks du serveur">
<ClockIcon />
</button>
)}
{me.admin && (
<button className="icon-btn" onClick={onEdit} aria-label={`Modifier ${server.name}`} title="Modifier">
<EditIcon />
@@ -341,7 +372,7 @@ function TargetBlock({ server, target, scan, me, keep, filtering, onCheck, onApp
<span>Exclure cette stack des mises à jour (elle reste analysée et affichée, sans bouton « Mettre à jour »)</span>
</label>
)}
{me.admin && <AutoEditor stack={st} busy={applying} tz={tz} onSave={(x) => onAuto(st, x)} />}
{me.admin && <AutoEditor stack={st} busy={applying} tz={tz} hostSchedule={server.auto?.schedule} onSave={(x) => onAuto(st, x)} />}
{!me.admin && st.auto && (
<div className="small-text muted">
Mise a jour automatique : <code>{st.auto.schedule}</code>
+35
View File
@@ -88,6 +88,34 @@ export interface AutoInfo {
pending?: boolean;
}
/** Resultat d'une stack lors d'une mise a jour globale programmee. */
export interface HostStackResult {
target: string;
user: string;
dir: string;
name: string;
ok: boolean;
/** Rien a faire (deja a jour, stack arretee). */
skipped?: boolean;
message: string;
}
/** Mise a jour globale programmee d'un serveur. */
export interface HostAutoInfo {
schedule: string;
by?: string;
since: string;
next?: string;
lastRun?: string;
lastOk: boolean;
lastMessage?: string;
results?: HostStackResult[];
pending?: boolean;
running?: boolean;
/** Stack en cours pendant une execution. */
current?: string;
}
export interface Scan {
running: boolean;
task?: "scan" | "apply";
@@ -116,6 +144,8 @@ export interface Server extends ServerInput {
targets: Target[];
/** Résultat de chaque connexion, par identifiant de connexion. */
scans: Record<string, Scan>;
/** Mise a jour globale programmee du serveur. */
auto?: HostAutoInfo;
}
export interface Summary {
@@ -236,6 +266,11 @@ export const api = {
await request(`/api/servers/${q(serverId)}/targets/${q(targetId)}/auto`, json({ dir, schedule }, "PUT"));
},
/** Programme la mise a jour globale d'un serveur (crontab) ; schedule vide : la desactive. */
autoServer: async (serverId: string, schedule: string): Promise<void> => {
await request(`/api/servers/${q(serverId)}/auto`, json({ schedule }, "PUT"));
},
/** Valide une planification et renvoie ses prochaines executions. */
cronPreview: async (expr: string): Promise<string[]> => (await (await request(`/api/cron?expr=${q(expr)}`)).json()).next,
+42
View File
@@ -1348,3 +1348,45 @@ button.copy-ko {
.auto-table td {
vertical-align: top;
}
/* Planification globale d'un serveur : meme couleur, badge carre */
.auto-badge.host {
border-radius: 0.3rem;
}
h2 .auto-badge,
.server-head .auto-badge {
vertical-align: middle;
}
.auto-h {
margin: 1rem 0 0.4rem;
font-size: 0.95rem;
}
.auto-actions {
white-space: nowrap;
}
.auto-actions button + button {
margin-left: 0.3rem;
}
.modal .auto-form,
.modal .auto-preview {
padding-left: 0;
margin: 0.4rem 0;
}
.auto-results {
list-style: none;
margin: 0.4rem 0 0;
padding: 0;
max-height: 12rem;
overflow: auto;
}
.auto-results li {
display: flex;
align-items: center;
gap: 0.3rem;
padding: 0.1rem 0;
}
.auto-results li.ok svg {
color: var(--ok);
}
.auto-results li.ko svg {
color: var(--danger);
}