Commit 124a0db5 authored by Konstantin Schulz's avatar Konstantin Schulz
Browse files

browser page refresh now works for Nginx and "ng serve"

parent c458fdb4
......@@ -23,6 +23,7 @@ RUN npm i -g @angular/cli
RUN npm install
# workaround to fix the missing binding issue for node-sass
RUN npm rebuild node-sass
# TODO: for some reason, this does not persist?!?!??!
RUN ionic cordova build browser --prod --release --max-old-space-size=4096
# TODO: for some reason, this does not work?!?!??!
COPY platforms/browser/config.xml www/config.xml
# TODO: cordova uses a fixed path starting at root (i.e. korpling.org/ instead of korpling.org/mc/). How do we deal with this to give it access to the config.xml file? Change the production server's NGINX config?
#COPY platforms/browser/config.xml www/config.xml
......@@ -2,11 +2,6 @@
1. Install Docker (https://docs.docker.com/v17.12/install/) and Docker-Compose (https://docs.docker.com/compose/install/)
2. Clone the repo:
#####################################
# TODO: CHANGE THE REMOTE URI #######################
#####################################
`git clone https://scm.cms.hu-berlin.de/callidus/mc_frontend.git`
3. Move to the newly created folder:
`cd mc_frontend`
......@@ -14,6 +9,10 @@
Make sure to assign at least 4GB RAM (Memory) to the Docker container, otherwise the build will fail.
5. Run `docker-compose up -d` and enjoy!
----------------------------------------------------------------
##### Access to the Docker container
To build the application for production environments, use: `ionic cordova build browser --prod --release --max-old-space-size=4096` and serve the content of the `www/` folder, e.g. with Nginx.
----------------------------------------------------------------
##### Access to the Docker container
Use `docker-compose down` to stop and remove the currently running containers.
......@@ -25,5 +24,7 @@ To snapshot a running container, use `docker commit CONTAINER_ID`. It returns a
## Configuration
### Backend URL
To change the URL for the backend, use the `ionic.config.json` file (proxies > proxyUrl). By default, the system assumes that backend and frontend are installed on the same machine.
### Frontend URL
Use the `--host 0.0.0.0 --disable-host-check` flag for `ng serve` if you want to use it in a production environment with an Nginx server using proxy_pass.
### Other
For all other kinds of configuration, use `src/assets/config.json`.
......@@ -35,6 +35,7 @@ http {
root /home/mc/mc_frontend/www;
index index.html index.htm;
rewrite ^(.*)mc-service(.*)^ http://localhost:5000$2 last;
try_files $uri $uri/ /index.html =404;
}
location /mc-service/ {
......
{
"name": "mc_frontend",
"version": "0.6.7",
"version": "0.6.8",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -763,9 +763,9 @@
},
"dependencies": {
"typescript": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.3.3.tgz",
"integrity": "sha512-Y21Xqe54TBVp+VDSNbuDYdGw0BpoR/Q6wo/+35M8PAU0vipahnyduJWirxxdxjsAkS7hue53x2zp8gz7F05u0A==",
"version": "3.3.4000",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.3.4000.tgz",
"integrity": "sha512-jjOcCZvpkl2+z7JFn0yBOoLQyLoIkNZAs/fYJkUG6VKy6zLPHJGfQJYFHzibB6GJaF/8QrcECtlQ5cpvRHSMEA==",
"dev": true
}
}
......
{
"name": "mc_frontend",
"version": "0.6.7",
"version": "0.6.8",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
......@@ -48,7 +48,7 @@
"@angular/compiler": "~7.2.2",
"@angular/compiler-cli": "^7.2.10",
"@angular/language-service": "~7.2.2",
"@ionic/angular-toolkit": "~1.3.0",
"@ionic/angular-toolkit": "^1.3.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~10.12.0",
......
......@@ -26,6 +26,9 @@ export class CorpusService {
public toastCtrl: ToastController) {
this.translate.get('ERROR_CORPORA_UNAVAILABLE').subscribe(value => this.corporaUnavailableString = value);
this.checkForUpdates().then();
if (HelperService.mostRecentSetup) {
this.restoreLastCorpus();
}
}
async checkForUpdates() {
......@@ -55,7 +58,7 @@ export class CorpusService {
this.loadCorporaFromLocalStorage();
resolve();
}
}, async (error: HttpErrorResponse) => {
}, async (error: HttpErrorResponse) => {
this.loadCorporaFromLocalStorage();
const toast = await this.toastCtrl.create({
message: this.corporaUnavailableString,
......@@ -122,4 +125,10 @@ export class CorpusService {
});
});
}
restoreLastCorpus() {
this.currentCorpus = HelperService.mostRecentSetup.currentCorpus;
this.currentTextRange = HelperService.mostRecentSetup.currentTextRange;
this.isTextRangeCorrect = true;
}
}
......@@ -128,6 +128,9 @@ export class ExerciseService {
this.translateService.get(InstructionsTranslation[ExerciseType.cloze]).subscribe((value) => {
this.exercise.instructionsTranslation = value;
});
if (HelperService.mostRecentSetup) {
this.restoreLastURN();
}
// map the different phenomena to their respective Enum for processing and display/translation
this.phenomenonMap[Phenomenon.partOfSpeech] = [{}, PartOfSpeechTranslation, {}];
this.phenomenonMap[Phenomenon.dependency] = [{}, DependencyTranslation, {}];
......@@ -237,4 +240,15 @@ export class ExerciseService {
this.annisResponse = ar;
this.currentText = ar.graph.nodes.map(x => x.annis_tok).join(' ');
}
restoreLastURN() {
return new Promise((resolve, reject) => {
this.currentUrn = HelperService.mostRecentSetup.currentUrn;
this.getText().then(() => {
resolve();
}, () => {
reject();
});
});
}
}
......@@ -54,11 +54,8 @@ export class HomePage {
}
restoreLastSetup() {
this.exerciseService.currentUrn = HelperService.mostRecentSetup.currentUrn;
this.corpusService.currentCorpus = HelperService.mostRecentSetup.currentCorpus;
this.corpusService.currentTextRange = HelperService.mostRecentSetup.currentTextRange;
this.corpusService.isTextRangeCorrect = true;
this.exerciseService.getText().then(() => {
this.corpusService.restoreLastCorpus();
this.exerciseService.restoreLastURN().then(() => {
if (HelperService.isVocabularyCheck) {
this.navCtrl.navigateForward('/vocabulary-check').then();
} else {
......
......@@ -7,24 +7,24 @@ import {HelperService} from 'src/app/helper.service';
import {TranslateService} from '@ngx-translate/core';
@Component({
selector: 'app-show-text',
templateUrl: './show-text.page.html',
styleUrls: ['./show-text.page.scss'],
selector: 'app-show-text',
templateUrl: './show-text.page.html',
styleUrls: ['./show-text.page.scss'],
})
export class ShowTextPage {
HelperService = HelperService;
public ObjectKeys = Object.keys;
public highlightOOV = false;
HelperService = HelperService;
public ObjectKeys = Object.keys;
public highlightOOV = false;
constructor(public navCtrl: NavController,
public corpusService: CorpusService,
public exerciseService: ExerciseService,
public toastCtrl: ToastController,
public translateService: TranslateService,
public vocService: VocabularyService) {
}
constructor(public navCtrl: NavController,
public corpusService: CorpusService,
public exerciseService: ExerciseService,
public toastCtrl: ToastController,
public translateService: TranslateService,
public vocService: VocabularyService) {
}
goToExerciseParametersPage() {
this.navCtrl.navigateForward('exercise-parameters').then();
}
goToExerciseParametersPage() {
this.navCtrl.navigateForward('exercise-parameters').then();
}
}
......@@ -5,7 +5,7 @@
<meta charset="utf-8" />
<title>Ionic App</title>
<base href="/" />
<base href="./" />
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment