feat: enhance Ahoy dashboard city listings
- 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:
parent
b97ac8b91d
commit
4dca074c6d
@ -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| status_tag(city.active? ? "活跃" : "停用") }
|
||||||
column("操作") { |city|
|
# column("操作") { |city|
|
||||||
if city.active?
|
# if city.active?
|
||||||
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),
|
||||||
method: :post,
|
# method: :post,
|
||||||
data: { confirm: "确定要停用 #{city.name} 吗?" }
|
# data: { confirm: "确定要停用 #{city.name} 吗?" }
|
||||||
else
|
# else
|
||||||
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),
|
||||||
method: :post,
|
# method: :post,
|
||||||
data: { confirm: "确定要激活 #{city.name} 吗?" }
|
# data: { confirm: "确定要激活 #{city.name} 吗?" }
|
||||||
end
|
# end
|
||||||
}
|
# }
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
|
||||||
# 添加一个事件列表面板
|
# 添加一个事件列表面板
|
||||||
panel "最近事件" do
|
panel "最近事件" do
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user