import React from "react"; import {Form, Col, Button} from "react-bootstrap"; import style from "./GeneralSettings.module.css" class GeneralSettings extends React.Component { constructor(props) { super(props); this.state = { passwordsupport: false, videopath: "", tvshowpath: "", mediacentername: "", password: "" }; } componentDidMount() { const updateRequest = new FormData(); updateRequest.append('action', 'loadGeneralSettings'); fetch('/api/Settings.php', {method: 'POST', body: updateRequest}) .then((response) => response.json() .then((result) => { this.setState({ videopath: result.video_path, tvshowpath: result.episode_path, mediacentername: result.mediacenter_name, password: result.password, passwordsupport: result.passwordEnabled }); })); } render() { return ( <>
{ e.preventDefault(); this.saveSettings(); }}> Video Path this.setState({videopath: ee.target.value})}/> TV Show Path this.setState({tvshowpath: e.target.value})}/> { this.setState({passwordsupport: !this.state.passwordsupport}) }} /> {this.state.passwordsupport ? Password this.setState({password: e.target.value})}/> : null } The name of the Mediacenter this.setState({mediacentername: e.target.value})}/>
); } saveSettings() { const updateRequest = new FormData(); updateRequest.append('action', 'saveGeneralSettings'); fetch('/api/settings.php', {method: 'POST', body: updateRequest}) .then((response) => response.json() .then((result) => { // todo 2020-07-4: settings result here })); } } export default GeneralSettings;