This commit is contained in:
jude 2022-05-15 12:14:07 +01:00
parent bfc2d71ca0
commit 6f7d0f67b3
8 changed files with 68 additions and 39 deletions

View File

@ -420,12 +420,11 @@ pub async fn create_reminder(
interval_seconds,
interval_months,
name,
pin,
restartable,
tts,
username,
`utc_time`
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
new_uid,
attachment_data,
reminder.attachment_name,
@ -447,7 +446,6 @@ pub async fn create_reminder(
reminder.interval_seconds,
reminder.interval_months,
name,
reminder.pin,
reminder.restartable,
reminder.tts,
reminder.username,
@ -479,7 +477,6 @@ pub async fn create_reminder(
reminders.interval_seconds,
reminders.interval_months,
reminders.name,
reminders.pin,
reminders.restartable,
reminders.tts,
reminders.uid,
@ -543,7 +540,6 @@ pub async fn get_reminders(id: u64, ctx: &State<Context>, pool: &State<Pool<MySq
reminders.interval_seconds,
reminders.interval_months,
reminders.name,
reminders.pin,
reminders.restartable,
reminders.tts,
reminders.uid,
@ -600,7 +596,6 @@ pub async fn edit_reminder(
interval_seconds,
interval_months,
name,
pin,
restartable,
tts,
username,
@ -687,7 +682,6 @@ pub async fn edit_reminder(
reminders.interval_seconds,
reminders.interval_months,
reminders.name,
reminders.pin,
reminders.restartable,
reminders.tts,
reminders.uid,

View File

@ -97,7 +97,6 @@ pub struct Reminder {
interval_months: Option<u32>,
#[serde(default = "name_default")]
name: String,
pin: bool,
restartable: bool,
tts: bool,
#[serde(default)]
@ -151,8 +150,6 @@ pub struct PatchReminder {
#[serde(default)]
name: Unset<String>,
#[serde(default)]
pin: Unset<bool>,
#[serde(default)]
restartable: Unset<bool>,
#[serde(default)]
tts: Unset<bool>,
@ -213,8 +210,8 @@ mod base64s {
where
D: Deserializer<'de>,
{
let string = String::deserialize(deserializer)?;
Some(base64::decode(string).map_err(de::Error::custom)).transpose()
let string = Option::<String>::deserialize(deserializer)?;
Some(string.map(|b| base64::decode(b).map_err(de::Error::custom))).flatten().transpose()
}
}

View File

@ -288,6 +288,10 @@ textarea, input {
width: 100%;
}
input.default-width {
width: initial;
}
.message-input:placeholder-shown {
border-top: none;
border-left: none;

View File

@ -14,8 +14,16 @@ const $deleteTemplateBtn = document.querySelector("button#delete-template");
const $templateSelect = document.querySelector("select#templateSelect");
let channels = [];
let guildNames = {};
let roles = [];
let templates = {};
let mentions = new Tribute({
values: [],
allowSpaces: true,
selectTemplate: (item) => {
return `<@&${item.original.value}>`;
},
});
let globalPatreon = false;
let guildPatreon = false;
@ -32,18 +40,6 @@ function intToColor(i) {
return `#${i.toString(16).padStart(6, "0")}`;
}
function resize_textareas() {
document.querySelectorAll("textarea.autoresize").forEach((element) => {
element.style.height = "";
element.style.height = element.scrollHeight + 3 + "px";
element.addEventListener("input", () => {
element.style.height = "";
element.style.height = element.scrollHeight + 3 + "px";
});
});
}
function switch_pane(selector) {
document.querySelectorAll("aside a").forEach((el) => {
el.classList.remove("is-active");
@ -53,8 +49,6 @@ function switch_pane(selector) {
});
document.getElementById(selector).classList.remove("is-hidden");
resize_textareas();
}
function update_select(sel) {
@ -98,7 +92,16 @@ function fetch_roles(guild_id) {
if (data.error) {
show_error(data.error);
} else {
roles = data;
let values = Array.from(
data.map((role) => {
return {
key: role.name,
value: role.id,
};
})
);
mentions.collection[0].values = values;
}
});
}
@ -171,6 +174,8 @@ async function fetch_reminders(guild_id) {
newFrame.querySelector(".reminderContent").dataset["uid"] =
reminder["uid"];
mentions.attach(newFrame.querySelector("textarea"));
deserialize_reminder(reminder, newFrame, "load");
$reminderBox.appendChild(newFrame);
@ -312,7 +317,6 @@ async function serialize_reminder(node, mode) {
interval_seconds: mode !== "template" ? interval.seconds : null,
interval_months: mode !== "template" ? interval.months : null,
name: node.querySelector('input[name="name"]').value,
pin: node.querySelector('input[name="pin"]').checked,
tts: node.querySelector('input[name="tts"]').checked,
username: node.querySelector('input[name="username"]').value,
utc_time: utc_time,
@ -400,6 +404,7 @@ document.addEventListener("guildSwitched", async (e) => {
.querySelectorAll(".patreon-only")
.forEach((el) => el.classList.remove("is-locked"));
}
fetch_roles(e.detail.guild_id);
fetch_templates(e.detail.guild_id);
await fetch_channels(e.detail.guild_id);
@ -414,8 +419,6 @@ document.addEventListener("guildSwitched", async (e) => {
});
});
resize_textareas();
$loader.classList.add("is-hidden");
});
@ -553,6 +556,8 @@ document.querySelectorAll(".show-modal").forEach((element) => {
document.addEventListener("DOMContentLoaded", () => {
$loader.classList.remove("is-hidden");
mentions.attach(document.querySelectorAll("textarea"));
document.querySelectorAll(".navbar-burger").forEach((el) => {
el.addEventListener("click", () => {
const target = el.dataset["target"];
@ -591,6 +596,8 @@ document.addEventListener("DOMContentLoaded", () => {
const $template = document.getElementById("guildListEntry");
for (let guild of data) {
guildNames[guild.id] = guild.name;
document.querySelectorAll(".guildList").forEach((element) => {
const $clone = $template.content.cloneNode(true);
const $anchor = $clone.querySelector("a");
@ -607,11 +614,7 @@ document.addEventListener("DOMContentLoaded", () => {
$anchor.addEventListener("click", async (e) => {
e.preventDefault();
window.history.pushState(
{},
"",
`/dashboard/${guild.id}?name=${guild.name}`
);
window.history.pushState({}, "", `/dashboard/${guild.id}`);
const event = new CustomEvent("guildSwitched", {
detail: {
guild_name: guild.name,
@ -629,8 +632,8 @@ document.addEventListener("DOMContentLoaded", () => {
const matches = window.location.href.match(/dashboard\/(\d+)/);
if (matches) {
let id = matches[1];
let name =
new URLSearchParams(window.location.search).get("name") || id;
let name = guildNames[id];
const event = new CustomEvent("guildSwitched", {
detail: {
guild_name: name,
@ -923,7 +926,6 @@ document.addEventListener("DOMNodeInserted", () => {
});
check_embed_fields();
resize_textareas();
});
document.addEventListener("click", (ev) => {

View File

@ -27,8 +27,10 @@
<link rel="stylesheet" href="/static/css/font.css">
<link rel="stylesheet" href="/static/css/style.css">
<link rel="stylesheet" href="/static/css/dtsel.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tributejs/5.1.3/tribute.css" integrity="sha512-GnwBnXd+ZGO9CdP343MUr0jCcJXCr++JVtQRnllexRW2IDq4Zvrh/McTQjooAKnSUbXZ7wamp7AQSweTnfMVoA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="/static/js/luxon.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tributejs/5.1.3/tribute.min.js" integrity="sha512-KJYWC7RKz/Abtsu1QXd7VJ1IJua7P7GTpl3IKUqfa21Otg2opvRYmkui/CXBC6qeDYCNlQZ7c+7JfDXnKdILUA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</head>
<body>
<nav class="navbar is-spaced is-size-4 is-hidden-desktop dashboard-navbar" role="navigation"
@ -173,6 +175,36 @@
<button class="delete close-modal" aria-label="close"></button>
</header>
<section class="modal-card-body">
<div class="control">
<div class="field">
<input type="checkbox" class="default-width">
<label>Reminders</label>
</div>
</div>
<div class="control">
<div class="field">
<input type="checkbox" class="default-width">
<label>Todo Lists</label>
</div>
</div>
<div class="control">
<div class="field">
<input type="checkbox" class="default-width">
<label>Timers</label>
</div>
</div>
<div class="control">
<div class="field">
<input type="checkbox" class="default-width">
<label>Reminder templates</label>
</div>
</div>
<div class="control">
<div class="field">
<input type="checkbox" class="default-width">
<label>Macros</label>
</div>
</div>
<div class="has-text-centered">
<button class="button is-success is-outlined" id="import-data">Import Data</button>
<button class="button is-success" id="export-data">Export Data</button>

View File

@ -125,7 +125,7 @@
<p class="title">Import/Export</p>
<p class="subtitle">Learn how to import and export data from the dashboard</p>
<div class="content has-text-centered">
<a class="button is-size-4 is-rounded is-light" href="/help/macros">
<a class="button is-size-4 is-rounded is-light" href="/help/iemanager">
<p class="is-size-4">
Read <span class="icon"><i class="fas fa-chevron-right"></i></span>
</p>