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

remove octoprint script + rework setup + scrollable custom actions #1186

Merged
merged 1 commit into from
Nov 17, 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
1 change: 0 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ function createWindow() {
nodeIntegration: true,
enableRemoteModule: true,
worldSafeExecuteJavaScript: true,
// TODO: enable + contextBridge (probably electron-ngx before release 12)
contextIsolation: false,
},
icon: path.join(__dirname, 'dist', 'assets', 'icon', 'icon.png'),
Expand Down
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"compare-versions": "^3.6.0",
"electron-store": "^6.0.1",
"got": "^11.8.0",
"jquery": "^3.5.1",
"lodash": "^4.17.20",
"ngx-electron": "^2.2.0",
"ngx-spinner": "^10.0.1",
Expand Down
102 changes: 0 additions & 102 deletions sample.config.json

This file was deleted.

68 changes: 27 additions & 41 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
import { ChangeDetectorRef, Component, NgZone, OnInit } from '@angular/core';
import { Component, NgZone, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import _ from 'lodash';
import { ElectronService } from 'ngx-electron';

import { AppService } from './app.service';
import { ConfigService } from './config/config.service';
import { NotificationService } from './notification/notification.service';
import { OctoprintScriptService } from './octoprint-script.service';

declare global {
interface Window {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
require: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
process: any;
}
}

@Component({
selector: 'app-root',
Expand All @@ -26,12 +16,10 @@ export class AppComponent implements OnInit {
public constructor(
private service: AppService,
private configService: ConfigService,
private octoprintScriptService: OctoprintScriptService,
private notificationService: NotificationService,
private router: Router,
private electronService: ElectronService,
private changeDetector: ChangeDetectorRef,
private ngZone: NgZone,
private zone: NgZone,
) {}

public activated = false;
Expand Down Expand Up @@ -79,9 +67,9 @@ export class AppComponent implements OnInit {

private waitForOctoprint() {
this.electronService.ipcRenderer.on('octoprintReady', (_, octoprintReady: boolean) => {
this.ngZone.run(() => {
this.zone.run(() => {
if (octoprintReady) {
this.initializeOctoprintService();
this.connectWebsocket();
this.status = 'initializing';
} else {
this.notificationService
Expand All @@ -92,12 +80,11 @@ export class AppComponent implements OnInit {
.then(this.checkOctoprintPort.bind(this));
this.status = 'no connection';
}
this.changeDetector.detectChanges();
});
});

this.electronService.ipcRenderer.on('waitPortError', (_, error: Error) => {
this.ngZone.run(() => {
this.zone.run(() => {
this.notificationService.setError('System Error - please restart', error.message);
});
});
Expand All @@ -112,30 +99,29 @@ export class AppComponent implements OnInit {
host: urlNoProtocol.split(':')[0],
port: Number(urlNoProtocol.split(':')[1].split('/')[0]),
});
this.changeDetector.detectChanges();
}

private initializeOctoprintService() {
const showPrinterConnectedTimeout = setTimeout(() => {
this.showConnectionHint = true;
}, 30000);
this.octoprintScriptService
.initialize(this.configService.getURL(''), this.configService.getAccessKey())
.then(() => {
this.octoprintScriptService.authenticate(this.configService.getAccessKey());
if (this.configService.isTouchscreen()) {
this.router.navigate(['/main-screen']);
} else {
this.router.navigate(['/main-screen-no-touch']);
}
})
.catch(() => {
console.log('REJECTED');
this.notificationService.setError(
"Can't get OctoPrint script!",
'Please restart your machine. If the error persists open a new issue on GitHub.',
);
})
.finally(() => clearTimeout(showPrinterConnectedTimeout));
private connectWebsocket() {
if (this.configService.isTouchscreen()) {
this.router.navigate(['/main-screen']);
} else {
this.router.navigate(['/main-screen-no-touch']);
}
// const showPrinterConnectedTimeout = setTimeout(() => {
// this.showConnectionHint = true;
// }, 30000);
// this.octoprintScriptService
// .initialize(this.configService.getURL(''), this.configService.getAccessKey())
// .then(() => {
// this.octoprintScriptService.authenticate(this.configService.getAccessKey());
// })
// .catch(() => {
// console.log('REJECTED');
// this.notificationService.setError(
// "Can't get OctoPrint script!",
// 'Please restart your machine. If the error persists open a new issue on GitHub.',
// );
// })
// .finally(() => clearTimeout(showPrinterConnectedTimeout));
}
}
23 changes: 17 additions & 6 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ import { AppRoutingModule } from './app.routing.module';
import { AppService } from './app.service';
import { BottomBarComponent } from './bottom-bar/bottom-bar.component';
import { ConfigService } from './config/config.service';
import { InvalidConfigComponent } from './config/invalid-config/invalid-config.component';
import { NoConfigComponent } from './config/no-config/no-config.component';
import { ConfigInvalidComponent } from './config/invalid/invalid.component';
import { DiscoverOctoprintComponent } from './config/setup/discover-octoprint/discover-octoprint.component';
import { ExtruderInformationComponent } from './config/setup/extruder-information/extruder-information.component';
import { OctoprintAuthenticationComponent } from './config/setup/octoprint-authentication/octoprint-authentication.component';
import { PersonalizationComponent } from './config/setup/personalization/personalization.component';
import { PluginsComponent } from './config/setup/plugins/plugins.component';
import { ConfigSetupComponent } from './config/setup/setup.component';
import { WelcomeComponent } from './config/setup/welcome/welcome.component';
import { ControlComponent } from './control/control.component';
import { FilamentComponent } from './filament/filament.component';
import { FilesComponent } from './files/files.component';
Expand All @@ -29,7 +35,6 @@ import { MainScreenComponent } from './main-screen/main-screen.component';
import { MainScreenNoTouchComponent } from './main-screen/no-touch/main-screen-no-touch.component';
import { NotificationComponent } from './notification/notification.component';
import { NotificationService } from './notification/notification.service';
import { OctoprintScriptService } from './octoprint-script.service';
import { PrintControlComponent } from './print-control/print-control.component';
import { PrinterStatusComponent } from './printer-status/printer-status.component';
import { PrinterService } from './printer.service';
Expand All @@ -45,21 +50,27 @@ import { URLSafePipe } from './url.pipe';
ControlComponent,
FilamentComponent,
FilesComponent,
InvalidConfigComponent,
ConfigInvalidComponent,
JobStatusComponent,
LayerProgressComponent,
LongPress,
MainMenuComponent,
MainScreenComponent,
MainScreenNoTouchComponent,
NoConfigComponent,
ConfigSetupComponent,
NotificationComponent,
PrintControlComponent,
PrinterStatusComponent,
SettingsComponent,
StandbyComponent,
UpdateComponent,
URLSafePipe,
WelcomeComponent,
DiscoverOctoprintComponent,
OctoprintAuthenticationComponent,
PersonalizationComponent,
ExtruderInformationComponent,
PluginsComponent,
],
imports: [
BrowserModule,
Expand All @@ -73,7 +84,7 @@ import { URLSafePipe } from './url.pipe';
BrowserAnimationsModule,
MatRippleModule,
],
providers: [AppService, ConfigService, NotificationService, PrinterService, JobService, OctoprintScriptService],
providers: [AppService, ConfigService, NotificationService, PrinterService, JobService],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
Expand Down
8 changes: 4 additions & 4 deletions src/app/app.routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { InvalidConfigComponent } from './config/invalid-config/invalid-config.component';
import { NoConfigComponent } from './config/no-config/no-config.component';
import { ConfigInvalidComponent } from './config/invalid/invalid.component';
import { ConfigSetupComponent } from './config/setup/setup.component';
import { ControlComponent } from './control/control.component';
import { FilamentComponent } from './filament/filament.component';
import { FilesComponent } from './files/files.component';
Expand Down Expand Up @@ -35,11 +35,11 @@ const routes: Routes = [
},
{
path: 'invalid-config',
component: InvalidConfigComponent,
component: ConfigInvalidComponent,
},
{
path: 'no-config',
component: NoConfigComponent,
component: ConfigSetupComponent,
},
{
path: 'settings',
Expand Down
1 change: 0 additions & 1 deletion src/app/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export class AppService {
config.printer.zBabystepGCode = 'M290 Z';
config.octodash.previewProgressCircle = false;
this.configService.saveConfig(config);
this.configService.updateConfig();
return true;
}

Expand Down
Loading