From: Greg Burri Date: Wed, 19 Jun 2024 13:33:06 +0000 (+0200) Subject: Add icon when self muted of deafen X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=49972902ee2dab3a555b58d91a099900323b6007;p=mumble_web.git Add icon when self muted of deafen --- diff --git a/Cargo.lock b/Cargo.lock index 3eb5a8a..3a5ea2d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,19 +82,6 @@ dependencies = [ "nom", ] -[[package]] -name = "async-compression" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd066d0b4ef8ecb03a55319dc13aa6910616d0f44008a045bb1835af830abff5" -dependencies = [ - "flate2", - "futures-core", - "memchr", - "pin-project-lite", - "tokio", -] - [[package]] name = "async-trait" version = "0.1.80" @@ -251,15 +238,6 @@ dependencies = [ "unicode_categories", ] -[[package]] -name = "crc32fast" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" -dependencies = [ - "cfg-if", -] - [[package]] name = "deunicode" version = "1.6.0" @@ -284,16 +262,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "flate2" -version = "1.0.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - [[package]] name = "fnv" version = "1.0.7" @@ -1081,10 +1049,8 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ - "async-compression", "bitflags", "bytes", - "futures-core", "futures-util", "http", "http-body", diff --git a/Cargo.toml b/Cargo.toml index 0cf7267..5d6e904 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" axum = { version = "0.7", features = ["http2"] } tokio = { version = "1", features = ["full"] } tower = { version = "0.4", features = ["util"] } -tower-http = { version = "0.5", features = ["fs", "trace", "compression-gzip"] } +tower-http = { version = "0.5", features = ["fs", "trace"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/README.md b/README.md new file mode 100644 index 0000000..edc79be --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Systemd + +"/doc/mumble_web.service" is a systemd user service file. On linux it must be placed +in "~/.config/systemd/user". + +# Documentation + +Axum: https://docs.rs/axum/latest/axum/index.html +Axum examples: https://github.com/tokio-rs/axum/blob/main/ECOSYSTEM.md +Tower HTTP: https://docs.rs/tower-http/0.5.2/tower_http/index.html +Askama: https://djc.github.io/askama/askama.html diff --git a/doc/mumble_web.service b/doc/mumble_web.service new file mode 100644 index 0000000..21e7b66 --- /dev/null +++ b/doc/mumble_web.service @@ -0,0 +1,13 @@ +[Unit] +Description=mumble_web + +[Service] +WorkingDirectory=/var/www/mumble_web +ExecStart=/var/www/mumble_web/mumble_web +SyslogIdentifier=mumble_web +Restart=always +RestartSec=10 +KillSignal=SIGINT + +[Install] +WantedBy=default.target diff --git a/ice/ice.py b/ice/ice.py index f981bd8..34cba11 100644 --- a/ice/ice.py +++ b/ice/ice.py @@ -4,23 +4,29 @@ initdata = Ice.InitializationData() initdata.properties = Ice.createProperties(None, initdata.properties) initdata.properties.setProperty('Ice.ImplicitContext', 'Shared') -def getChannelPath(channels, channelId): +def getChannelPath(channels, channelId, first=True): if channelId == 0: - return "" + return "/" else: channel = channels[channelId] - return getChannelPath(channels, channel.parent) + "/" + channel.name + return getChannelPath(channels, channel.parent, False) + channel.name + \ + ("" if first else "/") def getUsers(server): - return map(lambda u: (u.name, u.channel), server.getUsers().values()) + return map(lambda u: (u.name, u.channel, u.selfMute, u.selfDeaf), server.getUsers().values()) def getUsersAsJson(server): channels = server.getChannels() users = getUsers(server) return json.dumps( [ - {'username': username, 'channel': getChannelPath(channels, channel)} - for (username, channel) in users + { + 'username': username, + 'channel': getChannelPath(channels, channel), + 'selfMute': selfMute, + 'selfDeaf': selfDeaf + } + for (username, channel, selfMute, selfDeaf) in users ] ) diff --git a/src/ice.rs b/src/ice.rs index f917f82..c772ddc 100644 --- a/src/ice.rs +++ b/src/ice.rs @@ -22,6 +22,8 @@ const CACHED_VALUES_DURATION: Duration = Duration::from_secs(5); pub struct User { pub name: String, pub channel: String, + pub self_mute: bool, + pub self_deaf: bool, // 🔇 } pub struct Ice { @@ -137,6 +139,8 @@ impl Ice { users.push(User { name: user_json["username"].as_str().unwrap().to_string(), channel: user_json["channel"].as_str().unwrap().to_string(), + self_mute: user_json["selfMute"].as_bool().unwrap(), + self_deaf: user_json["selfDeaf"].as_bool().unwrap(), }); } self.cached_users = users.clone(); @@ -148,10 +152,10 @@ impl Ice { impl Drop for Ice { fn drop(&mut self) { - println!("Dropping..",); + // println!("Ice: dropping...",); self.dropped.store(true, Ordering::Relaxed); self.kill_event.set(); self.kill_event.wait(); - println!("Dropped!",); + // println!("Ice: dropped!",); } } diff --git a/src/main.rs b/src/main.rs index 6352630..2055ed5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,13 +8,25 @@ use askama::Template; use askama_axum::IntoResponse; use axum::{extract::State, routing::get, Router}; use tokio::signal; -use tower_http::{compression::CompressionLayer, services::ServeDir}; +use tower_http::services::ServeDir; mod ice; #[derive(Eq)] struct User { name: String, + self_mute: bool, + self_deaf: bool, +} + +impl User { + fn from_ice_user(user: &ice::User) -> Self { + User { + name: user.name.clone(), + self_mute: user.self_mute, + self_deaf: user.self_deaf, + } + } } impl PartialEq for User { @@ -57,8 +69,7 @@ async fn main() { let app = Router::new() .route("/", get(root)) .nest_service("/static", ServeDir::new("static")) - .with_state(ice) - .layer(CompressionLayer::new()); + .with_state(ice); let addr = SocketAddr::from(([127, 0, 0, 1], 8086)); let listener = tokio::net::TcpListener::bind(addr).await.unwrap(); @@ -76,17 +87,13 @@ async fn root(State(ice): State>>) -> impl IntoResponse { 'next_user: for u in &users { for c in &mut channels { if c.name == u.channel { - c.users.push(User { - name: u.name.clone(), - }); + c.users.push(User::from_ice_user(u)); continue 'next_user; } } let channel = Channel { name: u.channel.clone(), - users: vec![User { - name: u.name.clone(), - }], + users: vec![User::from_ice_user(u)], }; channels.push(channel); } diff --git a/static/deafened_self.svg b/static/deafened_self.svg new file mode 100644 index 0000000..05037d4 --- /dev/null +++ b/static/deafened_self.svg @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/static/muted_self.svg b/static/muted_self.svg new file mode 100644 index 0000000..be80b95 --- /dev/null +++ b/static/muted_self.svg @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/style.scss b/style.scss index b745f54..255e4da 100644 --- a/style.scss +++ b/style.scss @@ -28,10 +28,17 @@ body { background-color: #252525; } -#channel { +.channel { color: #c5c500; } +.icon { + height: 20px; + margin-left: 5px; + margin-right: 5px; + vertical-align: bottom; +} + h1 { font-size: x-large; margin: 20px 20px 16px 20px; diff --git a/templates/main.html b/templates/main.html index 18fe2c5..5bc6fba 100644 --- a/templates/main.html +++ b/templates/main.html @@ -4,7 +4,7 @@ - Euphoirik Mumble + Euphorik Mumble @@ -15,10 +15,13 @@

No user connected

{% else %} {% for channel in channels %} -

{{ channel.name }}

+

{{ channel.name }}

{% endfor %}