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

Show pause screen if not paused from OctoDash #958

Merged
merged 2 commits into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Show pause screen, even if print is paused from OctoPrintrom
  • Loading branch information
UnchartedBull committed Aug 31, 2020
commit 4e67dea985de930c4727636701c112c31e924edc
17 changes: 15 additions & 2 deletions src/app/job.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class JobService {
);
try {
job = {
status: data.state,
status: JobStatus[data.state],
filename: data.job.file.display.replace('.gcode', '').replace('.ufp', ''),
thumbnail: await this.fileService.getThumbnail(
'/' + data.job.file.origin + '/' + data.job.file.path,
Expand Down Expand Up @@ -256,7 +256,7 @@ interface Duration {
}

export interface Job {
status: string;
status: JobStatus;
filename: string;
thumbnail: string | undefined;
progress: number;
Expand All @@ -266,3 +266,16 @@ export interface Job {
estimatedPrintTime?: Duration;
estimatedEndTime?: string;
}

export enum JobStatus {
Operational,
Pausing,
Paused,
Printing,
Cancelling,
Error,
Closed,
Ready,
SdReady,
Loading,
}
33 changes: 30 additions & 3 deletions src/app/print-control/print-control.component.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { Component } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';
import { take } from 'rxjs/operators';

import { JobService } from '../job.service';
import { Job, JobService, JobStatus } from '../job.service';
import { PrinterService, PrinterStatusAPI } from '../printer.service';

@Component({
selector: 'app-print-control',
templateUrl: './print-control.component.html',
styleUrls: ['./print-control.component.scss'],
})
export class PrintControlComponent {
export class PrintControlComponent implements OnInit, OnDestroy {
private subscriptions: Subscription = new Subscription();

public showControls = false;
public controlView = ControlView;
public view = ControlView.MAIN;
private showedPauseScreen = false;

public temperatureHotend: number;
public temperatureHeatbed: number;
Expand All @@ -28,6 +32,29 @@ export class PrintControlComponent {
this.zOffset = 0;
}

public ngOnInit(): void {
this.subscriptions.add(
this.jobService.getObservable().subscribe((job: Job): void => {
if (job.status === JobStatus.Paused) {
if (!this.showedPauseScreen) {
this.view = ControlView.PAUSE;
this.showControls = true;
this.showedPauseScreen = true;
}
} else {
if (this.showedPauseScreen && this.showControls) {
this.showControls = false;
}
this.showedPauseScreen = false;
}
}),
);
}

public ngOnDestroy(): void {
this.subscriptions.unsubscribe();
}

public isClickOnPreview(event: MouseEvent): boolean {
const previewSwitchMin = window.innerWidth * 0.08;
const previewSwitchMax = window.innerWidth * 0.25;
Expand Down