Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import {Component, HostListener, Inject} from '@angular/core';
import {AuthService} from "./services/auth.service";
import {StorageService} from "./services/storage.service";
import {ActivatedRoute, Router} from "@angular/router";
import {AlertService} from "./services/alert.service";
import {
faCheckSquare,
faClone,
faCube,
faHome,
faList,
faMoon,
faSignInAlt,
faSignOutAlt,
faSlidersH,
faStream,
faSun,
faToggleOn
} from "@fortawesome/free-solid-svg-icons";
import {DOCUMENT} from "@angular/common";
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
public faHome = faHome;
public faClone = faClone;
public faStream = faStream;
public faSlidersH = faSlidersH;
public faSignInAlt = faSignInAlt;
public faSignOutAlt = faSignOutAlt;
public faCube = faCube;
public faList = faList;
public faCheckSquare = faCheckSquare;
public faSun = faSun;
public faMoon = faMoon;
public faToggleOn = faToggleOn;
public darkMode = false;
constructor(
private authService: AuthService,
private storageService: StorageService,
private router: Router,
private route: ActivatedRoute,
private alertService: AlertService,
@Inject(DOCUMENT) document
) {
/*
this.route.queryParams.subscribe(params => {
if (params.hasOwnProperty('ticket')) {
console.log(params.ticket);
if (this.authService.logIn(decodeURIComponent(params.ticket))) {
this.alertService.success('You are logged in.');
} else {
this.alertService.error('Login failed');
}
}
});
*/
const dm = this.storageService.getLocal('darkmode');
this.darkMode = (dm === 'true');
}
@HostListener('window:scroll', ['$event'])
onWindowScroll(e) {
let stickyNav = document.getElementById('sticky_nav');
if (window.pageYOffset > 100) {
stickyNav.classList.add('sticky');
} else {
stickyNav.classList.remove('sticky');
}
}
isLoggedIn(): boolean {
return this.authService.isAuthenticated();
}
signIn(): void {
this.authService.signIn();
}
signOut(): void {
this.alertService.success('You are logged out.');
this.storageService.deleteLocal('jwt');
this.router.navigate(['/']);
}
setDarkMode(dm: boolean): void {
this.darkMode = dm;
this.storageService.saveLocal('darkmode', dm.toString());
}
}