2021-10-30 10:46:54 +02:00
|
|
|
import { Component, OnDestroy, OnInit } from '@angular/core';
|
2021-04-13 21:53:58 +02:00
|
|
|
import { Router } from '@angular/router';
|
2021-04-21 20:27:39 +02:00
|
|
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
|
|
|
import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service';
|
2021-04-13 21:53:58 +02:00
|
|
|
import { format } from 'date-fns';
|
|
|
|
import { Subject } from 'rxjs';
|
|
|
|
|
|
|
|
@Component({
|
2021-10-13 11:51:33 +02:00
|
|
|
host: { class: 'mb-5' },
|
2021-06-05 17:16:07 +02:00
|
|
|
selector: 'gf-landing-page',
|
2021-10-13 11:51:33 +02:00
|
|
|
styleUrls: ['./landing-page.scss'],
|
|
|
|
templateUrl: './landing-page.html'
|
2021-04-13 21:53:58 +02:00
|
|
|
})
|
2021-06-05 17:16:07 +02:00
|
|
|
export class LandingPageComponent implements OnDestroy, OnInit {
|
2021-04-13 21:53:58 +02:00
|
|
|
public currentYear = format(new Date(), 'yyyy');
|
|
|
|
public demoAuthToken: string;
|
|
|
|
|
|
|
|
private unsubscribeSubject = new Subject<void>();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
public constructor(
|
|
|
|
private dataService: DataService,
|
|
|
|
private router: Router,
|
2021-06-14 21:57:09 +02:00
|
|
|
private tokenStorageService: TokenStorageService
|
2021-04-13 21:53:58 +02:00
|
|
|
) {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the controller
|
|
|
|
*/
|
|
|
|
public ngOnInit() {
|
2021-07-17 11:04:43 +02:00
|
|
|
const { demoAuthToken } = this.dataService.fetchInfo();
|
2021-04-13 21:53:58 +02:00
|
|
|
|
2021-07-17 11:04:43 +02:00
|
|
|
this.demoAuthToken = demoAuthToken;
|
2021-04-13 21:53:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public setToken(aToken: string) {
|
2021-06-14 21:57:09 +02:00
|
|
|
this.tokenStorageService.saveToken(aToken, true);
|
2021-04-13 21:53:58 +02:00
|
|
|
|
|
|
|
this.router.navigate(['/']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnDestroy() {
|
|
|
|
this.unsubscribeSubject.next();
|
|
|
|
this.unsubscribeSubject.complete();
|
|
|
|
}
|
|
|
|
}
|