Files
InterferenceETL/etl_app/theme.py
T

325 lines
18 KiB
Python

from __future__ import annotations
from pathlib import Path
ICON_PATH = Path(__file__).resolve().parent / "static" / "icon.svg"
ICON_SVG = ICON_PATH.read_text(encoding="utf-8")
STYLE = """
<style>
body {
--etl-bg: #f4f7fb;
--etl-panel: #ffffff;
--etl-soft: #f8fafc;
--etl-text: #1f2937;
--etl-muted: #6b7280;
--etl-border: #e5e7eb;
--etl-primary: #2563eb;
--etl-primary-soft: #eff6ff;
--etl-on-primary: #ffffff;
--etl-success: #16a34a;
--etl-success-soft: #ecfdf3;
--etl-warning: #d97706;
--etl-warning-soft: #fffbeb;
--etl-danger: #e11d48;
--etl-danger-soft: #fff1f2;
--etl-neutral: #475569;
--etl-neutral-soft: #f1f5f9;
--etl-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 20px rgba(15, 23, 42, 0.04);
--q-primary: #2563eb !important;
background: var(--etl-bg) !important;
color: var(--etl-text);
font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
-webkit-font-smoothing: antialiased;
}
body.body--dark {
--etl-bg: #101014;
--etl-panel: #18181c;
--etl-soft: #1f1f24;
--etl-text: rgba(255, 255, 255, 0.86);
--etl-muted: rgba(255, 255, 255, 0.52);
--etl-border: rgba(255, 255, 255, 0.09);
--etl-primary: #63e2b7;
--etl-primary-soft: rgba(99, 226, 183, 0.14);
--etl-on-primary: #0d2a20;
--etl-success: #63e2b7;
--etl-success-soft: rgba(99, 226, 183, 0.14);
--etl-warning: #f2c97d;
--etl-warning-soft: rgba(242, 201, 125, 0.14);
--etl-danger: #fb7185;
--etl-danger-soft: rgba(251, 113, 133, 0.14);
--etl-neutral: rgba(255, 255, 255, 0.72);
--etl-neutral-soft: rgba(255, 255, 255, 0.08);
--etl-shadow: none;
--q-primary: #63e2b7 !important;
}
@layer theme {
.q-btn.bg-primary { color: var(--etl-on-primary) !important; }
.etl-btn.q-btn--outline { color: var(--etl-text) !important; }
.etl-btn-danger.q-btn--outline { color: var(--etl-danger) !important; }
.etl-tool-btn { color: var(--etl-muted) !important; }
.etl-segment .q-btn { color: var(--etl-muted) !important; }
.etl-segment .q-btn.bg-primary { background: var(--etl-panel) !important; color: var(--etl-primary) !important; }
}
html, body { height: 100%; overflow: hidden; }
.nicegui-content {
height: 100vh; height: 100dvh; min-height: 0; overflow: hidden;
display: flex; flex-direction: column;
padding: 0 !important; gap: 0 !important; align-items: stretch !important;
}
.etl-muted { color: var(--etl-muted); }
.etl-grow { flex: 1; }
.etl-shell { flex: 1; width: 100%; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.etl-header {
position: sticky; top: 0; z-index: 20;
background: color-mix(in srgb, var(--etl-panel) 90%, transparent);
backdrop-filter: blur(12px);
border-bottom: 1px solid var(--etl-border);
}
.etl-header-inner {
max-width: 1240px; margin: 0 auto; height: 60px; padding: 0 24px;
display: flex; align-items: center; gap: 32px;
}
.etl-brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.etl-brand-icon svg { width: 34px; height: 34px; display: block; }
.etl-brand-title { font-size: 16px; font-weight: 600; line-height: 1.25; }
.etl-tabs { flex: 1; min-width: 0; align-self: stretch; color: var(--etl-muted); }
.etl-tabs .q-tabs__content { height: 60px; }
.etl-tabs .q-tab { min-height: 60px; padding: 0 14px; }
.etl-tabs .q-tab__label { font-size: 14px; font-weight: 500; }
.etl-tabs .q-tab--active { color: var(--etl-primary); }
.etl-tabs .q-tab--active .q-tab__label { font-weight: 600; }
.etl-tabs .q-tab__indicator { height: 2px; border-radius: 2px 2px 0 0; }
.etl-header-tools { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.etl-pill {
display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 12px; margin-right: 6px;
border-radius: 999px; font-size: 12.5px; font-weight: 500;
color: var(--etl-muted); background: var(--etl-neutral-soft);
}
.etl-pill.is-on { color: var(--etl-success); background: var(--etl-success-soft); }
.etl-pill-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.etl-pill.is-on .etl-pill-dot { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 24%, transparent); }
.etl-tool-btn { min-width: 34px; min-height: 34px; font-weight: 600; font-size: 13px; }
.etl-user { display: flex; align-items: center; gap: 8px; margin-left: 6px; padding-left: 14px; border-left: 1px solid var(--etl-border); }
.etl-avatar {
width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
background: var(--etl-primary-soft); color: var(--etl-primary); font-size: 13px; font-weight: 600;
}
.etl-user-name { font-size: 13.5px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.etl-main {
width: 100%; max-width: 1240px; margin: 0 auto; padding: 24px;
flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column;
}
.etl-main.is-wide { max-width: none; }
.etl-panels, .etl-panels .q-tab-panel { background: transparent !important; padding: 0 !important; color: inherit; }
.etl-panels { width: 100%; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.etl-panels > .q-panel { flex: 1; min-height: 0; height: 100% !important; overflow: hidden !important; }
.etl-panel {
display: flex !important; flex-direction: column; align-items: stretch !important; gap: 16px !important;
height: 100%; min-height: 0; overflow: auto; box-sizing: border-box;
}
.etl-panel.etl-panel-fit { overflow: hidden; }
.etl-card { background: var(--etl-panel); border: 1px solid var(--etl-border); border-radius: 12px; box-shadow: var(--etl-shadow); }
.etl-card-head {
display: flex; align-items: center; justify-content: space-between; gap: 12px;
min-height: 52px; padding: 0 20px; border-bottom: 1px solid var(--etl-border);
}
.etl-card-title { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 600; }
.etl-card-icon { font-size: 18px; color: var(--etl-muted); }
.etl-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.etl-metric { padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; min-height: 132px; }
.etl-metric-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.etl-metric-title { font-size: 13px; color: var(--etl-muted); }
.etl-metric-icon { font-size: 20px; color: var(--etl-muted); opacity: 0.6; flex-shrink: 0; }
.etl-metric-value-row { display: flex; align-items: center; gap: 8px; min-height: 34px; min-width: 0; }
.etl-metric-value { font-size: 22px; font-weight: 600; line-height: 1.35; overflow-wrap: break-word; }
.etl-metric-value.is-muted { color: var(--etl-muted); }
.etl-metric-value.tone-neutral { color: var(--etl-text); }
.etl-metric-spinner { color: var(--etl-primary); flex-shrink: 0; }
.etl-metric-sub { font-size: 12.5px; line-height: 1.45; color: var(--etl-muted); overflow-wrap: break-word; }
.tone-primary { color: var(--etl-primary); }
.tone-success { color: var(--etl-success); }
.tone-warning { color: var(--etl-warning); }
.tone-danger { color: var(--etl-danger); }
.tone-neutral { color: var(--etl-neutral); }
.etl-actions { padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.etl-actions-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.etl-btn { min-height: 36px; padding: 0 16px; border-radius: 8px; font-weight: 500; }
.etl-btn .q-icon { font-size: 18px; }
.etl-btn.q-btn--outline::before { border-color: var(--etl-border) !important; }
.etl-btn.q-btn--outline:hover::before { border-color: color-mix(in srgb, var(--etl-primary) 45%, var(--etl-border)) !important; }
.etl-btn-danger.q-btn--outline::before { border-color: color-mix(in srgb, var(--etl-danger) 40%, transparent) !important; }
.etl-today { font-size: 13px; }
.etl-panel-fit > .etl-split { flex: 1 1 auto; min-height: 0; }
.etl-split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: stretch; min-height: 0; }
.etl-log-card, .etl-recent-card { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.etl-log {
font-family: "Cascadia Mono", "JetBrains Mono", Consolas, "Microsoft YaHei", monospace;
font-size: 12.5px; line-height: 1.7; white-space: pre-wrap; word-break: break-all; color: var(--etl-text);
}
.etl-log-card .etl-log, .etl-recent {
flex: 1 1 auto; height: auto; min-height: 0; overflow: auto;
}
.etl-log-card .etl-log { padding: 14px 20px; background: var(--etl-soft); border-radius: 0 0 12px 12px; }
.etl-log-meta { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.etl-recent { padding: 6px 8px 8px; }
.etl-recent-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; cursor: pointer; transition: background 0.15s; }
.etl-recent-item:hover { background: var(--etl-soft); }
.etl-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.etl-recent-text { flex: 1; min-width: 0; }
.etl-recent-status { font-size: 13.5px; font-weight: 500; }
.etl-recent-detail { font-size: 12px; color: var(--etl-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.etl-recent-time { font-size: 12px; color: var(--etl-muted); font-variant-numeric: tabular-nums; }
.etl-link-btn { font-size: 13px; }
.etl-empty { padding: 28px 12px; text-align: center; font-size: 13px; }
.etl-segment { border: 1px solid var(--etl-border); border-radius: 8px; padding: 2px; background: var(--etl-soft); box-shadow: none; }
.etl-segment .q-btn { border-radius: 6px !important; padding: 0 12px; min-height: 30px; font-weight: 500; }
.etl-segment .q-btn.bg-primary { box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 0 0 1px var(--etl-border); }
.etl-runs-card { overflow: hidden; }
.etl-runs-toolbar {
display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
padding: 12px 20px; border-bottom: 1px solid var(--etl-border);
}
.etl-runs-tools { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.etl-table { background: transparent !important; color: inherit !important; box-shadow: none !important; }
.etl-table thead tr th {
font-size: 12.5px; font-weight: 500; color: var(--etl-muted); background: var(--etl-soft);
border-bottom: 1px solid var(--etl-border) !important; height: 40px;
}
.etl-table tbody td { font-size: 13px; height: 46px; border-color: var(--etl-border) !important; font-variant-numeric: tabular-nums; }
.etl-table tbody tr { cursor: pointer; }
.etl-table tbody tr:hover td { background: var(--etl-soft); }
.etl-table .q-table__bottom { border-top: none; color: var(--etl-muted); font-size: 13px; }
.etl-cell-detail { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--etl-muted); }
.etl-badge {
display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px;
font-size: 12px; font-weight: 500; white-space: nowrap;
}
.etl-badge.tone-primary { background: var(--etl-primary-soft); }
.etl-badge.tone-success { background: var(--etl-success-soft); }
.etl-badge.tone-warning { background: var(--etl-warning-soft); }
.etl-badge.tone-danger { background: var(--etl-danger-soft); }
.etl-badge.tone-neutral { background: var(--etl-neutral-soft); }
.etl-runs-footer { display: flex; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid var(--etl-border); }
.etl-data-tools { flex-wrap: wrap; justify-content: flex-end; }
.etl-data-search { width: 260px; }
.etl-data-sort { width: 200px; }
.etl-data-summary {
padding: 10px 20px; font-size: 13px; color: var(--etl-muted); border-bottom: 1px solid var(--etl-border);
font-variant-numeric: tabular-nums;
}
.etl-data-summary.tone-danger { color: var(--etl-danger); }
.etl-data-card { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.etl-data-card > :not(.etl-data-table) { flex-shrink: 0; }
.etl-data-table { flex: 1 1 auto; min-height: 0; }
.etl-data-table .q-table__middle { flex: 1 1 auto; min-height: 0; overflow: auto; }
.etl-data-table thead tr:first-child th { position: sticky; top: 0; z-index: 2; box-shadow: inset 0 -1px 0 var(--etl-border); }
.etl-data-table tbody td { white-space: nowrap; }
.etl-data-table td.etl-col-cell { width: 100%; max-width: 0; }
.etl-cell-name { min-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.etl-net {
display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px;
font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--etl-neutral-soft); color: var(--etl-text);
}
.etl-net.net-26g { background: rgba(37, 99, 235, 0.12); color: #2563eb; }
.etl-net.net-700m { background: rgba(124, 58, 237, 0.12); color: #7c3aed; }
.etl-net.net-tdd { background: rgba(13, 148, 136, 0.13); color: #0d9488; }
.etl-net.net-fdd { background: rgba(217, 119, 6, 0.13); color: #b45309; }
.body--dark .etl-net.net-26g { color: #7aa7ff; }
.body--dark .etl-net.net-700m { color: #b69cff; }
.body--dark .etl-net.net-tdd { color: #5eead4; }
.body--dark .etl-net.net-fdd { color: #fbbf24; }
.etl-data-footer { justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.etl-data-size { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.etl-page-size { width: 84px; }
.etl-dialog.etl-data-dialog { width: min(760px, 94vw); }
.etl-detail { width: 100%; padding: 6px 20px 20px; }
.etl-detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 20px; padding: 12px 0 16px; }
.etl-detail-grid .etl-meta-value { word-break: break-all; }
.etl-detail-title { font-size: 13px; font-weight: 600; padding: 14px 0 10px; border-top: 1px solid var(--etl-border); }
.etl-detail-matrix {
display: grid; grid-template-columns: 72px repeat(5, minmax(0, 1fr)); gap: 10px 12px; align-items: center;
padding: 12px 14px; border-radius: 8px; background: var(--etl-soft); font-variant-numeric: tabular-nums;
}
.etl-dialog {
width: min(960px, 94vw); max-width: none !important; padding: 0 !important; gap: 0 !important;
border-radius: 12px !important; background: var(--etl-panel) !important; color: var(--etl-text);
}
.etl-dialog-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--etl-border); }
.etl-dialog-title { font-size: 15px; font-weight: 600; }
.etl-dialog-meta {
display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; width: 100%;
padding: 14px 20px; border-bottom: 1px solid var(--etl-border);
}
.etl-meta-label { font-size: 12px; color: var(--etl-muted); }
.etl-meta-value { font-size: 13px; font-variant-numeric: tabular-nums; }
.etl-log-dialog { width: 100%; max-height: 56vh; min-height: 220px; overflow: auto; padding: 14px 20px; background: var(--etl-soft); }
.etl-dialog-foot { display: flex; justify-content: flex-end; gap: 8px; width: 100%; padding: 12px 16px; border-top: 1px solid var(--etl-border); }
.etl-settings { width: 100%; max-width: 940px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.etl-section { padding: 4px 24px 6px; }
.etl-section-title { font-size: 15px; font-weight: 600; padding: 16px 0 4px; }
.etl-fields { display: flex; flex-direction: column; }
.etl-field {
display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: center;
padding: 12px 0; border-top: 1px solid var(--etl-border);
}
.etl-field:first-child { border-top: none; }
.etl-field-label { display: flex; align-items: center; gap: 4px; min-width: 0; font-size: 13.5px; }
.etl-field-label-text { min-width: 0; }
.etl-hint { font-size: 16px; color: var(--etl-muted); cursor: help; flex-shrink: 0; }
.etl-hint-tip { max-width: 280px; white-space: normal; line-height: 1.5; }
.etl-field-control { min-width: 0; display: flex; align-items: center; }
.etl-input { width: 100%; max-width: 520px; }
.etl-input-short { max-width: 200px; }
.etl-input.etl-textarea { max-width: none; }
.etl-textarea textarea { font-family: "Cascadia Mono", Consolas, "Microsoft YaHei", monospace; font-size: 12.5px; line-height: 1.6; }
.etl-save-bar {
position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
padding: 14px 0 18px; background: linear-gradient(to top, var(--etl-bg) 72%, transparent);
}
.etl-save-bar .q-btn { flex-shrink: 0; white-space: nowrap; }
.etl-checks { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.etl-check { display: flex; align-items: center; gap: 6px; font-size: 13px; min-width: 0; }
.etl-check .q-icon { font-size: 18px; }
.etl-check.is-ok { color: var(--etl-success); }
.etl-check.is-fail { color: var(--etl-danger); }
.etl-check-name { font-weight: 600; flex-shrink: 0; }
.etl-check-text { color: var(--etl-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.etl-forbidden { min-height: 100vh; width: 100%; display: grid; place-items: center; }
.etl-forbidden-card { padding: 40px 56px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.etl-forbidden-icon { font-size: 40px; color: var(--etl-muted); }
.etl-forbidden-title { font-size: 18px; font-weight: 600; }
@media (max-width: 1080px) {
.etl-split { grid-template-columns: 1fr; }
.etl-panel.etl-panel-fit { overflow: auto; }
.etl-log-card .etl-log { min-height: 240px; }
.etl-recent { min-height: 220px; }
.etl-user-name { display: none; }
}
@media (max-width: 720px) {
.etl-header-inner { gap: 12px; padding: 0 12px; }
.etl-pill { display: none; }
.etl-main { padding: 16px 12px; }
.etl-cards { grid-template-columns: 1fr; }
.etl-field { grid-template-columns: 1fr; gap: 8px; }
.etl-dialog-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.etl-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.etl-data-search, .etl-data-sort { width: 100%; }
}
</style>
"""