statustab: show active jobs
parent
92b25de34e
commit
e60eb23f4d
|
@ -174,20 +174,20 @@ impl StatusPanel {
|
||||||
ret
|
ret
|
||||||
};
|
};
|
||||||
self.content
|
self.content
|
||||||
.resize(120, 40 + context.accounts.len() * 20, default_cell);
|
.resize(120, 40 + context.accounts.len() * 45, default_cell);
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
"Accounts",
|
"Accounts",
|
||||||
&mut self.content,
|
&mut self.content,
|
||||||
self.theme_default.fg,
|
self.theme_default.fg,
|
||||||
self.theme_default.bg,
|
self.theme_default.bg,
|
||||||
self.theme_default.attrs,
|
self.theme_default.attrs,
|
||||||
((2, 10), (120 - 1, 10)),
|
((2, 2), (120 - 1, 2)),
|
||||||
Some(2),
|
Some(2),
|
||||||
);
|
);
|
||||||
|
|
||||||
for (i, (_h, a)) in context.accounts.iter().enumerate() {
|
for (i, (_h, a)) in context.accounts.iter().enumerate() {
|
||||||
for x in 2..(120 - 1) {
|
for x in 2..(120 - 1) {
|
||||||
set_and_join_box(&mut self.content, (x, 12 + i * 10), BoxBoundary::Horizontal);
|
set_and_join_box(&mut self.content, (x, 4 + i * 10), BoxBoundary::Horizontal);
|
||||||
}
|
}
|
||||||
//create_box(&mut self.content, ((2, 5 + i * 10), (120 - 1, 15 + i * 10)));
|
//create_box(&mut self.content, ((2, 5 + i * 10), (120 - 1, 15 + i * 10)));
|
||||||
let (x, y) = write_string_to_grid(
|
let (x, y) = write_string_to_grid(
|
||||||
|
@ -196,7 +196,7 @@ impl StatusPanel {
|
||||||
self.theme_default.fg,
|
self.theme_default.fg,
|
||||||
self.theme_default.bg,
|
self.theme_default.bg,
|
||||||
Attr::BOLD,
|
Attr::BOLD,
|
||||||
((3, 12 + i * 10), (120 - 2, 12 + i * 10)),
|
((3, 4 + i * 10), (120 - 2, 4 + i * 10)),
|
||||||
Some(3),
|
Some(3),
|
||||||
);
|
);
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
|
@ -205,7 +205,7 @@ impl StatusPanel {
|
||||||
Color::Byte(32),
|
Color::Byte(32),
|
||||||
self.theme_default.bg,
|
self.theme_default.bg,
|
||||||
self.theme_default.attrs,
|
self.theme_default.attrs,
|
||||||
((x, y), (120 - 2, 12 + i * 10)),
|
((x, y), (120 - 2, y)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
|
@ -469,7 +469,7 @@ impl Component for AccountStatus {
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
line += 1;
|
line += 1;
|
||||||
for (i, (name, status)) in extensions.into_iter().enumerate() {
|
for (name, status) in extensions.into_iter() {
|
||||||
let (width, height) = self.content.size();
|
let (width, height) = self.content.size();
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
name.trim_at_boundary(30),
|
name.trim_at_boundary(30),
|
||||||
|
@ -477,7 +477,7 @@ impl Component for AccountStatus {
|
||||||
self.theme_default.fg,
|
self.theme_default.fg,
|
||||||
self.theme_default.bg,
|
self.theme_default.bg,
|
||||||
self.theme_default.attrs,
|
self.theme_default.attrs,
|
||||||
((1, line + i), (width - 1, height - 1)),
|
((1, line), (width - 1, height - 1)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ impl Component for AccountStatus {
|
||||||
Color::Red,
|
Color::Red,
|
||||||
self.theme_default.bg,
|
self.theme_default.bg,
|
||||||
self.theme_default.attrs,
|
self.theme_default.attrs,
|
||||||
((max_name_width + 6, line + i), (width - 1, height - 1)),
|
((max_name_width + 6, line), (width - 1, height - 1)),
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
MailBackendExtensionStatus::Supported { comment: _ } => write_string_to_grid(
|
MailBackendExtensionStatus::Supported { comment: _ } => write_string_to_grid(
|
||||||
|
@ -498,7 +498,7 @@ impl Component for AccountStatus {
|
||||||
Color::Green,
|
Color::Green,
|
||||||
self.theme_default.bg,
|
self.theme_default.bg,
|
||||||
self.theme_default.attrs,
|
self.theme_default.attrs,
|
||||||
((max_name_width + 6, line + i), (width - 1, height - 1)),
|
((max_name_width + 6, line), (width - 1, height - 1)),
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
MailBackendExtensionStatus::Enabled { comment: _ } => write_string_to_grid(
|
MailBackendExtensionStatus::Enabled { comment: _ } => write_string_to_grid(
|
||||||
|
@ -507,7 +507,7 @@ impl Component for AccountStatus {
|
||||||
Color::Green,
|
Color::Green,
|
||||||
self.theme_default.bg,
|
self.theme_default.bg,
|
||||||
self.theme_default.attrs,
|
self.theme_default.attrs,
|
||||||
((max_name_width + 6, line + i), (width - 1, height - 1)),
|
((max_name_width + 6, line), (width - 1, height - 1)),
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
@ -546,8 +546,52 @@ impl Component for AccountStatus {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
line += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
line += 2;
|
||||||
|
|
||||||
|
write_string_to_grid(
|
||||||
|
"In-progress jobs:",
|
||||||
|
&mut self.content,
|
||||||
|
self.theme_default.fg,
|
||||||
|
self.theme_default.bg,
|
||||||
|
Attr::BOLD,
|
||||||
|
((1, line), (width - 1, height - 1)),
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
|
||||||
|
for (job_id, req) in a.active_jobs.iter() {
|
||||||
|
use crate::conf::accounts::JobRequest;
|
||||||
|
let (x, y) = write_string_to_grid(
|
||||||
|
&format!("{} {}", req, job_id),
|
||||||
|
&mut self.content,
|
||||||
|
self.theme_default.fg,
|
||||||
|
self.theme_default.bg,
|
||||||
|
self.theme_default.attrs,
|
||||||
|
((1, line), (width - 1, height - 1)),
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
if let JobRequest::DeleteMailbox { mailbox_hash, .. }
|
||||||
|
| JobRequest::SetMailboxPermissions(mailbox_hash, _, _)
|
||||||
|
| JobRequest::SetMailboxSubscription(mailbox_hash, _, _)
|
||||||
|
| JobRequest::CopyTo(mailbox_hash, _, _)
|
||||||
|
| JobRequest::Refresh(mailbox_hash, _, _)
|
||||||
|
| JobRequest::Fetch(mailbox_hash, _, _) = req
|
||||||
|
{
|
||||||
|
write_string_to_grid(
|
||||||
|
a.mailbox_entries[mailbox_hash].name(),
|
||||||
|
&mut self.content,
|
||||||
|
self.theme_default.fg,
|
||||||
|
self.theme_default.bg,
|
||||||
|
self.theme_default.attrs,
|
||||||
|
((x + 1, y), (width - 1, height - 1)),
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
line += 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* self.content may have been resized with write_string_to_grid() calls above since it has
|
/* self.content may have been resized with write_string_to_grid() calls above since it has
|
||||||
* growable set */
|
* growable set */
|
||||||
|
|
|
@ -278,22 +278,59 @@ impl core::fmt::Debug for JobRequest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl core::fmt::Display for JobRequest {
|
||||||
|
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||||
|
match self {
|
||||||
|
JobRequest::Generic { name, .. } => write!(f, "{}", name),
|
||||||
|
JobRequest::Mailboxes(_, _) => write!(f, "Get mailbox list"),
|
||||||
|
JobRequest::Fetch(_, _, _) => write!(f, "Mailbox fetch"),
|
||||||
|
JobRequest::IsOnline(_, _) => write!(f, "Online status check"),
|
||||||
|
JobRequest::Refresh(_, _, _) => write!(f, "Refresh mailbox"),
|
||||||
|
JobRequest::SetFlags(batch, _, _) => write!(
|
||||||
|
f,
|
||||||
|
"Set flags for {} message{}",
|
||||||
|
batch.len(),
|
||||||
|
if batch.len() == 1 { "" } else { "s" }
|
||||||
|
),
|
||||||
|
JobRequest::SaveMessage { .. } => write!(f, "Save message"),
|
||||||
|
JobRequest::CopyTo(_, _, _) => write!(f, "Copy message."),
|
||||||
|
JobRequest::DeleteMessages(batch, _, _) => write!(
|
||||||
|
f,
|
||||||
|
"Delete {} message{}",
|
||||||
|
batch.len(),
|
||||||
|
if batch.len() == 1 { "" } else { "s" }
|
||||||
|
),
|
||||||
|
JobRequest::CreateMailbox { path, .. } => write!(f, "Create mailbox {}", path),
|
||||||
|
JobRequest::DeleteMailbox { .. } => write!(f, "Delete mailbox"),
|
||||||
|
//JobRequest::RenameMailbox,
|
||||||
|
JobRequest::Search(_) => write!(f, "Search"),
|
||||||
|
JobRequest::AsBytes(_) => write!(f, "Message body fetch"),
|
||||||
|
JobRequest::SetMailboxPermissions(_, _, _) => write!(f, "Set mailbox permissions"),
|
||||||
|
JobRequest::SetMailboxSubscription(_, _, _) => write!(f, "Set mailbox subscription"),
|
||||||
|
JobRequest::Watch { .. } => write!(f, "Background watch"),
|
||||||
|
JobRequest::SendMessageBackground(_, _) | JobRequest::SendMessage => {
|
||||||
|
write!(f, "Sending message")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl JobRequest {
|
impl JobRequest {
|
||||||
fn is_watch(&self) -> bool {
|
pub fn is_watch(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
JobRequest::Watch { .. } => true,
|
JobRequest::Watch { .. } => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_fetch(&self, mailbox_hash: MailboxHash) -> bool {
|
pub fn is_fetch(&self, mailbox_hash: MailboxHash) -> bool {
|
||||||
match self {
|
match self {
|
||||||
JobRequest::Fetch(h, _, _) if *h == mailbox_hash => true,
|
JobRequest::Fetch(h, _, _) if *h == mailbox_hash => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_online(&self) -> bool {
|
pub fn is_online(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
JobRequest::IsOnline(_, _) => true,
|
JobRequest::IsOnline(_, _) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
|
|
Loading…
Reference in New Issue