Skip to content

Commit

Permalink
Show pause screen if not paused from OctoDash (#958)
Browse files Browse the repository at this point in the history
* Show pause screen, even if print is paused from OctoPrintrom

* text improvements
  • Loading branch information
UnchartedBull authored Aug 31, 2020
1 parent 678aa19 commit 04fc97b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
6 changes: 2 additions & 4 deletions src/app/job-status/job-status.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,5 @@
</span>
</div>
</div>
<div class="job-info__no-job" *ngIf="!job && isFileLoaded()">loading info ...</div>
<div class="job-info__no-job" *ngIf="(!job && !isFileLoaded()) || (job && !isPrinting() && !isFileLoaded())">
no job running ...
</div>
<div class="job-info__no-job" *ngIf="(!job && isFileLoaded()) || (!job && isPrinting())">loading info ...</div>
<div class="job-info__no-job" *ngIf="!job && !isFileLoaded() && !isPrinting()">no job running ...</div>
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

0 comments on commit 04fc97b

Please sign in to comment.