Changeset 188ee53 for trip-planner-front/src/app
- Timestamp:
- 10/19/21 16:40:43 (3 years ago)
- Branches:
- master
- Children:
- 6a80231
- Parents:
- eed0bf8
- Location:
- trip-planner-front/src/app
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/src/app/_services/location.service.ts
reed0bf8 r188ee53 9 9 constructor(private httpClient : HttpClient){} 10 10 11 getAllPlaces(locationId: number, companionId: number, lengthOfStay: number, categoryIds: string): Observable<Object[]>{ 12 let url = "http://localhost:8080/api/trip/locations"; 13 return this.httpClient.get<Location[]>(url + '?locationId=' + locationId + '&companionId=' + companionId + '&lengthOfStay=' + lengthOfStay + '&categoryIds='+ categoryIds); 11 getLocationsFromCity(cityId: number, companionId: number, lengthOfStay: number, categoryIds: string): Observable<Object[]>{ 12 let url = "http://localhost:8080/api/city/locations"; 13 return this.httpClient.get<Location[]>(url + '?cityId=' + cityId + '&companionId=' + companionId + '&lengthOfStay=' + lengthOfStay + '&categoryIds='+ categoryIds); 14 } 15 16 getLocationsFromRegion(regionId: number, companionId: number, lengthOfStay: number, categoryIds: string):Observable<Object[]>{ 17 let url = "http://localhost:8080/api/region/locations"; 18 return this.httpClient.get<Location[]>(url + '?regionId=' + regionId + '&companionId=' + companionId + '&lengthOfStay=' + lengthOfStay + '&categoryIds='+ categoryIds); 14 19 } 15 20 } -
trip-planner-front/src/app/locations-form/locations-form.component.css
reed0bf8 r188ee53 18 18 float: right; 19 19 } 20 21 .colorClass{ 22 color:yellow; 23 } -
trip-planner-front/src/app/locations-form/locations-form.component.html
reed0bf8 r188ee53 3 3 <div class="example-form"> 4 4 5 <div class=" d-block">5 <div class="form-group"> 6 6 <button class="btn" (click)="chooseCityOption()" > 7 7 City … … 35 35 <mat-form-field appearance="fill" class="example-full-width"> 36 36 <mat-label>Please select a city</mat-label> 37 <mat-select [(ngModel)]=" locationId" placeholder="Select city">37 <mat-select [(ngModel)]="cityId" placeholder="Select city"> 38 38 <mat-option [value]="city.id" *ngFor="let city of cities" [value]="city.id"> {{city.name}}</mat-option> 39 39 </mat-select> 40 40 </mat-form-field> 41 41 </div> 42 42 43 43 44 <div *ngIf="regionOption"> … … 62 63 <mat-form-field class="example-full-width" appearance="fill"> 63 64 <mat-label>Please select a number of days</mat-label> 64 <input matInput placeholder="No. Days" type="number" [(ngModel)]="lengthOfStay">65 <input matInput placeholder="No. Days" type="number" min="1" value="0" max="30" [constraintMaxNumberDays()] [(ngModel)]="lengthOfStay"> 65 66 </mat-form-field> 66 67 … … 68 69 <mat-chip-list selectable multiple> 69 70 <mat-chip #c="matChip" selected *ngFor="let category of categories" 70 (click)="toggleSelection(c, category)" 71 (click)="toggleSelection(c, category)"> 71 72 <mat-icon *ngIf="!c.selected" >check</mat-icon> 72 73 {{category.name}} 73 74 </mat-chip> 74 75 </mat-chip-list> 76 <br> 75 77 <button mat-raised-button color="primary" (click)="createMyPlanner()">Create my planner</button> 76 77 78 78 79 </div> -
trip-planner-front/src/app/locations-form/locations-form.component.ts
reed0bf8 r188ee53 35 35 locationId: number; 36 36 regionId: number; 37 cityId: number; 37 38 companionId: number; 38 39 lengthOfStay: number; 39 40 cityOption: boolean = false; 40 41 regionOption: boolean = false; 42 value:number; 43 max: number; 41 44 42 45 constructor(private cityService : CityService, private regionService: RegionService, … … 54 57 this.categoryIds = ''; 55 58 this.regionId = 0; 59 this.cityId = 0; 60 this.value = 0; 61 this.max = 30; 56 62 } 57 63 … … 119 125 createMyPlanner(){ 120 126 this.categoryIds = this.chipsSeletion.join(','); 121 console.log(this.companionId); 122 this.locationService.getAllPlaces(this.locationId, this.companionId, this.lengthOfStay, this.categoryIds).subscribe( 123 result => { 124 console.log(result); 125 } 126 ); 127 console.log(this.categoryIds); 128 129 if(this.cityOption){ 130 this.locationService.getLocationsFromCity(this.cityId, this.companionId, this.lengthOfStay, this.categoryIds).subscribe( 131 result => { 132 console.log(result); 133 } 134 ); 135 }else if(this.regionOption){ 136 137 this.locationService.getLocationsFromRegion(this.regionId, this.companionId, this.lengthOfStay, this.categoryIds).subscribe( 138 result => { 139 console.log(result); 140 } 141 ); 142 } 143 144 127 145 } 128 146 chooseCityOption(){ … … 134 152 this.cityOption = false; 135 153 } 154 155 constraintMaxNumberDays(){ 156 if(this.value > this.max){ 157 this.value = this.max; 158 } 159 } 136 160 }
Note:
See TracChangeset
for help on using the changeset viewer.