mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-08 01:14:34 +02:00
Visualize generic object/JSON data of element history data as pretty tree structure on log detail page
This commit is contained in:
parent
9be3eba694
commit
272684e7eb
4 changed files with 57 additions and 1 deletions
|
@ -88,13 +88,23 @@ class LogDataFormatter
|
|||
}
|
||||
|
||||
|
||||
return htmlspecialchars(json_encode($data, JSON_PRETTY_PRINT));
|
||||
return $this->formatJSON($data);
|
||||
}
|
||||
|
||||
|
||||
throw new \RuntimeException('Type of $data not supported (' . gettype($data) . ')');
|
||||
}
|
||||
|
||||
private function formatJSON(array $data): string
|
||||
{
|
||||
$json = htmlspecialchars(json_encode($data, JSON_PRETTY_PRINT), ENT_QUOTES | ENT_SUBSTITUTE);
|
||||
|
||||
return sprintf(
|
||||
'<div data-controller="elements--json-formatter" data-json="%s"></div>',
|
||||
$json
|
||||
);
|
||||
}
|
||||
|
||||
private function formatForeignKey(array $data, AbstractLogEntry $logEntry, string $fieldName): string
|
||||
{
|
||||
//Extract the id from the @id key
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue