Changeset e29cc2e for trip-planner-front/src/app/location
- Timestamp:
- 11/25/21 22:08:24 (3 years ago)
- Branches:
- master
- Children:
- 8d391a1
- Parents:
- 59329aa
- Location:
- trip-planner-front/src/app/location
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/src/app/location/add-location-to-planner-panel/add-location-to-planner-panel.component.html
r59329aa re29cc2e 1 <form > 2 <h1 mat-dialog-title>Please select a planner where u want your location to be saved</h1> 3 4 <table class="table" > 5 <tbody> 6 <tr *ngFor="let planner of planners"> 7 <td>{{planner.name}}</td> 8 <td><button mat-raised-button color="primary" (click)="onFormSavePlanner(planner.id)">Save</button></td> 9 </tr> 10 11 </tbody> 12 </table> 13 </form> 14 15 <button type="button" mat-button (click)="onCancelClick()">Cancel</button> 1 <p-table [value]="planners" [paginator]="true" [rows]="3" [responsive]="true"> 2 <ng-template pTemplate="header"> 3 <tr> 4 <th pSortableColumn="name">Name <p-sortIcon field="vin"></p-sortIcon> 5 </th> 6 <th style="width:4em"></th> 7 </tr> 8 </ng-template> 9 <ng-template pTemplate="body" let-planner> 10 <tr> 11 <td>{{planner.name}}</td> 12 13 <td> 14 <button pButton pRipple type="button" icon="pi pi-heart" 15 class="p-button-rounded p-button-help p-button-text" (click)="selectPlanner(planner)"></button> 16 </td> 17 </tr> 18 </ng-template> 19 </p-table> 20 -
trip-planner-front/src/app/location/add-location-to-planner-panel/add-location-to-planner-panel.component.ts
r59329aa re29cc2e 1 1 import { Component, OnInit } from '@angular/core'; 2 import { MatDialogRef } from '@angular/material/dialog';3 2 import { ActivatedRoute } from '@angular/router'; 4 import { PlannerLocationDto } from 'src/app/_models/dto/plannerLocationDto';5 import { Location } from 'src/app/_models/location';6 3 import { Planner } from 'src/app/_models/planner'; 7 import { LocationService } from 'src/app/_services/location.service';8 4 import { PlannerService } from 'src/app/_services/planner.service'; 5 import { DynamicDialogRef } from 'primeng/dynamicdialog'; 6 7 8 9 9 10 10 @Component({ … … 16 16 17 17 planners: Planner[]; 18 location: Location;19 plannerId: number;20 locationId: number;21 plannerLocationDto: PlannerLocationDto;22 locationsInPlanner: Location[];23 18 24 19 25 constructor(private dialogRef: MatDialogRef<AddLocationToPlannerPanelComponent>, private plannerService: PlannerService, 26 private locationService: LocationService, private route: ActivatedRoute) { 20 21 constructor(private plannerService: PlannerService, 22 private route: ActivatedRoute, private ref: DynamicDialogRef) { 27 23 this.planners = []; 28 this.location = new Location;29 this.plannerId = 1;30 this.locationId = 1;31 this.plannerLocationDto = new PlannerLocationDto();32 this.locationsInPlanner = [];33 24 } 34 25 35 26 ngOnInit(): void { 27 36 28 this.plannerService.getAllPlanners().subscribe( 37 data=> {38 this.planners = data;29 planner => { 30 this.planners = planner; 39 31 } 40 32 ); 33 } 34 35 selectPlanner(planner: Planner) { 36 this.ref.close(planner); 37 } 41 38 42 39 43 this.route.queryParams44 .subscribe(params => {45 this.locationId = params.locationId;46 }47 );48 }49 50 onCancelClick(): void {51 this.dialogRef.close();52 53 }54 55 onFormSavePlanner(plannerId: number) {56 console.log("PLANNER ID: " + plannerId);57 console.log("LOC ID "+ this.locationId);58 this.plannerLocationDto.locationId = this.locationId;59 this.plannerLocationDto.plannerId = plannerId;60 /*61 this.locationService.postLocationToPlanner(this.plannerLocationDto).subscribe(62 data => {63 console.log(data);64 }65 );66 */67 68 // window.location.reload();69 }70 40 71 41 } -
trip-planner-front/src/app/location/location-details/location-details.component.html
r59329aa re29cc2e 7 7 <div class="card"> 8 8 <h5>More photos</h5> 9 <p-galleria [value]="images" [responsiveOptions]="responsiveOptions" [containerStyle]="{'max-width': '640px'}" [numVisible]="5"10 [ circular]="true" [showItemNavigators]="true">9 <p-galleria [value]="images" [responsiveOptions]="responsiveOptions" [containerStyle]="{'max-width': '640px'}" 10 [numVisible]="5" [circular]="true" [showItemNavigators]="true"> 11 11 <ng-template pTemplate="item" let-image> 12 <img src="data:image/png;base64,{{image.content}}" style="width: 100%; height: 350px; display: block;" /> 12 <img src="data:image/png;base64,{{image.content}}" 13 style="width: 100%; height: 350px; display: block;" /> 13 14 </ng-template> 14 15 <ng-template pTemplate="thumbnail" let-image> 15 16 <div class="p-grid p-nogutter p-justify-center"> 16 <img src="data:image/png;base64,{{image.content}}" style="width: 50px; height:50px; display: block;" /> 17 <img src="data:image/png;base64,{{image.content}}" 18 style=" height:50px; display: block;" /> 17 19 </div> 18 20 </ng-template> 19 21 </p-galleria> 20 22 </div> 23 -
trip-planner-front/src/app/location/location-details/location-details.component.ts
r59329aa re29cc2e 1 import { Component, OnInit , ViewEncapsulation} from '@angular/core';1 import { Component, OnInit, ViewEncapsulation } from '@angular/core'; 2 2 import { ActivatedRoute, Router } from '@angular/router'; 3 3 import { Images } from 'src/app/_models/images'; … … 16 16 locationDetails: Location; 17 17 images: Images[]; 18 responsiveOptions;19 18 20 constructor(private route: ActivatedRoute, private router: Router, private locationService 21 private imagesService: ImagesService) {19 constructor(private route: ActivatedRoute, private router: Router, private locationService: LocationService, 20 private imagesService: ImagesService) { 22 21 this.locationId = 1; 23 22 this.locationDetails = new Location(); 24 23 this.images = []; 24 } 25 25 26 this.responsiveOptions= [27 26 responsiveOptions:any[] = [ 27 { 28 28 breakpoint: '1024px', 29 29 numVisible: 5 … … 37 37 numVisible: 1 38 38 } 39 ]; 40 } 41 42 39 ]; 43 40 ngOnInit(): void { 44 41 this.route.queryParams 45 .subscribe(params => {46 this.locationId = params.id;47 });42 .subscribe(params => { 43 this.locationId = params.id; 44 }); 48 45 49 46 this.locationService.getLocation(this.locationId).subscribe( 50 47 data => { 51 48 this.locationDetails = data; 52 49 } 53 50 ); 54 51 55 52 this.imagesService.getAllImagesForLocation(this.locationId).subscribe( 56 53 image => { 57 54 this.images = image; 58 55 } 59 );56 ); 60 57 } 61 58 62 59 63 60 } -
trip-planner-front/src/app/location/location.component.html
r59329aa re29cc2e 1 1 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" 2 2 integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous"> 3 3 <p-toast></p-toast> 4 4 <h3>Here are all locations</h3> 5 6 <table class="table" 5 <button pButton pRipple type="button" icon="pi pi-bell" class="p-button-rounded p-button-warning" label="Back to my Planners" (click)="onClickBackToMyPlanners()"></button> 6 <table class="table"> 7 7 <thead> 8 8 <tr> … … 17 17 <td>{{location.id}}</td> 18 18 <td>{{location.name}}</td> 19 <td><button mat-raised-button color="primary" (click)="openDialogSave(location.id)">Add to my planner</button></td> 20 <td><button mat-raised-button color="primary" (click)="onClickSeeDetails(location.id)">See details</button></td> 21 </tr> 19 <td><button type="button" (click)="show(location)" pButton icon="pi pi-info-circle" 20 label="Add to my planner"></button></td> 21 <td><button type="button" color="primary" pButton icon="pi pi-info-circle" 22 (click)="onClickSeeDetails(location.id)" label="See details"></button></td> 23 </tr> 22 24 </tbody> 23 25 </table> 26 -
trip-planner-front/src/app/location/location.component.ts
r59329aa re29cc2e 1 import { Component, Input, OnInit, Output } from '@angular/core';1 import { Component, OnInit } from '@angular/core'; 2 2 import { FormBuilder, FormGroup, Validators } from '@angular/forms'; 3 import { MatDialog } from '@angular/material/dialog';4 3 import { ActivatedRoute, Router } from '@angular/router'; 4 import { MessageService, PrimeNGConfig } from 'primeng/api'; 5 import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog'; 6 import { Planner } from '../_models/planner'; 5 7 import { LocationService } from '../_services/location.service'; 6 8 import { AddLocationToPlannerPanelComponent } from './add-location-to-planner-panel/add-location-to-planner-panel.component'; 9 import { Location } from '../_models/location'; 10 import { PlannerLocationDto } from '../_models/dto/plannerLocationDto'; 11 7 12 8 13 @Component({ 9 14 selector: 'app-location', 10 15 templateUrl: './location.component.html', 11 styleUrls: ['./location.component.css'] 16 styleUrls: ['./location.component.css'], 17 providers: [DialogService, MessageService] 12 18 }) 13 19 export class LocationComponent implements OnInit { 14 20 15 form: FormGroup;16 21 categoryIds: string; 17 22 cityId: number; … … 23 28 regionId: number; 24 29 locationId: number; 30 plannerLocationDto: PlannerLocationDto; 31 ref: DynamicDialogRef; 25 32 26 constructor(private fb: FormBuilder, private route: ActivatedRoute, private locationService: LocationService, 27 private router: Router, private dialog: MatDialog) { 28 this.form = fb.group({ 29 title: fb.control('initial value', Validators.required) 30 }); 33 34 35 constructor(private route: ActivatedRoute, private locationService: LocationService, 36 private router: Router, private dialogService: DialogService, private messageService: MessageService) { 31 37 this.cityId = 1; 32 38 this.companionId = 1; … … 36 42 this.regionId = 1; 37 43 this.locationId = 1; 44 this.ref = new DynamicDialogRef; 45 this.plannerLocationDto = new PlannerLocationDto(); 46 38 47 } 39 48 … … 71 80 } 72 81 73 openDialogSave(locationId){ 74 // console.log(locationId); 75 const dialogRef = this.dialog.open(AddLocationToPlannerPanelComponent, { 76 width: '250px', 77 data: {} 78 }); 79 this.router.navigate(['locations'], {queryParams: {regionId: this.regionId, companionId: this.companionId, lengthOfStay: this.lengthOfStay, categoryIds: this.categoryIds, locationId: locationId}}); 80 82 onClickSeeDetails(id: number) { 83 this.router.navigate(['location'], { queryParams: { id: id } }); 81 84 } 82 85 83 onClickSeeDetails(id: number){ 84 this.router.navigate(['location'], {queryParams: {id: id}}); 86 show(location: Location) { 87 this.ref = this.dialogService.open(AddLocationToPlannerPanelComponent, { 88 header: 'Choose a Planner', 89 width: '70%', 90 contentStyle: { "max-height": "500px", "overflow": "auto" }, 91 baseZIndex: 10000 92 }); 93 94 this.ref.onClose.subscribe((planner: Planner) => { 95 96 this.plannerLocationDto.locationId = location.id; 97 this.plannerLocationDto.plannerId = planner.id; 98 console.log("LOC ID: " + this.plannerLocationDto.locationId); 99 console.log("PLANNER ID: " + this.plannerLocationDto.plannerId); 100 this.locationService.postLocationToPlanner(this.plannerLocationDto).subscribe( 101 data => { 102 console.log(data); 103 } 104 ); 105 if (planner) { 106 this.messageService.add({ severity: 'success', summary: 'Location ' + location.name + ' has been added to planner: ' , detail: planner.name }); 107 } 108 }); 109 } 110 111 ngOnDestroy() { 112 if (this.ref) { 113 this.ref.close(); 114 } 115 } 116 117 onClickBackToMyPlanners(){ 118 this.router.navigate(['planners']); 85 119 } 86 120 }
Note:
See TracChangeset
for help on using the changeset viewer.