Commit ae075c0a authored by Konstantin Schulz's avatar Konstantin Schulz

simplified navigation in the helper service

parent 14ad6a23
Pipeline #12422 passed with stages
in 2 minutes and 29 seconds
......@@ -28,7 +28,7 @@
</ion-row>
<ion-row>
<ion-col>
<a (click)="helperService.goToExerciseListPage(navCtrl).then(closeMenu.bind(this))">
<a (click)="helperService.goToPage(navCtrl, configMC.pageUrlExerciseList).then(closeMenu.bind(this))">
{{ 'EXERCISE_LIST' | translate }}
</a>
</ion-col>
......@@ -42,7 +42,7 @@
</ion-row>
<ion-row>
<ion-col>
<a (click)="helperService.goToSemanticsPage(navCtrl).then(closeMenu.bind(this))">
<a (click)="helperService.goToPage(navCtrl, configMC.pageUrlSemantics).then(closeMenu.bind(this))">
{{ 'SEMANTICS' | translate }}
</a>
</ion-col>
......@@ -54,35 +54,35 @@
</ion-title>
<ion-row>
<ion-col>
<a (click)="helperService.goToInfoPage(navCtrl).then(closeMenu.bind(this))">
<a (click)="helperService.goToPage(navCtrl, configMC.pageUrlInfo).then(closeMenu.bind(this))">
{{ 'ABOUT' | translate }}
</a>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<a (click)="helperService.goToDocSoftwarePage(navCtrl).then(closeMenu.bind(this))">
<a (click)="helperService.goToPage(navCtrl, configMC.pageUrlDocSoftware).then(closeMenu.bind(this))">
{{ 'DOC_SOFTWARE' | translate }}
</a>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<a (click)="helperService.goToDocExercisesPage(navCtrl).then(closeMenu.bind(this))">
<a (click)="helperService.goToPage(navCtrl, configMC.pageUrlDocExercises).then(closeMenu.bind(this))">
{{ 'DOC_EXERCISES' | translate }}
</a>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<a (click)="helperService.goToDocVocUnitPage(navCtrl).then(closeMenu.bind(this))">
<a (click)="helperService.goToPage(navCtrl, configMC.pageUrlDocVocUnit).then(closeMenu.bind(this))">
{{ 'DOC_VOC_UNIT' | translate }}
</a>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<a (click)="helperService.goToSourcesPage(navCtrl).then(closeMenu.bind(this))">
<a (click)="helperService.goToPage(navCtrl, configMC.pageUrlSources).then(closeMenu.bind(this))">
{{ 'SOURCES' | translate }}
</a>
</ion-col>
......
......@@ -41,7 +41,7 @@ describe('AuthorDetailPage', () => {
it('should show possible references', () => {
const currentCorpusSpy: Spy = spyOn(authorDetailPage.corpusService, 'setCurrentCorpus');
const textRangeSpy: Spy = spyOn(authorDetailPage.helperService, 'goToTextRangePage').and.returnValue(Promise.resolve(true));
const textRangeSpy: Spy = spyOn(authorDetailPage.helperService, 'goToPage').and.returnValue(Promise.resolve(true));
authorDetailPage.showPossibleReferences({source_urn: ''});
expect(currentCorpusSpy).toHaveBeenCalledTimes(1);
expect(textRangeSpy).toHaveBeenCalledTimes(1);
......
......@@ -5,6 +5,7 @@ import {TranslateService} from '@ngx-translate/core';
import {HelperService} from '../helper.service';
import {CorpusService} from 'src/app/corpus.service';
import {HttpClient} from '@angular/common/http';
import configMC from '../../configMC';
@Component({
selector: 'app-author-detail',
......@@ -22,6 +23,6 @@ export class AuthorDetailPage {
showPossibleReferences(corpus: CorpusMC) {
this.corpusService.setCurrentCorpus(corpus);
this.helperService.goToTextRangePage(this.navCtrl).then();
this.helperService.goToPage(this.navCtrl, configMC.pageUrlTextRange).then();
}
}
......@@ -75,7 +75,7 @@ describe('AuthorPage', () => {
it('should restore the last setup', (done) => {
const restoreSpy: Spy = spyOn(authorPage.corpusService, 'restoreLastCorpus').and.callFake(() => Promise.reject());
const showTextSpy: Spy = spyOn(authorPage.helperService, 'goToShowTextPage').and.returnValue(Promise.resolve(true));
const vocCheckSpy: Spy = spyOn(authorPage.helperService, 'goToVocabularyCheckPage').and.returnValue(Promise.resolve(true));
const vocCheckSpy: Spy = spyOn(authorPage.helperService, 'goToPage').and.returnValue(Promise.resolve(true));
authorPage.helperService.isVocabularyCheck = false;
authorPage.restoreLastSetup().then(() => {
}, () => {
......@@ -95,7 +95,7 @@ describe('AuthorPage', () => {
it('should show corpora', () => {
authorPage.helperService.applicationState.next(authorPage.helperService.deepCopy(MockMC.applicationState));
spyOn(authorPage.helperService, 'goToAuthorDetailPage').and.returnValue(Promise.resolve(true));
spyOn(authorPage.helperService, 'goToPage').and.returnValue(Promise.resolve(true));
const author: Author = new Author({name: '', corpora: []});
authorPage.showCorpora(author);
expect(authorPage.corpusService.currentAuthor).toBe(author);
......
......@@ -8,6 +8,7 @@ import {HelperService} from '../helper.service';
import {ExerciseService} from '../exercise.service';
import {ApplicationState} from '../models/applicationState';
import {take} from 'rxjs/operators';
import configMC from '../../configMC';
/**
* Generated class for the AuthorPage page.
......@@ -68,7 +69,7 @@ export class AuthorPage implements OnInit {
return new Promise<void>((resolve, reject) => {
this.corpusService.restoreLastCorpus().then(() => {
if (this.helperService.isVocabularyCheck) {
this.helperService.goToVocabularyCheckPage(this.navCtrl).then();
this.helperService.goToPage(this.navCtrl, configMC.pageUrlVocabularyCheck).then();
return resolve();
} else {
this.helperService.goToShowTextPage(this.navCtrl).then();
......@@ -85,7 +86,7 @@ export class AuthorPage implements OnInit {
this.helperService.applicationState.pipe(take(1)).subscribe((as: ApplicationState) => {
as.currentSetup.currentAuthor = author;
this.helperService.saveApplicationState(as).then();
this.helperService.goToAuthorDetailPage(this.navCtrl).then();
this.helperService.goToPage(this.navCtrl, configMC.pageUrlAuthorDetail).then();
});
}
......
......@@ -118,19 +118,19 @@
<ion-toolbar>
<ion-tabs>
<ion-tab-bar slot="bottom">
<ion-tab-button (click)="helperService.goToInfoPage(navCtrl)">
<ion-tab-button (click)="helperService.goToPage(navCtrl, configMC.pageUrlInfo)">
<ion-icon name="information-circle"></ion-icon>
<ion-label>{{ 'ABOUT' | translate }}</ion-label>
</ion-tab-button>
<ion-tab-button (click)="helperService.goToDocSoftwarePage(navCtrl)">
<ion-tab-button (click)="helperService.goToPage(navCtrl, configMC.pageUrlDocSoftware)">
<ion-icon name="code"></ion-icon>
<ion-label>{{ 'DOC_SOFTWARE' | translate}}</ion-label>
</ion-tab-button>
<ion-tab-button (click)="helperService.goToDocVocUnitPage(navCtrl)">
<ion-tab-button (click)="helperService.goToPage(navCtrl, configMC.pageUrlDocVocUnit)">
<ion-icon name="school"></ion-icon>
<ion-label>{{'DOC_VOC_UNIT' | translate}}</ion-label>
</ion-tab-button>
<ion-tab-button (click)="helperService.goToImprintPage(navCtrl)">
<ion-tab-button (click)="helperService.goToPage(navCtrl, configMC.pageUrlImprint)">
<ion-icon name="today"></ion-icon>
<ion-label>{{ 'IMPRINT' | translate }}</ion-label>
</ion-tab-button>
......
......@@ -4,6 +4,7 @@ import {NavController} from '@ionic/angular';
import {HttpClient} from '@angular/common/http';
import {TranslateService} from '@ngx-translate/core';
import {ExerciseDocumentation} from 'src/app/models/exerciseDocumentation';
import configMC from '../../configMC';
@Component({
selector: 'app-doc-exercises',
......@@ -12,6 +13,7 @@ import {ExerciseDocumentation} from 'src/app/models/exerciseDocumentation';
})
export class DocExercisesPage implements OnInit {
public configMC = configMC;
exerciseGenDocs: ExerciseDocumentation[] = [];
vocUnitDocs: ExerciseDocumentation[] = [];
......
......@@ -98,19 +98,19 @@
<ion-toolbar>
<ion-tabs>
<ion-tab-bar slot="bottom">
<ion-tab-button (click)="helperService.goToInfoPage(navCtrl)">
<ion-tab-button (click)="helperService.goToPage(navCtrl, configMC.pageUrlInfo)">
<ion-icon name="information-circle"></ion-icon>
<ion-label>{{ 'ABOUT' | translate }}</ion-label>
</ion-tab-button>
<ion-tab-button (click)="helperService.goToDocExercisesPage(navCtrl)">
<ion-tab-button (click)="helperService.goToPage(navCtrl, configMC.pageUrlDocExercises)">
<ion-icon name="tablet-landscape"></ion-icon>
<ion-label>{{'DOC_EXERCISES' | translate}}</ion-label>
</ion-tab-button>
<ion-tab-button (click)="helperService.goToDocVocUnitPage(navCtrl)">
<ion-tab-button (click)="helperService.goToPage(navCtrl, configMC.pageUrlDocVocUnit)">
<ion-icon name="school"></ion-icon>
<ion-label>{{'DOC_VOC_UNIT' | translate}}</ion-label>
</ion-tab-button>
<ion-tab-button (click)="helperService.goToImprintPage(navCtrl)">
<ion-tab-button (click)="helperService.goToPage(navCtrl, configMC.pageUrlImprint)">
<ion-icon name="today"></ion-icon>
<ion-label>{{ 'IMPRINT' | translate }}</ion-label>
</ion-tab-button>
......
......@@ -95,19 +95,19 @@
<ion-toolbar>
<ion-tabs>
<ion-tab-bar slot="bottom">
<ion-tab-button (click)="helperService.goToInfoPage(navCtrl)">
<ion-tab-button (click)="helperService.goToPage(navCtrl, configMC.pageUrlInfo)">
<ion-icon name="information-circle"></ion-icon>
<ion-label>{{ 'ABOUT' | translate }}</ion-label>
</ion-tab-button>
<ion-tab-button (click)="helperService.goToDocSoftwarePage(navCtrl)">
<ion-tab-button (click)="helperService.goToPage(navCtrl, configMC.pageUrlDocSoftware)">
<ion-icon name="code"></ion-icon>
<ion-label>{{ 'DOC_SOFTWARE' | translate}}</ion-label>
</ion-tab-button>
<ion-tab-button (click)="helperService.goToDocExercisesPage(navCtrl)">
<ion-tab-button (click)="helperService.goToPage(navCtrl, configMC.pageUrlDocExercises)">
<ion-icon name="tablet-landscape"></ion-icon>
<ion-label>{{'DOC_EXERCISES' | translate}}</ion-label>
</ion-tab-button>
<ion-tab-button (click)="helperService.goToImprintPage(navCtrl)">
<ion-tab-button (click)="helperService.goToPage(navCtrl, configMC.pageUrlImprint)">
<ion-icon name="today"></ion-icon>
<ion-label>{{ 'IMPRINT' | translate }}</ion-label>
</ion-tab-button>
......
......@@ -3,6 +3,7 @@ import {HelperService} from 'src/app/helper.service';
import {NavController} from '@ionic/angular';
import {HttpClient} from '@angular/common/http';
import {TranslateService} from '@ngx-translate/core';
import configMC from '../../configMC';
@Component({
selector: 'app-doc-voc-unit',
......@@ -11,6 +12,7 @@ import {TranslateService} from '@ngx-translate/core';
})
export class DocVocUnitPage {
public configMC = configMC;
hypothesisIndices: number[] = [...Array(5).keys()];
questionsIndices: number[] = [...Array(10).keys()];
sequenceIndices: number[] = [...Array(6).keys()];
......
......@@ -103,7 +103,7 @@ describe('ExerciseListPage', () => {
it('should show an exercise', (done) => {
const requestSpy: Spy = spyOn(exerciseListPage.helperService, 'makeGetRequest').and.callFake(() => Promise.reject());
spyOn(exerciseListPage.helperService, 'goToPreviewPage').and.returnValue(Promise.resolve(true));
spyOn(exerciseListPage.helperService, 'goToPage').and.returnValue(Promise.resolve(true));
exerciseListPage.showExercise(new ExerciseMC()).then(() => {
requestSpy.and.returnValue(Promise.resolve({}));
exerciseListPage.showExercise(new ExerciseMC({exercise_type: MoodleExerciseType.markWords.toString()})).then(() => {
......
......@@ -151,7 +151,7 @@ export class ExerciseListPage implements OnInit {
this.corpusService.annisResponse = ar;
const met: MoodleExerciseType = MoodleExerciseType[exercise.exercise_type];
this.corpusService.exercise.type = ExerciseType[met.toString()];
this.helperService.goToPreviewPage(this.navCtrl).then();
this.helperService.goToPage(this.navCtrl, configMC.pageUrlPreview).then();
return resolve();
}, () => {
return resolve();
......
......@@ -17,7 +17,7 @@ import {QueryMC} from '../models/queryMC';
import {PhenomenonMapContent} from '../models/phenomenonMap';
import Spy = jasmine.Spy;
import MockMC from '../models/mockMC';
import {Phenomenon} from '../../../openapi';
import {ExerciseForm, Phenomenon} from '../../../openapi';
describe('ExerciseParametersPage', () => {
let exerciseParametersPage: ExerciseParametersPage;
......@@ -54,6 +54,7 @@ describe('ExerciseParametersPage', () => {
it('should generate an exercise', (done) => {
exerciseParametersPage.corpusService.annisResponse = {solutions: []};
exerciseParametersPage.helperService.applicationState.next(exerciseParametersPage.helperService.deepCopy(MockMC.applicationState));
exerciseParametersPage.corpusService.initCurrentCorpus().then(async () => {
exerciseParametersPage.corpusService.currentTextRange = new ReplaySubject<TextRange>(1);
exerciseParametersPage.corpusService.currentTextRange.next(new TextRange({start: [], end: []}));
......@@ -104,6 +105,7 @@ describe('ExerciseParametersPage', () => {
});
it('should get exercise data', (done) => {
exerciseParametersPage.helperService.applicationState.next(exerciseParametersPage.helperService.deepCopy(MockMC.applicationState));
exerciseParametersPage.corpusService.initCurrentCorpus().then(async () => {
exerciseParametersPage.corpusService.currentTextRange = new ReplaySubject<TextRange>(1);
exerciseParametersPage.corpusService.currentTextRange.next(new TextRange({start: ['', ''], end: ['', '']}));
......@@ -124,13 +126,14 @@ describe('ExerciseParametersPage', () => {
it('should get a H5P exercise', (done) => {
const requestSpy: Spy = spyOn(exerciseParametersPage.helperService, 'makePostRequest').and.returnValue(Promise.resolve({}));
const navSpy: Spy = spyOn(exerciseParametersPage.helperService, 'goToPreviewPage').and.returnValue(Promise.resolve(true));
const navSpy: Spy = spyOn(exerciseParametersPage.helperService, 'goToPage').and.returnValue(Promise.resolve(true));
exerciseParametersPage.corpusService.annisResponse = {};
exerciseParametersPage.helperService.applicationState.next(exerciseParametersPage.helperService.deepCopy(MockMC.applicationState));
exerciseParametersPage.getH5Pexercise(new FormData()).then(() => {
const ef: ExerciseForm = {instructions: '', search_values: '', type: '', urn: ''};
exerciseParametersPage.getH5Pexercise(ef).then(() => {
expect(navSpy).toHaveBeenCalledTimes(1);
requestSpy.and.callFake(() => Promise.reject());
exerciseParametersPage.getH5Pexercise(new FormData()).then(() => {
exerciseParametersPage.getH5Pexercise(ef).then(() => {
}, () => {
expect(navSpy).toHaveBeenCalledTimes(1);
done();
......@@ -139,7 +142,7 @@ describe('ExerciseParametersPage', () => {
});
it('should get a KWIC exercise', (done) => {
const navSpy: Spy = spyOn(exerciseParametersPage.helperService, 'goToKwicPage').and.returnValue(Promise.resolve(true));
const navSpy: Spy = spyOn(exerciseParametersPage.helperService, 'goToPage').and.returnValue(Promise.resolve(true));
const requestSpy: Spy = spyOn(exerciseParametersPage.helperService, 'makePostRequest').and.returnValue(Promise.resolve('svg'));
exerciseParametersPage.getKwicExercise('').then(() => {
expect(exerciseParametersPage.exerciseService.kwicGraphs.length).toBe(3);
......
......@@ -19,7 +19,7 @@ import {ApplicationState} from '../models/applicationState';
import {take} from 'rxjs/operators';
import {TextRange} from '../models/textRange';
import configMC from '../../configMC';
import {AnnisResponse, FrequencyItem, Phenomenon} from '../../../openapi';
import {AnnisResponse, ExerciseForm, FrequencyItem, Phenomenon} from '../../../openapi';
import {KwicForm} from '../../../openapi';
@Component({
......@@ -105,20 +105,21 @@ export class ExerciseParametersPage implements OnInit {
this.corpusService.currentTextRange.pipe(take(1)).subscribe((tr: TextRange) => {
// TODO: change the corpus title to something meaningful, e.g. concatenate user ID and wanted exercise title
const workTitle: string = cc.title + ', ' + tr.start.filter(x => x).join('.') + '-' + tr.end.filter(x => x).join('.');
const formData = new FormData();
formData.append('urn', this.corpusService.currentUrn);
formData.append('search_values', JSON.stringify(searchValues));
formData.append('correct_feedback', this.corpusService.exercise.feedback.correct);
formData.append('instructions', instructions);
formData.append('general_feedback', this.corpusService.exercise.feedback.general);
formData.append('incorrect_feedback', this.corpusService.exercise.feedback.incorrect);
formData.append('language', this.translateService.currentLang);
formData.append('partially_correct_feedback', this.corpusService.exercise.feedback.partiallyCorrect);
formData.append('type', MoodleExerciseType[this.corpusService.exercise.type]);
formData.append('type_translation', this.corpusService.exercise.typeTranslation);
formData.append('work_author', cc.author);
formData.append('work_title', workTitle);
this.getH5Pexercise(formData).then(() => {
const ef: ExerciseForm = {
correct_feedback: this.corpusService.exercise.feedback.correct,
instructions,
general_feedback: this.corpusService.exercise.feedback.general,
incorrect_feedback: this.corpusService.exercise.feedback.incorrect,
language: this.translateService.currentLang,
partially_correct_feedback: this.corpusService.exercise.feedback.partiallyCorrect,
search_values: JSON.stringify(searchValues),
type: MoodleExerciseType[this.corpusService.exercise.type],
type_translation: this.corpusService.exercise.typeTranslation,
urn: this.corpusService.currentUrn,
work_author: cc.author,
work_title: workTitle,
};
this.getH5Pexercise(ef).then(() => {
return resolve();
});
});
......@@ -126,9 +127,13 @@ export class ExerciseParametersPage implements OnInit {
});
}
getH5Pexercise(formData: FormData): Promise<void> {
getH5Pexercise(ef: ExerciseForm): Promise<void> {
return new Promise<void>((resolve, reject) => {
const url: string = configMC.backendBaseUrl + configMC.backendApiExercisePath;
const formData = new FormData();
Object.keys(ef).forEach((key: string) => {
formData.append(key, ef[key]);
});
this.helperService.makePostRequest(this.http, this.toastCtrl, url, formData).then((ar: AnnisResponse) => {
// save the old frequency analysis in case we want to change the exercise parameters at a later time
ar.frequency_analysis = this.corpusService.annisResponse.frequency_analysis;
......@@ -138,7 +143,7 @@ export class ExerciseParametersPage implements OnInit {
this.corpusService.annisResponse.exercise_id = ar.exercise_id;
this.corpusService.annisResponse.uri = ar.uri;
this.corpusService.annisResponse.solutions = ar.solutions;
this.helperService.goToPreviewPage(this.navCtrl).then();
this.helperService.goToPage(this.navCtrl, configMC.pageUrlPreview).then();
return resolve();
});
}, () => {
......@@ -162,7 +167,7 @@ export class ExerciseParametersPage implements OnInit {
const kwicUrl: string = configMC.backendBaseUrl + configMC.backendApiKwicPath;
this.helperService.makePostRequest(this.http, this.toastCtrl, kwicUrl, formData).then((svgString: string) => {
this.exerciseService.kwicGraphs = svgString;
this.helperService.goToKwicPage(this.navCtrl).then();
this.helperService.goToPage(this.navCtrl, configMC.pageUrlKwic).then();
return resolve();
}, () => {
return reject();
......
......@@ -99,10 +99,10 @@ describe('HelperService', () => {
});
it('should go to a specific page', (done) => {
function checkNavigation(navFunctions: any[], pageUrls: string[], navController: NavController, navSpy: Spy): Promise<void> {
function checkNavigation(pageUrls: string[], navController: NavController, navSpy: Spy): Promise<void> {
return new Promise<void>(resolve => {
range(0, navFunctions.length).forEach(async (idx: number) => {
await navFunctions[idx](navController);
range(0, pageUrls.length).forEach(async (idx: number) => {
await helperService.goToPage(navController, pageUrls[idx]);
expect(navSpy).toHaveBeenCalledWith(pageUrls[idx]);
});
return resolve();
......@@ -111,16 +111,12 @@ describe('HelperService', () => {
const navCtrl: NavController = TestBed.inject(NavController);
const forwardSpy: Spy = spyOn(navCtrl, 'navigateForward').and.returnValue(Promise.resolve(true));
const navFnArr: any[] = [helperService.goToAuthorDetailPage, helperService.goToDocExercisesPage, helperService.goToDocSoftwarePage,
helperService.goToDocVocUnitPage, helperService.goToExerciseListPage, helperService.goToExerciseParametersPage,
helperService.goToImprintPage, helperService.goToInfoPage, helperService.goToPreviewPage, helperService.goToSourcesPage,
helperService.goToTextRangePage, helperService.goToVocabularyCheckPage, helperService.goToKwicPage,
helperService.goToRankingPage, helperService.goToSemanticsPage];
const pageUrlArr: string[] = [configMC.pageUrlAuthorDetail, configMC.pageUrlDocExercises, configMC.pageUrlDocSoftware,
configMC.pageUrlDocVocUnit, configMC.pageUrlExerciseList, configMC.pageUrlExerciseParameters, configMC.pageUrlImprint,
configMC.pageUrlInfo, configMC.pageUrlPreview, configMC.pageUrlSources, configMC.pageUrlTextRange,
configMC.pageUrlVocabularyCheck, configMC.pageUrlKwic, configMC.pageUrlRanking, configMC.pageUrlSemantics];
checkNavigation(navFnArr, pageUrlArr, navCtrl, forwardSpy).then(async () => {
const pageUrlArr: string[] = [configMC.pageUrlSemantics, configMC.pageUrlVocabularyCheck, configMC.pageUrlTextRange,
configMC.pageUrlSources, configMC.pageUrlRanking, configMC.pageUrlPreview, configMC.pageUrlKwic,
configMC.pageUrlInfo, configMC.pageUrlImprint, configMC.pageUrlExerciseParameters,
configMC.pageUrlExerciseList, configMC.pageUrlDocVocUnit, configMC.pageUrlDocSoftware,
configMC.pageUrlDocExercises, configMC.pageUrlAuthorDetail];
checkNavigation(pageUrlArr, navCtrl, forwardSpy).then(async () => {
await helperService.goToAuthorPage(navCtrl);
expect(helperService.isVocabularyCheck).toBeFalsy();
await helperService.goToShowTextPage(navCtrl, true);
......
......@@ -200,88 +200,32 @@ export class HelperService {
return H5P;
}
goToAuthorDetailPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward(configMC.pageUrlAuthorDetail);
}
goToAuthorPage(navCtrl: NavController): Promise<boolean> {
this.isVocabularyCheck = false;
return navCtrl.navigateForward(configMC.pageUrlAuthor);
}
goToDocExercisesPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward(configMC.pageUrlDocExercises);
}
goToDocSoftwarePage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward(configMC.pageUrlDocSoftware);
}
goToDocVocUnitPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward(configMC.pageUrlDocVocUnit);
}
goToExerciseListPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward(configMC.pageUrlExerciseList);
}
goToExerciseParametersPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward(configMC.pageUrlExerciseParameters);
return this.goToPage(navCtrl, configMC.pageUrlAuthor);
}
goToHomePage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateRoot(configMC.pageUrlHome);
}
goToImprintPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward(configMC.pageUrlImprint);
}
goToInfoPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward(configMC.pageUrlInfo);
}
goToKwicPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward(configMC.pageUrlKwic);
}
goToPreviewPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward(configMC.pageUrlPreview);
}
goToRankingPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward(configMC.pageUrlRanking);
}
goToSemanticsPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward(configMC.pageUrlSemantics);
goToPage(navCtrl: NavController, pageUrl: string): Promise<boolean> {
return navCtrl.navigateForward(pageUrl);
}
goToShowTextPage(navCtrl: NavController, isVocabularyCheck: boolean = false): Promise<boolean> {
return new Promise<boolean>((resolve) => {
navCtrl.navigateForward(configMC.pageUrlShowText).then((result: boolean) => {
this.goToPage(navCtrl, configMC.pageUrlShowText).then((result: boolean) => {
this.isVocabularyCheck = isVocabularyCheck;
return resolve(result);
});
});
}
goToSourcesPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward(configMC.pageUrlSources);
}
goToTestPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateRoot(configMC.pageUrlTest);
}
goToTextRangePage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward(configMC.pageUrlTextRange);
}
goToVocabularyCheckPage(navCtrl: NavController): Promise<boolean> {
return navCtrl.navigateForward(configMC.pageUrlVocabularyCheck);
}
handleRequestError(toastCtrl: ToastController, error: HttpErrorResponse, errorMessage: string, url: string): void {
this.openRequests.splice(this.openRequests.indexOf(url), 1);
this.currentError = error;
......@@ -315,7 +259,7 @@ export class HelperService {
configMC.backendBaseUrl = part1.concat(configMC.backendBaseApiPath).concat('/');
}
if (!configMC.frontendBaseUrl) {
configMC.frontendBaseUrl = location.href.slice(0, -configMC.pageUrlHome.length);
configMC.frontendBaseUrl = location.href.substring(0, location.href.lastIndexOf('/') + 1);
}
}
......
......@@ -62,7 +62,8 @@
{{'EXERCISE_TYPE_MATCHING' | translate }}<br>
</p>
<p>
<ion-button (click)="helperService.goToExerciseListPage(navCtrl)">{{ 'CONTINUE' | translate }}
<ion-button
(click)="helperService.goToPage(navCtrl, configMC.pageUrlExerciseList)">{{ 'CONTINUE' | translate }}
</ion-button>
</p>
</div>
......@@ -96,7 +97,8 @@
{{'DOC_VOC_UNIT' | translate }}<br>
</p>
<p>
<ion-button (click)="helperService.goToInfoPage(navCtrl)">{{ 'CONTINUE' | translate }}
<ion-button
(click)="helperService.goToPage(navCtrl, configMC.pageUrlInfo)">{{ 'CONTINUE' | translate }}
</ion-button>
</p>
</div>
......@@ -113,7 +115,7 @@
<ion-toolbar>
<ion-tabs id="tabs">
<ion-tab-bar slot="bottom">
<ion-tab-button (click)="helperService.goToImprintPage(navCtrl)">
<ion-tab-button (click)="helperService.goToPage(navCtrl, configMC.pageUrlImprint)">
<ion-icon name="today"></ion-icon>
<ion-label>{{ 'IMPRINT' | translate }}</ion-label>
</ion-tab-button>
......
......@@ -8,6 +8,7 @@ import {ExerciseService} from 'src/app/exercise.service';
import {CorpusService} from 'src/app/corpus.service';
import {take} from 'rxjs/operators';
import { version } from 'src/version';
import configMC from '../../configMC';
@Component({
selector: 'app-home',
......@@ -15,6 +16,7 @@ import { version } from 'src/version';
styleUrls: ['home.page.scss'],
})
export class HomePage implements OnInit {
public configMC = configMC;
public isCorpusUpdateInProgress = false;
public version: string;
......
......@@ -114,19 +114,19 @@
<ion-toolbar>
<ion-tabs>
<ion-tab-bar slot="bottom">
<ion-tab-button (click)="helperService.goToInfoPage(navCtrl)">
<ion-tab-button (click)="helperService.goToPage(navCtrl, configMC.pageUrlInfo)">
<ion-icon name="information-circle"></ion-icon>
<ion-label>{{ 'ABOUT' | translate }}</ion-label>
</ion-tab-button>