detect is log is an object and display json view

This commit is contained in:
Iuri Matias 2018-10-15 21:11:56 -04:00 committed by Pascal Precht
parent b126871a95
commit 4020d4d6c1
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
2 changed files with 9 additions and 4 deletions

View File

@ -117,7 +117,7 @@ export const commands = {
{ {
timestamp: new Date().getTime(), timestamp: new Date().getTime(),
name: EMBARK_PROCESS_NAME, name: EMBARK_PROCESS_NAME,
msg: `console> ${payload.command}<br>${ansiToHtml(command.result)}`, msg: `${ansiToHtml(command.result)}`,
command: `console> ${payload.command}<br>`, command: `console> ${payload.command}<br>`,
result: command.result result: command.result
} }

View File

@ -70,13 +70,18 @@ class Console extends Component {
.reverse() .reverse()
.map((item, i) => { .map((item, i) => {
if (item.result && item.result[0] === "{") { if (item.result && (item.result[0] === "{" || item.result[0] === "[")) {
return( return(
<div>
<p key={i} className={item.logLevel} dangerouslySetInnerHTML={{__html: (convert.toHtml(item.command || ""))}}></p>
<ReactJson src={JSON.parse(item.result)} theme="monokai" sortKeys={true} collapsed={1} /> <ReactJson src={JSON.parse(item.result)} theme="monokai" sortKeys={true} collapsed={1} />
</div>
) )
} }
<p key={i} className={item.logLevel} dangerouslySetInnerHTML={{__html: convert.toHtml(item.msg)}}></p>
return (
<p key={i} className={item.logLevel} dangerouslySetInnerHTML={{__html: (convert.toHtml(item.command || "") + convert.toHtml(item.msg))}}></p>
)
}) })
} }
</Logs> </Logs>