From: Dominik Csapak <d.csapak@proxmox.com>
To: yew-devel@lists.proxmox.com
Subject: [yew-devel] [PATCH yew-comp 01/20] remove old rrd uplot code
Date: Fri, 30 May 2025 14:21:43 +0200 [thread overview]
Message-ID: <20250530122202.2779300-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250530122202.2779300-1-d.csapak@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
next prev parent reply other threads:[~2025-05-30 12:21 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-30 12:21 [yew-devel] [PATCH yew-comp 00/20] refactor and improve rrd graph code Dominik Csapak
2025-05-30 12:21 ` Dominik Csapak [this message]
2025-05-30 12:21 ` [yew-devel] [PATCH yew-comp 02/20] rrd: refactor code for compute_min_max Dominik Csapak
2025-05-30 12:21 ` [yew-devel] [PATCH yew-comp 03/20] rrd: move into own module Dominik Csapak
2025-05-30 12:21 ` [yew-devel] [PATCH yew-comp 04/20] rrd: move unit calculation to " Dominik Csapak
2025-05-30 12:21 ` [yew-devel] [PATCH yew-comp 05/20] rrd: units: add tests Dominik Csapak
2025-05-30 12:21 ` [yew-devel] [PATCH yew-comp 06/20] rrd: units: simplify calculations for get_grid_unit_base Dominik Csapak
2025-05-30 12:21 ` [yew-devel] [PATCH yew-comp 07/20] rrd: remove unnecessary `no_data` field Dominik Csapak
2025-05-30 12:21 ` [yew-devel] [PATCH yew-comp 08/20] rrd: align tooltip directly to pointer position Dominik Csapak
2025-05-30 12:21 ` [yew-devel] [PATCH yew-comp 09/20] rrd: use 'cross_pos' state instead of 'draw_cross' Dominik Csapak
2025-05-30 12:21 ` [yew-devel] [PATCH yew-comp 10/20] rrd: give all elements in svg keys Dominik Csapak
2025-05-30 12:21 ` [yew-devel] [PATCH yew-comp 11/20] rrd: simplify toggle Msg Dominik Csapak
2025-05-30 12:21 ` [yew-devel] [PATCH yew-comp 12/20] rrd: remove wrongly annotated lifetime Dominik Csapak
2025-05-30 12:21 ` [yew-devel] [PATCH yew-comp 13/20] rrd: refactor series related struct and functions into own module Dominik Csapak
2025-05-30 12:21 ` [yew-devel] [PATCH yew-comp 14/20] rrd: clamp view range when time_data changes Dominik Csapak
2025-05-30 12:21 ` [yew-devel] [PATCH yew-comp 15/20] rrd: refactor grid data computation Dominik Csapak
2025-05-30 12:21 ` [yew-devel] [PATCH yew-comp 16/20] rrd: introduce GraphSpace struct and use it to precalculate graph data Dominik Csapak
2025-05-30 12:21 ` [yew-devel] [PATCH yew-comp 17/20] rrd: precalculate the grid line and label positions Dominik Csapak
2025-05-30 12:22 ` [yew-devel] [PATCH yew-comp 18/20] rrd: calculate series svg data only when necessary Dominik Csapak
2025-05-30 12:22 ` [yew-devel] [PATCH yew-comp 19/20] rrd: refactor selection rectangle calculation Dominik Csapak
2025-05-30 12:22 ` [yew-devel] [PATCH yew-comp 20/20] rrd: refactor the cross position calculation Dominik Csapak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250530122202.2779300-2-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=yew-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal