Merge pull request #2304 from r888888888/admin-dashboard

Admin dashboard
This commit is contained in:
Albert Yi
2014-11-07 14:12:55 -08:00
16 changed files with 224 additions and 157 deletions

View File

@@ -0,0 +1,5 @@
#c-admin-dashboards {
.section {
margin-bottom: 2em;
}
}

View File

@@ -0,0 +1,9 @@
module Admin
class DashboardsController < ApplicationController
before_filter :admin_only
def show
@dashboard = AdminDashboard.new
end
end
end

View File

@@ -18,7 +18,8 @@ class UserNameChangeRequestsController < ApplicationController
if @change_request.errors.any?
render :action => "new"
else
redirect_to user_name_change_request_path(@change_request), :notice => "Your request has been submitted and is pending admin review"
@change_request.approve!
redirect_to user_name_change_request_path(@change_request), :notice => "Your name has been changed"
end
end

View File

@@ -0,0 +1,17 @@
class AdminDashboard
def tag_aliases
TagAlias.where(status: "pending").order("id desc")
end
def tag_implications
TagImplication.where(status: "pending").order("id desc")
end
def update_requests
BulkUpdateRequest.where(status: "pending").order("id desc")
end
def forum_topics
ForumTopic.where(category_id: 1).order("id desc").limit(20)
end
end

View File

@@ -0,0 +1,29 @@
<div id="c-admin-dashboards">
<div id="a-show">
<h1>Admin Dashboard</h1>
<div class="section">
<h2>Aliases</h2>
<%= render "tag_aliases/listing", :tag_aliases => @dashboard.tag_aliases %>
</div>
<div class="section">
<h2>Implications</h2>
<%= render "tag_implications/listing", :tag_implications => @dashboard.tag_implications %>
</div>
<div class="section">
<h2>Bulk Update Requests</h2>
<%= render "bulk_update_requests/listing", :bulk_update_requests => @dashboard.update_requests %>
</div>
<div class="section">
<h2>Forum Topics</h2>
<%= render "forum_topics/listing", :forum_topics => @dashboard.forum_topics %>
</div>
</div>
</div>
<% content_for(:page_title) do %>
Admin Dashboard - <%= Danbooru.config.app_name %>
<% end %>

View File

@@ -0,0 +1,30 @@
<table class="striped" width="100%">
<thead>
<tr>
<th>Creator</th>
<th>Forum</th>
<th>Script</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
<% bulk_update_requests.each do |request| %>
<tr id="request-<%= request.id %>">
<td><%= link_to_user(request.user) %></td>
<td><%= link_to(request.forum_topic_id, forum_topic_path(request.forum_topic_id)) %></td>
<td><%= script_with_line_breaks(request.script) %></td>
<td><%= request.status %></td>
<td>
<% if CurrentUser.is_moderator? && request.status == "pending" %>
<%= link_to "Approve", approve_bulk_update_request_path(request), :method => :post %> |
<% end %>
<% if request.editable?(CurrentUser.user) %>
<%= link_to "Delete", bulk_update_request_path(request), :method => :delete, :data => {:confirm => "Are you sure you want to delete this bulk update request?"} %> |
<%= link_to "Edit", edit_bulk_update_request_path(request) %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>

View File

@@ -2,36 +2,7 @@
<div class="index">
<h1>Bulk Update Requests</h1>
<table class="striped" width="100%">
<thead>
<tr>
<th>Creator</th>
<th>Forum</th>
<th>Script</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
<% @bulk_update_requests.each do |request| %>
<tr id="request-<%= request.id %>">
<td><%= link_to_user(request.user) %></td>
<td><%= link_to(request.forum_topic_id, forum_topic_path(request.forum_topic_id)) %></td>
<td><%= script_with_line_breaks(request.script) %></td>
<td><%= request.status %></td>
<td>
<% if CurrentUser.is_moderator? && request.status == "pending" %>
<%= link_to "Approve", approve_bulk_update_request_path(request), :method => :post %> |
<% end %>
<% if request.editable?(CurrentUser.user) %>
<%= link_to "Delete", bulk_update_request_path(request), :method => :delete, :data => {:confirm => "Are you sure you want to delete this bulk update request?"} %> |
<%= link_to "Edit", edit_bulk_update_request_path(request) %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= render "listing", :bulk_update_requests => @bulk_update_requests %>
<%= numbered_paginator(@bulk_update_requests) %>
</div>

View File

@@ -0,0 +1,38 @@
<table width="100%" class="striped">
<thead>
<tr>
<th>Title</th>
<th>Creator</th>
<th>Updated by</th>
<th>Updated at</th>
</tr>
</thead>
<tbody>
<% forum_topics.each do |topic| %>
<tr class="forum-topic-row forum-topic-category-<%= topic.category_id %>">
<td>
<% if topic.is_sticky? %>
<span class="sticky">Sticky:</span>
<% end %>
<% unless topic.read_by?(CurrentUser.user) %>
<span class="new">NEW</span>
<% end %>
<%= link_to topic.title, forum_topic_path(topic) %>
<% if topic.response_count > Danbooru.config.posts_per_page %>
<%= link_to "page #{topic.last_page}", forum_topic_path(topic, :page => topic.last_page), :class => "last-page" %>
<% end %>
<% if topic.is_locked? %>
<span class="locked-topic">(locked)</span>
<% end %>
</td>
<td><%= link_to_user topic.creator %></td>
<td><%= link_to_user topic.updater %></td>
<td><%= compact_time topic.updated_at %></td>
</tr>
<% end %>
</tbody>
</table>

View File

@@ -7,44 +7,7 @@
<%= link_to "All", forum_topics_path %>, <%= ForumTopic::CATEGORIES.map {|id, name| link_to_unless_current(name, forum_topics_path(:search => {:category_id => id}))}.join(", ").html_safe %>
</p>
<table width="100%" class="striped">
<thead>
<tr>
<th>Title</th>
<th>Creator</th>
<th>Updated by</th>
<th>Updated at</th>
</tr>
</thead>
<tbody>
<% @forum_topics.each do |topic| %>
<tr class="forum-topic-row forum-topic-category-<%= topic.category_id %>">
<td>
<% if topic.is_sticky? %>
<span class="sticky">Sticky:</span>
<% end %>
<% unless topic.read_by?(CurrentUser.user) %>
<span class="new">NEW</span>
<% end %>
<%= link_to topic.title, forum_topic_path(topic) %>
<% if topic.response_count > Danbooru.config.posts_per_page %>
<%= link_to "page #{topic.last_page}", forum_topic_path(topic, :page => topic.last_page), :class => "last-page" %>
<% end %>
<% if topic.is_locked? %>
<span class="locked-topic">(locked)</span>
<% end %>
</td>
<td><%= link_to_user topic.creator %></td>
<td><%= link_to_user topic.updater %></td>
<td><%= compact_time topic.updated_at %></td>
</tr>
<% end %>
</tbody>
</table>
<%= render "listing", :forum_topics => @forum_topics %>
<%= numbered_paginator(@forum_topics) %>
</div>

View File

@@ -113,6 +113,7 @@
<li><%= link_to("IP Bans", ip_bans_path) %></li>
<li><%= link_to("News Updates", news_updates_path) %></li>
<li><%= link_to("Alias & Implication Import", new_admin_alias_and_implication_import_path) %></li>
<li><%= link_to("Admin Dashboard", admin_dashboard_path) %></li>
<% end %>
<% if Danbooru.config.is_user_advertiser?(CurrentUser.user) %>

View File

@@ -0,0 +1,46 @@
<table width="100%" class="striped">
<thead>
<tr>
<th width="30%">From</th>
<th width="30%">To</th>
<th width="10%">Reference</th>
<th width="10%">Status</th>
<th width="20%"></th>
</tr>
</thead>
<tbody>
<% tag_aliases.each do |tag_alias| %>
<tr id="tag-alias-<%= tag_alias.id %>">
<td class="category-<%= tag_alias.antecedent_tag.category %>"><%= link_to tag_alias.antecedent_name, posts_path(:tags => tag_alias.antecedent_name) %> <span class="count"><%= tag_alias.antecedent_tag.post_count rescue 0 %></span></td>
<td class="category-<%= tag_alias.consequent_tag.try(:category) %>"><%= link_to tag_alias.consequent_name, posts_path(:tags => tag_alias.consequent_name) %> <span class="count"><%= tag_alias.consequent_tag.post_count rescue 0 %></span></td>
<td>
<% if tag_alias.forum_topic_id %>
<%= link_to tag_alias.forum_topic_id, forum_topic_path(tag_alias.forum_topic_id) %>
<% end %>
</td>
<td id="tag-alias-status-for-<%= tag_alias.id %>">
<%= tag_alias.status %>
</td>
<td>
<%= link_to "Show", tag_alias_path(tag_alias) %>
<% if tag_alias.editable_by?(CurrentUser.user) %>
| <%= link_to "Edit", edit_tag_alias_path(tag_alias) %>
<% end %>
<% if tag_alias.is_pending? && tag_alias.editable_by?(CurrentUser.user) %>
| <%= link_to "Delete", tag_alias_path(tag_alias), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this alias?"} %>
<% end %>
<% if CurrentUser.is_admin? && tag_alias.is_pending? %>
| <%= link_to "Approve", approve_tag_alias_path(tag_alias), :remote => true, :method => :post %>
<% end %>
<% if CurrentUser.is_janitor? %>
| <%= link_to "Fix", tag_alias_correction_path(:tag_alias_id => tag_alias.id) %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>

View File

@@ -7,58 +7,13 @@
<% end %>
</div>
<table width="100%" class="striped">
<thead>
<tr>
<th width="30%">From</th>
<th width="30%">To</th>
<th width="10%">Reference</th>
<th width="10%">Status</th>
<th width="20%"></th>
</tr>
</thead>
<tbody>
<% @tag_aliases.each do |tag_alias| %>
<tr id="tag-alias-<%= tag_alias.id %>">
<td class="category-<%= tag_alias.antecedent_tag.category %>"><%= link_to tag_alias.antecedent_name, posts_path(:tags => tag_alias.antecedent_name) %> <span class="count"><%= tag_alias.antecedent_tag.post_count rescue 0 %></span></td>
<td class="category-<%= tag_alias.consequent_tag.try(:category) %>"><%= link_to tag_alias.consequent_name, posts_path(:tags => tag_alias.consequent_name) %> <span class="count"><%= tag_alias.consequent_tag.post_count rescue 0 %></span></td>
<td>
<% if tag_alias.forum_topic_id %>
<%= link_to tag_alias.forum_topic_id, forum_topic_path(tag_alias.forum_topic_id) %>
<% end %>
</td>
<td id="tag-alias-status-for-<%= tag_alias.id %>">
<%= tag_alias.status %>
</td>
<td>
<%= link_to "Show", tag_alias_path(tag_alias) %>
<%= render "listing", :tag_aliases => @tag_aliases %>
<% if tag_alias.editable_by?(CurrentUser.user) %>
| <%= link_to "Edit", edit_tag_alias_path(tag_alias) %>
<% end %>
<% if tag_alias.is_pending? && tag_alias.editable_by?(CurrentUser.user) %>
| <%= link_to "Delete", tag_alias_path(tag_alias), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this alias?"} %>
<% end %>
<% if CurrentUser.is_admin? && tag_alias.is_pending? %>
| <%= link_to "Approve", approve_tag_alias_path(tag_alias), :remote => true, :method => :post %>
<% end %>
<% if CurrentUser.is_janitor? %>
| <%= link_to "Fix", tag_alias_correction_path(:tag_alias_id => tag_alias.id) %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= numbered_paginator(@tag_aliases) %>
<%= numbered_paginator(@tag_aliases) if @tag_aliases.respond_to?(:current_page) %>
</div>
</div>
<%= render "secondary_links" %>
<%= render "tag_aliases/secondary_links" %>
<% content_for(:page_title) do %>
Tag Aliases - <%= Danbooru.config.app_name %>

View File

@@ -0,0 +1,40 @@
<table width="100%" class="striped">
<thead>
<tr>
<th width="30%">From</th>
<th width="30%">To</th>
<th width="10%">Reference</th>
<th width="10%">Status</th>
<th width="15%"></th>
</tr>
</thead>
<tbody>
<% tag_implications.each do |tag_implication| %>
<tr id="tag-implication-<%= tag_implication.id %>">
<td><%= link_to tag_implication.antecedent_name, posts_path(:tags => tag_implication.antecedent_name) %> <span class="count"><%= tag_implication.antecedent_tag.post_count rescue 0 %></span></td>
<td><%= link_to tag_implication.consequent_name, posts_path(:tags => tag_implication.consequent_name) %> <span class="count"><%= tag_implication.consequent_tag.post_count rescue 0 %></span></td>
<td>
<% if tag_implication.forum_topic_id %>
<%= link_to tag_implication.forum_topic_id, forum_topic_path(tag_implication.forum_topic_id) %>
<% end %>
</td>
<td id="tag-implication-status-for-<%= tag_implication.id %>"><%= tag_implication.status %></td>
<td>
<%= link_to "Show", tag_implication_path(tag_implication) %>
<% if tag_implication.is_pending? && tag_implication.editable_by?(CurrentUser.user) %>
| <%= link_to "Edit", edit_tag_implication_path(tag_implication) %>
<% end %>
<% if tag_implication.deletable_by?(CurrentUser.user) %>
| <%= link_to "Delete", tag_implication_path(tag_implication), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this implication?"} %>
<% end %>
<% if CurrentUser.user.is_admin? && tag_implication.is_pending? %>
| <%= link_to "Approve", approve_tag_implication_path(tag_implication), :remote => true, :method => :post %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>

View File

@@ -7,46 +7,7 @@
<% end %>
</div>
<table width="100%" class="striped">
<thead>
<tr>
<th width="30%">From</th>
<th width="30%">To</th>
<th width="10%">Reference</th>
<th width="10%">Status</th>
<th width="15%"></th>
</tr>
</thead>
<tbody>
<% @tag_implications.each do |tag_implication| %>
<tr id="tag-implication-<%= tag_implication.id %>">
<td><%= link_to tag_implication.antecedent_name, posts_path(:tags => tag_implication.antecedent_name) %> <span class="count"><%= tag_implication.antecedent_tag.post_count rescue 0 %></span></td>
<td><%= link_to tag_implication.consequent_name, posts_path(:tags => tag_implication.consequent_name) %> <span class="count"><%= tag_implication.consequent_tag.post_count rescue 0 %></span></td>
<td>
<% if tag_implication.forum_topic_id %>
<%= link_to tag_implication.forum_topic_id, forum_topic_path(tag_implication.forum_topic_id) %>
<% end %>
</td>
<td id="tag-implication-status-for-<%= tag_implication.id %>"><%= tag_implication.status %></td>
<td>
<%= link_to "Show", tag_implication_path(tag_implication) %>
<% if tag_implication.is_pending? && tag_implication.editable_by?(CurrentUser.user) %>
| <%= link_to "Edit", edit_tag_implication_path(tag_implication) %>
<% end %>
<% if tag_implication.deletable_by?(CurrentUser.user) %>
| <%= link_to "Delete", tag_implication_path(tag_implication), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this implication?"} %>
<% end %>
<% if CurrentUser.user.is_admin? && tag_implication.is_pending? %>
| <%= link_to "Approve", approve_tag_implication_path(tag_implication), :remote => true, :method => :post %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= render "listing", :tag_implications => @tag_implications %>
<%= numbered_paginator(@tag_implications) %>
</div>

View File

@@ -2,6 +2,7 @@ Rails.application.routes.draw do
namespace :admin do
resources :users, :only => [:edit, :update]
resource :alias_and_implication_import, :only => [:new, :create]
resource :dashboard, :only => [:show]
end
namespace :mobile do
resources :posts, :only => [:index, :show]