Skip to content

Commit

Permalink
#40 Merge branch 'develop' into localization
Browse files Browse the repository at this point in the history
# Conflicts:
#	CitizenApplication/app/app.ts
  • Loading branch information
skaldo committed Jun 4, 2016
2 parents f238ad9 + edabccd commit 617bd2d
Show file tree
Hide file tree
Showing 49 changed files with 1,121 additions and 322 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Android_Api_Key

AIzaSyCTDvPOMux4GiwFYSM_WNBqaivyHD1_7G8
3 changes: 3 additions & 0 deletions CitizenApplication/api_keys/maps/ios/Google_maps_iOS_API_Key
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Google_maps_iOS_API_Key

AIzaSyCxD2jkTLp-2cE8YWtx8leLCFHojWhwzhw
15 changes: 8 additions & 7 deletions CitizenApplication/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@
* Created by skaldo on the initial commit
* Added i18n support by tim284 on the 28.05.2016
* Reviewed by skaldo on the 29.05.2016 - inject pipe application-wide, restructured a bit.
* Merged by skaldo on the 04.06.2016
*/
import {App, Platform} from 'ionic-angular';
import {StatusBar} from 'ionic-native';
import {provide, PLATFORM_PIPES} from '@angular/core';
import {Provider, provide, PLATFORM_PIPES} from '@angular/core';
import {Http} from '@angular/http';
import {TranslateService, TranslateLoader, TranslateStaticLoader, TranslatePipe} from 'ng2-translate';
import {TabsPage} from './pages/tabs/tabs';
import {RestApiProvider} from './providers/data/RestApiProvider';
import {PersistentDataProvider} from './providers/data/PersistentDataProvider';
import {CitizenDataService} from './providers/data/CitizenDataService';
import {RestApiProvider, PersistentDataProvider, CitizenDataService} from './providers/data';
import {ConfigurationService} from './providers/config';
import {IStorage, InjectableLocalStorage} from './providers/storage';

@App({
template: '<ion-nav [root]="rootPage"></ion-nav>',
template: '<!-- custom-router-outlet></custom-router-outlet --><ion-nav [root]="rootPage"></ion-nav>',
config: {}, // http://ionicframework.com/docs/v2/api/config/Config/
// pipes: [TranslatePipe],
providers: [
provide(TranslateLoader, {
useFactory: (http: Http) => new TranslateStaticLoader(http, 'lang', '.json'),
deps: [Http]
}),
provide(PLATFORM_PIPES, {useValue: [TranslatePipe], multi: true}),
TranslateService, CitizenDataService, RestApiProvider, PersistentDataProvider],
new Provider(IStorage, { useClass: InjectableLocalStorage }),
TranslateService, CitizenDataService, RestApiProvider, PersistentDataProvider, ConfigurationService],
})
export class MyApp {
public rootPage: any = TabsPage;
Expand Down
51 changes: 38 additions & 13 deletions CitizenApplication/app/components/map/map.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {Component, ElementRef, OnInit} from '@angular/core';
import {Component, ElementRef, AfterViewInit, OnDestroy} from '@angular/core';
import {Geolocation} from 'ionic-native';
import {Logger, LoggerFactory} from '../../providers/logger';
import {ConfigurationService} from '../../providers/config';

/*
Created by skaldo and mmueller on the 09.05.2016.
Expand All @@ -10,32 +12,49 @@ import {Geolocation} from 'ionic-native';
selector: 'map',
templateUrl: 'build/components/map/map.html'
})
export class Map implements OnInit {
export class Map implements AfterViewInit, OnDestroy {
private map: google.maps.Map;
private markers: { [key: string]: google.maps.Marker; } = {};
private mapElement;

private logger: Logger;

private defaultMapOptions = {
zoom: 17,
mypTypeId: google.maps.MapTypeId.ROADMAP,
center: new google.maps.LatLng(49.4428949, 7.5893631),
zoom: 15,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
mapTypeIds: [
google.maps.MapTypeId.ROADMAP,
google.maps.MapTypeId.SATELLITE
]
},
zoomControl: true,
rotateControl: true
};

private defaultGeoLocationOptions = {
timeout: 10000,
enableHighAccuracy: true
};

constructor(private element: ElementRef) {
constructor(private element: ElementRef, private config: ConfigurationService) {
this.logger = new LoggerFactory().getLogger(this.config.misc.log_level, 'MapComponent', this.config.misc.log_pretty_print);
}

centerMap(center?: google.maps.LatLng) {
this.logger.debug('centering');
if (!center) {
this.logger.debug('getCurrentPosition');
Geolocation.getCurrentPosition(this.defaultGeoLocationOptions).then((position) => {
this.logger.debug('got location: ' + position);
let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
this.centerMap(latLng);
}).catch(error => {
// Handling the error.
console.log('Unable to get the current location. ' + error);
console.log('Setting: 49.4428949, 7.5893631 as center.');
this.logger.error('Unable to get the current location. ' + error);
this.logger.error('Setting: 49.4428949, 7.5893631 as center.');
this.centerMap(new google.maps.LatLng(49.4428949, 7.5893631));
});
return;
Expand All @@ -44,24 +63,30 @@ export class Map implements OnInit {
}

createMap() {
let element = this.element.nativeElement.children[0];
this.map = new google.maps.Map(element, this.defaultMapOptions);
console.log(element);
this.mapElement = this.element.nativeElement.children[0];
this.map = new google.maps.Map(this.mapElement, this.defaultMapOptions);
}

ngOnInit() {
ngAfterViewInit() {
this.createMap();
this.centerMap();
this.initPositionMarker();
}

ngOnDestroy() {
this.logger.debug('Removing the map element along with all the children.');
while (this.mapElement.firstChild) {
this.mapElement.removeChild(this.mapElement.firstChild);
}
}

initPositionMarker() {
Geolocation.getCurrentPosition(this.defaultGeoLocationOptions).then((position) => {
let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
this.addPositionMarker(latLng, 'Standort');
}).catch(error => {
// Handling the error.
console.log('Unable to get the current location. ' + error);
this.logger.error('Unable to get the current location. ' + error);
});
}

Expand Down Expand Up @@ -103,7 +128,7 @@ export class Map implements OnInit {
this.markers[name] = marker;
}

addBusMarker(position: google.maps.LatLng, name) {
addBusMarker(position: google.maps.LatLng, name) {
let markerLatLong = position;

let marker = new google.maps.Marker({
Expand Down
5 changes: 3 additions & 2 deletions CitizenApplication/app/pages/bus-detail/bus-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
<div [ngSwitch]="busViewType" class="container">
<div class="info" *ngSwitchWhen="'information'">
<div class="picture">
<div style="background-image: url({{bus.picture}});">
<!-- fix for iOS -->
<!--<div style="background-image: url({{bus.picture}});">-->
<img src="{{bus.picture}}">
</div>
<!--</div>-->
<figcaption></figcaption>
</div>
</div>
Expand Down
11 changes: 7 additions & 4 deletions CitizenApplication/app/pages/bus-detail/bus-detail.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {Page, NavController, NavParams} from 'ionic-angular';
import {IBus, Bus, IBusRealTimeData} from '../../providers/model';
import {CitizenDataService} from '../../providers/data/CitizenDataService';
import {CitizenDataService} from '../../providers/data';
import {Map} from '../../components/map/map';
import {Logger, LoggerFactory} from '../../providers/logger';
import {ConfigurationService} from '../../providers/config';

/*
Generated class for the BusDetailPage page.
Expand All @@ -17,6 +19,7 @@ export class BusDetailPage {
private schedule: { lineId: number; time: Date; };
private _realTimeData: IBusRealTimeData;
private busId: number;
private logger: Logger;

get realTimeData(): IBusRealTimeData {
return this._realTimeData;
Expand All @@ -28,13 +31,14 @@ export class BusDetailPage {
public bus: Bus = new Bus();
public busViewType = 'information';

constructor(public nav: NavController, private navParams: NavParams, private cDS: CitizenDataService) {
constructor(public nav: NavController, private navParams: NavParams, private cDS: CitizenDataService, private config: ConfigurationService) {
this.schedule = navParams.data;
// Caution, change this to the bus ID in the next iteration.
this.busId = this.schedule.lineId;
this.fetchBus();
this.fetchBusRealTimeData();
// Start some update interval for the posititon of the bus.
this.logger = new LoggerFactory().getLogger(config.misc.log_level, 'BusDetailPage', config.misc.log_pretty_print);
}

/**
Expand Down Expand Up @@ -68,8 +72,7 @@ export class BusDetailPage {
this.cDS.getBusses().subscribe(data => {
id = id || this.busId;
this.bus = data.busses.find(bus => {
// TODO: Iteration 2 - instead of line use the bus id.
return bus.id === this.schedule.lineId;
return bus.id === id;
});
});
}
Expand Down
6 changes: 5 additions & 1 deletion CitizenApplication/app/pages/home/home.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {Page, NavController, Toast} from 'ionic-angular';
import {StopListPage} from '../stop-list/stop-list';
import {BusDetailPage} from '../bus-detail/bus-detail';
import {ConfigurationService} from '../../providers/config';
import {Logger, LoggerFactory} from '../../providers/logger';

/*
Generated class for the HomePage page.
Expand All @@ -14,8 +16,10 @@ import {BusDetailPage} from '../bus-detail/bus-detail';
export class HomePage {
private ip: string;
private reqNumber: number;
constructor(public nav: NavController) {
private logger: Logger;
constructor(public nav: NavController, private config: ConfigurationService) {
this.reqNumber = 0;
this.logger = new LoggerFactory().getLogger(config.misc.log_level, 'HomePage', config.misc.log_pretty_print);
}

goToStops() {
Expand Down
8 changes: 7 additions & 1 deletion CitizenApplication/app/pages/map/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@
import {Page, NavController} from 'ionic-angular';
import {ViewChild} from '@angular/core';
import {Map} from '../../components/map/map';
import {Logger, LoggerFactory} from '../../providers/logger';
import {ConfigurationService} from '../../providers/config';

@Page({
templateUrl: 'build/pages/map/map.html',
directives: [Map]
})
export class MapPage {

private logger: Logger;

@ViewChild(Map) map: Map;
constructor(public nav: NavController) {
constructor(public nav: NavController, private config: ConfigurationService) {
this.logger = new LoggerFactory().getLogger(config.misc.log_level, 'MapPage', config.misc.log_pretty_print);
}
centerMap() {
this.map.centerMap();
Expand Down
8 changes: 6 additions & 2 deletions CitizenApplication/app/pages/stop-detail/stop-detail.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {Page, NavController, NavParams, ActionSheet} from 'ionic-angular';
import {IStop} from '../../providers/model/Stop';
import {IStop} from '../../providers/model';
import {BusDetailPage} from '../bus-detail/bus-detail';
import {Logger, LoggerFactory} from '../../providers/logger';
import {ConfigurationService} from '../../providers/config';

/*
Generated class for the StopDetailPage page.
Expand All @@ -13,8 +15,10 @@ import {BusDetailPage} from '../bus-detail/bus-detail';
})
export class StopDetailPage {
private stop: IStop;
constructor(public nav: NavController, private navParams: NavParams) {
private logger: Logger;
constructor(public nav: NavController, private navParams: NavParams, private config: ConfigurationService) {
this.stop = navParams.data;
this.logger = new LoggerFactory().getLogger(config.misc.log_level, 'StopDetailPage', config.misc.log_pretty_print);
}

infoClicked(schedule) {
Expand Down
19 changes: 9 additions & 10 deletions CitizenApplication/app/pages/stop-list/stop-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
*/

import {Page, NavController, Refresher} from 'ionic-angular';
import {Point} from '../../providers/model/geojson/Point';
import {Point, IStop} from '../../providers/model';
import {StopDetailPage} from '../stop-detail/stop-detail';
import {CitizenDataService} from '../../providers/data/CitizenDataService';
import {IStop} from '../../providers/model/Stop';
import {CitizenDataService} from '../../providers/data';
import {Logger, LoggerFactory} from '../../providers/logger';
import {ConfigurationService} from '../../providers/config';

class ViewStop implements IStop {
public name: string;
Expand Down Expand Up @@ -63,8 +64,10 @@ class ViewStop implements IStop {
export class StopListPage {
// private searchText: String;
private stops: Array<ViewStop> = new Array<ViewStop>();
constructor(public nav: NavController, private cDS: CitizenDataService) {
private logger: Logger;
constructor(public nav: NavController, private cDS: CitizenDataService, private config: ConfigurationService) {
this.refreshStops();
this.logger = new LoggerFactory().getLogger(config.misc.log_level, 'StopListPage', config.misc.log_pretty_print);
}

public onSearch(event) {
Expand Down Expand Up @@ -100,9 +103,9 @@ export class StopListPage {
let observable = this.cDS.getStops();
this.stops = new Array<ViewStop>();
observable.subscribe(data => {
this.log('Stops recieved');
this.logger.debug('Stops recieved');
data.stops.forEach(stop => {
this.log('UI: got stop' + stop.name);
this.logger.debug('UI: got stop' + stop.name);
// faking time in order to prevent errors:
stop.schedule.forEach(item => {
item.time = this.getRandomTime();
Expand All @@ -112,8 +115,4 @@ export class StopListPage {
});
return observable;
}

private log(message: string): void {
console.log('StopListPage: ' + message);
}
}
Loading

0 comments on commit 617bd2d

Please sign in to comment.