|
1 | 1 | import * as q from '../../../../../backend/src/Model' |
2 | 2 | import * as React from 'react' |
3 | | -import * as fs from 'fs' |
4 | 3 | import CodeDiff from '../CodeDiff' |
5 | 4 | import { AppState } from '../../../reducers' |
6 | 5 | import { Base64Message } from '../../../../../backend/src/Model/Base64Message' |
7 | | -import { Payload } from '../../../../../backend/src/Model/sparkplugb' |
| 6 | +import { SparkplugPayload } from '../../../../../backend/src/Model/SparkplugB' |
8 | 7 | import { connect } from 'react-redux' |
9 | 8 | import { ValueRendererDisplayMode } from '../../../reducers/Settings' |
10 | 9 | import { Fade } from '@material-ui/core' |
| 10 | +import { Decoder } from '../../../../../backend/src/Model/Decoder' |
11 | 11 |
|
12 | 12 | interface Props { |
13 | 13 | message: q.Message |
@@ -49,20 +49,7 @@ class ValueRenderer extends React.Component<Props, State> { |
49 | 49 | try { |
50 | 50 | JSON.parse(str) |
51 | 51 | } catch (error) { |
52 | | - try { |
53 | | - //Sparkplugb |
54 | | - if (Payload === undefined) { |
55 | | - throw Error('sparkplugb.Payload is not loaded yet') |
56 | | - } |
57 | | - let json = Payload.toObject(Payload.decode(Base64Message.toUint8Array(msg)), { |
58 | | - longs: String, |
59 | | - enums: String, |
60 | | - bytes: String, |
61 | | - }) |
62 | | - return [JSON.stringify(json, undefined, ' '), 'json'] |
63 | | - } catch (error) { |
64 | | - return [str, undefined] |
65 | | - } |
| 52 | + return [str, undefined] |
66 | 53 | } |
67 | 54 |
|
68 | 55 | return [this.messageToPrettyJson(str), 'json'] |
@@ -98,7 +85,10 @@ class ValueRenderer extends React.Component<Props, State> { |
98 | 85 | } |
99 | 86 |
|
100 | 87 | public render() { |
101 | | - return <div style={{ padding: '0px 0px 8px 0px', width: '100%' }}>{this.renderValue()}</div> |
| 88 | + return <div style={{ padding: '0px 0px 8px 0px', width: '100%' }}> |
| 89 | + {this.props.message?.payload?.decoder === Decoder.SPARKPLUG && "Decoded SparkplugB"} |
| 90 | + {this.renderValue()} |
| 91 | + </div> |
102 | 92 | } |
103 | 93 |
|
104 | 94 | public renderValue() { |
|
0 commit comments