make targets to be choosen
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
2d01ef73c7
commit
105ca64dc6
@ -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.46"
|
version = "0.3.47"
|
||||||
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"
|
||||||
|
@ -163,6 +163,10 @@ impl Component for CurrentValidatorDetails {
|
|||||||
Cell::from(Text::from("Forbidden".to_string()).alignment(Alignment::Left)),
|
Cell::from(Text::from("Forbidden".to_string()).alignment(Alignment::Left)),
|
||||||
Cell::from(Text::from(self.is_nomination_disabled.to_string()).alignment(Alignment::Right)),
|
Cell::from(Text::from(self.is_nomination_disabled.to_string()).alignment(Alignment::Right)),
|
||||||
]),
|
]),
|
||||||
|
Row::new(vec![
|
||||||
|
Cell::from(Text::from("Nominators".to_string()).alignment(Alignment::Left)),
|
||||||
|
Cell::from(Text::from(self.others_len.to_string()).alignment(Alignment::Right)),
|
||||||
|
]),
|
||||||
Row::new(vec![
|
Row::new(vec![
|
||||||
Cell::from(Text::from("Total staked".to_string()).alignment(Alignment::Left)),
|
Cell::from(Text::from("Total staked".to_string()).alignment(Alignment::Left)),
|
||||||
Cell::from(Text::from(self.prepare_u128(self.total_balance)).alignment(Alignment::Right)),
|
Cell::from(Text::from(self.prepare_u128(self.total_balance)).alignment(Alignment::Right)),
|
||||||
@ -172,8 +176,8 @@ impl Component for CurrentValidatorDetails {
|
|||||||
Cell::from(Text::from(self.prepare_u128(self.own_balance)).alignment(Alignment::Right)),
|
Cell::from(Text::from(self.prepare_u128(self.own_balance)).alignment(Alignment::Right)),
|
||||||
]),
|
]),
|
||||||
Row::new(vec![
|
Row::new(vec![
|
||||||
Cell::from(Text::from("Nominators".to_string()).alignment(Alignment::Left)),
|
Cell::from(Text::from("Imbalance".to_string()).alignment(Alignment::Left)),
|
||||||
Cell::from(Text::from(self.others_len.to_string()).alignment(Alignment::Right)),
|
Cell::from(Text::from(self.prepare_stake_imbalance()).alignment(Alignment::Right)),
|
||||||
]),
|
]),
|
||||||
Row::new(vec![
|
Row::new(vec![
|
||||||
Cell::from(Text::from("Commission".to_string()).alignment(Alignment::Left)),
|
Cell::from(Text::from("Commission".to_string()).alignment(Alignment::Left)),
|
||||||
@ -187,10 +191,6 @@ impl Component for CurrentValidatorDetails {
|
|||||||
Cell::from(Text::from("In next era".to_string()).alignment(Alignment::Left)),
|
Cell::from(Text::from("In next era".to_string()).alignment(Alignment::Left)),
|
||||||
Cell::from(Text::from(self.prepare_state_string()).alignment(Alignment::Right)),
|
Cell::from(Text::from(self.prepare_state_string()).alignment(Alignment::Right)),
|
||||||
]),
|
]),
|
||||||
Row::new(vec![
|
|
||||||
Cell::from(Text::from("Imbalance".to_string()).alignment(Alignment::Left)),
|
|
||||||
Cell::from(Text::from(self.prepare_stake_imbalance()).alignment(Alignment::Right)),
|
|
||||||
]),
|
|
||||||
Row::new(vec![
|
Row::new(vec![
|
||||||
Cell::from(Text::from("Last payout".to_string()).alignment(Alignment::Left)),
|
Cell::from(Text::from("Last payout".to_string()).alignment(Alignment::Left)),
|
||||||
Cell::from(Text::from(format!("{} days ago", self.latest_era_claim)).alignment(Alignment::Right)),
|
Cell::from(Text::from(format!("{} days ago", self.latest_era_claim)).alignment(Alignment::Right)),
|
||||||
|
@ -34,6 +34,7 @@ pub struct CurrentValidators {
|
|||||||
table_state: TableState,
|
table_state: TableState,
|
||||||
individual: Vec<EraRewardPoints>,
|
individual: Vec<EraRewardPoints>,
|
||||||
known_validators: std::collections::HashMap<[u8; 32], String>,
|
known_validators: std::collections::HashMap<[u8; 32], String>,
|
||||||
|
checked_validators: std::collections::HashSet<[u8; 32]>,
|
||||||
total_points: u32,
|
total_points: u32,
|
||||||
era_index: u32,
|
era_index: u32,
|
||||||
my_stash_id: Option<[u8; 32]>,
|
my_stash_id: Option<[u8; 32]>,
|
||||||
@ -57,6 +58,7 @@ impl CurrentValidators {
|
|||||||
table_state: TableState::new(),
|
table_state: TableState::new(),
|
||||||
individual: Default::default(),
|
individual: Default::default(),
|
||||||
known_validators: Default::default(),
|
known_validators: Default::default(),
|
||||||
|
checked_validators: Default::default(),
|
||||||
total_points: 0,
|
total_points: 0,
|
||||||
era_index: 0,
|
era_index: 0,
|
||||||
my_stash_id: None,
|
my_stash_id: None,
|
||||||
@ -78,6 +80,23 @@ impl CurrentValidators {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn clear_choosen(&mut self) {
|
||||||
|
self.checked_validators.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn flip_validator_check(&mut self) {
|
||||||
|
if let Some(index) = self.table_state.selected() {
|
||||||
|
if let Some(indiv) = self.individual.get(index) {
|
||||||
|
let current_account_id = indiv.account_id;
|
||||||
|
if self.checked_validators.contains(¤t_account_id) {
|
||||||
|
self.checked_validators.remove(¤t_account_id);
|
||||||
|
} else {
|
||||||
|
self.checked_validators.insert(current_account_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn save_validator_name(&mut self, new_name: String) {
|
fn save_validator_name(&mut self, new_name: String) {
|
||||||
if let Some(index) = self.table_state.selected() {
|
if let Some(index) = self.table_state.selected() {
|
||||||
let account_id = self.individual[index].account_id;
|
let account_id = self.individual[index].account_id;
|
||||||
@ -250,6 +269,8 @@ impl Component for CurrentValidators {
|
|||||||
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::Char('R') => self.update_known_validator_record(),
|
KeyCode::Char('R') => self.update_known_validator_record(),
|
||||||
|
KeyCode::Char('C') => self.clear_choosen(),
|
||||||
|
KeyCode::Enter => self.flip_validator_check(),
|
||||||
_ => {},
|
_ => {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -266,6 +287,11 @@ impl Component for CurrentValidators {
|
|||||||
.map(|(index, info)| {
|
.map(|(index, info)| {
|
||||||
let mut address_text = Text::from(info.address.clone()).alignment(Alignment::Center);
|
let mut address_text = Text::from(info.address.clone()).alignment(Alignment::Center);
|
||||||
let mut points_text = Text::from(info.points.to_string()).alignment(Alignment::Right);
|
let mut points_text = Text::from(info.points.to_string()).alignment(Alignment::Right);
|
||||||
|
let is_choosen_text = if self.checked_validators.contains(&info.account_id) {
|
||||||
|
">"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
};
|
||||||
|
|
||||||
if info.disabled {
|
if info.disabled {
|
||||||
address_text = address_text.add_modifier(Modifier::CROSSED_OUT);
|
address_text = address_text.add_modifier(Modifier::CROSSED_OUT);
|
||||||
@ -285,6 +311,7 @@ impl Component for CurrentValidators {
|
|||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or("My stash".to_string());
|
.unwrap_or("My stash".to_string());
|
||||||
Row::new(vec![
|
Row::new(vec![
|
||||||
|
Cell::from(Text::from(is_choosen_text).alignment(Alignment::Left)),
|
||||||
Cell::from(Text::from(name).alignment(Alignment::Left)),
|
Cell::from(Text::from(name).alignment(Alignment::Left)),
|
||||||
Cell::from(address_text),
|
Cell::from(address_text),
|
||||||
Cell::from(points_text),
|
Cell::from(points_text),
|
||||||
@ -295,6 +322,7 @@ impl Component for CurrentValidators {
|
|||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or("Ghostie".to_string());
|
.unwrap_or("Ghostie".to_string());
|
||||||
Row::new(vec![
|
Row::new(vec![
|
||||||
|
Cell::from(Text::from(is_choosen_text).alignment(Alignment::Left)),
|
||||||
Cell::from(Text::from(name).alignment(Alignment::Left)),
|
Cell::from(Text::from(name).alignment(Alignment::Left)),
|
||||||
Cell::from(address_text),
|
Cell::from(address_text),
|
||||||
Cell::from(points_text),
|
Cell::from(points_text),
|
||||||
@ -302,6 +330,7 @@ impl Component for CurrentValidators {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
|
Constraint::Length(1),
|
||||||
Constraint::Length(12),
|
Constraint::Length(12),
|
||||||
Constraint::Min(0),
|
Constraint::Min(0),
|
||||||
Constraint::Length(6),
|
Constraint::Length(6),
|
||||||
|
Loading…
Reference in New Issue
Block a user