feat: enhance Ahoy dashboard city listings
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run
Docker / docker (push) Waiting to run

- Add ID column to least popular active cities table
- Improve region display in cities table
- Remove commented-out code section for cleaner view

This update enhances the Ahoy dashboard by providing more
information in the cities listing, specifically the ID
of each city and a clearer representation of the region
it belongs to. Additionally, it removes outdated code to
improve maintainability.
This commit is contained in:
songtianlun 2025-02-05 15:12:29 +08:00
parent b97ac8b91d
commit 4dca074c6d
2 changed files with 30 additions and 50 deletions

View File

@ -40,9 +40,11 @@ ActiveAdmin.register_page "Ahoy Dashboard" do
panel "最冷门活跃城市" do panel "最冷门活跃城市" do
# table_for City.least_popular_active.limit(10) do # table_for City.least_popular_active.limit(10) do
table_for City.least_popular_active do table_for City.least_popular_active do
column("ID") { |city| city.id }
column("城市") { |city| link_to(city.name, admin_city_path(city)) } column("城市") { |city| link_to(city.name, admin_city_path(city)) }
column("访问量") { |city| city.view_count } column("访问量") { |city| city.view_count }
column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") } column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") }
column("所属区域") { |city| city.country.name+"/"+city.country.region.name }
# column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") } # column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") }
column("操作") { |city| column("操作") { |city|
button_to "停用", button_to "停用",
@ -58,10 +60,11 @@ ActiveAdmin.register_page "Ahoy Dashboard" do
panel "热门未活跃城市" do panel "热门未活跃城市" do
# table_for City.most_popular_inactive.limit(10) do # table_for City.most_popular_inactive.limit(10) do
table_for City.most_popular_inactive do table_for City.most_popular_inactive do
column("ID") { |city| city.id }
column("城市") { |city| link_to(city.name, admin_city_path(city)) } column("城市") { |city| link_to(city.name, admin_city_path(city)) }
column("访问量") { |city| city.view_count } column("访问量") { |city| city.view_count }
column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") } column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") }
column("所属区域") { |city| city.country.region.name } column("所属区域") { |city| city.country.name+"/"+city.country.region.name }
column("操作") { |city| column("操作") { |city|
button_to "激活", button_to "激活",
admin_ahoy_dashboard_toggle_city_status_path(city_id: city.id), admin_ahoy_dashboard_toggle_city_status_path(city_id: city.id),
@ -73,31 +76,31 @@ ActiveAdmin.register_page "Ahoy Dashboard" do
end end
end end
columns do # columns do
column do # column do
panel "城市排名" do # panel "城市排名" do
table_for City.by_popularity do # table_for City.by_popularity do
column("城市") { |city| link_to(city.name, admin_city_path(city)) } # column("城市") { |city| link_to(city.name, admin_city_path(city)) }
column("访问量") { |city| city.view_count } # column("访问量") { |city| city.view_count }
column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") }
# column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") } # column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") }
column("操作") { |city| # # column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") }
if city.active? # column("操作") { |city|
button_to "停用", # if city.active?
admin_ahoy_dashboard_toggle_city_status_path(city_id: city.id), # button_to "停用",
method: :post, # admin_ahoy_dashboard_toggle_city_status_path(city_id: city.id),
data: { confirm: "确定要停用 #{city.name} 吗?" } # method: :post,
else # data: { confirm: "确定要停用 #{city.name} 吗?" }
button_to "激活", # else
admin_ahoy_dashboard_toggle_city_status_path(city_id: city.id), # button_to "激活",
method: :post, # admin_ahoy_dashboard_toggle_city_status_path(city_id: city.id),
data: { confirm: "确定要激活 #{city.name} 吗?" } # method: :post,
end # data: { confirm: "确定要激活 #{city.name} 吗?" }
} # end
end # }
end # end
end # end
end # end
# end
# 添加一个事件列表面板 # 添加一个事件列表面板
panel "最近事件" do panel "最近事件" do

View File

@ -39,30 +39,7 @@ ActiveAdmin.register_page "Dashboard" do
end end
end end
columns do # 一个事件列表面板
column do
panel "最冷门活跃城市" do
table_for City.least_popular_active.limit(10) do
column("城市") { |city| link_to(city.name, admin_city_path(city)) }
column("访问量") { |city| city.view_count }
# column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") }
end
end
end
column do
panel "热门未活跃城市" do
table_for City.most_popular_inactive.limit(10) do
column("城市") { |city| link_to(city.name, admin_city_path(city)) }
column("访问量") { |city| city.view_count }
column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") }
column("所属区域") { |city| city.country.region.name }
end
end
end
end
# 添加一个事件列表面板
panel "最近事件" do panel "最近事件" do
table_for Ahoy::Event.order(time: :desc).limit(10) do table_for Ahoy::Event.order(time: :desc).limit(10) do
column :time column :time