@@ -11,13 +11,11 @@ const Input = styled('input')({
1111
1212const numberFormat = new Intl . NumberFormat ( 'en-US' )
1313
14- const UploadCard = ( { authenticated, feedView = false , publicUpload = false , fetchVideos, cardWidth, handleAlert, reserveDateSpace = false } ) => {
15- const cardHeight = cardWidth / 1.77 + 32
14+ const UploadCard = ( { authenticated, handleAlert, mini} ) => {
1615 const [ selectedFile , setSelectedFile ] = React . useState ( )
1716 const [ isSelected , setIsSelected ] = React . useState ( false )
1817 const [ progress , setProgress ] = React . useState ( 0 )
1918 const [ uploadRate , setUploadRate ] = React . useState ( )
20- const app_config = getSetting ( 'app_config' )
2119 const uiConfig = getSetting ( 'ui_config' )
2220
2321 const changeHandler = ( event ) => {
@@ -69,19 +67,19 @@ const UploadCard = ({ authenticated, feedView = false, publicUpload = false, fet
6967 const formData = new FormData ( )
7068 formData . append ( 'file' , selectedFile )
7169 try {
72- if ( publicUpload ) {
73- await VideoService . publicUpload ( formData , uploadProgress )
74- }
75- if ( ! publicUpload && authenticated ) {
70+ if ( authenticated ) {
7671 await VideoService . upload ( formData , uploadProgress )
72+ } else {
73+ await VideoService . publicUpload ( formData , uploadProgress )
7774 }
7875 handleAlert ( {
7976 type : 'success' ,
8077 message : 'Your upload will be available in a few seconds.' ,
8178 autohideDuration : 3500 ,
8279 open : true ,
83- onClose : ( ) => fetchVideos ( ) ,
80+ // onClose: () => fetchVideos(),
8481 } )
82+ setTimeout ( ( ) => window . dispatchEvent ( new Event ( 'transcodingStarted' ) ) , 5000 )
8583 } catch ( err ) {
8684 handleAlert ( {
8785 type : 'error' ,
@@ -119,20 +117,18 @@ const UploadCard = ({ authenticated, feedView = false, publicUpload = false, fet
119117 formData . append ( 'lastModified' , selectedFile . lastModified . toString ( ) ) ;
120118 formData . append ( 'fileType' , selectedFile . type ) ;
121119
122- if ( publicUpload ) {
123- await VideoService . publicUploadChunked ( formData , uploadProgressChunked , selectedFile . size , start ) ;
124- } else if ( ! publicUpload && authenticated ) {
125- await VideoService . uploadChunked ( formData , uploadProgressChunked , selectedFile . size , start ) ;
126- }
120+ authenticated ? await VideoService . uploadChunked ( formData , uploadProgressChunked , selectedFile . size , start )
121+ : await VideoService . publicUploadChunked ( formData , uploadProgressChunked , selectedFile . size , start )
127122 }
128123
129124 handleAlert ( {
130125 type : 'success' ,
131126 message : 'Your upload will be available in a few seconds.' ,
132127 autohideDuration : 3500 ,
133128 open : true ,
134- onClose : ( ) => fetchVideos ( ) ,
129+ // onClose: () => fetchVideos(),
135130 } ) ;
131+ setTimeout ( ( ) => window . dispatchEvent ( new Event ( 'transcodingStarted' ) ) , 5000 )
136132 } catch ( err ) {
137133 handleAlert ( {
138134 type : 'error' ,
@@ -155,21 +151,18 @@ const UploadCard = ({ authenticated, feedView = false, publicUpload = false, fet
155151 // eslint-disable-next-line
156152 } , [ selectedFile ] )
157153
158- if ( feedView && ! uiConfig ?. allow_public_upload ) return null
159- if ( ! feedView && ! uiConfig ?. show_admin_upload ) return null
154+ if ( ! authenticated && ! uiConfig ?. allow_public_upload ) return null
155+ if ( authenticated && ! uiConfig ?. show_admin_upload ) return null
160156
161157 return (
162- < Grid item sx = { { ml : 0.75 , mr : 0.75 , mb : 3 } } >
163- { reserveDateSpace && (
164- < Box sx = { { height : 20 , mb : 1 } } />
165- ) }
158+ < Grid item sx = { { mx : 1 , mt : 2 } } >
166159 < label htmlFor = "icon-button-file" >
167160 { /* Add onDrop and onDragOver handlers */ }
168161 < Paper
169162 sx = { {
170163 position : 'relative' ,
171- width : cardWidth ,
172- height : cardHeight ,
164+ width : '100%' ,
165+ height : '50px' ,
173166 cursor : 'pointer' ,
174167 background : 'rgba(0,0,0,0)' ,
175168 overflow : 'hidden' ,
@@ -178,8 +171,8 @@ const UploadCard = ({ authenticated, feedView = false, publicUpload = false, fet
178171 onDrop = { dropHandler }
179172 onDragOver = { dragOverHandler }
180173 >
181- < Box sx = { { display : 'flex' , p : 2 , height : '100%' } } justifyContent = "center" alignItems = "center" >
182- < Stack sx = { { zIndex : 0 , width : '100%' } } alignItems = "center" >
174+ < Box sx = { { display : 'flex' , p : 1 , height : '100%' } } justifyContent = "center" alignItems = "center" >
175+ < Stack sx = { { zIndex : 0 , width : '100%' } } alignItems = "center" justifyContent = "center" >
183176 { ! isSelected && (
184177 < Input
185178 id = "icon-button-file"
@@ -189,20 +182,27 @@ const UploadCard = ({ authenticated, feedView = false, publicUpload = false, fet
189182 onChange = { changeHandler }
190183 />
191184 ) }
192- < CloudUploadIcon sx = { { fontSize : 75 } } />
185+ { progress === 0 && ! mini && < CloudUploadIcon sx = { { fontSize : 32 } } /> }
186+ { progress === 0 && mini && progress === 0 && < CloudUploadIcon sx = { { fontSize : 20 } } /> }
193187 { progress !== 0 && progress !== 1 && (
194188 < >
195- < Typography component = "div" variant = "overline" align = "center" sx = { { fontWeight : 600 , fontSize : 16 } } >
196- Uploading... { ( 100 * progress ) . toFixed ( 0 ) } %
197- </ Typography >
198- < Typography variant = "overline" align = "center" sx = { { fontWeight : 600 , fontSize : 12 } } >
199- { numberFormat . format ( uploadRate . loaded . toFixed ( 0 ) ) } /{ ' ' }
200- { numberFormat . format ( uploadRate . total . toFixed ( 0 ) ) } MB's
201- </ Typography >
189+ { ! mini ?
190+ < >
191+ < Typography component = "div" variant = "overline" align = "center" sx = { { fontWeight : 600 , fontSize : 12 } } >
192+ Uploading... { ( 100 * progress ) . toFixed ( 0 ) } %
193+ </ Typography >
194+ < Typography variant = "overline" align = "center" sx = { { fontWeight : 600 , fontSize : 12 } } >
195+ { numberFormat . format ( uploadRate . loaded . toFixed ( 0 ) ) } /{ ' ' }
196+ { numberFormat . format ( uploadRate . total . toFixed ( 0 ) ) } MB's
197+ </ Typography >
198+ </ > : < Typography component = "div" variant = "overline" align = "center" justifyItems = "center" sx = { { fontWeight : 600 , fontSize : 12 } } >
199+ { ( 100 * progress ) . toFixed ( 0 ) } %
200+ </ Typography >
201+ }
202202 </ >
203203 ) }
204- { progress === 1 && (
205- < Typography component = "div" variant = "overline" align = "center" sx = { { fontWeight : 600 , fontSize : 16 } } >
204+ { progress === 1 && ! mini && (
205+ < Typography component = "div" variant = "overline" align = "center" sx = { { fontWeight : 600 , fontSize : 12 } } >
206206 Processing...
207207 < Typography
208208 component = "span"
@@ -215,15 +215,20 @@ const UploadCard = ({ authenticated, feedView = false, publicUpload = false, fet
215215 </ Typography >
216216 </ Typography >
217217 ) }
218+ { progress === 1 && mini && (
219+ < Typography component = "div" variant = "overline" align = "center" justifyItems = "center" sx = { { fontWeight : 600 , fontSize : 12 } } >
220+ 100%
221+ </ Typography >
222+ ) }
218223 </ Stack >
219224 </ Box >
220225 < Box
221226 sx = { {
222227 position : 'absolute' ,
223228 bottom : 0 ,
224229 zIndex : - 1 ,
225- height : cardHeight ,
226- width : cardWidth * progress ,
230+ height : mini ? ` ${ progress * 100 } %` : '100%' ,
231+ width : mini ? '100%' : ` ${ progress * 100 } %` ,
227232 backgroundImage : 'linear-gradient(90deg, #BC00E6DF, #FF3729D9)' ,
228233 borderRadius : '10px' ,
229234 } }
0 commit comments