Commit d5cd808b authored by Konstantin Schulz's avatar Konstantin Schulz
Browse files

added a customizable configuration file

parent 348fc83e
......@@ -24,16 +24,8 @@
"INSTRUCTIONS": "Anweisungen",
"INSTRUCTIONS_FILL_THE_GAP": "Ordne die Wörter aus dem Pool den richtigen Lücken zu!",
"LOCAL_STORAGE_KEY_CORPORA": "mc/corpora",
"MC_API_CORPORA_URL": "http://141.20.186.246:5000/mc/api/v1.0/corpora",
"MC_API_EXERCISE_URL": "http://141.20.186.246:5000/mc/api/v1.0/exercise",
"MC_API_FILE_URL": "http://141.20.186.246:5000/mc/api/v1.0/file",
"MC_API_RAW_TEXT_URL": "http://141.20.186.246:5000/mc/api/v1.0/rawtext",
"PART_OF_SPEECH_CONJUNCTION": "Konjunktion",
"PDF": "PDF",
"PERSEIDS_CTS_API_BASE_URL": "https://cts.perseids.org/api/cts?request=",
"PERSEIDS_CTS_API_GET_CAPABILITIES": "GetCapabilities",
"PERSEIDS_CTS_API_GET_VALID_REFF": "GetValidReff",
"PERSEIDS_CTS_API_URN_SNIPPET": "&urn=",
"PHENOMENON_DEPENDENCY": "Dependenz",
"PHENOMENON_PART_OF_SPEECH": "Wortart",
"PREVIEW": "Vorschau",
......
export class ConfigMC {
public static backendBaseUrl: string = "http://141.20.186.246:5000";
public static backendApiPath: string = "/mc/api/v1.0/";
public static backendApiCorporaPath: string = "corpora";
public static backendApiExercisePath: string = "exercise";
public static backendApiFilePath: string = "file";
public static backendApiRawtextPath: string = "rawtext";
public static perseidsCTSapiBaseUrl: string = "https://cts.perseids.org/api/cts?request=";
public static perseidsCTSapiGetCapabilities: string = "GetCapabilities";
public static perseidsCTSapiGetValidReff = "GetValidReff";
public static perseidsCTSapiUrnSnippet = "&urn=";
}
\ No newline at end of file
......@@ -19,21 +19,12 @@ import {AuthorDetailPage} from "../author-detail/author-detail";
templateUrl: 'author.html',
})
export class AuthorPage {
// private corpusUrl: string;
public authorsDisplayed: Author[];
constructor(public navCtrl: NavController,
public translate: TranslateService,
public corpusProvider: CorpusProvider,
public http: HttpClient) {
// if (!this.corpusProvider.availableCorpora) {
// this.corpusProvider.availableCorpora = [];
// this.corpusProvider.availableAuthors = [];
// this.translate.get("MC_API_CORPORA_URL").subscribe((value) => {
// this.corpusUrl = value;
// this.corpusProvider.getCorpora(this.corpusUrl);
// });
// }
this.authorsDisplayed = this.corpusProvider.availableAuthors;
}
......
......@@ -25,14 +25,5 @@ export class HomePage {
}
test() {
// window.localStorage.removeItem("__mc_storage__");
// this.translate.get("MC_API_CORPORA_URL").subscribe((corpusUrl: string) => {
// this.http.get(corpusUrl).subscribe((data: object) => {
// let jsonString: string = JSON.stringify(data["corpora"]);
// window.localStorage.setItem("mc/corpora", jsonString);
// });
// });
let a = JSON.parse(window.localStorage.getItem("mc/corpora"));
let b = 0;
}
}
......@@ -6,6 +6,7 @@ import {ExerciseProvider} from "../../providers/exercise/exercise";
import {TranslateService} from "@ngx-translate/core";
import {CorpusProvider} from "../../providers/corpus/corpus";
import {FileType} from "../../models/enum";
import {ConfigMC} from "../../config";
/**
* Generated class for the PreviewPage page.
......@@ -51,7 +52,8 @@ export class PreviewPage {
formData.append("partially_correct_feedback", this.exerciseProvider.exercise.feedback.partiallyCorrect);
formData.append("incorrect_feedback", this.exerciseProvider.exercise.feedback.incorrect);
formData.append("general_feedback", this.exerciseProvider.exercise.feedback.general);
this.http.post(this.exerciseProvider.MCapiExerciseUrlString, formData).subscribe((ar: AnnisResponse) => {
let url = ConfigMC.backendBaseUrl + ConfigMC.backendApiPath + ConfigMC.backendApiExercisePath;
this.http.post(url, formData).subscribe((ar: AnnisResponse) => {
let maxGapLength = Math.max.apply(Math, Object.keys(ar.solution).map(key => ar.solution[key].length));
ar.graph.nodes.forEach((node) => {
if (node.annis_tok.startsWith("[[")) {
......@@ -59,6 +61,9 @@ export class PreviewPage {
}
});
this.exerciseProvider.annisResponse = ar;
}, (error) => {
let a = 0;
console.log(error);
});
}
......@@ -66,6 +71,7 @@ export class PreviewPage {
let uriParts: string[] = this.exerciseProvider.annisResponse.uri.split("/");
let fileId: string = uriParts[uriParts.length - 1];
let fileTypeString: string = "?type=" + type;
window.open(this.exerciseProvider.MCapiFileUrlString + "/" + fileId + fileTypeString, "_blank");
let url = ConfigMC.backendBaseUrl + ConfigMC.backendApiPath + ConfigMC.backendApiFilePath;
window.open(url + "/" + fileId + fileTypeString, "_blank");
}
}
......@@ -8,6 +8,7 @@ import {GetValidReff} from "../../models/getValidReff";
import {RequestMC} from "../../models/requestMC";
import {Reply} from "../../models/reply";
import {Reff} from "../../models/reff";
import {ConfigMC} from "../../config";
/*
Generated class for the CorpusProvider provider.
......@@ -17,36 +18,16 @@ import {Reff} from "../../models/reff";
*/
@Injectable()
export class CorpusProvider {
public CTSgetValReffString: string;
public CTSurnString: string;
public CTSbaseURL: string;
public CTSgetCapString: string;
public availableCorpora: CorpusMC[];
public availableAuthors: Author[];
public currentAuthor: Author;
public currentCorpus: CorpusMC;
public currentUrn: string;
public xml2jsParser: Parser;
private MCapiRawTextUrlString: string;
public currentText: string = "";
constructor(public translate: TranslateService,
public http: HttpClient) {
this.translate.get("PERSEIDS_CTS_API_BASE_URL").subscribe((value: string) => {
this.CTSbaseURL = value;
});
this.translate.get("PERSEIDS_CTS_API_GET_CAPABILITIES").subscribe((value: string) => {
this.CTSgetCapString = value;
});
this.translate.get("PERSEIDS_CTS_API_URN_SNIPPET").subscribe((value: string) => {
this.CTSurnString = value;
});
this.translate.get("PERSEIDS_CTS_API_GET_VALID_REFF").subscribe((value: string) => {
this.CTSgetValReffString = value;
});
this.translate.get("MC_API_RAW_TEXT_URL").subscribe((value: string) => {
this.MCapiRawTextUrlString = value;
});
this.xml2jsParser = new Parser();
if (!this.availableCorpora) {
this.getCorpora();
......@@ -87,11 +68,12 @@ export class CorpusProvider {
}
getCTStextPassage(urn: string) {
return this.http.get(this.MCapiRawTextUrlString, {params: {"urn": urn}});
let url = ConfigMC.backendBaseUrl + ConfigMC.backendApiPath + ConfigMC.backendApiRawtextPath;
return this.http.get(url, {params: {"urn": urn}});
}
getCTSvalidReff(urn: string) {
let fullUrl = this.CTSbaseURL + this.CTSgetValReffString + this.CTSurnString + urn;
let fullUrl = ConfigMC.perseidsCTSapiBaseUrl + ConfigMC.perseidsCTSapiGetValidReff + ConfigMC.perseidsCTSapiUrnSnippet + urn;
return this.http.get(fullUrl, {responseType: 'text'});
}
......@@ -103,11 +85,11 @@ export class CorpusProvider {
let storedCorporaJSONstring: string = window.localStorage.getItem(key);
if (!storedCorporaJSONstring) {
// get corpora from REST API
this.translate.get("MC_API_CORPORA_URL").subscribe((url: string) => {
this.http.get(url).subscribe((data: object) => {
let corpusList: CorpusMC[] = data["corpora"] as CorpusMC[];
this.processCorpora(corpusList);
});
let url = ConfigMC.backendBaseUrl + ConfigMC.backendApiPath + ConfigMC.backendApiCorporaPath;
this.http.get(url).subscribe((data: object) => {
let corpusList: CorpusMC[] = data["corpora"] as CorpusMC[];
window.localStorage.setItem(key, JSON.stringify(corpusList));
this.processCorpora(corpusList);
});
}
else {
......
......@@ -24,17 +24,9 @@ export class ExerciseProvider {
feedback: new Feedback({general: "", incorrect: "", partiallyCorrect: "", correct: ""})
});
public annisResponse: AnnisResponse;
public MCapiExerciseUrlString: string;
public MCapiFileUrlString: string;
constructor(public http: HttpClient,
public translateService: TranslateService) {
this.translateService.get("MC_API_EXERCISE_URL").subscribe((value) => {
this.MCapiExerciseUrlString = value;
});
this.translateService.get("MC_API_FILE_URL").subscribe((value) => {
this.MCapiFileUrlString = value;
});
this.translateService.get("EXERCISE_FEEDBACK_CORRECT_DEFAULT").subscribe((value: string) => {
this.exercise.feedback.correct = value;
});
......
Supports Markdown
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