- Update menu labels for cities, countries, and regions - Introduce new entities for states and subregions in Admin Panel - Implement admin authentication for weather art generation - Modify application controller to check for admin user - Refactor view to display admin panel based on user permissions - Update routes to include weather art generation action These changes enhance the admin interface for better management of cities and related entities. The new admin checks ensure that only authorized users can generate weather art, improving security and functionality.
58 lines
2.7 KiB
Plaintext
58 lines
2.7 KiB
Plaintext
<!-- 主要统计信息后面添加 -->
|
|
<% if current_user_is_admin? %>
|
|
<div class="mt-8 p-6 bg-base-100/90 backdrop-blur-sm shadow-xl rounded-box">
|
|
<h3 class="text-xl font-bold mb-4 flex items-center gap-2">
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z" />
|
|
</svg>
|
|
Admin Panel
|
|
</h3>
|
|
|
|
<!-- 统计数据 -->
|
|
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4 mb-6">
|
|
<div class="stat bg-base-200/50 rounded-box">
|
|
<div class="stat-title">Success Rate</div>
|
|
<div class="stat-value text-primary text-2xl">
|
|
<%= "hello" %>%
|
|
</div>
|
|
<div class="stat-desc">Generation Success Rate</div>
|
|
</div>
|
|
|
|
<div class="stat bg-base-200/50 rounded-box">
|
|
<div class="stat-title">Last Generated</div>
|
|
<div class="stat-value text-2xl">
|
|
<%= time_ago_in_words(@city.weather_arts.last&.created_at) if @city.weather_arts.last %>
|
|
</div>
|
|
<div class="stat-desc">Time since last generation</div>
|
|
</div>
|
|
|
|
<div class="stat bg-base-200/50 rounded-box">
|
|
<div class="stat-title">Failed Attempts</div>
|
|
<div class="stat-value text-error text-2xl">
|
|
<%= "hello" %>
|
|
</div>
|
|
<div class="stat-desc">Total failed generations</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 操作按钮 -->
|
|
<div class="flex flex-wrap gap-4">
|
|
<%= button_to generate_weather_art_city_path(@city),
|
|
method: :post,
|
|
class: "btn btn-primary gap-2" do %>
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" />
|
|
</svg>
|
|
Generate New Art
|
|
<% end %>
|
|
|
|
<%= link_to edit_city_path(@city),
|
|
class: "btn btn-secondary gap-2" do %>
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
|
|
</svg>
|
|
Edit City
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<% end %> |