feat: Manage page for task queue
This commit is contained in:
parent
a67185c750
commit
060f7a2081
6 changed files with 161 additions and 0 deletions
|
@ -252,6 +252,10 @@ class Admin extends Controller{
|
|||
return $this->adminObj->saveAria2Setting(input('post.'));
|
||||
}
|
||||
|
||||
public function SaveTaskOption(){
|
||||
return $this->adminObj->saveTaskOption(input('post.'));
|
||||
}
|
||||
|
||||
public function SendTestMail(){
|
||||
return $this->adminObj->sendTestMail(input('post.'));
|
||||
}
|
||||
|
@ -474,6 +478,15 @@ class Admin extends Controller{
|
|||
]);
|
||||
}
|
||||
|
||||
public function Queue(){
|
||||
$taskOption = Option::getValue("task_queue_token");
|
||||
return view('task', [
|
||||
'options' => $this->siteOptions,
|
||||
'taskOption' => $taskOption,
|
||||
'task' => $this->adminObj->getTasks(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function PurchaseGroup(){
|
||||
$groupData = json_decode(Option::getValue("group_sell_data"),true);
|
||||
foreach ($groupData as $key => $value) {
|
||||
|
|
|
@ -12,6 +12,9 @@ class Queue extends Controller{
|
|||
|
||||
public function __construct(\think\Request $request = null){
|
||||
$token = Option::getValue("task_queue_token");
|
||||
if($token==""){
|
||||
abort(403);
|
||||
}
|
||||
if(Request::instance()->header("Authorization") !="Bearer ".$token){
|
||||
abort(403);
|
||||
}
|
||||
|
|
|
@ -109,6 +109,10 @@ class AdminHandler extends Model{
|
|||
return $this->saveOptions($options);
|
||||
}
|
||||
|
||||
public function saveTaskOption($options){
|
||||
return $this->saveOptions($options);
|
||||
}
|
||||
|
||||
public function saveMailTemplate($options){
|
||||
return $this->saveOptions($options);
|
||||
}
|
||||
|
@ -394,6 +398,13 @@ class AdminHandler extends Model{
|
|||
$this->pageNow = input("?get.page")?input("get.page"):1;
|
||||
}
|
||||
|
||||
public function getTasks(){
|
||||
$taskData = Db::name("task")
|
||||
->order("id DESC")
|
||||
->paginate(10);
|
||||
return $taskData;
|
||||
}
|
||||
|
||||
public function listFile(){
|
||||
$pageSize = !cookie('?pageSize') ? 10 : cookie('pageSize');
|
||||
$orderType = empty(cookie('orderMethodFile')) ? "id DESC" : cookie('orderMethodFile');
|
||||
|
|
99
application/index/view/admin/task.html
Normal file
99
application/index/view/admin/task.html
Normal file
|
@ -0,0 +1,99 @@
|
|||
{extend name="header_admin" /}
|
||||
{block name="title"}任务队列 - {$options.siteName}{/block}
|
||||
{block name="content"}
|
||||
<div class="content-wrapper">
|
||||
<div class="container-fluid">
|
||||
<!-- Breadcrumbs-->
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item">
|
||||
<a href="/Admin">管理面板</a>
|
||||
</li>
|
||||
<li class="breadcrumb-item active">任务队列</li>
|
||||
<li class="breadcrumb-item active">配置</li>
|
||||
</ol>
|
||||
|
||||
<!-- Area Chart Example-->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h2>任务队列</h2>
|
||||
<br>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<ul class="nav nav-tabs card-header-tabs">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#options"><i class="fa fa-cog" aria-hidden="true"></i> 配置</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#list"><i class="fa fa-list" aria-hidden="true"></i> 任务列表</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="tab-content" >
|
||||
<div class="tab-pane fade show active" id="options" role="tabpanel" aria-labelledby="pills-home-tab">
|
||||
<form id="taskOptions">
|
||||
<div class="row form-setting">
|
||||
<div class="col-md-1 form-label ">
|
||||
<label for="fromName" class="col-form-label col-form-label-sm">Token</label>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<input type="text" class="form-control" name="task_queue_token" id="task_queue_token" value="{$taskOption}" spellcheck="false">
|
||||
|
||||
</div>
|
||||
<div class="col-md-4 option-des"> 任务队列鉴权Token,应该与任务队列配置文件conf.yaml中的token保持一致,留空表示禁止任务队列请求</div>
|
||||
</div>
|
||||
<div class="row form-setting">
|
||||
<div class="col-md-1 form-label ">
|
||||
</div>
|
||||
<div class="col-md-4"> <button type="button" class="btn btn-outline-secondary" id="generateToken">随机生成Token</button> <button type="button" class="btn btn-primary" id="saveTask">保存设置</button></div>
|
||||
<div class="col-md-4 option-des"> </div>
|
||||
<br><br><br>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="list" role="tabpanel" aria-labelledby="pills-profile-tab">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="textCenter">#</th>
|
||||
<th scope="col" width="50%">任务名</th>
|
||||
<th scope="col" class="textCenter">状态</th>
|
||||
<th scope="col" class="textCenter">创建日期</th>
|
||||
<th scope="col" class="textCenter">创建者UID</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="listContent">
|
||||
{volist name='task' id='t'}
|
||||
<tr id="i-{$t.id}" >
|
||||
<th scope="row" class="textCenter">{$t.id}</th>
|
||||
<td>{$t.task_name}</td>
|
||||
<td class="textCenter">{$t.status}</td>
|
||||
<td class="textCenter">{$t.addtime}</td>
|
||||
<td class="textCenter">{$t.uid}</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
{$task->render()}
|
||||
</div>
|
||||
<div class="tab-pane fade" id="tools" role="tabpanel" aria-labelledby="pills-profile-tab">
|
||||
ddd
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><br>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Example DataTables Card-->
|
||||
</div>
|
||||
<!-- /.container-fluid-->
|
||||
</div>
|
||||
{/block}
|
||||
{block name="js"}
|
||||
<script src="/static/js/admin/summernote.min.js"></script>
|
||||
<script src="/static/js/admin/summernote-zh-CN.min.js"></script>
|
||||
<script src="/static/js/admin/task.js"></script>
|
||||
{/block}
|
|
@ -122,6 +122,9 @@
|
|||
<span class="nav-link-text">其他</span>
|
||||
</a>
|
||||
<ul class="sidenav-second-level collapse" id="else">
|
||||
<li>
|
||||
<a href="/Admin/Queue">任务队列</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/Admin/Cron">定时任务</a>
|
||||
</li>
|
||||
|
|
32
static/js/admin/task.js
Normal file
32
static/js/admin/task.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
$("#saveTask").click(function() {
|
||||
$("#saveTask").attr("disabled", "true");
|
||||
$.post("/Admin/SaveTaskOption",
|
||||
$("#taskOptions").serialize()
|
||||
, function(data) {
|
||||
if (data.error == "1") {
|
||||
toastr["warning"](data.msg);
|
||||
$("#saveTask").removeAttr("disabled");
|
||||
} else if (data.error == "200") {
|
||||
toastr["success"]("设置已保存");
|
||||
$("#saveTask").removeAttr("disabled");
|
||||
}else{
|
||||
toastr["warning"]("未知错误");
|
||||
$("#saveTask").removeAttr("disabled");
|
||||
}
|
||||
});
|
||||
})
|
||||
$("#generateToken").click(function(){
|
||||
len = 64;
|
||||
var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
|
||||
var maxPos = $chars.length;
|
||||
var pwd = '';
|
||||
for (i = 0; i < len; i++) {
|
||||
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
|
||||
}
|
||||
$("#task_queue_token").val(pwd);
|
||||
})
|
||||
$(document).ready(function(){
|
||||
if(document.location.href.indexOf("page")!=-1){
|
||||
$("[href='#list']").click();
|
||||
}
|
||||
})
|
Loading…
Add table
Reference in a new issue