In admin we added a updatehandler so that a child can update this parent element. Also added our new sidebar for filtering our requested items by query and category.

This commit is contained in:
2018-01-09 16:03:11 +01:00
parent 4d99cae74c
commit 33cb6f5f09

View File

@@ -20,10 +20,16 @@ class AdminComponent extends React.Component {
this.state = { this.state = {
requested_objects: '', requested_objects: '',
} }
this.updateHandler = this.updateHandler.bind(this)
} }
// Fetches all requested elements and updates the state with response // Fetches all requested elements and updates the state with response
componentWillMount() { componentWillMount() {
this.fetchRequestedItems()
}
fetchRequestedItems() {
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({
@@ -32,6 +38,10 @@ class AdminComponent extends React.Component {
}) })
} }
updateHandler() {
this.fetchRequestedItems()
}
// Displays loginform if not logged in and passes response from // Displays loginform if not logged in and passes response from
// api call to sidebar and infoPanel through props // api call to sidebar and infoPanel through props
verifyLoggedIn() { verifyLoggedIn() {
@@ -52,18 +62,19 @@ class AdminComponent extends React.Component {
return ( return (
<div> <div>
<div style={adminCSS.selectedObjectPanel}>
<AdminRequestInfo
selectedRequest={selectedRequest}
listItemSelected={listItemSelected}
updateHandler = {this.updateHandler}
/>
</div>
<div style={adminCSS.sidebar}> <div style={adminCSS.sidebar}>
<Sidebar <Sidebar
requested_objects={this.state.requested_objects} requested_objects={this.state.requested_objects}
listItemSelected={listItemSelected} listItemSelected={listItemSelected}
/> />
</div> </div>
<div style={adminCSS.selectedObjectPanel}>
<AdminRequestInfo
selectedRequest={selectedRequest}
listItemSelected={listItemSelected}
/>
</div>
</div> </div>
) )
} }