From 7bf713dfea681da50bb0626f8c50e79cd13794ea Mon Sep 17 00:00:00 2001 From: Rick Watson Date: Sun, 1 Dec 2019 08:28:40 +0000 Subject: [PATCH] rename "reset" to "restart" --- interface/src/constants/Endpoints.js | 2 +- interface/src/containers/SystemStatus.js | 48 ++++++++++++------------ lib/framework/ESP8266React.cpp | 2 +- lib/framework/ESP8266React.h | 4 +- lib/framework/ResetService.cpp | 18 --------- lib/framework/ResetService.h | 29 -------------- lib/framework/RestartService.cpp | 18 +++++++++ lib/framework/RestartService.h | 29 ++++++++++++++ 8 files changed, 75 insertions(+), 75 deletions(-) delete mode 100644 lib/framework/ResetService.cpp delete mode 100644 lib/framework/ResetService.h create mode 100644 lib/framework/RestartService.cpp create mode 100644 lib/framework/RestartService.h diff --git a/interface/src/constants/Endpoints.js b/interface/src/constants/Endpoints.js index fc6b7cc..2fc772d 100644 --- a/interface/src/constants/Endpoints.js +++ b/interface/src/constants/Endpoints.js @@ -13,4 +13,4 @@ export const SYSTEM_STATUS_ENDPOINT = ENDPOINT_ROOT + "systemStatus"; export const SIGN_IN_ENDPOINT = ENDPOINT_ROOT + "signIn"; export const VERIFY_AUTHORIZATION_ENDPOINT = ENDPOINT_ROOT + "verifyAuthorization"; export const SECURITY_SETTINGS_ENDPOINT = ENDPOINT_ROOT + "securitySettings"; -export const RESET_ENDPOINT = ENDPOINT_ROOT + "reset"; +export const RESTART_ENDPOINT = ENDPOINT_ROOT + "restart"; diff --git a/interface/src/containers/SystemStatus.js b/interface/src/containers/SystemStatus.js index ba7e317..b502cfd 100644 --- a/interface/src/containers/SystemStatus.js +++ b/interface/src/containers/SystemStatus.js @@ -22,7 +22,7 @@ import DataUsageIcon from '@material-ui/icons/DataUsage'; import AutorenewIcon from '@material-ui/icons/Autorenew'; import RefreshIcon from '@material-ui/icons/Refresh'; -import { SYSTEM_STATUS_ENDPOINT, RESET_ENDPOINT } from '../constants/Endpoints'; +import { SYSTEM_STATUS_ENDPOINT, RESTART_ENDPOINT } from '../constants/Endpoints'; import { restComponent } from '../components/RestComponent'; import LoadingNotification from '../components/LoadingNotification'; import SectionContent from '../components/SectionContent'; @@ -42,7 +42,7 @@ class SystemStatus extends Component { super(props); this.state = { - confirmReset: false, + confirmRestart: false, processing: false } } @@ -112,53 +112,53 @@ class SystemStatus extends Component { - ); } - onReset = () => { - this.setState({ confirmReset: true }); + onRestart = () => { + this.setState({ confirmRestart: true }); } - onResetRejected = () => { - this.setState({ confirmReset: false }); + onRestartRejected = () => { + this.setState({ confirmRestart: false }); } - onResetConfirmed = () => { + onRestartConfirmed = () => { this.setState({ processing: true }); - redirectingAuthorizedFetch(RESET_ENDPOINT, { method: 'POST' }) + redirectingAuthorizedFetch(RESTART_ENDPOINT, { method: 'POST' }) .then(response => { if (response.status === 200) { - this.props.enqueueSnackbar("Device is resetting", { variant: 'info' }); - this.setState({ processing: false, confirmReset: false }); + this.props.enqueueSnackbar("Device is restarting", { variant: 'info' }); + this.setState({ processing: false, confirmRestart: false }); } else { throw Error("Invalid status code: " + response.status); } }) .catch(error => { - this.props.enqueueSnackbar(error.message || "Problem resetting device", { variant: 'error' }); - this.setState({ processing: false, confirmReset: false }); + this.props.enqueueSnackbar(error.message || "Problem restarting device", { variant: 'error' }); + this.setState({ processing: false, confirmRestart: false }); }); } - renderResetDialog() { + renderRestartDialog() { return ( - Confirm Reset + Confirm Restart - Are you sure you want to reset the device? + Are you sure you want to restart the device? - - @@ -171,14 +171,14 @@ class SystemStatus extends Component { return ( this.renderSystemStatus(data, classes) } /> - {this.renderResetDialog()} + {this.renderRestartDialog()} ) } diff --git a/lib/framework/ESP8266React.cpp b/lib/framework/ESP8266React.cpp index e2cdcb8..fefa68e 100644 --- a/lib/framework/ESP8266React.cpp +++ b/lib/framework/ESP8266React.cpp @@ -6,7 +6,7 @@ ESP8266React::ESP8266React(AsyncWebServer* server, FS* fs): _apSettingsService(server, fs, &_securitySettingsService), _ntpSettingsService(server, fs, &_securitySettingsService), _otaSettingsService(server, fs, &_securitySettingsService), - _ResetService(server, &_securitySettingsService), + _restartService(server, &_securitySettingsService), _authenticationService(server, &_securitySettingsService), _wifiScanner(server, &_securitySettingsService), _wifiStatus(server, &_securitySettingsService), diff --git a/lib/framework/ESP8266React.h b/lib/framework/ESP8266React.h index 75e33a8..1232345 100644 --- a/lib/framework/ESP8266React.h +++ b/lib/framework/ESP8266React.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include class ESP8266React { @@ -47,7 +47,7 @@ class ESP8266React { APSettingsService _apSettingsService; NTPSettingsService _ntpSettingsService; OTASettingsService _otaSettingsService; - ResetService _ResetService; + RestartService _restartService; AuthenticationService _authenticationService; diff --git a/lib/framework/ResetService.cpp b/lib/framework/ResetService.cpp deleted file mode 100644 index 660de7d..0000000 --- a/lib/framework/ResetService.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include - -ResetService::ResetService(AsyncWebServer* server, SecurityManager* securityManager) { - server->on(RESET_SERVICE_PATH, HTTP_POST, securityManager->wrapRequest( - std::bind(&ResetService::reset, this, std::placeholders::_1), AuthenticationPredicates::IS_ADMIN - )); -} - -void ResetService::reset(AsyncWebServerRequest* request) { - request->onDisconnect([]() { -#if defined(ESP8266) - ESP.reset(); -#elif defined(ESP_PLATFORM) - ESP.restart(); -#endif - }); - request->send(200); -} diff --git a/lib/framework/ResetService.h b/lib/framework/ResetService.h deleted file mode 100644 index ab9b729..0000000 --- a/lib/framework/ResetService.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef ResetService_h -#define ResetService_h - -#if defined(ESP8266) - #include - #include -#elif defined(ESP_PLATFORM) - #include - #include -#endif - -#include -#include - -#define RESET_SERVICE_PATH "/rest/reset" - -class ResetService { - - public: - - ResetService(AsyncWebServer* server, SecurityManager* securityManager); - - private: - - void reset(AsyncWebServerRequest *request); - -}; - -#endif // end ResetService_h \ No newline at end of file diff --git a/lib/framework/RestartService.cpp b/lib/framework/RestartService.cpp new file mode 100644 index 0000000..fda03c8 --- /dev/null +++ b/lib/framework/RestartService.cpp @@ -0,0 +1,18 @@ +#include + +RestartService::RestartService(AsyncWebServer* server, SecurityManager* securityManager) { + server->on(RESTART_SERVICE_PATH, HTTP_POST, securityManager->wrapRequest( + std::bind(&RestartService::restart, this, std::placeholders::_1), AuthenticationPredicates::IS_ADMIN + )); +} + +void RestartService::restart(AsyncWebServerRequest* request) { + request->onDisconnect([]() { +#if defined(ESP8266) + ESP.reset(); +#elif defined(ESP_PLATFORM) + ESP.restart(); +#endif + }); + request->send(200); +} diff --git a/lib/framework/RestartService.h b/lib/framework/RestartService.h new file mode 100644 index 0000000..8bcfec3 --- /dev/null +++ b/lib/framework/RestartService.h @@ -0,0 +1,29 @@ +#ifndef RestartService_h +#define RestartService_h + +#if defined(ESP8266) + #include + #include +#elif defined(ESP_PLATFORM) + #include + #include +#endif + +#include +#include + +#define RESTART_SERVICE_PATH "/rest/restart" + +class RestartService { + + public: + + RestartService(AsyncWebServer* server, SecurityManager* securityManager); + + private: + + void restart(AsyncWebServerRequest *request); + +}; + +#endif // end RestartService_h \ No newline at end of file