Commit 11e3848a authored by Ratnadeep Rajendra Kharade's avatar Ratnadeep Rajendra Kharade
Browse files

Added api integration for showing bike list

parent e878023d
master 1-login-with-token-authentication 10-show-bikes-from-api-response-on-map 13-show-bike-details 14-api-integration-for-registration 15-find-the-street-name-by-geo-location-data 16-create-search-location-functionality 17-create-toast-message-service 18-design-feedback-page 18-design-feedback-page-2 19-registration-page-validation 20-ride-history 20-ride-history-2 21-reservation-history 22-hire-reserved-bike 24-routing-from-users-current-position-to-the-bike 25-current-bike-reservation-workflow 28-routing-from-bike-location-to-user-s-destination 34-navigation-menu-is-getting-displayed-on-login-page 36-cancel-hired-bike 37-display-username-on-homepage 38-display-calculated-name-of-the-street-on-reservation-and-hire-page 39-validation-on-login-page 4-reserve-a-bike 40-map-performance-improvement-map-angle-doesn-t-change-when-selected-3d 41-display-live-location-of-user-on-map 42-add-log-in-button-on-registration-page-add-extra-messages-for-email-and-password-validation 42-add-log-in-button-on-registration-page-add-extra-messages-for-email-and-password-validation-2 45-show-stepwise-navigation-instructions-on-my-ride-page 46-show-bicycle-route-between-bike-and-user-s-destination 47-show-alternate-routes-for-bike-to-destination 48-create-a-common-service-for-getting-user-s-current-location-and-live-location 49-show-loading-page 50-add-dependencies-locally-to-improve-app-performance 51-while-navigating-between-pages-map-doesn-t-load-properly 52-page-loader-is-getting-displayed-everywhere 53-scrollining-in-ride-history 53-scrollining-in-ride-history-2 55-change-password 56-create-dummy-page-or-menu-for-hotline-contact 57-registration-not-working-from-app 58-add-flow-on-navigate-button-to-route-from-user-to-bike 6-user-registration 60-create-common-theming-styles-and-colors 61-chnage-styles-for-bike-list-and-bug-fixes 62-change-in-feedback-workflow 63-password-reset-api-integration 64-close-button-on-home-page-to-redirect-to-bike-list 66-highlight-selected-route-from-list-of-different-routes 67-deactivate-user-api-integration 68-display-no-go-areas-on-map 69-add-launcher-icon-for-application-on-android 70-add-validation-for-feedback-should-not-be-empty 71-prediction-ui-implementation-send-location-of-bike-to-backend 72-feedback-toast-message 73-removal-here-maps-api-key Show-Bike-details-when-bike-icon-is-clicked prototype1 search_functionality
No related merge requests found
Showing with 85 additions and 11 deletions
+85 -11
......@@ -12,6 +12,8 @@ import { Geolocation } from '@ionic-native/geolocation/ngx';
import { HttpClientModule } from '@angular/common/http';
import { RestService } from './rest.service';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
......@@ -25,6 +27,7 @@ import { HttpClientModule } from '@angular/common/http';
Geolocation,
StatusBar,
SplashScreen,
RestService,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
......
......@@ -4,6 +4,8 @@ import { Router } from '@angular/router';
import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { RestService } from '../../rest.service';
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
......@@ -15,7 +17,7 @@ export class LoginPage implements OnInit {
correctCredentials = false;
loginApi: Observable<any>;
constructor(private router: Router, public httpClient: HttpClient) {
constructor(private router: Router, public httpClient: HttpClient, public restService: RestService) {
}
......@@ -35,6 +37,7 @@ export class LoginPage implements OnInit {
this.loginApi
.subscribe((data) => {
console.log('my data: ', data);
this.restService.setToken(data.token);
this.router.navigateByUrl('/home');
}, (error) => {
console.log(error);
......
......@@ -21,17 +21,17 @@
<ion-footer>
<div class="bike-list-container">
<ion-icon class="bike-list-expander" name="arrow-dropup-circle" (click)="expandBikeList()"></ion-icon>
<div class="bike-container" *ngFor="let i of tempArr">
<div class="bike-container" *ngFor="let bike of bikes">
<div class="bike-name">
Bike 1
{{bike.name}}
</div>
<div class="battery-info">
<div><ion-icon class="battery-icon" name="battery-charging"></ion-icon></div>
<div>100%</div>
<div>{{bike.batteryPercentage + " %"}}</div>
</div>
<div class="address-info">
<div class="disance">56m</div>
<div class="address">Schllingstrasse 129</div>
<div class="disance">{{bike.distance + "m"}}</div>
<div class="address">{{bike.address}}</div>
</div>
</div>
</div>
......
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { Geolocation } from '@ionic-native/geolocation/ngx';
import { RestService } from '../rest.service';
import { Observable } from 'rxjs';
import { HttpClient, HttpHeaders } from '@angular/common/http';
declare var H: any;
@Component({
selector: 'app-home',
......@@ -9,6 +14,9 @@ declare var H: any;
export class HomePage {
private platform: any;
private map: any;
bikes = [];
bikeApi: Observable<any>;
private currentLocation = { lat: 0, lng: 0 };
public is3DChecked = false;
......@@ -29,15 +37,20 @@ export class HomePage {
//@ViewChild("mapElement", { static: false })
//public mapElement: ElementRef;
public constructor(private geolocation: Geolocation) {
constructor(private geolocation: Geolocation,
public restService: RestService,
public httpClient: HttpClient) {
this.platform = new H.service.Platform({
'apikey': 'tiVTgBnPbgV1spie5U2MSy-obhD9r2sGiOCbBzFY2_k'
});
}
public ngOnInit() { }
ngOnInit() {
this.getBikesList();
}
public ngAfterViewInit() {
ngAfterViewInit() {
setTimeout(() => {
this.loadmap("2D");
}, 1000);
......@@ -45,6 +58,30 @@ export class HomePage {
window.addEventListener('resize', () => this.map.getViewPort().resize());
}
getBikesList() {
this.geolocation.getCurrentPosition(
{
maximumAge: 1000, timeout: 5000,
enableHighAccuracy: true
}
).then((resp) => {
this.currentLocation.lat = resp.coords.latitude;
this.currentLocation.lng = resp.coords.longitude;
let url = 'http://193.196.52.237:8081/admin/bikes' + '?lat=' + this.currentLocation.lat + '&lng=' + this.currentLocation.lng;
const headers = new HttpHeaders().set("Authorization", "Bearer " + this.restService.getToken());
this.bikeApi = this.httpClient.get(url, {headers});
this.bikeApi
.subscribe((resp) => {
console.log('my data: ', resp);
this.bikes = resp.data;
}, (error) => console.log(error));
}, er => {
alert('Can not retrieve Location')
}).catch((error) => {
alert('Error getting location - ' + JSON.stringify(error))
});
}
loadmap(style) {
// Obtain the default map types from the platform object
var mapStyle = "raster";
......@@ -91,8 +128,8 @@ export class HomePage {
mapSettings.setAlignment('top-right');
zoom.setAlignment('left-top');
if(style === "3D") {
this.map.getViewModel().setLookAtData({tilt: 60});
if (style === "3D") {
this.map.getViewModel().setLookAtData({ tilt: 60 });
}
this.getLocation(this.map);
var img = ['../../../assets/images/ic_high.png', '../../../assets/images/ic_medium.png', '../../../assets/images/ic_low.png'];
......
import { TestBed } from '@angular/core/testing';
import { RestService } from './rest.service';
describe('RestService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: RestService = TestBed.get(RestService);
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class RestService {
token: String;
constructor() { }
setToken(token) {
this.token = token;
}
getToken() {
return this.token;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment