Make order search, device results and decisions visible in the WebUI

This commit is contained in:
2026-11-18 09:14:42 +01:00
parent 5b6e9c9cdb
commit 14a271f61a
8 changed files with 155 additions and 45 deletions
+8 -2
View File
@@ -34,6 +34,7 @@ test('reviews the fixed MCP request, rejects it once and blocks a changed hash',
targets:[{...target,hostname:'WERK-LINUX'}], created_at:created, jobs:[], job_count:0, execution_state:null };
const path = '/api/v1/tenants/'+saved.tenant_id;
let approval = 'pending_approval', corrupt = false, rights = true;
const decision = { principal: 'Marta', at: created, testsimulation: true };
const decisions: unknown[] = [];
const listing = (items: unknown[]) => ({items,next_cursor:null,completeness:'complete',truncated:false,as_of:created});
await page.route(origin+'/auth/config', r => r.fulfill({json:{dev_login_enabled:true,local_login_enabled:false,oidc_configured:false,oidc_login_url:null}}));
@@ -44,13 +45,13 @@ test('reviews the fixed MCP request, rejects it once and blocks a changed hash',
if (url.pathname === '/api/v1/approvals') {
const pending = approval === 'pending_approval';
const visible = rights && !url.searchParams.has('count_only') && (url.searchParams.get('status') === 'pending') === pending;
return route.fulfill({json:{...listing(visible ? [{...summary,approval_state:approval}]:[]), customers:rights?[customer]:[],
return route.fulfill({json:{...listing(visible ? [{...summary,approval_state:approval,decision:pending ? null : decision}]:[]), customers:rights?[customer]:[],
can_review:rights,pending_count:rights && pending?1:0}});
}
if (url.pathname === path+'/operation-plans/'+saved.plan_id) return route.fulfill({json:{
...summary, plan_payload:saved, payload:saved, plan_hash:corrupt?'f'.repeat(64):key,plan_payload_bytes:[...Buffer.from(raw)],
resolved_targets:[target], excluded_targets:[], jobs:[{...job,...target,job_id:payload.job_id,attempt_id:payload.attempt_id}],
expires_at:expires, approval_state:approval, authorization_status:'required'
expires_at:expires, approval_state:approval, authorization_status:'required', decision:approval === 'rejected' ? decision : null
}});
if (url.pathname === path+'/operation-plans/'+saved.plan_id+'/authorizations' && req.method() === 'POST') {
decisions.push(req.postDataJSON()); approval='rejected';
@@ -75,7 +76,12 @@ test('reviews the fixed MCP request, rejects it once and blocks a changed hash',
await page.getByRole('link',{name:/^Genehmigungen/}).click();
await expect(inbox.getByText('Keine offenen Genehmigungen.')).toBeVisible();
await inbox.getByRole('button',{name:'Verlauf'}).click();
const entry = inbox.locator('td[data-label="Entschieden von und am"]');
await expect(entry).toContainText('Marta');
await expect(entry).toContainText('Simulierter Testentscheid');
await expect(entry.locator('time')).toHaveAttribute('datetime', created);
await inbox.getByRole('button',{name:'Freies Skript'}).click();
await expect(page.locator('section[data-plan-id] time')).toHaveAttribute('datetime', created);
await expect(page.locator('section[data-plan-id] .order-status')).toHaveText('Abgelehnt');
await expect(reject).toHaveCount(0);
corrupt=true; approval='pending_approval'; await page.reload();
+9
View File
@@ -217,6 +217,15 @@ test('shows the bound script text alongside single and per-device results', asyn
await expect(page.getByLabel('stderr Textansicht')).toHaveText('Fehler auf Windows');
await page.getByRole('button', { name: 'Ergebnis schließen für test-windows' }).click();
await expect(page.getByRole('region', { name: 'Gespeichertes Konsolenergebnis' })).toHaveCount(0);
resultReads.clear();
await openOrder(multiOperationId + '/' + jobs[1]!.job_id);
await expect(page.getByRole('heading', { name: 'Ergebnis für test-windows' })).toBeVisible();
await expect(page.getByLabel('stderr Textansicht')).toHaveText('Fehler auf Windows');
expect([...resultReads]).toEqual([jobs[1]!.job_id]);
resultReads.clear();
await openOrder(multiOperationId + '/' + randomUUID());
await expect(page.getByRole('alert')).toContainText('gehört nicht zu diesem Auftrag');
expect(resultReads.size).toBe(0);
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(390);
mismatchedPlan = true;
await page.reload();
+4 -3
View File
@@ -1,5 +1,5 @@
import { useState } from 'react';
import { page, record, request, objectId, tenant, type Tenant } from './api';
import { page, record, request, objectId, tenant } from './api';
import { ErrorBox, useResource } from './resource';
import { OrderRows, PageButtons } from './order-presentation';
@@ -15,7 +15,7 @@ export function usePendingApprovals(enabled: boolean, revision = 0) {
}, [enabled, revision], enabled);
return resource.error ? null : resource.data;
}
export function ApprovalInbox({ open }: { customers?: Tenant[]; open: (tenantId: string, planId: string) => void }) {
export function ApprovalInbox({ open, ownId }: { ownId: string; open: (tenantId: string, planId: string) => void }) {
const [view, setView] = useState<'pending'|'history'>('pending');
const [customer, setCustomer] = useState('');
const [pages, setPages] = useState<string[]>([]);
@@ -44,7 +44,8 @@ export function ApprovalInbox({ open }: { customers?: Tenant[]; open: (tenantId:
<ErrorBox error={list.error}/>
{!list.data && !list.error && <p className="list-message">Anträge werden geladen …</p>}
{list.data && (!!list.data.items.length
? <OrderRows items={list.data.items} decisionList open={row => open(objectId(row,'tenant'), objectId(row,'plan'))}/>
? <OrderRows items={list.data.items} decisionList decisionHistory={view === 'history'} ownId={ownId}
open={row => open(objectId(row,'tenant'), objectId(row,'plan'))}/>
: <p className="list-message">{view === 'pending' ? 'Keine offenen Genehmigungen.' : 'Keine abgeschlossenen Anträge.'}</p>)}
{list.data && <PageButtons pages={pages} next={list.data.next_cursor} change={setPages}/>}
</section>;
+20 -12
View File
@@ -15,7 +15,8 @@ import { AdminControl } from './management';
import { allowed } from './safety';
import { CatalogCheckNotice } from './catalog-check';
import { ErrorBox, errorText, useResource } from './resource';
import { NavIcon } from './navigation';
import { NavIcon, orderDetailRoute } from './navigation';
import { orderTitle, Status } from './order-presentation';
import { RecoveryReview, recoveryAsset, recoveryTenant } from './recovery-review';
import { EchoProbeReview } from './echo-probe-review';
import { EchoCompletionReview } from './echo-completion-review';
@@ -107,7 +108,7 @@ type Props = {
onSelection: (s: Target) => void;
onCreateOrder: () => void;
onEnroll: () => void;
onOperation: (customer: string, id: string) => void;
onOperation: (customer: string, id: string, jobId: string) => void;
};
function devicePath(customer: string, asset: string) {
return tenantPath(customer, '/devices/' + encodeURIComponent(asset));
@@ -127,7 +128,7 @@ function DeviceDetail({
agent: string;
auth: Session;
back: () => void;
openOperation: (id: string) => void;
openOperation: (id: string, jobId: string) => void;
changed: () => void;
}) {
const path = devicePath(customer, asset);
@@ -212,14 +213,21 @@ function DeviceDetail({
<p className="muted">Keine Aufträge für dieses Gerät.</p>
) : (
<ul className="job-list">
{jobs.map((j) => (
<li key={objectId(j, 'job')}>
<button className="link" onClick={() => openOperation(objectId(j, 'operation'))}>
Auftrag vom {time(j.created_at)}
</button>
<span>{label(j.state)}</span>
</li>
))}
{jobs.map((job) => {
const id = objectId(job, 'operation'), jobId = objectId(job, 'job');
const title = orderTitle(job);
return <li className="job-row" key={jobId}>
<div className="device-job-name"><strong>{title}</strong><small>{time(job.created_at)}</small></div>
<Status value={job.state}/>
<a className="quiet" href={'#auftraege/' + orderDetailRoute(customer, id, jobId)}
aria-label={'Ergebnis öffnen · ' + title + ' · ' + time(job.created_at)}
onClick={event => {
if (event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) return;
event.preventDefault();
openOperation(id, jobId);
}}>Ergebnis öffnen</a>
</li>;
})}
</ul>
)}
</section>
@@ -352,7 +360,7 @@ export function Devices({
{...target}
auth={auth}
back={back}
openOperation={(id) => onOperation(target.customer, id)}
openOperation={(id, jobId) => onOperation(target.customer, id, jobId)}
changed={() => {
back();
setRoutes([]);
+90 -24
View File
@@ -1,13 +1,13 @@
import { actionTitle, deviceName, display, Fact, identityName, OrderRows, orderTitle, PageButtons, Requester, Status, statusOf, targets, when } from './order-presentation';
import { actionTitle, ApprovalDecision, deviceName, display, Fact, identityName, OrderRows, orderTitle, PageButtons, Requester, Status, statusOf, statusText, targets, when } from './order-presentation';
import { Devices } from './devices';
import { CustomerManagement } from './customer-management';
import { ErrorBox, useResource, errorText } from './resource';
import { NavIcon, type NavKey } from './navigation';
import { NavIcon, orderDetailRoute, type NavKey } from './navigation';
import { OrderComposer } from './order-composer';
import { ApprovalInbox, usePendingApprovals } from './approval-inbox';
import { ScriptLibrary } from './script-library';
import { McpTokenManagement } from './mcp-token-management';
import React, { useEffect, useState } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import { createRoot } from 'react-dom/client';
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';
@@ -357,6 +357,9 @@ function PlanDetail({ tenantId, id, auth, onOperation, customerName, mode = 'rev
<Requester id={saved.principal} ownId={auth.principal.id}/>
</Fact>}
<Fact label="Status">{data.approval_state ? <Status value={data.approval_state}/> : 'Vorbereitet'}</Fact>
{typeof data.approval_state === 'string' && data.approval_state !== 'pending_approval' && <Fact label="Entscheidung">
<ApprovalDecision order={data} ownId={auth.principal.id}/>
</Fact>}
<Fact label="Anlass">{display(saved.reason, 'Kein Anlass angegeben')}</Fact>
</dl>
<h3>Zielgeräte und Zeitfenster</h3>
@@ -393,18 +396,70 @@ function PlanDetail({ tenantId, id, auth, onOperation, customerName, mode = 'rev
</section>;
}
function Operations({ tenantId, open, customerName }: { tenantId: string; open: (id: string) => void; customerName?: string }) {
const emptyOrderFilters = { q: '', device: '', status: '', from: '', to: '' };
type OrderFilters = typeof emptyOrderFilters;
const orderStatuses = ['pending_approval', 'approved', 'queued', 'running', 'succeeded', 'partially_succeeded',
'failed', 'needs_attention', 'rejected', 'expired', 'revoked', 'cancelled'];
function orderDay(value: string, next = false) {
const date = new Date(value + 'T00:00:00');
if (next) date.setDate(date.getDate() + 1);
return date.toISOString();
}
function Operations({ tenantId, open, customerName, filters, apply }: {
tenantId: string; open: (id: string) => void; customerName?: string;
filters: OrderFilters; apply: (filters: OrderFilters) => void;
}) {
const [pages, setPages] = useState<string[]>([]);
const [draft, setDraft] = useState(filters);
const [filterError, setFilterError] = useState<string | null>(null);
const cursor = pages[pages.length - 1];
const list = useResource(async signal => page(await request(tenantPath(tenantId,
'/operations?sort=recent' + (cursor ? '&cursor=' + encodeURIComponent(cursor) : '')), { signal })), [tenantId, cursor], true);
if (list.error) return <ErrorBox error={list.error}/>;
const params = new URLSearchParams({sort:'recent', limit:'25'});
if (cursor) params.set('cursor', cursor);
if (filters.q) params.set('q', filters.q);
if (filters.device) params.set('device', filters.device);
if (filters.status) params.set('status', filters.status);
if (filters.from) params.set('from', orderDay(filters.from));
if (filters.to) params.set('until', orderDay(filters.to, true));
const query = params.toString();
const list = useResource(async signal => page(await request(tenantPath(tenantId, '/operations?' + query), { signal })), [tenantId, query], true);
const filtering = Object.values(filters).some(Boolean);
function reset() {
setDraft(emptyOrderFilters);
setFilterError(null);
setPages([]);
apply(emptyOrderFilters);
}
return <section aria-label="Auftragsliste" className="fleet">
<form className="order-filters" aria-label="Aufträge filtern" onSubmit={event => {
event.preventDefault();
if (draft.from && draft.to && draft.from > draft.to) {
setFilterError('Das Enddatum darf nicht vor dem Startdatum liegen.');
return;
}
setPages([]);
setFilterError(null);
apply({ ...draft, q: draft.q.trim(), device: draft.device.trim() });
}}>
<label>Auftrag<input type="search" maxLength={120} value={draft.q} onChange={e => setDraft({ ...draft, q:e.target.value })} placeholder="Name oder Anlass"/></label>
<label>Gerät<input type="search" maxLength={120} value={draft.device} onChange={e => setDraft({ ...draft, device:e.target.value })} placeholder="Hostname oder Geräte-ID"/></label>
<label>Status<select value={draft.status} onChange={e => setDraft({ ...draft, status:e.target.value })}>
<option value="">Alle Status</option>
{orderStatuses.map(status => <option key={status} value={status}>{statusText(status)}</option>)}
</select></label>
<label>Von<input type="date" value={draft.from} onChange={e => setDraft({ ...draft, from:e.target.value })}/></label>
<label>Bis einschließlich<input type="date" value={draft.to} onChange={e => setDraft({ ...draft, to:e.target.value })}/></label>
<div className="order-filter-actions">
<button type="submit">Filtern</button>
{(filtering || Object.values(draft).some(Boolean)) && <button type="button" className="quiet" onClick={reset}>Filter zurücksetzen</button>}
</div>
<ErrorBox error={filterError}/>
</form>
<ErrorBox error={list.error}/>
{!list.data && !list.error && <p className="list-message">Aufträge werden geladen …</p>}
{list.data && (list.data.items.length
{list.data && !list.error && (list.data.items.length
? <OrderRows items={list.data.items} customerName={customerName} open={row => open(objectId(row,'operation'))}/>
: <p className="list-message">Für diesen Kunden gibt es noch keine Aufträge.</p>)}
{list.data && <PageButtons pages={pages} next={list.data.next_cursor} change={setPages}/>}
: <p className="list-message">{filtering ? 'Keine Aufträge passen zu den Filtern.' : 'Für diesen Kunden gibt es noch keine Aufträge.'}</p>)}
{list.data && !list.error && <PageButtons pages={pages} next={list.data.next_cursor} change={setPages}/>}
</section>;
}
function OrderScript({ tenantId, operation, names }: { tenantId: string; operation: RecordValue; names: RecordValue[] }) {
@@ -449,16 +504,17 @@ function OrderScript({ tenantId, operation, names }: { tenantId: string; operati
})}
</article>;
}
function OperationDetail({ tenantId, id, auth, openPlan, customerName }: {
tenantId: string; id: string; auth: Session; openPlan: (id: string) => void; customerName?: string
function OperationDetail({ tenantId, id, resultId: linkedResult, auth, openPlan, customerName }: {
tenantId: string; id: string; resultId?: string; auth: Session; openPlan: (id: string) => void; customerName?: string
}) {
const op = useResource(async signal => record(await request(tenantPath(tenantId, '/operations/' + encodeURIComponent(id)), { signal })), [tenantId, id], true);
const [jobId, setJobId] = useState<string | null>(null);
const [jobId, setJobId] = useState<string | null>(linkedResult ?? null);
const data = op.error ? null : op.data;
if (!data) return <section data-operation-id={id}><ErrorBox error={op.error}/>{!op.error && <p>Auftrag wird geladen …</p>}</section>;
const names = targets(data);
const jobs = Array.isArray(data.jobs) ? data.jobs.map(j => record(j)) : [];
const singleJob = jobs.length === 1 ? jobs[0] : null;
const resultMissing = !!linkedResult && !jobs.some(job => job.job_id === linkedResult);
const singleJob = jobs.length === 1 && !resultMissing ? jobs[0] : null;
const name = (job: RecordValue) => {
const target = names.find(t => t.asset_id === job.asset_id && t.agent_id === job.agent_id);
return target ? deviceName(target) : display(job.asset_id, 'Gerät unbekannt');
@@ -470,9 +526,10 @@ function OperationDetail({ tenantId, id, auth, openPlan, customerName }: {
<Fact label="Anlass">{display(data.reason, 'Kein Anlass angegeben')}</Fact></dl>
<div className="order-execution">
{singleJob ? <JobDetail key={objectId(singleJob, 'job')} tenantId={tenantId}
id={objectId(singleJob, 'job')} hostname={name(singleJob)} auth={auth}/>
id={objectId(singleJob, 'job')} hostname={name(singleJob)} auth={auth} scrollToResult={!!linkedResult}/>
: <div className="order-results">
<h3>Geräte und Ergebnisse</h3>
{resultMissing && <p role="alert">Das verlinkte Geräteergebnis gehört nicht zu diesem Auftrag oder ist nicht mehr verfügbar.</p>}
{jobs.length ? <ul className="job-list">{jobs.map(job => {
const resultId = objectId(job, 'job');
const hostname = name(job);
@@ -486,7 +543,8 @@ function OperationDetail({ tenantId, id, auth, openPlan, customerName }: {
aria-label={action + ' für ' + hostname}
onClick={() => setJobId(expanded ? null : resultId)}>{action}</button>
</div>
{expanded && <JobDetail tenantId={tenantId} id={resultId} hostname={hostname} auth={auth}/>}
{expanded && <JobDetail tenantId={tenantId} id={resultId} hostname={hostname} auth={auth}
scrollToResult={!!jobId && jobId === linkedResult}/>}
</li>;
})}</ul>
: <><p>{names.map(deviceName).join(', ')}</p><p className="muted">{data.approval_state === 'pending_approval'
@@ -500,13 +558,19 @@ function OperationDetail({ tenantId, id, auth, openPlan, customerName }: {
<JsonView value={data} label="Technische Auftragsdaten"/>
</section>;
}
function JobDetail({ tenantId, id, auth, hostname }: { tenantId: string; id: string; auth: Session; hostname: string }) {
function JobDetail({ tenantId, id, auth, hostname, scrollToResult }: {
tenantId: string; id: string; auth: Session; hostname: string; scrollToResult?: boolean
}) {
const job = useResource(async signal => record(await request(tenantPath(tenantId, '/jobs/'+encodeURIComponent(id)), { signal })), [tenantId, id], true);
const result = useRef<HTMLElement>(null);
useEffect(() => {
if (scrollToResult) result.current?.scrollIntoView({ block:'start' });
}, [id, scrollToResult]);
const [error, setError] = useState<string | null>(null), [busy, setBusy] = useState(false);
const data = job.error ? null : job.data;
const state = data?.state;
const terminal = ['succeeded','failed','cancelled','expired','unknown','closed_unknown'];
return <article className="job-result" data-job-id={id}><h3>Ergebnis für {hostname}</h3><ErrorBox error={job.error ?? error}/>
return <article ref={result} className="job-result" data-job-id={id}><h3>Ergebnis für {hostname}</h3><ErrorBox error={job.error ?? error}/>
{!data && !job.error && <p>Ergebnis wird geladen …</p>}
{data && <><ConsoleOutput job={data}/><JsonView value={data} label="Technische Ausführungsdaten"/></>}
{data && allowed(auth,'jobs:cancel') && !terminal.includes(String(state)) && !data.cancel_requested && <details><summary>Abbruch anfordern</summary>
@@ -567,7 +631,8 @@ function Workspace({ auth, logout }: { auth: Session; logout: () => void }) {
);
const customers = tenants.data?.items ?? auth.tenants;
const [selectedCustomer, setCustomer] = useState(auth.tenants[0]?.tenant_id ?? '');
const [detailKind, detailTenant, detailId] = route.tab.split('/');
const [detailKind, detailTenant, detailId, detailJob] = route.tab.split('/');
const [orderFilters, setOrderFilters] = useState(emptyOrderFilters);
const detailRoute = (route.page === 'genehmigungen' && detailKind === 'pruefen')
|| (route.page === 'auftraege' && (detailKind === 'ansehen' || detailKind === 'entwurf'));
const customer = detailRoute && detailTenant ? detailTenant : selectedCustomer;
@@ -601,9 +666,9 @@ function Workspace({ auth, logout }: { auth: Session; logout: () => void }) {
// Gate rendering during a tenant change; a previously loaded session is scoped to its own customer.
const scoped = current.data?.id === customer ? current.data.auth : null;
const customerName = customers.find((c) => c.tenant_id === customer)?.name ?? '';
function openOperation(tenantId: string, id: string) {
function openOperation(tenantId: string, id: string, jobId?: string) {
switchCustomer(tenantId);
go('auftraege', `ansehen/${tenantId}/${id}`);
go('auftraege', orderDetailRoute(tenantId, id, jobId));
}
function openReview(tenantId: string, id: string) {
switchCustomer(tenantId);
@@ -741,7 +806,7 @@ function Workspace({ auth, logout }: { auth: Session; logout: () => void }) {
<a href="#genehmigungen" className="back-link">← Zu den Genehmigungen</a>
<PlanDetail key={detailId} tenantId={customer} id={detailId} auth={scoped}
customerName={customerName} mode="review" onOperation={afterSubmission} />
</> : <><div className="page-title"><h1>Genehmigungen</h1></div><ApprovalInbox customers={customers} open={openReview} /></>
</> : <><div className="page-title"><h1>Genehmigungen</h1></div><ApprovalInbox ownId={auth.principal.id} open={openReview} /></>
)}
{route.page === 'auftraege' && (
route.tab === 'neu' ? <>
@@ -759,13 +824,14 @@ function Workspace({ auth, logout }: { auth: Session; logout: () => void }) {
{detailKind === 'entwurf' ?
<PlanDetail key={detailId} tenantId={customer} id={detailId} auth={scoped}
customerName={customerName} mode="submit" onOperation={afterSubmission} />
: <OperationDetail key={detailId} tenantId={customer} id={detailId} auth={scoped}
: <OperationDetail key={detailId+'/'+(detailJob ?? '')} tenantId={customer} id={detailId} resultId={detailJob} auth={scoped}
customerName={customerName} openPlan={id => openReview(customer,id)} />}
</> : <>
<div className="page-title"><h1>Aufträge</h1>
{allowed(scoped, 'operations:plan') && <a className="primary-action" href="#auftraege/neu"><NavIcon name="plus" /> Neuer Auftrag</a>}
</div>
<Operations tenantId={customer} customerName={customerName} open={id => openOperation(customer,id)} />
<Operations tenantId={customer} customerName={customerName} open={id => openOperation(customer,id)}
filters={orderFilters} apply={setOrderFilters}/>
</>
)}
{route.page === 'verwaltung' && (
+3
View File
@@ -1,4 +1,7 @@
export type NavKey = 'geraete' | 'auftraege' | 'genehmigungen' | 'skripte' | 'kunden' | 'verwaltung';
export function orderDetailRoute(tenantId: string, operationId: string, jobId?: string) {
return ['ansehen', tenantId, operationId, ...(jobId ? [jobId] : [])].map(encodeURIComponent).join('/');
}
const glyphs = {
geraete: 'M3 4h18v12H3z M8 20h8 M12 16v4',
auftraege: 'M8 5H5v16h14V5h-3 M9 3h6v4H9z M8 12h8 M8 16h5',
+16 -3
View File
@@ -39,11 +39,23 @@ export function Requester({ id, ownId }: { id: unknown; ownId?: string }) {
export function Status({ value }: { value: unknown }) { return <span className={'order-status state-' + String(value)}>{statusText(value)}</span>; }
export function Fact({ label, children }: { label: string; children: ReactNode }) { return <div><dt>{label}</dt><dd>{children}</dd></div>; }
export function OrderRows({ items, customerName, decisionList, open }: {
items: RecordValue[]; customerName?: string; decisionList?: boolean; open: (row: RecordValue) => void
export function ApprovalDecision({ order, ownId }: { order: RecordValue; ownId?: string }) {
const decision = order.decision && typeof order.decision === 'object' ? record(order.decision) : null;
if (typeof decision?.principal !== 'string' || typeof decision.at !== 'string') {
return <span className="muted">{order.approval_state === 'expired' ? 'Automatisch abgelaufen' : 'Entscheidung nicht belegt'}</span>;
}
return <><Requester id={decision.principal} ownId={ownId}/>
{decision.testsimulation === true && <small>Simulierter Testentscheid</small>}
<small><time dateTime={decision.at}>{when(decision.at)}</time></small></>;
}
export function OrderRows({ items, customerName, decisionList, decisionHistory, ownId, open }: {
items: RecordValue[]; customerName?: string; decisionList?: boolean; decisionHistory?: boolean;
ownId?: string; open: (row: RecordValue) => void
}) {
return <div className="table fleet-table order-list"><table><thead><tr>
<th>Auftrag</th><th>Kunde</th><th>Geräte</th><th>{decisionList ? 'Eingereicht von' : 'Erstellt'}</th><th>Status</th>
{decisionHistory && <th scope="col">Entschieden von und am</th>}
</tr></thead><tbody>{items.map(row => {
const all = targets(row);
const devices = all.slice(0, 2).map(deviceName).join(', ');
@@ -53,8 +65,9 @@ export function OrderRows({ items, customerName, decisionList, open }: {
{revision && <small>Version {String(revision.version)}</small>}</td>
<td data-label="Kunde">{display(row.customer_name, customerName)}</td>
<td data-label="Geräte">{devices || (typeof row.planned_job_count === 'number' ? String(row.planned_job_count) : 'Unbekannt')}{all.length > 2 && ' und '+(all.length-2)+' weitere'}</td>
<td data-label={decisionList ? 'Eingereicht von' : 'Erstellt'}>{decisionList ? <Requester id={row.requester}/> : when(row.created_at)}</td>
<td data-label={decisionList ? 'Eingereicht von' : 'Erstellt'}>{decisionList ? <Requester id={row.requester} ownId={ownId}/> : when(row.created_at)}</td>
<td data-label="Status"><Status value={decisionList ? row.approval_state : statusOf(row)}/></td>
{decisionHistory && <td data-label="Entschieden von und am"><ApprovalDecision order={row} ownId={ownId}/></td>}
</tr>;
})}</tbody></table></div>;
}
+5 -1
View File
@@ -117,7 +117,11 @@ section.fleet { padding:0; overflow:hidden; }
.job-row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.job-row strong { flex:1 1 8rem; }
.job-row button { margin:0; }
.job-result { margin-top:22px; border-color:#b9d5c8; background:#f2f8f5; }
.device-job-name { flex:1 1 14rem; min-width:0; }
.job-result { margin-top:22px; scroll-margin-top:16px; border-color:#b9d5c8; background:#f2f8f5; }
.order-filters { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,10rem),1fr)); gap:12px; padding:16px 20px; border-bottom:1px solid var(--line); }
.order-filters label { margin:0; min-width:0; }
.order-filter-actions,.order-filters .error { grid-column:1/-1; }
.job-result > h3 { font-size:1.15rem; }
.job-result > section { margin:0; padding:0; border:0; background:none; }
.job-result > section > p:first-child { margin-top:0; }