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 site settings and dynamic page titles

Juan Denis5dec8ba81e62
diff --git a/frontend/index.html b/frontend/index.html
index 770a2049..8339525d 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -3,9 +3,10 @@
<head>
<meta charset="UTF-8" />
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>React Dashboard Template</title>
+ <meta name="description" content="ServerKit - Server Management Dashboard" />
+ <title>ServerKit</title>
</head>
<body>
diff --git a/frontend/public/favicon.svg b/frontend/public/favicon.svg
new file mode 100644
index 00000000..dde8395c
--- /dev/null
+++ b/frontend/public/favicon.svg
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="none">
+ <rect width="32" height="32" rx="6" fill="#6366f1"/>
+ <path d="M8 10h16M8 16h16M8 22h12" stroke="white" stroke-width="2.5" stroke-linecap="round"/>
+ <circle cx="24" cy="22" r="2" fill="#22c55e"/>
+</svg>
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index 882c5d39..88a9888c 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -1,5 +1,5 @@
-import React from 'react';
-import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
+import React, { useEffect } from 'react';
+import { BrowserRouter as Router, Routes, Route, Navigate, useLocation } from 'react-router-dom';
import { AuthProvider, useAuth } from './contexts/AuthContext';
import { ToastProvider } from './contexts/ToastContext';
import { ToastContainer } from './components/Toast';
@@ -29,6 +29,52 @@ import Servers from './pages/Servers';
import ServerDetail from './pages/ServerDetail';
import Downloads from './pages/Downloads';
+// Page title mapping
+const PAGE_TITLES = {
+ '/': 'Dashboard',
+ '/login': 'Login',
+ '/register': 'Register',
+ '/setup': 'Setup',
+ '/apps': 'Applications',
+ '/templates': 'Templates',
+ '/workflow': 'Workflow Builder',
+ '/domains': 'Domains',
+ '/databases': 'Databases',
+ '/ssl': 'SSL Certificates',
+ '/docker': 'Docker',
+ '/servers': 'Servers',
+ '/downloads': 'Downloads',
+ '/git': 'Git Repositories',
+ '/files': 'File Manager',
+ '/ftp': 'FTP Server',
+ '/monitoring': 'Monitoring',
+ '/backups': 'Backups',
+ '/cron': 'Cron Jobs',
+ '/security': 'Security',
+ '/terminal': 'Terminal',
+ '/settings': 'Settings',
+};
+
+function PageTitleUpdater() {
+ const location = useLocation();
+
+ useEffect(() => {
+ const path = location.pathname;
+ let title = PAGE_TITLES[path];
+
+ // Handle dynamic routes
+ if (!title) {
+ if (path.startsWith('/apps/')) title = 'Application Details';
+ else if (path.startsWith('/servers/')) title = 'Server Details';
+ else title = 'ServerKit';
+ }
+
+ document.title = title ? `${title} | ServerKit` : 'ServerKit';
+ }, [location]);
+
+ return null;
+}
+
function PrivateRoute({ children }) {
const { isAuthenticated, loading, needsSetup } = useAuth();
@@ -132,6 +178,7 @@ function AppRoutes() {
function App() {
return (
<Router>
+ <PageTitleUpdater />
<AuthProvider>
<ToastProvider>
<AppRoutes />
diff --git a/frontend/src/hooks/usePageTitle.js b/frontend/src/hooks/usePageTitle.js
new file mode 100644
index 00000000..c7ac1a10
--- /dev/null
+++ b/frontend/src/hooks/usePageTitle.js
@@ -0,0 +1,18 @@
+import { useEffect } from 'react';
+
+/**
+ * Hook to set the page title
+ * @param {string} title - The page title (will be appended with " | ServerKit")
+ */
+export function usePageTitle(title) {
+ useEffect(() => {
+ const previousTitle = document.title;
+ document.title = title ? `${title} | ServerKit` : 'ServerKit';
+
+ return () => {
+ document.title = previousTitle;
+ };
+ }, [title]);
+}
+
+export default usePageTitle;
diff --git a/frontend/src/pages/Login.jsx b/frontend/src/pages/Login.jsx
index bebae3c9..34c4454b 100644
--- a/frontend/src/pages/Login.jsx
+++ b/frontend/src/pages/Login.jsx
@@ -16,7 +16,7 @@ const Login = () => {
const [useBackupCode, setUseBackupCode] = useState(false);
const [backupCode, setBackupCode] = useState('');
- const { login, setUser, setTokens } = useAuth();
+ const { login, setUser, setTokens, registrationEnabled } = useAuth();
const navigate = useNavigate();
// Refs for TOTP input fields
@@ -262,9 +262,11 @@ const Login = () => {
</button>
</form>
- <p className="auth-footer">
- Don't have an account? <Link to="/register">Create one</Link>
- </p>
+ {registrationEnabled && (
+ <p className="auth-footer">
+ Don't have an account? <Link to="/register">Create one</Link>
+ </p>
+ )}
</div>
</div>
);
diff --git a/frontend/src/pages/Settings.jsx b/frontend/src/pages/Settings.jsx
index 8f5951a3..3a99659c 100644
--- a/frontend/src/pages/Settings.jsx
+++ b/frontend/src/pages/Settings.jsx
@@ -106,6 +106,16 @@ const Settings = () => {
</svg>
Audit Log
</button>
+ <button
+ className={`settings-nav-item ${activeTab === 'site' ? 'active' : ''}`}
+ onClick={() => setActiveTab('site')}
+ >
+ <svg viewBox="0 0 24 24" width="18" height="18">
+ <circle cx="12" cy="12" r="3"/>
+ <path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/>
+ </svg>
+ Site Settings
+ </button>
</>
)}
<button
@@ -129,6 +139,7 @@ const Settings = () => {
{activeTab === 'system' && <SystemInfo />}
{activeTab === 'users' && isAdmin && <UsersTab />}
{activeTab === 'audit' && isAdmin && <AuditLogTab />}
+ {activeTab === 'site' && isAdmin && <SiteSettings />}
{activeTab === 'about' && <AboutSection />}
</div>
</div>
@@ -1924,6 +1935,86 @@ const AboutSection = () => {
);
};
+const SiteSettings = () => {
+ const [settings, setSettings] = useState({
+ registration_enabled: false
+ });
+ const [loading, setLoading] = useState(true);
+ const [saving, setSaving] = useState(false);
+ const [message, setMessage] = useState(null);
+
+ useEffect(() => {
+ loadSettings();
+ }, []);
+
+ async function loadSettings() {
+ try {
+ const data = await api.getSystemSettings();
+ setSettings({
+ registration_enabled: data.registration_enabled || false
+ });
+ } catch (err) {
+ console.error('Failed to load settings:', err);
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ async function handleToggleRegistration() {
+ setSaving(true);
+ setMessage(null);
+
+ try {
+ const newValue = !settings.registration_enabled;
+ await api.updateSystemSetting('registration_enabled', newValue);
+ setSettings({ ...settings, registration_enabled: newValue });
+ setMessage({ type: 'success', text: `User registration ${newValue ? 'enabled' : 'disabled'}` });
+ } catch (err) {
+ setMessage({ type: 'error', text: err.message || 'Failed to update setting' });
+ } finally {
+ setSaving(false);
+ }
+ }
+
+ if (loading) {
+ return <div className="settings-section"><p>Loading...</p></div>;
+ }
+
+ return (
+ <div className="settings-section">
+ <h2>Site Settings</h2>
+ <p className="section-description">Configure global site settings</p>
+
+ {message && (
+ <div className={`message ${message.type}`}>{message.text}</div>
+ )}
+
+ <div className="settings-card">
+ <h3>User Registration</h3>
+ <p>Allow new users to create accounts on the login page.</p>
+
+ <div className="form-group">
+ <label className="toggle-switch-label">
+ <span>Enable public registration</span>
+ <label className="toggle-switch">
+ <input
+ type="checkbox"
+ checked={settings.registration_enabled}
+ onChange={handleToggleRegistration}
+ disabled={saving}
+ />
+ <span className="toggle-slider"></span>
+ </label>
+ </label>
+ <span className="form-help">
+ When disabled, only administrators can create new user accounts.
+ </span>
+ </div>
+ </div>
+ </div>
+ );
+};
+
// Helper functions
function formatBytes(bytes) {
if (!bytes) return '-';