Merge pull request #81 from KevinMidboe/frontend

Frontend
This commit was merged in pull request #81.
This commit is contained in:
2018-02-07 14:38:16 +01:00
committed by GitHub
5 changed files with 25 additions and 13 deletions

View File

@@ -21,8 +21,8 @@ class SearchObject {
this.year = object.year; this.year = object.year;
this.type = object.type; this.type = object.type;
this.rating = object.rating; this.rating = object.rating;
this.poster = object.poster; this.poster = object.poster_path;
this.background = object.background; this.background = object.background_path;
this.matchedInPlex = object.matchedInPlex; this.matchedInPlex = object.matchedInPlex;
this.summary = object.summary; this.summary = object.summary;
} }

View File

@@ -33,7 +33,7 @@ class AdminComponent extends React.Component {
fetchJSON('https://apollo.kevinmidboe.com/api/v1/plex/requests/all', 'GET') fetchJSON('https://apollo.kevinmidboe.com/api/v1/plex/requests/all', 'GET')
.then(result => { .then(result => {
this.setState({ this.setState({
requested_objects: result.requestedItems.reverse() requested_objects: result.results.reverse()
}) })
}) })
} }

View File

@@ -171,7 +171,7 @@ class AdminRequestInfo extends Component {
<div style={requestInfoCSS.wrapper}> <div style={requestInfoCSS.wrapper}>
<div style={requestInfoCSS.stick}> <div style={requestInfoCSS.stick}>
<span style={requestInfoCSS.title}> {request.name} {request.year}</span> <span style={requestInfoCSS.title}> {request.title} {request.year}</span>
<span style={{marginLeft: '2em'}}> <span style={{marginLeft: '2em'}}>
<span style={requestInfoCSS.type_icon}>{this.generateTypeIcon(request.type)}</span> <span style={requestInfoCSS.type_icon}>{this.generateTypeIcon(request.type)}</span>
{/*<span style={style.type_text}>{request.type.capitalize()}</span> <br />*/} {/*<span style={style.type_text}>{request.type.capitalize()}</span> <br />*/}
@@ -201,7 +201,7 @@ class AdminRequestInfo extends Component {
</div> </div>
</div> </div>
<PirateSearch style={requestInfoCSS.search} name={request.name} /> <PirateSearch style={requestInfoCSS.search} name={request.title} />
</div> </div>
) )

View File

@@ -79,11 +79,10 @@ class SidebarComponent extends Component {
const query = event.target.value; const query = event.target.value;
let filteredByQuery = this.props.requested_objects.map((item, index) => { let filteredByQuery = this.props.requested_objects.map((item, index) => {
if (item.name.toLowerCase().indexOf(query.toLowerCase()) != -1) if (item.title.toLowerCase().indexOf(query.toLowerCase()) != -1)
return this.generateListElements(index, item); return this.generateListElements(index, item);
}) })
console.log(filteredByQuery)
this.setState({ this.setState({
requestItemsToBeDisplayed: filteredByQuery, requestItemsToBeDisplayed: filteredByQuery,
filterQuery: query, filterQuery: query,
@@ -190,7 +189,7 @@ class SidebarComponent extends Component {
active={sidebarCSS.cardSelected}> active={sidebarCSS.cardSelected}>
<h2 style={sidebarCSS.titleCard}> <h2 style={sidebarCSS.titleCard}>
<span>{ item.name }</span> <span>{ item.title }</span>
</h2> </h2>
<p style={sidebarCSS.pCard}> <p style={sidebarCSS.pCard}>

View File

@@ -38,7 +38,8 @@ class TorrentTable extends Component {
// Link to repo: https://github.com/sindresorhus/pretty-bytes // Link to repo: https://github.com/sindresorhus/pretty-bytes
convertSizeToHumanSize(num) { convertSizeToHumanSize(num) {
if (!Number.isFinite(num)) { if (!Number.isFinite(num)) {
throw new TypeError(`Expected a finite number, got ${typeof num}: ${num}`); return num
// throw new TypeError(`Expected a finite number, got ${typeof num}: ${num}`);
} }
const neg = num < 0; const neg = num < 0;
@@ -57,6 +58,17 @@ class TorrentTable extends Component {
return (neg ? '-' : '') + numStr + ' ' + unit; return (neg ? '-' : '') + numStr + ' ' + unit;
} }
convertHumanSizeToBytes(string) {
const [numStr, unit] = string.split(' ');
if (this.UNITS.indexOf(unit) === -1) {
return string
}
const exponent = this.UNITS.indexOf(unit) * 3
return numStr * (Math.pow(10, exponent))
}
sendToDownload(magnet) { sendToDownload(magnet) {
const apiData = { const apiData = {
magnet: magnet, magnet: magnet,
@@ -80,8 +92,6 @@ class TorrentTable extends Component {
return item return item
}) })
console.log(filteredByQuery)
this.setState({ this.setState({
torrentResponse: filteredByQuery, torrentResponse: filteredByQuery,
filterQuery: query, filterQuery: query,
@@ -101,6 +111,9 @@ class TorrentTable extends Component {
let valueA = isNaN(a[col]) ? a[col] : parseInt(a[col]) let valueA = isNaN(a[col]) ? a[col] : parseInt(a[col])
let valueB = isNaN(b[col]) ? b[col] : parseInt(b[col]) let valueB = isNaN(b[col]) ? b[col] : parseInt(b[col])
valueA = (col == 'size') ? this.convertHumanSizeToBytes(valueA) : valueA
valueB = (col == 'size') ? this.convertHumanSizeToBytes(valueB) : valueB
if (direction) if (direction)
return valueA<valueB? 1:valueA>valueB?-1:0; return valueA<valueB? 1:valueA>valueB?-1:0;
else else