mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
make DnvConfig a seperate crate and pass to ui
This commit is contained in:
14
bin/dnetview/src/config.rs
Normal file
14
bin/dnetview/src/config.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub const CONFIG_FILE_CONTENTS: &[u8] = include_bytes!("../dnetview_config.toml");
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||
pub struct DnvConfig {
|
||||
pub nodes: Vec<IrcNode>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||
pub struct IrcNode {
|
||||
pub node_id: String,
|
||||
//pub rpc_url: String,
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
pub mod config;
|
||||
pub mod model;
|
||||
pub mod options;
|
||||
pub mod ui;
|
||||
pub mod view;
|
||||
|
||||
pub use config::{DnvConfig, CONFIG_FILE_CONTENTS};
|
||||
pub use model::{IdList, InfoList, Model, NodeInfo};
|
||||
pub use options::ProgramOptions;
|
||||
pub use ui::ui;
|
||||
|
||||
@@ -11,7 +11,6 @@ use darkfi::{
|
||||
use async_std::sync::Arc;
|
||||
use easy_parallel::Parallel;
|
||||
use log::{debug, info};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value};
|
||||
use simplelog::*;
|
||||
use smol::Executor;
|
||||
@@ -30,6 +29,7 @@ use tui::{
|
||||
use url::Url;
|
||||
|
||||
use dnetview::{
|
||||
config::{DnvConfig, CONFIG_FILE_CONTENTS},
|
||||
model::{Connection, IdList, InfoList, NodeInfo},
|
||||
options::ProgramOptions,
|
||||
ui,
|
||||
@@ -37,19 +37,6 @@ use dnetview::{
|
||||
Model, View,
|
||||
};
|
||||
|
||||
const CONFIG_FILE_CONTENTS: &[u8] = include_bytes!("../dnetview_config.toml");
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||
pub struct DnvConfig {
|
||||
pub nodes: Vec<IrcNode>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||
pub struct IrcNode {
|
||||
pub node_id: String,
|
||||
//pub rpc_url: String,
|
||||
}
|
||||
|
||||
struct Map {
|
||||
url: Url,
|
||||
}
|
||||
@@ -230,7 +217,7 @@ async fn render<B: Backend>(
|
||||
loop {
|
||||
view.update(model.info_list.infos.lock().await.clone());
|
||||
terminal.draw(|f| {
|
||||
ui::ui(f, view.clone());
|
||||
ui::ui(f, view.clone(), &config);
|
||||
})?;
|
||||
for k in asi.by_ref().keys() {
|
||||
match k.unwrap() {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::view::View;
|
||||
use crate::DnvConfig;
|
||||
|
||||
use tui::{
|
||||
backend::Backend,
|
||||
@@ -9,7 +10,7 @@ use tui::{
|
||||
Frame,
|
||||
};
|
||||
|
||||
pub fn ui<B: Backend>(f: &mut Frame<'_, B>, mut view: View) {
|
||||
pub fn ui<B: Backend>(f: &mut Frame<'_, B>, mut view: View, config: &DnvConfig) {
|
||||
let slice = Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.margin(2)
|
||||
|
||||
Reference in New Issue
Block a user