Updated to use sqlite3 instead of sqlite in api

This commit is contained in:
2017-07-29 13:21:25 +02:00
parent a436f79770
commit fbf49e4cd9
5 changed files with 28 additions and 38 deletions

View File

@@ -1,5 +1,7 @@
import React from 'react';
import '../app.css';
class MovieObject {
constructor(object) {
this.id = object.id;
@@ -12,36 +14,35 @@ class MovieObject {
}
requestExisting(movie) {
console.log('Exists', movie)
console.log('Exists', movie);
}
requestMovie(id) {
fetch('http://localhost:31459/api/v1/plex/request/' + id, {
method: 'POST'
})
});
}
getElement() {
var returnList = []
returnList.push(<p>{this.title} ({this.year})</p>)
var posterPath, buttonState;
if (this.poster != undefined) {
posterPath = 'https://image.tmdb.org/t/p/w150' + this.poster;
}
returnList.push(<img src={posterPath}></img>);
var posterPath = 'https://image.tmdb.org/t/p/w154' + this.poster;
var buttonState;
if (this.matchedInPlex) {
returnList.push(<button onClick={() => this.requestExisting(this)}>Request anyway</button>)
buttonState = <button onClick={() => {this.requestExisting(this)}}>Request anyway</button>;
} else {
returnList.push(<button onClick={() => this.requestMovie(this.id)}>Request</button>)
buttonState = <button onClick={() => {this.requestMovie(this.id)}}>Request</button>;
}
returnList.push(<span>{this.overview}</span>);
returnList.push(<br></br>);
return returnList;
return (
<div key={this.id} className='movie_wrapper'>
<img src={posterPath}></img>
<div className='movie_content'>
<span className='movie_header'>{this.title} ({this.year})</span>
<br></br>
{buttonState}
<br></br>
<span>{this.overview}</span>
</div>
</div>)
}
}

View File

@@ -83,7 +83,7 @@ class SearchRequest extends React.Component {
render(){
return(
<div>
<div>
<input
type="text"
onKeyPress={(event) => this._handleQueryKeyPress(event)}
@@ -94,9 +94,9 @@ class SearchRequest extends React.Component {
<br></br>
<br></br>
<span id='requestMovieList' ref='requestMovieList'>
{this.state.responseMovieList}
</span>
<div id='requestMovieList' ref='requestMovieList'>
{this.state.responseMovieList}
</div>
</div>
)
}

View File

@@ -1,11 +0,0 @@
{
"database": {
"host": "shows.db"
},
"webserver": {
"port": 31459
},
"tmdb": {
"apiKey": "9fa154f5355c37a1b9b57ac06e7d6712"
}
}

View File

@@ -8,13 +8,13 @@
"body-parser": "~1.0.1",
"cross-env": "^3.1.3",
"express": "~4.0.0",
"mongoose": "~3.6.13",
"mongoose": "^3.6.13",
"moviedb": "^0.2.7",
"node-cache": "^4.1.1",
"nodemailer": "^4.0.1",
"python-shell": "^0.4.0",
"request": "^2.81.0",
"request-promise": "^4.2",
"sqlite": "^2.5.0"
"sqlite3": "^2.5.0"
}
}

View File

@@ -1,19 +1,19 @@
const fs = require('fs');
const path = require('path');
const sqlite = require('sqlite');
const sqlite3 = require('sqlite3');
class SqliteDatabase {
constructor(host) {
this.host = host;
this.connection = sqlite;
this.connection = sqlite3;
// this.schemaDirectory = path.join(__dirname, 'schemas');
}
connect() {
return Promise.resolve()
.then(() => sqlite.open(this.host))
.then(() => new sqlite3.Database(this.host))
}
all(sql, parameters) {