Skip to content

Commit

Permalink
Notification Monitor, filter by queue type
Browse files Browse the repository at this point in the history
  • Loading branch information
FMaz008 committed Oct 22, 2024
1 parent 202f50a commit f3320dd
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 21 deletions.
7 changes: 6 additions & 1 deletion page/notifications.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@
<label for="pauseFeed">
<input type="button" name="pauseFeed" id="pauseFeed" value="Pause & Buffer Feed" />
</label>
<label for="filter-type" style="float: right; margin-right: 20px">
<label for="filter-queue" style="float: right; margin-right: 20px">
Filter by:
<select name="filter-queue">
<option value="-1">Show all queues</option>
<option value="last_chance">AFA</option>
<option value="encore">AI</option>
</select>
<select name="filter-type">
<option value="-1">Show all notifications</option>
<option value="0">Regular only</option>
Expand Down
52 changes: 32 additions & 20 deletions page/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,19 @@ async function init() {
);

//Bind the event when changing the filter
const filter = document.querySelector("select[name='filter-type']");
filter.addEventListener("change", function () {
if (filter.value == "-1") {
//Display all notifications
document.querySelectorAll(".vh-notification-box").forEach(function (node, key, parent) {
node.style.display = "grid";
});
} else {
//Display a specific type of notifications only
document.querySelectorAll(".vh-notification-box").forEach(function (node, key, parent) {
processNotificationFiltering(node);
});
}
const filterType = document.querySelector("select[name='filter-type']");
filterType.addEventListener("change", function () {
//Display a specific type of notifications only
document.querySelectorAll(".vh-notification-box").forEach(function (node, key, parent) {
processNotificationFiltering(node);
});
});
const filterQueue = document.querySelector("select[name='filter-queue']");
filterQueue.addEventListener("change", function () {
//Display a specific type of notifications only
document.querySelectorAll(".vh-notification-box").forEach(function (node, key, parent) {
processNotificationFiltering(node);
});
});

//Bind Pause Feed button
Expand Down Expand Up @@ -238,25 +238,37 @@ function processNotificationFiltering(node) {
if (!node) {
return false;
}
const filter = document.querySelector("select[name='filter-type']");
const filterType = document.querySelector("select[name='filter-type']");
const notificationType = parseInt(node.getAttribute("data-notification-type"));
const filterQueue = document.querySelector("select[name='filter-queue']");
const queueType = node.getAttribute("data-queue");

//Feed Paused
if (node.dataset.feedPaused == "true") {
node.style.display = "none";
return false;
}

if (filter.value == -1) {
if (filterType.value == -1) {
node.style.display = "grid";
return true;
} else if (filter.value == TYPE_HIGHLIGHT_OR_ZEROETV) {
} else if (filterType.value == TYPE_HIGHLIGHT_OR_ZEROETV) {
const typesToShow = [TYPE_HIGHLIGHT, TYPE_ZEROETV];
node.style.display = typesToShow.includes(notificationType) ? "grid" : "none";
return typesToShow.includes(notificationType);
typesToShow.includes(notificationType);
} else {
node.style.display = notificationType == filter.value ? "grid" : "none";
return notificationType == filter.value;
node.style.display = notificationType == filterType.value ? "grid" : "none";
notificationType == filterType.value;
}

if (node.style.display == "grid") {
if (filterQueue.value == "-1") {
return true;
} else {
node.style.display = queueType == filterQueue.value ? "grid" : "none";
return queueType == filterQueue.value;
}
} else {
return false;
}
}

Expand Down
1 change: 1 addition & 0 deletions view/notification_monitor.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class="vh-notification-box"
data-notification-type="{{$type}}"
data-feed-paused="{{$feedPaused}}"
data-queue="{{$queue}}"
>
<div class="vh-notification-toolbar">
<a href="{{$url}}" target="_blank">
Expand Down

0 comments on commit f3320dd

Please sign in to comment.