Commit 91e2d6ed authored by Konstantin Schulz's avatar Konstantin Schulz
Browse files

improved citation system and added corpus refresh button

parent f29a5cf0
{
"name": "mcClient",
"version": "0.1.8",
"version": "0.1.9",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
......
......@@ -3,6 +3,8 @@
"AUTHOR_SEARCH": "Autor suchen...",
"AUTHOR_SELECT": "Autor auswählen",
"CALLIDUS_PROJECT": "CALLIDUS-Projekt",
"CORPORA_REFRESH": "Korpora aktualisieren",
"CORPUS_UPDATE_COMPLETED": "Korpus-Update abgeschlossen",
"DEPENDENCY_ADJECTIVAL_CLAUSE": "Attributsatz",
"DEPENDENCY_ADJECTIVAL_MODIFIER": "Adjektivische Ergänzung",
"DEPENDENCY_ADVERBIAL_CLAUSE_MODIFIER": "Adverbialsatz",
......
......@@ -3,6 +3,8 @@
"AUTHOR_SEARCH": "Search author...",
"AUTHOR_SELECT": "Select author",
"CALLIDUS_PROJECT": "CALLIDUS Project",
"CORPORA_REFRESH": "Refresh corpora",
"CORPUS_UPDATE_COMPLETED": "Corpus update completed",
"DEPENDENCY_ADJECTIVAL_CLAUSE": "Adjectival Clause",
"DEPENDENCY_ADJECTIVAL_MODIFIER": "Adjectival Clause",
"DEPENDENCY_ADVERBIAL_CLAUSE_MODIFIER": "Adverbial Clause",
......
......@@ -9,7 +9,8 @@ export class CorpusMC {
public citation_level_1: string;
public citation_level_2: string;
public citation_level_3: string;
public citations: { [value: number]: Citation; };
// public citations: { [value: number]: Citation; };
public citations: { [label: string]: Citation; };
constructor(init?: Partial<CorpusMC>) {
Object.assign(this, init);
}
......
export class TextRange {
public start: number[];
public end: number[];
public start: string;
public end: string;
constructor(init?:Partial<TextRange>) {
Object.assign(this, init);
}
......
......@@ -19,106 +19,51 @@
<ion-content padding>
<ion-grid *ngIf="ObjectKeys(corpusProvider.currentCorpus.citations).length > 0; else loading">
<ion-row>
<ion-col><h1>{{ 'START' | translate }}</h1></ion-col>
<ion-col><h1>{{ 'END' | translate }}</h1></ion-col>
</ion-row>
<ion-grid>
<!--*ngIf="currentlyAvailableCitations.length > 0; else loading"-->
<ion-row>
<ion-col>
<ion-label>
{{corpusProvider.currentCorpus.citation_level_1}}
<span *ngIf="corpusProvider.currentCorpus.citation_level_2 !== CitationLevel[CitationLevel.default]">
- {{corpusProvider.currentCorpus.citation_level_2}}
<span *ngIf="corpusProvider.currentCorpus.citation_level_3 !== CitationLevel[CitationLevel.default]">
- {{corpusProvider.currentCorpus.citation_level_3}}
</span>
</span>
</ion-label>
<ion-select [(ngModel)]="corpusProvider.currentTextRange.start[0]" name="textRangeStart0"
(ionChange)="showFurtherReferences($event.toString(), 1, true)">
<ion-option *ngFor="let key of ObjectKeys(corpusProvider.currentCorpus.citations)"
[value]="corpusProvider.currentCorpus.citations[key].value">
{{corpusProvider.currentCorpus.citations[key].label}}
</ion-option>
</ion-select>
</ion-col>
<ion-col>
<ion-label>
{{corpusProvider.currentCorpus.citation_level_1}}
</ion-label>
<ion-select [(ngModel)]="corpusProvider.currentTextRange.end[0]" name="textRangeEnd0"
(ionChange)="showFurtherReferences($event.toString(), 1, false)">
<ion-option *ngFor="let key2 of ObjectKeys(corpusProvider.currentCorpus.citations)"
[value]="corpusProvider.currentCorpus.citations[key2].value">
{{corpusProvider.currentCorpus.citations[key2].label}}
</ion-option>
</ion-select>
</ion-col>
</ion-row>
<ion-row *ngIf="corpusProvider.currentCorpus.citation_level_2 != CitationLevel[CitationLevel.default]">
<ion-col>
<ion-label>
{{corpusProvider.currentCorpus.citation_level_2}}
</ion-label>
<ion-select [(ngModel)]="corpusProvider.currentTextRange.start[1]" name="textRangeStart1"
(ionChange)="showFurtherReferences($event.toString(), 2, true)"
*ngIf="corpusProvider.currentTextRange.start[0] && ObjectKeys(corpusProvider.currentCorpus.citations[corpusProvider.currentTextRange.start[0]].subcitations).length > 0">
<ion-option
*ngFor="let key3 of ObjectKeys(corpusProvider.currentCorpus.citations[corpusProvider.currentTextRange.start[0]].subcitations)"
[value]="corpusProvider.currentCorpus.citations[corpusProvider.currentTextRange.start[0]].subcitations[key3].value">
{{corpusProvider.currentCorpus.citations[corpusProvider.currentTextRange.start[0]].subcitations[key3].label}}
</ion-option>
</ion-select>
</ion-col>
<ion-col>
<ion-label>
{{corpusProvider.currentCorpus.citation_level_2}}
</ion-label>
<ion-select [(ngModel)]="corpusProvider.currentTextRange.end[1]" name="textRangeEnd1"
(ionChange)="showFurtherReferences($event.toString(), 2, false)"
*ngIf="corpusProvider.currentTextRange.end[0] && ObjectKeys(corpusProvider.currentCorpus.citations[corpusProvider.currentTextRange.end[0]].subcitations).length > 0">
<ion-option
*ngFor="let key4 of ObjectKeys(corpusProvider.currentCorpus.citations[corpusProvider.currentTextRange.end[0]].subcitations)"
[value]="corpusProvider.currentCorpus.citations[corpusProvider.currentTextRange.end[0]].subcitations[key4].value">
{{corpusProvider.currentCorpus.citations[corpusProvider.currentTextRange.end[0]].subcitations[key4].label}}
</ion-option>
</ion-select>
</ion-col>
<ion-row>
<ion-col><h1>{{ 'START' | translate }}</h1></ion-col>
<ion-col><h1>{{ 'END' | translate }}</h1></ion-col>
</ion-row>
<ion-row *ngIf="corpusProvider.currentCorpus.citation_level_3 != CitationLevel[CitationLevel.default]">
<ion-row>
<ion-col>
<ion-label>
{{corpusProvider.currentCorpus.citation_level_3}}
</ion-label>
<ion-select [(ngModel)]="corpusProvider.currentTextRange.start[2]" name="textRangeStart2"
*ngIf="corpusProvider.currentTextRange.start[1] && ObjectKeys(corpusProvider.currentCorpus.citations[corpusProvider.currentTextRange.start[0]].subcitations[corpusProvider.currentTextRange.start[1]].subcitations).length > 0">
<ion-option
*ngFor="let key5 of ObjectKeys(corpusProvider.currentCorpus.citations[corpusProvider.currentTextRange.start[0]].subcitations[corpusProvider.currentTextRange.start[1]].subcitations)"
[value]="corpusProvider.currentCorpus.citations[corpusProvider.currentTextRange.start[0]].subcitations[corpusProvider.currentTextRange.start[1]].subcitations[key5].value">
{{corpusProvider.currentCorpus.citations[corpusProvider.currentTextRange.start[0]].subcitations[corpusProvider.currentTextRange.start[1]].subcitations[key5].label}}
</ion-option>
</ion-select>
<ion-input [(ngModel)]="corpusProvider.currentTextRange.start" list="citationLevels"
name="textRangeStart" (ionChange)="showFurtherReferences($event.value).then()"
placeholder="{{ '0' + (corpusProvider.currentCorpus.citation_level_2 === CitationLevel[CitationLevel.default] ? '' : (corpusProvider.currentCorpus.citation_level_3 === CitationLevel[CitationLevel.default] ? '.0' : '.0.0'))}}"></ion-input>
</ion-col>
<ion-col>
<ion-label>
{{corpusProvider.currentCorpus.citation_level_3}}
</ion-label>
<ion-select [(ngModel)]="corpusProvider.currentTextRange.end[2]" name="textRangeEnd2"
*ngIf="corpusProvider.currentTextRange.end[1] && ObjectKeys(corpusProvider.currentCorpus.citations[corpusProvider.currentTextRange.end[0]].subcitations[corpusProvider.currentTextRange.end[1]].subcitations).length > 0">
<ion-option
*ngFor="let key6 of ObjectKeys(corpusProvider.currentCorpus.citations[corpusProvider.currentTextRange.end[0]].subcitations[corpusProvider.currentTextRange.end[1]].subcitations)"
[value]="corpusProvider.currentCorpus.citations[corpusProvider.currentTextRange.end[0]].subcitations[corpusProvider.currentTextRange.end[1]].subcitations[key6].value">
{{corpusProvider.currentCorpus.citations[corpusProvider.currentTextRange.end[0]].subcitations[corpusProvider.currentTextRange.end[1]].subcitations[key6].label}}
</ion-option>
</ion-select>
<ion-input [(ngModel)]="corpusProvider.currentTextRange.end" list="citationLevels"
name="textRangeEnd" (ionChange)="showFurtherReferences($event.value).then()"
placeholder="{{ '0' + (corpusProvider.currentCorpus.citation_level_2 === CitationLevel[CitationLevel.default] ? '' : (corpusProvider.currentCorpus.citation_level_3 === CitationLevel[CitationLevel.default] ? '.0' : '.0.0'))}}"></ion-input>
</ion-col>
<datalist id="citationLevels">
<option *ngFor="let key of currentlyAvailableCitations" [value]="key"></option>
</datalist>
</ion-row>
<ion-row>
<ion-col></ion-col>
<ion-col>
<button type="button" ion-button icon-only (click)="copyStartToEnd().then()">
<button type="button" ion-button icon-only (click)="corpusProvider.currentTextRange.end = corpusProvider.currentTextRange.start">
<ion-icon name="copy"></ion-icon>
</button>
</ion-col>
</ion-row>
</ion-grid>
<button ion-button block (click)="showText()">{{ "SHOW" | translate }}</button>
<ng-template #loading>
<ion-spinner></ion-spinner>
</ng-template>
<!--<ng-template #loading>-->
<!--<ion-spinner></ion-spinner>-->
<!--</ng-template>-->
</ion-content>
This diff is collapsed.
......@@ -12,6 +12,11 @@
</ion-header>
<ion-content padding>
<div *ngIf="!isCorpusUpdateInProgress; else loading"></div>
<button ion-button block (click)="goToAuthorPage()">{{ 'AUTHOR_SELECT' | translate }}</button>
<button ion-button block (click)="refreshCorpora()">{{ 'CORPORA_REFRESH' | translate }}</button>
<button ion-button block (click)="test()" [ngClass]="isProductionEnv">{{ 'TEST' | translate }}</button>
<ng-template #loading>
<ion-spinner></ion-spinner>
</ng-template>
</ion-content>
import {Component} from '@angular/core';
import {NavController, NavParams} from 'ionic-angular';
import {NavController, NavParams, ToastController} from 'ionic-angular';
import {AuthorPage} from "../author/author";
import {HttpClient} from "@angular/common/http";
import {ExerciseProvider} from "../../providers/exercise/exercise";
......@@ -15,13 +15,19 @@ import {VocabularyCheckPage} from "../vocabulary-check/vocabulary-check";
export class HomePage {
public isProductionEnv = ['localhost', '127.0.0.1'].indexOf(window.location.hostname) > -1 ? '' : 'hide';
public FeedbackPage = FeedbackPage;
public corpusUpdateCompletedString: string;
window = window;
public isCorpusUpdateInProgress: boolean = false;
listValues: any = ['1', '2', '3'];
constructor(public navCtrl: NavController, public navParams: NavParams,
public http: HttpClient,
public exerciseProvider: ExerciseProvider,
public translate: TranslateService,
public corpusProvider: CorpusProvider) {
public corpusProvider: CorpusProvider,
public toastCtrl: ToastController) {
this.translate.get("CORPUS_UPDATE_COMPLETED").subscribe(value => this.corpusUpdateCompletedString = value);
}
goToAuthorPage() {
......@@ -31,4 +37,27 @@ export class HomePage {
async test() {
this.navCtrl.push(VocabularyCheckPage).then();
}
refreshCorpora() {
this.isCorpusUpdateInProgress = true;
this.corpusProvider.getCorpora(true);
this.isCorpusUpdateInProgress = false;
let toast = this.toastCtrl.create({
message: this.corpusUpdateCompletedString,
duration: 3000,
position: 'top'
});
toast.present().then();
let a = new Date().getTime()
}
showFurtherReferences(value: string){
if (!value){
return;
}
if (value.endsWith(".")){
this.listValues = ['1.1', '1.2', '1.3'];
}
console.log(value);
}
}
......@@ -8,7 +8,7 @@
<ion-navbar>
<ion-title>{{corpusProvider.currentCorpus.author}}: {{corpusProvider.currentCorpus.title}}
{{corpusProvider.currentLastUrnPart}}
{{corpusProvider.currentTextRange.start + "-" + corpusProvider.currentTextRange.end}}
</ion-title>
<ion-buttons end>
<button ion-button icon-only color="primary" (click)="navCtrl.push(FeedbackPage)">
......
......@@ -28,7 +28,7 @@ export class CorpusProvider {
public currentUrn: string;
public xml2jsParser: Parser;
public currentText: string = "";
public currentTextRange: TextRange = new TextRange({start: [0, 0, 0], end: [0, 0, 0]});
public currentTextRange: TextRange = new TextRange({start: "", end: ""});
public currentLastUrnPart: string = "";
public currentCitations: Citation[] = [];
public partOfSpeechMap: { [rawValue: string]: PartOfSpeechValue } = {
......@@ -149,6 +149,8 @@ export class CorpusProvider {
}
getCorpora(fromServer: boolean = false) {
this.availableCorpora = [];
this.availableAuthors = [];
if (fromServer) {
// get corpora from REST API
let url = HelperProvider.config["backendBaseUrl"] + HelperProvider.config["backendApiCorporaPath"];
......@@ -171,8 +173,6 @@ export class CorpusProvider {
while (!HelperProvider.config) {
await new Promise(resolve => setTimeout(resolve, 50));
}
this.availableCorpora = [];
this.availableAuthors = [];
// check local storage for necessary updates
let updateInfoJSONstring: string = window.localStorage.getItem(HelperProvider.config["localStorageKeyUpdateInfo"]);
if (!updateInfoJSONstring) {
......
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