redesign: file tree always left, transfer area bottom, bookmarks, history
This commit is contained in:
parent
4e637535f0
commit
9cb8e47a97
7 changed files with 287 additions and 151 deletions
|
|
@ -1,3 +1,4 @@
|
|||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::domain::connection::{ConnectionParams, ConnectionStatus};
|
||||
|
|
@ -27,18 +28,34 @@ pub struct PendingRemoteList {
|
|||
pub result: PendingResult<Vec<FileEntry>>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Bookmark {
|
||||
pub name: String,
|
||||
pub path: String,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct HistoryEntry {
|
||||
pub host: String,
|
||||
pub port: u16,
|
||||
pub user: String,
|
||||
pub time: String,
|
||||
}
|
||||
|
||||
pub struct AppState {
|
||||
pub tabs: Vec<ConnectionTab>,
|
||||
pub active_tab: usize,
|
||||
pub local_path: String,
|
||||
pub local_entries: Vec<FileEntry>,
|
||||
pub local_selected: Option<String>,
|
||||
pub local_tree_open: bool,
|
||||
pub show_connect_dialog: bool,
|
||||
pub onboarding_host: String,
|
||||
pub onboarding_user: String,
|
||||
pub onboarding_pass: String,
|
||||
pub onboarding_port: String,
|
||||
pub show_bookmarks: bool,
|
||||
pub show_history: bool,
|
||||
pub bookmarks: Vec<Bookmark>,
|
||||
pub history: Vec<HistoryEntry>,
|
||||
pub tree_expanded: HashMap<String, bool>,
|
||||
pub tree_children: HashMap<String, Vec<FileEntry>>,
|
||||
pub tree_loading: HashMap<String, bool>,
|
||||
pub connect_label: String,
|
||||
pub connect_host: String,
|
||||
pub connect_port: String,
|
||||
|
|
@ -68,12 +85,18 @@ impl Default for AppState {
|
|||
.to_string(),
|
||||
local_entries: Vec::new(),
|
||||
local_selected: None,
|
||||
local_tree_open: false,
|
||||
show_connect_dialog: false,
|
||||
onboarding_host: String::new(),
|
||||
onboarding_user: String::new(),
|
||||
onboarding_pass: String::new(),
|
||||
onboarding_port: String::new(),
|
||||
show_bookmarks: false,
|
||||
show_history: false,
|
||||
bookmarks: vec![
|
||||
Bookmark { name: "Home".into(), path: dirs::home_dir().unwrap_or_default().to_string_lossy().to_string() },
|
||||
Bookmark { name: "Root".into(), path: "/".into() },
|
||||
Bookmark { name: "Downloads".into(), path: dirs::download_dir().map(|p| p.to_string_lossy().to_string()).unwrap_or_else(|| "/tmp".into()) },
|
||||
],
|
||||
history: Vec::new(),
|
||||
tree_expanded: HashMap::new(),
|
||||
tree_children: HashMap::new(),
|
||||
tree_loading: HashMap::new(),
|
||||
connect_label: String::new(),
|
||||
connect_host: String::new(),
|
||||
connect_port: "22".into(),
|
||||
|
|
@ -112,4 +135,18 @@ impl AppState {
|
|||
Some(&self.tabs[idx])
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_history(&mut self, host: &str, port: u16, user: &str) {
|
||||
use chrono::Local;
|
||||
let now = Local::now().format("%H:%M %d.%m").to_string();
|
||||
self.history.insert(0, HistoryEntry {
|
||||
host: host.into(),
|
||||
port,
|
||||
user: user.into(),
|
||||
time: now,
|
||||
});
|
||||
if self.history.len() > 20 {
|
||||
self.history.truncate(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue