Restyle to work on most screen sizes

This commit is contained in:
jude 2023-09-17 18:03:57 +01:00
parent 5ee9094bac
commit 06165c1b36
5 changed files with 89 additions and 60 deletions

View File

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

View File

@ -26,7 +26,7 @@ use crate::{
routes::{ routes::{
dashboard::{ dashboard::{
create_database_channel, create_reminder, template_name_default, DeleteReminder, create_database_channel, create_reminder, template_name_default, DeleteReminder,
DeleteReminderTemplate, PatchReminder, Reminder, ReminderTemplate, DeleteReminderTemplate, PatchReminder, Reminder, ReminderCreate, ReminderTemplate,
}, },
JsonResult, JsonResult,
}, },
@ -298,7 +298,7 @@ pub async fn delete_reminder_template(
#[post("/api/guild/<id>/reminders", data = "<reminder>")] #[post("/api/guild/<id>/reminders", data = "<reminder>")]
pub async fn create_guild_reminder( pub async fn create_guild_reminder(
id: u64, id: u64,
reminder: Json<Reminder>, reminder: Json<ReminderCreate>,
cookies: &CookieJar<'_>, cookies: &CookieJar<'_>,
serenity_context: &State<Context>, serenity_context: &State<Context>,
pool: &State<Pool<MySql>>, pool: &State<Pool<MySql>>,

View File

@ -118,6 +118,37 @@ pub struct EmbedField {
inline: bool, inline: bool,
} }
#[derive(Deserialize)]
pub struct ReminderCreate {
#[serde(with = "base64s")]
attachment: Option<Vec<u8>>,
attachment_name: Option<String>,
avatar: Option<String>,
channel: 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,
username: Option<String>,
utc_time: NaiveDateTime,
}
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct Reminder { pub struct Reminder {
#[serde(with = "base64s")] #[serde(with = "base64s")]
@ -383,7 +414,7 @@ pub async fn create_reminder(
pool: impl sqlx::Executor<'_, Database = Database> + Copy, pool: impl sqlx::Executor<'_, Database = Database> + Copy,
guild_id: GuildId, guild_id: GuildId,
user_id: UserId, user_id: UserId,
reminder: Reminder, reminder: ReminderCreate,
) -> JsonResult { ) -> JsonResult {
// check guild in db // check guild in db
match sqlx::query!("SELECT 1 as A FROM guilds WHERE guild = ?", guild_id.0) 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 // 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_exists = channel.is_some();
let channel_matches_guild = let channel_matches_guild =
@ -418,7 +449,7 @@ pub async fn create_reminder(
return Err(json!({"error": "Channel not found"})); 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 { if let Err(e) = channel {
warn!("`create_database_channel` returned an error code: {:?}", e); warn!("`create_database_channel` returned an error code: {:?}", e);

View File

@ -129,6 +129,12 @@ div.split-controls {
margin-top: 0 !important; margin-top: 0 !important;
} }
.reminder-settings > .column {
flex-grow: 0;
flex-shrink: 0;
flex-basis: 50%;
}
div.reminderContent { div.reminderContent {
margin-top: 10px; margin-top: 10px;
margin-bottom: 10px; margin-bottom: 10px;
@ -294,7 +300,7 @@ div.dashboard-sidebar:not(.mobile-sidebar) {
ul.guildList { ul.guildList {
flex-grow: 1; flex-grow: 1;
flex-shrink: 1; flex-shrink: 1;
overflow: scroll; overflow: auto;
} }
div.dashboard-sidebar:not(.mobile-sidebar) .aside-footer { div.dashboard-sidebar:not(.mobile-sidebar) .aside-footer {
@ -453,8 +459,7 @@ input.default-width {
.customizable.is-400x300 img { .customizable.is-400x300 img {
margin-top: 10px; margin-top: 10px;
width: 100%; width: 100%;
min-height: 100px; height: 100px;
max-height: 400px;
} }
.customizable.is-32x32 img { .customizable.is-32x32 img {
@ -598,6 +603,14 @@ input.default-width {
border-bottom: 1px solid #fff; border-bottom: 1px solid #fff;
} }
.channel-selector {
width: 100%;
}
.select {
width: 100%;
}
li.highlight { li.highlight {
margin-bottom: 0 !important; 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) { @media only screen and (max-width: 768px) {
.button-row-edit { .button-row-edit {
display: flex; display: flex;
@ -651,26 +679,6 @@ li.highlight {
width: 100%; width: 100%;
margin: 4px; 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 */ /* loader */

View File

@ -133,8 +133,6 @@
</article> </article>
</div> </div>
<div class="column settings"> <div class="column settings">
<div class="columns">
<div class="column">
<div class="field channel-field"> <div class="field channel-field">
<div class="collapses"> <div class="collapses">
<label class="label" for="channelOption">Channel*</label> <label class="label" for="channelOption">Channel*</label>
@ -149,8 +147,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="column">
<div class="field"> <div class="field">
<div class="control"> <div class="control">
<label class="label collapses"> <label class="label collapses">
@ -159,8 +156,6 @@
</label> </label>
</div> </div>
</div> </div>
</div>
</div>
<div class="collapses split-controls"> <div class="collapses split-controls">
<div> <div>