From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <yew-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id D78411FF15C for <inbox@lore.proxmox.com>; Fri, 30 May 2025 14:21:50 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BAEEC2E652; Fri, 30 May 2025 14:22:06 +0200 (CEST) From: Dominik Csapak <d.csapak@proxmox.com> To: yew-devel@lists.proxmox.com Date: Fri, 30 May 2025 14:21:43 +0200 Message-Id: <20250530122202.2779300-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250530122202.2779300-1-d.csapak@proxmox.com> References: <20250530122202.2779300-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.022 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 Subject: [yew-devel] [PATCH yew-comp 01/20] remove old rrd uplot code X-BeenThere: yew-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Yew framework devel list at Proxmox <yew-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/yew-devel>, <mailto:yew-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/yew-devel/> List-Post: <mailto:yew-devel@lists.proxmox.com> List-Help: <mailto:yew-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel>, <mailto:yew-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Yew framework devel list at Proxmox <yew-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: yew-devel-bounces@lists.proxmox.com Sender: "yew-devel" <yew-devel-bounces@lists.proxmox.com> it's not in use (not even included) so let's just remove it Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> --- js-helper-module.js | 18 ----- src/lib.rs | 15 ---- src/rrd_graph.rs | 169 -------------------------------------------- 3 files changed, 202 deletions(-) delete mode 100644 src/rrd_graph.rs diff --git a/js-helper-module.js b/js-helper-module.js index 45ccbb7..9f0bd96 100644 --- a/js-helper-module.js +++ b/js-helper-module.js @@ -17,27 +17,9 @@ function get_cookie() { return document.cookie; } -function uplot(opts, data, node) { - return new uPlot(opts, data, node); -} - -function uplot_set_data(uplot, data) { - uplot.setData(data); -} - -function uplot_set_size(uplot, width, height) { - uplot.setSize({ - width: width, - height: height, - }); -} - export { async_sleep, get_cookie, set_cookie, clear_auth_cookie, - uplot, - uplot_set_data, - uplot_set_size, }; diff --git a/src/lib.rs b/src/lib.rs index 091cb72..ff3044a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -217,11 +217,6 @@ extern "C" { pub fn get_cookie() -> String; pub fn set_cookie(value: &str); pub fn clear_auth_cookie(name: &str); - - // uPlot binding - pub fn uplot(opts: &JsValue, data: &JsValue, node: web_sys::Node) -> JsValue; - pub fn uplot_set_data(uplot: &JsValue, data: &JsValue); - pub fn uplot_set_size(uplot: &JsValue, width: usize, height: usize); } // Create wrapper which panics if called from target_arch!=wasm32 @@ -230,7 +225,6 @@ extern "C" { pub use panic_wrapper::*; #[cfg(not(target_arch = "wasm32"))] mod panic_wrapper { - use wasm_bindgen::JsValue; pub fn async_sleep(_ms: i32) -> js_sys::Promise { unreachable!() } @@ -243,15 +237,6 @@ mod panic_wrapper { pub fn clear_auth_cookie(_name: &str) { unreachable!() } - pub fn uplot(_opts: &JsValue, _data: &JsValue, _node: web_sys::Node) -> JsValue { - unreachable!() - } - pub fn uplot_set_data(_uplot: &JsValue, _data: &JsValue) { - unreachable!() - } - pub fn uplot_set_size(_uplot: &JsValue, _width: usize, _height: usize) { - unreachable!() - } } pub fn store_csrf_token(crsf_token: &str) { diff --git a/src/rrd_graph.rs b/src/rrd_graph.rs deleted file mode 100644 index 9ced377..0000000 --- a/src/rrd_graph.rs +++ /dev/null @@ -1,169 +0,0 @@ -use std::rc::Rc; - -use serde_json::json; -use wasm_bindgen::JsValue; - -use yew::html::IntoPropValue; -use yew::prelude::*; -use yew::virtual_dom::{VComp, VNode}; - -use pwt::dom::DomSizeObserver; -use pwt::prelude::*; -use pwt::widget::Panel; - -#[derive(Clone, PartialEq, Properties)] -pub struct RRDGraph { - #[prop_or_default] - pub title: Option<AttrValue>, - // Legend Label - #[prop_or_default] - pub label: Option<String>, - #[prop_or_default] - pub class: Classes, - - pub data: Rc<(Vec<i64>, Vec<f64>)>, -} - -impl RRDGraph { - pub fn new(data: Rc<(Vec<i64>, Vec<f64>)>) -> Self { - yew::props!(RRDGraph { data }) - } - - pub fn title(mut self, title: impl IntoPropValue<Option<AttrValue>>) -> Self { - self.set_title(title); - self - } - - pub fn set_title(&mut self, title: impl IntoPropValue<Option<AttrValue>>) { - self.title = title.into_prop_value(); - } - - pub fn label(mut self, label: impl Into<String>) -> Self { - self.label = Some(label.into()); - self - } - - /// Builder style method to add a html class - pub fn class(mut self, class: impl Into<Classes>) -> Self { - self.add_class(class); - self - } - - /// Method to add a html class - pub fn add_class(&mut self, class: impl Into<Classes>) { - self.class.push(class); - } -} - -pub enum Msg { - Reload, - ViewportResize(f64, f64), -} - -pub struct PwtRRDGraph { - node_ref: NodeRef, - size_observer: Option<DomSizeObserver>, - width: usize, - uplot: Option<JsValue>, -} - -const DEFAULT_RRD_WIDTH: usize = 800; -const DEFAULT_RRD_HEIGHT: usize = 250; - -impl Component for PwtRRDGraph { - type Message = Msg; - type Properties = RRDGraph; - - fn create(ctx: &Context<Self>) -> Self { - ctx.link().send_message(Msg::Reload); - Self { - node_ref: NodeRef::default(), - size_observer: None, - width: DEFAULT_RRD_WIDTH, - uplot: None, - } - } - - fn update(&mut self, _ctx: &Context<Self>, msg: Self::Message) -> bool { - match msg { - Msg::Reload => true, - Msg::ViewportResize(width, _height) => { - self.width = width as usize; - true - } - } - } - - fn view(&self, ctx: &Context<Self>) -> Html { - let props = ctx.props(); - - Panel::new() - .title(props.title.clone()) - .class(props.class.clone()) - .with_child( - Container::new() - .padding(2) - .with_child(html! {<div ref={self.node_ref.clone()}>}), - ) - .into() - } - - fn changed(&mut self, ctx: &Context<Self>, _old_props: &Self::Properties) -> bool { - if let Some(uplot) = &self.uplot { - let data = pwt::to_js_value(ctx.props().data.as_ref()).unwrap(); - crate::uplot_set_size(uplot, self.width, DEFAULT_RRD_HEIGHT); - crate::uplot_set_data(uplot, &data); - } - true - } - - fn rendered(&mut self, ctx: &Context<Self>, first_render: bool) { - if first_render { - if let Some(el) = self.node_ref.cast::<web_sys::Element>() { - let link = ctx.link().clone(); - let size_observer = DomSizeObserver::new(&el, move |(width, height)| { - link.send_message(Msg::ViewportResize(width, height)); - }); - - self.size_observer = Some(size_observer); - } - - let props = ctx.props(); - - let mut serie1 = json!({ - // initial toggled state (optional) - "show": true, - - "spanGaps": false, - - // series style - "stroke": "#94ae0a", - "fill": "#94ae0a80", - "width": 1, - }); - - if let Some(ref label) = props.label { - serie1["label"] = label.as_str().into(); - } - - let opts = json!({ - "width": self.width, - "height": DEFAULT_RRD_HEIGHT, - "series": [ {}, serie1 ], - }); - - let opts = pwt::to_js_value(&opts).unwrap(); - - let data = pwt::to_js_value(props.data.as_ref()).unwrap(); - - self.uplot = Some(crate::uplot(&opts, &data, self.node_ref.get().unwrap())); - } - } -} - -impl Into<VNode> for RRDGraph { - fn into(self) -> VNode { - let comp = VComp::new::<PwtRRDGraph>(Rc::new(self), None); - VNode::from(comp) - } -} -- 2.39.5 _______________________________________________ yew-devel mailing list yew-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel