From 060f7a2081e68a30a704cd3f7cf06d2dbf072773 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Sat, 20 Oct 2018 15:25:35 +0800 Subject: [PATCH] feat: Manage page for task queue --- application/index/controller/Admin.php | 13 ++++ application/index/controller/Queue.php | 3 + application/index/model/AdminHandler.php | 11 +++ application/index/view/admin/task.html | 99 ++++++++++++++++++++++++ application/index/view/header_admin.html | 3 + static/js/admin/task.js | 32 ++++++++ 6 files changed, 161 insertions(+) create mode 100644 application/index/view/admin/task.html create mode 100644 static/js/admin/task.js diff --git a/application/index/controller/Admin.php b/application/index/controller/Admin.php index 95fbb7d..0d55d85 100644 --- a/application/index/controller/Admin.php +++ b/application/index/controller/Admin.php @@ -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) { diff --git a/application/index/controller/Queue.php b/application/index/controller/Queue.php index 1472099..b884ba6 100644 --- a/application/index/controller/Queue.php +++ b/application/index/controller/Queue.php @@ -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); } diff --git a/application/index/model/AdminHandler.php b/application/index/model/AdminHandler.php index 0fac613..b71e934 100644 --- a/application/index/model/AdminHandler.php +++ b/application/index/model/AdminHandler.php @@ -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'); diff --git a/application/index/view/admin/task.html b/application/index/view/admin/task.html new file mode 100644 index 0000000..9fa92cc --- /dev/null +++ b/application/index/view/admin/task.html @@ -0,0 +1,99 @@ +{extend name="header_admin" /} +{block name="title"}任务队列 - {$options.siteName}{/block} +{block name="content"} +
# | +任务名 | +状态 | +创建日期 | +创建者UID | +
---|---|---|---|---|
{$t.id} | +{$t.task_name} | +{$t.status} | +{$t.addtime} | +{$t.uid} | +