-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathDropZone.jsx
60 lines (50 loc) · 1.6 KB
/
DropZone.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React, { Component } from 'react';
import DropzoneComponent from 'react-dropzone-component';
import FilesActions from './../actions/FilesActions';
import PropTypes from 'prop-types';
const icon = '/assets/img/pizilla/favicon.ico';
class DropZone extends Component {
static propTypes = {
path: PropTypes.string
}
constructor(props) {
super(props);
if ('Notification' in window) {
Notification.requestPermission();
}
// For a full list of possible configurations,
// please consult http://www.dropzonejs.com/#configuration
this.djsConfig = {
maxFilesize: 4096, //MB
parallelUploads: 10,
uploadMultiple: true
};
this.componentConfig = {
postUrl: '/upload',
showFiletypeIcon: true
};
this.dropzone = null;
}
success = (file, path) => {
FilesActions.updateFileList(path);
const body = `Filename : ${file.name}`;
if('Notification' in window && Notification.permission === 'granted') {
new Notification('File uploaded successfully',{ body , icon });
}
}
render = () => {
const { path } = this.props;
const eventHandlers = {
init: (dz) => this.dropzone = dz,
success: (file) => this.success(file, path)
};
return (
<DropzoneComponent
config={ this.componentConfig }
djsConfig={ this.djsConfig }
eventHandlers={ eventHandlers }
/>
);
}
}
export default DropZone;