From 51d0b2116274de2ebe9a23900eb85139a091c95a Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 1 Dec 2024 18:30:45 +0100 Subject: [PATCH] [#437] Added application panel with events monitor tab. --- platypush/backend/http/webapp/src/Events.vue | 2 + .../backend/http/webapp/src/assets/icons.json | 3 + .../http/webapp/src/components/Nav.vue | 27 +- .../OutputRenderers/EventRenderer.vue | 206 +++++++++++++++ .../elements/OutputRenderers/Mixin.vue | 67 +++++ .../OutputRenderers/ObjectRenderer.vue | 69 +++++ .../OutputRenderers/StringRenderer.vue | 17 ++ .../elements/OutputRenderers/style.scss | 142 +++++++++++ .../Actions.vue} | 7 +- .../components/panels/Application/Events.vue | 235 ++++++++++++++++++ .../components/panels/Application/Index.vue | 106 ++++++++ .../src/components/panels/Settings/Index.vue | 4 +- .../backend/http/webapp/src/views/Panel.vue | 1 + 13 files changed, 871 insertions(+), 15 deletions(-) create mode 100644 platypush/backend/http/webapp/src/components/elements/OutputRenderers/EventRenderer.vue create mode 100644 platypush/backend/http/webapp/src/components/elements/OutputRenderers/Mixin.vue create mode 100644 platypush/backend/http/webapp/src/components/elements/OutputRenderers/ObjectRenderer.vue create mode 100644 platypush/backend/http/webapp/src/components/elements/OutputRenderers/StringRenderer.vue create mode 100644 platypush/backend/http/webapp/src/components/elements/OutputRenderers/style.scss rename platypush/backend/http/webapp/src/components/panels/{Settings/Application.vue => Application/Actions.vue} (88%) create mode 100644 platypush/backend/http/webapp/src/components/panels/Application/Events.vue create mode 100644 platypush/backend/http/webapp/src/components/panels/Application/Index.vue diff --git a/platypush/backend/http/webapp/src/Events.vue b/platypush/backend/http/webapp/src/Events.vue index 19226c11dc..a25836c5cf 100644 --- a/platypush/backend/http/webapp/src/Events.vue +++ b/platypush/backend/http/webapp/src/Events.vue @@ -53,6 +53,8 @@ export default { return } + bus.emit('event', event) + if (null in this.handlers) { // lgtm [js/implicit-operand-conversion] handlers.push(this.handlers[null]) // lgtm [js/implicit-operand-conversion] } diff --git a/platypush/backend/http/webapp/src/assets/icons.json b/platypush/backend/http/webapp/src/assets/icons.json index fd58b5f7bc..1a9300caec 100644 --- a/platypush/backend/http/webapp/src/assets/icons.json +++ b/platypush/backend/http/webapp/src/assets/icons.json @@ -2,6 +2,9 @@ "alarm": { "class": "fas fa-stopwatch" }, + "application": { + "class": "fas fa-sliders" + }, "arduino": { "class": "fas fa-microchip" }, diff --git a/platypush/backend/http/webapp/src/components/Nav.vue b/platypush/backend/http/webapp/src/components/Nav.vue index 08d5375909..c6488668fc 100644 --- a/platypush/backend/http/webapp/src/components/Nav.vue +++ b/platypush/backend/http/webapp/src/components/Nav.vue @@ -117,7 +117,7 @@ export default { computed: { specialPlugins() { - return ['execute', 'entities', 'file', 'procedures'] + return ['execute', 'entities', 'file', 'application', 'procedures'] }, panelNames() { @@ -132,6 +132,7 @@ export default { let panelNames = Object.keys(this.panels).sort() panelNames = prepend(panelNames, 'file') panelNames = prepend(panelNames, 'procedures') + panelNames = prepend(panelNames, 'application') panelNames = prepend(panelNames, 'execute') panelNames = prepend(panelNames, 'entities') return panelNames @@ -151,16 +152,20 @@ export default { }, displayName(name) { - if (name === 'entities') - return 'Home' - if (name === 'execute') - return 'Execute' - if (name === 'file') - return 'Files' - if (name === 'procedures') - return 'Procedures' - - return name + switch (name) { + case 'application': + return 'Application' + case 'entities': + return 'Home' + case 'execute': + return 'Execute' + case 'file': + return 'Files' + case 'procedures': + return 'Procedures' + default: + return name + } }, setConnected(connected) { diff --git a/platypush/backend/http/webapp/src/components/elements/OutputRenderers/EventRenderer.vue b/platypush/backend/http/webapp/src/components/elements/OutputRenderers/EventRenderer.vue new file mode 100644 index 0000000000..d795230945 --- /dev/null +++ b/platypush/backend/http/webapp/src/components/elements/OutputRenderers/EventRenderer.vue @@ -0,0 +1,206 @@ + + + + + diff --git a/platypush/backend/http/webapp/src/components/elements/OutputRenderers/Mixin.vue b/platypush/backend/http/webapp/src/components/elements/OutputRenderers/Mixin.vue new file mode 100644 index 0000000000..dcdeae1aa2 --- /dev/null +++ b/platypush/backend/http/webapp/src/components/elements/OutputRenderers/Mixin.vue @@ -0,0 +1,67 @@ + diff --git a/platypush/backend/http/webapp/src/components/elements/OutputRenderers/ObjectRenderer.vue b/platypush/backend/http/webapp/src/components/elements/OutputRenderers/ObjectRenderer.vue new file mode 100644 index 0000000000..a5a3a51dc8 --- /dev/null +++ b/platypush/backend/http/webapp/src/components/elements/OutputRenderers/ObjectRenderer.vue @@ -0,0 +1,69 @@ + + + + + diff --git a/platypush/backend/http/webapp/src/components/elements/OutputRenderers/StringRenderer.vue b/platypush/backend/http/webapp/src/components/elements/OutputRenderers/StringRenderer.vue new file mode 100644 index 0000000000..fb741461ed --- /dev/null +++ b/platypush/backend/http/webapp/src/components/elements/OutputRenderers/StringRenderer.vue @@ -0,0 +1,17 @@ + + + + + diff --git a/platypush/backend/http/webapp/src/components/elements/OutputRenderers/style.scss b/platypush/backend/http/webapp/src/components/elements/OutputRenderers/style.scss new file mode 100644 index 0000000000..40573c5ce9 --- /dev/null +++ b/platypush/backend/http/webapp/src/components/elements/OutputRenderers/style.scss @@ -0,0 +1,142 @@ +.renderer { + --default-bg: #{$background-color}; + --even-color: #{$default-bg-2}; + --odd-color: inherit; + --hover-bg: #{$hover-bg}; + --text-color: #{$default-fg}; + --time-color: #{$no-items-color}; + --type-color: #{$default-fg-2}; + + &.dark { + --default-bg: black; + --even-color: #141414; + --odd-color: inherit; + --hover-bg: #333; + --text-color: #fff; + --time-color: #999; + --type-color: #fbf6bb; + } + + width: fit-content; + min-width: 100%; + color: var(--text-color); + display: flex; + flex-direction: column; + position: relative; + text-decoration: none; + cursor: initial; + + &.even, .even { + background: var(--even-color); + } + + &.odd, .odd { + background: var(--odd-color); + } + + &:hover { + .expanded, .editor-container { + color: initial !important; + } + } + + .header, .expanded { + display: flex; + flex: 1 1 auto; + } + + .header { + padding: 0.5em 1em; + cursor: pointer; + + @include until($tablet) { + flex-direction: column; + } + + &:hover { + background: var(--hover-bg) !important; + } + + @include from($tablet) { + align-items: center; + } + } + + &.expanded { + .header { + padding: 1em; + font-weight: bold; + border-bottom: 1px solid var(--time-color); + } + } + + .expanded { + background: var(--default-bg); + cursor: default; + flex-direction: column; + + .rows { + width: calc(100% - 1.35em); + display: flex; + flex-direction: column; + } + + .row { + width: 100%; + display: flex; + align-items: center; + padding: 0.25em 0; + margin: 0.25em 0; + + @include until($tablet) { + flex-direction: column; + } + + &.args { + align-items: flex-start; + flex-direction: column; + } + + .key { + @extend .col-s-12, .col-m-4; + } + + .value { + display: flex; + margin: 0; + overflow: hidden; + text-overflow: ellipsis; + + @include from($tablet) { + justify-content: flex-end; + } + + &.scalar { + @extend .col-s-12, .col-m-8; + padding-right: 0.5em; + } + + &.object { + width: 100%; + } + } + } + } + + .time { + color: var(--time-color); + letter-spacing: 0.02em; + } + + .type { + color: var(--type-color); + letter-spacing: 0.03em; + } + + pre { + margin: 0; + padding: 0; + white-space: nowrap; + overflow: initial; + } +} diff --git a/platypush/backend/http/webapp/src/components/panels/Settings/Application.vue b/platypush/backend/http/webapp/src/components/panels/Application/Actions.vue similarity index 88% rename from platypush/backend/http/webapp/src/components/panels/Settings/Application.vue rename to platypush/backend/http/webapp/src/components/panels/Application/Actions.vue index 763184f2ad..5bc7b35f3a 100644 --- a/platypush/backend/http/webapp/src/components/panels/Settings/Application.vue +++ b/platypush/backend/http/webapp/src/components/panels/Application/Actions.vue @@ -13,10 +13,15 @@ diff --git a/platypush/backend/http/webapp/src/components/panels/Application/Events.vue b/platypush/backend/http/webapp/src/components/panels/Application/Events.vue new file mode 100644 index 0000000000..9150e5cc82 --- /dev/null +++ b/platypush/backend/http/webapp/src/components/panels/Application/Events.vue @@ -0,0 +1,235 @@ + + + + + diff --git a/platypush/backend/http/webapp/src/components/panels/Application/Index.vue b/platypush/backend/http/webapp/src/components/panels/Application/Index.vue new file mode 100644 index 0000000000..9aad6bbf2b --- /dev/null +++ b/platypush/backend/http/webapp/src/components/panels/Application/Index.vue @@ -0,0 +1,106 @@ + + + + + diff --git a/platypush/backend/http/webapp/src/components/panels/Settings/Index.vue b/platypush/backend/http/webapp/src/components/panels/Settings/Index.vue index 00655d7da2..9351e762fb 100644 --- a/platypush/backend/http/webapp/src/components/panels/Settings/Index.vue +++ b/platypush/backend/http/webapp/src/components/panels/Settings/Index.vue @@ -1,7 +1,6 @@