Commit 4fc61c47 authored by Konstantin Schulz's avatar Konstantin Schulz
Browse files

initial commit

parent f28d9e16
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import {Component} from '@angular/core';
import {Config, Platform} from 'ionic-angular';
import {StatusBar} from '@ionic-native/status-bar';
import {SplashScreen} from '@ionic-native/splash-screen';
import {HomePage} from '../pages/home/home';
import {TranslateService} from "@ngx-translate/core";
import { HomePage } from '../pages/home/home';
@Component({
templateUrl: 'app.html'
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = HomePage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
});
}
export class MCclient {
rootPage: any = HomePage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, private translate: TranslateService, private config: Config) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
});
this.initTranslate();
}
initTranslate() {
// Set the default language for translation strings, and the current language.
this.translate.setDefaultLang('de');
// if (this.translate.getBrowserLang() !== undefined) {
// this.translate.use(this.translate.getBrowserLang());
// } else {
this.translate.use('de'); // Set your language here
// }
this.translate.get(['BACK_BUTTON_TEXT']).subscribe(values => {
this.config.set('ios', 'backButtonText', values.BACK_BUTTON_TEXT);
});
}
}
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import {BrowserModule} from '@angular/platform-browser';
import {ErrorHandler, NgModule} from '@angular/core';
import {IonicApp, IonicErrorHandler, IonicModule} from 'ionic-angular';
import {SplashScreen} from '@ionic-native/splash-screen';
import {StatusBar} from '@ionic-native/status-bar';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import {MCclient} from './app.component';
import {CorpusProvider} from '../providers/corpus/corpus';
import {HttpClient, HttpClientModule} from "@angular/common/http";
import {HomePageModule} from "../pages/home/home.module";
import {TranslateLoader, TranslateModule} from "@ngx-translate/core";
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
import {AuthorDetailPageModule} from "../pages/author-detail/author-detail.module";
// The translate loader needs to know where to load i18n files
// in Ionic's static asset pipeline.
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
@NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
declarations: [
MCclient
],
imports: [
BrowserModule,
IonicModule.forRoot(MCclient),
HttpClientModule,
HomePageModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpClient]
}
}),
AuthorDetailPageModule
],
bootstrap: [IonicApp],
entryComponents: [
MCclient
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
CorpusProvider
]
})
export class AppModule {}
export class AppModule {
}
{
"AUTHORS": "Autoren",
"AUTHOR_SEARCH": "Autor suchen...",
"AUTHOR_SELECT": "Autor auswählen",
"CORPUS_SELECT": "Korpus auswählen"
}
\ No newline at end of file
import {CorpusMC} from "./corpusMC";
export class Author {
public corpora: CorpusMC[];
public name: string;
constructor(init?:Partial<Author>) {
Object.assign(this, init);
}
}
export class CorpusMC {
public author: string;
public cid: number;
public sourceUrn: string;
public title: string;
public uri: string;
constructor(init?:Partial<CorpusMC>) {
Object.assign(this, init);
}
}
<!--
Generated template for the AuthorDetailPage page.
See http://ionicframework.com/docs/components/#navigation for more info on
Ionic pages and navigation.
-->
<ion-header>
<ion-navbar>
<ion-title>{{ 'CORPUS_SELECT' | translate }}</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list>
<ion-item-sliding *ngFor="let corpus of corpusProvider.currentAuthor.corpora">
<button ion-item (click)="showText(corpus)">
<p>{{corpus.title}}</p>
</button>
</ion-item-sliding>
</ion-list>
</ion-content>
import {NgModule} from '@angular/core';
import {IonicPageModule} from 'ionic-angular';
import {AuthorDetailPage} from './author-detail';
import {TranslateModule} from "@ngx-translate/core";
@NgModule({
declarations: [
AuthorDetailPage,
],
imports: [
IonicPageModule.forChild(AuthorDetailPage),
TranslateModule.forChild()
],
})
export class AuthorDetailPageModule {
}
import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {CorpusProvider} from "../../providers/corpus/corpus";
import {CorpusMC} from "../../models/corpusMC";
/**
* Generated class for the AuthorDetailPage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-author-detail',
templateUrl: 'author-detail.html',
})
export class AuthorDetailPage {
constructor(public navCtrl: NavController, public navParams: NavParams,
public corpusProvider: CorpusProvider) {
}
showText(corpus: CorpusMC) {
}
}
<ion-header>
<ion-navbar>
<ion-title>
Ionic Blank
</ion-title>
</ion-navbar>
<ion-navbar>
<ion-title>
{{ 'AUTHOR_SELECT' | translate }}
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
The world is your oyster.
<p>
If you get lost, the <a href="http://ionicframework.com/docs/v2">docs</a> will be your guide.
</p>
<ion-searchbar (ionInput)="getAuthors($event)" placeholder="{{ 'AUTHOR_SEARCH' | translate }}"></ion-searchbar>
<ion-list>
<ion-title>
{{ 'AUTHORS' | translate }}
</ion-title>
<ion-item-sliding *ngFor="let author of authorsDisplayed">
<button ion-item (click)="showCorpora(author)">
<p>{{author.name}}</p>
</button>
</ion-item-sliding>
</ion-list>
</ion-content>
import {NgModule} from '@angular/core';
import {TranslateModule} from '@ngx-translate/core';
import {IonicPageModule} from 'ionic-angular';
import {CommonModule} from "@angular/common";
import {HomePage} from "./home";
@NgModule({
declarations: [
HomePage,
],
imports: [
IonicPageModule.forChild(HomePage),
TranslateModule.forChild(),
CommonModule
],
exports: [
HomePage
]
})
export class HomePageModule {
}
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';
import {CorpusProvider} from "../../providers/corpus/corpus";
import {HttpClient} from "@angular/common/http";
import {CorpusMC} from "../../models/corpusMC";
import {TranslateService} from "@ngx-translate/core";
import {Author} from "../../models/author";
import {AuthorDetailPage} from "../author-detail/author-detail";
@Component({
selector: 'page-home',
templateUrl: 'home.html'
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController) {
private corpusUrl: string = "http://141.20.186.246:5000/mc/api/v1.0/corpora";
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 = [];
let resultObservable = this.http.get(this.corpusUrl);
resultObservable.subscribe((data: object) => {
let corpusList: CorpusMC[] = data["corpora"] as CorpusMC[];
corpusList.forEach((corpus: CorpusMC) => {
this.corpusProvider.availableCorpora.push(corpus);
let authorIndex = this.corpusProvider.availableAuthors.map(author => author.name).indexOf(corpus.author);
if (authorIndex > -1) {
this.corpusProvider.availableAuthors[authorIndex].corpora.push(corpus);
}
else {
this.corpusProvider.availableAuthors.push(new Author({
name: corpus.author,
corpora: [corpus]
}));
}
});
this.corpusProvider.availableAuthors.sort((author1, author2) => {
if (author1.name < author2.name) {
return -1;
}
else if (author1.name > author2.name) {
return 1;
}
return 0;
});
});
}
this.authorsDisplayed = this.corpusProvider.availableAuthors;
}
getAuthors(event) { // Type: InputEvent
let value: string = event.target.value;
if (value === "") {
this.authorsDisplayed = this.corpusProvider.availableAuthors;
}
else if (!value || !value.trim()) {
this.authorsDisplayed = [];
}
else {
this.authorsDisplayed = this.corpusProvider.availableAuthors.filter((author: Author) => {
return HomePage.filterAuthor(author, value)
});
}
}
static filterAuthor(author: Author, filterValue: string) {
return author.name.toLowerCase().includes(filterValue.toLowerCase());
}
showCorpora(author: Author) {
this.corpusProvider.currentAuthor = author;
this.navCtrl.push(AuthorDetailPage).then();
}
}
import {Injectable} from '@angular/core';
import {CorpusMC} from "../../models/corpusMC";
import {Author} from "../../models/author";
/*
Generated class for the CorpusProvider provider.
See https://angular.io/guide/dependency-injection for more info on providers
and Angular DI.
*/
@Injectable()
export class CorpusProvider {
public availableCorpora: CorpusMC[];
public availableAuthors: Author[];
public currentAuthor: Author;
constructor() {
}
}
......@@ -6,7 +6,7 @@
"experimentalDecorators": true,
"lib": [
"dom",
"es2015"
"es7" // es2015
],
"module": "es2015",
"moduleResolution": "node",
......
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