Skip to content
Snippets Groups Projects
Commit 1110d634 authored by wonko's avatar wonko
Browse files

refactored lecturesprovider for storage use

parent 4c1c1023
No related branches found
No related tags found
No related merge requests found
<?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>
......@@ -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(() => {
});
}
}
......@@ -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 }
......
......@@ -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 {
......
......@@ -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">
......
......@@ -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;
}
}
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){
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment