Skip to content

Commit

Permalink
correct error
Browse files Browse the repository at this point in the history
  • Loading branch information
Liyuse committed Apr 29, 2018
1 parent 96514ba commit 497395d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 34 deletions.
10 changes: 5 additions & 5 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@
<edit-config file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription">
<string>Required to send machine location.</string>
</edit-config>
<plugin name="cordova-plugin-geolocation" spec="^4.0.1">
<variable name="GEOLOCATION_USAGE_DESCRIPTION" value="To locate you" />
</plugin>
<plugin name="cordova-plugin-advanced-http" spec="^1.11.1" />
<plugin name="cordova.plugins.diagnostic" spec="^4.0.5" />
<plugin name="cordova-plugin-googlemaps" spec="^2.2.9">
<variable name="API_KEY_FOR_IOS" value="AIzaSyDYBD9kcnAd-Zcf-hn5d_Aq9Y2vLgqDfsw" />
<variable name="API_KEY_FOR_ANDROID" value="(API_KEY_FOR_ANDROID)" />
<variable name="LOCATION_WHEN_IN_USE_DESCRIPTION" value="This app wants to get your location while this app runs only." />
<variable name="LOCATION_ALWAYS_USAGE_DESCRIPTION" value="This app wants to get your location always, even this app runs in background." />
</plugin>
<plugin name="cordova-plugin-geolocation" spec="^4.0.1">
<variable name="GEOLOCATION_USAGE_DESCRIPTION" value="To locate you" />
</plugin>
<plugin name="cordova.plugins.diagnostic" spec="^4.0.5" />
<plugin name="cordova-plugin-advanced-http" spec="^1.11.1" />
<engine name="browser" spec="5.0.3" />
</widget>
1 change: 1 addition & 0 deletions src/app/cafe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export class Cafe {
fullness: number;
place_id: number;
website: string;
// busy_array: Array<number>;
}
22 changes: 9 additions & 13 deletions src/pages/details/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,29 @@
<ion-content class=" cards-bg">

<ion-card class="cards-list-demo">
<!-- Cafe name -->
<ion-card-header>
{{item["name"]}}
</ion-card-header>

<ion-list detail-none>
<!-- user input seat availability -->
<button ion-item>
<button ion-item detail-none>
<ion-icon name='ios-stats-outline' item-start></ion-icon>
Current Seat Availability
{{item["status"]}}
<ion-icon [ngStyle]="{'color': item.status, 'position': 'absolute', 'right': '25px' }" name="radio-button-on"></ion-icon>
</button>
</ion-list>
<p>
<!-- button version of updating seat status -->
<!-- <button ion-button (click)="updateStatus({'status': 'green'})" color="secondary" block>Empty</button>
<button ion-button (click)="updateStatus({'status': 'orange'})" color="orange" block>Filling</button>
<button ion-button (click)="updateStatus({'status': 'red'})" color="danger" block>Full</button> -->

<ion-item>
<ion-label>How full is {{item["name"]}}?</ion-label>
<ion-range #x (ionChange)="changeGradient(x.ratio, item.busyness[0][0])" min="0" max="100" step="5" color="{{item.color}}" [(ngModel)]= item.busyness[0][1]></ion-range>
<!--<button ion-button (click)="SetNewPercent()" color="danger">Submit</button>-->

<ion-item>
<ion-label>How full is {{item["name"]}} {{percent}}?</ion-label>
<ion-range min="0" max="100" step="5" color="secondary" [(ngModel)]= "percent"></ion-range>
</ion-item>
</p>

Expand All @@ -42,7 +44,6 @@
<!-- cafe address -->
<button ion-item text-wrap>
<ion-icon name='ios-link-outline' item-start></ion-icon>
{{item["address"]}}
</button>
<!-- cafe direction (link to google map) -->
<button padding ion-button (click)= "navigate()" block [ngStyle]="{'width': '90%', 'margin': 'auto' }"> <ion-icon name='ios-pin-outline' item-start></ion-icon>
Expand Down Expand Up @@ -83,11 +84,6 @@
<ion-option value="7" >Sunday</ion-option>
</ion-select>
</ion-item>
</ion-list>
<!-- <button ion-item> OLD BUTTON
<ion-icon name='ios-pin-outline' item-start></ion-icon>
Direction
</button> -->
</ion-list>

</ion-card>
</ion-content>
12 changes: 8 additions & 4 deletions src/pages/details/details.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { Component } from '@angular/core';
import { NavController, NavParams, Platform} from 'ionic-angular';
import {Cafe} from "../../app/cafe";
import {AngularFireDatabase, AngularFireObject} from 'angularfire2/database';
import {AngularFireDatabase,AngularFireObject} from 'angularfire2/database';
import { LaunchNavigator, LaunchNavigatorOptions } from '@ionic-native/launch-navigator';

/**
Expand All @@ -16,7 +16,7 @@ import { LaunchNavigator, LaunchNavigatorOptions } from '@ionic-native/launch-na
templateUrl: 'details.html'
})
export class DetailsPage {
item: Cafe;
item: Cafe;//here the type of item has some non-consistency with 'Cafe'!!!!!!!!!!! Need to be revised
name: string;
cafe: AngularFireObject<any>;
destination:string;
Expand Down Expand Up @@ -50,7 +50,7 @@ export class DetailsPage {
this.applemaps="http://maps.apple.com/?q="+this.item.address;

if (this.item.populartimes!=null) {
// get the data from firebase
// get the data from Firebase
this.item.currentPop = this.item.populartimes[day-1]["data"][hours];
this.barChartData[0].data = this.item.populartimes[day-1]["data"].slice(6, 24);
this.barChartData[0].label = 'Estimated Current Popularity on ' + this.item.populartimes[day-1].name;
Expand All @@ -62,6 +62,7 @@ export class DetailsPage {
this.oppeningInfo = "It closes this day. Please pick another day!";
this.item.currentPop = 0;
}
console.log(this.item.place_id);
this.cafe = adb.object('/cafe_list/' + this.item.place_id);

//kind of inefficient, but i couldnt call the function changeGradient here for some reason
Expand All @@ -75,6 +76,7 @@ export class DetailsPage {
this.item.color = "danger";
}
console.log(this.item);

}
navigate(){
if (this.platform.is('mobileweb') || this.platform.is('core')) {
Expand Down Expand Up @@ -128,4 +130,6 @@ export class DetailsPage {
this.oppeningInfo = "It closes this day. Please pick another day!";
}
}


}
5 changes: 3 additions & 2 deletions src/pages/home/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

<ion-content>
<ion-list>
<button ion-item *ngFor="let item of show_list"
<button ion-item *ngFor="let item of show_list "
detail-none
[navPush]="pagedetails"
[navParams]="item">
{{ item["name"] }}

<ion-icon [ngStyle]="{'color': item.status, 'position': 'absolute', 'right': '15px' }" name="radio-button-on"></ion-icon>
<p [ngStyle]="{'float': 'right', 'margin-right': '25px'}">
{{ item["distance"] }}
<!--{{ item["distance"] }}-->
miles</p>
</button>
</ion-list>
Expand Down
15 changes: 5 additions & 10 deletions src/pages/home/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import { DetailsPage} from "../details/details";
import { AngularFireDatabase,AngularFireList} from 'angularfire2/database';
import { Observable } from 'rxjs/Observable';
import {Geolocation} from "@ionic-native/geolocation";
import {ILatLng, LatLng} from '@ionic-native/google-maps';//LocationService
import {LatLng} from '@ionic-native/google-maps';//LocationService
import {HttpClient} from "@angular/common/http";
import { Spherical} from "@ionic-native/google-maps";
import {Cafe} from "../../app/cafe";


@Component({
selector: 'page-home',
Expand All @@ -33,9 +31,10 @@ export class HomePage
// get user's current coordination using google's place nearbysearch api
var userCoords = new LatLng(resp.coords.latitude, resp.coords.longitude);
this.http.get('https://maps.googleapis.com/maps/api/place/nearbysearch/json?location='+
resp.coords.latitude +','
+resp.coords.longitude +
'&rankby=distance&type=cafe&key=AIzaSyCfPG3wQmh-RMjmgY1F3xipVbmkvdq49RM').subscribe(
resp.coords.latitude
+ ',' +
resp.coords.longitude
+ '&rankby=distance&type=cafe&key=AIzaSyCfPG3wQmh-RMjmgY1F3xipVbmkvdq49RM').subscribe(
data=>
{
this.apiResults = data["results"];
Expand All @@ -57,7 +56,6 @@ export class HomePage
console.log(item);
if(item!=null && item['id']!=undefined){

//console.log(apiResult["geometry"]);
item["distance"] = compute_distance(userCoords, item["coordinates"]);
var newStatus = chooseColor(getCurrentPop(item));
this.adb.object('/cafe_list/'+item["id"]).update({ status: newStatus});
Expand All @@ -77,9 +75,6 @@ export class HomePage
}

function compute_distance(coords1, coords2) {
//google plugin version -- driving distance
//return (Spherical.computeDistanceBetween(coords1,coords2)/(1610)).toFixed(1);

//temporary version -- straight-line distance
var dis = (getDistanceFromLatLonInKm(coords1["lat"],coords1["lng"],coords2["lat"],coords2["lng"])/1.61).toFixed(1);
return dis;
Expand Down

0 comments on commit 497395d

Please sign in to comment.