超级管理员页面

dev_aliyun_beta
SylorHuang 5 years ago
parent b9dafd2772
commit 829c91211e

@ -0,0 +1,20 @@
$(document).on('turbolinks:load', function() {
if ($('body.admins-project-package-applies-index-page').length > 0) {
var $searchFrom = $('.project-package-applies-form');
$searchFrom.find('select[name="status"]').val('pending');
$searchFrom.on('click', '.search-form-tab', function(){
var $link = $(this);
$searchFrom.find('input[name="keyword"]').val('');
$searchFrom.find('select[name="status"]').val('all');
if($link.data('value') === 'all'){
$searchFrom.find('.status-filter').show();
} else {
$searchFrom.find('.status-filter').hide();
$searchFrom.find('select[name="status"]').val('pending');
}
});
}
})

@ -0,0 +1,20 @@
$(document).on('turbolinks:load', function() {
if ($('body.admins-video-applies-index-page').length > 0) {
var $searchFrom = $('.video-applies-form');
$searchFrom.find('select[name="status"]').val('pending');
$searchFrom.on('click', '.search-form-tab', function(){
var $link = $(this);
$searchFrom.find('input[name="keyword"]').val('');
$searchFrom.find('select[name="status"]').val('all');
if($link.data('value') === 'all'){
$searchFrom.find('.status-filter').show();
} else {
$searchFrom.find('.status-filter').hide();
$searchFrom.find('select[name="status"]').val('pending');
}
});
}
})

@ -0,0 +1,9 @@
.admins-project-package-applies-index-page {
.project-package-applies-list-container {
span {
&.apply-status-agreed { color: #28a745; }
&.apply-status-refused { color: #dc3545; }
&.apply-status-processed { color: #6c757d; }
}
}
}

@ -0,0 +1,9 @@
.admins-video-applies-index-page {
.video-applies-list-container {
span {
&.apply-status-agreed { color: #28a745; }
&.apply-status-refused { color: #dc3545; }
&.apply-status-processed { color: #6c757d; }
}
}
}

@ -0,0 +1,37 @@
class Admins::ProjectPackageAppliesController < Admins::BaseController
before_action :current_apply,only: [:agree,:refuse]
def index
params[:status] ||= 'pending'
status = params[:status]
if status == 'all'
status = %w(agreed refused)
end
package_applies = ProjectPackageApply.where(status: status)
keyword = params[:keyword].to_s.strip || ""
if keyword.present?
package_applies = package_applies.joins(:project_package).where("project_packages.title like ?","%#{keyword}%")
end
@package_applies = paginate package_applies.includes(project_package: { creator: :user_extension })
end
def agree
ProjectPackages::AgreeApplyService.new(current_apply).call
render_success_js
rescue ProjectPackages::AgreeApplyService::Error => e
render json: { status: -1, message: e.message }
end
def refuse
ProjectPackages::RefuseApplyService.new(current_apply, reason: params[:reason]).call
render_success_js
rescue ProjectPackages::RefuseApplyService::Error => e
render json: { status: -1, message: e.message }
end
private
def current_apply
@_current_apply ||= ProjectPackageApply.find(params[:id])
end
end

@ -0,0 +1,41 @@
class Admins::VideoAppliesController < Admins::BaseController
def index
params[:status] ||= 'pending'
status = params[:status]
if status == 'all'
status = %w(agreed refused)
end
applies = VideoApply.where(status: status).order('video_applies.updated_at desc')
search = params[:keyword].to_s.strip
if search.present?
applies = applies.joins(:video)
.where('videos.title like :search', search: "%#{search}%")
end
@video_applies = paginate applies.includes(video: { user: :user_extension })
end
def agree
Videos::AgreeApplyService.new(current_video_apply, current_user).call
render_success_js
rescue Videos::AgreeApplyService::Error => e
render json: { status: -1, message: e.message }
end
def refuse
Videos::RefuseApplyService.new(current_video_apply, current_user, reason: params[:reason]).call
render_success_js
rescue Videos::RefuseApplyService::Error => e
render json: { status: -1, message: e.message }
end
private
def current_video_apply
@_current_video_apply ||= VideoApply.find(params[:id])
end
end

@ -0,0 +1,32 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('众包需求发布') %>
<% end %>
<div class="box search-form-container flex-column mb-0 pb-0 project-package-applies-form">
<ul class="nav nav-tabs w-100 search-form-tabs">
<li class="nav-item">
<%= link_to '待审批', admins_project_package_applies_path(status: :pending), remote: true, 'data-value': 'pending',
class: "nav-link search-form-tab #{params[:status] == 'pending' ? 'active' : ''}" %>
</li>
<li class="nav-item">
<%= link_to '已审批', admins_project_package_applies_path(status: "all"), remote: true, 'data-value': 'all',
class: "nav-link search-form-tab #{params[:status] != 'pending' ? 'active' : ''}" %>
</li>
</ul>
<%= form_tag(admins_project_package_applies_path(unsafe_params), method: :get, class: 'form-inline search-form justify-content-end mt-3', remote: true) do %>
<div class="form-group status-filter" style="<%= params[:status] != 'pending' ? '' : 'display: none;' %>">
<label for="status">审核状态:</label>
<% status_options = [['全部', 'all'], ['已同意', 'agreed'], ['已拒绝', 'refused']] %>
<%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
</div>
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '需求标题检索') %>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
<% end %>
</div>
<div class="box project-package-applies-list-container">
<%= render(partial: 'admins/project_package_applies/shared/list', locals: { applies: @package_applies}) %>
</div>
<%= render(partial: 'admins/shared/admin_common_refuse_modal') %>

@ -0,0 +1 @@
$('.project-package-applies-list-container').html("<%= j( render partial: 'admins/project_package_applies/shared/list', locals: { applies: @package_applies } ) %>");

@ -0,0 +1,56 @@
<% is_processed = params[:status].to_s != 'pending' %>
<table class="table table-hover text-center library_applies-list-table">
<thead class="thead-light">
<tr>
<th width="8%">头像</th>
<th width="14%">姓名</th>
<th width="26%" class="text-left">众包需求</th>
<th width="26%" class="text-left">需求描述</th>
<th width="16%">时间</th>
<% if is_processed %>
<th width="16%">拒绝原因</th>
<th width="8%">状态</th>
<% else %>
<th width="20%">操作</th>
<% end %>
</tr>
</thead>
<tbody>
<% if applies.present? %>
<% applies.each do |apply| %>
<% package = apply.project_package %>
<% user = package.creator %>
<tr class="project-package-item project-package-applies-<%= apply.id %>">
<td>
<%= link_to "/users/#{user.login}", class: 'professional-authentication-avatar', target: '_blank', data: { toggle: 'tooltip', title: '个人主页' } do %>
<img src="/images/<%= url_to_avatar(user) %>" class="rounded-circle" width="40" height="40" />
<% end %>
</td>
<td><%= user.real_name %></td>
<td class="text-left"><%= link_to package.title, "/crowdsourcing/#{package.id}", :target => "_blank" %></td>
<td class="text-left"><%= overflow_hidden_span package.content[0..50] + "..."%></td>
<td><%= apply.updated_at.strftime('%Y-%m-%d %H:%M') %></td>
<% if is_processed %>
<td class="text-secondary"><%= overflow_hidden_span apply.reason %></td>
<td><span class="apply-status-<%= apply.status %>"><%= t("admins_apply_status.status.#{apply.status}") %></span></td>
<% else %>
<td class="action-container">
<%= agree_link '同意', agree_admins_project_package_apply_path(apply, element: ".project_package_applies-#{apply.id}"), 'data-confirm': '确认审核通过?' %>
<%= javascript_void_link('拒绝', class: 'action refuse-action',
data: {
toggle: 'modal', target: '.admin-common-refuse-modal', id: apply.id,
url: refuse_admins_project_package_apply_path(apply, element: ".project_package_applies-#{apply.id}")
}) %>
</td>
<% end %>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: applies } %>

@ -59,7 +59,10 @@
<li><%= sidebar_item(admins_shixun_authorizations_path, '实训发布', icon: 'object-ungroup', controller: 'admins-shixun_authorizations') %></li>
<li><%= sidebar_item(admins_subject_authorizations_path, '实践课程发布', icon: 'object-group', controller: 'admins-subject_authorizations') %></li>
<li><%= sidebar_item(admins_library_applies_path, '教学案例发布', icon: 'language', controller: 'admins-library_applies') %></li>
<% end %>
<li><%= sidebar_item(admins_project_package_applies_path, '众包需求发布', icon: 'joomla', controller: 'admins-project_package_applies') %></li>
<li><%= sidebar_item(admins_video_applies_path, '视频发布', icon: 'film', controller: 'admins-video_applies') %></li>
<% end %>
</li>
<li><%= sidebar_item('/', '返回主站', icon: 'sign-out', controller: 'root') %></li>

@ -0,0 +1,32 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('视频发布') %>
<% end %>
<div class="box search-form-container flex-column mb-0 pb-0 video-applies-form">
<ul class="nav nav-tabs w-100 search-form-tabs">
<li class="nav-item">
<%= link_to '待审批', admins_video_applies_path(status: :pending), remote: true, 'data-value': 'pending',
class: "nav-link search-form-tab #{params[:status] == 'pending' ? 'active' : ''}" %>
</li>
<li class="nav-item">
<%= link_to '已审批', admins_video_applies_path(status: "all"), remote: true, 'data-value': 'all',
class: "nav-link search-form-tab #{params[:status] != 'pending' ? 'active' : ''}" %>
</li>
</ul>
<%= form_tag(admins_video_applies_path(unsafe_params), method: :get, class: 'form-inline search-form justify-content-end mt-3', remote: true) do %>
<div class="form-group status-filter" style="<%= params[:status] != 'pending' ? '' : 'display: none;' %>">
<label for="status">审核状态:</label>
<% status_options = [['全部', 'all'], ['已同意', 'agreed'], ['已拒绝', 'refused']] %>
<%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
</div>
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '需求标题检索') %>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
<% end %>
</div>
<div class="box video-applies-list-container">
<%= render(partial: 'admins/video_applies/shared/list', locals: { applies: @video_applies}) %>
</div>
<%= render(partial: 'admins/shared/admin_common_refuse_modal') %>

@ -0,0 +1 @@
$('.video-applies-list-container').html("<%= j( render partial: 'admins/video_applies/shared/list', locals: { applies: @video_applies } ) %>");

@ -0,0 +1,56 @@
<% is_processed = params[:status].to_s != 'pending' %>
<table class="table table-hover text-center library_applies-list-table">
<thead class="thead-light">
<tr>
<th width="8%">头像</th>
<th width="14%">姓名</th>
<th width="26%" class="text-left">视频名称</th>
<th width="26%" class="text-left">播放链接</th>
<th width="16%">时间</th>
<% if is_processed %>
<th width="16%">拒绝原因</th>
<th width="8%">状态</th>
<% else %>
<th width="20%">操作</th>
<% end %>
</tr>
</thead>
<tbody>
<% if applies.present? %>
<% applies.each do |v| %>
<% video = v.video %>
<% user = video.user %>
<tr class="video-applies-item video-applies-<%= v.id %>">
<td>
<%= link_to "/users/#{user.login}", class: 'professional-authentication-avatar', target: '_blank', data: { toggle: 'tooltip', title: '个人主页' } do %>
<img src="/images/<%= url_to_avatar(user) %>" class="rounded-circle" width="40" height="40" />
<% end %>
</td>
<td><%= user.real_name %></td>
<td class="text-left"><%= link_to video.title, video.file_url, :target => "_blank" %></td>
<td class="text-left"><%= link_to "播放视频",video.file_url, target: "_blank" %></td>
<td><%= v.updated_at.strftime('%Y-%m-%d %H:%M') %></td>
<% if is_processed %>
<td class="text-secondary"><%= overflow_hidden_span v.reason %></td>
<td><span class="apply-status-<%= v.status %>"><%= t("admins_apply_status.status.#{v.status}") %></span></td>
<% else %>
<td class="action-container">
<%= agree_link '同意', agree_admins_video_apply_path(v, element: ".video_applies-#{v.id}"), 'data-confirm': '确认审核通过?' %>
<%= javascript_void_link('拒绝', class: 'action refuse-action',
data: {
toggle: 'modal', target: '.admin-common-refuse-modal', id: v.id,
url: refuse_admins_video_apply_path(v, element: ".video_applies-#{v.id}")
}) %>
</td>
<% end %>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: applies } %>

@ -6,4 +6,11 @@ zh-CN:
button_test: 测试
button_edit: 编辑
button_delete: 删除
button_delete: 删除
admins_apply_status:
status:
'pending': '待审批'
'processed': '已审批'
'refused': '已拒绝'
'agreed': '已同意'

@ -804,6 +804,12 @@ Rails.application.routes.draw do
post :refuse
end
end
resources :video_applies, only: [:index] do
member do
post :agree
post :refuse
end
end
resources :identity_authentications, only: [:index] do
member do
post :agree

@ -15,4 +15,17 @@
# t.text :actual_output
#
# t.timestamps
# end
# end
#
# video_p = {
# user_id: 1,
# title: "第一个测试的.mp4",
# uuid: "748fa8165062433781ccd87f1f815403",
# cover_url: "http://outin-396971199eed11e991a100163e1c7426.oss-cn-shanghai.aliyuncs.com/sv/30ec9167-16ca9111f7d/30ec9167-16ca9111f7d.mp4",
# file_url: "http://outin-396971199eed11e991a100163e1c7426.oss-cn-shanghai.aliyuncs.com/sv/30ec9167-16ca9111f7d/30ec9167-16ca9111f7d.mp4",
# status: "pending",
# vod_status: "uploaded",
# published_at: nil,
# filesize: 14877403
# }
Loading…
Cancel
Save