Fixed station monitor to be compatible with the backend. i tired, i eeps.
This commit is contained in:
parent
ee6082bf25
commit
45e177125c
1 changed files with 25 additions and 25 deletions
|
|
@ -15,7 +15,6 @@ from prompt_toolkit.layout.containers import Window, VSplit, HSplit
|
|||
from prompt_toolkit.layout.controls import BufferControl
|
||||
from prompt_toolkit.key_binding import KeyBindings
|
||||
import threading
|
||||
import time
|
||||
|
||||
|
||||
def run_station_monitor(hafas: backend.HafasClient | None = None):
|
||||
|
|
@ -69,37 +68,38 @@ def run_station_monitor(hafas: backend.HafasClient | None = None):
|
|||
def handle_enter(event):
|
||||
global app_state
|
||||
|
||||
user_input = userinputBuffer.text.strip()
|
||||
user_input = userinputBuffer.text.strip()
|
||||
|
||||
if not user_input:
|
||||
app_state = "MONITOR"
|
||||
return
|
||||
|
||||
if user_input:
|
||||
app_state = "RESULTS"
|
||||
results = hafas.getStationNames(user_input)
|
||||
|
||||
|
||||
if not results:
|
||||
arrivalBuffer.text = f"Keine Stationen gefunden für: {user_input}"
|
||||
departureBuffer.text= ""
|
||||
userinputBuffer.text=""
|
||||
app_state = "MONITOR"
|
||||
|
||||
else:
|
||||
station_name = results[0][1]
|
||||
station_id = results[0][0]
|
||||
|
||||
arrivals = hafas.getArrDep(station_id, arrdep="ARR", count=3)
|
||||
arrivalBuffer.text = f"Ankünfte für {station_name}:\n"
|
||||
for arrival in arrivals:
|
||||
arrivalBuffer.insert_text(f"\n {arrival}")
|
||||
|
||||
departures = hafas.getArrDep(station_id, arrdep="DEP", count=3)
|
||||
departureBuffer.text = f"Abfahrten für {station_name}:\n"
|
||||
for departure in departures:
|
||||
departureBuffer.insert_text(f"\n {departure}")
|
||||
|
||||
|
||||
departureBuffer.text = ""
|
||||
userinputBuffer.text = ""
|
||||
app_state = "MONITOR"
|
||||
return
|
||||
|
||||
else:
|
||||
app_state = "MONITOR"
|
||||
station_name = results[0][0]
|
||||
station_id = results[0][1]
|
||||
|
||||
arrivals = hafas.getArrDep(station_id, arrdep="ARR", count=5)
|
||||
arrivalBuffer.text = (
|
||||
f"Ankünfte für {station_name}:\n"
|
||||
+ "\n".join(f" {arrival["departure_time"]} {arrival["line"]} --> {arrival["name"]}" for arrival in arrivals)
|
||||
)
|
||||
|
||||
departures = hafas.getArrDep(station_id, arrdep="DEP", count=5)
|
||||
departureBuffer.text = (
|
||||
f"Abfahrten für {station_name}:\n"
|
||||
+ "\n".join(f" {departure["departure_time"]} {departure["line"]} --> {departure["name"]}" for departure in departures)
|
||||
)
|
||||
|
||||
userinputBuffer.text = ""
|
||||
|
||||
|
||||
@keyB.add("c-q")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue