Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
<div class="mb-4">
|
||||
<label for="email" class="block text-gray-700 font-bold mb-2">Email:</label>
|
||||
<input type="email" id="email" name="email" placeholder="Inserisci la tua email"
|
||||
<input type="email" id="email" name="email" placeholder="Inserisci username"
|
||||
class="w-full px-4 py-2 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-600 focus:border-transparent">
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,10 +1,31 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Router} from "@angular/router";
|
||||
import {TranslateService} from "../../service/language/translate.service";
|
||||
import {ReadTranslateJsonService} from "../../service/language/readTranslateJson.service";
|
||||
import {cookieService} from "../../service/cookie.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
templateUrl: './login.component.html',
|
||||
styleUrls: ['./login.component.css']
|
||||
})
|
||||
export class LoginComponent {
|
||||
export class LoginComponent implements OnInit{
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private translateService: TranslateService,
|
||||
private readTranslationJsonService: ReadTranslateJsonService,
|
||||
private cookieService: cookieService,
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
|
||||
}
|
||||
|
||||
submit(username: string, password: string) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {AfterViewInit, Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
||||
import {distinctUntilChanged, fromEvent, Subject, Subscription} from "rxjs";
|
||||
import {ReadjsonService} from "../service/readjson.service";
|
||||
import {Router} from "@angular/router";
|
||||
import {TranslateService} from '../service/language/translate.service';
|
||||
import {ReadTranslateJsonService} from "../service/language/readTranslateJson.service";
|
||||
@@ -34,7 +33,6 @@ export class HomeComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
|
||||
constructor(
|
||||
private readjsonService: ReadjsonService,
|
||||
private router: Router,
|
||||
private translateService: TranslateService,
|
||||
private readTranslationJsonService: ReadTranslateJsonService,
|
||||
|
||||
@@ -19,8 +19,8 @@ export class cookieService {
|
||||
|
||||
getUsername(): string {
|
||||
let username = this.coockieService.get('username');
|
||||
if (username == null) {
|
||||
this.router.navigate(['/login']);
|
||||
if (username == '' || username == undefined) {
|
||||
this.router.navigate(['/login']).then(r => console.log("redirect to login"));
|
||||
return '';
|
||||
} else {
|
||||
return username;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import {Injectable} from "@angular/core";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {catchError, Observable} from "rxjs";
|
||||
import {LocationEntity} from "../../interface/LocationEntity";
|
||||
import {WaypointsEntity} from "../../interface/WaypointsEntity";
|
||||
import {WaypointsVisitedEntity} from "../../interface/WaypointsVisitedEntity";
|
||||
|
||||
const BASE_URL = "progetto152";
|
||||
const WAYPOINT_VISITED = BASE_URL + "/waypoint/visited/";
|
||||
const GET_WAYPOINT_BY_USER = WAYPOINT_VISITED + "USER/";
|
||||
const WAYPOINT_VISITED = BASE_URL + "/waypoint/visited";
|
||||
const GET_WAYPOINT_BY_USER = WAYPOINT_VISITED + "/USER/";
|
||||
|
||||
|
||||
@Injectable({
|
||||
@@ -20,26 +19,26 @@ export class WaypointVisitedService {
|
||||
}
|
||||
|
||||
getWaypoints() {
|
||||
return this.http.get<WaypointsEntity[]>(WAYPOINT_VISITED);
|
||||
return this.http.get<WaypointsVisitedEntity[]>(WAYPOINT_VISITED);
|
||||
}
|
||||
|
||||
getwaypointVisited(id: number) {
|
||||
return this.http.get<WaypointsEntity>(WAYPOINT_VISITED + id);
|
||||
return this.http.get<WaypointsVisitedEntity>(WAYPOINT_VISITED +"/"+ id);
|
||||
}
|
||||
|
||||
getWaypointByUser(user: string) {
|
||||
return this.http.get<WaypointsEntity[]>(GET_WAYPOINT_BY_USER + user);
|
||||
return this.http.get<WaypointsVisitedEntity[]>(GET_WAYPOINT_BY_USER + user);
|
||||
}
|
||||
|
||||
createWaypoint(waypoint: WaypointsEntity) {
|
||||
return this.http.post<WaypointsEntity>(WAYPOINT_VISITED, waypoint);
|
||||
createWaypoint(waypointvisited: WaypointsVisitedEntity) {
|
||||
return this.http.post<WaypointsEntity>(WAYPOINT_VISITED, waypointvisited);
|
||||
}
|
||||
|
||||
updateWaypoint(waypoint: WaypointsEntity, id: number) {
|
||||
return this.http.put<WaypointsEntity>(WAYPOINT_VISITED + id, waypoint);
|
||||
updateWaypoint(waypoint: WaypointsVisitedEntity, id: number) {
|
||||
return this.http.put<WaypointsVisitedEntity>(WAYPOINT_VISITED +"/"+ id, waypoint);
|
||||
}
|
||||
|
||||
deleteWaypoint(id: number) {
|
||||
return this.http.delete<WaypointsEntity>(WAYPOINT_VISITED + id);
|
||||
return this.http.delete<WaypointsVisitedEntity>(WAYPOINT_VISITED + id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {Locations, waypoint} from "../interface/data";
|
||||
import {BehaviorSubject, map, Observable, tap} from "rxjs";
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ReadjsonService{
|
||||
private locations: BehaviorSubject<Locations[]> = new BehaviorSubject<Locations[]>([]);
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
this.http.get<Locations[]>('assets/data.json').subscribe(data => {
|
||||
this.locations.next(data)
|
||||
console.log("data loaded", data)
|
||||
});
|
||||
}
|
||||
getLocations(): Observable<Partial<Locations>[]> {
|
||||
return this.locations.pipe(
|
||||
map((locations) => {
|
||||
return locations.map((loc: Locations) => ({
|
||||
location: loc.location,
|
||||
region: loc.region,
|
||||
lat: loc.lat,
|
||||
lon: loc.lon
|
||||
}))
|
||||
}),
|
||||
tap(data => console.log("data requested", data)))
|
||||
}
|
||||
|
||||
getLocation(location: string): Observable<Locations> {
|
||||
return this.locations.pipe(
|
||||
map((locations) => {
|
||||
const foundLocation: Locations | undefined = locations.find((loc: Locations) => loc.location === location);
|
||||
return foundLocation ? foundLocation : {location: '', region: '', lat: 0, lon: 0, waypoints: []};
|
||||
}),
|
||||
tap(data => console.log("data requested", data))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
getWaypoint(location: string, id: number): Observable<waypoint[]> {
|
||||
return this.locations.pipe(
|
||||
map((locations) => {
|
||||
const foundLocation: Locations | undefined = locations.find((loc: Locations) => loc.location === location);
|
||||
if (foundLocation?.waypoints) {
|
||||
return foundLocation ? foundLocation.waypoints.filter((way: waypoint) => way.id === id) : [];
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}),
|
||||
tap(data => console.log("data requested", data))
|
||||
);
|
||||
}
|
||||
|
||||
getWaypoints(location: string): Observable<waypoint[]> {
|
||||
return this.locations.pipe(
|
||||
map((locations) => {
|
||||
const foundLocation: Locations | undefined = locations.find((loc: Locations) => loc.location === location);
|
||||
if (foundLocation?.waypoints) {
|
||||
return foundLocation ? foundLocation.waypoints : [];
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}),
|
||||
tap(data => console.log("data requested", data))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user