From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 1B7BF1FF14F for ; Fri, 08 May 2026 17:58:08 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EEE9D1D887; Fri, 8 May 2026 17:58:07 +0200 (CEST) From: Shannon Sterz To: yew-devel@lists.proxmox.com Subject: [PATCH yew-mobile-gui v2 19/21] node: add a rudimentary firewall tab for cluster nodes Date: Fri, 8 May 2026 17:57:20 +0200 Message-ID: <20260508155722.464564-20-s.sterz@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260508155722.464564-1-s.sterz@proxmox.com> References: <20260508155722.464564-1-s.sterz@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778255736805 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.115 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: VQOWNNGJW6XHE4NKZHKC6ZPDJEY7YSAW X-Message-ID-Hash: VQOWNNGJW6XHE4NKZHKC6ZPDJEY7YSAW X-MailFrom: s.sterz@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Yew framework devel list at Proxmox List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Shannon Sterz --- src/pages/page_node_status/firewall_panel.rs | 135 +++++++++++++++++++ src/pages/page_node_status/mod.rs | 18 +++ 2 files changed, 153 insertions(+) create mode 100644 src/pages/page_node_status/firewall_panel.rs diff --git a/src/pages/page_node_status/firewall_panel.rs b/src/pages/page_node_status/firewall_panel.rs new file mode 100644 index 0000000..e42bbf5 --- /dev/null +++ b/src/pages/page_node_status/firewall_panel.rs @@ -0,0 +1,135 @@ +use std::rc::Rc; + +use serde::{Deserialize, Serialize}; +use yew::virtual_dom::{VComp, VNode}; + +use pwt::prelude::*; +use pwt::props::StorageLocation; +use pwt::state::PersistentState; +use pwt::widget::{Column, MiniScroll, TabBar, TabBarItem}; + +use proxmox_yew_comp::configuration::pve::{FirewallOptionsNodePanel, FirewallRulesPanel}; + +#[derive(Clone, PartialEq, Properties)] +pub struct NodeFirewallPanel { + node: AttrValue, +} + +impl NodeFirewallPanel { + pub fn new(node: impl Into) -> Self { + Self { node: node.into() } + } +} + +#[derive(Copy, Clone, Default, PartialEq, Serialize, Deserialize)] +pub enum ViewState { + #[default] + Rules, + Options, + //Log, +} +pub struct PveNodeFirewallPanel { + view_state: PersistentState, +} + +pub enum Msg { + SetViewState(ViewState), +} + +impl Component for PveNodeFirewallPanel { + type Message = Msg; + type Properties = NodeFirewallPanel; + + fn create(ctx: &Context) -> Self { + let props = ctx.props(); + + let view_state = PersistentState::new(StorageLocation::session(format!( + "node-{}-firewall-tab-bar-state", + props.node + ))); + + Self { view_state } + } + + fn update(&mut self, _ctx: &Context, msg: Self::Message) -> bool { + match msg { + Msg::SetViewState(view_state) => { + self.view_state.update(view_state); + } + } + true + } + fn view(&self, ctx: &Context) -> Html { + let props = ctx.props(); + + let (active_tab, content): (_, Html) = match *self.view_state { + ViewState::Rules => ( + "rules", + FirewallRulesPanel::node_firewall(props.node.clone()) + .mobile(true) + .readonly(true) + .into(), + ), + ViewState::Options => ( + "options", + FirewallOptionsNodePanel::new(props.node.clone()) + .mobile(true) + .readonly(true) + .into(), + ), + /*ViewState::Log => ( + "log", + html! { +
{ format!("Firewall log for VM {}", props.vmid) }
+ }, + ),*/ + }; + + let tab_bar = TabBar::new() + .style(pwt::widget::TabBarStyle::MaterialSecondary) + .class(pwt::css::JustifyContent::Center) + .class("pwt-flex-fill") + .active(active_tab) + .with_item( + TabBarItem::new() + .key("rules") + .label(tr!("Rules")) + .icon_class("fa fa-shield") + .on_activate(ctx.link().callback(|_| Msg::SetViewState(ViewState::Rules))), + ) + .with_item( + TabBarItem::new() + .key("options") + .label(tr!("Options")) + .icon_class("fa fa-gear") + .on_activate( + ctx.link() + .callback(|_| Msg::SetViewState(ViewState::Options)), + ), + ) + /*.with_item( + TabBarItem::new() + .key("log") + .label(tr!("Log")) + .icon_class("fa fa-list") + .on_activate(ctx.link().callback(|_| Msg::SetViewState(ViewState::Log))), + )*/; + + Column::new() + .class(pwt::css::FlexFit) + .with_child( + MiniScroll::new(tab_bar) + .class("pwt-flex-none") + .scroll_mode(pwt::widget::MiniScrollMode::Native), + ) + .with_child(content) + .into() + } +} + +impl From for VNode { + fn from(val: NodeFirewallPanel) -> Self { + let comp = VComp::new::(Rc::new(val), None); + VNode::from(comp) + } +} diff --git a/src/pages/page_node_status/mod.rs b/src/pages/page_node_status/mod.rs index a566179..efb3d92 100644 --- a/src/pages/page_node_status/mod.rs +++ b/src/pages/page_node_status/mod.rs @@ -28,6 +28,9 @@ pub use services_panel::NodeServicesPanel; mod updates_panel; pub use updates_panel::NodeUpdatesPanel; +mod firewall_panel; +use firewall_panel::NodeFirewallPanel; + #[derive(Clone, PartialEq, Properties)] pub struct PageNodeStatus { node: AttrValue, @@ -47,6 +50,7 @@ pub enum ViewState { Dashboard, Services, Updates, + Firewall, } pub enum Msg { @@ -119,6 +123,10 @@ impl Component for PvePageNodeStatus { NodeServicesPanel::new(props.node.clone(), standalone).into(), ), ViewState::Updates => ("updates", NodeUpdatesPanel::new(props.node.clone()).into()), + ViewState::Firewall => ( + "firewall", + NodeFirewallPanel::new(props.node.clone()).into(), + ), }; let tab_bar = TabBar::new() @@ -154,6 +162,16 @@ impl Component for PvePageNodeStatus { ctx.link() .callback(|_| Msg::SetViewState(ViewState::Updates)), ), + ) + .with_item( + TabBarItem::new() + .label(tr!("Firewall")) + .icon_class("fa fa-shield") + .key("firewall") + .on_activate( + ctx.link() + .callback(|_| Msg::SetViewState(ViewState::Firewall)), + ), ); Column::new() -- 2.47.3