2020-10-25 18:48:23 +00:00
|
|
|
import React from 'react';
|
|
|
|
import style from './Preview.module.css';
|
|
|
|
import {Spinner} from 'react-bootstrap';
|
2020-12-29 19:39:30 +00:00
|
|
|
import {Link} from 'react-router-dom';
|
2020-12-17 20:53:22 +00:00
|
|
|
import GlobalInfos from '../../utils/GlobalInfos';
|
|
|
|
import {callAPIPlain} from '../../utils/Api';
|
2020-05-31 20:24:35 +02:00
|
|
|
|
2021-01-22 21:05:21 +00:00
|
|
|
interface PreviewProps{
|
|
|
|
name: string;
|
|
|
|
movie_id: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface PreviewState {
|
|
|
|
previewpicture: string | null;
|
|
|
|
}
|
|
|
|
|
2020-08-12 17:50:25 +00:00
|
|
|
/**
|
|
|
|
* Component for single preview tile
|
|
|
|
* floating side by side
|
|
|
|
*/
|
2021-01-22 21:05:21 +00:00
|
|
|
class Preview extends React.Component<PreviewProps, PreviewState> {
|
|
|
|
constructor(props: PreviewProps) {
|
|
|
|
super(props);
|
2020-05-31 20:24:35 +02:00
|
|
|
|
|
|
|
this.state = {
|
2021-01-22 21:05:21 +00:00
|
|
|
previewpicture: null
|
2020-05-31 20:24:35 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-01-22 21:05:21 +00:00
|
|
|
componentDidMount(): void {
|
2020-12-17 20:53:22 +00:00
|
|
|
callAPIPlain('video.php', {action: 'readThumbnail', movieid: this.props.movie_id}, (result) => {
|
|
|
|
this.setState({
|
2021-01-22 21:05:21 +00:00
|
|
|
previewpicture: result
|
2020-12-17 20:53:22 +00:00
|
|
|
});
|
2020-05-31 23:22:50 +02:00
|
|
|
});
|
2020-05-31 20:24:35 +02:00
|
|
|
}
|
|
|
|
|
2021-01-22 21:05:21 +00:00
|
|
|
render(): JSX.Element {
|
2020-08-05 22:00:55 +02:00
|
|
|
const themeStyle = GlobalInfos.getThemeStyle();
|
2020-05-31 20:24:35 +02:00
|
|
|
return (
|
2020-12-29 19:39:30 +00:00
|
|
|
<Link to={'/player/' + this.props.movie_id}>
|
|
|
|
<div className={style.videopreview + ' ' + themeStyle.secbackground + ' ' + themeStyle.preview}>
|
2021-01-22 21:05:21 +00:00
|
|
|
<div className={style.previewtitle + ' ' + themeStyle.lighttextcolor}>{this.props.name}</div>
|
2020-12-29 19:39:30 +00:00
|
|
|
<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-06-18 21:53:48 +02:00
|
|
|
|
2020-12-29 19:39:30 +00:00
|
|
|
</div>
|
|
|
|
<div className={style.previewbottom}>
|
2020-06-04 16:45:24 +02:00
|
|
|
|
2020-12-29 19:39:30 +00:00
|
|
|
</div>
|
2020-06-04 16:45:24 +02:00
|
|
|
</div>
|
2020-12-29 19:39:30 +00:00
|
|
|
</Link>
|
2020-05-31 23:22:50 +02:00
|
|
|
|
2020-12-29 19:39:30 +00:00
|
|
|
);
|
2020-05-31 23:22:50 +02:00
|
|
|
}
|
2020-05-31 20:24:35 +02:00
|
|
|
}
|
|
|
|
|
2020-08-12 17:50:25 +00:00
|
|
|
/**
|
|
|
|
* Component for a Tag-name tile (used in category page)
|
|
|
|
*/
|
2021-01-22 21:05:21 +00:00
|
|
|
export class TagPreview extends React.Component<{name: string}> {
|
|
|
|
render(): JSX.Element {
|
2020-08-05 22:00:55 +02:00
|
|
|
const themeStyle = GlobalInfos.getThemeStyle();
|
2020-06-07 15:48:27 +02:00
|
|
|
return (
|
2020-10-09 14:00:51 +00:00
|
|
|
<div
|
2020-12-29 19:39:30 +00:00
|
|
|
className={style.videopreview + ' ' + style.tagpreview + ' ' + themeStyle.secbackground + ' ' + themeStyle.preview}>
|
2020-08-03 23:31:43 +00:00
|
|
|
<div className={style.tagpreviewtitle + ' ' + themeStyle.lighttextcolor}>
|
2020-06-07 21:42:01 +02:00
|
|
|
{this.props.name}
|
2020-06-07 15:48:27 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-31 20:24:35 +02:00
|
|
|
export default Preview;
|