Removed unsued imports.
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import glamorous from 'glamorous';
|
|
||||||
|
|
||||||
// StyleComponents
|
// StyleComponents
|
||||||
import mediaResultItem from './styledComponents/mediaResultItem.jsx';
|
|
||||||
|
|
||||||
class MovieObject {
|
class MovieObject {
|
||||||
constructor(object) {
|
constructor(object) {
|
||||||
@@ -12,7 +10,7 @@ class MovieObject {
|
|||||||
// Check if object.poster != undefined
|
// Check if object.poster != undefined
|
||||||
this.poster = object.poster;
|
this.poster = object.poster;
|
||||||
this.matchedInPlex = object.matchedInPlex;
|
this.matchedInPlex = object.matchedInPlex;
|
||||||
this.overview = object.overview;
|
this.summary = object.summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
requestExisting(movie) {
|
requestExisting(movie) {
|
||||||
@@ -124,7 +122,7 @@ class MovieObject {
|
|||||||
<div>
|
<div>
|
||||||
<span style={resultTitle}>{this.title} ({this.year})</span>
|
<span style={resultTitle}>{this.title} ({this.year})</span>
|
||||||
<br></br>
|
<br></br>
|
||||||
<span>{this.overview}</span>
|
<span>{this.summary}</span>
|
||||||
<br></br>
|
<br></br>
|
||||||
|
|
||||||
<span className='imdbLogo'>
|
<span className='imdbLogo'>
|
||||||
|
|||||||
@@ -5,34 +5,35 @@ import MovieObject from './MovieObject.jsx';
|
|||||||
// TODO add option for searching multi, movies or tv shows
|
// TODO add option for searching multi, movies or tv shows
|
||||||
|
|
||||||
class SearchRequest extends React.Component {
|
class SearchRequest extends React.Component {
|
||||||
constructor(props){
|
constructor(props){
|
||||||
super(props)
|
super(props)
|
||||||
// Constructor with states holding the search query and the element of reponse.
|
// Constructor with states holding the search query and the element of reponse.
|
||||||
this.state = {
|
this.state = {
|
||||||
searchQuery: '',
|
searchQuery: '',
|
||||||
responseMovieList: null,
|
responseMovieList: null,
|
||||||
movieFilter: true,
|
movieFilter: true,
|
||||||
tvshowFilter: false
|
tvshowFilter: false,
|
||||||
|
page: 1
|
||||||
}
|
}
|
||||||
|
|
||||||
this.URLs = {
|
this.URLs = {
|
||||||
request: 'https://apollo.kevinmidboe.com/api/v1/plex/request?query=',
|
request: 'https://apollo.kevinmidboe.com/api/v1/plex/request?page='+this.props.page+'&query=',
|
||||||
sendRequest: 'https://apollo.kevinmidboe.com/api/v1/plex/request?query='
|
sendRequest: 'https://apollo.kevinmidboe.com/api/v1/plex/request?query='
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
componentDidMount(){
|
componentDidMount(){
|
||||||
var that = this;
|
var that = this;
|
||||||
this.setState({responseMovieList: null})
|
this.setState({responseMovieList: null})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handles all errors of the response of a fetch call
|
// Handles all errors of the response of a fetch call
|
||||||
handleErrors(response) {
|
handleErrors(response) {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw Error(response.status);
|
throw Error(response.status);
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchQuery() {
|
fetchQuery() {
|
||||||
@@ -42,27 +43,27 @@ class SearchRequest extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fetch(url)
|
fetch(url)
|
||||||
// Check if the response is ok
|
// Check if the response is ok
|
||||||
.then(response => this.handleErrors(response))
|
.then(response => this.handleErrors(response))
|
||||||
.then(response => response.json()) // Convert to json object and pass to next then
|
.then(response => response.json()) // Convert to json object and pass to next then
|
||||||
.then(data => { // Parse the data of the JSON response
|
.then(data => { // Parse the data of the JSON response
|
||||||
// If it is something here it updates the state variable with the HTML list of all
|
// If it is something here it updates the state variable with the HTML list of all
|
||||||
// movie objects that where returned by the search request
|
// movie objects that where returned by the search request
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
this.setState({
|
this.setState({
|
||||||
responseMovieList: data.map(item => this.createMovieObjects(item))
|
responseMovieList: data.map(item => this.createMovieObjects(item))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// If the --------
|
// If the --------
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
this.setState({
|
this.setState({
|
||||||
responseMovieList: <h1>Not Found</h1>
|
responseMovieList: <h1>Not Found</h1>
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('Error submit: ', error.toString());
|
console.log('Error submit: ', error.toString());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updates the internal state of the query search field.
|
// Updates the internal state of the query search field.
|
||||||
|
|||||||
Reference in New Issue
Block a user