diff --git a/src/components/MonitorList.vue b/src/components/MonitorList.vue
index 86091e185..d782e730a 100644
--- a/src/components/MonitorList.vue
+++ b/src/components/MonitorList.vue
@@ -177,8 +177,13 @@ export default {
* @returns {boolean} True if any filter is active, false otherwise.
*/
filtersActive() {
- return this.$router.currentRoute.value.query?.status != null || this.$router.currentRoute.value.query?.active != null || this.$router.currentRoute.value.query?.tags != null || this.searchText !== "";
- }
+ return (
+ this.$router.currentRoute.value.query?.status != null ||
+ this.$router.currentRoute.value.query?.active != null ||
+ this.$router.currentRoute.value.query?.tags != null ||
+ this.searchText !== ""
+ );
+ },
},
watch: {
searchText() {
@@ -232,24 +237,20 @@ export default {
const fetchedTagIDs = tagParams
? tagParams
- .split(",")
- .map(identifier => {
- const tagID = parseInt(identifier, 10);
- if (isNaN(tagID)) {
- return;
- }
- return tags.find(t => t.tag_id === tagID)?.id ?? 1;
- })
- .filter(tagID => tagID !== 0)
+ .split(",")
+ .map((identifier) => {
+ const tagID = parseInt(identifier, 10);
+ if (isNaN(tagID)) {
+ return;
+ }
+ return tags.find((t) => t.tag_id === tagID)?.id ?? 1;
+ })
+ .filter((tagID) => tagID !== 0)
: undefined;
this.updateFilter({
- status: statusParams ? statusParams.split(",").map(
- status => status.trim()
- ) : queryParams?.["status"],
- active: activeParams ? activeParams.split(",").map(
- active => active.trim()
- ) : queryParams?.["active"],
+ status: statusParams ? statusParams.split(",").map((status) => status.trim()) : queryParams?.["status"],
+ active: activeParams ? activeParams.split(",").map((active) => active.trim()) : queryParams?.["active"],
tags: tagParams ? fetchedTagIDs : queryParams?.["tags"],
});
},
@@ -291,16 +292,13 @@ export default {
updateFilter(newFilter) {
const newQuery = { ...this.$router.currentRoute.value.query };
- for (const [ key, value ] of Object.entries(newFilter)) {
- if (!value
- || (value instanceof Array && value.length === 0)) {
+ for (const [key, value] of Object.entries(newFilter)) {
+ if (!value || (value instanceof Array && value.length === 0)) {
delete newQuery[key];
continue;
}
- newQuery[key] = value instanceof Array
- ? value.length > 0 ? value.join(",") : null
- : value;
+ newQuery[key] = value instanceof Array ? (value.length > 0 ? value.join(",") : null) : value;
}
this.$router.push({ query: newQuery });
},
@@ -395,7 +393,10 @@ export default {
// filter by status
let statusMatch = true;
- if (this.$router.currentRoute.value.query?.status != null && this.$router.currentRoute.value.query?.status.length > 0) {
+ if (
+ this.$router.currentRoute.value.query?.status != null &&
+ this.$router.currentRoute.value.query?.status.length > 0
+ ) {
if (monitor.id in this.$root.lastHeartbeatList && this.$root.lastHeartbeatList[monitor.id]) {
monitor.status = this.$root.lastHeartbeatList[monitor.id].status;
}
@@ -404,16 +405,22 @@ export default {
// filter by active
let activeMatch = true;
- if (this.$router.currentRoute.value.query?.active != null && this.$router.currentRoute.value.query?.active.length > 0) {
+ if (
+ this.$router.currentRoute.value.query?.active != null &&
+ this.$router.currentRoute.value.query?.active.length > 0
+ ) {
activeMatch = this.$router.currentRoute.value.query?.active.includes(monitor.active);
}
// filter by tags
let tagsMatch = true;
const tagsInURL = this.$router.currentRoute.value.query?.tags?.split(",") || [];
- if (this.$router.currentRoute.value.query?.tags != null && this.$router.currentRoute.value.query?.tags.length > 0) {
- const monitorTagIds = monitor.tags.map(tag => tag.tag_id);
- tagsMatch = tagsInURL.map(Number).some(tagId => monitorTagIds.includes(tagId));
+ if (
+ this.$router.currentRoute.value.query?.tags != null &&
+ this.$router.currentRoute.value.query?.tags.length > 0
+ ) {
+ const monitorTagIds = monitor.tags.map((tag) => tag.tag_id);
+ tagsMatch = tagsInURL.map(Number).some((tagId) => monitorTagIds.includes(tagId));
}
return searchTextMatch && statusMatch && activeMatch && tagsMatch;
diff --git a/src/components/MonitorListFilter.vue b/src/components/MonitorListFilter.vue
index e3549de91..520e72b6a 100644
--- a/src/components/MonitorListFilter.vue
+++ b/src/components/MonitorListFilter.vue
@@ -13,11 +13,12 @@
{{ numFiltersActive }}
-
+
-
+
{{ $t("Status") }}
@@ -137,8 +138,14 @@
{{ $t("Tags") }}
@@ -154,7 +161,7 @@
{{ getTaggedMonitorCount(tag) }}
@@ -184,7 +191,7 @@ export default {
Status,
Tag,
},
- emits: [ "updateFilter" ],
+ emits: ["updateFilter"],
data() {
return {
tagsList: [],
@@ -192,10 +199,14 @@ export default {
},
computed: {
numFiltersActive() {
- return this.$router.currentRoute.value.query.status?.length > 0 ? 1 : 0 +
- this.$router.currentRoute.value.query.active?.length > 0 ? 1 : 0 +
- this.$router.currentRoute.value.query.tags?.length > 0 ? 1 : 0;
- }
+ return this.$router.currentRoute.value.query.status?.length > 0
+ ? 1
+ : 0 + this.$router.currentRoute.value.query.active?.length > 0
+ ? 1
+ : 0 + this.$router.currentRoute.value.query.tags?.length > 0
+ ? 1
+ : 0;
+ },
},
mounted() {
this.getExistingTags();
@@ -216,7 +227,7 @@ export default {
};
if (newFilter.status.includes("" + status)) {
- newFilter.status = newFilter.status.filter(item => item !== "" + status);
+ newFilter.status = newFilter.status.filter((item) => item !== "" + status);
} else {
newFilter.status.push(status);
}
@@ -229,7 +240,7 @@ export default {
};
if (newFilter.active.includes("" + active)) {
- newFilter.active = newFilter.active.filter(item => item !== "" + active);
+ newFilter.active = newFilter.active.filter((item) => item !== "" + active);
} else {
newFilter.active.push(active);
}
@@ -242,7 +253,7 @@ export default {
};
if (newFilter.tags.includes("" + tag.id)) {
- newFilter.tags = newFilter.tags.filter(item => item !== "" + tag.id);
+ newFilter.tags = newFilter.tags.filter((item) => item !== "" + tag.id);
} else {
newFilter.tags.push(tag.id);
}
diff --git a/src/components/TagEditDialog.vue b/src/components/TagEditDialog.vue
index 8210c38b8..262c3c74c 100644
--- a/src/components/TagEditDialog.vue
+++ b/src/components/TagEditDialog.vue
@@ -17,7 +17,7 @@
v-model="tag.name"
type="text"
class="form-control"
- :class="{'is-invalid': nameInvalid || nameContainsComma}"
+ :class="{ 'is-invalid': nameInvalid || nameContainsComma }"
required
/>