From 7345cc9943fa3812a963caeb61808823bed04b39 Mon Sep 17 00:00:00 2001 From: Rahul Date: Wed, 11 Mar 2020 17:50:04 +0530 Subject: [PATCH 1/4] Added MQTT support --- components/realtime/mqtt.vue | 260 +++++++++++++++++++++++++++++++++++ lang/en-US.js | 5 + package-lock.json | 5 + package.json | 1 + pages/realtime.vue | 19 ++- 5 files changed, 284 insertions(+), 6 deletions(-) create mode 100644 components/realtime/mqtt.vue diff --git a/components/realtime/mqtt.vue b/components/realtime/mqtt.vue new file mode 100644 index 000000000..36beb5d0e --- /dev/null +++ b/components/realtime/mqtt.vue @@ -0,0 +1,260 @@ + + diff --git a/lang/en-US.js b/lang/en-US.js index dbbfd4343..745b0c41f 100644 --- a/lang/en-US.js +++ b/lang/en-US.js @@ -276,4 +276,9 @@ export default { notes: "Notes", socketio: "Socket.IO", event_name: "Event Name", + mqtt_topic: "Topic", + mqtt_topic_title: "Publish / Subscribe topic", + mqtt_publish: "Publish", + mqtt_subscribe: "Subscribe", + mqtt_unsubscribe: "Unsubscribe", } diff --git a/package-lock.json b/package-lock.json index 02bdfb1a1..4c8515bb0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8983,6 +8983,11 @@ "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" }, + "paho-mqtt": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/paho-mqtt/-/paho-mqtt-1.1.0.tgz", + "integrity": "sha512-KPbL9KAB0ASvhSDbOrZBaccXS+/s7/LIofbPyERww8hM5Ko71GUJQ6Nmg0BWqj8phAIT8zdf/Sd/RftHU9i2HA==" + }, "pako": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.10.tgz", diff --git a/package.json b/package.json index 5e1065a04..991ecfed2 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "graphql-language-service-interface": "^2.3.3", "nuxt": "^2.11.0", "nuxt-i18n": "^6.6.0", + "paho-mqtt": "^1.1.0", "socket.io-client": "^2.3.0", "v-tooltip": "^2.0.3", "vue-virtual-scroll-list": "^1.4.6", diff --git a/pages/realtime.vue b/pages/realtime.vue index fa56ee5c8..7fd9c3ac6 100644 --- a/pages/realtime.vue +++ b/pages/realtime.vue @@ -27,9 +27,7 @@ > {{ !connectionState ? $t("connect") : $t("disconnect") }} - - {{ !connectionState ? "sync" : "sync_disabled" }} - + {{ !connectionState ? "sync" : "sync_disabled" }} @@ -94,9 +92,7 @@ > {{ !connectionSSEState ? $t("start") : $t("stop") }} - - {{ !connectionSSEState ? "sync" : "sync_disabled" }} - + {{ !connectionSSEState ? "sync" : "sync_disabled" }} @@ -118,6 +114,16 @@ + + +
+ +
+ + +
+ +
@@ -132,6 +138,7 @@ export default { socketio: () => import("../components/realtime/socketio"), tabs: () => import("../components/ui/tabs"), tab: () => import("../components/ui/tab"), + mqtt: () => import("../components/realtime/mqtt"), realtimeLog, }, data() { From 49bb77c09868b7b428050b4238ca7c3ed35ca8d8 Mon Sep 17 00:00:00 2001 From: Rahul Date: Wed, 11 Mar 2020 17:59:24 +0530 Subject: [PATCH 2/4] Added MQTT entry to readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index acbd42b99..4632d760e 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,8 @@ _Customized themes are synced with local session storage_ 🌩 **Socket.IO**: Send and Receive data with socketio server. SocketIO is popular websocket solution. +🦟 **MQTT**: Subscribe and Publish to topics of a MQTT Broker. + 🔮 **GraphQL**: GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. - Set endpoint and get schemas From 7d465ca489f9c917e21ddaba0b363b6277c6d6cc Mon Sep 17 00:00:00 2001 From: Rahul Date: Thu, 12 Mar 2020 00:00:56 +0530 Subject: [PATCH 3/4] Fixed conflicts --- lang/en-US.js | 1 + pages/realtime.vue | 21 +++++++++------------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lang/en-US.js b/lang/en-US.js index 745b0c41f..c5d6b93e1 100644 --- a/lang/en-US.js +++ b/lang/en-US.js @@ -276,6 +276,7 @@ export default { notes: "Notes", socketio: "Socket.IO", event_name: "Event Name", + mqtt: "MQTT", mqtt_topic: "Topic", mqtt_topic_title: "Publish / Subscribe topic", mqtt_publish: "Publish", diff --git a/pages/realtime.vue b/pages/realtime.vue index 7fd9c3ac6..0185976e7 100644 --- a/pages/realtime.vue +++ b/pages/realtime.vue @@ -27,7 +27,9 @@ > {{ !connectionState ? $t("connect") : $t("disconnect") }} - {{ !connectionState ? "sync" : "sync_disabled" }} + {{ + !connectionState ? "sync" : "sync_disabled" + }} @@ -92,7 +94,9 @@ > {{ !connectionSSEState ? $t("start") : $t("stop") }} - {{ !connectionSSEState ? "sync" : "sync_disabled" }} + {{ + !connectionSSEState ? "sync" : "sync_disabled" + }} @@ -113,17 +117,10 @@ + + + - - -
- -
- - -
- -
From 87c0702959f29c2b1ec6b34d011bcd9ee435c73c Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Thu, 12 Mar 2020 01:31:54 +0530 Subject: [PATCH 4/4] :recycle: Refactor --- components/realtime/mqtt.vue | 11 +- components/realtime/socketio.vue | 5 +- components/realtime/sse.vue | 160 +++++++++++++++ components/realtime/websocket.vue | 182 +++++++++++++++++ package-lock.json | 12 +- pages/realtime.vue | 329 +----------------------------- 6 files changed, 362 insertions(+), 337 deletions(-) create mode 100644 components/realtime/sse.vue create mode 100644 components/realtime/websocket.vue diff --git a/components/realtime/mqtt.vue b/components/realtime/mqtt.vue index 36beb5d0e..73edcad42 100644 --- a/components/realtime/mqtt.vue +++ b/components/realtime/mqtt.vue @@ -19,10 +19,11 @@ +
  • - +
    @@ -66,19 +67,19 @@ + diff --git a/components/realtime/websocket.vue b/components/realtime/websocket.vue new file mode 100644 index 000000000..a2d1b0415 --- /dev/null +++ b/components/realtime/websocket.vue @@ -0,0 +1,182 @@ + + + diff --git a/package-lock.json b/package-lock.json index 4c8515bb0..4820350d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2198,9 +2198,9 @@ "integrity": "sha512-8ZVAxwyCGAxQX8mOp9imSXH0hoSPkGfy8igJy+WO/7axL30saRhKgg1XPACSmxxPA7nfHVwM+ShWXT+vKsNuFg==" }, "acorn": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.0.tgz", - "integrity": "sha512-gac8OEcQ2Li1dxIEWGZzsp2BitJxwkwcOm0zHAJLcPJaVvm58FRnk6RkuLRpU1EujipU2ZFODv2P9DLMfnV8mw==" + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz", + "integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==" }, "acorn-walk": { "version": "6.2.0", @@ -7322,9 +7322,9 @@ } }, "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" }, "last-call-webpack-plugin": { "version": "3.0.0", diff --git a/pages/realtime.vue b/pages/realtime.vue index 0185976e7..ac400985d 100644 --- a/pages/realtime.vue +++ b/pages/realtime.vue @@ -3,120 +3,17 @@
    - -
      -
    • - - -
    • -
      -
    • - - -
    • -
      -
    -
    - - -
      -
    • - -
    • -
    -
      -
    • - - -
    • -
      -
    • - - -
    • -
      -
    -
    +
    - -
      -
    • - - -
    • -
      -
    • - - -
    • -
      -
    -
    - - -
      -
    • - -
      -
    • -
    -
    +
    + @@ -126,229 +23,15 @@