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:
40
src/ui/components/status.py
Normal file
40
src/ui/components/status.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
from textual.widgets import Static
|
||||||
|
from enum import Enum
|
||||||
|
from typing import Literal
|
||||||
|
|
||||||
|
|
||||||
|
class StatusType(str, Enum):
|
||||||
|
SUCCESS = "success"
|
||||||
|
FAILURE = "failure"
|
||||||
|
PENDING = "pending"
|
||||||
|
RUNNING = "running"
|
||||||
|
|
||||||
|
|
||||||
|
class StatusIndicator(Static):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
status: StatusType = StatusType.SUCCESS,
|
||||||
|
**kwargs
|
||||||
|
):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
self.status = status
|
||||||
|
self.update_display()
|
||||||
|
|
||||||
|
def update_display(self) -> None:
|
||||||
|
symbols = {
|
||||||
|
StatusType.SUCCESS: "[✓]",
|
||||||
|
StatusType.FAILURE: "[✗]",
|
||||||
|
StatusType.PENDING: "[?]",
|
||||||
|
StatusType.RUNNING: "[•]",
|
||||||
|
}
|
||||||
|
colors = {
|
||||||
|
StatusType.SUCCESS: "green",
|
||||||
|
StatusType.FAILURE: "red",
|
||||||
|
StatusType.PENDING: "yellow",
|
||||||
|
StatusType.RUNNING: "blue",
|
||||||
|
}
|
||||||
|
self.update(f"{symbols[self.status]} [{colors[self.status]}]{self.status.value}[/]")
|
||||||
|
|
||||||
|
def set_status(self, status: StatusType) -> None:
|
||||||
|
self.status = status
|
||||||
|
self.update_display()
|
||||||
Reference in New Issue
Block a user