Changed OR char, and added environmental variabels for urls
This commit is contained in:
parent
f13b74a94f
commit
f6197fd142
3
.env.development
Normal file
3
.env.development
Normal file
@ -0,0 +1,3 @@
|
||||
VITE_FETCH_URL=http://localhost:8080/
|
||||
VITE_FETCH_PATH=simplify/table/
|
||||
VITE_FETCH_FULL=$VITE_FETCH_URL$VITE_FETCH_PATH
|
3
.env.production
Normal file
3
.env.production
Normal file
@ -0,0 +1,3 @@
|
||||
VITE_FETCH_URL=https://api.martials.no/
|
||||
VITE_FETCH_PATH=simplify-truths/do/simplify/table/
|
||||
VITE_FETCH_FULL=$VITE_FETCH_URL$VITE_FETCH_PATH
|
11
env.d.ts
vendored
Normal file
11
env.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_FETCH_URL: string,
|
||||
readonly VITE_FETCH_PATH: string,
|
||||
readonly VITE_FETCH_FULL: string,
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv
|
||||
}
|
8
package-lock.json
generated
8
package-lock.json
generated
@ -925,6 +925,14 @@
|
||||
"resolved": "https://registry.npmjs.org/@types/diff/-/diff-5.0.2.tgz",
|
||||
"integrity": "sha512-uw8eYMIReOwstQ0QKF0sICefSy8cNO/v7gOTiIy9SbwuHyEecJUm7qlgueOO5S1udZ5I/irVydHVwMchgzbKTg=="
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "18.15.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz",
|
||||
"integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "7.4.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
|
||||
|
@ -25,10 +25,6 @@ import { exportToExcel } from "./functions/export";
|
||||
import { Link } from "./components/link";
|
||||
import { isTouch } from "./functions/touch";
|
||||
|
||||
const endpoint = "https://api.martials.no/simplify-truths/do/simplify/table";
|
||||
const localhost = "http://localhost:8080/simplify/table";
|
||||
const useDev = true;
|
||||
|
||||
type Option = { name: string, value: "NONE" | "TRUE" | "FALSE" | "DEFAULT" | "TRUE_FIRST" | "FALSE_FIRST" };
|
||||
|
||||
// TODO move some code to new components
|
||||
@ -95,7 +91,7 @@ const TruthTablePage: Component = () => {
|
||||
let exp = getInputElement()?.value;
|
||||
|
||||
if (exp) {
|
||||
exp = exp.replaceAll("|", "/").trimEnd();
|
||||
exp = exp.replaceAll("|", ":").trimEnd();
|
||||
|
||||
history.pushState(null, "", `?exp=${ encodeURIComponent(exp) }&simplify=${ simplifyEnabled() }&
|
||||
hide=${ hideValues().value }&sort=${ sortValues().value }&hideIntermediate=${ hideIntermediates() }`);
|
||||
@ -110,8 +106,8 @@ hide=${ hideValues().value }&sort=${ sortValues().value }&hideIntermediate=${ hi
|
||||
if (exp !== "") {
|
||||
setError(null);
|
||||
setIsLoaded(false);
|
||||
|
||||
fetch(`${ useDev ? localhost : endpoint }/${ encodeURIComponent(exp) }?
|
||||
// TODO add button on DEV to switch between local and remote
|
||||
fetch(`${ import.meta.env.VITE_FETCH_FULL }${ encodeURIComponent(exp) }?
|
||||
simplify=${ simplifyEnabled() }&hide=${ hideValues().value }&sort=${ sortValues().value }&caseSensitive=false&
|
||||
hideIntermediate=${ hideIntermediates() }`)
|
||||
.then(res => res.json())
|
||||
|
Loading…
x
Reference in New Issue
Block a user