Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decode data in frontend #795

Merged
merged 16 commits into from
May 25, 2024
Merged

Conversation

thomasnordquist
Copy link
Owner

@thomasnordquist thomasnordquist commented May 21, 2024

What needs to improve:

  • button placement for selecting the decoder
  • message should be decoded immediatly after changing the decoder (currently a re-render is only triggered by a new message)
  • clean up: this pr is still a bit messy (eg. decoder classes in wrong file ...)

mhorsche and others added 5 commits January 11, 2021 10:11
- Select data type (string, json, hex, uint, int, float) for each topic individually
- Default data type is 'string'
- Show milliseconds in message received timestamp
- possible data types are: 'json', 'string', 'hex', 'uint8', 'uint16', 'uint32', 'uint64', 'int8', 'int16', 'int32', 'int64', 'float', 'double'
- default is 'json'
@thomasnordquist thomasnordquist force-pushed the tnordquist/decode-data-in-frontend branch from adda7a7 to c88978f Compare May 22, 2024 13:12
@thomasnordquist thomasnordquist marked this pull request as ready for review May 22, 2024 13:13
@@ -98,7 +98,7 @@ export class MqttSource implements DataSource<MqttOptions> {

public publish(msg: MqttMessage) {
if (this.client) {
this.client.publish(msg.topic, msg.payload ? Base64Message.toUnicodeString(msg.payload) : '', {
this.client.publish(msg.topic, msg.payload?.toBuffer() ?? '', {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can't call method on serialized object. make Base64Message.toBuffer static?

Copy link
Owner Author

Choose a reason for hiding this comment

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

You are right, this is a bit messy.
I'll add a DTO (Data Transfer Object) type to differentiate between these two types.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You are right, this is a bit messy. I'll add a DTO (Data Transfer Object) type to differentiate between these two types.

Good, publish is broken at the moment

Copy link
Owner Author

Choose a reason for hiding this comment

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

Nice catch btw., Maybe I'll add a few automated test scenarios later on.

This should work now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice catch btw., Maybe I'll add a few automated test scenarios later on.

This should work now.

Speaking of automated tests, I did a dirty hack when moving to Playwright, the expandTopic logic is broken. It does not work when topics have the same name in path since multiple nodes will be matched.

i.e

/livingtroom/lamp
/bedroom/upstairs/lamp
/lamp/device1

I opened an issue on this #796

@@ -17,6 +19,7 @@ export class TreeNode<ViewModel extends Destroyable> {
public onMessage = new EventDispatcher<Message>()
public onDestroy = new EventDispatcher<TreeNode<ViewModel>>()
public isTree = false
public type: TopicDataType = 'json'
Copy link
Collaborator

Choose a reason for hiding this comment

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

@thomasnordquist i'm a bit confused about node.type here? Should't type be derived from the selected Decoder?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Understandable, I think you are right.

{options.map(([decoder, format], index) => (
<MenuItem
key={format}
selected={node && format === node.type}
Copy link
Collaborator

Choose a reason for hiding this comment

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

@thomasnordquist i'm a bit confused about node.type here? Should't type be derived from the selected Decoder?

@thomasnordquist thomasnordquist merged commit 8b43e20 into master May 25, 2024
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants