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.
This commit is contained in:
songtianlun 2025-02-05 14:18:59 +08:00
parent 31c2913ea6
commit 76a8275af6

View File

@ -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