|
|
@@ -0,0 +1,807 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="zh-CN">
|
|
|
+
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>Data Nexus - 宽表数据试图</title>
|
|
|
+ <meta name="description" content="Data Nexus 宽表数据视图控制台">
|
|
|
+ <link rel="preconnect" href="https://fonts.googleapis.com">
|
|
|
+ <link
|
|
|
+ href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap"
|
|
|
+ rel="stylesheet">
|
|
|
+ <style>
|
|
|
+ *,
|
|
|
+ *::before,
|
|
|
+ *::after {
|
|
|
+ margin: 0;
|
|
|
+ padding: 0;
|
|
|
+ box-sizing: border-box;
|
|
|
+ }
|
|
|
+
|
|
|
+ :root {
|
|
|
+ --bg-base: #080c18;
|
|
|
+ --bg-sidebar: #0c1222;
|
|
|
+ --bg-surface: #111827;
|
|
|
+ --bg-card: #151f32;
|
|
|
+ --bg-card-head: rgba(0, 0, 0, 0.2);
|
|
|
+ --bg-hover: rgba(255, 255, 255, 0.04);
|
|
|
+ --bg-active: rgba(99, 179, 237, 0.08);
|
|
|
+ --border: rgba(255, 255, 255, 0.06);
|
|
|
+ --border-card: rgba(255, 255, 255, 0.08);
|
|
|
+ --border-active: rgba(99, 179, 237, 0.35);
|
|
|
+ --text-primary: #e2e8f0;
|
|
|
+ --text-secondary: #8b9ab5;
|
|
|
+ --text-muted: #556477;
|
|
|
+ --accent: #63b3ed;
|
|
|
+ --accent-light: #90cdf4;
|
|
|
+ --accent-dim: rgba(99, 179, 237, 0.12);
|
|
|
+ --green: #68d391;
|
|
|
+ --orange: #f6ad55;
|
|
|
+ --purple: #b794f4;
|
|
|
+ --radius: 8px;
|
|
|
+ --sidebar-w: 280px;
|
|
|
+ }
|
|
|
+
|
|
|
+ body {
|
|
|
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
|
|
|
+ background: var(--bg-base);
|
|
|
+ color: var(--text-primary);
|
|
|
+ height: 100vh;
|
|
|
+ overflow: hidden;
|
|
|
+ line-height: 1.5;
|
|
|
+ }
|
|
|
+
|
|
|
+ ::-webkit-scrollbar {
|
|
|
+ width: 6px;
|
|
|
+ height: 6px;
|
|
|
+ }
|
|
|
+
|
|
|
+ ::-webkit-scrollbar-track {
|
|
|
+ background: transparent;
|
|
|
+ }
|
|
|
+
|
|
|
+ ::-webkit-scrollbar-thumb {
|
|
|
+ background: rgba(255, 255, 255, 0.1);
|
|
|
+ border-radius: 3px;
|
|
|
+ }
|
|
|
+
|
|
|
+ ::-webkit-scrollbar-thumb:hover {
|
|
|
+ background: rgba(255, 255, 255, 0.2);
|
|
|
+ }
|
|
|
+
|
|
|
+ .app {
|
|
|
+ display: grid;
|
|
|
+ grid-template-columns: var(--sidebar-w) 1fr;
|
|
|
+ height: 100vh;
|
|
|
+ }
|
|
|
+
|
|
|
+ .sidebar {
|
|
|
+ background: var(--bg-sidebar);
|
|
|
+ border-right: 1px solid var(--border);
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+
|
|
|
+ .sidebar-header {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 10px;
|
|
|
+ padding: 20px 20px 16px;
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .sidebar-header svg {
|
|
|
+ width: 26px;
|
|
|
+ height: 26px;
|
|
|
+ color: var(--accent);
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .sidebar-header span {
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: 700;
|
|
|
+ background: linear-gradient(135deg, var(--accent-light), var(--purple));
|
|
|
+ -webkit-background-clip: text;
|
|
|
+ background-clip: text;
|
|
|
+ -webkit-text-fill-color: transparent;
|
|
|
+ }
|
|
|
+
|
|
|
+ .sidebar-divider {
|
|
|
+ height: 1px;
|
|
|
+ background: var(--border);
|
|
|
+ margin: 8px 16px;
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .stage-tree-wrap {
|
|
|
+ flex: 1;
|
|
|
+ overflow-y: auto;
|
|
|
+ padding: 0 8px 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .tree-branch-header {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 4px;
|
|
|
+ padding: 7px 10px;
|
|
|
+ cursor: pointer;
|
|
|
+ border-radius: 6px;
|
|
|
+ transition: background 0.12s;
|
|
|
+ user-select: none;
|
|
|
+ font-size: 13px;
|
|
|
+ color: var(--text-secondary);
|
|
|
+ }
|
|
|
+
|
|
|
+ .tree-branch-header:hover {
|
|
|
+ background: var(--bg-hover);
|
|
|
+ }
|
|
|
+
|
|
|
+ .tree-arrow {
|
|
|
+ width: 16px;
|
|
|
+ height: 16px;
|
|
|
+ color: var(--text-muted);
|
|
|
+ transition: transform 0.2s;
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .tree-arrow.open {
|
|
|
+ transform: rotate(90deg);
|
|
|
+ }
|
|
|
+
|
|
|
+ .tree-children {
|
|
|
+ display: none;
|
|
|
+ padding-left: 8px;
|
|
|
+ margin-left: 12px;
|
|
|
+ border-left: 1px solid var(--border);
|
|
|
+ }
|
|
|
+
|
|
|
+ .tree-children.open {
|
|
|
+ display: block;
|
|
|
+ }
|
|
|
+
|
|
|
+ .tree-leaf {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 8px;
|
|
|
+ padding: 7px 10px 7px 12px;
|
|
|
+ cursor: pointer;
|
|
|
+ border-radius: 6px;
|
|
|
+ transition: all 0.12s;
|
|
|
+ font-size: 13px;
|
|
|
+ color: var(--text-secondary);
|
|
|
+ }
|
|
|
+
|
|
|
+ .tree-leaf:hover {
|
|
|
+ background: var(--bg-hover);
|
|
|
+ color: var(--text-primary);
|
|
|
+ }
|
|
|
+
|
|
|
+ .tree-leaf.active {
|
|
|
+ background: var(--bg-active);
|
|
|
+ color: var(--accent);
|
|
|
+ font-weight: 500;
|
|
|
+ }
|
|
|
+
|
|
|
+ .tree-dot {
|
|
|
+ width: 5px;
|
|
|
+ height: 5px;
|
|
|
+ border-radius: 50%;
|
|
|
+ background: var(--text-muted);
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .tree-leaf.active .tree-dot {
|
|
|
+ background: var(--accent);
|
|
|
+ }
|
|
|
+
|
|
|
+ .tree-count {
|
|
|
+ margin-left: auto;
|
|
|
+ font-size: 11px;
|
|
|
+ color: var(--text-muted);
|
|
|
+ background: rgba(255, 255, 255, 0.04);
|
|
|
+ padding: 1px 6px;
|
|
|
+ border-radius: 4px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .content {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ height: 100vh;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+
|
|
|
+ .content-header {
|
|
|
+ flex-shrink: 0;
|
|
|
+ padding: 18px 28px;
|
|
|
+ border-bottom: 1px solid var(--border);
|
|
|
+ background: rgba(12, 18, 34, 0.6);
|
|
|
+ backdrop-filter: blur(12px);
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ min-height: 60px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .stage-path {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 6px;
|
|
|
+ font-size: 14px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .stage-path .sep {
|
|
|
+ color: var(--text-muted);
|
|
|
+ font-size: 11px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .stage-path .seg {
|
|
|
+ color: var(--text-secondary);
|
|
|
+ }
|
|
|
+
|
|
|
+ .stage-path .seg:last-child {
|
|
|
+ color: var(--text-primary);
|
|
|
+ font-weight: 600;
|
|
|
+ }
|
|
|
+
|
|
|
+ .header-info {
|
|
|
+ font-size: 12px;
|
|
|
+ color: var(--text-muted);
|
|
|
+ }
|
|
|
+
|
|
|
+ .content-body {
|
|
|
+ flex: 1;
|
|
|
+ overflow: auto;
|
|
|
+ padding: 24px;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Welcome & Loading state */
|
|
|
+ .state-box {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ height: 100%;
|
|
|
+ text-align: center;
|
|
|
+ color: var(--text-muted);
|
|
|
+ padding: 40px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .state-box svg {
|
|
|
+ width: 56px;
|
|
|
+ height: 56px;
|
|
|
+ margin-bottom: 20px;
|
|
|
+ opacity: 0.25;
|
|
|
+ }
|
|
|
+
|
|
|
+ .state-box h2 {
|
|
|
+ font-size: 17px;
|
|
|
+ font-weight: 600;
|
|
|
+ color: var(--text-secondary);
|
|
|
+ margin-bottom: 6px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .state-box p {
|
|
|
+ font-size: 13px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .spinner {
|
|
|
+ width: 28px;
|
|
|
+ height: 28px;
|
|
|
+ border: 3px solid var(--border);
|
|
|
+ border-top-color: var(--accent);
|
|
|
+ border-radius: 50%;
|
|
|
+ animation: spin 0.7s linear infinite;
|
|
|
+ margin-bottom: 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ @keyframes spin {
|
|
|
+ to {
|
|
|
+ transform: rotate(360deg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Records Table */
|
|
|
+ .records-table {
|
|
|
+ width: 100%;
|
|
|
+ border-collapse: separate;
|
|
|
+ border-spacing: 0;
|
|
|
+ background: var(--bg-card);
|
|
|
+ border: 1px solid var(--border-card);
|
|
|
+ border-radius: var(--radius);
|
|
|
+ }
|
|
|
+
|
|
|
+ .records-table th {
|
|
|
+ background: var(--bg-card-head);
|
|
|
+ color: var(--text-secondary);
|
|
|
+ font-size: 13px;
|
|
|
+ font-weight: 600;
|
|
|
+ text-align: left;
|
|
|
+ padding: 14px 16px;
|
|
|
+ border-bottom: 1px solid var(--border);
|
|
|
+ white-space: nowrap;
|
|
|
+ }
|
|
|
+
|
|
|
+ .records-table td {
|
|
|
+ border-bottom: 1px solid var(--border);
|
|
|
+ padding: 16px;
|
|
|
+ vertical-align: top;
|
|
|
+ }
|
|
|
+
|
|
|
+ .records-table tr:last-child td {
|
|
|
+ border-bottom: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ .records-table td.meta-cell {
|
|
|
+ white-space: nowrap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Bubble Tree (File rendering) */
|
|
|
+ .bubble-tree {
|
|
|
+ background: rgba(0, 0, 0, 0.15);
|
|
|
+ border-radius: 6px;
|
|
|
+ border: 1px solid var(--border);
|
|
|
+ overflow: hidden;
|
|
|
+ font-size: 12px;
|
|
|
+ min-width: 200px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .fg-header {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ padding: 8px 10px;
|
|
|
+ gap: 6px;
|
|
|
+ cursor: pointer;
|
|
|
+ border-bottom: 1px solid var(--border);
|
|
|
+ transition: background 0.1s;
|
|
|
+ }
|
|
|
+
|
|
|
+ .fg-header:hover {
|
|
|
+ background: var(--bg-hover);
|
|
|
+ }
|
|
|
+
|
|
|
+ .fg-arrow {
|
|
|
+ width: 12px;
|
|
|
+ height: 12px;
|
|
|
+ color: var(--text-muted);
|
|
|
+ transition: transform 0.2s;
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .fg-arrow.open {
|
|
|
+ transform: rotate(90deg);
|
|
|
+ }
|
|
|
+
|
|
|
+ .fg-icon {
|
|
|
+ width: 14px;
|
|
|
+ height: 14px;
|
|
|
+ color: var(--orange);
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .fg-name {
|
|
|
+ color: var(--text-primary);
|
|
|
+ font-weight: 500;
|
|
|
+ }
|
|
|
+
|
|
|
+ .file-row {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ padding: 6px 10px;
|
|
|
+ border-bottom: 1px solid var(--border);
|
|
|
+ gap: 10px;
|
|
|
+ transition: background 0.1s;
|
|
|
+ }
|
|
|
+
|
|
|
+ .file-row:hover {
|
|
|
+ background: var(--bg-hover);
|
|
|
+ }
|
|
|
+
|
|
|
+ .file-row:last-child {
|
|
|
+ border-bottom: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ .file-name-col {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 6px;
|
|
|
+ min-width: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .f-icon {
|
|
|
+ width: 14px;
|
|
|
+ height: 14px;
|
|
|
+ color: var(--text-muted);
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .f-name {
|
|
|
+ color: var(--text-primary);
|
|
|
+ white-space: nowrap;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ max-width: 200px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .btn-dl {
|
|
|
+ display: inline-flex;
|
|
|
+ align-items: center;
|
|
|
+ padding: 3px 6px;
|
|
|
+ border-radius: 4px;
|
|
|
+ background: var(--accent-dim);
|
|
|
+ color: var(--accent);
|
|
|
+ text-decoration: none;
|
|
|
+ transition: all 0.15s;
|
|
|
+ }
|
|
|
+
|
|
|
+ .btn-dl:hover {
|
|
|
+ background: rgba(99, 179, 237, 0.2);
|
|
|
+ }
|
|
|
+
|
|
|
+ .btn-dl svg {
|
|
|
+ width: 12px;
|
|
|
+ height: 12px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .commit-badge {
|
|
|
+ display: inline-flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 4px;
|
|
|
+ font-family: 'JetBrains Mono', monospace;
|
|
|
+ background: var(--accent-dim);
|
|
|
+ color: var(--accent);
|
|
|
+ padding: 3px 8px;
|
|
|
+ border-radius: 4px;
|
|
|
+ font-size: 12px;
|
|
|
+ margin-bottom: 4px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .meta-text {
|
|
|
+ font-size: 12px;
|
|
|
+ color: var(--text-muted);
|
|
|
+ margin-bottom: 2px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .empty-cell {
|
|
|
+ color: var(--text-muted);
|
|
|
+ font-size: 13px;
|
|
|
+ font-style: italic;
|
|
|
+ }
|
|
|
+
|
|
|
+ .load-more {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ padding: 20px 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .load-more-btn {
|
|
|
+ padding: 9px 28px;
|
|
|
+ border-radius: 6px;
|
|
|
+ border: 1px solid var(--border);
|
|
|
+ background: var(--bg-card);
|
|
|
+ color: var(--text-secondary);
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+
|
|
|
+ .load-more-btn:hover {
|
|
|
+ background: var(--bg-hover);
|
|
|
+ color: var(--text-primary);
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+
|
|
|
+<body>
|
|
|
+ <div class="app">
|
|
|
+ <aside class="sidebar">
|
|
|
+ <div class="sidebar-header">
|
|
|
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
|
+ <rect x="3" y="3" width="18" height="18" rx="2" ry="2" />
|
|
|
+ <line x1="3" y1="9" x2="21" y2="9" />
|
|
|
+ <line x1="9" y1="21" x2="9" y2="9" />
|
|
|
+ </svg>
|
|
|
+ <span>宽表数据视图</span>
|
|
|
+ </div>
|
|
|
+ <div class="sidebar-divider"></div>
|
|
|
+ <div class="stage-tree-wrap" id="stageTreeWrap"></div>
|
|
|
+ </aside>
|
|
|
+ <main class="content">
|
|
|
+ <div class="content-header">
|
|
|
+ <div class="stage-path" id="stagePath"><span class="seg" style="color:var(--text-muted)">选择左侧数据阶段</span>
|
|
|
+ </div>
|
|
|
+ <div class="header-info" id="headerInfo"></div>
|
|
|
+ </div>
|
|
|
+ <div class="content-body" id="contentBody">
|
|
|
+ <div class="state-box">
|
|
|
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
|
+ <rect x="3" y="3" width="18" height="18" rx="2" ry="2" />
|
|
|
+ <line x1="3" y1="9" x2="21" y2="9" />
|
|
|
+ <line x1="9" y1="21" x2="9" y2="9" />
|
|
|
+ </svg>
|
|
|
+ <h2>欢迎使用宽表视图控制台</h2>
|
|
|
+ <p>从左侧选择阶段,即可查看以 group key 聚合排列的数据网格表</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </main>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <script>
|
|
|
+ const IC = {
|
|
|
+ commit: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="4"/><line x1="1.05" y1="12" x2="7" y2="12"/><line x1="17.01" y1="12" x2="22.96" y2="12"/></svg>',
|
|
|
+ file: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>',
|
|
|
+ folder: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"/></svg>',
|
|
|
+ download: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',
|
|
|
+ chevron: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>',
|
|
|
+ };
|
|
|
+
|
|
|
+ const PAGE_SIZE = 20;
|
|
|
+ let S = { stages: [], stageProjectMap: {}, stage: null, records: [], skip: 0, hasMore: true, loading: false };
|
|
|
+
|
|
|
+ const $ = id => document.getElementById(id);
|
|
|
+ function esc(s) { if (!s) return ''; const d = document.createElement('div'); d.textContent = s; return d.innerHTML; }
|
|
|
+ function relTime(iso) {
|
|
|
+ if (!iso) return '';
|
|
|
+ const m = Math.floor((Date.now() - new Date(iso).getTime()) / 60000);
|
|
|
+ if (m < 1) return '刚刚'; if (m < 60) return m + ' 分钟前';
|
|
|
+ const h = Math.floor(m / 60); if (h < 24) return h + ' 小时前';
|
|
|
+ const d = Math.floor(h / 24); if (d < 30) return d + ' 天前';
|
|
|
+ const date = new Date(iso);
|
|
|
+ return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`;
|
|
|
+ }
|
|
|
+
|
|
|
+ async function api(url) { const r = await fetch(url); if (!r.ok) throw new Error(r.status); return r.json(); }
|
|
|
+
|
|
|
+ async function loadAllStages() {
|
|
|
+ $('stageTreeWrap').innerHTML = '<div style="padding:16px;text-align:center;"><div class="spinner" style="margin:0 auto 8px;"></div><span style="font-size:12px;color:var(--text-muted)">加载中...</span></div>';
|
|
|
+ try {
|
|
|
+ S.stages = await api('/stages/all');
|
|
|
+ S.stageProjectMap = {};
|
|
|
+ S.stages.forEach(st => { S.stageProjectMap[st.name] = st.project_id; });
|
|
|
+ renderStageTree();
|
|
|
+ } catch (e) { $('stageTreeWrap').innerHTML = '<div style="padding:16px;color:#fc8181;font-size:13px;">加载失败</div>'; }
|
|
|
+ }
|
|
|
+
|
|
|
+ function buildTree(stages) {
|
|
|
+ const root = [];
|
|
|
+ for (const st of stages) {
|
|
|
+ const parts = st.name.split('/');
|
|
|
+ let cur = root;
|
|
|
+ for (let i = 0; i < parts.length; i++) {
|
|
|
+ let node = cur.find(n => n.label === parts[i]);
|
|
|
+ if (!node) { node = { label: parts[i], children: [] }; cur.push(node); }
|
|
|
+ if (i === parts.length - 1) { node.stage = st.name; node.count = st.version_count; }
|
|
|
+ cur = node.children;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return root;
|
|
|
+ }
|
|
|
+
|
|
|
+ function renderStageTree() {
|
|
|
+ const tree = buildTree(S.stages);
|
|
|
+ $('stageTreeWrap').innerHTML = tree.length ? renderNodes(tree) : '<div style="padding:16px;font-size:13px;color:var(--text-muted)">暂无数据阶段</div>';
|
|
|
+ }
|
|
|
+
|
|
|
+ function renderNodes(nodes) {
|
|
|
+ let h = '';
|
|
|
+ for (const n of nodes) {
|
|
|
+ if (n.stage && n.children.length === 0) {
|
|
|
+ h += `<div class="tree-leaf" data-stage="${esc(n.stage)}" onclick="selectStage(this, '${esc(n.stage)}')">
|
|
|
+ <span class="tree-dot"></span><span>${esc(n.label)}</span>
|
|
|
+ <span class="tree-count">${n.count || ''}</span>
|
|
|
+ </div>`;
|
|
|
+ } else {
|
|
|
+ const id = 'tb_' + Math.random().toString(36).substr(2, 6);
|
|
|
+ h += `<div>
|
|
|
+ <div class="tree-branch-header" onclick="toggleBranch('${id}', this)">
|
|
|
+ <span class="tree-arrow" id="a_${id}">${IC.chevron}</span><span>${esc(n.label)}</span>
|
|
|
+ </div>
|
|
|
+ <div class="tree-children" id="${id}">${renderNodes(n.children)}</div>
|
|
|
+ </div>`;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return h;
|
|
|
+ }
|
|
|
+
|
|
|
+ function toggleBranch(id) {
|
|
|
+ const ch = $(id), ar = $('a_' + id);
|
|
|
+ if (ch) ch.classList.toggle('open');
|
|
|
+ if (ar) ar.classList.toggle('open');
|
|
|
+ }
|
|
|
+
|
|
|
+ function selectStage(el, stageName) {
|
|
|
+ document.querySelectorAll('.tree-leaf.active').forEach(e => e.classList.remove('active'));
|
|
|
+ el.classList.add('active');
|
|
|
+ S.stage = stageName;
|
|
|
+ S.records = []; S.skip = 0; S.hasMore = true;
|
|
|
+ updateHeader();
|
|
|
+ loadRecords();
|
|
|
+ }
|
|
|
+
|
|
|
+ function updateHeader() {
|
|
|
+ if (!S.stage) {
|
|
|
+ $('stagePath').innerHTML = '<span class="seg" style="color:var(--text-muted)">选择左侧数据阶段</span>';
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const parts = S.stage.split('/');
|
|
|
+ $('stagePath').innerHTML = parts.map((p, i) => `${i > 0 ? '<span class="sep">/</span>' : ''}<span class="seg">${esc(p)}</span>`).join('');
|
|
|
+ }
|
|
|
+
|
|
|
+ async function loadRecords(append = false) {
|
|
|
+ if (S.loading) return;
|
|
|
+ S.loading = true;
|
|
|
+ if (!append) $('contentBody').innerHTML = '<div class="state-box"><div class="spinner"></div><p>加载中...</p></div>';
|
|
|
+
|
|
|
+ try {
|
|
|
+ const pid = S.stageProjectMap[S.stage];
|
|
|
+ const data = await api(`/projects/${pid}/records?stage=${encodeURIComponent(S.stage)}&skip=${S.skip}&limit=${PAGE_SIZE}`);
|
|
|
+
|
|
|
+ if (!append) S.records = [];
|
|
|
+ S.records.push(...data);
|
|
|
+ S.hasMore = data.length >= PAGE_SIZE;
|
|
|
+ S.skip += data.length;
|
|
|
+
|
|
|
+ renderTable();
|
|
|
+ } catch (e) {
|
|
|
+ if (!append) $('contentBody').innerHTML = '<div class="state-box"><p style="color:#fc8181;">加载失败: ' + esc(e.message) + '</p></div>';
|
|
|
+ }
|
|
|
+ S.loading = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* ------- Bubble Directory Tree Builder ------- */
|
|
|
+ function buildFileTree(files) {
|
|
|
+ const root = { dirs: {}, files: [], path: '' };
|
|
|
+ if (!files || !files.length) return root;
|
|
|
+
|
|
|
+ files.forEach(f => {
|
|
|
+ const parts = f.relative_path.split('/');
|
|
|
+ let cur = root;
|
|
|
+ for (let i = 0; i < parts.length - 1; i++) {
|
|
|
+ const p = parts[i];
|
|
|
+ if (!cur.dirs[p]) {
|
|
|
+ const curPath = cur.path ? cur.path + '/' + p : p;
|
|
|
+ cur.dirs[p] = { name: p, path: curPath, dirs: {}, files: [] };
|
|
|
+ }
|
|
|
+ cur = cur.dirs[p];
|
|
|
+ }
|
|
|
+ cur.files.push(f);
|
|
|
+ });
|
|
|
+
|
|
|
+ // Compact single-child directories
|
|
|
+ function compact(node) {
|
|
|
+ Object.keys(node.dirs).forEach(k => compact(node.dirs[k]));
|
|
|
+ Object.keys(node.dirs).forEach(k => {
|
|
|
+ let child = node.dirs[k];
|
|
|
+ if (!child) return;
|
|
|
+ let changed = true;
|
|
|
+ while (changed) {
|
|
|
+ changed = false;
|
|
|
+ if (Object.keys(child.dirs).length === 1 && child.files.length === 0) {
|
|
|
+ const onlyChildKey = Object.keys(child.dirs)[0];
|
|
|
+ const onlyChild = child.dirs[onlyChildKey];
|
|
|
+ child.name = child.name + '/' + onlyChild.name;
|
|
|
+ child.path = onlyChild.path;
|
|
|
+ child.dirs = onlyChild.dirs;
|
|
|
+ child.files = onlyChild.files;
|
|
|
+ changed = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ compact(root);
|
|
|
+ return root;
|
|
|
+ }
|
|
|
+
|
|
|
+ function renderSubTree(node, depth) {
|
|
|
+ let h = '';
|
|
|
+ const dirKeys = Object.keys(node.dirs).sort((a, b) => a.localeCompare(b));
|
|
|
+ dirKeys.forEach(k => {
|
|
|
+ const d = node.dirs[k];
|
|
|
+ const gid = 'fg_' + Math.random().toString(36).substr(2, 6);
|
|
|
+ const padding = `padding-left: ${10 + depth * 14}px;`;
|
|
|
+ h += `
|
|
|
+ <div class="fg-header" style="${padding}" onclick="toggleBranch('${gid}')">
|
|
|
+ <span class="fg-arrow" id="a_${gid}">${IC.chevron}</span>
|
|
|
+ <span class="fg-icon">${IC.folder}</span>
|
|
|
+ <span class="fg-name" title="${esc(d.path)}">${esc(d.name)}/</span>
|
|
|
+ </div>
|
|
|
+ <div class="tree-children open" id="${gid}" style="margin-left:0; padding-left:0; border-left:none;">
|
|
|
+ ${renderSubTree(d, depth + 1)}
|
|
|
+ </div>`;
|
|
|
+ });
|
|
|
+
|
|
|
+ node.files.sort((a, b) => a.relative_path.localeCompare(b.relative_path)).forEach(f => {
|
|
|
+ let displayName = f.relative_path;
|
|
|
+ if (node.path && f.relative_path.startsWith(node.path + '/')) {
|
|
|
+ displayName = f.relative_path.substring(node.path.length + 1);
|
|
|
+ } else if (f.relative_path.includes('/')) {
|
|
|
+ displayName = f.relative_path.split('/').pop();
|
|
|
+ }
|
|
|
+ const padding = `padding-left: ${10 + depth * 14 + (dirKeys.length > 0 ? 18 : 0)}px;`;
|
|
|
+ h += `
|
|
|
+ <div class="file-row" style="${padding}">
|
|
|
+ <div class="file-name-col" title="${esc(f.relative_path)}">
|
|
|
+ <span class="f-icon">${IC.file}</span>
|
|
|
+ <span class="f-name">${esc(displayName)}</span>
|
|
|
+ </div>
|
|
|
+ <a class="btn-dl" href="/files/${f.id}/content" download><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg></a>
|
|
|
+ </div>`;
|
|
|
+ if (f.extracted_value) {
|
|
|
+ h += `<div style="padding-left: ${10 + depth * 14 + (dirKeys.length > 0 ? 18 : 0)}px; padding-right:10px; padding-bottom:6px; margin-top:-4px; color:var(--text-muted); font-size:11px; white-space:pre-wrap; word-break:break-all;">↳ Extract: ${esc(f.extracted_value)}</div>`;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return h;
|
|
|
+ }
|
|
|
+
|
|
|
+ function renderBubbleTree(files) {
|
|
|
+ if (!files || files.length === 0) return '<div class="empty-cell">无数据</div>';
|
|
|
+ const root = buildFileTree(files);
|
|
|
+ return `<div class="bubble-tree" style="margin-bottom:8px;">${renderSubTree(root, 0)}</div>`;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* ------- Render Table ------- */
|
|
|
+ function renderTable() {
|
|
|
+ if (!S.records.length) {
|
|
|
+ $('contentBody').innerHTML = '<div class="state-box"><h2>暂无数据</h2><p>找不到符合要求的阶段记录数据</p></div>';
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Extract dynamic columns
|
|
|
+ const inLabels = new Set();
|
|
|
+ const outLabels = new Set();
|
|
|
+
|
|
|
+ S.records.forEach(r => {
|
|
|
+ (r.inputs || []).forEach(f => inLabels.add(f.label || '未命名'));
|
|
|
+ (r.outputs || []).forEach(f => outLabels.add(f.label || '未命名'));
|
|
|
+ });
|
|
|
+
|
|
|
+ const sortedInLabels = Array.from(inLabels).sort();
|
|
|
+ const sortedOutLabels = Array.from(outLabels).sort();
|
|
|
+
|
|
|
+ let h = `<div style="overflow-x:auto;">
|
|
|
+ <table class="records-table">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th>Metadata</th>`;
|
|
|
+ sortedInLabels.forEach(lbl => h += `<th>${esc(lbl)} (输入)</th>`);
|
|
|
+ sortedOutLabels.forEach(lbl => h += `<th>${esc(lbl)} (输出)</th>`);
|
|
|
+ h += ` </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>`;
|
|
|
+
|
|
|
+ S.records.forEach(r => {
|
|
|
+ h += `<tr><td class="meta-cell">
|
|
|
+ <div class="commit-badge">${IC.commit} ${esc(r.commit_id.substring(0, 8))}</div>
|
|
|
+ <div class="meta-text">By: ${esc(r.author || 'unknown')}</div>
|
|
|
+ <div class="meta-text">Time: ${relTime(r.created_at)}</div>
|
|
|
+ ${r.group_key ? `<div class="meta-text" style="color:var(--orange)">Grp: ${esc(r.group_key)}</div>` : ''}
|
|
|
+ </td>`;
|
|
|
+
|
|
|
+ sortedInLabels.forEach(lbl => {
|
|
|
+ const groupFiles = (r.inputs || []).filter(f => (f.label || '未命名') === lbl);
|
|
|
+ h += `<td>${renderBubbleTree(groupFiles)}</td>`;
|
|
|
+ });
|
|
|
+
|
|
|
+ sortedOutLabels.forEach(lbl => {
|
|
|
+ const groupFiles = (r.outputs || []).filter(f => (f.label || '未命名') === lbl);
|
|
|
+ h += `<td>${renderBubbleTree(groupFiles)}</td>`;
|
|
|
+ });
|
|
|
+ h += `</tr>`;
|
|
|
+ });
|
|
|
+
|
|
|
+ h += ` </tbody>
|
|
|
+ </table>
|
|
|
+ </div>`;
|
|
|
+
|
|
|
+ if (S.hasMore) {
|
|
|
+ h += '<div class="load-more"><button class="load-more-btn" onclick="loadRecords(true)">加载更多</button></div>';
|
|
|
+ }
|
|
|
+
|
|
|
+ $('contentBody').innerHTML = h;
|
|
|
+ }
|
|
|
+
|
|
|
+ loadAllStages();
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+
|
|
|
+</html>
|