From 024ffe2a7f6652ebe005fced3221dd17d9197f0b Mon Sep 17 00:00:00 2001 From: Whizel Date: Sat, 6 Apr 2019 20:40:11 +0200 Subject: [PATCH] Comitting before pulling Picture service --- client/Nightr/src/app/app.component.html | 8 ++--- client/Nightr/src/app/app.component.ts | 33 ++++++++++++------- .../locationButton.component.html | 2 +- .../locationButton.component.ts | 8 +++-- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/client/Nightr/src/app/app.component.html b/client/Nightr/src/app/app.component.html index 97b4fff..2ba3f44 100644 --- a/client/Nightr/src/app/app.component.html +++ b/client/Nightr/src/app/app.component.html @@ -1,11 +1,11 @@ - - - + - + + + diff --git a/client/Nightr/src/app/app.component.ts b/client/Nightr/src/app/app.component.ts index 0758a86..3359e3a 100644 --- a/client/Nightr/src/app/app.component.ts +++ b/client/Nightr/src/app/app.component.ts @@ -1,8 +1,11 @@ import { Component } from "@angular/core"; import * as dialogs from "tns-core-modules/ui/dialogs"; -import { MyHttpPostService } from './services/my-http-post-service' import { TouchGestureEventData, GestureEventData } from 'tns-core-modules/ui/gestures' -import { isEnabled, enableLocationRequest, getCurrentLocation, watchLocation, distance, clearWatch } from "nativescript-geolocation"; +import { Location } from "nativescript-geolocation"; + +import { MyHttpPostService } from './services/my-http-post-service' +import { MyGeoLocationService} from './services/my-geo-location.service'; +import { MyBatteryInfoService } from './services/my-battery-info.service'; @Component({ selector: "ns-app", @@ -12,30 +15,38 @@ import { isEnabled, enableLocationRequest, getCurrentLocation, watchLocation, di providers: [MyHttpPostService] }) export class AppComponent { - public user: string = ""; - public pass: string = ""; returnMessage: string = ""; + myReturnJSON: JSON; + locationData: Location; - constructor(private myHttpPostSerivce: MyHttpPostService) { } + constructor(private myHttpPostSerivce: MyHttpPostService, + private geoLocationService: MyGeoLocationService, + private batterInfoService: MyBatteryInfoService) { } public onTap(args: GestureEventData): any { - this.submit(); - dialogs.confirm("Should be result").then(result => { - console.log("Dialog result: " + result); + this.geoLocationService.getLocation().then(location => { + this.locationData = location; + console.log('this is locationData', this.locationData); + this.submit(); + }).catch(error => { }); } + public onLocationTap(args: GestureEventData): any { + console.log('This should be batterinfo', this.batterInfoService.getPowerPercent()); + } + public submit(): void { this.makePostRequest(); } private makePostRequest(): void { - console.log('Reached makepostRequest'); this.myHttpPostSerivce - .postData({ username: this.user, password: this.pass }) + .postData({ position: this.locationData }) .subscribe(res => { console.log('This is res', res); - this.returnMessage = (res).json.data.username; + this.myReturnJSON = (res).json.data.username; + console.log('THis is myreturnJSON', this.myReturnJSON); }); } } diff --git a/client/Nightr/src/app/component/locationButton/locationButton.component.html b/client/Nightr/src/app/component/locationButton/locationButton.component.html index 5088fab..9fe4bc3 100644 --- a/client/Nightr/src/app/component/locationButton/locationButton.component.html +++ b/client/Nightr/src/app/component/locationButton/locationButton.component.html @@ -1,4 +1,4 @@ - + diff --git a/client/Nightr/src/app/component/locationButton/locationButton.component.ts b/client/Nightr/src/app/component/locationButton/locationButton.component.ts index 8495420..d28c873 100644 --- a/client/Nightr/src/app/component/locationButton/locationButton.component.ts +++ b/client/Nightr/src/app/component/locationButton/locationButton.component.ts @@ -1,4 +1,5 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, EventEmitter, OnInit, Output } from '@angular/core'; +import { TouchGestureEventData, GestureEventData } from 'tns-core-modules/ui/gestures' import { MyGeoLocationService} from '../../services/my-geo-location.service'; @Component({ selector: 'ns-locationButton', @@ -11,12 +12,15 @@ export class MyLocationButtonComponent implements OnInit { lat = "start"; geoLocationService = new MyGeoLocationService(); + @Output() tap: EventEmitter = new EventEmitter(); + constructor() { } ngOnInit() { } - onTap() { + onTap(args: GestureEventData): any { + this.tap.emit(args); this.geoLocationService.getLocation().then(location => { this.lat = ""+location.latitude; }).catch(error => {