Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go into standby if unable to contact OctoPrint #540

Merged
merged 6 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/app/notification/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ export class NotificationService {
private observable: Observable<Notification>;
private observer: Observer<Notification>;
private hideNotifications = false;
private bootGrace = true;

public constructor() {
this.observable = new Observable((observer: Observer<Notification>): void => {
this.observer = observer;
setTimeout((): void => {
this.bootGrace = false;
}, 30000);
}).pipe(shareReplay(1));
}

Expand All @@ -27,7 +31,7 @@ export class NotificationService {
}

public setError(heading: string, text: string): void {
if (!this.hideNotifications) {
if ((!this.hideNotifications && !this.bootGrace) || (this.bootGrace && !text.endsWith('0 Unknown Error'))) {
this.observer.next({ heading, text, type: 'error' });
}
}
Expand All @@ -45,6 +49,10 @@ export class NotificationService {
public getObservable(): Observable<Notification> {
return this.observable;
}

public getBootGrace(): boolean {
return this.bootGrace;
}
}

export interface Notification {
Expand Down
13 changes: 13 additions & 0 deletions src/app/printer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ export class PrinterService {
);
}
});
} else if (error.status === 0 && this.notificationService.getBootGrace()) {
const printerStatus: PrinterStatusAPI = {
status: `connecting ...`,
nozzle: {
current: 0,
set: 0,
},
heatbed: {
current: 0,
set: 0,
},
};
observer.next(printerStatus);
} else {
const printerStatus: PrinterStatusAPI = {
status: `error (${error.status})`,
Expand Down