1- import { Component , OnInit } from "@angular/core" ;
1+ import { animate , state , style , transition , trigger } from "@angular/animations" ;
2+ import { Component , EventEmitter , OnInit , Output } from "@angular/core" ;
3+ import { MatIconRegistry } from "@angular/material/icon" ;
4+ import { DomSanitizer } from "@angular/platform-browser" ;
25import { Router } from "@angular/router" ;
36import { Organisation } from "@app/admin/organisation/organisation.model" ;
47import { PermissionType } from "@app/admin/permission/permission.model" ;
@@ -17,6 +20,35 @@ import { UserResponse } from "./../admin/users/user.model";
1720 selector : "app-navbar" ,
1821 templateUrl : "./navbar.component.html" ,
1922 styleUrls : [ "./navbar.component.scss" ] ,
23+ animations : [
24+ trigger ( "navAnimation" , [
25+ state (
26+ "void" ,
27+ style ( {
28+ transform : "translateX(-100%)" ,
29+ opacity : 0 ,
30+ } )
31+ ) ,
32+ transition ( ":enter" , [
33+ animate (
34+ "0.3s ease-out" ,
35+ style ( {
36+ transform : "translateX(0)" ,
37+ opacity : 1 ,
38+ } )
39+ ) ,
40+ ] ) ,
41+ transition ( ":leave" , [
42+ animate (
43+ "0.3s ease-in" ,
44+ style ( {
45+ transform : "translateX(-100%)" ,
46+ opacity : 0 ,
47+ } )
48+ ) ,
49+ ] ) ,
50+ ] ) ,
51+ ] ,
2052} )
2153export class NavbarComponent implements OnInit {
2254 public organisations : Organisation [ ] ;
@@ -30,6 +62,8 @@ export class NavbarComponent implements OnInit {
3062 isLoginMode = true ;
3163 user : User ;
3264
65+ isVisible = true ;
66+
3367 userInfo : CurrentUserInfoResponse ;
3468 faSignInAlt = faSignInAlt ;
3569 imagePath = "../../assets/images/os2iot.png " ;
@@ -41,11 +75,21 @@ export class NavbarComponent implements OnInit {
4175 private sharedVariableService : SharedVariableService ,
4276 private loggedInService : LoggedInService ,
4377 private meService : MeService ,
44- private route : Router
78+ private route : Router ,
79+ private matIconRegistry : MatIconRegistry ,
80+ private domSanitizer : DomSanitizer
4581 ) {
82+ this . matIconRegistry . addSvgIcon (
83+ "nav-arrow" ,
84+ this . domSanitizer . bypassSecurityTrustResourceUrl ( "assets/images/arrows-up-to-line.svg" ) ,
85+ { }
86+ ) ;
87+
4688 translate . use ( "da" ) ;
4789 }
4890
91+ @Output ( ) navToggle = new EventEmitter < boolean > ( ) ;
92+
4993 onLogout ( ) {
5094 this . authService . logout ( ) ;
5195 this . router . navigateByUrl ( "auth" ) ;
@@ -90,6 +134,7 @@ export class NavbarComponent implements OnInit {
90134 this . getAllowedOrganizations ( ) ;
91135 this . organisations . sort ( ( a , b ) => a . name . localeCompare ( b . name , "en" , { numeric : true } ) ) ;
92136 this . selected = this . sharedVariableService . getSelectedOrganisationId ( ) ;
137+ this . navToggle . emit ( this . isVisible ) ;
93138 }
94139
95140 getAllowedOrganizations ( ) {
@@ -132,6 +177,11 @@ export class NavbarComponent implements OnInit {
132177 }
133178 }
134179
180+ public toggleNavbar ( ) {
181+ this . isVisible = ! this . isVisible ;
182+ this . navToggle . emit ( this . isVisible ) ;
183+ }
184+
135185 setSelectedOrganisation ( value : number ) {
136186 this . sharedVariableService . setSelectedOrganisationId ( value ) ;
137187 }
0 commit comments