mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-06 21:44:13 +03:00
Use API response to update data instead of trying to re-parse all of the values
This commit is contained in:
parent
142bc2078a
commit
c3993eec22
@ -75,7 +75,7 @@
|
|||||||
"deletedName_other": "{{count}} faces have been successfully deleted.",
|
"deletedName_other": "{{count}} faces have been successfully deleted.",
|
||||||
"renamedFace": "Successfully renamed face to {{name}}",
|
"renamedFace": "Successfully renamed face to {{name}}",
|
||||||
"trainedFace": "Successfully trained face.",
|
"trainedFace": "Successfully trained face.",
|
||||||
"updatedFaceScore": "Successfully updated face score."
|
"updatedFaceScore": "Successfully updated face score to {{name}} ({{score}})."
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"uploadingImageFailed": "Failed to upload image: {{errorMessage}}",
|
"uploadingImageFailed": "Failed to upload image: {{errorMessage}}",
|
||||||
|
|||||||
@ -622,7 +622,15 @@ type TrainingGridProps = {
|
|||||||
faceNames: string[];
|
faceNames: string[];
|
||||||
selectedFaces: string[];
|
selectedFaces: string[];
|
||||||
onClickFaces: (images: string[], ctrl: boolean) => void;
|
onClickFaces: (images: string[], ctrl: boolean) => void;
|
||||||
onRefresh: () => void;
|
onRefresh: (
|
||||||
|
data?:
|
||||||
|
| FaceLibraryData
|
||||||
|
| Promise<FaceLibraryData>
|
||||||
|
| ((
|
||||||
|
currentData: FaceLibraryData | undefined,
|
||||||
|
) => FaceLibraryData | undefined),
|
||||||
|
opts?: boolean | { revalidate?: boolean },
|
||||||
|
) => Promise<FaceLibraryData | undefined>;
|
||||||
};
|
};
|
||||||
function TrainingGrid({
|
function TrainingGrid({
|
||||||
config,
|
config,
|
||||||
@ -726,7 +734,15 @@ type FaceAttemptGroupProps = {
|
|||||||
faceNames: string[];
|
faceNames: string[];
|
||||||
selectedFaces: string[];
|
selectedFaces: string[];
|
||||||
onClickFaces: (image: string[], ctrl: boolean) => void;
|
onClickFaces: (image: string[], ctrl: boolean) => void;
|
||||||
onRefresh: () => void;
|
onRefresh: (
|
||||||
|
data?:
|
||||||
|
| FaceLibraryData
|
||||||
|
| Promise<FaceLibraryData>
|
||||||
|
| ((
|
||||||
|
currentData: FaceLibraryData | undefined,
|
||||||
|
) => FaceLibraryData | undefined),
|
||||||
|
opts?: boolean | { revalidate?: boolean },
|
||||||
|
) => Promise<FaceLibraryData | undefined>;
|
||||||
};
|
};
|
||||||
function FaceAttemptGroup({
|
function FaceAttemptGroup({
|
||||||
config,
|
config,
|
||||||
@ -814,11 +830,44 @@ function FaceAttemptGroup({
|
|||||||
axios
|
axios
|
||||||
.post(`/faces/reprocess`, { training_file: data.filename })
|
.post(`/faces/reprocess`, { training_file: data.filename })
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
if (resp.status == 200) {
|
if (resp.status == 200 && resp.data?.success) {
|
||||||
toast.success(t("toast.success.updatedFaceScore"), {
|
const { face_name, score } = resp.data;
|
||||||
position: "top-center",
|
const oldFilename = data.filename;
|
||||||
});
|
const parts = oldFilename.split("-");
|
||||||
onRefresh();
|
const newFilename = `${parts[0]}-${parts[1]}-${parts[2]}-${face_name}-${score}.webp`;
|
||||||
|
|
||||||
|
onRefresh(
|
||||||
|
(currentData: FaceLibraryData | undefined) => {
|
||||||
|
if (!currentData?.train) return currentData;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...currentData,
|
||||||
|
train: currentData.train.map((filename: string) =>
|
||||||
|
filename === oldFilename ? newFilename : filename,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
{ revalidate: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
toast.success(
|
||||||
|
t("toast.success.updatedFaceScore", {
|
||||||
|
name: face_name,
|
||||||
|
score: score.toFixed(2),
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
position: "top-center",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else if (resp.data?.success === false) {
|
||||||
|
// Handle case where API returns success: false
|
||||||
|
const errorMessage = resp.data?.message || "Unknown error";
|
||||||
|
toast.error(
|
||||||
|
t("toast.error.updateFaceScoreFailed", { errorMessage }),
|
||||||
|
{
|
||||||
|
position: "top-center",
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user