Skip to content

Commit

Permalink
Misc fixes (#14064)
Browse files Browse the repository at this point in the history
* Add loading indicator when explore view is revalidating

* Portal tooltip in object lifecycle pane

* Better config file handling

* Only manually set aspect ratio when using alert videos
  • Loading branch information
hawkeye217 authored Sep 30, 2024
1 parent 775a3a1 commit 3688a3b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
6 changes: 6 additions & 0 deletions frigate/ptz/autotrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,12 @@ def _autotracker_setup(self, camera_config, camera):
def _write_config(self, camera):
config_file = os.environ.get("CONFIG_FILE", f"{CONFIG_DIR}/config.yml")

# Check if we can use .yaml instead of .yml
config_file_yaml = config_file.replace(".yml", ".yaml")

if os.path.isfile(config_file_yaml):
config_file = config_file_yaml

logger.debug(
f"{camera}: Writing new config with autotracker motion coefficients: {self.config.cameras[camera].onvif.autotracking.movement_weights}"
)
Expand Down
19 changes: 15 additions & 4 deletions frigate/util/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,23 @@ def update_yaml_from_url(file_path, url):
def update_yaml_file(file_path, key_path, new_value):
yaml = YAML()
yaml.indent(mapping=2, sequence=4, offset=2)
with open(file_path, "r") as f:
data = yaml.load(f)

try:
with open(file_path, "r") as f:
data = yaml.load(f)
except FileNotFoundError:
logger.error(
f"Unable to read from Frigate config file {file_path}. Make sure it exists and is readable."
)
return

data = update_yaml(data, key_path, new_value)
with open(file_path, "w") as f:
yaml.dump(data, f)

try:
with open(file_path, "w") as f:
yaml.dump(data, f)
except Exception as e:
logger.error(f"Unable to write to Frigate config file {file_path}: {e}")


def update_yaml(data, key_path, new_value):
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/card/AnimatedEventCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function AnimatedEventCard({
<div
className="relative h-24 4k:h-32"
style={{
aspectRatio: aspectRatio,
aspectRatio: alertVideos ? aspectRatio : undefined,
}}
onMouseEnter={isDesktop ? () => setIsHovered(true) : undefined}
onMouseLeave={isDesktop ? () => setIsHovered(false) : undefined}
Expand Down
4 changes: 3 additions & 1 deletion web/src/components/overlay/detail/ObjectLifecycle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ export default function ObjectLifecycle({
/>
</Button>
</TooltipTrigger>
<TooltipContent>Adjust annotation settings</TooltipContent>
<TooltipPortal>
<TooltipContent>Adjust annotation settings</TooltipContent>
</TooltipPortal>
</Tooltip>
</div>
</div>
Expand Down
15 changes: 12 additions & 3 deletions web/src/views/explore/ExploreView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ export default function ExploreView({

// data

const { data: events, mutate } = useSWR<SearchResult[]>(
const {
data: events,
mutate,
isLoading,
isValidating,
} = useSWR<SearchResult[]>(
[
"events/explore",
{
Expand Down Expand Up @@ -81,7 +86,7 @@ export default function ExploreView({
}
}, [events, searchDetail, setSearchDetail]);

if (!events) {
if (isLoading) {
return (
<ActivityIndicator className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2" />
);
Expand All @@ -93,6 +98,7 @@ export default function ExploreView({
<ThumbnailRow
key={label}
searchResults={filteredEvents}
isValidating={isValidating}
objectType={label}
setSearchDetail={setSearchDetail}
/>
Expand All @@ -104,12 +110,14 @@ export default function ExploreView({
type ThumbnailRowType = {
objectType: string;
searchResults?: SearchResult[];
isValidating: boolean;
setSearchDetail: (search: SearchResult | undefined) => void;
};

function ThumbnailRow({
objectType,
searchResults,
isValidating,
setSearchDetail,
}: ThumbnailRowType) {
const navigate = useNavigate();
Expand All @@ -123,7 +131,7 @@ function ThumbnailRow({

return (
<div className="rounded-lg bg-background_alt p-2 md:px-4">
<div className="text-lg capitalize">
<div className="flex flex-row items-center text-lg capitalize">
{objectType.replaceAll("_", " ")}
{searchResults && (
<span className="ml-3 text-sm text-secondary-foreground">
Expand All @@ -135,6 +143,7 @@ function ThumbnailRow({
tracked objects){" "}
</span>
)}
{isValidating && <ActivityIndicator className="ml-2 size-4" />}
</div>
<div className="flex flex-row items-center space-x-2 py-2">
{searchResults?.map((event) => (
Expand Down

0 comments on commit 3688a3b

Please sign in to comment.