wip: sort by

This commit is contained in:
Jack Wills
2022-07-22 16:33:40 +00:00
parent dc4a62910c
commit d14744b378
6 changed files with 258 additions and 166 deletions
+24 -25
View File
@@ -1,6 +1,7 @@
use bollard::{
container::{ListContainersOptions, LogsOptions, StartContainerOptions, Stats, StatsOptions},
Docker, models::ContainerSummary,
models::ContainerSummary,
Docker,
};
use futures_util::{future::join_all, StreamExt};
use parking_lot::Mutex;
@@ -8,7 +9,7 @@ use std::sync::Arc;
use tokio::{sync::mpsc::Receiver, task::JoinHandle};
use crate::{
app_data::{AppData, DockerControls, SortedOrder, Header},
app_data::{AppData, DockerControls, Header, SortedOrder},
app_error::AppError,
parse_args::CliArgs,
ui::GuiState,
@@ -123,25 +124,25 @@ impl DockerData {
}
}
// pub fn sort_containers(i: &mut [ContainerSummary], so: SortedOrder, header: Header) -> &[ContainerSummary] {
// match header {
// Header::State => {
// match so {
// SortedOrder::Asc => i.sort_by(|a,b|b.state.cmp(&a.state)),
// SortedOrder::Desc => i.sort_by(|a,b|a.state.cmp(&b.state)),
// }
// pub fn sort_containers(i: &mut [ContainerSummary], so: SortedOrder, header: Header) -> &[ContainerSummary] {
// match header {
// Header::State => {
// match so {
// SortedOrder::Asc => i.sort_by(|a,b|b.state.cmp(&a.state)),
// SortedOrder::Desc => i.sort_by(|a,b|a.state.cmp(&b.state)),
// }
// },
// Header::Image => {
// match so {
// SortedOrder::Asc => i.sort_by(|a,b|b.image.cmp(&a.image)),
// SortedOrder::Desc => i.sort_by(|a,b|a.image.cmp(&b.image)),
// }
// },
// _ => ()
// }
// i
// }
// },
// Header::Image => {
// match so {
// SortedOrder::Asc => i.sort_by(|a,b|b.image.cmp(&a.image)),
// SortedOrder::Desc => i.sort_by(|a,b|a.image.cmp(&b.image)),
// }
// },
// _ => ()
// }
// i
// }
/// Get all current containers, handle into ContainerItem in the app_data struct rather than here
/// Just make sure that items sent are guaranteed to have an id
@@ -163,13 +164,12 @@ impl DockerData {
.filter(|i| i.id.is_some())
.for_each(|c| output.push(c.to_owned()));
// containers.so
// let a = Self::sort_containers(&mut output, SortedOrder::Asc, Header::State);
// containers.so
// let a = Self::sort_containers(&mut output, SortedOrder::Asc, Header::State);
self.app_data.lock().update_containers(&output);
// self.app_data.lock().sort_containers(SortedOrder::Asc, Header::State);
// self.app_data.lock().sort_containers(SortedOrder::Asc, Header::State);
output
.iter()
@@ -241,7 +241,6 @@ impl DockerData {
};
self.update_all_container_stats(&all_ids).await;
}
/// Animate the loading icon