admins 页面的修改

This commit is contained in:
sylor_huang@126.com 2020-05-14 18:08:27 +08:00
parent 96e03ac249
commit ac2e3ae730
43 changed files with 822 additions and 58 deletions

View File

@ -135,5 +135,6 @@
padding: 10px 20px 0;
background: #fff;
}
.mt-10{margin-top: 10px;}
}

View File

@ -0,0 +1,83 @@
class Admins::ProjectCategoriesController < Admins::BaseController
before_action :get_category, only: [:edit,:update, :destroy]
before_action :validate_names, only: [:create, :update]
def index
sort_by = params[:sort_by] ||= 'created_at'
sort_direction = params[:sort_direction] ||= 'desc'
q = ProjectCategory.ransack(name_cont: params[:name])
project_categories = q.result(distinct: true).order("#{sort_by} #{sort_direction}")
@project_categories = paginate(project_categories)
end
def new
@project_category = ProjectCategory.new
end
def edit
end
def create
max_position_items = ProjectCategory.select(:id, :position).pluck(:position).reject!(&:blank?)
max_position = max_position_items.present? ? max_position_items.max.to_i : 0
@project_category = ProjectCategory.new(name: @name,position: max_position)
if @project_category.save
redirect_to admins_project_categories_path
flash[:success] = '创建成功'
else
redirect_to admins_project_categories_path
flash[:danger] = '创建失败'
end
end
def update
if @project_category.update_attribute(:name, @name)
redirect_to admins_project_categories_path
flash[:success] = '更新成功'
else
redirect_to admins_project_categories_path
flash[:success] = '更新失败'
end
end
def destroy
if @project_language.destroy
redirect_to admins_project_categories_path
flash[:success] = "删除成功"
else
redirect_to admins_project_categories_path
flash[:danger] = "删除失败"
end
end
private
def get_category
@project_category = ProjectCategory.find_by(id: params[:id])
unless @project_category.present?
redirect_to admins_project_categories_path
flash[:danger] = "分类不存在"
end
end
def check_language_present?(name)
return true if name.blank?
name_downcase = name.downcase
name_upcase = name.upcase
name_first_big = name.capitalize
ProjectCategory.exists?(name: name_downcase) || ProjectCategory.exists?(name: name_upcase) || ProjectCategory.exists?(name: name_first_big)
end
def validate_names
@name = params[:project_category][:name].to_s.first(64)
if @name.blank?
redirect_to admins_project_categories_path
flash[:danger] = '名称不能为空'
elsif check_language_present?(@name) && @project_category.blank?
redirect_to admins_project_categories_path
flash[:danger] = '分类已存在'
end
end
end

View File

@ -0,0 +1,120 @@
class Admins::ProjectIgnoresController < Admins::BaseController
before_action :set_ignore, only: [:edit,:update, :destroy,:show]
before_action :validate_params, only: [:create, :update]
def index
sort_by = params[:sort_by] ||= 'created_at'
sort_direction = params[:sort_direction] ||= 'desc'
q = Ignore.ransack(name_cont: params[:search])
project_ignores = q.result(distinct: true).order("#{sort_by} #{sort_direction}")
@project_ignores = paginate(project_ignores)
end
def new
@project_ignore = Ignore.new
end
def show
end
def create
# conditions = params[:license][:conditions_array].reject(&:blank?).join(",") if params[:license][:conditions_array].present?
# permissions = params[:license][:permissions_array].reject(&:blank?).join(",") if params[:license][:permissions_array].present?
# limitations = params[:license][:limitations_array].reject(&:blank?).join(",") if params[:license][:limitations_array].present?
# max_position_items = License.select(:id, :position).pluck(:position).reject!(&:blank?)
# max_position = max_position_items.present? ? max_position_items.max.to_i : 0
# other_params = {
# conditions: conditions.to_s,
# permissions: permissions.to_s,
# limitations: limitations.to_s,
# position: max_position
# }
@project_ignore = Ignore.new(ignore_params)
if @project_ignore.save!
redirect_to admins_project_ignores_path
flash[:success] = "创建成功"
else
render :new
flash[:danger] = "创建失败"
end
end
def edit
end
def update
# conditions = params[:license][:conditions_array].reject(&:blank?).join(",") if params[:license][:conditions_array].present?
# permissions = params[:license][:permissions_array].reject(&:blank?).join(",") if params[:license][:permissions_array].present?
# limitations = params[:license][:limitations_array].reject(&:blank?).join(",") if params[:license][:limitations_array].present?
# other_params = {
# conditions: conditions.to_s,
# permissions: permissions.to_s,
# limitations: limitations.to_s
# }
if @project_ignore.update_attributes(ignore_params)
redirect_to admins_project_ignores_path
flash[:success] = "更新成功"
else
render :edit
flash[:danger] = "更新失败"
end
end
def destroy
if @project_ignore.present?
if @project_ignore.destroy
redirect_to admins_project_ignores_path
flash[:success] = "删除成功"
else
redirect_to admins_project_ignores_path
flash[:success] = "删除失败"
end
else
redirect_to admins_project_ignores_path
flash[:success] = "删除失败:许可证已被项目引用"
end
end
# def move
# cate_opt = params[:opr]
# cate_position = @project_license.position.to_i
# move_status = up_and_down(cate_opt,@project_license,cate_position,"license")
# if move_status == 0
# @c_msg = "移动成功"
# else
# @c_msg = "移动失败"
# end
# end
private
def set_ignore
@project_ignore = Ignore.find_by_id(params[:id])
end
def ignore_params
params.require(:ignore).permit(:name,:content)
end
def validate_params
name = params[:ignore][:name]
if name.blank?
flash[:danger] = "名称不允许为空"
redirect_to admins_project_ignores_path
elsif check_ignore_present?(name) && @project_ignore.blank?
flash[:danger] = "创建失败:名称已存在"
redirect_to admins_project_ignores_path
end
end
def check_ignore_present?(name)
return true if name.blank?
name_downcase = name.downcase
name_upcase = name.upcase
name_first_big = name.capitalize
Ignore.exists?(name: name_downcase) || Ignore.exists?(name: name_upcase) || Ignore.exists?(name: name_first_big)
end
end

View File

@ -0,0 +1,82 @@
class Admins::ProjectLanguagesController < Admins::BaseController
before_action :get_language, only: [:edit,:update, :destroy]
before_action :validate_names, only: [:create, :update]
def index
sort_by = params[:sort_by] ||= 'created_at'
sort_direction = params[:sort_direction] ||= 'desc'
q = ProjectLanguage.ransack(name_cont: params[:search])
project_languages = q.result(distinct: true).order("#{sort_by} #{sort_direction}")
@project_languages = paginate(project_languages)
end
def new
@project_language = ProjectLanguage.new
end
def edit
end
def create
max_position_items = ProjectLanguage.select(:id, :position).pluck(:position).reject!(&:blank?)
max_position = max_position_items.present? ? max_position_items.max.to_i : 0
@project_language = ProjectLanguage.new(name: @name,position:max_position)
if @project_language.save
redirect_to admins_project_languages_path
flash[:success] = '创建成功'
else
redirect_to admins_project_languages_path
flash[:danger] = '创建失败'
end
end
def update
if @project_language.update_attribute(:name, @name)
redirect_to admins_project_languages_path
flash[:success] = '更新成功'
else
redirect_to admins_project_languages_path
flash[:success] = '更新失败'
end
end
def destroy
if @project_language.destroy
redirect_to admins_project_languages_path
flash[:success] = "项目语言删除成功"
else
redirect_to admins_project_languages_path
flash[:danger] = "项目语言删除失败"
end
end
private
def get_language
@project_language = ProjectLanguage.find_by(id: params[:id])
unless @project_language.present?
redirect_to admins_project_languages_path
flash[:danger] = "项目语言不存在"
end
end
def check_language_present?(name)
return true if name.blank?
name_downcase = name.downcase
name_upcase = name.upcase
name_first_big = name.capitalize
ProjectLanguage.exists?(name: name_downcase) || ProjectLanguage.exists?(name: name_upcase) || ProjectLanguage.exists?(name: name_first_big)
end
def validate_names
@name = params[:project_language][:name].to_s.first(64)
if @name.blank?
redirect_to admins_project_languages_path
flash[:danger] = '名称不能为空'
elsif check_language_present?(@name) && @project_language.blank?
redirect_to admins_project_languages_path
flash[:danger] = '项目语言已存在'
end
end
end

View File

@ -0,0 +1,120 @@
class Admins::ProjectLicensesController < Admins::BaseController
before_action :set_license, only: [:edit,:update, :destroy,:show]
before_action :validate_params, only: [:create, :update]
def index
sort_by = params[:sort_by] ||= 'created_at'
sort_direction = params[:sort_direction] ||= 'desc'
q = License.ransack(name_cont: params[:search])
project_licenses = q.result(distinct: true).order("#{sort_by} #{sort_direction}")
@project_licenses = paginate(project_licenses)
end
def new
@project_license = License.new
end
def show
end
def create
# conditions = params[:license][:conditions_array].reject(&:blank?).join(",") if params[:license][:conditions_array].present?
# permissions = params[:license][:permissions_array].reject(&:blank?).join(",") if params[:license][:permissions_array].present?
# limitations = params[:license][:limitations_array].reject(&:blank?).join(",") if params[:license][:limitations_array].present?
# max_position_items = License.select(:id, :position).pluck(:position).reject!(&:blank?)
# max_position = max_position_items.present? ? max_position_items.max.to_i : 0
# other_params = {
# conditions: conditions.to_s,
# permissions: permissions.to_s,
# limitations: limitations.to_s,
# position: max_position
# }
@project_license = License.new(license_params)
if @project_license.save!
redirect_to admins_project_licenses_path
flash[:success] = "创建成功"
else
render :new
flash[:danger] = "创建失败"
end
end
def edit
end
def update
# conditions = params[:license][:conditions_array].reject(&:blank?).join(",") if params[:license][:conditions_array].present?
# permissions = params[:license][:permissions_array].reject(&:blank?).join(",") if params[:license][:permissions_array].present?
# limitations = params[:license][:limitations_array].reject(&:blank?).join(",") if params[:license][:limitations_array].present?
# other_params = {
# conditions: conditions.to_s,
# permissions: permissions.to_s,
# limitations: limitations.to_s
# }
if @project_license.update_attributes(license_params)
redirect_to admins_project_licenses_path
flash[:success] = "更新成功"
else
render :edit
flash[:danger] = "更新失败"
end
end
def destroy
if @project_license.present?
if @project_license.destroy
redirect_to admins_project_licenses_path
flash[:success] = "删除成功"
else
redirect_to admins_project_licenses_path
flash[:success] = "删除失败"
end
else
redirect_to admins_project_licenses_path
flash[:success] = "删除失败:许可证已被项目引用"
end
end
# def move
# cate_opt = params[:opr]
# cate_position = @project_license.position.to_i
# move_status = up_and_down(cate_opt,@project_license,cate_position,"license")
# if move_status == 0
# @c_msg = "移动成功"
# else
# @c_msg = "移动失败"
# end
# end
private
def set_license
@project_license = License.find_by_id(params[:id])
end
def license_params
params.require(:license).permit(:name,:content)
end
def validate_params
name = params[:license][:name]
if name.blank?
flash[:danger] = "名称不允许为空"
redirect_to admins_project_licenses_path
elsif check_license_present?(name) && @project_license.blank?
flash[:danger] = "创建失败:名称已存在"
redirect_to admins_project_licenses_path
end
end
def check_license_present?(name)
return true if name.blank?
name_downcase = name.downcase
name_upcase = name.upcase
name_first_big = name.capitalize
License.exists?(name: name_downcase) || License.exists?(name: name_upcase) || License.exists?(name: name_first_big)
end
end

View File

@ -1,10 +1,11 @@
class Admins::ProjectsController < Admins::BaseController
def index
default_sort('created_at', 'desc')
sort_by = params[:sort_by] ||= 'created_on'
sort_direction = params[:sort_direction] ||= 'desc'
search = params[:search].to_s.strip
projects = Project.where("name like ?", "%#{search}%")
projects = Project.where("name like ?", "%#{search}%").order("#{sort_by} #{sort_direction}")
@projects = paginate projects.includes(:owner, :members, :issues, :versions, :attachments, :project_score)
end
@ -21,5 +22,4 @@ class Admins::ProjectsController < Admins::BaseController
render_delete_success
end
end
end

View File

@ -4,7 +4,7 @@ class Admins::UsersController < Admins::BaseController
params[:sort_direction] = params[:sort_direction].presence || 'desc'
users = Admins::UserQuery.call(params)
@users = paginate users.includes(:user_extension)
@users = paginate users.includes(:user_extension, projects: :members)
end
def edit

View File

@ -607,7 +607,7 @@ class User < ApplicationRecord
end
def projects_count
Project.joins(:members).where(members: { user_id: self.id }).select(:id).size
Project.includes(:members).joins(:members).where(members: { user_id: self.id }).select(:id).size
end
# 是否已经签到

View File

@ -0,0 +1,21 @@
<div class="modal fade project-category-change-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><%= type == "create" ? "新增" : "编辑" %></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<%= form_for @project_category, url: {controller: "project_categories", action: "#{type}"} do |p| %>
<div class="modal-body">
<%= p.text_field :name,class: "form-control input-lg",placeholder: "分类名称",required: true, maxlength: 64%>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<%= p.submit "确认", class: "btn btn-primary submit-btn" %>
</div>
<% end %>
</div>
</div>
</div>

View File

@ -0,0 +1,33 @@
<table class="table table-hover text-center subject-list-table">
<thead class="thead-light">
<tr>
<th width="5%">序号</th>
<th width="30%">名称</th>
<th width="20%"><%= sort_tag('项目数', name: 'projects_count', path: admins_project_categories_path) %></th>
<th width="20%"><%= sort_tag('创建时间', name: 'created_at', path: admins_project_categories_path) %></th>
<th width="25%">操作</th>
</tr>
</thead>
<tbody>
<% if project_categories.present? %>
<% project_categories.each_with_index do |project_category, index| %>
<tr class="project-language-item-<%= project_category.id %>">
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<td>
<%= link_to(project_category.name, "/projects?category_id=#{project_category.id}", target: '_blank') %>
</td>
<td><%= project_category.projects_count %></td>
<td><%= project_category.created_at&.strftime('%Y-%m-%d %H:%M') %></td>
<td class="action-container">
<%= link_to "编辑", edit_admins_project_category_path(project_category), remote: true, class: "action" %>
<%= link_to "删除", admins_project_category_path(project_category), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: project_categories } %>

View File

@ -0,0 +1,2 @@
$("#project-category-modals").html("<%= j render(partial: 'admins/project_categories/form_modal', locals: {type: 'update'}) %>")
$(".project-category-change-modal").modal('show');

View File

@ -0,0 +1,18 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('分类列表') %>
<% end %>
<div class="box search-form-container project-category-list-form">
<%= form_tag(admins_project_categories_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
<%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '名称检索') %>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
<input type="reset" class="btn btn-secondary clear-btn" value="清空"/>
<% end %>
<%= link_to "新增", new_admins_project_category_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %>
</div>
<div class="box admin-list-container project-category-list-container">
<%= render partial: 'admins/project_categories/list', locals: { project_categories: @project_categories } %>
</div>
<div id="project-category-modals">
</div>

View File

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

View File

@ -0,0 +1,2 @@
$("#project-category-modals").html("<%= j render(partial: 'admins/project_categories/form_modal', locals: {type: 'create'}) %>")
$(".project-category-change-modal").modal('show');

View File

@ -0,0 +1,9 @@
<div class="box search-form-container project-list-form">
<div style="line-height: 38px;" class="flex-1"><%= @project_ignore.name %></div>
<%= link_to "返回", admins_project_ignores_path, class: "btn btn-default pull-right" %>
</div>
<div class="box">
<%= @project_ignore.content.html_safe %>
</div>

View File

@ -0,0 +1,38 @@
<div class="box search-form-container project-list-form">
<div style="line-height: 38px;" class="flex-1"><%= type == "create" ? "新建" : "编辑" %>忽略文件</div>
<%= link_to "返回", admins_project_ignores_path, class: "btn btn-default pull-right" %>
</div>
<div class="box">
<%= form_for @project_ignore, url: {controller: "project_ignores", action: "#{type}"} do |f| %>
<div class="form-group">
<label>
<span class="color-grey-6 pt10">
文件名称
<span class="ml10 color-orange mr20">*</span>
</span>
</label>
<div class="mt-10">
<%= f.text_field :name, class: "form-control input-lg", maxlength: "60", placeholder: "请输入忽略文件的全称" %>
</div>
</div>
<div class="form-group">
<label>
<span class="color-grey-6 pt10">
文件内容
<span class="ml10 color-orange mr20">*</span>
</span>
</label>
<div class="mt-10">
<%= f.text_area :content,class:"form-control", rows: "10", cols: "20",placeholer: "忽略文件的简要介绍不得超过500字" %>
</div>
</div>
<div class="form-group">
<%= f.submit "确认", class: "btn btn-primary submit-btn" %>
</div>
<% end %>
</div>

View File

@ -0,0 +1,45 @@
<table class="table table-hover text-center subject-list-table">
<thead class="thead-light">
<tr>
<th width="5%">序号</th>
<th width="15%">名称</th>
<th width="35%">简介</th>
<%
=begin%>
<th width="10%"><%= sort_tag('项目数', name: 'projects_count', path: admins_project_licenses_path) %></th>
<%
=end%>
<th width="15%"><%= sort_tag('创建时间', name: 'created_at', path: admins_project_licenses_path) %></th>
<th width="20%">操作</th>
</tr>
</thead>
<tbody>
<% if project_ignores.present? %>
<% project_ignores.each_with_index do |project_ignore, index| %>
<tr class="project-language-item-<%= project_ignore.id %>">
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<td>
<%= link_to project_ignore.name, admins_project_ignore_path(project_ignore.id), remote: true %>
</td>
<td>
<%= project_ignore.content.to_s.truncate(200) %>
</td>
<%
=begin%>
<td><%= project_license.projects_count %></td>
<%
=end%>
<td><%= project_ignore.created_at&.strftime('%Y-%m-%d %H:%M') %></td>
<td class="action-container">
<%= link_to "编辑", edit_admins_project_ignore_path(project_ignore),remote: true, class: "action" %>
<%= link_to "删除", admins_project_ignore_path(project_ignore), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: project_ignores } %>

View File

@ -0,0 +1 @@
$("#admins-project-ignore-content").html("<%= j render partial: 'admins/project_ignores/form', locals:{type: 'update'} %>")

View File

@ -0,0 +1,18 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('git忽略文件') %>
<% end %>
<div id="admins-project-ignore-content">
<div class="box search-form-container project-list-form">
<%= form_tag(admins_project_ignores_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
<%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '名称检索') %>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
<input type="reset" class="btn btn-secondary clear-btn" value="清空"/>
<% end %>
<%= link_to "新增", new_admins_project_ignore_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %>
</div>
<div class="box admin-list-container project-ignore-list-container">
<%= render partial: 'admins/project_ignores/list', locals: { project_ignores: @project_ignores } %>
</div>
</div>

View File

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

View File

@ -0,0 +1 @@
$("#admins-project-ignore-content").html("<%= j render partial: 'admins/project_ignores/form', locals:{type: 'create'} %>")

View File

@ -0,0 +1 @@
$("#admins-project-ignore-content").html("<%= j render partial: 'admins/project_ignores/content' %>")

View File

@ -0,0 +1,21 @@
<div class="modal fade project-language-change-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><%= type == "create" ? "新增" : "编辑" %></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<%= form_for @project_language, url: {controller: "project_languages", action: "#{type}"} do |p| %>
<div class="modal-body">
<%= p.text_field :name,class: "form-control input-lg",placeholder: "项目语言名称",required: true, maxlength: 64%>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<%= p.submit "确认", class: "btn btn-primary submit-btn" %>
</div>
<% end %>
</div>
</div>
</div>

View File

@ -0,0 +1,33 @@
<table class="table table-hover text-center subject-list-table">
<thead class="thead-light">
<tr>
<th width="5%">序号</th>
<th width="30%">名称</th>
<th width="20%"><%= sort_tag('项目数', name: 'projects_count', path: admins_project_languages_path) %></th>
<th width="20%"><%= sort_tag('创建时间', name: 'created_at', path: admins_project_languages_path) %></th>
<th width="25%">操作</th>
</tr>
</thead>
<tbody>
<% if project_languages.present? %>
<% project_languages.each_with_index do |project_language, index| %>
<tr class="project-language-item-<%= project_language.id %>">
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<td>
<%= link_to(project_language.name, "javascript:void(0)") %>
</td>
<td><%= project_language.projects_count %></td>
<td><%= project_language.created_at&.strftime('%Y-%m-%d %H:%M') %></td>
<td class="action-container">
<%= link_to "编辑", edit_admins_project_language_path(project_language), remote: true, class: "action" %>
<%= link_to "删除", admins_project_language_path(project_language), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: project_languages } %>

View File

@ -0,0 +1,2 @@
$("#project-language-modals").html("<%= j render(partial: 'admins/project_languages/form_modal', locals: {type: 'update'}) %>")
$(".project-language-change-modal").modal('show');

View File

@ -0,0 +1,18 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('项目语言') %>
<% end %>
<div class="box search-form-container project-list-form">
<%= form_tag(admins_project_languages_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
<%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '名称检索') %>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
<input type="reset" class="btn btn-secondary clear-btn" value="清空"/>
<% end %>
<%= link_to "新增", new_admins_project_language_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %>
</div>
<div class="box admin-list-container project-language-list-container">
<%= render partial: 'admins/project_languages/list', locals: { project_languages: @project_languages } %>
</div>
<div id="project-language-modals">
</div>

View File

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

View File

@ -0,0 +1,2 @@
$("#project-language-modals").html("<%= j render(partial: 'admins/project_languages/form_modal', locals: {type: 'create'}) %>")
$(".project-language-change-modal").modal('show');

View File

@ -0,0 +1,9 @@
<div class="box search-form-container project-list-form">
<div style="line-height: 38px;" class="flex-1"><%= @project_license.name %></div>
<%= link_to "返回", admins_project_licenses_path, class: "btn btn-default pull-right" %>
</div>
<div class="box">
<%= @project_license.content.html_safe %>
</div>

View File

@ -0,0 +1,38 @@
<div class="box search-form-container project-list-form">
<div style="line-height: 38px;" class="flex-1"><%= type == "create" ? "新建" : "编辑" %>开源许可证</div>
<%= link_to "返回", admins_project_licenses_path, class: "btn btn-default pull-right" %>
</div>
<div class="box">
<%= form_for @project_license, url: {controller: "project_licenses", action: "#{type}"} do |f| %>
<div class="form-group">
<label>
<span class="color-grey-6 pt10">
许可证名称
<span class="ml10 color-orange mr20">*</span>
</span>
</label>
<div class="mt-10">
<%= f.text_field :name, class: "form-control input-lg", maxlength: "60", placeholder: "请输入开源许可证的全称" %>
</div>
</div>
<div class="form-group">
<label>
<span class="color-grey-6 pt10">
许可证内容
<span class="ml10 color-orange mr20">*</span>
</span>
</label>
<div class="mt-10">
<%= f.text_area :content,class:"form-control", rows: "10", cols: "20",placeholer: "许可证的简要介绍不得超过500字" %>
</div>
</div>
<div class="form-group">
<%= f.submit "确认", class: "btn btn-primary submit-btn" %>
</div>
<% end %>
</div>

View File

@ -0,0 +1,45 @@
<table class="table table-hover text-center subject-list-table">
<thead class="thead-light">
<tr>
<th width="5%">序号</th>
<th width="15%">名称</th>
<th width="35%">简介</th>
<%
=begin%>
<th width="10%"><%= sort_tag('项目数', name: 'projects_count', path: admins_project_licenses_path) %></th>
<%
=end%>
<th width="15%"><%= sort_tag('创建时间', name: 'created_at', path: admins_project_licenses_path) %></th>
<th width="20%">操作</th>
</tr>
</thead>
<tbody>
<% if project_licenses.present? %>
<% project_licenses.each_with_index do |project_license, index| %>
<tr class="project-language-item-<%= project_license.id %>">
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<td>
<%= link_to project_license.name, admins_project_license_path(project_license.id), remote: true %>
</td>
<td>
<%= project_license.content.to_s.truncate(200) %>
</td>
<%
=begin%>
<td><%= project_license.projects_count %></td>
<%
=end%>
<td><%= project_license.created_at&.strftime('%Y-%m-%d %H:%M') %></td>
<td class="action-container">
<%= link_to "编辑", edit_admins_project_license_path(project_license),remote: true, class: "action" %>
<%= link_to "删除", admins_project_license_path(project_license), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: project_licenses } %>

View File

@ -0,0 +1 @@
$("#admins-project-license-content").html("<%= j render partial: 'admins/project_licenses/form', locals:{type: 'update'} %>")

View File

@ -0,0 +1,18 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('开源许可证') %>
<% end %>
<div id="admins-project-license-content">
<div class="box search-form-container project-list-form">
<%= form_tag(admins_project_licenses_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
<%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '名称检索') %>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
<input type="reset" class="btn btn-secondary clear-btn" value="清空"/>
<% end %>
<%= link_to "新增", new_admins_project_license_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %>
</div>
<div class="box admin-list-container project-license-list-container">
<%= render partial: 'admins/project_licenses/list', locals: { project_licenses: @project_licenses } %>
</div>
</div>

View File

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

View File

@ -0,0 +1 @@
$("#admins-project-license-content").html("<%= j render partial: 'admins/project_licenses/form', locals:{type: 'create'} %>")

View File

@ -0,0 +1 @@
$("#admins-project-license-content").html("<%= j render partial: 'admins/project_licenses/content' %>")

View File

@ -12,7 +12,7 @@
<th width="6%">里程碑</th>
<th width="10%">成员</th>
<th width="10%">管理员</th>
<th width="11%"><%= sort_tag('创建时间', name: 'created_at', path: admins_projects_path) %></th>
<th width="11%"><%= sort_tag('创建时间', name: 'created_on', path: admins_projects_path) %></th>
<th width="10%">操作</th>
</tr>
</thead>

View File

@ -14,54 +14,18 @@
<!-- Sidebar Links -->
<ul class="list-unstyled components">
<li><%= sidebar_item(admins_path, '概览', icon: 'dashboard', controller: 'admins-dashboards') %></li>
<li>
<%= sidebar_item_group('#schools-submenu', '单位管理', icon: 'building') do %>
<li><%= sidebar_item(admins_schools_path, '单位列表', icon: 'university', controller: 'admins-schools') %></li>
<li><%= sidebar_item(admins_departments_path, '部门列表', icon: 'sitemap', controller: 'admins-departments') %></li>
<li><%= sidebar_item(admins_partners_path, '合作伙伴', icon: 'handshake-o', controller: 'admins-partners') %></li>
<% end %>
</li>
<li>
<%= sidebar_item_group('#user-submenu', '用户', icon: 'user') do %>
<li><%= sidebar_item(admins_users_path, '用户列表', icon: 'user', controller: 'admins-users') %></li>
<li><%= sidebar_item(admins_user_statistics_path, '用户实训情况', icon: 'area-chart', controller: 'admins-user_statistics') %></li>
<% end %>
</li>
<li>
<%= sidebar_item_group('#apply-review-submenu', '审核', icon: 'gavel') do %>
<li><%= sidebar_item(admins_identity_authentications_path, '实名认证', icon: 'id-card-o', controller: 'admins-identity_authentications') %></li>
<li><%= sidebar_item(admins_professional_authentications_path, '职业认证', icon: 'drivers-license', controller: 'admins-professional_authentications') %></li>
<li><%= sidebar_item(admins_department_applies_path, '部门审批', icon: 'newspaper-o', controller: 'admins-department_applies') %></li>
<li><%= sidebar_item(admins_unit_applies_path, '单位审批', icon: 'building-o', controller: 'admins-unit_applies') %></li>
<li><%= sidebar_item(admins_project_package_applies_path, '众包需求发布', icon: 'joomla', controller: 'admins-project_package_applies') %></li>
<% end %>
</li>
<li>
<%= sidebar_item_group('#comments-submenu', '消息', icon: 'comments') do %>
<li><%= sidebar_item(admins_shixun_feedback_messages_path, '实训反馈', icon: 'comment', controller: 'admins-shixun_feedback_messages') %></li>
<% end %>
</li>
<li>
<%= sidebar_item_group('#running-data', '运营数据', icon: 'bar-chart') do %>
<li><%= sidebar_item(admins_salesmans_path, '销售数据列表', icon: 'columns', controller: 'admins-salesmans') %></li>
<% end %>
</li>
<li>
<%= sidebar_item_group('#other-submenu', '其他', icon: 'list-alt') do %>
<li><%= sidebar_item(admins_repertoires_path, '技术体系', icon: 'sitemap', controller: 'admins-repertoires') %></li>
<% end %>
</li>
<li>
<%= sidebar_item_group('#major-identification-submenu', '工程认证', icon: 'anchor') do %>
<li><%= sidebar_item(admins_major_informations_path, '本科专业目录', icon: 'outdent', controller: 'admins-major_informations') %></li>
<li><%= sidebar_item(admins_auth_schools_path, '认证单位列表', icon: 'th', controller: 'admins-auth_schools') %></li>
<%= sidebar_item_group('#projects-submenu', '开源项目', icon: 'database') do %>
<li><%= sidebar_item(admins_projects_path, '项目列表', icon: 'database', controller: 'admins-projects') %></li>
<li><%= sidebar_item(admins_project_languages_path, '项目语言', icon: 'language', controller: 'admins-project_languages') %></li>
<li><%= sidebar_item(admins_project_categories_path, '分类列表', icon: 'sitemap', controller: 'admins-project_categories') %></li>
<li><%= sidebar_item(admins_project_licenses_path, '开源许可证', icon: 'file-text-o', controller: 'admins-project_licenses') %></li>
<li><%= sidebar_item(admins_project_ignores_path, '忽略文件', icon: 'git', controller: 'admins-project_ignores') %></li>
<% end %>
</li>
@ -76,7 +40,9 @@
<li><%= sidebar_item(edit_admins_help_center_path, '帮助中心', icon: 'question-circle-o', controller: 'admins-help_centers') %></li>
<% end %>
</li>
<li>
<%= sidebar_item('/sidekiq', '定时任务', icon: 'bell', controller: 'root') %>
</li>
<li><%= sidebar_item('/', '返回主站', icon: 'sign-out', controller: 'root') %></li>
</ul>
</nav>

View File

@ -23,12 +23,20 @@
</div>
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: 'ID/姓名/邮箱/手机号检索') %>
<%= text_field_tag(:school_name, params[:school_name], class: 'form-control col-sm-2', placeholder: '学校/单位检索') %>
<%
=begin%>
<%= text_field_tag(:school_name, params[:school_name], class: 'form-control col-sm-2', placeholder: '学校/单位检索') %>
<%
=end%>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
<% end %>
<%= javascript_void_link '导入用户', class: 'btn btn-secondary btn-sm', data: { toggle: 'modal', target: '.admin-import-user-modal'} %>
<%= javascript_void_link '导入课堂成员', class: 'btn btn-secondary btn-sm ml-2', data: { toggle: 'modal', target: '.admin-import-course-member-modal'} %>
<%
=begin%>
<%= javascript_void_link '导入课堂成员', class: 'btn btn-secondary btn-sm ml-2', data: { toggle: 'modal', target: '.admin-import-course-member-modal'} %>
<%
=end%>
</div>
<div class="box admin-list-container users-list-container">

View File

@ -8,8 +8,7 @@
<th width="7%">角色</th>
<th width="10%"><%= sort_tag('创建于', name: 'created_on', path: admins_users_path) %></th>
<th width="10%"><%= sort_tag('最后登录', name: 'last_login_on', path: admins_users_path) %></th>
<th width="6%"><%= sort_tag('经验值', name: 'experience', path: admins_users_path) %></th>
<th width="6%"><%= sort_tag('金币', name: 'grade', path: admins_users_path) %></th>
<th width="12%">项目数</th>
<th width="14%">操作</th>
</tr>
</thead>
@ -28,8 +27,7 @@
<td><%= user.identity %></td>
<td><%= display_text(user.created_on&.strftime('%Y-%m-%d %H:%M')) %></td>
<td><%= display_text(user.last_login_on&.strftime('%Y-%m-%d %H:%M')) %></td>
<td><%= user.experience.to_i %></td>
<td class="grade-content"><%= user.grade.to_i %></td>
<td><%= link_to user.projects_count, "/users/#{user.login}/projects", target: "_blank" %></td>
<td class="action-container">
<%= link_to '编辑', edit_admins_user_path(user), class: 'action' %>

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>EduCoder后台管理</title>
<title>ForgePlus后台管理</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel='shortcut icon' type='image/x-icon' href='/favicon.ico' />

View File

@ -2,9 +2,9 @@ Rails.application.routes.draw do
require 'sidekiq/web'
require 'admin_constraint'
# mount Sidekiq::Web => '/sidekiq'
mount Sidekiq::Web => '/sidekiq'
mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new
# mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new
get 'attachments/download/:id', to: 'attachments#show'
get 'attachments/download/:id/:filename', to: 'attachments#show'
@ -389,6 +389,10 @@ Rails.application.routes.draw do
get :visits_static
end
end
resources :project_languages
resources :project_categories
resources :project_licenses
resources :project_ignores
resources :major_informations, only: [:index]
resources :ec_templates, only: [:index, :destroy] do
collection do

BIN
public/favicon.ico Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 10 KiB