diff --git a/etl_app/i18n.py b/etl_app/i18n.py index 9338650..afcd7fe 100644 --- a/etl_app/i18n.py +++ b/etl_app/i18n.py @@ -14,7 +14,6 @@ MESSAGES: dict[str, dict[str, str]] = { "header.languageShort": "EN", "card.schedule": "定时任务", "card.current": "当前状态", - "card.lastRun": "最近结果", "card.latestData": "最新入库", "schedule.every": "每 {n} 分钟", "schedule.cron": "Cron {expr}", @@ -59,9 +58,7 @@ MESSAGES: dict[str, dict[str, str]] = { "trigger.schedule": "定时", "trigger.manual": "手动", "trigger.dryRun": "试运行", - "detail.missing": "缺少 {count} 类:{sources}", - "detail.missingShort": "缺少 {count} 类源文件", - "detail.noFiles": "未找到源文件", + "detail.missing": "缺少 {count} 类:{sources}", "detail.noFiles": "未找到源文件", "detail.upToDate": "数据库已是 {time}", "detail.timeout": "超过 {n} 分钟未完成", "detail.dryRunOutput": "结果保存在本地", @@ -194,7 +191,6 @@ MESSAGES: dict[str, dict[str, str]] = { "header.languageShort": "中", "card.schedule": "Schedule", "card.current": "Current", - "card.lastRun": "Last result", "card.latestData": "Latest data", "schedule.every": "Every {n} min", "schedule.cron": "Cron {expr}", @@ -239,9 +235,7 @@ MESSAGES: dict[str, dict[str, str]] = { "trigger.schedule": "Scheduled", "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.missing": "Missing {count}: {sources}", "detail.noFiles": "No source files found", "detail.upToDate": "Database already at {time}", "detail.timeout": "Not finished within {n} min", "detail.dryRunOutput": "Result kept locally", diff --git a/etl_app/theme.py b/etl_app/theme.py index f7369e8..6da958d 100644 --- a/etl_app/theme.py +++ b/etl_app/theme.py @@ -105,6 +105,7 @@ body.body--dark { .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; } +.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%; } .etl-panel { display: flex !important; flex-direction: column; align-items: stretch !important; gap: 16px !important; } @@ -117,7 +118,7 @@ body.body--dark { .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(4, minmax(0, 1fr)); gap: 16px; } +.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); } @@ -127,7 +128,6 @@ body.body--dark { .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-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); } @@ -211,7 +211,8 @@ body.body--dark { .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-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); @@ -287,7 +288,6 @@ body.body--dark { .etl-forbidden-title { font-size: 18px; font-weight: 600; } @media (max-width: 1080px) { - .etl-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } .etl-split { grid-template-columns: 1fr; } .etl-user-name, .etl-brand-sub { display: none; } } diff --git a/etl_app/ui.py b/etl_app/ui.py index 18a7be6..d125418 100644 --- a/etl_app/ui.py +++ b/etl_app/ui.py @@ -123,7 +123,7 @@ class AdminPage: self.status = self.service.status() with ui.element("div").classes("etl-shell"): self.build_header() - with ui.element("main").classes("etl-main"): + with ui.element("main").classes("etl-main") as main: with ui.tab_panels(self.tabs, value="overview", animated=False).classes("etl-panels"): with ui.tab_panel("overview").classes("etl-panel"): self.build_overview() @@ -133,6 +133,7 @@ class AdminPage: self.build_data() with ui.tab_panel("settings").classes("etl-panel"): self.build_settings() + self.main = main self.build_log_dialog() self.build_data_dialog() self.refresh() @@ -190,7 +191,6 @@ class AdminPage: with ui.element("div").classes("etl-cards"): self.card_schedule = self.metric_card("schedule", t("card.schedule")) self.card_current = self.metric_card("bolt", t("card.current")) - self.card_last = self.metric_card("task_alt", t("card.lastRun")) self.card_latest = self.metric_card("storage", t("card.latestData")) with ui.element("section").classes("etl-card etl-actions"): @@ -234,16 +234,12 @@ 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") - 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} + sub = ui.label("").classes("etl-metric-sub") + return {"value": value, "sub": sub, "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 set_notes(self, card: dict[str, Any], text: str = "") -> None: + card["sub"].set_text(text) + card["sub"].set_visibility(bool(text)) def refresh(self) -> None: self.status = self.service.status() @@ -262,6 +258,7 @@ class AdminPage: return latest.get("id", 0) async def change_tab(self, event: Any) -> None: + self.main.classes(add="is-wide") if event.value == "data" else self.main.classes(remove="is-wide") if event.value == "data" and self.data_marker is None: await self.load_data() @@ -308,22 +305,6 @@ class AdminPage: 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"] - card = self.card_last - card["spinner"].set_visibility(False) - if last: - card["value"].set_text(self.status_text(last)) - card["value"].classes(replace=f"etl-metric-value tone-{tone_of(last['status'])}") - 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") - self.set_notes(card) - latest = status["last_processed"] card = self.card_latest card["spinner"].set_visibility(False) @@ -502,7 +483,7 @@ class AdminPage: columns = [ {"name": "network", "label": t("data.col.network"), "field": "network_type", "align": "left"}, {"name": "cgi", "label": t("data.col.cgi"), "field": "cgi", "align": "left"}, - {"name": "cell", "label": t("data.col.cell"), "field": "cell_name", "align": "left"}, + {"name": "cell", "label": t("data.col.cell"), "field": "cell_name", "align": "left", "classes": "etl-col-cell"}, {"name": "interference", "label": t("data.col.interference"), "field": "interference_dbm", "align": "right"}, {"name": "prev", "label": t("data.col.prev"), "field": "prev_interference_dbm", "align": "right"}, {"name": "change", "label": t("data.col.change"), "field": "change", "align": "right"}, @@ -993,15 +974,6 @@ 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":