Improve live notification

This commit is contained in:
aditya.chandel
2025-01-12 15:26:09 -07:00
parent e603333c08
commit 6bcb10b292
8 changed files with 67 additions and 102 deletions
@@ -20,32 +20,31 @@
<div class="topbar-right-items">
<app-book-searcher></app-book-searcher>
<ul class="topbar-items">
<div class="flex gap-6">
<li>
<a class="topbar-item">
<i class="pi pi-plus-circle text-surface-700 dark:text-surface-100" (click)="openLibraryCreatorDialog()"
pTooltip="Create New Library" tooltipPosition="top"></i>
</a>
</li>
<li>
<a class="topbar-item">
<i class="pi pi-upload text-surface-700 dark:text-surface-100" (click)="openFileUploadDialog()"
pTooltip="Upload book" tooltipPosition="top"></i>
</a>
</li>
</div>
<p-divider layout="vertical" />
<li>
<i class="pi pi-wave-pulse" style="font-size: 1.5rem"
(click)="toggleEventDisplay()"
(mouseenter)="onMouseEnter()"
(mouseleave)="onMouseLeave()"
[class.pulsating]="eventHighlight"
[class.highlight]="eventHighlight"></i>
<div *ngIf="showEvents" class="live-event-container" (mouseleave)="onMouseLeave()">
<p *ngIf="latestEvent.timestamp">{{ latestEvent.timestamp }}</p>
<p>{{ latestEvent.message }}</p>
</div>
<li class="relative">
<button type="button" class="topbar-item" enterActiveClass="animate-scalein" enterFromClass="hidden" leaveActiveClass="animate-fadeout" leaveToClass="hidden" pStyleClass="@next" [hideOnOutsideClick]="true">
<i class="pi pi-wave-pulse" style="font-size: 1.5rem"
[class.pulsating]="eventHighlight"
[class.highlight]="eventHighlight"></i>
</button>
<app-live-notification-box class="config-panel notification-box"></app-live-notification-box>
</li>
<p-divider layout="vertical" />
<li>
<a class="topbar-item">
<i class="pi pi-plus-circle text-surface-700 dark:text-surface-100" (click)="openLibraryCreatorDialog()"
pTooltip="Create New Library" tooltipPosition="top"></i>
</a>
</li>
<li>
<a class="topbar-item">
<i class="pi pi-upload text-surface-700 dark:text-surface-100" (click)="openFileUploadDialog()"
pTooltip="Upload book" tooltipPosition="top"></i>
</a>
</li>
<li class="relative">
<button type="button" class="topbar-item config-item" enterActiveClass="animate-scalein" enterFromClass="hidden" leaveActiveClass="animate-fadeout" leaveToClass="hidden" pStyleClass="@next" [hideOnOutsideClick]="true">
<i class="pi pi-palette"></i>
@@ -1,18 +1,3 @@
.live-event-container {
position: absolute;
top: 43px;
right: -180px;
width: 500px;
background: var(--card-background);
border: 0.5px solid var(--primary-color);
border-radius: 4px;
padding: 12px;
overflow-x: hidden;
/*z-index: 1000;*/
word-wrap: break-word;
white-space: normal;
}
.highlight {
color: red !important;
}
@@ -9,13 +9,14 @@ import {FormsModule} from '@angular/forms';
import {InputTextModule} from 'primeng/inputtext';
import {BookSearcherComponent} from '../../../book/components/book-searcher/book-searcher.component';
import {FileUploadComponent} from '../../../utilities/component/file-upload/file-upload.component';
import {NgClass, NgIf} from '@angular/common';
import {NgClass} from '@angular/common';
import {EventService} from '../../../shared/websocket/event.service';
import {LogNotification} from '../../../shared/websocket/model/log-notification.model';
import {Button} from 'primeng/button';
import {StyleClass} from 'primeng/styleclass';
import {Divider} from 'primeng/divider';
import {ThemeConfiguratorComponent} from '../theme-configurator/theme-configurator.component';
import {LiveNotificationBoxComponent} from '../../../live-notification-box/live-notification-box.component';
@Component({
selector: 'app-topbar',
@@ -27,19 +28,18 @@ import {ThemeConfiguratorComponent} from '../theme-configurator/theme-configurat
FormsModule,
InputTextModule,
BookSearcherComponent,
NgIf,
Button,
ThemeConfiguratorComponent,
StyleClass,
NgClass,
Divider
Divider,
LiveNotificationBoxComponent
],
})
export class AppTopBarComponent implements OnDestroy {
items!: MenuItem[];
ref: DynamicDialogRef | undefined;
latestEvent: LogNotification = {message: 'No recent notifications...'};
eventHighlight: boolean = false;
showEvents: boolean = false;
eventTimeout: any;
@@ -49,9 +49,6 @@ export class AppTopBarComponent implements OnDestroy {
@ViewChild('topbarmenu') menu!: ElementRef;
constructor(public layoutService: LayoutService, public dialogService: PrimeDialogService, private eventService: EventService) {
this.eventService.latestEvent$.subscribe(event => {
this.latestEvent = event;
});
this.eventService.eventHighlight$.subscribe(highlight => {
this.eventHighlight = highlight;
});
@@ -32,7 +32,7 @@
<div class="config-panel-settings">
<span class="config-panel-label">Presets</span>
<p-selectbutton [options]="presets" [ngModel]="selectedPreset()" (ngModelChange)="onPresetChange($event)" [allowEmpty]="false" size="small"/>
<p-selectbutton [options]="presets" [ngModel]="selectedPreset()" (ngModelChange)="onPresetChange($event)" [allowEmpty]="false" size="small"></p-selectbutton>
</div>
<div class="flex">
<div class="flex-1">
@@ -0,0 +1,5 @@
<div class="flex flex-col min-w-20">
<p>{{latestEvent.timestamp}}</p>
<p>{{latestEvent.message}}</p>
</div>
@@ -0,0 +1,25 @@
import {Component, Input} from '@angular/core';
import {LogNotification} from '../shared/websocket/model/log-notification.model';
import {EventService} from '../shared/websocket/event.service';
@Component({
selector: 'app-live-notification-box',
standalone: true,
templateUrl: './live-notification-box.component.html',
styleUrl: './live-notification-box.component.scss',
host: {
class: 'config-panel hidden'
},
})
export class LiveNotificationBoxComponent {
latestEvent: LogNotification = {message: 'No recent notifications...'};
constructor(private eventService: EventService) {
this.eventService.latestEvent$.subscribe(event => {
this.latestEvent = event;
});
}
}
@@ -205,7 +205,7 @@
.config-panel {
position: absolute;
top: calc(100% + 2px);
top: calc(100% + 4px);
inset-inline-end: 0;
width: 18rem;
padding: .75rem;
@@ -215,6 +215,14 @@
transform-origin: top;
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
&.notification-box {
width: 30rem;
background-color: var(--card-background);
border: 0.25px solid var(--primary-color);
border-radius: 4px;
min-height: 5rem;
}
.config-panel-content {
display: flex;
flex-direction: column;
@@ -262,61 +270,6 @@
}
}
.version-item {
width: auto;
padding: 0.5rem;
.version-text {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.version-icon {
margin-left: .25rem;
color: var(--text-secondary-color);
}
}
.versions-panel {
padding: .25rem;
background-color: var(--overlay-background);
position: absolute;
right: 0;
top: calc(100% + 2px);
border-radius: 6px;
border: 1px solid var(--border-color);
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
transform-origin: top;
ul {
padding: 0;
margin: 0;
list-style-type: none;
display: flex;
flex-direction: column;
gap: 4px;
li {
margin: 2px;
}
a {
display: inline-flex;
padding: 0.5rem .75rem;
border-radius: 6px;
width: 100%;
overflow: hidden;
color: var(--text-color);
white-space: nowrap;
&:hover {
background-color: var(--hover-background);
}
}
}
}
}
.topbar-right-items {