2020-06-04 22:19:18 +02:00
|
|
|
import React from "react";
|
2020-06-07 11:37:50 +02:00
|
|
|
import "../css/DefaultPage.css"
|
2020-06-04 22:19:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
class SettingsPage extends React.Component {
|
|
|
|
constructor(props, context) {
|
|
|
|
super(props, context);
|
|
|
|
this.state = {
|
|
|
|
text: []
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
updateStatus = () => {
|
|
|
|
const updateRequest = new FormData();
|
|
|
|
fetch('/api/extractionData.php', {method: 'POST', body: updateRequest})
|
|
|
|
.then((response) => response.json()
|
|
|
|
.then((result) => {
|
|
|
|
if (result.contentAvailable === true) {
|
|
|
|
console.log(result);
|
|
|
|
this.setState({
|
|
|
|
text: [...result.message.split("\n"),
|
|
|
|
...this.state.text]
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
clearInterval(this.myinterval);
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
.catch(() => {
|
|
|
|
console.log("no connection to backend");
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
if(this.myinterval){
|
|
|
|
clearInterval(this.myinterval);
|
|
|
|
}
|
|
|
|
this.myinterval = setInterval(this.updateStatus, 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
clearInterval(this.myinterval);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div className='pageheader'>
|
|
|
|
<span className='pageheadertitle'>Settings Page</span>
|
|
|
|
<span className='pageheadersubtitle'>todo</span>
|
|
|
|
<hr/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button onClick={() => {
|
|
|
|
this.startReindex()
|
|
|
|
}}>Reindex Movies
|
|
|
|
</button>
|
|
|
|
<div>{this.state.text.map(m => (
|
|
|
|
<div>{m}</div>
|
|
|
|
))}</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
startReindex() {
|
|
|
|
console.log("starting");
|
|
|
|
const updateRequest = new FormData();
|
|
|
|
// fetch all videos available
|
|
|
|
fetch('/api/extractvideopreviews.php', {method: 'POST', body: updateRequest})
|
|
|
|
.then((response) => response.json()
|
|
|
|
.then((result) => {
|
|
|
|
console.log("returned");
|
|
|
|
}))
|
|
|
|
.catch(() => {
|
|
|
|
console.log("no connection to backend");
|
|
|
|
});
|
|
|
|
if(this.myinterval){
|
|
|
|
clearInterval(this.myinterval);
|
|
|
|
}
|
|
|
|
this.myinterval = setInterval(this.updateStatus, 1000);
|
|
|
|
console.log("sent");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SettingsPage;
|