feat: add process details, notifications, export, multi-host support
- Add per-process details modal with kill/pause/resume functionality - GET /api/v1/processes/:pid for detailed process info - POST /api/v1/processes/:pid/signal for sending signals - ProcessDetailModal component with state, resources, command line - Add desktop notifications for alerts - Browser Notification API integration - Toggle in AlertsCard with permission handling - Auto-close for warnings, persistent for critical - Add CSV/JSON export functionality - GET /api/v1/export/metrics?format=csv|json - Export buttons in SettingsPanel - Includes host name in filename - Add multi-host monitoring support - HostSelector component for switching between backends - Hosts store with localStorage persistence - All API calls updated for remote host URLs - Add disk I/O rate charts to HistoryCard - Read/write bytes/sec sparklines - Complements existing network rate charts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
39
frontend/src/lib/api/processes.ts
Normal file
39
frontend/src/lib/api/processes.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { get } from 'svelte/store';
|
||||
import { activeHost } from '$lib/stores/hosts';
|
||||
import type { ProcessDetail } from '$lib/types/metrics';
|
||||
|
||||
function getApiBase(): string {
|
||||
const host = get(activeHost);
|
||||
const baseUrl = host.isLocal ? '' : host.url;
|
||||
return `${baseUrl}/api/v1`;
|
||||
}
|
||||
|
||||
export async function getProcessDetail(pid: number): Promise<ProcessDetail> {
|
||||
const response = await fetch(`${getApiBase()}/processes/${pid}`);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch process ${pid}: ${response.statusText}`);
|
||||
}
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export interface SignalResult {
|
||||
success: boolean;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export async function sendSignal(pid: number, signal: number): Promise<SignalResult> {
|
||||
const response = await fetch(`${getApiBase()}/processes/${pid}/signal`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ signal })
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
// Common signal constants
|
||||
export const SIGNALS = {
|
||||
SIGTERM: 15, // Graceful termination
|
||||
SIGKILL: 9, // Force kill
|
||||
SIGSTOP: 19, // Pause process
|
||||
SIGCONT: 18 // Resume process
|
||||
} as const;
|
||||
Reference in New Issue
Block a user