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