diff --git a/backend/src/api/endpoints/websocket_api.rs b/backend/src/api/endpoints/websocket_api.rs index ae966a2f1..128d44219 100644 --- a/backend/src/api/endpoints/websocket_api.rs +++ b/backend/src/api/endpoints/websocket_api.rs @@ -8,7 +8,7 @@ use axum::{ response::IntoResponse, }; use log::{error, info}; -use shared::model::{ProtocolHandler, ProtocolHandlerMemory, ProtocolMessage, WsCloseCode, PROTOCOL_VERSION}; +use shared::model::{ProtocolHandler, ProtocolHandlerMemory, ProtocolMessage, UserRole, WsCloseCode, PROTOCOL_VERSION}; use std::sync::Arc; // WebSocket upgrade handler @@ -114,11 +114,11 @@ async fn handle_protocol_message( Ok(ProtocolMessage::Auth(auth_token)) => { mem.token = None; if verify_auth_admin_token(&auth_token, secret_key) { - mem.admin = true; + mem.role = UserRole::Admin; mem.token = Some(auth_token); Some(ProtocolMessage::Authorized) } else if verify_auth_user_token(&auth_token, secret_key) { - mem.admin = false; + mem.role = UserRole::User; mem.token = Some(auth_token); Some(ProtocolMessage::Authorized) } else { @@ -127,7 +127,7 @@ async fn handle_protocol_message( }, Ok(ProtocolMessage::StatusRequest(auth_token)) => { if !auth || verify_auth_admin_token(&auth_token, secret_key) { - mem.admin = true; + mem.role = UserRole::Admin; mem.token = Some(auth_token); let status = create_status_check(app_state).await; Some(ProtocolMessage::StatusResponse(status)) @@ -192,7 +192,7 @@ async fn handle_event_message(socket: &mut WebSocket, event: EventMessage, handl match handler { ProtocolHandler::Version(_) => {}, ProtocolHandler::Default(mem) => { - if mem.admin { + if mem.role.is_admin() { match event { EventMessage::ActiveUserChange(users, connections) => { let msg = ProtocolMessage::ActiveUserResponse(users, connections) diff --git a/backend/src/model/config/app.rs b/backend/src/model/config/app.rs index 833a1d43f..56d33ce78 100644 --- a/backend/src/model/config/app.rs +++ b/backend/src/model/config/app.rs @@ -326,7 +326,7 @@ impl AppConfig { } match utils::read_file_as_bytes(&PathBuf::from(&file_path)) { - Ok(data) => Some(TransportStreamBuffer::new(data, )), + Ok(data) => Some(TransportStreamBuffer::new(data)), Err(err) => { error!("Failed to load a resource file: {} {err}", file_path.display()); None diff --git a/backend/src/model/config/base.rs b/backend/src/model/config/base.rs index 273cd9d81..c2c472715 100644 --- a/backend/src/model/config/base.rs +++ b/backend/src/model/config/base.rs @@ -122,7 +122,7 @@ macros::from_impl!(Config); impl From<&ConfigDto> for Config { fn from(dto: &ConfigDto) -> Self { Config { - threads: 0, + threads: dto.threads, api: ConfigApi::from(&dto.api), working_dir: dto.working_dir.to_string(), backup_dir: dto.backup_dir.clone(), diff --git a/backend/src/model/config/input.rs b/backend/src/model/config/input.rs index 75cbe552e..22478576f 100644 --- a/backend/src/model/config/input.rs +++ b/backend/src/model/config/input.rs @@ -150,7 +150,7 @@ impl ConfigInput { let mut aliases: Vec = batch_aliases.into_iter() .map(ConfigInputAlias::from) .collect(); - if let Some(mut first) = aliases.pop() { + if let Some(mut first) = aliases.remove(0) { self.username = first.username.take(); self.password = first.password.take(); self.url = first.url.trim().to_string(); @@ -222,9 +222,6 @@ pub fn get_batch_aliases(input_type: InputType, url: &str) -> Result { - if !batch_aliases.is_empty() { - batch_aliases.reverse(); - } Ok(Some((file_path, batch_aliases))) } Err(err) => { diff --git a/shared/src/model/config/input.rs b/shared/src/model/config/input.rs index 0d27f4b4b..09da6d2f0 100644 --- a/shared/src/model/config/input.rs +++ b/shared/src/model/config/input.rs @@ -14,7 +14,6 @@ macro_rules! apply_batch_aliases { ($target:expr, $batch_aliases:expr) => {{ if !$batch_aliases.is_empty() { if !$batch_aliases.is_empty() { - $batch_aliases.reverse(); if let Some(aliases) = $target.aliases.as_mut() { aliases.extend($batch_aliases); } else { diff --git a/shared/src/model/web_socket.rs b/shared/src/model/web_socket.rs index ccc88c0e4..22c70385f 100644 --- a/shared/src/model/web_socket.rs +++ b/shared/src/model/web_socket.rs @@ -5,18 +5,27 @@ use serde::{Deserialize, Serialize}; pub const PROTOCOL_VERSION: u8 = 1; -pub struct ProtocolHandlerMemory { - pub token: Option, - pub admin: bool, +#[derive(Default)] +pub enum UserRole { + #[default] + Unauthorized, + Admin, + User, } -impl Default for ProtocolHandlerMemory { - fn default() -> Self { - Self { - token: None, - admin: false, - } +impl UserRole { + pub fn is_admin(&self) -> bool { + self.eq(&UserRole::Admin) } + pub fn is_user(&self) -> bool { + self.eq(&UserRole::User) + } +} + +#[derive(Default)] +pub struct ProtocolHandlerMemory { + pub token: Option, + pub role: UserRole, } pub enum ProtocolHandler { diff --git a/webui/public/assets/icons.json b/webui/public/assets/icons.json index 9e1bbfa6c..c0e3cf103 100644 --- a/webui/public/assets/icons.json +++ b/webui/public/assets/icons.json @@ -384,5 +384,10 @@ { "keys": ["Stats"], "path": "m 14.852111,10.994975 h 7.14787 C 21.528804,6.2512562 17.759381,2.4723619 13.027548,2 v 7.1658292 c 0.852132,0.3115584 1.513786,0.9748738 1.824563,1.8291458 m 0.18047,-6.4522612 c 2.005014,0.8241205 3.609023,2.4321605 4.431077,4.4422109 H 16.025046 C 15.744341,8.6130655 15.40349,8.2713567 15.032562,7.9899498 Z M 2,12 c 0,5.21608 3.9598995,9.497487 9.022557,10 V 14.834171 C 9.8596486,14.41206 9.0175433,13.306533 9.0175433,12 c 0,-1.306533 0.8421053,-2.4120603 2.0050137,-2.8341708 V 2 C 5.9598995,2.5025127 2,6.7839197 2,12 M 9.0175433,4.5427138 V 7.9999999 C 7.7844623,8.9246232 7.0125293,10.40201 7.0125293,12 c 0,1.59799 0.771933,3.075377 2.005014,4.01005 v 3.457287 C 6.0501232,18.271357 4.0050102,15.366834 4.0050102,12 c 0,-3.3668343 2.045113,-6.2713567 5.0125331,-7.4572862 M 13.027567,14.834171 V 22 C 17.7594,21.527638 21.528823,17.748744 22,13.005025 h -7.14787 c -0.310774,0.854272 -0.972432,1.517588 -1.824563,1.829146 m 2.005014,1.175879 c 0.370944,-0.281406 0.711779,-0.613065 0.992484,-0.994975 h 3.438593 c -0.822054,2.010051 -2.426063,3.618091 -4.431077,4.442211 z" + }, + { + "keys": ["AppTitle"], + "path": "m 29.887057,23.96271 c -0.309617,-0.03458 -0.587239,-0.102226 -0.61694,-0.150315 -0.0297,-0.04809 -0.01305,-0.185134 0.03702,-0.304538 0.05007,-0.119402 0.476231,-1.113172 0.947032,-2.208375 0.470802,-1.095206 1.128686,-2.631337 1.461965,-3.413623 0.333281,-0.78229 0.78433,-1.819759 1.002332,-2.305492 0.218002,-0.485728 0.38646,-0.893058 0.374351,-0.905176 -0.01211,-0.01212 -0.138841,0.131262 -0.281626,0.318625 -0.584838,0.767417 -1.477913,1.549838 -2.158316,1.890902 -0.946065,0.474226 -2.053647,0.02815 -2.293121,-0.92354 -0.109298,-0.434364 -0.09593,-1.098314 0.02926,-1.453384 0.16738,-0.474728 0.130347,-0.472976 -0.226576,0.01073 -0.456739,0.618979 -1.382489,1.520422 -1.978855,1.926894 -0.628645,0.428471 -1.177379,0.622591 -1.759951,0.622591 -1.218833,0 -1.934639,-0.707273 -2.032051,-2.007823 l -0.04336,-0.578945 -0.185697,0.279965 c -0.271897,0.409928 -1.062214,1.242256 -1.50178,1.581612 -0.884165,0.682596 -1.557084,0.865563 -2.264633,0.615751 -0.404112,-0.142676 -0.656245,-0.391786 -0.847995,-0.837824 -0.130791,-0.304243 -0.150469,-0.456606 -0.124041,-0.960457 l 0.03141,-0.598848 -0.147249,0.202282 c -0.619793,0.851428 -1.679698,1.791491 -2.396186,2.12526 -0.942509,0.439053 -1.987108,0.07131 -2.297411,-0.808784 -0.259501,-0.73601 -0.07643,-1.583613 0.815805,-3.777037 1.510973,-3.7145167 1.856717,-4.4621281 2.130766,-4.6074113 0.198437,-0.105202 1.68835,-0.05833 1.805075,0.05678 0.03761,0.037101 -0.290209,0.7739645 -0.796896,1.7912241 -1.995592,4.0064832 -2.55621,5.9239012 -1.828985,6.2554772 0.308763,0.140778 0.749849,-0.09319 1.476745,-0.783336 1.218309,-1.156698 1.911542,-2.268117 2.845356,-4.561785 0.68333,-1.6784107 1.049736,-2.4668112 1.221481,-2.6282683 0.09183,-0.08633 0.296034,-0.1742821 0.453793,-0.1954581 0.343357,-0.04609 1.292239,0.03436 1.433138,0.1215011 0.08028,0.04965 -0.03535,0.3406282 -0.584581,1.4709559 -2.289721,4.7123474 -2.781953,6.5659854 -1.743266,6.5647894 0.417024,-5.38e-4 1.141092,-0.553964 1.873694,-1.432259 0.594623,-0.71288 0.942965,-1.304039 1.230229,-2.087775 C 23.91296,9.6321839 25.576639,6.1028589 27.204501,3.2357201 28.157913,1.5564841 28.901923,0.69284161 29.766632,0.26160635 30.223588,0.03372122 30.356796,-9.5796693e-5 30.797122,2.0336393e-7 31.645423,2.1420349e-4 32.023773,0.29544037 32.098005,1.0151708 c 0.119773,1.1613087 -0.770754,3.2059259 -2.589974,5.9464675 -1.309187,1.9722102 -2.714991,3.6652247 -3.992473,4.8081377 -0.688928,0.616358 -0.720878,0.658131 -0.863045,1.128333 -0.367222,1.214562 -0.433685,2.231608 -0.171954,2.631332 0.0677,0.1034 0.240354,0.221815 0.387918,0.266056 0.727267,0.218045 1.916475,-0.556523 3.133208,-2.040756 0.857178,-1.045625 1.28117,-1.801342 2.981668,-5.3144758 0.166935,-0.3448792 0.379157,-0.6766464 0.4716,-0.7372604 0.127012,-0.08328 0.34208,-0.1074681 0.880262,-0.09901 0.801521,0.01261 0.921979,0.04038 0.921979,0.2126202 0,0.06647 -0.523102,1.1591416 -1.162449,2.428152 -1.79432,3.561459 -2.253626,4.921337 -1.819648,5.387479 0.324069,0.348085 0.892248,0.121047 1.725783,-0.689605 1.299079,-1.263417 2.304534,-2.907808 3.244563,-5.3063829 0.711861,-1.8163802 0.714512,-1.8216512 0.970398,-1.9286392 0.268695,-0.1123461 1.564101,-0.1347201 1.729768,-0.02988 0.141997,0.08986 0.03497,0.3805463 -0.508254,1.3804059 -0.447556,0.823774 -0.515066,1.0565862 -0.137148,0.4729588 0.433175,-0.6689655 1.257769,-1.4716389 1.771684,-1.7245891 0.433471,-0.2133561 0.528782,-0.2326551 1.148909,-0.2326551 0.625512,0 0.7054,0.01656 1.065209,0.2207802 1.537499,0.8726665 1.269271,3.0718644 -0.745677,6.1138384 -0.894735,1.350781 -1.811328,2.215617 -2.846886,2.686126 -0.466045,0.211753 -0.536899,0.223362 -1.344784,0.220322 -0.960805,-0.0036 -1.197448,-0.07481 -1.670656,-0.502621 l -0.281659,-0.254637 -0.07632,0.202918 c -0.07748,0.205986 -0.858186,2.131688 -2.143752,5.28779 -0.823722,2.022255 -0.956154,2.323685 -1.045049,2.378665 -0.130859,0.08093 -0.69425,0.09707 -1.244167,0.03564 z m 7.195976,-8.459117 c 1.067968,-0.505581 2.163826,-1.975676 2.955026,-3.964179 0.455631,-1.145121 0.556339,-2.0641711 0.283944,-2.5912835 -0.241064,-0.4664913 -0.732521,-0.5441283 -1.254462,-0.1981701 -0.766557,0.5080923 -2.250195,2.3498386 -3.091477,3.8376706 -0.326462,0.577354 -1.013237,2.184307 -1.013237,2.370823 0,0.180744 0.367539,0.570796 0.639614,0.678792 0.375691,0.149125 1.002853,0.09251 1.480592,-0.133653 z M 25.690178,10.738584 c 1.962214,-2.1233597 3.868618,-4.8927474 5.010681,-7.2788907 0.799637,-1.670708 0.925941,-2.53527255 0.370378,-2.53527255 -0.75856,0 -3.426917,4.40056465 -5.347319,8.81862225 -0.274196,0.630816 -0.56033,1.274916 -0.635848,1.431326 -0.07552,0.156414 -0.111415,0.274362 -0.07977,0.262108 0.03165,-0.01226 0.338491,-0.326306 0.681876,-0.697893 z M 2.2656814,19.142265 C 1.3810681,18.911182 0.62931455,18.316779 0.22696953,17.530272 0.09366123,17.269681 0.03624163,17.027443 0.01203508,16.623528 c -0.03593428,-0.59962 0.0096134,-0.704242 0.12307983,-0.282624 0.103504,0.384645 0.69096298,1.013026 1.16352929,1.24458 1.0720346,0.525284 2.2564855,0.426913 3.4915253,-0.289986 C 5.3506687,16.97015 6.475331,15.835265 6.9537153,15.11229 7.4385728,14.379531 8.3254692,12.561819 9.5908747,9.707385 11.533784,5.3246813 12.181216,4.1455026 13.304276,2.944123 13.540239,2.6917008 13.712342,2.4642016 13.686725,2.4385666 13.601793,2.3535766 11.382573,1.9300333 10.390249,1.8094272 9.1921935,1.6638172 7.2177103,1.7009082 6.3934067,1.8845073 4.9877683,2.1975865 3.8352867,2.9455599 3.1608669,3.9824586 2.665249,4.744454 2.5283575,5.1831132 2.5283575,6.0092968 c 0,0.9426516 0.1716489,1.4003108 0.7376035,1.9666551 0.4322918,0.4325912 0.8834718,0.6291184 1.4442907,0.6291184 H 4.9912118 L 4.8085796,8.7488274 C 4.2875813,9.1589266 3.4695067,9.2157516 2.7807328,8.8896805 1.4318074,8.2510971 0.74013531,6.6133032 1.0988026,4.9070861 1.3140353,3.8831995 1.8111009,3.022913 2.6460036,2.2292905 4.3498438,0.60969456 6.8311135,-0.02877882 10.195554,0.28666337 c 1.751541,0.1642201 2.74004,0.3377812 6.822549,1.19790963 2.927643,0.6168124 4.722846,0.6993765 6.339667,0.2915732 0.779613,-0.196639 1.6479,-0.6420393 2.088134,-1.07113458 0.340445,-0.3318342 0.363019,-0.34303221 0.318069,-0.1577831 C 25.618085,1.1484519 24.613777,2.2726876 23.783015,2.7647328 22.844754,3.3204512 21.783182,3.5681573 20.358311,3.5638533 18.864048,3.5593502 18.284567,3.4750432 16.277271,2.97021 L 15.110027,2.6766478 14.866212,2.956188 c -0.857994,0.9837076 -2.104109,3.438254 -3.734312,7.355694 -0.885615,2.128165 -1.4993943,3.503623 -1.8709331,4.19268 -1.1877279,2.202762 -2.9114421,3.942651 -4.43788,4.47952 -0.8570464,0.301435 -1.7884747,0.359048 -2.5574055,0.158183 z M 56.372127,16.981213 c -0.08795,-0.04244 -0.159905,-0.09992 -0.159905,-0.127723 0,-0.0278 0.426014,-0.478952 0.946698,-1.002554 0.961418,-0.966802 1.721093,-1.872897 2.378644,-2.837102 l 0.364083,-0.533877 -0.116139,-0.675113 c -0.06388,-0.371313 -0.124944,-0.686935 -0.135708,-0.701376 -0.01077,-0.01443 -0.268934,0.174805 -0.573714,0.420559 -0.719983,0.580538 -1.195225,0.882292 -1.743801,1.107221 -0.244703,0.100331 -0.491886,0.206427 -0.549298,0.235765 -0.05741,0.02934 -0.265284,0.33174 -0.461943,0.672002 -0.818599,1.416356 -1.814403,2.509747 -2.702812,2.967681 -0.696762,0.359148 -1.047409,0.43758 -1.82244,0.407637 -0.534215,-0.02064 -0.743963,-0.06261 -1.066863,-0.213458 -0.72599,-0.339176 -1.184615,-0.957028 -1.364145,-1.837753 l -0.08977,-0.440366 -0.206199,0.27365 c -0.622757,0.826467 -1.597288,1.673803 -2.316827,2.014435 -0.970814,0.459584 -1.986674,0.160954 -2.306914,-0.67816 -0.165683,-0.434138 -0.104371,-1.301276 0.145536,-2.058268 0.345408,-1.046282 1.183942,-2.671253 2.12742,-4.122675 0.253501,-0.3899802 0.451596,-0.7183764 0.44021,-0.7297704 -0.01139,-0.0114 -0.273514,0.01459 -0.582505,0.05775 -0.308992,0.04316 -0.712008,0.05865 -0.895594,0.03443 l -0.333786,-0.04404 -0.58429,0.9798094 c -0.607854,1.019322 -1.042445,1.897437 -1.372667,2.773569 l -0.193603,0.513651 -0.173034,-0.113453 c -0.228449,-0.149789 -0.279578,-0.387167 -0.179324,-0.832554 0.102981,-0.4575 0.663037,-1.632545 1.16681,-2.448059 0.210701,-0.341085 0.43779,-0.7262093 0.504643,-0.8558304 l 0.121551,-0.23567 -0.25291,-0.2801342 C 44.146055,8.4083991 44.130627,8.3618691 44.130627,7.9087639 c 0,-1.0859377 0.786468,-1.7544701 1.49969,-1.2748027 0.336413,0.226254 0.412723,0.5622832 0.258497,1.1382937 -0.140115,0.5232932 -0.120005,0.5461542 0.48046,0.5462073 0.541573,4.89e-5 1.214615,-0.1580312 1.682076,-0.3950733 0.429049,-0.2175661 0.612882,-0.1737931 0.840745,0.2001921 0.283305,0.4649773 0.214512,0.6505574 -0.803714,2.168224 -1.519107,2.264232 -2.427118,4.735612 -1.938444,5.275964 0.19902,0.220064 0.630697,0.197222 1.072155,-0.05673 0.417049,-0.239913 1.541325,-1.379548 1.906925,-1.932976 0.140222,-0.212263 0.353751,-0.689961 0.474505,-1.061545 0.399431,-1.229125 1.084025,-2.304943 2.126997,-3.3425074 1.141378,-1.1354586 1.981432,-1.5702088 3.131408,-1.6205849 1.162365,-0.05092 1.861817,0.3092041 2.28947,1.1787737 0.228168,0.4639462 0.2334,0.4956473 0.231212,1.4005526 -0.0016,0.678357 -0.03601,1.037222 -0.128576,1.342431 -0.06948,0.229113 -0.11045,0.432462 -0.09104,0.45189 0.01942,0.01943 0.268062,-0.08802 0.552551,-0.238773 0.351385,-0.186204 0.727598,-0.479345 1.173204,-0.914155 l 0.655953,-0.640054 -0.04198,-0.8679253 c -0.03564,-0.7367624 -0.02414,-0.8951496 0.07597,-1.0480636 0.148066,-0.2261312 0.532554,-0.4237392 1.046956,-0.5380823 0.329752,-0.0733 0.433428,-0.07146 0.60408,0.01072 0.194395,0.09363 0.205694,0.123194 0.200507,0.5245483 -0.003,0.2339331 -0.0315,0.8095125 -0.06329,1.2790637 -0.05624,0.8309052 -0.0024,1.9625612 0.09262,1.9483152 0.02597,-0.0039 0.251903,-0.235913 0.502046,-0.5156 0.250146,-0.279685 1.004793,-1.0685679 1.676993,-1.7530694 1.462193,-1.4889488 1.872825,-1.749177 2.294149,-1.4538688 0.104385,0.07316 0.15795,0.1841071 0.15795,0.3271402 0,0.2479571 -0.09453,0.3489792 -1.210812,1.2938777 -1.236108,1.0463343 -3.266486,3.0283983 -3.266486,3.1887563 0,0.219602 0.395223,1.350981 0.646773,1.85147 0.311984,0.620733 0.584126,0.943715 0.940708,1.116453 0.526938,0.255264 1.000052,0.162851 1.733412,-0.338583 0.459168,-0.313957 1.430317,-1.291901 1.794438,-1.806995 0.13129,-0.185728 0.25069,-0.3257 0.265332,-0.311048 0.05322,0.05326 -0.261612,0.779096 -0.544907,1.256274 -0.656782,1.106291 -1.532435,1.977112 -2.419437,2.406078 -0.487366,0.235699 -0.584741,0.257492 -1.137091,0.254506 -0.480911,-0.0027 -0.665227,-0.0353 -0.903982,-0.160368 -0.698081,-0.365682 -1.341068,-1.347666 -1.662372,-2.538815 -0.08441,-0.312918 -0.165458,-0.61241 -0.180113,-0.665545 -0.01467,-0.05313 -0.268027,0.24843 -0.563051,0.670138 -0.933833,1.334817 -1.918278,2.424253 -2.429834,2.68897 -0.253477,0.131169 -0.546605,0.141963 -0.781156,0.02876 z m -3.165268,-1.452942 c 0.529605,-0.250031 1.127411,-0.931336 1.532073,-1.746068 0.463861,-0.933916 0.468758,-0.898022 -0.155293,-1.138261 -0.653823,-0.2517 -1.356709,-0.745791 -1.633353,-1.148155 -0.115342,-0.167759 -0.270573,-0.49259 -0.344958,-0.721849 l -0.135242,-0.416836 -0.43075,0.848576 c -0.588496,1.159339 -0.887998,2.053054 -0.927856,2.768735 -0.05637,1.012078 0.211496,1.534371 0.874573,1.705291 0.436119,0.112415 0.742403,0.07442 1.220806,-0.151433 z m 2.331172,-3.95406 C 55.600221,11.36886 55.696952,10.858837 55.753,10.440828 55.861338,9.6328309 55.8211,9.1594077 55.609256,8.7494584 55.469093,8.4782252 55.301465,8.3917182 54.916048,8.3917182 c -1.314579,0 -1.834882,2.1605198 -0.745104,3.0939738 0.3004,0.257304 0.741539,0.44695 1.061337,0.456269 0.17217,0.005 0.204724,-0.03414 0.30575,-0.36775 z M 32.773791,6.427741 C 32.44799,6.2614679 32.310502,5.9653808 32.348146,5.5111055 32.41546,4.698886 33.193965,4.2025287 33.922689,4.5072179 c 0.726277,0.3036671 0.742951,1.3168467 0.03036,1.845028 -0.26294,0.1948971 -0.869247,0.2337102 -1.179261,0.0755 z", + "viewport": "0 0 67 24" } ] \ No newline at end of file diff --git a/webui/public/config.json b/webui/public/config.json index c863c56cd..138d5b0b7 100644 --- a/webui/public/config.json +++ b/webui/public/config.json @@ -1,6 +1,5 @@ { "tabTitle": "tuliprox", - "appTitle": "tuliprox", "appLogo": "/assets/tuliprox-logo.svg", "api": { "apiUrl": "/api/v1/", diff --git a/webui/scss/app/_app_header.scss b/webui/scss/app/_app_header.scss index 66c3e8cce..e0197e812 100644 --- a/webui/scss/app/_app_header.scss +++ b/webui/scss/app/_app_header.scss @@ -13,6 +13,9 @@ width: 2.5rem; height: 2.5rem; } + .icon-AppTitle { + width: 100px !important; + } &-toolbar { display: flex; align-items: center; diff --git a/webui/scss/app/_component.scss b/webui/scss/app/_component.scss index 416d9747f..4b4e60e19 100644 --- a/webui/scss/app/_component.scss +++ b/webui/scss/app/_component.scss @@ -19,7 +19,8 @@ @forward "components/dashboard/stats_view"; @forward "components/list_view"; @forward "components/userlist/userlist_view"; -@forward "components/playlist/playlist_view"; +@forward "components/playlist/playlist_editor_view"; +@forward "components/playlist/playlist_explorer_view"; @forward "components/playlist/assistant/playlist_assistant"; @forward "components/reveal_content"; @forward "components/hide_content"; diff --git a/webui/scss/app/components/playlist/_playlist_view.scss b/webui/scss/app/components/playlist/_playlist_editor_view.scss similarity index 94% rename from webui/scss/app/components/playlist/_playlist_view.scss rename to webui/scss/app/components/playlist/_playlist_editor_view.scss index ee2474eca..4816c1901 100644 --- a/webui/scss/app/components/playlist/_playlist_view.scss +++ b/webui/scss/app/components/playlist/_playlist_editor_view.scss @@ -1,5 +1,5 @@ -.tp__playlist-create, -.tp__playlist-list { +.tp__playlist-editor-create, +.tp__playlist-editor-list { &__body { diff --git a/webui/scss/app/components/playlist/_playlist_explorer_view.scss b/webui/scss/app/components/playlist/_playlist_explorer_view.scss new file mode 100644 index 000000000..4816c1901 --- /dev/null +++ b/webui/scss/app/components/playlist/_playlist_explorer_view.scss @@ -0,0 +1,46 @@ +.tp__playlist-editor-create, +.tp__playlist-editor-list { + + &__body { + + > :nth-child(even) { + border-left: 2px solid var(--output-xtream-color); + } + + > :nth-child(odd) { + border-left: 2px solid var(--output-hdhomerun-color); + } + } + + &__source { + display: flex; + flex-flow: column; + border-top: 1px solid var(--border-color); + border-bottom: 1px solid var(--border-color); + border-right: 1px solid var(--border-color); + box-sizing: border-box; + border-top-right-radius: var(--border-radius); + border-bottom-right-radius: var(--border-radius); + padding: var(--padding-mini); + gap: var(--gap-default); + + .svg-icon { + width: 1.2rem; + min-width: 1.2rem; + min-height: 1.2rem; + } + &-label, + &-inputs > .tp__collapse-panel__header > .tp__collapse-panel__header-title { + display: flex; + flex-flow: row; + align-items: center; + gap: var(--gap-default); + font-size: 1.2rem; + } + &-label { + color: var(--modest-text-color); + fill: var(--modest-text-color); + + } + } +} \ No newline at end of file diff --git a/webui/scss/main.scss b/webui/scss/main.scss index 27cd39f4f..b6a662f4a 100644 --- a/webui/scss/main.scss +++ b/webui/scss/main.scss @@ -34,4 +34,3 @@ body { max-width: 100%; background-color: inherit; } - diff --git a/webui/src/app/components/home.rs b/webui/src/app/components/home.rs index 014afb45c..f16acf324 100644 --- a/webui/src/app/components/home.rs +++ b/webui/src/app/components/home.rs @@ -1,18 +1,17 @@ +use crate::app::components::{AppIcon, DashboardView, IconButton, InputRow, Panel, PlaylistEditorView, PlaylistExplorerView, Sidebar, StatsView, UserlistView}; +use crate::app::context::{ConfigContext, PlaylistContext, StatusContext}; +use crate::hooks::{use_server_status, use_service_context}; +use crate::model::ViewType; +use crate::services::WsMessage; +use shared::model::{AppConfigDto, StatusCheck}; use std::future; use std::rc::Rc; use yew::prelude::*; use yew::suspense::use_future; -use shared::model::{AppConfigDto, StatusCheck}; -use crate::app::components::{IconButton, Sidebar, DashboardView, PlaylistView, Panel, UserlistView, StatsView}; -use crate::app::context::{ConfigContext, StatusContext}; -use crate::model::ViewType; -use crate::hooks::{use_server_status, use_service_context}; -use crate::services::WsMessage; #[function_component] pub fn Home() -> Html { let services = use_service_context(); - let app_title = services.config.ui_config.app_title.as_ref().map_or("tuliprox", |v| v.as_str()); let config = use_state(|| None::>); let status = use_state(|| None::>); @@ -65,6 +64,32 @@ pub fn Home() -> Html { }); } + let sources = use_memo(config.clone(), |config_ctx| { + if let Some(cfg) = config_ctx.as_ref() { + let mut sources = vec![]; + for source in &cfg.sources.sources { + let mut inputs = vec![]; + for input_cfg in &source.inputs { + let input = Rc::new(input_cfg.clone()); + inputs.push(Rc::new(InputRow::Input(Rc::clone(&input)))); + if let Some(aliases) = input_cfg.aliases.as_ref() { + for alias in aliases { + inputs.push(Rc::new(InputRow::Alias(Rc::new(alias.clone()), Rc::clone(&input)))); + } + } + } + let mut targets = vec![]; + for target in &source.targets { + targets.push(Rc::new(target.clone())); + } + sources.push((inputs, targets)); + } + Some(Rc::new(sources)) + } else { + None + } + }); + // { // let services_ctx = services.clone(); // let status_signal = status.clone(); @@ -126,12 +151,15 @@ pub fn Home() -> Html { // } let config_context = ConfigContext { - config: (*config).clone(), + config: (*config).clone(), }; let status_context = StatusContext { status: (*status).clone(), }; + let playlist_context = PlaylistContext { + sources: sources.clone(), + }; //
//
@@ -139,12 +167,19 @@ pub fn Home() -> Html { html! { context={config_context}> context={status_context}> + context={playlist_context}>
- {app_title} + { + if let Some(ref title) = services.config.ui_config.app_title { + html! { title.as_str() } + } else { + html! { } + } + }
//