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

This commit is contained in:
tito
2023-05-07 11:45:34 +02:00
9 changed files with 74 additions and 96 deletions

View File

@@ -2,7 +2,7 @@
<div class="dropdown dropdown-hover" id="translate"> <div class="dropdown dropdown-hover" id="translate">
<label tabindex="0" class="btn m-1 bg-black border-neutral text-base-100 hover:bg-neutral hover:text-base-100" <label tabindex="0" class="btn m-1 bg-black border-neutral text-base-100 hover:bg-neutral hover:text-base-100"
id="translateLabel">{{homeTranslations.translate}}</label> id="translateLabel">{{homeTranslations.translate}}</label>
<ul tabindex="0" class="dropdown-content menu p-2 shadow rounded-box w-52" id="translateUl"> <ul tabindex="0" class="dropdown-content menu p-2 shadow rounded-box w-52 bg-base-100" id="translateUl">
<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>

View File

@@ -1,16 +1,20 @@
<div *ngIf="isNear" class="container"> <div *ngIf="isNear" class="container">
<h1> <h1>
{{translations.locationName}}{{locationParams}} {{translations.locationName}}: {{locationParams}}
</h1> </h1>
<div class="container2">
<div class="left">
<div *ngFor="let locations of locations, let i = index" class="row"> <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> <div class="distance">
<h4 *ngIf="locations.distance && !positionNotFound">{{translations.distance}}{{locations.distance}} km</h4> <h4 *ngIf="locations.distance && !positionNotFound">{{translations.distance}}{{locations.distance}} km</h4>
<h4 *ngIf="positionNotFound">{{translations.positionNotFoundErrorMessage}}</h4> <h4 *ngIf="positionNotFound">{{translations.positionNotFoundErrorMessage}}</h4>
</div> </div>
</div> </div>
</div>
</div>
</div> </div>
<div *ngIf="!isNear && location && waypoints" class="container"> <div *ngIf="!isNear && location && waypoints" class="container">
@@ -24,16 +28,16 @@
<a class="link link-primary" href="location/{{location.location}}/{{waypoint.id}}"> {{waypoint.name}}</a> <a class="link link-primary" href="location/{{location.location}}/{{waypoint.id}}"> {{waypoint.name}}</a>
</h3> </h3>
<div class="distance"> <div class="distance">
<h4 *ngIf="waypoint.distance && !positionNotFound">{{translations.distance}}{{waypoint.distance}} km</h4> <h4 *ngIf="waypoint.distance && !positionNotFound">{{translations.distance}}: {{waypoint.distance}} km</h4>
<h4 *ngIf="positionNotFound">{{translations.positionNotFoundErrorMessage}}</h4> <h4 *ngIf="positionNotFound">{{translations.positionNotFoundErrorMessage}}</h4>
</div> </div>
</div> </div>
</div> </div>
<div class="right"> <div class="right">
<div class="radial-progress text-primary" id="radial" style="--value:70; --size:12rem; --thickness: 1.5rem;"> <div class="radial-progress text-primary" id="radial" style="--value:{{percentage}}; --size:12rem; --thickness: 1.5rem;">
<span style="font-size: 20pt"> <span style="font-size: 20pt">
70% {{percentage}}%
</span> </span>
</div> </div>
</div> </div>

View File

@@ -9,6 +9,8 @@ import {WaypointService} from "../../service/http/waypoint.service"
import {cookieService} from "../../service/cookie.service"; import {cookieService} from "../../service/cookie.service";
import {UserService} from "../../service/http/user.service"; import {UserService} from "../../service/http/user.service";
import {WaypointVisitedService} from "../../service/http/waypointVisited.service"; import {WaypointVisitedService} from "../../service/http/waypointVisited.service";
import {ReadTranslateJsonService} from "../../service/language/readTranslateJson.service";
import {filter} from "rxjs";
@Component({ @Component({
selector: 'app-list', selector: 'app-list',
@@ -42,10 +44,12 @@ export class ListComponent implements OnInit, OnChanges {
private waypointVisitedService: WaypointVisitedService, private waypointVisitedService: WaypointVisitedService,
private userService: UserService, private userService: UserService,
private cookieService: cookieService, private cookieService: cookieService,
private readTranslationJsonService: ReadTranslateJsonService,
) { ) {
} }
async ngOnInit() { async ngOnInit() {
this.translations = this.readTranslationJsonService.getListTransaltions();
this.username = this.cookieService.getUsername(); this.username = this.cookieService.getUsername();
this.route.params.subscribe(params => { this.route.params.subscribe(params => {
this.locationParams = params['location']; this.locationParams = params['location'];
@@ -57,8 +61,8 @@ export class ListComponent implements OnInit, OnChanges {
this.waypointService.getWaypoints(this.location.location).subscribe(waypoints => { this.waypointService.getWaypoints(this.location.location).subscribe(waypoints => {
this.waypoints = waypoints; this.waypoints = waypoints;
console.log("waypoints", this.waypoints); console.log("waypoints", this.waypoints);
this.setVisited();
this.setDistance(); this.setDistance();
//this.setVisited();
}); });
} }
@@ -70,7 +74,7 @@ export class ListComponent implements OnInit, OnChanges {
}); });
this.getPosition(); this.getPosition();
this.positionNotFoundFunction(); this.positionNotFoundFunction();
this.setDistance();
} }
@@ -126,7 +130,26 @@ export class ListComponent implements OnInit, OnChanges {
} }
} }
} }
/*
private setVisited(): void {
console.log("setVisited")
if (this.username && this.waypoints) {
for (let i = 0; i < this.waypoints.length; i++) {
if (this.waypoints[i].id) {
this.waypointVisitedService.getWaypointByUserAndWaypoint(this.username, this.waypoints[i].id).subscribe((waypointVisited: any) => {
if (this.waypoints) {
this.waypoints[i].visited = waypointVisited;
console.log(this.waypoints[i].visited);
this.setPercentage();
}
});
}
}
}
}
/*
private setVisited(): void { private setVisited(): void {
if (this.username && this.waypoints) { if (this.username && this.waypoints) {
for (let i = 0; i < this.waypoints.length; i++) { for (let i = 0; i < this.waypoints.length; i++) {
@@ -136,7 +159,8 @@ export class ListComponent implements OnInit, OnChanges {
} }
} }
} }
*/ */
/* /*
private setVisited(): void { private setVisited(): void {
this.userService.getUser(this.username).subscribe((user: any) => { this.userService.getUser(this.username).subscribe((user: any) => {
@@ -162,9 +186,17 @@ export class ListComponent implements OnInit, OnChanges {
*/ */
setPercentage() setPercentage(): void {
: if (this.waypoints) {
void { let count: number = 0;
this.percentage = this.waypoints?.length ?? 0; for (let i = 0; i < this.waypoints.length; i++) {
if (this.waypoints[i].visited) {
count++;
} }
}
this.percentage = parseFloat((count / this.waypoints.length * 100).toFixed(0));
}
console.log("percentage", this.percentage)
}
} }

View File

@@ -1,7 +1,7 @@
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {UserEntity} from "../../interface/UserEntity"; import {UserEntity} from "../../interface/UserEntity";
import {LocationEntity} from "../../interface/LocationEntity"; import {LocationEntity} from "../../interface/LocationEntity";
import {WaypointsEntity} from "../../interface/WaypointsEntity"; import {newWaypoint, WaypointsEntity} from "../../interface/WaypointsEntity";
import {Router} from "@angular/router"; import {Router} from "@angular/router";
import {LocationService} from "../../service/http/location.service"; import {LocationService} from "../../service/http/location.service";
import {UserService} from "../../service/http/user.service"; import {UserService} from "../../service/http/user.service";
@@ -26,7 +26,7 @@ export class ManagementComponent implements OnInit {
newUser: UserEntity = { password: "", username: ""}; newUser: UserEntity = { password: "", username: ""};
newLocation: LocationEntity = {location: "", lat: 0, lon: 0, region: ""}; newLocation: LocationEntity = {location: "", lat: 0, lon: 0, region: ""};
newWaypoint: WaypointsEntity = {description: "", img: "", lat: 0, locationName: "", lon: 0, name: ""}; newWaypoint: newWaypoint = {description: "", img: "", lat: 0, locationName: "", lon: 0, name: ""};
locations: LocationEntity[] | undefined; locations: LocationEntity[] | undefined;
waypoints: WaypointsEntity[] | undefined; waypoints: WaypointsEntity[] | undefined;

View File

@@ -1,5 +1,5 @@
export interface WaypointsEntity { export interface WaypointsEntity {
id?: number; id: number;
name: string; name: string;
lat: number; lat: number;
lon: number; lon: number;
@@ -9,3 +9,11 @@ export interface WaypointsEntity {
distance?: number; distance?: number;
visited?: boolean; visited?: boolean;
} }
export interface newWaypoint {
name: string;
lat: number;
lon: number;
description: string;
img: string;
locationName: string;
}

View File

@@ -1,6 +1,6 @@
import {Injectable} from "@angular/core"; import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http"; import {HttpClient} from "@angular/common/http";
import {WaypointsEntity} from "../../interface/WaypointsEntity"; import {newWaypoint, WaypointsEntity} from "../../interface/WaypointsEntity";
import {catchError, throwError} from "rxjs"; import {catchError, throwError} from "rxjs";
const BASE_URL = "progetto152"; const BASE_URL = "progetto152";
@@ -35,7 +35,7 @@ export class WaypointService {
return this.http.get<WaypointsEntity>(GET_WAYPOINT_BY_ID + id); return this.http.get<WaypointsEntity>(GET_WAYPOINT_BY_ID + id);
} }
createWaypoint(waypoint: WaypointsEntity) { createWaypoint(waypoint: newWaypoint) {
return this.http.post<WaypointsEntity>(WAYPOINT, waypoint); return this.http.post<WaypointsEntity>(WAYPOINT, waypoint);
} }

View File

@@ -31,7 +31,7 @@ export class WaypointVisitedService {
} }
getWaypointByUserAndWaypoint(user: string, waypoint: number) { getWaypointByUserAndWaypoint(user: string, waypoint: number) {
return this.http.get<boolean>(GET_WAYPOINT_BY_USER + user + "/" + waypoint); return this.http.get<boolean>(WAYPOINT_VISITED+ "/"+user + "/" + waypoint);
} }
createWaypoint(waypointvisited: WaypointsVisitedEntity) { createWaypoint(waypointvisited: WaypointsVisitedEntity) {

View File

@@ -1,66 +0,0 @@
[
{
"location": "Biasca",
"region": "ticino",
"lat": 46.361184,
"lon": 8.970937,
"waypoints": [
{
"id": 1,
"name": "Cascata Santa Petronilla",
"lat": 46.35328215446709,
"lon": 8.97758397155138,
"description": "",
"img": "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"
},
{
"id": 2,
"name": "Casa Küng",
"lat": 46.363570208549994,
"lon": 8.963464722308554,
"description": "Descrizione del punto 2",
"img": "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"
},
{
"id": 3,
"name": "Punto 3",
"lat": 46.123,
"lon": 8.123,
"description": "Descrizione del punto 3",
"img": "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"
}
]
},
{
"location": "Lugano",
"region": "TI",
"lat": 46.0036778,
"lon": 8.951052,
"waypoints": [
{
"id": 4,
"name": "Punto 1",
"lat": 46.123,
"lon": 8.123,
"description": "un grandissimo",
"img": "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"
},
{
"id": 5,
"name": "Punto 2",
"lat": 46.123,
"lon": 8.123,
"description": "Descrizione del punto 2",
"img": "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"
},
{
"id": 6,
"name": "Punto 3",
"lat": 46.123,
"lon": 8.123,
"description": "Descrizione del punto 3",
"img": "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"
}
]
}
]

View File

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