style: color dashboard sections
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "shusub2"
|
||||
version = "0.2.6"
|
||||
version = "0.2.7"
|
||||
description = "Terminal UI for Sub2API account quota and daily usage"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.11"
|
||||
|
||||
+20
-9
@@ -19,7 +19,7 @@ from typing import Any
|
||||
|
||||
|
||||
APP_NAME = "shusub2"
|
||||
FALLBACK_VERSION = "0.2.6"
|
||||
FALLBACK_VERSION = "0.2.7"
|
||||
DEFAULT_API_URL = "http://127.0.0.1:18318/api/tui/accounts"
|
||||
DEFAULT_CONFIG_FILE = "~/.config/shusub2/api-url"
|
||||
DEFAULT_STATUS_CONFIG_FILE = "~/.config/shusub2/status-url"
|
||||
@@ -1491,13 +1491,17 @@ def run_textual(
|
||||
if self.key_rows:
|
||||
top_key = self.key_rows[0]
|
||||
key_summary = f"keys {top_key['name']} {format_cost(top_key['cost'])}"
|
||||
summary = (
|
||||
f"accounts {len(self.account_rows)}/{account_total} ({usable} usable, "
|
||||
f"{format_cost(totals.get('today_cost_usd'))}) | "
|
||||
f"keys {len(self.key_rows)} ({key_summary.removeprefix('keys ')}) | "
|
||||
f"logs {len(self.log_rows)}/{logs_total} | "
|
||||
f"errors {len(self.error_rows)}/{self.errors_total()}"
|
||||
summary = Text()
|
||||
summary.append(
|
||||
f"accounts {len(self.account_rows)}/{account_total} ({usable} usable, {format_cost(totals.get('today_cost_usd'))})",
|
||||
style="green",
|
||||
)
|
||||
summary.append(" | ", style="dim")
|
||||
summary.append(f"keys {len(self.key_rows)} ({key_summary.removeprefix('keys ')})", style="yellow")
|
||||
summary.append(" | ", style="dim")
|
||||
summary.append(f"logs {len(self.log_rows)}/{logs_total}", style="magenta")
|
||||
summary.append(" | ", style="dim")
|
||||
summary.append(f"errors {len(self.error_rows)}/{self.errors_total()}", style="red")
|
||||
self.query_one("#summary", Static).update(summary)
|
||||
|
||||
status_bits = [version_message]
|
||||
@@ -1958,14 +1962,21 @@ def run_textual(
|
||||
|
||||
class Sub2APIQuotaApp(App[None]):
|
||||
CSS = """
|
||||
#summary { height: 1; padding: 0 1; color: $accent; }
|
||||
#summary { height: 1; padding: 0 1; color: $foreground; }
|
||||
#filter { height: 1; border: none; padding: 0 1; }
|
||||
#filter:focus { border: none; }
|
||||
#accounts { height: 1fr; min-height: 3; }
|
||||
#keys { height: auto; max-height: 6; }
|
||||
.dashboard #keys { height: 1fr; min-height: 0; max-height: 100%; }
|
||||
.dashboard #accounts { background: $success 5%; }
|
||||
.dashboard #accounts > .datatable--header { background: $success 35%; color: $foreground; }
|
||||
.dashboard #keys { height: 1fr; min-height: 0; max-height: 100%; background: $warning 5%; }
|
||||
.dashboard #keys > .datatable--header { background: $warning 35%; color: $foreground; }
|
||||
#logs { height: 1fr; min-height: 3; }
|
||||
.dashboard #logs { background: $secondary 5%; }
|
||||
.dashboard #logs > .datatable--header { background: $secondary 35%; color: $foreground; }
|
||||
#errors { height: 1fr; min-height: 3; }
|
||||
.dashboard #errors { background: $error 5%; }
|
||||
.dashboard #errors > .datatable--header { background: $error 35%; color: $foreground; }
|
||||
#detail { height: 2; padding: 0 1; background: $surface-lighten-1; }
|
||||
#status { height: 1; padding: 0 1; color: $text-muted; }
|
||||
"""
|
||||
|
||||
@@ -755,10 +755,11 @@ class DashboardLayoutTests(unittest.IsolatedAsyncioTestCase):
|
||||
self.assertEqual(type(screen).__name__, "DashboardScreen")
|
||||
self.assertEqual(screen.query_one("#filter").region.height, 1)
|
||||
self.assertEqual(screen.query_one("#detail").region.height, 2)
|
||||
for selector in ("#accounts", "#keys", "#logs", "#errors"):
|
||||
table = screen.query_one(selector)
|
||||
tables = [screen.query_one(selector) for selector in ("#accounts", "#keys", "#logs", "#errors")]
|
||||
for table in tables:
|
||||
self.assertGreaterEqual(table.region.height, 4)
|
||||
self.assertLessEqual(table.virtual_size.width, table.region.width)
|
||||
self.assertEqual(len({table.styles.background for table in tables}), 4)
|
||||
self.assertIn("wmy", str(screen.query_one("#summary").render()))
|
||||
for key, expected_id in (("k", "keys"), ("l", "logs"), ("e", "errors"), ("a", "accounts")):
|
||||
await pilot.press(key)
|
||||
|
||||
Reference in New Issue
Block a user