adding unit test for rendering site and fixing LP export issue #46
+9
-4
@@ -2,7 +2,7 @@
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { Box, Button, Output } from "./modules";
|
||||
import { calculate_click, downloadLP, import_click } from "./scripts"
|
||||
import { calculate_clickMaximize, calculate_clickMinimize, downloadLP, import_click } from "./scripts"
|
||||
import text from "./lang"
|
||||
|
||||
export default function Home() {
|
||||
@@ -19,7 +19,8 @@ export default function Home() {
|
||||
const tr_boxVarsDesc = text(language, "boxVarsDesc");
|
||||
const tr_boxOut = text(language, "boxOut");
|
||||
const tr_boxExportLP = text(language, "boxExportLP");
|
||||
const tr_calc = text(language, "buttonCalc");
|
||||
const tr_calc_max = text(language, "maximize");
|
||||
const tr_calc_min = text(language, "minimize");
|
||||
|
||||
const handleLanguageChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
setLanguage(event.target.value);
|
||||
@@ -59,9 +60,13 @@ export default function Home() {
|
||||
placeholder={tr_boxVarsDesc}
|
||||
id="vars" />
|
||||
<Button
|
||||
title={tr_calc}
|
||||
title={tr_calc_max}
|
||||
className={"button_green"}
|
||||
onClickFunc={calculate_click} />
|
||||
onClickFunc={calculate_clickMaximize} />
|
||||
<Button
|
||||
title={tr_calc_min}
|
||||
className={"button_green"}
|
||||
onClickFunc={calculate_clickMinimize} />
|
||||
<Button
|
||||
title={tr_boxExportLP}
|
||||
className={"button"}
|
||||
|
||||
+12
-2
@@ -128,7 +128,7 @@ function isInputFilled(obj: string | undefined, subj: string | undefined, bounds
|
||||
return true;
|
||||
}
|
||||
|
||||
export function calculate_click() {
|
||||
function calculate_click(maximize: boolean) {
|
||||
customLogClear();
|
||||
const timer = walltimeStart();
|
||||
customLog("calculating");
|
||||
@@ -214,7 +214,11 @@ export function calculate_click() {
|
||||
// catch error: variables field has invalid characters
|
||||
if (!isInputValidRegex(objective, subject, bounds, variables)) return;
|
||||
|
||||
let wholeText: string = "Maximize\n obj: " + objective
|
||||
// fetch operator
|
||||
let operator = "Minimize";
|
||||
if (maximize) operator = "Maximize";
|
||||
|
||||
let wholeText: string = operator + "\n obj: " + objective
|
||||
+ "\nSubject To \n" + subject
|
||||
+ "\nBounds \n" + bounds
|
||||
+ "\nGenerals \n" + variables
|
||||
@@ -298,7 +302,13 @@ function downloadLPFormatting(objective: any, subject: any, bounds: any) {
|
||||
return lpFormat;
|
||||
}
|
||||
|
||||
export function calculate_clickMaximize() {
|
||||
calculate_click(true);
|
||||
}
|
||||
|
||||
export function calculate_clickMinimize() {
|
||||
calculate_click(false);
|
||||
}
|
||||
|
||||
|
||||
function downloadProblemDownload(content: string) {
|
||||
|
||||
Reference in New Issue
Block a user