From 0a75dd7e3c687bb0b985afb5c905122247c35252 Mon Sep 17 00:00:00 2001 From: proddy Date: Mon, 17 Nov 2025 12:26:14 +0100 Subject: [PATCH] new action resetMQTT, called from MQTT Settings page --- interface/src/app/settings/MqttSettings.tsx | 47 ++++++++++++++++----- mock-api/restServer.ts | 4 ++ src/core/mqtt.cpp | 6 ++- src/web/WebStatusService.cpp | 3 ++ 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/interface/src/app/settings/MqttSettings.tsx b/interface/src/app/settings/MqttSettings.tsx index eca71a19c..f03d906a0 100644 --- a/interface/src/app/settings/MqttSettings.tsx +++ b/interface/src/app/settings/MqttSettings.tsx @@ -1,8 +1,11 @@ import { useCallback, useMemo, useState } from 'react'; +import { toast } from 'react-toastify'; import CancelIcon from '@mui/icons-material/Cancel'; +import SettingsBackupRestoreIcon from '@mui/icons-material/SettingsBackupRestore'; import WarningIcon from '@mui/icons-material/Warning'; import { + Box, Button, Checkbox, Grid, @@ -30,6 +33,8 @@ import type { MqttSettingsType } from 'types'; import { numberValue, updateValueDirty, useRest } from 'utils'; import { createMqttSettingsValidator, validate } from 'validators'; +import { callAction } from '../../api/app'; + const MqttSettings = () => { const { loadData, @@ -52,6 +57,16 @@ const MqttSettings = () => { const [fieldErrors, setFieldErrors] = useState(); + const sendResetMQTT = useCallback(() => { + void callAction({ action: 'resetMQTT' }) + .then(() => { + toast.success('MQTT ' + LL.REFRESH() + ' successful'); + }) + .catch((error) => { + toast.error(String(error.error?.message || 'An error occurred')); + }); + }, []); + const updateFormValue = useMemo( () => updateValueDirty( @@ -114,16 +129,28 @@ const MqttSettings = () => { {blocker ? : null} <> - - } - label={LL.ENABLE_MQTT()} - /> + + + } + label={LL.ENABLE_MQTT()} + /> + {data.enabled && ( + + )} +