Skip to content

Commit

Permalink
Merge pull request #7 from flomang/master
Browse files Browse the repository at this point in the history
Added chain type to node stats status bar.
  • Loading branch information
yeastplume authored Sep 22, 2022
2 parents 74920ac + 7f6c310 commit d703d44
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 20 deletions.
10 changes: 0 additions & 10 deletions crates/core/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,6 @@ impl NodeInterface {
}
}

pub fn with_sender(chain_type: global::ChainTypes, ui_sender: Option<iced_mpsc::Sender<UIMessage>>) -> Self {
NodeInterface {
chain_type: None,
config: None,
ui_sender,
node_started: false,
tx_controller: None,
}
}

pub fn set_ui_sender(&mut self, ui_sender: iced_mpsc::Sender<UIMessage>) {
self.ui_sender = Some(ui_sender)
}
Expand Down
3 changes: 2 additions & 1 deletion locale/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"transaction-pool-title": "Transaction Pool",
"transaction-pool-size-label": "Size",
"stem-pool-size-label": "Stem Pool Size",
"status-line-title": "Status",
"status-line-title-main": "Status (Mainnet)",
"status-line-title-test": "Status (Testnet)",
"use-testnet": "This is a testnet wallet"
}
3 changes: 2 additions & 1 deletion locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@
"transaction-pool-title": "Transaction Pool",
"transaction-pool-size-label": "Size",
"stem-pool-size-label": "Stem Pool Size",
"status-line-title": "Status",
"status-line-title-main": "Status (Mainnet)",
"status-line-title-test": "Status (Testnet)",
"wallet-list": "Wallets",
"cancel":"Cancel",
"display-name":"Display Name",
Expand Down
6 changes: 4 additions & 2 deletions src/gui/element/node/embedded/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {
crate::gui::{style, GrinGui, Message},
crate::Result,
grin_gui_core::theme::ColorPalette,
grin_gui_core::{config::Config, wallet::WalletInterface},
grin_gui_core::{config::Config, wallet::WalletInterface, node::ChainTypes},
grin_gui_core::node::ServerStats,
iced::{Column, Command, Container, Length, Space},
};
Expand Down Expand Up @@ -47,9 +47,11 @@ pub fn handle_message(
pub fn data_container<'a>(
color_palette: ColorPalette,
state: &'a mut StateContainer,
chain_type: ChainTypes,

) -> Container<'a, Message> {
let content = match state.mode {
Mode::Summary => summary::data_container(color_palette, &mut state.summary_state, &state.server_stats),
Mode::Summary => summary::data_container(color_palette, &mut state.summary_state, &state.server_stats, chain_type),
_ => Container::new(Column::new())
};

Expand Down
10 changes: 8 additions & 2 deletions src/gui/element/node/embedded/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use {
grin_gui_core::theme::ColorPalette,
grin_gui_core::{
fs::PersistentData,
node::{ServerStats, SyncStatus},
node::{ServerStats, SyncStatus, ChainTypes},
wallet::{StatusMessage, WalletInfo, WalletInterface},
},
iced::{
Expand Down Expand Up @@ -194,6 +194,7 @@ pub fn data_container<'a>(
color_palette: ColorPalette,
state: &'a mut StateContainer,
stats: &'a Option<ServerStats>,
chain_type: ChainTypes,

) -> Container<'a, Message> {

Expand Down Expand Up @@ -239,8 +240,13 @@ pub fn data_container<'a>(
.push(Space::new(Length::Fill, Length::Units(0)))
.align_items(Alignment::Center);

let status_line_title = match chain_type {
ChainTypes::Testnet => localized_string("status-line-title-test"),
_ => localized_string("status-line-title-main"),
};

let status_line_card = Card::new(
Text::new(localized_string("status-line-title")).size(DEFAULT_HEADER_FONT_SIZE),
Text::new(status_line_title).size(DEFAULT_HEADER_FONT_SIZE),
status_line_row,
)
.style(style::NormalModalCardContainer(color_palette));
Expand Down
5 changes: 3 additions & 2 deletions src/gui/element/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use {
super::super::{DEFAULT_FONT_SIZE, DEFAULT_PADDING},
crate::gui::{style, GrinGui, Message},
crate::Result,
grin_gui_core::theme::ColorPalette,
grin_gui_core::{theme::ColorPalette, node::ChainTypes},
iced::{Column, Command, Container, Length, Space},
};

Expand Down Expand Up @@ -36,9 +36,10 @@ impl StateContainer {
pub fn data_container<'a>(
color_palette: ColorPalette,
state: &'a mut StateContainer,
chain_type: ChainTypes,
) -> Container<'a, Message> {
let content = match state.mode {
Mode::Embedded => embedded::data_container(color_palette, &mut state.embedded_state),
Mode::Embedded => embedded::data_container(color_palette, &mut state.embedded_state, chain_type),
_ => Container::new(Column::new()),
};

Expand Down
16 changes: 14 additions & 2 deletions src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,20 @@ impl Application for GrinGui {

fn new(config: Config) -> (Self, Command<Message>) {
let mut grin_gui = GrinGui::default();

// default Mainnet
global::set_local_chain_type(ChainTypes::Mainnet);

if let Some(wallet_index) = config.current_wallet_index {
let wallet = config.wallets[wallet_index].clone();
// is tesnet and embedded node??
}

// is tesnet
if wallet.is_testnet {
global::set_local_chain_type(ChainTypes::Testnet);
}

// if embedded node ??
}

let wallet_interface = grin_gui.wallet_interface.clone();
let mut w = wallet_interface.write().unwrap();
Expand Down Expand Up @@ -228,9 +238,11 @@ impl Application for GrinGui {
content = content.push(setup_container)
}
element::menu::Mode::Node => {
let chain_type = self.node_interface.read().unwrap().chain_type.unwrap_or_else( || ChainTypes::Mainnet);
let node_container = element::node::data_container(
color_palette,
&mut self.node_state,
chain_type,
);
content = content.push(node_container)
}
Expand Down

0 comments on commit d703d44

Please sign in to comment.