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

merge master #380

Merged
merged 41 commits into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
722c933
Bump @types/node from 12.12.14 to 12.12.15
dependabot-preview[bot] Dec 9, 2019
22b7049
Bump @types/node from 12.12.15 to 12.12.16
dependabot-preview[bot] Dec 9, 2019
d4a018f
Bump electron from 7.1.3 to 7.1.4
dependabot-preview[bot] Dec 10, 2019
16fe8b0
Bump @types/node from 12.12.16 to 12.12.17
dependabot-preview[bot] Dec 10, 2019
7c69343
Bump ngx-spinner from 8.0.3 to 8.1.0
dependabot-preview[bot] Dec 12, 2019
bb97e68
Bump electron from 7.1.4 to 7.1.5
dependabot-preview[bot] Dec 13, 2019
da8e08b
Bump @types/node from 12.12.17 to 12.12.18
dependabot-preview[bot] Dec 16, 2019
1585f4a
Bump @types/node from 12.12.18 to 12.12.19
dependabot-preview[bot] Dec 17, 2019
66d0a6f
Bump @types/node from 12.12.19 to 12.12.20
dependabot-preview[bot] Dec 17, 2019
fad9fee
Bump electron from 7.1.5 to 7.1.6
dependabot-preview[bot] Dec 18, 2019
4efadab
Bump @types/node from 12.12.20 to 12.12.21
dependabot-preview[bot] Dec 18, 2019
94c59ed
Bump codelyzer from 5.2.0 to 5.2.1
dependabot-preview[bot] Dec 18, 2019
846a4b9
Bump @angular-devkit/build-angular from 0.803.20 to 0.803.21
dependabot-preview[bot] Dec 19, 2019
173d386
Bump @angular/cli from 8.3.20 to 8.3.21
dependabot-preview[bot] Dec 19, 2019
4c53e53
Bump electron from 7.1.6 to 7.1.7
dependabot-preview[bot] Dec 19, 2019
1fc289b
Bump @types/node from 12.12.21 to 13.1.0
dependabot-preview[bot] Dec 23, 2019
05a6e14
Bump @types/node from 13.1.0 to 13.1.1
dependabot-preview[bot] Dec 26, 2019
f8089ba
Bump rxjs from 6.5.3 to 6.5.4
dependabot-preview[bot] Dec 27, 2019
35f32da
Bump @types/node from 13.1.1 to 13.1.2
dependabot-preview[bot] Dec 30, 2019
d72ae86
Bump @types/node from 13.1.2 to 13.1.3
dependabot-preview[bot] Jan 3, 2020
f2e6aa1
Bump @types/node from 13.1.3 to 13.1.4
dependabot-preview[bot] Jan 3, 2020
b0f9893
Bump @types/node from 13.1.4 to 13.1.5
dependabot-preview[bot] Jan 8, 2020
a3d2b41
Bump electron from 7.1.7 to 7.1.8
dependabot-preview[bot] Jan 8, 2020
ce3e911
Bump @angular/cli from 8.3.21 to 8.3.22
dependabot-preview[bot] Jan 8, 2020
1bc5478
Bump @angular-devkit/build-angular from 0.803.21 to 0.803.22
dependabot-preview[bot] Jan 8, 2020
ed1bc01
Bump @types/node from 13.1.5 to 13.1.6
dependabot-preview[bot] Jan 9, 2020
2bd43f7
Bump ts-node from 8.5.4 to 8.6.0
dependabot-preview[bot] Jan 10, 2020
6f8f37a
Bump ts-node from 8.6.0 to 8.6.1
dependabot-preview[bot] Jan 10, 2020
e2ca9d9
Update issue templates
UnchartedBull Jan 13, 2020
5e39de1
Bump ts-node from 8.6.1 to 8.6.2
dependabot-preview[bot] Jan 13, 2020
f46f71c
Bump electron from 7.1.8 to 7.1.9
dependabot-preview[bot] Jan 13, 2020
dd56d47
Bump @types/node from 13.1.6 to 13.1.7
dependabot-preview[bot] Jan 15, 2020
d7a0706
Bump @angular-devkit/build-angular from 0.803.22 to 0.803.23
dependabot-preview[bot] Jan 15, 2020
5c1788a
Bump @angular/cli from 8.3.22 to 8.3.23
dependabot-preview[bot] Jan 16, 2020
e2ab42a
Bump @types/node from 13.1.7 to 13.1.8
dependabot-preview[bot] Jan 17, 2020
9cdc2d0
Bump ajv from 6.10.2 to 6.11.0
dependabot-preview[bot] Jan 18, 2020
9691be3
Bump wait-on from 3.3.0 to 4.0.0
dependabot-preview[bot] Jan 19, 2020
7d33876
Update README.md
UnchartedBull Jan 22, 2020
bdd26f2
Update README.md
UnchartedBull Jan 22, 2020
3225248
Fix/standby improvements (#378)
UnchartedBull Jan 22, 2020
14fc113
Merge branch 'feature/settings' into master
UnchartedBull Jan 22, 2020
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
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ If applicable, add screenshots to help explain your problem.
- Hardware [e.g. Raspberry Pi, if you have layout issues please also include your screen resolution]
- OS Info [e.g. Raspbian Buster Lite, please also indicate if you used OctoPi]
- OctoDash Version [e.g. v1.0.0]
- OctoPrint Version [e.g. v1.0.0]

**Additional context**
Add any other context about the problem here.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ wget -qO- https://github.com/UnchartedBull/OctoDash/raw/master/scripts/install.s

For more options and information have a look at the [wiki](https://github.com/UnchartedBull/OctoDash/wiki/Installation).

No Screen? [No Problem](https://github.com/UnchartedBull/OctoDash/wiki/Installation#setup-without-keyboard).
No Keyboard? [No Problem](https://github.com/UnchartedBull/OctoDash/wiki/Installation#setup-without-keyboard).

Having issues during the installation? Please have a look at the [Troubleshooting Guide](https://github.com/UnchartedBull/OctoDash/wiki/Troubleshooting) first.

Expand Down
1,968 changes: 967 additions & 1,001 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,32 @@
"@fortawesome/angular-fontawesome": "^0.5.0",
"@fortawesome/fontawesome-svg-core": "^1.2.25",
"@fortawesome/free-solid-svg-icons": "^5.11.2",
"ajv": "^6.10.2",
"ajv": "^6.11.0",
"angular-svg-round-progressbar": "^3.0.1",
"electron-store": "^5.1.0",
"hammerjs": "^2.0.8",
"lodash": "^4.17.15",
"ngx-spinner": "^8.0.3",
"rxjs": "~6.5.3",
"ngx-spinner": "^8.1.0",
"rxjs": "~6.5.4",
"tslib": "^1.9.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.803.20",
"@angular/cli": "~8.3.20",
"@angular-devkit/build-angular": "^0.803.23",
"@angular/cli": "~8.3.23",
"@angular/compiler-cli": "^8.2.2",
"@angular/language-service": "~8.2.14",
"@types/ajv": "^1.0.0",
"@types/lodash": "^4.14.149",
"@types/node": "~12.12.14",
"codelyzer": "^5.2.0",
"electron": "^7.1.3",
"@types/node": "~13.1.8",
"codelyzer": "^5.2.1",
"electron": "^7.1.9",
"electron-builder": "^22.2.0",
"electron-reload": "^1.5.0",
"npm-run-all": "^4.1.5",
"ts-node": "~8.5.4",
"ts-node": "~8.6.2",
"tslint": "~5.20.1",
"typescript": "~3.5.3",
"wait-on": "^3.3.0"
"wait-on": "^4.0.0"
}
}
5 changes: 5 additions & 0 deletions src/app/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ export class ConfigService {
return this.config.octodash.turnScreenOffSleep;
}

public isPSUControlEnabled(): boolean {
// TODO: implement in next config change
return false;
}

public getFilamentThickness(): number {
return this.config.filament.thickness;
}
Expand Down
30 changes: 7 additions & 23 deletions src/app/notification/notification.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Component, OnDestroy } from '@angular/core';
import { Subscription } from 'rxjs';
import { NotificationService, Message } from './notification.service';
import { PrinterService } from '../printer.service';
import { Router } from '@angular/router';
import { NotificationService, Notification } from './notification.service';

@Component({
selector: 'app-notification',
Expand All @@ -13,41 +11,27 @@ export class NotificationComponent implements OnDestroy {

private subscriptions: Subscription = new Subscription();

public notification: Message = {
public notification: Notification = {
heading: '',
text: '',
type: ''
};
public show = false;

public constructor(private notificationService: NotificationService, private printerService: PrinterService, private router: Router) {
this.subscriptions.add(this.notificationService.getObservable().subscribe((message: Message) => this.setMessage(message)));
public constructor(private notificationService: NotificationService) {
this.subscriptions.add(this.notificationService.getObservable().subscribe((message: Notification) => this.setNotification(message)));
}

public hideNotification() {
this.show = false;
}

public setMessage(message: Message) {
if (message.printerStatusError) {
this.printerService.isPrinterOffline().then((printerOffline) => {
if (printerOffline) {
this.hideNotification();
console.clear();
this.router.navigate(['/standby']);
} else {
this.notification = message;
this.show = true;
}
});
} else {
this.notification = message;
this.show = true;
}
public setNotification(notification: Notification) {
this.notification = notification;
this.show = true;
}

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

}
26 changes: 19 additions & 7 deletions src/app/notification/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,30 @@ import { shareReplay } from 'rxjs/operators';
})
export class NotificationService {

private observable: Observable<Message>;
private observer: Observer<Message>;
private observable: Observable<Notification>;
private observer: Observer<Notification>;
private hideNotifications = false;

constructor() {
this.observable = new Observable((observer: Observer<Message>) => {
this.observable = new Observable((observer: Observer<Notification>) => {
this.observer = observer;
}).pipe(shareReplay(1));
}

setError(heading: string, text: string, printerStatusError = false) {
this.observer.next({ heading, text, type: 'error', printerStatusError });
enableNotifications() {
console.clear();
this.hideNotifications = false;
}

disableNotifications() {
console.clear();
this.hideNotifications = true;
}

setError(heading: string, text: string) {
if (!this.hideNotifications) {
this.observer.next({ heading, text, type: 'error' });
}
}

setUpdate(heading: string, text: string) {
Expand All @@ -29,9 +42,8 @@ export class NotificationService {
}
}

export interface Message {
export interface Notification {
heading: string;
text: string;
type: string;
printerStatusError?: boolean;
}
16 changes: 14 additions & 2 deletions src/app/printer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { shareReplay } from 'rxjs/operators';
import { OctoprintPrinterStatusAPI } from './octoprint-api/printerStatusAPI';
import { NotificationService } from './notification/notification.service';
import { OctoprintConnectionAPI } from './octoprint-api/connectionAPI';
import { Router } from '@angular/router';

@Injectable({
providedIn: 'root'
Expand All @@ -16,7 +17,11 @@ export class PrinterService {
httpPOSTRequest: Subscription;
observable: Observable<PrinterStatusAPI>;

constructor(private http: HttpClient, private configService: ConfigService, private notificationService: NotificationService) {
constructor(
private http: HttpClient,
private configService: ConfigService,
private notificationService: NotificationService,
private router: Router) {
this.observable = new Observable((observer: Observer<PrinterStatusAPI>) => {
timer(500, this.configService.getAPIInterval()).subscribe(_ => {
if (this.httpGETRequest) {
Expand All @@ -38,7 +43,14 @@ export class PrinterService {
observer.next(printerStatus);
}, (error: HttpErrorResponse) => {
if (error.status === 409) {
this.notificationService.setError('Can\'t retrieve printer status!', error.message, true);
this.isPrinterOffline().then((printerOffline) => {
if (printerOffline) {
this.router.navigate(['/standby']);
this.notificationService.disableNotifications();
} else {
this.notificationService.setError('Can\'t retrieve printer status!', error.message);
}
});
} else {
const printerStatus: PrinterStatusAPI = {
status: `error (${error.status})`,
Expand Down
67 changes: 45 additions & 22 deletions src/app/standby/standby.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Component, OnInit } from '@angular/core';
import { ConfigService } from '../config/config.service';
import { Subscription } from 'rxjs';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Router } from '@angular/router';
import { AppService } from '../app.service';
import { NotificationService } from '../notification/notification.service';
import { OctoprintConnectionAPI } from '../octoprint-api/connectionAPI';
import { PsuControlService } from '../plugin-service/psu-control.service';

@Component({
selector: 'app-standby',
Expand All @@ -14,9 +16,14 @@ export class StandbyComponent implements OnInit {

connecting = false;
error = '';
httpPOSTRequest: Subscription;

constructor(private configService: ConfigService, private http: HttpClient, private router: Router, private service: AppService) { }
constructor(
private configService: ConfigService,
private http: HttpClient,
private router: Router,
private service: AppService,
private notificationService: NotificationService,
private psuControlService: PsuControlService) { }

ngOnInit() {
if (this.configService.getAutomaticScreenSleep()) {
Expand All @@ -26,30 +33,46 @@ export class StandbyComponent implements OnInit {

reconnect() {
this.connecting = true;
if (this.httpPOSTRequest) {
this.httpPOSTRequest.unsubscribe();
if (this.configService.isPSUControlEnabled()) {
this.psuControlService.changePSUState(true);
}
this.http.get(this.configService.getURL('connection'), this.configService.getHTTPHeaders())
.subscribe(
(data: OctoprintConnectionAPI) => {
if (data.current.state === 'Closed') {
this.http.post(this.configService.getURL('connection'), connectPayload, this.configService.getHTTPHeaders())
.subscribe(
() => {
this.disableStandby();
},
() => {
this.connecting = false;
this.error =
'OctoPrint can\'t connect to your printer. Please make sure that the connection works, then come back and try again.';
});
} else {
this.disableStandby();
}
},
(error: HttpErrorResponse) => {
this.connecting = false;
this.error = 'There is something really wrong, OctoDash can\'t get a response from OctoPrint. Please check your setup!';
});
const connectPayload: ConnectCommand = {
command: 'connect',
save: false
};
this.httpPOSTRequest = this.http.post(this.configService.getURL('connection'), connectPayload, this.configService.getHTTPHeaders())
.subscribe(
() => {
setTimeout(() => {
this.connecting = false;
if (this.configService.getAutomaticScreenSleep()) {
this.service.turnDisplayOn();
}
this.router.navigate(['/main-screen']);
}, 4000);
},
() => {
this.connecting = false;
this.error =
'OctoPrint can\'t connect to your printer. Please make sure that the connection works, then come back and try again.';
}
);
}

disableStandby() {
setTimeout(() => {
this.connecting = false;
if (this.configService.getAutomaticScreenSleep()) {
this.service.turnDisplayOn();
}
this.notificationService.enableNotifications();
this.router.navigate(['/main-screen']);
}, 2000);
}
}

Expand Down