Can delete a device relay from UI

This commit is contained in:
2024-08-31 20:03:46 +02:00
parent f35aac04f6
commit b0023a5167
5 changed files with 107 additions and 25 deletions

View File

@ -4,9 +4,9 @@ import {
DialogActions,
DialogContent,
DialogTitle,
Grid,
Typography,
} from "@mui/material";
import Grid from "@mui/material/Grid2";
import { TimePicker } from "@mui/x-date-pickers";
import React from "react";
import { Device, DeviceRelay } from "../api/DeviceApi";
@ -81,7 +81,7 @@ export function EditDeviceRelaysDialog(p: {
<DialogContent>
<DialogFormTitle>General info</DialogFormTitle>
<Grid container spacing={2}>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<TextInput
editable
label="Relay name"
@ -97,7 +97,7 @@ export function EditDeviceRelaysDialog(p: {
size={ServerApi.Config.constraints.dev_name_len}
/>
</Grid>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<CheckboxInput
editable
label="Enable relay"
@ -112,7 +112,7 @@ export function EditDeviceRelaysDialog(p: {
}
/>
</Grid>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<TextInput
editable
label="Priority"
@ -130,7 +130,7 @@ export function EditDeviceRelaysDialog(p: {
helperText="Relay priority when selecting relays to turn on. 0 = lowest priority"
/>
</Grid>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<TextInput
editable
label="Consumption"
@ -148,7 +148,7 @@ export function EditDeviceRelaysDialog(p: {
helperText="Estimated consumption of device powered by relay"
/>
</Grid>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<TextInput
editable
label="Minimal uptime"
@ -166,7 +166,7 @@ export function EditDeviceRelaysDialog(p: {
helperText="Minimal time this relay shall be left on before it can be turned off (in seconds)"
/>
</Grid>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<TextInput
editable
label="Minimal downtime"
@ -188,7 +188,7 @@ export function EditDeviceRelaysDialog(p: {
<DialogFormTitle>Daily runtime</DialogFormTitle>
<Grid container spacing={2}>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<CheckboxInput
editable
label="Enable minimal runtime"
@ -208,7 +208,7 @@ export function EditDeviceRelaysDialog(p: {
{!!relay.daily_runtime && (
<>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<TextInput
editable
label="Minimal daily runtime"
@ -231,7 +231,7 @@ export function EditDeviceRelaysDialog(p: {
helperText="Minimum time, in seconds, that this relay should run each day"
/>
</Grid>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<TimePicker
label="Reset time"
value={timeOfDay(relay.daily_runtime!.reset_time)}
@ -248,7 +248,7 @@ export function EditDeviceRelaysDialog(p: {
}
/>
</Grid>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<MultipleSelectInput
label="Catchup hours"
helperText="The hours during which the relay should be turned on to reach expected runtime"
@ -278,7 +278,7 @@ export function EditDeviceRelaysDialog(p: {
<DialogFormTitle>Constraints</DialogFormTitle>
<Grid container spacing={2}>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<SelectMultipleRelaysInput
label="Required relays"
exclude={[relay.id]}
@ -294,7 +294,7 @@ export function EditDeviceRelaysDialog(p: {
helperText="Relays that must be already up for this relay to be started"
/>
</Grid>
<Grid item xs={6}>
<Grid size={{ xs: 6 }}>
<SelectMultipleRelaysInput
label="Conflicting relays"
exclude={[relay.id]}