Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # src/app/detail/detail.component.ts
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
allowfullscreen>
|
||||
</iframe>
|
||||
</div>
|
||||
<button (click)="generateQR()">
|
||||
<button >
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="17.334" height="23.4863">
|
||||
<g>
|
||||
<rect height="23.4863" opacity="0" width="17.334" x="0" y="0"/>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<li (click)="switchLanguage('DE')"><a>DE</a></li>
|
||||
<li (click)="switchLanguage('FR')"><a>FR</a></li>
|
||||
<li (click)="switchLanguage('IT')"><a>IT</a></li>
|
||||
<li (click)="switchLanguage('EN')"><a>EN</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -52,14 +53,6 @@
|
||||
{{luogo.location}}
|
||||
</li>
|
||||
|
||||
<li class="menu-title">
|
||||
<span>{{translations.menuNear}}</span>
|
||||
</li>
|
||||
|
||||
<li *ngFor="let luogo of luoghiNear()">
|
||||
{{luogo.location}}
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,7 @@ import {Locations} from "../interface/data";
|
||||
import {Router} from "@angular/router";
|
||||
import { TranslateService } from '../service/translate.service';
|
||||
import {ReadTranslateJsonService} from "../service/readTranslateJsonService";
|
||||
import {translations} from "../interface/translations";
|
||||
import {homeTranslations} from "../interface/translations";
|
||||
|
||||
|
||||
|
||||
@@ -28,15 +28,14 @@ export class HomeComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
suggerimentoAttivo: boolean = false;
|
||||
suggerimento: string = '';
|
||||
completamento: string = '';
|
||||
input: string = 'How are you?';
|
||||
translations: translations = {} as translations;
|
||||
translations: homeTranslations = {} as homeTranslations;
|
||||
|
||||
|
||||
constructor(private readjsonService: ReadjsonService, private router: Router, private translateService: TranslateService, private readTranslationJsonService: ReadTranslateJsonService) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.translations = this.readTranslationJsonService.getData();
|
||||
this.translations = this.readTranslationJsonService.getHomeTranslations();
|
||||
console.log("translations loaded", this.translations)
|
||||
|
||||
this.readjsonService.getLocations().subscribe(data => {
|
||||
@@ -124,7 +123,6 @@ export class HomeComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.translations.menuPlaces = await this.translateService.getData(this.translations.menuPlaces, lang);
|
||||
this.translations.alertMessage = await this.translateService.getData(this.translations.alertMessage, lang);
|
||||
this.translations.searchPlaceholder = await this.translateService.getData(this.translations.searchPlaceholder, lang);
|
||||
this.translations.menuNear = await this.translateService.getData(this.translations.menuNear, lang);
|
||||
this.translations.searchButton = await this.translateService.getData(this.translations.searchButton, lang);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
export interface translations {
|
||||
export interface homeTranslations {
|
||||
alertMessage: string;
|
||||
translate: string;
|
||||
searchButton: string;
|
||||
searchPlaceholder: string;
|
||||
menuPlaces: string;
|
||||
menuNear: string;
|
||||
}
|
||||
|
||||
export interface listTranslations {
|
||||
translate: string;
|
||||
locationName: string;
|
||||
distance: string;
|
||||
positionNotFoundErrorMessage: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,27 +1,38 @@
|
||||
<div *ngIf="isNear">
|
||||
<div class="dropdown dropdown-hover" id="translate">
|
||||
<label tabindex="0" class="btn m-1 bg-black border-neutral text-base-100" id="translateLabel">{{translations.translate}}</label>
|
||||
<ul tabindex="0" class="dropdown-content menu p-2 shadow rounded-box w-52" id="translateUl">
|
||||
<li (click)="switchLanguage('DE')"><a>DE</a></li>
|
||||
<li (click)="switchLanguage('FR')"><a>FR</a></li>
|
||||
<li (click)="switchLanguage('IT')"><a>IT</a></li>
|
||||
<li (click)="switchLanguage('EN')"><a>EN</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div *ngIf="isNear" class="container">
|
||||
<h1>
|
||||
Posizione {{locationParams}} non trovata
|
||||
{{translations.locationName}}{{locationParams}}
|
||||
</h1>
|
||||
<div *ngFor="let locations of locations, let i = index">
|
||||
<div *ngFor="let locations of locations, let i = index" class="row">
|
||||
<h3>
|
||||
<a class="link link-primary" href="location/{{locations.location}}">{{locations.location}}</a>
|
||||
</h3>
|
||||
<div *ngIf="distance[i]">
|
||||
<h4>Distance: {{distance[i]}} km</h4>
|
||||
<div>
|
||||
<h4 *ngIf="distance[i]">{{translations.distance}}{{distance[i]}} km</h4>
|
||||
<h4 *ngIf="positionNotFound">could not retrieve distance</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="!isNear && location && location.waypoints">
|
||||
<div *ngIf="!isNear && location && location.waypoints" class="container">
|
||||
<h1>
|
||||
{{location.location}}
|
||||
</h1>
|
||||
<div *ngFor="let waypoinst of location.waypoints, let i = index">
|
||||
<div *ngFor="let waypoinst of location.waypoints, let i = index" class="row">
|
||||
<h3>
|
||||
<a class="link link-primary" href="location/{{location.location}}/{{waypoinst.id}}"> {{waypoinst.name}}</a>
|
||||
</h3>
|
||||
<div *ngIf="distance[i]">
|
||||
<h4>Distance: {{distance[i]}} km</h4>
|
||||
<div class="distance">
|
||||
<h4 *ngIf="distance[i]">{{translations.distance}}{{distance[i]}} km</h4>
|
||||
<h4 *ngIf="positionNotFound">{{translations.positionNotFoundErrorMessage}}</h4>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,9 @@ import {Locations} from "../interface/data";
|
||||
import {ReadjsonService} from "../service/readjson.service";
|
||||
import {ActivatedRoute} from "@angular/router";
|
||||
import {positionService} from "../service/position.service";
|
||||
import {listTranslations} from "../interface/translations";
|
||||
import {TranslateService} from "../service/translate.service";
|
||||
import {ReadTranslateJsonService} from "../service/readTranslateJsonService";
|
||||
|
||||
@Component({
|
||||
selector: 'app-list',
|
||||
@@ -20,11 +23,15 @@ export class ListComponent implements OnInit, OnChanges {
|
||||
|
||||
distance: number[] = [];
|
||||
|
||||
translations: listTranslations = {} as listTranslations
|
||||
|
||||
constructor(private route: ActivatedRoute, private readjsonService: ReadjsonService, private positionService: positionService) {
|
||||
positionNotFound: boolean = false;
|
||||
|
||||
constructor(private route: ActivatedRoute, private readjsonService: ReadjsonService, private positionService: positionService, private translateService: TranslateService, private readTranslationJsonService: ReadTranslateJsonService) {
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
this.translations = this.readTranslationJsonService.getListTransaltions();
|
||||
this.route.params.subscribe(params => {
|
||||
this.locationParams = params['location'];
|
||||
});
|
||||
@@ -43,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) {
|
||||
@@ -69,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 {
|
||||
@@ -98,5 +117,10 @@ export class ListComponent implements OnInit, OnChanges {
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
|
||||
async switchLanguage(lang: string) {
|
||||
this.translations.translate = await this.translateService.getData(this.translations.translate, lang);
|
||||
this.translations.distance = await this.translateService.getData(this.translations.distance, lang);
|
||||
this.translations.locationName = await this.translateService.getData(this.translations.locationName, lang);
|
||||
this.translations.positionNotFoundErrorMessage = await this.translateService.getData(this.translations.positionNotFoundErrorMessage, lang);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,39 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {translations} from "../interface/translations";
|
||||
import {homeTranslations} from "../interface/translations";
|
||||
import {listTranslations} from "../interface/translations";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ReadTranslateJsonService {
|
||||
private translationData: translations = {} as translations;
|
||||
private homeTranslations: homeTranslations = {} as homeTranslations;
|
||||
private listTranslation: listTranslations = {} as listTranslations;
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
this.http.get<translations>('assets/i18n/en.json').subscribe(data => {
|
||||
this.translationData.alertMessage = data.alertMessage;
|
||||
this.translationData.translate = data.translate;
|
||||
this.translationData.searchButton = data.searchButton;
|
||||
this.translationData.searchPlaceholder = data.searchPlaceholder;
|
||||
this.translationData.menuPlaces = data.menuPlaces;
|
||||
this.translationData.menuNear = data.menuNear;
|
||||
console.log("data loaded", this.translationData)
|
||||
this.http.get<homeTranslations>('assets/i18n/home/en.json').subscribe(data => {
|
||||
this.homeTranslations.alertMessage = data.alertMessage;
|
||||
this.homeTranslations.translate = data.translate;
|
||||
this.homeTranslations.searchButton = data.searchButton;
|
||||
this.homeTranslations.searchPlaceholder = data.searchPlaceholder;
|
||||
this.homeTranslations.menuPlaces = data.menuPlaces;
|
||||
console.log("data loaded", this.homeTranslations)
|
||||
});
|
||||
|
||||
this.http.get<listTranslations>('assets/i18n/list/en.json').subscribe(data => {
|
||||
this.listTranslation.translate = data.translate;
|
||||
this.listTranslation.distance = data.distance;
|
||||
this.listTranslation.locationName = data.locationName;
|
||||
this.listTranslation.positionNotFoundErrorMessage = data.positionNotFoundErrorMessage;
|
||||
console.log("data loaded", this.homeTranslations)
|
||||
});
|
||||
}
|
||||
|
||||
getData(): translations {
|
||||
console.log("data loaded", this.translationData)
|
||||
return this.translationData;
|
||||
getHomeTranslations(): homeTranslations {
|
||||
return this.homeTranslations;
|
||||
}
|
||||
|
||||
getListTransaltions(): listTranslations {
|
||||
return this.listTranslation;
|
||||
}
|
||||
}
|
||||
|
||||
0
src/assets/i18n/detail/en.json
Normal file
0
src/assets/i18n/detail/en.json
Normal file
@@ -3,6 +3,5 @@
|
||||
"translate": "Translate",
|
||||
"searchButton": "Search",
|
||||
"searchPlaceholder": "Type here...",
|
||||
"menuPlaces": "Places",
|
||||
"menuNear": "Near"
|
||||
"menuPlaces": "Places"
|
||||
}
|
||||
6
src/assets/i18n/list/en.json
Normal file
6
src/assets/i18n/list/en.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"translate": "Translate",
|
||||
"locationName": "Position not found: ",
|
||||
"distance": "Distance: ",
|
||||
"positionNotFoundErrorMessage": "Could not retrieve position"
|
||||
}
|
||||
Reference in New Issue
Block a user