2021-05-25 13:38:10 +00:00
|
|
|
import React from "react"
|
|
|
|
import BoxFull from "../base/BoxFull"
|
|
|
|
import FormLabelled from "../base/FormLabelled"
|
|
|
|
import FormLabel from "../base/formparts/FormLabel"
|
|
|
|
import InputWithIcon from "../base/InputWithIcon"
|
2021-05-25 15:10:40 +00:00
|
|
|
import { faBell, faPlus, faStopwatch, faThermometerThreeQuarters } from "@fortawesome/free-solid-svg-icons"
|
2021-05-25 13:38:10 +00:00
|
|
|
import Radio from "../base/Radio"
|
|
|
|
import Button from "../base/Button"
|
|
|
|
import FormAlert from "../base/formparts/FormAlert"
|
|
|
|
import useStrings from "../../hooks/useStrings"
|
|
|
|
|
|
|
|
|
|
|
|
export default function BoxAlertCreate(
|
|
|
|
{
|
|
|
|
name,
|
|
|
|
setName,
|
|
|
|
evaluationMode,
|
|
|
|
setEvaluationMode,
|
|
|
|
limit,
|
|
|
|
setLimit,
|
|
|
|
windowSize,
|
|
|
|
setWindowSize,
|
|
|
|
running,
|
|
|
|
error,
|
|
|
|
save,
|
|
|
|
...props
|
|
|
|
}) {
|
|
|
|
|
|
|
|
const strings = useStrings()
|
|
|
|
|
|
|
|
return (
|
2021-05-25 16:28:32 +00:00
|
|
|
<BoxFull header={strings.createAlert} {...props}>
|
2021-05-25 13:38:10 +00:00
|
|
|
<FormLabelled
|
|
|
|
onSubmit={e => {
|
|
|
|
e.preventDefault()
|
|
|
|
save()
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<FormLabel htmlFor={"alert-name"} text={strings.alertName}>
|
|
|
|
<InputWithIcon
|
|
|
|
id={"alert-name"}
|
|
|
|
icon={faBell}
|
|
|
|
value={name}
|
|
|
|
onChange={e => setName(e.target.value)}
|
|
|
|
/>
|
|
|
|
</FormLabel>
|
|
|
|
<FormLabel htmlFor={"filter-mode"} text={strings.request}>
|
|
|
|
<label>
|
|
|
|
<Radio
|
|
|
|
name={"filter-mode"}
|
|
|
|
onChange={() => setEvaluationMode(0)}
|
|
|
|
checked={evaluationMode === 0}
|
|
|
|
/>
|
|
|
|
{strings.filterOR}
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<label>
|
|
|
|
<Radio
|
|
|
|
name={"filter-mode"}
|
|
|
|
onChange={() => setEvaluationMode(1)}
|
|
|
|
checked={evaluationMode === 1}
|
|
|
|
/>
|
|
|
|
{strings.filterAND}
|
|
|
|
</label>
|
|
|
|
</FormLabel>
|
|
|
|
<FormLabel htmlFor={"alert-limit"} text={strings.alertLimit}>
|
|
|
|
<InputWithIcon
|
|
|
|
id={"alert-limit"}
|
|
|
|
type={"number"}
|
|
|
|
icon={faThermometerThreeQuarters}
|
|
|
|
value={limit}
|
2021-05-25 16:24:16 +00:00
|
|
|
onChange={e => setLimit(e.target.value)}
|
2021-05-25 13:38:10 +00:00
|
|
|
/>
|
|
|
|
</FormLabel>
|
|
|
|
<FormLabel htmlFor={"alert-window"} text={strings.alertWindow}>
|
|
|
|
<InputWithIcon
|
|
|
|
id={"alert-window"}
|
|
|
|
type={"number"}
|
|
|
|
icon={faStopwatch}
|
|
|
|
value={windowSize}
|
2021-05-25 16:24:16 +00:00
|
|
|
onChange={e => setWindowSize(e.target.value)}
|
2021-05-25 13:38:10 +00:00
|
|
|
/>
|
|
|
|
</FormLabel>
|
|
|
|
{error ?
|
|
|
|
<FormAlert color={"Red"}>
|
|
|
|
{strings[error.data.code]}
|
|
|
|
</FormAlert>
|
|
|
|
: null}
|
|
|
|
<Button
|
|
|
|
style={{ "gridColumn": "1 / 3" }}
|
|
|
|
icon={faPlus}
|
|
|
|
color={"Green"}
|
|
|
|
onClick={save}
|
|
|
|
disabled={running}
|
|
|
|
>
|
|
|
|
{strings.createAlert}
|
|
|
|
</Button>
|
|
|
|
</FormLabelled>
|
|
|
|
</BoxFull>
|
|
|
|
)
|
|
|
|
}
|