implement full load of videos and startdata
modify api where necessary
This commit is contained in:
@ -10,17 +10,12 @@ import {Route, Switch, withRouter} from 'react-router-dom';
|
||||
import {RouteComponentProps} from 'react-router';
|
||||
import SearchHandling from './SearchHandling';
|
||||
import {VideoTypes} from '../../types/ApiTypes';
|
||||
import {DefaultTags} from "../../types/GeneralTypes";
|
||||
|
||||
interface props extends RouteComponentProps {}
|
||||
|
||||
interface state {
|
||||
sideinfo: {
|
||||
videonr: number,
|
||||
fullhdvideonr: number,
|
||||
hdvideonr: number,
|
||||
sdvideonr: number,
|
||||
tagnr: number
|
||||
},
|
||||
sideinfo: VideoTypes.startDataType
|
||||
subtitle: string,
|
||||
data: VideoTypes.VideoUnloadedType[],
|
||||
selectionnr: number
|
||||
@ -38,11 +33,12 @@ export class HomePage extends React.Component<props, state> {
|
||||
|
||||
this.state = {
|
||||
sideinfo: {
|
||||
videonr: 0,
|
||||
fullhdvideonr: 0,
|
||||
hdvideonr: 0,
|
||||
sdvideonr: 0,
|
||||
tagnr: 0
|
||||
VideoNr: 0,
|
||||
FullHdNr: 0,
|
||||
HDNr: 0,
|
||||
SDNr: 0,
|
||||
DifferentTags: 0,
|
||||
Tagged: 0,
|
||||
},
|
||||
subtitle: 'All Videos',
|
||||
data: [],
|
||||
@ -52,7 +48,7 @@ export class HomePage extends React.Component<props, state> {
|
||||
|
||||
componentDidMount(): void {
|
||||
// initial get of all videos
|
||||
this.fetchVideoData('All');
|
||||
this.fetchVideoData(DefaultTags.all.TagId);
|
||||
this.fetchStartData();
|
||||
}
|
||||
|
||||
@ -62,7 +58,7 @@ export class HomePage extends React.Component<props, state> {
|
||||
*
|
||||
* @param tag tag to fetch videos
|
||||
*/
|
||||
fetchVideoData(tag: string): void {
|
||||
fetchVideoData(tag: number): void {
|
||||
callAPI(APINode.Video, {action: 'getMovies', tag: tag}, (result: VideoTypes.VideoUnloadedType[]) => {
|
||||
this.setState({
|
||||
data: []
|
||||
@ -70,7 +66,6 @@ export class HomePage extends React.Component<props, state> {
|
||||
this.setState({
|
||||
data: result,
|
||||
selectionnr: result.length,
|
||||
subtitle: `${tag} Videos`
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -80,15 +75,7 @@ export class HomePage extends React.Component<props, state> {
|
||||
*/
|
||||
fetchStartData(): void {
|
||||
callAPI(APINode.Video, {action: 'getStartData'}, (result: VideoTypes.startDataType) => {
|
||||
this.setState({
|
||||
sideinfo: {
|
||||
videonr: result['total'],
|
||||
fullhdvideonr: result['fullhd'],
|
||||
hdvideonr: result['hd'],
|
||||
sdvideonr: result['sd'],
|
||||
tagnr: result['tags']
|
||||
}
|
||||
});
|
||||
this.setState({sideinfo: result});
|
||||
});
|
||||
}
|
||||
|
||||
@ -119,17 +106,30 @@ export class HomePage extends React.Component<props, state> {
|
||||
<SideBar>
|
||||
<SideBarTitle>Infos:</SideBarTitle>
|
||||
<Line/>
|
||||
<SideBarItem><b>{this.state.sideinfo.videonr}</b> Videos Total!</SideBarItem>
|
||||
<SideBarItem><b>{this.state.sideinfo.fullhdvideonr}</b> FULL-HD Videos!</SideBarItem>
|
||||
<SideBarItem><b>{this.state.sideinfo.hdvideonr}</b> HD Videos!</SideBarItem>
|
||||
<SideBarItem><b>{this.state.sideinfo.sdvideonr}</b> SD Videos!</SideBarItem>
|
||||
<SideBarItem><b>{this.state.sideinfo.tagnr}</b> different Tags!</SideBarItem>
|
||||
<SideBarItem><b>{this.state.sideinfo.VideoNr}</b> Videos Total!</SideBarItem>
|
||||
<SideBarItem><b>{this.state.sideinfo.FullHdNr}</b> FULL-HD Videos!</SideBarItem>
|
||||
<SideBarItem><b>{this.state.sideinfo.HDNr}</b> HD Videos!</SideBarItem>
|
||||
<SideBarItem><b>{this.state.sideinfo.SDNr}</b> SD Videos!</SideBarItem>
|
||||
<SideBarItem><b>{this.state.sideinfo.DifferentTags}</b> different Tags!</SideBarItem>
|
||||
<Line/>
|
||||
<SideBarTitle>Default Tags:</SideBarTitle>
|
||||
<Tag tagInfo={{tag_name: 'All', tag_id: -1}} onclick={(): void => this.fetchVideoData('All')}/>
|
||||
<Tag tagInfo={{tag_name: 'FullHd', tag_id: -1}} onclick={(): void => this.fetchVideoData('FullHd')}/>
|
||||
<Tag tagInfo={{tag_name: 'LowQuality', tag_id: -1}} onclick={(): void => this.fetchVideoData('LowQuality')}/>
|
||||
<Tag tagInfo={{tag_name: 'HD', tag_id: -1}} onclick={(): void => this.fetchVideoData('HD')}/>
|
||||
<Tag tagInfo={{TagName: 'All', TagId: DefaultTags.all.TagId}} onclick={(): void => {
|
||||
this.fetchVideoData(DefaultTags.all.TagId);
|
||||
this.setState({subtitle: `All Videos`});
|
||||
}}/>
|
||||
<Tag tagInfo={{TagName: 'Full Hd', TagId: DefaultTags.fullhd.TagId}} onclick={(): void => {
|
||||
this.fetchVideoData(DefaultTags.fullhd.TagId);
|
||||
this.setState({subtitle: `Full Hd Videos`});
|
||||
}}/>
|
||||
<Tag tagInfo={{TagName: 'Low Quality', TagId: DefaultTags.lowq.TagId}}
|
||||
onclick={(): void => {
|
||||
this.fetchVideoData(DefaultTags.lowq.TagId);
|
||||
this.setState({subtitle: `Low Quality Videos`});
|
||||
}}/>
|
||||
<Tag tagInfo={{TagName: 'HD', TagId: DefaultTags.hd.TagId}} onclick={(): void => {
|
||||
this.fetchVideoData(DefaultTags.hd.TagId);
|
||||
this.setState({subtitle: `HD Videos`});
|
||||
}}/>
|
||||
</SideBar>
|
||||
{this.state.data.length !== 0 ?
|
||||
<VideoContainer
|
||||
|
Reference in New Issue
Block a user