mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 02:35:22 +03:00
Make default order to be sorted alphabetically
This commit is contained in:
parent
a5855ab428
commit
82a6d41fef
@ -372,9 +372,6 @@ class BirdseyeModeEnum(str, Enum):
|
|||||||
class BirdseyeConfig(FrigateBaseModel):
|
class BirdseyeConfig(FrigateBaseModel):
|
||||||
enabled: bool = Field(default=True, title="Enable birdseye view.")
|
enabled: bool = Field(default=True, title="Enable birdseye view.")
|
||||||
restream: bool = Field(default=False, title="Restream birdseye via RTSP.")
|
restream: bool = Field(default=False, title="Restream birdseye via RTSP.")
|
||||||
sort_cameras: bool = Field(
|
|
||||||
default=False, title="Sort cameras by position and name."
|
|
||||||
)
|
|
||||||
width: int = Field(default=1280, title="Birdseye width.")
|
width: int = Field(default=1280, title="Birdseye width.")
|
||||||
height: int = Field(default=720, title="Birdseye height.")
|
height: int = Field(default=720, title="Birdseye height.")
|
||||||
quality: int = Field(
|
quality: int = Field(
|
||||||
@ -391,9 +388,7 @@ class BirdseyeConfig(FrigateBaseModel):
|
|||||||
# uses BaseModel because some global attributes are not available at the camera level
|
# uses BaseModel because some global attributes are not available at the camera level
|
||||||
class BirdseyeCameraConfig(BaseModel):
|
class BirdseyeCameraConfig(BaseModel):
|
||||||
enabled: bool = Field(default=True, title="Enable birdseye view for camera.")
|
enabled: bool = Field(default=True, title="Enable birdseye view for camera.")
|
||||||
position: int = Field(
|
order: int = Field(default=0, title="Position of the camera in the birdseye view.")
|
||||||
default=0, title="Position of the camera in the birdseye view."
|
|
||||||
)
|
|
||||||
mode: BirdseyeModeEnum = Field(
|
mode: BirdseyeModeEnum = Field(
|
||||||
default=BirdseyeModeEnum.objects, title="Tracking mode for camera."
|
default=BirdseyeModeEnum.objects, title="Tracking mode for camera."
|
||||||
)
|
)
|
||||||
|
|||||||
@ -293,20 +293,15 @@ class BirdsEyeFrameManager:
|
|||||||
# calculate layout dimensions
|
# calculate layout dimensions
|
||||||
layout_dim = math.ceil(math.sqrt(len(active_cameras)))
|
layout_dim = math.ceil(math.sqrt(len(active_cameras)))
|
||||||
|
|
||||||
# check if we need to reset the layout because sorting is enabled and there are new cameras to add
|
# check if we need to reset the layout because there are new cameras to add
|
||||||
reset_layout = (
|
reset_layout = (
|
||||||
True
|
True if len(active_cameras.difference(self.active_cameras)) > 0 else False
|
||||||
if self.config.birdseye.sort_cameras
|
|
||||||
and len(active_cameras.difference(self.active_cameras)) > 0
|
|
||||||
else False
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# reset the layout if it needs to be different
|
# reset the layout if it needs to be different
|
||||||
if layout_dim != self.layout_dim or reset_layout:
|
if layout_dim != self.layout_dim or reset_layout:
|
||||||
if reset_layout:
|
if reset_layout:
|
||||||
logger.debug(
|
logger.debug(f"Added new cameras, resetting layout...")
|
||||||
f"Added new cameras and Birdseye sorting is enabled, resetting layout..."
|
|
||||||
)
|
|
||||||
|
|
||||||
logger.debug(f"Changing layout size from {self.layout_dim} to {layout_dim}")
|
logger.debug(f"Changing layout size from {self.layout_dim} to {layout_dim}")
|
||||||
self.layout_dim = layout_dim
|
self.layout_dim = layout_dim
|
||||||
@ -341,14 +336,13 @@ class BirdsEyeFrameManager:
|
|||||||
|
|
||||||
self.active_cameras = active_cameras
|
self.active_cameras = active_cameras
|
||||||
|
|
||||||
if self.config.birdseye.sort_cameras:
|
|
||||||
# this also converts added_cameras from a set to a list since we need
|
# this also converts added_cameras from a set to a list since we need
|
||||||
# to pop elements in order
|
# to pop elements in order
|
||||||
added_cameras = sorted(
|
added_cameras = sorted(
|
||||||
added_cameras,
|
added_cameras,
|
||||||
# sort cameras by the position and by name if the position is the same
|
# sort cameras by order and by name if the order is the same
|
||||||
key=lambda added_camera: (
|
key=lambda added_camera: (
|
||||||
self.config.cameras[added_camera].birdseye.position,
|
self.config.cameras[added_camera].birdseye.order,
|
||||||
added_camera,
|
added_camera,
|
||||||
),
|
),
|
||||||
# we're popping out elements from the end, so this needs to be reverse
|
# we're popping out elements from the end, so this needs to be reverse
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user