From 38c5172316a1ede33a5baffdae1db919a1e80cbe Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 19 Oct 2023 00:33:17 +0200 Subject: [PATCH] [UI] Show the connected/disconnected status in the `Nav` icon. --- platypush/backend/http/webapp/src/Events.vue | 5 +++ .../http/webapp/src/components/Nav.vue | 34 +++++++++++++++++++ .../src/components/panels/Entities/Index.vue | 2 +- .../http/webapp/src/style/themes/light.scss | 1 + 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/platypush/backend/http/webapp/src/Events.vue b/platypush/backend/http/webapp/src/Events.vue index 9162b0c4d8..19226c11dc 100644 --- a/platypush/backend/http/webapp/src/Events.vue +++ b/platypush/backend/http/webapp/src/Events.vue @@ -181,6 +181,11 @@ export default { created() { bus.on('subscribe', this.subscribe) bus.on('unsubscribe', this.unsubscribe) + + this.$watch('opened', (open) => { + bus.emit(open ? 'connect' : 'disconnect') + }) + this.init() }, } diff --git a/platypush/backend/http/webapp/src/components/Nav.vue b/platypush/backend/http/webapp/src/components/Nav.vue index 9d32ab51e0..ebdee69131 100644 --- a/platypush/backend/http/webapp/src/components/Nav.vue +++ b/platypush/backend/http/webapp/src/components/Nav.vue @@ -3,6 +3,9 @@
+
    @@ -76,6 +79,7 @@ import icons from '@/assets/icons.json' import Utils from "@/Utils"; import configSections from '@/components/panels/Settings/sections.json'; +import { bus } from "@/bus"; export default { name: "Nav", @@ -137,11 +141,18 @@ export default { return name }, + + setConnected(connected) { + return () => { + this.connected = connected + } + }, }, data() { return { collapsed: true, + connected: false, icons: icons, host: null, configSections: configSections, @@ -150,6 +161,8 @@ export default { mounted() { this.collapsed = this.collapsedDefault + bus.on('connect', this.setConnected(true)) + bus.on('disconnect', this.setConnected(false)) }, } @@ -239,10 +252,26 @@ nav { background: $nav-toggler-bg; display: flex; font-size: 1.5em; + position: relative; cursor: pointer; padding: 0.4em; align-items: center; box-shadow: $nav-toggler-shadow; + + .icon.status { + position: absolute; + top: calc($toggler-height / 2 + 0.3em); + right: 0.5em; + font-size: 0.5em; + + &.ok { + color: $ok-fg; + } + + &.error { + color: $error-fg; + } + } } .hostname { @@ -328,6 +357,11 @@ nav { background: $nav-toggler-collapsed-mobile-bg; color: $nav-toggler-collapsed-mobile-fg; } + + .icon.status { + top: 0.75em; + left: 2em; + } } .footer { diff --git a/platypush/backend/http/webapp/src/components/panels/Entities/Index.vue b/platypush/backend/http/webapp/src/components/panels/Entities/Index.vue index 5631191f78..d5faabd213 100644 --- a/platypush/backend/http/webapp/src/components/panels/Entities/Index.vue +++ b/platypush/backend/http/webapp/src/components/panels/Entities/Index.vue @@ -39,7 +39,7 @@ -
    +
    diff --git a/platypush/backend/http/webapp/src/style/themes/light.scss b/platypush/backend/http/webapp/src/style/themes/light.scss index 7e37f6d0f3..4254e270ac 100644 --- a/platypush/backend/http/webapp/src/style/themes/light.scss +++ b/platypush/backend/http/webapp/src/style/themes/light.scss @@ -6,6 +6,7 @@ $default-bg-4: #f1f3f2 !default; $default-bg-5: #edf0ee !default; $default-bg-6: #e4eae8 !default; $default-bg-7: #e4e4e4 !default; +$ok-fg: #17ad17 !default; $error-fg: #ad1717 !default; $default-fg: black !default;