mirror of
https://github.com/ANL-CEEESA/UnitCommitment.jl.git
synced 2025-12-07 16:58:51 -06:00
web: Update nullable number handling
This commit is contained in:
@@ -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");
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user