1
- import { ChangeDetectorRef , Component , OnInit } from '@angular/core' ;
1
+ import { AfterViewInit , ChangeDetectorRef , Component , ElementRef , OnInit , ViewChild } from '@angular/core' ;
2
2
import { MatDialog } from '@angular/material/dialog' ;
3
3
import { AttributesManagerService , UsersManagerService } from '@perun-web-apps/perun/openapi' ;
4
4
import { PreferredLanguageService , StoreService } from '@perun-web-apps/perun/services' ;
@@ -9,7 +9,7 @@ import { TranslateService } from '@ngx-translate/core';
9
9
templateUrl : './app.component.html' ,
10
10
styleUrls : [ './app.component.scss' ] ,
11
11
} )
12
- export class AppComponent implements OnInit {
12
+ export class AppComponent implements OnInit , AfterViewInit {
13
13
14
14
constructor ( private dialog : MatDialog ,
15
15
private usersService : UsersManagerService ,
@@ -27,6 +27,7 @@ export class AppComponent implements OnInit{
27
27
authWithoutToken = false ;
28
28
contentHeight = 'calc(100vh - 84px)' ;
29
29
contentBackgroundColor = this . store . get ( 'theme' , 'content_bg_color' ) ;
30
+ @ViewChild ( 'footer' ) footer : ElementRef ;
30
31
31
32
ngOnInit ( ) {
32
33
const prefLang = this . preferredLangService . getPreferredLanguage ( null ) ;
@@ -47,7 +48,8 @@ export class AppComponent implements OnInit{
47
48
} else {
48
49
this . authWithoutToken = true ;
49
50
this . attributesManagerService . getLogins ( this . store . getPerunPrincipal ( ) . userId ) . subscribe ( logins => {
50
- this . login = logins . find ( login => login . friendlyNameParameter === this . namespace ) . value . toString ( ) ;
51
+ const selectedLogin = logins . find ( login => login . friendlyNameParameter === this . namespace ) ;
52
+ this . login = selectedLogin ? selectedLogin . value . toString ( ) : '' ;
51
53
} ) ;
52
54
}
53
55
}
@@ -62,9 +64,8 @@ export class AppComponent implements OnInit{
62
64
}
63
65
}
64
66
65
- setContentHeight ( height : number ) {
66
- this . contentHeight = 'calc(100vh - 84px - ' + height + 'px)' ;
67
+ ngAfterViewInit ( ) : void {
68
+ this . contentHeight = 'calc(100vh - 84px - ' + this . footer . nativeElement . offsetHeight + 'px)' ;
67
69
this . changeDetector . detectChanges ( ) ;
68
70
}
69
-
70
71
}
0 commit comments