diff --git a/src/app/bottom-bar/bottom-bar.component.html b/src/app/bottom-bar/bottom-bar.component.html
index 22214226c..d02b6fe9a 100644
--- a/src/app/bottom-bar/bottom-bar.component.html
+++ b/src/app/bottom-bar/bottom-bar.component.html
@@ -6,7 +6,7 @@
{{ enclosureTemperature.temperature }}{{ enclosureTemperature.unit }}
- {{ getStringStatus(printerStatus) }}
+ {{ statusText }}
|
diff --git a/src/app/bottom-bar/bottom-bar.component.ts b/src/app/bottom-bar/bottom-bar.component.ts
index a54d33c48..7b2b607c1 100644
--- a/src/app/bottom-bar/bottom-bar.component.ts
+++ b/src/app/bottom-bar/bottom-bar.component.ts
@@ -15,9 +15,9 @@ import { SocketService } from '../services/socket/socket.service';
})
export class BottomBarComponent implements OnDestroy {
private subscriptions: Subscription = new Subscription();
- private printerReady = false;
+ private lastStatusText: string;
- public printerStatus: PrinterState;
+ public statusText: string;
public enclosureTemperature: TemperatureReading;
public constructor(
@@ -28,44 +28,49 @@ export class BottomBarComponent implements OnDestroy {
) {
if (this.configService.getAmbientTemperatureSensorName() !== null) {
this.subscriptions.add(
- timer(2500, 15000).subscribe(() => {
- if (this.printerReady) {
- // TODO
- this.enclosureService.getEnclosureTemperature().subscribe({
- next: (temperatureReading: TemperatureReading) => (this.enclosureTemperature = temperatureReading),
- error: (error: HttpErrorResponse) => {
- this.notificationService.setNotification({
- heading: $localize`:@@error-enclosure-temp:Can't retrieve enclosure temperature!`,
- text: error.message,
- type: NotificationType.ERROR,
- time: new Date(),
- });
- },
- });
- }
+ timer(10000, 15000).subscribe(() => {
+ this.enclosureService.getEnclosureTemperature().subscribe({
+ next: (temperatureReading: TemperatureReading) => (this.enclosureTemperature = temperatureReading),
+ error: (error: HttpErrorResponse) => {
+ this.notificationService.setNotification({
+ heading: $localize`:@@error-enclosure-temp:Can't retrieve enclosure temperature!`,
+ text: error.message,
+ type: NotificationType.ERROR,
+ time: new Date(),
+ });
+ },
+ });
}),
);
}
this.subscriptions.add(
this.socketService.getPrinterStatusSubscribable().subscribe((printerStatus: PrinterStatus): void => {
- this.printerStatus = printerStatus?.status;
- if (!this.printerReady) {
- this.printerReady = [PrinterState.operational, PrinterState.printing, PrinterState.paused].includes(
- this.printerStatus,
- );
- }
+ this.setStatusText(this.getStringStatus(printerStatus?.status));
+ }),
+ );
+
+ this.subscriptions.add(
+ this.socketService.getPrinterStatusText().subscribe((statusText: string): void => {
+ this.setStatusText(statusText);
}),
);
}
- public getStringStatus(printerState: PrinterState): string {
+ private getStringStatus(printerState: PrinterState): string {
if (printerState === PrinterState.socketDead) {
return 'socket is dead';
}
return PrinterState[printerState];
}
+ private setStatusText(statusText: string) {
+ if (statusText !== this.lastStatusText) {
+ this.lastStatusText = this.statusText;
+ this.statusText = statusText;
+ }
+ }
+
public getPrinterName(): string {
return this.configService.getPrinterName();
}
diff --git a/src/app/notification/notification.service.ts b/src/app/notification/notification.service.ts
index 954109899..b1d4f411c 100644
--- a/src/app/notification/notification.service.ts
+++ b/src/app/notification/notification.service.ts
@@ -31,6 +31,10 @@ export class NotificationService {
if (this.observer) {
this.observer.next(notification);
this.notificationStack.push(notification);
+
+ if (this.notificationStack.length > 25) {
+ this.notificationStack.shift();
+ }
} else {
setTimeout(this.setNotification.bind(this), 1000, notification);
}
diff --git a/src/app/services/socket/socket.octoprint.service.ts b/src/app/services/socket/socket.octoprint.service.ts
index e94fa89bc..0c20c3da2 100644
--- a/src/app/services/socket/socket.octoprint.service.ts
+++ b/src/app/services/socket/socket.octoprint.service.ts
@@ -37,6 +37,7 @@ export class OctoPrintSocketService implements SocketService {
private printerStatusSubject: Subject;
private jobStatusSubject: Subject;
private eventSubject: Subject;
+ private statusTextSubject: Subject;
private printerStatus: PrinterStatus;
private jobStatus: JobStatus;
@@ -51,7 +52,8 @@ export class OctoPrintSocketService implements SocketService {
) {
this.printerStatusSubject = new ReplaySubject(1);
this.jobStatusSubject = new Subject();
- this.eventSubject = new ReplaySubject();
+ this.eventSubject = new ReplaySubject(5);
+ this.statusTextSubject = new ReplaySubject(1);
}
//==== SETUP & AUTH ====//
@@ -383,12 +385,8 @@ export class OctoPrintSocketService implements SocketService {
sticky: true,
} as Notification);
} else if (notification.text || notification.message) {
- this.notificationService.setNotification({
- heading: $localize`:@@printer-information:Printer information`,
- text: notification.text ?? notification.message,
- type: NotificationType.INFO,
- time: new Date(),
- } as Notification);
+ console.log(notification.text ?? notification.message);
+ this.statusTextSubject.next(notification.text ?? notification.message);
}
}
}
@@ -427,4 +425,8 @@ export class OctoPrintSocketService implements SocketService {
public getEventSubscribable(): Observable {
return this.eventSubject;
}
+
+ public getPrinterStatusText(): Observable {
+ return this.statusTextSubject;
+ }
}
diff --git a/src/app/services/socket/socket.service.ts b/src/app/services/socket/socket.service.ts
index 47d1f532e..424f3af00 100644
--- a/src/app/services/socket/socket.service.ts
+++ b/src/app/services/socket/socket.service.ts
@@ -9,6 +9,8 @@ export abstract class SocketService {
abstract getPrinterStatusSubscribable(): Observable;
+ abstract getPrinterStatusText(): Observable;
+
abstract getJobStatusSubscribable(): Observable;
abstract getEventSubscribable(): Observable;