Make execution controls and maintenance workflows easier to use
This commit is contained in:
+60
-17
@@ -9,7 +9,7 @@ import { ScriptLibrary } from './script-library';
|
||||
import { McpTokenManagement } from './mcp-token-management';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import { actions, Action, ApiError, authConfig, approvalBlockers, expectedStdout, objectId, page, Page, PlanInput, pretty, record, RecordValue, request, session, Session, stringField, tenant, tenantPath, validateInput, windowsPowerShellRemoteSignedProfile, fullMaintenanceScriptProfile } from './api';
|
||||
import { actions, Action, ApiError, authConfig, approvalBlockers, expectedStdout, objectId, page, PlanInput, pretty, record, RecordValue, request, session, Session, stringField, tenant, tenantPath, validateInput, windowsPowerShellRemoteSignedProfile, fullMaintenanceScriptProfile } from './api';
|
||||
import './style.css';
|
||||
import { AdminControl, Catalog, TenantControls } from './management';
|
||||
import { allowed, availableActions, parseStrictJson, powerShellApprovalBlockers, powerShellPlanJobs, rootWarning, systemWarning, systemPlanJobs, validateSensitiveInput, verifyPlanIntegrity, queryLogsApprovalBlockers, queryLogsPlanJobs, windowsMsiApprovalBlockers, windowsMsiPlanJobs, verifyWindowsMsiManifest, fullMaintenanceWarning } from './safety';
|
||||
@@ -115,14 +115,15 @@ export function QueryLogsPlanNotice({ plan }: { plan: RecordValue }) {
|
||||
return <aside className="warning" aria-label="Feste Live-Logfenster"><p>UI-genehmigte Liveabfrage aus hashgeprüften gespeicherten Planbytes; kein passives Inventar, keine automatische Erhebung.</p><ul>{jobs.map((job, i) => <li key={i}>Asset: {job.assetId} · Quelle: {job.source}{job.windows ? <> · Kanal: {job.channel} · Provider: {job.provider} · agent_service</> : ' · Linux-Journal'} · UTC-Fenster: [{job.since}, {job.until}) · maximal {job.maxLines} {job.windows ? 'Events' : 'Zeilen'} · {job.outputBytes} Bytes · äußere Joblaufzeit {job.runtimeSeconds}s{job.windows && ' · inneres Abfragebudget höchstens5000ms, zwischen Win32-Aufrufen kooperativ geprüft'}</li>)}</ul><p>Grenzen, Abbruch, fehlende Rechte und Teilabdeckung bleiben sichtbar. Keine Bookmarkfortschreibung durch diesen Auftrag; die Abfrage behauptet keine vollständige Sammlung aller Systemlogs.</p></aside>;
|
||||
} catch { return <aside role="alert" className="error">Logfenster ist nicht verifiziert oder wurde verändert. Keine Genehmigung ohne gültige gespeicherte Planbytes.</aside>; }
|
||||
}
|
||||
function PageStatus({ data }: { data: Page }) { return <p className={data.completeness === 'complete' && !data.truncated ? 'muted' : 'warning'}>Listenstand: {data.as_of} · Vollständigkeit: {data.completeness} · begrenzt: {String(data.truncated)}. Fehlende Einträge sind kein Löschungsnachweis.</p>; }
|
||||
const initialParameters: Record<Action, RecordValue> = {
|
||||
run_script: {}, refresh_inventory: { scope: 'linux.base' }, query_logs: { unit: '', since: '', until: '', max_lines: 1000 }, set_service_state: { unit: '', state: 'running' }, ensure_package: { provider: 'apt', recipe_version: '', package: '', version: '', architecture: 'amd64', installation_context: 'system', apt_manifest: null }, apply_updates: { provider: 'apt', packages: [], reboot_policy: 'never', apt_manifest: null }, reboot: { reason: '', dependency_group: '', reconnect_timeout_seconds: 300 }, apt_native_acceptance: { recipe_id: 'rmm-apt-fixture-install-1.0', recipe_version: '1', apt_manifest: null },
|
||||
update_agent: { release_id: '' },
|
||||
};
|
||||
function Planner({ tenantId, auth, selected, showPlan }: { tenantId: string; auth: Session; selected: string[]; showPlan: (id: string) => void }) {
|
||||
const choices = availableActions(auth, actions).filter(action => auth.principal.simulated || !['run_script', 'reboot'].includes(action));
|
||||
const [scriptPlatform, setScriptPlatform] = useState('linux'), [mixedVariants, setMixedVariants] = useState('[]');
|
||||
const [action, setAction] = useState<Action>('run_script'), [parameters, setParameters] = useState('{}'), [error, setError] = useState<string | null>(null), [busy, setBusy] = useState(false);
|
||||
const initialAction = auth.principal.simulated ? 'run_script' : 'refresh_inventory';
|
||||
const [action, setAction] = useState<Action>(initialAction), [parameters, setParameters] = useState(pretty(initialParameters[initialAction])), [error, setError] = useState<string | null>(null), [busy, setBusy] = useState(false);
|
||||
const [identity, setIdentity] = useState('agent_service');
|
||||
return <section><h2>Neuen unveränderlichen Plan vorbereiten</h2><p>Nur fest ausgewählte Asset-IDs. Keine Ausführung durch Planung oder Antrag; jede Aktion einschließlich Live-Inventar benötigt Genehmigung.</p>
|
||||
<form onSubmit={async e => { e.preventDefault(); setBusy(true); setError(null); const f = new FormData(e.currentTarget); try {
|
||||
@@ -132,7 +133,7 @@ function Planner({ tenantId, auth, selected, showPlan }: { tenantId: string; aut
|
||||
const ids = String(f.get('artifact_ids') ?? '').split(/[\s,]+/).filter(Boolean); if (ids.length) { if (ids.length > 16 || new Set(ids).size !== ids.length || ids.some(id => !/^[0-9a-f-]{36}$/i.test(id))) throw new Error('Maximal 16 eindeutige feste Artefakt-UUIDs'); input.artifact_ids = ids; }
|
||||
validateInput(input); await validateSensitiveInput(input, auth); const plan = record(await request(tenantPath(tenantId, '/operation-plans'), { body: input, csrf: auth.csrf_token })); showPlan(objectId(plan, 'plan'));
|
||||
} catch (e) { setError(errorText(e)); } finally { setBusy(false); } }}>
|
||||
<label>Aktion<select aria-label="Aktion" value={action} onChange={e => { const next = availableActions(auth, actions).find(a => a === e.target.value); if (next) { setAction(next); setParameters(pretty(initialParameters[next])); } }}>{availableActions(auth, actions).map(a => <option key={a} value={a}>{a}</option>)}</select></label>
|
||||
<label>Aktion<select aria-label="Aktion" value={action} onChange={e => { const next = choices.find(a => a === e.target.value); if (next) { setAction(next); setParameters(pretty(initialParameters[next])); } }}>{choices.map(a => <option key={a} value={a}>{auth.principal.simulated ? a : actionTitle(a)}</option>)}</select></label>
|
||||
{action === 'update_agent' && <p className="warning">{agentUpdateWarning} Nur parameters.release_id aus dem Katalog; keine freien Vorgänger-, Dateipfad-, Artefakt- oder Policywerte. Gesamtbudget600s, Ausgabelimit höchstens65536Bytes. Fehlende frische Gerätepreview ergibt keine Planung.</p>}
|
||||
{action === 'query_logs' && <p>Windows-MVP nur Quelle windows.eventlog.application.rustdiscovery-mvp-test, Kanal Application, Provider RustDiscovery-MVP-Test, agent_service. Festes UTC-Fenster höchstens24h,1–1000Events,1024–65536Bytes,äußere Joblaufzeit10–120s; inneres kooperatives Abfragebudget höchstens5000ms. Keine freie Kanal-/XPathauswahl und keine Bookmarkfortschreibung. Linux behält seine feste Journalunit.</p>}
|
||||
{action === 'apt_native_acceptance' && <p className="warning">NUR SIMULIERTE DEV/TEST-NATIVABNAHME. In Vorbereitung; Backend/Helper/Scope müssen diese eigene Aktion unterstützen. Nur rmm-apt-fixture-install-1.0 oder rmm-apt-fixture-update-1.1, Rezeptversion 1, vollständiges Schema-2-Manifest. null/Platzhalter sind nicht konfiguriert, keine Produktionsaktion, keine automatische Ausführung.</p>}
|
||||
@@ -158,7 +159,14 @@ function WindowsMsiCatalog({ tenantId, auth }: { tenantId: string; auth: Session
|
||||
return { ...result, items };
|
||||
}, [tenantId, cursor, revision]);
|
||||
return <section><h2>Getrennter unveränderlicher Windows-MSI-Katalog</h2><p>Nur die zwei festen eigenen Machine/x64-Rezepte. Import ist Metadatenpflege mit catalog:write, keine Genehmigung, Installation oder Capabilityfreigabe. Öffentliche MSI-Artefakte werden über den bestehenden Artefaktimport gebunden. Vollständiges geprüftes Manifest für den Parametereditor kopieren.</p><ErrorBox error={list.error}/>
|
||||
{list.data && <><PageStatus data={list.data}/><JsonView value={list.data.items} label="Hashgeprüfte feste MSI-Manifeste"/><button disabled={!cursor} onClick={() => setCursor(null)}>Erste MSI-Rezeptseite</button><button disabled={!list.data.next_cursor} onClick={() => setCursor(list.data?.next_cursor ?? null)}>Nächste MSI-Rezeptseite</button></>}
|
||||
{list.data && <>
|
||||
{list.data.items.length ? <JsonView value={list.data.items} label="Hashgeprüfte feste MSI-Manifeste"/>
|
||||
: <p>Für diesen Kunden sind keine Windows-MSI-Rezepte hinterlegt.</p>}
|
||||
{(cursor || list.data.next_cursor) && <div className="list-footer">
|
||||
<button disabled={!cursor} onClick={() => setCursor(null)}>Erste MSI-Rezeptseite</button>
|
||||
<button disabled={!list.data.next_cursor} onClick={() => setCursor(list.data?.next_cursor ?? null)}>Nächste MSI-Rezeptseite</button>
|
||||
</div>}
|
||||
</>}
|
||||
<details><summary>Neues festes MSI-Manifest importieren</summary><form onSubmit={async event => { event.preventDefault(); setBusy(true); setError(null); setReceipt(null); try {
|
||||
if (!allowed(auth, 'catalog:write')) throw new Error('catalog:write unbekannt/nicht erteilt');
|
||||
const manifest = await verifyWindowsMsiManifest(parseStrictJson(source));
|
||||
@@ -179,7 +187,27 @@ function AgentReleaseCatalog({ tenantId, auth }: { tenantId: string; auth: Sessi
|
||||
return { ...result, items };
|
||||
}, [tenantId, cursor, revision]);
|
||||
return <section><h2>Signierter Agent-Releasekatalog</h2><p>Installierte Clients können hier veröffentlichte Versionen beim nächsten regulären Abruf beziehen. Jedes signierte Manifest bindet eine Plattform sowie die genauen Agent- und Helperdateien.</p><ErrorBox error={list.error}/>
|
||||
{list.data && <><PageStatus data={list.data}/><JsonView value={list.data.items} label="Feste Agent-/Helper-Releases und Manifesthashes"/><button disabled={!cursor} onClick={() => setCursor(null)}>Erste Releaseseite</button><button disabled={!list.data.next_cursor} onClick={() => setCursor(list.data?.next_cursor ?? null)}>Nächste Releaseseite</button></>}
|
||||
{!list.data && !list.error && <p>Releases werden geladen …</p>}
|
||||
{list.data && !list.error && <>
|
||||
{list.data.items.length ? <div className="table fleet-table release-table"><table>
|
||||
<thead><tr><th>Version</th><th>Plattform</th><th>Sequenz</th><th>Prüfstatus</th></tr></thead>
|
||||
<tbody>{list.data.items.map(item => {
|
||||
const manifest = record(item.manifest);
|
||||
const platform = stringField(manifest, 'platform');
|
||||
return <tr key={objectId(item, 'release')}>
|
||||
<td className="hostname"><strong>{stringField(manifest, 'version')}</strong></td>
|
||||
<td data-label="Plattform">{platform.includes('windows') ? 'Windows' : 'Linux'}<small>{platform}</small></td>
|
||||
<td data-label="Sequenz">{String(manifest.release_sequence)}</td>
|
||||
<td data-label="Prüfstatus">{item.signature_and_time_valid ? 'Signatur und Zeitfenster gültig' : 'Derzeit ungültig'}</td>
|
||||
</tr>;
|
||||
})}</tbody>
|
||||
</table></div> : <p>Für diesen Kunden liegen noch keine Agent-Releases im Katalog.</p>}
|
||||
{(cursor || list.data.next_cursor) && <div className="list-footer">
|
||||
<button className="quiet" disabled={!cursor} onClick={() => setCursor(null)}>Erste Releaseseite</button>
|
||||
<button className="quiet" disabled={!list.data.next_cursor} onClick={() => setCursor(list.data?.next_cursor ?? null)}>Nächste Releaseseite</button>
|
||||
</div>}
|
||||
{!!list.data.items.length && <JsonView value={list.data.items} label="Manifeste und Prüfsummen"/>}
|
||||
</>}
|
||||
<details><summary>Signiertes festes Release mit Agent und Helper veröffentlichen</summary><p>Der Server prüft Signatur, Größe und SHA-256 beider Dateien. Erst nach dem vollständigen Upload wird die neue Version für Geräte sichtbar.</p>
|
||||
<form onSubmit={async event => { event.preventDefault(); setBusy(true); setError(null); setReceipts([]); const form = new FormData(event.currentTarget); try {
|
||||
if (!allowed(auth, 'catalog:write')) throw new Error('catalog:write unbekannt/nicht erteilt');
|
||||
@@ -204,10 +232,17 @@ function DeviceEnrollment({ tenantId, auth, customerName }: { tenantId: string;
|
||||
const [enrollment, setEnrollment] = useState<{ token: string; expires: string; origin: string | null; platforms: string[] } | null>(null);
|
||||
const [enrollmentError, setEnrollmentError] = useState<string | null>(null);
|
||||
const [issuing, setIssuing] = useState(false);
|
||||
const [copied, setCopied] = useState(false);
|
||||
return <section aria-label="Gerät aufnehmen"><h2>Gerät aufnehmen</h2>
|
||||
<p>Das HTTPS-Installationsskript fragt auf dem Gerät nach dem Einmalcode. Er gilt für <strong>{customerName}</strong> und läuft nach 15 Minuten ab.</p>
|
||||
<p>Kunde <strong>{customerName}</strong> · Der Einmalcode gilt 15 Minuten.</p>
|
||||
<h3>Installation auf dem Zielgerät</h3>
|
||||
<ul>
|
||||
<li><strong>Linux</strong> · Installationsskript per HTTPS laden und mit Administratorrechten starten.</li>
|
||||
<li><strong>Windows</strong> · Installationsskript per HTTPS laden und in einer administrativen PowerShell starten.</li>
|
||||
</ul>
|
||||
<p>Die passenden Befehle erscheinen mit dem Einmalcode. Das Skript fragt den Code auf dem Zielgerät ab.</p>
|
||||
<button disabled={issuing || !allowed(auth, 'devices:enroll')} onClick={async () => {
|
||||
setIssuing(true); setEnrollment(null); setEnrollmentError(null);
|
||||
setIssuing(true); setEnrollment(null); setEnrollmentError(null); setCopied(false);
|
||||
try {
|
||||
const result = record(await request(tenantPath(tenantId, '/enrollment-tokens'), { body: {}, csrf: auth.csrf_token }));
|
||||
if (typeof result.token !== 'string' || !/^[a-f0-9]{64}$/.test(result.token) || typeof result.expires_at !== 'string') throw new Error('Ungültiger Einmalcode');
|
||||
@@ -216,7 +251,13 @@ function DeviceEnrollment({ tenantId, auth, customerName }: { tenantId: string;
|
||||
} catch (error) { setEnrollmentError(errorText(error)); } finally { setIssuing(false); }
|
||||
}}>Einmalcode erstellen</button>
|
||||
<ErrorBox error={enrollmentError}/>
|
||||
{enrollment && <><label>Einmalcode gültig bis {new Date(enrollment.expires).toLocaleString()}<input readOnly value={enrollment.token}/></label><button onClick={() => setEnrollment(null)}>Code ausblenden</button>
|
||||
{enrollment && <><label>Einmalcode gültig bis {when(enrollment.expires)}<input readOnly value={enrollment.token}/></label>
|
||||
<button onClick={async () => {
|
||||
try { await navigator.clipboard.writeText(enrollment.token); setCopied(true); }
|
||||
catch { setEnrollmentError('Der Browser konnte den Einmalcode nicht kopieren. Sie können ihn im Feld markieren.'); }
|
||||
}}>Einmalcode kopieren</button>
|
||||
<button className="quiet" onClick={() => { setEnrollment(null); setCopied(false); }}>Code ausblenden</button>
|
||||
{copied && <p role="status">Einmalcode wurde kopiert.</p>}
|
||||
{enrollment.origin && enrollment.platforms.includes('x86_64-unknown-linux-gnu') && <><p>Linux, mit einem Administratorkonto ausführen</p><pre>{`curl --fail --show-error --silent '${enrollment.origin}/install/linux.sh' -o linux.sh && sudo sh linux.sh '${enrollment.origin}'`}</pre></>}
|
||||
{enrollment.origin && ['x86_64-pc-windows-msvc','x86_64-pc-windows-gnu'].filter(p => enrollment.platforms.includes(p)).map(platform =>
|
||||
<div key={platform}><p>Windows {platform.endsWith('-gnu') ? 'GNU (Entwicklungsrelease)' : 'MSVC'}, in einer administrativen Windows PowerShell ausführen</p>
|
||||
@@ -580,7 +621,7 @@ function Workspace({ auth, logout }: { auth: Session; logout: () => void }) {
|
||||
['zugang', 'MCP-Tokens'],
|
||||
['aufnahme', 'Geräteaufnahme'],
|
||||
['releases', 'Agent-Releases'],
|
||||
['kataloge', 'Paketkataloge'],
|
||||
['kataloge', 'Erweitert'],
|
||||
['rechte', 'Rechte & Ausführungsstopp']
|
||||
];
|
||||
const adminTab = tabs.some(([id]) => id === route.tab) ? route.tab : 'zugang';
|
||||
@@ -706,15 +747,13 @@ function Workspace({ auth, logout }: { auth: Session; logout: () => void }) {
|
||||
route.tab === 'neu' ? <>
|
||||
<a href="#auftraege" className="back-link">← Zu den Aufträgen</a>
|
||||
<OrderComposer tenantId={customer} customerName={customerName} auth={scoped} initialAssetIds={selected} onSubmitted={afterSubmission} onDraft={showDraft} />
|
||||
<details className="advanced-order"><summary>Weitere Wartungsaktionen</summary>
|
||||
<p>Inventur, Dienstverwaltung und weitere Wartungsaufträge planen.</p>
|
||||
<a className="quiet" href="#auftraege/wartung">Wartungsauftrag planen</a>
|
||||
</details>
|
||||
</> : route.tab === 'wartung' ? <>
|
||||
<a href="#auftraege/neu" className="back-link">← Zum neuen Auftrag</a>
|
||||
<a href="#verwaltung/kataloge" className="back-link">← Zur erweiterten Verwaltung</a>
|
||||
<div className="page-title"><h1>Wartungsauftrag planen</h1></div>
|
||||
<a className="quiet" href="#geraete">Geräte auswählen</a>
|
||||
<Planner tenantId={customer} auth={scoped} selected={selected} showPlan={showDraft} />
|
||||
{allowed(scoped, 'operations:plan') ? <>
|
||||
<a className="quiet" href="#geraete">Geräte auswählen</a>
|
||||
<Planner tenantId={customer} auth={scoped} selected={selected} showPlan={showDraft} />
|
||||
</> : <p>Die Berechtigung zum Planen von Aufträgen fehlt.</p>}
|
||||
</> : detailRoute && detailId ? <>
|
||||
<a href="#auftraege" className="back-link">← Zu den Aufträgen</a>
|
||||
{detailKind === 'entwurf' ?
|
||||
@@ -750,6 +789,10 @@ function Workspace({ auth, logout }: { auth: Session; logout: () => void }) {
|
||||
{adminTab === 'releases' && <AgentReleaseCatalog tenantId={customer} auth={scoped} />}
|
||||
{adminTab === 'kataloge' && (
|
||||
<>
|
||||
{allowed(scoped, 'operations:plan') && <section>
|
||||
<h2>Erweiterte Wartung</h2>
|
||||
<a className="quiet" href="#auftraege/wartung">Wartungsauftrag planen</a>
|
||||
</section>}
|
||||
<Catalog tenantId={customer} auth={scoped} />
|
||||
<WindowsMsiCatalog tenantId={customer} auth={scoped} />
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user