Merge remote-tracking branch 'origin/standalone_develop' into standalone_develop

This commit is contained in:
xxq250 2023-08-29 14:43:36 +08:00
commit 46430fc0f0
45 changed files with 446 additions and 101 deletions

View File

@ -0,0 +1,3 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

View File

@ -0,0 +1,3 @@
// Place all the styles related to the admins/page_themes controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -3,9 +3,7 @@ class Admins::IdentityVerificationsController < Admins::BaseController
def index
params[:sort_by] = params[:sort_by].presence || 'created_at'
params[:sort_direction] = params[:sort_direction].presence || 'desc'
identity_verifications = Admins::IdentityVerificationQuery.call(params)
@identity_verifications = paginate identity_verifications.preload(:user)
end
@ -16,9 +14,13 @@ class Admins::IdentityVerificationsController < Admins::BaseController
end
def update
@identity_verification.update(update_params)
flash[:success] = '保存成功'
render 'edit'
if @identity_verification.update(update_params)
redirect_to admins_identity_verifications_path
flash[:success] = "更新成功"
else
redirect_to admins_identity_verifications_path
flash[:danger] = "更新失败"
end
end
private

View File

@ -0,0 +1,79 @@
class Admins::PageThemesController < Admins::BaseController
before_action :finder_page_theme, only: [:edit, :update, :destroy]
def index
params[:sort_by] = params[:sort_by].presence || 'created_at'
params[:sort_direction] = params[:sort_direction].presence || 'desc'
page_themes = Admins::PageThemesQuery.call(params)
@page_themes = paginate page_themes
end
def show
render 'edit'
end
def edit
end
def create
@page_theme = PageTheme.new theme_params
if @page_theme.save
save_image_file(params[:image])
redirect_to admins_page_themes_path
flash[:success] = "新增主题成功"
else
redirect_to admins_page_themes_path
flash[:danger] = "新增主题失败: #{@page_theme.errors.messages.values.flatten.join(',')}"
end
end
def destroy
if PageTheme.where(language_frame: @page_theme.language_frame).count <= 1
flash[:danger] = "删除主题失败,必须存在一个主题"
return redirect_to admins_page_themes_path
end
if @page_theme.destroy
redirect_to admins_page_themes_path
flash[:success] = "删除主题成功"
else
redirect_to admins_page_themes_path
flash[:danger] = "删除主题失败"
end
end
def new
@page_theme = PageTheme.new
end
def update
@page_theme.attributes = theme_params
if @page_theme.save
save_image_file(params[:image])
redirect_to admins_page_themes_path
flash[:success] = "更新成功"
else
redirect_to admins_page_themes_path
flash[:danger] = "更新失败"
end
end
private
def finder_page_theme
@page_theme = PageTheme.find(params[:id])
end
def theme_params
params.require(:page_theme).permit(:language_frame, :name, :cate, :image_url, :clone_url, :order_index)
end
def save_image_file(file)
return unless file.present? && file.is_a?(ActionDispatch::Http::UploadedFile)
file_path = Util::FileManage.source_disk_filename(@page_theme, "image")
File.delete(file_path) if File.exist?(file_path) # 删除之前的文件
Util.write_file(file, file_path)
end
end

View File

@ -17,6 +17,17 @@ class Admins::SitePagesController < Admins::BaseController
def edit
end
def destroy
if @site_page.destroy
redirect_to admins_site_pages_path
flash[:success] = "删除站点成功"
else
redirect_to admins_site_pages_path
flash[:danger] = "删除站点失败"
end
end
def update
@site_page.update(update_params)
flash[:success] = '保存成功'

View File

@ -100,6 +100,8 @@ class ProjectsController < ApplicationController
def page_migrate
return normal_status(-1, "您还未开通Page服务无法进行新建站点") unless current_user.id_card_verify
return normal_status(-1, "你已使用了 #{page_site_params[:identifier]} 作为page标识") if Page.exists?(identifier: page_site_params[:identifier], user: current_user)
Projects::MigrateForm.new(mirror_params).validate!
@project =

View File

@ -2,21 +2,22 @@ class SitePagesController < ApplicationController
before_action :require_login, except: [:softbot_build, :themes]
before_action :require_profile_completed, only: [:create]
before_action :load_project, except: [:softbot_build, :index, :themes]
before_action :authenticate_user!, except: [:softbot_build, :index, :themes]
before_action :authenticate_user!, except: [:softbot_build, :index, :themes, :show]
before_action :authenticate_member!, only: [:show]
def index
@pages = PageQuery.call(params,current_user)
@pages = paginate(@pages)
pages = PageQuery.call(params,current_user)
@total_count = pages.size
@pages = paginate(pages)
end
def show
@page = Page.find_by(user_id: current_user.id, project_id: @project.id)
@page = Page.find_by(project_id: @project.id)
return render_ok({data:nil}) unless @page.present?
end
def create
return normal_status(-1, "您还未通过身份认证无法开通Page") unless current_user.id_card_verify
return normal_status(-1, "您还未开通Page服务无法进行部署") unless current_user.website_permission
return normal_status(-1, "你还未开通Page服务无法进行部署") unless current_user.website_permission
return normal_status(-1, "你已使用了 #{params[:identifier]} 作为page标识") if Page.exists?(identifier: params[:identifier], user: current_user)
return normal_status(-1, "该仓库已开通Page服务") if Page.exists?(project: @project)
@page = Page.new(create_params)
@ -26,7 +27,7 @@ class SitePagesController < ApplicationController
end
def build
return normal_status(-1, "还未开通Page服务无法进行部署") unless current_user.website_permission
return normal_status(-1, "还未开通Page服务无法进行部署") unless current_user.website_permission
return normal_status(-1, "该仓库还未开通Page服务无法进行部署") unless Page.exists?(project: @project)
@page = Page.find params[:id]
return normal_status(-1, @page.state_description) unless @page.state
@ -42,7 +43,7 @@ class SitePagesController < ApplicationController
def softbot_build
branch = params[:ref].split("/").last
user = User.find_by_login params[:repository][:owner][:login]
return normal_status(-1, "还未开通Page服务无法进行部署") unless user.website_permission
return normal_status(-1, "还未开通Page服务无法进行部署") unless user.website_permission
project = Project.where(identifier: params[:repository][:name],user_id: user.id)
return normal_status(-1, "你没有权限操作") if project.owner?(user)
@ -54,15 +55,22 @@ class SitePagesController < ApplicationController
end
def themes
data = YAML.load_file(Rails.root.join('config/admins', 'page_themes.yml'))
render_ok({themes:data[theme_params.downcase]})
# data = YAML.load_file(Rails.root.join('config/admins', 'page_themes.yml'))
# render_ok({themes:data[theme_params.downcase]})
@themes = PageTheme.where(language_frame:theme_params).order(order_index: :asc)
end
private
def authenticate_user!
return if @project.is_public
return if @project.owner?(current_user)
render_forbidden('你没有权限操作')
unless @project.manager?(current_user) || current_user.admin?
return render_forbidden('你不是管理员,没有权限操作')
end
end
def authenticate_member!
unless @project.member?(current_user) || current_user.admin?
return render_forbidden('你不是成员,没有权限操作')
end
end
def theme_params

View File

@ -0,0 +1,2 @@
module Admins::PageThemesHelper
end

View File

@ -26,8 +26,6 @@
# cloud_url :string(255) default("")
# course_second_category_id :integer default("0")
# delay_publish :boolean default("0")
# memo_image :boolean default("0")
# extra_type :integer default("0")
#
# Indexes
#

View File

@ -1,20 +1,27 @@
# == Schema Information
#
# Table name: ignores
# user_id
# student_name
# school
# profession
# location
# grade
# phone
# mail
# created_on
# is_delete
# prove_attachment_id
# cancel_count
# round
# Table name: glcc_registration_task
#
# id :integer not null, primary key
# reg_id :integer not null
# task_name :string(255)
# task_desc :text(16777215)
# task_difficulty :integer
# task_url :string(1000)
# task_reward :string(255)
# tutor_name :string(255)
# tutor_mail :string(255)
# tutor_phone :string(255)
# created_on :datetime
# is_delete :boolean default("0"), not null
# sort_no :integer default("0")
# locked :boolean default("0")
# round :integer default("1"), not null
# check_status :boolean default("0")
#
# Indexes
#
# idx_glcc_reg_id (reg_id)
#
class GlccRegistrationTask < ActiveRecord::Base

View File

@ -17,7 +17,7 @@
#
# Indexes
#
# index_identity_verifications_on_user_id (user_id)
# index_identity_verifications_on_number (number)
#
class IdentityVerification < ApplicationRecord

View File

@ -7,7 +7,6 @@
# content :text(65535)
# created_at :datetime not null
# updated_at :datetime not null
# is_secret :boolean default("0")
#
class License < ApplicationRecord

View File

@ -11,7 +11,6 @@
# course_group_id :integer default("0")
# is_collect :integer default("1")
# graduation_group_id :integer default("0")
# is_apply_signature :boolean default("0")
# team_user_id :integer
#
# Indexes

View File

@ -5,7 +5,6 @@
# id :integer not null, primary key
# user_id :integer
# organization_id :integer
# is_creator :boolean default("0")
# created_at :datetime not null
# updated_at :datetime not null
#

29
app/models/page_theme.rb Normal file
View File

@ -0,0 +1,29 @@
# == Schema Information
#
# Table name: page_themes
#
# id :integer not null, primary key
# name :string(255) not null
# language_frame :integer default("0")
# image_url :string(255)
# clone_url :string(255) not null
# order_index :integer default("0")
# created_at :datetime not null
# updated_at :datetime not null
#
class PageTheme < ApplicationRecord
enum language_frame: { hugo: 0, jeklly: 1, hexo: 2}
validates :name, presence: {message: "主题名不能为空"}, uniqueness: {message: "主题名已存在",scope: :language_frame},length: {maximum: 255}
def image
page_image_url('image')
end
private
def page_image_url(type)
return nil unless Util::FileManage.exists?(self, type)
Util::FileManage.source_disk_file_url(self, type)
end
end

View File

@ -62,7 +62,6 @@
#
# Indexes
#
# index_projects_on_forked_count (forked_count)
# index_projects_on_forked_from_project_id (forked_from_project_id)
# index_projects_on_identifier (identifier)
# index_projects_on_invite_code (invite_code)
@ -72,7 +71,6 @@
# index_projects_on_license_id (license_id)
# index_projects_on_name (name)
# index_projects_on_platform (platform)
# index_projects_on_praises_count (praises_count)
# index_projects_on_project_category_id (project_category_id)
# index_projects_on_project_language_id (project_language_id)
# index_projects_on_project_type (project_type)
@ -80,7 +78,6 @@
# index_projects_on_rgt (rgt)
# index_projects_on_status (status)
# index_projects_on_updated_on (updated_on)
# index_projects_on_user_id (user_id)
#
class Project < ApplicationRecord
@ -120,6 +117,7 @@ class Project < ApplicationRecord
has_many :issues, dependent: :destroy
# has_many :user_grades, dependent: :destroy
has_many :attachments, as: :container, dependent: :destroy
has_one :page, dependent: :destroy
has_one :project_score, dependent: :destroy
has_many :versions, -> { order("versions.created_on DESC, versions.name DESC") }, dependent: :destroy
has_many :praise_treads, as: :praise_tread_object, dependent: :destroy

View File

@ -15,7 +15,6 @@
# Indexes
#
# index_project_categories_on_ancestry (ancestry)
# index_project_categories_on_id (id)
#
class ProjectCategory < ApplicationRecord

View File

@ -9,10 +9,6 @@
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_project_languages_on_id (id)
#
class ProjectLanguage < ApplicationRecord
include Projectable

View File

@ -27,7 +27,6 @@
#
# Indexes
#
# index_name (project_id)
# index_repositories_on_identifier (identifier)
# index_repositories_on_project_id (project_id)
# index_repositories_on_user_id (user_id)

View File

@ -22,9 +22,9 @@
# school_id :integer
# description :string(255)
# department_id :integer
# province :text(65535)
# custom_department :string(255)
# province :string(255)
# city :string(255)
# custom_department :string(255)
# show_email :boolean default("0")
# show_location :boolean default("0")
# show_department :boolean default("0")

View File

@ -3,14 +3,14 @@ class Admins::IdentityVerificationQuery < ApplicationQuery
attr_reader :params
sort_columns :updated_at, default_by: :updated_at, default_direction: :desc
sort_columns :created_at, default_by: :created_at, default_direction: :desc
def initialize(params)
@params = params
end
def call
state = params[:state].blank? ? [0,1,2] : params[:state].to_i
state = params[:state] == "all" ? [0,1,2] : params[:state].nil? ? [0] : params[:state].to_i
applies = IdentityVerification.where(state: state)
custom_sort(applies, params[:sort_by], params[:sort_direction])
end

View File

@ -0,0 +1,17 @@
class Admins::PageThemesQuery < ApplicationQuery
include CustomSortable
attr_reader :params
sort_columns :created_at, default_by: :created_at, default_direction: :desc
def initialize(params)
@params = params
end
def call
language_frame = params[:language_frame].blank? ? [0..99] : params[:language_frame]
page_themes = PageTheme.where(language_frame: language_frame)
custom_sort(page_themes, params[:sort_by], params[:sort_direction])
end
end

View File

@ -3,11 +3,11 @@ class PageQuery < ApplicationQuery
def initialize(params, user)
@user = user
@params = params
end
def call
pages = Page.where(user: @user)
pages = Page.where(user: @user).order(created_at: :desc)
pages
end
end

View File

@ -1,6 +1,6 @@
<%
define_admin_breadcrumbs do
add_admin_breadcrumb('用户管理', admins_identity_verifications_path)
add_admin_breadcrumb('身份审核列表', admins_identity_verifications_path)
add_admin_breadcrumb('用户身份审核详情')
end
%>
@ -62,7 +62,7 @@
<div class="form-row">
<td>
<% if @identity_verification.card_front_attachment.present? %>
<%= link_to "#{@identity_verification.card_front_attachment.try(:filename)}",attachment_path(@identity_verification.card_front_attachment), target: "_blank" %>
<%= image_tag("/api/attachments/#{@identity_verification.card_front}", width: 100, height: 100, class: 'preview-image auth-image', data: { toggle: 'tooltip', title: '点击预览' }) %>
<%else%>
<p> 图片无法展示,图片已丢失</p>
<%end%>
@ -72,7 +72,7 @@
<div class="form-row">
<td>
<% if @identity_verification.card_back_attachment.present? %>
<%= link_to "#{@identity_verification.card_back_attachment.try(:filename)}",attachment_path(@identity_verification.card_back_attachment), target: "_blank" %>
<%= image_tag("/api/attachments/#{@identity_verification.card_back}", width: 100, height: 100, class: 'preview-image auth-image', data: { toggle: 'tooltip', title: '点击预览' }) %>
<%else%>
<p> 图片无法展示,图片已丢失</p>
<%end%>
@ -82,7 +82,7 @@
<div class="form-row">
<td>
<% if @identity_verification.hold_card_front_attachment.present? %>
<%= link_to "#{@identity_verification.hold_card_front_attachment.try(:filename)}",attachment_path(@identity_verification.hold_card_front_attachment), target: "_blank" %>
<%= image_tag("/api/attachments/#{@identity_verification.hold_card_front}", width: 100, height: 100, class: 'preview-image auth-image', data: { toggle: 'tooltip', title: '点击预览' }) %>
<%else%>
<p> 图片无法展示,图片已丢失</p>
<%end%>
@ -92,26 +92,17 @@
<div class="form-row">
<td>
<% if @identity_verification.hold_card_back_attachment.present? %>
<%= link_to "#{@identity_verification.hold_card_back_attachment.try(:filename)}",attachment_path(@identity_verification.hold_card_back_attachment), target: "_blank" %>
<%= image_tag("/api/attachments/#{@identity_verification.hold_card_back}", width: 100, height: 100, class: 'preview-image auth-image', data: { toggle: 'tooltip', title: '点击预览' }) %>
<%else%>
<p> 图片无法展示,图片已丢失</p>
<%end%>
</td>
</div>
</br>
<div class="form-row">
<label><b>是否通过身份证审核: </b></label>
</div>
<b>
<% if @identity_verification.state == "已通过" %>
<% unless @identity_verification.state == "已通过" %>
<div class="form-row">
<p> 用户身份审核已通过</p>
</div>
<%else%>
<div class="form-row">
<%= f.radio_button :state, '已通过' %> 通过  
<%= f.radio_button :state, '已拒绝' %> 拒绝
<%= radio_button_tag("identity_verification[state]","已通过", required: 'required') %>通过  
<%= radio_button_tag("identity_verification[state]","已拒绝", required: 'required') %>拒绝
</div>
</br>
<div class="form-row">
@ -124,8 +115,5 @@
<% end %>
</b>
</div>
<% end %>
</div>

View File

@ -1,12 +1,12 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('用户管理', admins_identity_verifications_path) %>
<% add_admin_breadcrumb('身份审核列表', admins_identity_verifications_path) %>
<% end %>
<div class="box search-form-container user-list-form">
<%= form_tag(admins_identity_verifications_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
<div class="form-group mr-2">
<label for="state">状态:</label>
<% state_options = [['全部',nil], ['待审核', 0], ['已通过', 1], ['已拒绝', 2]] %>
<% state_options = [['待审核', 0], ['全部',"all"], ['已通过', 1], ['已拒绝', 2]] %>
<%= select_tag(:state, options_for_select(state_options), class: 'form-control') %>
</div>

View File

@ -1,4 +1,4 @@
<table class="table table-hover identity-verifications-list-table">
<table class="table table-hover identity-verifications-list-table">
<thead class="thead-light">
<tr>
<th width="10%">序号</th>

View File

@ -0,0 +1,60 @@
<div class="modal fade page-themes-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 @page_theme, url: {controller: "page_themes", action: "#{type}"}, html: { enctype: 'multipart/form-data' } do |p| %>
<div class="modal-body">
<% if type == "create"%>
<div class="form-group">
<label>
建站工具 <span class="ml10 color-orange mr20">*</span>
</label>
<% state_options = [['hugo', "hugo"], ['jeklly', "jeklly"],['hexo',"hexo"]] %>
<%= select_tag('page_theme[language_frame]', options_for_select(state_options), class: 'form-control') %>
</div>
<% end%>
<div class="form-group">
<label>
主题名 <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_field :name, class: "form-control input-lg",required: true, maxlength: 100, size: 100 %>
</div>
<div class="form-group">
<label>
仓库url <span class="ml10 color-orange mr20">*</span>
</label>
<%= p.text_field :clone_url, class: "form-control",placeholder: "https://gitlink.org.cn/XXXX/xxxx.git",required: true, pattern: "https://gitlink.org.cn/.*"%>
</div>
<div class="form-group">
<label>
排序等级
</label>
<%= p.number_field :order_index, class: "form-control",placeholder: ""%>
</div>
<div class="logo-item">
<% logo_img = @page_theme.image %>
<div class="logo-item-left mr-3 <%= logo_img ? 'has-img' : '' %>">
<img class="logo-item-img nav-logo-img" src="<%= logo_img %>" style="<%= logo_img.present? ? '' : 'display: none' %>"/>
<%= file_field_tag(:image, accept: 'image/png,image/jpg,image/jpeg',style: "display: none", value: params[:image]) %>
<label for="image" class="logo-item-upload" data-toggle="tooltip" data-title="选择图片"></label>
</div>
<div class="logo-item-right">
<div class="logo-item-title flex-1">logo <span class="ml10 color-orange mr20">*</span></div>
<div>格式PNG、JPG、JPEG、SVG</div>
</div>
</div>
</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,35 @@
<table class="table table-hover text-center subject-list-table">
<thead class="thead-light">
<tr>
<th width="5%">序号</th>
<th width="10%">建站工具</th>
<th width="5%">顺序</th>
<th width="15%">主题名</th>
<th width="20%">图片</th>
<th width="25%">仓库url</th>
<th width="20%">操作</th>
</tr>
</thead>
<tbody>
<% if page_themes.present? %>
<% page_themes.each_with_index do |theme, index| %>
<tr class="page-theme-item-<%= theme.id %>">
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<td><%= theme.language_frame %></td>
<td><%= theme.order_index %></td>
<td style="word-break: break-all;word-wrap: break-word;" ><%= theme.name %></td>
<td><img style="width:150px" src="<%= theme.image %>" /></td>
<td style="word-break: break-all;word-wrap: break-word;" ><a href="<%= theme.clone_url %>" target="_blank"><%= theme.clone_url %></a> </td>
<td class="action-container">
<%= link_to "编辑", edit_admins_page_theme_path(theme), remote: true, class: "action" %>
<%= link_to "删除", admins_page_theme_path(theme), 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: page_themes } %>

View File

@ -0,0 +1,18 @@
$("#page-themes-modals").html("<%= j render(partial: 'admins/page_themes/form_modal', locals: {type: 'update'}) %>")
$(".page-themes-change-modal").modal('show');
$('.logo-item-left').on("change", 'input[type="file"]', function () {
var $fileInput = $(this);
var file = this.files[0];
var imageType = /image.*/;
if (file && file.type.match(imageType)) {
var reader = new FileReader();
reader.onload = function () {
var $box = $fileInput.parent();
$box.find('img').attr('src', reader.result).css('display', 'block');
$box.addClass('has-img');
};
reader.readAsDataURL(file);
} else {
}
});

View File

@ -0,0 +1,21 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('站点主题配置') %>
<% end %>
<div class="box search-form-container project-list-form">
<%= form_tag(admins_page_themes_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
<div class="form-group mr-2">
<label for="language_frame">建站工具:</label>
<% state_options = [['全部',nil], ['hugo', 0], ['jeklly', 1],['hexo',2]] %>
<%= select_tag(:language_frame, options_for_select(state_options), class: 'form-control') %>
</div>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
<% end %>
<%= link_to "新增", new_admins_page_theme_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %>
</div>
<div class="box admin-list-container page-themes-list-container">
<%= render partial: 'admins/page_themes/list', locals: { page_themes: @page_themes } %>
</div>
<div id="page-themes-modals">
</div>

View File

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

View File

@ -0,0 +1,18 @@
$("#page-themes-modals").html("<%= j render(partial: 'admins/page_themes/form_modal', locals: {type: 'create'}) %>")
$(".page-themes-change-modal").modal('show');
$('.logo-item-left').on("change", 'input[type="file"]', function () {
var $fileInput = $(this);
var file = this.files[0];
var imageType = /image.*/;
if (file && file.type.match(imageType)) {
var reader = new FileReader();
reader.onload = function () {
var $box = $fileInput.parent();
$box.find('img').attr('src', reader.result).css('display', 'block');
$box.addClass('has-img');
};
reader.readAsDataURL(file);
} else {
}
});

View File

@ -32,6 +32,7 @@
<%= sidebar_item_group('#pages-submenu', '站点管理', icon: 'cogs') do %>
<li><%= sidebar_item(admins_identity_verifications_path, '身份审核列表', icon: 'user', controller: 'admins-identity_verifications') %></li>
<li><%= sidebar_item(admins_site_pages_path, '用户站点列表', icon: 'sitemap', controller: 'admins-site_pages') %></li>
<li><%= sidebar_item(admins_page_themes_path, '站点主题配置', icon: 'cogs', controller: 'admins-page_themes') %></li>
<% end %>
</li>

View File

@ -1,7 +1,7 @@
<%
define_admin_breadcrumbs do
add_admin_breadcrumb('用户管理', admins_site_pages_path)
add_admin_breadcrumb('站点列表')
add_admin_breadcrumb('用户站点列表', admins_site_pages_path)
add_admin_breadcrumb('站点详情')
end
%>
@ -50,9 +50,9 @@
<%= simple_form_for(@site_page, url: admins_site_page_path(@site_page)) do |f| %>
<div class="mt-4">
<h6>审核信息</h6>
<label>当前身份审核状态为 <b><%=@site_page.state %></b></label>
<label>当前用户的站点权限为: <b><%=@site_page.user.website_permission == true ? "正常" : "关闭,已被管理员强制关闭建站权限" %></b></label></br>
<label>当前站点状态为: <b><%=@site_page.state == true ? "正常" : "关闭,关闭理由为:#{@site_page.state_description}" %></b></label>
<div class="form-row">
<%= f.input :identifier, label: '站点标识', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-5' , value: @site_page.identifier } %>
</div>
@ -62,7 +62,7 @@
</div>
<div class="form-row">
<%= f.input :language_frame, label: '建站工具', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, class: 'col-md-5' , value: @site_page.language_frame } %>
<%= f.input :language_frame, label: '建站工具', wrapper_html: { class: 'col-md-3' }, input_html: { readonly: true, type:'text', class: 'col-md-5' , value: @site_page.language_frame } %>
</div>
<div class="form-row">

View File

@ -1,5 +1,5 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('用户管理', admins_site_pages_path) %>
<% add_admin_breadcrumb('用户站点列表', admins_site_pages_path) %>
<% end %>
<div class="box search-form-container user-list-form">

View File

@ -1,21 +1,21 @@
<table class="table table-hover identity-verifications-list-table">
<thead class="thead-light">
<tr>
<th width="10%">序号</th>
<th width="10%" class="text-left">昵称</th>
<th width="5%">序号</th>
<th width="5%" class="text-left">昵称</th>
<th width="10%" class="text-left">仓库</th>
<th width="10%">站点状态</th>
<th width="5%">站点状态</th>
<th width="10%" class="text-left">站点名</th>
<th width="10%" class="text-left">站点标识</th>
<th width="20%" class="text-left">站点地址</th>
<th width="10%" class="text-left">站点地址</th>
<th width="10%" class="text-left">建站工具</th>
<th width="5%" class="text-left">建站工具</th>
<th width="10%" class="text-left">主题</th>
<th width="10%" class="text-left">上次构建时间</th>
<th width="10%" class="text-left">上次部署时间</th>
<th width="10%"><%= sort_tag('创建于', name: 'created_at', path: admins_site_pages_path) %></th>
<th width="14%">操作</th>
<th width="10%">操作</th>
</tr>
</thead>
<tbody>
@ -29,15 +29,18 @@
<% end %>
</td>
<td class="text-left">
<%= link_to "/#{site_page.user.login}/#{site_page.project.identifier}", target: '_blank' do %>
<%= overflow_hidden_span site_page.project.name, width: 100 %>
<%= link_to "/#{site_page.user.login}/#{site_page.project.try(:identifier)}", target: '_blank' do %>
<%= overflow_hidden_span site_page.project.try(:name), width: 100 %>
<% end %>
</td>
<td><%= display_text(site_page.state == true ? "正常" : "已关闭") %></td>
<td><%= display_text(site_page.site_name) %></td>
<td><%= display_text(site_page.identifier) %></td>
<td><%= link_to "#{site_page.url}", site_page.url, target: '_blank'%></td>
<td style="word-break: break-all;word-wrap: break-word;"><%= display_text(site_page.site_name) %></td>
<td style="word-break: break-all;word-wrap: break-word;"><%= display_text(site_page.identifier) %></td>
<td class="text-left">
<%= link_to "#{site_page.url}", target: '_blank' do %>
<%= overflow_hidden_span site_page.url, width: 120 %>
<% end %>
</td>
<td><%= display_text(site_page.language_frame) %></td>
<td><%= display_text(site_page.theme) %></td>
<td><%= display_text(site_page.last_build_at&.strftime('%Y-%m-%d %H:%M')) %></td>
@ -46,6 +49,7 @@
<td class="action-container">
<%= link_to "查看", edit_admins_site_page_path(site_page), class: 'action' %>
<%= link_to "删除", admins_site_page_path(site_page), method: :delete, data:{confirm: "确认删除吗,删除后站点将无法访问?"}, class: "action" %>
</td>
</tr>
<% end %>

View File

@ -97,7 +97,7 @@
<div class="form-group check_boxes optional">
<%= f.label :role, label: '站点权限' %>
<div class="d-flex">
<%= f.input :website_permission, as: :boolean, label: '开通站点', checked_value: 1, unchecked_value: 0 %>
<%= f.input :website_permission, as: :boolean, label: "开通站点(<b>关闭后,将清除该用户所有站点信息,此操作不可逆,请谨慎操作! 请谨慎操作!! 请谨慎操作!!</b>".html_safe, checked_value: 1, unchecked_value: 0 %>
</div>
</div>
<% end %>
@ -108,7 +108,7 @@
</div>
<div class="form-row mt-4">
<%= f.button :submit, value: '保存', class: 'btn-primary mr-3 px-4' %>
<%= f.button :submit, value: '保存', class: 'btn-primary mr-3 px-4 action' ,data:{confirm: "确认更改?"}%>
<%= link_to '取消', admins_users_path, class: 'btn btn-secondary px-4' %>
</div>
<% end %>

View File

@ -7,6 +7,7 @@ json.project_id page.project_id
json.site_name page.site_name
json.theme page.theme
json.state page.state
json.state_description page.state_description
json.language_frame page.language_frame
json.url page.url
json.created_at page.created_at.strftime("%Y-%m-%d %H:%M:%S")

View File

@ -1,4 +1,4 @@
json.total_count @pages.size
json.total_count @total_count
json.pages @pages.each do |page|
json.partial! 'info', locals: {page: page}
end

View File

@ -0,0 +1,10 @@
json.total_count @themes.size
json.themes @themes.map{|e|
{
name: e.name,
language_frame: e.language_frame,
image: e.image,
clone_url: e.clone_url,
order_index: e.order_index,
}
}

View File

@ -815,6 +815,7 @@ Rails.application.routes.draw do
resources :users_rank, only: [:index]
resources :identity_verifications
resources :site_pages
resources :page_themes
resources :projects_rank, only: [:index]
resources :sites
resources :edu_settings

View File

@ -0,0 +1,12 @@
class CreatePageThemes < ActiveRecord::Migration[5.2]
def change
create_table :page_themes do |t|
t.string :name, null:false
t.integer :language_frame, default:0
t.string :image_url
t.string :clone_url, null:false
t.integer :order_index,default: 0
t.timestamps
end
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Admins::PageThemesController, type: :controller do
end

View File

@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the Admins::PageThemesHelper. For example:
#
# describe Admins::PageThemesHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe Admins::PageThemesHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe PageTheme, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end