diff --git a/src/app/component/login/login.component.html b/src/app/component/login/login.component.html index f656508..f681a9d 100644 --- a/src/app/component/login/login.component.html +++ b/src/app/component/login/login.component.html @@ -9,7 +9,7 @@
-
diff --git a/src/app/component/login/login.component.ts b/src/app/component/login/login.component.ts index 80a60e8..93f098b 100644 --- a/src/app/component/login/login.component.ts +++ b/src/app/component/login/login.component.ts @@ -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) { + + } } diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts index 2f5c906..c1255ff 100644 --- a/src/app/home/home.component.ts +++ b/src/app/home/home.component.ts @@ -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, diff --git a/src/app/service/cookie.service.ts b/src/app/service/cookie.service.ts index 2bf6a1e..cb0843a 100644 --- a/src/app/service/cookie.service.ts +++ b/src/app/service/cookie.service.ts @@ -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; diff --git a/src/app/service/readjson.service.ts b/src/app/service/readjson.service.ts deleted file mode 100644 index d9b65cf..0000000 --- a/src/app/service/readjson.service.ts +++ /dev/null @@ -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 = new BehaviorSubject([]); - - constructor(private http: HttpClient) { - this.http.get('assets/data.json').subscribe(data => { - this.locations.next(data) - console.log("data loaded", data) - }); - } - getLocations(): Observable[]> { - 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 { - 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 { - 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 { - 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)) - ); - } - -}