feat: Substitute the Backend URL dynamically

This commit is contained in:
Alexander Polynomdivision 2018-10-12 17:34:32 +02:00
parent 45dc47f3b9
commit 30fda90a7b
7 changed files with 23 additions and 17 deletions

6
frontend/in.json Normal file
View File

@ -0,0 +1,6 @@
{
"backend_url": {
"prod": "https://latinise.me",
"dev": "https://192.168.178.100",
}
}

View File

@ -13,6 +13,7 @@
"@material-ui/core": "^1.5.1", "@material-ui/core": "^1.5.1",
"@material-ui/icons": "^2.0.3", "@material-ui/icons": "^2.0.3",
"js-levenshtein": "^1.1.4", "js-levenshtein": "^1.1.4",
"mustache": "^3.0.0",
"react": "^16.4.2", "react": "^16.4.2",
"react-dom": "^16.4.2", "react-dom": "^16.4.2",
"react-redux": "^5.0.7", "react-redux": "^5.0.7",
@ -26,6 +27,7 @@
"jest": "^23.6.0", "jest": "^23.6.0",
"parcel-bundler": "^1.9.7", "parcel-bundler": "^1.9.7",
"parcel-plugin-handlebars": "^0.4.4", "parcel-plugin-handlebars": "^0.4.4",
"parcel-plugin-in": "git+https://gitlab.com/Polynomdivision/parcel-plugin-in.git",
"ts-jest": "^23.1.4", "ts-jest": "^23.1.4",
"typescript": "^2.9.2", "typescript": "^2.9.2",
"uglify-js": "^3.4.9", "uglify-js": "^3.4.9",

View File

@ -17,7 +17,7 @@ import VocabPage from "../containers/VocabPage";
import Drawer from "../containers/Drawer"; import Drawer from "../containers/Drawer";
import { BACKEND_URL } from "../config"; import { BACKEND_URL } from "../config.in";
import { ILevel } from "../models/level"; import { ILevel } from "../models/level";
import { TopTen } from "../models/learner"; import { TopTen } from "../models/learner";

11
frontend/src/config.in Normal file
View File

@ -0,0 +1,11 @@
module.exports = {
// Maximum distance from the answer to be still considered correct
LEVENSHTEIN_MAX_DISTANCE: 2,
BACKEND_URL: "{{{backend_url}}}",
// How often a wrongly answered group will be readded to the review queue
MAX_ERROR_THRESHOLD: 2,
// After how many failed attempts should we help the user
REVIEW_HELP_MOD: 3
};

View File

@ -1,11 +0,0 @@
// Maximum distance from the answer to be still considered correct
export const LEVENSHTEIN_MAX_DISTANCE = 2;
// export const BACKEND_URL = "http://127.0.0.1";
export const BACKEND_URL = "https://192.168.178.100";
// How often a wrongly answered group will be readded to the review queue
export const MAX_ERROR_THRESHOLD = 2;
// After how many failed attempts should we help the user
export const REVIEW_HELP_MOD = 3;

View File

@ -10,7 +10,7 @@ import Snackbar from "@material-ui/core/Snackbar";
import { withRouter } from "react-router-dom"; import { withRouter } from "react-router-dom";
import { BACKEND_URL } from "../config"; import { BACKEND_URL } from "../config.in";
interface IProps { interface IProps {
history: any; history: any;

View File

@ -31,10 +31,8 @@ import { ReviewType, IReviewMetadata } from "../models/review";
import lev from "js-levenshtein"; import lev from "js-levenshtein";
import { import {
LEVENSHTEIN_MAX_DISTANCE, MAX_ERROR_THRESHOLD, LEVENSHTEIN_MAX_DISTANCE, MAX_ERROR_THRESHOLD,
REVIEW_HELP_MOD REVIEW_HELP_MOD, BACKEND_URL
} from "../config"; } from "../config.in";
import { BACKEND_URL } from "../config";
import { Queue } from "../utils/queue"; import { Queue } from "../utils/queue";