From d470bf001937217b6e6bddd44f679a7ca7fef477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20V=C3=A1squez?= Date: Mon, 20 Jul 2026 17:39:11 -0600 Subject: [PATCH 1/2] Add stats to madmin dashboard and fix VersionJump index columns - Replace the dashboard's resource link grid (duplicated in the sidebar) with stat tiles and recent-activity lists (stories, projects, estimates). - Add Madmin::DashboardController#show to load the counts and recent records. - Show technology, initial_version and target_version on the VersionJumps index (madmin only renders id/title/name by default, so it showed only IDs). - Add a Dashboard nav link and keep the sidebar visible on desktop. --- .../madmin/dashboard_controller.rb | 21 +++++ app/madmin/resources/version_jump_resource.rb | 6 +- .../madmin/application/_navigation.html.erb | 16 +++- app/views/madmin/dashboard/show.html.erb | 77 +++++++++++++++++++ 4 files changed, 113 insertions(+), 7 deletions(-) create mode 100644 app/controllers/madmin/dashboard_controller.rb create mode 100644 app/views/madmin/dashboard/show.html.erb diff --git a/app/controllers/madmin/dashboard_controller.rb b/app/controllers/madmin/dashboard_controller.rb new file mode 100644 index 00000000..1bcc26f4 --- /dev/null +++ b/app/controllers/madmin/dashboard_controller.rb @@ -0,0 +1,21 @@ +module Madmin + class DashboardController < Madmin::ApplicationController + def show + @stats = { + projects_active: Project.active.count, + projects_archived: Project.where(status: "archived").count, + stories_pending: Story.pending.count, + stories_approved: Story.approved.count, + stories_rejected: Story.rejected.count, + estimates: Estimate.count, + users: User.count, + comments: Comment.count, + version_jumps: VersionJump.count + } + + @recent_stories = Story.order(created_at: :desc).limit(5) + @recent_projects = Project.order(created_at: :desc).limit(5) + @recent_estimates = Estimate.includes(:story, :user).order(created_at: :desc).limit(5) + end + end +end diff --git a/app/madmin/resources/version_jump_resource.rb b/app/madmin/resources/version_jump_resource.rb index 6bc0f68f..306e61fe 100644 --- a/app/madmin/resources/version_jump_resource.rb +++ b/app/madmin/resources/version_jump_resource.rb @@ -1,9 +1,9 @@ class VersionJumpResource < Madmin::Resource # Attributes attribute :id, form: false - attribute :technology - attribute :initial_version - attribute :target_version + attribute :technology, index: true + attribute :initial_version, index: true + attribute :target_version, index: true # Associations attribute :projects, form: false diff --git a/app/views/madmin/application/_navigation.html.erb b/app/views/madmin/application/_navigation.html.erb index 54f5240a..1b562a15 100644 --- a/app/views/madmin/application/_navigation.html.erb +++ b/app/views/madmin/application/_navigation.html.erb @@ -20,10 +20,18 @@ -