Compare commits

...
Author SHA1 Message Date
Josh Hawkins 7008be001b add mobile test to legacy layouts spec 2026-12-03 09:31:03 -06:00
Josh Hawkins 18bbd2f0ae compact converted 0.18 grid layouts in render order
0.18 stored every new grid tile at y 0 and left gaps behind removed cameras, relying on the grid's vertical compaction at render to stack tiles in render order (Birdseye, then camera order). The current grid renders without compaction and conversion only rescaled the coordinates, so upgraded groups with more than three tiles showed tiles on top of each other, often covering Birdseye, and gaps that 0.18 never displayed. Conversion now sorts tiles by render order and compacts them once, so each layout opens as 0.18 showed it.
2026-12-03 09:15:05 -06:00
Josh HawkinsandGitHub 582ec9b92f Fix deletes on defaulted ffmpeg args (#25145)
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Build (push) Waiting to run
CI / AMD64 Smoke Test (push) Blocked by required conditions
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
2026-12-02 15:58:26 -08:00
8 changed files with 538 additions and 42 deletions
+2 -1
View File
@@ -13,7 +13,8 @@
* Tiles measured in separate round-trips can straddle that reflow and disagree * Tiles measured in separate round-trips can straddle that reflow and disagree
* on scale, so cameraBoxes() takes every measurement in one evaluate. * on scale, so cameraBoxes() takes every measurement in one evaluate.
* *
* Used by live-grid-aspect-modes.spec.ts and masonry-live-grid.spec.ts. * Used by live-grid-aspect-modes.spec.ts, live-grid-legacy-layouts.spec.ts and
* masonry-live-grid.spec.ts.
*/ */
import { expect, type Page } from "@playwright/test"; import { expect, type Page } from "@playwright/test";
+5
View File
@@ -45,6 +45,11 @@ export class LivePage extends BasePage {
); );
} }
/** Birdseye tile on the draggable grid, the one without a camera card. */
get birdseyeTile(): Locator {
return this.page.locator(".react-grid-item:not(:has([data-camera]))");
}
/** Edit-layout toggle on the draggable grid (desktop, custom groups). */ /** Edit-layout toggle on the draggable grid (desktop, custom groups). */
get editLayoutButton(): Locator { get editLayoutButton(): Locator {
return this.page.getByTestId("toggle-edit-layout"); return this.page.getByTestId("toggle-edit-layout");
+9 -8
View File
@@ -89,8 +89,8 @@ test.describe("Live grid aspect modes @critical", () => {
}); });
// 0.17/0.18 shape: bare array on a 12-column grid, 4x4 standard tiles. // 0.17/0.18 shape: bare array on a 12-column grid, 4x4 standard tiles.
// backyard was manually resized to 8x8 and sits beside front_door's column, // backyard was manually resized to 8x8 and sits beside front_door's column.
// front_door is a standard tile on the row below. // front_door is stored on the row below, but 0.18 compacted it to the top.
const key = await persistedLayoutKey(frigateApp.page, GROUP); const key = await persistedLayoutKey(frigateApp.page, GROUP);
await seedLayout(frigateApp.page, key, [ await seedLayout(frigateApp.page, key, [
{ i: "backyard", x: 4, y: 0, w: 8, h: 8, moved: false, static: false }, { i: "backyard", x: 4, y: 0, w: 8, h: 8, moved: false, static: false },
@@ -127,21 +127,21 @@ test.describe("Live grid aspect modes @critical", () => {
stored.layout.find((i: LayoutItem) => i.i === "front_door"), stored.layout.find((i: LayoutItem) => i.i === "front_door"),
).toMatchObject({ ).toMatchObject({
x: 0, x: 0,
y: 144, y: 0,
w: 32, w: 32,
h: 72, h: 72,
}); });
// arrangement on screen: backyard indented, front_door below it // arrangement on screen: front_door top-left, backyard beside it
const { backyard, front_door: frontDoor } = await cameraBoxes( const { backyard, front_door: frontDoor } = await cameraBoxes(
frigateApp.page, frigateApp.page,
["backyard", "front_door"] as const, ["backyard", "front_door"] as const,
); );
expect(backyard.x).toBeGreaterThan(frontDoor.x + frontDoor.w / 2); expect(backyard.x).toBeGreaterThan(frontDoor.x + frontDoor.w / 2);
expect(frontDoor.y).toBeGreaterThan(backyard.y + backyard.h / 2); expect(Math.abs(frontDoor.y - backyard.y)).toBeLessThan(2);
}); });
test("conversion is a pure scale, so odd sizes and positions survive", async ({ test("conversion scales odd sizes and keeps tiles adjacent", async ({
frigateApp, frigateApp,
}) => { }) => {
await frigateApp.goto(`/?group=${GROUP}`); await frigateApp.goto(`/?group=${GROUP}`);
@@ -175,8 +175,9 @@ test.describe("Live grid aspect modes @critical", () => {
)!; )!;
const backyard = stored.layout.find((i: LayoutItem) => i.i === "backyard")!; const backyard = stored.layout.find((i: LayoutItem) => i.i === "backyard")!;
expect(frontDoor).toMatchObject({ x: 0, y: 54, w: 40, h: 90 }); // the empty rows above both tiles compact away, as they did in 0.18
expect(backyard).toMatchObject({ x: 40, y: 54, w: 56, h: 90 }); expect(frontDoor).toMatchObject({ x: 0, y: 0, w: 40, h: 90 });
expect(backyard).toMatchObject({ x: 40, y: 0, w: 56, h: 90 });
// still adjacent, still inside the grid, still not overlapping // still adjacent, still inside the grid, still not overlapping
expect(frontDoor.x + frontDoor.w).toBe(backyard.x); expect(frontDoor.x + frontDoor.w).toBe(backyard.x);
@@ -0,0 +1,187 @@
/**
* Live grid layouts saved by 0.18.
*
* 0.18 stored every new tile at y 0 and let the grid compact the tiles at
* render, in render order (Birdseye, then camera order). Its stored layouts
* can share cells and hold gaps that never showed. Conversion compacts the same
* way, so each layout opens exactly as 0.18 displayed it.
*
* Each stored layout below was captured from 0.18's IndexedDB, and each
* expected cell is where 0.18 rendered that tile.
*/
import { test, expect } from "../fixtures/frigate-test";
import { BASE_CONFIG } from "../fixtures/mock-data/config";
import { LivePage } from "../pages/live.page";
import {
persistedLayoutKey,
readLayout,
seedLayout,
type LayoutItem,
} from "../helpers/grid-layout";
// one 0.18 cell is 32 columns by 72 rows on the current grid
const CELL_W = 32;
const CELL_H = 72;
const tile = (i: string, x: number, y: number) => ({ i, x, y, w: 4, h: 4 });
type Scenario = {
name: string;
cameras: string[];
stored: LayoutItem[];
rendered: Record<string, [number, number]>;
};
const SCENARIOS: Scenario[] = [
{
name: "a group created with Birdseye",
cameras: ["birdseye", "front_door", "backyard", "garage"],
stored: [
tile("birdseye", 0, 0),
tile("front_door", 4, 0),
tile("backyard", 8, 0),
tile("garage", 0, 0),
],
rendered: {
birdseye: [0, 0],
front_door: [1, 0],
backyard: [2, 0],
garage: [0, 1],
},
},
{
name: "Birdseye and a camera added after a drag",
cameras: [
"front_door",
"backyard",
"garage",
"porch",
"driveway",
"birdseye",
],
stored: [
tile("front_door", 0, 4),
tile("backyard", 4, 0),
tile("garage", 8, 0),
tile("porch", 0, 0),
tile("driveway", 4, 0),
tile("birdseye", 0, 0),
],
rendered: {
birdseye: [0, 0],
backyard: [1, 0],
garage: [2, 0],
porch: [0, 1],
driveway: [1, 1],
front_door: [0, 2],
},
},
{
name: "a camera added ahead of the others in camera order",
cameras: ["backyard", "garage", "porch", "driveway", "front_door"],
stored: [
tile("backyard", 0, 0),
tile("garage", 4, 0),
tile("porch", 8, 0),
tile("driveway", 0, 0),
tile("front_door", 0, 0),
],
rendered: {
front_door: [0, 0],
garage: [1, 0],
porch: [2, 0],
backyard: [0, 1],
driveway: [0, 2],
},
},
{
name: "a camera removed after a drag",
cameras: ["front_door", "backyard", "garage"],
stored: [
tile("front_door", 0, 4),
tile("backyard", 4, 0),
tile("garage", 8, 0),
],
rendered: {
front_door: [0, 0],
backyard: [1, 0],
garage: [2, 0],
},
},
];
const frontDoor = BASE_CONFIG.cameras.front_door;
test.describe("Live grid 0.18 layouts @critical", () => {
test.skip(
({ frigateApp }) => frigateApp.isMobile,
"Draggable grid is desktop-only",
);
SCENARIOS.forEach(({ name, cameras, stored, rendered }, index) => {
test(`opens ${name} as 0.18 showed it`, async ({ frigateApp }) => {
const group = `legacy${index}`;
await frigateApp.installDefaults({
config: {
cameras: {
porch: { ...frontDoor, name: "porch" },
driveway: { ...frontDoor, name: "driveway" },
},
camera_groups: { [group]: { cameras, icon: "LuCar", order: 1 } },
},
});
await frigateApp.goto(`/?group=${group}`);
const key = await persistedLayoutKey(frigateApp.page, group);
await seedLayout(frigateApp.page, key, stored);
await frigateApp.page.reload();
await expect
.poll(async () => (await readLayout(frigateApp.page, key))?.version, {
timeout: 10_000,
})
.toBe(2);
const layout = (await readLayout(frigateApp.page, key))!.layout;
const cells = Object.fromEntries(
layout.map((item) => [item.i, [item.x / CELL_W, item.y / CELL_H]]),
);
expect(cells).toEqual(rendered);
if (cameras.includes("birdseye")) {
await new LivePage(frigateApp.page, true).birdseyeTile.click();
await expect(frigateApp.page).toHaveURL(/#birdseye/);
}
});
});
});
test.describe("Live grid 0.18 layouts on mobile @critical @mobile", () => {
test("a group with Birdseye shows every tile in the static grid", async ({
frigateApp,
}) => {
test.skip(!frigateApp.isMobile, "Mobile-only");
const { cameras } = SCENARIOS[0];
await frigateApp.installDefaults({
config: {
camera_groups: { legacy: { cameras, icon: "LuCar", order: 1 } },
},
});
await frigateApp.goto("/?group=legacy");
const live = new LivePage(frigateApp.page, false);
for (const camera of cameras.filter((name) => name !== "birdseye")) {
await expect(live.cameraCard(camera).first()).toBeVisible({
timeout: 10_000,
});
}
// the static grid never reads a stored layout, so nothing can cover Birdseye
await expect(frigateApp.page.locator(".react-grid-item")).toHaveCount(0);
await expect(
frigateApp.page.locator(
"#pageRoot .aspect-video:not([data-camera]):not(:has([data-camera]))",
),
).toBeVisible();
});
});
+247 -2
View File
@@ -1,13 +1,16 @@
/** /**
* Hardware acceleration args widget -- MEDIUM tier. * FFmpeg args widget -- MEDIUM tier.
* *
* Global hwaccel offers Auto (writes "auto") and Disabled (writes []). * Global hwaccel offers Auto (writes "auto") and Disabled (writes []).
* Cameras offer Disabled next to "Inherit from global setting". * Cameras offer Disabled next to "Inherit from global setting".
* Global input and record args offer Default, and record_sub offers
* "Same as record" (writes []).
*/ */
import { readFileSync } from "node:fs"; import { readFileSync } from "node:fs";
import { resolve, dirname } from "node:path"; import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url"; import { fileURLToPath } from "node:url";
import type { Locator } from "@playwright/test";
import { test, expect, type FrigateApp } from "../../fixtures/frigate-test"; import { test, expect, type FrigateApp } from "../../fixtures/frigate-test";
import { import {
configFactory, configFactory,
@@ -49,7 +52,10 @@ async function openSettings(
json: { json: {
hwaccel_args: ["preset-vaapi", "preset-nvidia"], hwaccel_args: ["preset-vaapi", "preset-nvidia"],
input_args: ["preset-rtsp-generic"], input_args: ["preset-rtsp-generic"],
output_args: { record: ["preset-record-generic"], detect: [] }, output_args: {
record: ["preset-record-generic", "preset-record-generic-audio-aac"],
detect: [],
},
}, },
}), }),
); );
@@ -576,3 +582,242 @@ test.describe("hwaccel args widget @medium", () => {
).toBeChecked(); ).toBeChecked();
}); });
}); });
const DEFAULT_MODE = "default";
const DEFAULTED_FIELDS = ["root_input_args", "root_output_args_record"];
const RECORD_SUB = "root_output_args_record_sub";
// Sections also open on their own when a field inside them has a pending
// change, so a blind click can close one again. Clicks inside a section
// wait for its open animation to finish.
const expand = async (trigger: Locator) => {
await expect(async () => {
if ((await trigger.getAttribute("aria-expanded")) !== "true") {
await trigger.click();
}
await expect(trigger).toHaveAttribute("aria-expanded", "true", {
timeout: 1_000,
});
}).toPass();
await trigger.page().waitForFunction(() =>
document
.getAnimations()
.filter((animation) =>
(animation as CSSAnimation).animationName?.startsWith("collapsible"),
)
.every((animation) => animation.playState === "finished"),
);
};
const showOutputArgs = (app: FrigateApp) =>
expand(
app.page
.locator("[aria-expanded]")
.filter({ has: app.page.getByText("Output arguments", { exact: true }) }),
);
// A sidebar switch lands after a delay, so wait for the FFmpeg form before
// opening its sections.
const showGlobalArgs = async (app: FrigateApp) => {
await expect(radio(app, "root_hwaccel_args", "auto")).toBeVisible();
await expand(app.page.getByRole("button", { name: /Advanced/ }).first());
await showOutputArgs(app);
};
const switchSection = (app: FrigateApp, name: string) =>
app.page
.locator('[data-sidebar="menu-sub-button"]', {
hasText: new RegExp(`^${name}$`),
})
.click();
// The sidebar commits a switch after a delay, and a second click before
// then cancels the first, so wait for the FFmpeg form to unmount.
const leaveFfmpegAndReturn = async (app: FrigateApp) => {
await switchSection(app, "Recording");
await expect(radio(app, "root_hwaccel_args", "auto")).toHaveCount(0);
await switchSection(app, "FFmpeg");
};
test.describe("ffmpeg default args @medium", () => {
test("global defaults show Default", async ({ frigateApp }) => {
await openSettings(frigateApp, "/settings?page=globalFfmpeg");
await showGlobalArgs(frigateApp);
for (const field of DEFAULTED_FIELDS) {
await expect(radio(frigateApp, field, DEFAULT_MODE)).toBeChecked();
}
});
test("global Default on defaults sends no delete", async ({ frigateApp }) => {
const capture = await openSettings(
frigateApp,
"/settings?page=globalFfmpeg",
);
await showGlobalArgs(frigateApp);
for (const field of DEFAULTED_FIELDS) {
const unset = radio(frigateApp, field, DEFAULT_MODE);
await radio(frigateApp, field, "manual").click();
await manualInput(frigateApp, field).fill("-x 1");
await unset.click();
await expect(unset).toBeChecked();
}
await frigateApp.page
.getByRole("switch", { name: "Apple compatibility" })
.click();
await save(frigateApp).click();
await expect.poll(capture.saved, { timeout: 5_000 }).toMatchObject({
config_data: { ffmpeg: { apple_compatibility: true } },
});
const { ffmpeg } = (
capture.saved() as { config_data: { ffmpeg: Record<string, unknown> } }
).config_data;
expect(ffmpeg).not.toHaveProperty("input_args");
expect(ffmpeg).not.toHaveProperty("output_args");
});
test("Default then Manual starts with an empty box", async ({
frigateApp,
}) => {
await openSettings(frigateApp, "/settings?page=globalFfmpeg");
await showGlobalArgs(frigateApp);
for (const field of DEFAULTED_FIELDS) {
const manual = radio(frigateApp, field, "manual");
await manual.click();
await expect(manual).toBeChecked();
await expect(manualInput(frigateApp, field)).toHaveValue("");
}
await expect(save(frigateApp)).toBeDisabled();
});
test("global Default on defaults stays across a section switch", async ({
frigateApp,
}) => {
test.skip(frigateApp.isMobile, "the section sidebar is desktop only");
await openSettings(frigateApp, "/settings?page=globalFfmpeg");
await showGlobalArgs(frigateApp);
for (const field of DEFAULTED_FIELDS) {
await radio(frigateApp, field, "manual").click();
await manualInput(frigateApp, field).fill("-x 1");
await radio(frigateApp, field, DEFAULT_MODE).click();
}
await leaveFfmpegAndReturn(frigateApp);
await showGlobalArgs(frigateApp);
for (const field of DEFAULTED_FIELDS) {
await expect(radio(frigateApp, field, DEFAULT_MODE)).toBeChecked();
}
await expect(save(frigateApp)).toBeDisabled();
});
test("global Default on saved args deletes them", async ({ frigateApp }) => {
test.skip(frigateApp.isMobile, "the section sidebar is desktop only");
const capture = await openSettings(
frigateApp,
"/settings?page=globalFfmpeg",
{ ffmpeg: { input_args: "-in 1", output_args: { record: "-out 1" } } },
);
await showGlobalArgs(frigateApp);
for (const field of DEFAULTED_FIELDS) {
await radio(frigateApp, field, DEFAULT_MODE).click();
}
await leaveFfmpegAndReturn(frigateApp);
await showGlobalArgs(frigateApp);
for (const field of DEFAULTED_FIELDS) {
await expect(radio(frigateApp, field, DEFAULT_MODE)).toBeChecked();
}
await save(frigateApp).click();
await expect.poll(capture.saved, { timeout: 5_000 }).toMatchObject({
config_data: {
ffmpeg: { input_args: "", output_args: { record: "" } },
},
});
});
test("Same as record on defaults leaves nothing to save", async ({
frigateApp,
}) => {
await openSettings(frigateApp, "/settings?page=globalFfmpeg");
await showGlobalArgs(frigateApp);
const sameAsRecord = radio(frigateApp, RECORD_SUB, "inherit");
await expect(sameAsRecord).toBeChecked();
await radio(frigateApp, RECORD_SUB, "preset").click();
await expect(save(frigateApp)).toBeEnabled();
await sameAsRecord.click();
await expect(sameAsRecord).toBeChecked();
await expect(save(frigateApp)).toBeDisabled();
});
test("global Same as record on saved args saves an empty list", async ({
frigateApp,
}) => {
const capture = await openSettings(
frigateApp,
"/settings?page=globalFfmpeg",
{ ffmpeg: { output_args: { record_sub: "preset-record-generic" } } },
);
await showGlobalArgs(frigateApp);
await radio(frigateApp, RECORD_SUB, "inherit").click();
await save(frigateApp).click();
await expect.poll(capture.saved, { timeout: 5_000 }).toMatchObject({
config_data: { ffmpeg: { output_args: { record_sub: [] } } },
});
});
test("camera Same as record over a global value saves an empty list", async ({
frigateApp,
}) => {
const recordSub = { output_args: { record_sub: "preset-record-generic" } };
const capture = await openSettings(
frigateApp,
"/settings?page=cameraFfmpeg&camera=front_door",
{
ffmpeg: recordSub,
cameras: {
front_door: { ffmpeg: recordSub },
backyard: { ffmpeg: { input_args: "-backyard 1" } },
},
},
);
// Only Backyard has manual input args, which shows which camera's form
// is on screen.
const inputArgs = (mode: string) =>
radio(frigateApp, "root_input_args", mode);
const sameAsRecord = radio(frigateApp, RECORD_SUB, "inherit");
await expect(inputArgs("inherit")).toBeChecked();
await showOutputArgs(frigateApp);
await sameAsRecord.click();
await frigateApp.page
.getByRole("button", { name: "Select a camera" })
.click();
await frigateApp.page.getByRole("switch", { name: "Backyard" }).click();
await expect(inputArgs("manual")).toBeChecked();
await frigateApp.page
.getByRole("button", { name: "Select a camera" })
.click();
await frigateApp.page.getByRole("switch", { name: "Front Door" }).click();
await expect(inputArgs("inherit")).toBeChecked();
await showOutputArgs(frigateApp);
await expect(sameAsRecord).toBeChecked();
await save(frigateApp).click();
await expect.poll(capture.saved, { timeout: 5_000 }).toMatchObject({
config_data: {
cameras: {
front_door: { ffmpeg: { output_args: { record_sub: [] } } },
},
},
});
});
});
+1 -1
View File
@@ -1607,7 +1607,7 @@
"preset": "Preset", "preset": "Preset",
"manual": "Manual arguments", "manual": "Manual arguments",
"inherit": "Inherit from camera setting", "inherit": "Inherit from camera setting",
"none": "None", "default": "Default",
"auto": "Auto", "auto": "Auto",
"autoDescription": "Frigate detects Nvidia or VAAPI hardware. After saving, this field shows the detected preset, or Disabled if none is found. Other hardware needs a preset.", "autoDescription": "Frigate detects Nvidia or VAAPI hardware. After saving, this field shows the detected preset, or Disabled if none is found. Other hardware needs a preset.",
"disabled": "Disabled", "disabled": "Disabled",
@@ -1,4 +1,4 @@
import type { WidgetProps } from "@rjsf/utils"; import type { RJSFSchema, WidgetProps } from "@rjsf/utils";
import useSWR from "swr"; import useSWR from "swr";
import { useCallback, useEffect, useMemo, useState } from "react"; import { useCallback, useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
@@ -25,7 +25,7 @@ type FfmpegPresetResponse = {
}; };
type FfmpegArgsMode = type FfmpegArgsMode =
"preset" | "manual" | "inherit" | "none" | "auto" | "disabled"; "preset" | "manual" | "inherit" | "default" | "auto" | "disabled";
// RJSF remounts the widget when the value flips between a string and a list, // RJSF remounts the widget when the value flips between a string and a list,
// so the user's mode choice lives outside the component. It applies only // so the user's mode choice lives outside the component. It applies only
@@ -68,6 +68,20 @@ const getPresetOptions = (
return []; return [];
}; };
// AnyOfField hands the widget a branch without the default, so read it
// from the section schema, which arrives with its $refs resolved.
const getSchemaDefault = (
rootSchema: RJSFSchema | undefined,
fieldPath: string | undefined,
): unknown => {
if (!rootSchema || !fieldPath) {
return undefined;
}
const schemaPath = fieldPath.split(".").flatMap((key) => ["properties", key]);
return get(rootSchema, [...schemaPath, "default"]);
};
const resolveMode = ( const resolveMode = (
value: unknown, value: unknown,
presets: string[], presets: string[],
@@ -77,7 +91,7 @@ const resolveMode = (
): FfmpegArgsMode => { ): FfmpegArgsMode => {
if (value === null || value === undefined) { if (value === null || value === undefined) {
if (allowInherit) return "inherit"; if (allowInherit) return "inherit";
return hwaccelModes ? "auto" : "none"; return hwaccelModes ? "auto" : "default";
} }
if (allowInherit && Array.isArray(value) && value.length === 0) { if (allowInherit && Array.isArray(value) && value.length === 0) {
@@ -157,15 +171,27 @@ export function FfmpegArgsWidget(props: WidgetProps) {
const useSplitLayout = options?.splitLayout !== false; const useSplitLayout = options?.splitLayout !== false;
// Detect camera-level top-level fields (not inside inputs array). // Detect camera-level top-level fields (not inside inputs array).
// These should show "Use global setting" instead of "None". // These should show "Use global setting" instead of "Default".
const isInputScoped = id.includes("_inputs_"); const isInputScoped = id.includes("_inputs_");
const showUseGlobalSetting = isCameraLevel && !isInputScoped && !allowInherit; const showUseGlobalSetting = isCameraLevel && !isInputScoped && !allowInherit;
// Hardware acceleration offers Auto and Disabled in place of None. Auto // Hardware acceleration offers Auto and Disabled in place of Default. Auto
// sends the literal "auto" because the form holds the resolved value, so a // sends the literal "auto" because the form holds the resolved value, so a
// delete could target a key that is absent from the YAML. // delete could target a key that is absent from the YAML.
const hwaccelModes = presetField === "hwaccel_args" && !allowInherit; const hwaccelModes = presetField === "hwaccel_args" && !allowInherit;
const unsetMode: FfmpegArgsMode =
showUseGlobalSetting || allowInherit
? "inherit"
: hwaccelModes
? "auto"
: "default";
const schemaDefault =
unsetMode === "default"
? getSchemaDefault(props.registry?.rootSchema, globalFieldPath)
: undefined;
// Extract the global value for this specific field to detect inheritance // Extract the global value for this specific field to detect inheritance
const globalFieldValue = useMemo(() => { const globalFieldValue = useMemo(() => {
if ( if (
@@ -233,6 +259,9 @@ export function FfmpegArgsWidget(props: WidgetProps) {
if (hwaccelModes && value === "" && !isEqual(savedValue, "")) { if (hwaccelModes && value === "" && !isEqual(savedValue, "")) {
return "manual" as FfmpegArgsMode; return "manual" as FfmpegArgsMode;
} }
if (schemaDefault !== undefined && isEqual(value, schemaDefault)) {
return "default" as FfmpegArgsMode;
}
return resolveMode( return resolveMode(
value, value,
presetOptions, presetOptions,
@@ -249,6 +278,7 @@ export function FfmpegArgsWidget(props: WidgetProps) {
allowInherit, allowInherit,
hwaccelModes, hwaccelModes,
savedValue, savedValue,
schemaDefault,
]); ]);
const modeKey = [ const modeKey = [
@@ -324,15 +354,27 @@ export function FfmpegArgsWidget(props: WidgetProps) {
const handleModeChange = useCallback( const handleModeChange = useCallback(
(nextMode: FfmpegArgsMode) => { (nextMode: FfmpegArgsMode) => {
// Restoring an inherited saved value leaves the form clean. Sending // An empty record_sub is the backend's "same as record" at both levels.
// undefined would delete a key that may be absent from the YAML. // Deleting it could target a key absent from the YAML, and a camera
// would fall back to the global value instead.
if (nextMode === "inherit" && presetField === "output_args.record_sub") {
choose(nextMode, []);
return;
}
// Restoring an inherited or default saved value leaves the form clean.
// Sending undefined would delete a key that may be absent from the
// YAML. A global value that differs from the default must be in it.
if (nextMode === "inherit") { if (nextMode === "inherit") {
choose(nextMode, isInherited(savedValue) ? savedValue : undefined); choose(nextMode, isInherited(savedValue) ? savedValue : undefined);
return; return;
} }
if (nextMode === "none") { if (nextMode === "default") {
choose(nextMode, undefined); choose(
nextMode,
isEqual(savedValue, schemaDefault) ? savedValue : undefined,
);
return; return;
} }
@@ -362,7 +404,12 @@ export function FfmpegArgsWidget(props: WidgetProps) {
// Start from the saved manual args, if any, so a switch back to Manual // Start from the saved manual args, if any, so a switch back to Manual
// shows them instead of an empty box. // shows them instead of an empty box.
if (mode === "preset" || mode === "auto" || mode === "disabled") { if (
mode === "preset" ||
mode === "default" ||
mode === "auto" ||
mode === "disabled"
) {
const savedIsManual = const savedIsManual =
resolveMode( resolveMode(
savedValue, savedValue,
@@ -384,8 +431,10 @@ export function FfmpegArgsWidget(props: WidgetProps) {
hwaccelModes, hwaccelModes,
isInherited, isInherited,
mode, mode,
presetField,
presetOptions, presetOptions,
savedValue, savedValue,
schemaDefault,
value, value,
], ],
); );
@@ -454,12 +503,6 @@ export function FfmpegArgsWidget(props: WidgetProps) {
? schema.description ? schema.description
: translatedDescription; : translatedDescription;
const unsetMode: FfmpegArgsMode =
showUseGlobalSetting || allowInherit
? "inherit"
: hwaccelModes
? "auto"
: "none";
const unsetLabel = showUseGlobalSetting const unsetLabel = showUseGlobalSetting
? t("configForm.ffmpegArgs.useGlobalSetting", { ns: "views/settings" }) ? t("configForm.ffmpegArgs.useGlobalSetting", { ns: "views/settings" })
: allowInherit : allowInherit
@@ -470,7 +513,7 @@ export function FfmpegArgsWidget(props: WidgetProps) {
? t(unsetLabelKey ?? "configForm.ffmpegArgs.auto", { ? t(unsetLabelKey ?? "configForm.ffmpegArgs.auto", {
ns: "views/settings", ns: "views/settings",
}) })
: t(unsetLabelKey ?? "configForm.ffmpegArgs.none", { : t(unsetLabelKey ?? "configForm.ffmpegArgs.default", {
ns: "views/settings", ns: "views/settings",
}); });
@@ -528,7 +571,7 @@ export function FfmpegArgsWidget(props: WidgetProps) {
</p> </p>
) : mode === "auto" || ) : mode === "auto" ||
mode === "inherit" || mode === "inherit" ||
mode === "none" || mode === "default" ||
mode === "disabled" ? null : mode === "preset" && canUsePresets ? ( mode === "disabled" ? null : mode === "preset" && canUsePresets ? (
<Select <Select
value={presetValue} value={presetValue}
+26 -12
View File
@@ -18,7 +18,11 @@ import {
LayoutItem, LayoutItem,
ResponsiveGridLayout as Responsive, ResponsiveGridLayout as Responsive,
} from "react-grid-layout"; } from "react-grid-layout";
import { aspectRatio, getCompactor } from "react-grid-layout/core"; import {
aspectRatio,
getCompactor,
verticalCompactor,
} from "react-grid-layout/core";
import "react-grid-layout/css/styles.css"; import "react-grid-layout/css/styles.css";
import "react-resizable/css/styles.css"; import "react-resizable/css/styles.css";
import { import {
@@ -311,10 +315,17 @@ export default function DraggableGridLayout({
[layoutAspects], [layoutAspects],
); );
const cameraNames = useMemo(
() =>
includeBirdseye && birdseyeConfig?.enabled
? ["birdseye", ...cameras.map((camera) => camera?.name || "")]
: cameras.map((camera) => camera?.name || ""),
[cameras, includeBirdseye, birdseyeConfig],
);
// Rescale a pre-masonry layout onto the current grid. Both axes scale by a // Rescale a pre-masonry layout onto the current grid. Both axes scale by a
// constant, so tiles the user resized keep their size and their arrangement // constant, so tiles the user resized keep their size. Only meaningful in
// stays intact. Only meaningful in bucketed mode, where a tile still has the // bucketed mode, where a tile still has the shape those coordinates assumed.
// shape those coordinates assumed.
const convertLegacyLayout = useCallback( const convertLegacyLayout = useCallback(
(stored: unknown): Layout | undefined => { (stored: unknown): Layout | undefined => {
if (naturalAspectLayout || !Array.isArray(stored) || !stored.length) { if (naturalAspectLayout || !Array.isArray(stored) || !stored.length) {
@@ -349,9 +360,17 @@ export default function DraggableGridLayout({
}); });
} }
return converted; // 0.18 stored new tiles at y 0 and compacted the grid at render, in
// render order. Compacting the same way reproduces what 0.18 showed.
return verticalCompactor.compact(
converted
.filter((item) => cameraNames.includes(item.i))
.sort((a, b) => cameraNames.indexOf(a.i) - cameraNames.indexOf(b.i)),
GRID_COLS,
);
}, },
[naturalAspectLayout], [naturalAspectLayout, cameraNames],
); );
const generateLayout = useCallback( const generateLayout = useCallback(
@@ -360,11 +379,6 @@ export default function DraggableGridLayout({
return; return;
} }
const cameraNames =
includeBirdseye && birdseyeConfig?.enabled
? ["birdseye", ...cameras.map((camera) => camera?.name || "")]
: cameras.map((camera) => camera?.name || "");
const existing: LayoutItem[] = baseLayout const existing: LayoutItem[] = baseLayout
? baseLayout.filter((layout) => cameraNames.includes(layout.i)) ? baseLayout.filter((layout) => cameraNames.includes(layout.i))
: []; : [];
@@ -426,7 +440,7 @@ export default function DraggableGridLayout({
return result; return result;
}, },
[cameras, isGridLayoutLoaded, includeBirdseye, birdseyeConfig, dimsFor], [cameraNames, isGridLayoutLoaded, dimsFor],
); );
useEffect(() => { useEffect(() => {