File tree Expand file tree Collapse file tree 2 files changed +24
-15
lines changed Expand file tree Collapse file tree 2 files changed +24
-15
lines changed Original file line number Diff line number Diff line change @@ -18,18 +18,6 @@ export default class FileUploadItem extends Component {
1818 render ( ) {
1919 let { file, height, width } = this . props ;
2020
21- const imgStyle = {
22- display : 'block' ,
23- marginLeft : 'auto' ,
24- marginRight : 'auto'
25- } ;
26-
27- let image = null ;
28-
29- if ( file . type . match ( / i m a g e / ) ) {
30- image = < img height = { height } width = { width } src = { file . preview } style = { imgStyle } /> ;
31- }
32-
3321 //TODO truncate fileName to keep the Col in the same height
3422 const containerStyle = {
3523 backgroundColor : "#e0e0e0" ,
@@ -46,11 +34,20 @@ export default class FileUploadItem extends Component {
4634 paddingRight : "10px"
4735 } ;
4836
37+ const imgStyle = {
38+ display : 'block' ,
39+ marginLeft : 'auto' ,
40+ marginRight : 'auto'
41+ } ;
42+
43+ //TODO check this
44+ let image = ( file . type . match ( / i m a g e / ) ) ? file . preview : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAVFBMVEW9w8f///+Vpaa8wsbCx8uvubyerK2ksLKqtLeYp6jV2dyQoaKsuLmPoKG4v8Ocqqze4uP2+PjQ19e8xsfEzM34+fni5ObM0dTn6urX2t3u7/Czu7+daS8oAAAD0ElEQVR4nO3dbXOiMBiFYUCB0PBibW139f//z0Wdju5umzyE8HDCnPtrpzXXhLcGRrJ862VrD2DxKEw/CtOPwvSj8Lnzx+H3y5IdVxV+7Pu+3y2baVcTnl5GXbZ4ZbcAUST80OBdhYWNT5QIP3sV31W4AFEg3OtM4F0Yn+gX6gFvwuhEr/BTD3gXxib6hAetffAhjEz0CE+awC9hXKJHqLmNPoRRiW7hq+oUPoQxiW7hi+oUPgkjEt1C3Sl8FsYjOoXnFYXRiE7hQXcj/VsYi+gUKu+G/wgjEZ1C3XPFf8I4RKdQ8ZL0W2EUIrYwBhFcGIGILpxPhBfOJuIL5xITEM4kpiCcR0xCOIuYhnAOMRHhDGIqwnBiMsJgYjrCUGJCwkBiSsIwYlLCIGJawhBiYsIAYmrC6cTkhJOJUMKLRDiVCCXs7QJEKGEmAk4kYgmHBYhYQiMUTiFiCXeyHXESEUuYVVKhnAgmvIgnUUwEE+7lkyglggmznVwoJKIJp2ynMiKcMDORiXjCrI1LBBTK/sUQExGFWT9EPGlACsdpbKJd3YAKx2NqXQiRnsffYYVjfWlqSdVbqkJx+60LdxRSCB+FFOJHYaBQurQZq0FdOGFBJUoVhRRSSCGFKQonrPlFyOoLL6VuF3UhUBRSiB+FFOJHIYX4UUghfhRSiB+FFP5Q1eimv07DOzOx43ophRRSSGGKwtLoVqoLgaKQQvwopBA/CinEj0IK8aOQQvwopPCH6qHSbKjVhbxvETuuJlJIIYVbFG7/bCH7Qod4GXUhUBRSiB+FFOJHIYX4UUghfhRSiB+FFP7Q9lcxtr8Stf3VRAoppJDC5YXbP1ts/0kFoCikED8KKcSPQgrxo5BC/CikED8KKcSPQgrxo5BC/CikED8KXT9MpWBhv/bIhfXBQsd3pEFVBgsdzyFBZYKFjnvnUFXBwiGNzbQcwufQ8XgAUEP4HFbW8R4pmC52hrBo9muP39t+KMKFdVHgH05NUdTBwtYWBfpZvy8K2wYL36/vx8O+Nt2NI7TvwcJDN/5+g0zcNeMIu0Ow8NTdHinDPaBebuPrTsHCvL39BYt6uDH3t0w6d0OP8HCfxKJBvLgpm/vg3BupR5g3Xw8/NgbroNqbx9DcBI/waxKv22pTGaP8as7vM6ZqHm9B9UyhT5jXui9UnZ51nu4FwhO80HkgFQjzX53/U1as++UDeIXPuyJevp1QJESeRf8MioT5a41p7OpXweglwjw/WjxjZ4+iscuEo7HqLM5h1dqukvnkwjw/H9/aqvF/+uI1Vft2PIvH/Qe0D6lLW0grSAAAAABJRU5ErkJggg==" ;
45+
4946 return (
5047 < Col xs = { 4 } md = { 4 } >
5148 < div style = { containerStyle } >
5249 < div >
53- { image }
50+ < img height = { height } width = { width } src = { image } style = { imgStyle } />
5451 </ div >
5552 < div >
5653 < p style = { fileNameStyle } >
Original file line number Diff line number Diff line change @@ -16,12 +16,24 @@ export default class FileUpload extends Component {
1616 } ;
1717
1818 onDrop = ( files ) => {
19- //TODO Check file and size. Avoid duplicated files
20- let fileArray = [ ...files , ...this . state . files ] ;
19+ let fileArray = this . filter ( [ ...files , ...this . state . files ] ) ;
2120
2221 this . setState ( { files : fileArray } ) ;
2322 } ;
2423
24+ //TODO JS: Create a correct filter..
25+ filter = ( array ) => {
26+ // let a = [];
27+ //
28+ // array.forEach((item) => {
29+ // if (a.indexOf(item) < 0) {
30+ // a.push(item);
31+ // }
32+ // });
33+
34+ return Array . from ( new Set ( array ) ) ;
35+ } ;
36+
2537 onClick = ( ) => {
2638 // TODO Handle response status for upload service
2739 const { files } = this . state ;
You can’t perform that action at this time.
0 commit comments