collapse/expand elements. moved the embed color picker

This commit is contained in:
jude 2022-03-20 18:29:27 +00:00
parent 318be1fa5e
commit af9d8bea62
9 changed files with 599 additions and 568 deletions

View File

@ -1 +1,2 @@
printWidth = 90
tabWidth = 4

View File

@ -362,7 +362,49 @@ pub async fn edit_reminder(
.await;
}
json!({})
match sqlx::query_as_unchecked!(
Reminder,
"SELECT reminders.attachment,
reminders.attachment_name,
reminders.avatar,
channels.channel,
reminders.content,
reminders.embed_author,
reminders.embed_author_url,
reminders.embed_color,
reminders.embed_description,
reminders.embed_footer,
reminders.embed_footer_url,
reminders.embed_image_url,
reminders.embed_thumbnail_url,
reminders.embed_title,
reminders.enabled,
reminders.expires,
reminders.interval_seconds,
reminders.interval_months,
reminders.name,
reminders.pin,
reminders.restartable,
reminders.tts,
reminders.uid,
reminders.username,
reminders.utc_time
FROM reminders
LEFT JOIN channels ON channels.id = reminders.channel_id
WHERE uid = ?",
reminder.uid
)
.fetch_one(pool.inner())
.await
{
Ok(reminder) => json!(reminder),
Err(e) => {
warn!("Error exiting `edit_reminder': {:?}", e);
json!({"error": "Unknown error"})
}
}
}
#[delete("/api/guild/<id>/reminders", data = "<reminder>")]

View File

@ -2,6 +2,69 @@
font-family: "Ubuntu Bold", "Ubuntu", sans-serif;
}
/* override styles for when the div is collapsed */
div.reminderContent.is-collapsed .column.discord-frame {
display: none;
}
div.reminderContent.is-collapsed .collapses {
display: none;
}
div.reminderContent.is-collapsed .invert-collapses {
display: inline-flex;
}
div.reminderContent .invert-collapses {
display: none;
}
div.reminderContent.is-collapsed .settings {
display: flex;
flex-direction: row;
padding-bottom: 0;
}
div.reminderContent.is-collapsed .channel-field {
display: inline-flex;
order: 1;
}
div.reminderContent.is-collapsed .columns {
display: inline-flex;
margin-bottom: 0px;
flex-grow: 1;
order: 2;
}
div.reminderContent.is-collapsed input[name="name"] {
display: inline-flex;
flex-grow: 1;
}
div.reminderContent.is-collapsed button.hide-box {
display: inline-flex;
}
div.reminderContent.is-collapsed button.hide-box i {
transform: rotate(90deg);
}
/* END */
/* dashboard styles */
button.change-color {
position: absolute;
left: calc(-1rem - 40px);
}
.media-content {
overflow-x: visible;
}
div.discord-embed {
position: relative;
}
div.reminderContent {
padding: 2px;
background-color: #f5f5f5;
@ -340,36 +403,6 @@ textarea, input {
flex-wrap: wrap;
}
.icon-toggle {
color: #fff;
opacity: 0.2;
}
.preview-toggle {
color: #fcb620;
opacity: 0.2;
}
a.level-item.preview-toggle:hover {
color: #fcb620;
}
.preview-toggle.is-active {
opacity: 1;
}
a.level-item.icon-toggle:hover {
color: inherit;
}
a.level-item:hover {
color: rgb(55, 127, 242)
}
.icon-toggle.is-active {
opacity: 1;
}
.channel-select {
font-size: 1.125rem;
margin-bottom: 4px;

23
web/static/js/expand.js Normal file
View File

@ -0,0 +1,23 @@
function collapse_all() {
document.querySelectorAll("div.reminderContent:not(.creator)").forEach((el) => {
el.classList.add("is-collapsed");
});
}
function expand_all() {
document.querySelectorAll("div.reminderContent:not(.creator)").forEach((el) => {
el.classList.remove("is-collapsed");
});
}
const expandAll = document.querySelector("#expandAll");
expandAll.addEventListener("change", (ev) => {
if (ev.target.value === "expand") {
expand_all();
} else if (ev.target.value === "collapse") {
collapse_all();
}
ev.target.value = "";
});

View File

@ -11,8 +11,6 @@ let botTimezone = "UTC";
let channels;
let roles;
const remindersLoadedEvent = new Event("remindersLoaded");
function colorToInt(r, g, b) {
return (r << 16) + (g << 8) + b;
}
@ -44,24 +42,17 @@ function switch_pane(selector) {
function update_select(sel) {
if (sel.selectedOptions[0].dataset["webhookAvatar"]) {
sel
.closest("div.reminderContent")
.querySelector("img.discord-avatar").src =
sel.closest("div.reminderContent").querySelector("img.discord-avatar").src =
sel.selectedOptions[0].dataset["webhookAvatar"];
} else {
sel
.closest("div.reminderContent")
.querySelector("img.discord-avatar").src = "";
sel.closest("div.reminderContent").querySelector("img.discord-avatar").src = "";
}
if (sel.selectedOptions[0].dataset["webhookName"]) {
sel
.closest("div.reminderContent")
.querySelector("input.discord-username").value =
sel.closest("div.reminderContent").querySelector("input.discord-username").value =
sel.selectedOptions[0].dataset["webhookName"];
} else {
sel
.closest("div.reminderContent")
.querySelector("input.discord-username").value = "";
sel.closest("div.reminderContent").querySelector("input.discord-username").value =
"";
}
}
@ -84,145 +75,106 @@ function fetch_roles(guild_id) {
}
async function fetch_reminders(guild_id) {
// fetch dm reminders instead
if (guild_id === undefined) {
const $reminderBox = document.querySelector("div#personalReminders");
const $reminderBox = document.querySelector("div#guildReminders");
// reset div contents
$reminderBox.innerHTML = "";
// reset div contents
$reminderBox.innerHTML = "";
// fetch reminders
await fetch("dashboard/api/user/reminders")
.then((response) => response.json())
.then((data) => {
if (data.error) {
show_error(data.error);
} else {
const $template = document.querySelector(
"template#personalReminder"
);
// fetch reminders
await fetch(`dashboard/api/guild/${guild_id}/reminders`)
.then((response) => response.json())
.then((data) => {
if (data.error) {
show_error(data.error);
} else {
const $template = document.querySelector("template#guildReminder");
for (let reminder of data) {
let newFrame = $template.content.cloneNode(true);
for (let reminder of data) {
let newFrame = $template.content.cloneNode(true);
for (let prop in reminder) {
if (
reminder.hasOwnProperty(prop) &&
reminder[prop] !== null
) {
let $input = newFrame.querySelector(
`*[name="${prop}"]`
);
let $image = newFrame.querySelector(
`img.${prop}`
);
newFrame.querySelector(".reminderContent").dataset.uid =
reminder["uid"];
if ($input !== null) {
$input.value = reminder[prop];
} else if ($image !== null) {
$image.src = reminder[prop];
}
// populate channels
set_channels(newFrame.querySelector("select.channel-selector"));
// populate majority of items
for (let prop in reminder) {
if (reminder.hasOwnProperty(prop) && reminder[prop] !== null) {
let $input = newFrame.querySelector(`*[name="${prop}"]`);
let $image = newFrame.querySelector(`img.${prop}`);
if ($input !== null) {
$input.value = reminder[prop];
} else if ($image !== null) {
$image.src = reminder[prop];
}
}
$reminderBox.append(newFrame);
}
}
});
} else {
const $reminderBox = document.querySelector("div#guildReminders");
// reset div contents
$reminderBox.innerHTML = "";
let $enableBtn = newFrame.querySelector(".disable-enable");
$enableBtn.textContent = reminder["enabled"] ? "Disable" : "Enable";
$enableBtn.dataset.action = reminder["enabled"]
? "disable"
: "enable";
// fetch reminders
await fetch(`dashboard/api/guild/${guild_id}/reminders`)
.then((response) => response.json())
.then((data) => {
if (data.error) {
show_error(data.error);
} else {
console.log(data);
const $template = document.querySelector(
"template#guildReminder"
let timeInput = newFrame.querySelector('input[name="time"]');
let localTime = luxon.DateTime.fromISO(reminder["utc_time"]).setZone(
timezone
);
timeInput.value = localTime.toFormat("yyyy-LL-dd'T'HH:mm:ss");
for (let reminder of data) {
let newFrame = $template.content.cloneNode(true);
$reminderBox.appendChild(newFrame);
newFrame.querySelector(".reminderContent").dataset.uid =
reminder["uid"];
// populate channels
set_channels(
newFrame.querySelector("select.channel-selector")
);
// populate majority of items
for (let prop in reminder) {
if (
reminder.hasOwnProperty(prop) &&
reminder[prop] !== null
) {
let $input = newFrame.querySelector(
`*[name="${prop}"]`
);
let $image = newFrame.querySelector(
`img.${prop}`
);
if ($input !== null) {
$input.value = reminder[prop];
} else if ($image !== null) {
$image.src = reminder[prop];
}
}
}
let guild = document.querySelector(
".guildList a.is-active"
).dataset["guild"];
let $enableBtn =
newFrame.querySelector(".disable-enable");
$enableBtn.textContent = reminder["enabled"]
? "Disable"
: "Enable";
$enableBtn.addEventListener("click", () => {
fetch(`/dashboard/api/guild/${guild}/reminders`, {
method: "PATCH",
body: JSON.stringify({
uid: reminder["uid"],
enabled: false,
}),
});
});
let timeInput =
newFrame.querySelector('input[name="time"]');
let localTime = luxon.DateTime.fromISO(
reminder["utc_time"]
).setZone(timezone);
timeInput.value = localTime.toFormat(
"yyyy-LL-dd'T'HH:mm:ss"
);
$reminderBox.appendChild(newFrame);
}
reminder.node = $reminderBox.lastElementChild;
}
});
}
document.dispatchEvent(remindersLoadedEvent);
const remindersLoadedEvent = new CustomEvent("remindersLoaded", {
detail: data,
});
document.dispatchEvent(remindersLoadedEvent);
}
});
register_interval_hide();
}
document.addEventListener("remindersLoaded", (event) => {
const guild = document.querySelector(".guildList a.is-active").dataset["guild"];
for (let reminder of event.detail) {
reminder.node.querySelector("button.hide-box").addEventListener("click", () => {
reminder.node.closest(".reminderContent").classList.toggle("is-collapsed");
});
const enableBtn = reminder.node.querySelector(".disable-enable");
enableBtn.addEventListener("click", () => {
let enable = enableBtn.dataset.action === "enable";
fetch(`/dashboard/api/guild/${guild}/reminders`, {
method: "PATCH",
body: JSON.stringify({
uid: reminder["uid"],
enabled: enable,
}),
})
.then((response) => response.json())
.then((data) => {
if (data.error) {
show_error(data.error);
} else {
enableBtn.textContent = data["enabled"] ? "Disable" : "Enable";
enableBtn.dataset.action = data["enabled"] ? "enable" : "disable";
}
});
});
}
});
function show_error(error) {
document
.getElementById("errors")
.querySelector("span.error-message").textContent = error;
document.getElementById("errors").querySelector("span.error-message").textContent =
error;
document.getElementById("errors").classList.add("is-active");
window.setTimeout(() => {
@ -235,9 +187,7 @@ function update_times() {
element.textContent = timezone;
});
document.querySelectorAll("span.set-time").forEach((element) => {
element.textContent = luxon.DateTime.now()
.setZone(timezone)
.toFormat("HH:mm");
element.textContent = luxon.DateTime.now().setZone(timezone).toFormat("HH:mm");
});
document.querySelectorAll("span.browser-timezone").forEach((element) => {
element.textContent = browserTimezone;
@ -249,9 +199,7 @@ function update_times() {
element.textContent = botTimezone;
});
document.querySelectorAll("span.bot-time").forEach((element) => {
element.textContent = luxon.DateTime.now()
.setZone(botTimezone)
.toFormat("HH:mm");
element.textContent = luxon.DateTime.now().setZone(botTimezone).toFormat("HH:mm");
});
}
@ -263,12 +211,10 @@ document.getElementById("set-bot-timezone").addEventListener("click", () => {
timezone = botTimezone;
update_times();
});
document
.getElementById("set-browser-timezone")
.addEventListener("click", () => {
timezone = browserTimezone;
update_times();
});
document.getElementById("set-browser-timezone").addEventListener("click", () => {
timezone = browserTimezone;
update_times();
});
document.getElementById("update-bot-timezone").addEventListener("click", () => {
timezone = browserTimezone;
fetch("/dashboard/api/user", {
@ -302,21 +248,7 @@ colorPicker.on("color:change", function (color) {
$colorPickerInput.value = color.hexString;
});
document.querySelectorAll(".discord-embed").forEach((element) => {
element.addEventListener("click", (e) => {
if (
e.offsetX <
parseInt(window.getComputedStyle(element).borderLeftWidth)
) {
$discordFrame = element;
$colorPickerModal.classList.toggle("is-active");
colorPicker.color.rgbString =
window.getComputedStyle($discordFrame).borderLeftColor;
}
});
});
document.querySelectorAll(".set-color").forEach((element) => {
document.querySelectorAll(".change-color").forEach((element) => {
element.addEventListener("click", (e) => {
e.preventDefault();
@ -329,20 +261,16 @@ document.querySelectorAll(".set-color").forEach((element) => {
});
});
$colorPickerModal
.querySelector("button.is-success")
.addEventListener("click", () => {
$discordFrame.style.borderLeftColor = colorPicker.color.rgbString;
$colorPickerModal.querySelector("button.is-success").addEventListener("click", () => {
$discordFrame.style.borderLeftColor = colorPicker.color.rgbString;
$colorPickerModal.classList.remove("is-active");
});
$colorPickerModal.classList.remove("is-active");
});
document.querySelectorAll("a.show-modal").forEach((element) => {
element.addEventListener("click", (e) => {
e.preventDefault();
document
.getElementById(element.dataset["modal"])
.classList.toggle("is-active");
document.getElementById(element.dataset["modal"]).classList.toggle("is-active");
});
});
@ -359,34 +287,35 @@ document.addEventListener("DOMContentLoaded", () => {
});
});
let hideBox = document.querySelector("#reminderCreator button.hide-box");
hideBox.addEventListener("click", () => {
hideBox.closest(".reminderContent").classList.toggle("is-collapsed");
});
fetch("/dashboard/api/user")
.then((response) => response.json())
.then((data) => {
if (data.error) {
show_error(data.error);
} else {
document
.querySelectorAll("a.switch-pane")
.forEach((element) => {
element.innerHTML = element.innerHTML.replace(
"%username%",
data.name
);
document.querySelectorAll("a.switch-pane").forEach((element) => {
element.innerHTML = element.innerHTML.replace(
"%username%",
data.name
);
element.addEventListener("click", (e) => {
e.preventDefault();
element.addEventListener("click", (e) => {
e.preventDefault();
switch_pane(element.dataset["pane"]);
switch_pane(element.dataset["pane"]);
element.classList.add("is-active");
element.classList.add("is-active");
document
.querySelectorAll("p.pageTitle")
.forEach((el) => {
el.textContent = "Your Reminders";
});
document.querySelectorAll("p.pageTitle").forEach((el) => {
el.textContent = "Your Reminders";
});
});
});
if (data.timezone !== null) {
botTimezone = data.timezone;
@ -405,78 +334,67 @@ document.addEventListener("DOMContentLoaded", () => {
const $template = document.getElementById("guildListEntry");
for (let guild of data) {
document
.querySelectorAll(".guildList")
.forEach((element) => {
const $clone = $template.content.cloneNode(true);
const $anchor = $clone.querySelector("a");
document.querySelectorAll(".guildList").forEach((element) => {
const $clone = $template.content.cloneNode(true);
const $anchor = $clone.querySelector("a");
$anchor.innerHTML = $clone
.querySelector("a")
.innerHTML.replace("%guildname%", guild.name);
$anchor.dataset["guild"] = guild.id;
$anchor.dataset["name"] = guild.name;
$anchor.innerHTML = $clone
.querySelector("a")
.innerHTML.replace("%guildname%", guild.name);
$anchor.dataset["guild"] = guild.id;
$anchor.dataset["name"] = guild.name;
$anchor.addEventListener("click", async (e) => {
e.preventDefault();
$anchor.addEventListener("click", async (e) => {
e.preventDefault();
$loader.classList.remove("is-hidden");
$loader.classList.remove("is-hidden");
switch_pane($anchor.dataset["pane"]);
switch_pane($anchor.dataset["pane"]);
reset_guild_pane();
reset_guild_pane();
fetch_roles($anchor.dataset["guild"]);
fetch_roles($anchor.dataset["guild"]);
await fetch(
`/dashboard/api/guild/${$anchor.dataset["guild"]}/channels`
)
.then((response) => response.json())
.then((data) => {
if (data.error) {
if (
data.error ===
"Bot not in guild"
) {
switch_pane("guild-error");
} else {
show_error(data.error);
}
await fetch(
`/dashboard/api/guild/${$anchor.dataset["guild"]}/channels`
)
.then((response) => response.json())
.then((data) => {
if (data.error) {
if (data.error === "Bot not in guild") {
switch_pane("guild-error");
} else {
channels = data;
document
.querySelectorAll(
"select.channel-selector"
)
.forEach(set_channels);
show_error(data.error);
}
});
} else {
channels = data;
fetch_reminders($anchor.dataset["guild"]);
document
.querySelectorAll("select.channel-selector")
.forEach(set_channels);
}
});
document
.querySelectorAll("p.pageTitle")
.forEach((el) => {
el.textContent =
$anchor.dataset["name"] +
" Reminders";
});
document
.querySelectorAll("select.channel-selector")
.forEach((el) => {
el.addEventListener("change", (e) => {
update_select(e.target);
});
});
$anchor.classList.add("is-active");
resize_textareas();
fetch_reminders($anchor.dataset["guild"]);
$loader.classList.add("is-hidden");
document.querySelectorAll("p.pageTitle").forEach((el) => {
el.textContent = $anchor.dataset["name"] + " Reminders";
});
document
.querySelectorAll("select.channel-selector")
.forEach((el) => {
el.addEventListener("change", (e) => {
update_select(e.target);
});
});
$anchor.classList.add("is-active");
resize_textareas();
element.append($clone);
$loader.classList.add("is-hidden");
});
element.append($clone);
});
}
}
});
@ -505,95 +423,68 @@ function set_channels(element) {
let $createReminder = document.querySelector("#reminderCreator");
$createReminder
.querySelector("button#createReminder")
.addEventListener("click", () => {
// create reminder object
let seconds =
parseInt(
$createReminder.querySelector('input[name="interval_seconds"]')
.value
) || null;
let months =
parseInt(
$createReminder.querySelector('input[name="interval_months"]')
.value
) || null;
$createReminder.querySelector("button#createReminder").addEventListener("click", () => {
// create reminder object
let seconds =
parseInt($createReminder.querySelector('input[name="interval_seconds"]').value) ||
null;
let months =
parseInt($createReminder.querySelector('input[name="interval_months"]').value) ||
null;
let rgb_color = window.getComputedStyle(
$createReminder.querySelector("div.discord-embed")
).borderLeftColor;
let rgb = rgb_color.match(/\d+/g);
let color = colorToInt(
parseInt(rgb[0]),
parseInt(rgb[1]),
parseInt(rgb[2])
);
let rgb_color = window.getComputedStyle(
$createReminder.querySelector("div.discord-embed")
).borderLeftColor;
let rgb = rgb_color.match(/\d+/g);
let color = colorToInt(parseInt(rgb[0]), parseInt(rgb[1]), parseInt(rgb[2]));
let utc_time = luxon.DateTime.fromISO(
$createReminder.querySelector('input[name="time"]').value
).setZone("UTC");
let utc_time = luxon.DateTime.fromISO(
$createReminder.querySelector('input[name="time"]').value
).setZone("UTC");
let reminder = {
avatar: $createReminder.querySelector("img.discord-avatar").src,
channel: $createReminder.querySelector("select.channel-selector")
.value,
content: $createReminder.querySelector("textarea#messageContent")
.value,
embed_author_url: $createReminder.querySelector(
"img.embed_author_url"
).src,
embed_author: $createReminder.querySelector("textarea#embedAuthor")
.value,
embed_color: color,
embed_description: $createReminder.querySelector(
"textarea#embedDescription"
).value,
embed_footer: $createReminder.querySelector("textarea#embedFooter")
.value,
embed_footer_url: $createReminder.querySelector(
"img.embed_footer_url"
).src,
embed_image_url: $createReminder.querySelector(
"img.embed_image_url"
).src,
embed_thumbnail_url: $createReminder.querySelector(
"img.embed_thumbnail_url"
).src,
embed_title: $createReminder.querySelector("textarea#embedTitle")
.value,
enabled: true,
expires: null,
interval_seconds: seconds,
interval_months: months,
name: $createReminder.querySelector('input[name="name"]').value,
pin: $createReminder.querySelector('input[name="pin"]').checked,
restartable: false,
tts: $createReminder.querySelector('input[name="tts"]').checked,
username: $createReminder.querySelector("input#reminderUsername")
.value,
utc_time: utc_time.toFormat("yyyy-LL-dd'T'HH:mm:ss"),
};
let reminder = {
avatar: $createReminder.querySelector("img.discord-avatar").src,
channel: $createReminder.querySelector("select.channel-selector").value,
content: $createReminder.querySelector("textarea#messageContent").value,
embed_author_url: $createReminder.querySelector("img.embed_author_url").src,
embed_author: $createReminder.querySelector("textarea#embedAuthor").value,
embed_color: color,
embed_description: $createReminder.querySelector("textarea#embedDescription")
.value,
embed_footer: $createReminder.querySelector("textarea#embedFooter").value,
embed_footer_url: $createReminder.querySelector("img.embed_footer_url").src,
embed_image_url: $createReminder.querySelector("img.embed_image_url").src,
embed_thumbnail_url: $createReminder.querySelector("img.embed_thumbnail_url").src,
embed_title: $createReminder.querySelector("textarea#embedTitle").value,
enabled: true,
expires: null,
interval_seconds: seconds,
interval_months: months,
name: $createReminder.querySelector('input[name="name"]').value,
pin: $createReminder.querySelector('input[name="pin"]').checked,
restartable: false,
tts: $createReminder.querySelector('input[name="tts"]').checked,
username: $createReminder.querySelector("input#reminderUsername").value,
utc_time: utc_time.toFormat("yyyy-LL-dd'T'HH:mm:ss"),
};
// send to server
let guild = document.querySelector(".guildList a.is-active").dataset[
"guild"
];
// send to server
let guild = document.querySelector(".guildList a.is-active").dataset["guild"];
fetch(`/dashboard/api/guild/${guild}/reminders`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(reminder),
})
.then((response) => response.json())
.then((data) => console.log(data));
fetch(`/dashboard/api/guild/${guild}/reminders`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(reminder),
})
.then((response) => response.json())
.then((data) => console.log(data));
// process response
// process response
// reset inputs
});
// reset inputs
});
document.querySelectorAll("textarea.autoresize").forEach((element) => {
element.addEventListener("input", () => {
@ -641,18 +532,6 @@ document.querySelectorAll("a.icon-toggle").forEach((element) => {
});
});
let $showButton = document.querySelector("button#showReminderCreator");
$showButton.addEventListener("click", () => {
$showButton
.querySelector("span.icon i")
.classList.toggle("fa-chevron-right");
$showButton
.querySelector("span.icon i")
.classList.toggle("fa-chevron-down");
document.querySelector("div#reminderCreator").classList.toggle("is-hidden");
});
function register_interval_hide() {
let $showInterval = document.querySelectorAll("a.intervalLabel");
@ -679,9 +558,7 @@ fileInput.forEach((element) => {
function check_embed_fields() {
document.querySelectorAll(".discord-field-title").forEach((element) => {
const $template = document.querySelector("template#embedFieldTemplate");
const $complement = element.parentElement.querySelector(
".discord-field-value"
);
const $complement = element.parentElement.querySelector(".discord-field-value");
// when the user clicks out of the field title and if the field title/value are empty, remove the field
element.addEventListener("blur", () => {
@ -732,15 +609,18 @@ function check_embed_fields() {
document.addEventListener("DOMNodeInserted", () => {
document.querySelectorAll("div.mobile-sidebar a").forEach((element) => {
element.addEventListener("click", (e) => {
document
.getElementById("mobileSidebar")
.classList.remove("is-active");
document.getElementById("mobileSidebar").classList.remove("is-active");
document.querySelectorAll(".navbar-burger").forEach((el) => {
el.classList.remove("is-active");
});
});
});
document.querySelectorAll('input[type="datetime-local"]').forEach((el) => {
let now = luxon.DateTime.now().setZone(timezone);
el.min = now.toFormat("yyyy-LL-dd'T'HH:mm:ss");
});
check_embed_fields();
resize_textareas();
});

View File

@ -12,9 +12,27 @@ function sort_by(cond) {
.forEach((node) => guildReminders.appendChild(node));
// go through and add channel categories
for (let child in guildReminders.children) {
let currentChannelGroup = null;
for (let child of guildReminders.querySelectorAll("div.reminderContent")) {
let thisChannelGroup = child.querySelector("select.channel-selector").value;
if (currentChannelGroup !== thisChannelGroup) {
let newNode = document.createElement("div");
newNode.textContent =
"#" + channels.find((a) => a.id === thisChannelGroup).name;
newNode.classList.add("channel-tag");
guildReminders.insertBefore(newNode, child);
currentChannelGroup = thisChannelGroup;
}
}
} else {
// remove any channel tags if previous ordering was by channel
guildReminders.querySelectorAll("div.channel-tag").forEach((el) => {
el.remove();
});
if (cond === "time") {
[...guildReminders.children]
.sort((a, b) => {
@ -41,8 +59,10 @@ function sort_by(cond) {
}
}
document.querySelector("#orderBy").addEventListener("change", (element) => {
sort_by(element.value);
const selector = document.querySelector("#orderBy");
selector.addEventListener("change", () => {
sort_by(selector.value);
});
document.addEventListener("remindersLoaded", () => {

View File

@ -54,14 +54,14 @@
</div>
</nav>
<div id="loader" class="is-hidden hero is-fullheight" style="position: fixed; background-color: white; opacity: 0.8; width: 100vw; z-index: 999;">
<div id="loader" class="is-hidden hero is-fullheight" style="position: fixed; background-color: rgba(255, 255, 255, 0.8); width: 100vw; z-index: 999;">
<div class="hero-body">
<div class="container has-text-centered">
<p class="title" style="font-size: 6rem; color: #8fb677">
<i class="fas fa-cog fa-spin"></i>
</p>
<p class="subtitle">
Bear with...
<strong>Loading...</strong>
</p>
</div>
</div>

View File

@ -1,215 +1,226 @@
<div class="columns reminderContent">
<div class="columns reminderContent {% if creating %}creator{% endif %}">
<div class="column discord-frame">
<div class="">
<article class="media">
<figure class="media-left">
<p class="image is-32x32 customizable">
<a>
<img class="is-rounded discord-avatar" src="">
</a>
</p>
</figure>
<div class="media-content">
<div class="content">
<div class="discord-message-header">
<label class="is-sr-only" for="reminderUsername">Username Override</label>
<input class="discord-username message-input" placeholder="Username Override"
maxlength="32" id="reminderUsername" name="username">
</div>
<label class="is-sr-only" for="messageContent">Message</label>
<textarea class="message-input autoresize discord-content"
placeholder="Message Content..."
maxlength="2000" id="messageContent" name="content" rows="1"></textarea>
<article class="media">
<figure class="media-left">
<p class="image is-32x32 customizable">
<a>
<img class="is-rounded discord-avatar" src="">
</a>
</p>
</figure>
<div class="media-content">
<div class="content">
<div class="discord-message-header">
<label class="is-sr-only" for="reminderUsername">Username Override</label>
<input class="discord-username message-input" placeholder="Username Override"
maxlength="32" id="reminderUsername" name="username">
</div>
<label class="is-sr-only" for="messageContent">Message</label>
<textarea class="message-input autoresize discord-content"
placeholder="Message Content..."
maxlength="2000" id="messageContent" name="content" rows="1"></textarea>
<div class="discord-embed">
<div class="embed-body">
<div class="a">
<div class="embed-author-box">
<div class="a">
<p class="image is-24x24 customizable">
<a>
<img class="is-rounded embed_author_url" src="">
</a>
</p>
</div>
<div class="b">
<label class="is-sr-only" for="embedAuthor">Embed Author</label>
<textarea
class="discord-embed-author message-input autoresize"
placeholder="Embed Author..." rows="1" maxlength="256"
id="embedAuthor" name="embed_author"></textarea>
</div>
<div class="discord-embed">
<div class="embed-body">
<button class="change-color button is-rounded is-small">
<i class="fas fa-eye-dropper"></i>
</button>
<div class="a">
<div class="embed-author-box">
<div class="a">
<p class="image is-24x24 customizable">
<a>
<img class="is-rounded embed_author_url" src="">
</a>
</p>
</div>
<label class="is-sr-only" for="embedTitle">Embed Title</label>
<textarea class="discord-title message-input autoresize"
placeholder="Embed Title..."
maxlength="256" id="embedTitle" rows="1"
name="embed_title"></textarea>
<br>
<label class="is-sr-only" for="embedDescription">Embed Description</label>
<textarea class="discord-description message-input autoresize "
placeholder="Embed Description..."
maxlength="4096" id="embedDescription" name="embed_description"
rows="1"></textarea>
<br>
<div class="embed-multifield-box">
<div class="embed-field-box">
<label class="is-sr-only" for="embedFieldTitle">Field Title</label>
<textarea
class="discord-field-title field-input message-input autoresize "
placeholder="Field Title..." rows="1"
maxlength="256" id="embedFieldTitle"
name="embed_field_title[]"></textarea>
<label class="is-sr-only" for="embedFieldValue">Field Value</label>
<textarea
class="discord-field-value field-input message-input autoresize "
placeholder="Field Value..."
maxlength="1024" id="embedFieldValue" name="embed_field_value[]"
rows="1"></textarea>
</div>
<div class="b">
<label class="is-sr-only" for="embedAuthor">Embed Author</label>
<textarea
class="discord-embed-author message-input autoresize"
placeholder="Embed Author..." rows="1" maxlength="256"
id="embedAuthor" name="embed_author"></textarea>
</div>
</div>
<div class="b">
<p class="image thumbnail customizable">
<a>
<img class="embed_thumbnail_url" src="" alt="Square thumbnail embedded image">
</a>
</p>
<label class="is-sr-only" for="embedTitle">Embed Title</label>
<textarea class="discord-title message-input autoresize"
placeholder="Embed Title..."
maxlength="256" id="embedTitle" rows="1"
name="embed_title"></textarea>
<br>
<label class="is-sr-only" for="embedDescription">Embed Description</label>
<textarea class="discord-description message-input autoresize "
placeholder="Embed Description..."
maxlength="4096" id="embedDescription" name="embed_description"
rows="1"></textarea>
<br>
<div class="embed-multifield-box">
<div class="embed-field-box">
<label class="is-sr-only" for="embedFieldTitle">Field Title</label>
<textarea
class="discord-field-title field-input message-input autoresize "
placeholder="Field Title..." rows="1"
maxlength="256" id="embedFieldTitle"
name="embed_field_title[]"></textarea>
<label class="is-sr-only" for="embedFieldValue">Field Value</label>
<textarea
class="discord-field-value field-input message-input autoresize "
placeholder="Field Value..."
maxlength="1024" id="embedFieldValue" name="embed_field_value[]"
rows="1"></textarea>
</div>
</div>
</div>
<p class="image is-400x300 customizable">
<div class="b">
<p class="image thumbnail customizable">
<a>
<img class="embed_thumbnail_url" src="" alt="Square thumbnail embedded image">
</a>
</p>
</div>
</div>
<p class="image is-400x300 customizable">
<a>
<img class="embed_image_url" src="" alt="Large embedded image">
</a>
</p>
<div class="embed-footer-box">
<p class="image is-20x20 customizable">
<a>
<img class="embed_image_url" src="" alt="Large embedded image">
<img class="is-rounded embed_footer_url" src="" alt="Footer profile-like image">
</a>
</p>
<div class="embed-footer-box">
<p class="image is-20x20 customizable">
<a>
<img class="is-rounded embed_footer_url" src="" alt="Footer profile-like image">
</a>
</p>
<label class="is-sr-only" for="embedFooter">Embed Footer text</label>
<textarea class="discord-embed-footer message-input autoresize "
placeholder="Embed Footer..."
maxlength="2048" id="embedFooter" name="embed_footer" rows="1"></textarea>
</div>
<label class="is-sr-only" for="embedFooter">Embed Footer text</label>
<textarea class="discord-embed-footer message-input autoresize "
placeholder="Embed Footer..."
maxlength="2048" id="embedFooter" name="embed_footer" rows="1"></textarea>
</div>
</div>
</div>
</article>
</div>
</div>
</article>
</div>
<div class="column">
<div class="field">
<div class="control">
<label class="label sr-only">Reminder Name</label>
<input class="input" type="text" name="name" placeholder="Reminder Name">
<div class="column settings">
<div class="columns is-mobile">
<div class="column">
<div class="field">
<div class="control">
<label class="label sr-only">Reminder Name</label>
<input class="input" type="text" name="name" placeholder="Reminder Name">
</div>
</div>
</div>
<div class="column is-narrow">
<button class="button is-rounded hide-box">
<i class="fas fa-chevron-down"></i>
</button>
</div>
</div>
<div class="field">
<label class="label">Channel</label>
<div class="control">
<div class="field channel-field">
<div class="collapses">
<label class="label" for="channelOption">Channel</label>
</div>
<div class="control has-icons-left">
<div class="select">
<select id="channelOption" name="channel" class="channel-selector">
</select>
</div>
</div>
</div>
<div class="field">
<label class="label">Time</label>
<div class="control">
<input class="input" type="datetime-local" step="1" name="time">
</div>
</div>
<div class="field">
<a class="intervalLabel"><label class="label">Interval <i class="fas fa-chevron-down"></i></label></a>
<div class="control intervalSelector">
<div class="columns">
<div class="column">
<input class="input" type="number" name="interval_months" placeholder="Months">
</div>
<div class="column">
<input class="input" type="number" name="interval_days" placeholder="Days">
</div>
<div class="column">
<input class="input" type="number" name="interval_hours" placeholder="Hours">
</div>
<div class="column">
<input class="input" type="number" name="interval_minutes" placeholder="Minutes">
</div>
<div class="column">
<input class="input" type="number" name="interval_seconds" placeholder="Seconds">
</div>
<div class="icon is-small is-left">
<i class="fas fa-hashtag"></i>
</div>
</div>
</div>
<div class="columns">
<div class="column has-text-centered">
<div style="display: inline-block;">
<label class="label">Enable TTS <input type="checkbox" name="tts"></label>
<div class="collapses">
<div class="field">
<label class="label">Time</label>
<div class="control">
<input class="input" type="datetime-local" step="1" name="time">
</div>
</div>
<div class="column has-text-centered">
<div style="display: inline-block;">
<label class="label">Pin Message <input type="checkbox" name="pin"></label>
<div class="field">
<a class="intervalLabel"><label class="label">Interval <i class="fas fa-chevron-down"></i></label></a>
<div class="control intervalSelector">
<div class="columns">
<div class="column">
<input class="input" type="number" name="interval_months" placeholder="Months">
</div>
<div class="column">
<input class="input" type="number" name="interval_days" placeholder="Days">
</div>
<div class="column">
<input class="input" type="number" name="interval_hours" placeholder="Hours">
</div>
<div class="column">
<input class="input" type="number" name="interval_minutes" placeholder="Minutes">
</div>
<div class="column">
<input class="input" type="number" name="interval_seconds" placeholder="Seconds">
</div>
</div>
</div>
</div>
<div class="column has-text-centered">
<div class="file is-boxed">
<label class="file-label">
<input class="file-input" type="file">
<span class="file-cta">
<span class="file-label">
Add Attachment
<div class="columns">
<div class="column has-text-centered">
<div style="display: inline-block;">
<label class="label">Enable TTS <input type="checkbox" name="tts"></label>
</div>
</div>
<div class="column has-text-centered">
<div style="display: inline-block;">
<label class="label">Pin Message <input type="checkbox" name="pin"></label>
</div>
</div>
<div class="column has-text-centered">
<div class="file is-boxed">
<label class="file-label">
<input class="file-input" type="file">
<span class="file-cta">
<span class="file-label">
Add Attachment
</span>
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
</span>
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
</span>
</label>
</label>
</div>
</div>
</div>
<span style="width: 12px;"></span>
{% if creating %}
<button class="button is-outlined">
Load Template
</button>
<button class="button is-success is-outlined" id="createTemplate">
Create Template
</button>
<button class="button is-success" id="createReminder">
Create Reminder
</button>
{% else %}
<button class="button is-primary" disabled>
Saved!
</button>
<button class="button is-warning disable-enable">
Disable
</button>
<button class="button is-danger">
Delete
</button>
{% endif %}
</div>
<a class="set-color">
<p>
Set Embed Color <span class="icon is-small"><i class="far fa-eye-dropper"></i></span>
</p>
</a>
<span style="width: 12px;"></span>
{% if creating %}
<button class="button is-outlined">
Load Template
</button>
<button class="button is-success is-outlined" id="createTemplate">
Create Template
</button>
<button class="button is-success" id="createReminder">
Create Reminder
</button>
{% else %}
<button class="button is-primary" disabled>
Saved!
</button>
<button class="button is-warning disable-enable">
Disable
</button>
<button class="button is-danger">
Delete
</button>
{% endif %}
</div>
</div>

View File

@ -1,25 +1,45 @@
<div style="margin: 0 12px 12px 12px;">
<div class="create-reminder">
<button class="button is-rounded is-light" id="showReminderCreator">
<strong>Create Reminder <span class="icon left-pad"><i class="fas fa-chevron-down"></i></span></strong>
</button>
<strong>Create Reminder</strong>
<div id="reminderCreator">
{% set creating = true %}
{% include "reminder_dashboard/guild_reminder" %}
{% set creating = false %}
</div>
<br>
<div class="field" style="margin-top: 22px;">
<div class="control has-icons-left">
<div class="select is-small">
<select id="orderBy">
<option value="time" selected>Time</option>
<option value="name">Name</option>
<option value="channel">Channel</option>
</select>
<div class="field">
<div class="columns">
<div class="column">
<strong>Reminders</strong>
</div>
<div class="icon is-small is-left">
<i class="fas fa-sort-amount-down"></i>
<div class="column is-narrow">
<div class="control has-icons-left">
<div class="select is-small">
<select id="orderBy">
<option value="time" selected>Time</option>
<option value="name">Name</option>
<option value="channel">Channel</option>
</select>
</div>
<div class="icon is-small is-left">
<i class="fas fa-sort-amount-down"></i>
</div>
</div>
</div>
<div class="column is-narrow">
<div class="control has-icons-left">
<div class="select is-small">
<select id="expandAll">
<option value="" selected>Expand/Collapse...</option>
<option value="expand">Expand All</option>
<option value="collapse">Collapse All</option>
</select>
</div>
<div class="icon is-small is-left">
<i class="fas fa-expand-arrows"></i>
</div>
</div>
</div>
</div>
</div>
@ -31,3 +51,4 @@
</div>
<script src="/static/js/sort.js"></script>
<script src="/static/js/expand.js"></script>