refactor json object check

This commit is contained in:
Iuri Matias 2018-10-16 09:26:41 -04:00 committed by Pascal Precht
parent 4020d4d6c1
commit eb8de02ed0
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 10 additions and 1 deletions

View File

@ -57,6 +57,15 @@ class Console extends Component {
)
}
isJsonObject(item) {
if (!item.result) return false;
try {
return typeof(JSON.parse(item.result)) === 'object'
} catch(_err) {
return false;
}
}
renderTabs() {
const {processLogs, processes} = this.props;
@ -70,7 +79,7 @@ class Console extends Component {
.reverse()
.map((item, i) => {
if (item.result && (item.result[0] === "{" || item.result[0] === "[")) {
if (this.isJsonObject(item)) {
return(
<div>
<p key={i} className={item.logLevel} dangerouslySetInnerHTML={{__html: (convert.toHtml(item.command || ""))}}></p>