Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

synch dev #573

Merged
merged 5 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ updates:
time: "05:30"
open-pull-requests-limit: 50
- package-ecosystem: cargo
directory: "/loremaster-frontend"
directory: "/loremaster-web-interface"
schedule:
interval: daily
time: "05:30"
Expand Down
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/loremaster.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
{
"cSpell.words": [
"bindgen",
"chrono",
"Combobox",
"cose",
"ctap",
"fidokey",
"gloo",
"Hasher",
"listbox",
"openapi",
"reqwasm",
"Rustls",
"webauthn"
"webauthn",
"YUBIKEY"
],
"editor.insertSpaces": false,
"editor.tabSize": 2,
"git.enableCommitSigning": true,
"yaml.schemas": {
"openapi:v3": "file:///home/naes/github/loremaster/documentation/openapi/chronicle/openapi%3A%20%273.0.2%27.yml"
}
},
"rust-analyzer.linkedProjects": [
"./loremaster-web-interface/Cargo.toml",
"./loremaster-web-server/Cargo.toml"
]
}
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
members = ["loremaster-database", "loremaster-web-server"]
default-members = ["loremaster-database", "loremaster-web-server"]
members = ["loremaster", "loremaster-database", "loremaster-web-server"]
default-members = ["loremaster", "loremaster-database", "loremaster-web-server"]
exclude = ["loremaster-web-interface"]
resolver = "2"
File renamed without changes.
7 changes: 7 additions & 0 deletions database/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Loremaster Database

Docker compose command

```sh
docker-compose -f docker-compose.yml up
```
File renamed without changes.
13 changes: 11 additions & 2 deletions loremaster-database/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion loremaster-database/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ edition = "2021"
anyhow = "1.0.75"
# Provides async programming foundational functionality
futures = "0.3.28"
loremaster = { path = "../loremaster" }
# Database client/pool/toolkit
sqlx = { version = "0.6.3", features = [
"json",
Expand All @@ -25,4 +26,4 @@ sqlx = { version = "0.6.3", features = [
# Error/exception handling
thiserror = "1.0.49"
# Backend async I/O functionality
tokio = { version = "1.32.0", features = ["full"] }
tokio = { version = "1.33.0", features = ["full"] }
37 changes: 36 additions & 1 deletion loremaster-database/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,43 @@
use anyhow::Result;
use loremaster::data::postgres_handler::PostgresHandler;
use sqlx::PgPool;

const CONNECTION_STRING_ENVIRONMENT_VARIABLE_KEY: &str = "POSTGRES_CONNECTION_STRING";
const DATABASE_FOLDER_PATH: &str = "../database/";

#[tokio::main]
async fn main() -> Result<()> {
println!("Hello, world!");
println!("Starting up...");

let postgres_connection_string: String =
std::env::var(CONNECTION_STRING_ENVIRONMENT_VARIABLE_KEY)
.expect("Missing postgresql connection string.");

if postgres_connection_string.is_empty() {
panic!("Postgresql connection string is empty!");
}

if !std::path::Path::new(DATABASE_FOLDER_PATH).exists() {
panic!("Database folder path does not exist!");
}

let postgres_handler: PostgresHandler =
PostgresHandler::new(postgres_connection_string).await?;

ping(&postgres_handler.database_pool).await?;

Ok(())
}

pub async fn ping(database_pool: &PgPool) -> Result<()> {
const PING_QUERY: &str = "SELECT 1;";

let rows_affected: u64 = sqlx::query(PING_QUERY)
.execute(database_pool)
.await?
.rows_affected();

println!("{}", rows_affected);

Ok(())
}
29 changes: 16 additions & 13 deletions loremaster-web-interface/src/components/combobox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,29 @@ pub fn ComboBox<'combobox, G: Html>(
});

view! {context,
div(class=classes) {
label() { (label) }
input(type="text", bind:value=query) {}
label() { (label) }
div(class=format!("{} combobox", classes)) {
input(type="text", bind:value=query, class="combobox-input") {}
input(type="hidden", value=(match selected.get().as_ref() {
Some(option) => option.to_string(),
None => String::new(),
}), name=selected_html_input_name)
select() {
ul(class="combobox-options ", role="listbox", aria-label=label) {
Keyed(
iterable=filtered_options,
view= move |context, option| view! { context,
option(
class=COMBOBOX_OPTION_CSS_CLASSES,
value=option.id.to_string(),
title=option.description,
on:click=move |event: Event| {
view= move |context, option| {
let display_text = option.display_text.clone();
view! { context,
li(
class=COMBOBOX_OPTION_CSS_CLASSES,
value=option.id.to_string(),
title=option.description
) { button(on:click=move |event: Event| {
event.prevent_default();
selected.set(Some(option.id))
}
) { (option.display_text) }
selected.set(Some(option.id));
query.set(display_text.to_owned());
}) { (option.display_text) } }
}
},
key=|option| option.id
)
Expand Down
15 changes: 13 additions & 2 deletions loremaster-web-interface/src/components/container.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use sycamore::prelude::*;
use perseus::reactor::Reactor;
use sycamore::{futures::spawn_local_scoped, prelude::*};

use crate::components::navigation::{side_nav_bar::SideNavBar, top_nav_bar::TopNavBar};
use crate::{
components::navigation::{side_nav_bar::SideNavBar, top_nav_bar::TopNavBar},
global_state::ApplicationStateRx,
};

#[derive(Prop)]
pub struct ContainerProperties<'a, G: Html> {
Expand All @@ -13,7 +17,14 @@ pub fn Container<'a, G: Html>(
context: Scope<'a>,
ContainerProperties { title, children }: ContainerProperties<'a, G>,
) -> View<G> {
let user_authentication =
Reactor::<G>::from_cx(context).get_global_state::<ApplicationStateRx>(context);
let children: View<G> = children.call(context);
if G::IS_BROWSER {
spawn_local_scoped(context, async {
user_authentication.authentication.detect_state().await;
});
}
view! {context,
div(class="glass container") {
TopNavBar()
Expand Down
14 changes: 13 additions & 1 deletion loremaster-web-interface/src/components/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ pub const CLOSE_X_SVG_HTML: SvgIcon = r#"
</svg>
"#;

pub const PASSWORD_SVH_HTML: SvgIcon = r#"
pub const PASSWORD_SVG_HTML: SvgIcon = r#"
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="none" />
<line x1="40" y1="56" x2="40" y2="200" fill="none" stroke="currentColor" stroke-linecap="round"
Expand All @@ -295,3 +295,15 @@ pub const PASSWORD_SVH_HTML: SvgIcon = r#"
stroke-linecap="round" stroke-linejoin="round" stroke-width="16" />
</svg>
"#;

pub const LAYOUT_SVG_HTML: SvgIcon = r#"
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<rect width="256" height="256" fill="none" />
<line x1="104" y1="104" x2="104" y2="208" fill="none" stroke="currentColor" stroke-linecap="round"
stroke-linejoin="round" stroke-width="16" />
<line x1="32" y1="104" x2="224" y2="104" fill="none" stroke="currentColor" stroke-linecap="round"
stroke-linejoin="round" stroke-width="16" />
<rect x="32" y="48" width="192" height="160" rx="8" fill="none" stroke="currentColor"
stroke-linecap="round" stroke-linejoin="round" stroke-width="16" />
</svg>
"#;
24 changes: 20 additions & 4 deletions loremaster-web-interface/src/components/modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct ModalProperties<'modal, G: Html> {
pub children: Children<'modal, G>,
pub button_label: &'static str,
pub modal_type: &'modal ReadSignal<ModalType>,
pub close_on_click_outside: &'modal ReadSignal<bool>,
}

#[component]
Expand All @@ -28,6 +29,7 @@ pub fn Modal<'modal, G: Html>(
html_class,
button_label,
modal_type,
close_on_click_outside,
}: ModalProperties<'modal, G>,
) -> View<G> {
let children = children.call(context);
Expand All @@ -41,6 +43,17 @@ pub fn Modal<'modal, G: Html>(
close_dialog(&dialog_id.to_string());
};

let on_modal_click_handler = move |event: Event| {
if !*close_on_click_outside.get() {
return;
}
if let Some(html_element) = event.target() {
if html_element.dyn_ref::<HtmlDialogElement>().is_some() {
close_dialog(&dialog_id.to_string())
}
}
};

view! {context,
button(on:click=open_click_handler, class=html_class) { (button_label) }
dialog(
Expand All @@ -49,11 +62,14 @@ pub fn Modal<'modal, G: Html>(
ModalType::Default => "modal",
ModalType::SidePanelRight => "modal-side-panel-right",
ModalType::SidePanelLeft => "modal-side-panel-left",
})
}),
on:click=on_modal_click_handler
) {
button(title="close",on:click=close_click_handler, class="modal-close", dangerously_set_inner_html=CLOSE_X_SVG_HTML) { }
div() {
(children)
div(class="modal-container") {
button(title="close",on:click=close_click_handler, class="modal-close", dangerously_set_inner_html=CLOSE_X_SVG_HTML) { }
div() {
(children)
}
}
}
}
Expand Down
Loading