Clean up thumbnail schema handling.
This commit is contained in:
+15
-53
@@ -1070,41 +1070,28 @@ export type ViewerConfig = z.infer<typeof viewerConfigSchema>;
|
|||||||
/**
|
/**
|
||||||
* Event gallery configuration section (clips, snapshots).
|
* Event gallery configuration section (clips, snapshots).
|
||||||
*/
|
*/
|
||||||
|
const galleryThumbnailControlsDefaults = {
|
||||||
|
...thumbnailControlsDefaults,
|
||||||
|
show_details: false,
|
||||||
|
};
|
||||||
|
|
||||||
const galleryConfigDefault = {
|
const galleryConfigDefault = {
|
||||||
controls: {
|
controls: {
|
||||||
thumbnails: {
|
thumbnails: galleryThumbnailControlsDefaults,
|
||||||
size: 100,
|
|
||||||
show_details: false,
|
|
||||||
show_favorite_control: true,
|
|
||||||
show_timeline_control: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const gallerythumbnailsControlSchema = thumbnailsControlSchema.extend({
|
||||||
|
show_details: z.boolean().default(galleryThumbnailControlsDefaults.show_details),
|
||||||
|
});
|
||||||
|
|
||||||
const galleryConfigSchema = z
|
const galleryConfigSchema = z
|
||||||
.object({
|
.object({
|
||||||
controls: z
|
controls: z
|
||||||
.object({
|
.object({
|
||||||
thumbnails: thumbnailsControlSchema
|
thumbnails: gallerythumbnailsControlSchema.default(
|
||||||
// Gallery shows thumbnails "centrally" so no need for the mode.
|
galleryConfigDefault.controls.thumbnails,
|
||||||
.omit({ mode: true })
|
|
||||||
.extend({
|
|
||||||
size: thumbnailsControlSchema.shape.size.default(
|
|
||||||
galleryConfigDefault.controls.thumbnails.size,
|
|
||||||
),
|
),
|
||||||
show_details: thumbnailsControlSchema.shape.show_details.default(
|
|
||||||
galleryConfigDefault.controls.thumbnails.show_details,
|
|
||||||
),
|
|
||||||
show_favorite_control:
|
|
||||||
thumbnailsControlSchema.shape.show_favorite_control.default(
|
|
||||||
galleryConfigDefault.controls.thumbnails.show_favorite_control,
|
|
||||||
),
|
|
||||||
show_timeline_control:
|
|
||||||
thumbnailsControlSchema.shape.show_timeline_control.default(
|
|
||||||
galleryConfigDefault.controls.thumbnails.show_timeline_control,
|
|
||||||
),
|
|
||||||
})
|
|
||||||
.default(galleryConfigDefault.controls.thumbnails),
|
|
||||||
})
|
})
|
||||||
.default(galleryConfigDefault.controls),
|
.default(galleryConfigDefault.controls),
|
||||||
})
|
})
|
||||||
@@ -1144,13 +1131,7 @@ const dimensionsConfigSchema = z
|
|||||||
const timelineConfigDefault = {
|
const timelineConfigDefault = {
|
||||||
...timelineCoreConfigDefault,
|
...timelineCoreConfigDefault,
|
||||||
controls: {
|
controls: {
|
||||||
thumbnails: {
|
thumbnails: thumbnailControlsDefaults,
|
||||||
mode: 'left' as const,
|
|
||||||
size: 100,
|
|
||||||
show_details: true,
|
|
||||||
show_favorite_control: true,
|
|
||||||
show_timeline_control: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1158,27 +1139,9 @@ const timelineConfigSchema = timelineCoreConfigSchema
|
|||||||
.extend({
|
.extend({
|
||||||
controls: z
|
controls: z
|
||||||
.object({
|
.object({
|
||||||
thumbnails: thumbnailsControlSchema
|
thumbnails: thumbnailsControlSchema.default(
|
||||||
.extend({
|
timelineConfigDefault.controls.thumbnails,
|
||||||
mode: thumbnailsControlSchema.shape.mode.default(
|
|
||||||
timelineConfigDefault.controls.thumbnails.mode,
|
|
||||||
),
|
),
|
||||||
size: thumbnailsControlSchema.shape.size.default(
|
|
||||||
timelineConfigDefault.controls.thumbnails.size,
|
|
||||||
),
|
|
||||||
show_details: thumbnailsControlSchema.shape.show_details.default(
|
|
||||||
timelineConfigDefault.controls.thumbnails.show_details,
|
|
||||||
),
|
|
||||||
show_favorite_control:
|
|
||||||
thumbnailsControlSchema.shape.show_favorite_control.default(
|
|
||||||
timelineConfigDefault.controls.thumbnails.show_favorite_control,
|
|
||||||
),
|
|
||||||
show_timeline_control:
|
|
||||||
thumbnailsControlSchema.shape.show_timeline_control.default(
|
|
||||||
timelineConfigDefault.controls.thumbnails.show_timeline_control,
|
|
||||||
),
|
|
||||||
})
|
|
||||||
.default(timelineConfigDefault.controls.thumbnails),
|
|
||||||
})
|
})
|
||||||
.default(timelineConfigDefault.controls),
|
.default(timelineConfigDefault.controls),
|
||||||
})
|
})
|
||||||
@@ -1425,7 +1388,6 @@ export interface FrigateBrowseMediaSource extends BrowseMediaSource {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const frigateBrowseMediaSourceSchema: z.ZodSchema<BrowseMediaSource> = z.lazy(
|
export const frigateBrowseMediaSourceSchema: z.ZodSchema<BrowseMediaSource> = z.lazy(
|
||||||
() =>
|
() =>
|
||||||
z.object({
|
z.object({
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// Easy:
|
// Easy:
|
||||||
// - TODO: Refactor thumbnailsControlSchema to all use the shortform for other thumbnail users beyond live.
|
|
||||||
// - TODO: Should be able to set live media to 'all' and have it work.
|
// - TODO: Should be able to set live media to 'all' and have it work.
|
||||||
// - TODO: Are there elements of ViewMedia (e.g. getEventCount) that should be moved into subclasses (e.g. a recording subclass).
|
// - TODO: Are there elements of ViewMedia (e.g. getEventCount) that should be moved into subclasses (e.g. a recording subclass).
|
||||||
// - TODO: In MediaQueriesBase, do we need to generic? Just have T be a MediaQuery?
|
// - TODO: In MediaQueriesBase, do we need to generic? Just have T be a MediaQuery?
|
||||||
|
|||||||
Reference in New Issue
Block a user