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

Reduce input during on-boarding #954

Merged
merged 51 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
8554b88
- Add mdns and ngx-electron plugin
TheSin- Aug 29, 2020
8923014
Merge with upstream master
TheSin- Aug 29, 2020
7313d24
Add postinstall so it auto rebuilds electron against node
TheSin- Aug 31, 2020
b038c08
Update src/app/config/no-config/no-config.component.ts
TheSin- Aug 31, 2020
6c53aec
Update src/app/config/no-config/no-config.component.ts
TheSin- Aug 31, 2020
8716587
Update src/app/config/no-config/no-config.component.ts
TheSin- Aug 31, 2020
68887b1
Resolve a few issues with VSCode and more consistent var naming
TheSin- Aug 31, 2020
afb80d7
Add version compare to disable older Nodes
TheSin- Aug 31, 2020
57172e1
Switch back to 5000 as the default and add a note about port 80
TheSin- Aug 31, 2020
8564d39
test
UnchartedBull Aug 31, 2020
9caf235
Revert "test"
UnchartedBull Aug 31, 2020
73387d2
Attempt to fix CI
TheSin- Aug 31, 2020
36887ce
Merge branch 'master' of git://github.com/TheSin-/OctoDash
TheSin- Aug 31, 2020
a2dff3a
restructure main.js
UnchartedBull Aug 31, 2020
957cb03
With the new changes newer node is working again
TheSin- Aug 31, 2020
735f395
Use proper indentation
TheSin- Aug 31, 2020
0e3d9a6
Forgot to update package-lock with node update
TheSin- Aug 31, 2020
becd2c4
electron stuff finished
UnchartedBull Aug 31, 2020
540fc43
Fix lint errors and warnings
TheSin- Aug 31, 2020
2e2e675
Merge remote-tracking branch 'origin/master'
UnchartedBull Aug 31, 2020
ab726d4
finalise workflow
UnchartedBull Aug 31, 2020
8f91083
small bugfix
UnchartedBull Aug 31, 2020
e2f64d2
prevent the same instance showing multiple times
UnchartedBull Aug 31, 2020
6bafeb3
remove node from angular app
UnchartedBull Aug 31, 2020
d050ae0
Manually trigger change detection
UnchartedBull Aug 31, 2020
727ad51
Also trigger change detection for Page changes to fix bug
UnchartedBull Aug 31, 2020
ad0c41b
intial setup to load op script
UnchartedBull Sep 1, 2020
dd4816f
Fix ngZone issue
UnchartedBull Sep 1, 2020
6bc207d
Merge remote-tracking branch 'upstream/master'
TheSin- Sep 1, 2020
5824236
Remove ngx-electron from package-lock
TheSin- Sep 1, 2020
510bf8a
Remove electron-rebuild, postinstall script and test if the travis ch…
TheSin- Sep 1, 2020
11ff0b5
Tested and no longer required, was a rebuild only issue
TheSin- Sep 1, 2020
b174b30
Merge master
TheSin- Sep 2, 2020
beabf32
fix OctoPrint var
UnchartedBull Sep 2, 2020
ae5a087
finally get that freakin jQuery working
UnchartedBull Sep 2, 2020
5f7fe86
cleanup + reset URL if manual input is opened.
UnchartedBull Sep 2, 2020
2a62ccb
Check OctoPrint connection and load client library
UnchartedBull Sep 2, 2020
dbc7db9
Update package-lock, fix a few navigation bugs
TheSin- Sep 3, 2020
4df9b99
Make sure pages can't go below 0 or above totalPages
TheSin- Sep 3, 2020
a913bd3
refactor navigation controller + show next button after page 1 again
UnchartedBull Sep 4, 2020
77bafa9
login with request working
UnchartedBull Sep 4, 2020
4bc7f96
use printer name from printerprofile
UnchartedBull Sep 4, 2020
bf98a4a
fix setup (all working)
UnchartedBull Sep 4, 2020
5dac7f9
Merge with Master
TheSin- Sep 4, 2020
6083fca
Convert to range slider to numeric input is not required
TheSin- Sep 11, 2020
e63a183
Merge changes from master
TheSin- Sep 11, 2020
f6086df
I think 150 would be fast enough to load
TheSin- Sep 11, 2020
159e418
value selector for numbers
UnchartedBull Sep 15, 2020
dd861f0
Merge branch 'master' into master
UnchartedBull Sep 15, 2020
3f33af4
fix layout issue
UnchartedBull Sep 15, 2020
be231ef
Fix alignemnt on large and small views
TheSin- Sep 15, 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
457 changes: 451 additions & 6 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
}
},
"scripts": {
"postinstall": "node ./node_modules/.bin/electron-rebuild",
"ng": "ng",
"start": "npm-run-all -p ng:serve electron:serve electron:serve:big",
"start:big": "npm-run-all -p ng:serve electron:serve:big",
Expand Down Expand Up @@ -82,6 +83,8 @@
"electron-store": "^6.0.0",
"got": "^11.5.2",
"lodash": "^4.17.20",
"mdns": "^2.5.1",
"ngx-electron": "^2.2.0",
"ngx-spinner": "^10.0.1",
"progress-stream": "^2.0.0",
"rxjs": "~6.6.2",
Expand All @@ -95,12 +98,13 @@
"@angular/language-service": "~10.0.14",
"@types/ajv": "^1.0.0",
"@types/lodash": "^4.14.161",
"@types/node": "^14.6.2",
"@types/node": "^12.12.54",
"@typescript-eslint/eslint-plugin": "^3.10.1",
"@typescript-eslint/parser": "^3.10.1",
"codelyzer": "^6.0.0",
"electron": "^10.1.0",
"electron-builder": "^22.8.0",
"electron-rebuild": "^2.0.0",
"electron-reload": "^1.5.0",
"eslint": "7.7.0",
"eslint-plugin-import": "^2.22.0",
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { FaIconLibrary, FontAwesomeModule } from '@fortawesome/angular-fontaweso
import { fas } from '@fortawesome/free-solid-svg-icons';
import { RoundProgressModule } from 'angular-svg-round-progressbar';
import { NgxSpinnerModule } from 'ngx-spinner';
import { NgxElectronModule } from 'ngx-electron';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app.routing.module';
Expand Down Expand Up @@ -65,6 +66,7 @@ import { URLSafePipe } from './url.pipe';
FormsModule,
FontAwesomeModule,
NgxSpinnerModule,
NgxElectronModule,
BrowserAnimationsModule,
MatRippleModule,
],
Expand Down
80 changes: 52 additions & 28 deletions src/app/config/no-config/no-config.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<fa-icon [icon]="['fas', 'smile']"></fa-icon>
</span>
</div>
<div *ngIf="page === 1">
<div *ngIf="page === 3">
UnchartedBull marked this conversation as resolved.
Show resolved Hide resolved
<span class="no-config__text">
First, tell me some facts about your printer so I can personalize OctoDash for you.
</span>
Expand All @@ -63,7 +63,7 @@
Wiki.
</div>
</div>
<div *ngIf="page === 2">
<div *ngIf="page === 4">
<span class="no-config__text">I also need some information about your extruder.</span>
<form class="no-config__form no-config__2-form">
<label for="feedLength" class="no-config__input-label">Feed Length:</label>
Expand Down Expand Up @@ -99,33 +99,54 @@
</div>
</form>
</div>
<div *ngIf="page === 3">
<div *ngIf="page === 1">
<span class="no-config__text">
Now I need to know something about your OctoPrint setup, so I can talk to your printer.
</span>
<form class="no-config__form">
<label for="octoprintURLName" class="no-config__input-label">URL:</label>
<span class="no-config__input-prefix">http://</span>
<input
type="text"
id="octoprintURLName"
<label for="octoprintInstance" class="no-config__input-label">Instance:</label>
<select
id="octoprintInstance"
class="no-config__input"
[(ngModel)]="this.config.octoprint.urlSplit.url"
name="octoprintURLName"
required
style="width: 42.5vw"
/>
:
<input
type="text"
id="octoprintURLPort"
class="no-config__input"
[(ngModel)]="this.config.octoprint.urlSplit.port"
name="octoprintURLPort"
required
style="width: 14vw"
/>
<br />
[(ngModel)]="opInstance"
name="octoprintInstance"
style="width: 67vw;"
size="3"
require
>
<option *ngFor="let node of objectvalues(octoprintNodes)" [ngValue]="node" [disabled]="node.disable">{{ node.display }}</option>
</select>
</form>
</div>
<div *ngIf="page === 2">
<span class="no-config__text">
Now I need to know something about your OctoPrint setup, so I can talk to your printer.
</span>
<form class="no-config__form">
<div *ngIf="manualEntry">
<label for="octoprintURLName" class="no-config__input-label">URL:</label>
<span class="no-config__input-prefix">http://</span>
<input
type="text"
id="octoprintURLName"
class="no-config__input"
[(ngModel)]="this.config.octoprint.urlSplit.url"
name="octoprintURLName"
required
style="width: 42.5vw;"
/>
:
<input
type="text"
id="octoprintURLPort"
class="no-config__input"
[(ngModel)]="this.config.octoprint.urlSplit.port"
name="octoprintURLPort"
required
style="width: 14vw;"
/>
<br />
</div>
<label for="accessToken" class="no-config__input-label">API Key:</label>
<input
type="text"
Expand All @@ -137,8 +158,11 @@
required
/>
</form>
<span class="no-config__text">
{{ this.opApiMsg }}
</span>
</div>
<div *ngIf="page === 4">
<div *ngIf="page === 5">
<span class="no-config__text">And now personalize me to your liking.</span>
<form class="no-config__form">
<div class="no-config__checkbox-container" (click)="config.octodash.touchscreen = !config.octodash.touchscreen">
Expand All @@ -165,9 +189,9 @@
</div>
</form>
</div>
<div *ngIf="page === 5">
<div *ngIf="page === 6">
<span class="no-config__text">What plugins are you running?</span>
<div style="text-align: center">
<div style="text-align: center;">
<div class="no-config__checkbox-container" (click)="config.plugins.displayLayerProgress.enabled = true">
<span class="no-config__checkbox">
<span
Expand Down Expand Up @@ -227,7 +251,7 @@
</div>
</div>
</div>
<div *ngIf="page === 6">
<div *ngIf="page === 7">
<span class="no-config__text">Great! I'll check everything.</span>
<div class="no-config__6-check-wrapper">
<span class="no-config__6-check">
Expand Down
79 changes: 69 additions & 10 deletions src/app/config/no-config/no-config.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

import { ElectronService } from 'ngx-electron';

import { Config, ConfigService } from '../config.service';

@Component({
Expand All @@ -10,27 +12,40 @@ import { Config, ConfigService } from '../config.service';
styleUrls: ['./no-config.component.scss'],
})
export class NoConfigComponent implements OnInit {
public page = 0;
public totalPages = 6;
public page: number = 0;
public totalPages: number = 7;
TheSin- marked this conversation as resolved.
Show resolved Hide resolved

public configUpdate: boolean;
public config: Config;
public configErrors: string[];
public configValid: boolean;
public configSaved: string;

public octoprintConnection: boolean;
public objectvalues = Object.values;
public octoprintNodes: any = {
'other': {
'display': 'Other (> 1.4.0)',
TheSin- marked this conversation as resolved.
Show resolved Hide resolved
'name': 'other',
'version': '1.4.0',
'url': 'other',
'disable': false
}
};
public opInstance: any = this.octoprintNodes['other'];
public opApiMsg: string = '';
TheSin- marked this conversation as resolved.
Show resolved Hide resolved
public manualEntry: boolean = true;
public octoprintConnection: boolean = false;
public octoprintConnectionError: string;

public constructor(private configService: ConfigService, private http: HttpClient, private router: Router) {
public constructor(private configService: ConfigService, private http: HttpClient, private router: Router, private _electronService: ElectronService) {
this.configUpdate = this.configService.isUpdate();
console.log(this.configUpdate);
if (this.configUpdate) {
this.config = configService.getCurrentConfig();
} else {
this.config = {
octoprint: {
url: 'http://localhost:5000/api/',
url: 'http://localhost:80/api/',
TheSin- marked this conversation as resolved.
Show resolved Hide resolved
accessToken: '',
},
printer: {
Expand Down Expand Up @@ -137,9 +152,28 @@ export class NoConfigComponent implements OnInit {

public ngOnInit(): void {
this.changeProgress();

const mdns = this._electronService.remote.require('mdns');
const browser = mdns.createBrowser(mdns.tcp('octoprint'));
browser.on('serviceUp', service => {
var node = {
'display': service.name.match(/"([^"]+)"/)[1] + ' (' + service.txtRecord.version + ')',
'name': service.name.match(/"([^"]+)"/)[1],
'version': service.txtRecord.version,
'url': service.host.replace(/\.$/, '') + ":" + service.port + service.txtRecord.path.replace(/\/$/, '') + "/api/",
// Compare version to make sure it meets the requirement
'disable': false
};

this.octoprintNodes[service.host.replace(/\.$/, '').replace('.', '_')] = node;
});
browser.on('serviceDown', service => {
delete this.octoprintNodes[service.host.replace(/\.$/, '').replace('.', '_')];
});
browser.start();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put this in main.js, this would remove the ngx-electron dependency and the icp links are already there, plus we would get around having to add node to the main angular app.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you want me to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that is beyond me, this took me long enough to figure out ;)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I'll take that one :)

}

public testOctoprintAPI(): boolean {
public async testOctoprintAPI(): Promise<any> {
TheSin- marked this conversation as resolved.
Show resolved Hide resolved
const httpHeaders = {
headers: new HttpHeaders({
'x-api-key': this.config.octoprint.accessToken,
Expand All @@ -166,12 +200,12 @@ export class NoConfigComponent implements OnInit {
return true;
}

public validateConfig(): void {
public async validateConfig(): Promise<any> {
TheSin- marked this conversation as resolved.
Show resolved Hide resolved
this.configValid = this.configService.validateGiven(this.config);
if (!this.configValid) {
this.configErrors = this.configService.getErrors();
} else {
this.testOctoprintAPI();
this.saveConfig();
}
}

Expand All @@ -184,16 +218,41 @@ export class NoConfigComponent implements OnInit {
this.router.navigate(['/main-screen']);
}

public increasePage(): void {
public async increasePage(): Promise<any> {
TheSin- marked this conversation as resolved.
Show resolved Hide resolved
this.page += 1;
if (this.page <= 2) {
if (JSON.stringify(this.opInstance) != JSON.stringify(this.octoprintNodes['other'])) {
this.config.octoprint.url = 'http://' + this.opInstance['url'];
this.manualEntry = false;
} else {
this.config.octoprint.url = 'http://localhost:80/api/';
this.manualEntry = true;
}
} else if (this.config.octoprint.accessToken == '' && this.page > 2) {
this.page = 2;
} else if (this.page > 2) {
if (this.octoprintConnection === false) {
await this.testOctoprintAPI().then(res => {
this.opApiMsg = '';
if (this.opInstance.name != 'other') {
this.config.printer.name = this.opInstance.name;
} else {
this.config.printer.name = '';
}
}, err => {
this.opApiMsg = 'API Error: ' + this.octoprintConnectionError;
this.page = 2;
});
}
}
UnchartedBull marked this conversation as resolved.
Show resolved Hide resolved
if (this.page === this.totalPages) {
this.createConfig();
}
this.changeProgress();
}

public decreasePage(): void {
if (this.page === 5) {
if (this.page == this.totalPages - 1) {
UnchartedBull marked this conversation as resolved.
Show resolved Hide resolved
this.config = this.configService.revertConfigForInput(this.config);
}
this.page -= 1;
Expand Down
4 changes: 2 additions & 2 deletions src/app/filament/filament.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class FilamentComponent implements OnInit {
private totalPages = 5;

public page: number;
private timeout: number;
private timeout2: number;
private timeout: NodeJS.Timer;
private timeout2: NodeJS.Timer;

public filamentSpools: FilamentSpoolList;
public isLoadingSpools = true;
Expand Down
2 changes: 1 addition & 1 deletion src/app/files.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { OctoprintFilesAPI, OctoprintFolderAPI, OctoprintFolderContentAPI } from
})
export class FilesService {
private httpGETRequest: Subscription;
private httpGETRequestTimeout: number;
private httpGETRequestTimeout: NodeJS.Timer;
private httpPOSTRequest: Subscription;
private httpDELETERequest: Subscription;

Expand Down
2 changes: 1 addition & 1 deletion src/app/standby/standby.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class StandbyComponent implements OnInit {
public connecting = false;
public error = '';
private connectionRetries = 3;
private displaySleepTimeout: number;
private displaySleepTimeout: NodeJS.Timer;

public constructor(
private configService: ConfigService,
Expand Down
2 changes: 1 addition & 1 deletion src/app/update/update.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class UpdateComponent implements OnInit {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
private ipc: any;
private installationAnimationInterval: number;
private installationAnimationInterval: NodeJS.Timer;
public updateProgress: UpdateDownloadProgress = {
percentage: 0,
transferred: 0,
Expand Down