Optimize and reorganize code

This commit is contained in:
Adrian Woźniak 2020-06-10 22:11:51 +02:00
parent 2c173669d3
commit a37fb19d7f
14 changed files with 35 additions and 29 deletions

View File

@ -9,9 +9,9 @@ server {
ssl_certificate /home/eraden/code/eraden/jirs/jirs-client/js/nginx-selfsigned.crt; 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; ssl_certificate_key /home/eraden/code/eraden/jirs/jirs-client/js/nginx-selfsigned.key;
# if ($scheme != "https") { # if ($scheme != "https") {
# return 301 https://$host$request_uri; # return 301 https://$host$request_uri;
# } # }
location ~ .wasm { location ~ .wasm {
default_type application/wasm; default_type application/wasm;

View File

@ -2,14 +2,14 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta content="width=device-width, initial-scale=1.0" name="viewport">
<link rel="icon" href="/favicon.png"> <link href="/favicon.png" rel="icon">
<link href="/logo2.svg" rel="icon"> <link href="/logo2.svg" rel="icon">
<title>JIRS</title> <title>JIRS</title>
<link rel="stylesheet" type="text/css" href="/styles.css"> <link href="/styles.css" rel="stylesheet" type="text/css">
</head> </head>
<body> <body>
<main id="app"></main> <main id="app"></main>
<script type="module" src="/index.js"></script> <script src="/index.js" type="module"></script>
</body> </body>
</html> </html>

View File

@ -1,5 +1,5 @@
mod update;
mod view;
pub use update::update; pub use update::update;
pub use view::view; pub use view::view;
mod update;
mod view;

View File

@ -1,5 +1,5 @@
mod update;
mod view;
pub use update::*; pub use update::*;
pub use view::*; pub use view::*;
mod update;
mod view;

View File

@ -1,5 +1,5 @@
mod update;
mod view;
pub use update::update; pub use update::update;
pub use view::view; pub use view::view;
mod update;
mod view;

View File

@ -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::model::{Model, Page, PageContent, ProjectSettingsPage};
use crate::shared::styled_select::StyledSelectChange; use crate::shared::styled_select::StyledSelectChange;
use crate::ws::{enqueue_ws_msg, send_ws_msg}; use crate::ws::{enqueue_ws_msg, send_ws_msg};
use crate::FieldChange::TabChanged; use crate::FieldChange::TabChanged;
use crate::{FieldId, Msg, PageChanged, ProjectPageChange, WebSocketChanged}; 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<Msg>) { pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
if model.page != Page::ProjectSettings { if model.page != Page::ProjectSettings {

View File

@ -1,9 +1,10 @@
use seed::{prelude::*, *};
use crate::shared::styled_button::StyledButton; use crate::shared::styled_button::StyledButton;
use crate::shared::styled_icon::{Icon, StyledIcon}; use crate::shared::styled_icon::{Icon, StyledIcon};
use crate::shared::styled_tooltip::StyledTooltip; use crate::shared::styled_tooltip::StyledTooltip;
use crate::shared::ToNode; use crate::shared::ToNode;
use crate::{FieldId, Msg}; use crate::{FieldId, Msg};
use seed::{prelude::*, *};
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub enum HeadingSize { pub enum HeadingSize {

View File

@ -1,10 +1,10 @@
const getWsHostName = () => process.env.JIRS_SERVER_BIND === "0.0.0.0" ? 'localhost' : process.env.JIRS_SERVER_BIND; 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 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 => { import("/jirs.js").then(async module => {
window.module = module; window.module = module;
await module.default(); 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()); module.render(host_url, wsUrl());
}); });

View File

@ -1,4 +1,5 @@
extern crate wasm_bindgen_test; extern crate wasm_bindgen_test;
use wasm_bindgen_test::*; use wasm_bindgen_test::*;
use jirs_client::validations::*; use jirs_client::validations::*;

View File

@ -139,7 +139,7 @@ impl ParseToken<ColorProperty> for CssParser {
let a = self.parse_token()?; let a = self.parse_token()?;
match a { match a {
PropertyValue::Other(f) if -0.001f64 > f || f > 1.001f64 => { 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));
} }
_ => (), _ => (),
}; };

View File

@ -1,4 +1,5 @@
.foo {} .foo {
}
.bar { .bar {
} }
@ -10,7 +11,7 @@
.baz { .baz {
display: block; display: block;
justify-content : space-between; justify-content: space-between;
color: red; color: red;
background-color: #42413d; background-color: #42413d;
} }

View File

@ -123,7 +123,7 @@ impl Handler<CreateMessage> for DbExecutor {
_ => { _ => {
return Err(ServiceErrors::RecordNotFound( return Err(ServiceErrors::RecordNotFound(
"No matching user found".to_string(), "No matching user found".to_string(),
)) ));
} }
}; };

View File

@ -1,4 +1,5 @@
use actix::{Handler, Message}; use actix::{Handler, Message};
use diesel::connection::TransactionManager;
use diesel::pg::Pg; use diesel::pg::Pg;
use diesel::prelude::*; use diesel::prelude::*;
@ -6,7 +7,6 @@ use jirs_data::{ProjectId, UserId, UserProject, UserProjectId, UserRole};
use crate::db::DbExecutor; use crate::db::DbExecutor;
use crate::errors::ServiceErrors; use crate::errors::ServiceErrors;
use diesel::connection::TransactionManager;
pub struct CurrentUserProject { pub struct CurrentUserProject {
pub user_id: UserId, pub user_id: UserId,

View File

@ -73,7 +73,7 @@ impl WsHandler<CheckAuthToken> for WebSocketActor {
Ok(Err(_)) => { Ok(Err(_)) => {
return Ok(Some(WsMsg::AuthorizeLoaded(Err( return Ok(Some(WsMsg::AuthorizeLoaded(Err(
"Invalid auth token".to_string() "Invalid auth token".to_string()
)))) ))));
} }
_ => return Ok(Some(WsMsg::AuthorizeExpired)), _ => return Ok(Some(WsMsg::AuthorizeExpired)),
}; };