import React from 'react';
import {
Button,
Checkbox,
Confirm,
Container,
Divider,
Form,
Header,
Loader,
Placeholder,
Tab,
Table
} from "semantic-ui-react";
import {getConfig, getDownloads, killDownload, postDownload, saveConfig} from "../api";
import TimezoneSelect from 'react-timezone-select';
import {secondsToDate, secondsToFrequency} from "./Common";
class Settings extends React.Component {
constructor(props) {
super(props);
this.state = {
disabled: false,
ready: false,
validTimezone: true,
timezone: '',
}
this.mediaDirectory = React.createRef();
this.handleSubmit = this.handleSubmit.bind(this);
}
async componentDidMount() {
let config = await getConfig();
this.setState({
ready: true,
disabled: config.wrol_mode,
timezone: config.timezone || '',
});
this.mediaDirectory.current.value = config.media_directory;
}
async handleSubmit(e) {
e.preventDefault();
let config = {
media_directory: this.mediaDirectory.current.value,
timezone: this.state.timezone.value,
};
this.setState({validTimezone: true});
let response = await saveConfig(config);
if (response.status !== 200) {
let json = await response.json();
if (json.api_error === 'Invalid timezone') {
this.setState({validTimezone: false});
}
}
}
handleTimezoneChange = async (timezone) => {
this.setState({timezone});
}
render() {
if (this.state.ready === false) {
return
The global settings for your server.
When saved, these will be written to your local.yaml file. Storing these settings in your
local configuration file (rather than the database) allows your WROLPi to be rebuilt and save your
settings.
This directory must already exist.
The directory in which your media will be stored. Typically, this will be some external
drive like /media/wrolpi.
Note: User settings and favorites can still be modified.
Enable read-only mode. No content can be deleted or modified. Enable this when the SHTF and you
want to prevent any potential loss of data.
No downloads are scheduled to be downloaded.
} else if (this.state.once_downloads !== null) { onceTable = (No downloads are scheduled to be downloaded.
} else if (this.state.recurring_downloads !== null) { recurringTable = (