Skip to content

Commit 6df1cd9

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

26 files changed

Lines changed: 341 additions & 208 deletions

src/bonsai.rs

Lines changed: 7 additions & 7 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,32 +102,32 @@ 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"))
115+
button(text("NODE BLOCKS"))
116116
.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"))
120+
button(text("NODE UTREEXO"))
121121
.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"))
125+
button(text("NODE SETTINGS"))
126126
.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"))
130+
button(text("ABOUT BONSAI"))
131131
.on_press(BonsaiMessage::SelectTab(Tab::About))
132132
.height(SIDEBAR_BUTTON_HEIGHT)
133133
.width(Length::Fill)

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/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;

src/node/interface/overview/container.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/node/interface/overview/mod.rs

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

0 commit comments

Comments
 (0)