8000 Feature/任务配置优化 by yoonper · Pull Request #118 · 4x99/code6 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feature/任务配置优化 #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion app/Http/Controllers/ConfigJobController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Models\ConfigJob;
use Cron\CronExpression;
use Illuminate\Http\Request;

class ConfigJobController extends Controller
Expand All @@ -20,7 +21,11 @@ public function view()
*/
public function index()
{
return ConfigJob::orderByDesc('id')->get();
$data = ConfigJob::orderByDesc('id')->get();
foreach ($data as &$item) {
$item['next_scan_at'] = $this->getNextScanAt($item['scan_interval_min']);
}
return $data;
}

/**
Expand Down Expand Up @@ -66,6 +71,7 @@ public function update(Request $request, $id)
$fields = ['keyword', 'scan_page', 'scan_interval_min', 'store_type', 'description'];
$configJob = ConfigJob::find($id);
$success = $configJob->update($request->all($fields));
$configJob['next_scan_at'] = $this->getNextScanAt($configJob['scan_interval_min']);
return ['success' => $success, 'data' => $configJob];
} catch (\Exception $e) {
return ['success' => false, 'message' => $e->getMessage()];
Expand All @@ -87,4 +93,17 @@ public function destroy($id)
return ['success' => false, 'message' => $e->getMessage()];
}
}

/**
* 下次扫描时间
*
* @param $interval
* @return string
*/
private function getNextScanAt($interval)
{
$expression = "*/$interval * * * *";
$cron = CronExpression::factory($expression);
return $cron->getNextRunDate()->format('Y-m-d H:i:s');
}
}
6 changes: 6 additions & 0 deletions public/css/configJob.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.x-grid-cell-inner {
white-space: pre-wrap;
word-break: break-all;
line-height: 20px;
}

.x-window-text a, .x-window-text span {
color: #0070D5;
}
Expand Down
29 changes: 22 additions & 7 deletions resources/views/configJob/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

var grid = Ext.create('plugin.grid', {
store: Ext.data.StoreManager.lookup('store'),
bufferedRenderer: false,
tbar: {
margin: '5 12 15 18',
items: [
Expand Down Expand Up @@ -61,28 +62,40 @@
{
text: '扫描页数',
dataIndex: 'scan_page',
width: 170,
width: 110,
align: 'center',
},
{
text: '扫描间隔(分钟)',
text: '扫描间隔',
dataIndex: 'scan_interval_min',
width: 170,
width: 110,
align: 'center',
renderer: function (value) {
return value + ' 分钟';
}
},
{
text: '扫描结果',
dataIndex: 'store_type',
width: 170,
width: 160,
align: 'center',
renderer: function (value) {
return storeType[value].text;
}
},
{
text: '最后扫描时间',
text: '下次扫描时间',
dataIndex: 'next_scan_at',
width: 160,
align: 'center',
renderer: function (value) {
return value ? value : '-';
}
},
{
text: '最近扫描时间',
dataIndex: 'last_scan_at',
width: 170,
width: 160,
align: 'center',
renderer: function (value) {
return value ? value : '-';
Expand All @@ -100,7 +113,7 @@
{
text: '操作',
sortable: false,
width: 250,
width: 220,
align: 'center',
xtype: 'widgetcolumn',
widget: {
Expand Down Expand Up @@ -182,13 +195,15 @@ function winForm(data) {
name: 'scan_page',
fieldLabel: '扫描页数(每页 30 条)',
minValue: 1,
allowDecimals: false,
value: data.scan_page ? data.scan_page : 3,
},
{
xtype: 'numberfield',
name: 'scan_interval_min',
fieldLabel: '扫描间隔(分钟)',
minValue: 1,
allowDecimals: false,
value: data.scan_interval_min ? data.scan_interval_min : 60,
},
{
Expand Down
0