Wire all dashboard buttons: auth downloads, get_log feedback, action tests.
This commit is contained in:
32
server/web/src/components/AuthDownloadButton.tsx
Normal file
32
server/web/src/components/AuthDownloadButton.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { useState, type ReactNode } from 'react';
|
||||
import { downloadAuthedFile } from '../api/download';
|
||||
|
||||
type Props = {
|
||||
apiPath: string;
|
||||
filename: string;
|
||||
className?: string;
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
export default function AuthDownloadButton({ apiPath, filename, className, children }: Props) {
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
const handleClick = async (e: React.MouseEvent) => {
|
||||
e.preventDefault();
|
||||
if (busy) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
await downloadAuthedFile(apiPath, filename);
|
||||
} catch (err) {
|
||||
window.alert(err instanceof Error ? err.message : 'Download failed');
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<button type="button" className={className} onClick={handleClick} disabled={busy}>
|
||||
{busy ? '…' : children}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -74,7 +74,12 @@ export default function AgentRemoteActions({
|
||||
setBusy(action);
|
||||
try {
|
||||
if (!compact) addLog(`> Executing ${action}...`);
|
||||
await api.sendAgentCommand(agentId, action, args);
|
||||
const res = await api.sendAgentCommand(agentId, action, args);
|
||||
if (res.success === false) {
|
||||
addLog(`Command rejected: ${res.error ?? 'unknown error'}`);
|
||||
return;
|
||||
}
|
||||
if (!compact) addLog(`> ${action} sent to ${agentId === 'all' ? 'fleet' : agentName}`);
|
||||
onCommandSent?.(action);
|
||||
} catch (err: unknown) {
|
||||
const msg = err instanceof Error ? err.message : 'Command failed';
|
||||
|
||||
Reference in New Issue
Block a user