From 985924086e395aff3e2769ce5a12c75848bf3ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?= Date: Fri, 8 Nov 2024 11:11:07 +0100 Subject: [PATCH] NotificationsOverlay UI --- .../api/Notification/notification.service.ts | 18 +++++++++-- src/main/angular/src/app/app.component.html | 19 ++++++++---- src/main/angular/src/app/app.component.less | 30 +++++++++++++++---- src/main/angular/src/app/app.component.ts | 8 ++--- 4 files changed, 56 insertions(+), 19 deletions(-) diff --git a/src/main/angular/src/app/api/Notification/notification.service.ts b/src/main/angular/src/app/api/Notification/notification.service.ts index 24e52d3..c74e179 100644 --- a/src/main/angular/src/app/api/Notification/notification.service.ts +++ b/src/main/angular/src/app/api/Notification/notification.service.ts @@ -7,9 +7,9 @@ import {Notification} from "./Notification"; }) export class NotificationService { - public notifications: Notification[] = [ - new Notification('', 'Test', new Date(), 'test', null), - ]; + public visible: boolean = false; + + public notifications: Notification[] = []; constructor( protected readonly api: ApiService, @@ -17,4 +17,16 @@ export class NotificationService { // - } + dismiss(notification: Notification) { + this.notifications.splice(this.notifications.indexOf(notification), 1); + if (this.notifications.length === 0) { + this.visible = false; + } + // this.api.postNone(['Notification', 'dismiss'], notification.uuid); + } + + toggle() { + this.visible = !this.visible; + } + } diff --git a/src/main/angular/src/app/app.component.html b/src/main/angular/src/app/app.component.html index e6b8afc..74e2314 100644 --- a/src/main/angular/src/app/app.component.html +++ b/src/main/angular/src/app/app.component.html @@ -27,14 +27,21 @@ -
+
- {{ notification.title }} +
+ {{ notification.title }} +
+
+ X +
+
+ +
+
-
-
- {{ notification.title }} -
+
+
diff --git a/src/main/angular/src/app/app.component.less b/src/main/angular/src/app/app.component.less index 0037082..fdfef5b 100644 --- a/src/main/angular/src/app/app.component.less +++ b/src/main/angular/src/app/app.component.less @@ -38,17 +38,37 @@ .notificationsOverlay { position: fixed; - background-color: lightgray; - border: 1px solid gray; + background-color: #eaeaea; + border: 1px solid #aeaeae; + border-top: none; border-radius: 0 0 @space @space; - box-shadow: -0.5em 0.5em 1em rgba(0, 0, 0, 0.5); + box-shadow: 0 0.5em 1em rgba(0, 0, 0, 0.5); .notificationOverlayEntry { - border-bottom: 1px solid gray; padding: @halfSpace; + + .title { + float: left; + } + + .dismiss { + float: right; + color: red; + width: 1.5em; + height: 1.5em; + font-weight: bold; + text-align: center; + border-radius: 50%; + } + + .dismiss:hover { + background-color: red; + color: black; + } + } - .notificationOverlayEntry:hover { + .notificationOverlayEntry:hover:not(:has(div:hover)) { background-color: lightskyblue; } diff --git a/src/main/angular/src/app/app.component.ts b/src/main/angular/src/app/app.component.ts index 4972edc..6564760 100644 --- a/src/main/angular/src/app/app.component.ts +++ b/src/main/angular/src/app/app.component.ts @@ -1,6 +1,6 @@ import {AfterViewInit, Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core'; import {Router, RouterLink, RouterLinkActive, RouterOutlet} from '@angular/router'; -import {JsonPipe, NgForOf, NgIf} from "@angular/common"; +import {JsonPipe, NgForOf, NgIf, NgTemplateOutlet} from "@angular/common"; import {UserService} from "./api/User/user.service"; import {Subscription, timer} from "rxjs"; import {NotificationService} from "./api/Notification/notification.service"; @@ -8,7 +8,7 @@ import {NotificationService} from "./api/Notification/notification.service"; @Component({ selector: 'app-root', standalone: true, - imports: [RouterOutlet, RouterLink, RouterLinkActive, NgIf, NgForOf, JsonPipe], + imports: [RouterOutlet, RouterLink, RouterLinkActive, NgIf, NgForOf, JsonPipe, NgTemplateOutlet], templateUrl: './app.component.html', styleUrl: './app.component.less' }) @@ -41,8 +41,6 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit { this.onResize(); } - protected notificationsOverlayVisible: boolean = true; - constructor( protected readonly router: Router, protected readonly userService: UserService, @@ -69,7 +67,7 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit { } toggleMenu() { - this.notificationsOverlayVisible = !this.notificationsOverlayVisible; + this.notificationService.toggle(); this.onResize(); }