web: add link to original message.
This commit is contained in:
@@ -7,7 +7,7 @@ use log::{error, info, Level};
|
|||||||
use seed::{prelude::*, *};
|
use seed::{prelude::*, *};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use notmuch::{Message, SearchSummary, ThreadSet};
|
use notmuch::{Message, SearchSummary, ThreadNode, ThreadSet};
|
||||||
|
|
||||||
// ------ ------
|
// ------ ------
|
||||||
// Init
|
// Init
|
||||||
@@ -84,7 +84,7 @@ fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn search_request(query: &str) -> fetch::Result<SearchSummary> {
|
async fn search_request(query: &str) -> fetch::Result<SearchSummary> {
|
||||||
Request::new(get_search_request_url(query))
|
Request::new(api::search(query))
|
||||||
.method(Method::Get)
|
.method(Method::Get)
|
||||||
.fetch()
|
.fetch()
|
||||||
.await?
|
.await?
|
||||||
@@ -93,12 +93,21 @@ async fn search_request(query: &str) -> fetch::Result<SearchSummary> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_search_request_url(query: &str) -> String {
|
mod api {
|
||||||
format!("http://nixos-07:9345/search/{}", query)
|
const BASE_URL: &str = "http://nixos-07:9345";
|
||||||
|
pub fn search(query: &str) -> String {
|
||||||
|
format!("{}/search/{}", BASE_URL, query)
|
||||||
|
}
|
||||||
|
pub fn show(query: &str) -> String {
|
||||||
|
format!("{}/show/{}", BASE_URL, query)
|
||||||
|
}
|
||||||
|
pub fn original(message_id: &str) -> String {
|
||||||
|
format!("{}/original/{}", BASE_URL, message_id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn show_request(query: &str) -> fetch::Result<ThreadSet> {
|
async fn show_request(query: &str) -> fetch::Result<ThreadSet> {
|
||||||
Request::new(get_show_request_url(query))
|
Request::new(api::show(query))
|
||||||
.method(Method::Get)
|
.method(Method::Get)
|
||||||
.fetch()
|
.fetch()
|
||||||
.await?
|
.await?
|
||||||
@@ -107,51 +116,41 @@ async fn show_request(query: &str) -> fetch::Result<ThreadSet> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_show_request_url(query: &str) -> String {
|
|
||||||
format!("http://nixos-07:9345/show/{}", query)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------ ------
|
// ------ ------
|
||||||
// View
|
// View
|
||||||
// ------ ------
|
// ------ ------
|
||||||
|
|
||||||
fn view_message(msg: Option<&Message>) -> Node<Msg> {
|
fn view_message(thread: &ThreadNode) -> Node<Msg> {
|
||||||
|
let msg = thread.0.as_ref();
|
||||||
if let Some(msg) = msg {
|
if let Some(msg) = msg {
|
||||||
div![
|
div![
|
||||||
dl![
|
a![attrs! {At::Href=>api::original(&msg.id)}, "Original"],
|
||||||
dt!["Subject"],
|
table![
|
||||||
dd![&msg.headers.subject],
|
tr![th!["Subject"], td![&msg.headers.subject],],
|
||||||
dt!["From"],
|
tr![th!["From"], td![&msg.headers.from],],
|
||||||
dd![&msg.headers.from],
|
tr![th!["To"], td![&msg.headers.to],],
|
||||||
dt!["To"],
|
tr![th!["CC"], td![&msg.headers.cc],],
|
||||||
dd![&msg.headers.to],
|
tr![th!["BCC"], td![&msg.headers.bcc],],
|
||||||
dt!["CC"],
|
tr![th!["Reply-To"], td![&msg.headers.reply_to],],
|
||||||
dd![&msg.headers.cc],
|
tr![th!["Date"], td![&msg.headers.date],],
|
||||||
dt!["BCC"],
|
|
||||||
dd![&msg.headers.bcc],
|
|
||||||
dt!["Reply-To"],
|
|
||||||
dd![&msg.headers.reply_to],
|
|
||||||
dt!["Date"],
|
|
||||||
dd![&msg.headers.date],
|
|
||||||
],
|
],
|
||||||
dl![
|
table![
|
||||||
dt!["MessageId"],
|
tr![th!["MessageId"], td![&msg.id],],
|
||||||
dd![&msg.id],
|
tr![
|
||||||
dt!["Match"],
|
th!["Match"],
|
||||||
dd![if msg.r#match { "true" } else { "false" }],
|
td![if msg.r#match { "true" } else { "false" }],
|
||||||
dt!["Excluded"],
|
],
|
||||||
dd![if msg.excluded { "true" } else { "false" }],
|
tr![
|
||||||
dt!["Filename"],
|
th!["Excluded"],
|
||||||
dd![&msg.filename],
|
td![if msg.excluded { "true" } else { "false" }],
|
||||||
dt!["Timestamp"],
|
],
|
||||||
dd![msg.timestamp.to_string()],
|
tr![th!["Filename"], td![&msg.filename],],
|
||||||
dt!["Date"],
|
tr![th!["Timestamp"], td![msg.timestamp.to_string()],],
|
||||||
dd![&msg.date_relative],
|
tr![th!["Date"], td![&msg.date_relative],],
|
||||||
dt!["Tags"],
|
tr![th!["Tags"], td![format!("{:?}", msg.tags)],],
|
||||||
dd![format!("{:?}", msg.tags)],
|
|
||||||
],
|
],
|
||||||
// msg.body.iter().map(|part| pre![part])
|
// msg.body.iter().map(|part| pre![part])
|
||||||
pre![format!("{:#?}", msg.body)]
|
pre![format!("{:#?}", thread)]
|
||||||
]
|
]
|
||||||
} else {
|
} else {
|
||||||
div![h2!["No message"]]
|
div![h2!["No message"]]
|
||||||
@@ -173,7 +172,7 @@ fn view(model: &Model) -> Node<Msg> {
|
|||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(thread_node_idx, thread_node)| div![
|
.map(|(thread_node_idx, thread_node)| div![
|
||||||
h3![format!("thread node {}", thread_node_idx)],
|
h3![format!("thread node {}", thread_node_idx)],
|
||||||
view_message(thread_node.0.as_ref())
|
view_message(thread_node)
|
||||||
])
|
])
|
||||||
])]
|
])]
|
||||||
} else if let Some(search_results) = &model.search_results {
|
} else if let Some(search_results) = &model.search_results {
|
||||||
|
|||||||
Reference in New Issue
Block a user