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/')
|
@app.get('/screen/')
|
||||||
async def list_screens():
|
async def list_screens():
|
||||||
return {'screens': await svc.get_screens()}
|
return await svc.get_screens()
|
||||||
|
|
||||||
|
|
||||||
@app.post(
|
@app.post(
|
||||||
|
|
|
@ -2,7 +2,7 @@ import asyncio
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, Optional
|
||||||
|
|
||||||
import pydantic
|
import pydantic
|
||||||
from aiomarionette import Marionette, WindowRect
|
from aiomarionette import Marionette, WindowRect
|
||||||
|
@ -35,16 +35,16 @@ class HUDService:
|
||||||
|
|
||||||
self.urls_file = Path('urls.json')
|
self.urls_file = Path('urls.json')
|
||||||
|
|
||||||
async def get_screens(self) -> List[HUDScreen]:
|
async def get_screens(self) -> Dict[str, HUDScreen]:
|
||||||
assert self.marionette
|
assert self.marionette
|
||||||
screens = []
|
screens = {}
|
||||||
for handle in await self.marionette.get_window_handles():
|
for name, handle in self.windows.items():
|
||||||
await self.marionette.switch_to_window(handle)
|
await self.marionette.switch_to_window(handle)
|
||||||
title = await self.marionette.get_title()
|
title = await self.marionette.get_title()
|
||||||
url = await self.marionette.get_url()
|
url = await self.marionette.get_url()
|
||||||
rect = await self.marionette.get_window_rect()
|
rect = await self.marionette.get_window_rect()
|
||||||
screens.append(
|
screens[name] = HUDScreen(
|
||||||
HUDScreen(handle=handle, title=title, url=url, dimensions=rect)
|
handle=handle, title=title, url=url, dimensions=rect
|
||||||
)
|
)
|
||||||
return screens
|
return screens
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue