-
Notifications
You must be signed in to change notification settings - Fork 2
release/react #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/react
Are you sure you want to change the base?
release/react #18
Changes from all commits
bb481ae
51d711c
598b10a
3204fbe
bfb231f
5ac0c48
c6d79d4
f59c033
9ee719f
564bbbe
e4da1d2
3c624b5
8b9887a
41d49d3
6faef78
869ff2f
0831d64
b0217a7
0423b38
6fe4914
5bd511a
e46b07c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,71 +1,50 @@ | ||
| import React, {Component} from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import $ from 'jquery'; | ||
|
|
||
| import { | ||
| Button, | ||
| Form, | ||
| FormGroup, | ||
| Input, | ||
| Label, | ||
| Table, | ||
| } from 'reactstrap'; | ||
|
|
||
| import { | ||
| actionRipTracks, | ||
| } from '../api.js' | ||
| import {Button, Form, FormGroup, Input, Label, Table,} from 'reactstrap'; | ||
|
|
||
| import {actionRipTracks,} from '../api.js' | ||
|
|
||
| class DiscInfo extends Component { | ||
|
|
||
| constructor(props) { | ||
| super(props); | ||
| let selectedTracks = {}; | ||
| this.props.tracks && this.props.tracks.map((trackInfo, trackId) => { | ||
| selectedTracks[trackId] = trackInfo.isAutoSelected; | ||
| }); | ||
| this.state = { | ||
| checkAll: false, | ||
| discName: false, | ||
| selectedTracks: selectedTracks, | ||
| selectedTracks: this.props.tracks.map((trackInfo) => { | ||
| return trackInfo; | ||
| }) | ||
| }; | ||
| } | ||
|
|
||
| getTrackCheckboxes($formElement) { | ||
| return $formElement | ||
| .closest('fieldset') | ||
| .find('input[name=selectTrack]'); | ||
| } | ||
|
|
||
| // Toggle the checkbox on all tracks. | ||
| toggleAllTracks(event) { | ||
| let $target = $(event.target); | ||
| this.setState({ | ||
| checkAll: $target.prop('checked'), | ||
| }); | ||
| this.getTrackCheckboxes(event.target) | ||
| .prop('checked', this.state.checkAll); | ||
| alert('This functionality is currently disabled.'); | ||
| // let $target = $(event.target); | ||
| // this.setState({ | ||
| // checkAll: $target.prop('checked'), | ||
| // }); | ||
| // this.getTrackCheckboxes(event.target) | ||
| // .prop('checked', this.state.checkAll); | ||
| } | ||
|
|
||
| toggleTrack(trackId) { | ||
| let changeObj = {}; | ||
| changeObj[trackId] = !this.selectedTracks[trackId]; | ||
| this.setState({ | ||
| selectedTracks: Object.assign( | ||
| this.selectedTracks, changeObj | ||
| ) | ||
| }) | ||
| toggleTrack(event) { | ||
| let trackId = event.target.name; | ||
| this.state.selectedTracks[trackId].isSelected = event.target.checked; | ||
| } | ||
|
|
||
| // Command the server to rip certain tracks for this disc. | ||
| ripTracks(event) { | ||
| let ripTrackIds = this.getTrackCheckboxes(event.target) | ||
| .find(':checked') | ||
| .data('track-id'); | ||
| ripTracks() { | ||
| let trackIds = []; | ||
| this.state.selectedTracks.forEach((selectedTrack, trackId) => { | ||
| if (selectedTrack.isSelected) { | ||
| trackIds.push(trackId); | ||
| } | ||
| }); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was hoping to use a
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep you want |
||
| actionRipTracks( | ||
| this.state.discName, | ||
| this.props.discName, | ||
| this.props.driveId, | ||
| ripTrackIds | ||
| trackIds | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -109,14 +88,14 @@ class DiscInfo extends Component { | |
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {this.props.tracks && this.props.tracks.map(function(trackInfo, trackId) { | ||
| return <tr onClick={ (e) => this.toggleTrack(trackId) }> | ||
| {this.props.tracks && this.props.tracks.map((trackInfo, trackId) => { | ||
| return <tr> | ||
| <td> | ||
| <Input type="checkbox" | ||
| name="selectTrack" | ||
| checked={ this.state.selectedTracks[trackId] } | ||
| onChange={ (e) => this.toggleTrack(trackId) } | ||
| />s | ||
| name={trackId} | ||
| checked={this.state.selectedTracks[trackId].isSelected} | ||
| onChange={(event) => this.toggleTrack(event)} | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I set the name to the trackId and used the event, I was able to determine if a track was selected without using jQuery, which I thought was nice; we could likely eliminate jQuery completely.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah jQuery is superfluous once React comes into play. I just didn't quite realize it back then ;) |
||
| /> | ||
| </td> | ||
| <td>{ trackInfo.orderWeight }</td> | ||
| <td>{ trackInfo.name }</td> | ||
|
|
@@ -130,7 +109,9 @@ class DiscInfo extends Component { | |
| </Table> | ||
| </FormGroup> | ||
| <FormGroup> | ||
| <Button onClick={ (e) => this.ripTracks(e) } /> | ||
| <Button onClick={() => this.ripTracks()}> | ||
| Rip Tracks | ||
| </Button> | ||
| </FormGroup> | ||
| </fieldset> | ||
| </Form> | ||
|
|
@@ -152,7 +133,7 @@ DiscInfo.propTypes = { | |
| volumeName: PropTypes.string.isRequired, | ||
| tracks: PropTypes.arrayOf(PropTypes.shape({ | ||
| id: PropTypes.number.isRequired, | ||
| isAutoSelected: PropTypes.bool, | ||
| isSelected: PropTypes.bool, | ||
| ripStatus: PropTypes.oneOf(['none', 'busy', 'fail', 'success']), | ||
| chapterCount: PropTypes.number.isRequired, | ||
| diskSize: PropTypes.string.isRequired, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ class DiscPanel extends Component { | |
| constructor(props) { | ||
| super(props); | ||
| this.state = { | ||
| discInfo: {}, | ||
| discInfo: {} | ||
| }; | ||
| subscribeToDiscInfo(this.handleDiscInfo, this, this.props.driveId); | ||
| } | ||
|
|
@@ -39,27 +39,34 @@ class DiscPanel extends Component { | |
| } | ||
|
|
||
| render(){ | ||
| let discInfo = ''; | ||
| if (this.state.discInfo.tracks && this.state.discInfo.tracks.length > 0) { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I needed to conditionally display
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better way to do this would be something like: Then just |
||
| discInfo = <DiscInfo | ||
| driveState={this.props.driveState} | ||
| driveId={this.props.driveId} | ||
| discName={this.props.discName} | ||
| {...this.state.discInfo} | ||
| />; | ||
| } | ||
| return( | ||
| <div className="DiscPanel"> | ||
| <Card> | ||
| <CardBody> | ||
| <CardTitle> | ||
| <span> | ||
| { this.props.driveId } | ||
| {this.props.driveId} | ||
| </span> | ||
| - | ||
| <span> | ||
| { this.props.discName || 'No Disc' } | ||
| {this.props.discName || 'No Disc'} | ||
| </span> | ||
| </CardTitle> | ||
| <Button onClick={ () => this.refreshDiscInfo() }> | ||
| <span className="glyphicon glyphicon-refresh" /> | ||
| <Button onClick={() => this.refreshDiscInfo()}> | ||
| Refresh Disc | ||
| </Button> | ||
| </CardBody> | ||
| <CardBody> | ||
| <DiscInfo driveState={ this.props.driveState } | ||
| { ...this.state.discInfo } | ||
| /> | ||
| {discInfo} | ||
| </CardBody> | ||
| </Card> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -213,7 +213,7 @@ class MakeMkv { | |
| trackIds.map((trackId) => this.ripQueue.driveId.add(trackId)); | ||
| } | ||
|
|
||
| if (!this.ripQueue.driveId.length) { | ||
| if (!this.ripQueue.driveId.size) { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kind of confused.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep this was wrong. Looks like the conditional doesn't do anything, so not really sure what I was going for honestly |
||
| // @TODO: What to do here? | ||
| return; | ||
| } | ||
|
|
@@ -224,7 +224,7 @@ class MakeMkv { | |
| }; | ||
|
|
||
| this.ripTrack( | ||
| saveDirectory, driveId, this.ripQueue.driveId.pop(), newCallback | ||
| saveDirectory, driveId, Array.from(this.ripQueue.driveId).pop(), newCallback | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hoping this actually removes the last element from the set and returns it; rather than just returning it. Hoping to test drive some of this stuff later on, but just trying to get things working quick-and-dirty for now with minimal change.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't, and you can't access sets by index either. Better would probably be to just switch the set back to an array - it was just to clear up an edge case when someone submits the same track twice. It would only be possible if there are two UIs open talking to the server at the same time, and both submit the same track for ripping (within milliseconds of each other). Totally not going to happen outside of a lab
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But if you did want to handle this: Seems like a lot of work though, when we could accomplish the same functionality by just guarding the array push for the track |
||
| ); | ||
|
|
||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add this back once I get ripping working.