refactor: DockerData refactors

Use a croner in the docker_data, instead of in the ui thread, as this thread will be paused when in exec mode.

is_initilised is again done in docker_data, after stats have been calculated

use bollard from git, waiting for new release due to Docker changes
This commit is contained in:
Jack Wills
2023-11-15 16:12:18 +00:00
parent 6a4cf6490d
commit 650aa0fc91
3 changed files with 122 additions and 60 deletions
+10 -1
View File
@@ -121,6 +121,9 @@ pub enum State {
}
impl State {
pub const fn is_alive(self) -> bool {
matches!(self, Self::Running)
}
pub const fn get_color(self) -> Color {
match self {
Self::Paused => Color::Yellow,
@@ -158,6 +161,12 @@ impl From<&str> for State {
}
}
impl From<Option<String>> for State {
fn from(input: Option<String>) -> Self {
input.map_or(Self::Unknown, |input| Self::from(input.as_str()))
}
}
impl fmt::Display for State {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let disp = match self {
@@ -216,7 +225,7 @@ impl fmt::Display for DockerControls {
Self::Restart => "restart",
Self::Start => "start",
Self::Stop => "stop",
Self::Unpause => "unpause",
Self::Unpause => "resume",
};
write!(f, "{disp}")
}