collapse/expand elements. moved the embed color picker
This commit is contained in:
parent
318be1fa5e
commit
af9d8bea62
@ -1 +1,2 @@
|
|||||||
|
printWidth = 90
|
||||||
tabWidth = 4
|
tabWidth = 4
|
||||||
|
@ -362,7 +362,49 @@ pub async fn edit_reminder(
|
|||||||
.await;
|
.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>")]
|
#[delete("/api/guild/<id>/reminders", data = "<reminder>")]
|
||||||
|
@ -2,6 +2,69 @@
|
|||||||
font-family: "Ubuntu Bold", "Ubuntu", sans-serif;
|
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 {
|
div.reminderContent {
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
@ -340,36 +403,6 @@ textarea, input {
|
|||||||
flex-wrap: wrap;
|
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 {
|
.channel-select {
|
||||||
font-size: 1.125rem;
|
font-size: 1.125rem;
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
|
23
web/static/js/expand.js
Normal file
23
web/static/js/expand.js
Normal 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 = "";
|
||||||
|
});
|
@ -11,8 +11,6 @@ let botTimezone = "UTC";
|
|||||||
let channels;
|
let channels;
|
||||||
let roles;
|
let roles;
|
||||||
|
|
||||||
const remindersLoadedEvent = new Event("remindersLoaded");
|
|
||||||
|
|
||||||
function colorToInt(r, g, b) {
|
function colorToInt(r, g, b) {
|
||||||
return (r << 16) + (g << 8) + b;
|
return (r << 16) + (g << 8) + b;
|
||||||
}
|
}
|
||||||
@ -44,24 +42,17 @@ function switch_pane(selector) {
|
|||||||
|
|
||||||
function update_select(sel) {
|
function update_select(sel) {
|
||||||
if (sel.selectedOptions[0].dataset["webhookAvatar"]) {
|
if (sel.selectedOptions[0].dataset["webhookAvatar"]) {
|
||||||
sel
|
sel.closest("div.reminderContent").querySelector("img.discord-avatar").src =
|
||||||
.closest("div.reminderContent")
|
|
||||||
.querySelector("img.discord-avatar").src =
|
|
||||||
sel.selectedOptions[0].dataset["webhookAvatar"];
|
sel.selectedOptions[0].dataset["webhookAvatar"];
|
||||||
} else {
|
} else {
|
||||||
sel
|
sel.closest("div.reminderContent").querySelector("img.discord-avatar").src = "";
|
||||||
.closest("div.reminderContent")
|
|
||||||
.querySelector("img.discord-avatar").src = "";
|
|
||||||
}
|
}
|
||||||
if (sel.selectedOptions[0].dataset["webhookName"]) {
|
if (sel.selectedOptions[0].dataset["webhookName"]) {
|
||||||
sel
|
sel.closest("div.reminderContent").querySelector("input.discord-username").value =
|
||||||
.closest("div.reminderContent")
|
|
||||||
.querySelector("input.discord-username").value =
|
|
||||||
sel.selectedOptions[0].dataset["webhookName"];
|
sel.selectedOptions[0].dataset["webhookName"];
|
||||||
} else {
|
} else {
|
||||||
sel
|
sel.closest("div.reminderContent").querySelector("input.discord-username").value =
|
||||||
.closest("div.reminderContent")
|
"";
|
||||||
.querySelector("input.discord-username").value = "";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,52 +75,6 @@ function fetch_roles(guild_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function fetch_reminders(guild_id) {
|
async function fetch_reminders(guild_id) {
|
||||||
// fetch dm reminders instead
|
|
||||||
if (guild_id === undefined) {
|
|
||||||
const $reminderBox = document.querySelector("div#personalReminders");
|
|
||||||
|
|
||||||
// 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"
|
|
||||||
);
|
|
||||||
|
|
||||||
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}`
|
|
||||||
);
|
|
||||||
|
|
||||||
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");
|
const $reminderBox = document.querySelector("div#guildReminders");
|
||||||
|
|
||||||
// reset div contents
|
// reset div contents
|
||||||
@ -142,11 +87,7 @@ async function fetch_reminders(guild_id) {
|
|||||||
if (data.error) {
|
if (data.error) {
|
||||||
show_error(data.error);
|
show_error(data.error);
|
||||||
} else {
|
} else {
|
||||||
console.log(data);
|
const $template = document.querySelector("template#guildReminder");
|
||||||
|
|
||||||
const $template = document.querySelector(
|
|
||||||
"template#guildReminder"
|
|
||||||
);
|
|
||||||
|
|
||||||
for (let reminder of data) {
|
for (let reminder of data) {
|
||||||
let newFrame = $template.content.cloneNode(true);
|
let newFrame = $template.content.cloneNode(true);
|
||||||
@ -155,22 +96,13 @@ async function fetch_reminders(guild_id) {
|
|||||||
reminder["uid"];
|
reminder["uid"];
|
||||||
|
|
||||||
// populate channels
|
// populate channels
|
||||||
set_channels(
|
set_channels(newFrame.querySelector("select.channel-selector"));
|
||||||
newFrame.querySelector("select.channel-selector")
|
|
||||||
);
|
|
||||||
|
|
||||||
// populate majority of items
|
// populate majority of items
|
||||||
for (let prop in reminder) {
|
for (let prop in reminder) {
|
||||||
if (
|
if (reminder.hasOwnProperty(prop) && reminder[prop] !== null) {
|
||||||
reminder.hasOwnProperty(prop) &&
|
let $input = newFrame.querySelector(`*[name="${prop}"]`);
|
||||||
reminder[prop] !== null
|
let $image = newFrame.querySelector(`img.${prop}`);
|
||||||
) {
|
|
||||||
let $input = newFrame.querySelector(
|
|
||||||
`*[name="${prop}"]`
|
|
||||||
);
|
|
||||||
let $image = newFrame.querySelector(
|
|
||||||
`img.${prop}`
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($input !== null) {
|
if ($input !== null) {
|
||||||
$input.value = reminder[prop];
|
$input.value = reminder[prop];
|
||||||
@ -180,49 +112,69 @@ async function fetch_reminders(guild_id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let guild = document.querySelector(
|
let $enableBtn = newFrame.querySelector(".disable-enable");
|
||||||
".guildList a.is-active"
|
$enableBtn.textContent = reminder["enabled"] ? "Disable" : "Enable";
|
||||||
).dataset["guild"];
|
$enableBtn.dataset.action = reminder["enabled"]
|
||||||
|
? "disable"
|
||||||
|
: "enable";
|
||||||
|
|
||||||
let $enableBtn =
|
let timeInput = newFrame.querySelector('input[name="time"]');
|
||||||
newFrame.querySelector(".disable-enable");
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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";
|
||||||
|
|
||||||
$enableBtn.textContent = reminder["enabled"]
|
|
||||||
? "Disable"
|
|
||||||
: "Enable";
|
|
||||||
$enableBtn.addEventListener("click", () => {
|
|
||||||
fetch(`/dashboard/api/guild/${guild}/reminders`, {
|
fetch(`/dashboard/api/guild/${guild}/reminders`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
uid: reminder["uid"],
|
uid: reminder["uid"],
|
||||||
enabled: false,
|
enabled: enable,
|
||||||
}),
|
}),
|
||||||
});
|
})
|
||||||
});
|
.then((response) => response.json())
|
||||||
|
.then((data) => {
|
||||||
let timeInput =
|
if (data.error) {
|
||||||
newFrame.querySelector('input[name="time"]');
|
show_error(data.error);
|
||||||
let localTime = luxon.DateTime.fromISO(
|
} else {
|
||||||
reminder["utc_time"]
|
enableBtn.textContent = data["enabled"] ? "Disable" : "Enable";
|
||||||
).setZone(timezone);
|
enableBtn.dataset.action = data["enabled"] ? "enable" : "disable";
|
||||||
timeInput.value = localTime.toFormat(
|
|
||||||
"yyyy-LL-dd'T'HH:mm:ss"
|
|
||||||
);
|
|
||||||
|
|
||||||
$reminderBox.appendChild(newFrame);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
document.dispatchEvent(remindersLoadedEvent);
|
|
||||||
register_interval_hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_error(error) {
|
function show_error(error) {
|
||||||
document
|
document.getElementById("errors").querySelector("span.error-message").textContent =
|
||||||
.getElementById("errors")
|
error;
|
||||||
.querySelector("span.error-message").textContent = error;
|
|
||||||
document.getElementById("errors").classList.add("is-active");
|
document.getElementById("errors").classList.add("is-active");
|
||||||
|
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
@ -235,9 +187,7 @@ function update_times() {
|
|||||||
element.textContent = timezone;
|
element.textContent = timezone;
|
||||||
});
|
});
|
||||||
document.querySelectorAll("span.set-time").forEach((element) => {
|
document.querySelectorAll("span.set-time").forEach((element) => {
|
||||||
element.textContent = luxon.DateTime.now()
|
element.textContent = luxon.DateTime.now().setZone(timezone).toFormat("HH:mm");
|
||||||
.setZone(timezone)
|
|
||||||
.toFormat("HH:mm");
|
|
||||||
});
|
});
|
||||||
document.querySelectorAll("span.browser-timezone").forEach((element) => {
|
document.querySelectorAll("span.browser-timezone").forEach((element) => {
|
||||||
element.textContent = browserTimezone;
|
element.textContent = browserTimezone;
|
||||||
@ -249,9 +199,7 @@ function update_times() {
|
|||||||
element.textContent = botTimezone;
|
element.textContent = botTimezone;
|
||||||
});
|
});
|
||||||
document.querySelectorAll("span.bot-time").forEach((element) => {
|
document.querySelectorAll("span.bot-time").forEach((element) => {
|
||||||
element.textContent = luxon.DateTime.now()
|
element.textContent = luxon.DateTime.now().setZone(botTimezone).toFormat("HH:mm");
|
||||||
.setZone(botTimezone)
|
|
||||||
.toFormat("HH:mm");
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,12 +211,10 @@ document.getElementById("set-bot-timezone").addEventListener("click", () => {
|
|||||||
timezone = botTimezone;
|
timezone = botTimezone;
|
||||||
update_times();
|
update_times();
|
||||||
});
|
});
|
||||||
document
|
document.getElementById("set-browser-timezone").addEventListener("click", () => {
|
||||||
.getElementById("set-browser-timezone")
|
|
||||||
.addEventListener("click", () => {
|
|
||||||
timezone = browserTimezone;
|
timezone = browserTimezone;
|
||||||
update_times();
|
update_times();
|
||||||
});
|
});
|
||||||
document.getElementById("update-bot-timezone").addEventListener("click", () => {
|
document.getElementById("update-bot-timezone").addEventListener("click", () => {
|
||||||
timezone = browserTimezone;
|
timezone = browserTimezone;
|
||||||
fetch("/dashboard/api/user", {
|
fetch("/dashboard/api/user", {
|
||||||
@ -302,21 +248,7 @@ colorPicker.on("color:change", function (color) {
|
|||||||
$colorPickerInput.value = color.hexString;
|
$colorPickerInput.value = color.hexString;
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelectorAll(".discord-embed").forEach((element) => {
|
document.querySelectorAll(".change-color").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) => {
|
|
||||||
element.addEventListener("click", (e) => {
|
element.addEventListener("click", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -329,20 +261,16 @@ document.querySelectorAll(".set-color").forEach((element) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$colorPickerModal
|
$colorPickerModal.querySelector("button.is-success").addEventListener("click", () => {
|
||||||
.querySelector("button.is-success")
|
|
||||||
.addEventListener("click", () => {
|
|
||||||
$discordFrame.style.borderLeftColor = colorPicker.color.rgbString;
|
$discordFrame.style.borderLeftColor = colorPicker.color.rgbString;
|
||||||
|
|
||||||
$colorPickerModal.classList.remove("is-active");
|
$colorPickerModal.classList.remove("is-active");
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelectorAll("a.show-modal").forEach((element) => {
|
document.querySelectorAll("a.show-modal").forEach((element) => {
|
||||||
element.addEventListener("click", (e) => {
|
element.addEventListener("click", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
document
|
document.getElementById(element.dataset["modal"]).classList.toggle("is-active");
|
||||||
.getElementById(element.dataset["modal"])
|
|
||||||
.classList.toggle("is-active");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -359,15 +287,18 @@ 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")
|
fetch("/dashboard/api/user")
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
show_error(data.error);
|
show_error(data.error);
|
||||||
} else {
|
} else {
|
||||||
document
|
document.querySelectorAll("a.switch-pane").forEach((element) => {
|
||||||
.querySelectorAll("a.switch-pane")
|
|
||||||
.forEach((element) => {
|
|
||||||
element.innerHTML = element.innerHTML.replace(
|
element.innerHTML = element.innerHTML.replace(
|
||||||
"%username%",
|
"%username%",
|
||||||
data.name
|
data.name
|
||||||
@ -380,9 +311,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
|
|
||||||
element.classList.add("is-active");
|
element.classList.add("is-active");
|
||||||
|
|
||||||
document
|
document.querySelectorAll("p.pageTitle").forEach((el) => {
|
||||||
.querySelectorAll("p.pageTitle")
|
|
||||||
.forEach((el) => {
|
|
||||||
el.textContent = "Your Reminders";
|
el.textContent = "Your Reminders";
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -405,9 +334,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
const $template = document.getElementById("guildListEntry");
|
const $template = document.getElementById("guildListEntry");
|
||||||
|
|
||||||
for (let guild of data) {
|
for (let guild of data) {
|
||||||
document
|
document.querySelectorAll(".guildList").forEach((element) => {
|
||||||
.querySelectorAll(".guildList")
|
|
||||||
.forEach((element) => {
|
|
||||||
const $clone = $template.content.cloneNode(true);
|
const $clone = $template.content.cloneNode(true);
|
||||||
const $anchor = $clone.querySelector("a");
|
const $anchor = $clone.querySelector("a");
|
||||||
|
|
||||||
@ -434,10 +361,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
if (
|
if (data.error === "Bot not in guild") {
|
||||||
data.error ===
|
|
||||||
"Bot not in guild"
|
|
||||||
) {
|
|
||||||
switch_pane("guild-error");
|
switch_pane("guild-error");
|
||||||
} else {
|
} else {
|
||||||
show_error(data.error);
|
show_error(data.error);
|
||||||
@ -446,21 +370,15 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
channels = data;
|
channels = data;
|
||||||
|
|
||||||
document
|
document
|
||||||
.querySelectorAll(
|
.querySelectorAll("select.channel-selector")
|
||||||
"select.channel-selector"
|
|
||||||
)
|
|
||||||
.forEach(set_channels);
|
.forEach(set_channels);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
fetch_reminders($anchor.dataset["guild"]);
|
fetch_reminders($anchor.dataset["guild"]);
|
||||||
|
|
||||||
document
|
document.querySelectorAll("p.pageTitle").forEach((el) => {
|
||||||
.querySelectorAll("p.pageTitle")
|
el.textContent = $anchor.dataset["name"] + " Reminders";
|
||||||
.forEach((el) => {
|
|
||||||
el.textContent =
|
|
||||||
$anchor.dataset["name"] +
|
|
||||||
" Reminders";
|
|
||||||
});
|
});
|
||||||
document
|
document
|
||||||
.querySelectorAll("select.channel-selector")
|
.querySelectorAll("select.channel-selector")
|
||||||
@ -505,30 +423,20 @@ function set_channels(element) {
|
|||||||
|
|
||||||
let $createReminder = document.querySelector("#reminderCreator");
|
let $createReminder = document.querySelector("#reminderCreator");
|
||||||
|
|
||||||
$createReminder
|
$createReminder.querySelector("button#createReminder").addEventListener("click", () => {
|
||||||
.querySelector("button#createReminder")
|
|
||||||
.addEventListener("click", () => {
|
|
||||||
// create reminder object
|
// create reminder object
|
||||||
let seconds =
|
let seconds =
|
||||||
parseInt(
|
parseInt($createReminder.querySelector('input[name="interval_seconds"]').value) ||
|
||||||
$createReminder.querySelector('input[name="interval_seconds"]')
|
null;
|
||||||
.value
|
|
||||||
) || null;
|
|
||||||
let months =
|
let months =
|
||||||
parseInt(
|
parseInt($createReminder.querySelector('input[name="interval_months"]').value) ||
|
||||||
$createReminder.querySelector('input[name="interval_months"]')
|
null;
|
||||||
.value
|
|
||||||
) || null;
|
|
||||||
|
|
||||||
let rgb_color = window.getComputedStyle(
|
let rgb_color = window.getComputedStyle(
|
||||||
$createReminder.querySelector("div.discord-embed")
|
$createReminder.querySelector("div.discord-embed")
|
||||||
).borderLeftColor;
|
).borderLeftColor;
|
||||||
let rgb = rgb_color.match(/\d+/g);
|
let rgb = rgb_color.match(/\d+/g);
|
||||||
let color = colorToInt(
|
let color = colorToInt(parseInt(rgb[0]), parseInt(rgb[1]), parseInt(rgb[2]));
|
||||||
parseInt(rgb[0]),
|
|
||||||
parseInt(rgb[1]),
|
|
||||||
parseInt(rgb[2])
|
|
||||||
);
|
|
||||||
|
|
||||||
let utc_time = luxon.DateTime.fromISO(
|
let utc_time = luxon.DateTime.fromISO(
|
||||||
$createReminder.querySelector('input[name="time"]').value
|
$createReminder.querySelector('input[name="time"]').value
|
||||||
@ -536,32 +444,18 @@ $createReminder
|
|||||||
|
|
||||||
let reminder = {
|
let reminder = {
|
||||||
avatar: $createReminder.querySelector("img.discord-avatar").src,
|
avatar: $createReminder.querySelector("img.discord-avatar").src,
|
||||||
channel: $createReminder.querySelector("select.channel-selector")
|
channel: $createReminder.querySelector("select.channel-selector").value,
|
||||||
.value,
|
content: $createReminder.querySelector("textarea#messageContent").value,
|
||||||
content: $createReminder.querySelector("textarea#messageContent")
|
embed_author_url: $createReminder.querySelector("img.embed_author_url").src,
|
||||||
.value,
|
embed_author: $createReminder.querySelector("textarea#embedAuthor").value,
|
||||||
embed_author_url: $createReminder.querySelector(
|
|
||||||
"img.embed_author_url"
|
|
||||||
).src,
|
|
||||||
embed_author: $createReminder.querySelector("textarea#embedAuthor")
|
|
||||||
.value,
|
|
||||||
embed_color: color,
|
embed_color: color,
|
||||||
embed_description: $createReminder.querySelector(
|
embed_description: $createReminder.querySelector("textarea#embedDescription")
|
||||||
"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,
|
.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,
|
enabled: true,
|
||||||
expires: null,
|
expires: null,
|
||||||
interval_seconds: seconds,
|
interval_seconds: seconds,
|
||||||
@ -570,15 +464,12 @@ $createReminder
|
|||||||
pin: $createReminder.querySelector('input[name="pin"]').checked,
|
pin: $createReminder.querySelector('input[name="pin"]').checked,
|
||||||
restartable: false,
|
restartable: false,
|
||||||
tts: $createReminder.querySelector('input[name="tts"]').checked,
|
tts: $createReminder.querySelector('input[name="tts"]').checked,
|
||||||
username: $createReminder.querySelector("input#reminderUsername")
|
username: $createReminder.querySelector("input#reminderUsername").value,
|
||||||
.value,
|
|
||||||
utc_time: utc_time.toFormat("yyyy-LL-dd'T'HH:mm:ss"),
|
utc_time: utc_time.toFormat("yyyy-LL-dd'T'HH:mm:ss"),
|
||||||
};
|
};
|
||||||
|
|
||||||
// send to server
|
// send to server
|
||||||
let guild = document.querySelector(".guildList a.is-active").dataset[
|
let guild = document.querySelector(".guildList a.is-active").dataset["guild"];
|
||||||
"guild"
|
|
||||||
];
|
|
||||||
|
|
||||||
fetch(`/dashboard/api/guild/${guild}/reminders`, {
|
fetch(`/dashboard/api/guild/${guild}/reminders`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@ -593,7 +484,7 @@ $createReminder
|
|||||||
// process response
|
// process response
|
||||||
|
|
||||||
// reset inputs
|
// reset inputs
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelectorAll("textarea.autoresize").forEach((element) => {
|
document.querySelectorAll("textarea.autoresize").forEach((element) => {
|
||||||
element.addEventListener("input", () => {
|
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() {
|
function register_interval_hide() {
|
||||||
let $showInterval = document.querySelectorAll("a.intervalLabel");
|
let $showInterval = document.querySelectorAll("a.intervalLabel");
|
||||||
|
|
||||||
@ -679,9 +558,7 @@ fileInput.forEach((element) => {
|
|||||||
function check_embed_fields() {
|
function check_embed_fields() {
|
||||||
document.querySelectorAll(".discord-field-title").forEach((element) => {
|
document.querySelectorAll(".discord-field-title").forEach((element) => {
|
||||||
const $template = document.querySelector("template#embedFieldTemplate");
|
const $template = document.querySelector("template#embedFieldTemplate");
|
||||||
const $complement = element.parentElement.querySelector(
|
const $complement = element.parentElement.querySelector(".discord-field-value");
|
||||||
".discord-field-value"
|
|
||||||
);
|
|
||||||
|
|
||||||
// when the user clicks out of the field title and if the field title/value are empty, remove the field
|
// when the user clicks out of the field title and if the field title/value are empty, remove the field
|
||||||
element.addEventListener("blur", () => {
|
element.addEventListener("blur", () => {
|
||||||
@ -732,15 +609,18 @@ function check_embed_fields() {
|
|||||||
document.addEventListener("DOMNodeInserted", () => {
|
document.addEventListener("DOMNodeInserted", () => {
|
||||||
document.querySelectorAll("div.mobile-sidebar a").forEach((element) => {
|
document.querySelectorAll("div.mobile-sidebar a").forEach((element) => {
|
||||||
element.addEventListener("click", (e) => {
|
element.addEventListener("click", (e) => {
|
||||||
document
|
document.getElementById("mobileSidebar").classList.remove("is-active");
|
||||||
.getElementById("mobileSidebar")
|
|
||||||
.classList.remove("is-active");
|
|
||||||
document.querySelectorAll(".navbar-burger").forEach((el) => {
|
document.querySelectorAll(".navbar-burger").forEach((el) => {
|
||||||
el.classList.remove("is-active");
|
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();
|
check_embed_fields();
|
||||||
resize_textareas();
|
resize_textareas();
|
||||||
});
|
});
|
||||||
|
@ -12,9 +12,27 @@ function sort_by(cond) {
|
|||||||
.forEach((node) => guildReminders.appendChild(node));
|
.forEach((node) => guildReminders.appendChild(node));
|
||||||
|
|
||||||
// go through and add channel categories
|
// 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 {
|
} else {
|
||||||
|
// remove any channel tags if previous ordering was by channel
|
||||||
|
guildReminders.querySelectorAll("div.channel-tag").forEach((el) => {
|
||||||
|
el.remove();
|
||||||
|
});
|
||||||
|
|
||||||
if (cond === "time") {
|
if (cond === "time") {
|
||||||
[...guildReminders.children]
|
[...guildReminders.children]
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
@ -41,8 +59,10 @@ function sort_by(cond) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.querySelector("#orderBy").addEventListener("change", (element) => {
|
const selector = document.querySelector("#orderBy");
|
||||||
sort_by(element.value);
|
|
||||||
|
selector.addEventListener("change", () => {
|
||||||
|
sort_by(selector.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener("remindersLoaded", () => {
|
document.addEventListener("remindersLoaded", () => {
|
||||||
|
@ -54,14 +54,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</nav>
|
</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="hero-body">
|
||||||
<div class="container has-text-centered">
|
<div class="container has-text-centered">
|
||||||
<p class="title" style="font-size: 6rem; color: #8fb677">
|
<p class="title" style="font-size: 6rem; color: #8fb677">
|
||||||
<i class="fas fa-cog fa-spin"></i>
|
<i class="fas fa-cog fa-spin"></i>
|
||||||
</p>
|
</p>
|
||||||
<p class="subtitle">
|
<p class="subtitle">
|
||||||
Bear with...
|
<strong>Loading...</strong>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<div class="columns reminderContent">
|
<div class="columns reminderContent {% if creating %}creator{% endif %}">
|
||||||
<div class="column discord-frame">
|
<div class="column discord-frame">
|
||||||
<div class="">
|
|
||||||
<article class="media">
|
<article class="media">
|
||||||
<figure class="media-left">
|
<figure class="media-left">
|
||||||
<p class="image is-32x32 customizable">
|
<p class="image is-32x32 customizable">
|
||||||
@ -23,6 +22,9 @@
|
|||||||
|
|
||||||
<div class="discord-embed">
|
<div class="discord-embed">
|
||||||
<div class="embed-body">
|
<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="a">
|
||||||
<div class="embed-author-box">
|
<div class="embed-author-box">
|
||||||
<div class="a">
|
<div class="a">
|
||||||
@ -106,7 +108,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="column settings">
|
||||||
|
<div class="columns is-mobile">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
@ -114,17 +117,30 @@
|
|||||||
<input class="input" type="text" name="name" placeholder="Reminder Name">
|
<input class="input" type="text" name="name" placeholder="Reminder Name">
|
||||||
</div>
|
</div>
|
||||||
</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">
|
<div class="field channel-field">
|
||||||
<label class="label">Channel</label>
|
<div class="collapses">
|
||||||
<div class="control">
|
<label class="label" for="channelOption">Channel</label>
|
||||||
|
</div>
|
||||||
|
<div class="control has-icons-left">
|
||||||
<div class="select">
|
<div class="select">
|
||||||
<select id="channelOption" name="channel" class="channel-selector">
|
<select id="channelOption" name="channel" class="channel-selector">
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="icon is-small is-left">
|
||||||
|
<i class="fas fa-hashtag"></i>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="collapses">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">Time</label>
|
<label class="label">Time</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
@ -183,12 +199,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</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>
|
<span style="width: 12px;"></span>
|
||||||
{% if creating %}
|
{% if creating %}
|
||||||
<button class="button is-outlined">
|
<button class="button is-outlined">
|
||||||
@ -212,4 +222,5 @@
|
|||||||
</button>
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
<div style="margin: 0 12px 12px 12px;">
|
<div style="margin: 0 12px 12px 12px;">
|
||||||
<div class="create-reminder">
|
<div class="create-reminder">
|
||||||
<button class="button is-rounded is-light" id="showReminderCreator">
|
<strong>Create Reminder</strong>
|
||||||
<strong>Create Reminder <span class="icon left-pad"><i class="fas fa-chevron-down"></i></span></strong>
|
|
||||||
</button>
|
|
||||||
<div id="reminderCreator">
|
<div id="reminderCreator">
|
||||||
{% set creating = true %}
|
{% set creating = true %}
|
||||||
{% include "reminder_dashboard/guild_reminder" %}
|
{% include "reminder_dashboard/guild_reminder" %}
|
||||||
{% set creating = false %}
|
{% set creating = false %}
|
||||||
</div>
|
</div>
|
||||||
|
<br>
|
||||||
|
|
||||||
<div class="field" style="margin-top: 22px;">
|
<div class="field">
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column">
|
||||||
|
<strong>Reminders</strong>
|
||||||
|
</div>
|
||||||
|
<div class="column is-narrow">
|
||||||
<div class="control has-icons-left">
|
<div class="control has-icons-left">
|
||||||
<div class="select is-small">
|
<div class="select is-small">
|
||||||
<select id="orderBy">
|
<select id="orderBy">
|
||||||
@ -23,6 +27,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</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>
|
||||||
|
|
||||||
<div id="guildReminders">
|
<div id="guildReminders">
|
||||||
|
|
||||||
@ -31,3 +51,4 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/sort.js"></script>
|
<script src="/static/js/sort.js"></script>
|
||||||
|
<script src="/static/js/expand.js"></script>
|
||||||
|
Loading…
Reference in New Issue
Block a user