Merge #1514: [GUI] Change default file name for transactions export
6c1d0518eb7748fe801c7fb141fbc7205eed27ec use left alignment for export modal text (Michael Mallan)
f92177c04ace796e7eef5bb7ee5cf5b2a6e563ec align export modal buttons to the right (Michael Mallan)
98195e03b6878cd31e1d34ba246700b6ae95ceb1 hide progress bar once export completed (Michael Mallan)
e5208bb7077ed05ebcc29ddec6d426d0efe6e247 use button helper for exporting transactions (Michael Mallan)
5529a8cd57e8a46327e018d94f903ee8008b6a70 change transactions export default file name (Michael Mallan)
Pull request description:
The default file name has been changed to "liana-txs-{date}.csv", e.g. "liana-txs-2025-01-03T10-03-39.csv".
I also changed the "Export" button to use a helper as suggested by edouardparis.
ACKs for top commit:
edouardparis:
ACK 6c1d0518eb7748fe801c7fb141fbc7205eed27ec
Tree-SHA512: 74a68c4130d7dce8f3e0839089191c7a34dd468a4c7e2a379ef30d049d38f3350a519465b792a6be14d3996288fdb6c5989c9c99b008f429fe85e62abcc4845a
This commit is contained in:
commit
71a110bb8d
@ -1,13 +1,13 @@
|
||||
use iced::{
|
||||
widget::{progress_bar, Button, Column, Container, Row, Space},
|
||||
alignment::Horizontal,
|
||||
widget::{progress_bar, Column, Container, Row, Space},
|
||||
Length,
|
||||
};
|
||||
use liana_ui::{
|
||||
component::{
|
||||
card,
|
||||
button, card,
|
||||
text::{h4_bold, text},
|
||||
},
|
||||
theme,
|
||||
widget::Element,
|
||||
};
|
||||
|
||||
@ -22,14 +22,13 @@ pub fn export_modal<'a>(
|
||||
) -> Element<'a, Message> {
|
||||
let button = match state {
|
||||
ExportState::Started | ExportState::Progress(_) => {
|
||||
Some(Button::new("Cancel").on_press(ExportMessage::UserStop.into()))
|
||||
Some(button::secondary(None, "Cancel").on_press(ExportMessage::UserStop.into()))
|
||||
}
|
||||
ExportState::Ended | ExportState::TimedOut | ExportState::Aborted => {
|
||||
Some(Button::new("Close").on_press(ExportMessage::Close.into()))
|
||||
Some(button::secondary(None, "Close").on_press(ExportMessage::Close.into()))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
.map(|b| b.height(32).style(theme::Button::Primary));
|
||||
};
|
||||
let msg = if let Some(error) = error {
|
||||
format!("{:?}", error)
|
||||
} else {
|
||||
@ -55,31 +54,26 @@ pub fn export_modal<'a>(
|
||||
100.0
|
||||
}
|
||||
};
|
||||
let progress_bar_row = Row::new()
|
||||
.push(Space::with_width(30))
|
||||
.push(progress_bar(0.0..=100.0, p))
|
||||
.push(Space::with_width(30));
|
||||
let button_row = button.map(|b| {
|
||||
let progress_bar_row = (*state != ExportState::Ended).then_some(
|
||||
Row::new()
|
||||
.push(Space::with_width(Length::Fill))
|
||||
.push(b)
|
||||
.push(Space::with_width(Length::Fill))
|
||||
});
|
||||
.push(Space::with_width(30))
|
||||
.push(progress_bar(0.0..=100.0, p))
|
||||
.push(Space::with_width(30)),
|
||||
);
|
||||
card::simple(
|
||||
Column::new()
|
||||
.spacing(10)
|
||||
.push(Container::new(h4_bold(format!("Export {export_type}"))).width(Length::Fill))
|
||||
.push(Space::with_height(Length::Fill))
|
||||
.push(progress_bar_row)
|
||||
.push_maybe(progress_bar_row)
|
||||
.push(Space::with_height(Length::Fill))
|
||||
.push(
|
||||
Row::new()
|
||||
.push(Space::with_width(Length::Fill))
|
||||
.push(text(msg))
|
||||
.push(Space::with_width(Length::Fill)),
|
||||
)
|
||||
.push(Row::new().push(text(msg)))
|
||||
.push(Space::with_height(Length::Fill))
|
||||
.push_maybe(button_row)
|
||||
.push_maybe(button.map(|b| {
|
||||
Container::new(b)
|
||||
.align_x(Horizontal::Right)
|
||||
.width(Length::Fill)
|
||||
}))
|
||||
.push(Space::with_height(5)),
|
||||
)
|
||||
.width(Length::Fixed(500.0))
|
||||
|
||||
@ -45,11 +45,7 @@ pub fn transactions_view<'a>(
|
||||
Row::new()
|
||||
.push(Container::new(h3("Transactions")))
|
||||
.push(Space::with_width(Length::Fill))
|
||||
.push(
|
||||
Button::new("Export")
|
||||
.on_press(ExportMessage::Open.into())
|
||||
.style(theme::Button::Secondary),
|
||||
),
|
||||
.push(button::secondary(None, "Export").on_press(ExportMessage::Open.into())),
|
||||
)
|
||||
.push(
|
||||
Column::new()
|
||||
|
||||
@ -382,9 +382,11 @@ pub async fn export_subscription(mut state: State) -> (ExportProgress, State) {
|
||||
}
|
||||
|
||||
pub async fn get_path() -> Option<PathBuf> {
|
||||
let date = chrono::Local::now().format("%Y-%m-%dT%H-%M-%S");
|
||||
let file_name = format!("liana-txs-{date}.csv");
|
||||
rfd::AsyncFileDialog::new()
|
||||
.set_title("Choose a location to export...")
|
||||
.set_file_name("liana.csv")
|
||||
.set_file_name(file_name)
|
||||
.save_file()
|
||||
.await
|
||||
.map(|fh| fh.path().to_path_buf())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user