mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-23 05:34:57 +02:00
some starting work on a temp graph widget; I'll do disk in a separate PR
This commit is contained in:
parent
c0cbdab688
commit
477514697c
@ -55,6 +55,10 @@ pub struct TimeSeriesData {
|
||||
#[cfg(feature = "gpu")]
|
||||
/// GPU memory data.
|
||||
pub gpu_mem: HashMap<String, Values>,
|
||||
|
||||
/// Temperature data, if needed. A mapping of sensor names to
|
||||
/// their temperature values.
|
||||
pub temp: HashMap<String, Values>,
|
||||
}
|
||||
|
||||
impl TimeSeriesData {
|
||||
|
@ -1 +1,3 @@
|
||||
//! Code for a disk graph widget.
|
||||
|
||||
// TODO: Implement this.
|
||||
|
@ -19,3 +19,9 @@ pub use network_graph::*;
|
||||
pub use process_table::*;
|
||||
pub use temperature_graph::*;
|
||||
pub use temperature_table::*;
|
||||
|
||||
/// Whether an event is handled by the current element or not.
|
||||
pub enum EventHandled {
|
||||
Handled,
|
||||
NotHandled,
|
||||
}
|
||||
|
@ -1 +1,57 @@
|
||||
//! Code for a temperature graph widget.
|
||||
|
||||
use std::time::Instant;
|
||||
|
||||
use crossterm::event::{KeyEvent, MouseEvent};
|
||||
use tui::{Frame, layout::Rect};
|
||||
|
||||
use crate::app::{App, data::TemperatureType};
|
||||
|
||||
use super::EventHandled;
|
||||
|
||||
/// A temperature graph widget.
|
||||
///
|
||||
/// The current implementation of this uses tuine-style code; this will
|
||||
/// become the standard later on for all widgets.
|
||||
#[derive(Default)]
|
||||
pub struct TemperatureGraph {
|
||||
current_display_time: u64,
|
||||
autohide_timer: Option<Instant>,
|
||||
current_max_temperature: u32,
|
||||
temperature_unit: TemperatureType,
|
||||
}
|
||||
|
||||
impl TemperatureGraph {
|
||||
pub fn temperature_unit(mut self, unit: TemperatureType) -> Self {
|
||||
self.temperature_unit = unit;
|
||||
self
|
||||
}
|
||||
|
||||
/// How this widget handles key events.
|
||||
///
|
||||
/// TODO: This may merge with [`Self::handle_mouse_event`] in the future.
|
||||
pub fn handle_key_event(event: KeyEvent) -> EventHandled {
|
||||
EventHandled::NotHandled
|
||||
}
|
||||
|
||||
/// How this widget handles mouse events.
|
||||
///
|
||||
/// TODO: This may merge with [`Self::handle_key_event`] in the future.
|
||||
pub fn handle_mouse_event(event: MouseEvent) -> EventHandled {
|
||||
EventHandled::NotHandled
|
||||
}
|
||||
|
||||
// /// How to lay out this widget in terms of sizing.
|
||||
//
|
||||
// For now, this is not implemented, and we will directly give sizes.
|
||||
// pub fn layout() {}
|
||||
|
||||
/// How to draw this widget.
|
||||
///
|
||||
/// This implementation is a bit of a hack/placeholder, in the future we don't want to bring in stuff like [`App`].
|
||||
pub fn draw(&mut self, frame: &mut Frame<'_>, app_state: &mut App, draw_area: Rect) {
|
||||
let data = &app_state.data_store.get_data().timeseries_data.temp;
|
||||
|
||||
// Inspect the newest entry of each sensor to determine the current max temperature.
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user