feat: implement Phase 4 - Configuration Management
Features added:
- View all process configurations in sortable table
- Reload supervisord configuration with confirmation
- Add new process groups dynamically
- Remove process groups with confirmation
- Configuration auto-refresh every 10 seconds
Implementation details:
- Created config API routes: /api/supervisor/config (GET), /api/supervisor/config/reload (POST), /api/supervisor/config/group (POST/DELETE)
- Added React Query hooks: useConfig, useReloadConfig, useAddProcessGroup, useRemoveProcessGroup
- Created components:
- ConfigTable: Sortable table with columns for group, name, command, directory, autostart, priority, numprocs
- ReloadConfigButton: Reload config with confirmation dialog
- ProcessGroupForm: Add/remove groups with separate forms
Configuration page features:
- Displays all process configurations in sortable table
- Click column headers to sort (ascending/descending)
- Visual indicators for autostart (green dot = enabled)
- Shows command in monospace code blocks
- Process group management forms
- Reload configuration button in header
Data displayed per process:
- Group name
- Process name
- Command (with syntax highlighting)
- Working directory
- Autostart enabled/disabled
- Priority value
- Number of processes (numprocs)
Phase 4 complete (8-10 hours estimated)
2025-11-23 19:20:20 +01:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
import { ConfigInfo } from '@/lib/supervisor/types';
|
|
|
|
|
import { Card, CardContent } from '@/components/ui/card';
|
|
|
|
|
import { ChevronUp, ChevronDown } from 'lucide-react';
|
|
|
|
|
import { cn } from '@/lib/utils/cn';
|
|
|
|
|
|
|
|
|
|
interface ConfigTableProps {
|
|
|
|
|
configs: ConfigInfo[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type SortField = 'group' | 'name' | 'command' | 'autostart' | 'directory';
|
|
|
|
|
type SortDirection = 'asc' | 'desc';
|
|
|
|
|
|
|
|
|
|
export function ConfigTable({ configs }: ConfigTableProps) {
|
|
|
|
|
const [sortField, setSortField] = useState<SortField>('group');
|
|
|
|
|
const [sortDirection, setSortDirection] = useState<SortDirection>('asc');
|
|
|
|
|
|
|
|
|
|
const handleSort = (field: SortField) => {
|
|
|
|
|
if (sortField === field) {
|
|
|
|
|
setSortDirection(sortDirection === 'asc' ? 'desc' : 'asc');
|
|
|
|
|
} else {
|
|
|
|
|
setSortField(field);
|
|
|
|
|
setSortDirection('asc');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const sortedConfigs = [...configs].sort((a, b) => {
|
|
|
|
|
let aVal: any = a[sortField];
|
|
|
|
|
let bVal: any = b[sortField];
|
|
|
|
|
|
|
|
|
|
// Handle boolean values
|
|
|
|
|
if (typeof aVal === 'boolean') {
|
|
|
|
|
aVal = aVal ? 1 : 0;
|
|
|
|
|
bVal = bVal ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle string values
|
|
|
|
|
if (typeof aVal === 'string') {
|
|
|
|
|
aVal = aVal.toLowerCase();
|
|
|
|
|
bVal = bVal.toLowerCase();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (aVal < bVal) return sortDirection === 'asc' ? -1 : 1;
|
|
|
|
|
if (aVal > bVal) return sortDirection === 'asc' ? 1 : -1;
|
|
|
|
|
return 0;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const SortIcon = ({ field }: { field: SortField }) => {
|
|
|
|
|
if (sortField !== field) return null;
|
|
|
|
|
return sortDirection === 'asc' ? (
|
|
|
|
|
<ChevronUp className="h-4 w-4 inline-block ml-1" />
|
|
|
|
|
) : (
|
|
|
|
|
<ChevronDown className="h-4 w-4 inline-block ml-1" />
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2025-11-23 21:21:22 +01:00
|
|
|
<>
|
|
|
|
|
{/* Desktop Table View - hidden on mobile */}
|
|
|
|
|
<Card className="hidden md:block">
|
|
|
|
|
<CardContent className="p-0">
|
|
|
|
|
<div className="overflow-x-auto">
|
|
|
|
|
<table className="w-full">
|
|
|
|
|
<thead className="bg-muted/50 border-b">
|
|
|
|
|
<tr>
|
|
|
|
|
<th
|
|
|
|
|
className="text-left p-3 cursor-pointer hover:bg-muted transition-colors"
|
|
|
|
|
onClick={() => handleSort('group')}
|
|
|
|
|
>
|
|
|
|
|
Group <SortIcon field="group" />
|
|
|
|
|
</th>
|
|
|
|
|
<th
|
|
|
|
|
className="text-left p-3 cursor-pointer hover:bg-muted transition-colors"
|
|
|
|
|
onClick={() => handleSort('name')}
|
|
|
|
|
>
|
|
|
|
|
Name <SortIcon field="name" />
|
|
|
|
|
</th>
|
|
|
|
|
<th
|
|
|
|
|
className="text-left p-3 cursor-pointer hover:bg-muted transition-colors"
|
|
|
|
|
onClick={() => handleSort('command')}
|
|
|
|
|
>
|
|
|
|
|
Command <SortIcon field="command" />
|
|
|
|
|
</th>
|
|
|
|
|
<th className="text-left p-3">Directory</th>
|
|
|
|
|
<th
|
|
|
|
|
className="text-center p-3 cursor-pointer hover:bg-muted transition-colors"
|
|
|
|
|
onClick={() => handleSort('autostart')}
|
|
|
|
|
>
|
|
|
|
|
Autostart <SortIcon field="autostart" />
|
|
|
|
|
</th>
|
|
|
|
|
<th className="text-center p-3">Priority</th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
{sortedConfigs.map((config, index) => (
|
|
|
|
|
<tr
|
|
|
|
|
key={`${config.group}:${config.name}`}
|
|
|
|
|
className={cn(
|
|
|
|
|
'border-b hover:bg-muted/20 transition-colors',
|
|
|
|
|
index % 2 === 0 && 'bg-muted/5'
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<td className="p-3 font-medium">{config.group}</td>
|
|
|
|
|
<td className="p-3">{config.name}</td>
|
|
|
|
|
<td className="p-3">
|
|
|
|
|
<code className="text-xs bg-muted px-2 py-1 rounded">{config.command}</code>
|
|
|
|
|
</td>
|
|
|
|
|
<td className="p-3 text-sm text-muted-foreground">{config.directory}</td>
|
|
|
|
|
<td className="p-3 text-center">
|
|
|
|
|
<span
|
|
|
|
|
className={cn(
|
|
|
|
|
'inline-block w-3 h-3 rounded-full',
|
|
|
|
|
config.autostart ? 'bg-success' : 'bg-muted'
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</td>
|
fix: update ConfigInfo schema to match Supervisor API response
Updated the ConfigInfoSchema to accurately reflect the data structure
returned by Supervisor's getAllConfigInfo() XML-RPC method, fixing Zod
validation errors on the /config page.
Schema changes:
- Removed fields not in API: environment, priority, process_name, numprocs, numprocs_start, username
- Added missing fields: autorestart, killasgroup, process_prio, group_prio, stdout_syslog, stderr_syslog, serverurl
- Fixed type mismatches:
- stopsignal: string → number (API returns signal numbers like 15)
- uid: number|null → string (API returns username strings)
- directory: string|null → string
Updated ConfigTable.tsx to use process_prio instead of priority and
removed the non-existent numprocs column.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 22:39:33 +01:00
|
|
|
<td className="p-3 text-center text-sm">{config.process_prio}</td>
|
2025-11-23 21:21:22 +01:00
|
|
|
</tr>
|
|
|
|
|
))}
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
{/* Mobile Card View - visible on mobile only */}
|
|
|
|
|
<div className="md:hidden space-y-4">
|
|
|
|
|
{sortedConfigs.map((config) => (
|
|
|
|
|
<Card key={`${config.group}:${config.name}`}>
|
|
|
|
|
<CardContent className="space-y-3">
|
|
|
|
|
<div className="flex items-start justify-between">
|
|
|
|
|
<div>
|
|
|
|
|
<div className="font-medium text-lg">{config.name}</div>
|
|
|
|
|
<div className="text-sm text-muted-foreground">{config.group}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<span
|
feat: implement Phase 4 - Configuration Management
Features added:
- View all process configurations in sortable table
- Reload supervisord configuration with confirmation
- Add new process groups dynamically
- Remove process groups with confirmation
- Configuration auto-refresh every 10 seconds
Implementation details:
- Created config API routes: /api/supervisor/config (GET), /api/supervisor/config/reload (POST), /api/supervisor/config/group (POST/DELETE)
- Added React Query hooks: useConfig, useReloadConfig, useAddProcessGroup, useRemoveProcessGroup
- Created components:
- ConfigTable: Sortable table with columns for group, name, command, directory, autostart, priority, numprocs
- ReloadConfigButton: Reload config with confirmation dialog
- ProcessGroupForm: Add/remove groups with separate forms
Configuration page features:
- Displays all process configurations in sortable table
- Click column headers to sort (ascending/descending)
- Visual indicators for autostart (green dot = enabled)
- Shows command in monospace code blocks
- Process group management forms
- Reload configuration button in header
Data displayed per process:
- Group name
- Process name
- Command (with syntax highlighting)
- Working directory
- Autostart enabled/disabled
- Priority value
- Number of processes (numprocs)
Phase 4 complete (8-10 hours estimated)
2025-11-23 19:20:20 +01:00
|
|
|
className={cn(
|
2025-11-23 21:21:22 +01:00
|
|
|
'inline-block w-3 h-3 rounded-full mt-1',
|
|
|
|
|
config.autostart ? 'bg-success' : 'bg-muted'
|
feat: implement Phase 4 - Configuration Management
Features added:
- View all process configurations in sortable table
- Reload supervisord configuration with confirmation
- Add new process groups dynamically
- Remove process groups with confirmation
- Configuration auto-refresh every 10 seconds
Implementation details:
- Created config API routes: /api/supervisor/config (GET), /api/supervisor/config/reload (POST), /api/supervisor/config/group (POST/DELETE)
- Added React Query hooks: useConfig, useReloadConfig, useAddProcessGroup, useRemoveProcessGroup
- Created components:
- ConfigTable: Sortable table with columns for group, name, command, directory, autostart, priority, numprocs
- ReloadConfigButton: Reload config with confirmation dialog
- ProcessGroupForm: Add/remove groups with separate forms
Configuration page features:
- Displays all process configurations in sortable table
- Click column headers to sort (ascending/descending)
- Visual indicators for autostart (green dot = enabled)
- Shows command in monospace code blocks
- Process group management forms
- Reload configuration button in header
Data displayed per process:
- Group name
- Process name
- Command (with syntax highlighting)
- Working directory
- Autostart enabled/disabled
- Priority value
- Number of processes (numprocs)
Phase 4 complete (8-10 hours estimated)
2025-11-23 19:20:20 +01:00
|
|
|
)}
|
2025-11-23 21:21:22 +01:00
|
|
|
title={config.autostart ? 'Autostart enabled' : 'Autostart disabled'}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="space-y-2 text-sm">
|
|
|
|
|
<div>
|
|
|
|
|
<span className="text-muted-foreground">Command:</span>
|
|
|
|
|
<code className="block mt-1 text-xs bg-muted px-2 py-1 rounded break-all">
|
|
|
|
|
{config.command}
|
|
|
|
|
</code>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<span className="text-muted-foreground">Directory:</span>
|
|
|
|
|
<div className="mt-1 text-xs break-all">{config.directory}</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
fix: update ConfigInfo schema to match Supervisor API response
Updated the ConfigInfoSchema to accurately reflect the data structure
returned by Supervisor's getAllConfigInfo() XML-RPC method, fixing Zod
validation errors on the /config page.
Schema changes:
- Removed fields not in API: environment, priority, process_name, numprocs, numprocs_start, username
- Added missing fields: autorestart, killasgroup, process_prio, group_prio, stdout_syslog, stderr_syslog, serverurl
- Fixed type mismatches:
- stopsignal: string → number (API returns signal numbers like 15)
- uid: number|null → string (API returns username strings)
- directory: string|null → string
Updated ConfigTable.tsx to use process_prio instead of priority and
removed the non-existent numprocs column.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 22:39:33 +01:00
|
|
|
<div className="pt-2">
|
|
|
|
|
<span className="text-muted-foreground">Priority:</span>
|
|
|
|
|
<span className="ml-2 font-mono">{config.process_prio}</span>
|
2025-11-23 21:21:22 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
feat: implement Phase 4 - Configuration Management
Features added:
- View all process configurations in sortable table
- Reload supervisord configuration with confirmation
- Add new process groups dynamically
- Remove process groups with confirmation
- Configuration auto-refresh every 10 seconds
Implementation details:
- Created config API routes: /api/supervisor/config (GET), /api/supervisor/config/reload (POST), /api/supervisor/config/group (POST/DELETE)
- Added React Query hooks: useConfig, useReloadConfig, useAddProcessGroup, useRemoveProcessGroup
- Created components:
- ConfigTable: Sortable table with columns for group, name, command, directory, autostart, priority, numprocs
- ReloadConfigButton: Reload config with confirmation dialog
- ProcessGroupForm: Add/remove groups with separate forms
Configuration page features:
- Displays all process configurations in sortable table
- Click column headers to sort (ascending/descending)
- Visual indicators for autostart (green dot = enabled)
- Shows command in monospace code blocks
- Process group management forms
- Reload configuration button in header
Data displayed per process:
- Group name
- Process name
- Command (with syntax highlighting)
- Working directory
- Autostart enabled/disabled
- Priority value
- Number of processes (numprocs)
Phase 4 complete (8-10 hours estimated)
2025-11-23 19:20:20 +01:00
|
|
|
);
|
|
|
|
|
}
|