From 76a8275af6e575ba5f34bf41ca84f2b2bf1774cd Mon Sep 17 00:00:00 2001 From: songtianlun Date: Wed, 5 Feb 2025 14:18:59 +0800 Subject: [PATCH] feat: add city ranking panel to dashboard - Implement a new panel in the Ahoy Dashboard - Display least popular active cities along with their visit counts - Include action buttons to toggle city statuses with confirmations This addition enhances the admin dashboard by providing insights into city rankings based on user visits. It allows administrators to manage city statuses directly from the dashboard, improving usability and functionality. --- app/admin/ahoy_dashboard.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/admin/ahoy_dashboard.rb b/app/admin/ahoy_dashboard.rb index a73aa5e..19bda68 100644 --- a/app/admin/ahoy_dashboard.rb +++ b/app/admin/ahoy_dashboard.rb @@ -71,6 +71,25 @@ ActiveAdmin.register_page "Ahoy Dashboard" do end end + columns do + column do + panel "城市排名" do + table_for City.least_popular_active do + column("城市") { |city| link_to(city.name, admin_city_path(city)) } + column("访问量") { |city| city.view_count } + column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") } + # column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") } + column("操作") { |city| + button_to "停用", + admin_ahoy_dashboard_toggle_city_status_path(city_id: city.id), + method: :post, + data: { confirm: "确定要停用 #{city.name} 吗?" } + } + end + end + end + end + # 添加一个事件列表面板 panel "最近事件" do table_for Ahoy::Event.order(time: :desc).limit(10) do