fix: 数据列表改为卡片内滚动,概览卡片说明完整换行
数据表占满顶栏以下的剩余高度,横竖滚动都发生在表格内部,表头固定、分页栏始终可见。概览卡片不再把说明截成半句,放得下就换行;源文件名单过长时卡片只保留完整短句。
This commit is contained in:
@@ -60,6 +60,7 @@ MESSAGES: dict[str, dict[str, str]] = {
|
||||
"trigger.manual": "手动",
|
||||
"trigger.dryRun": "试运行",
|
||||
"detail.missing": "缺少 {count} 类:{sources}",
|
||||
"detail.missingShort": "缺少 {count} 类源文件",
|
||||
"detail.noFiles": "未找到源文件",
|
||||
"detail.upToDate": "数据库已是 {time}",
|
||||
"detail.timeout": "超过 {n} 分钟未完成",
|
||||
@@ -239,6 +240,7 @@ MESSAGES: dict[str, dict[str, str]] = {
|
||||
"trigger.manual": "Manual",
|
||||
"trigger.dryRun": "Dry run",
|
||||
"detail.missing": "Missing {count}: {sources}",
|
||||
"detail.missingShort": "{count} source types missing",
|
||||
"detail.noFiles": "No source files found",
|
||||
"detail.upToDate": "Database already at {time}",
|
||||
"detail.timeout": "Not finished within {n} min",
|
||||
|
||||
+15
-6
@@ -118,16 +118,17 @@ body.body--dark {
|
||||
.etl-card-icon { font-size: 18px; color: var(--etl-muted); }
|
||||
|
||||
.etl-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
|
||||
.etl-metric { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; min-height: 120px; }
|
||||
.etl-metric-head { display: flex; align-items: center; justify-content: space-between; }
|
||||
.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; }
|
||||
.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.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.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; color: var(--etl-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.etl-metric-notes { display: flex; flex-direction: column; gap: 2px; min-height: 18px; }
|
||||
.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); }
|
||||
@@ -201,7 +202,14 @@ body.body--dark {
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.etl-data-summary.tone-danger { color: var(--etl-danger); }
|
||||
.etl-data-table .q-table__middle { overflow-x: auto; }
|
||||
.etl-data-card {
|
||||
display: flex; flex-direction: column; min-height: 420px;
|
||||
height: calc(100vh - 109px); height: calc(100dvh - 109px);
|
||||
}
|
||||
.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-cell-name { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.etl-net {
|
||||
@@ -292,6 +300,7 @@ body.body--dark {
|
||||
.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%; }
|
||||
.etl-data-card { height: calc(100vh - 93px); height: calc(100dvh - 93px); }
|
||||
}
|
||||
</style>
|
||||
"""
|
||||
|
||||
+40
-14
@@ -234,8 +234,16 @@ class AdminPage:
|
||||
with ui.element("div").classes("etl-metric-value-row"):
|
||||
spinner = ui.spinner(size="18px").classes("etl-metric-spinner")
|
||||
value = ui.label("").classes("etl-metric-value")
|
||||
sub = ui.label("").classes("etl-metric-sub")
|
||||
return {"value": value, "sub": sub, "spinner": spinner}
|
||||
with ui.element("div").classes("etl-metric-notes"):
|
||||
sub = ui.label("").classes("etl-metric-sub")
|
||||
extra = ui.label("").classes("etl-metric-sub")
|
||||
return {"value": value, "sub": sub, "extra": extra, "spinner": spinner}
|
||||
|
||||
def set_notes(self, card: dict[str, Any], *lines: str) -> None:
|
||||
visible = [line for line in lines if line and line != self.t("empty.dash")]
|
||||
for label, text in zip((card["sub"], card["extra"]), [*visible, "", ""][:2], strict=True):
|
||||
label.set_text(text)
|
||||
label.set_visibility(bool(text))
|
||||
|
||||
def refresh(self) -> None:
|
||||
self.status = self.service.status()
|
||||
@@ -268,14 +276,14 @@ class AdminPage:
|
||||
card = self.card_schedule
|
||||
if not status["configured"]:
|
||||
card["value"].set_text(t("schedule.setup"))
|
||||
card["sub"].set_text(t("empty.dash"))
|
||||
self.set_notes(card)
|
||||
elif not status["schedule_enabled"]:
|
||||
card["value"].set_text(t("schedule.paused"))
|
||||
card["sub"].set_text(self.schedule_text())
|
||||
self.set_notes(card, self.schedule_text())
|
||||
else:
|
||||
card["value"].set_text(self.schedule_text())
|
||||
next_run = status["next_run_at"]
|
||||
card["sub"].set_text(t("schedule.next", time=next_run[11:19]) if next_run else t("empty.dash"))
|
||||
self.set_notes(card, t("schedule.next", time=next_run[11:19]) if next_run else "")
|
||||
card["value"].classes(replace="etl-metric-value" + ("" if status["schedule_enabled"] else " is-muted"))
|
||||
card["spinner"].set_visibility(False)
|
||||
|
||||
@@ -284,19 +292,20 @@ class AdminPage:
|
||||
card["spinner"].set_visibility(bool(running))
|
||||
if running:
|
||||
card["value"].set_text(t("current.running"))
|
||||
card["sub"].set_text(
|
||||
self.set_notes(
|
||||
card,
|
||||
t(
|
||||
"current.elapsed",
|
||||
id=running["id"],
|
||||
trigger=self.trigger_text(running["trigger"], running["dry_run"]),
|
||||
elapsed=elapsed_since(running["started_at"]),
|
||||
)
|
||||
),
|
||||
)
|
||||
else:
|
||||
last = status["last_run"]
|
||||
card["value"].set_text(t("current.idle"))
|
||||
finished = (last or {}).get("finished_at") or ""
|
||||
card["sub"].set_text(t("current.lastFinished", time=finished[5:19]) if finished else t("empty.dash"))
|
||||
self.set_notes(card, t("current.lastFinished", time=finished[5:19]) if finished else "")
|
||||
card["value"].classes(replace="etl-metric-value" + (" tone-primary" if running else ""))
|
||||
|
||||
last = status["last_run"]
|
||||
@@ -305,11 +314,15 @@ class AdminPage:
|
||||
if last:
|
||||
card["value"].set_text(self.status_text(last))
|
||||
card["value"].classes(replace=f"etl-metric-value tone-{tone_of(last['status'])}")
|
||||
card["sub"].set_text(f"{last['started_at'][5:19]} · {self.detail_text(last) or self.trigger_text(last['trigger'], last['dry_run'])}")
|
||||
self.set_notes(
|
||||
card,
|
||||
last["started_at"][5:19],
|
||||
self.card_detail(last) or self.trigger_text(last["trigger"], last["dry_run"]),
|
||||
)
|
||||
else:
|
||||
card["value"].set_text(t("empty.never"))
|
||||
card["value"].classes(replace="etl-metric-value is-muted")
|
||||
card["sub"].set_text(t("empty.dash"))
|
||||
self.set_notes(card)
|
||||
|
||||
latest = status["last_processed"]
|
||||
card = self.card_latest
|
||||
@@ -317,14 +330,15 @@ class AdminPage:
|
||||
if latest:
|
||||
card["value"].set_text(short_time(latest["target_time"]) or t("empty.dash"))
|
||||
rows = latest.get("summary_rows")
|
||||
card["sub"].set_text(
|
||||
t("latest.rows", rows=f"{rows:,}" if isinstance(rows, int) else "-", time=(latest["finished_at"] or "")[5:16])
|
||||
self.set_notes(
|
||||
card,
|
||||
t("latest.rows", rows=f"{rows:,}" if isinstance(rows, int) else "-", time=(latest["finished_at"] or "")[5:16]),
|
||||
)
|
||||
card["value"].classes(replace="etl-metric-value")
|
||||
else:
|
||||
card["value"].set_text(t("empty.dash"))
|
||||
card["value"].set_text(t("empty.never"))
|
||||
card["value"].classes(replace="etl-metric-value is-muted")
|
||||
card["sub"].set_text(t("empty.never"))
|
||||
self.set_notes(card)
|
||||
|
||||
def refresh_actions(self) -> None:
|
||||
running = bool(self.status["running"])
|
||||
@@ -569,6 +583,9 @@ class AdminPage:
|
||||
self.data_table.rows = [self.data_row(index, item) for index, item in enumerate(self.data_items)]
|
||||
self.data_table.props["no-data-label"] = t("data.noMatch" if result["networks"] else "data.empty")
|
||||
self.data_table.update()
|
||||
self.data_table.client.run_javascript(
|
||||
f"document.querySelector('#{self.data_table.html_id} .q-table__middle')?.scrollTo(0, 0)"
|
||||
)
|
||||
self.data_pagination.max = result["pages"]
|
||||
self.data_pagination.value = result["page"]
|
||||
self.data_pagination.update()
|
||||
@@ -976,6 +993,15 @@ class AdminPage:
|
||||
return self.t("trigger.dryRun")
|
||||
return self.t(f"trigger.{trigger}")
|
||||
|
||||
def card_detail(self, row: dict[str, Any]) -> str:
|
||||
if row["status"] == "waiting":
|
||||
detail = str(row.get("detail") or "")
|
||||
if not detail or detail == "no_source_files":
|
||||
return self.t("detail.noFiles")
|
||||
count = len([item for item in detail.split(",") if item])
|
||||
return self.t("detail.missingShort", count=count)
|
||||
return self.detail_text(row)
|
||||
|
||||
def detail_text(self, row: dict[str, Any]) -> str:
|
||||
status, detail = row["status"], str(row.get("detail") or "")
|
||||
if status == "waiting":
|
||||
|
||||
Reference in New Issue
Block a user