[autofix.ci] apply automated fixes
This commit is contained in:
parent
b9b2f9343a
commit
51d07a64df
@ -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;
|
||||
|
||||
@ -13,11 +13,12 @@
|
||||
<span v-if="numFiltersActive > 0" class="px-1 fw-bold">{{ numFiltersActive }}</span>
|
||||
<font-awesome-icon v-if="numFiltersActive > 0" icon="times" />
|
||||
</button>
|
||||
<MonitorListFilterDropdown
|
||||
:filterActive="$router.currentRoute.value.query?.status?.length > 0"
|
||||
>
|
||||
<MonitorListFilterDropdown :filterActive="$router.currentRoute.value.query?.status?.length > 0">
|
||||
<template #status>
|
||||
<Status v-if="$router.currentRoute.value.query?.status?.length === 1" :status="$router.currentRoute.value.query?.status[0]" />
|
||||
<Status
|
||||
v-if="$router.currentRoute.value.query?.status?.length === 1"
|
||||
:status="$router.currentRoute.value.query?.status[0]"
|
||||
/>
|
||||
<span v-else>
|
||||
{{ $t("Status") }}
|
||||
</span>
|
||||
@ -137,8 +138,14 @@
|
||||
<MonitorListFilterDropdown :filterActive="$router.currentRoute.value.query?.tags?.length > 0">
|
||||
<template #status>
|
||||
<Tag
|
||||
v-if="$router.currentRoute.value.query?.tags?.split?.(',')?.length === 1 && tagsList.find(tag => tag.id === +$router.currentRoute.value.query?.tags?.split?.(',')?.[0])"
|
||||
:item="tagsList.find(tag => tag.id === +$router.currentRoute.value.query?.tags?.split?.(',')?.[0])" :size="'sm'"
|
||||
v-if="
|
||||
$router.currentRoute.value.query?.tags?.split?.(',')?.length === 1 &&
|
||||
tagsList.find((tag) => tag.id === +$router.currentRoute.value.query?.tags?.split?.(',')?.[0])
|
||||
"
|
||||
:item="
|
||||
tagsList.find((tag) => tag.id === +$router.currentRoute.value.query?.tags?.split?.(',')?.[0])
|
||||
"
|
||||
:size="'sm'"
|
||||
/>
|
||||
<span v-else>
|
||||
{{ $t("Tags") }}
|
||||
@ -154,7 +161,7 @@
|
||||
<span class="ps-3">
|
||||
{{ getTaggedMonitorCount(tag) }}
|
||||
<span
|
||||
v-if="$router.currentRoute.value.query?.tags?.split(',').includes(''+tag.id)"
|
||||
v-if="$router.currentRoute.value.query?.tags?.split(',').includes('' + tag.id)"
|
||||
class="px-1 filter-active"
|
||||
>
|
||||
<font-awesome-icon icon="check" />
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
v-model="tag.name"
|
||||
type="text"
|
||||
class="form-control"
|
||||
:class="{'is-invalid': nameInvalid || nameContainsComma}"
|
||||
:class="{ 'is-invalid': nameInvalid || nameContainsComma }"
|
||||
required
|
||||
/>
|
||||
<div class="invalid-feedback">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user