Skip to content

Commit 013b774

Browse files
committedJan 18, 2025·
Merge branch 'develop'
2 parents 5b8e5f2 + a631aa9 commit 013b774

File tree

5 files changed

+118
-11
lines changed

5 files changed

+118
-11
lines changed
 

‎linux-resources/io.github.Omniaevo.mqtt5-explorer.metainfo.xml

+22-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<id>io.github.Omniaevo.mqtt5-explorer</id>
44

55
<name>MQTT5 Explorer</name>
6-
<summary>A simple MQTT client that supports MQTT5 protocol.</summary>
6+
<summary>A simple but powerful MQTT5 client</summary>
77

88
<metadata_license>MIT</metadata_license>
99
<project_license>GPL-3.0-only</project_license>
@@ -14,6 +14,11 @@
1414
</p>
1515
</description>
1616

17+
<branding>
18+
<color type="primary" scheme_preference="light">#cba2c9</color>
19+
<color type="primary" scheme_preference="dark">#7094c9</color>
20+
</branding>
21+
1722
<launchable type="desktop-id">io.github.Omniaevo.mqtt5-explorer.desktop</launchable>
1823

1924
<developer_name>Omniaevo SRL</developer_name>
@@ -36,17 +41,30 @@
3641

3742
<screenshots>
3843
<screenshot type="default">
39-
<image>https://github.com/Omniaevo/mqtt5-explorer/blob/master/screenshots/mqtt5-explorer-promotional.jpg</image>
44+
<image>https://omniaevo.github.io/assets/images/mqtt5-explorer-promotional.jpg</image>
45+
<caption>Light + Dark theme</caption>
4046
</screenshot>
4147
<screenshot>
42-
<image>https://github.com/Omniaevo/mqtt5-explorer/blob/master/screenshots/client-connection-white.png</image>
48+
<image>https://omniaevo.github.io/assets/images/client-connection-white.png</image>
49+
<caption>Light theme</caption>
4350
</screenshot>
4451
<screenshot>
45-
<image>https://github.com/Omniaevo/mqtt5-explorer/blob/master/screenshots/client-connection.png</image>
52+
<image>https://omniaevo.github.io/assets/images/client-connection.png</image>
53+
<caption>Dark theme</caption>
4654
</screenshot>
4755
</screenshots>
4856

4957
<releases>
58+
<release version="1.17.0" date="2025-01-18">
59+
<url type="details">https://github.com/Omniaevo/mqtt5-explorer/releases/tag/v1.17.0</url>
60+
<description>
61+
<p>In this release:</p>
62+
<ul>
63+
<li>Export all saved connections to Json format;</li>
64+
<li>Import connections from Json.</li>
65+
</ul>
66+
</description>
67+
</release>
5068
<release version="1.16.1" date="2025-01-17" />
5169
<release version="1.16.0" date="2025-01-16" />
5270
<release version="1.15.0" date="2024-09-24" />

‎package-lock.json

+7-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mqtt5-explorer",
3-
"version": "1.16.1",
3+
"version": "1.17.0",
44
"private": false,
55
"license": "GPLv3",
66
"description": "A simple MQTT client that supports MQTT5 protocol.",

‎src/background.js

+46
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
import { createProtocol } from "vue-cli-plugin-electron-builder/lib";
1919
import path from "path";
2020
import Store from "electron-store";
21+
import fs from "fs";
2122

2223
const isDevelopment = process.env.NODE_ENV !== "production";
2324
const isSingleInstance = app.requestSingleInstanceLock();
@@ -143,6 +144,51 @@ let menuTemplate = (page = pages.HOME) => [
143144
: []),
144145
],
145146
},
147+
...(page === pages.HOME
148+
? [
149+
{
150+
label: "Connections",
151+
submenu: [
152+
{
153+
label: "Export all",
154+
click: () => {
155+
if (win != undefined && win.webContents != undefined) {
156+
win.webContents.send("exportDataPressed");
157+
}
158+
},
159+
},
160+
{
161+
label: "Import from file",
162+
click: () => {
163+
if (win == undefined || win.webContents == undefined) return;
164+
165+
dialog
166+
.showOpenDialog({
167+
properties: ["openFile"],
168+
filters: [
169+
{ name: "Json (*.json)", extensions: ["json"] },
170+
{ name: "All Files", extensions: ["*"] },
171+
],
172+
})
173+
.then((result) => {
174+
if (result.canceled) return;
175+
176+
const fileContent = fs.readFileSync(
177+
result.filePaths[0],
178+
"utf8"
179+
);
180+
181+
win.webContents.send("importDataPressed", fileContent);
182+
})
183+
.catch((err) => {
184+
win.webContents.send("importDataPressed", `Error: ${err}`);
185+
});
186+
},
187+
},
188+
],
189+
},
190+
]
191+
: []),
146192
...(page === pages.VIEWER
147193
? [
148194
{

‎src/views/Home.vue

+42
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@
365365
import ConnectionForm from "../components/ConnectionForm.vue";
366366
import ConnectionProperties from "../models/ConnectionProperties";
367367
import { shell, ipcRenderer } from "electron";
368+
import { v4 as uuidv4 } from "uuid";
369+
import moment from "moment";
368370
369371
export default {
370372
name: "Home",
@@ -487,14 +489,54 @@ export default {
487489
488490
ipcRenderer.send("enterHomePage");
489491
ipcRenderer.on("settingsPressed", this.toggleSettingsDrawer);
492+
ipcRenderer.on("exportDataPressed", this.exportConnectionData);
493+
ipcRenderer.on("importDataPressed", this.importConnectionData);
490494
},
491495
492496
beforeDestroy() {
493497
this.$store.commit("setSelectedConnectionId", this.tabId);
498+
494499
ipcRenderer.removeListener("settingsPressed", this.toggleSettingsDrawer);
500+
ipcRenderer.removeListener("exportDataPressed", this.exportConnectionData);
501+
ipcRenderer.removeListener("importDataPressed", this.importConnectionData);
495502
},
496503
497504
methods: {
505+
exportConnectionData() {
506+
const savedConnections = JSON.parse(
507+
this.$estore.get(this.connectionsStore) || "[]"
508+
);
509+
const blob = new Blob([JSON.stringify(savedConnections, null, 2)], {
510+
type: "application/json",
511+
});
512+
const fileDownload = document.createElement("a");
513+
514+
fileDownload.href = URL.createObjectURL(blob);
515+
fileDownload.download = `connections-${moment().valueOf()}.json`;
516+
fileDownload.style.display = "none";
517+
518+
document.body.appendChild(fileDownload);
519+
fileDownload.click();
520+
document.body.removeChild(fileDownload);
521+
},
522+
importConnectionData(_, fileContent) {
523+
try {
524+
const connections = (JSON.parse(fileContent) || []).filter((props) =>
525+
ConnectionProperties.validate(props)
526+
);
527+
528+
// Generate new UUIDs if not present (for retro-compatibility)
529+
connections.forEach((connection) => {
530+
connection.id = connection.id || uuidv4();
531+
});
532+
533+
this.$store.commit("loadPersistentConnections", connections);
534+
this.persistConnections();
535+
} catch {
536+
// File is not valid
537+
// Do nothing
538+
}
539+
},
498540
scrollTabs(to = "bottom") {
499541
this.$nextTick(() => {
500542
const tabs = document.querySelector("#tabs-list");

0 commit comments

Comments
 (0)
Please sign in to comment.