Improved alert filter UI.

This commit is contained in:
DebaucheryLibrarian 2025-03-13 00:49:09 +01:00
parent 4e15c4ca03
commit 7cebb1bcce
2 changed files with 65 additions and 14 deletions

View File

@ -52,15 +52,22 @@
:class="{ active: filterExpressions }" :class="{ active: filterExpressions }"
@click="filterExpressions = !filterExpressions" @click="filterExpressions = !filterExpressions"
/> />
</div>
<div class="filters-section">
<Icon <Icon
v-if="filterCombined === false"
icon="target3" icon="target3"
title="Only show uncombined alerts" title="Only show uncombined alerts"
class="noselect active filters-uncombined"
@click="toggleFilterCombined"
/>
<Icon
v-else
icon="make-group"
title="Only show combined alerts"
class="noselect filters-uncombined" class="noselect filters-uncombined"
:class="{ active: filterCombined }" :class="{ active: filterCombined }"
@click="filterCombined = !filterCombined" @click="toggleFilterCombined"
/> />
</div> </div>
</div> </div>
@ -239,7 +246,7 @@ const filterActors = ref(false);
const filterEntities = ref(false); const filterEntities = ref(false);
const filterTags = ref(false); const filterTags = ref(false);
const filterExpressions = ref(false); const filterExpressions = ref(false);
const filterCombined = ref(false); const filterCombined = ref(null);
const filteredAlerts = computed(() => { const filteredAlerts = computed(() => {
const queryRegex = new RegExp(query.value, 'i'); const queryRegex = new RegExp(query.value, 'i');
@ -261,7 +268,11 @@ const filteredAlerts = computed(() => {
return false; return false;
} }
if (filterCombined.value && [...alert.actors, ...alert.entities, ...alert.tags, ...alert.matches].length > 1) { if (filterCombined.value === false && [...alert.actors, ...alert.entities, ...alert.tags, ...alert.matches].length > 1) {
return false;
}
if (filterCombined.value === true && [...alert.actors, ...alert.entities, ...alert.tags, ...alert.matches].length === 1) {
return false; return false;
} }
@ -323,6 +334,14 @@ async function removeAlert(alert) {
done.value = true; done.value = true;
} }
} }
const filterCombinedStates = [null, true, false];
function toggleFilterCombined() {
const index = filterCombinedStates.indexOf(filterCombined.value);
filterCombined.value = filterCombinedStates[(index + 1) % filterCombinedStates.length];
}
</script> </script>
<style scoped> <style scoped>
@ -333,9 +352,13 @@ async function removeAlert(alert) {
.filters { .filters {
display: flex; display: flex;
flex-wrap: wrap;
align-items: center; align-items: center;
padding-left: .5rem; gap: .5rem;
margin-bottom: .5rem; box-sizing: border-box;
padding: 0 .5rem;
margin: .5rem 0 .75rem 0;
overflow: hidden;
.input { .input {
margin-right: 1rem; margin-right: 1rem;
@ -348,22 +371,28 @@ async function removeAlert(alert) {
fill: var(--glass); fill: var(--glass);
&:hover { &:hover {
fill: var(--primary); fill: var(--glass-strong-10);
cursor: pointer; cursor: pointer;
} }
&.active { &.active {
fill: var(--primary); fill: var(--primary);
} }
&.success {
fill: var(--success);
}
&.error {
fill: var(--error);
}
} }
} }
.filters-section { .filters-uncombined.icon {
&:not(:last-child) { padding-left: .75rem;
padding-right: .5rem; border-left: solid 1px var(--glass-weak-30);
border-right: solid 1px var(--glass-weak-30); margin-left: .5rem;
margin-right: .5rem;
}
} }
.alert { .alert {
@ -480,6 +509,10 @@ async function removeAlert(alert) {
.alert { .alert {
padding: 0 .5rem; padding: 0 .5rem;
} }
.filters {
justify-content: space-between;
}
} }
@media(--small-20) { @media(--small-20) {
@ -493,4 +526,15 @@ async function removeAlert(alert) {
justify-content: space-between; justify-content: space-between;
} }
} }
@media(--small-30) {
.filters {
flex-direction: column;
justify-content: center;
.input {
width: 100%;
}
}
}
</style> </style>

View File

@ -5,6 +5,7 @@
> >
<div <div
v-if="showSecondary && !!itemAlerts" v-if="showSecondary && !!itemAlerts"
class="alert-trigger"
> >
<Icon <Icon
v-if="itemAlerted" v-if="itemAlerted"
@ -360,4 +361,10 @@ async function reloadStashes(newStash) {
fill: var(--text-light); fill: var(--text-light);
} }
} }
.alert-trigger:not(:last-child) {
padding-right: .25rem;
border-right: solid 1px var(--highlight-weak-30);
margin-right: .25rem;
}
</style> </style>