From 7cc97834369627c4889021d174915ca1d8365082 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Mon, 26 Jun 2023 13:21:51 +0800 Subject: [PATCH 1/5] Fix: Active needs to return bool instead of 0 --- server/model/monitor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 2dfe2e65f..017e6813f 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -155,7 +155,7 @@ class Monitor extends BeanModel { async isActive() { const parentActive = await Monitor.isParentActive(this.id); - return this.active && parentActive; + return (this.active === 1) && parentActive; } /** From 79b38e0e7bf7247da499e7f1266d3e674bfafd55 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Mon, 26 Jun 2023 13:23:06 +0800 Subject: [PATCH 2/5] Feat: Improve monitorList filtering --- src/components/MonitorList.vue | 90 ++++-- src/components/MonitorListFilter.vue | 283 +++++++++++++++++++ src/components/MonitorListFilterDropdown.vue | 131 +++++++++ src/mixins/socket.js | 5 +- 4 files changed, 490 insertions(+), 19 deletions(-) create mode 100644 src/components/MonitorListFilter.vue create mode 100644 src/components/MonitorListFilterDropdown.vue diff --git a/src/components/MonitorList.vue b/src/components/MonitorList.vue index c69169ccf..9ee46e243 100644 --- a/src/components/MonitorList.vue +++ b/src/components/MonitorList.vue @@ -1,17 +1,25 @@ @@ -159,8 +205,6 @@ export default { margin: -10px; margin-bottom: 10px; padding: 10px; - display: flex; - justify-content: space-between; .dark & { background-color: $dark-header-bg; @@ -168,6 +212,17 @@ export default { } } +.header-top { + display: flex; + justify-content: space-between; + align-items: center; +} + +.header-filter { + display: flex; + align-items: center; +} + @media (max-width: 770px) { .list-header { margin: -20px; @@ -216,5 +271,4 @@ export default { padding-left: 67px; margin-top: 5px; } - diff --git a/src/components/MonitorListFilter.vue b/src/components/MonitorListFilter.vue new file mode 100644 index 000000000..022f7d919 --- /dev/null +++ b/src/components/MonitorListFilter.vue @@ -0,0 +1,283 @@ + + + + + diff --git a/src/components/MonitorListFilterDropdown.vue b/src/components/MonitorListFilterDropdown.vue new file mode 100644 index 000000000..adf3d6b35 --- /dev/null +++ b/src/components/MonitorListFilterDropdown.vue @@ -0,0 +1,131 @@ + + + + + diff --git a/src/mixins/socket.js b/src/mixins/socket.js index e2834251a..8e078b100 100644 --- a/src/mixins/socket.js +++ b/src/mixins/socket.js @@ -693,9 +693,11 @@ export default { stats() { let result = { + active: 0, up: 0, down: 0, maintenance: 0, + pending: 0, unknown: 0, pause: 0, }; @@ -707,12 +709,13 @@ export default { if (monitor && ! monitor.active) { result.pause++; } else if (beat) { + result.active++; if (beat.status === UP) { result.up++; } else if (beat.status === DOWN) { result.down++; } else if (beat.status === PENDING) { - result.up++; + result.pending++; } else if (beat.status === MAINTENANCE) { result.maintenance++; } else { From cea894cc6d7dcba0ab599f0b85bf5dccb85d899c Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Mon, 26 Jun 2023 13:39:19 +0800 Subject: [PATCH 3/5] Chore: Fix lint --- src/components/MonitorListFilterDropdown.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/MonitorListFilterDropdown.vue b/src/components/MonitorListFilterDropdown.vue index adf3d6b35..01b9678f9 100644 --- a/src/components/MonitorListFilterDropdown.vue +++ b/src/components/MonitorListFilterDropdown.vue @@ -48,14 +48,14 @@ export default { .filter-dropdown-menu { z-index: 100; transition: all 0.2s; - padding: 5px 0px !important; + padding: 5px 0 !important; border-radius: 16px; overflow: hidden; position: absolute; - inset: 0px auto auto 0px; - margin: 0px; - transform: translate(0px, 36px); + inset: 0 auto auto 0; + margin: 0; + transform: translate(0, 36px); box-shadow: 0 15px 70px rgba(0, 0, 0, 0.1); visibility: hidden; list-style: none; From f8c9a20afdaae76b3d2307c296f5631beddde27b Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Mon, 26 Jun 2023 13:42:46 +0800 Subject: [PATCH 4/5] Chore: Disable clear filters button --- src/components/MonitorListFilter.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/MonitorListFilter.vue b/src/components/MonitorListFilter.vue index 022f7d919..2dcd062fa 100644 --- a/src/components/MonitorListFilter.vue +++ b/src/components/MonitorListFilter.vue @@ -6,6 +6,7 @@ class="clear-filters-btn btn" :class="{ 'active': numFiltersActive > 0}" tabindex="0" + :disabled="numFiltersActive === 0" @click="clearFilters" > From e2a87eb4300d67c6911775ca24962475fbe1580a Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sun, 16 Jul 2023 21:15:25 +0800 Subject: [PATCH 5/5] Improve the filter translate keys --- src/components/MonitorListFilter.vue | 6 +++--- src/lang/en.json | 2 ++ src/lang/zh-HK.json | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/MonitorListFilter.vue b/src/components/MonitorListFilter.vue index 2dcd062fa..dbb1eb940 100644 --- a/src/components/MonitorListFilter.vue +++ b/src/components/MonitorListFilter.vue @@ -81,10 +81,10 @@