mirror of
https://github.com/ANL-CEEESA/UnitCommitment.jl.git
synced 2025-12-08 01:08:50 -06:00
web: use defaults; calculate table height
This commit is contained in:
@@ -152,6 +152,12 @@ interface BusesTableProps {
|
||||
onBusRenamed: (oldName: string, newName: string) => ValidationError | null;
|
||||
}
|
||||
|
||||
function computeBusesTableHeight(scenario: UnitCommitmentScenario): string {
|
||||
const numBuses = Object.keys(scenario.Buses).length;
|
||||
const height = 65 + Math.min(numBuses, 15) * 28;
|
||||
return `${height}px`;
|
||||
}
|
||||
|
||||
function BusesTable(props: BusesTableProps) {
|
||||
const tableContainerRef = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
@@ -188,7 +194,7 @@ function BusesTable(props: BusesTableProps) {
|
||||
layout: "fitColumns",
|
||||
data: generateBusesTableData(scenario),
|
||||
columns: generateBusesTableColumns(scenario),
|
||||
maxHeight: "500px",
|
||||
height: computeBusesTableHeight(scenario),
|
||||
});
|
||||
table.on("cellEdited", (cell) => {
|
||||
onCellEdited(cell);
|
||||
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
changeTimeHorizon,
|
||||
changeTimeStep,
|
||||
} from "../../core/Operations/parameterOperations";
|
||||
import { preprocess } from "../../core/Operations/preprocessing";
|
||||
|
||||
const CaseBuilder = () => {
|
||||
const [scenario, setScenario] = useState(TEST_SCENARIO);
|
||||
@@ -87,11 +88,16 @@ const CaseBuilder = () => {
|
||||
};
|
||||
|
||||
const onLoad = (scenario: UnitCommitmentScenario) => {
|
||||
if (!validate(scenario)) {
|
||||
const preprocessed = preprocess(
|
||||
scenario,
|
||||
) as unknown as UnitCommitmentScenario;
|
||||
|
||||
// Validate and assign default values
|
||||
if (!validate(preprocessed)) {
|
||||
console.error(validate.errors);
|
||||
return;
|
||||
}
|
||||
setScenario(scenario);
|
||||
setScenario(preprocessed);
|
||||
};
|
||||
|
||||
const onParameterChanged = (key: string, value: string) => {
|
||||
|
||||
Reference in New Issue
Block a user