Skip to content

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

feat(1-1): add routing diagnostics UI to application detail

Juan Denis9a072fb4b957
diff --git a/frontend/src/pages/ApplicationDetail.jsx b/frontend/src/pages/ApplicationDetail.jsx
index b9d57cf9..a372db83 100644
--- a/frontend/src/pages/ApplicationDetail.jsx
+++ b/frontend/src/pages/ApplicationDetail.jsx
@@ -231,11 +231,13 @@ const ApplicationDetail = () => {
const OverviewTab = ({ app }) => {
const [status, setStatus] = useState(null);
+ const [appStatus, setAppStatus] = useState(null);
useEffect(() => {
if (['flask', 'django'].includes(app.app_type)) {
loadStatus();
}
+ loadAppStatus();
}, [app]);
async function loadStatus() {
@@ -247,6 +249,15 @@ const OverviewTab = ({ app }) => {
}
}
+ async function loadAppStatus() {
+ try {
+ const data = await api.getAppStatus(app.id);
+ setAppStatus(data);
+ } catch (err) {
+ console.error('Failed to load app status:', err);
+ }
+ }
+
return (
<div className="overview-grid">
<div className="card">
@@ -275,7 +286,14 @@ const OverviewTab = ({ app }) => {
{app.port && (
<div className="info-item">
<span className="info-label">Port</span>
- <span className="info-value">{app.port}</span>
+ <span className="info-value">
+ {app.port}
+ {appStatus && (
+ <span className={`port-status ${appStatus.port_accessible ? 'accessible' : 'not-accessible'}`}>
+ {appStatus.port_accessible ? ' (accessible)' : ' (not accessible)'}
+ </span>
+ )}
+ </span>
</div>
)}
<div className="info-item">
@@ -330,6 +348,152 @@ const OverviewTab = ({ app }) => {
</div>
</div>
)}
+
+ {app.app_type === 'docker' && (
+ <RoutingDiagnosticsCard appId={app.id} />
+ )}
+ </div>
+ );
+};
+
+const RoutingDiagnosticsCard = ({ appId }) => {
+ const [diagnostics, setDiagnostics] = useState(null);
+ const [loading, setLoading] = useState(false);
+ const [expanded, setExpanded] = useState(false);
+
+ async function runDiagnostics() {
+ setLoading(true);
+ try {
+ const response = await fetch(`/api/v1/domains/debug/diagnose/${appId}`, {
+ headers: {
+ 'Authorization': `Bearer ${localStorage.getItem('accessToken')}`
+ }
+ });
+ const data = await response.json();
+ setDiagnostics(data);
+ setExpanded(true);
+ } catch (err) {
+ console.error('Failed to run diagnostics:', err);
+ } finally {
+ setLoading(false);
+ }
+ }
+
+ function getHealthIcon(healthy) {
+ return healthy ? (
+ <span className="health-icon healthy">&#10003;</span>
+ ) : (
+ <span className="health-icon unhealthy">&#10007;</span>
+ );
+ }
+
+ return (
+ <div className="card diagnostics-card">
+ <div className="card-header-row">
+ <h3>Routing Diagnostics</h3>
+ <button
+ className="btn btn-sm btn-secondary"
+ onClick={runDiagnostics}
+ disabled={loading}
+ >
+ {loading ? 'Checking...' : 'Run Diagnostics'}
+ </button>
+ </div>
+
+ {diagnostics && (
+ <div className="diagnostics-results">
+ <div className={`health-summary ${diagnostics.health?.overall ? 'healthy' : 'unhealthy'}`}>
+ <span className="health-status">
+ {diagnostics.health?.overall ? 'All checks passed' : 'Issues detected'}
+ </span>
+ </div>
+
+ {diagnostics.nginx?.health && (
+ <div className="diagnostics-section">
+ <h4>Nginx Configuration</h4>
+ <div className="check-list">
+ <div className="check-item">
+ {getHealthIcon(diagnostics.nginx.health.config_exists)}
+ <span>Config exists</span>
+ </div>
+ <div className="check-item">
+ {getHealthIcon(diagnostics.nginx.health.config_enabled)}
+ <span>Config enabled</span>
+ </div>
+ <div className="check-item">
+ {getHealthIcon(diagnostics.nginx.health.nginx_running)}
+ <span>Nginx running</span>
+ </div>
+ <div className="check-item">
+ {getHealthIcon(diagnostics.nginx.health.syntax_valid)}
+ <span>Syntax valid</span>
+ </div>
+ </div>
+ </div>
+ )}
+
+ {diagnostics.docker && (
+ <div className="diagnostics-section">
+ <h4>Docker Status</h4>
+ <div className="check-list">
+ <div className="check-item">
+ {getHealthIcon(diagnostics.docker.port_check?.accessible)}
+ <span>Port {diagnostics.app?.port} accessible</span>
+ </div>
+ <div className="check-item">
+ {getHealthIcon(diagnostics.docker.containers?.length > 0)}
+ <span>{diagnostics.docker.containers?.length || 0} container(s) found</span>
+ </div>
+ </div>
+ </div>
+ )}
+
+ {diagnostics.health?.issues?.length > 0 && (
+ <div className="diagnostics-section issues">
+ <h4>Issues</h4>
+ <ul className="issues-list">
+ {diagnostics.health.issues.map((issue, idx) => (
+ <li key={idx}>{issue}</li>
+ ))}
+ </ul>
+ </div>
+ )}
+
+ {diagnostics.health?.recommendations?.length > 0 && (
+ <div className="diagnostics-section recommendations">
+ <h4>Recommendations</h4>
+ <ul className="recommendations-list">
+ {diagnostics.health.recommendations.map((rec, idx) => (
+ <li key={idx}>{rec}</li>
+ ))}
+ </ul>
+ </div>
+ )}
+
+ {expanded && diagnostics.nginx?.config?.content && (
+ <div className="diagnostics-section">
+ <h4>
+ Nginx Config
+ <button
+ className="btn btn-xs btn-ghost"
+ onClick={() => setExpanded(!expanded)}
+ >
+ {expanded ? 'Hide' : 'Show'}
+ </button>
+ </h4>
+ <pre className="config-preview">
+ {diagnostics.nginx.config.content}
+ </pre>
+ </div>
+ )}
+ </div>
+ )}
+
+ {!diagnostics && !loading && (
+ <p className="diagnostics-hint">
+ Click "Run Diagnostics" to check routing configuration and identify issues.
+ </p>
+ )}
</div>
);
};
diff --git a/frontend/src/styles/pages/_applications.less b/frontend/src/styles/pages/_applications.less
index 0d3a866a..6292e332 100644
--- a/frontend/src/styles/pages/_applications.less
+++ b/frontend/src/styles/pages/_applications.less
@@ -247,3 +247,149 @@
font-size: @font-size-sm;
}
}
+
+// ============================================
+// ROUTING DIAGNOSTICS
+// ============================================
+
+.diagnostics-card {
+ .card-header-row {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: @space-4;
+
+ h3 {
+ margin: 0;
+ }
+ }
+
+ .diagnostics-hint {
+ color: @text-tertiary;
+ font-size: @font-size-sm;
+ margin: 0;
+ }
+
+ .diagnostics-results {
+ .flex-column-gap(@space-4);
+ }
+
+ .health-summary {
+ padding: @space-3 @space-4;
+ border-radius: @radius-md;
+ font-weight: @font-weight-medium;
+
+ &.healthy {
+ background: rgba(34, 197, 94, 0.1);
+ color: @success;
+ }
+
+ &.unhealthy {
+ background: rgba(239, 68, 68, 0.1);
+ color: @danger;
+ }
+ }
+
+ .diagnostics-section {
+ h4 {
+ font-size: @font-size-sm;
+ font-weight: @font-weight-semibold;
+ color: @text-secondary;
+ margin-bottom: @space-2;
+ display: flex;
+ align-items: center;
+ gap: @space-2;
+ }
+
+ &.issues, &.recommendations {
+ padding: @space-3;
+ border-radius: @radius-md;
+ }
+
+ &.issues {
+ background: rgba(239, 68, 68, 0.05);
+ border: 1px solid rgba(239, 68, 68, 0.2);
+ }
+
+ &.recommendations {
+ background: rgba(234, 179, 8, 0.05);
+ border: 1px solid rgba(234, 179, 8, 0.2);
+ }
+ }
+
+ .check-list {
+ display: flex;
+ flex-wrap: wrap;
+ gap: @space-2 @space-4;
+ }
+
+ .check-item {
+ display: flex;
+ align-items: center;
+ gap: @space-2;
+ font-size: @font-size-sm;
+ color: @text-secondary;
+ }
+
+ .health-icon {
+ font-weight: bold;
+ font-size: @font-size-base;
+
+ &.healthy {
+ color: @success;
+ }
+
+ &.unhealthy {
+ color: @danger;
+ }
+ }
+
+ .issues-list, .recommendations-list {
+ margin: 0;
+ padding-left: @space-5;
+ font-size: @font-size-sm;
+
+ li {
+ margin-bottom: @space-1;
+
+ &:last-child {
+ margin-bottom: 0;
+ }
+ }
+ }
+
+ .issues-list {
+ color: @danger;
+ }
+
+ .recommendations-list {
+ color: @warning;
+ }
+
+ .config-preview {
+ margin: @space-2 0 0;
+ padding: @space-3;
+ background: @bg-hover;
+ border-radius: @radius-md;
+ font-family: @font-mono;
+ font-size: @font-size-xs;
+ color: @text-secondary;
+ overflow-x: auto;
+ white-space: pre;
+ max-height: 300px;
+ overflow-y: auto;
+ }
+}
+
+.port-status {
+ font-size: @font-size-xs;
+ margin-left: @space-2;
+
+ &.accessible {
+ color: @success;
+ }
+
+ &.not-accessible {
+ color: @danger;
+ }
+}