Compare commits

...

18 Commits

Author SHA1 Message Date
jude
d082f63635 Bump version 2023-09-23 17:37:28 +01:00
jude
9a51c548d6 Update dependencies 2023-09-23 16:18:33 +01:00
jude
4bc7ae8e23 Change migration 2023-09-23 15:16:45 +01:00
jude
6f1ef206df Correctly highlight options on mobile 2023-09-17 18:33:01 +01:00
jude
ec63c942d6 Move button row down 2023-09-17 18:11:22 +01:00
jude
06165c1b36 Restyle to work on most screen sizes 2023-09-17 18:03:57 +01:00
jude
5ee9094bac Handle deleted channels in sender 2023-09-17 14:09:50 +01:00
82dab53744 Merge pull request 'jude/orphan-reminders' (#1) from jude/orphan-reminders into next
Reviewed-on: #1
2023-09-16 17:09:33 +00:00
jude
5f703e8538 Add status update time to sender 2023-09-16 17:59:03 +01:00
jude
2993505a47 Add times to the log 2023-09-09 15:34:43 +01:00
jude
b225ad7e45 Render log rows 2023-09-03 16:00:49 +01:00
jude
ee89cb40c5 Move errors route into get_reminders route. Add database migration. 2023-09-03 15:01:42 +01:00
jude
b6b5e6d2b2 Add error pane 2023-08-27 17:41:23 +01:00
jude
adf29dca5d Start to think about how to display errors 2023-08-19 22:37:48 +01:00
jude
ea3fe3f543 Ensure postman doesn't try to send reminders with no channel 2023-08-19 21:28:05 +01:00
jude
109cf16dbb Store guild when creating reminders 2023-08-19 21:24:02 +01:00
jude
6726ca0c2d Correct migration script.
Stub code for routes. Update existing routes to set the reminder's guild
ID.
2023-08-19 21:24:02 +01:00
38133be15d In progress 2023-08-19 21:24:02 +01:00
25 changed files with 1564 additions and 1025 deletions

1407
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,18 @@
[package]
name = "reminder-rs"
version = "1.6.38"
version = "1.6.40"
authors = ["Jude Southworth <judesouthworth@pm.me>"]
edition = "2021"
license = "AGPL-3.0 only"
description = "Reminder Bot for Discord, now in Rust"
[dependencies]
poise = "0.5.5"
poise = "0.5"
dotenv = "0.15"
tokio = { version = "1", features = ["process", "full"] }
reqwest = "0.11"
lazy-regex = "2.3.0"
regex = "1.6"
lazy-regex = "3.0"
regex = "1.9"
log = "0.4"
env_logger = "0.10"
chrono = "0.4"
@ -25,7 +25,7 @@ serde_repr = "0.1"
rmp-serde = "1.1"
rand = "0.8"
levenshtein = "1.0"
sqlx = { version = "0.6", features = ["runtime-tokio-rustls", "macros", "mysql", "bigdecimal", "chrono", "migrate"]}
sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "macros", "mysql", "bigdecimal", "chrono", "migrate"]}
base64 = "0.21.0"
[dependencies.postman]

View File

@ -0,0 +1,19 @@
-- Drop existing constraint
ALTER TABLE `reminders` DROP CONSTRAINT `reminders_ibfk_1`;
ALTER TABLE `reminders` MODIFY COLUMN `channel_id` INT UNSIGNED;
ALTER TABLE `reminders` ADD COLUMN `guild_id` INT UNSIGNED;
ALTER TABLE `reminders`
ADD CONSTRAINT `guild_id_fk`
FOREIGN KEY (`guild_id`)
REFERENCES `guilds`(`id`)
ON DELETE CASCADE;
ALTER TABLE `reminders`
ADD CONSTRAINT `channel_id_fk`
FOREIGN KEY (`channel_id`)
REFERENCES `channels`(`id`)
ON DELETE SET NULL;
UPDATE `reminders` SET `guild_id` = (SELECT guilds.`id` FROM `channels` INNER JOIN `guilds` ON channels.guild_id = guilds.id WHERE reminders.channel_id = channels.id);

View File

@ -0,0 +1,4 @@
ALTER TABLE reminders ADD COLUMN `status_change_time` DATETIME;
-- This is a best-guess as to the status change time.
UPDATE reminders SET `status_change_time` = `utc_time` WHERE `status` != 'pending';

View File

@ -5,12 +5,12 @@ edition = "2021"
[dependencies]
tokio = { version = "1", features = ["process", "full"] }
regex = "1.4"
regex = "1.9"
log = "0.4"
chrono = "0.4"
chrono-tz = { version = "0.5", features = ["serde"] }
chrono-tz = { version = "0.8", features = ["serde"] }
lazy_static = "1.4"
num-integer = "0.1"
serde = "1.0"
sqlx = { version = "0.6", features = ["runtime-tokio-rustls", "macros", "mysql", "bigdecimal", "chrono", "json"]}
serenity = { version = "0.11.1", default-features = false, features = ["builder", "cache", "client", "gateway", "http", "model", "utils", "rustls_backend"] }
sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "macros", "mysql", "bigdecimal", "chrono", "json"]}
serenity = { version = "0.11", default-features = false, features = ["builder", "cache", "client", "gateway", "http", "model", "utils", "rustls_backend"] }

View File

@ -237,11 +237,11 @@ impl Into<CreateEmbed> for Embed {
pub struct Reminder {
id: u32,
channel_id: u64,
channel_id: Option<u64>,
webhook_id: Option<u64>,
webhook_token: Option<String>,
channel_paused: bool,
channel_paused: Option<bool>,
channel_paused_until: Option<NaiveDateTime>,
enabled: bool,
@ -297,7 +297,7 @@ SELECT
reminders.`username` AS username
FROM
reminders
INNER JOIN
LEFT JOIN
channels
ON
reminders.channel_id = channels.id
@ -343,7 +343,10 @@ WHERE
async fn reset_webhook(&self, pool: impl Executor<'_, Database = Database> + Copy) {
let _ = sqlx::query!(
"UPDATE channels SET webhook_id = NULL, webhook_token = NULL WHERE channel = ?",
"
UPDATE channels SET webhook_id = NULL, webhook_token = NULL
WHERE channel = ?
",
self.channel_id
)
.execute(pool)
@ -415,7 +418,9 @@ WHERE
self.set_sent(pool).await;
} else {
sqlx::query!(
"UPDATE reminders SET `utc_time` = ? WHERE `id` = ?",
"
UPDATE reminders SET `utc_time` = ? WHERE `id` = ?
",
updated_reminder_time.with_timezone(&Utc),
self.id
)
@ -448,7 +453,10 @@ WHERE
if *LOG_TO_DATABASE {
sqlx::query!(
"INSERT INTO stat (type, reminder_id, message) VALUES ('reminder_failed', ?, ?)",
"
INSERT INTO stat (type, reminder_id, message)
VALUES ('reminder_failed', ?, ?)
",
self.id,
message,
)
@ -461,7 +469,10 @@ WHERE
async fn log_success(&self, pool: impl Executor<'_, Database = Database> + Copy) {
if *LOG_TO_DATABASE {
sqlx::query!(
"INSERT INTO stat (type, reminder_id) VALUES ('reminder_sent', ?)",
"
INSERT INTO stat (type, reminder_id)
VALUES ('reminder_sent', ?)
",
self.id,
)
.execute(pool)
@ -471,10 +482,17 @@ WHERE
}
async fn set_sent(&self, pool: impl Executor<'_, Database = Database> + Copy) {
sqlx::query!("UPDATE reminders SET `status` = 'sent' WHERE `id` = ?", self.id)
.execute(pool)
.await
.expect(&format!("Could not delete Reminder {}", self.id));
sqlx::query!(
"
UPDATE reminders
SET `status` = 'sent', `status_change_time` = NOW()
WHERE `id` = ?
",
self.id
)
.execute(pool)
.await
.expect(&format!("Could not delete Reminder {}", self.id));
}
async fn set_failed(
@ -483,7 +501,11 @@ WHERE
message: &'static str,
) {
sqlx::query!(
"UPDATE reminders SET `status` = 'failed', `status_message` = ? WHERE `id` = ?",
"
UPDATE reminders
SET `status` = 'failed', `status_message` = ?, `status_change_time` = NOW()
WHERE `id` = ?
",
message,
self.id
)
@ -493,7 +515,9 @@ WHERE
}
async fn pin_message<M: Into<u64>>(&self, message_id: M, http: impl AsRef<Http>) {
let _ = http.as_ref().pin_message(self.channel_id, message_id.into(), None).await;
if let Some(channel_id) = self.channel_id {
let _ = http.as_ref().pin_message(channel_id, message_id.into(), None).await;
}
}
pub async fn send(
@ -503,10 +527,11 @@ WHERE
) {
async fn send_to_channel(
cache_http: impl CacheHttp,
channel_id: u64,
reminder: &Reminder,
embed: Option<CreateEmbed>,
) -> Result<()> {
let channel = ChannelId(reminder.channel_id).to_channel(&cache_http).await;
let channel = ChannelId(channel_id).to_channel(&cache_http).await;
match channel {
Ok(Channel::Guild(channel)) => {
@ -538,6 +563,7 @@ WHERE
Err(e) => Err(e),
}
}
Ok(Channel::Private(channel)) => {
match channel
.send_message(&cache_http.http(), |m| {
@ -567,7 +593,9 @@ WHERE
Err(e) => Err(e),
}
}
Err(e) => Err(e),
_ => Err(Error::Other("Channel not of valid type")),
}
}
@ -622,124 +650,151 @@ WHERE
}
}
if self.enabled
&& !(self.channel_paused
&& self
.channel_paused_until
.map_or(true, |inner| inner >= Utc::now().naive_local()))
{
let _ = sqlx::query!(
"UPDATE `channels` SET paused = 0, paused_until = NULL WHERE `channel` = ?",
self.channel_id
)
.execute(pool)
.await;
match self.channel_id {
Some(channel_id) => {
if self.enabled
&& !(self.channel_paused.unwrap_or(false)
&& self
.channel_paused_until
.map_or(true, |inner| inner >= Utc::now().naive_local()))
{
let _ = sqlx::query!(
"
UPDATE `channels`
SET paused = 0, paused_until = NULL
WHERE `channel` = ?
",
self.channel_id
)
.execute(pool)
.await;
let embed = Embed::from_id(pool, self.id).await.map(|e| e.into());
let embed = Embed::from_id(pool, self.id).await.map(|e| e.into());
let result = if let (Some(webhook_id), Some(webhook_token)) =
(self.webhook_id, &self.webhook_token)
{
let webhook_res =
cache_http.http().get_webhook_with_token(webhook_id, webhook_token).await;
let result = if let (Some(webhook_id), Some(webhook_token)) =
(self.webhook_id, &self.webhook_token)
{
let webhook_res = cache_http
.http()
.get_webhook_with_token(webhook_id, webhook_token)
.await;
if let Ok(webhook) = webhook_res {
send_to_webhook(cache_http, &self, webhook, embed).await
} else {
warn!("Webhook vanished for reminder {}: {:?}", self.id, webhook_res);
if let Ok(webhook) = webhook_res {
send_to_webhook(cache_http, &self, webhook, embed).await
} else {
warn!("Webhook vanished for reminder {}: {:?}", self.id, webhook_res);
self.reset_webhook(pool).await;
send_to_channel(cache_http, &self, embed).await
}
} else {
send_to_channel(cache_http, &self, embed).await
};
if let Err(e) = result {
if let Error::Http(error) = e {
if let HttpError::UnsuccessfulRequest(http_error) = *error {
match http_error.error.code {
10003 => {
self.log_error(
pool,
"Could not be sent as channel does not exist",
None::<&'static str>,
)
.await;
self.set_failed(
pool,
"Could not be sent as channel does not exist",
)
.await;
}
10004 => {
self.log_error(
pool,
"Could not be sent as guild does not exist",
None::<&'static str>,
)
.await;
self.set_failed(pool, "Could not be sent as guild does not exist")
.await;
}
50001 => {
self.log_error(
pool,
"Could not be sent as missing access",
None::<&'static str>,
)
.await;
self.set_failed(pool, "Could not be sent as missing access").await;
}
50007 => {
self.log_error(
pool,
"Could not be sent as user has DMs disabled",
None::<&'static str>,
)
.await;
self.set_failed(pool, "Could not be sent as user has DMs disabled")
.await;
}
50013 => {
self.log_error(
pool,
"Could not be sent as permissions are invalid",
None::<&'static str>,
)
.await;
self.set_failed(
pool,
"Could not be sent as permissions are invalid",
)
.await;
}
_ => {
self.log_error(
pool,
"HTTP error sending reminder",
Some(http_error),
)
.await;
self.refresh(pool).await;
}
self.reset_webhook(pool).await;
send_to_channel(cache_http, channel_id, &self, embed).await
}
} else {
self.log_error(pool, "(Likely) a parsing error", Some(error)).await;
send_to_channel(cache_http, channel_id, &self, embed).await
};
if let Err(e) = result {
if let Error::Http(error) = e {
if let HttpError::UnsuccessfulRequest(http_error) = *error {
match http_error.error.code {
10003 => {
self.log_error(
pool,
"Could not be sent as channel does not exist",
None::<&'static str>,
)
.await;
self.set_failed(
pool,
"Could not be sent as channel does not exist",
)
.await;
}
10004 => {
self.log_error(
pool,
"Could not be sent as guild does not exist",
None::<&'static str>,
)
.await;
self.set_failed(
pool,
"Could not be sent as guild does not exist",
)
.await;
}
50001 => {
self.log_error(
pool,
"Could not be sent as missing access",
None::<&'static str>,
)
.await;
self.set_failed(
pool,
"Could not be sent as missing access",
)
.await;
}
50007 => {
self.log_error(
pool,
"Could not be sent as user has DMs disabled",
None::<&'static str>,
)
.await;
self.set_failed(
pool,
"Could not be sent as user has DMs disabled",
)
.await;
}
50013 => {
self.log_error(
pool,
"Could not be sent as permissions are invalid",
None::<&'static str>,
)
.await;
self.set_failed(
pool,
"Could not be sent as permissions are invalid",
)
.await;
}
_ => {
self.log_error(
pool,
"HTTP error sending reminder",
Some(http_error),
)
.await;
self.refresh(pool).await;
}
}
} else {
self.log_error(pool, "(Likely) a parsing error", Some(error)).await;
self.refresh(pool).await;
}
} else {
self.log_error(pool, "Non-HTTP error", Some(e)).await;
self.refresh(pool).await;
}
} else {
self.log_success(pool).await;
self.refresh(pool).await;
}
} else {
self.log_error(pool, "Non-HTTP error", Some(e)).await;
info!("Reminder {} is paused", self.id);
self.refresh(pool).await;
}
} else {
self.log_success(pool).await;
self.refresh(pool).await;
}
} else {
info!("Reminder {} is paused", self.id);
self.refresh(pool).await;
None => {
info!("Reminder {} is orphaned", self.id);
self.log_error(pool, "Orphaned", Option::<u8>::None).await;
self.set_failed(pool, "Could not be sent as channel was deleted").await;
}
}
}
}

View File

@ -27,7 +27,7 @@ pub async fn migrate_macro(ctx: Context<'_>) -> Result<(), Error> {
"SELECT name, command FROM command_aliases WHERE guild_id = (SELECT id FROM guilds WHERE guild = ?)",
guild_id.0
)
.fetch_all(&mut transaction)
.fetch_all(&mut *transaction)
.await?;
let mut added_aliases = 0;
@ -42,7 +42,7 @@ pub async fn migrate_macro(ctx: Context<'_>) -> Result<(), Error> {
cmd_macro.description,
cmd_macro.commands
)
.execute(&mut transaction)
.execute(&mut *transaction)
.await?;
added_aliases += 1;

View File

@ -166,15 +166,21 @@ impl ComponentDataModel {
.await;
}
ComponentDataModel::DelSelector(selector) => {
let selected_id = component.data.values.join(",");
for id in &component.data.values {
match id.parse::<u32>() {
Ok(id) => {
if let Some(reminder) = Reminder::from_id(&data.database, id).await {
reminder.delete(&data.database).await.unwrap();
} else {
warn!("Attempt to delete non-existent reminder");
}
}
sqlx::query!(
"UPDATE reminders SET `status` = 'deleted' WHERE FIND_IN_SET(id, ?)",
selected_id
)
.execute(&data.database)
.await
.unwrap();
Err(e) => {
warn!("Error casting ID to integer: {:?}.", e);
}
}
}
let reminders = Reminder::from_guild(
&ctx,

View File

@ -10,6 +10,7 @@ pub struct ChannelData {
pub webhook_id: Option<u64>,
pub webhook_token: Option<String>,
pub paused: bool,
pub db_guild_id: Option<u32>,
pub paused_until: Option<NaiveDateTime>,
}
@ -22,7 +23,11 @@ impl ChannelData {
if let Ok(c) = sqlx::query_as_unchecked!(
Self,
"SELECT id, name, nudge, blacklisted, webhook_id, webhook_token, paused, paused_until FROM channels WHERE channel = ?",
"
SELECT id, name, nudge, blacklisted, webhook_id, webhook_token, paused, paused_until,
guild_id AS db_guild_id
FROM channels WHERE channel = ?
",
channel_id
)
.fetch_one(pool)
@ -30,12 +35,18 @@ impl ChannelData {
{
Ok(c)
} else {
let props = channel.to_owned().guild().map(|g| (g.guild_id.as_u64().to_owned(), g.name));
let props =
channel.to_owned().guild().map(|g| (g.guild_id.as_u64().to_owned(), g.name));
let (guild_id, channel_name) = if let Some((a, b)) = props { (Some(a), Some(b)) } else { (None, None) };
let (guild_id, channel_name) =
if let Some((a, b)) = props { (Some(a), Some(b)) } else { (None, None) };
sqlx::query!(
"INSERT IGNORE INTO channels (channel, name, guild_id) VALUES (?, ?, (SELECT id FROM guilds WHERE guild = ?))",
"
INSERT IGNORE INTO channels
(channel, name, guild_id)
VALUES (?, ?, (SELECT id FROM guilds WHERE guild = ?))
",
channel_id,
channel_name,
guild_id
@ -46,7 +57,10 @@ impl ChannelData {
Ok(sqlx::query_as_unchecked!(
Self,
"
SELECT id, name, nudge, blacklisted, webhook_id, webhook_token, paused, paused_until FROM channels WHERE channel = ?
SELECT id, name, nudge, blacklisted, webhook_id, webhook_token, paused,
paused_until, guild_id AS db_guild_id
FROM channels
WHERE channel = ?
",
channel_id
)
@ -58,8 +72,10 @@ SELECT id, name, nudge, blacklisted, webhook_id, webhook_token, paused, paused_u
pub async fn commit_changes(&self, pool: &MySqlPool) {
sqlx::query!(
"
UPDATE channels SET name = ?, nudge = ?, blacklisted = ?, webhook_id = ?, webhook_token = ?, paused = ?, paused_until \
= ? WHERE id = ?
UPDATE channels
SET name = ?, nudge = ?, blacklisted = ?, webhook_id = ?, webhook_token = ?,
paused = ?, paused_until = ?
WHERE id = ?
",
self.name,
self.nudge,

View File

@ -51,6 +51,7 @@ pub struct ReminderBuilder {
pool: MySqlPool,
uid: String,
channel: u32,
guild: Option<u32>,
thread_id: Option<u64>,
utc_time: NaiveDateTime,
timezone: String,
@ -86,6 +87,7 @@ impl ReminderBuilder {
INSERT INTO reminders (
`uid`,
`channel_id`,
`guild_id`,
`utc_time`,
`timezone`,
`interval_seconds`,
@ -110,11 +112,13 @@ INSERT INTO reminders (
?,
?,
?,
?,
?
)
",
self.uid,
self.channel,
self.guild,
utc_time,
self.timezone,
self.interval_seconds,
@ -247,10 +251,10 @@ impl<'a> MultiReminderBuilder<'a> {
{
Err(ReminderError::UserBlockedDm)
} else {
Ok(user_data.dm_channel)
Ok((user_data.dm_channel, None))
}
} else {
Ok(user_data.dm_channel)
Ok((user_data.dm_channel, None))
}
} else {
Err(ReminderError::InvalidTag)
@ -297,13 +301,13 @@ impl<'a> MultiReminderBuilder<'a> {
.commit_changes(&self.ctx.data().database)
.await;
Ok(channel_data.id)
Ok((channel_data.id, channel_data.db_guild_id))
}
Err(e) => Err(ReminderError::DiscordError(e.to_string())),
}
} else {
Ok(channel_data.id)
Ok((channel_data.id, channel_data.db_guild_id))
}
}
} else {
@ -317,7 +321,8 @@ impl<'a> MultiReminderBuilder<'a> {
let builder = ReminderBuilder {
pool: self.ctx.data().database.clone(),
uid: generate_uid(),
channel: c,
channel: c.0,
guild: c.1,
thread_id,
utc_time: self.utc_time,
timezone: self.timezone.to_string(),

View File

@ -304,10 +304,13 @@ WHERE
&self,
db: impl Executor<'_, Database = Database>,
) -> Result<(), sqlx::Error> {
sqlx::query!("UPDATE reminders SET `status` = 'deleted' WHERE uid = ?", self.uid)
.execute(db)
.await
.map(|_| ())
sqlx::query!(
"UPDATE reminders SET `status` = 'deleted', `status_change_time` = NOW() WHERE uid = ?",
self.uid
)
.execute(db)
.await
.map(|_| ())
}
pub fn display_content(&self) -> &str {

View File

@ -7,14 +7,14 @@ edition = "2018"
[dependencies]
rocket = { git = "https://github.com/SergioBenitez/Rocket", branch = "master", features = ["tls", "secrets", "json"] }
rocket_dyn_templates = { git = "https://github.com/SergioBenitez/Rocket", branch = "master", features = ["tera"] }
serenity = { version = "0.11.1", default-features = false, features = ["builder", "cache", "client", "gateway", "http", "model", "utils", "rustls_backend"] }
serenity = { version = "0.11", default-features = false, features = ["builder", "cache", "client", "gateway", "http", "model", "utils", "rustls_backend"] }
oauth2 = "4"
log = "0.4"
reqwest = "0.11"
serde = { version = "1.0", features = ["derive"] }
sqlx = { version = "0.6", features = ["runtime-tokio-rustls", "macros", "mysql", "chrono", "json"] }
sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "macros", "mysql", "chrono", "json"] }
chrono = "0.4"
chrono-tz = "0.5"
chrono-tz = "0.8"
lazy_static = "1.4.0"
rand = "0.7"
base64 = "0.13"

View File

@ -150,7 +150,8 @@ pub async fn initialize(
.mount(
"/dashboard",
routes![
routes::dashboard::dashboard,
routes::dashboard::dashboard_1,
routes::dashboard::dashboard_2,
routes::dashboard::dashboard_home,
routes::dashboard::user::get_user_info,
routes::dashboard::user::update_user_info,

View File

@ -12,8 +12,7 @@ use sqlx::{MySql, Pool};
use crate::routes::{
dashboard::{
create_reminder, generate_uid, ImportBody, Reminder, ReminderCsv, ReminderTemplateCsv,
TodoCsv,
create_reminder, ImportBody, ReminderCreate, ReminderCsv, ReminderTemplateCsv, TodoCsv,
},
JsonResult,
};
@ -141,7 +140,7 @@ pub async fn import_reminders(
match channel_id.parse::<u64>() {
Ok(channel_id) => {
let reminder = Reminder {
let reminder = ReminderCreate {
attachment: record.attachment,
attachment_name: record.attachment_name,
avatar: record.avatar,
@ -168,7 +167,6 @@ pub async fn import_reminders(
name: record.name,
restartable: record.restartable,
tts: record.tts,
uid: generate_uid(),
username: record.username,
utc_time: record.utc_time,
};

View File

@ -26,7 +26,7 @@ use crate::{
routes::{
dashboard::{
create_database_channel, create_reminder, template_name_default, DeleteReminder,
DeleteReminderTemplate, PatchReminder, Reminder, ReminderTemplate,
DeleteReminderTemplate, PatchReminder, Reminder, ReminderCreate, ReminderTemplate,
},
JsonResult,
},
@ -298,7 +298,7 @@ pub async fn delete_reminder_template(
#[post("/api/guild/<id>/reminders", data = "<reminder>")]
pub async fn create_guild_reminder(
id: u64,
reminder: Json<Reminder>,
reminder: Json<ReminderCreate>,
cookies: &CookieJar<'_>,
serenity_context: &State<Context>,
pool: &State<Pool<MySql>>,
@ -318,76 +318,65 @@ pub async fn create_guild_reminder(
.await
}
#[get("/api/guild/<id>/reminders")]
#[get("/api/guild/<id>/reminders?<status>")]
pub async fn get_reminders(
id: u64,
cookies: &CookieJar<'_>,
ctx: &State<Context>,
serenity_context: &State<Context>,
pool: &State<Pool<MySql>>,
status: Option<String>,
) -> JsonResult {
check_authorization!(cookies, serenity_context.inner(), id);
let channels_res = GuildId(id).channels(&ctx.inner()).await;
let status = status.unwrap_or("pending".to_string());
match channels_res {
Ok(channels) => {
let channels = channels
.keys()
.into_iter()
.map(|k| k.as_u64().to_string())
.collect::<Vec<String>>()
.join(",");
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,
IFNULL(reminders.embed_fields, '[]') AS embed_fields,
reminders.enabled,
reminders.expires,
reminders.interval_seconds,
reminders.interval_days,
reminders.interval_months,
reminders.name,
reminders.restartable,
reminders.tts,
reminders.uid,
reminders.username,
reminders.utc_time,
reminders.status,
reminders.status_change_time,
reminders.status_message
FROM reminders
LEFT JOIN channels ON channels.id = reminders.channel_id
WHERE FIND_IN_SET(`status`, ?) AND reminders.guild_id = (SELECT id FROM guilds WHERE guild = ?)",
status,
id
)
.fetch_all(pool.inner())
.await
.map(|r| Ok(json!(r)))
.unwrap_or_else(|e| {
warn!("Failed to complete SQL query: {:?}", e);
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,
IFNULL(reminders.embed_fields, '[]') AS embed_fields,
reminders.enabled,
reminders.expires,
reminders.interval_seconds,
reminders.interval_days,
reminders.interval_months,
reminders.name,
reminders.restartable,
reminders.tts,
reminders.uid,
reminders.username,
reminders.utc_time
FROM reminders
LEFT JOIN channels ON channels.id = reminders.channel_id
WHERE `status` = 'pending' AND FIND_IN_SET(channels.channel, ?)",
channels
)
.fetch_all(pool.inner())
.await
.map(|r| Ok(json!(r)))
.unwrap_or_else(|e| {
warn!("Failed to complete SQL query: {:?}", e);
json_err!("Could not load reminders")
})
}
Err(e) => {
warn!("Could not fetch channels from {}: {:?}", id, e);
Ok(json!([]))
}
}
json_err!("Could not load reminders")
})
}
#[patch("/api/guild/<id>/reminders", data = "<reminder>")]
@ -561,7 +550,8 @@ pub async fn edit_reminder(
match sqlx::query_as_unchecked!(
Reminder,
"SELECT reminders.attachment,
"
SELECT reminders.attachment,
reminders.attachment_name,
reminders.avatar,
channels.channel,
@ -586,7 +576,10 @@ pub async fn edit_reminder(
reminders.tts,
reminders.uid,
reminders.username,
reminders.utc_time
reminders.utc_time,
reminders.status,
reminders.status_change_time,
reminders.status_message
FROM reminders
LEFT JOIN channels ON channels.id = reminders.channel_id
WHERE uid = ?",
@ -610,9 +603,12 @@ pub async fn delete_reminder(
reminder: Json<DeleteReminder>,
pool: &State<Pool<MySql>>,
) -> JsonResult {
match sqlx::query!("UPDATE reminders SET `status` = 'deleted' WHERE uid = ?", reminder.uid)
.execute(pool.inner())
.await
match sqlx::query!(
"UPDATE reminders SET `status` = 'deleted', `status_change_time` = NOW() WHERE uid = ?",
reminder.uid
)
.execute(pool.inner())
.await
{
Ok(_) => Ok(json!({})),

View File

@ -118,8 +118,8 @@ pub struct EmbedField {
inline: bool,
}
#[derive(Serialize, Deserialize)]
pub struct Reminder {
#[derive(Deserialize)]
pub struct ReminderCreate {
#[serde(with = "base64s")]
attachment: Option<Vec<u8>>,
attachment_name: Option<String>,
@ -146,10 +146,45 @@ pub struct Reminder {
name: String,
restartable: bool,
tts: bool,
username: Option<String>,
utc_time: NaiveDateTime,
}
#[derive(Serialize, Deserialize)]
pub struct Reminder {
#[serde(with = "base64s")]
attachment: Option<Vec<u8>>,
attachment_name: Option<String>,
avatar: Option<String>,
#[serde(with = "string_opt")]
channel: Option<u64>,
content: String,
embed_author: String,
embed_author_url: Option<String>,
embed_color: u32,
embed_description: String,
embed_footer: String,
embed_footer_url: Option<String>,
embed_image_url: Option<String>,
embed_thumbnail_url: Option<String>,
embed_title: String,
embed_fields: Option<Json<Vec<EmbedField>>>,
enabled: bool,
expires: Option<NaiveDateTime>,
interval_seconds: Option<u32>,
interval_days: Option<u32>,
interval_months: Option<u32>,
#[serde(default = "name_default")]
name: String,
restartable: bool,
tts: bool,
#[serde(default)]
uid: String,
username: Option<String>,
utc_time: NaiveDateTime,
status: String,
status_message: Option<String>,
status_change_time: Option<NaiveDateTime>,
}
#[derive(Serialize, Deserialize)]
@ -288,15 +323,7 @@ pub fn generate_uid() -> String {
mod string {
use std::{fmt::Display, str::FromStr};
use serde::{de, Deserialize, Deserializer, Serializer};
pub fn serialize<T, S>(value: &T, serializer: S) -> Result<S::Ok, S::Error>
where
T: Display,
S: Serializer,
{
serializer.collect_str(value)
}
use serde::{de, Deserialize, Deserializer};
pub fn deserialize<'de, T, D>(deserializer: D) -> Result<T, D::Error>
where
@ -308,6 +335,34 @@ mod string {
}
}
mod string_opt {
use std::{fmt::Display, str::FromStr};
use serde::{de, Deserialize, Deserializer, Serializer};
pub fn serialize<T, S>(value: &Option<T>, serializer: S) -> Result<S::Ok, S::Error>
where
T: Display,
S: Serializer,
{
match value {
Some(value) => serializer.collect_str(value),
None => serializer.serialize_none(),
}
}
pub fn deserialize<'de, T, D>(deserializer: D) -> Result<Option<T>, D::Error>
where
T: FromStr,
T::Err: Display,
D: Deserializer<'de>,
{
Option::deserialize(deserializer)?
.map(|d: String| d.parse().map_err(de::Error::custom))
.transpose()
}
}
mod base64s {
use serde::{de, Deserialize, Deserializer, Serializer};
@ -352,7 +407,7 @@ pub async fn create_reminder(
pool: impl sqlx::Executor<'_, Database = Database> + Copy,
guild_id: GuildId,
user_id: UserId,
reminder: Reminder,
reminder: ReminderCreate,
) -> JsonResult {
// check guild in db
match sqlx::query!("SELECT 1 as A FROM guilds WHERE guild = ?", guild_id.0)
@ -380,7 +435,7 @@ pub async fn create_reminder(
if !channel_matches_guild || !channel_exists {
warn!(
"Error in `create_reminder`: channel {} not found for guild {} (channel exists: {})",
"Error in `create_reminder`: channel {:?} not found for guild {} (channel exists: {})",
reminder.channel, guild_id, channel_exists
);
@ -474,11 +529,13 @@ pub async fn create_reminder(
// write to db
match sqlx::query!(
"INSERT INTO reminders (
"
INSERT INTO reminders (
uid,
attachment,
attachment_name,
channel_id,
guild_id,
avatar,
content,
embed_author,
@ -501,11 +558,14 @@ pub async fn create_reminder(
tts,
username,
`utc_time`
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
) VALUES (?, ?, ?, ?,
(SELECT id FROM guilds WHERE guild = ?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?)",
new_uid,
attachment_data,
reminder.attachment_name,
channel,
guild_id.0,
reminder.avatar,
reminder.content,
reminder.embed_author,
@ -560,7 +620,10 @@ pub async fn create_reminder(
reminders.tts,
reminders.uid,
reminders.username,
reminders.utc_time
reminders.utc_time,
reminders.status,
reminders.status_change_time,
reminders.status_message
FROM reminders
LEFT JOIN channels ON channels.id = reminders.channel_id
WHERE uid = ?",
@ -662,7 +725,17 @@ pub async fn dashboard_home(cookies: &CookieJar<'_>) -> Result<Template, Redirec
}
#[get("/<_>")]
pub async fn dashboard(cookies: &CookieJar<'_>) -> Result<Template, Redirect> {
pub async fn dashboard_1(cookies: &CookieJar<'_>) -> Result<Template, Redirect> {
if cookies.get_private("userid").is_some() {
let map: HashMap<&str, String> = HashMap::new();
Ok(Template::render("dashboard", &map))
} else {
Err(Redirect::to("/login/discord"))
}
}
#[get("/<_>/<_>")]
pub async fn dashboard_2(cookies: &CookieJar<'_>) -> Result<Template, Redirect> {
if cookies.get_private("userid").is_some() {
let map: HashMap<&str, String> = HashMap::new();
Ok(Template::render("dashboard", &map))

View File

@ -15,6 +15,18 @@ div.reminderContent.is-collapsed .column.settings {
display: none;
}
div.reminderContent.is-collapsed .button-row {
display: none;
}
div.reminderContent.is-collapsed .button-row-edit {
display: none;
}
div.reminderContent.is-collapsed .reminder-topbar {
padding-bottom: 0;
}
div.reminderContent.is-collapsed .invert-collapses {
display: inline-flex;
}
@ -129,6 +141,12 @@ div.split-controls {
margin-top: 0 !important;
}
.reminder-settings > .column {
flex-grow: 0;
flex-shrink: 0;
flex-basis: 50%;
}
div.reminderContent {
margin-top: 10px;
margin-bottom: 10px;
@ -291,10 +309,19 @@ div.dashboard-sidebar:not(.mobile-sidebar) {
flex-direction: column;
}
ul.guildList {
flex-grow: 1;
flex-shrink: 1;
overflow: auto;
}
div.dashboard-sidebar:not(.mobile-sidebar) .aside-footer {
position: fixed;
bottom: 0;
width: 226px;
flex-shrink: 0;
flex-grow: 0;
}
div.dashboard-sidebar svg {
flex-shrink: 0;
}
div.mobile-sidebar {
@ -444,8 +471,7 @@ input.default-width {
.customizable.is-400x300 img {
margin-top: 10px;
width: 100%;
min-height: 100px;
max-height: 400px;
height: 100px;
}
.customizable.is-32x32 img {
@ -589,6 +615,14 @@ input.default-width {
border-bottom: 1px solid #fff;
}
.channel-selector {
width: 100%;
}
.select {
width: 100%;
}
li.highlight {
margin-bottom: 0 !important;
}
@ -612,7 +646,22 @@ li.highlight {
padding: 2px;
}
@media only screen and (max-width: 1408px) {
@media only screen and (max-width: 1023px) {
p.title.pageTitle {
display: none;
}
.dashboard-frame {
margin-top: 4rem !important;
}
.customizable.thumbnail img {
width: 60px;
height: 60px;
}
}
@media only screen and (max-width: 768px) {
.button-row {
display: flex;
flex-direction: column;
@ -630,37 +679,13 @@ li.highlight {
.button-row button {
width: 100%;
}
}
@media only screen and (max-width: 768px) {
.button-row-edit {
display: flex;
flex-direction: column;
.reminder-settings {
margin-bottom: 0 !important;
}
.button-row-edit > button {
width: 100%;
margin: 4px;
}
p.title.pageTitle {
display: none;
}
.dashboard-frame {
margin-top: 4rem !important;
}
}
@media only screen and (max-width: 768px) {
.customizable.thumbnail img {
width: 60px;
height: 60px;
}
.customizable.is-24x24 img {
width: 16px;
height: 16px;
.tts-row {
padding-bottom: 0;
}
}
@ -679,6 +704,86 @@ li.highlight {
/* END */
div.reminderError {
margin: 10px;
padding: 14px;
background-color: #f5f5f5;
border-radius: 8px;
}
div.reminderError .errorHead {
display: flex;
flex-direction: row;
}
div.reminderError .errorIcon {
padding: 8px;
border-radius: 4px;
margin-right: 12px;
}
div.reminderError .errorIcon .fas {
display: none
}
div.reminderError[data-case="deleted"] .errorIcon {
background-color: #e7e5e4;
}
div.reminderError[data-case="failed"] .errorIcon {
background-color: #fecaca;
}
div.reminderError[data-case="sent"] .errorIcon {
background-color: #d9f99d;
}
div.reminderError[data-case="deleted"] .errorIcon .fas.fa-trash {
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 {
font-size: 1rem;
display: flex;
flex-direction: column;
justify-content: center;
color: rgb(54, 54, 54);
flex-grow: 1;
}
div.reminderError .errorHead .reminderTime {
font-size: 1rem;
display: flex;
flex-direction: column;
flex-shrink: 1;
justify-content: center;
color: rgb(54, 54, 54);
background-color: #ffffff;
padding: 8px;
border-radius: 4px;
border-color: #e5e5e5;
border-width: 1px;
border-style: solid;
}
div.reminderError .reminderMessage {
font-size: 1rem;
display: flex;
flex-direction: column;
justify-content: center;
color: rgb(54, 54, 54);
flex-grow: 1;
font-style: italic;
}
/* other stuff */
.half-rem {
@ -716,6 +821,18 @@ a.switch-pane {
text-overflow: ellipsis;
}
.guild-submenu {
display: none;
}
.guild-submenu li {
font-size: 0.8rem;
}
a.switch-pane.is-active ~ .guild-submenu {
display: block;
}
.feedback {
background-color: #5865F2;
}

View File

@ -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 = {};
@ -33,7 +34,11 @@ let globalPatreon = false;
let guildPatreon = false;
function guildId() {
return document.querySelector(".guildList a.is-active").dataset["guild"];
return document.querySelector("li > a.is-active").parentElement.dataset["guild"];
}
function guildName() {
return guildNames[guildId()];
}
function colorToInt(r, g, b) {
@ -52,7 +57,7 @@ function switch_pane(selector) {
el.classList.add("is-hidden");
});
document.getElementById(selector).classList.remove("is-hidden");
document.querySelector(`*[data-name=${selector}]`).classList.remove("is-hidden");
}
function update_select(sel) {
@ -449,21 +454,27 @@ document.addEventListener("guildSwitched", async (e) => {
.querySelectorAll(".patreon-only")
.forEach((el) => el.classList.add("is-locked"));
let $anchor = document.querySelector(
`.switch-pane[data-guild="${e.detail.guild_id}"]`
);
let $li = document.querySelectorAll(`li[data-guild="${e.detail.guild_id}"]`);
let hasError = false;
if ($anchor === null) {
if ($li.length === 0) {
switch_pane("user-error");
hasError = true;
return;
}
switch_pane($anchor.dataset["pane"]);
switch_pane(e.detail.pane);
reset_guild_pane();
$anchor.classList.add("is-active");
document
.querySelectorAll(`li[data-guild="${e.detail.guild_id}"] > a`)
.forEach((el) => {
el.classList.add("is-active");
});
document
.querySelectorAll(
`li[data-guild="${e.detail.guild_id}"] *[data-pane="${e.detail.pane}"]`
)
.forEach((el) => {
el.classList.add("is-active");
});
if (globalPatreon || (await fetch_patreon(e.detail.guild_id))) {
document
@ -471,15 +482,26 @@ document.addEventListener("guildSwitched", async (e) => {
.forEach((el) => el.classList.remove("is-locked"));
}
hasError = await fetch_channels(e.detail.guild_id);
const event = new CustomEvent("paneLoad", {
detail: {
guild_id: e.detail.guild_id,
pane: e.detail.pane,
},
});
document.dispatchEvent(event);
});
document.addEventListener("paneLoad", async (ev) => {
const hasError = await fetch_channels(ev.detail.guild_id);
if (!hasError) {
fetch_roles(e.detail.guild_id);
fetch_templates(e.detail.guild_id);
fetch_reminders(e.detail.guild_id);
fetch_roles(ev.detail.guild_id);
fetch_templates(ev.detail.guild_id);
fetch_reminders(ev.detail.guild_id);
document.querySelectorAll("p.pageTitle").forEach((el) => {
el.textContent = `${e.detail.guild_name} Reminders`;
el.textContent = `${guildName()} Reminders`;
});
document.querySelectorAll("select.channel-selector").forEach((el) => {
el.addEventListener("change", (e) => {
update_select(e.target);
@ -684,36 +706,56 @@ document.addEventListener("DOMContentLoaded", async () => {
"%guildname%",
guild.name
);
$anchor.dataset["guild"] = guild.id;
$anchor.dataset["name"] = guild.name;
$anchor.href = `/dashboard/${guild.id}?name=${guild.name}`;
$anchor.href = `/dashboard/${guild.id}/reminders`;
$anchor.addEventListener("click", async (e) => {
e.preventDefault();
window.history.pushState({}, "", `/dashboard/${guild.id}`);
const event = new CustomEvent("guildSwitched", {
detail: {
guild_name: guild.name,
guild_id: guild.id,
},
const $li = $anchor.parentElement;
$li.dataset["guild"] = guild.id;
$li.querySelectorAll("a").forEach((el) => {
el.addEventListener("click", (e) => {
const pane = el.dataset["pane"];
const slug = el.dataset["slug"];
if (pane !== undefined && slug !== undefined) {
e.preventDefault();
switch_pane(pane);
window.history.pushState(
{},
"",
`/dashboard/${guild.id}/${slug}`
);
const event = new CustomEvent("guildSwitched", {
detail: {
guild_id: guild.id,
pane,
},
});
document.dispatchEvent(event);
}
});
document.dispatchEvent(event);
});
element.append($clone);
});
}
const matches = window.location.href.match(/dashboard\/(\d+)/);
const matches = window.location.href.match(
/dashboard\/(\d+)(\/)?([a-zA-Z\-]+)?/
);
if (matches) {
let id = matches[1];
let kind = matches[3];
let name = guildNames[id];
const event = new CustomEvent("guildSwitched", {
detail: {
guild_name: name,
guild_id: id,
pane: kind,
},
});

View File

@ -0,0 +1,45 @@
function loadErrors() {
return fetch(
`/dashboard/api/guild/${guildId()}/reminders?status=deleted,sent,failed`
).then((response) => response.json());
}
document.addEventListener("paneLoad", (ev) => {
if (ev.detail.pane !== "errors") {
return;
}
document.querySelectorAll(".reminderError").forEach((el) => el.remove());
const template = document.getElementById("reminderError");
const container = document.getElementById("reminderLog");
loadErrors()
.then((res) => {
res = res
.filter((r) => r.status_change_time !== null)
.sort((a, b) => a.status_change_time < b.status_change_time);
for (const reminder of res) {
const newRow = template.content.cloneNode(true);
newRow.querySelector(".reminderError").dataset["case"] = reminder.status;
const statusTime = new luxon.DateTime.fromISO(
reminder.status_change_time,
{ zone: "UTC" }
);
newRow.querySelector(".reminderName").textContent = reminder.name;
newRow.querySelector(".reminderMessage").textContent =
reminder.status_message;
newRow.querySelector(".reminderTime").textContent = statusTime
.toLocal()
.toLocaleString(luxon.DateTime.DATETIME_MED);
container.appendChild(newRow);
}
})
.finally(() => {
$loader.classList.add("is-hidden");
});
});

View File

@ -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', () => {
})

View File

@ -40,7 +40,7 @@
<div class="navbar-brand">
<a class="navbar-item" href="/">
<figure class="image">
<img src="/static/img/logo_nobg.webp" alt="Reminder Bot Logo">
<img width="28px" height="28px" src="/static/img/logo_nobg.webp" alt="Reminder Bot Logo">
</figure>
</a>
@ -234,6 +234,7 @@
<a href="/">
<div class="brand">
<img src="/static/img/logo_nobg.webp" alt="Reminder bot logo"
width="52px" height="52px"
class="dashboard-brand">
</div>
</a>
@ -332,16 +333,16 @@
<p class="subtitle is-hidden-desktop">Press the <span class="icon"><i class="fal fa-bars"></i></span> to get started</p>
</div>
</section>
<section id="guild" class="is-hidden">
<section data-name="reminders" class="is-hidden">
{% include "reminder_dashboard/reminder_dashboard" %}
</section>
<section id="reminder-errors" class="is-hidden">
<section data-name="errors" class="is-hidden">
{% include "reminder_dashboard/reminder_errors" %}
</section>
<section id="guild-error" class="is-hidden">
<section data-name="guild-error" class="is-hidden">
{% include "reminder_dashboard/guild_error" %}
</section>
<section id="user-error" class="is-hidden">
<section data-name="user-error" class="is-hidden">
{% include "reminder_dashboard/user_error" %}
</section>
</div>
@ -375,14 +376,28 @@
<template id="guildListEntry">
<li>
<a class="switch-pane" data-pane="guild">
<a class="switch-pane" data-pane="reminders" data-slug="reminders">
<span class="icon"><i class="fas fa-map-pin"></i></span> <span class="guild-name">%guildname%</span>
</a>
<ul class="guild-submenu">
<li>
<a class="switch-pane" data-pane="reminders" data-slug="reminders">
<span class="icon"><i class="fas fa-calendar-alt"></i></span> Reminders
</a>
<a class="switch-pane" data-pane="errors" data-slug="errors">
<span class="icon"><i class="fas fa-file-alt"></i></span> Logs
</a>
</li>
</ul>
</li>
</template>
<template id="guildReminder">
{% include "reminder_dashboard/guild_reminder" %}
{% include "reminder_dashboard/templates/guild_reminder" %}
</template>
<template id="reminderError">
{% include "reminder_dashboard/templates/reminder_error" %}
</template>
<script src="/static/js/iro.js"></script>

View File

@ -2,7 +2,7 @@
<strong>Create Reminder</strong>
<div id="reminderCreator">
{% set creating = true %}
{% include "reminder_dashboard/guild_reminder" %}
{% include "reminder_dashboard/templates/guild_reminder" %}
{% set creating = false %}
</div>
<br>
@ -46,6 +46,10 @@
<div id="guildReminders">
</div>
<div id="guildErrors">
</div>
</div>
<script src="/static/js/sort.js"></script>

View File

@ -1,4 +1,4 @@
<div>
<div id="reminderLog">
</div>

View File

@ -133,32 +133,27 @@
</article>
</div>
<div class="column settings">
<div class="columns">
<div class="column">
<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 name="channel" class="channel-selector">
</select>
</div>
<div class="icon is-small is-left">
<i class="fas fa-hashtag"></i>
</div>
</div>
<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 name="channel" class="channel-selector">
</select>
</div>
<div class="icon is-small is-left">
<i class="fas fa-hashtag"></i>
</div>
</div>
<div class="column">
<div class="field">
<div class="control">
<label class="label collapses">
Time*
<input class="input prefill-now" type="datetime-local" step="1" name="time">
</label>
</div>
</div>
</div>
<div class="field">
<div class="control">
<label class="label collapses">
Time*
<input class="input prefill-now" type="datetime-local" step="1" name="time">
</label>
</div>
</div>
@ -236,40 +231,39 @@
</div>
</div>
</div>
{% if creating %}
<div class="button-row">
<div class="button-row-reminder">
<button class="button is-success" id="createReminder">
<span>Create Reminder</span> <span class="icon"><i class="fas fa-sparkles"></i></span>
</button>
</div>
<div class="button-row-template">
<div>
<button class="button is-success is-outlined" id="createTemplate">
<span>Create Template</span> <span class="icon"><i class="fas fa-file-spreadsheet"></i></span>
</button>
</div>
<div>
<button class="button is-outlined show-modal is-pulled-right" data-modal="chooseTemplateModal">
Load Template
</button>
</div>
</div>
</div>
{% else %}
<div class="button-row-edit">
<button class="button is-success save-btn">
<span>Save</span> <span class="icon"><i class="fas fa-save"></i></span>
</button>
<button class="button is-warning disable-enable">
</button>
<button class="button is-danger delete-reminder">
Delete
</button>
</div>
{% endif %}
</div>
</div>
</div>
{% if creating %}
<div class="button-row">
<div class="button-row-reminder">
<button class="button is-success" id="createReminder">
<span>Create Reminder</span> <span class="icon"><i class="fas fa-sparkles"></i></span>
</button>
</div>
<div class="button-row-template">
<div>
<button class="button is-success is-outlined" id="createTemplate">
<span>Create Template</span> <span class="icon"><i class="fas fa-file-spreadsheet"></i></span>
</button>
</div>
<div>
<button class="button is-outlined show-modal is-pulled-right" data-modal="chooseTemplateModal">
Load Template
</button>
</div>
</div>
</div>
{% else %}
<div class="button-row-edit">
<button class="button is-success save-btn">
<span>Save</span> <span class="icon"><i class="fas fa-save"></i></span>
</button>
<button class="button is-warning disable-enable">
</button>
<button class="button is-danger delete-reminder">
Delete
</button>
</div>
{% endif %}
</div>

View File

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