mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-23 19:37:35 +08:00
feat: add xhttp subscriptions, network monitoring, chart legend toggle and ticket sender labels
This commit is contained in:
@@ -168,12 +168,19 @@ class MachineController extends Controller
|
||||
$params = $request->validate([
|
||||
'machine_id' => 'required|integer|exists:v2_server_machine,id',
|
||||
'limit' => 'nullable|integer|min:10|max:1440',
|
||||
'range_hours' => 'nullable|integer|min:1|max:24',
|
||||
]);
|
||||
|
||||
$query = ServerMachineLoadHistory::query()
|
||||
->where('machine_id', $params['machine_id']);
|
||||
|
||||
if (!empty($params['range_hours'])) {
|
||||
$query->where('recorded_at', '>=', now()->subHours((int) $params['range_hours'])->timestamp);
|
||||
}
|
||||
|
||||
$limit = (int) ($params['limit'] ?? 60);
|
||||
|
||||
$history = ServerMachineLoadHistory::query()
|
||||
->where('machine_id', $params['machine_id'])
|
||||
$history = $query
|
||||
->orderByDesc('recorded_at')
|
||||
->limit($limit)
|
||||
->get([
|
||||
@@ -182,6 +189,8 @@ class MachineController extends Controller
|
||||
'mem_used',
|
||||
'disk_total',
|
||||
'disk_used',
|
||||
'net_in_speed',
|
||||
'net_out_speed',
|
||||
'recorded_at',
|
||||
])
|
||||
->reverse()
|
||||
|
||||
@@ -225,6 +225,7 @@ class ManageController extends Controller
|
||||
'ids' => 'required|array',
|
||||
'ids.*' => 'integer',
|
||||
'show' => 'nullable|integer|in:0,1',
|
||||
'enabled' => 'nullable|boolean',
|
||||
]);
|
||||
|
||||
$ids = $params['ids'];
|
||||
@@ -236,6 +237,9 @@ class ManageController extends Controller
|
||||
if (array_key_exists('show', $params) && $params['show'] !== null) {
|
||||
$update['show'] = (int) $params['show'];
|
||||
}
|
||||
if (array_key_exists('enabled', $params) && $params['enabled'] !== null) {
|
||||
$update['enabled'] = (bool) $params['enabled'];
|
||||
}
|
||||
|
||||
if (empty($update)) {
|
||||
return $this->fail([400, '没有可更新的字段']);
|
||||
|
||||
Reference in New Issue
Block a user