From a37fb19d7fe1817997be3fd96722557457075b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Wo=C5=BAniak?= Date: Wed, 10 Jun 2020 22:11:51 +0200 Subject: [PATCH] Optimize and reorganize code --- jirs-client/jirs.nginx | 6 +++--- jirs-client/js/template.html | 8 ++++---- jirs-client/src/profile/mod.rs | 6 +++--- jirs-client/src/project/mod.rs | 6 +++--- jirs-client/src/project_settings/mod.rs | 6 +++--- jirs-client/src/project_settings/update.rs | 11 +++++++---- jirs-client/src/shared/styled_rte.rs | 3 ++- jirs-client/static/index.js | 4 ++-- jirs-client/tests/wasm.rs | 1 + jirs-css/src/prop/color.rs | 2 +- jirs-css/tests/a.css | 5 +++-- jirs-server/src/db/messages.rs | 2 +- jirs-server/src/db/user_projects.rs | 2 +- jirs-server/src/ws/auth.rs | 2 +- 14 files changed, 35 insertions(+), 29 deletions(-) diff --git a/jirs-client/jirs.nginx b/jirs-client/jirs.nginx index 8a6c243b..f6c75596 100644 --- a/jirs-client/jirs.nginx +++ b/jirs-client/jirs.nginx @@ -9,9 +9,9 @@ server { ssl_certificate /home/eraden/code/eraden/jirs/jirs-client/js/nginx-selfsigned.crt; ssl_certificate_key /home/eraden/code/eraden/jirs/jirs-client/js/nginx-selfsigned.key; -# if ($scheme != "https") { -# return 301 https://$host$request_uri; -# } + # if ($scheme != "https") { + # return 301 https://$host$request_uri; + # } location ~ .wasm { default_type application/wasm; diff --git a/jirs-client/js/template.html b/jirs-client/js/template.html index 997a8359..baa452b6 100644 --- a/jirs-client/js/template.html +++ b/jirs-client/js/template.html @@ -2,14 +2,14 @@ - - + + JIRS - +
- + diff --git a/jirs-client/src/profile/mod.rs b/jirs-client/src/profile/mod.rs index 3234ddf1..ba284010 100644 --- a/jirs-client/src/profile/mod.rs +++ b/jirs-client/src/profile/mod.rs @@ -1,5 +1,5 @@ -mod update; -mod view; - pub use update::update; pub use view::view; + +mod update; +mod view; diff --git a/jirs-client/src/project/mod.rs b/jirs-client/src/project/mod.rs index 5c871390..d42c7ecd 100644 --- a/jirs-client/src/project/mod.rs +++ b/jirs-client/src/project/mod.rs @@ -1,5 +1,5 @@ -mod update; -mod view; - pub use update::*; pub use view::*; + +mod update; +mod view; diff --git a/jirs-client/src/project_settings/mod.rs b/jirs-client/src/project_settings/mod.rs index 3234ddf1..ba284010 100644 --- a/jirs-client/src/project_settings/mod.rs +++ b/jirs-client/src/project_settings/mod.rs @@ -1,5 +1,5 @@ -mod update; -mod view; - pub use update::update; pub use view::view; + +mod update; +mod view; diff --git a/jirs-client/src/project_settings/update.rs b/jirs-client/src/project_settings/update.rs index 0a9609f6..459249cb 100644 --- a/jirs-client/src/project_settings/update.rs +++ b/jirs-client/src/project_settings/update.rs @@ -1,12 +1,15 @@ +use std::collections::HashSet; + +use seed::error; +use seed::prelude::Orders; + +use jirs_data::{IssueStatus, IssueStatusId, ProjectFieldId, UpdateProjectPayload, WsMsg}; + use crate::model::{Model, Page, PageContent, ProjectSettingsPage}; use crate::shared::styled_select::StyledSelectChange; use crate::ws::{enqueue_ws_msg, send_ws_msg}; use crate::FieldChange::TabChanged; use crate::{FieldId, Msg, PageChanged, ProjectPageChange, WebSocketChanged}; -use jirs_data::{IssueStatus, IssueStatusId, ProjectFieldId, UpdateProjectPayload, WsMsg}; -use seed::error; -use seed::prelude::Orders; -use std::collections::HashSet; pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders) { if model.page != Page::ProjectSettings { diff --git a/jirs-client/src/shared/styled_rte.rs b/jirs-client/src/shared/styled_rte.rs index 0c99b3a7..308fc1c4 100644 --- a/jirs-client/src/shared/styled_rte.rs +++ b/jirs-client/src/shared/styled_rte.rs @@ -1,9 +1,10 @@ +use seed::{prelude::*, *}; + use crate::shared::styled_button::StyledButton; use crate::shared::styled_icon::{Icon, StyledIcon}; use crate::shared::styled_tooltip::StyledTooltip; use crate::shared::ToNode; use crate::{FieldId, Msg}; -use seed::{prelude::*, *}; #[derive(Debug, Clone, Copy)] pub enum HeadingSize { diff --git a/jirs-client/static/index.js b/jirs-client/static/index.js index c81041f9..a077f6bd 100644 --- a/jirs-client/static/index.js +++ b/jirs-client/static/index.js @@ -1,10 +1,10 @@ const getWsHostName = () => process.env.JIRS_SERVER_BIND === "0.0.0.0" ? 'localhost' : process.env.JIRS_SERVER_BIND; const getProtocol = () => window.location.protocol.replace(/^http/, 'ws'); -const wsUrl = () => `${ getProtocol() }//${ getWsHostName() }:${ process.env.JIRS_SERVER_PORT }/ws/`; +const wsUrl = () => `${getProtocol()}//${getWsHostName()}:${process.env.JIRS_SERVER_PORT}/ws/`; import("/jirs.js").then(async module => { window.module = module; await module.default(); - const host_url = `${ location.protocol }//${ process.env.JIRS_SERVER_BIND }:${ process.env.JIRS_SERVER_PORT }`; + const host_url = `${location.protocol}//${process.env.JIRS_SERVER_BIND}:${process.env.JIRS_SERVER_PORT}`; module.render(host_url, wsUrl()); }); diff --git a/jirs-client/tests/wasm.rs b/jirs-client/tests/wasm.rs index ed4effad..728cc040 100644 --- a/jirs-client/tests/wasm.rs +++ b/jirs-client/tests/wasm.rs @@ -1,4 +1,5 @@ extern crate wasm_bindgen_test; + use wasm_bindgen_test::*; use jirs_client::validations::*; diff --git a/jirs-css/src/prop/color.rs b/jirs-css/src/prop/color.rs index 841339a3..0285fd4a 100644 --- a/jirs-css/src/prop/color.rs +++ b/jirs-css/src/prop/color.rs @@ -139,7 +139,7 @@ impl ParseToken for CssParser { let a = self.parse_token()?; match a { PropertyValue::Other(f) if -0.001f64 > f || f > 1.001f64 => { - return Err(format!("out of range hsl alpha value {:?}", a)) + return Err(format!("out of range hsl alpha value {:?}", a)); } _ => (), }; diff --git a/jirs-css/tests/a.css b/jirs-css/tests/a.css index e1166aba..142e2ff8 100644 --- a/jirs-css/tests/a.css +++ b/jirs-css/tests/a.css @@ -1,4 +1,5 @@ -.foo {} +.foo { +} .bar { } @@ -10,7 +11,7 @@ .baz { display: block; - justify-content : space-between; + justify-content: space-between; color: red; background-color: #42413d; } diff --git a/jirs-server/src/db/messages.rs b/jirs-server/src/db/messages.rs index c662bf20..0c701886 100644 --- a/jirs-server/src/db/messages.rs +++ b/jirs-server/src/db/messages.rs @@ -123,7 +123,7 @@ impl Handler for DbExecutor { _ => { return Err(ServiceErrors::RecordNotFound( "No matching user found".to_string(), - )) + )); } }; diff --git a/jirs-server/src/db/user_projects.rs b/jirs-server/src/db/user_projects.rs index d6f25135..0f018d4e 100644 --- a/jirs-server/src/db/user_projects.rs +++ b/jirs-server/src/db/user_projects.rs @@ -1,4 +1,5 @@ use actix::{Handler, Message}; +use diesel::connection::TransactionManager; use diesel::pg::Pg; use diesel::prelude::*; @@ -6,7 +7,6 @@ use jirs_data::{ProjectId, UserId, UserProject, UserProjectId, UserRole}; use crate::db::DbExecutor; use crate::errors::ServiceErrors; -use diesel::connection::TransactionManager; pub struct CurrentUserProject { pub user_id: UserId, diff --git a/jirs-server/src/ws/auth.rs b/jirs-server/src/ws/auth.rs index 79a6e1da..7f90e2c8 100644 --- a/jirs-server/src/ws/auth.rs +++ b/jirs-server/src/ws/auth.rs @@ -73,7 +73,7 @@ impl WsHandler for WebSocketActor { Ok(Err(_)) => { return Ok(Some(WsMsg::AuthorizeLoaded(Err( "Invalid auth token".to_string() - )))) + )))); } _ => return Ok(Some(WsMsg::AuthorizeExpired)), };