Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/app/detail/detail.component.ts
This commit is contained in:
tito
2023-04-26 15:52:18 +02:00
13 changed files with 22675 additions and 48 deletions

22538
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -19,6 +19,7 @@
"@angular/platform-browser-dynamic": "^15.0.0", "@angular/platform-browser-dynamic": "^15.0.0",
"@angular/router": "^15.0.0", "@angular/router": "^15.0.0",
"angularx-qrcode": "^15.0.1", "angularx-qrcode": "^15.0.1",
"canvas": "^2.11.2",
"daisyui": "^2.49.0", "daisyui": "^2.49.0",
"deepl": "^1.0.13", "deepl": "^1.0.13",
"geolib": "^3.3.3", "geolib": "^3.3.3",

View File

@@ -12,7 +12,7 @@
allowfullscreen> allowfullscreen>
</iframe> </iframe>
</div> </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"> <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> <g>
<rect height="23.4863" opacity="0" width="17.334" x="0" y="0"/> <rect height="23.4863" opacity="0" width="17.334" x="0" y="0"/>

View File

@@ -17,6 +17,7 @@
<li (click)="switchLanguage('DE')"><a>DE</a></li> <li (click)="switchLanguage('DE')"><a>DE</a></li>
<li (click)="switchLanguage('FR')"><a>FR</a></li> <li (click)="switchLanguage('FR')"><a>FR</a></li>
<li (click)="switchLanguage('IT')"><a>IT</a></li> <li (click)="switchLanguage('IT')"><a>IT</a></li>
<li (click)="switchLanguage('EN')"><a>EN</a></li>
</ul> </ul>
</div> </div>
@@ -52,14 +53,6 @@
{{luogo.location}} {{luogo.location}}
</li> </li>
<li class="menu-title">
<span>{{translations.menuNear}}</span>
</li>
<li *ngFor="let luogo of luoghiNear()">
{{luogo.location}}
</li>
</ul> </ul>
</ng-container> </ng-container>
</div> </div>

View File

@@ -5,7 +5,7 @@ import {Locations} from "../interface/data";
import {Router} from "@angular/router"; import {Router} from "@angular/router";
import { TranslateService } from '../service/translate.service'; import { TranslateService } from '../service/translate.service';
import {ReadTranslateJsonService} from "../service/readTranslateJsonService"; 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; suggerimentoAttivo: boolean = false;
suggerimento: string = ''; suggerimento: string = '';
completamento: string = ''; completamento: string = '';
input: string = 'How are you?'; translations: homeTranslations = {} as homeTranslations;
translations: translations = {} as translations;
constructor(private readjsonService: ReadjsonService, private router: Router, private translateService: TranslateService, private readTranslationJsonService: ReadTranslateJsonService) { constructor(private readjsonService: ReadjsonService, private router: Router, private translateService: TranslateService, private readTranslationJsonService: ReadTranslateJsonService) {
} }
ngOnInit(): void { ngOnInit(): void {
this.translations = this.readTranslationJsonService.getData(); this.translations = this.readTranslationJsonService.getHomeTranslations();
console.log("translations loaded", this.translations) console.log("translations loaded", this.translations)
this.readjsonService.getLocations().subscribe(data => { 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.menuPlaces = await this.translateService.getData(this.translations.menuPlaces, lang);
this.translations.alertMessage = await this.translateService.getData(this.translations.alertMessage, 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.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); this.translations.searchButton = await this.translateService.getData(this.translations.searchButton, lang);
} }
} }

View File

@@ -1,9 +1,15 @@
export interface translations { export interface homeTranslations {
alertMessage: string; alertMessage: string;
translate: string; translate: string;
searchButton: string; searchButton: string;
searchPlaceholder: string; searchPlaceholder: string;
menuPlaces: string; menuPlaces: string;
menuNear: string; }
export interface listTranslations {
translate: string;
locationName: string;
distance: string;
positionNotFoundErrorMessage: string;
} }

View File

@@ -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;
}

View File

@@ -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> <h1>
Posizione {{locationParams}} non trovata {{translations.locationName}}{{locationParams}}
</h1> </h1>
<div *ngFor="let locations of locations, let i = index"> <div *ngFor="let locations of locations, let i = index" class="row">
<h3> <h3>
<a class="link link-primary" href="location/{{locations.location}}">{{locations.location}}</a> <a class="link link-primary" href="location/{{locations.location}}">{{locations.location}}</a>
</h3> </h3>
<div *ngIf="distance[i]"> <div>
<h4>Distance: {{distance[i]}} km</h4> <h4 *ngIf="distance[i]">{{translations.distance}}{{distance[i]}} km</h4>
<h4 *ngIf="positionNotFound">could not retrieve distance</h4>
</div> </div>
</div> </div>
</div> </div>
<div *ngIf="!isNear && location && location.waypoints"> <div *ngIf="!isNear && location && location.waypoints" class="container">
<h1> <h1>
{{location.location}} {{location.location}}
</h1> </h1>
<div *ngFor="let waypoinst of location.waypoints, let i = index"> <div *ngFor="let waypoinst of location.waypoints, let i = index" class="row">
<h3> <h3>
<a class="link link-primary" href="location/{{location.location}}/{{waypoinst.id}}"> {{waypoinst.name}}</a> <a class="link link-primary" href="location/{{location.location}}/{{waypoinst.id}}"> {{waypoinst.name}}</a>
</h3> </h3>
<div *ngIf="distance[i]"> <div class="distance">
<h4>Distance: {{distance[i]}} km</h4> <h4 *ngIf="distance[i]">{{translations.distance}}{{distance[i]}} km</h4>
<h4 *ngIf="positionNotFound">{{translations.positionNotFoundErrorMessage}}</h4>
</div> </div>
</div> </div>

View File

@@ -3,6 +3,9 @@ import {Locations} from "../interface/data";
import {ReadjsonService} from "../service/readjson.service"; import {ReadjsonService} from "../service/readjson.service";
import {ActivatedRoute} from "@angular/router"; import {ActivatedRoute} from "@angular/router";
import {positionService} from "../service/position.service"; import {positionService} from "../service/position.service";
import {listTranslations} from "../interface/translations";
import {TranslateService} from "../service/translate.service";
import {ReadTranslateJsonService} from "../service/readTranslateJsonService";
@Component({ @Component({
selector: 'app-list', selector: 'app-list',
@@ -20,11 +23,15 @@ export class ListComponent implements OnInit, OnChanges {
distance: number[] = []; 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() { async ngOnInit() {
this.translations = this.readTranslationJsonService.getListTransaltions();
this.route.params.subscribe(params => { this.route.params.subscribe(params => {
this.locationParams = params['location']; this.locationParams = params['location'];
}); });
@@ -43,6 +50,18 @@ export class ListComponent implements OnInit, OnChanges {
} }
}); });
this.getPosition(); this.getPosition();
this.positionNotFoundFunction();
}
positionNotFoundFunction() {
if (!this.positionNotFound) {
setTimeout(() => {
if (!this.distance[0]) {
this.positionNotFound = true;
}
}, 5000);
}
} }
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {
@@ -98,5 +117,10 @@ export class ListComponent implements OnInit, OnChanges {
}, 2000); }, 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);
}
} }

View File

@@ -1,27 +1,39 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {HttpClient} from "@angular/common/http"; import {HttpClient} from "@angular/common/http";
import {translations} from "../interface/translations"; import {homeTranslations} from "../interface/translations";
import {listTranslations} from "../interface/translations";
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class ReadTranslateJsonService { export class ReadTranslateJsonService {
private translationData: translations = {} as translations; private homeTranslations: homeTranslations = {} as homeTranslations;
private listTranslation: listTranslations = {} as listTranslations;
constructor(private http: HttpClient) { constructor(private http: HttpClient) {
this.http.get<translations>('assets/i18n/en.json').subscribe(data => { this.http.get<homeTranslations>('assets/i18n/home/en.json').subscribe(data => {
this.translationData.alertMessage = data.alertMessage; this.homeTranslations.alertMessage = data.alertMessage;
this.translationData.translate = data.translate; this.homeTranslations.translate = data.translate;
this.translationData.searchButton = data.searchButton; this.homeTranslations.searchButton = data.searchButton;
this.translationData.searchPlaceholder = data.searchPlaceholder; this.homeTranslations.searchPlaceholder = data.searchPlaceholder;
this.translationData.menuPlaces = data.menuPlaces; this.homeTranslations.menuPlaces = data.menuPlaces;
this.translationData.menuNear = data.menuNear; console.log("data loaded", this.homeTranslations)
console.log("data loaded", this.translationData) });
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 { getHomeTranslations(): homeTranslations {
console.log("data loaded", this.translationData) return this.homeTranslations;
return this.translationData; }
getListTransaltions(): listTranslations {
return this.listTranslation;
} }
} }

View File

View File

@@ -3,6 +3,5 @@
"translate": "Translate", "translate": "Translate",
"searchButton": "Search", "searchButton": "Search",
"searchPlaceholder": "Type here...", "searchPlaceholder": "Type here...",
"menuPlaces": "Places", "menuPlaces": "Places"
"menuNear": "Near"
} }

View File

@@ -0,0 +1,6 @@
{
"translate": "Translate",
"locationName": "Position not found: ",
"distance": "Distance: ",
"positionNotFoundErrorMessage": "Could not retrieve position"
}