Files
OpenMediaCenter/src/pages/SettingsPage/GeneralSettings.js
T

86 lines
2.9 KiB
JavaScript
Raw Normal View History

import React from "react";
2020-06-29 21:34:43 +02:00
import {Form, Col, Button} from "react-bootstrap";
import "./GeneralSettings.css"
class GeneralSettings extends React.Component {
constructor(props) {
super(props);
2020-07-03 00:20:11 +02:00
this.state = {
tvshowsupport: false,
videopath: "",
tvshowpath: ""
};
}
componentDidMount() {
const updateRequest = new FormData();
2020-07-04 00:45:18 +02:00
updateRequest.append('action', 'loadGeneralSettings');
2020-07-03 00:20:11 +02:00
2020-07-04 00:45:18 +02:00
fetch('/api/settings.php', {method: 'POST', body: updateRequest})
2020-07-03 00:20:11 +02:00
.then((response) => response.json()
.then((result) => {
// todo 2020-07-3: set state here
2020-07-04 00:45:18 +02:00
// todo 2020-07-4: php and test code
2020-07-03 00:20:11 +02:00
}));
}
render() {
return (
<>
2020-06-29 21:34:43 +02:00
<div className='GeneralForm'>
2020-07-04 00:45:18 +02:00
<Form onSubmit={(e) => {
e.preventDefault();
this.saveSettings();
}}>
2020-06-29 21:34:43 +02:00
<Form.Row>
<Form.Group as={Col} controlId="formGridEmail">
<Form.Label>Video Path</Form.Label>
2020-07-03 00:20:11 +02:00
<Form.Control type="text" placeholder="/var/www/html/video"/>
2020-06-29 21:34:43 +02:00
</Form.Group>
<Form.Group as={Col} controlId="formGridPassword">
2020-07-03 00:20:11 +02:00
<Form.Label>TV Show Path</Form.Label>
<Form.Control type='text' placeholder="/var/www/html/tvshow"/>
2020-06-29 21:34:43 +02:00
</Form.Group>
</Form.Row>
2020-07-03 00:20:11 +02:00
<Form.Check
type="switch"
id="custom-switch"
label="Enable Password support"
onChange={() => {
this.setState({tvshowsupport: !this.state.tvshowsupport})
}}
/>
{this.state.tvshowsupport ?
<Form.Group controlId="passwordfield">
<Form.Label>Password</Form.Label>
<Form.Control type="password" placeholder="**********"/>
</Form.Group> : null
}
2020-06-29 21:34:43 +02:00
<Button variant="primary" type="submit">
Submit
</Button>
</Form>
</div>
</>
);
}
2020-07-04 00:45:18 +02:00
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;