import React, { Component } from 'react'; import { fetchJSON } from '../http.jsx'; import PirateSearch from './PirateSearch.jsx' // No in use! import InfoButton from '../buttons/InfoButton.jsx'; // Stylesheets import requestInfoCSS from '../styles/adminRequestInfo.jsx' import buttonsCSS from '../styles/buttons.jsx'; String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } class AdminRequestInfo extends Component { constructor() { super(); this.state = { statusValue: '', movieInfo: undefined, expandedSummary: false, } this.requestInfo = ''; } componentWillReceiveProps(props) { this.requestInfo = props.selectedRequest; this.state.statusValue = this.requestInfo.status; this.state.expandedSummary = false; this.fetchIteminfo() } userAgent(agent) { if (agent) { try { return agent.split(" ")[1].replace(/[\(\;]/g, ''); } catch(e) { return agent; } } return ''; } generateStatusDropdown() { return ( ) } updateRequestStatus(event) { const eventValue = event.target.value; const itemID = this.requestInfo.id; const apiData = { type: this.requestInfo.type, status: eventValue, } fetchJSON('https://apollo.kevinmidboe.com/api/v1/plex/request/' + itemID, 'PUT', apiData) .then((response) => { console.log('Response, updateRequestStatus: ', response) this.props.updateHandler() }) } generateStatusIndicator(status) { switch (status) { case 'requested': // Yellow return 'linear-gradient(to right, rgb(63, 195, 243) 0, rgb(63, 195, 243) 10px, #fff 4px, #fff 100%) no-repeat' case 'downloading': // Blue return 'linear-gradient(to right, rgb(255, 225, 77) 0, rgb(255, 225, 77) 10px, #fff 4px, #fff 100%) no-repeat' case 'downloaded': // Green return 'linear-gradient(to right, #39aa56 0, #39aa56 10px, #fff 4px, #fff 100%) no-repeat' default: return 'linear-gradient(to right, grey 0, grey 10px, #fff 4px, #fff 100%) no-repeat' } } generateTypeIcon(type) { if (type === 'show') return ( ) else if (type === 'movie') return ( ) else return ( ) } toggleSummmaryLength() { this.setState({ expandedSummary: !this.state.expandedSummary }) } generateSummary() { // { this.state.movieInfo != undefined ? this.state.movieInfo.summary : 'Loading...' } const info = this.state.movieInfo; if (info !== undefined) { const summary = this.state.movieInfo.summary const summary_short = summary.slice(0, 180); return (