Skip to content

Commit

Permalink
fix(ui): live tail should pretty print json
Browse files Browse the repository at this point in the history
close #1444
  • Loading branch information
tchiotludo committed Jun 27, 2023
1 parent a6f5cb4 commit 551f63a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion client/src/containers/Tail/Tail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'ace-builds/src-noconflict/theme-merbivore_soft';
import Root from '../../components/Root';
import DateTime from '../../components/DateTime';
import { EventSourcePolyfill } from 'event-source-polyfill';
import * as LosslessJson from 'lossless-json';

const STATUS = {
STOPPED: 'STOPPED',
Expand Down Expand Up @@ -464,12 +465,19 @@ class Tail extends Root {
type: 'text',
extraRow: true,
extraRowContent: (obj, index) => {
let value = obj.value;
try {
let json = LosslessJson.parse(obj.value);
value = LosslessJson.stringify(json, undefined, ' ');
// eslint-disable-next-line no-empty
} catch (e) {}

return (
<AceEditor
mode="json"
id={'value' + index}
theme="merbivore_soft"
value={obj.value}
value={value || 'null'}
readOnly
name="UNIQUE_ID_OF_DIV"
editorProps={{ $blockScrolling: true }}
Expand Down

1 comment on commit 551f63a

@htbmw
Copy link

@htbmw htbmw commented on 551f63a Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the implementation!

Please sign in to comment.