85 lines
2.6 KiB
JavaScript
Raw Normal View History

2020-05-31 20:24:35 +02:00
import React from "react";
import style from "./Preview.module.css";
2020-06-12 15:57:30 +00:00
import Player from "../../pages/Player/Player";
import {Spinner} from "react-bootstrap";
2020-07-26 18:17:29 +02:00
import StaticInfos from "../../GlobalInfos";
import darktheme from "../../AppDarkTheme.module.css";
import lighttheme from "../../AppLightTheme.module.css";
2020-05-31 20:24:35 +02:00
class Preview extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
previewpicture: null,
name: null
2020-05-31 20:24:35 +02:00
};
}
componentDidMount() {
this.setState({
previewpicture: null,
name: this.props.name
});
2020-05-31 20:24:35 +02:00
const updateRequest = new FormData();
updateRequest.append('action', 'readThumbnail');
updateRequest.append('movieid', this.props.movie_id);
2020-06-01 21:36:55 +02:00
fetch('/api/videoload.php', {method: 'POST', body: updateRequest})
2020-06-12 15:57:30 +00:00
.then((response) => response.text()
.then((result) => {
this.setState({
previewpicture: result
});
2020-05-31 20:24:35 +02:00
}));
}
render() {
2020-07-26 18:17:29 +02:00
const themeStyle = StaticInfos.isDarkTheme() ? darktheme : lighttheme;
2020-05-31 20:24:35 +02:00
return (
2020-08-03 18:38:22 +00:00
<div className={style.videopreview + ' ' + themeStyle.secbackground + ' '+ themeStyle.preview} onClick={() => this.itemClick()}>
<div className={style.previewtitle + ' '+ themeStyle.lighttextcolor}>{this.state.name}</div>
<div className={style.previewpic}>
{this.state.previewpicture != null ?
<img className={style.previewimage}
src={this.state.previewpicture}
alt='Pic loading.'/> :
<span className={style.loadAnimation}><Spinner animation="border"/></span>}
2020-05-31 20:24:35 +02:00
</div>
<div className={style.previewbottom}>
</div>
2020-05-31 20:24:35 +02:00
</div>
);
}
itemClick() {
console.log("item clicked!" + this.state.name);
2020-06-21 23:08:46 +02:00
this.props.viewbinding.changeRootElement(
<Player
viewbinding={this.props.viewbinding}
movie_id={this.props.movie_id}/>);
}
2020-05-31 20:24:35 +02:00
}
export class TagPreview extends React.Component {
render() {
return (
<div className={style.videopreview + ' ' + style.tagpreview} onClick={() => this.itemClick()}>
<div className={style.tagpreviewtitle}>
{this.props.name}
</div>
</div>
);
}
itemClick() {
this.props.categorybinding(this.props.name);
}
}
2020-05-31 20:24:35 +02:00
export default Preview;