Restyle index table.
This commit is contained in:
parent
19ee6f338d
commit
e5a27f82f9
@ -425,14 +425,14 @@ pub struct SearchTags(pub Vec<String>);
|
|||||||
pub struct ThreadSummary {
|
pub struct ThreadSummary {
|
||||||
pub thread: ThreadId,
|
pub thread: ThreadId,
|
||||||
pub timestamp: UnixTime,
|
pub timestamp: UnixTime,
|
||||||
pub date_relative: String,
|
|
||||||
/// user-friendly timestamp
|
/// user-friendly timestamp
|
||||||
pub matched: isize,
|
pub date_relative: String,
|
||||||
/// number of matched messages
|
/// number of matched messages
|
||||||
pub total: isize,
|
pub matched: isize,
|
||||||
/// total messages in thread
|
/// total messages in thread
|
||||||
pub authors: String,
|
pub total: isize,
|
||||||
/// comma-separated names with | between matched and unmatched
|
/// comma-separated names with | between matched and unmatched
|
||||||
|
pub authors: String,
|
||||||
pub subject: String,
|
pub subject: String,
|
||||||
pub tags: Vec<String>,
|
pub tags: Vec<String>,
|
||||||
|
|
||||||
@ -541,6 +541,8 @@ impl Notmuch {
|
|||||||
Ok(BufReader::new(child.stdout.take().unwrap()).lines())
|
Ok(BufReader::new(child.stdout.take().unwrap()).lines())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(wathiede): implement tags() based on "notmuch search --output=tags '*'"
|
||||||
|
|
||||||
fn run_notmuch<I, S>(&self, args: I) -> Result<Vec<u8>, NotmuchError>
|
fn run_notmuch<I, S>(&self, args: I) -> Result<Vec<u8>, NotmuchError>
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = S>,
|
I: IntoIterator<Item = S>,
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<link rel="modulepreload" href="/pkg/package.js" as="script" type="text/javascript">
|
<link rel="modulepreload" href="/pkg/package.js" as="script" type="text/javascript">
|
||||||
<link rel="preload" href="/pkg/package_bg.wasm" as="fetch" type="application/wasm" crossorigin="anonymous">
|
<link rel="preload" href="/pkg/package_bg.wasm" as="fetch" type="application/wasm" crossorigin="anonymous">
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
|
||||||
<style>
|
<style>
|
||||||
.message {
|
.message {
|
||||||
padding-left: 0.5em;
|
padding-left: 0.5em;
|
||||||
@ -23,6 +24,11 @@ iframe {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
.index .from {
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
.index .subject {
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|||||||
@ -267,6 +267,10 @@ fn set_title(title: &str) {
|
|||||||
seed::document().set_title(&format!("lb: {}", title));
|
seed::document().set_title(&format!("lb: {}", title));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn tags_chiclet(tags: &[String]) -> Node<Msg> {
|
||||||
|
empty![]
|
||||||
|
}
|
||||||
|
|
||||||
fn view_search_results(query: &str, search_results: &SearchSummary) -> Node<Msg> {
|
fn view_search_results(query: &str, search_results: &SearchSummary) -> Node<Msg> {
|
||||||
if query.is_empty() {
|
if query.is_empty() {
|
||||||
set_title("all mail");
|
set_title("all mail");
|
||||||
@ -276,20 +280,32 @@ fn view_search_results(query: &str, search_results: &SearchSummary) -> Node<Msg>
|
|||||||
let rows = search_results.0.iter().map(|r| {
|
let rows = search_results.0.iter().map(|r| {
|
||||||
let tid = r.thread.clone();
|
let tid = r.thread.clone();
|
||||||
tr![
|
tr![
|
||||||
td![],
|
|
||||||
td![
|
td![
|
||||||
|
C!["from"],
|
||||||
&r.authors,
|
&r.authors,
|
||||||
IF!(r.total>1 => small![" ", r.total.to_string()]),
|
IF!(r.total>1 => small![" ", r.total.to_string()]),
|
||||||
IF!(r.tags.contains(&"attachment".to_string()) => "📎"),
|
IF!(r.tags.contains(&"attachment".to_string()) => "📎"),
|
||||||
],
|
],
|
||||||
td![&r.subject],
|
td![C!["subject"], tags_chiclet(&r.tags), &r.subject],
|
||||||
td![&r.date_relative],
|
td![C!["date"], &r.date_relative],
|
||||||
ev(Ev::Click, move |_| Msg::ShowRequest(tid)),
|
ev(Ev::Click, move |_| Msg::ShowRequest(tid)),
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
div![table![
|
div![table![
|
||||||
tr![th!["tid"], th!["From"], th!["Subject"], th!["Date"]],
|
C![
|
||||||
rows
|
"table",
|
||||||
|
"index",
|
||||||
|
"is-fullwidth",
|
||||||
|
"is-hoverable",
|
||||||
|
"is-narrow",
|
||||||
|
"is-striped",
|
||||||
|
],
|
||||||
|
thead![tr![
|
||||||
|
th![C!["from"], "From"],
|
||||||
|
th![C!["subject"], "Subject"],
|
||||||
|
th![C!["date"], "Date"]
|
||||||
|
]],
|
||||||
|
tbody![rows]
|
||||||
]]
|
]]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,13 +359,20 @@ fn view_debug_thread_node(thread_node: &ThreadNode) -> Node<Msg> {
|
|||||||
|
|
||||||
fn view_header(query: &str) -> Node<Msg> {
|
fn view_header(query: &str) -> Node<Msg> {
|
||||||
let query = query.to_string();
|
let query = query.to_string();
|
||||||
div![
|
nav![
|
||||||
button![
|
C!["navbar"],
|
||||||
|
a![
|
||||||
|
C!["navbar-item", "button",],
|
||||||
"Unread",
|
"Unread",
|
||||||
ev(Ev::Click, |_| Msg::SearchRequest("is:unread".to_string())),
|
ev(Ev::Click, |_| Msg::SearchRequest("is:unread".to_string())),
|
||||||
],
|
],
|
||||||
button!["All", ev(Ev::Click, |_| Msg::SearchRequest("".to_string())),],
|
a![
|
||||||
|
C!["navbar-item", "button"],
|
||||||
|
"All",
|
||||||
|
ev(Ev::Click, |_| Msg::SearchRequest("".to_string())),
|
||||||
|
],
|
||||||
input![
|
input![
|
||||||
|
C!["navbar-item", "input"],
|
||||||
attrs! {
|
attrs! {
|
||||||
At::Placeholder => "Search";
|
At::Placeholder => "Search";
|
||||||
At::AutoFocus => true.as_at_value();
|
At::AutoFocus => true.as_at_value();
|
||||||
@ -373,7 +396,11 @@ fn view(model: &Model) -> Node<Msg> {
|
|||||||
Context::Thread(thread_set) => view_thread(thread_set),
|
Context::Thread(thread_set) => view_thread(thread_set),
|
||||||
Context::Search(search_results) => view_search_results(&model.query, search_results),
|
Context::Search(search_results) => view_search_results(&model.query, search_results),
|
||||||
};
|
};
|
||||||
div![view_header(&model.query), content]
|
|
||||||
|
section![
|
||||||
|
C!["section"],
|
||||||
|
div![C!["container"], view_header(&model.query), content]
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------ ------
|
// ------ ------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user