Initial upload: DevDash CLI with TUI dashboard
Some checks failed
CI / test (push) Has been cancelled
Some checks failed
CI / test (push) Has been cancelled
This commit is contained in:
58
src/ui/screens/dashboard.py
Normal file
58
src/ui/screens/dashboard.py
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
from textual.app import ComposeResult
|
||||||
|
from textual.containers import Container, Vertical, Grid
|
||||||
|
from textual.screen import Screen
|
||||||
|
from textual.widgets import Static, Header, Footer, Label
|
||||||
|
from textual import work
|
||||||
|
from src.ui.components.panels import GitStatusPanel, CIStatusPanel, PullRequestsPanel, IssuesPanel
|
||||||
|
from src.api.github import GitHubClient
|
||||||
|
from src.git.status import get_git_status, is_git_repo
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
class DashboardScreen(Screen):
|
||||||
|
CSS = """
|
||||||
|
DashboardScreen {
|
||||||
|
layout: grid;
|
||||||
|
grid-size: 2 2;
|
||||||
|
grid-rows: 1fr 1fr;
|
||||||
|
grid-columns: 1fr 1fr;
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
def compose(self) -> ComposeResult:
|
||||||
|
yield Header(show_clock=True)
|
||||||
|
yield Container(
|
||||||
|
GitStatusPanel(id="git-status"),
|
||||||
|
CIStatusPanel(id="ci-status"),
|
||||||
|
PullRequestsPanel(id="prs"),
|
||||||
|
IssuesPanel(id="issues"),
|
||||||
|
id="dashboard-grid"
|
||||||
|
)
|
||||||
|
yield Footer()
|
||||||
|
|
||||||
|
def on_mount(self) -> None:
|
||||||
|
self.refresh_dashboard()
|
||||||
|
|
||||||
|
def on_key(self, event: events.Key) -> None:
|
||||||
|
if event.key == "r":
|
||||||
|
self.refresh_dashboard()
|
||||||
|
elif event.key == "q":
|
||||||
|
self.app.exit()
|
||||||
|
|
||||||
|
@work(exclusive=True)
|
||||||
|
async def refresh_dashboard(self) -> None:
|
||||||
|
try:
|
||||||
|
git_status = get_git_status()
|
||||||
|
self.query_one("#git-status", GitStatusPanel).update_status(git_status)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
repo = os.environ.get("DEVDASH_REPO", "")
|
||||||
|
if repo and "/" in repo:
|
||||||
|
owner, repo_name = repo.split("/", 1)
|
||||||
|
try:
|
||||||
|
client = GitHubClient()
|
||||||
|
prs = await client.get_pull_requests(owner, repo_name)
|
||||||
|
self.query_one("#prs", PullRequestsPanel).update_prs(prs)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
Reference in New Issue
Block a user