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 log viewer UI and plugin local/upload install

Juan Denis07a778d2bbaf
diff --git a/backend/app/api/plugins.py b/backend/app/api/plugins.py
index df75c197..d33dc5b3 100644
--- a/backend/app/api/plugins.py
+++ b/backend/app/api/plugins.py
@@ -82,6 +82,91 @@ def install_plugin():
return jsonify({'error': f'Installation failed: {e}'}), 500
+@plugins_bp.route('/install-local', methods=['POST'])
+@jwt_required()
+def install_plugin_local():
+ """Install a plugin from a local directory on the panel host.
+
+ Body: { "path": "/abs/path/to/plugin-folder" }
+
+ Intended for plugin development: point at the working tree, install,
+ iterate. The path must exist on the panel host's filesystem and
+ contain a plugin.json. The folder is zipped in memory and run
+ through the same install pipeline as URL/upload installs, so
+ behavior matches.
+ """
+ user = get_current_user()
+ if not user or not user.is_admin:
+ return jsonify({'error': 'Admin access required'}), 403
+
+ data = request.get_json() or {}
+ path = (data.get('path') or '').strip()
+ if not path:
+ return jsonify({'error': 'path required'}), 400
+
+ from app.services.plugin_service import install_from_path
+ try:
+ plugin = install_from_path(path, user_id=user.id)
+ AuditService.log(
+ action=AuditLog.ACTION_RESOURCE_CREATE,
+ user_id=user.id,
+ target_type='plugin',
+ target_id=plugin.id,
+ details={'name': plugin.name, 'version': plugin.version, 'path': path, 'source': 'local'}
+ )
+ return jsonify(plugin.to_dict()), 201
+ except ValueError as e:
+ return jsonify({'error': str(e)}), 400
+ except Exception as e:
+ return jsonify({'error': f'Installation failed: {e}'}), 500
+
+
+@plugins_bp.route('/install-upload', methods=['POST'])
+@jwt_required()
+def install_plugin_upload():
+ """Install a plugin from an uploaded zip file.
+
+ Multipart: file=<plugin.zip>
+
+ Cap at 50 MB. Anything that needs to be bigger probably belongs in
+ a release artifact installed via /install instead.
+ """
+ user = get_current_user()
+ if not user or not user.is_admin:
+ return jsonify({'error': 'Admin access required'}), 403
+
+ if 'file' not in request.files:
+ return jsonify({'error': 'No file uploaded (use multipart field "file")'}), 400
+
+ f = request.files['file']
+ if not f or not f.filename:
+ return jsonify({'error': 'No file uploaded'}), 400
+
+ raw = f.read()
+ max_bytes = 50 * 1024 * 1024
+ if len(raw) > max_bytes:
+ return jsonify({'error': f'Upload exceeds {max_bytes // (1024 * 1024)} MB cap'}), 413
+
+ from app.services.plugin_service import install_from_zip
+ try:
+ plugin = install_from_zip(raw, user_id=user.id, source_name=f.filename)
+ AuditService.log(
+ action=AuditLog.ACTION_RESOURCE_CREATE,
+ user_id=user.id,
+ target_type='plugin',
+ target_id=plugin.id,
+ details={
+ 'name': plugin.name, 'version': plugin.version,
+ 'filename': f.filename, 'source': 'upload',
+ }
+ )
+ return jsonify(plugin.to_dict()), 201
+ except ValueError as e:
+ return jsonify({'error': str(e)}), 400
+ except Exception as e:
+ return jsonify({'error': f'Installation failed: {e}'}), 500
+
+
@plugins_bp.route('/<int:plugin_id>', methods=['DELETE'])
@jwt_required()
def uninstall_plugin(plugin_id):
diff --git a/frontend/src/components/log-viewer/LogContent.jsx b/frontend/src/components/log-viewer/LogContent.jsx
new file mode 100644
index 00000000..6494ab4f
--- /dev/null
+++ b/frontend/src/components/log-viewer/LogContent.jsx
@@ -0,0 +1,62 @@
+import { forwardRef, useMemo } from 'react';
+import { severityOf, splitOnMatch } from './logHelpers';
+
+const LogContent = forwardRef(function LogContent({
+ content,
+ loading,
+ emptyMessage,
+ showLineNumbers,
+ wrapLines,
+ searchPattern,
+}, ref) {
+ const lines = useMemo(() => {
+ if (!content) return [];
+ return content.split('\n');
+ }, [content]);
+
+ if (loading) {
+ return <div className="lv-content lv-content-loading">Loading log…</div>;
+ }
+
+ if (!content) {
+ return (
+ <div className="lv-content lv-content-empty">
+ <p>{emptyMessage || 'Select a log file to view its contents.'}</p>
+ </div>
+ );
+ }
+
+ return (
+ <div
+ ref={ref}
+ className={`lv-content ${wrapLines ? 'wrap' : 'nowrap'} ${showLineNumbers ? 'with-line-numbers' : ''}`}
+ >
+ <div className="lv-lines" role="presentation">
+ {lines.map((line, idx) => {
+ const sev = severityOf(line);
+ const segments = searchPattern ? splitOnMatch(line, searchPattern) : null;
+ return (
+ <div key={idx} className={`lv-line ${sev ? `sev-${sev}` : ''}`}>
+ {showLineNumbers && (
+ <span className="lv-line-no">{idx + 1}</span>
+ )}
+ <span className="lv-line-text">
+ {segments
+ ? segments.map((seg, i) =>
+ seg.match ? (
+ <mark key={i} className="lv-match">{seg.text}</mark>
+ ) : (
+ <span key={i}>{seg.text}</span>
+ )
+ )
+ : (line || ' ')}
+ </span>
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ );
+});
+
+export default LogContent;
diff --git a/frontend/src/components/log-viewer/LogFileList.jsx b/frontend/src/components/log-viewer/LogFileList.jsx
new file mode 100644
index 00000000..b5664337
--- /dev/null
+++ b/frontend/src/components/log-viewer/LogFileList.jsx
@@ -0,0 +1,127 @@
+import { useMemo, useState } from 'react';
+import { Search, RefreshCw, ChevronDown, ChevronRight, FileText, AlertTriangle, Activity, Database, Globe, Mail, Shield, Server } from 'lucide-react';
+import { LOG_GROUPS, categoriseLog, logKindFromPath, formatBytes, formatRelativeTime } from './logHelpers';
+
+const GROUP_ICONS = {
+ web: Globe,
+ app: Activity,
+ database: Database,
+ system: Server,
+ mail: Mail,
+ security: Shield,
+ other: FileText,
+};
+
+export default function LogFileList({ files, selectedPath, onSelect, onRefresh, loading }) {
+ const [query, setQuery] = useState('');
+ const [collapsed, setCollapsed] = useState(new Set());
+
+ const groups = useMemo(() => {
+ const filtered = files.filter((f) => {
+ if (!query.trim()) return true;
+ const q = query.toLowerCase();
+ return f.name?.toLowerCase().includes(q) || f.path?.toLowerCase().includes(q);
+ });
+ const buckets = new Map();
+ for (const f of filtered) {
+ const id = categoriseLog(f);
+ if (!buckets.has(id)) buckets.set(id, []);
+ buckets.get(id).push(f);
+ }
+ // Order groups, putting empty ones last
+ const order = [...LOG_GROUPS.map((g) => g.id), 'other'];
+ return order
+ .map((id) => ({
+ id,
+ label: id === 'other' ? 'Other' : LOG_GROUPS.find((g) => g.id === id)?.label,
+ files: (buckets.get(id) || []).sort((a, b) => (b.size || 0) - (a.size || 0)),
+ }))
+ .filter((g) => g.files.length > 0);
+ }, [files, query]);
+
+ const toggleGroup = (id) => {
+ const next = new Set(collapsed);
+ if (next.has(id)) next.delete(id); else next.add(id);
+ setCollapsed(next);
+ };
+
+ return (
+ <div className="lv-sidebar">
+ <div className="lv-sidebar-header">
+ <div className="lv-search">
+ <Search size={13} className="lv-search-icon" />
+ <input
+ type="text"
+ value={query}
+ onChange={(e) => setQuery(e.target.value)}
+ placeholder="Filter log files…"
+ />
+ </div>
+ <button
+ className="lv-icon-btn"
+ onClick={onRefresh}
+ disabled={loading}
+ title="Reload list"
+ >
+ <RefreshCw size={13} className={loading ? 'spinning' : ''} />
+ </button>
+ </div>
+
+ <div className="lv-sidebar-body">
+ {files.length === 0 ? (
+ <div className="lv-empty-hint">
+ <AlertTriangle size={20} />
+ <p>No log files found.</p>
+ </div>
+ ) : groups.length === 0 ? (
+ <div className="lv-empty-hint">
+ <p>No matches for &quot;{query}&quot;.</p>
+ </div>
+ ) : (
+ groups.map((group) => {
+ const Icon = GROUP_ICONS[group.id] || FileText;
+ const isCollapsed = collapsed.has(group.id);
+ return (
+ <div key={group.id} className="lv-group">
+ <button
+ className="lv-group-header"
+ onClick={() => toggleGroup(group.id)}
+ >
+ {isCollapsed ? <ChevronRight size={12} /> : <ChevronDown size={12} />}
+ <Icon size={13} className="lv-group-icon" />
+ <span>{group.label}</span>
+ <span className="lv-group-count">{group.files.length}</span>
+ </button>
+ {!isCollapsed && (
+ <div className="lv-group-files">
+ {group.files.map((log) => {
+ const kind = logKindFromPath(log.path || log.name);
+ const isActive = selectedPath === log.path;
+ return (
+ <button
+ key={log.path}
+ className={`lv-file ${isActive ? 'active' : ''}`}
+ onClick={() => onSelect(log)}
+ title={log.path}
+ >
+ <span className={`lv-file-dot kind-${kind}`} />
+ <span className="lv-file-name">{log.name}</span>
+ <span className="lv-file-size">{formatBytes(log.size)}</span>
+ {log.modified && (
+ <span className="lv-file-time">
+ {formatRelativeTime(log.modified)}
+ </span>
+ )}
+ </button>
+ );
+ })}
+ </div>
+ )}
+ </div>
+ );
+ })
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/frontend/src/components/log-viewer/LogToolbar.jsx b/frontend/src/components/log-viewer/LogToolbar.jsx
new file mode 100644
index 00000000..9c0065a0
--- /dev/null
+++ b/frontend/src/components/log-viewer/LogToolbar.jsx
@@ -0,0 +1,109 @@
+import { Search, RefreshCw, Download, Trash2, Maximize2, Minimize2, X, ArrowDownToLine, Hash, WrapText } from 'lucide-react';
+
+export default function LogToolbar({
+ searchPattern, onSearchChange, onSearchSubmit, onSearchClear,
+ lineCount, onLineCountChange, lineCountOptions = [50, 100, 200, 500, 1000, 5000],
+ autoRefresh, onAutoRefreshToggle,
+ showLineNumbers, onToggleLineNumbers,
+ wrapLines, onToggleWrap,
+ isFullscreen, onToggleFullscreen,
+ onRefresh, onDownload, onClear, onScrollToBottom,
+ canAct,
+}) {
+ return (
+ <div className="lv-toolbar">
+ <div className="lv-toolbar-left">
+ <div className="lv-search-field">
+ <Search size={13} className="lv-search-field-icon" />
+ <input
+ type="text"
+ placeholder="Search in log…"
+ value={searchPattern}
+ onChange={(e) => onSearchChange(e.target.value)}
+ onKeyDown={(e) => e.key === 'Enter' && onSearchSubmit()}
+ />
+ {searchPattern && (
+ <button className="lv-search-field-clear" onClick={onSearchClear} title="Clear">
+ <X size={11} />
+ </button>
+ )}
+ </div>
+ <select
+ className="lv-select"
+ value={lineCount}
+ onChange={(e) => onLineCountChange(parseInt(e.target.value, 10))}
+ title="Lines to fetch"
+ >
+ {lineCountOptions.map((n) => (
+ <option key={n} value={n}>{n.toLocaleString()} lines</option>
+ ))}
+ </select>
+ </div>
+
+ <div className="lv-toolbar-right">
+ <button
+ className={`lv-chip ${autoRefresh ? 'active' : ''}`}
+ onClick={onAutoRefreshToggle}
+ disabled={!canAct}
+ title="Auto-refresh every 3s and follow tail"
+ >
+ <span className={`lv-pulse ${autoRefresh ? 'on' : ''}`} />
+ <span>Live</span>
+ </button>
+ <button
+ className={`lv-icon-btn ${showLineNumbers ? 'active' : ''}`}
+ onClick={onToggleLineNumbers}
+ title="Toggle line numbers"
+ >
+ <Hash size={13} />
+ </button>
+ <button
+ className={`lv-icon-btn ${wrapLines ? 'active' : ''}`}
+ onClick={onToggleWrap}
+ title="Toggle word wrap"
+ >
+ <WrapText size={13} />
+ </button>
+ <button
+ className="lv-icon-btn"
+ onClick={onScrollToBottom}
+ disabled={!canAct}
+ title="Jump to end"
+ >
+ <ArrowDownToLine size={13} />
+ </button>
+ <button
+ className="lv-icon-btn"
+ onClick={onRefresh}
+ disabled={!canAct}
+ title="Refresh"
+ >
+ <RefreshCw size={13} />
+ </button>
+ <button
+ className="lv-icon-btn"
+ onClick={onDownload}
+ disabled={!canAct}
+ title="Download"
+ >
+ <Download size={13} />
+ </button>
+ <button
+ className="lv-icon-btn danger"
+ onClick={onClear}
+ disabled={!canAct}
+ title="Truncate log file"
+ >
+ <Trash2 size={13} />
+ </button>
+ <button
+ className="lv-icon-btn"
+ onClick={onToggleFullscreen}
+ title={isFullscreen ? 'Exit fullscreen' : 'Fullscreen'}
+ >
+ {isFullscreen ? <Minimize2 size={13} /> : <Maximize2 size={13} />}
+ </button>
+ </div>
+ </div>
+ );
+}
diff --git a/frontend/src/components/log-viewer/logHelpers.js b/frontend/src/components/log-viewer/logHelpers.js
new file mode 100644
index 00000000..849ea2d7
--- /dev/null
+++ b/frontend/src/components/log-viewer/logHelpers.js
@@ -0,0 +1,84 @@
+// Helpers for the log viewer: severity detection, file categorisation,
+// formatting, search highlighting.
+
+export const LOG_GROUPS = [
+ { id: 'web', label: 'Web Servers', match: (p) => /(nginx|apache2|httpd)/i.test(p) },
+ { id: 'app', label: 'Applications', match: (p) => /(php-fpm|gunicorn|uwsgi|node|app)/i.test(p) && !/nginx|apache/i.test(p) },
+ { id: 'database', label: 'Databases', match: (p) => /(mysql|mariadb|postgres|redis|mongo)/i.test(p) },
+ { id: 'system', label: 'System', match: (p) => /(syslog|messages|auth|secure|kern|dmesg|boot|cron)/i.test(p) },
+ { id: 'mail', label: 'Mail', match: (p) => /(mail|postfix|dovecot|exim)/i.test(p) },
+ { id: 'security', label: 'Security', match: (p) => /(fail2ban|ufw|iptables|audit)/i.test(p) },
+];
+
+export function categoriseLog(log) {
+ const probe = `${log.path || ''} ${log.name || ''}`;
+ for (const g of LOG_GROUPS) {
+ if (g.match(probe)) return g.id;
+ }
+ return 'other';
+}
+
+export function logKindFromPath(path) {
+ if (/error|err\b/i.test(path)) return 'error';
+ if (/access/i.test(path)) return 'access';
+ if (/nginx/i.test(path)) return 'nginx';
+ if (/apache/i.test(path)) return 'apache';
+ if (/mysql|mariadb|postgres/i.test(path)) return 'database';
+ if (/php/i.test(path)) return 'php';
+ if (/syslog|messages/i.test(path)) return 'system';
+ if (/auth|secure/i.test(path)) return 'security';
+ if (/mail|postfix|dovecot/i.test(path)) return 'mail';
+ return 'default';
+}
+
+// Detect severity per line. Order matters — fatal/error before warn before info.
+const SEVERITY_PATTERNS = [
+ { id: 'fatal', re: /\b(FATAL|CRITICAL|EMERG|ALERT|PANIC)\b/i },
+ { id: 'error', re: /\b(ERROR|ERR|FAIL(?:ED)?|EXCEPTION|TRACEBACK)\b/i },
+ { id: 'warn', re: /\b(WARN(?:ING)?|DEPRECATED|NOTICE)\b/i },
+ { id: 'info', re: /\b(INFO|NOTICE|STARTING|STARTED|READY|LISTENING)\b/i },
+ { id: 'debug', re: /\b(DEBUG|TRACE|VERBOSE)\b/i },
+];
+
+export function severityOf(line) {
+ if (!line) return null;
+ for (const p of SEVERITY_PATTERNS) {
+ if (p.re.test(line)) return p.id;
+ }
+ return null;
+}
+
+// Build escape-safe regex for highlighting search matches.
+function escapeRegex(str) {
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+}
+
+// Returns array of segments: [{ text, match: bool }]
+export function splitOnMatch(text, query) {
+ if (!query) return [{ text, match: false }];
+ const re = new RegExp(`(${escapeRegex(query)})`, 'gi');
+ const parts = text.split(re);
+ return parts
+ .filter((p) => p !== '')
+ .map((p) => ({ text: p, match: re.test(p) && p.toLowerCase() === query.toLowerCase() }));
+}
+
+// Bytes formatter shared by sidebar and status bar.
+export function formatBytes(bytes) {
+ if (bytes == null) return '';
+ if (bytes < 1024) return `${bytes} B`;
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
+ if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
+ return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
+}
+
+export function formatRelativeTime(iso) {
+ if (!iso) return '';
+ const d = new Date(iso);
+ const diff = (Date.now() - d.getTime()) / 1000;
+ if (diff < 60) return 'just now';
+ if (diff < 3600) return `${Math.floor(diff / 60)}m ago`;
+ if (diff < 86400) return `${Math.floor(diff / 3600)}h ago`;
+ if (diff < 604800) return `${Math.floor(diff / 86400)}d ago`;
+ return d.toLocaleDateString();
+}
diff --git a/frontend/src/pages/Marketplace.jsx b/frontend/src/pages/Marketplace.jsx
index 4b1fa1c1..8a0c8e1c 100644
--- a/frontend/src/pages/Marketplace.jsx
+++ b/frontend/src/pages/Marketplace.jsx
@@ -20,6 +20,9 @@ const Marketplace = () => {
const [category, setCategory] = useState('');
const [showSubmit, setShowSubmit] = useState(false);
const [pluginUrl, setPluginUrl] = useState('');
+ const [pluginPath, setPluginPath] = useState('');
+ const [pluginFile, setPluginFile] = useState(null);
+ const [installSource, setInstallSource] = useState('url');
const [installing, setInstalling] = useState(false);
const [form, setForm] = useState({ name: '', display_name: '', description: '', category: 'utility', version: '1.0.0', author: '' });
@@ -61,12 +64,27 @@ const Marketplace = () => {
};
const handlePluginInstall = async () => {
- if (!pluginUrl.trim()) return;
+ let action;
+ if (installSource === 'url') {
+ if (!pluginUrl.trim()) return;
+ action = () => api.installPlugin(pluginUrl.trim());
+ } else if (installSource === 'path') {
+ if (!pluginPath.trim()) return;
+ action = () => api.installPluginFromPath(pluginPath.trim());
+ } else if (installSource === 'upload') {
+ if (!pluginFile) return;
+ action = () => api.installPluginFromZip(pluginFile);
+ } else {
+ return;
+ }
+
setInstalling(true);
try {
- const result = await api.installPlugin(pluginUrl.trim());
+ const result = await action();
toast.success(`Plugin "${result.display_name}" installed. Restart backend to activate routes.`);
setPluginUrl('');
+ setPluginPath('');
+ setPluginFile(null);
loadExtensions();
} catch (err) {
toast.error(err.message || 'Plugin installation failed');
@@ -196,23 +214,105 @@ const Marketplace = () => {
<TabsContent value="plugins">
<div className="plugins-section">
<div className="plugin-install-form card">
- <h3>Install Plugin from URL</h3>
- <p className="text-muted">Paste a GitHub repo URL, release URL, or direct zip link.</p>
- <div className="plugin-install-row">
- <Input
- placeholder="https://github.com/user/serverkit-plugin"
- value={pluginUrl}
- onChange={e => setPluginUrl(e.target.value)}
- onKeyDown={e => e.key === 'Enter' && handlePluginInstall()}
- disabled={installing}
- />
- <Button
- onClick={handlePluginInstall}
- disabled={installing || !pluginUrl.trim()}
- >
- {installing ? 'Installing...' : 'Install'}
- </Button>
+ <h3>Install Plugin</h3>
+
+ <div className="plugin-install-tabs" role="tablist">
+ {[
+ { id: 'url', label: 'From URL' },
+ { id: 'path', label: 'From Folder' },
+ { id: 'upload', label: 'Upload Zip' },
+ ].map(t => (
+ <button
+ key={t.id}
+ role="tab"
+ type="button"
+ aria-selected={installSource === t.id}
+ className={`plugin-install-tab ${installSource === t.id ? 'plugin-install-tab--active' : ''}`}
+ onClick={() => setInstallSource(t.id)}
+ >
+ {t.label}
+ </button>
+ ))}
</div>
+
+ {installSource === 'url' && (
+ <>
+ <p className="text-muted">Paste a GitHub repo URL, release URL, or direct zip link.</p>
+ <div className="plugin-install-row">
+ <Input
+ placeholder="https://github.com/user/serverkit-plugin"
+ value={pluginUrl}
+ onChange={e => setPluginUrl(e.target.value)}
+ onKeyDown={e => e.key === 'Enter' && handlePluginInstall()}
+ disabled={installing}
+ />
+ <Button
+ onClick={handlePluginInstall}
+ disabled={installing || !pluginUrl.trim()}
+ >
+ {installing ? 'Installing...' : 'Install'}
+ </Button>
+ </div>
+ </>
+ )}
+
+ {installSource === 'path' && (
+ <>
+ <p className="text-muted">
+ Absolute path to a plugin folder on the panel host (must contain
+ <code> plugin.json</code>). Useful for plugin development —
+ edit, install, repeat.
+ </p>
+ <div className="plugin-install-row">
+ <Input
+ placeholder={
+ navigator.userAgent.toLowerCase().includes('win')
+ ? 'C:\\Users\\you\\Documents\\GitHub\\my-plugin'
+ : '/home/you/projects/my-plugin'
+ }
+ value={pluginPath}
+ onChange={e => setPluginPath(e.target.value)}
+ onKeyDown={e => e.key === 'Enter' && handlePluginInstall()}
+ disabled={installing}
+ />
+ <Button
+ onClick={handlePluginInstall}
+ disabled={installing || !pluginPath.trim()}
+ >
+ {installing ? 'Installing...' : 'Install'}
+ </Button>
+ </div>
+ </>
+ )}
+
+ {installSource === 'upload' && (
+ <>
+ <p className="text-muted">
+ Upload a plugin zip (max 50 MB). The archive must contain
+ <code> plugin.json</code> at the top level (or one folder deep,
+ as GitHub source zips do).
+ </p>
+ <div className="plugin-install-row">
+ <input
+ type="file"
+ accept=".zip,application/zip,application/x-zip-compressed"
+ disabled={installing}
+ onChange={e => setPluginFile(e.target.files?.[0] || null)}
+ />
+ <Button
+ onClick={handlePluginInstall}
+ disabled={installing || !pluginFile}
+ >
+ {installing ? 'Installing...' : 'Install'}
+ </Button>
+ </div>
+ {pluginFile && (
+ <div className="text-muted" style={{ marginTop: 6, fontSize: 12 }}>
+ {pluginFile.name} · {(pluginFile.size / 1024).toFixed(1)} KB
+ </div>
+ )}
+ </>
+ )}
</div>
<div className="installed-list">
diff --git a/frontend/src/pages/Terminal.jsx b/frontend/src/pages/Terminal.jsx
index d4e177de..4c69b425 100644
--- a/frontend/src/pages/Terminal.jsx
+++ b/frontend/src/pages/Terminal.jsx
@@ -1,16 +1,21 @@
-import React, { useState, useEffect, useRef } from 'react';
+import React, { useState, useEffect, useRef, useMemo } from 'react';
import useTabParam from '../hooks/useTabParam';
import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
import { useConfirm } from '../hooks/useConfirm';
import { ConfirmDialog } from '../components/ConfirmDialog';
-import { LogViewer } from '../components/LogViewer';
import { ProcessTable, ProcessDetailsPanel } from '../components/ProcessTable';
import { ServiceCard, ServicesGrid } from '../components/ServiceCard';
import { JournalControls } from '../components/JournalControls';
+import TargetPicker from '../components/TargetPicker';
+import LogFileList from '../components/log-viewer/LogFileList';
+import LogToolbar from '../components/log-viewer/LogToolbar';
+import LogContent from '../components/log-viewer/LogContent';
+import { formatBytes, logKindFromPath } from '../components/log-viewer/logHelpers';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
+import { FileText, Clock, AlertCircle } from 'lucide-react';
const VALID_TABS = ['logs', 'journal', 'processes', 'services'];
@@ -82,23 +87,61 @@ const Terminal = () => {
);
};
+const LOG_PREFS = {
+ showLineNumbers: 'serverkit-logs-line-numbers',
+ wrapLines: 'serverkit-logs-wrap',
+ lineCount: 'serverkit-logs-line-count',
+};
+
+// Operations supported by the agent for remote targets. Only `read` is
+// likely available today; everything else is panel-host-only until the
+// matching agent verbs land. Mirrors the FileManager pattern.
+const REMOTE_LOG_SUPPORTED = new Set(['list', 'read']);
+
const LogFilesTab = () => {
+ const toast = useToast();
const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();
+
+ const [target, setTarget] = useState({ kind: 'local' });
+ const isRemote = target.kind === 'agent';
+
const [logFiles, setLogFiles] = useState([]);
const [selectedLog, setSelectedLog] = useState(null);
const [logContent, setLogContent] = useState('');
const [loading, setLoading] = useState(true);
const [loadingContent, setLoadingContent] = useState(false);
const [error, setError] = useState(null);
- const [lineCount, setLineCount] = useState(100);
+ const [lastUpdated, setLastUpdated] = useState(null);
+
+ const [lineCount, setLineCount] = useState(() => {
+ const v = parseInt(localStorage.getItem(LOG_PREFS.lineCount), 10);
+ return Number.isFinite(v) ? v : 200;
+ });
const [searchPattern, setSearchPattern] = useState('');
+ const [appliedSearch, setAppliedSearch] = useState('');
const [autoRefresh, setAutoRefresh] = useState(false);
- const logViewerRef = useRef(null);
+ const [showLineNumbers, setShowLineNumbers] = useState(() => localStorage.getItem(LOG_PREFS.showLineNumbers) !== 'false');
+ const [wrapLines, setWrapLines] = useState(() => localStorage.getItem(LOG_PREFS.wrapLines) !== 'false');
+ const [isFullscreen, setIsFullscreen] = useState(false);
+
+ const contentRef = useRef(null);
const intervalRef = useRef(null);
+ const selectedLogObj = useMemo(
+ () => logFiles.find((l) => l.path === selectedLog) || null,
+ [logFiles, selectedLog]
+ );
+ useEffect(() => { localStorage.setItem(LOG_PREFS.showLineNumbers, showLineNumbers); }, [showLineNumbers]);
+ useEffect(() => { localStorage.setItem(LOG_PREFS.wrapLines, wrapLines); }, [wrapLines]);
+ useEffect(() => { localStorage.setItem(LOG_PREFS.lineCount, lineCount); }, [lineCount]);
+
+ // Reset when the target changes (clears previous server's selection)
useEffect(() => {
+ setSelectedLog(null);
+ setLogContent('');
+ setAutoRefresh(false);
loadLogFiles();
- }, []);
+ }, [target.kind, target.server_id]); // eslint-disable-line react-hooks/exhaustive-deps
useEffect(() => {
if (autoRefresh && selectedLog) {
@@ -106,14 +149,28 @@ const LogFilesTab = () => {
loadLogContent(selectedLog, false);
}, 3000);
}
- return () => {
- if (intervalRef.current) {
- clearInterval(intervalRef.current);
- }
- };
- }, [autoRefresh, selectedLog]);
+ return () => { if (intervalRef.current) clearInterval(intervalRef.current); };
+ }, [autoRefresh, selectedLog, lineCount, appliedSearch]); // eslint-disable-line
+
+ function ensureSupported(op) {
+ if (isRemote && !REMOTE_LOG_SUPPORTED.has(op)) {
+ toast.error(`This action isn't available on remote targets yet.`);
+ return false;
+ }
+ return true;
+ }
async function loadLogFiles() {
+ if (isRemote) {
+ // No remote log-file listing yet — gracefully empty out so the
+ // panel doesn't get confused with stale local entries.
+ setLogFiles([]);
+ setLoading(false);
+ setError(`Remote log listing isn't available yet for ${target.name}.`);
+ return;
+ }
+ setLoading(true);
+ setError(null);
try {
const data = await api.getLogFiles();
setLogFiles(data.logs || []);
@@ -128,17 +185,17 @@ const LogFilesTab = () => {
if (showLoading) setLoadingContent(true);
try {
let data;
- if (searchPattern.trim()) {
- data = await api.searchLog(logPath, searchPattern, lineCount);
+ if (appliedSearch.trim()) {
+ data = await api.searchLog(logPath, appliedSearch, lineCount);
} else {
data = await api.readLog(logPath, lineCount);
}
- setLogContent(data.content || data.lines?.join('\n') || 'No content');
+ setLogContent(data.content || data.lines?.join('\n') || '');
setSelectedLog(logPath);
+ setLastUpdated(new Date());
- // Scroll to bottom
- if (logViewerRef.current) {
- logViewerRef.current.scrollTop = logViewerRef.current.scrollHeight;
+ if (autoRefresh && contentRef.current) {
+ contentRef.current.scrollTop = contentRef.current.scrollHeight;
}
} catch (err) {
setLogContent(`Error loading log: ${err.message}`);
@@ -147,16 +204,60 @@ const LogFilesTab = () => {
}
}
+ function handleSelectFile(log) {
+ loadLogContent(log.path);
+ }
+
+ function handleSearchSubmit() {
+ setAppliedSearch(searchPattern);
+ if (selectedLog) {
+ // Re-fetch with new search.
+ (async () => {
+ setLoadingContent(true);
+ try {
+ const data = searchPattern.trim()
+ ? await api.searchLog(selectedLog, searchPattern, lineCount)
+ : await api.readLog(selectedLog, lineCount);
+ setLogContent(data.content || data.lines?.join('\n') || '');
+ setLastUpdated(new Date());
+ } catch (err) {
+ setLogContent(`Error: ${err.message}`);
+ } finally {
+ setLoadingContent(false);
+ }
+ })();
+ }
+ }
+
+ function handleSearchClear() {
+ setSearchPattern('');
+ setAppliedSearch('');
+ if (selectedLog) loadLogContent(selectedLog);
+ }
+
+ function scrollToBottom() {
+ if (contentRef.current) {
+ contentRef.current.scrollTop = contentRef.current.scrollHeight;
+ }
+ }
+
async function handleClearLog() {
+ if (!ensureSupported('clear')) return;
if (!selectedLog) return;
- const confirmed = await confirm({ title: 'Clear Log', message: `Clear ${selectedLog}? This cannot be undone.` });
+ const confirmed = await confirm({
+ title: 'Truncate log file',
+ message: `This will permanently empty ${selectedLog}. Continue?`,
+ variant: 'danger',
+ confirmText: 'Truncate',
+ });
if (!confirmed) return;
-
try {
await api.clearLog(selectedLog);
- setLogContent('Log cleared.');
+ setLogContent('');
+ toast.success('Log file truncated');
+ loadLogFiles();
} catch (err) {
- setError(err.message);
+ toast.error(`Failed: ${err.message}`);
}
}
@@ -171,59 +272,120 @@ const LogFilesTab = () => {
URL.revokeObjectURL(url);
}
- function getLogIcon(path) {
- if (path.includes('error')) return 'error';
- if (path.includes('access')) return 'access';
- if (path.includes('nginx')) return 'nginx';
- if (path.includes('mysql') || path.includes('postgres')) return 'database';
- return 'default';
- }
-
- function formatFileSize(bytes) {
- if (!bytes) return '0 B';
- const units = ['B', 'KB', 'MB', 'GB'];
- let i = 0;
- while (bytes >= 1024 && i < units.length - 1) {
- bytes /= 1024;
- i++;
- }
- return `${bytes.toFixed(1)} ${units[i]}`;
- }
-
- if (loading) {
- return <div className="loading">Loading log files...</div>;
- }
+ const visibleLineCount = useMemo(() => {
+ if (!logContent) return 0;
+ return logContent.split('\n').filter(Boolean).length;
+ }, [logContent]);
return (
- <div className="logs-container">
+ <div className={`lv-page ${isFullscreen ? 'fullscreen' : ''}`}>
+ <div className="lv-header">
+ <div className="lv-header-target">
+ <span className="lv-header-label">Source</span>
+ <TargetPicker
+ feature="logs"
+ value={target}
+ onChange={setTarget}
+ />
+ {isRemote && (
+ <span className="lv-header-hint">
+ <AlertCircle size={12} />
+ Read-only. Most actions require panel-host access.
+ </span>
+ )}
+ </div>
+ <div className="lv-header-stats">
+ {selectedLogObj && (
+ <>
+ <span className="lv-stat">
+ <FileText size={12} />
+ {selectedLogObj.name}
+ </span>
+ <span className="lv-stat-divider" />
+ <span className="lv-stat">
+ <span className="lv-stat-label">Size</span>
+ <span className="lv-stat-value">{formatBytes(selectedLogObj.size)}</span>
+ </span>
+ <span className="lv-stat">
+ <span className="lv-stat-label">Showing</span>
+ <span className="lv-stat-value">{visibleLineCount.toLocaleString()} lines</span>
+ </span>
+ {lastUpdated && (
+ <span className="lv-stat">
+ <Clock size={12} />
+ {lastUpdated.toLocaleTimeString()}
+ </span>
+ )}
+ </>
+ )}
+ </div>
+ </div>
+
{error && (
- <div className="alert alert-danger">
- {error}
- <button onClick={() => setError(null)} className="alert-close">&times;</button>
+ <div className="lv-error">
+ <AlertCircle size={14} />
+ <span>{error}</span>
+ <button onClick={() => setError(null)}>&times;</button>
</div>
)}
- <LogViewer
- files={logFiles}
- selectedPath={selectedLog}
- onSelectFile={(log) => loadLogContent(log.path)}
- onRefreshFiles={loadLogFiles}
- content={selectedLog ? logContent : ''}
- contentLoading={loadingContent}
- contentEmpty="Select a log file to view its contents."
- searchPattern={searchPattern}
- onSearchChange={setSearchPattern}
- onSearchSubmit={() => selectedLog && loadLogContent(selectedLog)}
- lineCount={lineCount}
- onLineCountChange={setLineCount}
- autoRefresh={autoRefresh}
- onAutoRefreshChange={setAutoRefresh}
- onRefreshContent={() => selectedLog && loadLogContent(selectedLog)}
- onDownload={handleDownload}
- onClear={handleClearLog}
- formatFileSize={formatFileSize}
- getLogIconType={(log) => getLogIcon(log.path)}
- />
+ <div className="lv-layout">
+ <LogFileList
+ files={logFiles}
+ selectedPath={selectedLog}
+ onSelect={handleSelectFile}
+ onRefresh={loadLogFiles}
+ loading={loading}
+ />
+
+ <div className="lv-viewer">
+ {selectedLog && (
+ <div className="lv-viewer-path">
+ <span className={`lv-viewer-path-dot kind-${logKindFromPath(selectedLog)}`} />
+ <code>{selectedLog}</code>
+ </div>
+ )}
+
+ <LogToolbar
+ searchPattern={searchPattern}
+ onSearchChange={setSearchPattern}
+ onSearchSubmit={handleSearchSubmit}
+ onSearchClear={handleSearchClear}
+ lineCount={lineCount}
+ onLineCountChange={(n) => { setLineCount(n); if (selectedLog) setTimeout(() => loadLogContent(selectedLog), 0); }}
+ autoRefresh={autoRefresh}
+ onAutoRefreshToggle={() => setAutoRefresh(!autoRefresh)}
+ showLineNumbers={showLineNumbers}
+ onToggleLineNumbers={() => setShowLineNumbers(!showLineNumbers)}
+ wrapLines={wrapLines}
+ onToggleWrap={() => setWrapLines(!wrapLines)}
+ isFullscreen={isFullscreen}
+ onToggleFullscreen={() => setIsFullscreen(!isFullscreen)}
+ onRefresh={() => selectedLog && loadLogContent(selectedLog)}
+ onDownload={handleDownload}
+ onClear={handleClearLog}
+ onScrollToBottom={scrollToBottom}
+ canAct={!!selectedLog && !loadingContent}
+ />
+
+ <LogContent
+ ref={contentRef}
+ content={selectedLog ? logContent : ''}
+ loading={loadingContent}
+ emptyMessage={
+ isRemote && logFiles.length === 0
+ ? `Remote log browsing isn't supported yet for ${target.name}.`
+ : logFiles.length === 0
+ ? 'No log files were found on this server.'
+ : 'Select a log file from the list to view its contents.'
+ }
+ showLineNumbers={showLineNumbers}
+ wrapLines={wrapLines}
+ searchPattern={appliedSearch}
+ />
+ </div>
+ </div>
+
<ConfirmDialog
isOpen={confirmState.isOpen}
title={confirmState.title}
diff --git a/frontend/src/services/api/client.js b/frontend/src/services/api/client.js
index f3173d6c..5d196b9d 100644
--- a/frontend/src/services/api/client.js
+++ b/frontend/src/services/api/client.js
@@ -25,16 +25,25 @@ class ApiClient {
const url = `${this.baseUrl}${endpoint}`;
const token = this.getToken();
+ // FormData uploads need browser-built Content-Type (with boundary)
+ // and must NOT be JSON-stringified. Detect and bypass both.
+ const isFormData = options.body instanceof FormData;
+
const config = {
headers: {
- 'Content-Type': 'application/json',
+ ...(isFormData ? {} : { 'Content-Type': 'application/json' }),
...(token && { Authorization: `Bearer ${token}` }),
...options.headers,
},
...options,
};
- if (options.body && typeof options.body === 'object') {
+ if (
+ !isFormData &&
+ options.body &&
+ typeof options.body === 'object' &&
+ !(options.body instanceof Blob)
+ ) {
config.body = JSON.stringify(options.body);
}
diff --git a/frontend/src/services/api/plugins.js b/frontend/src/services/api/plugins.js
index d8de32d0..d0190942 100644
--- a/frontend/src/services/api/plugins.js
+++ b/frontend/src/services/api/plugins.js
@@ -16,6 +16,22 @@ export async function installPlugin(url) {
});
}
+export async function installPluginFromPath(path) {
+ return this.request('/plugins/install-local', {
+ method: 'POST',
+ body: JSON.stringify({ path }),
+ });
+}
+
+export async function installPluginFromZip(file) {
+ const form = new FormData();
+ form.append('file', file);
+ return this.request('/plugins/install-upload', {
+ method: 'POST',
+ body: form,
+ });
+}
+
export async function uninstallPlugin(pluginId) {
return this.request(`/plugins/${pluginId}`, {
method: 'DELETE',
diff --git a/frontend/src/styles/pages/_file-manager.scss b/frontend/src/styles/pages/_file-manager.scss
index cd223410..c8d7ee20 100644
--- a/frontend/src/styles/pages/_file-manager.scss
+++ b/frontend/src/styles/pages/_file-manager.scss
@@ -1784,7 +1784,7 @@ $drawer-width: 520px;
border-radius: $radius-md;
background: rgba(99, 102, 241, 0.1);
color: var(--text-primary);
- font-size: $text-sm;
+ font-size: $font-size-sm;
border: 1px solid rgba(99, 102, 241, 0.25);
}
@@ -1800,7 +1800,7 @@ $drawer-width: 520px;
background: transparent;
border: none;
color: var(--text-primary);
- font-size: $text-sm;
+ font-size: $font-size-sm;
outline: none;
cursor: pointer;
}
diff --git a/frontend/src/styles/pages/_marketplace.scss b/frontend/src/styles/pages/_marketplace.scss
index be7958d5..3afec784 100644
--- a/frontend/src/styles/pages/_marketplace.scss
+++ b/frontend/src/styles/pages/_marketplace.scss
@@ -115,9 +115,46 @@
.plugin-install-row {
display: flex;
gap: $spacing-sm;
+ align-items: center;
+
+ .form-input,
+ input[type="text"] {
+ flex: 1;
+ }
- .form-input {
+ input[type="file"] {
flex: 1;
+ color: var(--text-muted);
+ font-size: $font-size-sm;
+ }
+ }
+
+ .plugin-install-tabs {
+ display: inline-flex;
+ gap: 0;
+ margin-bottom: $spacing-md;
+ background: var(--border-color, #2a2e36);
+ border-radius: 6px;
+ padding: 2px;
+ }
+
+ .plugin-install-tab {
+ padding: 6px 14px;
+ background: transparent;
+ border: none;
+ color: var(--text-muted);
+ font-size: $font-size-sm;
+ font-weight: 600;
+ cursor: pointer;
+ border-radius: 4px;
+
+ &:hover {
+ color: var(--text-color);
+ }
+
+ &--active {
+ background: var(--primary-color, #6366f1);
+ color: #fff;
}
}
}
diff --git a/frontend/src/styles/pages/_terminal.scss b/frontend/src/styles/pages/_terminal.scss
index a60ea379..3289293a 100644
--- a/frontend/src/styles/pages/_terminal.scss
+++ b/frontend/src/styles/pages/_terminal.scss
@@ -17,268 +17,648 @@
}
// ============================================
-// LOG FILES TAB
+// LOG VIEWER (LOG FILES TAB)
// ============================================
-.logs-container {
- height: calc(100vh - 280px);
- min-height: 500px;
+// Severity palette for log lines
+$lv-fatal: #ef4444;
+$lv-error: #f87171;
+$lv-warn: #f59e0b;
+$lv-info: #60a5fa;
+$lv-debug: #94a3b8;
+
+// Log-kind dot palette (file list + viewer header)
+$lk-error: #ef4444;
+$lk-access: #10b981;
+$lk-nginx: #6366f1;
+$lk-apache: #d97706;
+$lk-database: #a855f7;
+$lk-php: #777bb4;
+$lk-system: #94a3b8;
+$lk-security: #ec4899;
+$lk-mail: #14b8a6;
+$lk-default: #71717a;
+
+// Spinning animation reused by various refresh icons
+.lv-page .spinning { animation: spin 1s linear infinite; }
+@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
+
+.lv-page {
+ display: flex;
+ flex-direction: column;
+ gap: $space-3;
+ height: calc(100vh - 220px);
+ min-height: 540px;
+
+ &.fullscreen {
+ position: fixed;
+ inset: 0;
+ z-index: $z-modal;
+ height: 100vh;
+ background: $bg-body;
+ padding: $space-4;
+ }
+}
+
+// ─── Header strip (target picker + stats) ─────────────
+.lv-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: $space-4;
+ padding: $space-2 $space-3;
+ background: $bg-card;
+ border: 1px solid $border-default;
+ border-radius: $radius-lg;
+ flex-wrap: wrap;
+}
+
+.lv-header-target {
+ display: flex;
+ align-items: center;
+ gap: $space-3;
+ flex-wrap: wrap;
+}
+
+.lv-header-label {
+ font-size: 9px;
+ text-transform: uppercase;
+ letter-spacing: 0.06em;
+ font-weight: $font-weight-semibold;
+ color: $text-tertiary;
+}
+
+.lv-header-hint {
+ display: inline-flex;
+ align-items: center;
+ gap: $space-1;
+ padding: 2px $space-2;
+ background: $warning-bg;
+ border: 1px solid $warning-border;
+ border-radius: $radius-sm;
+ color: $warning;
+ font-size: $font-size-xs;
}
-.logs-layout {
+.lv-header-stats {
+ display: flex;
+ align-items: center;
+ gap: $space-3;
+ flex-wrap: wrap;
+ color: $text-tertiary;
+ font-size: $font-size-xs;
+}
+
+.lv-stat {
+ display: inline-flex;
+ align-items: center;
+ gap: $space-1;
+ color: $text-secondary;
+
+ svg { color: $text-tertiary; }
+}
+
+.lv-stat-label {
+ font-size: 9px;
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+ font-weight: $font-weight-semibold;
+ color: $text-tertiary;
+}
+
+.lv-stat-value {
+ font-family: $font-mono;
+ color: $text-secondary;
+}
+
+.lv-stat-divider {
+ width: 1px;
+ height: 12px;
+ background: $border-default;
+}
+
+// ─── Inline error banner ─────────────────────────────
+.lv-error {
+ display: flex;
+ align-items: center;
+ gap: $space-2;
+ padding: $space-2 $space-3;
+ background: $danger-bg;
+ border: 1px solid $danger-border;
+ border-radius: $radius-md;
+ color: $danger;
+ font-size: $font-size-sm;
+
+ > svg { flex-shrink: 0; }
+ > span { flex: 1; }
+
+ button {
+ background: transparent;
+ border: none;
+ color: $danger;
+ cursor: pointer;
+ font-size: 18px;
+ line-height: 1;
+ padding: 0 4px;
+ opacity: 0.7;
+
+ &:hover { opacity: 1; }
+ }
+}
+
+// ─── Layout ──────────────────────────────────────────
+.lv-layout {
display: grid;
grid-template-columns: 300px 1fr;
- gap: $space-6;
- height: 100%;
+ gap: $space-3;
+ flex: 1;
+ min-height: 0;
@media (max-width: $breakpoint-lg) {
grid-template-columns: 1fr;
- grid-template-rows: auto 1fr;
+ grid-template-rows: 240px 1fr;
}
}
-.logs-sidebar {
+// ─── Sidebar (file list) ─────────────────────────────
+.lv-sidebar {
background: $bg-card;
- border: 1px solid $border-subtle;
+ border: 1px solid $border-default;
border-radius: $radius-lg;
display: flex;
flex-direction: column;
overflow: hidden;
+ min-height: 0;
+}
- .sidebar-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: $space-4;
- border-bottom: 1px solid $border-subtle;
+.lv-sidebar-header {
+ display: flex;
+ align-items: center;
+ gap: $space-2;
+ padding: $space-2;
+ background: $bg-elevated;
+ border-bottom: 1px solid $border-default;
+}
- h3 {
- font-size: $font-size-sm;
- font-weight: 600;
- margin: 0;
+.lv-search {
+ position: relative;
+ flex: 1;
+ display: flex;
+ align-items: center;
+
+ .lv-search-icon {
+ position: absolute;
+ left: $space-2;
+ color: $text-tertiary;
+ pointer-events: none;
+ }
+
+ input {
+ width: 100%;
+ background: $bg-tertiary;
+ border: 1px solid transparent;
+ border-radius: $radius-sm;
+ padding: 6px 8px 6px 28px;
+ font-size: $font-size-sm;
+ color: $text-primary;
+ @include transition(all);
+
+ &::placeholder { color: $text-tertiary; }
+ &:focus {
+ outline: none;
+ border-color: $accent-primary;
+ background: $bg-body;
}
}
}
-.log-files-list {
+.lv-sidebar-body {
flex: 1;
overflow-y: auto;
padding: $space-2;
+ scrollbar-width: thin;
- .empty-hint {
- padding: $space-6;
- text-align: center;
- color: $text-tertiary;
- font-size: $font-size-sm;
- }
+ &::-webkit-scrollbar { width: 4px; }
+ &::-webkit-scrollbar-thumb { background: $border-default; border-radius: $radius-sm; }
}
-.log-file-item {
+.lv-empty-hint {
display: flex;
+ flex-direction: column;
align-items: center;
+ justify-content: center;
gap: $space-2;
- padding: $space-2 $space-4;
- border-radius: $radius-md;
- cursor: pointer;
- transition: all 0.15s ease;
-
- &:hover {
- background: $bg-hover;
- }
+ padding: $space-6 $space-3;
+ color: $text-tertiary;
+ text-align: center;
- &.active {
- background: $accent-primary;
- color: white;
+ svg { opacity: 0.6; }
+ p { margin: 0; font-size: $font-size-sm; }
+}
- .log-file-path,
- .log-file-size {
- color: rgba(255, 255, 255, 0.7);
- }
+// ─── Group section ───────────────────────────────────
+.lv-group {
+ display: flex;
+ flex-direction: column;
+ margin-bottom: $space-1;
+}
- .log-icon {
- background: rgba(255, 255, 255, 0.2);
- color: white;
- }
- }
+.lv-group-header {
+ display: flex;
+ align-items: center;
+ gap: $space-1;
+ padding: 4px 6px;
+ background: transparent;
+ border: none;
+ color: $text-secondary;
+ font-size: $font-size-xs;
+ font-weight: $font-weight-semibold;
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+ cursor: pointer;
+ border-radius: $radius-sm;
+ @include transition(background);
- .log-icon {
- width: 32px;
- height: 32px;
- border-radius: $radius-sm;
- display: flex;
- align-items: center;
- justify-content: center;
- flex-shrink: 0;
- background: $bg-hover;
+ &:hover { background: $bg-hover; color: $text-primary; }
- svg {
- stroke: currentColor;
- fill: none;
- stroke-width: 2;
- }
+ > svg:first-of-type { color: $text-tertiary; }
+ .lv-group-icon { color: $accent-primary; margin-right: 2px; }
+ > span { flex: 1; text-align: left; }
+}
- &.error {
- color: $danger;
- }
+.lv-group-count {
+ background: $bg-tertiary;
+ color: $text-tertiary;
+ border-radius: $radius-full;
+ padding: 1px 6px;
+ font-size: 9px;
+ font-weight: $font-weight-semibold;
+ line-height: 14px;
+ text-transform: none;
+}
- &.access {
- color: $success;
- }
+.lv-group-files {
+ display: flex;
+ flex-direction: column;
+ gap: 1px;
+ padding: 2px 0 $space-2;
+}
- &.nginx {
- color: $accent-primary;
- }
+// ─── File row ────────────────────────────────────────
+.lv-file {
+ display: grid;
+ grid-template-columns: 8px 1fr auto;
+ grid-template-rows: auto auto;
+ grid-template-areas:
+ 'dot name size'
+ 'dot name time';
+ align-items: center;
+ gap: 2px $space-2;
+ padding: 6px 8px;
+ background: transparent;
+ border: 1px solid transparent;
+ border-radius: $radius-md;
+ color: $text-primary;
+ font-size: $font-size-sm;
+ text-align: left;
+ cursor: pointer;
+ @include transition(all);
- &.database {
- color: #a855f7;
- }
+ &:hover {
+ background: $bg-hover;
+ border-color: $border-active;
}
- .log-file-info {
- flex: 1;
- min-width: 0;
- display: flex;
- flex-direction: column;
- gap: 2px;
- }
+ &.active {
+ background: $accent-glow;
+ border-color: fade($accent-primary-raw, 40%);
- .log-file-name {
- font-size: $font-size-sm;
- font-weight: 500;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
+ .lv-file-name { color: $accent-primary; }
}
+}
- .log-file-path {
- font-size: $font-size-xs;
- color: $text-tertiary;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
+.lv-file-dot {
+ grid-area: dot;
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ background: $lk-default;
+
+ &.kind-error { background: $lk-error; }
+ &.kind-access { background: $lk-access; }
+ &.kind-nginx { background: $lk-nginx; }
+ &.kind-apache { background: $lk-apache; }
+ &.kind-database { background: $lk-database; }
+ &.kind-php { background: $lk-php; }
+ &.kind-system { background: $lk-system; }
+ &.kind-security { background: $lk-security; }
+ &.kind-mail { background: $lk-mail; }
+}
- .log-file-size {
- font-size: $font-size-xs;
- color: $text-tertiary;
- flex-shrink: 0;
- }
+.lv-file-name {
+ grid-area: name;
+ font-weight: $font-weight-medium;
+ @include truncate();
}
-.logs-viewer {
+.lv-file-size {
+ grid-area: size;
+ font-family: $font-mono;
+ font-size: $font-size-xs;
+ color: $text-tertiary;
+}
+
+.lv-file-time {
+ grid-area: time;
+ font-size: 10px;
+ color: $text-tertiary;
+}
+
+// ─── Viewer pane ─────────────────────────────────────
+.lv-viewer {
background: $bg-card;
- border: 1px solid $border-subtle;
+ border: 1px solid $border-default;
border-radius: $radius-lg;
display: flex;
flex-direction: column;
overflow: hidden;
+ min-height: 0;
}
-.viewer-toolbar {
+.lv-viewer-path {
display: flex;
align-items: center;
+ gap: $space-2;
+ padding: $space-2 $space-3;
+ background: $bg-elevated;
+ border-bottom: 1px solid $border-default;
+
+ code {
+ font-family: $font-mono;
+ font-size: $font-size-xs;
+ color: $text-secondary;
+ background: transparent;
+ padding: 0;
+ }
+}
+
+.lv-viewer-path-dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ background: $lk-default;
+ flex-shrink: 0;
+
+ &.kind-error { background: $lk-error; }
+ &.kind-access { background: $lk-access; }
+ &.kind-nginx { background: $lk-nginx; }
+ &.kind-apache { background: $lk-apache; }
+ &.kind-database { background: $lk-database; }
+ &.kind-php { background: $lk-php; }
+ &.kind-system { background: $lk-system; }
+ &.kind-security { background: $lk-security; }
+ &.kind-mail { background: $lk-mail; }
+}
+
+// ─── Toolbar ─────────────────────────────────────────
+.lv-toolbar {
+ display: flex;
justify-content: space-between;
- gap: $space-4;
- padding: $space-2 $space-4;
- border-bottom: 1px solid $border-subtle;
+ align-items: center;
+ gap: $space-3;
+ padding: $space-2 $space-3;
+ border-bottom: 1px solid $border-default;
+ background: $bg-card;
flex-wrap: wrap;
+}
- .toolbar-left,
- .toolbar-right {
- display: flex;
- align-items: center;
- gap: $space-2;
- }
+.lv-toolbar-left,
+.lv-toolbar-right {
+ display: flex;
+ align-items: center;
+ gap: $space-1;
+ flex-wrap: wrap;
}
-.search-input {
+.lv-search-field {
+ position: relative;
display: flex;
align-items: center;
- gap: $space-2;
- padding: $space-1 $space-2;
- background: $bg-hover;
- border: 1px solid $border-subtle;
+ background: $bg-tertiary;
+ border: 1px solid transparent;
border-radius: $radius-md;
+ min-width: 220px;
+ @include transition(all);
- svg {
- stroke: $text-tertiary;
- fill: none;
- stroke-width: 2;
- flex-shrink: 0;
+ &:focus-within {
+ border-color: $accent-primary;
+ background: $bg-body;
+ }
+
+ .lv-search-field-icon {
+ position: absolute;
+ left: $space-3;
+ color: $text-tertiary;
+ pointer-events: none;
}
input {
+ background: transparent;
border: none;
- background: none;
- padding: 0;
+ padding: 6px $space-3 6px 30px;
font-size: $font-size-sm;
- width: 180px;
+ color: $text-primary;
+ width: 100%;
- &:focus {
- outline: none;
- }
+ &::placeholder { color: $text-tertiary; }
+ &:focus { outline: none; }
+ }
+
+ .lv-search-field-clear {
+ position: absolute;
+ right: 6px;
+ background: transparent;
+ border: none;
+ padding: 4px;
+ color: $text-tertiary;
+ cursor: pointer;
+ border-radius: $radius-sm;
+ display: flex;
+ align-items: center;
+
+ &:hover { background: $bg-hover; color: $text-primary; }
}
}
-.lines-select {
- padding: $space-1 $space-2;
- border: 1px solid $border-subtle;
- border-radius: $radius-sm;
- background: $bg-hover;
- color: $text-primary;
+.lv-select {
+ background: $bg-tertiary;
+ border: 1px solid transparent;
+ border-radius: $radius-md;
+ padding: 6px $space-3;
font-size: $font-size-sm;
+ color: $text-primary;
+ cursor: pointer;
+ @include transition(all);
+
+ &:focus, &:hover {
+ border-color: $border-hover;
+ outline: none;
+ }
}
-.auto-refresh-toggle {
+.lv-icon-btn {
+ background: transparent;
+ border: none;
+ padding: 6px;
+ border-radius: $radius-md;
+ color: $text-secondary;
+ cursor: pointer;
display: flex;
align-items: center;
- gap: $space-1;
- cursor: pointer;
- font-size: $font-size-sm;
+ justify-content: center;
+ @include transition(all);
+
+ &:hover:not(:disabled) {
+ background: $bg-hover;
+ color: $text-primary;
+ }
+ &:disabled { opacity: 0.4; cursor: not-allowed; }
+
+ &.active {
+ background: $accent-glow;
+ color: $accent-primary;
+ }
+
+ &.danger:hover:not(:disabled) {
+ background: $danger-bg;
+ color: $danger;
+ }
+}
+
+.lv-chip {
+ display: inline-flex;
+ align-items: center;
+ gap: $space-2;
+ padding: 5px 10px;
+ background: $bg-tertiary;
+ border: 1px solid transparent;
+ border-radius: $radius-md;
color: $text-secondary;
+ font-size: $font-size-sm;
+ font-weight: $font-weight-medium;
+ cursor: pointer;
+ @include transition(all);
- input {
- cursor: pointer;
+ &:hover:not(:disabled) { background: $bg-hover; color: $text-primary; }
+ &:disabled { opacity: 0.5; cursor: not-allowed; }
+ &.active {
+ background: $accent-glow;
+ border-color: fade($accent-primary-raw, 30%);
+ color: $accent-primary;
+ }
+}
+
+.lv-pulse {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ background: $text-tertiary;
+
+ &.on {
+ background: $success;
+ box-shadow: 0 0 0 0 fade($success, 60%);
+ animation: lv-pulse 1.6s ease-out infinite;
}
}
-.log-content {
+@keyframes lv-pulse {
+ 0% { box-shadow: 0 0 0 0 fade($success, 60%); }
+ 70% { box-shadow: 0 0 0 8px fade($success, 0%); }
+ 100% { box-shadow: 0 0 0 0 fade($success, 0%); }
+}
+
+// ─── Content (lines) ─────────────────────────────────
+.lv-content {
flex: 1;
overflow: auto;
- padding: 1rem;
- background: var(--bg-code);
+ background: $bg-body;
+ font-family: $font-mono;
+ font-size: $font-size-sm;
+ line-height: 1.55;
+ min-height: 0;
+ scrollbar-width: thin;
- pre {
- margin: 0;
- font-family: $font-mono;
- font-size: $font-size-sm;
- line-height: 1.4;
- color: var(--text-code);
- white-space: pre-wrap;
- word-wrap: break-word;
- overflow-wrap: break-word;
+ &::-webkit-scrollbar { width: 8px; height: 8px; }
+ &::-webkit-scrollbar-thumb { background: $border-default; border-radius: $radius-sm; }
+ &::-webkit-scrollbar-thumb:hover { background: $border-hover; }
+
+ &.wrap {
+ .lv-line-text { white-space: pre-wrap; word-break: break-word; }
+ }
+ &.nowrap {
+ .lv-line-text { white-space: pre; }
}
+}
- .empty-viewer {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- height: 100%;
- color: $text-tertiary;
+.lv-content-loading,
+.lv-content-empty {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ color: $text-tertiary;
+ text-align: center;
+ padding: $space-8;
- svg {
- stroke: currentColor;
- fill: none;
- stroke-width: 1.5;
- margin-bottom: $space-4;
- opacity: 0.5;
- }
+ p { margin: 0; max-width: 360px; line-height: 1.5; }
+}
- p {
- font-size: $font-size-sm;
- }
- }
+.lv-lines {
+ padding: $space-2 0;
+}
+
+.lv-line {
+ display: flex;
+ align-items: flex-start;
+ padding: 0 $space-3;
+ color: $text-primary;
+ @include transition(background);
+
+ &:hover { background: fade($accent-primary-raw, 4%); }
+
+ &.sev-fatal { color: $lv-fatal; background: fade($lv-fatal, 6%); }
+ &.sev-error { color: $lv-error; }
+ &.sev-warn { color: $lv-warn; }
+ &.sev-info { color: $lv-info; }
+ &.sev-debug { color: $lv-debug; opacity: 0.85; }
+
+ &.sev-fatal:hover { background: fade($lv-fatal, 12%); }
+ &.sev-error:hover { background: fade($lv-error, 8%); }
+ &.sev-warn:hover { background: fade($lv-warn, 8%); }
+}
+
+.lv-line-no {
+ flex-shrink: 0;
+ width: 56px;
+ padding-right: $space-3;
+ text-align: right;
+ color: $text-tertiary;
+ opacity: 0.6;
+ user-select: none;
+ font-size: $font-size-xs;
+ line-height: inherit;
+}
+
+.lv-line-text {
+ flex: 1;
+ min-width: 0;
+}
+
+.lv-match {
+ background: $warning;
+ color: $black;
+ padding: 0 2px;
+ border-radius: 2px;
+ font-weight: $font-weight-semibold;
}
// ============================================