diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-09-08 20:59:18 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-09-08 20:59:18 -0700 |
commit | a7b243a894f9b1b09cc9478104b920ec47a94380 (patch) | |
tree | 253a511b4ef409de126fb5c93a83c949252399f3 /modern | |
parent | 514843d04a1253f583612797a1947790c43717c3 (diff) | |
download | etbsa-traccar-web-a7b243a894f9b1b09cc9478104b920ec47a94380.tar.gz etbsa-traccar-web-a7b243a894f9b1b09cc9478104b920ec47a94380.tar.bz2 etbsa-traccar-web-a7b243a894f9b1b09cc9478104b920ec47a94380.zip |
Add calendar file upload
Diffstat (limited to 'modern')
-rw-r--r-- | modern/package.json | 1 | ||||
-rw-r--r-- | modern/src/settings/CalendarPage.js | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/modern/package.json b/modern/package.json index a9050fb..e5489a6 100644 --- a/modern/package.json +++ b/modern/package.json @@ -16,6 +16,7 @@ "canvas-tint-image": "^2.0.1", "mapbox-gl": "^1.13.1", "maplibre-gl": "^1.15.0", + "material-ui-dropzone": "^3.5.0", "moment": "^2.29.1", "react": "^17.0.2", "react-container-dimensions": "^1.4.1", diff --git a/modern/src/settings/CalendarPage.js b/modern/src/settings/CalendarPage.js index de714c3..60d4ef7 100644 --- a/modern/src/settings/CalendarPage.js +++ b/modern/src/settings/CalendarPage.js @@ -4,6 +4,7 @@ import { Accordion, AccordionSummary, AccordionDetails, makeStyles, Typography, } from '@material-ui/core'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; +import { DropzoneArea } from 'material-ui-dropzone'; import EditItemView from '../EditItemView'; import EditAttributesView from '../attributes/EditAttributesView'; import { useTranslation } from '../LocalizationProvider'; @@ -20,6 +21,19 @@ const CalendarPage = () => { const [item, setItem] = useState(); + const handleFiles = (files) => { + if (files.length > 0) { + const reader = new FileReader(); + reader.onload = (event) => { + const { result } = event.target; + setItem({ ...item, data: result.substr(result.indexOf(',') + 1) }); + }; + reader.readAsDataURL(files[0]); + } else { + setItem({ ...item, data: null }); + } + }; + return ( <EditItemView endpoint="calendars" item={item} setItem={setItem}> {item @@ -39,6 +53,10 @@ const CalendarPage = () => { label={t('sharedName')} variant="filled" /> + <DropzoneArea + filesLimit={1} + onChange={handleFiles} + /> </AccordionDetails> </Accordion> <Accordion> |