From 75833f4db41d6a6c6da97f57bf202a2ff5d9be81 Mon Sep 17 00:00:00 2001 From: grata Date: Tue, 25 Apr 2023 14:59:39 +0200 Subject: [PATCH] improved list.component style and added position not found error handling --- src/app/home/home.component.html | 1 + src/app/list/list.component.css | 39 ++++++++++++++++++++++++++++++++ src/app/list/list.component.html | 35 +++++++++++++++------------- src/app/list/list.component.ts | 28 ++++++++++++++++------- 4 files changed, 79 insertions(+), 24 deletions(-) diff --git a/src/app/home/home.component.html b/src/app/home/home.component.html index 9bdba3c..2545413 100644 --- a/src/app/home/home.component.html +++ b/src/app/home/home.component.html @@ -17,6 +17,7 @@
  • DE
  • FR
  • IT
  • +
  • EN
  • diff --git a/src/app/list/list.component.css b/src/app/list/list.component.css index e69de29..1b36773 100644 --- a/src/app/list/list.component.css +++ b/src/app/list/list.component.css @@ -0,0 +1,39 @@ +h1 { + font-size: 75px; + padding-left: 0; +} + +h3 { + font-size: 25px; + margin-top: 20px; +} + +h4 { + color: dimgray; +} + +.distance { + font-size: 20px; + border-bottom: 2px solid #E9E92D; + width: 35%; + padding-bottom: 20px; + height: 60px; +} + +.row { +} + +.container { + margin-left: 20px; + display: flex; + flex-direction: column; +} + +#translate{ + position: absolute; + right: 0; +} +#translateUl{ + position: absolute; + right: 0; +} diff --git a/src/app/list/list.component.html b/src/app/list/list.component.html index 3c24f74..089f016 100644 --- a/src/app/list/list.component.html +++ b/src/app/list/list.component.html @@ -1,35 +1,38 @@ - -
    + +

    {{translations.locationName}}{{locationParams}}

    -
    +

    {{locations.location}}

    -
    -

    {{translations.distance}}{{distance[i]}} km

    +
    +

    {{translations.distance}}{{distance[i]}} km

    +

    could not retrieve distance

    -
    +

    {{location.location}}

    -
    +

    {{waypoinst.name}}

    -
    -

    {{translations.distance}}{{distance[i]}} km

    +
    +

    {{translations.distance}}{{distance[i]}} km

    +

    could not retrieve distance

    diff --git a/src/app/list/list.component.ts b/src/app/list/list.component.ts index 0e6d1e2..f7ab6dd 100644 --- a/src/app/list/list.component.ts +++ b/src/app/list/list.component.ts @@ -25,6 +25,8 @@ export class ListComponent implements OnInit, OnChanges { translations: listTranslations = {} as listTranslations + positionNotFound: boolean = false; + constructor(private route: ActivatedRoute, private readjsonService: ReadjsonService, private positionService: positionService, private translateService: TranslateService, private readTranslationJsonService: ReadTranslateJsonService) { } @@ -48,6 +50,18 @@ export class ListComponent implements OnInit, OnChanges { } }); this.getPosition(); + this.positionNotFoundFunction(); + } + + positionNotFoundFunction() { + if (!this.positionNotFound) { + setTimeout(() => { + if (!this.distance[0]) { + this.positionNotFound = true; + + } + }, 5000); + } } ngOnChanges(changes: SimpleChanges) { @@ -74,26 +88,26 @@ export class ListComponent implements OnInit, OnChanges { } private setDistance(): void { - if (this.locations && this.location){ - if (this.isNear){ + if (this.locations && this.location) { + if (this.isNear) { console.log("location lenght " + this.locations.length); for (let i = 0; i < this.locations.length; i++) { - console.log("for"+i); + console.log("for" + i); console.log("lat" + this.locations[i].lat); this.distance.push(this.positionService.getDistanceBetweenCoordinates(this.locations[i].lat, this.locations[i].lon, this.positionCord.lat, this.positionCord.lon)); } - } else{ + } else { if (this.location?.waypoints) { console.log("waypoints lenght " + this.location.waypoints.length); for (let i = 0; i < this.location.waypoints.length; i++) { - console.log("for"+i); + console.log("for" + i); console.log("lat" + this.location.waypoints[i].lat); this.distance.push(this.positionService.getDistanceBetweenCoordinates(this.location.waypoints[i].lat, this.location.waypoints[i].lon, this.positionCord.lat, this.positionCord.lon)); } } } } - console.log("ciao" + this.distance[0]) + console.log("ciao" + this.distance[0]) } getPosition(): any { @@ -109,6 +123,4 @@ export class ListComponent implements OnInit, OnChanges { this.translations.locationName = await this.translateService.getData(this.translations.locationName, lang); } - - }