Implement distribution management API and UI forms; add distribution model and tests
This commit is contained in:
50
templates/ParameterInput.html
Normal file
50
templates/ParameterInput.html
Normal file
@@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Process Parameters Input</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Enter Parameters for a Scenario</h1>
|
||||
<form id="parameter-form">
|
||||
<label
|
||||
>Scenario ID:
|
||||
<input
|
||||
type="number"
|
||||
name="scenario_id"
|
||||
id="scenario_id"
|
||||
required /></label
|
||||
><br />
|
||||
<label>Name: <input type="text" name="name" id="name" required /></label
|
||||
><br />
|
||||
<label
|
||||
>Value:
|
||||
<input
|
||||
type="number"
|
||||
name="value"
|
||||
id="value"
|
||||
step="any"
|
||||
required /></label
|
||||
><br />
|
||||
<button type="submit">Add Parameter</button>
|
||||
</form>
|
||||
<div id="result"></div>
|
||||
<script>
|
||||
document
|
||||
.getElementById("parameter-form")
|
||||
.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
const scenario_id = document.getElementById("scenario_id").value;
|
||||
const name = document.getElementById("name").value;
|
||||
const value = parseFloat(document.getElementById("value").value);
|
||||
const resp = await fetch("/api/parameters/", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ scenario_id, name, value }),
|
||||
});
|
||||
const data = await resp.json();
|
||||
document.getElementById("result").innerText = JSON.stringify(data);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user