Ignore:
Timestamp:
12/28/21 08:56:55 (3 years ago)
Author:
Ema <ema_spirova@…>
Branches:
master
Children:
b738035
Parents:
84d0fbb
Message:

pre final presentation

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">
    23
    34<h3>Here you can edit your planner</h3>
    45
    5 <form [formGroup] = "form" (ngSubmit)="onSubmit()">
     6<form [formGroup]="form" (ngSubmit)="onSubmit()">
    67    <div class="form-gorup">
    78        <p>Planner name</p>
    89        <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">
    1011        </mat-form-field>
    1112        <p>Planner description</p>
    1213        <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>
    1416        </mat-form-field>
    1517    </div>
    16     <div class="container mb-4" >
     18    <div class="container mb-4">
    1719        <div class="row">
    1820            <div class="col-12">
     
    2022                    <table class="table table-striped">
    2123                        <thead>
    22                         <tr>
    23                             <th scope="col">Location name</th>
    24                         </tr>
     24                            <tr>
     25                                <th scope="col">Location name</th>
     26                            </tr>
    2527                        </thead>
    2628                        <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>
    3843                        </tbody>
    3944                    </table>
     
    4449    <button pButton pRipplelabel label="Save" class="p-button-help"></button>
    4550</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  
    2424
    2525  constructor(private router: Router, private route: ActivatedRoute, private fb: FormBuilder, private plannerService: PlannerService,
    26     private locationService : LocationService) {
     26    private locationService: LocationService) {
    2727    this.planner = new Planner();
    2828    this.planners = [];
     
    5050    this.locationService.getLocationsForPlanner(this.id).subscribe(
    5151      data => {
    52           this.locations = data;
     52        this.locations = data;
    5353      }
    5454    );
    55     }
    56  
     55  }
     56
    5757  onSubmit() {
    5858    this.updatePlanner();
     
    7777  }
    7878
    79   onClickBack(){
     79  onClickBack() {
    8080    this.router.navigate(['planners']);
    8181  }
     82
     83  onClickRemoveLocation(id : number){
     84   
     85  }
    8286}
  • 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">
    23
    34<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
    516<br>
    617<br>
    718<p-table [value]="planners" [paginator]="true" [rows]="3" [responsive]="true">
    8  
     19
    920  <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>
    2136  </ng-template>
    2237</p-table>
    23 
    24 
  • trip-planner-front/src/app/planner/planner.component.ts

    r84d0fbb rbdd6491  
    88import { MessageService, PrimeNGConfig } from 'primeng/api';
    99import { UserDto } from '../_models/dto/userDto';
    10 import { UserService } from '../_services/user.service';
    1110
    1211
     
    2322  ref: DynamicDialogRef;
    2423  user: UserDto;
     24  userDisplayName = '';
     25  status = '';
    2526
    2627  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) {
    2929    this.planners = [];
    3030    this.plannerDto = new PlannerDto();
     
    3636
    3737    this.primengConfig.ripple = true;
    38 
     38    let name1: string = sessionStorage.getItem("username") as string;
     39    this.userDisplayName = name1;
    3940    this.plannerService.getAllPlanners().subscribe(
    4041      data => {
    4142        this.planners = data;
    42         localStorage.getItem("token");
    4343      }
    44     ); 
     44    );
    4545  }
    4646
     
    6161      baseZIndex: 10000
    6262    });
    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     
    7275    });
    73    
     76
    7477  }
    7578
     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  }
    76101}
Note: See TracChangeset for help on using the changeset viewer.