diff --git a/src/config.xml b/src/config.xml index f6d7979e0de7ce17927f3203b2423d4db566472d..acc1dc1787b0a3009adb5577ec37bf5021e40cdc 100644 --- a/src/config.xml +++ b/src/config.xml @@ -1,5 +1,5 @@ <?xml version='1.0' encoding='utf-8'?> -<widget id="de.night.of.science" version="0.0.9" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> +<widget id="de.night.of.science" version="0.0.11" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>Night of Science</name> <description>An awesome Ionic/Cordova app.</description> <author email="hi@ionicframework" href="http://ionicframework.com/">Ionic Framework Team @@ -22,6 +22,7 @@ <preference name="FadeSplashScreenDuration" value="300" /> <preference name="SplashShowOnlyFirstTime" value="false" /> <preference name="SplashScreen" value="screen" /> + <preference name="AutoHideSplashScreen" value="false" /> <preference name="SplashScreenDelay" value="3000" /> <platform name="android"> <allow-intent href="market:*" /> @@ -84,6 +85,6 @@ <plugin name="cordova-plugin-splashscreen" spec="~4.0.2" /> <plugin name="cordova-plugin-statusbar" spec="~2.2.1" /> <plugin name="cordova-plugin-whitelist" spec="1.3.1" /> - <plugin name="ionic-plugin-keyboard" spec="~2.2.1" /> <plugin name="cordova-sqlite-storage" spec="^2.0.4" /> + <plugin name="ionic-plugin-keyboard" spec="~2.2.1" /> </widget> diff --git a/src/src/app/app.component.ts b/src/src/app/app.component.ts index 4de5ff79b3f237ae11634665a78a40761daef8fd..0c1859bb6564a5c10928b1feedf636c2a09f1048 100644 --- a/src/src/app/app.component.ts +++ b/src/src/app/app.component.ts @@ -2,7 +2,7 @@ import { Component, ViewChild } from '@angular/core'; import { Nav, Platform } from 'ionic-angular'; import { StatusBar } from '@ionic-native/status-bar'; import { SplashScreen } from '@ionic-native/splash-screen'; - +import { Storage } from '@ionic/storage'; import { Tabs } from '../pages/tabs/tabs'; @@ -10,6 +10,7 @@ import { Imprint } from '../pages/imprint/imprint'; import { Settings } from '../pages/settings/settings'; import { Sponsors } from '../pages/sponsors/sponsors'; +import { LecturesProvider } from '../providers/lectures-provider'; @Component({ templateUrl: 'app.html' @@ -21,7 +22,7 @@ export class MyApp { pages: Array<{title: string, component: any}>; - constructor(public platform: Platform, private statusBar: StatusBar, private splashScreen: SplashScreen) { + constructor(public platform: Platform, private statusBar: StatusBar, private splashScreen: SplashScreen, private storage: Storage, private lecturesProvider: LecturesProvider) { this.initializeApp(); // used for an example of ngFor and navigation @@ -40,8 +41,16 @@ export class MyApp { this.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. + this.initStorage(); this.statusBar.styleDefault(); this.splashScreen.hide(); }); } + + initStorage(){ + this.storage.ready().then(() => { + + + }); + } } diff --git a/src/src/app/app.module.ts b/src/src/app/app.module.ts index 8a9ff5c73128906432cfbd855a4bf0e0d3b210e2..dd9e1cf016924cf2680ecbf9b6c752cc4e955785 100644 --- a/src/src/app/app.module.ts +++ b/src/src/app/app.module.ts @@ -5,7 +5,7 @@ import { SplashScreen } from '@ionic-native/splash-screen'; import { StatusBar } from '@ionic-native/status-bar'; import { HttpModule } from '@angular/http'; import { Storage, IonicStorageModule } from '@ionic/storage'; - +import { Http } from '@angular/http'; import { MyApp } from './app.component'; import { Tabs } from '../pages/tabs/tabs'; @@ -17,6 +17,9 @@ import { Imprint } from '../pages/imprint/imprint'; import { Sponsors } from '../pages/sponsors/sponsors'; import { Settings } from '../pages/settings/settings'; +import { LecturesProvider } from '../providers/lectures-provider'; +import { LecturesProviderFactory } from '../providers/lectures-provider'; +import { FacebookProvider } from '../providers/facebook-provider'; let pages = [ MyApp, Tabs, @@ -58,7 +61,9 @@ export function providers() { return [ SplashScreen, StatusBar, - + FacebookProvider, + LecturesProvider, + // { provide: LecturesProvider, useFactory: LecturesProviderFactory, deps: [Http,Storage] }, { provide: Settings, useFactory: provideSettings, deps: [Storage] }, // Keep this to enable Ionic's runtime error handling during development { provide: ErrorHandler, useClass: IonicErrorHandler } diff --git a/src/src/pages/news/news.ts b/src/src/pages/news/news.ts index 53057fc59dac29470499a31e6dbb13e177d9ad2a..86d30b379ca0cef30aa4509474d112770151272e 100644 --- a/src/src/pages/news/news.ts +++ b/src/src/pages/news/news.ts @@ -5,8 +5,7 @@ import { FacebookProvider } from '../../providers/facebook-provider'; @Component({ selector: 'page-news', - templateUrl: 'news.html', - providers:[FacebookProvider], + templateUrl: 'news.html' }) export class News { diff --git a/src/src/pages/programme/programme.html b/src/src/pages/programme/programme.html index 5a421270404fdfdfc0c80bd8645bc4888cde0be8..85ac5fd357940543e531412b5ae605c42e12a8e0 100644 --- a/src/src/pages/programme/programme.html +++ b/src/src/pages/programme/programme.html @@ -12,7 +12,7 @@ <ion-content padding> <ion-slides (ionSlideDidChange)="slideChanged()"> - <ion-slide *ngFor="let room of lecturesData"> + <ion-slide *ngFor="let room of lecturesProvider.lecturesData"> <ion-list no-lines> <ion-item style="height: 12em; border-bottom: 1px solid #dedede;" *ngFor="let time of room.times"> diff --git a/src/src/pages/programme/programme.ts b/src/src/pages/programme/programme.ts index 49db10025c8d3a638c2b1708ddbae0d7d065177e..a0d6e8d279aa525bb78593f270e23d4d53663af2 100644 --- a/src/src/pages/programme/programme.ts +++ b/src/src/pages/programme/programme.ts @@ -7,43 +7,30 @@ import { Slides } from 'ionic-angular'; @Component({ selector: 'page-programme', - templateUrl: 'programme.html', - providers:[LecturesProvider], + templateUrl: 'programme.html' }) export class Programme { @ViewChild(Slides) slides: Slides; - room: any = "0"; + room: any = ""; + rooms: any[] = []; + times: any[] = []; loading: any; lecturesData: any; - constructor(public navCtrl: NavController, public navParams: NavParams, private lecturesProvider:LecturesProvider, public loadingCtrl: LoadingController) { - + constructor(public navCtrl: NavController, public navParams: NavParams, public lecturesProvider: LecturesProvider, public loadingCtrl: LoadingController) { this.loading = this.loadingCtrl.create({ content: ` <ion-spinner ></ion-spinner>` }); - this.getdata(); + console.log("using lecturesprovider" + this.lecturesProvider); + this.lecturesData = this.lecturesProvider.lecturesData; + } + ionViewDidLoad() { console.log('ionViewDidLoad Programme'); } - getdata(){ - this.lecturesProvider.getJsonData().subscribe( - result => { - this.lecturesData=result.schedule; - console.log("Success : "+this.lecturesData); - }, - err =>{ - console.error("Error : "+err); - } , - () => { - this.room = this.lecturesData[0].name - console.log('getData completed'); - } - ); - - } cardClass(lecture){ switch(lecture.fs){ case "Psychologie":{ @@ -124,6 +111,6 @@ export class Programme { slideChanged() { let currentIndex = this.slides.getActiveIndex(); - this.room = this.lecturesData[currentIndex].name; + this.room = this.lecturesProvider.lecturesData[currentIndex].name; } } diff --git a/src/src/providers/lectures-provider.ts b/src/src/providers/lectures-provider.ts index 588041f19c5f02e1ba125261800b63fd4d171643..e7c19c353be810d1c431b98b69571daf16adf8db 100644 --- a/src/src/providers/lectures-provider.ts +++ b/src/src/providers/lectures-provider.ts @@ -1,15 +1,65 @@ import { Injectable } from '@angular/core'; import { Http } from '@angular/http'; import 'rxjs/add/operator/map'; +import { Storage } from '@ionic/storage'; + @Injectable() export class LecturesProvider { - constructor(public http: Http) { - console.log('Hello LecturesProvider Provider'); - } - getJsonData(){ - return this.http.get('assets/data/lectures.json').map(res => res.json()); + private isInitialized: boolean = false; + times: any[] = [] + lecturesversion: string; + lecturesData: any; + initial: any = null; + constructor(public http: Http, public storage: Storage) { + console.log("Lectures Provider instatiated"); + if (!this.initial){ + storage.ready().then(() => { + + storage.get("lecturesversion").then((version) => { + if (version){ + console.log('lectures version: '+ version); + } else { + console.log('no lectures data: new install'); + http.get('assets/data/lectures.json').map(res => res.json()).subscribe( + result => { + this.lecturesData=result.schedule; + this.initial = true; + console.log("Lectures loaded from json"); + + //return new LecturesProvider(http, storage, lecturesData); + }, + err =>{ + console.error("Error : "+err); + } , + () => { + // this.room = tlecturesData[0].name + console.log('getData completed'); + } + ); + + + + } + }); + }); + + + + + + + } } +} + +export function LecturesProviderFactory(http: Http, storage: Storage){ + + + + + + }