Add severity to UI logs
This commit is contained in:
+8
-1
@@ -1,4 +1,11 @@
|
||||
<div class="flex flex-col p-4 space-y-2 live-border">
|
||||
<p class="text-xs text-zinc-400">{{ latestNotification.timestamp }}</p>
|
||||
<div class="flex flex-row items-center gap-2">
|
||||
@if (latestNotification.severity) {
|
||||
<app-tag [color]="getSeverityColor(latestNotification.severity)" size="3xs" class="self-center">
|
||||
{{ latestNotification.severity }}
|
||||
</app-tag>
|
||||
}
|
||||
<span class="text-xs text-zinc-400 self-center">{{ latestNotification.timestamp }}</span>
|
||||
</div>
|
||||
<p class="font-normal text-zinc-200">{{ latestNotification.message }}</p>
|
||||
</div>
|
||||
|
||||
+19
@@ -1,6 +1,9 @@
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {NotificationEventService} from '../../websocket/notification-event.service';
|
||||
import {LogNotification} from '../../websocket/model/log-notification.model';
|
||||
import {Tag} from 'primeng/tag';
|
||||
import {NgIf} from '@angular/common';
|
||||
import {TagComponent} from '../tag/tag.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-live-notification-box',
|
||||
@@ -10,6 +13,9 @@ import {LogNotification} from '../../websocket/model/log-notification.model';
|
||||
host: {
|
||||
class: 'config-panel'
|
||||
},
|
||||
imports: [
|
||||
TagComponent
|
||||
]
|
||||
})
|
||||
export class LiveNotificationBoxComponent {
|
||||
latestNotification: LogNotification = {message: 'No recent notifications...'};
|
||||
@@ -21,4 +27,17 @@ export class LiveNotificationBoxComponent {
|
||||
this.latestNotification = notification;
|
||||
});
|
||||
}
|
||||
|
||||
getSeverityColor(severity?: string): 'red' | 'amber' | 'green' | 'gray' {
|
||||
switch (severity) {
|
||||
case 'ERROR':
|
||||
return 'red';
|
||||
case 'WARN':
|
||||
return 'amber';
|
||||
case 'INFO':
|
||||
return 'green';
|
||||
default:
|
||||
return 'gray';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import {BookdropFileService} from '../../../../features/bookdrop/service/bookdro
|
||||
import {DialogLauncherService} from '../../../services/dialog-launcher.service';
|
||||
import {DuplicateFileService} from '../../../websocket/duplicate-file.service';
|
||||
import {UnifiedNotificationBoxComponent} from '../../../components/unified-notification-popover/unified-notification-popover-component';
|
||||
import {Severity, LogNotification} from '../../../websocket/model/log-notification.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-topbar',
|
||||
@@ -70,6 +71,7 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
private latestTasks: { [taskId: string]: MetadataBatchProgressNotification } = {};
|
||||
private latestHasPendingFiles = false;
|
||||
private latestHasDuplicateFiles = false;
|
||||
private latestNotificationSeverity?: Severity;
|
||||
|
||||
constructor(
|
||||
public layoutService: LayoutService,
|
||||
@@ -174,7 +176,8 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
private subscribeToNotifications() {
|
||||
this.notificationService.latestNotification$
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(() => {
|
||||
.subscribe((notification: LogNotification) => {
|
||||
this.latestNotificationSeverity = notification.severity;
|
||||
this.triggerPulseEffect();
|
||||
});
|
||||
}
|
||||
@@ -227,9 +230,21 @@ export class AppTopBarComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
get iconColor(): string {
|
||||
if (this.progressHighlight) return 'yellow';
|
||||
if (this.showPulse) return 'orange';
|
||||
if (this.completedTaskCount > 0 || this.hasPendingBookdropFiles || this.hasDuplicateFiles) return 'yellowgreen';
|
||||
if (this.progressHighlight) return 'gold';
|
||||
if (this.showPulse) {
|
||||
switch (this.latestNotificationSeverity) {
|
||||
case Severity.ERROR:
|
||||
return 'crimson';
|
||||
case Severity.INFO:
|
||||
return 'aqua';
|
||||
case Severity.WARN:
|
||||
return 'orange';
|
||||
default:
|
||||
return 'orange';
|
||||
}
|
||||
}
|
||||
if (this.completedTaskCount > 0 || this.hasPendingBookdropFiles || this.hasDuplicateFiles)
|
||||
return 'limegreen';
|
||||
return 'inherit';
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
export enum TaskStatus {
|
||||
IN_PROGRESS = 'IN_PROGRESS',
|
||||
CANCELLED = 'CANCELLED',
|
||||
COMPLETED = 'COMPLETED',
|
||||
FAILED = 'FAILED'
|
||||
export enum Severity {
|
||||
INFO = 'INFO',
|
||||
WARN = 'WARN',
|
||||
ERROR = 'ERROR'
|
||||
}
|
||||
|
||||
export interface LogNotification {
|
||||
timestamp?: string;
|
||||
message: string;
|
||||
severity?: Severity;
|
||||
}
|
||||
|
||||
export function parseLogNotification(messageBody: string): LogNotification {
|
||||
@@ -15,22 +15,6 @@ export function parseLogNotification(messageBody: string): LogNotification {
|
||||
return {
|
||||
timestamp: raw.timestamp ? new Date(raw.timestamp).toLocaleTimeString() : undefined,
|
||||
message: raw.message,
|
||||
};
|
||||
}
|
||||
|
||||
export interface TaskMessage {
|
||||
taskId: string;
|
||||
timestamp: string;
|
||||
title?: string;
|
||||
message: string;
|
||||
cancellable: boolean;
|
||||
status: TaskStatus;
|
||||
}
|
||||
|
||||
export function parseTaskMessage(messageBody: string): TaskMessage {
|
||||
const raw = JSON.parse(messageBody) as TaskMessage;
|
||||
return {
|
||||
...raw,
|
||||
timestamp: new Date(raw.timestamp).toLocaleTimeString()
|
||||
severity: raw.severity ? Severity[raw.severity as keyof typeof Severity] : undefined
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user