Skip to content

Commit

Permalink
version bumps
Browse files Browse the repository at this point in the history
  • Loading branch information
ddboline committed Apr 28, 2024
1 parent aaed866 commit 89e5515
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 88 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "diary_app_rust"
version = "0.10.8"
version = "0.10.9"
authors = ["Daniel Boline <[email protected]>"]
edition = "2018"

Expand All @@ -22,7 +22,7 @@ diary_app_bot = {path="diary_app_bot"}
dirs = "5.0"
env_logger = {version="0.11", features=["color", "humantime", "regex"], default_features = false}
time = {version="0.3", features=["serde-human-readable", "macros", "formatting"]}
tokio = {version="1.35", features=["rt", "macros", "rt-multi-thread"]}
tokio = {version="1.37", features=["rt", "macros", "rt-multi-thread"]}

[workspace]
members = [
Expand Down
25 changes: 13 additions & 12 deletions diary_app_api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "diary_app_api"
version = "0.10.8"
version = "0.10.9"
authors = ["Daniel Boline <[email protected]>"]
edition = "2018"

Expand All @@ -9,34 +9,35 @@ edition = "2018"
[dependencies]
anyhow = "1.0"
async-trait = "0.1"
authorized_users = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.12"}
authorized_users = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.13"}
aws-config = {version="1.1", features=["behavior-version-latest"]}
diary_app_lib = {path = "../diary_app_lib"}
dioxus = "0.4"
dioxus-ssr = "0.4"
dioxus = "0.5"
dioxus-core = "0.5"
dioxus-ssr = "0.5"
derive_more = "0.99"
futures = "0.3"
handlebars = "5.1"
itertools = "0.12"
log = "0.4"
maplit = "1.0"
parking_lot = "0.12"
postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.6", features=["deadpool"]}
rweb = {git = "https://github.com/ddboline/rweb.git", features=["openapi"], default-features=false, tag="0.15.1-1"}
rweb-helper = { git = "https://github.com/ddboline/rweb_helper.git", tag="0.5.1" }
postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.7", features=["deadpool"]}
rweb = {git = "https://github.com/ddboline/rweb.git", features=["openapi"], default-features=false, tag="0.15.2"}
rweb-helper = { git = "https://github.com/ddboline/rweb_helper.git", tag="0.5.3" }
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
serde_yaml = "0.9"
stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types", "rweb-openapi"], tag="0.9.2" }
stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types", "rweb-openapi"], tag="0.9.3" }
thiserror = "1.0"
time = {version="0.3", features=["serde-human-readable", "macros", "formatting"]}
time-tz = {version="2.0", features=["system"]}
tokio = {version="1.36", features=["time"]}
tokio = {version="1.37", features=["time"]}
uuid = "1.0"

[dev-dependencies]
auth_server_http = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.12"}
auth_server_lib = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.12"}
auth_server_http = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.13"}
auth_server_lib = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.13"}
env_logger = {version="0.11", features=["color", "humantime", "regex"], default_features = false}
reqwest = {version="0.11", features=["cookies", "json", "rustls-tls", "stream"]}
reqwest = {version="0.12", features=["cookies", "json", "rustls-tls", "stream"]}
150 changes: 95 additions & 55 deletions diary_app_api/src/elements.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use dioxus::prelude::{
component, dioxus_elements, rsx, Element, GlobalAttributes, IntoDynNode, Props, Scope,
VirtualDom,
component, dioxus_elements, rsx, Element, GlobalAttributes, IntoDynNode, Props, VirtualDom,
};
use rweb_helper::DateType;
use stack_string::StackString;
Expand All @@ -10,15 +9,24 @@ use time_tz::OffsetDateTimeExt;

use diary_app_lib::{date_time_wrapper::DateTimeWrapper, models::DiaryConflict};

pub fn index_body() -> String {
use crate::errors::ServiceError as Error;

/// # Errors
/// Returns error if formatting fails
pub fn index_body() -> Result<String, Error> {
let mut app = VirtualDom::new(IndexElement);
drop(app.rebuild());
dioxus_ssr::render(&app)
app.rebuild_in_place();
let mut renderer = dioxus_ssr::Renderer::default();
let mut buffer = String::new();
renderer
.render_to(&mut buffer, &app)
.map_err(Into::<Error>::into)?;
Ok(buffer)
}

#[component]
fn IndexElement(cx: Scope) -> Element {
cx.render(rsx! {
fn IndexElement() -> Element {
rsx! {
head {
style {
dangerous_inner_html: include_str!("../../templates/style.css")
Expand Down Expand Up @@ -79,14 +87,16 @@ fn IndexElement(cx: Scope) -> Element {
dangerous_inner_html: include_str!("../../templates/scripts.js")
}
}
})
}
}

/// # Errors
/// Returns error if formatting fails
pub fn list_body(
conflicts: HashSet<DateType>,
dates: Vec<DateType>,
start: Option<usize>,
) -> String {
) -> Result<String, Error> {
let mut app = VirtualDom::new_with_props(
DateListElement,
DateListElementProps {
Expand All @@ -95,13 +105,17 @@ pub fn list_body(
start,
},
);
drop(app.rebuild());
dioxus_ssr::render(&app)
app.rebuild_in_place();
let mut renderer = dioxus_ssr::Renderer::default();
let mut buffer = String::new();
renderer
.render_to(&mut buffer, &app)
.map_err(Into::<Error>::into)?;
Ok(buffer)
}

#[component]
fn DateListElement(
cx: Scope,
conflicts: HashSet<DateType>,
dates: Vec<DateType>,
start: Option<usize>,
Expand All @@ -128,8 +142,8 @@ fn DateListElement(
}
}
};
cx.render(rsx! {
dates.iter().enumerate().map(|(idx, t)| {
rsx! {
{dates.iter().enumerate().map(|(idx, t)| {
let d: Date = (*t).into();
let c = if conflicts.contains(t) {
Some(rsx! {
Expand All @@ -151,37 +165,43 @@ fn DateListElement(
name: "{d}",
value: "{d}",
"onclick": "switchToDate( '{d}' )",
c
{c}
},
br {},
}
}
})
buttons,
})
})},
{buttons},
}
}

pub fn list_conflicts_body(date: Option<DateType>, conflicts: Vec<DateTimeWrapper>) -> String {
/// # Errors
/// Returns error if formatting fails
pub fn list_conflicts_body(
date: Option<DateType>,
conflicts: Vec<DateTimeWrapper>,
) -> Result<String, Error> {
let mut app = VirtualDom::new_with_props(
ListConflictsElement,
ListConflictsElementProps { date, conflicts },
);
drop(app.rebuild());
dioxus_ssr::render(&app)
app.rebuild_in_place();
let mut renderer = dioxus_ssr::Renderer::default();
let mut buffer = String::new();
renderer
.render_to(&mut buffer, &app)
.map_err(Into::<Error>::into)?;
Ok(buffer)
}

#[component]
fn ListConflictsElement(
cx: Scope,
date: Option<DateType>,
conflicts: Vec<DateTimeWrapper>,
) -> Element {
fn ListConflictsElement(date: Option<DateType>, conflicts: Vec<DateTimeWrapper>) -> Element {
let local = DateTimeWrapper::local_tz();
let clean_conflicts = if let Some(date) = date {
if conflicts.is_empty() {
None
} else {
let date: Date = (*date).into();
let date: Date = (date).into();
Some(rsx! {
button {
"type": "submit",
Expand All @@ -193,8 +213,8 @@ fn ListConflictsElement(
} else {
None
};
cx.render(rsx! {
conflicts.iter().enumerate().map(|(idx, t)| {
rsx! {
{conflicts.iter().enumerate().map(|(idx, t)| {
let d: Date = date.unwrap_or_else(|| OffsetDateTime::now_utc().to_timezone(local).date().into()).into();
rsx! {
input {
Expand All @@ -205,28 +225,35 @@ fn ListConflictsElement(
"onclick": "showConflict( '{d}', '{t}' )",
}
}
}),
})},
br {
clean_conflicts,
{clean_conflicts},
button {
"type": "submit",
"onclick": "switchToList()",
"List",
},
},
})
}
}

pub fn search_body(results: Vec<StackString>) -> String {
/// # Errors
/// Returns error if formatting fails
pub fn search_body(results: Vec<StackString>) -> Result<String, Error> {
let mut app = VirtualDom::new_with_props(SearchElement, SearchElementProps { results });
drop(app.rebuild());
dioxus_ssr::render(&app)
app.rebuild_in_place();
let mut renderer = dioxus_ssr::Renderer::default();
let mut buffer = String::new();
renderer
.render_to(&mut buffer, &app)
.map_err(Into::<Error>::into)?;
Ok(buffer)
}

#[component]
fn SearchElement(cx: Scope, results: Vec<StackString>) -> Element {
fn SearchElement(results: Vec<StackString>) -> Element {
let body = results.join("\n");
cx.render(rsx! {
rsx! {
textarea {
"autofocus": "true",
readonly: "readonly",
Expand All @@ -236,10 +263,12 @@ fn SearchElement(cx: Scope, results: Vec<StackString>) -> Element {
"cols": "100",
"{body}",
}
})
}
}

pub fn edit_body(date: Date, text: Vec<StackString>, edit_button: bool) -> String {
/// # Errors
/// Returns error if formatting fails
pub fn edit_body(date: Date, text: Vec<StackString>, edit_button: bool) -> Result<String, Error> {
let mut app = VirtualDom::new_with_props(
EditElement,
EditElementProps {
Expand All @@ -248,14 +277,19 @@ pub fn edit_body(date: Date, text: Vec<StackString>, edit_button: bool) -> Strin
edit_button,
},
);
drop(app.rebuild());
dioxus_ssr::render(&app)
app.rebuild_in_place();
let mut renderer = dioxus_ssr::Renderer::default();
let mut buffer = String::new();
renderer
.render_to(&mut buffer, &app)
.map_err(Into::<Error>::into)?;
Ok(buffer)
}

#[component]
fn EditElement(cx: Scope, date: Date, text: Vec<StackString>, edit_button: bool) -> Element {
fn EditElement(date: Date, text: Vec<StackString>, edit_button: bool) -> Element {
let text = text.join("\n");
let buttons = if *edit_button {
let buttons = if edit_button {
rsx! {
input {
"type": "button",
Expand Down Expand Up @@ -283,7 +317,7 @@ fn EditElement(cx: Scope, date: Date, text: Vec<StackString>, edit_button: bool)
}
}
};
let textarea = if *edit_button {
let textarea = if edit_button {
rsx! {
textarea {
name: "message",
Expand All @@ -307,19 +341,21 @@ fn EditElement(cx: Scope, date: Date, text: Vec<StackString>, edit_button: bool)
}
}
};
cx.render(rsx! {
textarea,
rsx! {
{textarea},
br {
buttons
{buttons}
}
})
}
}

/// # Errors
/// Returns error if formatting fails
pub fn show_conflict_body(
date: Date,
conflicts: Vec<DiaryConflict>,
datetime: DateTimeWrapper,
) -> String {
) -> Result<String, Error> {
let mut app = VirtualDom::new_with_props(
ShowConflictElement,
ShowConflictElementProps {
Expand All @@ -328,13 +364,17 @@ pub fn show_conflict_body(
datetime,
},
);
drop(app.rebuild());
dioxus_ssr::render(&app)
app.rebuild_in_place();
let mut renderer = dioxus_ssr::Renderer::default();
let mut buffer = String::new();
renderer
.render_to(&mut buffer, &app)
.map_err(Into::<Error>::into)?;
Ok(buffer)
}

#[component]
fn ShowConflictElement(
cx: Scope,
date: Date,
conflicts: Vec<DiaryConflict>,
datetime: DateTimeWrapper,
Expand Down Expand Up @@ -411,9 +451,9 @@ fn ShowConflictElement(
"[year]-[month]-[day]T[hour]:[minute]:[second].[subsecond]Z"
))
.unwrap_or_else(|_| String::new());
cx.render(rsx! {
rsx! {
div {
conflict_text.into_iter(),
{conflict_text.into_iter()},
}
input {
"type": "button",
Expand All @@ -439,5 +479,5 @@ fn ShowConflictElement(
value: "Edit",
"onclick": "switchToEditor('{date}')",
},
})
}
}
Loading

0 comments on commit 89e5515

Please sign in to comment.