Ignore:
Timestamp:
02/06/22 18:15:51 (3 years ago)
Author:
Ema <ema_spirova@…>
Branches:
master
Children:
571e0df
Parents:
76712b2
Message:

add location feature

Location:
trip-planner-front/src/app
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • trip-planner-front/src/app/_services/location.service.ts

    r76712b2 r6fe77af  
    1 import { HttpClient } from "@angular/common/http";
     1import { HttpClient, HttpHeaders } from "@angular/common/http";
    22import { Injectable } from "@angular/core";
    33import { Observable } from "rxjs";
     4import { LocationDto } from "../_models/dto/locationDto";
    45import { PlannerLocationDto } from "../_models/dto/plannerLocationDto";
    56import { Location } from "../_models/location";
     
    910})
    1011export class LocationService{
     12
     13    httpHeaders: HttpHeaders = new HttpHeaders({
     14        'Authorization': '' + sessionStorage.getItem("token"),
     15        'Accept': 'application/json',
     16        'Content-Type': 'application/json'
     17    });
     18
    1119    constructor(private httpClient : HttpClient){}
    1220
     
    6573        return this.httpClient.get<Location[]>(url + "?place=" + place);
    6674    }
     75
     76    save(locationDto : LocationDto) : Observable<Location>{
     77        let url = "http://localhost:8080/api/add";
     78        return this.httpClient.post<Location>(url, locationDto, {headers: this.httpHeaders});
     79    }
    6780}
  • trip-planner-front/src/app/app-routing.module.ts

    r76712b2 r6fe77af  
    55import { HomepageComponent } from './homepage/homepage.component';
    66import { LoginComponent } from './homepage/login/login.component';
     7import { AddLocationComponent } from './location/add-location/add-location.component';
    78import { LocationDetailsComponent } from './location/location-details/location-details.component';
    89import { LocationComponent } from './location/location.component';
     
    1011import { EditPlannerComponent } from './planner/edit-planner/edit-planner.component';
    1112import { PlannerComponent } from './planner/planner.component';
     13
    1214
    1315const routes: Routes = [
     
    2022  {path: 'location', component: LocationDetailsComponent},
    2123  {path: 'explore', component: ExploreComponent},
    22   {path: 'results', component: ExploreResultComponent}
     24  {path: 'results', component: ExploreResultComponent},
     25  {path: 'add-location', component: AddLocationComponent}
    2326];
    2427
  • trip-planner-front/src/app/app.module.ts

    r76712b2 r6fe77af  
    5252import { ExploreResultComponent } from './explore/explore-result/explore-result.component';
    5353import {RatingModule} from 'primeng/rating';
    54 import { CustomValidators } from './providers/CustomValidators';
     54import { AddLocationComponent } from './location/add-location/add-location.component';
     55import {StepsModule} from 'primeng/steps';
     56import {MatStepperModule} from '@angular/material/stepper';
     57import {FileUploadModule} from 'primeng/fileupload';
    5558
    5659@NgModule({
     
    6871    LoginComponent,
    6972    ExploreComponent,
    70     ExploreResultComponent
    71   ],
     73    ExploreResultComponent,
     74    AddLocationComponent
     75    ],
    7276  imports: [
    7377    BrowserModule,
     
    110114    CardModule,
    111115    AutoCompleteModule,
    112     RatingModule
    113   ],
     116    RatingModule,
     117    StepsModule,
     118    MatStepperModule,
     119    FileUploadModule
     120    ],
    114121
    115122
  • trip-planner-front/src/app/explore/explore-result/explore-result.component.html

    r76712b2 r6fe77af  
    1515
    1616  <main role="main">
    17     <h1 style="color: #F77D62; display: inline; ">Explore </h1>
     17    <h1 style="color: #F77D62; display: inline;">Explore</h1>
    1818    <h1 style=" display: inline;">{{place}}</h1>
    1919    <div class="lightbox" *ngFor="let l of allLocation">
     
    2525      </div>
    2626    </div>
     27
     28
     29   
    2730    <div class="container">
    2831      <li *ngFor="let location of allLocation">
  • trip-planner-front/src/app/explore/explore-result/explore-result.component.ts

    r76712b2 r6fe77af  
    1717  }
    1818
     19  responsiveOptions:any[] = [
     20    {
     21        breakpoint: '1024px',
     22        numVisible: 5
     23    },
     24    {
     25        breakpoint: '768px',
     26        numVisible: 3
     27    },
     28    {
     29        breakpoint: '560px',
     30        numVisible: 1
     31    }
     32];
    1933  ngOnInit(): void {
    2034    this.route.queryParams
     
    2539
    2640      this.locationService.getAllLocationsSearch(this.place).subscribe(
    27         data => {
    28           this.allLocation = data;
     41        res => {
     42          this.allLocation = res;
    2943        }
    3044    )
  • trip-planner-front/src/app/location/location-details/location-details.component.ts

    r76712b2 r6fe77af  
    11import { Component, OnInit } from '@angular/core';
    2 import { ActivatedRoute, Router } from '@angular/router';
     2import { ActivatedRoute } from '@angular/router';
    33import { Images } from 'src/app/_models/images';
    44import { Location } from 'src/app/_models/location';
     
    1717  images: Images[];
    1818
    19   constructor(private route: ActivatedRoute, private router: Router, private locationService: LocationService,
     19  constructor(private route: ActivatedRoute, private locationService: LocationService,
    2020    private imagesService: ImagesService) {
    2121    this.locationId = 1;
  • trip-planner-front/src/app/locations-form/locations-form.component.html

    r76712b2 r6fe77af  
    3535      <mat-label>Please select a region</mat-label>
    3636      <mat-select [(ngModel)]="regionId" placeholder="Select region" name="region">
    37         <mat-option [value]="region.id" *ngFor="let region of regions" [value]="region.id"> {{region.name}}
     37        <mat-option [value]="region.id" *ngFor="let region of regions"> {{region.name}}
    3838        </mat-option>
    3939      </mat-select>
  • trip-planner-front/src/app/planner/planner.component.html

    r76712b2 r6fe77af  
    1313</nav>
    1414
     15<button pButton pRipple type="button" label="Add location" class="p-button-help " (click)="onClickAddLocation()"></button>
    1516
    1617<br>
  • trip-planner-front/src/app/planner/planner.component.ts

    r76712b2 r6fe77af  
    9999    window.location.reload();
    100100  }
     101
     102  onClickAddLocation(){
     103    this.router.navigate(['add-location']);
     104  }
    101105}
Note: See TracChangeset for help on using the changeset viewer.