mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-17 16:44:29 +03:00
Close upload dialog when done and add toasts
This commit is contained in:
parent
2993b7f040
commit
ce1ee0a28f
@ -20,7 +20,7 @@ export default function FaceLibrary() {
|
|||||||
|
|
||||||
// face data
|
// face data
|
||||||
|
|
||||||
const { data: faceData } = useSWR("faces");
|
const { data: faceData, mutate: refreshFaces } = useSWR("faces");
|
||||||
|
|
||||||
const faces = useMemo<string[]>(
|
const faces = useMemo<string[]>(
|
||||||
() => (faceData ? Object.keys(faceData) : []),
|
() => (faceData ? Object.keys(faceData) : []),
|
||||||
@ -47,13 +47,36 @@ export default function FaceLibrary() {
|
|||||||
(file: File) => {
|
(file: File) => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("file", file);
|
formData.append("file", file);
|
||||||
axios.post(`faces/${pageToggle}`, formData, {
|
axios
|
||||||
headers: {
|
.post(`faces/${pageToggle}`, formData, {
|
||||||
"Content-Type": "multipart/form-data",
|
headers: {
|
||||||
},
|
"Content-Type": "multipart/form-data",
|
||||||
});
|
},
|
||||||
|
})
|
||||||
|
.then((resp) => {
|
||||||
|
if (resp.status == 200) {
|
||||||
|
setUpload(false);
|
||||||
|
refreshFaces();
|
||||||
|
toast.success(
|
||||||
|
"Successfully uploaded iamge. View the file in the /exports folder.",
|
||||||
|
{ position: "top-center" },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
if (error.response?.data?.message) {
|
||||||
|
toast.error(
|
||||||
|
`Failed to upload image: ${error.response.data.message}`,
|
||||||
|
{ position: "top-center" },
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
toast.error(`Failed to upload image: ${error.message}`, {
|
||||||
|
position: "top-center",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
[pageToggle],
|
[pageToggle, refreshFaces],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user