diff --git a/main.js b/main.js index 1de6580e6..042d1592a 100644 --- a/main.js +++ b/main.js @@ -55,7 +55,7 @@ function createWindow() { window.setFullScreen(true) } - setTimeout(sendVersionInfo, 42 * 1000); + setTimeout(sendVersionInfo, 30 * 1000); activateScreenSleepListener(); window.on('closed', () => { diff --git a/sample.config.json b/sample.config.json index c6184d100..44a91c98d 100644 --- a/sample.config.json +++ b/sample.config.json @@ -1,51 +1,95 @@ { - "octoprint": { - "url": "http://localhost:5000/api/", - "accessToken": "INSERT API KEY HERE", - "apiInterval": 15000 - }, - "printer": { - "name": "NAME HERE", - "xySpeed": 100, - "zSpeed": 5 - }, - "filament": { - "thickness": 0, - "density": 0 - }, - "octodash": { - "touchscreen": true, - "temperatureSensor": null, - "customActions": [{ - "icon": "home", - "command": "G28", - "color": "#dcdde1" + "config": { + "octoprint": { + "accessToken": "INSERT API KEY HERE", + "url": "http://localhost:5000/api/" + }, + "printer": { + "name": "NAME HERE", + "xySpeed": 100, + "zSpeed": 5 + }, + "filament": { + "density": 0, + "thickness": 0, + "feedLength": 470, + "feedSpeed": 100 + }, + "plugins": { + "displayLayerProgress": { + "enabled": true }, - { - "icon": "ruler-vertical", - "command": "G29", - "color": "#44bd32" + "enclosure": { + "enabled": true, + "ambientSensorID": null, + "filament1SensorID": null, + "filament2SensorID": null }, - { - "icon": "fire-alt", - "command": "M140 S50; M104 S185", - "color": "#e1b12c" + "filamentManager": { + "enabled": true }, - { - "icon": "snowflake", - "command": "M140 S0; M104 S0", - "color": "#0097e6" + "preheatButton": { + "enabled": true }, - { - "icon": "redo-alt", - "command": "[!RELOAD]", - "color": "#7f8fa6" + "printTimeGenius": { + "enabled": true }, - { - "icon": "skull", - "command": "[!KILL]", - "color": "#e84118" + "psuControl": { + "enabled": true, + "turnOnPSUWhenExitingSleep": false } - ] + }, + "octodash": { + "customActions": [{ + "icon": "home", + "command": "G28", + "color": "#dcdde1", + "confirm": false, + "exit": false + }, + { + "icon": "ruler-vertical", + "command": "G29", + "color": "#44bd32", + "confirm": false, + "exit": false + }, + { + "icon": "fire-alt", + "command": "M140 S50; M104 S185", + "color": "#e1b12c", + "confirm": false, + "exit": true + }, + { + "icon": "snowflake", + "command": "M140 S0; M104 S0", + "color": "#0097e6", + "confirm": false, + "exit": true + }, + { + "icon": "redo-alt", + "command": "[!RELOAD]", + "color": "#7f8fa6", + "confirm": true, + "exit": false + }, + { + "icon": "skull", + "command": "[!KILL]", + "color": "#e84118", + "confirm": true, + "exit": false + } + ], + "fileSorting": { + "attribute": "name", + "order": "asc" + }, + "pollingInterval": 2000, + "touchscreen": true, + "turnScreenOffWhileSleeping": false + } } } diff --git a/src/app/app.service.ts b/src/app/app.service.ts index 69d913723..903efd014 100644 --- a/src/app/app.service.ts +++ b/src/app/app.service.ts @@ -34,7 +34,6 @@ export class AppService { // If the errors can be automatically fixed return true here public autoFixError(): boolean { const config = this.configService.getCurrentConfig(); - config.octodash.temperatureSensor.ambient = 1; this.configService.saveConfig(config); this.configService.updateConfig(); return false; @@ -53,6 +52,10 @@ export class AppService { setTimeout(this.checkUpdate.bind(this), 21.6 * 1000000); } + public getVersion(): string { + return this.version; + } + public turnDisplayOff(): void { if (this.ipc) { this.ipc.send('screenSleep', ''); diff --git a/src/app/config/config.service.ts b/src/app/config/config.service.ts index b66406ba6..e81059ca1 100644 --- a/src/app/config/config.service.ts +++ b/src/app/config/config.service.ts @@ -2,6 +2,8 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { environment } from '../../environments/environment'; import Ajv from 'ajv'; +import _ from 'lodash'; +import { DisplayLayerProgressAPI } from '../plugin-service/layer-progress.service'; declare global { interface Window { @@ -60,7 +62,11 @@ export class ConfigService { } public getCurrentConfig(): Config { - return this.config; + return (_.cloneDeep(this.config)); + } + + public isEqualToCurrentConfig(changedConfig: Config): boolean { + return _.isEqual(this.config, changedConfig); } public validate(): boolean { @@ -116,9 +122,10 @@ export class ConfigService { } public createConfigFromInput(config: Config) { - config.octoprint.url = `http://${config.octoprint.urlSplit.url}:${config.octoprint.urlSplit.port}/api/`; - delete config.octoprint.urlSplit; - return config; + const configOut = _.cloneDeep(config); + configOut.octoprint.url = `http://${configOut.octoprint.urlSplit.url}:${configOut.octoprint.urlSplit.port}/api/`; + delete configOut.octoprint.urlSplit; + return configOut; } public isLoaded(): boolean { @@ -137,8 +144,8 @@ export class ConfigService { return this.config.octoprint.url + path; } - public getAPIInterval(): number { - return this.config.octoprint.apiInterval; + public getAPIPollingInterval(): number { + return this.config.octodash.pollingInterval; } public getPrinterName(): string { @@ -174,16 +181,15 @@ export class ConfigService { } public getAmbientTemperatureSensorName(): number { - return this.config.octodash.temperatureSensor.ambient; + return this.config.plugins.enclosure.ambientSensorID; } public getAutomaticScreenSleep(): boolean { - return this.config.octodash.turnScreenOffSleep; + return this.config.octodash.turnScreenOffWhileSleeping; } - public isPSUControlEnabled(): boolean { - // TODO: implement in next config change - return false; + public turnOnPSUWhenExitingSleep(): boolean { + return this.config.plugins.psuControl.turnOnPSUWhenExitingSleep; } public getFilamentThickness(): number { @@ -199,32 +205,13 @@ export interface Config { octoprint: Octoprint; printer: Printer; filament: Filament; + plugins: Plugins; octodash: OctoDash; } -interface OctoDash { - touchscreen: boolean; - temperatureSensor: TemperatureSensor | null; - customActions: CustomAction[]; - turnScreenOffSleep: boolean; -} - -interface CustomAction { - icon: string; - command: string; - color: string; -} - -interface TemperatureSensor { - ambient: number | null; - filament1: number | null; - filament2: number | null; -} - interface Octoprint { url: string; accessToken: string; - apiInterval: number; urlSplit?: { url: string; port: number; @@ -240,6 +227,52 @@ interface Printer { interface Filament { thickness: number; density: number; + feedLength: number; + feedSpeed: number; +} + +interface Plugins { + displayLayerProgress: Plugin; + enclosure: EnclosurePlugin; + filamentManager: Plugin; + preheatButton: Plugin; + printTimeGenius: Plugin; + psuControl: PSUControlPlugin; +} + +interface Plugin { + enabled: boolean; +} + +interface EnclosurePlugin extends Plugin { + ambientSensorID: number | null; + filament1SensorID: number | null; + filament2SensorID: number | null; +} + +interface PSUControlPlugin extends Plugin { + turnOnPSUWhenExitingSleep: boolean; +} + +interface OctoDash { + customActions: CustomAction[]; + fileSorting: FileSorting; + pollingInterval: number; + touchscreen: boolean; + turnScreenOffWhileSleeping: boolean; +} + +interface CustomAction { + icon: string; + command: string; + color: string; + confirm: boolean; + exit: boolean; +} + +interface FileSorting { + attribute: string; + order: string; } const schema = { @@ -251,6 +284,7 @@ const schema = { 'octoprint', 'printer', 'filament', + 'plugins', 'octodash' ], properties: { @@ -258,24 +292,19 @@ const schema = { $id: '#/properties/octoprint', type: 'object', required: [ - 'url', 'accessToken', - 'apiInterval' + 'url' ], properties: { - url: { - $id: '#/properties/octoprint/properties/url', - type: 'string', - pattern: '^(.*)$' - }, accessToken: { $id: '#/properties/octoprint/properties/accessToken', type: 'string', pattern: '^(.*)$' }, - apiInterval: { - $id: '#/properties/octoprint/properties/apiInterval', - type: 'integer' + url: { + $id: '#/properties/octoprint/properties/url', + type: 'string', + pattern: '^(.*)$' } } }, @@ -307,60 +336,156 @@ const schema = { $id: '#/properties/filament', type: 'object', required: [ + 'density', 'thickness', - 'density' + 'feedLength', + 'feedSpeed' ], properties: { + density: { + $id: '#/properties/filament/properties/density', + type: 'number' + }, thickness: { $id: '#/properties/filament/properties/thickness', type: 'number' }, - density: { - $id: '#/properties/filament/properties/density', - type: 'number' + feedLength: { + $id: '#/properties/filament/properties/feedLength', + type: 'integer' + }, + feedSpeed: { + $id: '#/properties/filament/properties/feedSpeed', + type: 'integer' } } }, - octodash: { - $id: '#/properties/octodash', + plugins: { + $id: '#/properties/plugins', type: 'object', required: [ - 'touchscreen', - 'temperatureSensor', - 'customActions', - 'turnScreenOffSleep' + 'displayLayerProgress', + 'enclosure', + 'filamentManager', + 'preheatButton', + 'printTimeGenius', + 'psuControl' ], properties: { - touchscreen: { - $id: '#/properties/octodash/properties/touchscreen', - type: 'boolean' + displayLayerProgress: { + $id: '#/properties/plugins/properties/displayLayerProgress', + type: 'object', + required: [ + 'enabled' + ], + properties: { + enabled: { + $id: '#/properties/plugins/properties/displayLayerProgress/properties/enabled', + type: 'boolean' + } + } }, - temperatureSensor: { - $id: '#/properties/octodash/properties/temperatureSensor', + enclosure: { + $id: '#/properties/plugins/properties/enclosure', type: 'object', required: [ - 'ambient', - 'filament1', - 'filament2' + 'enabled', + 'ambientSensorID', + 'filament1SensorID', + 'filament2SensorID' ], properties: { - ambient: { - $id: '#/properties/octodash/properties/temperatureSensor/properties/ambient', + enabled: { + $id: '#/properties/plugins/properties/enclosure/properties/enabled', + type: 'boolean' + }, + ambientSensorID: { + $id: '#/properties/plugins/properties/enclosure/properties/ambientSensorID', type: ['number', 'null'], pattern: '^(.*)$' }, - filament1: { - $id: '#/properties/octodash/properties/temperatureSensor/properties/filament1', + filament1SensorID: { + $id: '#/properties/plugins/properties/enclosure/properties/filament1SensorID', type: ['number', 'null'], pattern: '^(.*)$' }, - filament2: { - $id: '#/properties/octodash/properties/temperatureSensor/properties/filament2', + filament2SensorID: { + $id: '#/properties/plugins/properties/enclosure/properties/filament2SensorID', type: ['number', 'null'], pattern: '^(.*)$' - }, + } + } + }, + filamentManager: { + $id: '#/properties/plugins/properties/filamentManager', + type: 'object', + required: [ + 'enabled' + ], + properties: { + enabled: { + $id: '#/properties/plugins/properties/filamentManager/properties/enabled', + type: 'boolean' + } } }, + preheatButton: { + $id: '#/properties/plugins/properties/preheatButton', + type: 'object', + required: [ + 'enabled' + ], + properties: { + enabled: { + $id: '#/properties/plugins/properties/preheatButton/properties/enabled', + type: 'boolean' + } + } + }, + printTimeGenius: { + $id: '#/properties/plugins/properties/printTimeGenius', + type: 'object', + required: [ + 'enabled' + ], + properties: { + enabled: { + $id: '#/properties/plugins/properties/printTimeGenius/properties/enabled', + type: 'boolean' + } + } + }, + psuControl: { + $id: '#/properties/plugins/properties/psuControl', + type: 'object', + required: [ + 'enabled', + 'turnOnPSUWhenExitingSleep' + ], + properties: { + enabled: { + $id: '#/properties/plugins/properties/printTimeGenius/properties/enabled', + type: 'boolean' + }, + turnOnPSUWhenExitingSleep: { + $id: '#/properties/octodash/properties/turnOnPSUWhenExitingSleep', + type: 'boolean' + } + } + } + } + }, + octodash: { + $id: '#/properties/octodash', + type: 'object', + required: [ + 'customActions', + 'fileSorting', + 'pollingInterval', + 'touchscreen', + 'turnScreenOffWhileSleeping' + ], + properties: { customActions: { $id: '#/properties/octodash/properties/customActions', type: 'array', @@ -370,7 +495,9 @@ const schema = { required: [ 'icon', 'command', - 'color' + 'color', + 'confirm', + 'exit' ], properties: { icon: { @@ -387,14 +514,50 @@ const schema = { $id: '#/properties/octodash/properties/customActions/items/properties/color', type: 'string', pattern: '^(.*)$' + }, + confirm: { + $id: '#/properties/octodash/properties/customActions/items/properties/confirm', + type: 'boolean' + }, + exit: { + $id: '#/properties/octodash/properties/customActions/items/properties/exit', + type: 'boolean' } } } }, - turnScreenOffSleep: { - $id: '#/properties/octodash/properties/turnScreenOffSleep', + fileSorting: { + $id: '#/properties/octodash/properties/fileSorting', + type: 'object', + required: [ + 'attribute', + 'order' + ], + properties: { + attribute: { + $id: '#/properties/octodash/properties/fileSorting/properties/attribute', + type: 'string', + pattern: '^(name|date|size)$' + }, + order: { + $id: '#/properties/octodash/properties/fileSorting/properties/order', + type: 'string', + pattern: '^(asc|dsc)$' + } + } + }, + pollingInterval: { + $id: '#/properties/octodash/properties/pollingInterval', + type: 'integer' + }, + touchscreen: { + $id: '#/properties/octodash/properties/touchscreen', type: 'boolean' }, + turnScreenOffWhileSleeping: { + $id: '#/properties/octodash/properties/turnScreenOffWhileSleeping', + type: 'boolean' + } } } } diff --git a/src/app/config/no-config/no-config.component.html b/src/app/config/no-config/no-config.component.html index dc498e02e..912bf4368 100644 --- a/src/app/config/no-config/no-config.component.html +++ b/src/app/config/no-config/no-config.component.html @@ -72,54 +72,100 @@
+ sort by +
+
+
+ Name
+ +
+
+
+ Date
+ +
+
+
+ Size
+ + |
+
+ order +
+
+
+ Ascending
+ +
+
+
+ Descending
+ + |
+
+ + + | ++ + + | +
+ |
+
+
+
+
+ Confirm
+
+ |
+
+
+
+ Return to Home
+
+ |
+