Skip to content

Commit

Permalink
UI updates. Beta release replacing old map widget.
Browse files Browse the repository at this point in the history
  • Loading branch information
webprofusion-chrisc committed Jun 22, 2016
1 parent ebbb0b8 commit 864a4b9
Show file tree
Hide file tree
Showing 23 changed files with 238 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ export class GoogleMapsWeb extends Base implements IMapProvider {

newMarker.poi = poi;

var anchorElement = document.getElementById("body");
google.maps.event.addListener(newMarker, 'click', function () {
//broadcast details of selected POI
if (console) console.log("POI clicked:" + this.poi.ID);
Expand Down
1 change: 1 addition & 0 deletions App/Ionic2/ocm-app/app/core/ocm/model/UserProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
Location: string;
WebsiteURL: string;
ReputationPoints: number;
ProfileImageURL:string;
}
63 changes: 27 additions & 36 deletions App/Ionic2/ocm-app/app/core/ocm/services/APIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,23 +141,18 @@ export class APIClient extends Base {

}

performSignIn(username: string, password: string) {
performSignIn(username: string, password: string): Promise<any> {

var serviceURL = this.serviceBaseURL + "/profile/authenticate/";

var data = { "emailaddress": username, "password": password };

//observable result is wrapper in a Promise for API consumer to handle result/rejection etc
return new Promise((resolve, reject) => {
this.http.post(serviceURL, JSON.stringify(data)).subscribe(res => {
if (res.status >= 300) {
reject(new AsyncResult(null, true, "LoginFailed", res));
} else {
this.authResponse = res.json();
resolve(this.authResponse);
}
});
});

return this.http.post(serviceURL, JSON.stringify(data)).map(res => {
this.authResponse = res.json();
return this.authResponse;
}).toPromise();
}

performSubmission(type: SubmissionType, data: any): Promise<any> {
Expand All @@ -168,7 +163,7 @@ export class APIClient extends Base {
return this.submitUserComment(data);
}
if (type == SubmissionType.Media) {
this.submitMediaItem(data);
return this.submitMediaItem(data);
}
}

Expand All @@ -177,23 +172,19 @@ export class APIClient extends Base {

this.log("[api] Submitting user comment");

return this.http.post(this.serviceBaseURL + "/comment/", jsonString, this.getHttpRequestOptions()).map(res => {
return res.json();
}).toPromise();


return this.http.post(this.serviceBaseURL + "/comment/", jsonString, this.getHttpRequestOptions())
.map(res => {
return res.json();
}).toPromise();
}

submitMediaItem(data): Promise<any> {
var jsonString = JSON.stringify(data);
//alert(JSON.stringify(data));
//return new Promise(resolve=>{resolve(null);});
return new Promise(resolve => {
this.http.post(this.serviceBaseURL + "/comment/?action=mediaitem_submission&format=json", jsonString, this.getHttpRequestOptions()).subscribe(res => {
resolve(res.json());
});
});

return this.http.post(this.serviceBaseURL + "/mediaitem/", jsonString, this.getHttpRequestOptions())
.map(res => {
res.json();
}).toPromise();
}

getPanoramioLocationPhotos(pos: GeoLatLng): Promise<any> {
Expand All @@ -212,7 +203,7 @@ export class APIClient extends Base {
var serviceURL = this.serviceBaseURL + "/poi/?client=" + this.clientName + "&output=json&includecomments.=true&chargepointid=" + id;
if (disableCaching) serviceURL += "&enablecaching=false";
if (!errorcallback) errorcallback = this.handleGeneralAjaxError;
var ajaxSettings: JQueryAjaxSettings = {
type: "GET",
url: serviceURL + "&callback=" + callbackname,
Expand All @@ -222,13 +213,13 @@ export class APIClient extends Base {
crossDomain: true,
error: errorcallback
};
$.ajax(ajaxSettings);
}
fetchGeocodeResult(address, successCallback, authSessionInfo, errorCallback) {
var authInfoParams = this.getAuthParamsFromSessionInfo(authSessionInfo);
var ajaxSettings: JQueryAjaxSettings = {
type: "GET",
url: this.serviceBaseURL + "/geocode/?client=" + this.clientName + "&address=" + address + "&output=json&verbose=false&camelcase=true&" + authInfoParams,
Expand All @@ -238,17 +229,17 @@ export class APIClient extends Base {
success: successCallback,
error: (errorCallback != null ? errorCallback : this.handleGeneralAjaxError)
};
$.ajax(ajaxSettings);
}
submitLocation(data, authSessionInfo, completedCallback, failureCallback) {
var authInfoParams = this.getAuthParamsFromSessionInfo(authSessionInfo);
var jsonString = JSON.stringify(data);
var ajaxSettings: JQueryAjaxSettings = {
type: "POST",
url: this.serviceBaseURL + "/?client=" + this.clientName + "&action=cp_submission&format=json" + authInfoParams,
Expand All @@ -257,10 +248,10 @@ export class APIClient extends Base {
crossDomain: true,
error: this.handleGeneralAjaxError
};
$.ajax(ajaxSettings);
}
*/


Expand Down
4 changes: 2 additions & 2 deletions App/Ionic2/ocm-app/app/core/ocm/services/AppManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ export class AppManager extends Base {

nav.present(this.loading);
}
public dismissLoadingProgress() {
this.loading.dismiss();
public dismissLoadingProgress(): Promise<any>{
return this.loading.dismiss();
}

/**
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion App/Ionic2/ocm-app/app/pages/comment/comment.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ion-navbar *navbar primary>
<ion-navbar *navbar default>
<ion-title>
Add Comment
</ion-title>
Expand All @@ -9,6 +9,7 @@
<h1>{{poi.AddressInfo.Title}}</h1>
<p>{{poi.AddressInfo.AddressLine1}}</p>
</div>
<p padding>Recent Check-ins are a big help to other drivers when planning their journey. Tell everyone what you thought about this charging location. </p>

<ion-list>

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

Expand All @@ -15,14 +15,14 @@ export class CommentPage {

commentTypes: any;
checkinTypes: any;
constructor(private navParams: NavParams, public appManager: AppManager, public nav: NavController, private zone:NgZone) {
constructor(private navParams: NavParams, private appManager: AppManager, private nav: NavController, private view: ViewController, private zone: NgZone) {

this.commentModel = <UserComment>{
ChargePointID: this.navParams.get('id'),
Comment: "",
CheckinStatusTypeID: 0,
CheckinStatusTypeID: 10,
UserCommentTypeID: 10,
Rating: 4
Rating: null
};

this.poi = this.navParams.get('poi');
Expand All @@ -37,7 +37,8 @@ export class CommentPage {

cancel() {

this.nav.pop();
//this.nav.pop();
this.view.dismiss();
}

add() {
Expand All @@ -52,25 +53,20 @@ export class CommentPage {


this.appManager.submitComment(this.commentModel).then((response) => {
alert("Your comment has been Published.");
this.zone.run(()=>{
this.nav.pop();
});
}) /*, (rejection) => {
/*if (rejection == null && rejection.ok && rejection.ok == true) {
this.nav.pop();
} else {
alert("There was a problem submitting your comment.");
loading.dismiss();
}*/
.catch((rejected) => {

alert("There was a problem submitting your comment." + JSON.stringify(rejected));

loading.dismiss();

});
this.appManager.log("Comment submitted");
loading.dismiss().then(() => {
this.view.dismiss();
}
);


}, (rejection) => {

this.appManager.showToastNotification(this.nav, "There was a problem submitting your comment.");

loading.dismiss();

});

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ion-navbar *navbar primary>
<ion-navbar *navbar default>
<ion-title>
Edit Favourite
</ion-title>
Expand Down
12 changes: 7 additions & 5 deletions App/Ionic2/ocm-app/app/pages/journeys/journeys.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ion-navbar *navbar primary>
<ion-navbar *navbar default>
<ion-title>
Journeys
</ion-title>
Expand Down Expand Up @@ -35,10 +35,12 @@

<ion-list *ngFor="let s of journey.Stages">
<ion-list-header style="font-size:1.5rem;">
{{s.Title}} -
<ion-icon name="ios-car"></ion-icon> 35 Miles
<ion-icon name="time"></ion-icon> 32 Minutes
<ion-icon name="flash"></ion-icon> 24kWh
{{s.Title}}

<ion-icon name="ios-car"></ion-icon> --
<ion-icon name="time"></ion-icon> --
<ion-icon name="flash"></ion-icon> --

</ion-list-header>

<ion-item *ngFor="let w of s.WayPoints">
Expand Down
8 changes: 4 additions & 4 deletions App/Ionic2/ocm-app/app/pages/mediaupload/mediaupload.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ <h1>{{poi.AddressInfo.Title}}</h1>
</p>
<div>

<div *ngIf="mode=='cordova'">
<div *ngIf="isBrowserMode()==false">
<button (click)="loadCameraOrLibraryImage()">Select Photo</button>
</div>

<div *ngIf="mode=='web'">
<div *ngIf="isBrowserMode()==true">
<label class="button button-default button-icon-left upload">
<span class="button-inner">
<ion-icon name="camera" role="img" class="ion-md-camera" aria-label="camera"></ion-icon>
Expand All @@ -42,7 +42,7 @@ <h1>{{poi.AddressInfo.Title}}</h1>
<ion-buttons start>

<button (click)="rotateImage()"> <ion-icon name="refresh"></ion-icon> Rotate</button>
<button (click)="performUpload()" primary> <ion-icon name="cloud-upload"></ion-icon> Upload Photo</button>

</ion-buttons>

</ion-toolbar>
Expand Down Expand Up @@ -76,7 +76,7 @@ <h1>{{poi.AddressInfo.Title}}</h1>
</button>
</ion-buttons>
<ion-buttons end>
<button royal>
<button (click)="performUpload()">
Upload
<ion-icon name="send"></ion-icon>
</button>
Expand Down
33 changes: 22 additions & 11 deletions App/Ionic2/ocm-app/app/pages/mediaupload/mediaupload.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component} from '@angular/core';
import {NavController, NavParams, Modal, Alert} from 'ionic-angular';
import {NavController, NavParams, Modal, Alert, ViewController} from 'ionic-angular';
import {AppManager} from '../../core/ocm/services/AppManager';
import {Camera} from 'ionic-native';

Expand All @@ -18,7 +18,7 @@ export class MediaUploadPage {
chargePointId: number;
poi: any;

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


this.processingQuality = 0.8;
Expand All @@ -29,13 +29,13 @@ export class MediaUploadPage {

this.chargePointId = this.navParams.get('id');
this.poi = this.navParams.get('poi');
this.comment = "test";
this.comment = "";
}

loadCameraOrLibraryImage() {

var _context = this;
if (this.mode == "cordova") {
if (!this.isBrowserMode()) {
Camera.getPicture({ targetWidth: this.targetWidth }).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64:
Expand All @@ -47,7 +47,7 @@ export class MediaUploadPage {
});
}

if (this.mode == "web") {
if (this.isBrowserMode()) {
var reader = new FileReader();

reader.onload = function () {
Expand All @@ -68,6 +68,11 @@ export class MediaUploadPage {

}

isBrowserMode():boolean{

return (this.appManager.isPlatform("core") ||this.appManager.isPlatform("mobileweb"));
}

processImage() {
var _appContext = this;
if (this.imgData != null) {
Expand Down Expand Up @@ -149,17 +154,23 @@ export class MediaUploadPage {

this.appManager.showLoadingProgress(this.nav, "Uploading photo..");
this.appManager.submitMediaItem(submission).then((result) => {
this.appManager.dismissLoadingProgress();
this.appManager.showToastNotification(this.nav, "Upload completed");
this.nav.pop();
this.appManager.dismissLoadingProgress().then(() => {
this.appManager.showToastNotification(this.nav, "Upload completed");
//this.nav.pop();
this.view.dismiss();
});

//todo: refresh POI details to show new upload
}, (rejected) => {
this.appManager.dismissLoadingProgress();
this.appManager.showToastNotification(this.nav, "Upload failed, please try again.");
this.appManager.dismissLoadingProgress().then(() => {

this.appManager.showToastNotification(this.nav, "Upload failed, please try again.");
});

});
}

cancel() {
this.nav.pop();
this.view.dismiss();
}
}
Loading

0 comments on commit 864a4b9

Please sign in to comment.