Use config attribute map instead of hard coded (#14387)

This commit is contained in:
Nicolas Mowen
2024-10-16 07:27:36 -06:00
committed by GitHub
parent eda52a3b82
commit 06f47f262f
6 changed files with 56 additions and 19 deletions

View File

@@ -1,4 +1,5 @@
import { IconName } from "@/components/icons/IconPicker";
import { FrigateConfig } from "@/types/frigateConfig";
import { BsPersonWalking } from "react-icons/bs";
import {
FaAmazon,
@@ -36,6 +37,19 @@ import { LuBox, LuLassoSelect } from "react-icons/lu";
import * as LuIcons from "react-icons/lu";
import { MdRecordVoiceOver } from "react-icons/md";
export function getAttributeLabels(config?: FrigateConfig) {
if (!config) {
return [];
}
const labels = new Set();
Object.values(config.model.attributes_map).forEach((values) =>
values.forEach((label) => labels.add(label)),
);
return [...labels];
}
export function isValidIconName(value: string): value is IconName {
return Object.keys(LuIcons).includes(value as IconName);
}