feat(app-ui): 機台綁定儲存後主動推送 update_settings,機台立即套用 UI
沿用 app 既有 update_settings→downloadSetting 處理(APK 不需改);推送失敗(離線)則下次同步套用 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bfbe311503
commit
ff1adea54c
@ -186,7 +186,7 @@ class UiElementController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateMachineBundle(Request $request, Machine $machine)
|
||||
public function updateMachineBundle(Request $request, Machine $machine, \App\Services\Machine\MqttService $mqttService)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'ui_bundle_id' => 'nullable|integer|exists:ui_bundles,id',
|
||||
@ -201,6 +201,26 @@ class UiElementController extends Controller
|
||||
$machine->settings = $settings;
|
||||
$machine->save();
|
||||
|
||||
return redirect()->route('admin.app.ui-machines')->with('success', __('Saved'));
|
||||
// 儲存後主動推送,讓機台立即重拉設定並套用 UI 換膚。
|
||||
// 沿用 app 端既有的 update_settings 處理(MqttService → downloadSetting → 解析 UISet),APK 不需改動。
|
||||
$command = \App\Models\Machine\RemoteCommand::create([
|
||||
'machine_id' => $machine->id,
|
||||
'user_id' => auth()->id(),
|
||||
'command_type' => 'update_settings',
|
||||
'payload' => [],
|
||||
'status' => 'pending',
|
||||
'remark' => __('Sync UI bundle'),
|
||||
]);
|
||||
|
||||
$pushed = $mqttService->pushCommand($machine->serial_no, 'update_settings', [], (string) $command->id);
|
||||
if (!$pushed) {
|
||||
$command->update(['status' => 'failed', 'note' => 'MQTT push failed']);
|
||||
}
|
||||
|
||||
$message = $pushed
|
||||
? __('Saved and update pushed to machine.')
|
||||
: __('Saved. Machine will apply on next sync/reboot.');
|
||||
|
||||
return redirect()->route('admin.app.ui-machines')->with('success', $message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2343,6 +2343,9 @@
|
||||
"UI element deleted": "UI element deleted",
|
||||
"UI bundle created": "UI bundle created",
|
||||
"UI bundle deleted": "UI bundle deleted",
|
||||
"Sync UI bundle": "Sync UI bundle",
|
||||
"Saved and update pushed to machine.": "Saved and update pushed to machine.",
|
||||
"Saved. Machine will apply on next sync/reboot.": "Saved. Machine will apply on next sync/reboot.",
|
||||
"No data": "No data",
|
||||
"Back": "Back",
|
||||
"Rename": "Rename",
|
||||
|
||||
@ -2344,6 +2344,9 @@
|
||||
"UI element deleted": "UI 元素已刪除",
|
||||
"UI bundle created": "UI 組合已新增",
|
||||
"UI bundle deleted": "UI 組合已刪除",
|
||||
"Sync UI bundle": "同步 UI 組合",
|
||||
"Saved and update pushed to machine.": "已儲存,並已推送更新到機台(機台將立即重拉並套用)。",
|
||||
"Saved. Machine will apply on next sync/reboot.": "已儲存。推送未成功(機台可能離線),將於下次同步/重開機時套用。",
|
||||
"No data": "無資料",
|
||||
"Back": "返回",
|
||||
"Rename": "重新命名",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user