From adf29dca5d474f233b997675bf949ab963433d99 Mon Sep 17 00:00:00 2001 From: jude Date: Sat, 19 Aug 2023 22:37:48 +0100 Subject: [PATCH] Start to think about how to display errors --- postman/src/sender.rs | 2 +- web/src/routes/dashboard/guild.rs | 2 +- web/static/js/main.js | 10 ++++++++++ web/static/js/reminder_errors.js | 19 ------------------- web/static/js/reminder_errors.ts | 19 ------------------- web/templates/dashboard.html.tera | 4 ++++ .../reminder_dashboard.html.tera | 4 ++++ 7 files changed, 20 insertions(+), 40 deletions(-) delete mode 100644 web/static/js/reminder_errors.js delete mode 100644 web/static/js/reminder_errors.ts diff --git a/postman/src/sender.rs b/postman/src/sender.rs index 096dad9..da99555 100644 --- a/postman/src/sender.rs +++ b/postman/src/sender.rs @@ -310,7 +310,7 @@ WHERE reminders WHERE reminders.`utc_time` <= NOW() AND - reminders.`channel_id` NOT NULL AND + reminders.`channel_id` IS NOT NULL AND `status` = 'pending' AND ( reminders.`interval_seconds` IS NOT NULL diff --git a/web/src/routes/dashboard/guild.rs b/web/src/routes/dashboard/guild.rs index 019e99d..0d34365 100644 --- a/web/src/routes/dashboard/guild.rs +++ b/web/src/routes/dashboard/guild.rs @@ -624,7 +624,7 @@ pub async fn get_reminder_errors( reminders.channel_id AS channel FROM reminders LEFT JOIN channels ON channels.id = reminders.channel_id - WHERE (`status` != 'pending' OR reminders.channel_id IS NULL) AND reminders.guild_id = (SELECT id FROM guilds WHERE guild = ?)", + WHERE (`status` = 'failed' OR reminders.channel_id IS NULL) AND reminders.guild_id = (SELECT id FROM guilds WHERE guild = ?)", id ) .fetch_all(pool.inner()) diff --git a/web/static/js/main.js b/web/static/js/main.js index b79ce7d..2199295 100644 --- a/web/static/js/main.js +++ b/web/static/js/main.js @@ -18,6 +18,7 @@ const $downloader = document.querySelector("a#downloader"); const $uploader = document.querySelector("input#uploader"); let channels = []; +let reminderErrors = []; let guildNames = {}; let roles = []; let templates = {}; @@ -36,6 +37,12 @@ function guildId() { return document.querySelector(".guildList a.is-active").dataset["guild"]; } +function loadErrors() { + return fetch(`/dashboard/api/guild/${guildId()}/errors`).then((response) => + response.json() + ); +} + function colorToInt(r, g, b) { return (r << 16) + (g << 8) + b; } @@ -476,6 +483,9 @@ document.addEventListener("guildSwitched", async (e) => { fetch_roles(e.detail.guild_id); fetch_templates(e.detail.guild_id); fetch_reminders(e.detail.guild_id); + loadErrors().then((res) => { + console.log(res); + }); document.querySelectorAll("p.pageTitle").forEach((el) => { el.textContent = `${e.detail.guild_name} Reminders`; diff --git a/web/static/js/reminder_errors.js b/web/static/js/reminder_errors.js deleted file mode 100644 index 42246bc..0000000 --- a/web/static/js/reminder_errors.js +++ /dev/null @@ -1,19 +0,0 @@ -let _reminderErrors = []; - -const reminderErrors = () => { - return _reminderErrors; -} - -const guildId = () => { - let selected = document.querySelector(".guildList a.is-active"); - return selected.dataset["guild"]; -} - - -function loadErrors() { - fetch(`/dashboard/api/guild/${guildId()}/errors`).then(response => response.json()) -} - -document.addEventListener('DOMContentLoaded', () => { - -}) diff --git a/web/static/js/reminder_errors.ts b/web/static/js/reminder_errors.ts deleted file mode 100644 index 6fa4798..0000000 --- a/web/static/js/reminder_errors.ts +++ /dev/null @@ -1,19 +0,0 @@ -let _reminderErrors = []; - -const reminderErrors = () => { - return _reminderErrors; -} - -const guildId = () => { - let selected: HTMLElement = document.querySelector(".guildList a.is-active"); - return selected.dataset["guild"]; -} - - -function loadErrors() { - fetch(`/dashboard/api/guild/${guildId()}/errors`).then(response => response.json()) -} - -document.addEventListener('DOMContentLoaded', () => { - -}) diff --git a/web/templates/dashboard.html.tera b/web/templates/dashboard.html.tera index c84b5dc..4731427 100644 --- a/web/templates/dashboard.html.tera +++ b/web/templates/dashboard.html.tera @@ -385,6 +385,10 @@ {% include "reminder_dashboard/guild_reminder" %} + + diff --git a/web/templates/reminder_dashboard/reminder_dashboard.html.tera b/web/templates/reminder_dashboard/reminder_dashboard.html.tera index 8849767..2ef2dd2 100644 --- a/web/templates/reminder_dashboard/reminder_dashboard.html.tera +++ b/web/templates/reminder_dashboard/reminder_dashboard.html.tera @@ -46,6 +46,10 @@
+ +
+ +