Add launch statistics to dashboard
This commit is contained in:
@@ -39,7 +39,10 @@ pub fn build_dashboard_page(db: &Rc<Database>) -> adw::NavigationPage {
|
||||
// Section 5: Disk Usage (actionable)
|
||||
content.append(&build_disk_usage_group(db));
|
||||
|
||||
// Section 6: Quick Actions
|
||||
// Section 6: Activity
|
||||
content.append(&build_activity_group(db));
|
||||
|
||||
// Section 7: Quick Actions
|
||||
content.append(&build_quick_actions_group());
|
||||
|
||||
clamp.set_child(Some(&content));
|
||||
@@ -350,6 +353,40 @@ fn build_disk_usage_group(db: &Rc<Database>) -> adw::PreferencesGroup {
|
||||
group
|
||||
}
|
||||
|
||||
fn build_activity_group(db: &Rc<Database>) -> adw::PreferencesGroup {
|
||||
let group = adw::PreferencesGroup::builder()
|
||||
.title("Activity")
|
||||
.description("Launch history and usage statistics")
|
||||
.build();
|
||||
|
||||
let total_launches = db.get_total_launch_count().unwrap_or(0);
|
||||
let total_row = adw::ActionRow::builder()
|
||||
.title("Total launches")
|
||||
.subtitle(&total_launches.to_string())
|
||||
.build();
|
||||
group.add(&total_row);
|
||||
|
||||
if let Ok(Some((name, time))) = db.get_last_launch() {
|
||||
let last_row = adw::ActionRow::builder()
|
||||
.title("Last launched")
|
||||
.subtitle(&format!("{} - {}", name, time))
|
||||
.build();
|
||||
group.add(&last_row);
|
||||
}
|
||||
|
||||
if let Ok(top) = db.get_top_launched(5) {
|
||||
for (name, count) in &top {
|
||||
let row = adw::ActionRow::builder()
|
||||
.title(name)
|
||||
.subtitle(&format!("{} launches", count))
|
||||
.build();
|
||||
group.add(&row);
|
||||
}
|
||||
}
|
||||
|
||||
group
|
||||
}
|
||||
|
||||
fn build_quick_actions_group() -> adw::PreferencesGroup {
|
||||
let group = adw::PreferencesGroup::builder()
|
||||
.title("Quick Actions")
|
||||
|
||||
Reference in New Issue
Block a user