Skip to content

Commit e9ee972

Browse files
committed
chore(ui): refactor NODE OVERVIEW plus other stuff
1 parent 9085fe5 commit e9ee972

29 files changed

Lines changed: 346 additions & 214 deletions

src/bonsai.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use iced::window::{Icon, Level, Position, Settings};
99
use iced::{Element, Length, Size, Subscription, Task, Theme};
1010
use tokio::runtime::Handle;
1111

12-
use common::interface::color::{DARK_GREY, GREEN, OFF_WHITE, ORANGE, RED, WHITE, PURPLE, YELLOW};
12+
use common::interface::color::{DARK_GREY, GREEN, OFF_WHITE, ORANGE, PURPLE, RED, WHITE, YELLOW};
1313
use common::interface::container::content::{CONTENT_PADDING, CONTENT_SPACING, content_container};
1414
use common::interface::container::header::{HEADER_HEIGHT, HEADER_PADDING, header_container};
1515
use common::interface::container::sidebar::{
@@ -102,33 +102,33 @@ impl Bonsai {
102102
.height(SIDEBAR_BUTTON_HEIGHT)
103103
.width(Length::Fill)
104104
.style(sidebar_button(self.active_tab == Tab::Ark, PURPLE)),
105-
button(text("[NODE] OVERVIEW"))
105+
button(text("NODE OVERVIEW"))
106106
.on_press(BonsaiMessage::SelectTab(Tab::NodeOverview))
107107
.height(SIDEBAR_BUTTON_HEIGHT)
108108
.width(Length::Fill)
109109
.style(sidebar_button(self.active_tab == Tab::NodeOverview, GREEN)),
110-
button(text("[NODE] P2P"))
110+
button(text("NODE P2P"))
111111
.on_press(BonsaiMessage::SelectTab(Tab::NodeP2P))
112112
.height(SIDEBAR_BUTTON_HEIGHT)
113113
.width(Length::Fill)
114114
.style(sidebar_button(self.active_tab == Tab::NodeP2P, GREEN)),
115-
button(text("[NODE] BLOCKS"))
116-
.on_press(BonsaiMessage::SelectTab(Tab::NodeBlocks))
115+
button(text("NODE BLOCKS"))
116+
//.on_press(BonsaiMessage::SelectTab(Tab::NodeBlocks))
117117
.height(SIDEBAR_BUTTON_HEIGHT)
118118
.width(Length::Fill)
119119
.style(sidebar_button(self.active_tab == Tab::NodeBlocks, GREEN)),
120-
button(text("[NODE] UTREEXO"))
121-
.on_press(BonsaiMessage::SelectTab(Tab::NodeUtreexo))
120+
button(text("NODE UTREEXO"))
121+
//.on_press(BonsaiMessage::SelectTab(Tab::NodeUtreexo))
122122
.height(SIDEBAR_BUTTON_HEIGHT)
123123
.width(Length::Fill)
124124
.style(sidebar_button(self.active_tab == Tab::NodeUtreexo, GREEN)),
125-
button(text("[NODE] SETTINGS"))
126-
.on_press(BonsaiMessage::SelectTab(Tab::NodeSettings))
125+
button(text("NODE SETTINGS"))
126+
//.on_press(BonsaiMessage::SelectTab(Tab::NodeSettings))
127127
.height(SIDEBAR_BUTTON_HEIGHT)
128128
.width(Length::Fill)
129129
.style(sidebar_button(self.active_tab == Tab::NodeSettings, GREEN)),
130-
button(text("ABOUT"))
131-
.on_press(BonsaiMessage::SelectTab(Tab::About))
130+
button(text("ABOUT BONSAI"))
131+
//.on_press(BonsaiMessage::SelectTab(Tab::About))
132132
.height(SIDEBAR_BUTTON_HEIGHT)
133133
.width(Length::Fill)
134134
.style(sidebar_button(self.active_tab == Tab::About, WHITE)),

src/common/interface/color.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ pub(crate) const WHITE: Color = Color::from_rgb(
3030
0xff as f32 / 255.0,
3131
);
3232

33+
/// Black.
34+
pub(crate) const BLACK: Color = Color::from_rgb(
35+
0x00 as f32 / 255.0,
36+
0x00 as f32 / 255.0,
37+
0x00 as f32 / 255.0,
38+
);
39+
3340
/// Gold.
3441
pub(crate) const YELLOW: Color = Color::from_rgb(
3542
0xff as f32 / 255.0,

src/common/interface/container/sidebar.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ pub fn sidebar_button(
5757
border,
5858
background,
5959
text_color,
60+
shadow,
6061
..Default::default()
6162
},
6263
Hovered => ButtonStyle {

src/common/logger.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ pub(crate) fn setup_logger() -> LogCapture {
1515
let (non_blocking_file, _guard) = tracing_appender::non_blocking(file_appender);
1616
std::mem::forget(_guard);
1717

18-
let log_capture = LogCapture::new(500); // Keep last 500 logs
18+
let log_capture = LogCapture::new(10_000); // Keep the last 10_000 logs
1919
let capture_layer = LogCaptureLayer::new(log_capture.clone());
2020

21-
// Build the subscriber
2221
tracing_subscriber::registry()
2322
.with(EnvFilter::try_from_default_env().unwrap_or_else(|_| {
2423
EnvFilter::new(

src/node/control.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub const DATA_DIR: &str = "./data/";
2222
pub const NETWORK: Network = Network::Signet;
2323
pub const FETCH_STATISTICS_TIME: u64 = 1;
2424

25-
#[derive(Default)]
25+
#[derive(Clone, Default)]
2626
pub(crate) enum NodeStatus {
2727
#[default]
2828
Inactive,
@@ -66,6 +66,30 @@ impl Node {
6666
Err(e) => NodeMessage::Error(BonsaiNodeError::from(e)),
6767
})
6868
}
69+
NodeMessage::Restart => {
70+
self.status = NodeStatus::ShuttingDown;
71+
self.subscription_active = false;
72+
self.is_shutting_down = true;
73+
self.start_time = None;
74+
75+
if let Some(node_handle) = self.handle.take() {
76+
let rt_handle = Handle::current();
77+
78+
Task::future(async move {
79+
let result = rt_handle
80+
.spawn(async move { stop_node(node_handle).await })
81+
.await;
82+
83+
match result {
84+
Ok(Ok(_)) => NodeMessage::Start,
85+
Ok(Err(e)) => NodeMessage::Error(BonsaiNodeError::from(e)),
86+
Err(e) => NodeMessage::Error(BonsaiNodeError::Generic(e.to_string())),
87+
}
88+
})
89+
} else {
90+
Task::done(NodeMessage::Start)
91+
}
92+
}
6993
NodeMessage::Starting => {
7094
self.status = NodeStatus::Starting;
7195
self.subscription_active = false;

src/node/interface/blocks/container.rs

Whitespace-only changes.

src/node/interface/blocks/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pub(crate) mod container;
1+
pub(crate) mod style;
22
pub(crate) mod view;

src/node/interface/blocks/style.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/node/interface/blocks/view.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/node/interface/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
pub(crate) mod overview;
1+
pub(crate) mod blocks;
22
pub(crate) mod common;
3+
pub(crate) mod overview;
34
pub(crate) mod p2p;
45
pub(crate) mod settings;
56
pub(crate) mod utreexo;
6-
pub(crate) mod blocks;

0 commit comments

Comments
 (0)