From 33b056d3974a051e6dd846212c0aa7dfb926b783 Mon Sep 17 00:00:00 2001 From: Konstantin Schulz Date: Fri, 27 Mar 2020 19:07:46 +0100 Subject: [PATCH] context size for KWIC view is now configurable --- .gitlab-ci.yml | 2 +- Dockerfile | 1 + docker-compose.yml | 3 +- package.json | 2 +- src/app/corpus.service.spec.ts | 19 +- .../exercise-parameters.page.html | 171 ++++++++++-------- .../exercise-parameters.page.ts | 7 +- src/app/semantics/semantics.page.ts | 11 +- src/assets/i18n/de.json | 2 + src/assets/i18n/en.json | 2 + 10 files changed, 120 insertions(+), 100 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d0efc9e..062ef7e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ coverage: stage: test script: - docker-compose build - - docker-compose run mc_frontend npm run test + - docker-compose run --entrypoint="npm run test" mc_frontend coverage: '/Statements.*?(\d+(?:\.\d+)?)%/' tags: - node diff --git a/Dockerfile b/Dockerfile index 428de62..467125a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,7 @@ RUN ng analytics off RUN npm install COPY . . +COPY ./config.xml ./www/config.xml # workaround to fix the missing binding issue for node-sass RUN npm rebuild node-sass diff --git a/docker-compose.yml b/docker-compose.yml index d84ece0..ff24eff 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: build: context: . dockerfile: Dockerfile - entrypoint: ng build --prod + entrypoint: ng build --prod app environment: - CHROME_BIN=google-chrome restart: always @@ -25,7 +25,6 @@ services: volumes: - $PWD/www:/usr/share/nginx/html - ./nginx.conf:/etc/nginx/nginx.conf - - ./config.xml:/usr/share/nginx/html/config.xml depends_on: - mc_frontend networks: diff --git a/package.json b/package.json index d12f4d5..ba2b3e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mc_frontend", - "version": "1.7.3", + "version": "1.7.4", "author": "Ionic Framework", "homepage": "https://ionicframework.com/", "scripts": { diff --git a/src/app/corpus.service.spec.ts b/src/app/corpus.service.spec.ts index 4daddf4..53cacb8 100644 --- a/src/app/corpus.service.spec.ts +++ b/src/app/corpus.service.spec.ts @@ -271,15 +271,16 @@ describe('CorpusService', () => { })); it('should initialize the update information', (done) => { - corpusService.storage.set(configMC.localStorageKeyUpdateInfo, null).then(() => { - corpusService.initUpdateInfo().then(() => { - corpusService.storage.get(configMC.localStorageKeyUpdateInfo).then((jsonString: string) => { - expect(jsonString).toBeTruthy(); - const setSpy: Spy = spyOn(corpusService.storage, 'set').and.returnValue(Promise.resolve()); - corpusService.initUpdateInfo().then(() => { - expect(setSpy).toHaveBeenCalledTimes(0); - done(); - }); + const updateInfoSpy: Spy = spyOn(corpusService.storage, 'get').withArgs(configMC.localStorageKeyUpdateInfo); + updateInfoSpy.and.returnValue(Promise.resolve('')); + corpusService.initUpdateInfo().then(() => { + updateInfoSpy.and.callThrough(); + corpusService.storage.get(configMC.localStorageKeyUpdateInfo).then((jsonString: string) => { + expect(jsonString).toBeTruthy(); + const setSpy: Spy = spyOn(corpusService.storage, 'set').and.returnValue(Promise.resolve()); + corpusService.initUpdateInfo().then(() => { + expect(setSpy).toHaveBeenCalledTimes(0); + done(); }); }); }); diff --git a/src/app/exercise-parameters/exercise-parameters.page.html b/src/app/exercise-parameters/exercise-parameters.page.html index b91977d..4c13f21 100644 --- a/src/app/exercise-parameters/exercise-parameters.page.html +++ b/src/app/exercise-parameters/exercise-parameters.page.html @@ -89,85 +89,102 @@ - - - - - - - - - -
-

- {{ 'INSTRUCTIONS' | translate }} - + {{ 'EXERCISE_FEEDBACK' | translate }}

-
-
-
- - - - - - - - - - - {{ 'EXERCISE_FEEDBACK' | translate }}: - - - - - - - - - - - - - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + + +
+

+ {{ 'INSTRUCTIONS' | translate }} + + {{ 'EXERCISE_FEEDBACK' | translate }}

+
+
+
+ + + + + + + + + + + {{ 'EXERCISE_FEEDBACK' | translate }}: + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
{{ 'PREVIEW' | translate }} diff --git a/src/app/exercise-parameters/exercise-parameters.page.ts b/src/app/exercise-parameters/exercise-parameters.page.ts index 8bf323b..9e5fdd3 100644 --- a/src/app/exercise-parameters/exercise-parameters.page.ts +++ b/src/app/exercise-parameters/exercise-parameters.page.ts @@ -8,7 +8,7 @@ import { } from '../models/enum'; import {AnnisResponse} from 'src/app/models/annisResponse'; import {NavController, ToastController} from '@ionic/angular'; -import {HttpClient, HttpErrorResponse} from '@angular/common/http'; +import {HttpClient} from '@angular/common/http'; import {Component, OnInit} from '@angular/core'; import {TranslateService} from '@ngx-translate/core'; import {ExerciseService} from 'src/app/exercise.service'; @@ -31,12 +31,13 @@ import configMC from '../../configMC'; export class ExerciseParametersPage implements OnInit { public ExerciseType = ExerciseType; ExerciseTypeTranslation = ExerciseTypeTranslation; + public leftContextSize = 5; public Math = Math; ObjectKeys = Object.keys; Phenomenon = Phenomenon; PhenomenonTranslation = PhenomenonTranslation; + public rightContextSize = 5; showFeedback = false; - textTooLongString: string; constructor(public navCtrl: NavController, public toastCtrl: ToastController, @@ -142,6 +143,8 @@ export class ExerciseParametersPage implements OnInit { getKwicExercise(formData: FormData): Promise { return new Promise((resolve, reject) => { + formData.append('ctx_left', (Math.max(Math.round(this.leftContextSize), 1)).toString()); + formData.append('ctx_right', (Math.max(Math.round(this.rightContextSize), 1)).toString()); const kwicUrl: string = configMC.backendBaseUrl + configMC.backendApiKwicPath; this.helperService.makePostRequest(this.http, this.toastCtrl, kwicUrl, formData).then((svgString: string) => { this.exerciseService.kwicGraphs = svgString; diff --git a/src/app/semantics/semantics.page.ts b/src/app/semantics/semantics.page.ts index 1463c8d..3e9a194 100644 --- a/src/app/semantics/semantics.page.ts +++ b/src/app/semantics/semantics.page.ts @@ -37,14 +37,9 @@ export class SemanticsPage implements OnInit { return new Promise(resolve => { this.activatedRoute.queryParams.subscribe((params: any) => { if (Object.keys(params).length) { - const paramSearchRegex: string = params.searchRegex; - this.searchRegex = paramSearchRegex ? paramSearchRegex : this.searchRegex; - const paramMinCount: string = params.minCount; - this.minCount = paramMinCount ? +paramMinCount : this.minCount; - const paramNearestNeighborCount: string = params.nearestNeighborCount; - this.nearestNeighborCount = paramNearestNeighborCount ? +paramNearestNeighborCount : this.nearestNeighborCount; - const paramHighlightRegex: string = params.highlightRegex; - this.highlightRegex = paramHighlightRegex ? paramHighlightRegex : this.highlightRegex; + Object.keys(params).forEach((key: string) => { + this[key] = typeof this[key] === 'number' ? +params[key] : params[key]; + }); // dirty hack to get the loading spinner displayed correctly setTimeout(this.updateVectorNetwork.bind(this), 500); } diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json index 08e975e..ea465e1 100644 --- a/src/assets/i18n/de.json +++ b/src/assets/i18n/de.json @@ -226,6 +226,7 @@ "INVALID_TEXT_RANGE": "Ungültige Textauswahl", "KWIC": "Beispielkontexte", "LANGUAGE_CHANGE": "Sprache wählen", + "LEFT_CONTEXT_SIZE": "Kontextwörter links", "LINK_COPIED": "Link kopiert", "MACHINA_CALLIDA": "Machina Callida", "MACHINA_CALLIDA_BACKEND": "Machina Callida Backend", @@ -278,6 +279,7 @@ "RESEARCH_STUDIES_3": "im Lateinunterricht der älteren Fortgeschrittenen (Oberstufe) ebenfalls die Studien zu Ovid und Cicero", "RESEARCH_STUDIES_4": "eine Testung der computergestützten Übungsformate (MC) durch Studierende der Klassischen Philologie (Dez. 2018)", "RESULT": "Ergebnis", + "RIGHT_CONTEXT_SIZE": "Kontextwörter rechts", "SEARCH": "Suche", "SEARCH_REGEX_MISSING": "Bitte Suchanfrage eingeben...", "SEMANTICS": "Semantik", diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index b3b1137..40370ca 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -226,6 +226,7 @@ "INVALID_TEXT_RANGE": "Invalid text range", "KWIC": "Keyword in context", "LANGUAGE_CHANGE": "Choose language", + "LEFT_CONTEXT_SIZE": "Context words left", "LINK_COPIED": "Link copied", "MACHINA_CALLIDA": "Machina Callida", "MACHINA_CALLIDA_BACKEND": "Machina Callida Backend", @@ -278,6 +279,7 @@ "RESEARCH_STUDIES_3": "in the Latin classes of the older advanced students (upper level) also the studies to Ovid and Cicero", "RESEARCH_STUDIES_4": "a test of the computer-aided exercise formats (MC) by students of classical philology (Dec. 2018)", "RESULT": "Result", + "RIGHT_CONTEXT_SIZE": "Context words right", "SEARCH": "Search", "SEARCH_REGEX_MISSING": "Please provide search query...", "SEMANTICS": "Semantics", -- GitLab