web: Update nullable number handling

This commit is contained in:
2025-06-27 11:37:50 -05:00
parent fff70cce67
commit 53489c1638
11 changed files with 84 additions and 44 deletions

View File

@@ -13,7 +13,6 @@ import "tabulator-tables/dist/css/tabulator.min.css";
import "../Common/Forms/Tables.css";
import { useState } from "react";
import Footer from "./Footer";
import { validate } from "../../core/Data/validate";
import { offerDownload } from "../Common/io";
import { preprocess } from "../../core/Operations/preprocessing";
import Toast from "../Common/Forms/Toast";
@@ -68,19 +67,14 @@ const CaseBuilder = () => {
setAndSaveScenario(newScenario);
};
const onLoad = (scenario: UnitCommitmentScenario) => {
const preprocessed = preprocess(
scenario,
) as unknown as UnitCommitmentScenario;
// Validate and assign default values
if (!validate(preprocessed)) {
setToastMessage("Error loading JSON file");
console.error(validate.errors);
const onLoad = (data: any) => {
const json = JSON.parse(data);
const [scenario, err] = preprocess(json);
if (err) {
setToastMessage(err.message);
return;
}
setAndSaveScenario(preprocessed);
setAndSaveScenario(scenario!);
setToastMessage("Data loaded successfully");
};

View File

@@ -22,8 +22,7 @@ function Header(props: HeaderProps) {
function onLoad() {
fileElem.current!.showFilePicker((data: any) => {
const scenario = JSON.parse(data) as UnitCommitmentScenario;
props.onLoad(scenario);
props.onLoad(data);
});
}

View File

@@ -51,13 +51,13 @@ export const ThermalUnitsColumnSpec: ColumnSpec[] = [
title: "Production cost curve (MW)",
type: "number[N]",
length: 10,
width: 75,
width: 80,
},
{
title: "Production cost curve ($)",
type: "number[N]",
length: 10,
width: 75,
width: 80,
},
{
title: "Startup costs ($)",
@@ -83,22 +83,22 @@ export const ThermalUnitsColumnSpec: ColumnSpec[] = [
},
{
title: "Ramp up limit (MW)",
type: "number",
type: "number?",
width: 100,
},
{
title: "Ramp down limit (MW)",
type: "number",
type: "number?",
width: 100,
},
{
title: "Startup limit (MW)",
type: "number",
type: "number?",
width: 80,
},
{
title: "Shutdown limit (MW)",
type: "number",
type: "number?",
width: 100,
},
{

View File

@@ -55,12 +55,12 @@ export const TransmissionLinesColumnSpec: ColumnSpec[] = [
},
{
title: "Normal flow limit (MW)",
type: "number",
type: "number?",
width: 60,
},
{
title: "Emergency flow limit (MW)",
type: "number",
type: "number?",
width: 60,
},
{