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.

Add cron job editing and tabbed route support

Juan Denis7aa7642586c8
diff --git a/backend/app/api/cron.py b/backend/app/api/cron.py
index 2e827b36..94b361a7 100644
--- a/backend/app/api/cron.py
+++ b/backend/app/api/cron.py
@@ -57,6 +57,25 @@ def create_job():
return jsonify(result), 400
+@cron_bp.route('/jobs/<job_id>', methods=['PUT'])
+@admin_required
+def update_job(job_id):
+ """Update a cron job."""
+ data = request.get_json()
+
+ result = CronService.update_job(
+ job_id=job_id,
+ name=data.get('name'),
+ command=data.get('command'),
+ schedule=data.get('schedule'),
+ description=data.get('description')
+ )
+
+ if result.get('success'):
+ return jsonify(result)
+ return jsonify(result), 400
+
+
@cron_bp.route('/jobs/<job_id>', methods=['DELETE'])
@admin_required
def delete_job(job_id):
diff --git a/backend/app/services/cron_service.py b/backend/app/services/cron_service.py
index 875569c7..289210f1 100644
--- a/backend/app/services/cron_service.py
+++ b/backend/app/services/cron_service.py
@@ -499,10 +499,82 @@ class CronService:
"""Get available schedule presets."""
return {
'success': True,
- 'presets': [
- {'name': name, 'schedule': schedule, 'description': cls._describe_schedule(schedule)}
- for name, schedule in cls.PRESETS.items()
- ]
+ 'presets': cls.PRESETS
+ }
+
+ @classmethod
+ def update_job(cls, job_id: str, name: str = None, command: str = None,
+ schedule: str = None, description: str = None) -> Dict:
+ """Update an existing cron job."""
+ metadata = cls._load_jobs_metadata()
+
+ if job_id not in metadata.get('jobs', {}):
+ return {'success': False, 'error': 'Job not found'}
+
+ job_data = metadata['jobs'][job_id]
+ old_schedule = job_data.get('schedule', '')
+ old_command = job_data.get('command', '')
+
+ new_schedule = schedule or old_schedule
+ new_command = command or old_command
+
+ if schedule and not cls._validate_schedule(schedule):
+ return {'success': False, 'error': 'Invalid cron schedule format'}
+
+ # Update crontab on Linux if schedule or command changed
+ if cls.is_linux() and (new_schedule != old_schedule or new_command != old_command):
+ try:
+ result = subprocess.run(
+ ['crontab', '-l'],
+ capture_output=True,
+ text=True,
+ timeout=10
+ )
+
+ if result.returncode == 0:
+ old_line = f"{old_schedule} {old_command}"
+ new_line = f"{new_schedule} {new_command}"
+ lines = result.stdout.split('\n')
+ new_lines = []
+ for line in lines:
+ if old_line in line:
+ new_lines.append(new_line)
+ else:
+ new_lines.append(line)
+
+ new_crontab = '\n'.join(new_lines)
+ process = subprocess.Popen(
+ ['crontab', '-'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ text=True
+ )
+ stdout, stderr = process.communicate(input=new_crontab, timeout=10)
+
+ if process.returncode != 0:
+ return {'success': False, 'error': stderr or 'Failed to update crontab'}
+
+ except subprocess.SubprocessError as e:
+ return {'success': False, 'error': str(e)}
+
+ # Update metadata
+ if name is not None:
+ job_data['name'] = name
+ if command is not None:
+ job_data['command'] = command
+ if schedule is not None:
+ job_data['schedule'] = schedule
+ if description is not None:
+ job_data['description'] = description
+ job_data['updated_at'] = datetime.now().isoformat()
+
+ cls._save_jobs_metadata(metadata)
+
+ return {
+ 'success': True,
+ 'job_id': job_id,
+ 'message': 'Job updated successfully'
}
@classmethod
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index 511f0e23..cc58bfd9 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -71,9 +71,13 @@ function PageTitleUpdater() {
const path = location.pathname;
let title = PAGE_TITLES[path];
- // Handle dynamic routes
+ // Handle dynamic routes and tab sub-routes
if (!title) {
- if (path.startsWith('/apps/')) title = 'Application Details';
+ // Check if it's a base page with a tab suffix (e.g., /security/firewall)
+ const basePath = '/' + path.split('/')[1];
+ if (PAGE_TITLES[basePath]) {
+ title = PAGE_TITLES[basePath];
+ } else if (path.startsWith('/apps/')) title = 'Application Details';
else if (path.startsWith('/servers/')) title = 'Server Details';
else if (path.startsWith('/wordpress/projects/')) title = 'WordPress Pipeline';
else if (path.startsWith('/wordpress/')) title = 'WordPress Site';
@@ -161,30 +165,42 @@ function AppRoutes() {
<Route index element={<Dashboard />} />
<Route path="apps" element={<Applications />} />
<Route path="apps/:id" element={<ApplicationDetail />} />
+ <Route path="apps/:id/:tab" element={<ApplicationDetail />} />
<Route path="wordpress" element={<WordPress />} />
<Route path="wordpress/projects" element={<WordPressProjects />} />
<Route path="wordpress/projects/:id" element={<WordPressProject />} />
+ <Route path="wordpress/projects/:id/:tab" element={<WordPressProject />} />
<Route path="wordpress/:id" element={<WordPressDetail />} />
+ <Route path="wordpress/:id/:tab" element={<WordPressDetail />} />
<Route path="templates" element={<Templates />} />
<Route path="workflow" element={<WorkflowBuilder />} />
<Route path="domains" element={<Domains />} />
<Route path="databases" element={<Databases />} />
+ <Route path="databases/:tab" element={<Databases />} />
<Route path="ssl" element={<SSLCertificates />} />
<Route path="docker" element={<Docker />} />
+ <Route path="docker/:tab" element={<Docker />} />
<Route path="servers" element={<Servers />} />
<Route path="servers/:id" element={<ServerDetail />} />
<Route path="servers/:id/:tab" element={<ServerDetail />} />
<Route path="downloads" element={<Downloads />} />
- <Route path="firewall" element={<Navigate to="/security" replace />} />
+ <Route path="firewall" element={<Navigate to="/security/firewall" replace />} />
<Route path="git" element={<Git />} />
+ <Route path="git/:tab" element={<Git />} />
<Route path="files" element={<FileManager />} />
<Route path="ftp" element={<FTPServer />} />
+ <Route path="ftp/:tab" element={<FTPServer />} />
<Route path="monitoring" element={<Monitoring />} />
+ <Route path="monitoring/:tab" element={<Monitoring />} />
<Route path="backups" element={<Backups />} />
+ <Route path="backups/:tab" element={<Backups />} />
<Route path="cron" element={<CronJobs />} />
<Route path="security" element={<Security />} />
+ <Route path="security/:tab" element={<Security />} />
<Route path="terminal" element={<Terminal />} />
+ <Route path="terminal/:tab" element={<Terminal />} />
<Route path="settings" element={<Settings />} />
+ <Route path="settings/:tab" element={<Settings />} />
</Route>
</Routes>
);
diff --git a/frontend/src/hooks/useTabParam.js b/frontend/src/hooks/useTabParam.js
new file mode 100644
index 00000000..ebf7d351
--- /dev/null
+++ b/frontend/src/hooks/useTabParam.js
@@ -0,0 +1,18 @@
+import { useParams, useNavigate } from 'react-router-dom';
+
+/**
+ * Syncs the active tab with a URL parameter.
+ * @param {string} basePath - The base route path (e.g., '/security', '/apps/5')
+ * @param {string[]} validTabs - List of valid tab slugs
+ * @param {string} defaultTab - Fallback tab when URL param is missing/invalid
+ * @returns {[string, (tab: string) => void]} - [activeTab, setActiveTab]
+ */
+export default function useTabParam(basePath, validTabs, defaultTab = validTabs[0]) {
+ const { tab } = useParams();
+ const navigate = useNavigate();
+
+ const activeTab = validTabs.includes(tab) ? tab : defaultTab;
+ const setActiveTab = (t) => navigate(`${basePath}/${t}`, { replace: true });
+
+ return [activeTab, setActiveTab];
+}
diff --git a/frontend/src/pages/ApplicationDetail.jsx b/frontend/src/pages/ApplicationDetail.jsx
index 90086234..06660aa9 100644
--- a/frontend/src/pages/ApplicationDetail.jsx
+++ b/frontend/src/pages/ApplicationDetail.jsx
@@ -2,18 +2,21 @@ import React, { useState, useEffect } from 'react';
import { useParams, useNavigate, Link } from 'react-router-dom';
import { GitBranch } from 'lucide-react';
import api from '../services/api';
+import useTabParam from '../hooks/useTabParam';
import { useToast } from '../contexts/ToastContext';
import EnvironmentVariables from '../components/EnvironmentVariables';
import PrivateURLSection from '../components/PrivateURLSection';
import LinkedAppsSection from '../components/LinkedAppsSection';
import LinkAppModal from '../components/LinkAppModal';
+const VALID_TABS = ['overview', 'environment', 'packages', 'gunicorn', 'commands', 'build', 'deploy', 'logs', 'settings'];
+
const ApplicationDetail = () => {
const { id } = useParams();
const navigate = useNavigate();
const [app, setApp] = useState(null);
const [loading, setLoading] = useState(true);
- const [activeTab, setActiveTab] = useState('overview');
+ const [activeTab, setActiveTab] = useTabParam(`/apps/${id}`, VALID_TABS);
useEffect(() => {
loadApp();
diff --git a/frontend/src/pages/Backups.jsx b/frontend/src/pages/Backups.jsx
index 0dbd3322..b8f09559 100644
--- a/frontend/src/pages/Backups.jsx
+++ b/frontend/src/pages/Backups.jsx
@@ -1,8 +1,11 @@
import React, { useState, useEffect } from 'react';
+import useTabParam from '../hooks/useTabParam';
import { Upload, Download, Check, AlertTriangle, Clock, Database, Package, FolderArchive, HardDrive, Cloud, CloudOff, RefreshCw, Trash2, Plus, Settings, CheckCircle, XCircle, Server, FileArchive } from 'lucide-react';
import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
+const VALID_TABS = ['backups', 'schedules', 'storage', 'settings'];
+
const Backups = () => {
const toast = useToast();
const [backups, setBackups] = useState([]);
@@ -13,7 +16,7 @@ const Backups = () => {
const [apps, setApps] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
- const [activeTab, setActiveTab] = useState('backups');
+ const [activeTab, setActiveTab] = useTabParam('/backups', VALID_TABS);
const [filterType, setFilterType] = useState('all');
// Modal states
diff --git a/frontend/src/pages/CronJobs.jsx b/frontend/src/pages/CronJobs.jsx
index 8de92fc5..037b9f11 100644
--- a/frontend/src/pages/CronJobs.jsx
+++ b/frontend/src/pages/CronJobs.jsx
@@ -11,8 +11,10 @@ const CronJobs = () => {
const [error, setError] = useState(null);
// Modal states
- const [showCreateModal, setShowCreateModal] = useState(false);
+ const [showJobModal, setShowJobModal] = useState(false);
+ const [editingJob, setEditingJob] = useState(null);
const [runningJobId, setRunningJobId] = useState(null);
+ const [runOutput, setRunOutput] = useState(null);
// Form state
const [jobForm, setJobForm] = useState({
@@ -47,23 +49,55 @@ const CronJobs = () => {
}
};
- const handleCreateJob = async (e) => {
+ const openCreateModal = () => {
+ setEditingJob(null);
+ resetForm();
+ setShowJobModal(true);
+ };
+
+ const openEditModal = (job) => {
+ setEditingJob(job);
+ const presetKey = Object.entries(presets).find(([, v]) => v === job.schedule)?.[0];
+ setJobForm({
+ name: job.name || '',
+ command: job.command || '',
+ schedule: job.schedule || '',
+ description: job.description || '',
+ usePreset: !!presetKey,
+ preset: presetKey || 'daily'
+ });
+ setShowJobModal(true);
+ };
+
+ const closeJobModal = () => {
+ setShowJobModal(false);
+ setEditingJob(null);
+ resetForm();
+ };
+
+ const handleSubmitJob = async (e) => {
e.preventDefault();
try {
const schedule = jobForm.usePreset
? presets[jobForm.preset]
: jobForm.schedule;
- await api.createCronJob({
+ const payload = {
name: jobForm.name,
command: jobForm.command,
schedule: schedule,
description: jobForm.description
- });
+ };
- toast.success('Cron job created successfully');
- setShowCreateModal(false);
- resetForm();
+ if (editingJob) {
+ await api.updateCronJob(editingJob.id, payload);
+ toast.success('Cron job updated successfully');
+ } else {
+ await api.createCronJob(payload);
+ toast.success('Cron job created successfully');
+ }
+
+ closeJobModal();
loadData();
} catch (err) {
toast.error(err.message);
@@ -96,7 +130,13 @@ const CronJobs = () => {
setRunningJobId(jobId);
const result = await api.runCronJob(jobId);
if (result.success) {
- toast.success('Job executed successfully');
+ setRunOutput({
+ jobId,
+ jobName: jobs.find(j => j.id === jobId)?.name || jobId,
+ exitCode: result.exit_code,
+ stdout: result.stdout,
+ stderr: result.stderr
+ });
} else {
toast.error(result.error || 'Job execution failed');
}
@@ -118,14 +158,6 @@ const CronJobs = () => {
});
};
- const formatSchedule = (schedule) => {
- const presetEntry = Object.entries(presets).find(([, value]) => value === schedule);
- if (presetEntry) {
- return presetEntry[0].replace(/_/g, ' ');
- }
- return schedule;
- };
-
const getScheduleDescription = (schedule) => {
const descriptions = {
'* * * * *': 'Every minute',
@@ -154,17 +186,17 @@ const CronJobs = () => {
<h1>Cron Jobs</h1>
<p className="page-subtitle">Manage scheduled tasks and automated jobs</p>
</div>
- <div className="page-actions">
+ <div className="page-header-actions">
<button className="btn btn-secondary" onClick={loadData}>
- <svg viewBox="0 0 24 24" width="16" height="16">
+ <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>
Refresh
</button>
- <button className="btn btn-primary" onClick={() => setShowCreateModal(true)}>
- <svg viewBox="0 0 24 24" width="16" height="16">
+ <button className="btn btn-primary" 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>
@@ -184,20 +216,20 @@ const CronJobs = () => {
<div className="stats-grid">
<div className="stat-card">
<div className="stat-icon cron">
- <svg viewBox="0 0 24 24" width="24" height="24">
+ <svg viewBox="0 0 24 24" width="24" height="24" 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="stat-content">
<span className="stat-label">Cron Service</span>
- <span className="stat-value">{status?.cron_available ? 'Available' : 'Not Available'}</span>
+ <span className="stat-value">{status?.available ? 'Available' : 'Not Available'}</span>
</div>
</div>
<div className="stat-card">
<div className="stat-icon jobs">
- <svg viewBox="0 0 24 24" width="24" height="24">
+ <svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" fill="none" strokeWidth="2">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
<line x1="16" y1="13" x2="8" y2="13"/>
@@ -213,7 +245,7 @@ const CronJobs = () => {
<div className="stat-card">
<div className="stat-icon active">
- <svg viewBox="0 0 24 24" width="24" height="24">
+ <svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" fill="none" strokeWidth="2">
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>
<polyline points="22 4 12 14.01 9 11.01"/>
</svg>
@@ -226,7 +258,7 @@ const CronJobs = () => {
<div className="stat-card">
<div className="stat-icon platform">
- <svg viewBox="0 0 24 24" width="24" height="24">
+ <svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" fill="none" strokeWidth="2">
<rect x="2" y="3" width="20" height="14" rx="2" ry="2"/>
<line x1="8" y1="21" x2="16" y2="21"/>
<line x1="12" y1="17" x2="12" y2="21"/>
@@ -247,23 +279,27 @@ const CronJobs = () => {
<div className="card-body">
{jobs.length === 0 ? (
<div className="empty-state">
- <svg viewBox="0 0 24 24" width="48" height="48">
+ <svg viewBox="0 0 24 24" width="48" height="48" stroke="currentColor" fill="none" strokeWidth="2">
<circle cx="12" cy="12" r="10"/>
<polyline points="12 6 12 12 16 14"/>
</svg>
<h3>No Cron Jobs</h3>
<p>No scheduled jobs found. Create your first cron job to automate tasks.</p>
- <button className="btn btn-primary" onClick={() => setShowCreateModal(true)}>
+ <button className="btn btn-primary" onClick={openCreateModal}>
Create Job
</button>
</div>
) : (
<div className="cron-list">
{jobs.map((job) => (
- <div key={job.id} className={`cron-item ${!job.enabled ? 'disabled' : ''}`}>
+ <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">
+ <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>
@@ -290,7 +326,7 @@ const CronJobs = () => {
</span>
</div>
- <div className="cron-item-actions">
+ <div className="cron-item-actions" onClick={e => e.stopPropagation()}>
<button
className="btn btn-sm btn-secondary"
onClick={() => handleRunJob(job.id)}
@@ -305,6 +341,16 @@ const CronJobs = () => {
</svg>
)}
</button>
+ <button
+ className="btn btn-sm btn-secondary"
+ 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
className={`btn btn-sm ${job.enabled ? 'btn-warning' : 'btn-success'}`}
onClick={() => handleToggleJob(job.id, job.enabled)}
@@ -339,15 +385,15 @@ const CronJobs = () => {
</div>
</div>
- {/* Create Job Modal */}
- {showCreateModal && (
- <div className="modal-overlay" onClick={() => setShowCreateModal(false)}>
+ {/* Create/Edit Job Modal */}
+ {showJobModal && (
+ <div className="modal-overlay" onClick={closeJobModal}>
<div className="modal" onClick={e => e.stopPropagation()}>
<div className="modal-header">
- <h2>Create Cron Job</h2>
- <button className="modal-close" onClick={() => setShowCreateModal(false)}>&times;</button>
+ <h2>{editingJob ? 'Edit Cron Job' : 'Create Cron Job'}</h2>
+ <button className="modal-close" onClick={closeJobModal}>&times;</button>
</div>
- <form onSubmit={handleCreateJob}>
+ <form onSubmit={handleSubmitJob}>
<div className="modal-body">
<div className="form-group">
<label>Job Name</label>
@@ -424,15 +470,57 @@ const CronJobs = () => {
</div>
</div>
<div className="modal-footer">
- <button type="button" className="btn btn-secondary" onClick={() => setShowCreateModal(false)}>
+ <button type="button" className="btn btn-secondary" onClick={closeJobModal}>
Cancel
</button>
- <button type="submit" className="btn btn-primary">Create Job</button>
+ <button type="submit" className="btn btn-primary">
+ {editingJob ? 'Save Changes' : 'Create Job'}
+ </button>
</div>
</form>
</div>
</div>
)}
+
+ {/* Run Output Modal */}
+ {runOutput && (
+ <div className="modal-overlay" onClick={() => setRunOutput(null)}>
+ <div className="modal" onClick={e => e.stopPropagation()}>
+ <div className="modal-header">
+ <h2>Run Output: {runOutput.jobName}</h2>
+ <button className="modal-close" onClick={() => setRunOutput(null)}>&times;</button>
+ </div>
+ <div className="modal-body">
+ <div className="run-output">
+ <div className="run-output-exit">
+ <span className="run-output-label">Exit Code</span>
+ <span className={`badge badge-${runOutput.exitCode === 0 ? 'success' : 'danger'}`}>
+ {runOutput.exitCode}
+ </span>
+ </div>
+ {runOutput.stdout && (
+ <div className="run-output-section">
+ <span className="run-output-label">stdout</span>
+ <pre className="run-output-pre">{runOutput.stdout}</pre>
+ </div>
+ )}
+ {runOutput.stderr && (
+ <div className="run-output-section">
+ <span className="run-output-label">stderr</span>
+ <pre className="run-output-pre run-output-pre--error">{runOutput.stderr}</pre>
+ </div>
+ )}
+ {!runOutput.stdout && !runOutput.stderr && (
+ <p className="text-muted">No output produced.</p>
+ )}
+ </div>
+ </div>
+ <div className="modal-footer">
+ <button className="btn btn-secondary" onClick={() => setRunOutput(null)}>Close</button>
+ </div>
+ </div>
+ </div>
+ )}
</div>
);
};
diff --git a/frontend/src/pages/Databases.jsx b/frontend/src/pages/Databases.jsx
index 6a756fce..7b089d64 100644
--- a/frontend/src/pages/Databases.jsx
+++ b/frontend/src/pages/Databases.jsx
@@ -1,10 +1,15 @@
import React, { useState, useEffect } from 'react';
+import { useParams } from 'react-router-dom';
+import useTabParam from '../hooks/useTabParam';
import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
import QueryRunner from '../components/QueryRunner';
+const VALID_TABS = ['mysql', 'postgresql', 'docker', 'backups', 'sqlite'];
+
const Databases = () => {
- const [activeTab, setActiveTab] = useState('mysql');
+ const { tab } = useParams();
+ const [activeTab, setActiveTab] = useTabParam('/databases', VALID_TABS);
const [status, setStatus] = useState(null);
const [loading, setLoading] = useState(true);
@@ -18,7 +23,7 @@ const Databases = () => {
setStatus(data);
// Default to available server
- if (!data.mysql.running && data.postgresql.running) {
+ if (!tab && !data.mysql.running && data.postgresql.running) {
setActiveTab('postgresql');
}
} catch (err) {
diff --git a/frontend/src/pages/Docker.jsx b/frontend/src/pages/Docker.jsx
index 7d4ae1a4..3b7c3533 100644
--- a/frontend/src/pages/Docker.jsx
+++ b/frontend/src/pages/Docker.jsx
@@ -1,4 +1,5 @@
import React, { useState, useEffect, useCallback, createContext, useContext } from 'react';
+import useTabParam from '../hooks/useTabParam';
import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
@@ -6,8 +7,10 @@ import { useToast } from '../contexts/ToastContext';
const ServerContext = createContext({ serverId: 'local', serverName: 'Local' });
const useServer = () => useContext(ServerContext);
+const VALID_TABS = ['containers', 'compose', 'images', 'volumes', 'networks'];
+
const Docker = () => {
- const [activeTab, setActiveTab] = useState('containers');
+ const [activeTab, setActiveTab] = useTabParam('/docker', VALID_TABS);
const [dockerStatus, setDockerStatus] = useState(null);
const [loading, setLoading] = useState(true);
const [servers, setServers] = useState([]);
diff --git a/frontend/src/pages/FTPServer.jsx b/frontend/src/pages/FTPServer.jsx
index 53ae74af..c6cb604e 100644
--- a/frontend/src/pages/FTPServer.jsx
+++ b/frontend/src/pages/FTPServer.jsx
@@ -1,9 +1,12 @@
import { useState, useEffect } from 'react';
+import useTabParam from '../hooks/useTabParam';
import { api } from '../services/api';
import { useToast } from '../contexts/ToastContext';
import Spinner from '../components/Spinner';
import ConfirmDialog from '../components/ConfirmDialog';
+const VALID_TABS = ['overview', 'users', 'connections', 'logs'];
+
function FTPServer() {
const [status, setStatus] = useState(null);
const [users, setUsers] = useState([]);
@@ -11,7 +14,7 @@ function FTPServer() {
const [config, setConfig] = useState(null);
const [logs, setLogs] = useState('');
const [loading, setLoading] = useState(true);
- const [activeTab, setActiveTab] = useState('overview');
+ const [activeTab, setActiveTab] = useTabParam('/ftp', VALID_TABS);
const [showUserModal, setShowUserModal] = useState(false);
const [showPasswordModal, setShowPasswordModal] = useState(false);
const [showInstallModal, setShowInstallModal] = useState(false);
diff --git a/frontend/src/pages/Git.jsx b/frontend/src/pages/Git.jsx
index 2b65a690..c65d492c 100644
--- a/frontend/src/pages/Git.jsx
+++ b/frontend/src/pages/Git.jsx
@@ -1,13 +1,16 @@
import { useState, useEffect } from 'react';
+import useTabParam from '../hooks/useTabParam';
import { api } from '../services/api';
import { useToast } from '../contexts/ToastContext';
import Spinner from '../components/Spinner';
import ConfirmDialog from '../components/ConfirmDialog';
+const VALID_TABS = ['overview', 'repositories', 'access', 'webhooks', 'deployments', 'settings'];
+
function Git() {
const [status, setStatus] = useState(null);
const [loading, setLoading] = useState(true);
- const [activeTab, setActiveTab] = useState('overview');
+ const [activeTab, setActiveTab] = useTabParam('/git', VALID_TABS);
const [showInstallModal, setShowInstallModal] = useState(false);
const [actionLoading, setActionLoading] = useState(false);
const [confirmDialog, setConfirmDialog] = useState(null);
diff --git a/frontend/src/pages/Monitoring.jsx b/frontend/src/pages/Monitoring.jsx
index 4acd0cf2..48cb30a3 100644
--- a/frontend/src/pages/Monitoring.jsx
+++ b/frontend/src/pages/Monitoring.jsx
@@ -1,7 +1,10 @@
import React, { useState, useEffect } from 'react';
+import useTabParam from '../hooks/useTabParam';
import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
+const VALID_TABS = ['overview', 'alerts', 'config', 'thresholds'];
+
const Monitoring = () => {
const toast = useToast();
const [status, setStatus] = useState(null);
@@ -10,7 +13,7 @@ const Monitoring = () => {
const [alertHistory, setAlertHistory] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
- const [activeTab, setActiveTab] = useState('overview');
+ const [activeTab, setActiveTab] = useTabParam('/monitoring', VALID_TABS);
// Config form state
const [configForm, setConfigForm] = useState({
diff --git a/frontend/src/pages/Security.jsx b/frontend/src/pages/Security.jsx
index 43fab09b..32759e30 100644
--- a/frontend/src/pages/Security.jsx
+++ b/frontend/src/pages/Security.jsx
@@ -1,12 +1,15 @@
import React, { useState, useEffect, useCallback } from 'react';
import { useAuth } from '../contexts/AuthContext';
+import useTabParam from '../hooks/useTabParam';
import api from '../services/api';
import ConfirmDialog from '../components/ConfirmDialog';
import { useToast } from '../contexts/ToastContext';
+const VALID_TABS = ['overview', 'firewall', 'fail2ban', 'ssh-keys', 'ip-lists', 'scanner', 'quarantine', 'integrity', 'audit', 'vulnerability', 'updates', 'events', 'settings'];
+
const Security = () => {
const { isAdmin } = useAuth();
- const [activeTab, setActiveTab] = useState('overview');
+ const [activeTab, setActiveTab] = useTabParam('/security', VALID_TABS);
const [status, setStatus] = useState(null);
const [loading, setLoading] = useState(true);
diff --git a/frontend/src/pages/Settings.jsx b/frontend/src/pages/Settings.jsx
index 8bfe553e..0de38ae7 100644
--- a/frontend/src/pages/Settings.jsx
+++ b/frontend/src/pages/Settings.jsx
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react';
+import useTabParam from '../hooks/useTabParam';
import { useAuth } from '../contexts/AuthContext';
import { useTheme } from '../contexts/ThemeContext';
import api from '../services/api';
@@ -18,8 +19,10 @@ import {
} from 'lucide-react';
import ServerKitLogo from '../assets/ServerKitLogo.svg';
+const VALID_TABS = ['profile', 'security', 'appearance', 'notifications', 'system', 'users', 'audit', 'site', 'developer', 'about'];
+
const Settings = () => {
- const [activeTab, setActiveTab] = useState('profile');
+ const [activeTab, setActiveTab] = useTabParam('/settings', VALID_TABS);
const { isAdmin } = useAuth();
const [devMode, setDevMode] = useState(false);
diff --git a/frontend/src/pages/Terminal.jsx b/frontend/src/pages/Terminal.jsx
index e0fb2792..967e77ea 100644
--- a/frontend/src/pages/Terminal.jsx
+++ b/frontend/src/pages/Terminal.jsx
@@ -1,9 +1,12 @@
import React, { useState, useEffect, useRef } from 'react';
+import useTabParam from '../hooks/useTabParam';
import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
+const VALID_TABS = ['logs', 'journal', 'processes', 'services'];
+
const Terminal = () => {
- const [activeTab, setActiveTab] = useState('logs');
+ const [activeTab, setActiveTab] = useTabParam('/terminal', VALID_TABS);
return (
<div className="page terminal-page">
diff --git a/frontend/src/pages/WordPressDetail.jsx b/frontend/src/pages/WordPressDetail.jsx
index 6f6da154..194f1199 100644
--- a/frontend/src/pages/WordPressDetail.jsx
+++ b/frontend/src/pages/WordPressDetail.jsx
@@ -1,6 +1,7 @@
import React, { useState, useEffect } from 'react';
import { useParams, useNavigate, Link } from 'react-router-dom';
import { ExternalLink, Settings, RefreshCw, Plus, Database, GitBranch, Package, Palette, Archive } from 'lucide-react';
+import useTabParam from '../hooks/useTabParam';
import wordpressApi from '../services/wordpress';
import { useToast } from '../contexts/ToastContext';
import { EnvironmentCard, SnapshotTable, GitConnectForm, CommitList } from '../components/wordpress';
@@ -59,13 +60,15 @@ const DetailPageSkeleton = () => (
</div>
);
+const VALID_TABS = ['overview', 'environments', 'database', 'plugins', 'themes', 'git', 'backups'];
+
const WordPressDetail = () => {
const { id } = useParams();
const navigate = useNavigate();
const toast = useToast();
const [site, setSite] = useState(null);
const [loading, setLoading] = useState(true);
- const [activeTab, setActiveTab] = useState('overview');
+ const [activeTab, setActiveTab] = useTabParam(`/wordpress/${id}`, VALID_TABS);
useEffect(() => {
loadSite();
diff --git a/frontend/src/pages/WordPressProject.jsx b/frontend/src/pages/WordPressProject.jsx
index 197bad21..e96e8b68 100644
--- a/frontend/src/pages/WordPressProject.jsx
+++ b/frontend/src/pages/WordPressProject.jsx
@@ -1,6 +1,7 @@
import React, { useState, useEffect, useCallback, useRef } from 'react';
import { useParams, useNavigate, Link } from 'react-router-dom';
import { Plus, ExternalLink, RefreshCw, GitBranch, Search, Shield, Activity, Settings } from 'lucide-react';
+import useTabParam from '../hooks/useTabParam';
import wordpressApi from '../services/wordpress';
import { useToast } from '../contexts/ToastContext';
import {
@@ -24,6 +25,8 @@ import { io } from 'socket.io-client';
const SOCKET_URL = import.meta.env.VITE_API_URL?.replace('/api/v1', '') || 'http://localhost:5000';
+const VALID_TABS = ['pipeline', 'activity', 'health'];
+
const WordPressProject = () => {
const { id } = useParams();
const navigate = useNavigate();
@@ -31,7 +34,7 @@ const WordPressProject = () => {
const [pipeline, setPipeline] = useState(null);
const [loading, setLoading] = useState(true);
- const [activeTab, setActiveTab] = useState('pipeline');
+ const [activeTab, setActiveTab] = useTabParam(`/wordpress/projects/${id}`, VALID_TABS);
const [showCreateEnvModal, setShowCreateEnvModal] = useState(false);
const [promoteModal, setPromoteModal] = useState(null);
const [syncModal, setSyncModal] = useState(null);
diff --git a/frontend/src/services/api.js b/frontend/src/services/api.js
index b036febe..59891f48 100644
--- a/frontend/src/services/api.js
+++ b/frontend/src/services/api.js
@@ -2044,6 +2044,13 @@ class ApiService {
});
}
+ async updateCronJob(jobId, data) {
+ return this.request(`/cron/jobs/${jobId}`, {
+ method: 'PUT',
+ body: data
+ });
+ }
+
async deleteCronJob(jobId) {
return this.request(`/cron/jobs/${jobId}`, { method: 'DELETE' });
}
diff --git a/frontend/src/styles/pages/_cron.less b/frontend/src/styles/pages/_cron.less
index 8e36f2ec..80f17b40 100644
--- a/frontend/src/styles/pages/_cron.less
+++ b/frontend/src/styles/pages/_cron.less
@@ -19,6 +19,15 @@
}
}
}
+
+ // Global SVG rule for buttons
+ .btn svg {
+ stroke: currentColor;
+ fill: none;
+ stroke-width: 2;
+ stroke-linecap: round;
+ stroke-linejoin: round;
+ }
}
// Stats icons
@@ -50,7 +59,12 @@
.cron-item {
.list-item-base();
- transition: opacity 0.2s ease;
+ transition: opacity 0.2s ease, background-color 0.15s ease;
+ cursor: pointer;
+
+ &:hover {
+ background: @bg-hover;
+ }
&.disabled {
opacity: 0.6;
@@ -163,6 +177,54 @@
}
}
+// Run output display
+.run-output {
+ display: flex;
+ flex-direction: column;
+ gap: @space-4;
+}
+
+.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-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%);
+ }
+}
+
// Spinner inline for running jobs
.spinner-inline {
display: inline-block;