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

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() { renderTabs() {
const {processLogs, processes} = this.props; const {processLogs, processes} = this.props;
@ -70,7 +79,7 @@ class Console extends Component {
.reverse() .reverse()
.map((item, i) => { .map((item, i) => {
if (item.result && (item.result[0] === "{" || item.result[0] === "[")) { if (this.isJsonObject(item)) {
return( return(
<div> <div>
<p key={i} className={item.logLevel} dangerouslySetInnerHTML={{__html: (convert.toHtml(item.command || ""))}}></p> <p key={i} className={item.logLevel} dangerouslySetInnerHTML={{__html: (convert.toHtml(item.command || ""))}}></p>