improve torrent approval

This commit is contained in:
xiaomlove
2022-08-16 18:31:04 +08:00
parent bda12cce03
commit b398c8db3c
21 changed files with 418 additions and 75 deletions

View File

@@ -23,6 +23,7 @@ return [
'isp' => 'ISP',
'menu' => 'Custom menu',
'username_change_log' => 'Username change log',
'torrent_deny_reason' => 'Deny Reasons',
],
'resources' => [
'agent_allow' => [

View File

@@ -29,6 +29,7 @@ return [
'deadline' => 'Deadline',
'permanent' => 'Permanent',
'operator' => 'Operator',
'action' => 'Action',
'setting' => [
'nav_text' => 'Setting',
'backup' => [

View File

@@ -46,32 +46,33 @@ return [
'claim_disabled' => 'Claim is disabled',
'operation_log' => [
\App\Models\TorrentOperationLog::ACTION_TYPE_APPROVAL_DENY => [
'type_text' => 'Banned',
'notify_subject' => 'Torrent was banned',
'notify_msg' => 'Your torrent[url=:detail_url]:torrent_name[/url] was banned by :operator, Reason: :reason',
'type_text' => 'Allowed',
'notify_subject' => 'Torrent was allowed',
'notify_msg' => 'Your torrent[url=:detail_url]:torrent_name[/url] was allowed by :operator, Reason: :reason',
],
\App\Models\TorrentOperationLog::ACTION_TYPE_APPROVAL_ALLOW => [
'type_text' => 'Cancel banned',
'notify_subject' => 'Torrent was unbanned',
'notify_msg' => 'Your torrent: [url=:detail_url]:torrent_name[/url] unbanned by :operator',
'type_text' => 'Denied',
'notify_subject' => 'Torrent was denied',
'notify_msg' => 'Your torrent: [url=:detail_url]:torrent_name[/url] denied by :operator',
],
\App\Models\TorrentOperationLog::ACTION_TYPE_APPROVAL_NONE => [
'type_text' => 'Cancel banned',
'notify_subject' => 'Torrent was unbanned',
'notify_msg' => 'Your torrent: [url=:detail_url]:torrent_name[/url] unbanned by :operator',
'type_text' => 'Not reviewed',
'notify_subject' => 'Torrent was mark as not reviewed',
'notify_msg' => 'Your torrent: [url=:detail_url]:torrent_name[/url] was mark as not reviewed by :operator',
]
],
'owner_update_torrent_subject' => 'Banned torrent have been updated',
'owner_update_torrent_msg' => 'Torrent[url=:detail_url]:torrent_name[/url] has been updated by the owner, you can check if it meets the requirements and cancel the ban',
'owner_update_torrent_subject' => 'Denied torrent have been updated',
'owner_update_torrent_msg' => 'Torrent[url=:detail_url]:torrent_name[/url] has been updated by the owner, you can check if it meets the requirements and allow',
'approval' => [
'modal_title' => 'Torrent approval',
'status_label' => 'Approval status',
'comment_label' => 'Comment(optional)',
'status_text' => [
\App\Models\Torrent::APPROVAL_STATUS_NONE => 'Not reviewed',
\App\Models\Torrent::APPROVAL_STATUS_ALLOW => 'Approved',
\App\Models\Torrent::APPROVAL_STATUS_DENY => 'Not approved',
\App\Models\Torrent::APPROVAL_STATUS_ALLOW => 'Allowed',
\App\Models\Torrent::APPROVAL_STATUS_DENY => 'Denied',
],
'deny_comment_show' => 'Denied, reason: :reason',
'logs_label' => 'Approval logs'
],
];

View File

@@ -23,6 +23,7 @@ return [
'isp' => 'ISP',
'menu' => '自定义菜单',
'username_change_log' => '改名记录',
'torrent_deny_reason' => '拒绝原因',
],
'resources' => [
'agent_allow' => [

View File

@@ -29,6 +29,7 @@ return [
'deadline' => '截止时间',
'permanent' => '永久有效',
'operator' => '操作者',
'action' => '操作',
'setting' => [
'nav_text' => '设置',
'backup' => [

View File

@@ -46,23 +46,23 @@ return [
'claim_disabled' => '认领未启用',
'operation_log' => [
\App\Models\TorrentOperationLog::ACTION_TYPE_APPROVAL_DENY => [
'type_text' => '禁止',
'notify_subject' => '种子被禁止',
'notify_msg' => '你的种子:[url=:detail_url]:torrent_name[/url] 被 :operator 禁止,原因::reason',
'type_text' => '审核拒绝',
'notify_subject' => '种子审核拒绝',
'notify_msg' => '你的种子:[url=:detail_url]:torrent_name[/url] 被 :operator 审核拒绝,原因::reason',
],
\App\Models\TorrentOperationLog::ACTION_TYPE_APPROVAL_ALLOW => [
'type_text' => '取消禁止',
'notify_subject' => '种子取消禁止',
'notify_msg' => '你的种子:[url=:detail_url]:torrent_name[/url] 被 :operator 取消禁止',
'type_text' => '审核通过',
'notify_subject' => '种子审核通过',
'notify_msg' => '你的种子:[url=:detail_url]:torrent_name[/url] 被 :operator 审核通过',
],
\App\Models\TorrentOperationLog::ACTION_TYPE_APPROVAL_NONE => [
'type_text' => '取消禁止',
'notify_subject' => '种子取消禁止',
'notify_msg' => '你的种子:[url=:detail_url]:torrent_name[/url] 被 :operator 取消禁止',
'type_text' => '标记未审核',
'notify_subject' => '种子标记未审核',
'notify_msg' => '你的种子:[url=:detail_url]:torrent_name[/url] 被 :operator 标记未审核',
]
],
'owner_update_torrent_subject' => '被禁种子已更新',
'owner_update_torrent_msg' => '种子:[url=:detail_url]:torrent_name[/url] 已被作者更新,可以检查是否符合要求并取消禁止',
'owner_update_torrent_subject' => '审核拒绝种子已更新',
'owner_update_torrent_msg' => '种子:[url=:detail_url]:torrent_name[/url] 已被作者更新,可以检查是否符合要求并审核通过',
'approval' => [
'modal_title' => '种子审核',
'status_label' => '审核状态',
@@ -73,5 +73,6 @@ return [
\App\Models\Torrent::APPROVAL_STATUS_DENY => '拒绝',
],
'deny_comment_show' => '审核不通过,原因::reason',
'logs_label' => '审核记录',
],
];

View File

@@ -23,6 +23,7 @@ return [
'isp' => 'ISP',
'menu' => '自定義菜單',
'username_change_log' => '改名記錄',
'torrent_deny_reason' => '拒絕原因',
],
'resources' => [
'agent_allow' => [

View File

@@ -29,6 +29,7 @@ return [
'deadline' => '截止時間',
'permanent' => '永久有效',
'operator' => '操作者',
'action' => '操作',
'setting' => [
'nav_text' => '設置',
'backup' => [

View File

@@ -46,23 +46,23 @@ return [
'claim_disabled' => '認領未啟用',
'operation_log' => [
\App\Models\TorrentOperationLog::ACTION_TYPE_APPROVAL_DENY => [
'type_text' => '禁止',
'notify_subject' => '種子被禁止',
'notify_msg' => '的種子:[url=:detail_url]:torrent_name[/url] 被 :operator 禁止,原因::reason',
'type_text' => '審核拒絕',
'notify_subject' => '種子審核拒絕',
'notify_msg' => '的種子:[url=:detail_url]:torrent_name[/url] 被 :operator 審核拒絕,原因::reason',
],
\App\Models\TorrentOperationLog::ACTION_TYPE_APPROVAL_ALLOW => [
'type_text' => '取消禁止',
'notify_subject' => '種子取消禁止',
'notify_msg' => '的種子:[url=:detail_url]:torrent_name[/url] 被 :operator 取消禁止',
'type_text' => '審核通過',
'notify_subject' => '種子審核通過',
'notify_msg' => '的種子:[url=:detail_url]:torrent_name[/url] 被 :operator 審核通過',
],
\App\Models\TorrentOperationLog::ACTION_TYPE_APPROVAL_NONE => [
'type_text' => '取消禁止',
'notify_subject' => '種子取消禁止',
'notify_msg' => '的種子:[url=:detail_url]:torrent_name[/url] 被 :operator 取消禁止',
'type_text' => '標記未審核',
'notify_subject' => '種子標記未審核',
'notify_msg' => '的種子:[url=:detail_url]:torrent_name[/url] 被 :operator 標記未審核',
]
],
'owner_update_torrent_subject' => '被禁種子已更新',
'owner_update_torrent_msg' => '種子:[url=:detail_url]:torrent_name[/url] 已被作者更新,可以檢查是否符合要求並取消禁止',
'owner_update_torrent_subject' => '審核拒絕種子已更新',
'owner_update_torrent_msg' => '種子:[url=:detail_url]:torrent_name[/url] 已被作者更新,可以檢查是否符合要求併審核通過',
'approval' => [
'modal_title' => '種子審核',
'status_label' => '審核狀態',
@@ -73,5 +73,6 @@ return [
\App\Models\Torrent::APPROVAL_STATUS_DENY => '拒絕',
],
'deny_comment_show' => '審核不通過,原因::reason',
'logs_label' => '審核記錄'
],
];

View File

@@ -0,0 +1,14 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="/styles/sprites.css">
<link rel="stylesheet" href="/vendor/layui/css/layui.css">
@stack('css')
<script type="text/javascript" src="/js/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="/vendor/layui/layui.js"></script>
@stack('scripts')
</head>
<body>
@yield('content')
</body>
</html>

View File

@@ -0,0 +1,107 @@
@extends('layui-page')
@push('css')
<style>
.form-comments {
display: flex;
}
.form-comments .form{
flex-basis: 60%;
}
.form-comments .comments{
flex-basis: 40%;
padding: 15px;
}
.form-comments .comments .comment{
padding: 5px 10px;
border: 1px solid #ccc;
border-radius: 10px;
cursor: pointer;
display: inline-block;
margin: 4px 0;
}
.layui-form-label {
width: 120px;
}
.layui-input-block {
margin-left: 150px;
}
</style>
@endpush
@section('content')
<div class="form-comments">
<form class="layui-form form" action="">
@csrf
<input type="hidden" name="torrent_id" value="{{ $torrent->id }}">
<div class="layui-form-item">
<label class="layui-form-label">{{ __('torrent.approval.status_label') }}</label>
<div class="layui-input-block">
@foreach (\App\Models\Torrent::listApprovalStatus(true) as $status => $text)
<input type="radio" name="approval_status" value="{{ $status }}" title="{{ $text }}" @if($status == $torrent->approval_status) checked @endif>
@endforeach
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">{{ __('torrent.approval.comment_label') }}</label>
<div class="layui-input-block">
<textarea id="approval-comment" name="comment" placeholder="" class="layui-textarea"></textarea>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" lay-submit lay-filter="formDemo">Submit</button>
<button type="reset" class="layui-btn layui-btn-primary">Reset</button>
</div>
</div>
</form>
<div class="comments">
@foreach($denyReasons as $reason)
<span class="comment">{{ $reason->name }}</span>
@endforeach
</div>
</div>
<div style="text-align: center;margin-top: 20px;font-weight: 400">{{ __('torrent.approval.logs_label') }}</div>
<table id="table"></table>
<script>
layui.use('table', function(){
var table = layui.table;
var util = layui.util;
table.render({
elem: '#table'
,size: 'sm' //小尺寸的表格
// ,height: 312
,url: '/web/torrent-approval-logs?__format=layui-table&torrent_id={{ $torrent->id }}' //数据接口
,page: true //开启分页
,cols: [[ //表头
{field: 'id', title: 'ID', }
,{field: 'username', title: '{{ __('label.username') }}', }
,{field: 'action_type_text', title: '{{ __('label.action') }}', }
,{field: 'comment', title: '{{ __('label.comment') }}',}
,{field: 'created_at', title: '{{ __('label.created_at') }}'}
]]
});
});
layui.use('form', function(){
var form = layui.form;
//监听提交
form.on('submit(formDemo)', function(data){
console.log(data)
jQuery.post('/web/torrent-approval', data.field, function (response) {
if (response.ret != 0) {
layer.alert(response.msg)
return
}
parent.window.location.reload()
}, 'json')
return false;
});
});
let approvalComment = jQuery('#approval-comment')
jQuery('.comments').on("click", '.comment', function () {
let text = jQuery(this).text()
let oldText = approvalComment.val()
approvalComment.val(oldText + text)
})
</script>
@endsection