From 06165c1b367221569aaf65f009153a91ef3c4c23 Mon Sep 17 00:00:00 2001 From: jude Date: Sun, 17 Sep 2023 18:03:57 +0100 Subject: [PATCH] Restyle to work on most screen sizes --- web/src/routes/dashboard/export.rs | 11 ++-- web/src/routes/dashboard/guild.rs | 4 +- web/src/routes/dashboard/mod.rs | 37 +++++++++++-- web/static/css/style.css | 54 +++++++++++-------- .../templates/guild_reminder.html.tera | 43 +++++++-------- 5 files changed, 89 insertions(+), 60 deletions(-) diff --git a/web/src/routes/dashboard/export.rs b/web/src/routes/dashboard/export.rs index f26a4aa..12a8188 100644 --- a/web/src/routes/dashboard/export.rs +++ b/web/src/routes/dashboard/export.rs @@ -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,11 +140,11 @@ pub async fn import_reminders( match channel_id.parse::() { Ok(channel_id) => { - let reminder = Reminder { + let reminder = ReminderCreate { attachment: record.attachment, attachment_name: record.attachment_name, avatar: record.avatar, - channel: Some(channel_id), + channel: channel_id, content: record.content, embed_author: record.embed_author, embed_author_url: record.embed_author_url, @@ -168,12 +167,8 @@ 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, - status: "pending".to_string(), - status_change_time: None, - status_message: None, }; create_reminder( diff --git a/web/src/routes/dashboard/guild.rs b/web/src/routes/dashboard/guild.rs index 023903a..6bb1f31 100644 --- a/web/src/routes/dashboard/guild.rs +++ b/web/src/routes/dashboard/guild.rs @@ -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//reminders", data = "")] pub async fn create_guild_reminder( id: u64, - reminder: Json, + reminder: Json, cookies: &CookieJar<'_>, serenity_context: &State, pool: &State>, diff --git a/web/src/routes/dashboard/mod.rs b/web/src/routes/dashboard/mod.rs index d72b52f..2ffe7af 100644 --- a/web/src/routes/dashboard/mod.rs +++ b/web/src/routes/dashboard/mod.rs @@ -118,6 +118,37 @@ pub struct EmbedField { inline: bool, } +#[derive(Deserialize)] +pub struct ReminderCreate { + #[serde(with = "base64s")] + attachment: Option>, + attachment_name: Option, + avatar: Option, + channel: u64, + content: String, + embed_author: String, + embed_author_url: Option, + embed_color: u32, + embed_description: String, + embed_footer: String, + embed_footer_url: Option, + embed_image_url: Option, + embed_thumbnail_url: Option, + embed_title: String, + embed_fields: Option>>, + enabled: bool, + expires: Option, + interval_seconds: Option, + interval_days: Option, + interval_months: Option, + #[serde(default = "name_default")] + name: String, + restartable: bool, + tts: bool, + username: Option, + utc_time: NaiveDateTime, +} + #[derive(Serialize, Deserialize)] pub struct Reminder { #[serde(with = "base64s")] @@ -383,7 +414,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) @@ -403,7 +434,7 @@ pub async fn create_reminder( } // validate channel - let channel = reminder.channel.map(|c| ChannelId(c).to_channel_cached(&ctx)).flatten(); + let channel = ChannelId(reminder.channel).to_channel_cached(&ctx); let channel_exists = channel.is_some(); let channel_matches_guild = @@ -418,7 +449,7 @@ pub async fn create_reminder( return Err(json!({"error": "Channel not found"})); } - let channel = create_database_channel(&ctx, ChannelId(reminder.channel.unwrap()), pool).await; + let channel = create_database_channel(&ctx, ChannelId(reminder.channel), pool).await; if let Err(e) = channel { warn!("`create_database_channel` returned an error code: {:?}", e); diff --git a/web/static/css/style.css b/web/static/css/style.css index 55fa8ee..63f80a8 100644 --- a/web/static/css/style.css +++ b/web/static/css/style.css @@ -129,6 +129,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; @@ -294,7 +300,7 @@ div.dashboard-sidebar:not(.mobile-sidebar) { ul.guildList { flex-grow: 1; flex-shrink: 1; - overflow: scroll; + overflow: auto; } div.dashboard-sidebar:not(.mobile-sidebar) .aside-footer { @@ -453,8 +459,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 { @@ -598,6 +603,14 @@ input.default-width { border-bottom: 1px solid #fff; } +.channel-selector { + width: 100%; +} + +.select { + width: 100%; +} + li.highlight { margin-bottom: 0 !important; } @@ -641,6 +654,21 @@ li.highlight { } } +@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-edit { display: flex; @@ -651,26 +679,6 @@ li.highlight { 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; - } } /* loader */ diff --git a/web/templates/reminder_dashboard/templates/guild_reminder.html.tera b/web/templates/reminder_dashboard/templates/guild_reminder.html.tera index ac510fe..2b8844c 100644 --- a/web/templates/reminder_dashboard/templates/guild_reminder.html.tera +++ b/web/templates/reminder_dashboard/templates/guild_reminder.html.tera @@ -133,32 +133,27 @@
-
-
-
-
- -
-
-
- -
-
- -
-
+
+
+ +
+
+
+ +
+
+
-
-
-
- -
-
+
+ +
+
+