Commit 71e61580 authored by Ratnadeep Rajendra Kharade's avatar Ratnadeep Rajendra Kharade
Browse files

Merge branch '52-page-loader-is-getting-displayed-everywhere' into 'master'

Resolve "Page loader is getting displayed everywhere"

Closes #52

See merge request 92khra1mst/hft_awado_app!37
parents 2dc7dc93 fe13b864
...@@ -42,7 +42,7 @@ export class LoginPage implements OnInit { ...@@ -42,7 +42,7 @@ export class LoginPage implements OnInit {
"email": this.username, "email": this.username,
"password": this.password "password": this.password
}); });
//this.loadingService.showLoader(); this.loadingService.showLoader();
this.loginApi this.loginApi
.subscribe((data) => { .subscribe((data) => {
//console.log('my data: ', data); //console.log('my data: ', data);
...@@ -50,11 +50,11 @@ export class LoginPage implements OnInit { ...@@ -50,11 +50,11 @@ export class LoginPage implements OnInit {
this.restService.isLoginPage = false; this.restService.isLoginPage = false;
this.userService.setUsername(this.username); this.userService.setUsername(this.username);
this.router.navigateByUrl('/home'); this.router.navigateByUrl('/home');
//this.loadingService.hideLoader(); this.loadingService.hideLoader();
}, (error) => { }, (error) => {
console.log(JSON.stringify(error)); console.log(JSON.stringify(error));
this.correctCredentials = true; this.correctCredentials = true;
//this.loadingService.hideLoader(); this.loadingService.hideLoader();
}); });
} }
register() { register() {
......
...@@ -20,15 +20,20 @@ ...@@ -20,15 +20,20 @@
</div--> </div-->
<!--div #mapElement style="width: 100%; height: 100%" id="mapContainer"></div--> <!--div #mapElement style="width: 100%; height: 100%" id="mapContainer"></div-->
<!--app-here-map [startRideSubject]="startRideSubject" [gotReservedBikeSubject]="gotReservedBikeSubject"></app-here-map--> <!--app-here-map [startRideSubject]="startRideSubject" [gotReservedBikeSubject]="gotReservedBikeSubject"></app-here-map-->
<div #mapElement style="width: 100%; height: 100%" id="mapContainer" *ngIf="!is3DChecked"></div> <ion-card *ngIf="!isBikeReserved">
<ion-fab class="get-position" vertical="bottom" horizontal="end" (click)="getCurrentPosition()" slot="fixed"> <ion-card-content>
No ride found
</ion-card-content>
</ion-card>
<div #mapElement style="width: 100%; height: 100%" id="mapContainer" *ngIf="isBikeReserved"></div>
<ion-fab *ngIf="isBikeReserved" class="get-position" vertical="bottom" horizontal="end" (click)="getCurrentPosition()" slot="fixed">
<ion-fab-button> <ion-fab-button>
<ion-icon name="locate"></ion-icon> <ion-icon name="locate"></ion-icon>
</ion-fab-button> </ion-fab-button>
</ion-fab> </ion-fab>
</ion-content> </ion-content>
<ion-footer> <ion-footer>
<div class="bike-details-container"> <div class="bike-details-container" *ngIf="isBikeReserved">
<div class="inner"> <div class="inner">
<div class="button-container"> <div class="button-container">
......
...@@ -27,6 +27,8 @@ export class HirebikePage implements OnInit { ...@@ -27,6 +27,8 @@ export class HirebikePage implements OnInit {
isBikeHired = false; isBikeHired = false;
noReservation = true; noReservation = true;
isBikeReserved = true;
currentRoute: any; currentRoute: any;
routeSummary: any; routeSummary: any;
wayPointsInfo:any; wayPointsInfo:any;
...@@ -160,7 +162,7 @@ export class HirebikePage implements OnInit { ...@@ -160,7 +162,7 @@ export class HirebikePage implements OnInit {
} }
getReservedBike() { getReservedBike() {
//this.loadingService.showLoader(); this.loadingService.showLoader();
this.storage.get('token').then((token) => { this.storage.get('token').then((token) => {
const headers = new HttpHeaders().set("Authorization", "Bearer " + token); const headers = new HttpHeaders().set("Authorization", "Bearer " + token);
//call reserved bike api //call reserved bike api
...@@ -179,35 +181,44 @@ export class HirebikePage implements OnInit { ...@@ -179,35 +181,44 @@ export class HirebikePage implements OnInit {
this.bikeDetails = resp.data; this.bikeDetails = resp.data;
this.noReservation = false; this.noReservation = false;
this.reverseGeocode(this.platform, this.bikeDetails.lat, this.bikeDetails.lon); this.reverseGeocode(this.platform, this.bikeDetails.lat, this.bikeDetails.lon);
this.isBikeReserved = true;
//pass reserved bike subject here map //pass reserved bike subject here map
this.gotReservedBikeSubject.next(resp.data); this.gotReservedBikeSubject.next(resp.data);
//this.loadingService.hideLoader(); this.loadingService.hideLoader();
}, (reservedBikeError) => { }, (reservedBikeError) => {
console.log(reservedBikeError); console.log(reservedBikeError);
//this.loadingService.hideLoader(); this.loadingService.hideLoader();
this.isBikeReserved = false;
}); });
} else {
this.loadingService.hideLoader();
this.isBikeReserved = false;
} }
}, (bikeDetailsError) => { }, (bikeDetailsError) => {
console.log(bikeDetailsError); console.log(bikeDetailsError);
//this.loadingService.hideLoader(); this.loadingService.hideLoader();
this.isBikeReserved = false;
}); });
}); });
} }
startTrip() { startTrip() {
this.isBikeHired = true;
this.startRideSubject.next('some value');
this.loadingService.showLoader();
this.storage.get('token').then((token) => { this.storage.get('token').then((token) => {
let url = 'http://193.196.52.237:8081/rent' + '?bikeId=' + this.bikeDetails.id; let url = 'http://193.196.52.237:8081/rent' + '?bikeId=' + this.bikeDetails.id;
const headers = new HttpHeaders().set("Authorization", "Bearer " + token); const headers = new HttpHeaders().set("Authorization", "Bearer " + token);
let bikeApi = this.httpClient.get(url, { headers }); let bikeApi = this.httpClient.get(url, { headers });
bikeApi.subscribe((resp) => { bikeApi.subscribe((resp) => {
console.log('my data: ', resp); console.log('my data: ', resp);
//this.loadingService.hideLoader(); this.loadingService.hideLoader();
this.toastService.showToast("Trip Started"); this.toastService.showToast("Trip Started");
this.isBikeHired = true; this.isBikeHired = true;
}, (error) => { }, (error) => {
console.log(error); console.log(error);
//this.loadingService.hideLoader(); this.loadingService.hideLoader();
this.toastService.showToast("This is ongoing Trip"); this.toastService.showToast("This is ongoing Trip");
}); });
}); });
...@@ -220,18 +231,18 @@ export class HirebikePage implements OnInit { ...@@ -220,18 +231,18 @@ export class HirebikePage implements OnInit {
} }
CancelTrip() { CancelTrip() {
//this.loadingService.showLoader(); this.loadingService.showLoader();
this.storage.get('token').then((token) => { this.storage.get('token').then((token) => {
let url = 'http://193.196.52.237:8081/rent' + '?bikeId=' + this.bikeDetails.id; let url = 'http://193.196.52.237:8081/rent' + '?bikeId=' + this.bikeDetails.id;
const headers = new HttpHeaders().set("Authorization", "Bearer " + token); const headers = new HttpHeaders().set("Authorization", "Bearer " + token);
let bikeApi = this.httpClient.delete(url, { headers }); let bikeApi = this.httpClient.delete(url, { headers });
bikeApi.subscribe((resp) => { bikeApi.subscribe((resp) => {
console.log('my data: ', resp); console.log('my data: ', resp);
//this.loadingService.hideLoader(); this.loadingService.hideLoader();
this.toastService.showToast("Trip Ended!"); this.toastService.showToast("Trip Ended!");
}, (error) => { }, (error) => {
console.log(error); console.log(error);
//this.loadingService.hideLoader(); this.loadingService.hideLoader();
this.toastService.showToast("No Ongong Trip to End") this.toastService.showToast("No Ongong Trip to End")
}); });
}); });
......
...@@ -145,7 +145,7 @@ export class HomePage implements OnInit, OnDestroy { ...@@ -145,7 +145,7 @@ export class HomePage implements OnInit, OnDestroy {
} }
getBikesList() { getBikesList() {
//this.loadingService.showLoader(); this.loadingService.showLoader();
this.storage.get('token').then((token) => { this.storage.get('token').then((token) => {
let url = 'http://193.196.52.237:8081/bikes' + '?lat=' + this.currentUserPosition.lat + '&lng=' + this.currentUserPosition.lng; let url = 'http://193.196.52.237:8081/bikes' + '?lat=' + this.currentUserPosition.lat + '&lng=' + this.currentUserPosition.lng;
const headers = new HttpHeaders().set("Authorization", "Bearer " + token); const headers = new HttpHeaders().set("Authorization", "Bearer " + token);
...@@ -158,9 +158,9 @@ export class HomePage implements OnInit, OnDestroy { ...@@ -158,9 +158,9 @@ export class HomePage implements OnInit, OnDestroy {
this.reverseGeocode(this.platform, this.bikes[i].lat, this.bikes[i].lon, i); this.reverseGeocode(this.platform, this.bikes[i].lat, this.bikes[i].lon, i);
} }
this.showBikesOnMap(); this.showBikesOnMap();
//this.loadingService.hideLoader(); this.loadingService.hideLoader();
}, (error) => {console.log(error) }, (error) => {console.log(error)
//this.loadingService.hideLoader(); this.loadingService.hideLoader();
}); });
}); });
} }
...@@ -261,7 +261,7 @@ export class HomePage implements OnInit, OnDestroy { ...@@ -261,7 +261,7 @@ export class HomePage implements OnInit, OnDestroy {
reserveBike() { reserveBike() {
//this.selectedBike=bikeS; //this.selectedBike=bikeS;
//this.loadingService.showLoader(); this.loadingService.showLoader();
this.storage.get('token').then((token) => { this.storage.get('token').then((token) => {
let url = 'http://193.196.52.237:8081/reservation' + '?bikeId=' + this.selectedBike.id; let url = 'http://193.196.52.237:8081/reservation' + '?bikeId=' + this.selectedBike.id;
const headers = new HttpHeaders().set("Authorization", "Bearer " + token); const headers = new HttpHeaders().set("Authorization", "Bearer " + token);
...@@ -271,10 +271,10 @@ export class HomePage implements OnInit, OnDestroy { ...@@ -271,10 +271,10 @@ export class HomePage implements OnInit, OnDestroy {
this.isBikeReserved = true; this.isBikeReserved = true;
this.toastService.showToast("Reservation Successful!"); this.toastService.showToast("Reservation Successful!");
this.router.navigateByUrl('/myreservation'); this.router.navigateByUrl('/myreservation');
//this.loadingService.hideLoader(); this.loadingService.hideLoader();
}, (error) => { }, (error) => {
console.log(error); console.log(error);
//this.loadingService.hideLoader(); this.loadingService.hideLoader();
this.toastService.showToast("Only one bike may be reserved or rented at a time"); this.toastService.showToast("Only one bike may be reserved or rented at a time");
}); });
}); });
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</ion-card-content> </ion-card-content>
</ion-card> </ion-card>
<div #mapElement style="width: 100%; height: 100%" id="mapContainer" *ngIf="isBikeReserved"></div> <div #mapElement style="width: 100%; height: 100%" id="mapContainer" *ngIf="isBikeReserved"></div>
<ion-fab class="get-position" vertical="bottom" horizontal="end" (click)="getCurrentPosition()" slot="fixed"> <ion-fab *ngIf="isBikeReserved" class="get-position" vertical="bottom" horizontal="end" (click)="getCurrentPosition()" slot="fixed">
<ion-fab-button> <ion-fab-button>
<ion-icon name="locate"></ion-icon> <ion-icon name="locate"></ion-icon>
</ion-fab-button> </ion-fab-button>
......
...@@ -131,7 +131,7 @@ export class MyreservationPage implements OnInit { ...@@ -131,7 +131,7 @@ export class MyreservationPage implements OnInit {
} }
getReservedBike() { getReservedBike() {
//this.loadingService.showLoader(); this.loadingService.showLoader();
this.storage.get('token').then((token) => { this.storage.get('token').then((token) => {
const headers = new HttpHeaders().set("Authorization", "Bearer " + token); const headers = new HttpHeaders().set("Authorization", "Bearer " + token);
//call reserved bike api //call reserved bike api
...@@ -147,7 +147,7 @@ export class MyreservationPage implements OnInit { ...@@ -147,7 +147,7 @@ export class MyreservationPage implements OnInit {
let bikeDetailsApi = this.httpClient.get(bikeDetailsUrl, { headers }); let bikeDetailsApi = this.httpClient.get(bikeDetailsUrl, { headers });
bikeDetailsApi.subscribe((resp: any) => { bikeDetailsApi.subscribe((resp: any) => {
console.log('Bike Details', resp); console.log('Bike Details', resp);
//this.loadingService.hideLoader(); this.loadingService.hideLoader();
this.bikeDetails = resp.data; this.bikeDetails = resp.data;
this.reverseGeocode(this.platform, this.bikeDetails.lat, this.bikeDetails.lon); this.reverseGeocode(this.platform, this.bikeDetails.lat, this.bikeDetails.lon);
this.isBikeReserved = true; this.isBikeReserved = true;
...@@ -163,13 +163,16 @@ export class MyreservationPage implements OnInit { ...@@ -163,13 +163,16 @@ export class MyreservationPage implements OnInit {
console.log(error.message); console.log(error.message);
}); });
}, (reservedBikeError) => { }, (reservedBikeError) => {
//this.loadingService.hideLoader(); this.loadingService.hideLoader();
console.log(reservedBikeError); console.log(reservedBikeError);
this.isBikeReserved = false; this.isBikeReserved = false;
}); });
} else {
this.loadingService.hideLoader();
this.isBikeReserved = false;
} }
}, (bikeDetailsError) => { }, (bikeDetailsError) => {
//this.loadingService.hideLoader(); this.loadingService.hideLoader();
console.log(bikeDetailsError) console.log(bikeDetailsError)
this.isBikeReserved = false; this.isBikeReserved = false;
}); });
......
Markdown is supported
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