feat: Implement basic general folder support (#2051)

- Related: #1748
This commit is contained in:
Dermot Duffy
2025-05-21 19:59:21 -07:00
committed by GitHub
parent 2eb0d9e35e
commit c6a4c8aea2
350 changed files with 12837 additions and 4509 deletions
@@ -0,0 +1,10 @@
import { z } from 'zod';
import { advancedCameraCardCustomActionsBaseSchema } from './base';
export const folderActionConfigSchema = advancedCameraCardCustomActionsBaseSchema.extend(
{
advanced_camera_card_action: z.literal('folder'),
folder: z.string().optional(),
},
);
export type FolderActionConfig = z.infer<typeof folderActionConfigSchema>;
+1 -2
View File
@@ -7,8 +7,7 @@ const PTZ_BASE_ACTIONS = [...PTZ_PAN_TILT_ACTIONS, ...PTZ_ZOOM_ACTIONS] as const
export type PTZBaseAction = (typeof PTZ_BASE_ACTIONS)[number];
// PTZ actions as used by the PTZ control (includes a 'home' button).
const PTZ_CONTROL_ACTIONS = [...PTZ_BASE_ACTIONS, 'home'] as const;
export type PTZControlAction = (typeof PTZ_CONTROL_ACTIONS)[number];
export type PTZControlAction = PTZBaseAction | 'home';
// PTZ actions as used by the camera manager (includes generic presets).
export const PTZ_ACTIONS = [...PTZ_BASE_ACTIONS, 'preset'] as const;
+17 -2
View File
@@ -1,8 +1,23 @@
import { z } from 'zod';
import { VIEWS_USER_SPECIFIED } from '../../common/const';
import {
AdvancedCameraCardUserSpecifiedView,
VIEWS_USER_SPECIFIED,
} from '../../common/const';
import { advancedCameraCardCustomActionsBaseSchema } from './base';
type AdvancedCameraCardUserSpecifiedViewWithoutFolder = Exclude<
AdvancedCameraCardUserSpecifiedView,
'folder'
>;
export const viewActionConfigSchema = advancedCameraCardCustomActionsBaseSchema.extend({
advanced_camera_card_action: z.enum(VIEWS_USER_SPECIFIED),
advanced_camera_card_action: z.enum(
// The folder view is handled by the `folder` action since it accepts an
// optional folder ID.
VIEWS_USER_SPECIFIED.filter((view) => view !== 'folder') as [
AdvancedCameraCardUserSpecifiedViewWithoutFolder,
...AdvancedCameraCardUserSpecifiedViewWithoutFolder[],
],
),
});
export type ViewActionConfig = z.infer<typeof viewActionConfigSchema>;
+2
View File
@@ -3,6 +3,7 @@ import { statusBarItemBaseSchema } from '../common/status-bar';
import { advancedCameraCardCustomActionsBaseSchema } from './custom/base';
import { cameraSelectActionConfigSchema } from './custom/camera-select';
import { viewDisplayModeActionConfigSchema } from './custom/display-mode';
import { folderActionConfigSchema } from './custom/folder';
import { generalActionConfigSchema } from './custom/general';
import { internalCallbackActionConfigSchema } from './custom/internal';
import { logActionConfigSchema } from './custom/log';
@@ -41,6 +42,7 @@ export const statusBarActionConfigSchema: z.ZodSchema<
const advancedCameraCardCustomActionSchema = z.union([
cameraSelectActionConfigSchema,
folderActionConfigSchema,
generalActionConfigSchema,
internalCallbackActionConfigSchema,
logActionConfigSchema,