Implement distribution management API and UI forms; add distribution model and tests

This commit is contained in:
2025-10-20 18:51:23 +02:00
parent 4533a4c166
commit 0b19a93e0d
10 changed files with 229 additions and 2 deletions

25
templates/Dashboard.html Normal file
View File

@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CalMiner Dashboard</title>
</head>
<body>
<h1>Simulation Results Dashboard</h1>
<div id="report-summary"></div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
// TODO: fetch summary report and render charts
async function loadReport() {
const response = await fetch('/api/reporting/summary', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify([])
});
const data = await response.json();
document.getElementById('report-summary').innerText = JSON.stringify(data);
}
loadReport();
</script>
</body>
</html>

View 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>

View File

@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Scenario Management</title>
</head>
<body>
<h1>Create a New Scenario</h1>
<form id="scenario-form">
<label>Name: <input type="text" name="name" id="name" required /></label
><br />
<label
>Description:
<input type="text" name="description" id="description" /></label
><br />
<button type="submit">Create Scenario</button>
</form>
<div id="result"></div>
<script>
document
.getElementById("scenario-form")
.addEventListener("submit", async (e) => {
e.preventDefault();
const name = document.getElementById("name").value;
const description = document.getElementById("description").value;
const resp = await fetch("/api/scenarios/", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ name, description }),
});
const data = await resp.json();
document.getElementById("result").innerText = JSON.stringify(data);
});
</script>
</body>
</html>