Commit d9b44d91 authored by gap95's avatar gap95
Browse files

Feedback functinality addedd

parent bf3c6976
......@@ -34,6 +34,10 @@ const routes: Routes = [
path: 'ridehistory',
loadChildren: () => import('./ridehistory/ridehistory.module').then( m => m.RidehistoryPageModule)
},
{
path: 'feedback',
loadChildren: () => import('./feedback/feedback.module').then( m => m.FeedbackPageModule)
},
{
path: 'feedback',
loadChildren: () => import('./feedback/feedback.module').then( m => m.FeedbackPageModule)
......
<ion-header>
<ion-toolbar>
<ion-title>Feedback</ion-title>
</ion-toolbar>
</ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-menu-button></ion-menu-button>
</ion-buttons>
<ion-title slot="start">
Feedback
</ion-title>
<ion-content>
<form [formGroup]="angForm" novalidate>
<ion-grid>
<ion-row justify-content-center>
<ion-col align-self-center size-md="6" size-lg="5" size-xs="12">
<div padding>
<img src="../../../assets/images/bike2gologo.png">
</div>
<div class="ion-text">
<h3>Feedback</h3>
</div>
<ion-item ><ion-input type="text" formControlName="Bikeid" ></ion-input></ion-item>
<div >
Bikeid
</ion-toolbar>
</ion-header>
<ion-content>
<!--form [formGroup]="angForm" novalidate--><div>
<ion-grid>
<ion-row justify-content-center>
<ion-col align-self-center size-md="6" size-lg="5" size-xs="12">
<div padding>
<img src="../../../assets/images/bike2gologo.png">
</div>
<div class="ion-text">
<h3>Feedback</h3>
</div>
<ion-item >
<ion-input type="text" formControlName="content" placeholder="Enter Feedback"></ion-input>
</ion-item>
<ion-item >
<ion-input type="textarea" [(ngModel)]="content" placeholder="Enter Feedback"></ion-input>
</ion-item>
<div id="correctCredentialsmsg" padding *ngIf="correctCredentials">
Wrong Credentials !
</div>
<div padding>
<ion-button size="large" expand="block" (click)="submitFeedback()">Register</ion-button>
</div>
</ion-col>
</ion-row>
</ion-grid>
</form>
</ion-content>
<div padding>
<ion-button size="large" expand="block" (click)="submitFeedback()">Submit Feedback</ion-button>
</div>
</ion-col>
</ion-row>
</ion-grid>
</div>
<!--/form-->
</ion-content>
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { RestService } from '../rest.service';
import { UserService } from '../services/user.service';
import { Storage } from '@ionic/storage';
import { Observable } from 'rxjs';
import { FeedbackService } from 'src/app/services/feedback.service';
@Component({
selector: 'app-feedback',
......@@ -6,10 +13,32 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./feedback.page.scss'],
})
export class FeedbackPage implements OnInit {
feedbackApi: Observable<any>;
content: "";
bikeId=this.feedbackService.getBikeid();
constructor() { }
constructor(private router: Router,
public httpClient: HttpClient,
public restService: RestService,
public userService: UserService,
private storage: Storage,
public feedbackService: FeedbackService) { }
ngOnInit() {
}
submitFeedback() {
this.storage.get('token').then((token) => {
let url = 'http://193.196.52.237:8081/feedbacks'
const headers = new HttpHeaders().set("Authorization", "Bearer " + token);
this.feedbackApi = this.httpClient.post<any>(url, {"content": this.content,"bikeId":this.bikeId},{headers});
this.feedbackApi.subscribe((resp) => {
console.log("rides response", resp);
//this.loadingService.hideLoader();
}, (error) => {console.log(error)
//this.loadingService.hideLoader();
});
});
}
}
\ No newline at end of file
......@@ -10,6 +10,7 @@ import { Router } from '@angular/router';
import { MapDataService } from '../services/map-data.service';
import { LocationService } from '../services/location.service';
import { LoadingService } from '../services/loading.service';
import { FeedbackService } from 'src/app/services/feedback.service';
declare var H: any;
@Component({
......@@ -52,6 +53,7 @@ export class HirebikePage implements OnInit {
public rideStarted = false;
constructor(private geolocation: Geolocation,
public restService: RestService,
public httpClient: HttpClient,
......@@ -60,7 +62,8 @@ export class HirebikePage implements OnInit {
private router: Router,
private mapDataService: MapDataService,
public locationService: LocationService,
public loadingService: LoadingService) {
public loadingService: LoadingService,
public feedbackService: FeedbackService) {
this.platform = new H.service.Platform({
'apikey': 'tiVTgBnPbgV1spie5U2MSy-obhD9r2sGiOCbBzFY2_k'
......@@ -197,11 +200,13 @@ export class HirebikePage implements OnInit {
startTrip() {
this.storage.get('token').then((token) => {
const 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);
let bikeApi = this.httpClient.get(url, { headers });
bikeApi.subscribe((resp) => {
console.log('my data: ', resp);
this.feedbackService.setBikeid(this.bikeDetails.id);
//this.loadingService.hideLoader();
this.toastService.showToast("Trip Started");
this.isBikeHired = true;
......@@ -229,6 +234,7 @@ export class HirebikePage implements OnInit {
console.log('my data: ', resp);
//this.loadingService.hideLoader();
this.toastService.showToast("Trip Ended!");
this.router.navigateByUrl('/feedback');
}, (error) => {
console.log(error);
//this.loadingService.hideLoader();
......
import { TestBed } from '@angular/core/testing';
import { FeedbackService } from './feedback.service';
describe('FeedbackService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: FeedbackService = TestBed.get(FeedbackService);
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class FeedbackService {
feedbackBikeDetails = {name : "",bikeid:""}
constructor() { }
public getBikeid(){
return this.feedbackBikeDetails.bikeid
}
public setBikeid (bikeid){
this.feedbackBikeDetails.bikeid = bikeid
}
}
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