-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
237 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import { useState } from "react"; | ||
import InsetPanel from "./InsetPanel"; | ||
import CheckCircleOutlineRoundedIcon from "@mui/icons-material/CheckCircleOutlineRounded"; | ||
import FormControl from "@mui/material/FormControl"; | ||
import InputLabel from "@mui/material/InputLabel"; | ||
import TextField from "@mui/material/TextField"; | ||
import MenuItem from "@mui/material/MenuItem"; | ||
import InputAdornment from "@mui/material/InputAdornment"; | ||
import Button from "@mui/material/Button"; | ||
import AddCircleOutlineIcon from "@mui/icons-material/AddCircleOutline"; | ||
import EditRoundedIcon from "@mui/icons-material/EditRounded"; | ||
import Select from "@mui/material/Select"; | ||
import VdbeView from "./VdbeView"; | ||
import "./styles/CreateEditVdbeForm.css"; | ||
|
||
function CreateEditFormFields({ vdbe, setVdbe }) { | ||
const onStalenessChange = (event) => { | ||
const maxStalenessMins = parseInt(event.target.value); | ||
if (isNaN(maxStalenessMins)) { | ||
setVdbe({ ...vdbe, max_staleness_ms: null }); | ||
return; | ||
} | ||
setVdbe({ ...vdbe, max_staleness_ms: maxStalenessMins * 60 * 1000 }); | ||
}; | ||
|
||
const onSloChange = (event) => { | ||
const sloMs = parseInt(event.target.value); | ||
if (isNaN(sloMs)) { | ||
setVdbe({ ...vdbe, p90_latency_slo_ms: null }); | ||
return; | ||
} | ||
setVdbe({ ...vdbe, p90_latency_slo_ms: sloMs }); | ||
}; | ||
|
||
return ( | ||
<div className="cev-form-fields"> | ||
<TextField | ||
variant="outlined" | ||
label="Name" | ||
className="cev-field" | ||
value={vdbe.name} | ||
onChange={(event) => setVdbe({ ...vdbe, name: event.target.value })} | ||
/> | ||
<TextField | ||
variant="outlined" | ||
label="Maximum Staleness (Freshness Constraint)" | ||
className="cev-field" | ||
slotProps={{ | ||
input: { | ||
endAdornment: ( | ||
<InputAdornment position="end">minutes</InputAdornment> | ||
), | ||
}, | ||
}} | ||
value={ | ||
vdbe.max_staleness_ms != null ? vdbe.max_staleness_ms / 60000 : "" | ||
} | ||
onChange={onStalenessChange} | ||
/> | ||
<TextField | ||
variant="outlined" | ||
label="Maximum p90 Latency (Performance SLO)" | ||
className="cev-field" | ||
slotProps={{ | ||
input: { | ||
endAdornment: ( | ||
<InputAdornment position="end">milliseconds</InputAdornment> | ||
), | ||
}, | ||
}} | ||
value={vdbe.p90_latency_slo_ms != null ? vdbe.p90_latency_slo_ms : ""} | ||
onChange={onSloChange} | ||
/> | ||
<FormControl fullWidth> | ||
<InputLabel id="cev-query-interface">Query Interface</InputLabel> | ||
<Select | ||
labelId="cev-query-interface" | ||
variant="outlined" | ||
label="Query Interface" | ||
className="cev-field" | ||
value={vdbe.interface} | ||
onChange={(event) => | ||
setVdbe({ ...vdbe, interface: event.target.value }) | ||
} | ||
> | ||
<MenuItem value="common">Common SQL</MenuItem> | ||
<MenuItem value="postgresql">PostgreSQL SQL</MenuItem> | ||
<MenuItem value="athena">Athena SQL</MenuItem> | ||
</Select> | ||
</FormControl> | ||
</div> | ||
); | ||
} | ||
|
||
function getEmptyVdbe() { | ||
return { | ||
name: null, | ||
max_staleness_ms: null, | ||
p90_latency_slo_ms: null, | ||
queryInterface: "postgresql", | ||
tables: [], | ||
}; | ||
} | ||
|
||
function CreateEditVdbeForm({ isEdit, currentVdbe }) { | ||
const [vdbe, setVdbe] = useState( | ||
currentVdbe != null ? currentVdbe : getEmptyVdbe(), | ||
); | ||
|
||
return ( | ||
<InsetPanel className="create-edit-vdbe-form"> | ||
<h2> | ||
{isEdit ? ( | ||
<EditRoundedIcon style={{ marginRight: "10px" }} /> | ||
) : ( | ||
<AddCircleOutlineIcon style={{ marginRight: "10px" }} /> | ||
)} | ||
{isEdit ? "Edit VDBE" : "Create VDBE"} | ||
</h2> | ||
<div className="cev-form-body"> | ||
<CreateEditFormFields vdbe={vdbe} setVdbe={setVdbe} /> | ||
<div className="cev-preview"> | ||
<VdbeView vdbe={vdbe} highlight={{}} editable={false} /> | ||
</div> | ||
</div> | ||
<div className="cev-buttons"> | ||
<Button variant="outlined">Cancel</Button> | ||
<Button | ||
variant="contained" | ||
startIcon={<CheckCircleOutlineRoundedIcon />} | ||
> | ||
{isEdit ? "Save" : "Create"} | ||
</Button> | ||
</div> | ||
</InsetPanel> | ||
); | ||
} | ||
|
||
export default CreateEditVdbeForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import "./styles/InsetPanel.css"; | ||
|
||
function InsetPanel({ children, className }) { | ||
return <div className={`inset-panel-wrap ${className}`}>{children}</div>; | ||
} | ||
|
||
export default InsetPanel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.create-edit-vdbe-form { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.create-edit-vdbe-form h2 { | ||
margin-bottom: 20px; | ||
} | ||
|
||
.cev-form-body { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
|
||
.cev-form-fields { | ||
display: flex; | ||
flex-direction: column; | ||
flex-grow: 3; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.cev-form-fields .cev-field { | ||
margin: 0 0 15px 0; | ||
} | ||
|
||
.cev-preview { | ||
flex-grow: 2; | ||
display: flex; | ||
justify-content: center; | ||
margin-top: -20px; | ||
} | ||
|
||
.cev-buttons { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: flex-end; | ||
} | ||
|
||
.cev-buttons button { | ||
margin-left: 20px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.inset-panel-wrap { | ||
display: flex; | ||
flex-direction: column; | ||
background-color: #f7f8f8; | ||
border-radius: 19px; | ||
padding: 29px; | ||
margin-bottom: 19px; | ||
} | ||
|
||
.inset-panel-wrap h2 { | ||
display: flex; | ||
align-items: center; | ||
font-size: 1.5em; | ||
margin: 0 0 5px 0; | ||
} |