api: List screens by monitor name
The *GET /screens/* path operation now returns a mapping of monitor names to screen properties. This matches the new behavior of the *POST /screen/{name}/refresh* operation.master
parent
d075a1b1a9
commit
b537896d56
|
@ -71,7 +71,7 @@ def get_marionette():
|
|||
|
||||
@app.get('/screen/')
|
||||
async def list_screens():
|
||||
return {'screens': await svc.get_screens()}
|
||||
return await svc.get_screens()
|
||||
|
||||
|
||||
@app.post(
|
||||
|
|
|
@ -2,7 +2,7 @@ import asyncio
|
|||
import json
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional
|
||||
from typing import Dict, Optional
|
||||
|
||||
import pydantic
|
||||
from aiomarionette import Marionette, WindowRect
|
||||
|
@ -35,16 +35,16 @@ class HUDService:
|
|||
|
||||
self.urls_file = Path('urls.json')
|
||||
|
||||
async def get_screens(self) -> List[HUDScreen]:
|
||||
async def get_screens(self) -> Dict[str, HUDScreen]:
|
||||
assert self.marionette
|
||||
screens = []
|
||||
for handle in await self.marionette.get_window_handles():
|
||||
screens = {}
|
||||
for name, handle in self.windows.items():
|
||||
await self.marionette.switch_to_window(handle)
|
||||
title = await self.marionette.get_title()
|
||||
url = await self.marionette.get_url()
|
||||
rect = await self.marionette.get_window_rect()
|
||||
screens.append(
|
||||
HUDScreen(handle=handle, title=title, url=url, dimensions=rect)
|
||||
screens[name] = HUDScreen(
|
||||
handle=handle, title=title, url=url, dimensions=rect
|
||||
)
|
||||
return screens
|
||||
|
||||
|
|
Loading…
Reference in New Issue