Compare commits
3 Commits
0af68ca624
...
a24a35aa51
Author | SHA1 | Date | |
---|---|---|---|
a24a35aa51 | |||
aed9fae2af | |||
987d8e544d |
@ -2,7 +2,7 @@
|
|||||||
name = "ghost-eye"
|
name = "ghost-eye"
|
||||||
authors = ["str3tch <stretch@ghostchain.io>"]
|
authors = ["str3tch <stretch@ghostchain.io>"]
|
||||||
description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost"
|
description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost"
|
||||||
version = "0.3.53"
|
version = "0.3.56"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
homepage = "https://git.ghostchain.io/ghostchain"
|
homepage = "https://git.ghostchain.io/ghostchain"
|
||||||
repository = "https://git.ghostchain.io/ghostchain/ghost-eye"
|
repository = "https://git.ghostchain.io/ghostchain/ghost-eye"
|
||||||
|
@ -36,6 +36,7 @@ pub enum Action {
|
|||||||
ClosePopup,
|
ClosePopup,
|
||||||
RotateSessionKeys,
|
RotateSessionKeys,
|
||||||
PayoutValidatorPopup(u32, bool),
|
PayoutValidatorPopup(u32, bool),
|
||||||
|
WithdrawValidatorPopup,
|
||||||
|
|
||||||
BalanceRequest([u8; 32], bool),
|
BalanceRequest([u8; 32], bool),
|
||||||
BalanceResponse([u8; 32], Option<SystemAccount>),
|
BalanceResponse([u8; 32], Option<SystemAccount>),
|
||||||
|
@ -183,7 +183,10 @@ impl PartialComponent for History {
|
|||||||
fn set_active(&mut self, current_tab: CurrentTab) {
|
fn set_active(&mut self, current_tab: CurrentTab) {
|
||||||
match current_tab {
|
match current_tab {
|
||||||
CurrentTab::History => self.is_active = true,
|
CurrentTab::History => self.is_active = true,
|
||||||
_ => self.is_active = false,
|
_ => {
|
||||||
|
self.table_state.select(None);
|
||||||
|
self.is_active = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -253,13 +256,19 @@ impl Component for History {
|
|||||||
era_index_text = era_index_text.add_modifier(Modifier::CROSSED_OUT);
|
era_index_text = era_index_text.add_modifier(Modifier::CROSSED_OUT);
|
||||||
slash_text = slash_text.add_modifier(Modifier::CROSSED_OUT);
|
slash_text = slash_text.add_modifier(Modifier::CROSSED_OUT);
|
||||||
reward_text = reward_text.add_modifier(Modifier::CROSSED_OUT);
|
reward_text = reward_text.add_modifier(Modifier::CROSSED_OUT);
|
||||||
}
|
|
||||||
|
|
||||||
Row::new(vec![
|
Row::new(vec![
|
||||||
Cell::from(era_index_text),
|
Cell::from(era_index_text),
|
||||||
Cell::from(slash_text),
|
Cell::from(slash_text),
|
||||||
Cell::from(reward_text),
|
Cell::from(reward_text),
|
||||||
])
|
]).style(self.palette.create_highlight_style())
|
||||||
|
} else {
|
||||||
|
Row::new(vec![
|
||||||
|
Cell::from(era_index_text),
|
||||||
|
Cell::from(slash_text),
|
||||||
|
Cell::from(reward_text),
|
||||||
|
])
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
Constraint::Length(4),
|
Constraint::Length(4),
|
||||||
@ -267,7 +276,7 @@ impl Component for History {
|
|||||||
Constraint::Fill(1),
|
Constraint::Fill(1),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.highlight_style(self.palette.create_highlight_style())
|
.highlight_style(self.palette.create_basic_style(true))
|
||||||
.column_spacing(1)
|
.column_spacing(1)
|
||||||
.block(Block::bordered()
|
.block(Block::bordered()
|
||||||
.border_style(border_style)
|
.border_style(border_style)
|
||||||
|
@ -244,6 +244,10 @@ impl Component for Validator {
|
|||||||
self.previous_tab = self.current_tab;
|
self.previous_tab = self.current_tab;
|
||||||
self.current_tab = CurrentTab::PayoutPopup;
|
self.current_tab = CurrentTab::PayoutPopup;
|
||||||
}
|
}
|
||||||
|
Action::WithdrawValidatorPopup => {
|
||||||
|
self.previous_tab = self.current_tab;
|
||||||
|
self.current_tab = CurrentTab::WithdrawPopup;
|
||||||
|
},
|
||||||
Action::ClosePopup => self.current_tab = self.previous_tab,
|
Action::ClosePopup => self.current_tab = self.previous_tab,
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,7 @@ impl Component for PayoutPopup {
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_key_event(&mut self, key: KeyEvent) -> Result<Option<Action>> {
|
fn handle_key_event(&mut self, key: KeyEvent) -> Result<Option<Action>> {
|
||||||
if self.is_active && key.kind == KeyEventKind::Press {
|
if self.is_active && key.kind == KeyEventKind::Press {
|
||||||
match key.code {
|
match key.code {
|
||||||
|
@ -11,9 +11,10 @@ use ratatui::{
|
|||||||
},
|
},
|
||||||
Frame
|
Frame
|
||||||
};
|
};
|
||||||
|
use tokio::sync::mpsc::UnboundedSender;
|
||||||
|
|
||||||
use super::{PartialComponent, Component, CurrentTab};
|
use super::{PartialComponent, Component, CurrentTab};
|
||||||
use crate::types::UnlockChunk;
|
use crate::types::{ActionTarget, ActionLevel, UnlockChunk};
|
||||||
use crate::{
|
use crate::{
|
||||||
action::Action,
|
action::Action,
|
||||||
config::Config,
|
config::Config,
|
||||||
@ -22,6 +23,7 @@ use crate::{
|
|||||||
|
|
||||||
pub struct Withdrawals {
|
pub struct Withdrawals {
|
||||||
is_active: bool,
|
is_active: bool,
|
||||||
|
action_tx: Option<UnboundedSender<Action>>,
|
||||||
palette: StylePalette,
|
palette: StylePalette,
|
||||||
scroll_state: ScrollbarState,
|
scroll_state: ScrollbarState,
|
||||||
table_state: TableState,
|
table_state: TableState,
|
||||||
@ -43,6 +45,7 @@ impl Withdrawals {
|
|||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
is_active: false,
|
is_active: false,
|
||||||
|
action_tx: None,
|
||||||
scroll_state: ScrollbarState::new(0),
|
scroll_state: ScrollbarState::new(0),
|
||||||
table_state: TableState::new(),
|
table_state: TableState::new(),
|
||||||
palette: StylePalette::default(),
|
palette: StylePalette::default(),
|
||||||
@ -52,6 +55,21 @@ impl Withdrawals {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn try_open_popup(&mut self) {
|
||||||
|
if let Some(action_tx) = &self.action_tx {
|
||||||
|
if let Some(index) = self.table_state.selected() {
|
||||||
|
if index == 0 && self.unlockings[0].era > self.current_era {
|
||||||
|
let _ = action_tx.send(Action::WithdrawValidatorPopup);
|
||||||
|
} else {
|
||||||
|
let _ = action_tx.send(Action::EventLog(
|
||||||
|
"Nothing to be witdrawn yet on the selected unlocking".to_string(),
|
||||||
|
ActionLevel::Info,
|
||||||
|
ActionTarget::ValidatorLog));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn first_row(&mut self) {
|
fn first_row(&mut self) {
|
||||||
if self.unlockings.len() > 0 {
|
if self.unlockings.len() > 0 {
|
||||||
self.table_state.select(Some(0));
|
self.table_state.select(Some(0));
|
||||||
@ -143,6 +161,11 @@ impl PartialComponent for Withdrawals {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Component for Withdrawals {
|
impl Component for Withdrawals {
|
||||||
|
fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()> {
|
||||||
|
self.action_tx = Some(tx);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||||
if let Some(style) = config.styles.get(&crate::app::Mode::Validator) {
|
if let Some(style) = config.styles.get(&crate::app::Mode::Validator) {
|
||||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
self.palette.with_normal_style(style.get("normal_style").copied());
|
||||||
@ -175,6 +198,7 @@ impl Component for Withdrawals {
|
|||||||
KeyCode::Down | KeyCode::Char('j') => self.next_row(),
|
KeyCode::Down | KeyCode::Char('j') => self.next_row(),
|
||||||
KeyCode::Char('g') => self.first_row(),
|
KeyCode::Char('g') => self.first_row(),
|
||||||
KeyCode::Char('G') => self.last_row(),
|
KeyCode::Char('G') => self.last_row(),
|
||||||
|
KeyCode::Enter => self.try_open_popup(),
|
||||||
_ => {},
|
_ => {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ use std::sync::mpsc::Sender;
|
|||||||
|
|
||||||
use color_eyre::Result;
|
use color_eyre::Result;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
|
widgets::Clear,
|
||||||
layout::{Alignment, Constraint, Rect},
|
layout::{Alignment, Constraint, Rect},
|
||||||
text::Text,
|
text::Text,
|
||||||
widgets::{Block, Cell, Row, Table},
|
widgets::{Block, Cell, Row, Table},
|
||||||
@ -215,6 +216,7 @@ impl Component for CurrentValidatorDetails {
|
|||||||
.title_style(self.palette.create_title_style(false))
|
.title_style(self.palette.create_title_style(false))
|
||||||
.title("Validator details"));
|
.title("Validator details"));
|
||||||
|
|
||||||
|
frame.render_widget(Clear, place);
|
||||||
frame.render_widget(table, place);
|
frame.render_widget(table, place);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user