Render log rows

This commit is contained in:
jude 2023-09-03 16:00:49 +01:00
parent ee89cb40c5
commit b225ad7e45
4 changed files with 50 additions and 65 deletions

View File

@ -706,16 +706,32 @@ div.reminderError .errorIcon {
margin-right: 12px; margin-right: 12px;
} }
div.reminderError .errorIcon.deleted { div.reminderError .errorIcon .fas {
display: none
}
div.reminderError[data-case="deleted"] .errorIcon {
background-color: #e7e5e4; background-color: #e7e5e4;
} }
div.reminderError .errorIcon.success { div.reminderError[data-case="failed"] .errorIcon {
background-color: #fecaca;
}
div.reminderError[data-case="sent"] .errorIcon {
background-color: #d9f99d; background-color: #d9f99d;
} }
div.reminderError .errorIcon.errored { div.reminderError[data-case="deleted"] .errorIcon .fas.fa-trash {
background-color: #fecaca; display: block;
}
div.reminderError[data-case="failed"] .errorIcon .fas.fa-exclamation-triangle {
display: block;
}
div.reminderError[data-case="sent"] .errorIcon .fas.fa-check {
display: block;
} }
div.reminderError .errorHead .reminderName { div.reminderError .errorHead .reminderName {

View File

@ -1,6 +1,6 @@
function loadErrors() { function loadErrors() {
return fetch( return fetch(
`/dashboard/api/guild/${guildId()}/reminders?status=deleted,sent,error` `/dashboard/api/guild/${guildId()}/reminders?status=deleted,sent,failed`
).then((response) => response.json()); ).then((response) => response.json());
} }
@ -9,9 +9,20 @@ document.addEventListener("paneLoad", (ev) => {
return; return;
} }
// Load errors document.querySelectorAll(".reminderError").forEach((el) => el.remove());
const template = document.getElementById("reminderError");
const container = document.getElementById("reminderLog");
loadErrors().then((res) => { loadErrors().then((res) => {
console.log(res); for (const reminder of res) {
const newRow = template.content.cloneNode(true);
newRow.querySelector(".reminderName").textContent = reminder.name;
newRow.querySelector(".reminderError").dataset["case"] = reminder.status;
container.appendChild(newRow);
}
}); });
$loader.classList.add("is-hidden"); $loader.classList.add("is-hidden");

View File

@ -1,51 +1,5 @@
<div> <div id="reminderLog">
<div class="reminderError">
<div class="errorHead">
<div class="errorIcon deleted">
<span class="icon">
<i class="fas fa-trash"></i>
</span>
</div>
<div class="reminderName">
Reminder
</div>
<div class="reminderTime">
</div>
</div>
</div>
<div class="reminderError">
<div class="errorHead">
<div class="errorIcon errored">
<span class="icon">
<i class="fas fa-exclamation-triangle"></i>
</span>
</div>
<div class="reminderName">
Reminder
</div>
<div class="reminderTime">
</div>
</div>
</div>
<div class="reminderError">
<div class="errorHead">
<div class="errorIcon success">
<span class="icon">
<i class="fas fa-check"></i>
</span>
</div>
<div class="reminderName">
Reminder
</div>
<div class="reminderTime">
</div>
</div>
</div>
</div> </div>
<script src="/static/js/reminder_errors.js"></script> <script src="/static/js/reminder_errors.js"></script>

View File

@ -1,13 +1,17 @@
<div class="reminderError"> <div class="reminderError" data-case="success">
<div class="errorIcon"> <div class="errorHead">
<span> <div class="errorIcon">
<i class="fas fa-trash"></i> <span class="icon">
</span> <i class="fas fa-trash"></i>
</div> <i class="fas fa-check"></i>
<div> <i class="fas fa-exclamation-triangle"></i>
<span class="reminderName"></span> </span>
</div> </div>
<div> <div class="reminderName">
<span></span> Reminder
</div>
<div class="reminderTime">
</div>
</div> </div>
</div> </div>