Compare commits
2
Commits
fbae62eec9
...
79e0b64de3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79e0b64de3 | ||
|
|
7a0dbbd5fb |
+1
-1
@@ -17,7 +17,7 @@ export const Galleria = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
var messagesRef = firebase.database().ref(`/messaggi/${evento}`);
|
var messagesRef = firebase.database().ref(`/messaggi/${evento}`);
|
||||||
|
console.log(`/messaggi/${evento}`);
|
||||||
messagesRef.once("value", function (snapshot) {
|
messagesRef.once("value", function (snapshot) {
|
||||||
const messaggiObject = snapshot.val();
|
const messaggiObject = snapshot.val();
|
||||||
const messaggi = Object.keys(messaggiObject)
|
const messaggi = Object.keys(messaggiObject)
|
||||||
|
|||||||
+2
-1
@@ -73,6 +73,7 @@ function ImageUpload({ onImageURLSet, onImageUploading }) {
|
|||||||
multiple
|
multiple
|
||||||
type="file"
|
type="file"
|
||||||
accept="image/*"
|
accept="image/*"
|
||||||
|
capture="camera"
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
<label htmlFor="raised-button-file">
|
<label htmlFor="raised-button-file">
|
||||||
@@ -89,7 +90,7 @@ function ImageUpload({ onImageURLSet, onImageUploading }) {
|
|||||||
spacing={2}
|
spacing={2}
|
||||||
style={{ justifyContent: "center", alignItems: "center" }}
|
style={{ justifyContent: "center", alignItems: "center" }}
|
||||||
>
|
>
|
||||||
<img style={{ width: 200 }} src={URL.createObjectURL(image)} />
|
<img style={{ width: 100 }} src={URL.createObjectURL(image)} />
|
||||||
<Stack
|
<Stack
|
||||||
spacing={4}
|
spacing={4}
|
||||||
style={{ width: "100%", justifyContent: "center" }}
|
style={{ width: "100%", justifyContent: "center" }}
|
||||||
|
|||||||
+55
-23
@@ -1,7 +1,13 @@
|
|||||||
import "./App.css";
|
import "./App.css";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import ReactDOM from "react-dom/client";
|
import ReactDOM from "react-dom/client";
|
||||||
import { BrowserRouter as Router, Routes, Route, Link } from "react-router-dom";
|
import {
|
||||||
|
BrowserRouter as Router,
|
||||||
|
Routes,
|
||||||
|
Route,
|
||||||
|
Link,
|
||||||
|
useParams,
|
||||||
|
} from "react-router-dom";
|
||||||
import firebase from "firebase/compat/app";
|
import firebase from "firebase/compat/app";
|
||||||
import "firebase/compat/database";
|
import "firebase/compat/database";
|
||||||
import "firebase/compat/analytics";
|
import "firebase/compat/analytics";
|
||||||
@@ -11,6 +17,7 @@ import { Admin } from "./Admin";
|
|||||||
import { Galleria } from "./Galleria";
|
import { Galleria } from "./Galleria";
|
||||||
import { ListaEventi } from "./ListaEventi";
|
import { ListaEventi } from "./ListaEventi";
|
||||||
import { Button } from "@mui/material";
|
import { Button } from "@mui/material";
|
||||||
|
import EXIF from "exif-js";
|
||||||
|
|
||||||
const firebaseConfig = {
|
const firebaseConfig = {
|
||||||
apiKey: "AIzaSyBWE1l8WV_7eyKT-PMu0Kq2w_WiV0SUhJw",
|
apiKey: "AIzaSyBWE1l8WV_7eyKT-PMu0Kq2w_WiV0SUhJw",
|
||||||
@@ -27,7 +34,13 @@ const firebaseConfig = {
|
|||||||
firebase.initializeApp(firebaseConfig);
|
firebase.initializeApp(firebaseConfig);
|
||||||
firebase.analytics();
|
firebase.analytics();
|
||||||
|
|
||||||
|
function parseDate(s) {
|
||||||
|
var b = s.split(/\D/);
|
||||||
|
return new Date(b[0], b[1] - 1, b[2], b[3], b[4], b[5]);
|
||||||
|
}
|
||||||
|
|
||||||
const Upload = () => {
|
const Upload = () => {
|
||||||
|
const { evento } = useParams();
|
||||||
const [uploadedFiles, setUploadedFiles] = useState([]);
|
const [uploadedFiles, setUploadedFiles] = useState([]);
|
||||||
|
|
||||||
const handleUploadFiles = (files) => {
|
const handleUploadFiles = (files) => {
|
||||||
@@ -35,31 +48,50 @@ const Upload = () => {
|
|||||||
|
|
||||||
function upload() {
|
function upload() {
|
||||||
const image = files[index];
|
const image = files[index];
|
||||||
const uploadTask = firebase
|
EXIF.getData(image, function () {
|
||||||
.storage()
|
var time = EXIF.getTag(this, "DateTime");
|
||||||
.ref(`images/${image.name}`)
|
if (time) {
|
||||||
.put(image, {
|
const timestamp = new Date(parseDate(time)).getTime();
|
||||||
cacheControl: "public,max-age=3000000",
|
const uploadTask = firebase
|
||||||
contentType: "image/jpeg",
|
.storage()
|
||||||
});
|
.ref(`images/${evento}/${image.name}`)
|
||||||
|
.put(image, {
|
||||||
|
cacheControl: "public,max-age=3000000",
|
||||||
|
contentType: "image/jpeg",
|
||||||
|
});
|
||||||
|
|
||||||
uploadTask.on(
|
uploadTask.on(
|
||||||
"state_changed",
|
"state_changed",
|
||||||
(snapshot) => {
|
(snapshot) => {
|
||||||
const progress = Math.round(
|
const progress = Math.round(
|
||||||
(snapshot.bytesTransferred / snapshot.totalBytes) * 100
|
(snapshot.bytesTransferred / snapshot.totalBytes) * 100
|
||||||
|
);
|
||||||
|
console.log(progress);
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.log(error);
|
||||||
|
},
|
||||||
|
(d) => {
|
||||||
|
// all done
|
||||||
|
console.log(d);
|
||||||
|
// var postListRef = firebase.database().ref(`messaggi/${evento}`);
|
||||||
|
// var newPostRef = postListRef.push();
|
||||||
|
// const update = {
|
||||||
|
// id: newPostRef.key,
|
||||||
|
// timestamp,
|
||||||
|
// approvato: true,
|
||||||
|
// immagineURL: "",
|
||||||
|
// };
|
||||||
|
|
||||||
|
// newPostRef.set(update);
|
||||||
|
|
||||||
|
// if (++index < files.length) {
|
||||||
|
// upload();
|
||||||
|
// }
|
||||||
|
}
|
||||||
);
|
);
|
||||||
console.log(progress);
|
|
||||||
},
|
|
||||||
(error) => {
|
|
||||||
console.log(error);
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
if (++index < files.length) {
|
|
||||||
upload();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
upload();
|
upload();
|
||||||
|
|||||||
Reference in New Issue
Block a user