feat(client): upgrade Systems, Workflows, Alerts, Vault, Config, Auth & Settings views for v1.1

This commit is contained in:
tyuXX 2026-11-28 05:23:31 +00:00
parent f7d2abe3de
commit f45d128c4f
9 changed files with 895 additions and 132 deletions

View file

@ -23,7 +23,7 @@ interface AlertChannelItem {
interface AlertRuleItem {
id: string;
name: string;
kind: 'metric' | 'disk' | 'offline' | 'probe' | 'system';
kind: 'metric' | 'disk' | 'offline' | 'probe' | 'system' | 'security-event';
severity: 'warn' | 'critical';
target: { serverId?: string; tags?: string[]; all?: boolean };
forConsecutivePolls: number;
@ -40,6 +40,7 @@ interface AlertRuleItem {
probeId?: string;
systemId?: string;
item?: string;
events?: string[];
}
interface MaintenanceWindowItem {
@ -330,11 +331,12 @@ export async function renderAlertsView(
const chUrl = el('input', { placeholder: 'Webhook / base URL (optional for ntfy.sh or Telegram)' });
const chExtra = el('input', { placeholder: 'Telegram chatId OR ntfy topic (optional)' });
const chRef = el('select', {});
for (const cr of credsRes.credentials) {
const webhookCreds = credsRes.credentials.filter((cr) => cr.type === 'webhook-secret');
for (const cr of webhookCreds) {
chRef.append(el('option', { value: cr.id }, `${cr.id} (${cr.type})`));
}
if (credsRes.credentials.length === 0) {
chRef.append(el('option', { value: 'webhook-main' }, 'webhook-main (add in Vault)'));
if (webhookCreds.length === 0) {
chRef.append(el('option', { value: 'webhook-main' }, 'webhook-main (add webhook-secret in Vault)'));
}
const chForm = el(
'form',
@ -385,7 +387,9 @@ export async function renderAlertsView(
? `offline >= ${r.offlineSec}s`
: r.kind === 'probe'
? `probe ${r.probeId ?? '*'}`
: `system ${r.systemId}/${r.item ?? '*'}`;
: r.kind === 'security-event'
? `security-event [${r.events?.join(', ') ?? ''}]`
: `system ${r.systemId}/${r.item ?? '*'}`;
const toggleBtn = el('button', { type: 'button', class: 'btn btn-sm mutating-action' }, r.enabled ? 'Disable' : 'Enable');
toggleBtn.addEventListener('click', () => {
void saveConfig({
@ -404,9 +408,9 @@ export async function renderAlertsView(
const ruleId = el('input', { placeholder: 'high-cpu', required: true });
const ruleName = el('input', { placeholder: 'High CPU Usage', required: true });
const ruleKind = el('select', {}, el('option', { value: 'metric' }, 'metric'), el('option', { value: 'disk' }, 'disk'), el('option', { value: 'offline' }, 'offline'), el('option', { value: 'probe' }, 'probe'), el('option', { value: 'system' }, 'system'));
const ruleKind = el('select', {}, el('option', { value: 'metric' }, 'metric'), el('option', { value: 'disk' }, 'disk'), el('option', { value: 'offline' }, 'offline'), el('option', { value: 'probe' }, 'probe'), el('option', { value: 'system' }, 'system'), el('option', { value: 'security-event' }, 'security-event'));
const ruleSev = el('select', {}, el('option', { value: 'warn' }, 'warn'), el('option', { value: 'critical' }, 'critical'));
const ruleParam1 = el('input', { placeholder: 'metric/mount/probe/system (e.g. cpuPct)' });
const ruleParam1 = el('input', { placeholder: 'metric/mount/probe/system or events csv (auth.lockout,ssh.host_key_mismatch,vault.panic_lock)' });
const ruleThresh = el('input', { type: 'number', value: '85', placeholder: 'Threshold / Offline sec' });
const rulePolls = el('input', { type: 'number', min: 1, value: '3', placeholder: 'forConsecutivePolls' });
const ruleChans = el('input', { placeholder: 'channelIds comma-sep (optional)' });
@ -443,6 +447,17 @@ export async function renderAlertsView(
nextRule = { ...base, kind: 'probe', probeId: ruleParam1.value.trim() || undefined };
} else if (ruleKind.value === 'system') {
nextRule = { ...base, kind: 'system', systemId: ruleParam1.value.trim() || 'docker-compose' };
} else if (ruleKind.value === 'security-event') {
const events = ruleParam1.value
.split(',')
.map((e) => e.trim())
.filter(Boolean);
nextRule = {
...base,
kind: 'security-event',
forConsecutivePolls: 1,
events: events.length > 0 ? events : ['auth.lockout', 'ssh.host_key_mismatch', 'vault.panic_lock'],
};
} else {
nextRule = { ...base, kind: 'metric', metric: (ruleParam1.value.trim() || 'cpuPct') as 'cpuPct', operator: 'gt', threshold: Number(ruleThresh.value || 85) };
}