diff --git a/src/components/MonitorList.vue b/src/components/MonitorList.vue
index 49be97ed5..88450948b 100644
--- a/src/components/MonitorList.vue
+++ b/src/components/MonitorList.vue
@@ -294,9 +294,7 @@ export default {
this.$router.replace({
query: {
...this.$route.query,
- status: newFilter.status,
- active: newFilter.active,
- tags: newFilter.tags,
+ ...newFilter,
},
});
},
@@ -388,7 +386,7 @@ export default {
// filter by status
let statusMatch = true;
- if (this.filterState.status != null && this.filterState.status.length > 0) {
+ if (this.filterState.status.length > 0) {
if (monitor.id in this.$root.lastHeartbeatList && this.$root.lastHeartbeatList[monitor.id]) {
monitor.status = this.$root.lastHeartbeatList[monitor.id].status;
}
@@ -397,13 +395,13 @@ export default {
// filter by active
let activeMatch = true;
- if (this.filterState.active != null && this.filterState.active.length > 0) {
+ if (this.filterState.active.length > 0) {
activeMatch = this.filterState.active.includes(monitor.active);
}
// filter by tags
let tagsMatch = true;
- if (this.filterState.tags != null && this.filterState.tags.length > 0) {
+ if (this.filterState.tags.length > 0) {
tagsMatch = monitor.tags.map(tag => tag.tag_id) // convert to array of tag IDs
.filter(monitorTagId => this.filterState.tags.includes(monitorTagId)) // perform Array Intersaction between filter and monitor's tags
.length > 0;
diff --git a/src/components/MonitorListFilter.vue b/src/components/MonitorListFilter.vue
index 251551006..5f223d60c 100644
--- a/src/components/MonitorListFilter.vue
+++ b/src/components/MonitorListFilter.vue
@@ -14,10 +14,10 @@
-
+
{{ $t('Status') }}
@@ -29,7 +29,7 @@
{{ $root.stats.up }}
-
+
@@ -42,7 +42,7 @@
{{ $root.stats.down }}
-
+
@@ -55,7 +55,7 @@
{{ $root.stats.pending }}
-
+
@@ -68,7 +68,7 @@
{{ $root.stats.maintenance }}
-
+
@@ -77,9 +77,9 @@
-
+
-
+
{{ $t("Running") }}
{{ $t("filterActivePaused") }}
{{ $t("Unknown") }}
@@ -95,7 +95,7 @@
{{ $t("Running") }}
{{ $root.stats.active }}
-
+
@@ -108,7 +108,7 @@
{{ $t("filterActivePaused") }}
{{ $root.stats.pause }}
-
+
@@ -117,11 +117,11 @@
-
+
@@ -136,7 +136,7 @@
{{ getTaggedMonitorCount(tag) }}
-
+
@@ -181,7 +181,7 @@ export default {
let num = 0;
Object.values(this.filterState).forEach(item => {
- if (item != null && item.length > 0) {
+ if (item.length > 0) {
num += 1;
}
});
@@ -219,14 +219,10 @@ export default {
...this.filterState
};
- if (newFilter.status == null) {
- newFilter.status = [ status ];
+ if (newFilter.status.includes(status)) {
+ newFilter.status = newFilter.status.filter(item => item !== status);
} else {
- if (newFilter.status.includes(status)) {
- newFilter.status = newFilter.status.filter(item => item !== status);
- } else {
- newFilter.status.push(status);
- }
+ newFilter.status.push(status);
}
this.$emit("updateFilter", newFilter);
},
@@ -235,14 +231,10 @@ export default {
...this.filterState
};
- if (newFilter.active == null) {
- newFilter.active = [ active ];
+ if (newFilter.active.includes(active)) {
+ newFilter.active = newFilter.active.filter(item => item !== active);
} else {
- if (newFilter.active.includes(active)) {
- newFilter.active = newFilter.active.filter(item => item !== active);
- } else {
- newFilter.active.push(active);
- }
+ newFilter.active.push(active);
}
this.$emit("updateFilter", newFilter);
},
@@ -251,14 +243,10 @@ export default {
...this.filterState
};
- if (newFilter.tags == null) {
- newFilter.tags = [ tag.id ];
+ if (newFilter.tags.includes(tag.id)) {
+ newFilter.tags = newFilter.tags.filter(item => item !== tag.id);
} else {
- if (newFilter.tags.includes(tag.id)) {
- newFilter.tags = newFilter.tags.filter(item => item !== tag.id);
- } else {
- newFilter.tags.push(tag.id);
- }
+ newFilter.tags.push(tag.id);
}
this.$emit("updateFilter", newFilter);
},