Fix user form
* fix issue with checkbox on user form * use consistent style for const char pointers * use unique hostname by default
This commit is contained in:
parent
7aed5c0eb2
commit
6e22893051
@ -3,7 +3,8 @@ build_flags =
|
||||
; WiFi settings
|
||||
-D FACTORY_WIFI_SSID=\"\"
|
||||
-D FACTORY_WIFI_PASSWORD=\"\"
|
||||
-D FACTORY_WIFI_HOSTNAME=\"esp-react\"
|
||||
; if unspecified the devices hardware ID will be used
|
||||
; -D FACTORY_WIFI_HOSTNAME=\"esp-react\"
|
||||
|
||||
; Access point settings
|
||||
-D FACTORY_AP_PROVISION_MODE=AP_MODE_DISCONNECTED
|
||||
|
@ -13,7 +13,7 @@ import SaveIcon from '@material-ui/icons/Save';
|
||||
import PersonAddIcon from '@material-ui/icons/PersonAdd';
|
||||
|
||||
import { withAuthenticatedContext, AuthenticatedContextProps } from '../authentication';
|
||||
import { RestFormProps, FormActions, FormButton } from '../components';
|
||||
import { RestFormProps, FormActions, FormButton, extractEventValue } from '../components';
|
||||
|
||||
import UserForm from './UserForm';
|
||||
import { SecuritySettings, User } from './types';
|
||||
@ -93,13 +93,9 @@ class ManageUsersForm extends React.Component<ManageUsersFormProps, ManageUsersF
|
||||
};
|
||||
|
||||
handleUserValueChange = (name: keyof User) => (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
this.setState({ user: { ...this.state.user!, [name]: event.target.value } });
|
||||
this.setState({ user: { ...this.state.user!, [name]: extractEventValue(event) } });
|
||||
};
|
||||
|
||||
handleUserCheckboxChange = (name: keyof User) => (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
this.setState({ user: { ...this.state.user!, [name]: event.target.checked } });
|
||||
}
|
||||
|
||||
onSubmit = () => {
|
||||
this.props.saveData();
|
||||
this.props.authenticatedContext.refresh();
|
||||
|
@ -11,7 +11,7 @@ class FSPersistence {
|
||||
JsonStateUpdater<T> stateUpdater,
|
||||
StatefulService<T>* statefulService,
|
||||
FS* fs,
|
||||
char const* filePath,
|
||||
const char* filePath,
|
||||
size_t bufferSize = DEFAULT_BUFFER_SIZE) :
|
||||
_stateReader(stateReader),
|
||||
_stateUpdater(stateUpdater),
|
||||
@ -81,7 +81,7 @@ class FSPersistence {
|
||||
JsonStateUpdater<T> _stateUpdater;
|
||||
StatefulService<T>* _statefulService;
|
||||
FS* _fs;
|
||||
char const* _filePath;
|
||||
const char* _filePath;
|
||||
size_t _bufferSize;
|
||||
update_handler_id_t _updateHandlerId;
|
||||
|
||||
|
@ -20,7 +20,7 @@ class WebSocketConnector {
|
||||
|
||||
WebSocketConnector(StatefulService<T>* statefulService,
|
||||
AsyncWebServer* server,
|
||||
char const* webSocketPath,
|
||||
const char* webSocketPath,
|
||||
SecurityManager* securityManager,
|
||||
AuthenticationPredicate authenticationPredicate,
|
||||
size_t bufferSize) :
|
||||
@ -40,7 +40,7 @@ class WebSocketConnector {
|
||||
|
||||
WebSocketConnector(StatefulService<T>* statefulService,
|
||||
AsyncWebServer* server,
|
||||
char const* webSocketPath,
|
||||
const char* webSocketPath,
|
||||
size_t bufferSize) :
|
||||
_statefulService(statefulService), _server(server), _webSocket(webSocketPath), _bufferSize(bufferSize) {
|
||||
_webSocket.onEvent(std::bind(&WebSocketConnector::onWSEvent,
|
||||
@ -77,7 +77,7 @@ class WebSocketTx : virtual public WebSocketConnector<T> {
|
||||
WebSocketTx(JsonStateReader<T> stateReader,
|
||||
StatefulService<T>* statefulService,
|
||||
AsyncWebServer* server,
|
||||
char const* webSocketPath,
|
||||
const char* webSocketPath,
|
||||
SecurityManager* securityManager,
|
||||
AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN,
|
||||
size_t bufferSize = DEFAULT_BUFFER_SIZE) :
|
||||
@ -95,7 +95,7 @@ class WebSocketTx : virtual public WebSocketConnector<T> {
|
||||
WebSocketTx(JsonStateReader<T> stateReader,
|
||||
StatefulService<T>* statefulService,
|
||||
AsyncWebServer* server,
|
||||
char const* webSocketPath,
|
||||
const char* webSocketPath,
|
||||
size_t bufferSize = DEFAULT_BUFFER_SIZE) :
|
||||
WebSocketConnector<T>(statefulService, server, webSocketPath, bufferSize), _stateReader(stateReader) {
|
||||
WebSocketConnector<T>::_statefulService->addUpdateHandler(
|
||||
@ -166,7 +166,7 @@ class WebSocketRx : virtual public WebSocketConnector<T> {
|
||||
WebSocketRx(JsonStateUpdater<T> stateUpdater,
|
||||
StatefulService<T>* statefulService,
|
||||
AsyncWebServer* server,
|
||||
char const* webSocketPath,
|
||||
const char* webSocketPath,
|
||||
SecurityManager* securityManager,
|
||||
AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN,
|
||||
size_t bufferSize = DEFAULT_BUFFER_SIZE) :
|
||||
@ -182,7 +182,7 @@ class WebSocketRx : virtual public WebSocketConnector<T> {
|
||||
WebSocketRx(JsonStateUpdater<T> stateUpdater,
|
||||
StatefulService<T>* statefulService,
|
||||
AsyncWebServer* server,
|
||||
char const* webSocketPath,
|
||||
const char* webSocketPath,
|
||||
size_t bufferSize = DEFAULT_BUFFER_SIZE) :
|
||||
WebSocketConnector<T>(statefulService, server, webSocketPath, bufferSize), _stateUpdater(stateUpdater) {
|
||||
}
|
||||
@ -221,7 +221,7 @@ class WebSocketTxRx : public WebSocketTx<T>, public WebSocketRx<T> {
|
||||
JsonStateUpdater<T> stateUpdater,
|
||||
StatefulService<T>* statefulService,
|
||||
AsyncWebServer* server,
|
||||
char const* webSocketPath,
|
||||
const char* webSocketPath,
|
||||
SecurityManager* securityManager,
|
||||
AuthenticationPredicate authenticationPredicate = AuthenticationPredicates::IS_ADMIN,
|
||||
size_t bufferSize = DEFAULT_BUFFER_SIZE) :
|
||||
@ -251,7 +251,7 @@ class WebSocketTxRx : public WebSocketTx<T>, public WebSocketRx<T> {
|
||||
JsonStateUpdater<T> stateUpdater,
|
||||
StatefulService<T>* statefulService,
|
||||
AsyncWebServer* server,
|
||||
char const* webSocketPath,
|
||||
const char* webSocketPath,
|
||||
size_t bufferSize = DEFAULT_BUFFER_SIZE) :
|
||||
WebSocketConnector<T>(statefulService, server, webSocketPath, bufferSize),
|
||||
WebSocketTx<T>(stateReader, statefulService, server, webSocketPath, bufferSize),
|
||||
|
@ -19,7 +19,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef FACTORY_WIFI_HOSTNAME
|
||||
#define FACTORY_WIFI_HOSTNAME ""
|
||||
#define FACTORY_WIFI_HOSTNAME ESPUtils::defaultDeviceValue("esp-react-")
|
||||
#endif
|
||||
|
||||
class WiFiSettings {
|
||||
|
Loading…
Reference in New Issue
Block a user