NotificationsOverlay UI
This commit is contained in:
parent
bc68777229
commit
985924086e
@ -7,9 +7,9 @@ import {Notification} from "./Notification";
|
|||||||
})
|
})
|
||||||
export class NotificationService {
|
export class NotificationService {
|
||||||
|
|
||||||
public notifications: Notification<any>[] = [
|
public visible: boolean = false;
|
||||||
new Notification('', 'Test', new Date(), 'test', null),
|
|
||||||
];
|
public notifications: Notification<any>[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected readonly api: ApiService,
|
protected readonly api: ApiService,
|
||||||
@ -17,4 +17,16 @@ export class NotificationService {
|
|||||||
// -
|
// -
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dismiss(notification: Notification<any>) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,14 +27,21 @@
|
|||||||
</div>
|
</div>
|
||||||
<router-outlet (activate)="onActivate($event)"/>
|
<router-outlet (activate)="onActivate($event)"/>
|
||||||
|
|
||||||
<div #notificationsOverlayMobile class="notificationsOverlay notificationsOverlayMobile" *ngIf="notificationsOverlayVisible" (window:resize)="onResize()">
|
<ng-template #tmp>
|
||||||
<div class="notificationOverlayEntry" *ngFor="let notification of notificationService.notifications">
|
<div class="notificationOverlayEntry" *ngFor="let notification of notificationService.notifications">
|
||||||
{{ notification.title }}
|
<div class="title">
|
||||||
|
{{ notification.title }}
|
||||||
|
</div>
|
||||||
|
<div class="dismiss" (click)="notificationService.dismiss(notification)">
|
||||||
|
X
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
<div #notificationsOverlayMobile class="notificationsOverlay notificationsOverlayMobile" *ngIf="notificationService.visible" (window:resize)="onResize()">
|
||||||
|
<ng-container *ngTemplateOutlet="tmp"></ng-container>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div #notificationsOverlayDesktop class="notificationsOverlay notificationsOverlayDesktop" *ngIf="notificationsOverlayVisible" (window:resize)="onResize()">
|
<div #notificationsOverlayDesktop class="notificationsOverlay notificationsOverlayDesktop" *ngIf="notificationService.visible" (window:resize)="onResize()">
|
||||||
<div class="notificationOverlayEntry" *ngFor="let notification of notificationService.notifications">
|
<ng-container *ngTemplateOutlet="tmp"></ng-container>
|
||||||
{{ notification.title }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -38,17 +38,37 @@
|
|||||||
|
|
||||||
.notificationsOverlay {
|
.notificationsOverlay {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
background-color: lightgray;
|
background-color: #eaeaea;
|
||||||
border: 1px solid gray;
|
border: 1px solid #aeaeae;
|
||||||
|
border-top: none;
|
||||||
border-radius: 0 0 @space @space;
|
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 {
|
.notificationOverlayEntry {
|
||||||
border-bottom: 1px solid gray;
|
|
||||||
padding: @halfSpace;
|
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;
|
background-color: lightskyblue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import {AfterViewInit, Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
import {AfterViewInit, Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
||||||
import {Router, RouterLink, RouterLinkActive, RouterOutlet} from '@angular/router';
|
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 {UserService} from "./api/User/user.service";
|
||||||
import {Subscription, timer} from "rxjs";
|
import {Subscription, timer} from "rxjs";
|
||||||
import {NotificationService} from "./api/Notification/notification.service";
|
import {NotificationService} from "./api/Notification/notification.service";
|
||||||
@ -8,7 +8,7 @@ import {NotificationService} from "./api/Notification/notification.service";
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [RouterOutlet, RouterLink, RouterLinkActive, NgIf, NgForOf, JsonPipe],
|
imports: [RouterOutlet, RouterLink, RouterLinkActive, NgIf, NgForOf, JsonPipe, NgTemplateOutlet],
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrl: './app.component.less'
|
styleUrl: './app.component.less'
|
||||||
})
|
})
|
||||||
@ -41,8 +41,6 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
this.onResize();
|
this.onResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected notificationsOverlayVisible: boolean = true;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected readonly router: Router,
|
protected readonly router: Router,
|
||||||
protected readonly userService: UserService,
|
protected readonly userService: UserService,
|
||||||
@ -69,7 +67,7 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggleMenu() {
|
toggleMenu() {
|
||||||
this.notificationsOverlayVisible = !this.notificationsOverlayVisible;
|
this.notificationService.toggle();
|
||||||
this.onResize();
|
this.onResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user