mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
UI fixes (#13246)
* Fix bad data in stats * Add support for changes dialog when leaving without saving config editor * Fix scrolling into view
This commit is contained in:
parent
e5448110fc
commit
9b4602acb3
@ -124,12 +124,49 @@ function ConfigEditor() {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// monitoring state
|
||||||
|
|
||||||
|
const [hasChanges, setHasChanges] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!config || !modelRef.current) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
modelRef.current.onDidChangeContent(() => {
|
||||||
|
if (modelRef.current?.getValue() != config) {
|
||||||
|
setHasChanges(true);
|
||||||
|
} else {
|
||||||
|
setHasChanges(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, [config]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (config && modelRef.current) {
|
if (config && modelRef.current) {
|
||||||
modelRef.current.setValue(config);
|
modelRef.current.setValue(config);
|
||||||
|
setHasChanges(false);
|
||||||
}
|
}
|
||||||
}, [config]);
|
}, [config]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let listener: ((e: BeforeUnloadEvent) => void) | undefined;
|
||||||
|
if (hasChanges) {
|
||||||
|
listener = (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.returnValue = true;
|
||||||
|
return "Exit without saving?";
|
||||||
|
};
|
||||||
|
window.addEventListener("beforeunload", listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (listener) {
|
||||||
|
window.removeEventListener("beforeunload", listener);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [hasChanges]);
|
||||||
|
|
||||||
if (!config) {
|
if (!config) {
|
||||||
return <ActivityIndicator />;
|
return <ActivityIndicator />;
|
||||||
}
|
}
|
||||||
|
@ -286,6 +286,7 @@ function Logs() {
|
|||||||
key={item}
|
key={item}
|
||||||
className={`flex items-center justify-between gap-2 ${logService == item ? "" : "text-muted-foreground"}`}
|
className={`flex items-center justify-between gap-2 ${logService == item ? "" : "text-muted-foreground"}`}
|
||||||
value={item}
|
value={item}
|
||||||
|
data-nav-item={item}
|
||||||
aria-label={`Select ${item}`}
|
aria-label={`Select ${item}`}
|
||||||
>
|
>
|
||||||
<div className="capitalize">{item}</div>
|
<div className="capitalize">{item}</div>
|
||||||
|
@ -163,7 +163,7 @@ export default function GeneralMetrics({
|
|||||||
series[key] = { name: key, data: [] };
|
series[key] = { name: key, data: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = stats.cpu_usages[detStats.pid.toString()].cpu;
|
const data = stats.cpu_usages[detStats.pid.toString()]?.cpu;
|
||||||
|
|
||||||
if (data != undefined) {
|
if (data != undefined) {
|
||||||
series[key].data.push({
|
series[key].data.push({
|
||||||
@ -304,7 +304,7 @@ export default function GeneralMetrics({
|
|||||||
series[key] = { name: key, data: [] };
|
series[key] = { name: key, data: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = stats.cpu_usages[procStats.pid.toString()].cpu;
|
const data = stats.cpu_usages[procStats.pid.toString()]?.cpu;
|
||||||
|
|
||||||
if (data != undefined) {
|
if (data != undefined) {
|
||||||
series[key].data.push({
|
series[key].data.push({
|
||||||
@ -338,11 +338,15 @@ export default function GeneralMetrics({
|
|||||||
series[key] = { name: key, data: [] };
|
series[key] = { name: key, data: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const data = stats.cpu_usages[procStats.pid.toString()]?.mem;
|
||||||
|
|
||||||
|
if (data) {
|
||||||
series[key].data.push({
|
series[key].data.push({
|
||||||
x: statsIdx + 1,
|
x: statsIdx + 1,
|
||||||
y: stats.cpu_usages[procStats.pid.toString()].mem,
|
y: data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return Object.values(series);
|
return Object.values(series);
|
||||||
|
Loading…
Reference in New Issue
Block a user