Changeset bdd6491 for trip-planner-front/src/app/planner
- Timestamp:
- 12/28/21 08:56:55 (3 years ago)
- Branches:
- master
- Children:
- b738035
- Parents:
- 84d0fbb
- Location:
- trip-planner-front/src/app/planner
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/src/app/planner/edit-planner/edit-planner.component.html
r84d0fbb rbdd6491 1 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous"> 1 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" 2 integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous"> 2 3 3 4 <h3>Here you can edit your planner</h3> 4 5 5 <form [formGroup] ="form" (ngSubmit)="onSubmit()">6 <form [formGroup]="form" (ngSubmit)="onSubmit()"> 6 7 <div class="form-gorup"> 7 8 <p>Planner name</p> 8 9 <mat-form-field appearance="fill"> 9 <input matInput required type="text" formControlName="name"placeholder="Planner name">10 <input matInput required type="text" formControlName="name" placeholder="Planner name"> 10 11 </mat-form-field> 11 12 <p>Planner description</p> 12 13 <mat-form-field appearance="fill"> 13 <textarea matInput required formControlName="description" type="text" placeholder="Planner description"></textarea> 14 <textarea matInput required formControlName="description" type="text" 15 placeholder="Planner description"></textarea> 14 16 </mat-form-field> 15 17 </div> 16 <div class="container mb-4" 18 <div class="container mb-4"> 17 19 <div class="row"> 18 20 <div class="col-12"> … … 20 22 <table class="table table-striped"> 21 23 <thead> 22 <tr>23 <th scope="col">Location name</th>24 </tr>24 <tr> 25 <th scope="col">Location name</th> 26 </tr> 25 27 </thead> 26 28 <tbody> 27 <tr> 28 <td> <button mat-raised-button color="primary" (click)="onClickAddLocation()"> 29 Add locations 30 </button> 31 </td> 32 </tr> 33 <tr *ngFor ="let location of locations"> 34 <td> 35 {{location.name}} 36 </td> 37 </tr> 29 <tr> 30 <td> <button mat-raised-button color="primary" (click)="onClickAddLocation()"> 31 Add locations 32 </button> 33 </td> 34 </tr> 35 <tr *ngFor="let location of locations"> 36 <td> 37 {{location.name}} 38 </td> 39 <td> 40 <button pButton pRipple type="button" icon="pi pi-times" class="p-button-rounded p-button-danger p-button-text"></button> 41 </td> 42 </tr> 38 43 </tbody> 39 44 </table> … … 44 49 <button pButton pRipplelabel label="Save" class="p-button-help"></button> 45 50 </form> 46 <button pButton pRipple label="Back" class="p-button-info" (click)="onClickBack()" [style]="{'margin-left': '.11em'}"></button> 51 <button pButton pRipple label="Back" class="p-button-info" (click)="onClickBack()" 52 [style]="{'margin-left': '.11em'}"></button> -
trip-planner-front/src/app/planner/edit-planner/edit-planner.component.ts
r84d0fbb rbdd6491 24 24 25 25 constructor(private router: Router, private route: ActivatedRoute, private fb: FormBuilder, private plannerService: PlannerService, 26 private locationService 26 private locationService: LocationService) { 27 27 this.planner = new Planner(); 28 28 this.planners = []; … … 50 50 this.locationService.getLocationsForPlanner(this.id).subscribe( 51 51 data => { 52 52 this.locations = data; 53 53 } 54 54 ); 55 56 55 } 56 57 57 onSubmit() { 58 58 this.updatePlanner(); … … 77 77 } 78 78 79 onClickBack() {79 onClickBack() { 80 80 this.router.navigate(['planners']); 81 81 } 82 83 onClickRemoveLocation(id : number){ 84 85 } 82 86 } -
trip-planner-front/src/app/planner/planner.component.html
r84d0fbb rbdd6491 1 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous"> 1 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" 2 integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous"> 2 3 3 4 <p-toast></p-toast> 4 <button pButton pRipple type="button" label="Create initial planner" class="p-button-help " (click)="show()"></button> 5 6 7 <nav class="navbar navbar-light bg-light justify-content-between"> 8 <button pButton pRipple type="button" label="Create initial planner" class="p-button-help " (click)="show()"></button> 9 <form class="form-inline"> 10 <span>Hello, {{userDisplayName}}</span> 11 <button class="btn btn-outline-success my-2 my-sm-0" type="submit" (click)="onClickLogout()">Log out</button> 12 </form> 13 </nav> 14 15 5 16 <br> 6 17 <br> 7 18 <p-table [value]="planners" [paginator]="true" [rows]="3" [responsive]="true"> 8 19 9 20 <ng-template pTemplate="body" let-planner> 10 <td > 11 <p-card header="{{planner.name}}" subheader="Card Subheader" [style]="{width: '360px'}" styleClass="p-card-shadow"> 12 <ng-template pTemplate="header"> 13 </ng-template> 14 <p>{{planner.description}}</p> 15 <ng-template pTemplate="footer"> 16 <button pButton pRipple type="button" label="Edit" class="p-button-outlined p-button-rounded p-button-help" (click)="onClickEditPlannerGet(planner.id)"></button> 17 <button pButton pRipple type="button" icon="pi pi-times" class="p-button-rounded p-button-danger p-button-outlined" label="Delete" [style]="{'margin-left': '.5em'}"></button> 18 </ng-template> 19 </p-card> 20 </td> 21 <td> 22 <p-card header="{{planner.name}}" subheader="Card Subheader" [style]="{width: '360px'}" 23 styleClass="p-card-shadow"> 24 <ng-template pTemplate="header"> 25 </ng-template> 26 <p>{{planner.description}}</p> 27 <ng-template pTemplate="footer"> 28 <button pButton pRipple type="button" label="Edit" class="p-button-outlined p-button-rounded p-button-help" 29 (click)="onClickEditPlannerGet(planner.id)"></button> 30 <button pButton pRipple type="button" icon="pi pi-times" 31 class="p-button-rounded p-button-danger p-button-outlined" label="Delete" 32 [style]="{'margin-left': '.5em'}" (click)="onDeletePlanner(planner.id)"></button> 33 </ng-template> 34 </p-card> 35 </td> 21 36 </ng-template> 22 37 </p-table> 23 24 -
trip-planner-front/src/app/planner/planner.component.ts
r84d0fbb rbdd6491 8 8 import { MessageService, PrimeNGConfig } from 'primeng/api'; 9 9 import { UserDto } from '../_models/dto/userDto'; 10 import { UserService } from '../_services/user.service';11 10 12 11 … … 23 22 ref: DynamicDialogRef; 24 23 user: UserDto; 24 userDisplayName = ''; 25 status = ''; 25 26 26 27 constructor(private plannerService: PlannerService, private router: Router, 27 private dialogService: DialogService, private primengConfig: PrimeNGConfig, private messageService: MessageService, 28 private userService : UserService) { 28 private dialogService: DialogService, private primengConfig: PrimeNGConfig, private messageService: MessageService) { 29 29 this.planners = []; 30 30 this.plannerDto = new PlannerDto(); … … 36 36 37 37 this.primengConfig.ripple = true; 38 38 let name1: string = sessionStorage.getItem("username") as string; 39 this.userDisplayName = name1; 39 40 this.plannerService.getAllPlanners().subscribe( 40 41 data => { 41 42 this.planners = data; 42 localStorage.getItem("token");43 43 } 44 ); 44 ); 45 45 } 46 46 … … 61 61 baseZIndex: 10000 62 62 }); 63 this.ref.onClose.subscribe((planner: Planner) => { 64 console.log("NOVOKREIRANIOT NAME NA PLANNER: " + planner.name); 65 this.plannerService.postInitialPlanner(planner).subscribe( 66 data=>{ 67 console.log(data); 68 }, 69 error => console.log('oops', error) 70 ); 71 this.messageService.add({ severity: 'success', summary: 'The planner: ' + planner.name + ' has been created.' }); 63 this.ref.onClose.subscribe((plannerDto: PlannerDto) => { 64 if (plannerDto) { 65 console.log("NOVOKREIRANIOT NAME NA PLANNER: " + plannerDto.name); 66 this.plannerService.postInitialPlanner(plannerDto).subscribe( 67 data => { 68 console.log(data); 69 }, 70 error => console.log('oops', error) 71 ); 72 this.messageService.add({ severity: 'success', summary: 'The planner: ' + plannerDto.name + ' has been created.' }); 73 } 74 72 75 }); 73 76 74 77 } 75 78 79 ngOnDestroy() { 80 if (this.ref) { 81 this.ref.close(); 82 } 83 } 84 85 onClickLogout() { 86 sessionStorage.removeItem("token"); 87 console.log("SESSION HAS ENDED, THE USER IS LOGGED OUT" + sessionStorage.getItem("token")); 88 this.router.navigate(['']); 89 } 90 91 onDeletePlanner(id: number) { 92 console.log("DELETE KOCHE: " + id); 93 this.plannerService.deletePlannerById(id).subscribe( 94 (data) => { 95 console.log(data); 96 }, 97 (error) => console.log('error', error) 98 ); 99 window.location.reload(); 100 } 76 101 }
Note:
See TracChangeset
for help on using the changeset viewer.