forked from devsecopsmaturitymodel/DevSecOps-MaturityModel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.component.ts
More file actions
52 lines (45 loc) · 1.48 KB
/
app.component.ts
File metadata and controls
52 lines (45 loc) · 1.48 KB
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
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Subject, takeUntil } from 'rxjs';
import { ThemeService } from './service/theme.service';
import { TitleService } from './service/title.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent implements OnInit, OnDestroy {
title = '';
defaultTitle = '';
subtitle = '';
menuIsOpen: boolean = true;
sidenavWidth: string = '250px';
private destroy$ = new Subject<void>();
constructor(private themeService: ThemeService, private titleService: TitleService) {
this.themeService.initTheme();
}
ngOnInit(): void {
let menuState: string | null = localStorage.getItem('state.menuIsOpen');
if (menuState === 'false') {
setTimeout(() => {
this.menuIsOpen = false;
this.sidenavWidth = '0px';
}, 600);
} else {
this.sidenavWidth = '250px';
}
// Subscribe to title changes
this.titleService.titleInfo$.pipe(takeUntil(this.destroy$)).subscribe(titleInfo => {
this.title = titleInfo?.dimension || '';
this.subtitle = titleInfo?.level ? 'Level ' + titleInfo?.level : '';
});
}
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
}
toggleMenu(): void {
this.menuIsOpen = !this.menuIsOpen;
this.sidenavWidth = this.menuIsOpen ? '250px' : '0px';
localStorage.setItem('state.menuIsOpen', this.menuIsOpen.toString());
}
}