server: improve warning formatting
Introduce a "raw" parameter for /server/info that defaults to False. Front ends that do not wish to recieve warnings with html line breaks may set this parameter to True, otherwise newlines will be replaced with "<br/>". Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
a8cbfe6345
commit
9a466f3b22
|
@ -399,6 +399,7 @@ class Server:
|
||||||
async def _handle_info_request(self,
|
async def _handle_info_request(self,
|
||||||
web_request: WebRequest
|
web_request: WebRequest
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
|
raw = web_request.get_boolean("raw", False)
|
||||||
file_manager: Optional[FileManager] = self.lookup_component(
|
file_manager: Optional[FileManager] = self.lookup_component(
|
||||||
'file_manager', None)
|
'file_manager', None)
|
||||||
reg_dirs = []
|
reg_dirs = []
|
||||||
|
@ -406,13 +407,19 @@ class Server:
|
||||||
reg_dirs = file_manager.get_registered_dirs()
|
reg_dirs = file_manager.get_registered_dirs()
|
||||||
wsm: WebsocketManager = self.lookup_component('websockets')
|
wsm: WebsocketManager = self.lookup_component('websockets')
|
||||||
mreqs = self.klippy_connection.missing_requirements
|
mreqs = self.klippy_connection.missing_requirements
|
||||||
|
if raw:
|
||||||
|
warnings = list(self.warnings.values())
|
||||||
|
else:
|
||||||
|
warnings = [
|
||||||
|
w.replace("\n", "<br/>") for w in self.warnings.values()
|
||||||
|
]
|
||||||
return {
|
return {
|
||||||
'klippy_connected': self.klippy_connection.is_connected(),
|
'klippy_connected': self.klippy_connection.is_connected(),
|
||||||
'klippy_state': self.klippy_connection.state,
|
'klippy_state': self.klippy_connection.state,
|
||||||
'components': list(self.components.keys()),
|
'components': list(self.components.keys()),
|
||||||
'failed_components': self.failed_components,
|
'failed_components': self.failed_components,
|
||||||
'registered_directories': reg_dirs,
|
'registered_directories': reg_dirs,
|
||||||
'warnings': list(self.warnings.values()),
|
'warnings': warnings,
|
||||||
'websocket_count': wsm.get_count(),
|
'websocket_count': wsm.get_count(),
|
||||||
'moonraker_version': self.app_args['software_version'],
|
'moonraker_version': self.app_args['software_version'],
|
||||||
'missing_klippy_requirements': mreqs,
|
'missing_klippy_requirements': mreqs,
|
||||||
|
|
Loading…
Reference in New Issue