diff --git a/migrations/20220215214154_favicon.sql b/migrations/20220215214154_favicon.sql new file mode 100644 index 0000000..239d77f --- /dev/null +++ b/migrations/20220215214154_favicon.sql @@ -0,0 +1,3 @@ + +ALTER TABLE application ADD COLUMN favicon Boolean DEFAULT false; +ALTER TABLE bookmark ADD COLUMN favicon Boolean DEFAULT false; diff --git a/src/api/applications.rs b/src/api/applications.rs index 2031171..0da08f9 100644 --- a/src/api/applications.rs +++ b/src/api/applications.rs @@ -15,6 +15,7 @@ struct ApiApplication { pub application_category_id: Option, pub enable_healthcheck: bool, pub healthcheck_status: Option, + pub favicon: bool, } impl From for ApiApplication { @@ -29,6 +30,7 @@ impl From for ApiApplication { application_category_id: model.application_category_id, enable_healthcheck: model.enable_healthcheck, healthcheck_status: None, + favicon: model.favicon, } } } @@ -65,6 +67,7 @@ pub async fn new_application( glyph: Set(data.0.glyph), application_category_id: Set(data.0.application_category_id), enable_healthcheck: Set(data.0.enable_healthcheck), + favicon: Set(data.0.favicon), }; let app = model.insert(&state.db).await?; Ok(HttpResponse::Ok().json(app)) @@ -106,6 +109,7 @@ pub async fn update_applications( application_category_id: Set(data.application_category_id), glyph: Set(data.glyph), enable_healthcheck: Set(data.enable_healthcheck), + favicon: Set(data.favicon), }; let model = ret.update(&state.db).await?; Ok(HttpResponse::Ok().json(model)) @@ -210,6 +214,7 @@ mod tests { active: true, application_category_id: None, enable_healthcheck: false, + ..Default::default() }; let state = setup_state().await?; diff --git a/src/api/authorization.rs b/src/api/authorization.rs index dfd659a..879d0f1 100644 --- a/src/api/authorization.rs +++ b/src/api/authorization.rs @@ -49,7 +49,7 @@ pub struct UpdatePasswordRequest { } #[instrument] -#[post("password")] +#[put("password")] pub async fn update_password( state: web::Data, req: web::Json, diff --git a/src/entity/application.rs b/src/entity/application.rs index 84ac8f8..870eb93 100644 --- a/src/entity/application.rs +++ b/src/entity/application.rs @@ -15,6 +15,7 @@ pub struct Model { pub glyph: Option, pub application_category_id: Option, pub enable_healthcheck: bool, + pub favicon: bool, } #[derive(Copy, Clone, Debug, EnumIter)] @@ -52,6 +53,7 @@ impl Default for Model { glyph: Default::default(), application_category_id: Default::default(), enable_healthcheck: false, + favicon: false, } } } diff --git a/src/events.rs b/src/events.rs index 780fee9..df3a0f7 100644 --- a/src/events.rs +++ b/src/events.rs @@ -73,7 +73,6 @@ impl Handler for EventBroker { type Result = (); fn handle(&mut self, msg: Event, _ctx: &mut Self::Context) -> Self::Result { - tracing::info!("Event received"); for (_, ses) in self.sessions.iter() { let _ = ses.addr.do_send(msg.clone()); } diff --git a/src/main.rs b/src/main.rs index 98cb83e..e1085cb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,6 @@ use actix_web::{ web::{self, Data}, App, HttpResponse, HttpServer, }; -use clap::crate_version; use rust_embed::RustEmbed; use sea_orm::{prelude::*, Database}; use tokio::sync::Mutex; @@ -100,13 +99,21 @@ async fn main() { .await { Ok(res) if res.status() == 200 => { - st.healthcheck_status.lock().await.insert(app.id, true); - let _ = events::EventBroker::from_registry() - .send(events::Event::HealthcheckChange { - app_id: app.id, - alive: true, - }) - .await; + if !st + .healthcheck_status + .lock() + .await + .get(&app.id) + .unwrap_or(&false) + { + st.healthcheck_status.lock().await.insert(app.id, true); + let _ = events::EventBroker::from_registry() + .send(events::Event::HealthcheckChange { + app_id: app.id, + alive: true, + }) + .await; + } } Err(e) => { tracing::warn!("Error performing healthcheck: {}", e); @@ -119,14 +126,22 @@ async fn main() { .await; } Ok(res) => { - tracing::warn!("Non 200 status code: {}", res.status()); - st.healthcheck_status.lock().await.insert(app.id, false); - let _ = events::EventBroker::from_registry() - .send(events::Event::HealthcheckChange { - app_id: app.id, - alive: false, - }) - .await; + if *st + .healthcheck_status + .lock() + .await + .get(&app.id) + .unwrap_or(&true) + { + tracing::warn!("Non 200 status code: {}", res.status()); + st.healthcheck_status.lock().await.insert(app.id, false); + let _ = events::EventBroker::from_registry() + .send(events::Event::HealthcheckChange { + app_id: app.id, + alive: false, + }) + .await; + } } } } diff --git a/src/ui/components/ApplicationModal.vue b/src/ui/components/ApplicationModal.vue index 0e062f3..105f2df 100644 --- a/src/ui/components/ApplicationModal.vue +++ b/src/ui/components/ApplicationModal.vue @@ -12,7 +12,8 @@ - + + @@ -84,6 +85,7 @@ export default { let resp = await axios.post("/api/applications", { active: true, enableHealthcheck: !!this.app.enableHealthcheck, + favicon: !!this.app.favicon, ...this.app, }); if (resp.status == 200) { diff --git a/src/ui/components/ApplicationTile.vue b/src/ui/components/ApplicationTile.vue index 82cefc0..9e40740 100644 --- a/src/ui/components/ApplicationTile.vue +++ b/src/ui/components/ApplicationTile.vue @@ -1,7 +1,7 @@