This commit is contained in:
Bastian Wagner
2024-09-11 10:42:54 +02:00
parent 110a4b89c6
commit 561ce15dd6
8 changed files with 94 additions and 2 deletions

View File

@@ -1,10 +1,12 @@
import { Injectable } from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { User } from '../model/user.interface';
import { Router } from '@angular/router';
@Injectable({
providedIn: 'root'
})
export class UserService {
private router: Router = inject(Router);
private _user: User;
@@ -18,4 +20,11 @@ export class UserService {
get user(): User {
return this._user;
}
logout() {
this.user = null;
localStorage.clear();
this.router.navigateByUrl('/');
}
}

View File

@@ -1,6 +1,10 @@
<div class="header">
<div class="title">SSO Beantastic</div>
<div> {{ userName }} </div>
<div class="flex-row">
<div> {{ userName }}</div>
<div class="logout" (click)="logout()" ></div>
</div>
</div>
<div class="flex-row body_design">

View File

@@ -60,4 +60,20 @@
align-items: flex-start;
gap: 32px;
justify-content: center;
}
.logout{
width: 32px;
height: 32px;
cursor: pointer;
background-color: transparent;
background-position: center;
background-size: 20px;
background-repeat: no-repeat;
border-radius: 4px;
transition: all 0.2s ease-in-out;
&:hover {
background-color: #ccc;
}
}

View File

@@ -117,6 +117,9 @@ export class DashboardComponent implements OnInit {
})
}
logout() {
this.userService.logout();
}
}

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 471.2 471.2" style="enable-background:new 0 0 471.2 471.2;" xml:space="preserve">
<g>
<g>
<path d="M227.619,444.2h-122.9c-33.4,0-60.5-27.2-60.5-60.5V87.5c0-33.4,27.2-60.5,60.5-60.5h124.9c7.5,0,13.5-6,13.5-13.5
s-6-13.5-13.5-13.5h-124.9c-48.3,0-87.5,39.3-87.5,87.5v296.2c0,48.3,39.3,87.5,87.5,87.5h122.9c7.5,0,13.5-6,13.5-13.5
S235.019,444.2,227.619,444.2z"/>
<path d="M450.019,226.1l-85.8-85.8c-5.3-5.3-13.8-5.3-19.1,0c-5.3,5.3-5.3,13.8,0,19.1l62.8,62.8h-273.9c-7.5,0-13.5,6-13.5,13.5
s6,13.5,13.5,13.5h273.9l-62.8,62.8c-5.3,5.3-5.3,13.8,0,19.1c2.6,2.6,6.1,4,9.5,4s6.9-1.3,9.5-4l85.8-85.8
C455.319,239.9,455.319,231.3,450.019,226.1z"/>
</g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -16,6 +16,10 @@ html, body {
background-image: url("assets/icons/user.svg");
}
.logout {
background-image: url("assets/icons/logout.svg");
}
.flex-row{
display: flex;
flex-direction: row;