Skip to content

Commit

Permalink
Migrate to Ionic 2.0 beta 8
Browse files Browse the repository at this point in the history
  • Loading branch information
webprofusion-chrisc committed Jun 13, 2016
1 parent e816696 commit 056c663
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 78 deletions.
47 changes: 24 additions & 23 deletions App/Ionic2/ocm-app/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {App, Platform, Config, Events, NavController} from 'ionic-angular';
import {Platform, Config, Events, NavController, ionicBootstrap} from 'ionic-angular';
import {StatusBar} from 'ionic-native';
import {Http, ConnectionBackend} from '@angular/http';
import {OnInit, provide, enableProdMode} from '@angular/core';
import {Component, OnInit, provide, enableProdMode} from '@angular/core';

import {APIClient} from './core/ocm/services/APIClient';
import {AppManager} from './core/ocm/services/AppManager'
Expand All @@ -20,25 +20,8 @@ declare var Connection: any;

enableProdMode();

@App({
template: '<ion-nav [root]="rootPage"></ion-nav>',
providers: [
AppManager,
POIManager,
Events,
provide(TranslateLoader, {
useFactory: (http: Http) => new TranslateStaticLoader(http, 'lang', '.json'),
deps: [Http]
}),
TranslateService,
APIClient,
SubmissionQueue,
JourneyManager,
ReferenceDataManager
],
config: {
mode: "ios"
}
@Component({
template: '<ion-nav [root]="rootPage"></ion-nav>'
})


Expand Down Expand Up @@ -80,8 +63,8 @@ export class OpenChargeMapApp extends Base implements OnInit {
//we can switch over to Native Maps API
}
if (platform.is("cordova") && StatusBar) {
// StatusBar.overlaysWebView(false);
// StatusBar.hide();//styleDefault();
// StatusBar.overlaysWebView(false);
// StatusBar.hide();//styleDefault();


}
Expand Down Expand Up @@ -168,3 +151,21 @@ export class OpenChargeMapApp extends Base implements OnInit {
}
}

ionicBootstrap(OpenChargeMapApp, [
AppManager,
POIManager,
Events,
provide(TranslateLoader, {
useFactory: (http: Http) => new TranslateStaticLoader(http, 'lang', '.json'),
deps: [Http]
}),
TranslateService,
APIClient,
SubmissionQueue,
JourneyManager,
ReferenceDataManager
], {
//config
prodMode:true,
mode:"ios"
});
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class GoogleMapsNative extends Base implements IMapProvider {
if (this.map == null) {
var mapCanvas = document.getElementById(mapCanvasID);
this.map = plugin.google.maps.Map.getMap();
this.map.setDebuggable(true);
//this.map.setDebuggable(true);
var mapManagerContext = this;

//setup map manipulation events
Expand Down Expand Up @@ -205,7 +205,8 @@ this.map.setDebuggable(true);
}
}, (marker) => {
//show full details when info window tapped
marker.addEventListener(plugin.google.maps.event.INFO_CLICK, function () {
//marker.addEventListener(plugin.google.maps.event.INFO_CLICK, function () {
marker.addEventListener(plugin.google.maps.event.MARKER_CLICK, function () {
var markerTitle = marker.getTitle();
var poiId = markerTitle.substr(4, markerTitle.indexOf(":") - 4);

Expand Down
6 changes: 3 additions & 3 deletions App/Ionic2/ocm-app/app/pages/comment/comment.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {Page, NavController, NavParams, Modal, Alert, Loading} from 'ionic-angular';
import {Component} from '@angular/core';
import {NavController, NavParams, Modal, Alert, Loading} from 'ionic-angular';
import {AppManager} from '../../core/ocm/services/AppManager';
import {UserComment} from '../../core/ocm/model/AppModels';


@Page({
@Component({
templateUrl: 'build/pages/comment/comment.html',
directives: []
})
Expand Down
5 changes: 3 additions & 2 deletions App/Ionic2/ocm-app/app/pages/journeys/favourite-editor.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {Page, NavParams, NavController} from 'ionic-angular';
import {Component} from '@angular/core';
import {NavParams, NavController} from 'ionic-angular';
import {AppManager} from '../../core/ocm/services/AppManager';
import {Journey, WayPoint, GeoLatLng, BookmarkedPOI} from '../../core/ocm/model/AppModels';
import {JourneyManager} from '../../core/ocm/services/JourneyManager';

@Page({
@Component({
templateUrl: 'build/pages/journeys/favourite-editor.html',
})

Expand Down
9 changes: 5 additions & 4 deletions App/Ionic2/ocm-app/app/pages/journeys/journeys.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {Page, Modal, NavController, Alert} from 'ionic-angular';
import {Component} from '@angular/core';
import {Modal, NavController, Alert} from 'ionic-angular';
import {AppManager} from '../../core/ocm/services/AppManager';
import {Journey, WayPoint, GeoLatLng} from '../../core/ocm/model/AppModels';
import {JourneyManager} from '../../core/ocm/services/JourneyManager';
import {APIClient} from '../../core/ocm/services/APIClient';
import {POIDetailsPage} from '../poi-details/poi-details';

@Page({
@Component({
templateUrl: 'build/pages/journeys/journeys.html',
})

Expand All @@ -16,9 +17,9 @@ export class JourneysPage {

constructor(private appManager: AppManager, private nav: NavController, private journeyManager: JourneyManager, private api: APIClient) {

this.discoverImages();
//this.discoverImages();

console.log(JSON.stringify(this.journeyManager.journeys, null, 4));
//console.log(JSON.stringify(this.journeyManager.journeys, null, 4));
}

discoverImages() {
Expand Down
13 changes: 3 additions & 10 deletions App/Ionic2/ocm-app/app/pages/mediaupload/mediaupload.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {Page, NavController, NavParams, Modal, Alert} from 'ionic-angular';
import {Component} from '@angular/core';
import {NavController, NavParams, Modal, Alert} from 'ionic-angular';
import {AppManager} from '../../core/ocm/services/AppManager';
import {Camera} from 'ionic-native';

@Page({
@Component({
templateUrl: 'build/pages/mediaupload/mediaupload.html'
})
export class MediaUploadPage {
Expand Down Expand Up @@ -31,14 +32,6 @@ export class MediaUploadPage {
this.comment = "test";
}

onPageWillEnter() {



}



loadCameraOrLibraryImage() {

var _context = this;
Expand Down
23 changes: 17 additions & 6 deletions App/Ionic2/ocm-app/app/pages/poi-details/poi-details.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {IonicApp, Page, NavController, NavParams, ViewController, Modal, ActionSheet} from 'ionic-angular';
import {Component} from '@angular/core';
import {NavController, NavParams, ViewController, Modal, ActionSheet} from 'ionic-angular';
import {TranslateService, TranslatePipe} from 'ng2-translate/ng2-translate';
import {AppManager} from '../../core/ocm/services/AppManager';
import {MediaUploadPage} from '../mediaupload/mediaupload';
import {CommentPage} from '../comment/comment';
import {FavouriteEditorPage} from '../journeys/favourite-editor';

@Page({
@Component({
templateUrl: 'build/pages/poi-details/poi-details.html',
pipes: [TranslatePipe]
})
Expand All @@ -15,10 +16,14 @@ export class POIDetailsPage {
selectedTab: string;
json: string;

constructor(private appManager: AppManager, private nav: NavController, navParams: NavParams, private translate: TranslateService, private view: ViewController) {
constructor(private appManager: AppManager, private nav: NavController, private navParams: NavParams, private translate: TranslateService, private view: ViewController) {

// If we navigated to this page, we will have an item available as a nav param
this.poi = navParams.get('item');


//this.json = JSON.stringify(this.poi, null, 1);

this.poi = this.navParams.get('item');
this.selectedTab = "location";

//create temporary properties for view model
Expand All @@ -36,8 +41,10 @@ export class POIDetailsPage {
} else {
this.poi._hasComments = false;
}
}

//this.json = JSON.stringify(this.poi, null, 1);
ionViewWillEnter() {

}
get staticMapURL(): string {

Expand Down Expand Up @@ -152,5 +159,9 @@ export class POIDetailsPage {
this.nav.pop();
}


dismiss() {
if (console && console.log) {
console.log("in poi details dismiss");
}
}
}
7 changes: 4 additions & 3 deletions App/Ionic2/ocm-app/app/pages/profile/profile.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {Page, NavController, Modal, Alert} from 'ionic-angular';
import {Component} from '@angular/core';
import {NavController, Modal, Alert} from 'ionic-angular';
import {AppManager} from '../../core/ocm/services/AppManager';
import {SignInPage} from '../signin/signin';
import {MediaUploadPage} from '../mediaupload/mediaupload';
import {CommentPage} from '../comment/comment';

@Page({
@Component({
templateUrl: 'build/pages/profile/profile.html'
})
export class ProfilePage {
Expand All @@ -14,7 +15,7 @@ export class ProfilePage {

}

onPageDidEnter() {
ionViewDidEnter() {

this.userProfile = this.appManager.getUserProfile();

Expand Down
2 changes: 1 addition & 1 deletion App/Ionic2/ocm-app/app/pages/search/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ion-spinner></ion-spinner>
</button>
</ion-buttons>
<ion-searchbar [(ngModel)]="searchKeyword" (input)="getPlacesAutoComplete($event)" (cancel)="onPlaceSearchCancel($event)">
<ion-searchbar [(ngModel)]="searchKeyword" (ionInput)="getPlacesAutoComplete($event)" (ionCancel)="onPlaceSearchCancel($event)">
[debounce]="500"></ion-searchbar>
<ion-buttons end>
<button (click)="openSearchOptions()" >
Expand Down
35 changes: 21 additions & 14 deletions App/Ionic2/ocm-app/app/pages/search/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// <reference path="../../lib/typings/collections/collections.d.ts" />
import {Component, OnInit} from '@angular/core';
import {Http} from '@angular/http';
import {IonicApp, Page, NavController, NavParams, Events, Platform, Loading, Modal} from 'ionic-angular';
import {NavController, NavParams, Events, Platform, Loading, Modal} from 'ionic-angular';
import {TranslateService, TranslatePipe} from 'ng2-translate/ng2-translate';
import {Keyboard} from 'ionic-native';
import {PlaceSearchResult, GeoLatLng, POISearchParams} from '../../core/ocm/model/AppModels';
Expand All @@ -17,7 +17,7 @@ import {SettingsPage} from '../settings/settings';
import {SignInPage} from '../signin/signin';


@Page({
@Component({
templateUrl: 'build/pages/search/search.html',
pipes: [TranslatePipe] // add in each component to invoke the transform method

Expand All @@ -35,6 +35,7 @@ export class SearchPage extends Base implements OnInit {
private placeSearchActive: boolean = false;
private searchKeyword: string;
private placeSearchFocussed: boolean = false;
private searchOnDemand: boolean = true;
constructor(
private appManager: AppManager,
private nav: NavController,
Expand Down Expand Up @@ -64,13 +65,13 @@ export class SearchPage extends Base implements OnInit {

}

onPageDidEnter() {
ionViewDidEnter() {
this.log("Entered search page.", LogLevel.VERBOSE);
//give input focus to native map
this.mapping.focusMap();
}

onPageWillLeave() {
ionViewWillLeave() {
//remove input focus from native map
this.log("Leavings search page.", LogLevel.VERBOSE);
this.mapping.unfocusMap();
Expand Down Expand Up @@ -196,7 +197,13 @@ export class SearchPage extends Base implements OnInit {


refreshResultsAfterMapChange() {
this.log("Refreshing Results..", LogLevel.VERBOSE);
if (!this.searchOnDemand) {
this.log("Skipping refresh, search on demand disabled..", LogLevel.VERBOSE);
return;
} else {
this.log("Refreshing Results..", LogLevel.VERBOSE);
}


this.initialResultsShown = true;
//this.appState.isSearchInProgress = true;
Expand Down Expand Up @@ -311,19 +318,19 @@ export class SearchPage extends Base implements OnInit {


this.log("Viewing/fetching POI Details " + args.poiId);

this.searchOnDemand = false; //suspend searches
this.poiManager.getPOIById(args.poiId, true).subscribe(poi => {

var poiDetailsModal = Modal.create(POIDetailsPage, { item: poi });
poiDetailsModal.onDismiss(()=>{
let poiDetailsModal = Modal.create(POIDetailsPage, { item: poi });

poiDetailsModal.onDismiss(() => {
//should focus map again..
this.mapping.focusMap();
this.log("Dismissing POI Details.");
this.mapping.focusMap();
this.searchOnDemand = true;
});
this.mapping.unfocusMap();
this.nav.present(poiDetailsModal).then(() => {
poiDetailsModal.showBackButton(true);
})
this.nav.present(poiDetailsModal);

}, (err) => {

Expand Down Expand Up @@ -402,7 +409,7 @@ export class SearchPage extends Base implements OnInit {
}
getPlacesAutoComplete() {

this.appManager.showToastNotification(this.nav, "Starting lookup for "+this.searchKeyword);
this.appManager.showToastNotification(this.nav, "Starting lookup for " + this.searchKeyword);
/*let loading = Loading.create({
content: "Searching..",
dismissOnPageChange: true,
Expand Down
6 changes: 3 additions & 3 deletions App/Ionic2/ocm-app/app/pages/settings/settings.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {Page} from 'ionic-angular';
import {Component} from '@angular/core';
import {AppManager} from '../../core/ocm/services/AppManager';
import {POIManager} from '../../core/ocm/services/POIManager';
import {SearchSettings} from '../../core/ocm/model/AppModels';

@Page({
@Component({
templateUrl: 'build/pages/settings/settings.html'
})
export class SettingsPage {
Expand All @@ -28,7 +28,7 @@ export class SettingsPage {
//TODO reference data manager with filtered versions of reference type lists
}

onPageWillLeave() {
ionViewWillLeave() {
//save search settings
this.appManager.searchSettings=this.searchSettings;
this.appManager.saveSearchSettings();
Expand Down
5 changes: 3 additions & 2 deletions App/Ionic2/ocm-app/app/pages/signin/signin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {Page, NavController, NavParams, Alert, Loading} from 'ionic-angular';
import {Component} from '@angular/core';
import {NavController, NavParams, Alert, Loading} from 'ionic-angular';
import {AppManager} from '../../core/ocm/services/AppManager';
import {UserProfile, AsyncResult} from '../../core/ocm/model/AppModels';


@Page({
@Component({
templateUrl: 'build/pages/signin/signin.html'
})
export class SignInPage {
Expand Down
4 changes: 2 additions & 2 deletions App/Ionic2/ocm-app/app/pages/tabs/tabs.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {Page} from 'ionic-angular';
import {Component} from '@angular/core';
import {SearchPage} from '../search/search';
import {JourneysPage} from '../journeys/journeys';
import {SettingsPage} from '../settings/settings';
import {ProfilePage} from '../profile/profile';
import {AppManager} from '../../core/ocm/services/AppManager';

@Page({
@Component({
templateUrl: 'build/pages/tabs/tabs.html'
})
export class TabsPage {
Expand Down
Loading

0 comments on commit 056c663

Please sign in to comment.