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

feat: support save and load payload from file #801

Merged
merged 5 commits into from
Jun 2, 2024

Conversation

bj00rn
Copy link
Collaborator

@bj00rn bj00rn commented May 27, 2024

Features

Save / Load payload from file

  • Open file dialog to set topic payload from file when publishing
  • Save value from payload to file
  • Use cases
    • for convenience
    • saving binary files is not supported, files are generated with utf8 encoding

Certificate selection

  • Move file operation to backend (not tested!)

Publish from file

image

image

Save payload to file

image

@bj00rn bj00rn marked this pull request as draft May 27, 2024 08:50
@bj00rn bj00rn requested a review from thomasnordquist May 27, 2024 08:50
@bj00rn bj00rn changed the title feat: support set payload from file when publishing feat: support save and load payload from file May 27, 2024
@bj00rn bj00rn force-pushed the feat/set-payload-from-file branch from 6d80bb8 to 076fcbe Compare May 27, 2024 13:17

if (!canceled && filePath !== undefined) {
try {
await fsPromise.writeFile(filePath, buffer)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For some reason binary payloads do not get written with correct encoding

Copy link
Owner

Choose a reason for hiding this comment

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

The front-end should probably not directly write to the filesystem.
This would block MQTT Explorer from becoming a web-app

Copy link
Collaborator Author

@bj00rn bj00rn May 27, 2024

Choose a reason for hiding this comment

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

moved file writing to backend, the read file operation is still in front atm. Same logic is in use for certificate selection

const data = await fsPromise.readFile(selectedFile)
. Better fix this too

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@thomasnordquist moved certificate selection file read to backend too. I have not tested it though since i do not use certs

@bj00rn bj00rn force-pushed the feat/set-payload-from-file branch from 076fcbe to 9d09ab2 Compare May 27, 2024 20:14
@bj00rn bj00rn marked this pull request as ready for review May 29, 2024 08:03
@thomasnordquist thomasnordquist merged commit f539e03 into master Jun 2, 2024
1 of 2 checks passed
@thomasnordquist
Copy link
Owner

Just noticed, how is saving working.
Is the encoding thing still an issue?

@bj00rn
Copy link
Collaborator Author

bj00rn commented Jun 2, 2024

Just noticed, how is saving working. Is the encoding thing still an issue?

Files are read/written in default utf-8 for now.

I experimented with opening payload from binary file but ran into problems since payload is encoded as string in reducer state from what I gather. To properly support binary payloads I think some refactoring needs to be done to support this.

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.

2 participants