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.

feat(ui): restyle the Cron Jobs body to the new look

Juan Denisb38053d448ef
diff --git a/frontend/src/pages/CronJobs.jsx b/frontend/src/pages/CronJobs.jsx
index 75432b5a..ad8f90d5 100644
--- a/frontend/src/pages/CronJobs.jsx
+++ b/frontend/src/pages/CronJobs.jsx
@@ -3,15 +3,17 @@ import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
import { useConfirm } from '../hooks/useConfirm';
import { ConfirmDialog } from '../components/ConfirmDialog';
-import { StatCard, StatsGrid } from '../components/StatCard';
import EmptyState from '../components/EmptyState';
-import { Clock, FileText, CheckCircle, Monitor } from 'lucide-react';
+import {
+ Clock, CheckCircle, Monitor, Activity, Plus, RefreshCw,
+ Play, Pause, Pencil, Trash2, Search,
+} from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Textarea } from '@/components/ui/textarea';
-import { Badge } from '@/components/ui/badge';
import { Checkbox } from '@/components/ui/checkbox';
+import { MetricCard, Pill, SegControl } from '@/components/ds';
const CronJobs = () => {
const toast = useToast();
@@ -22,6 +24,10 @@ const CronJobs = () => {
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
+ // List filters (client-side, over already-loaded jobs)
+ const [filter, setFilter] = useState('all');
+ const [query, setQuery] = useState('');
+
// Modal states
const [showJobModal, setShowJobModal] = useState(false);
const [editingJob, setEditingJob] = useState(null);
@@ -188,6 +194,21 @@ const CronJobs = () => {
return descriptions[schedule] || schedule;
};
+ const enabledCount = jobs.filter(j => j.enabled).length;
+ const disabledCount = jobs.length - enabledCount;
+
+ const serviceSub = status?.type === 'cron'
+ ? (status?.running ? 'daemon running' : 'daemon stopped')
+ : (status?.type === 'serverkit_scheduler' ? 'internal scheduler' : null);
+
+ const q = query.trim().toLowerCase();
+ const shownJobs = jobs.filter(job => (
+ (filter === 'all' || (filter === 'enabled' ? job.enabled : !job.enabled))
+ && (!q
+ || (job.name || '').toLowerCase().includes(q)
+ || (job.command || '').toLowerCase().includes(q))
+ ));
+
if (loading) {
return <EmptyState loading size="lg" title="Loading cron jobs..." />;
}
@@ -201,18 +222,11 @@ const CronJobs = () => {
</div>
<div className="page-header-actions">
<Button variant="outline" onClick={loadData}>
- <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="2">
- <polyline points="23 4 23 10 17 10"/>
- <polyline points="1 20 1 14 7 14"/>
- <path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/>
- </svg>
+ <RefreshCw size={15} />
Refresh
</Button>
<Button onClick={openCreateModal}>
- <svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="2">
- <line x1="12" y1="5" x2="12" y2="19"/>
- <line x1="5" y1="12" x2="19" y2="12"/>
- </svg>
+ <Plus size={15} />
Create Job
</Button>
</div>
@@ -225,126 +239,158 @@ const CronJobs = () => {
</div>
)}
- {/* Status Cards */}
- <StatsGrid>
- <StatCard icon={Clock} iconVariant="cron" label="Cron Service" value={status?.available ? 'Available' : 'Not Available'} />
- <StatCard icon={FileText} iconVariant="jobs" label="Total Jobs" value={jobs.length} />
- <StatCard icon={CheckCircle} iconVariant="active" label="Active Jobs" value={jobs.filter(j => j.enabled).length} />
- <StatCard icon={Monitor} iconVariant="platform" label="Platform" value={status?.platform || 'Unknown'} />
- </StatsGrid>
-
- {/* Jobs List */}
- <div className="card">
- <div className="card-header">
- <h3>Scheduled Jobs</h3>
- </div>
- <div className="card-body">
- {jobs.length === 0 ? (
- <EmptyState
- icon={Clock}
- title="No Cron Jobs"
- description="No scheduled jobs found. Create your first cron job to automate tasks."
- action={<Button onClick={openCreateModal}>Create Job</Button>}
- />
- ) : (
- <div className="cron-list">
- {jobs.map((job) => (
- <div
- key={job.id}
- className={`cron-item ${!job.enabled ? 'disabled' : ''}`}
- onClick={() => openEditModal(job)}
- >
- <div className="cron-item-info">
- <div className="cron-item-icon">
- <svg viewBox="0 0 24 24" width="20" height="20" stroke="currentColor" fill="none" strokeWidth="2">
- <circle cx="12" cy="12" r="10"/>
- <polyline points="12 6 12 12 16 14"/>
- </svg>
- </div>
- <div className="cron-item-details">
- <h3>{job.name || 'Unnamed Job'}</h3>
- <div className="cron-item-meta">
- <span className="mono" title={job.schedule}>
- {getScheduleDescription(job.schedule)}
- </span>
- {job.description && (
- <span className="description">{job.description}</span>
- )}
- </div>
- <div className="cron-item-command">
- <code>{job.command}</code>
- </div>
- </div>
- </div>
+ {/* KPI strip */}
+ <div className="cron-kpis">
+ <MetricCard tone="accent" icon={<Clock size={16} />} value={jobs.length} label="Cron jobs">
+ <div className="sk-kpi__sub"><span>{enabledCount} enabled</span></div>
+ </MetricCard>
+ <MetricCard tone="green" icon={<CheckCircle size={16} />} value={enabledCount} label="Active jobs">
+ {disabledCount > 0 && (
+ <div className="sk-kpi__sub"><span>{disabledCount} disabled</span></div>
+ )}
+ </MetricCard>
+ <MetricCard
+ tone={status?.available ? 'green' : 'amber'}
+ icon={<Activity size={16} />}
+ value={status?.available ? 'Available' : 'Not Available'}
+ label="Cron service"
+ >
+ {serviceSub && (
+ <div className="sk-kpi__sub"><span>{serviceSub}</span></div>
+ )}
+ </MetricCard>
+ <MetricCard tone="cyan" icon={<Monitor size={16} />} value={status?.platform || 'Unknown'} label="Platform" />
+ </div>
- <div className="cron-item-status">
- <Badge variant={job.enabled ? 'success' : 'secondary'}>
- {job.enabled ? 'Active' : 'Disabled'}
- </Badge>
- </div>
+ {/* Jobs list */}
+ {jobs.length === 0 ? (
+ <EmptyState
+ icon={Clock}
+ title="No Cron Jobs"
+ description="No scheduled jobs found. Create your first cron job to automate tasks."
+ action={<Button onClick={openCreateModal}>Create Job</Button>}
+ />
+ ) : (
+ <>
+ <div className="cron-listhead">
+ <h2>Scheduled jobs</h2>
+ <div className="cron-search">
+ <Search size={15} />
+ <input
+ type="text"
+ placeholder="Search jobs or commands…"
+ value={query}
+ onChange={(e) => setQuery(e.target.value)}
+ />
+ </div>
+ <SegControl
+ value={filter}
+ onChange={setFilter}
+ options={[
+ { value: 'all', label: 'All' },
+ { value: 'enabled', label: 'Enabled' },
+ { value: 'disabled', label: 'Disabled' },
+ ]}
+ />
+ </div>
- <div className="cron-item-actions" onClick={e => e.stopPropagation()}>
- <Button
- variant="outline"
- size="sm"
- onClick={() => handleRunJob(job.id)}
- disabled={runningJobId === job.id}
- title="Run now"
- >
- {runningJobId === job.id ? (
- <span className="spinner-inline"></span>
- ) : (
- <svg viewBox="0 0 24 24" width="14" height="14">
- <polygon points="5 3 19 12 5 21 5 3"/>
- </svg>
- )}
- </Button>
- <Button
- variant="outline"
- size="sm"
- onClick={() => openEditModal(job)}
- title="Edit"
- >
- <svg viewBox="0 0 24 24" width="14" height="14">
- <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
- <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
- </svg>
- </Button>
- <Button
- variant="outline"
- size="sm"
- onClick={() => handleToggleJob(job.id, job.enabled)}
- title={job.enabled ? 'Disable' : 'Enable'}
- >
- {job.enabled ? (
- <svg viewBox="0 0 24 24" width="14" height="14">
- <rect x="6" y="4" width="4" height="16"/>
- <rect x="14" y="4" width="4" height="16"/>
- </svg>
- ) : (
- <svg viewBox="0 0 24 24" width="14" height="14">
- <polygon points="5 3 19 12 5 21 5 3"/>
- </svg>
- )}
- </Button>
- <Button
- variant="destructive"
- size="sm"
- onClick={() => handleDeleteJob(job.id)}
- title="Delete"
- >
- <svg viewBox="0 0 24 24" width="14" height="14">
- <polyline points="3 6 5 6 21 6"/>
- <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
- </svg>
- </Button>
- </div>
- </div>
- ))}
+ {shownJobs.length === 0 ? (
+ <div className="cron-empty">No jobs match the current filter.</div>
+ ) : (
+ <div className="cron-card">
+ <table className="sk-dtable cron-table">
+ <thead>
+ <tr>
+ <th>Job</th>
+ <th>Schedule</th>
+ <th>Status</th>
+ <th aria-label="Actions" />
+ </tr>
+ </thead>
+ <tbody>
+ {shownJobs.map((job) => {
+ const readable = getScheduleDescription(job.schedule);
+ return (
+ <tr
+ key={job.id}
+ className={`is-clickable${job.enabled ? '' : ' is-disabled'}`}
+ onClick={() => openEditModal(job)}
+ >
+ <td>
+ <div className="sk-cell-name">
+ <span className="cron-ico"><Clock size={15} /></span>
+ <div className="cron-jobcell">
+ <div className="cron-jobcell__name">{job.name || 'Unnamed Job'}</div>
+ {job.description && (
+ <div className="cron-jobcell__desc">{job.description}</div>
+ )}
+ <div className="sk-cell-sub cron-jobcell__cmd" title={job.command}>
+ {job.command}
+ </div>
+ </div>
+ </div>
+ </td>
+ <td>
+ <span className="cron-sched"><Clock size={11} />{job.schedule}</span>
+ {readable !== job.schedule && (
+ <div className="cron-sched-readable">{readable}</div>
+ )}
+ </td>
+ <td>
+ <Pill kind={job.enabled ? 'green' : 'gray'}>
+ {job.enabled ? 'Enabled' : 'Disabled'}
+ </Pill>
+ </td>
+ <td onClick={e => e.stopPropagation()}>
+ <div className="cron-actions">
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => handleRunJob(job.id)}
+ disabled={runningJobId === job.id}
+ title="Run now"
+ >
+ {runningJobId === job.id ? (
+ <span className="spinner-inline"></span>
+ ) : (
+ <Play size={14} />
+ )}
+ </Button>
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => openEditModal(job)}
+ title="Edit"
+ >
+ <Pencil size={14} />
+ </Button>
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => handleToggleJob(job.id, job.enabled)}
+ title={job.enabled ? 'Disable' : 'Enable'}
+ >
+ {job.enabled ? <Pause size={14} /> : <Play size={14} />}
+ </Button>
+ <Button
+ variant="destructive"
+ size="sm"
+ onClick={() => handleDeleteJob(job.id)}
+ title="Delete"
+ >
+ <Trash2 size={14} />
+ </Button>
+ </div>
+ </td>
+ </tr>
+ );
+ })}
+ </tbody>
+ </table>
</div>
)}
- </div>
- </div>
+ </>
+ )}
{/* Create/Edit Job Modal */}
{showJobModal && (
@@ -459,9 +505,9 @@ const CronJobs = () => {
<div className="run-output">
<div className="run-output-exit">
<span className="run-output-label">Exit Code</span>
- <Badge variant={runOutput.exitCode === 0 ? 'success' : 'destructive'}>
+ <Pill kind={runOutput.exitCode === 0 ? 'green' : 'red'}>
{runOutput.exitCode}
- </Badge>
+ </Pill>
</div>
{runOutput.stdout && (
<div className="run-output-section">
diff --git a/frontend/src/styles/pages/_cron.scss b/frontend/src/styles/pages/_cron.scss
index 5a1dc037..dab41474 100644
--- a/frontend/src/styles/pages/_cron.scss
+++ b/frontend/src/styles/pages/_cron.scss
@@ -1,239 +1,260 @@
// ============================================
-// CRON JOBS PAGE
+// CRON JOBS PAGE (redesign — infra console look)
// ============================================
.cron-page {
- .page-header {
- margin-bottom: $space-6;
-
- .page-header-content {
- h1 {
- font-size: $font-size-2xl;
- font-weight: $font-weight-semibold;
- margin: 0 0 $space-1 0;
- }
- .page-description {
- color: $text-secondary;
- margin: 0;
- }
- }
- }
-
- // Global SVG rule for buttons
- .btn svg {
- stroke: currentColor;
- fill: none;
- stroke-width: 2;
- stroke-linecap: round;
- stroke-linejoin: round;
- }
-}
+ // ── KPI strip ───────────────────────────────────────────
+ .cron-kpis {
+ display: grid;
+ grid-template-columns: repeat(4, 1fr);
+ gap: $space-4;
+ margin-bottom: $space-5;
-// Stats icons
-.stat-icon {
- &.cron {
- background: fade($accent-primary-raw, 10%);
- color: $accent-primary;
+ @media (max-width: $breakpoint-lg) { grid-template-columns: repeat(2, 1fr); }
+ @media (max-width: $breakpoint-sm) { grid-template-columns: 1fr; }
}
- &.jobs {
- background: fade($color-docker, 10%);
- color: $color-docker;
- }
+ // ── list head: eyebrow + search + segmented filter ──────
+ .cron-listhead {
+ display: flex;
+ align-items: center;
+ gap: $space-3;
+ margin-bottom: $space-3;
+
+ h2 {
+ flex: 1;
+ min-width: 0;
+ margin: 0;
+ font-family: var(--mono);
+ font-size: 10.5px;
+ font-weight: $font-weight-semibold;
+ letter-spacing: 0.08em;
+ text-transform: uppercase;
+ color: var(--text-faint);
+ }
- &.active {
- background: fade($success, 10%);
- color: $success;
- }
+ @media (max-width: $breakpoint-md) {
+ flex-wrap: wrap;
- &.platform {
- background: fade($warning, 10%);
- color: $warning;
+ h2 { flex-basis: 100%; }
+ .cron-search { flex: 1; width: auto; }
+ }
}
-}
-.cron-list {
- @include flex-column-gap($space-3);
-}
+ .cron-search {
+ display: flex;
+ align-items: center;
+ gap: $space-2;
+ width: 240px;
+ height: 34px;
+ padding: 0 $space-3;
+ background: var(--surface);
+ border: 1px solid var(--border);
+ border-radius: $radius-lg;
+ @include transition(border-color);
-.cron-item {
- @include list-item-base();
- transition: opacity 0.2s ease, background-color 0.15s ease;
- cursor: pointer;
+ &:focus-within { border-color: var(--accent); }
- &:hover {
- background: $bg-hover;
- }
+ svg {
+ color: var(--text-faint);
+ flex-shrink: 0;
+ }
- &.disabled {
- opacity: 0.6;
+ input {
+ flex: 1;
+ min-width: 0;
+ background: none;
+ border: none;
+ outline: none;
+ color: var(--text);
+ font-size: 13px;
- .cron-item-icon {
- color: $text-tertiary;
+ &::placeholder { color: var(--text-faint); }
}
}
-}
-
-.cron-item-info {
- @include flex-start();
- gap: $space-4;
- flex: 1;
- min-width: 0;
-}
-
-.cron-item-icon {
- @include icon-box();
- background: $bg-hover;
- border-radius: $radius-lg;
- color: $accent-primary;
-}
-.cron-item-details {
- min-width: 0;
- flex: 1;
+ // ── jobs table ──────────────────────────────────────────
+ .cron-card {
+ background: var(--surface);
+ border: 1px solid var(--border-soft);
+ border-radius: var(--radius);
+ overflow: hidden;
+ }
- h3 {
- font-size: $font-size-base;
- font-weight: $font-weight-semibold;
- color: $text-primary;
- margin-bottom: $space-1;
- @include truncate();
+ .cron-empty {
+ padding: $space-10;
+ text-align: center;
+ color: var(--text-faint);
+ font-size: 13px;
+ background: var(--surface);
+ border: 1px solid var(--border-soft);
+ border-radius: var(--radius);
}
-}
-.cron-item-meta {
- @include flex-start();
- gap: $space-3;
- font-size: $font-size-sm;
- color: $text-tertiary;
- flex-wrap: wrap;
- margin-bottom: $space-2;
+ .cron-table {
+ // Schedule / Status fixed; actions column shrinks to fit
+ th:nth-child(2) { width: 200px; }
+ th:nth-child(3) { width: 110px; }
+ th:last-child { width: 1%; }
+ td:last-child { white-space: nowrap; }
- .mono {
- @include mono-text();
- background: $bg-hover;
- padding: $space-1 - 2 $space-2 - 2;
- border-radius: $radius-sm;
- }
+ tbody tr.is-disabled {
+ opacity: 0.55;
- .description {
- color: $text-secondary;
+ .cron-ico {
+ background: var(--surface-3);
+ color: var(--text-faint);
+ }
+ }
}
-}
-.cron-item-command {
- code {
- display: inline-block;
- max-width: 100%;
- font-family: $font-mono;
- font-size: $font-size-xs;
- color: $text-secondary;
- background: $bg-hover;
- padding: $space-1 $space-2;
- border-radius: $radius-sm;
- @include truncate();
+ // job cell: accent icon tile + name / description / mono command
+ .cron-ico {
+ width: 30px;
+ height: 30px;
+ border-radius: 8px;
+ display: grid;
+ place-items: center;
+ flex-shrink: 0;
+ background: var(--accent-bg);
+ color: var(--accent-bright);
}
-}
-.cron-item-status {
- flex-shrink: 0;
- margin-right: $space-3;
-}
+ .cron-jobcell {
+ min-width: 0;
-.cron-item-actions {
- display: flex;
- gap: $space-2;
- flex-shrink: 0;
+ &__desc {
+ margin-top: 2px;
+ font-size: 12px;
+ font-weight: $font-weight-normal;
+ color: var(--text-dim);
+ }
+
+ &__cmd {
+ max-width: 460px;
+ font-weight: $font-weight-normal;
+ @include truncate();
+ }
+ }
- .btn {
- padding: $space-2;
+ // schedule expression chip + readable hint
+ .cron-sched {
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ padding: 2px 8px;
+ font-family: var(--mono);
+ font-size: 11.5px;
+ color: var(--text-dim);
+ background: var(--surface-2);
+ border: 1px solid var(--border);
+ border-radius: 6px;
+ white-space: nowrap;
svg {
- stroke: currentColor;
- stroke-width: 2;
- fill: none;
+ color: var(--text-faint);
+ flex-shrink: 0;
}
}
- .btn-warning {
- background: fade($warning, 10%);
- color: $warning;
- border: 1px solid fade($warning, 20%);
+ .cron-sched-readable {
+ margin-top: 3px;
+ font-size: 11px;
+ color: var(--text-faint);
+ }
- &:hover {
- background: fade($warning, 20%);
- }
+ .cron-actions {
+ display: flex;
+ justify-content: flex-end;
+ gap: $space-1;
}
- .btn-success {
- background: fade($success, 10%);
- color: $success;
- border: 1px solid fade($success, 20%);
+ @media (max-width: $breakpoint-md) {
+ .cron-card { overflow-x: auto; }
+ .cron-table { min-width: 640px; }
+ }
- &:hover {
- background: fade($success, 20%);
+ // ── create/edit modal (field labels → mono eyebrows) ────
+ .modal {
+ .form-group > label:not(.checkbox-label) {
+ font-family: var(--mono);
+ font-size: 10.5px;
+ font-weight: $font-weight-semibold;
+ letter-spacing: 0.08em;
+ text-transform: uppercase;
+ color: var(--text-faint);
+ }
+
+ .form-help {
+ display: block;
+ margin-top: $space-2;
+ font-family: var(--mono);
+ font-size: 11px;
+ color: var(--text-faint);
}
}
-}
-// Run output display
-.run-output {
- display: flex;
- flex-direction: column;
- gap: $space-4;
-}
+ // ── run-output modal ────────────────────────────────────
+ .run-output {
+ display: flex;
+ flex-direction: column;
+ gap: $space-4;
+ }
-.run-output-exit {
- display: flex;
- align-items: center;
- gap: $space-3;
-}
+ .run-output-exit {
+ display: flex;
+ align-items: center;
+ gap: $space-3;
+ }
-.run-output-label {
- font-size: $font-size-sm;
- font-weight: $font-weight-semibold;
- color: $text-secondary;
- text-transform: uppercase;
- letter-spacing: 0.05em;
-}
+ .run-output-label {
+ font-family: var(--mono);
+ font-size: 10.5px;
+ font-weight: $font-weight-semibold;
+ letter-spacing: 0.08em;
+ text-transform: uppercase;
+ color: var(--text-faint);
+ }
-.run-output-section {
- display: flex;
- flex-direction: column;
- gap: $space-2;
-}
+ .run-output-section {
+ display: flex;
+ flex-direction: column;
+ gap: $space-2;
+ }
-.run-output-pre {
- font-family: $font-mono;
- font-size: $font-size-xs;
- background: $bg-hover;
- color: $text-primary;
- padding: $space-3;
- border-radius: $radius-md;
- border: 1px solid $border-subtle;
- max-height: 300px;
- overflow: auto;
- white-space: pre-wrap;
- word-break: break-all;
- margin: 0;
-
- &--error {
- color: $danger;
- border-color: fade($danger, 20%);
- background: fade($danger, 5%);
+ .run-output-pre {
+ margin: 0;
+ padding: $space-3 $space-4;
+ font-family: var(--mono);
+ font-size: 12px;
+ line-height: 1.62;
+ background: var(--bg-code);
+ color: var(--text-code);
+ border: 1px solid var(--border);
+ border-radius: var(--radius-sm);
+ max-height: 300px;
+ overflow: auto;
+ white-space: pre-wrap;
+ word-break: break-all;
+ @include custom-scrollbar();
+
+ &--error {
+ color: var(--red);
+ border-color: rgba(251, 111, 111, 0.28);
+ }
}
-}
-// Spinner inline for running jobs
-.spinner-inline {
- display: inline-block;
- width: 14px;
- height: 14px;
- border: 2px solid $border-subtle;
- border-top-color: $accent-primary;
- border-radius: 50%;
- animation: spin 0.8s linear infinite;
+ // spinner inside the run-now button
+ .spinner-inline {
+ display: inline-block;
+ width: 14px;
+ height: 14px;
+ border: 2px solid var(--border-strong);
+ border-top-color: var(--accent);
+ border-radius: 50%;
+ animation: spin 0.8s linear infinite;
+ }
}
@keyframes spin {