Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

Monitoring UI, public page & slug validation

Juan Denis35f46073d405
diff --git a/backend/app/api/monitoring.py b/backend/app/api/monitoring.py
index 756d0edd..36f5c5e6 100644
--- a/backend/app/api/monitoring.py
+++ b/backend/app/api/monitoring.py
@@ -86,6 +86,9 @@ def update_config():
current_config = MonitoringService.get_config()
# Update config with new values
+ if 'enabled' in data:
+ current_config['enabled'] = bool(data['enabled'])
+
if 'thresholds' in data:
current_config['thresholds'] = {**current_config.get('thresholds', {}), **data['thresholds']}
diff --git a/backend/app/services/status_page_service.py b/backend/app/services/status_page_service.py
index 77181ba0..5936e390 100644
--- a/backend/app/services/status_page_service.py
+++ b/backend/app/services/status_page_service.py
@@ -1,4 +1,5 @@
import logging
+import re
import socket
import time
from datetime import datetime, timedelta
@@ -13,6 +14,20 @@ logger = logging.getLogger(__name__)
class StatusPageService:
"""Service for public status pages and automated health checks."""
+ SLUG_PATTERN = re.compile(r'^[a-z0-9]+(?:-[a-z0-9]+)*$')
+
+ @staticmethod
+ def normalize_slug(value):
+ slug = (value or '').strip().lower()
+ slug = re.sub(r'[\s_]+', '-', slug)
+ slug = re.sub(r'[^a-z0-9-]', '', slug)
+ slug = re.sub(r'-{2,}', '-', slug).strip('-')
+ if not slug:
+ raise ValueError('Slug is required')
+ if not StatusPageService.SLUG_PATTERN.match(slug):
+ raise ValueError('Slug can only contain lowercase letters, numbers, and hyphens')
+ return slug
+
# --- Pages ---
@staticmethod
@@ -29,7 +44,7 @@ class StatusPageService:
@staticmethod
def create_page(data):
- slug = data.get('slug', '').strip().lower()
+ slug = StatusPageService.normalize_slug(data.get('slug'))
if StatusPage.query.filter_by(slug=slug).first():
raise ValueError(f"Status page '{slug}' already exists")
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index 57ee6551..c342d436 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -45,9 +45,10 @@ import SourceConnectionCallback from './pages/SourceConnectionCallback';
import DatabaseMigration from './pages/DatabaseMigration';
import ServerTemplates from './pages/ServerTemplates';
import Workspaces from './pages/Workspaces';
-import DNSZones from './pages/DNSZones';
-import StatusPages from './pages/StatusPages';
-import CloudProvision from './pages/CloudProvision';
+import DNSZones from './pages/DNSZones';
+import StatusPages from './pages/StatusPages';
+import PublicStatusPage from './pages/PublicStatusPage';
+import CloudProvision from './pages/CloudProvision';
import Marketplace from './pages/Marketplace';
import StyleGuide from './pages/StyleGuide';
import AppMap from './pages/AppMap';
@@ -210,13 +211,14 @@ function AppRoutes() {
<Register />
</PublicRoute>
} />
- <Route path="/connections/callback/:provider" element={
- <PrivateRoute>
- <SourceConnectionCallback />
- </PrivateRoute>
- } />
- {/* Standalone plugin layouts — bare or custom. Each group is
- a sibling top-level Route under PrivateRoute, so the
+ <Route path="/connections/callback/:provider" element={
+ <PrivateRoute>
+ <SourceConnectionCallback />
+ </PrivateRoute>
+ } />
+ <Route path="/status/:slug" element={<PublicStatusPage />} />
+ {/* Standalone plugin layouts — bare or custom. Each group is
+ a sibling top-level Route under PrivateRoute, so the
plugin owns the chrome (no DashboardLayout sidebar). */}
{standaloneGroups.map((group) => {
const Layout = group.LayoutComponent;
diff --git a/frontend/src/pages/Monitoring.jsx b/frontend/src/pages/Monitoring.jsx
index e9462215..91b6de59 100644
--- a/frontend/src/pages/Monitoring.jsx
+++ b/frontend/src/pages/Monitoring.jsx
@@ -1,147 +1,264 @@
-import React, { useState, useEffect } from 'react';
+import { useEffect, useMemo, useState } from 'react';
+import { Link } from 'react-router-dom';
import useTabParam from '../hooks/useTabParam';
import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
-import { StatCard, StatsGrid } from '../components/StatCard';
-import { Circle, Bell, Clock, Mail } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Badge } from '@/components/ui/badge';
-import { Checkbox } from '@/components/ui/checkbox';
+import { Switch } from '@/components/ui/switch';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
+import {
+ Activity,
+ Bell,
+ CheckCircle2,
+ Clock,
+ Cpu,
+ Gauge,
+ HardDrive,
+ Mail,
+ MemoryStick,
+ PlayCircle,
+ RefreshCw,
+ Settings,
+ Siren,
+ Webhook,
+} from 'lucide-react';
const VALID_TABS = ['overview', 'alerts', 'config', 'thresholds'];
+const DEFAULT_THRESHOLDS = {
+ cpu_percent: 80,
+ memory_percent: 85,
+ disk_percent: 90,
+ load_average: 5.0,
+};
+
+const CHANNEL_META = {
+ discord: { label: 'Discord', icon: Webhook },
+ slack: { label: 'Slack', icon: Webhook },
+ telegram: { label: 'Telegram', icon: Bell },
+ email: { label: 'Email', icon: Mail },
+ generic_webhook: { label: 'Webhook', icon: Webhook },
+};
+
+function formatTimestamp(timestamp) {
+ if (!timestamp) return 'Never';
+ return new Date(timestamp).toLocaleString();
+}
+
+function formatNumber(value, digits = 1) {
+ if (typeof value !== 'number' || Number.isNaN(value)) return '-';
+ return value.toFixed(digits);
+}
+
+function formatMetric(value, unit = '%') {
+ if (typeof value !== 'number' || Number.isNaN(value)) return '-';
+ return `${value.toFixed(unit === '' ? 2 : 1)}${unit}`;
+}
+
+function getAlertSeverityVariant(severity) {
+ switch (severity) {
+ case 'critical':
+ return 'destructive';
+ case 'warning':
+ return 'warning';
+ case 'info':
+ return 'info';
+ default:
+ return 'secondary';
+ }
+}
+
const Monitoring = () => {
const toast = useToast();
const [status, setStatus] = useState(null);
- const [config, setConfig] = useState(null);
- const [thresholds, setThresholds] = useState(null);
+ const [thresholds, setThresholds] = useState(DEFAULT_THRESHOLDS);
const [alertHistory, setAlertHistory] = useState([]);
const [loading, setLoading] = useState(true);
+ const [savingConfig, setSavingConfig] = useState(false);
+ const [savingThresholds, setSavingThresholds] = useState(false);
+ const [checkingAlerts, setCheckingAlerts] = useState(false);
const [error, setError] = useState(null);
const [activeTab, setActiveTab] = useTabParam('/monitoring', VALID_TABS);
- // Config form state
const [configForm, setConfigForm] = useState({
enabled: false,
check_interval: 60,
- alert_email: '',
- alert_webhook: ''
});
- // Threshold form state
- const [thresholdForm, setThresholdForm] = useState({
- cpu_percent: 90,
- memory_percent: 90,
- disk_percent: 90,
- load_average: 5.0
- });
-
- const [testEmail, setTestEmail] = useState('');
- const [testWebhook, setTestWebhook] = useState('');
-
- useEffect(() => {
- loadData();
- }, []);
+ const [thresholdForm, setThresholdForm] = useState(DEFAULT_THRESHOLDS);
const loadData = async () => {
try {
setLoading(true);
+ setError(null);
const [statusRes, configRes, thresholdsRes, historyRes] = await Promise.all([
api.getMonitoringStatus(),
api.getMonitoringConfig(),
api.getMonitoringThresholds(),
- api.getAlertHistory(50)
+ api.getAlertHistory(50),
]);
+ const nextThresholds = { ...DEFAULT_THRESHOLDS, ...(thresholdsRes.thresholds || {}) };
setStatus(statusRes);
- setConfig(configRes);
- setThresholds(thresholdsRes.thresholds);
+ setThresholds(nextThresholds);
+ setThresholdForm(nextThresholds);
setAlertHistory(historyRes.alerts || []);
-
- if (configRes) {
- setConfigForm({
- enabled: configRes.enabled || false,
- check_interval: configRes.check_interval || 60,
- alert_email: configRes.alert_email || '',
- alert_webhook: configRes.alert_webhook || ''
- });
- }
-
- if (thresholdsRes.thresholds) {
- setThresholdForm(thresholdsRes.thresholds);
- }
+ setConfigForm({
+ enabled: Boolean(configRes.enabled),
+ check_interval: configRes.check_interval || 60,
+ });
} catch (err) {
- setError(err.message);
+ setError(err.message || 'Failed to load monitoring data');
} finally {
setLoading(false);
}
};
+ useEffect(() => {
+ loadData();
+ }, []);
+
+ const metricRules = useMemo(() => {
+ const metrics = status?.current_metrics || {};
+ return [
+ {
+ key: 'cpu_percent',
+ label: 'CPU usage',
+ description: 'cpu',
+ icon: Cpu,
+ unit: '%',
+ current: metrics.cpu?.percent,
+ threshold: thresholdForm.cpu_percent,
+ persistedThreshold: thresholds.cpu_percent,
+ },
+ {
+ key: 'memory_percent',
+ label: 'Memory usage',
+ description: 'memory',
+ icon: MemoryStick,
+ unit: '%',
+ current: metrics.memory?.percent,
+ threshold: thresholdForm.memory_percent,
+ persistedThreshold: thresholds.memory_percent,
+ },
+ {
+ key: 'disk_percent',
+ label: 'Disk usage',
+ description: 'disk',
+ icon: HardDrive,
+ unit: '%',
+ current: metrics.disk?.percent,
+ threshold: thresholdForm.disk_percent,
+ persistedThreshold: thresholds.disk_percent,
+ },
+ {
+ key: 'load_average',
+ label: 'Load average',
+ description: 'load',
+ icon: Gauge,
+ unit: '',
+ current: metrics.load_average?.['1min'],
+ threshold: thresholdForm.load_average,
+ persistedThreshold: thresholds.load_average,
+ },
+ ];
+ }, [status, thresholdForm, thresholds]);
+
+ const notificationChannels = useMemo(() => {
+ return Object.entries(status?.notifications || {}).map(([key, channel]) => ({
+ key,
+ ...channel,
+ ...(CHANNEL_META[key] || { label: key, icon: Bell }),
+ }));
+ }, [status]);
+
+ const activeAlerts = status?.active_alerts || [];
+ const enabledChannelCount = notificationChannels.filter((channel) => channel.enabled && channel.configured).length;
+ const alertRuleCount = metricRules.length;
+
const handleToggleMonitoring = async () => {
try {
- if (status?.monitoring_active) {
+ if (status?.enabled) {
await api.stopMonitoring();
+ toast.success('Monitoring stopped');
} else {
await api.startMonitoring();
+ toast.success('Monitoring started');
}
- loadData();
+ await loadData();
} catch (err) {
- setError(err.message);
+ setError(err.message || 'Failed to update monitoring state');
}
};
const handleSaveConfig = async (e) => {
e.preventDefault();
try {
- await api.updateMonitoringConfig(configForm);
- loadData();
+ setSavingConfig(true);
+ const wasEnabled = Boolean(status?.enabled);
+ await api.updateMonitoringConfig({
+ enabled: configForm.enabled,
+ check_interval: Number(configForm.check_interval) || 60,
+ });
+
+ if (configForm.enabled !== wasEnabled) {
+ if (configForm.enabled) {
+ await api.startMonitoring();
+ } else {
+ await api.stopMonitoring();
+ }
+ }
+
+ toast.success('Monitoring delivery saved');
+ await loadData();
} catch (err) {
- setError(err.message);
+ toast.error(err.message || 'Failed to save monitoring settings');
+ } finally {
+ setSavingConfig(false);
}
};
const handleSaveThresholds = async (e) => {
e.preventDefault();
try {
- await api.updateMonitoringThresholds(thresholdForm);
- loadData();
+ setSavingThresholds(true);
+ await api.updateMonitoringThresholds({
+ cpu_percent: Number(thresholdForm.cpu_percent),
+ memory_percent: Number(thresholdForm.memory_percent),
+ disk_percent: Number(thresholdForm.disk_percent),
+ load_average: Number(thresholdForm.load_average),
+ });
+ toast.success('Alert rules saved');
+ await loadData();
} catch (err) {
- setError(err.message);
- }
- };
-
- const handleTestEmail = async () => {
- try {
- await api.testEmailAlert(testEmail || configForm.alert_email);
- toast.success('Test email sent successfully');
- } catch (err) {
- toast.error(err.message);
+ toast.error(err.message || 'Failed to save alert rules');
+ } finally {
+ setSavingThresholds(false);
}
};
- const handleTestWebhook = async () => {
+ const handleCheckAlerts = async () => {
try {
- await api.testWebhookAlert(testWebhook || configForm.alert_webhook);
- toast.success('Test webhook sent successfully');
+ setCheckingAlerts(true);
+ const result = await api.checkAlerts();
+ const count = result.alerts?.length || 0;
+ toast[count > 0 ? 'warning' : 'success'](`${count} active alert${count !== 1 ? 's' : ''}`);
+ await loadData();
} catch (err) {
- toast.error(err.message);
- }
- };
-
- const getAlertSeverityVariant = (severity) => {
- switch (severity) {
- case 'critical': return 'destructive';
- case 'warning': return 'warning';
- case 'info': return 'info';
- default: return 'secondary';
+ toast.error(err.message || 'Alert check failed');
+ } finally {
+ setCheckingAlerts(false);
}
};
- const formatTimestamp = (timestamp) => {
- return new Date(timestamp).toLocaleString();
+ const updateThreshold = (key, value) => {
+ setThresholdForm((current) => ({
+ ...current,
+ [key]: value,
+ }));
};
if (loading) {
@@ -153,26 +270,25 @@ const Monitoring = () => {
<div className="page-header">
<div>
<h1>Monitoring & Alerts</h1>
- <p className="page-subtitle">System monitoring and alert configuration</p>
+ <p className="page-subtitle">System resource alerts and delivery</p>
</div>
<div className="page-actions">
+ <Button variant="outline" onClick={loadData}>
+ <RefreshCw size={16} />
+ Refresh
+ </Button>
<Button
- variant={status?.monitoring_active ? 'destructive' : 'default'}
+ variant={status?.enabled ? 'destructive' : 'default'}
onClick={handleToggleMonitoring}
>
- {status?.monitoring_active ? (
+ {status?.enabled ? (
<>
- <svg viewBox="0 0 24 24" width="16" height="16">
- <rect x="6" y="4" width="4" height="16"/>
- <rect x="14" y="4" width="4" height="16"/>
- </svg>
+ <Activity size={16} />
Stop Monitoring
</>
) : (
<>
- <svg viewBox="0 0 24 24" width="16" height="16">
- <polygon points="5 3 19 12 5 21 5 3"/>
- </svg>
+ <PlayCircle size={16} />
Start Monitoring
</>
)}
@@ -190,280 +306,249 @@ const Monitoring = () => {
<Tabs value={activeTab} onValueChange={setActiveTab}>
<TabsList>
<TabsTrigger value="overview">Overview</TabsTrigger>
- <TabsTrigger value="alerts">Alert History</TabsTrigger>
- <TabsTrigger value="config">Configuration</TabsTrigger>
- <TabsTrigger value="thresholds">Thresholds</TabsTrigger>
+ <TabsTrigger value="thresholds">Alert Rules</TabsTrigger>
+ <TabsTrigger value="config">Delivery</TabsTrigger>
+ <TabsTrigger value="alerts">History</TabsTrigger>
</TabsList>
<TabsContent value="overview">
<div className="monitoring-overview">
- <StatsGrid>
- <StatCard
- icon={Circle}
- iconVariant="status"
- label="Monitoring Status"
- value={status?.monitoring_active ? 'Active' : 'Inactive'}
- valueClassName={status?.monitoring_active ? 'text-success' : 'text-muted'}
- />
- <StatCard icon={Bell} iconVariant="alerts" label="Recent Alerts" value={alertHistory.length} />
- <StatCard icon={Clock} iconVariant="interval" label="Check Interval" value={`${config?.check_interval || 60}s`} />
- <StatCard
- icon={Mail}
- iconVariant="notifications"
- label="Notifications"
- value={
- config?.alert_email && config?.alert_webhook
- ? 'Email + Webhook'
- : config?.alert_email
- ? 'Email'
- : config?.alert_webhook
- ? 'Webhook'
- : 'None'
- }
- />
- </StatsGrid>
-
- <div className="card">
- <div className="card-header">
- <h3>Current Thresholds</h3>
+ <section className={`monitoring-hero ${status?.enabled ? 'is-active' : ''}`}>
+ <div>
+ <Badge variant={status?.enabled ? 'success' : 'secondary'}>
+ {status?.enabled ? <CheckCircle2 size={14} /> : <Clock size={14} />}
+ {status?.enabled ? 'Monitoring active' : 'Monitoring paused'}
+ </Badge>
+ <h2>{activeAlerts.length > 0 ? `${activeAlerts.length} active alert${activeAlerts.length !== 1 ? 's' : ''}` : 'No active alerts'}</h2>
+ <p>
+ Checks run every {status?.check_interval || configForm.check_interval || 60} seconds.
+ </p>
</div>
- <div className="card-body">
- <div className="threshold-grid">
- <div className="threshold-item">
- <span className="threshold-label">CPU Usage</span>
- <span className="threshold-value">{thresholds?.cpu_percent || 90}%</span>
- </div>
- <div className="threshold-item">
- <span className="threshold-label">Memory Usage</span>
- <span className="threshold-value">{thresholds?.memory_percent || 90}%</span>
- </div>
- <div className="threshold-item">
- <span className="threshold-label">Disk Usage</span>
- <span className="threshold-value">{thresholds?.disk_percent || 90}%</span>
- </div>
- <div className="threshold-item">
- <span className="threshold-label">Load Average</span>
- <span className="threshold-value">{thresholds?.load_average || 5.0}</span>
- </div>
- </div>
+ <div className="monitoring-hero__actions">
+ <Button variant="outline" onClick={handleCheckAlerts} disabled={checkingAlerts}>
+ <Siren size={16} />
+ {checkingAlerts ? 'Checking...' : 'Check Now'}
+ </Button>
+ </div>
+ </section>
+
+ <div className="monitoring-summary-grid">
+ <div>
+ <span>Alert rules</span>
+ <strong>{alertRuleCount}</strong>
+ </div>
+ <div>
+ <span>Delivery channels</span>
+ <strong>{enabledChannelCount}</strong>
+ </div>
+ <div>
+ <span>History</span>
+ <strong>{alertHistory.length}</strong>
</div>
</div>
- {alertHistory.length > 0 && (
- <div className="card">
- <div className="card-header">
- <h3>Recent Alerts</h3>
- </div>
- <div className="card-body">
- <div className="alert-list">
- {alertHistory.slice(0, 5).map((alert, index) => (
- <div key={index} className="alert-item">
- <Badge variant={getAlertSeverityVariant(alert.severity)}>
- {alert.severity}
- </Badge>
- <span className="alert-message">{alert.message}</span>
- <span className="alert-time">{formatTimestamp(alert.timestamp)}</span>
+ <section className="monitoring-panel">
+ <div className="monitoring-panel__header">
+ <h3>Current Metrics</h3>
+ <Button size="sm" variant="outline" onClick={() => setActiveTab('thresholds')}>
+ <Settings size={14} />
+ Rules
+ </Button>
+ </div>
+ <div className="metric-rule-grid metric-rule-grid--compact">
+ {metricRules.map((rule) => {
+ const Icon = rule.icon;
+ const isTriggered = typeof rule.current === 'number' && rule.current > rule.persistedThreshold;
+ return (
+ <article key={rule.key} className={`metric-rule-card ${isTriggered ? 'is-triggered' : ''}`}>
+ <div className="metric-rule-card__icon">
+ <Icon size={18} />
</div>
- ))}
- </div>
- </div>
+ <div>
+ <span>{rule.label}</span>
+ <strong>{formatMetric(rule.current, rule.unit)}</strong>
+ </div>
+ <Badge variant={isTriggered ? 'warning' : 'success'}>
+ {isTriggered ? 'Alerting' : `Under ${formatMetric(rule.persistedThreshold, rule.unit)}`}
+ </Badge>
+ </article>
+ );
+ })}
</div>
+ </section>
+
+ {activeAlerts.length > 0 && (
+ <section className="monitoring-panel monitoring-panel--warning">
+ <div className="monitoring-panel__header">
+ <h3>Active Alerts</h3>
+ </div>
+ <div className="alert-list">
+ {activeAlerts.map((alert, index) => (
+ <div key={`${alert.type}-${index}`} className="alert-item">
+ <Badge variant={getAlertSeverityVariant(alert.severity)}>
+ {alert.severity}
+ </Badge>
+ <span className="alert-message">{alert.message}</span>
+ <span className="alert-time">{formatNumber(alert.value)} / {alert.threshold}</span>
+ </div>
+ ))}
+ </div>
+ </section>
)}
</div>
</TabsContent>
- <TabsContent value="alerts">
- <div className="card">
- <div className="card-header">
- <h3>Alert History</h3>
- <Button variant="outline" size="sm" onClick={loadData}>
- Refresh
+ <TabsContent value="thresholds">
+ <form className="monitoring-panel" onSubmit={handleSaveThresholds}>
+ <div className="monitoring-panel__header">
+ <h3>Alert Rules</h3>
+ <Button type="submit" disabled={savingThresholds}>
+ {savingThresholds ? 'Saving...' : 'Save Rules'}
</Button>
</div>
- <div className="card-body">
- {alertHistory.length === 0 ? (
- <div className="empty-state">
- <svg viewBox="0 0 24 24" width="48" height="48">
- <path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/>
- <path d="M13.73 21a2 2 0 0 1-3.46 0"/>
- </svg>
- <h3>No Alerts</h3>
- <p>No alerts have been triggered yet.</p>
- </div>
- ) : (
- <table className="table">
- <thead>
- <tr>
- <th>Severity</th>
- <th>Type</th>
- <th>Message</th>
- <th>Value</th>
- <th>Threshold</th>
- <th>Time</th>
- </tr>
- </thead>
- <tbody>
- {alertHistory.map((alert, index) => (
- <tr key={index}>
- <td>
- <Badge variant={getAlertSeverityVariant(alert.severity)}>
- {alert.severity}
- </Badge>
- </td>
- <td>{alert.type}</td>
- <td>{alert.message}</td>
- <td>{alert.value?.toFixed(1)}</td>
- <td>{alert.threshold}</td>
- <td>{formatTimestamp(alert.timestamp)}</td>
- </tr>
- ))}
- </tbody>
- </table>
- )}
+ <div className="metric-rule-grid">
+ {metricRules.map((rule) => {
+ const Icon = rule.icon;
+ const isTriggered = typeof rule.current === 'number' && rule.current > rule.threshold;
+ return (
+ <article key={rule.key} className={`metric-rule-editor ${isTriggered ? 'is-triggered' : ''}`}>
+ <div className="metric-rule-editor__main">
+ <div className="metric-rule-card__icon">
+ <Icon size={18} />
+ </div>
+ <div>
+ <h4>{rule.label}</h4>
+ <span>Current: {formatMetric(rule.current, rule.unit)}</span>
+ </div>
+ </div>
+ <div className="metric-rule-editor__threshold">
+ <Label htmlFor={`threshold-${rule.key}`}>Trigger above</Label>
+ <Input
+ id={`threshold-${rule.key}`}
+ type="number"
+ min={rule.key === 'load_average' ? '0.1' : '1'}
+ max={rule.key === 'load_average' ? '100' : '100'}
+ step={rule.key === 'load_average' ? '0.1' : '1'}
+ value={rule.threshold}
+ onChange={(e) => updateThreshold(rule.key, e.target.value)}
+ />
+ </div>
+ <Badge variant={isTriggered ? 'warning' : 'secondary'}>
+ {isTriggered ? 'Would alert now' : 'Quiet'}
+ </Badge>
+ </article>
+ );
+ })}
</div>
- </div>
+ </form>
</TabsContent>
<TabsContent value="config">
- <div className="card">
- <div className="card-header">
- <h3>Monitoring Configuration</h3>
- </div>
- <div className="card-body">
- <form onSubmit={handleSaveConfig}>
- <div className="form-group">
- <label className="checkbox-label">
- <Checkbox
- checked={configForm.enabled}
- onCheckedChange={(checked) => setConfigForm({...configForm, enabled: checked})}
- />
- <span>Enable Monitoring</span>
- </label>
- </div>
-
- <div className="form-group">
- <Label>Check Interval (seconds)</Label>
- <Input
- type="number"
- value={configForm.check_interval}
- onChange={(e) => setConfigForm({...configForm, check_interval: parseInt(e.target.value)})}
- min="10"
- max="3600"
- />
- </div>
-
- <div className="form-group">
- <Label>Alert Email</Label>
- <div className="input-group">
- <Input
- type="email"
- value={configForm.alert_email}
- onChange={(e) => setConfigForm({...configForm, alert_email: e.target.value})}
- placeholder="[email protected]"
- />
- <Button
- type="button"
- variant="outline"
- onClick={handleTestEmail}
- disabled={!configForm.alert_email}
- >
- Test
- </Button>
- </div>
- </div>
-
- <div className="form-group">
- <Label>Webhook URL</Label>
- <div className="input-group">
- <Input
- type="url"
- value={configForm.alert_webhook}
- onChange={(e) => setConfigForm({...configForm, alert_webhook: e.target.value})}
- placeholder="https://hooks.slack.com/..."
- />
- <Button
- type="button"
- variant="outline"
- onClick={handleTestWebhook}
- disabled={!configForm.alert_webhook}
- >
- Test
- </Button>
- </div>
- </div>
-
- <div className="form-actions">
- <Button type="submit">Save Configuration</Button>
+ <div className="monitoring-delivery-layout">
+ <form className="monitoring-panel" onSubmit={handleSaveConfig}>
+ <div className="monitoring-panel__header">
+ <h3>Scheduler</h3>
+ <Button type="submit" disabled={savingConfig}>
+ {savingConfig ? 'Saving...' : 'Save Delivery'}
+ </Button>
+ </div>
+ <div className="monitoring-switch-row">
+ <div>
+ <strong>Run resource checks</strong>
+ <span>{configForm.enabled ? 'Enabled' : 'Paused'}</span>
</div>
- </form>
- </div>
+ <Switch
+ checked={configForm.enabled}
+ onCheckedChange={(checked) => setConfigForm({ ...configForm, enabled: checked })}
+ />
+ </div>
+ <div className="form-group">
+ <Label htmlFor="monitoring-interval">Check interval</Label>
+ <Input
+ id="monitoring-interval"
+ type="number"
+ min="10"
+ max="3600"
+ value={configForm.check_interval}
+ onChange={(e) => setConfigForm({ ...configForm, check_interval: e.target.value })}
+ />
+ <span className="form-help">Seconds between checks.</span>
+ </div>
+ </form>
+
+ <section className="monitoring-panel">
+ <div className="monitoring-panel__header">
+ <h3>Notification Channels</h3>
+ <Button size="sm" asChild>
+ <Link to="/settings/notifications">
+ <Settings size={14} />
+ Configure
+ </Link>
+ </Button>
+ </div>
+ <div className="notification-channel-grid">
+ {notificationChannels.map((channel) => {
+ const Icon = channel.icon;
+ const ready = channel.enabled && channel.configured;
+ return (
+ <article key={channel.key} className={`notification-channel-tile ${ready ? 'is-ready' : ''}`}>
+ <Icon size={18} />
+ <div>
+ <strong>{channel.label}</strong>
+ <span>{ready ? 'Enabled' : channel.configured ? 'Configured' : 'Not configured'}</span>
+ </div>
+ <Badge variant={ready ? 'success' : 'secondary'}>
+ {ready ? 'Ready' : 'Off'}
+ </Badge>
+ </article>
+ );
+ })}
+ </div>
+ </section>
</div>
</TabsContent>
- <TabsContent value="thresholds">
- <div className="card">
- <div className="card-header">
- <h3>Alert Thresholds</h3>
- </div>
- <div className="card-body">
- <form onSubmit={handleSaveThresholds}>
- <div className="threshold-form-grid">
- <div className="form-group">
- <Label>CPU Usage (%)</Label>
- <Input
- type="number"
- value={thresholdForm.cpu_percent}
- onChange={(e) => setThresholdForm({...thresholdForm, cpu_percent: parseInt(e.target.value)})}
- min="1"
- max="100"
- />
- <span className="form-help">Alert when CPU exceeds this percentage</span>
- </div>
-
- <div className="form-group">
- <Label>Memory Usage (%)</Label>
- <Input
- type="number"
- value={thresholdForm.memory_percent}
- onChange={(e) => setThresholdForm({...thresholdForm, memory_percent: parseInt(e.target.value)})}
- min="1"
- max="100"
- />
- <span className="form-help">Alert when memory exceeds this percentage</span>
- </div>
-
- <div className="form-group">
- <Label>Disk Usage (%)</Label>
- <Input
- type="number"
- value={thresholdForm.disk_percent}
- onChange={(e) => setThresholdForm({...thresholdForm, disk_percent: parseInt(e.target.value)})}
- min="1"
- max="100"
- />
- <span className="form-help">Alert when disk exceeds this percentage</span>
- </div>
-
- <div className="form-group">
- <Label>Load Average</Label>
- <Input
- type="number"
- step="0.1"
- value={thresholdForm.load_average}
- onChange={(e) => setThresholdForm({...thresholdForm, load_average: parseFloat(e.target.value)})}
- min="0.1"
- max="100"
- />
- <span className="form-help">Alert when load average exceeds this value</span>
- </div>
- </div>
-
- <div className="form-actions">
- <Button type="submit">Save Thresholds</Button>
- </div>
- </form>
+ <TabsContent value="alerts">
+ <section className="monitoring-panel">
+ <div className="monitoring-panel__header">
+ <h3>Alert History</h3>
+ <div>
+ <Button variant="outline" size="sm" onClick={handleCheckAlerts} disabled={checkingAlerts}>
+ <Siren size={14} />
+ Check Now
+ </Button>
+ <Button variant="outline" size="sm" onClick={loadData}>
+ <RefreshCw size={14} />
+ Refresh
+ </Button>
+ </div>
</div>
- </div>
+ {alertHistory.length === 0 ? (
+ <div className="empty-state monitoring-empty">
+ <Bell size={40} />
+ <h3>No Alerts</h3>
+ <p>No alerts have been triggered yet.</p>
+ </div>
+ ) : (
+ <div className="monitoring-history-list">
+ {alertHistory.map((alert, index) => (
+ <article key={`${alert.timestamp}-${index}`} className="monitoring-history-row">
+ <Badge variant={getAlertSeverityVariant(alert.severity)}>
+ {alert.severity}
+ </Badge>
+ <div>
+ <strong>{alert.type}</strong>
+ <span>{alert.message}</span>
+ </div>
+ <div className="monitoring-history-row__meta">
+ <span>{formatNumber(alert.value)} / {alert.threshold}</span>
+ <span>{formatTimestamp(alert.timestamp)}</span>
+ </div>
+ </article>
+ ))}
+ </div>
+ )}
+ </section>
</TabsContent>
</Tabs>
</div>
diff --git a/frontend/src/pages/PublicStatusPage.jsx b/frontend/src/pages/PublicStatusPage.jsx
new file mode 100644
index 00000000..27852606
--- /dev/null
+++ b/frontend/src/pages/PublicStatusPage.jsx
@@ -0,0 +1,197 @@
+import { useEffect, useMemo, useState } from 'react';
+import { useParams } from 'react-router-dom';
+import api from '../services/api';
+import Spinner from '../components/Spinner';
+import { Badge } from '@/components/ui/badge';
+import { Activity, AlertTriangle, CheckCircle2, Clock, XCircle } from 'lucide-react';
+
+const STATUS_META = {
+ operational: { label: 'Operational', badge: 'success', icon: CheckCircle2 },
+ degraded: { label: 'Degraded', badge: 'warning', icon: AlertTriangle },
+ partial_outage: { label: 'Partial outage', badge: 'warning', icon: AlertTriangle },
+ major_outage: { label: 'Major outage', badge: 'destructive', icon: XCircle },
+ maintenance: { label: 'Maintenance', badge: 'info', icon: Clock },
+};
+
+const IMPACT_META = {
+ none: 'None',
+ minor: 'Minor',
+ major: 'Major',
+ critical: 'Critical',
+};
+
+function formatDate(value) {
+ if (!value) return 'Never';
+ return new Date(value).toLocaleString();
+}
+
+function formatUptime(value) {
+ if (typeof value !== 'number') return '100.00%';
+ return `${value.toFixed(2)}%`;
+}
+
+function PublicStatusPage() {
+ const { slug } = useParams();
+ const [data, setData] = useState(null);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState(null);
+
+ useEffect(() => {
+ async function loadPage() {
+ try {
+ setLoading(true);
+ setError(null);
+ const response = await api.getPublicStatusPage(slug);
+ setData(response);
+ } catch (err) {
+ setError(err.message || 'Status page not found');
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ loadPage();
+ }, [slug]);
+
+ const components = useMemo(() => {
+ if (!data?.groups) return [];
+ return Object.values(data.groups).flat();
+ }, [data]);
+
+ if (loading) {
+ return (
+ <main className="public-status-page">
+ <Spinner />
+ </main>
+ );
+ }
+
+ if (error || !data) {
+ return (
+ <main className="public-status-page">
+ <section className="public-status-shell public-status-shell--empty">
+ <XCircle size={32} />
+ <h1>Status page unavailable</h1>
+ <p>{error || 'Status page not found'}</p>
+ </section>
+ </main>
+ );
+ }
+
+ const { page, overall_status: overallStatus, active_incidents: activeIncidents = [], recent_incidents: recentIncidents = [] } = data;
+ const overallMeta = STATUS_META[overallStatus] || STATUS_META.operational;
+ const OverallIcon = overallMeta.icon;
+
+ return (
+ <main className="public-status-page">
+ <section className={`public-status-hero public-status-hero--${overallStatus}`}>
+ <div>
+ <h1>{page.name}</h1>
+ {page.description && <p>{page.description}</p>}
+ </div>
+ <Badge variant={overallMeta.badge} className="public-status-badge">
+ <OverallIcon size={16} />
+ {overallMeta.label}
+ </Badge>
+ </section>
+
+ <section className="public-status-summary">
+ <div>
+ <span>Components</span>
+ <strong>{components.length}</strong>
+ </div>
+ <div>
+ <span>Active incidents</span>
+ <strong>{activeIncidents.length}</strong>
+ </div>
+ <div>
+ <span>30 day uptime</span>
+ <strong>{formatUptime(
+ components.length
+ ? components.reduce((total, component) => total + (component.uptime_30d || 100), 0) / components.length
+ : 100
+ )}</strong>
+ </div>
+ </section>
+
+ {activeIncidents.length > 0 && (
+ <section className="public-status-section">
+ <header>
+ <h2>Active Incidents</h2>
+ </header>
+ <div className="public-incident-list">
+ {activeIncidents.map((incident) => (
+ <article key={incident.id} className="public-incident public-incident--active">
+ <div>
+ <h3>{incident.title}</h3>
+ <span>{formatDate(incident.created_at)}</span>
+ </div>
+ <Badge variant="warning">{IMPACT_META[incident.impact] || incident.impact}</Badge>
+ {incident.body && <p>{incident.body}</p>}
+ </article>
+ ))}
+ </div>
+ </section>
+ )}
+
+ <section className="public-status-section">
+ <header>
+ <h2>Components</h2>
+ </header>
+ <div className="public-component-groups">
+ {Object.entries(data.groups || {}).map(([groupName, groupComponents]) => (
+ <div key={groupName} className="public-component-group">
+ <h3>{groupName}</h3>
+ <div className="public-component-list">
+ {groupComponents.map((component) => {
+ const statusMeta = STATUS_META[component.status] || STATUS_META.operational;
+ const StatusIcon = statusMeta.icon;
+ return (
+ <article key={component.id} className="public-component-row">
+ <div>
+ <StatusIcon size={18} />
+ <span>{component.name}</span>
+ </div>
+ <div className="public-component-row__meta">
+ <span>{formatUptime(component.uptime_30d)}</span>
+ {component.last_response_time && <span>{component.last_response_time}ms</span>}
+ <Badge variant={statusMeta.badge}>{statusMeta.label}</Badge>
+ </div>
+ </article>
+ );
+ })}
+ </div>
+ </div>
+ ))}
+ {components.length === 0 && (
+ <div className="public-status-empty">
+ <Activity size={24} />
+ <span>No components published.</span>
+ </div>
+ )}
+ </div>
+ </section>
+
+ {recentIncidents.length > 0 && (
+ <section className="public-status-section">
+ <header>
+ <h2>Recent Incidents</h2>
+ </header>
+ <div className="public-incident-list">
+ {recentIncidents.map((incident) => (
+ <article key={incident.id} className="public-incident">
+ <div>
+ <h3>{incident.title}</h3>
+ <span>{formatDate(incident.resolved_at || incident.created_at)}</span>
+ </div>
+ <Badge variant="success">Resolved</Badge>
+ </article>
+ ))}
+ </div>
+ </section>
+ )}
+ </main>
+ );
+}
+
+export default PublicStatusPage;
diff --git a/frontend/src/pages/StatusPages.jsx b/frontend/src/pages/StatusPages.jsx
index 3c2c1a10..8878cff6 100644
--- a/frontend/src/pages/StatusPages.jsx
+++ b/frontend/src/pages/StatusPages.jsx
@@ -1,4 +1,4 @@
-import React, { useState, useEffect, useCallback } from 'react';
+import { useEffect, useMemo, useState } from 'react';
import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
import { useAuth } from '../contexts/AuthContext';
@@ -9,6 +9,93 @@ import { Input } from '@/components/ui/input';
import { Textarea } from '@/components/ui/textarea';
import { Badge } from '@/components/ui/badge';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
+import {
+ Activity,
+ AlertTriangle,
+ CheckCircle2,
+ Copy,
+ ExternalLink,
+ Globe2,
+ PlayCircle,
+ Plus,
+ RefreshCw,
+ Trash2,
+ Wrench,
+ XCircle,
+} from 'lucide-react';
+
+const STATUS_META = {
+ operational: { label: 'Operational', badge: 'success', tone: 'success', icon: CheckCircle2 },
+ degraded: { label: 'Degraded', badge: 'warning', tone: 'warning', icon: AlertTriangle },
+ partial_outage: { label: 'Partial outage', badge: 'warning', tone: 'warning', icon: AlertTriangle },
+ major_outage: { label: 'Major outage', badge: 'destructive', tone: 'danger', icon: XCircle },
+ maintenance: { label: 'Maintenance', badge: 'info', tone: 'info', icon: Wrench },
+};
+
+const INCIDENT_STATUS = [
+ { value: 'investigating', label: 'Investigating' },
+ { value: 'identified', label: 'Identified' },
+ { value: 'monitoring', label: 'Monitoring' },
+ { value: 'resolved', label: 'Resolved' },
+];
+
+const IMPACT_OPTIONS = [
+ { value: 'none', label: 'None' },
+ { value: 'minor', label: 'Minor' },
+ { value: 'major', label: 'Major' },
+ { value: 'critical', label: 'Critical' },
+];
+
+const CHECK_TARGET_PLACEHOLDERS = {
+ http: 'https://example.com/health',
+ tcp: 'example.com:443',
+ dns: 'example.com',
+ ping: 'example.com',
+};
+
+const defaultPageForm = { name: '', slug: '', description: '', primary_color: '#4f46e5' };
+const defaultCompForm = {
+ name: '',
+ group: 'Services',
+ check_type: 'http',
+ check_target: '',
+ check_interval: 60,
+ check_timeout: 10,
+};
+const defaultIncidentForm = { title: '', status: 'investigating', impact: 'minor', body: '' };
+
+function normalizeSlug(value) {
+ return (value || '')
+ .toLowerCase()
+ .trim()
+ .replace(/[\s_]+/g, '-')
+ .replace(/[^a-z0-9-]/g, '')
+ .replace(/-+/g, '-')
+ .replace(/^-|-$/g, '');
+}
+
+function formatDate(value) {
+ if (!value) return 'Never';
+ return new Date(value).toLocaleString();
+}
+
+function formatUptime(value) {
+ if (typeof value !== 'number') return '100.00%';
+ return `${value.toFixed(2)}%`;
+}
+
+function getPublicStatusUrl(page) {
+ if (!page) return '';
+ return `${window.location.origin}/status/${page.slug}`;
+}
+
+function getOverallStatus(components) {
+ const statuses = components.map((component) => component.status);
+ if (statuses.some((status) => status === 'major_outage')) return 'major_outage';
+ if (statuses.some((status) => status === 'partial_outage' || status === 'degraded')) return 'degraded';
+ if (statuses.some((status) => status === 'maintenance')) return 'maintenance';
+ return 'operational';
+}
const StatusPages = () => {
const toast = useToast();
@@ -23,46 +110,101 @@ const StatusPages = () => {
const [showCreateIncident, setShowCreateIncident] = useState(false);
const [deleteConfirm, setDeleteConfirm] = useState(null);
- const [pageForm, setPageForm] = useState({ name: '', slug: '', description: '', primary_color: '#4f46e5' });
- const [compForm, setCompForm] = useState({ name: '', group: 'Services', check_type: 'http', check_target: '', check_interval: 60 });
- const [incidentForm, setIncidentForm] = useState({ title: '', impact: 'minor', body: '' });
+ const [pageForm, setPageForm] = useState(defaultPageForm);
+ const [compForm, setCompForm] = useState(defaultCompForm);
+ const [incidentForm, setIncidentForm] = useState(defaultIncidentForm);
- const loadPages = useCallback(async () => {
- try {
- const data = await api.getStatusPages();
- setPages(data.pages || []);
- } catch (err) {
- toast.error('Failed to load status pages');
- } finally {
- setLoading(false);
- }
- }, [toast]);
+ const isAdmin = Boolean(user?.is_admin);
- useEffect(() => { loadPages(); }, [loadPages]);
+ const groupedComponents = useMemo(() => {
+ return components.reduce((groups, component) => {
+ const groupName = component.group || 'Services';
+ groups[groupName] = groups[groupName] || [];
+ groups[groupName].push(component);
+ return groups;
+ }, {});
+ }, [components]);
- const loadPageDetails = async (pageId) => {
+ const activeIncidents = useMemo(
+ () => incidents.filter((incident) => incident.status !== 'resolved'),
+ [incidents]
+ );
+
+ const overallStatus = useMemo(() => getOverallStatus(components), [components]);
+ const overallMeta = STATUS_META[overallStatus] || STATUS_META.operational;
+ const OverallIcon = overallMeta.icon;
+ const selectedUrl = getPublicStatusUrl(selectedPage);
+
+ const loadPageDetails = async (page) => {
+ if (!page) return;
try {
const [cData, iData] = await Promise.all([
- api.getStatusPageComponents(pageId),
- api.getStatusPageIncidents(pageId),
+ api.getStatusPageComponents(page.id),
+ api.getStatusPageIncidents(page.id),
]);
+ setSelectedPage(page);
setComponents(cData.components || []);
setIncidents(iData.incidents || []);
- setSelectedPage(pages.find(p => p.id === pageId));
} catch (err) {
- toast.error('Failed to load details');
+ toast.error(err.message || 'Failed to load page details');
}
};
+ const loadPages = async () => {
+ try {
+ setLoading(true);
+ const data = await api.getStatusPages();
+ const nextPages = data.pages || [];
+ setPages(nextPages);
+
+ const nextSelected = selectedPage
+ ? nextPages.find((page) => page.id === selectedPage.id) || nextPages[0]
+ : nextPages[0];
+
+ if (nextSelected) {
+ await loadPageDetails(nextSelected);
+ } else {
+ setSelectedPage(null);
+ setComponents([]);
+ setIncidents([]);
+ }
+ } catch (err) {
+ toast.error(err.message || 'Failed to load status pages');
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ useEffect(() => {
+ loadPages();
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ const handlePageNameChange = (name) => {
+ setPageForm((prev) => {
+ const previousAutoSlug = normalizeSlug(prev.name);
+ const shouldSyncSlug = !prev.slug || prev.slug === previousAutoSlug;
+ return {
+ ...prev,
+ name,
+ slug: shouldSyncSlug ? normalizeSlug(name) : prev.slug,
+ };
+ });
+ };
+
const handleCreatePage = async () => {
try {
- const page = await api.createStatusPage(pageForm);
+ const page = await api.createStatusPage({
+ ...pageForm,
+ slug: normalizeSlug(pageForm.slug),
+ });
toast.success('Status page created');
setShowCreatePage(false);
- setPageForm({ name: '', slug: '', description: '', primary_color: '#4f46e5' });
- loadPages();
+ setPageForm(defaultPageForm);
+ setPages((current) => [...current, page].sort((a, b) => a.name.localeCompare(b.name)));
+ await loadPageDetails(page);
} catch (err) {
- toast.error(err.message);
+ toast.error(err.message || 'Failed to create status page');
}
};
@@ -72,19 +214,21 @@ const StatusPages = () => {
await api.createStatusComponent(selectedPage.id, compForm);
toast.success('Component added');
setShowCreateComponent(false);
- loadPageDetails(selectedPage.id);
+ setCompForm(defaultCompForm);
+ await loadPageDetails(selectedPage);
+ await loadPages();
} catch (err) {
- toast.error(err.message);
+ toast.error(err.message || 'Failed to add component');
}
};
- const handleRunCheck = async (compId) => {
+ const handleRunCheck = async (component) => {
try {
- const result = await api.runStatusCheck(compId);
- toast.success(`Check: ${result.status} (${result.response_time}ms)`);
- if (selectedPage) loadPageDetails(selectedPage.id);
+ const result = await api.runStatusCheck(component.id);
+ toast.success(`Check ${result.status}${result.response_time ? ` in ${result.response_time}ms` : ''}`);
+ if (selectedPage) await loadPageDetails(selectedPage);
} catch (err) {
- toast.error(err.message);
+ toast.error(err.message || 'Check failed');
}
};
@@ -94,25 +238,66 @@ const StatusPages = () => {
await api.createStatusIncident(selectedPage.id, incidentForm);
toast.success('Incident created');
setShowCreateIncident(false);
- setIncidentForm({ title: '', impact: 'minor', body: '' });
- loadPageDetails(selectedPage.id);
+ setIncidentForm(defaultIncidentForm);
+ await loadPageDetails(selectedPage);
} catch (err) {
- toast.error(err.message);
+ toast.error(err.message || 'Failed to create incident');
}
};
- const handleResolveIncident = async (incidentId) => {
+ const handleUpdateIncidentStatus = async (incident, status) => {
try {
- await api.updateStatusIncident(incidentId, { status: 'resolved', update_body: 'Issue has been resolved.' });
- toast.success('Incident resolved');
- if (selectedPage) loadPageDetails(selectedPage.id);
+ const statusLabel = INCIDENT_STATUS.find((item) => item.value === status)?.label || status;
+ await api.updateStatusIncident(incident.id, {
+ status,
+ update_body: status === 'resolved' ? 'Issue has been resolved.' : `Status changed to ${statusLabel}.`,
+ });
+ toast.success(`Incident set to ${statusLabel}`);
+ if (selectedPage) await loadPageDetails(selectedPage);
} catch (err) {
- toast.error(err.message);
+ toast.error(err.message || 'Failed to update incident');
+ }
+ };
+
+ const handleCopyUrl = async () => {
+ if (!selectedUrl) return;
+ try {
+ await navigator.clipboard.writeText(selectedUrl);
+ toast.success('Status page URL copied');
+ } catch {
+ toast.error('Could not copy URL');
}
};
- const statusColors = {
- operational: 'success', degraded: 'warning', partial_outage: 'warning', major_outage: 'danger', maintenance: 'info'
+ const handleConfirmDelete = async () => {
+ if (!deleteConfirm) return;
+ try {
+ if (deleteConfirm.type === 'page') {
+ await api.deleteStatusPage(deleteConfirm.item.id);
+ toast.success('Status page deleted');
+ setDeleteConfirm(null);
+ setSelectedPage(null);
+ setComponents([]);
+ setIncidents([]);
+ await loadPages();
+ return;
+ }
+
+ if (deleteConfirm.type === 'component') {
+ await api.deleteStatusComponent(deleteConfirm.item.id);
+ toast.success('Component deleted');
+ }
+
+ if (deleteConfirm.type === 'incident') {
+ await api.deleteStatusIncident(deleteConfirm.item.id);
+ toast.success('Incident deleted');
+ }
+
+ setDeleteConfirm(null);
+ if (selectedPage) await loadPageDetails(selectedPage);
+ } catch (err) {
+ toast.error(err.message || 'Delete failed');
+ }
};
if (loading) return <Spinner />;
@@ -125,60 +310,148 @@ const StatusPages = () => {
<p className="page-description">{pages.length} page{pages.length !== 1 ? 's' : ''}</p>
</div>
<div className="page-header-actions">
- {user?.is_admin && (
- <Button onClick={() => setShowCreatePage(true)}>Create Page</Button>
+ <Button variant="outline" onClick={loadPages}>
+ <RefreshCw size={16} />
+ Refresh
+ </Button>
+ {isAdmin && (
+ <Button onClick={() => setShowCreatePage(true)}>
+ <Plus size={16} />
+ Create Page
+ </Button>
)}
</div>
</div>
<div className="status-layout">
- <div className="status-pages-list">
- {pages.map(page => (
- <div key={page.id} className={`status-page-item ${selectedPage?.id === page.id ? 'active' : ''}`}
- onClick={() => loadPageDetails(page.id)}>
- <strong>{page.name}</strong>
- <span className="text-muted">/{page.slug} &bull; {page.component_count} components</span>
- </div>
+ <aside className="status-pages-list" aria-label="Status pages">
+ {pages.map((page) => (
+ <button
+ key={page.id}
+ type="button"
+ className={`status-page-item ${selectedPage?.id === page.id ? 'active' : ''}`}
+ onClick={() => loadPageDetails(page)}
+ >
+ <span className="status-page-item__name">{page.name}</span>
+ <span className="status-page-item__slug">/{page.slug}</span>
+ <span className="status-page-item__meta">
+ <Globe2 size={14} />
+ {page.component_count} component{page.component_count !== 1 ? 's' : ''}
+ </span>
+ </button>
))}
- {pages.length === 0 && <div className="empty-state"><p>No status pages yet.</p></div>}
- </div>
+ {pages.length === 0 && (
+ <div className="empty-state status-pages-empty">
+ <Activity size={32} />
+ <p>No status pages yet.</p>
+ </div>
+ )}
+ </aside>
- {selectedPage && (
- <div className="status-detail-panel">
- <div className="status-detail-panel__header">
- <h2>{selectedPage.name}</h2>
- <span className="text-muted">/{selectedPage.slug}</span>
+ {selectedPage ? (
+ <section className="status-detail-panel">
+ <div className="status-detail-panel__hero">
+ <div>
+ <Badge variant={overallMeta.badge} className="status-overall-badge">
+ <OverallIcon size={15} />
+ {overallMeta.label}
+ </Badge>
+ <h2>{selectedPage.name}</h2>
+ {selectedPage.description && <p>{selectedPage.description}</p>}
+ </div>
+ <div className="status-url-card">
+ <span>Public URL</span>
+ <code>{selectedUrl}</code>
+ <div>
+ <Button size="sm" variant="outline" onClick={handleCopyUrl}>
+ <Copy size={14} />
+ Copy
+ </Button>
+ <Button size="sm" asChild>
+ <a href={selectedUrl} target="_blank" rel="noreferrer">
+ <ExternalLink size={14} />
+ Open
+ </a>
+ </Button>
+ </div>
+ </div>
+ </div>
+
+ <div className="status-detail-metrics">
+ <div>
+ <span>Components</span>
+ <strong>{components.length}</strong>
+ </div>
+ <div>
+ <span>Active incidents</span>
+ <strong>{activeIncidents.length}</strong>
+ </div>
+ <div>
+ <span>30 day uptime</span>
+ <strong>{formatUptime(
+ components.length
+ ? components.reduce((total, component) => total + (component.uptime_30d || 100), 0) / components.length
+ : 100
+ )}</strong>
+ </div>
</div>
<Tabs defaultValue="components">
<TabsList>
<TabsTrigger value="components">Components</TabsTrigger>
<TabsTrigger value="incidents">Incidents</TabsTrigger>
+ <TabsTrigger value="settings">Page</TabsTrigger>
</TabsList>
<TabsContent value="components">
<div className="status-actions-bar">
- {user?.is_admin && (
- <Button size="sm" onClick={() => setShowCreateComponent(true)}>Add Component</Button>
+ {isAdmin && (
+ <Button size="sm" onClick={() => setShowCreateComponent(true)}>
+ <Plus size={14} />
+ Add Component
+ </Button>
)}
</div>
+
<div className="components-list">
- {components.map(comp => (
- <div key={comp.id} className="component-row">
- <div className="component-row__info">
- <span className={`status-dot status-dot--${statusColors[comp.status] || 'muted'}`} />
- <div>
- <strong>{comp.name}</strong>
- <span className="text-muted"> &bull; {comp.group}</span>
- </div>
- </div>
- <div className="component-row__stats">
- <span>{comp.uptime_30d?.toFixed(2)}% uptime</span>
- {comp.last_response_time && <span>{comp.last_response_time}ms</span>}
- </div>
- <div className="component-row__actions">
- <Button size="sm" variant="outline" onClick={() => handleRunCheck(comp.id)}>Check Now</Button>
- </div>
+ {Object.entries(groupedComponents).map(([groupName, groupComponents]) => (
+ <div key={groupName} className="component-group">
+ <h3>{groupName}</h3>
+ {groupComponents.map((component) => {
+ const meta = STATUS_META[component.status] || STATUS_META.operational;
+ const Icon = meta.icon;
+ return (
+ <div key={component.id} className="component-row">
+ <div className="component-row__info">
+ <span className={`status-dot status-dot--${meta.tone}`} />
+ <div>
+ <strong>{component.name}</strong>
+ <span>{component.check_type.toUpperCase()} - {component.check_target || 'No target'}</span>
+ </div>
+ </div>
+ <div className="component-row__stats">
+ <Badge variant={meta.badge}>
+ <Icon size={14} />
+ {meta.label}
+ </Badge>
+ <span>{formatUptime(component.uptime_30d)} uptime</span>
+ <span>{component.last_response_time ? `${component.last_response_time}ms` : 'No response'}</span>
+ <span>{formatDate(component.last_check_at)}</span>
+ </div>
+ {isAdmin && (
+ <div className="component-row__actions">
+ <Button size="sm" variant="outline" onClick={() => handleRunCheck(component)}>
+ <PlayCircle size={14} />
+ Check
+ </Button>
+ <Button size="sm" variant="ghost" onClick={() => setDeleteConfirm({ type: 'component', item: component })}>
+ <Trash2 size={14} />
+ </Button>
+ </div>
+ )}
+ </div>
+ );
+ })}
</div>
))}
{components.length === 0 && <p className="text-muted">No components yet.</p>}
@@ -187,44 +460,138 @@ const StatusPages = () => {
<TabsContent value="incidents">
<div className="status-actions-bar">
- {user?.is_admin && (
- <Button size="sm" onClick={() => setShowCreateIncident(true)}>Create Incident</Button>
+ {isAdmin && (
+ <Button size="sm" onClick={() => setShowCreateIncident(true)}>
+ <Plus size={14} />
+ Create Incident
+ </Button>
)}
</div>
<div className="incidents-list">
- {incidents.map(inc => (
- <div key={inc.id} className="incident-row">
+ {incidents.map((incident) => (
+ <article key={incident.id} className={`incident-row incident-row--${incident.status}`}>
<div className="incident-row__header">
- <strong>{inc.title}</strong>
- <Badge variant={inc.status === 'resolved' ? 'success' : 'warning'}>{inc.status}</Badge>
+ <div>
+ <strong>{incident.title}</strong>
+ <span>{formatDate(incident.created_at)}</span>
+ </div>
+ <div>
+ <Badge variant={incident.status === 'resolved' ? 'success' : 'warning'}>
+ {incident.status}
+ </Badge>
+ <Badge variant={incident.impact === 'critical' ? 'destructive' : 'secondary'}>
+ {incident.impact}
+ </Badge>
+ </div>
</div>
- <span className="text-muted">Impact: {inc.impact}</span>
- {inc.body && <p>{inc.body}</p>}
- {inc.status !== 'resolved' && user?.is_admin && (
- <Button size="sm" variant="secondary" onClick={() => handleResolveIncident(inc.id)}>Resolve</Button>
+ {incident.body && <p>{incident.body}</p>}
+ {incident.updates?.length > 0 && (
+ <div className="incident-timeline">
+ {incident.updates.map((update) => (
+ <div key={update.id}>
+ <span>{formatDate(update.created_at)}</span>
+ <strong>{update.status}</strong>
+ <p>{update.body}</p>
+ </div>
+ ))}
+ </div>
)}
- </div>
+ {isAdmin && (
+ <div className="incident-row__actions">
+ {incident.status !== 'resolved' && (
+ <>
+ {INCIDENT_STATUS.filter((status) => status.value !== incident.status).map((status) => (
+ <Button
+ key={status.value}
+ size="sm"
+ variant={status.value === 'resolved' ? 'secondary' : 'outline'}
+ onClick={() => handleUpdateIncidentStatus(incident, status.value)}
+ >
+ {status.label}
+ </Button>
+ ))}
+ </>
+ )}
+ <Button size="sm" variant="ghost" onClick={() => setDeleteConfirm({ type: 'incident', item: incident })}>
+ <Trash2 size={14} />
+ </Button>
+ </div>
+ )}
+ </article>
))}
{incidents.length === 0 && <p className="text-muted">No incidents.</p>}
</div>
</TabsContent>
+
+ <TabsContent value="settings">
+ <div className="status-page-settings">
+ <div>
+ <span>Slug</span>
+ <strong>/{selectedPage.slug}</strong>
+ </div>
+ <div>
+ <span>Visibility</span>
+ <Badge variant={selectedPage.is_public ? 'success' : 'secondary'}>
+ {selectedPage.is_public ? 'Public' : 'Private'}
+ </Badge>
+ </div>
+ <div>
+ <span>Created</span>
+ <strong>{formatDate(selectedPage.created_at)}</strong>
+ </div>
+ {isAdmin && (
+ <Button variant="destructive" onClick={() => setDeleteConfirm({ type: 'page', item: selectedPage })}>
+ <Trash2 size={16} />
+ Delete Page
+ </Button>
+ )}
+ </div>
+ </TabsContent>
</Tabs>
- </div>
+ </section>
+ ) : (
+ <section className="status-detail-panel status-detail-panel--empty">
+ <Activity size={32} />
+ <p>Select a status page.</p>
+ </section>
)}
</div>
{showCreatePage && (
<div className="modal-overlay" onClick={() => setShowCreatePage(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header"><h2>Create Status Page</h2><button className="modal-close" onClick={() => setShowCreatePage(false)}>&times;</button></div>
+ <div className="modal status-modal" onClick={(e) => e.stopPropagation()}>
+ <div className="modal-header">
+ <h2>Create Status Page</h2>
+ <button className="modal-close" onClick={() => setShowCreatePage(false)}>&times;</button>
+ </div>
<div className="modal-body">
- <div className="form-group"><label>Name</label><Input value={pageForm.name} onChange={e => setPageForm({...pageForm, name: e.target.value})} /></div>
- <div className="form-group"><label>Slug (URL path)</label><Input value={pageForm.slug} onChange={e => setPageForm({...pageForm, slug: e.target.value})} placeholder="my-services" /></div>
- <div className="form-group"><label>Description</label><Textarea value={pageForm.description} onChange={e => setPageForm({...pageForm, description: e.target.value})} rows={2} /></div>
+ <div className="form-group">
+ <label>Name</label>
+ <Input value={pageForm.name} onChange={(e) => handlePageNameChange(e.target.value)} autoFocus />
+ </div>
+ <div className="form-group">
+ <label>Slug</label>
+ <Input
+ value={pageForm.slug}
+ onChange={(e) => setPageForm({ ...pageForm, slug: normalizeSlug(e.target.value) })}
+ placeholder="my-services"
+ />
+ <span className="form-help">/status/{pageForm.slug || 'my-services'}</span>
+ </div>
+ <div className="form-group">
+ <label>Description</label>
+ <Textarea
+ value={pageForm.description}
+ onChange={(e) => setPageForm({ ...pageForm, description: e.target.value })}
+ rows={3}
+ />
+ </div>
</div>
<div className="modal-footer">
<Button variant="outline" onClick={() => setShowCreatePage(false)}>Cancel</Button>
- <Button onClick={handleCreatePage} disabled={!pageForm.name || !pageForm.slug}>Create</Button>
+ <Button onClick={handleCreatePage} disabled={!pageForm.name.trim() || !pageForm.slug.trim()}>
+ Create
+ </Button>
</div>
</div>
</div>
@@ -232,18 +599,65 @@ const StatusPages = () => {
{showCreateComponent && (
<div className="modal-overlay" onClick={() => setShowCreateComponent(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header"><h2>Add Component</h2><button className="modal-close" onClick={() => setShowCreateComponent(false)}>&times;</button></div>
- <div className="modal-body">
- <div className="form-group"><label>Name</label><Input value={compForm.name} onChange={e => setCompForm({...compForm, name: e.target.value})} /></div>
- <div className="form-group"><label>Group</label><Input value={compForm.group} onChange={e => setCompForm({...compForm, group: e.target.value})} /></div>
- <div className="form-group"><label>Check Type</label><select className="form-select" value={compForm.check_type} onChange={e => setCompForm({...compForm, check_type: e.target.value})}><option value="http">HTTP</option><option value="tcp">TCP</option><option value="dns">DNS</option><option value="ping">Ping</option></select></div>
- <div className="form-group"><label>Check Target</label><Input value={compForm.check_target} onChange={e => setCompForm({...compForm, check_target: e.target.value})} placeholder="https://example.com or host:port" /></div>
- <div className="form-group"><label>Check Interval (seconds)</label><Input type="number" value={compForm.check_interval} onChange={e => setCompForm({...compForm, check_interval: parseInt(e.target.value) || 60})} /></div>
+ <div className="modal status-modal" onClick={(e) => e.stopPropagation()}>
+ <div className="modal-header">
+ <h2>Add Component</h2>
+ <button className="modal-close" onClick={() => setShowCreateComponent(false)}>&times;</button>
+ </div>
+ <div className="modal-body status-modal-grid">
+ <div className="form-group">
+ <label>Name</label>
+ <Input value={compForm.name} onChange={(e) => setCompForm({ ...compForm, name: e.target.value })} autoFocus />
+ </div>
+ <div className="form-group">
+ <label>Group</label>
+ <Input value={compForm.group} onChange={(e) => setCompForm({ ...compForm, group: e.target.value })} />
+ </div>
+ <div className="form-group">
+ <label>Check Type</label>
+ <select
+ className="form-select"
+ value={compForm.check_type}
+ onChange={(e) => setCompForm({ ...compForm, check_type: e.target.value })}
+ >
+ <option value="http">HTTP</option>
+ <option value="tcp">TCP</option>
+ <option value="dns">DNS</option>
+ <option value="ping">Ping</option>
+ </select>
+ </div>
+ <div className="form-group">
+ <label>Target</label>
+ <Input
+ value={compForm.check_target}
+ onChange={(e) => setCompForm({ ...compForm, check_target: e.target.value })}
+ placeholder={CHECK_TARGET_PLACEHOLDERS[compForm.check_type]}
+ />
+ </div>
+ <div className="form-group">
+ <label>Interval</label>
+ <Input
+ type="number"
+ min="30"
+ value={compForm.check_interval}
+ onChange={(e) => setCompForm({ ...compForm, check_interval: parseInt(e.target.value, 10) || 60 })}
+ />
+ </div>
+ <div className="form-group">
+ <label>Timeout</label>
+ <Input
+ type="number"
+ min="1"
+ value={compForm.check_timeout}
+ onChange={(e) => setCompForm({ ...compForm, check_timeout: parseInt(e.target.value, 10) || 10 })}
+ />
+ </div>
</div>
<div className="modal-footer">
<Button variant="outline" onClick={() => setShowCreateComponent(false)}>Cancel</Button>
- <Button onClick={handleCreateComponent} disabled={!compForm.name}>Add</Button>
+ <Button onClick={handleCreateComponent} disabled={!compForm.name.trim() || !compForm.check_target.trim()}>
+ Add Component
+ </Button>
</div>
</div>
</div>
@@ -251,20 +665,70 @@ const StatusPages = () => {
{showCreateIncident && (
<div className="modal-overlay" onClick={() => setShowCreateIncident(false)}>
- <div className="modal" onClick={e => e.stopPropagation()}>
- <div className="modal-header"><h2>Create Incident</h2><button className="modal-close" onClick={() => setShowCreateIncident(false)}>&times;</button></div>
+ <div className="modal status-modal" onClick={(e) => e.stopPropagation()}>
+ <div className="modal-header">
+ <h2>Create Incident</h2>
+ <button className="modal-close" onClick={() => setShowCreateIncident(false)}>&times;</button>
+ </div>
<div className="modal-body">
- <div className="form-group"><label>Title</label><Input value={incidentForm.title} onChange={e => setIncidentForm({...incidentForm, title: e.target.value})} /></div>
- <div className="form-group"><label>Impact</label><select className="form-select" value={incidentForm.impact} onChange={e => setIncidentForm({...incidentForm, impact: e.target.value})}><option value="none">None</option><option value="minor">Minor</option><option value="major">Major</option><option value="critical">Critical</option></select></div>
- <div className="form-group"><label>Description</label><Textarea value={incidentForm.body} onChange={e => setIncidentForm({...incidentForm, body: e.target.value})} rows={3} /></div>
+ <div className="form-group">
+ <label>Title</label>
+ <Input value={incidentForm.title} onChange={(e) => setIncidentForm({ ...incidentForm, title: e.target.value })} autoFocus />
+ </div>
+ <div className="status-modal-grid">
+ <div className="form-group">
+ <label>Status</label>
+ <select
+ className="form-select"
+ value={incidentForm.status}
+ onChange={(e) => setIncidentForm({ ...incidentForm, status: e.target.value })}
+ >
+ {INCIDENT_STATUS.filter((status) => status.value !== 'resolved').map((status) => (
+ <option key={status.value} value={status.value}>{status.label}</option>
+ ))}
+ </select>
+ </div>
+ <div className="form-group">
+ <label>Impact</label>
+ <select
+ className="form-select"
+ value={incidentForm.impact}
+ onChange={(e) => setIncidentForm({ ...incidentForm, impact: e.target.value })}
+ >
+ {IMPACT_OPTIONS.map((impact) => (
+ <option key={impact.value} value={impact.value}>{impact.label}</option>
+ ))}
+ </select>
+ </div>
+ </div>
+ <div className="form-group">
+ <label>Description</label>
+ <Textarea
+ value={incidentForm.body}
+ onChange={(e) => setIncidentForm({ ...incidentForm, body: e.target.value })}
+ rows={4}
+ />
+ </div>
</div>
<div className="modal-footer">
<Button variant="outline" onClick={() => setShowCreateIncident(false)}>Cancel</Button>
- <Button onClick={handleCreateIncident} disabled={!incidentForm.title}>Create</Button>
+ <Button onClick={handleCreateIncident} disabled={!incidentForm.title.trim()}>
+ Create Incident
+ </Button>
</div>
</div>
</div>
)}
+
+ <ConfirmDialog
+ isOpen={Boolean(deleteConfirm)}
+ title={`Delete ${deleteConfirm?.type || 'item'}?`}
+ message="This removes the selected record and related status data."
+ confirmText="Delete"
+ requireConfirmation={deleteConfirm?.item?.name || deleteConfirm?.item?.title}
+ onConfirm={handleConfirmDelete}
+ onCancel={() => setDeleteConfirm(null)}
+ />
</div>
);
};
diff --git a/frontend/src/styles/pages/_monitoring.scss b/frontend/src/styles/pages/_monitoring.scss
index ea41cccd..f9493c06 100644
--- a/frontend/src/styles/pages/_monitoring.scss
+++ b/frontend/src/styles/pages/_monitoring.scss
@@ -1,143 +1,394 @@
-// ============================================
-// MONITORING PAGE
-// ============================================
+// Monitoring Page
.monitoring-page {
- .monitoring-overview {
+ .monitoring-overview,
+ .monitoring-delivery-layout {
+ display: grid;
+ gap: $space-5;
+ }
+
+ .monitoring-hero {
display: flex;
- flex-direction: column;
- gap: $space-6;
+ justify-content: space-between;
+ align-items: flex-start;
+ gap: $space-5;
+ padding: $space-6;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-lg;
+ background: linear-gradient(135deg, $bg-card, $bg-elevated);
+
+ &.is-active {
+ border-color: fade($success, 35%);
+ }
+
+ h2 {
+ margin: $space-3 0 $space-2;
+ font-size: $font-size-2xl;
+ line-height: 1.1;
+ }
+
+ p {
+ margin: 0;
+ color: $text-secondary;
+ }
+
+ &__actions {
+ flex: 0 0 auto;
+ display: flex;
+ gap: $space-2;
+ }
+
+ @media (max-width: 760px) {
+ flex-direction: column;
+ }
}
- .threshold-grid {
+ .monitoring-summary-grid {
display: grid;
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
- gap: $space-4;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: $space-3;
+
+ > div {
+ padding: $space-4;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-md;
+ background: $bg-card;
+ }
+
+ span {
+ display: block;
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+ font-weight: $font-weight-semibold;
+ text-transform: uppercase;
+ }
+
+ strong {
+ display: block;
+ margin-top: $space-2;
+ font-size: $font-size-xl;
+ }
+
+ @media (max-width: 720px) {
+ grid-template-columns: 1fr;
+ }
+ }
+
+ .monitoring-panel {
+ min-width: 0;
+ padding: $space-5;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-lg;
+ background: $bg-card;
+
+ &--warning {
+ border-color: fade($warning, 35%);
+ }
}
- .threshold-item {
+ .monitoring-panel__header {
display: flex;
justify-content: space-between;
align-items: center;
- padding: $space-4;
- background: $bg-hover;
+ gap: $space-3;
+ margin-bottom: $space-4;
+
+ h3 {
+ margin: 0;
+ font-size: $font-size-lg;
+ }
+
+ > div {
+ display: flex;
+ flex-wrap: wrap;
+ gap: $space-2;
+ }
+
+ @media (max-width: 640px) {
+ align-items: flex-start;
+ flex-direction: column;
+ }
+ }
+
+ .metric-rule-grid {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: $space-3;
+
+ &--compact {
+ grid-template-columns: repeat(4, minmax(0, 1fr));
+ }
+
+ @media (max-width: 1180px) {
+ &,
+ &--compact {
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ }
+ }
+
+ @media (max-width: 720px) {
+ &,
+ &--compact {
+ grid-template-columns: 1fr;
+ }
+ }
+ }
+
+ .metric-rule-card,
+ .metric-rule-editor {
+ min-width: 0;
+ border: 1px solid $border-subtle;
border-radius: $radius-md;
+ background: $bg-elevated;
}
- .threshold-label {
- color: $text-secondary;
- font-size: $font-size-sm;
+ .metric-rule-card {
+ display: grid;
+ grid-template-columns: auto minmax(0, 1fr);
+ gap: $space-3;
+ align-items: center;
+ padding: $space-4;
+
+ > div:nth-child(2) {
+ min-width: 0;
+ display: grid;
+ gap: 4px;
+ }
+
+ span {
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+ font-weight: $font-weight-semibold;
+ text-transform: uppercase;
+ }
+
+ strong {
+ font-size: $font-size-xl;
+ line-height: 1;
+ }
+
+ [data-slot="badge"] {
+ grid-column: 1 / -1;
+ justify-self: start;
+ }
+
+ &.is-triggered {
+ border-color: fade($warning, 40%);
+ }
}
- .threshold-value {
- font-size: $font-size-lg;
- font-weight: $font-weight-semibold;
+ .metric-rule-card__icon {
+ width: 36px;
+ height: 36px;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ border-radius: $radius-md;
+ background: $accent-glow;
color: $accent-primary;
}
- .threshold-form-grid {
+ .metric-rule-editor {
display: grid;
- grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
- gap: $space-6;
+ grid-template-columns: minmax(0, 1fr) 160px auto;
+ gap: $space-4;
+ align-items: center;
+ padding: $space-4;
+
+ &.is-triggered {
+ border-color: fade($warning, 40%);
+ background: linear-gradient(135deg, $bg-elevated, fade($warning, 6%));
+ }
+
+ &__main {
+ display: flex;
+ gap: $space-3;
+ align-items: center;
+ min-width: 0;
+
+ h4 {
+ margin: 0 0 3px;
+ font-size: $font-size-base;
+ }
+
+ span {
+ color: $text-secondary;
+ font-size: $font-size-sm;
+ }
+ }
+
+ &__threshold {
+ display: grid;
+ gap: $space-2;
+ }
+
+ @media (max-width: 820px) {
+ grid-template-columns: 1fr;
+ align-items: start;
+ }
}
- .alert-list {
- display: flex;
- flex-direction: column;
- gap: $space-2;
+ .monitoring-delivery-layout {
+ grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
+
+ @media (max-width: 1000px) {
+ grid-template-columns: 1fr;
+ }
}
- .alert-item {
+ .monitoring-switch-row {
display: flex;
+ justify-content: space-between;
align-items: center;
gap: $space-4;
- padding: $space-3 $space-4;
- background: $bg-hover;
+ padding: $space-4;
+ margin-bottom: $space-4;
+ border: 1px solid $border-subtle;
border-radius: $radius-md;
+ background: $bg-elevated;
- .badge {
- flex-shrink: 0;
+ strong,
+ span {
+ display: block;
}
- .alert-message {
- flex: 1;
+ span {
+ margin-top: 3px;
+ color: $text-tertiary;
font-size: $font-size-sm;
- color: $text-primary;
}
+ }
- .alert-time {
- color: $text-tertiary;
- font-size: $font-size-xs;
- white-space: nowrap;
- }
+ .notification-channel-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
+ gap: $space-3;
}
- // Stat icon variants for monitoring
- .stat-icon {
- &.status {
- background: fade($success, 10%);
- color: $success;
- }
+ .notification-channel-tile {
+ display: grid;
+ grid-template-columns: auto minmax(0, 1fr) auto;
+ gap: $space-3;
+ align-items: center;
+ padding: $space-4;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-md;
+ background: $bg-elevated;
- &.alerts {
- background: fade($danger, 10%);
- color: $danger;
+ &.is-ready {
+ border-color: fade($success, 35%);
}
- &.interval {
- background: fade($accent-primary-raw, 10%);
+ > svg {
color: $accent-primary;
}
- &.notifications {
- background: fade(#a855f7, 10%);
- color: #a855f7;
+ strong,
+ span {
+ display: block;
}
- }
- .text-success {
- color: $success;
+ span {
+ margin-top: 3px;
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+ }
}
- .text-muted {
- color: $text-tertiary;
+ .alert-list {
+ display: flex;
+ flex-direction: column;
+ gap: $space-2;
}
- .input-group {
+ .alert-item {
display: flex;
- gap: $space-2;
+ align-items: center;
+ gap: $space-3;
+ padding: $space-3 $space-4;
+ background: $bg-elevated;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-md;
- input {
+ .alert-message {
flex: 1;
+ min-width: 0;
+ color: $text-primary;
+ font-size: $font-size-sm;
+ }
+
+ .alert-time {
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+ white-space: nowrap;
}
- .btn {
- flex-shrink: 0;
+ @media (max-width: 640px) {
+ align-items: flex-start;
+ flex-direction: column;
+
+ .alert-time {
+ white-space: normal;
+ }
}
}
- .checkbox-label {
- display: flex;
- align-items: center;
+ .monitoring-history-list {
+ display: grid;
gap: $space-2;
- cursor: pointer;
+ }
- input[type="checkbox"] {
- width: 18px;
- height: 18px;
- cursor: pointer;
+ .monitoring-history-row {
+ display: grid;
+ grid-template-columns: auto minmax(0, 1fr) auto;
+ gap: $space-4;
+ align-items: center;
+ padding: $space-4;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-md;
+ background: $bg-elevated;
+
+ > div {
+ min-width: 0;
+ display: grid;
+ gap: 4px;
+ }
+
+ strong {
+ text-transform: capitalize;
}
span {
+ color: $text-secondary;
font-size: $font-size-sm;
- color: $text-primary;
+ }
+
+ &__meta {
+ justify-items: end;
+
+ span {
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+ }
+ }
+
+ @media (max-width: 760px) {
+ grid-template-columns: 1fr;
+
+ &__meta {
+ justify-items: start;
+ }
}
}
+ .monitoring-empty {
+ min-height: 240px;
+ }
+
.form-help {
display: block;
margin-top: $space-1;
- font-size: $font-size-xs;
color: $text-tertiary;
+ font-size: $font-size-xs;
}
}
diff --git a/frontend/src/styles/pages/_status-pages.scss b/frontend/src/styles/pages/_status-pages.scss
index 9073ce53..cef0b136 100644
--- a/frontend/src/styles/pages/_status-pages.scss
+++ b/frontend/src/styles/pages/_status-pages.scss
@@ -1,13 +1,13 @@
-// Status Pages styles
+// Status Pages
.status-pages-page {
.status-layout {
display: grid;
- grid-template-columns: 280px 1fr;
- gap: $spacing-lg;
- margin-top: $spacing-lg;
+ grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
+ gap: $space-5;
+ margin-top: $space-5;
- @media (max-width: 900px) {
+ @media (max-width: 960px) {
grid-template-columns: 1fr;
}
}
@@ -15,97 +15,611 @@
.status-pages-list {
display: flex;
flex-direction: column;
- gap: $spacing-xs;
+ gap: $space-2;
+ min-width: 0;
}
.status-page-item {
- padding: $spacing-md;
- background: $card-bg;
- border: 1px solid $border-color;
+ width: 100%;
+ padding: $space-4;
+ background: $bg-card;
+ border: 1px solid $border-subtle;
border-radius: $radius-md;
+ color: $text-primary;
cursor: pointer;
- display: flex;
- flex-direction: column;
- gap: 2px;
- transition: border-color 0.15s;
+ display: grid;
+ gap: $space-2;
+ text-align: left;
+ transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
+
+ &:hover,
+ &.active {
+ background: $bg-hover;
+ border-color: $accent-primary;
+ }
+
+ &.active {
+ box-shadow: inset 3px 0 0 $accent-primary;
+ }
+
+ &__name {
+ font-size: $font-size-sm;
+ font-weight: $font-weight-semibold;
+ }
+
+ &__slug {
+ color: $text-tertiary;
+ font-family: $font-mono;
+ font-size: $font-size-xs;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ &__meta {
+ display: inline-flex;
+ align-items: center;
+ gap: $space-1;
+ color: $text-secondary;
+ font-size: $font-size-xs;
+ }
+ }
- &:hover, &.active { border-color: $primary-color; }
+ .status-pages-empty {
+ min-height: 160px;
}
.status-detail-panel {
- background: $card-bg;
- border: 1px solid $border-color;
+ min-width: 0;
+ background: $bg-card;
+ border: 1px solid $border-subtle;
border-radius: $radius-lg;
- padding: $spacing-lg;
+ padding: $space-5;
- &__header {
+ &--empty {
+ min-height: 320px;
+ display: grid;
+ place-items: center;
+ align-content: center;
+ gap: $space-3;
+ color: $text-tertiary;
+ }
+ }
+
+ .status-detail-panel__hero {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
+ gap: $space-5;
+ align-items: stretch;
+ margin-bottom: $space-5;
+
+ h2 {
+ margin: $space-3 0 $space-2;
+ font-size: $font-size-2xl;
+ line-height: 1.15;
+ }
+
+ p {
+ margin: 0;
+ color: $text-secondary;
+ max-width: 760px;
+ }
+
+ @media (max-width: 1100px) {
+ grid-template-columns: 1fr;
+ }
+ }
+
+ .status-overall-badge {
+ width: max-content;
+ }
+
+ .status-url-card {
+ display: grid;
+ gap: $space-3;
+ padding: $space-4;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-md;
+ background: $bg-hover;
+
+ > span {
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+ font-weight: $font-weight-semibold;
+ text-transform: uppercase;
+ }
+
+ code {
+ min-width: 0;
+ overflow-wrap: anywhere;
+ color: $text-primary;
+ font-family: $font-mono;
+ font-size: $font-size-sm;
+ line-height: 1.4;
+ }
+
+ > div {
display: flex;
- align-items: baseline;
- gap: $spacing-sm;
- margin-bottom: $spacing-md;
- h2 { margin: 0; }
+ flex-wrap: wrap;
+ gap: $space-2;
+ }
+ }
+
+ .status-detail-metrics {
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: $space-3;
+ margin-bottom: $space-5;
+
+ > div {
+ padding: $space-4;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-md;
+ background: $bg-elevated;
+ }
+
+ span {
+ display: block;
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+ font-weight: $font-weight-semibold;
+ text-transform: uppercase;
+ }
+
+ strong {
+ display: block;
+ margin-top: $space-2;
+ font-size: $font-size-xl;
+ line-height: 1;
+ }
+
+ @media (max-width: 720px) {
+ grid-template-columns: 1fr;
}
}
.status-actions-bar {
display: flex;
justify-content: flex-end;
- margin: $spacing-md 0;
+ margin: $space-4 0;
}
- .components-list {
- display: flex;
- flex-direction: column;
- gap: $spacing-xs;
+ .components-list,
+ .incidents-list {
+ display: grid;
+ gap: $space-4;
+ }
+
+ .component-group {
+ display: grid;
+ gap: $space-2;
+
+ h3 {
+ margin: 0;
+ color: $text-secondary;
+ font-size: $font-size-sm;
+ font-weight: $font-weight-semibold;
+ }
}
.component-row {
- display: flex;
- justify-content: space-between;
+ display: grid;
+ grid-template-columns: minmax(220px, 1fr) minmax(260px, auto) auto;
+ gap: $space-4;
align-items: center;
- padding: $spacing-md;
- border: 1px solid $border-color;
+ padding: $space-4;
+ border: 1px solid $border-subtle;
border-radius: $radius-md;
+ background: $bg-elevated;
&__info {
+ min-width: 0;
display: flex;
align-items: center;
- gap: $spacing-sm;
+ gap: $space-3;
+
+ > div {
+ min-width: 0;
+ display: grid;
+ gap: 3px;
+ }
+
+ strong,
+ span {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ span {
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+ }
}
&__stats {
display: flex;
- gap: $spacing-md;
- font-size: 0.85rem;
- color: $text-muted;
+ flex-wrap: wrap;
+ align-items: center;
+ justify-content: flex-end;
+ gap: $space-2;
+ color: $text-secondary;
+ font-size: $font-size-xs;
}
&__actions {
display: flex;
- gap: $spacing-xs;
+ justify-content: flex-end;
+ gap: $space-2;
+ }
+
+ @media (max-width: 1180px) {
+ grid-template-columns: 1fr;
+
+ &__stats,
+ &__actions {
+ justify-content: flex-start;
+ }
}
}
- .incidents-list {
- display: flex;
- flex-direction: column;
- gap: $spacing-md;
+ .status-dot {
+ width: 10px;
+ height: 10px;
+ border-radius: $radius-full;
+ flex: 0 0 auto;
+
+ &--success {
+ background: $success;
+ box-shadow: 0 0 0 4px $success-bg;
+ }
+
+ &--warning {
+ background: $warning;
+ box-shadow: 0 0 0 4px $warning-bg;
+ }
+
+ &--danger {
+ background: $danger;
+ box-shadow: 0 0 0 4px $danger-bg;
+ }
+
+ &--info {
+ background: $info;
+ box-shadow: 0 0 0 4px $info-bg;
+ }
}
.incident-row {
- padding: $spacing-md;
- border: 1px solid $border-color;
+ display: grid;
+ gap: $space-3;
+ padding: $space-4;
+ border: 1px solid $border-subtle;
+ border-left-width: 3px;
border-radius: $radius-md;
- display: flex;
- flex-direction: column;
- gap: $spacing-xs;
+ background: $bg-elevated;
+
+ &--resolved {
+ border-left-color: $success;
+ }
+
+ &--investigating,
+ &--identified {
+ border-left-color: $warning;
+ }
+
+ &--monitoring {
+ border-left-color: $info;
+ }
&__header {
display: flex;
justify-content: space-between;
+ gap: $space-3;
+
+ > div {
+ min-width: 0;
+ }
+
+ strong {
+ display: block;
+ margin-bottom: 3px;
+ }
+
+ span {
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+ }
+
+ > div:last-child {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: flex-end;
+ gap: $space-2;
+ }
+ }
+
+ p {
+ margin: 0;
+ color: $text-secondary;
+ line-height: 1.5;
+ }
+
+ &__actions {
+ display: flex;
+ flex-wrap: wrap;
+ gap: $space-2;
+ }
+ }
+
+ .incident-timeline {
+ display: grid;
+ gap: $space-2;
+ padding-left: $space-3;
+ border-left: 1px solid $border-subtle;
+
+ > div {
+ display: grid;
+ gap: 2px;
+ }
+
+ span {
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+ }
+
+ strong {
+ color: $text-secondary;
+ font-size: $font-size-xs;
+ text-transform: uppercase;
+ }
+ }
+
+ .status-page-settings {
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
+ gap: $space-3;
+ align-items: center;
+ margin-top: $space-4;
+
+ > div {
+ min-height: 72px;
+ padding: $space-4;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-md;
+ background: $bg-elevated;
+ }
+
+ span {
+ display: block;
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+ font-weight: $font-weight-semibold;
+ text-transform: uppercase;
+ }
+
+ strong {
+ display: block;
+ margin-top: $space-2;
+ overflow-wrap: anywhere;
+ }
+
+ @media (max-width: 960px) {
+ grid-template-columns: 1fr;
+ }
+ }
+
+ .status-modal {
+ max-width: 640px;
+ }
+
+ .status-modal-grid {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: $space-4;
+
+ @media (max-width: 640px) {
+ grid-template-columns: 1fr;
+ }
+ }
+}
+
+.public-status-page {
+ min-height: 100vh;
+ padding: clamp(24px, 4vw, 56px);
+ background:
+ linear-gradient(180deg, fade($accent-primary-raw, 8%) 0%, transparent 280px),
+ $bg-body;
+ color: $text-primary;
+
+ .public-status-hero,
+ .public-status-summary,
+ .public-status-section,
+ .public-status-shell {
+ width: min(1040px, 100%);
+ margin: 0 auto;
+ }
+
+ .public-status-hero {
+ display: flex;
+ justify-content: space-between;
+ align-items: flex-start;
+ gap: $space-5;
+ padding: $space-6;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-lg;
+ background: $bg-card;
+
+ h1 {
+ margin: 0;
+ font-size: clamp(2rem, 5vw, 3.5rem);
+ line-height: 1;
+ }
+
+ p {
+ margin: $space-3 0 0;
+ color: $text-secondary;
+ max-width: 720px;
+ }
+
+ @media (max-width: 700px) {
+ flex-direction: column;
+ }
+ }
+
+ .public-status-badge {
+ min-height: 34px;
+ padding: 8px $space-3;
+ }
+
+ .public-status-summary {
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: $space-3;
+ margin-top: $space-4;
+
+ > div {
+ padding: $space-4;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-md;
+ background: $bg-card;
+ }
+
+ span {
+ display: block;
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+ font-weight: $font-weight-semibold;
+ text-transform: uppercase;
+ }
+
+ strong {
+ display: block;
+ margin-top: $space-2;
+ font-size: $font-size-xl;
+ }
+
+ @media (max-width: 700px) {
+ grid-template-columns: 1fr;
+ }
+ }
+
+ .public-status-section {
+ margin-top: $space-5;
+
+ > header {
+ margin-bottom: $space-3;
+ }
+
+ h2,
+ h3 {
+ margin: 0;
+ }
+ }
+
+ .public-component-groups,
+ .public-component-list,
+ .public-incident-list {
+ display: grid;
+ gap: $space-3;
+ }
+
+ .public-component-group {
+ display: grid;
+ gap: $space-2;
+
+ > h3 {
+ color: $text-secondary;
+ font-size: $font-size-sm;
+ }
+ }
+
+ .public-component-row,
+ .public-incident,
+ .public-status-empty,
+ .public-status-shell {
+ padding: $space-4;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-md;
+ background: $bg-card;
+ }
+
+ .public-component-row {
+ display: flex;
+ justify-content: space-between;
+ gap: $space-4;
+ align-items: center;
+
+ > div:first-child {
+ display: flex;
align-items: center;
+ gap: $space-3;
+ min-width: 0;
+
+ span {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+ }
+
+ &__meta {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: flex-end;
+ gap: $space-2;
+ color: $text-secondary;
+ font-size: $font-size-xs;
+ }
+
+ @media (max-width: 760px) {
+ align-items: flex-start;
+ flex-direction: column;
+
+ &__meta {
+ justify-content: flex-start;
+ }
+ }
+ }
+
+ .public-incident {
+ display: grid;
+ gap: $space-3;
+
+ &--active {
+ border-left: 3px solid $warning;
+ }
+
+ > div {
+ display: flex;
+ justify-content: space-between;
+ gap: $space-3;
+ }
+
+ h3 {
+ font-size: $font-size-base;
}
- p { margin: 0; font-size: 0.9rem; color: $text-secondary; }
+ span {
+ display: block;
+ margin-top: 3px;
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+ }
+
+ p {
+ margin: 0;
+ color: $text-secondary;
+ }
+ }
+
+ .public-status-empty,
+ .public-status-shell--empty {
+ display: grid;
+ place-items: center;
+ gap: $space-2;
+ min-height: 180px;
+ color: $text-tertiary;
+ text-align: center;
}
}