@@ -4,9 +4,6 @@ import $ from 'jquery';
44
55import {
66 Button ,
7- Card ,
8- CardBody ,
9- CardTitle ,
107 Form ,
118 FormGroup ,
129 Input ,
@@ -23,9 +20,14 @@ class DiscInfo extends Component {
2320
2421 constructor ( props ) {
2522 super ( props ) ;
23+ let selectedTracks = { } ;
24+ this . props . tracks . map ( ( trackInfo , trackId ) => {
25+ selectedTracks [ trackId ] = trackInfo . isAutoSelected ;
26+ } ) ;
2627 this . state = {
2728 checkAll : false ,
28- discName : this . props . discTitle ,
29+ discName : false ,
30+ selectedTracks : { } ,
2931 } ;
3032 }
3133
@@ -38,11 +40,23 @@ class DiscInfo extends Component {
3840 // Toggle the checkbox on all tracks.
3941 toggleAllTracks ( event ) {
4042 let $target = $ ( event . target ) ;
41- this . state . checkAll = $target . prop ( 'checked' ) ;
43+ this . setState ( {
44+ checkAll : $target . prop ( 'checked' ) ,
45+ } ) ;
4246 this . getTrackCheckboxes ( event . target )
4347 . prop ( 'checked' , this . state . checkAll ) ;
4448 }
4549
50+ toggleTrack ( trackId ) {
51+ let changeObj = { } ;
52+ changeObj [ trackId ] = ! this . selectedTracks [ trackId ] ;
53+ this . setState ( {
54+ selectedTracks : Object . assign (
55+ this . selectedTracks , changeObj
56+ )
57+ } )
58+ }
59+
4660 // Command the server to rip certain tracks for this disc.
4761 ripTracks ( event ) {
4862 let ripTrackIds = this . getTrackCheckboxes ( event . target )
@@ -56,15 +70,20 @@ class DiscInfo extends Component {
5670 }
5771
5872 render ( ) {
59- return (
60- < Form onSubmit = { this . handleSubmit } >
61- < fieldset { ...( this . props . isRipping ? 'disabled' : '' ) } >
73+ return ( < div >
74+ < h1 className = { this . props . name ? 'invisible' : '' } >
75+ Drive is { this . props . driveState }
76+ </ h1 >
77+ < Form onSubmit = { this . handleSubmit }
78+ className = { ! this . props . name ? 'invisible' : '' }
79+ >
80+ < fieldset { ...( this . props . isRipping ? { disabled : 'disabled' } : { } ) } >
6281 < FormGroup >
6382 < Label for = "discName" >
6483 Name
6584 </ Label >
6685 < Input type = "text"
67- value = { this . state . discName }
86+ value = { this . state . discName || this . props . name }
6887 onChange = {
6988 ( event ) => {
7089 this . setState ( { discName : event . target . value } )
@@ -78,8 +97,8 @@ class DiscInfo extends Component {
7897 < tr >
7998 < th >
8099 < Input type = "checkbox"
81- checked = { this . state . checkAll }
82- onChange = { this . toggleAllTracks } />
100+ { ... ( this . state . checkAll ? { checked : 'checked' } : { } ) }
101+ onChange = { ( e ) => this . toggleAllTracks ( e ) } />
83102 </ th >
84103 < th > #</ th >
85104 < th > Source</ th >
@@ -90,49 +109,47 @@ class DiscInfo extends Component {
90109 </ tr >
91110 </ thead >
92111 < tbody >
93- {
94- this . props . tracks . map ( function ( trackInfo ) {
95- return < tr >
96- < td >
97- < Input type = "checkbox"
98- name = "selectTrack"
99- data-track-id = { trackInfo . id }
100- { ...( trackInfo . isAutoSelected ? 'checked' : '' ) }
101- />
102- </ td >
103- < td > { trackInfo . orderWeight } </ td >
104- < td > { trackInfo . name } </ td >
105- < td > { trackInfo . chapterCount } </ td >
106- < td > { trackInfo . diskSize } </ td >
107- < td > { trackInfo . streams . metadata } </ td >
108- < td > { trackInfo . segments . map } </ td >
109- </ tr > ;
110- } )
111- }
112+ { this . props . tracks && this . props . tracks . map ( function ( trackInfo , trackId ) {
113+ return < tr onClick = { ( e ) => this . toggleTrack ( trackId ) } >
114+ < td >
115+ < Input type = "checkbox"
116+ name = "selectTrack"
117+ data-track-id = { trackId }
118+ checked = { this . state . selectedTracks [ trackId ] }
119+ onChange = { ( e ) => this . toggleTrack ( trackId ) }
120+ /> s
121+ </ td >
122+ < td > { trackInfo . orderWeight } </ td >
123+ < td > { trackInfo . name } </ td >
124+ < td > { trackInfo . chapterCount } </ td >
125+ < td > { trackInfo . diskSize } </ td >
126+ < td > { trackInfo . streams . length } </ td >
127+ < td > { trackInfo . segmentsMap } </ td >
128+ </ tr > ;
129+ } ) }
112130 </ tbody >
113131 </ Table >
114132 </ FormGroup >
115133 < FormGroup >
116- < Button onClick = { this . ripTracks } />
134+ < Button onClick = { ( e ) => this . ripTracks ( e ) } />
117135 </ FormGroup >
118136 </ fieldset >
119137 </ Form >
120- ) ;
138+ </ div > ) ;
121139 }
122140}
123141
124142DiscInfo . propTypes = {
143+ driveState : PropTypes . string . isRequired ,
125144 isRipping : PropTypes . bool ,
126- metadata : PropTypes . shape ( {
127- lngCode : PropTypes . string . isRequired ,
128- lngName : PropTypes . string . isRequired ,
129- } ) ,
145+ metadataLngCode : PropTypes . string . isRequired ,
146+ metadataLngName : PropTypes . string . isRequired ,
130147 name : PropTypes . string . isRequired ,
131148 orderWeight : PropTypes . number . isRequired ,
149+ panelTitle : PropTypes . string ,
132150 sanitized : PropTypes . string ,
133151 treeInfo : PropTypes . string . isRequired ,
134- driveId : PropTypes . string . isRequired ,
135- discType : PropTypes . string . isRequired ,
152+ type : PropTypes . string . isRequired ,
136153 volumeName : PropTypes . string . isRequired ,
137154 tracks : PropTypes . arrayOf ( PropTypes . shape ( {
138155 id : PropTypes . number . isRequired ,
@@ -142,33 +159,24 @@ DiscInfo.propTypes = {
142159 diskSize : PropTypes . string . isRequired ,
143160 diskSizeBytes : PropTypes . number . isRequired ,
144161 duration : PropTypes . string . isRequired ,
145- metadata : PropTypes . shape ( {
146- lngCode : PropTypes . string . isRequired ,
147- lngName : PropTypes . string . isRequired ,
148- } ) ,
162+ metadataLngCode : PropTypes . string . isRequired ,
163+ metadataLngName : PropTypes . string . isRequired ,
149164 name : PropTypes . string . isRequired ,
150165 orderWeight : PropTypes . number . isRequired ,
151- outputFileName : PropTypes . string . isRequired ,
152- segments : PropTypes . shape ( {
153- count : PropTypes . number . isRequired ,
154- map : PropTypes . string . isRequired ,
155- } ) ,
166+ outputFilename : PropTypes . string . isRequired ,
167+ panelTitle : PropTypes . string ,
168+ segmentsCount : PropTypes . number . isRequired ,
169+ segmentsMap : PropTypes . string . isRequired ,
156170 sourceFileName : PropTypes . string . isRequired ,
157171 treeInfo : PropTypes . string . isRequired ,
158- streams : PropTypes . shape ( {
159- metadata : PropTypes . shape ( {
160- audio : PropTypes . number . isRequired ,
161- subtitle : PropTypes . number . isRequired ,
162- video : PropTypes . number . isRequired ,
163- } ) ,
164- details : PropTypes . any ,
165- } )
172+ streams : PropTypes . arrayOf (
173+ PropTypes . objectOf ( PropTypes . string )
174+ ) ,
166175 } ) ) ,
167176} ;
168177
169178DiscInfo . defaultProps = {
170179 isRipping : false ,
171- tracks : [ ] ,
172180} ;
173181
174182export default DiscInfo ;
0 commit comments