wallet + config + ui: load wallet info, wallet connections and app config refactoring, check external connections availability, config subdir argument format, item button color, radio buttons stroke, chain type selection from connections, update translations

This commit is contained in:
ardocrat
2023-08-09 02:22:16 +03:00
parent 8ed6bc0578
commit 076a692e1b
27 changed files with 647 additions and 856 deletions
+8 -16
View File
@@ -45,9 +45,7 @@ impl PeersConfig {
/// Save peers config to the file.
pub fn save(&self) {
let chain_type = AppConfig::chain_type();
let chain_name = chain_type.shortname();
let sub_dir = Some(chain_name.as_str());
let config_path = Settings::get_config_path(Self::FILE_NAME, sub_dir);
let config_path = Settings::get_config_path(Self::FILE_NAME, Some(chain_type.shortname()));
Settings::write_to_file(self, config_path);
}
@@ -147,8 +145,7 @@ impl NodeConfig {
// Initialize peers config.
let peers_config = {
let chain_name = chain_type.shortname();
let sub_dir = Some(chain_name.as_str());
let sub_dir = Some(chain_type.shortname());
let path = Settings::get_config_path(PeersConfig::FILE_NAME, sub_dir);
let config = Settings::read_from_file::<PeersConfig>(path.clone());
if !path.exists() || config.is_err() {
@@ -160,8 +157,7 @@ impl NodeConfig {
// Initialize node config.
let node_config = {
let chain_name = chain_type.shortname();
let sub_dir = Some(chain_name.as_str());
let sub_dir = Some(chain_type.shortname());
let path = Settings::get_config_path(SERVER_CONFIG_FILE_NAME, sub_dir);
let config = Settings::read_from_file::<ConfigMembers>(path.clone());
if !path.exists() || config.is_err() {
@@ -176,9 +172,8 @@ impl NodeConfig {
/// Save default node config for specified [`ChainTypes`].
fn save_default_node_server_config(chain_type: &ChainTypes) -> ConfigMembers {
let chain_name = chain_type.shortname();
let sub_dir = Some(chain_name.as_str());
let path = Settings::get_config_path(SERVER_CONFIG_FILE_NAME, sub_dir);
let sub_dir = Some(chain_type.shortname());
let path = Settings::get_config_path(SERVER_CONFIG_FILE_NAME, sub_dir.clone());
let mut default_config = GlobalConfig::for_chain(chain_type);
default_config.update_paths(&Settings::get_base_path(sub_dir));
let config = default_config.members.unwrap();
@@ -188,8 +183,7 @@ impl NodeConfig {
/// Save default peers config for specified [`ChainTypes`].
fn save_default_peers_config(chain_type: &ChainTypes) -> PeersConfig {
let chain_name = chain_type.shortname();
let sub_dir = Some(chain_name.as_str());
let sub_dir = Some(chain_type.shortname());
let path = Settings::get_config_path(PeersConfig::FILE_NAME, sub_dir);
let config = PeersConfig::default();
Settings::write_to_file(&config, path);
@@ -198,8 +192,7 @@ impl NodeConfig {
/// Save node config to the file.
pub fn save(&self) {
let chain_name = self.node.server.chain_type.shortname();
let sub_dir = Some(chain_name.as_str());
let sub_dir = Some(self.node.server.chain_type.shortname());
let config_path = Settings::get_config_path(SERVER_CONFIG_FILE_NAME, sub_dir);
Settings::write_to_file(&self.node, config_path);
}
@@ -241,8 +234,7 @@ impl NodeConfig {
/// Get path for secret file.
fn get_secret_path(chain_type: &ChainTypes, secret_file_name: &str) -> PathBuf {
let chain_name = chain_type.shortname();
let sub_dir = Some(chain_name.as_str());
let sub_dir = Some(chain_type.shortname());
let grin_path = Settings::get_base_path(sub_dir);
let mut api_secret_path = grin_path;
api_secret_path.push(secret_file_name);