Add ability to rename camera groups (#14339)

* Add ability to rename camera groups

* clean up

* ampersand consistency
This commit is contained in:
Josh Hawkins 2024-10-14 10:27:50 -05:00 committed by GitHub
parent 0ee32cf110
commit dd7a07bd0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -643,6 +643,11 @@ export function CameraGroupEdit({
setIsLoading(true);
let renamingQuery = "";
if (editingGroup && editingGroup[0] !== values.name) {
renamingQuery = `camera_groups.${editingGroup[0]}&`;
}
const order =
editingGroup === undefined
? currentGroups.length + 1
@ -655,9 +660,12 @@ export function CameraGroupEdit({
.join("");
axios
.put(`config/set?${orderQuery}&${iconQuery}${cameraQueries}`, {
requires_restart: 0,
})
.put(
`config/set?${renamingQuery}${orderQuery}&${iconQuery}${cameraQueries}`,
{
requires_restart: 0,
},
)
.then((res) => {
if (res.status === 200) {
toast.success(`Camera group (${values.name}) has been saved.`, {
@ -712,7 +720,6 @@ export function CameraGroupEdit({
<Input
className="text-md w-full border border-input bg-background p-2 hover:bg-accent hover:text-accent-foreground dark:[color-scheme:dark]"
placeholder="Enter a name..."
disabled={editingGroup !== undefined}
{...field}
/>
</FormControl>