From 8554b88b66801f554e6b5ac0389d079605b627b6 Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Sat, 29 Aug 2020 10:27:58 -0600 Subject: [PATCH 01/43] - Add mdns and ngx-electron plugin - Add electron-rebuild to dev depends so that electron can be rebuilt with the installed node - Fix setTimeout and setInstance to with with Node modules (required for mdns) - Reduce the version on node as electron needs to be on the same version for this to work - Change order in on boarding wizard to select API first - Use mdns to detect and list octoprint instances (WIP need to figure out min version required) - Auto set Printer name if a detected install if found. I'm trying to reduce input and the need for a keyboard during onboarding. Obviously this is just the first step as the API key still needs to be inputed. But it's still a start. Follow Issue #921 for more info on the changes. --- package-lock.json | 457 +++++++++++++++++- package.json | 5 +- src/app/app.module.ts | 2 + .../config/no-config/no-config.component.html | 78 +-- .../config/no-config/no-config.component.ts | 103 +++- src/app/filament/filament.component.ts | 4 +- src/app/files.service.ts | 2 +- src/app/standby/standby.component.ts | 2 +- src/app/update/update.component.ts | 2 +- 9 files changed, 595 insertions(+), 60 deletions(-) diff --git a/package-lock.json b/package-lock.json index 49abf6f11..a96c47e96 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2591,9 +2591,9 @@ "dev": true }, "@types/node": { - "version": "14.6.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.6.0.tgz", - "integrity": "sha512-mikldZQitV94akrc4sCcSjtJfsTKt4p+e/s0AGscVA6XArQ9kFclP+ZiYUMnq987rc6QlYxXv/EivqlfSLxpKA==" + "version": "12.12.54", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.54.tgz", + "integrity": "sha512-ge4xZ3vSBornVYlDnk7yZ0gK6ChHf/CHB7Gl1I0Jhah8DDnEQqBzgohYG4FX4p81TNirSETOiSyn+y1r9/IR6w==" }, "@types/q": { "version": "1.5.4", @@ -2971,6 +2971,12 @@ "integrity": "sha512-Eu9ELJWCz/c1e9gTiCY+FceWxcqzjYEbqMgtndnuSqZSUCOL73TWNK2mHfIj4Cw2E/ongOp+JISVNCmovt2KYQ==", "dev": true }, + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true + }, "accepts": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", @@ -3311,6 +3317,16 @@ "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", "dev": true }, + "are-we-there-yet": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", + "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", + "dev": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, "arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", @@ -4692,6 +4708,12 @@ "q": "^1.1.2" } }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true + }, "codelyzer": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/codelyzer/-/codelyzer-6.0.0.tgz", @@ -4791,6 +4813,12 @@ "simple-swizzle": "^0.2.2" } }, + "colors": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", + "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", + "dev": true + }, "combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -4962,6 +4990,12 @@ "integrity": "sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==", "dev": true }, + "console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", + "dev": true + }, "constants-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", @@ -5814,6 +5848,12 @@ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", "dev": true }, + "delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", + "dev": true + }, "depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", @@ -5842,6 +5882,12 @@ "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", "dev": true }, + "detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", + "dev": true + }, "detect-node": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.0.4.tgz", @@ -6440,6 +6486,137 @@ } } }, + "electron-rebuild": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/electron-rebuild/-/electron-rebuild-2.0.0.tgz", + "integrity": "sha512-A+acX+oU2g1ImoEuQGfsYWOGKCq757KyMN/INSVMiNvjqzE6tmZ4/xim6Q1Rca9aRhep+QdMVwoIVsp/jq0woQ==", + "dev": true, + "requires": { + "colors": "^1.3.3", + "debug": "^4.1.1", + "detect-libc": "^1.0.3", + "fs-extra": "^8.1.0", + "node-abi": "^2.11.0", + "node-gyp": "^7.1.0", + "ora": "^3.4.0", + "spawn-rx": "^3.0.0", + "yargs": "^14.2.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "dev": true, + "requires": { + "restore-cursor": "^2.0.0" + } + }, + "fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "log-symbols": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", + "integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==", + "dev": true, + "requires": { + "chalk": "^2.0.1" + } + }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "dev": true + }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "dev": true, + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "ora": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/ora/-/ora-3.4.0.tgz", + "integrity": "sha512-eNwHudNbO1folBP3JsZ19v9azXWtQZjICdr3Q0TDPIaeBQ3mXLrh54wM+er0+hSp+dWKf+Z8KM58CYzEyIYxYg==", + "dev": true, + "requires": { + "chalk": "^2.4.2", + "cli-cursor": "^2.1.0", + "cli-spinners": "^2.0.0", + "log-symbols": "^2.2.0", + "strip-ansi": "^5.2.0", + "wcwidth": "^1.0.1" + } + }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "dev": true, + "requires": { + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "yargs": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-14.2.3.tgz", + "integrity": "sha512-ZbotRWhF+lkjijC/VhmOT9wSgyBQ7+zr13+YLkhfsSiTriYsMzkTUFP18pFhWwBeMa5gUc1MzbhrO6/VB7c9Xg==", + "dev": true, + "requires": { + "cliui": "^5.0.0", + "decamelize": "^1.2.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^15.0.1" + } + }, + "yargs-parser": { + "version": "15.0.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-15.0.1.tgz", + "integrity": "sha512-0OAMV2mAZQrs3FkNpDQcBk1x5HXb8X4twADss4S0Iuk+2dGnLOE/fRHrsYm542GduMveyA77OF4wrNJuanRCWw==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } + }, "electron-reload": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/electron-reload/-/electron-reload-1.5.0.tgz", @@ -7878,6 +8055,44 @@ "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "dev": true }, + "gauge": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", + "dev": true, + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + } + } + }, "genfun": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/genfun/-/genfun-5.0.0.tgz", @@ -8094,6 +8309,12 @@ "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", "dev": true }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", + "dev": true + }, "has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", @@ -9529,6 +9750,12 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==" }, + "lodash.assign": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz", + "integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=", + "dev": true + }, "lodash.clonedeep": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", @@ -9736,6 +9963,22 @@ "integrity": "sha512-iV3XNKw06j5Q7mi6h+9vbx23Tv7JkjEVgKHW4pimwyDGWm0OIQntJJ+u1C6mg6mK1EaTv42XQ7w76yuzH7M2cA==", "dev": true }, + "mdns": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/mdns/-/mdns-2.5.1.tgz", + "integrity": "sha512-JglS7Ed3Yf0BCpyC7LXA1MUrumMV8jj4g67nT3+m886SFYllz2HWBg8ObywFXWbBSv5gW0meMOOS4vVa2jZGCw==", + "requires": { + "bindings": "~1.2.1", + "nan": "^2.14.0" + }, + "dependencies": { + "bindings": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz", + "integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE=" + } + } + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -10126,9 +10369,7 @@ "nan": { "version": "2.14.1", "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", - "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==", - "dev": true, - "optional": true + "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==" }, "nanomatch": { "version": "1.2.13", @@ -10180,6 +10421,21 @@ "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", "dev": true }, + "ngx-electron": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ngx-electron/-/ngx-electron-2.2.0.tgz", + "integrity": "sha512-Yl7Dsnvp97k0XpIuiB54X7Ij2+zU5x0pCAYnN//VZ9tF7c6S3//OZ9dN9Et7p/zIjCV3Hg9vyw68dPJEZGk+LQ==", + "requires": { + "tslib": "^1.9.0" + }, + "dependencies": { + "tslib": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", + "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==" + } + } + }, "ngx-spinner": { "version": "10.0.1", "resolved": "https://registry.npmjs.org/ngx-spinner/-/ngx-spinner-10.0.1.tgz", @@ -10201,6 +10457,23 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, + "node-abi": { + "version": "2.19.1", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.19.1.tgz", + "integrity": "sha512-HbtmIuByq44yhAzK7b9j/FelKlHYISKQn0mtvcBrU5QBkhoCMp5bu8Hv5AI34DcKfOAcJBcOEMwLlwO62FFu9A==", + "dev": true, + "requires": { + "semver": "^5.4.1" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } + } + }, "node-fetch-npm": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/node-fetch-npm/-/node-fetch-npm-2.0.4.tgz", @@ -10218,6 +10491,86 @@ "integrity": "sha512-7ASaDa3pD+lJ3WvXFsxekJQelBKRpne+GOVbLbtHYdd7pFspyeuJHnWfLplGf3SwKGbfs/aYl5V/JCIaHVUKKQ==", "dev": true }, + "node-gyp": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-7.1.0.tgz", + "integrity": "sha512-rjlHQlnl1dqiDZxZYiKqQdrjias7V+81OVR5PTzZioCBtWkNdrKy06M05HLKxy/pcKikKRCabeDRoZaEc6nIjw==", + "dev": true, + "requires": { + "env-paths": "^2.2.0", + "glob": "^7.1.4", + "graceful-fs": "^4.2.3", + "nopt": "^4.0.3", + "npmlog": "^4.1.2", + "request": "^2.88.2", + "rimraf": "^2.6.3", + "semver": "^7.3.2", + "tar": "^6.0.1", + "which": "^2.0.2" + }, + "dependencies": { + "chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "dev": true + }, + "minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "dev": true, + "requires": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + } + }, + "mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "dev": true + }, + "tar": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.0.5.tgz", + "integrity": "sha512-0b4HOimQHj9nXNEAA7zWwMM91Zhhba3pspja6sQbgTpynOJf+bkjBnfybNYzbpLbnwXnbyB4LOREvlyXLkCHSg==", + "dev": true, + "requires": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^3.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + } + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, "node-libs-browser": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.2.1.tgz", @@ -10278,6 +10631,16 @@ "integrity": "sha512-gsO4vjEdQaTusZAEebUWp2a5d7dF5DYoIpDG7WySnk7BuZDW+GPpHXoXXuYawRBr/9t5q54tirPz79kFIWg4dA==", "dev": true }, + "nopt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz", + "integrity": "sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg==", + "dev": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, "normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", @@ -10527,6 +10890,18 @@ "path-key": "^2.0.0" } }, + "npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "dev": true, + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, "nth-check": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", @@ -10542,6 +10917,12 @@ "integrity": "sha1-b2gragJ6Tp3fpFZM0lidHU5mnt4=", "dev": true }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, "oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", @@ -13739,6 +14120,34 @@ "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", "dev": true }, + "spawn-rx": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spawn-rx/-/spawn-rx-3.0.0.tgz", + "integrity": "sha512-dw4Ryg/KMNfkKa5ezAR5aZe9wNwPdKlnHEXtHOjVnyEDSPQyOpIPPRtcIiu7127SmtHhaCjw21yC43HliW0iIg==", + "dev": true, + "requires": { + "debug": "^2.5.1", + "lodash.assign": "^4.2.0", + "rxjs": "^6.3.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, "spdx-correct": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", @@ -16039,6 +16448,42 @@ "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "dev": true }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dev": true, + "requires": { + "string-width": "^1.0.2 || 2" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, "widest-line": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-3.1.0.tgz", diff --git a/package.json b/package.json index eddf8274c..a8332e151 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,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", @@ -95,12 +97,13 @@ "@angular/language-service": "~10.0.11", "@types/ajv": "^1.0.0", "@types/lodash": "^4.14.159", - "@types/node": "^14.6.0", + "@types/node": "~12.12.54", "@typescript-eslint/eslint-plugin": "^3.9.1", "@typescript-eslint/parser": "^3.9.1", "codelyzer": "^6.0.0", "electron": "^9.2.1", "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", diff --git a/src/app/app.module.ts b/src/app/app.module.ts index cd8c126bd..32ec3916a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -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"; @@ -65,6 +66,7 @@ import { URLSafePipe } from "./url.pipe"; FormsModule, FontAwesomeModule, NgxSpinnerModule, + NgxElectronModule, BrowserAnimationsModule, MatRippleModule, ], diff --git a/src/app/config/no-config/no-config.component.html b/src/app/config/no-config/no-config.component.html index a1168d368..c79bf832b 100644 --- a/src/app/config/no-config/no-config.component.html +++ b/src/app/config/no-config/no-config.component.html @@ -32,7 +32,7 @@ Thanks for choosing OctoDash -
+
First, tell me some facts about your printer so I can personalize OctoDash for you. @@ -54,7 +54,7 @@ Wiki.
-
+
I also need some information about your extruder. @@ -92,33 +92,54 @@
-
+
Now I need to know something about your OctoPrint setup, so I can talk to your printer.
- - http:// - Instance: + -
+ [(ngModel)]="opInstance" + name="octoprintInstance" + style="width: 67vw;" + size="3" + require + > + + +
+
+
+ + Now I need to know something about your OctoPrint setup, so I can talk to your printer. + +
+
+ + http:// + + : + +
+
+ + {{ this.opApiMsg }} +
-
+
And now personalize me to your liking. @@ -160,7 +184,7 @@
-
+
What plugins are you running? @@ -224,7 +248,7 @@
-
+
Great! I'll check everything. diff --git a/src/app/config/no-config/no-config.component.ts b/src/app/config/no-config/no-config.component.ts index 840b5eceb..6fe48e84e 100644 --- a/src/app/config/no-config/no-config.component.ts +++ b/src/app/config/no-config/no-config.component.ts @@ -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({ @@ -10,8 +12,8 @@ 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; private configUpdate: boolean; public config: Config; @@ -19,10 +21,23 @@ export class NoConfigComponent implements OnInit { public configValid: boolean; public configSaved: string; - public octoprintConnection: boolean; + public objectvalues = Object.values; + public octoprintNodes: any = { + 'other': { + 'display': 'Other (> 1.4.0)', + 'name': 'other', + 'version': '1.4.0', + 'url': 'other', + 'disable': false + } + }; + public opInstance: any = this.octoprintNodes['other']; + public opApiMsg: string = ''; + 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) { @@ -30,7 +45,7 @@ export class NoConfigComponent implements OnInit { } else { this.config = { octoprint: { - url: "http://localhost:5000/api/", + url: "http://localhost:80/api/", accessToken: "", }, printer: { @@ -137,25 +152,46 @@ 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(); } - public testOctoprintAPI(): boolean { + public async testOctoprintAPI(): Promise { const httpHeaders = { headers: new HttpHeaders({ "x-api-key": this.config.octoprint.accessToken, }), }; - this.http.get(this.config.octoprint.url + "connection", httpHeaders).subscribe( - (): void => { - this.octoprintConnection = true; - this.saveConfig(); - }, - (error: HttpErrorResponse): void => { - this.octoprintConnection = false; - this.octoprintConnectionError = error.message; - } - ); - return true; + return new Promise((resolve, reject) => { + this.http.get(this.config.octoprint.url + "connection", httpHeaders).subscribe( + (): void => { + this.octoprintConnection = true; + resolve(); + }, + (error: HttpErrorResponse): void => { + this.octoprintConnection = false; + this.octoprintConnectionError = error.message; + reject(); + } + ); + }); } public createConfig(): boolean { @@ -166,12 +202,12 @@ export class NoConfigComponent implements OnInit { return true; } - public validateConfig(): void { + public async validateConfig(): Promise { this.configValid = this.configService.validateGiven(this.config); if (!this.configValid) { this.configErrors = this.configService.getErrors(); } else { - this.testOctoprintAPI(); + this.saveConfig(); } } @@ -184,8 +220,33 @@ export class NoConfigComponent implements OnInit { this.router.navigate(["/main-screen"]); } - public increasePage(): void { + public async increasePage(): Promise { 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; + }); + } + } if (this.page === this.totalPages) { this.createConfig(); } @@ -193,7 +254,7 @@ export class NoConfigComponent implements OnInit { } public decreasePage(): void { - if (this.page === 5) { + if (this.page == this.totalPages - 1) { this.config = this.configService.revertConfigForInput(this.config); } this.page -= 1; diff --git a/src/app/filament/filament.component.ts b/src/app/filament/filament.component.ts index 4f336d0ec..f5915c467 100644 --- a/src/app/filament/filament.component.ts +++ b/src/app/filament/filament.component.ts @@ -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; diff --git a/src/app/files.service.ts b/src/app/files.service.ts index a032dcade..cc669058f 100644 --- a/src/app/files.service.ts +++ b/src/app/files.service.ts @@ -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; diff --git a/src/app/standby/standby.component.ts b/src/app/standby/standby.component.ts index cc16329ab..6b03daf6d 100644 --- a/src/app/standby/standby.component.ts +++ b/src/app/standby/standby.component.ts @@ -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, diff --git a/src/app/update/update.component.ts b/src/app/update/update.component.ts index 50bf316f1..7a7e090d0 100644 --- a/src/app/update/update.component.ts +++ b/src/app/update/update.component.ts @@ -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, From 7313d24e3f02c6ceb725e09fd0de0a6e75654217 Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Sun, 30 Aug 2020 20:35:03 -0600 Subject: [PATCH 02/43] Add postinstall so it auto rebuilds electron against node --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index ef77140e5..2ea4a8465 100644 --- a/package.json +++ b/package.json @@ -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", From b038c08f4581896ed0716cd70416a32a2fd6d81e Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Mon, 31 Aug 2020 07:16:49 -0600 Subject: [PATCH 03/43] Update src/app/config/no-config/no-config.component.ts Returns void Co-authored-by: Timon G. --- src/app/config/no-config/no-config.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/config/no-config/no-config.component.ts b/src/app/config/no-config/no-config.component.ts index 0f27ec513..5247e965f 100644 --- a/src/app/config/no-config/no-config.component.ts +++ b/src/app/config/no-config/no-config.component.ts @@ -200,7 +200,7 @@ export class NoConfigComponent implements OnInit { return true; } - public async validateConfig(): Promise { + public async validateConfig(): Promise { this.configValid = this.configService.validateGiven(this.config); if (!this.configValid) { this.configErrors = this.configService.getErrors(); From 6c53aec70d404dc0d593d8bc89b26c450f11e51b Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Mon, 31 Aug 2020 07:17:52 -0600 Subject: [PATCH 04/43] Update src/app/config/no-config/no-config.component.ts Return Boolean Co-authored-by: Timon G. --- src/app/config/no-config/no-config.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/config/no-config/no-config.component.ts b/src/app/config/no-config/no-config.component.ts index 5247e965f..9abdffad0 100644 --- a/src/app/config/no-config/no-config.component.ts +++ b/src/app/config/no-config/no-config.component.ts @@ -173,7 +173,7 @@ export class NoConfigComponent implements OnInit { browser.start(); } - public async testOctoprintAPI(): Promise { + public async testOctoprintAPI(): Promise { const httpHeaders = { headers: new HttpHeaders({ 'x-api-key': this.config.octoprint.accessToken, From 8716587eabee25f52b3a2ae8c270a311cb0a4b61 Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Mon, 31 Aug 2020 07:20:03 -0600 Subject: [PATCH 05/43] Update src/app/config/no-config/no-config.component.ts Returns void Co-authored-by: Timon G. --- src/app/config/no-config/no-config.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/config/no-config/no-config.component.ts b/src/app/config/no-config/no-config.component.ts index 9abdffad0..cc7ef7e55 100644 --- a/src/app/config/no-config/no-config.component.ts +++ b/src/app/config/no-config/no-config.component.ts @@ -218,7 +218,7 @@ export class NoConfigComponent implements OnInit { this.router.navigate(['/main-screen']); } - public async increasePage(): Promise { + public async increasePage(): Promise { this.page += 1; if (this.page <= 2) { if (JSON.stringify(this.opInstance) != JSON.stringify(this.octoprintNodes['other'])) { From 68887b1a678c816e1df968f462b990e8e5fdf92f Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Mon, 31 Aug 2020 07:29:26 -0600 Subject: [PATCH 06/43] Resolve a few issues with VSCode and more consistent var naming --- .../config/no-config/no-config.component.html | 4 ++-- .../config/no-config/no-config.component.ts | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/app/config/no-config/no-config.component.html b/src/app/config/no-config/no-config.component.html index 2a75620a2..e5f828309 100644 --- a/src/app/config/no-config/no-config.component.html +++ b/src/app/config/no-config/no-config.component.html @@ -108,7 +108,7 @@ 2) { From 8564d39406dfb765f6710b87c146fd91f3938aee Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Mon, 31 Aug 2020 19:09:22 +0200 Subject: [PATCH 09/43] test --- test | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test diff --git a/test b/test new file mode 100644 index 000000000..e69de29bb From 9caf235f210d4d069672aa3b887c1a9526dfc768 Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Mon, 31 Aug 2020 19:09:22 +0200 Subject: [PATCH 10/43] Revert "test" This reverts commit 8564d39406dfb765f6710b87c146fd91f3938aee. --- test | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 test diff --git a/test b/test deleted file mode 100644 index e69de29bb..000000000 From 73387d2618db9fb39f0f514ecc37194ce70fb75a Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Mon, 31 Aug 2020 11:22:27 -0600 Subject: [PATCH 11/43] Attempt to fix CI --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 083841bbf..945f012ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,10 @@ cache: directories: - ./node_modules +before_install: + - travis_retry sudo apt-get update + - travis_retry sudo apt-get install --no-install-recommends --no-upgrade -qq libavahi-compat-libdnssd-dev + install: - npm install From a2dff3a0a2e0e426b4aedf0d20902c1b2dc92054 Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Mon, 31 Aug 2020 20:25:27 +0200 Subject: [PATCH 12/43] restructure main.js --- .eslintrc.js | 14 +- helper/discover.js | 0 helper/listener.js | 53 ++++++ helper/styles.js | 25 +++ helper/update.js | 100 +++++++++++ main.js | 163 +---------------- package-lock.json | 423 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 8 files changed, 618 insertions(+), 161 deletions(-) create mode 100644 helper/discover.js create mode 100644 helper/listener.js create mode 100644 helper/styles.js create mode 100644 helper/update.js diff --git a/.eslintrc.js b/.eslintrc.js index 5b09e9579..523eca1f1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,6 +8,7 @@ module.exports = { 'plugin:import/errors', 'plugin:import/warnings', 'plugin:import/typescript', + 'node' ], parserOptions: { ecmaVersion: 2020, @@ -17,7 +18,7 @@ module.exports = { '@typescript-eslint/no-parameter-properties': 'off', '@typescript-eslint/no-use-before-define': 'off', 'import/no-unresolved': 'off', - camelcase: 'warn', + 'camelcase': 'warn', 'simple-import-sort/sort': 'warn', 'sort-imports': 'off', 'import/first': 'warn', @@ -41,6 +42,17 @@ module.exports = { }, ], }, + env: { + node: false, + typescript: true, + }, + }, + { + files: '**/*.js', + env: { + node: true, + typescript: false, + }, }, ], }; diff --git a/helper/discover.js b/helper/discover.js new file mode 100644 index 000000000..e69de29bb diff --git a/helper/listener.js b/helper/listener.js new file mode 100644 index 000000000..a45c537cf --- /dev/null +++ b/helper/listener.js @@ -0,0 +1,53 @@ +const path = require('path'); +const url = require('url'); + +const exec = require('child_process').exec; + +const sendCustomStyles = require('./styles'); +const { downloadUpdate, sendVersionInfo } = require('./update'); + +function activateScreenSleepListener(ipcMain) { + ipcMain.on('screenSleep', () => { + exec('xset dpms force standby'); + }); + + ipcMain.on('screenWakeup', () => { + exec('xset s off'); + exec('xset -dpms'); + exec('xset s noblank'); + }); +} + +function activateReloadListener(ipcMain, window) { + ipcMain.on('reload', () => { + window.loadURL( + url.format({ + pathname: path.join(__dirname, 'dist/index.html'), + protocol: 'file:', + slashes: true, + }), + ); + }); +} + +function activateAppInfoListener(ipcMain, window, app) { + ipcMain.on('appInfo', () => { + sendCustomStyles(window); + sendVersionInfo(window, app); + }); +} + +function activateUpdateListener(ipcMain, window) { + ipcMain.on('update', (_, updateInfo) => { + downloadUpdate(updateInfo, window); + }); +} + +function activateListeners(ipcMain, window, app) { + activateAppInfoListener(ipcMain, window, app); + activateScreenSleepListener(ipcMain); + activateReloadListener(ipcMain, window); + activateUpdateListener(ipcMain, window); +} + +module.exports = activateListeners; diff --git a/helper/styles.js b/helper/styles.js new file mode 100644 index 000000000..673c29709 --- /dev/null +++ b/helper/styles.js @@ -0,0 +1,25 @@ +const fs = require('fs'); +const path = require('path'); +const { app } = require('electron'); + +function sendCustomStyles(window) { + fs.readFile(path.join(app.getPath('userData'), 'custom-styles.css'), 'utf-8', (err, data) => { + if (err) { + if (err.code === 'ENOENT') { + fs.writeFile(path.join(app.getPath('userData'), 'custom-styles.css'), '', err => { + if (err) { + window.webContents.send('customStylesError', err); + } else { + window.webContents.send('customStyles', ''); + } + }); + } else { + window.webContents.send('customStylesError', err); + } + } else { + window.webContents.send('customStyles', data); + } + }); +} + +module.exports = sendCustomStyles; diff --git a/helper/update.js b/helper/update.js new file mode 100644 index 000000000..a9f4f1d10 --- /dev/null +++ b/helper/update.js @@ -0,0 +1,100 @@ +const fs = require('fs'); +const got = require('got'); +const stream = require('stream'); +const { promisify } = require('util'); +const progress = require('progress-stream'); + +const exec = require('child_process').exec; + + +function downloadUpdate(updateInfo, window) { + const downloadPath = '/tmp/octodash.deb'; + + exec('arch', (err, stdout, stderr) => { + if (err || stderr) { + window.webContents.send('updateError', { + error: err ? err : { message: stderr }, + }); + } + got(updateInfo.assetsURL) + .then(releaseFiles => { + const reducer = (accumulator, currentValue) => accumulator + currentValue; + let averageETA = []; + let downloadURL; + let packageSize; + for (let package of JSON.parse(releaseFiles.body)) { + if (package.name.includes(stdout.trim())) { + downloadURL = package.browser_download_url; + packageSize = package.size; + } + } + if (downloadURL) { + const downloadPipeline = promisify(stream.pipeline); + let downloadProgress = progress({ + length: packageSize, + time: 300, + }); + + downloadProgress.on('progress', progress => { + averageETA.push(progress.eta); + if (averageETA.length > 4) averageETA.shift(); + window.webContents.send('updateDownloadProgress', { + percentage: progress.percentage, + transferred: (progress.transferred / 100000).toFixed(1), + total: (progress.length / 1000000).toFixed(1), + remaining: (progress.remaining / 100000).toFixed(1), + eta: new Date(averageETA.reduce(reducer) * 1000).toISOString().substr(14, 5), + runtime: new Date(progress.runtime * 1000).toISOString().substr(14, 5), + delta: (progress.delta / 100000).toFixed(1), + speed: (progress.speed / 1000000).toFixed(2), + }); + }); + + try { + if (fs.existsSync(downloadPath)) fs.unlinkSync(downloadPath); + } catch { + // no need to handle this properly + } + + downloadPipeline(got.stream(downloadURL), downloadProgress, fs.createWriteStream(downloadPath)) + .catch(error => { + window.webContents.send('updateError', { + error: { + message: `Can't download package! ${error.message}.`, + }, + }); + }) + .then(() => { + window.webContents.send('updateDownloadFinished'); + exec('sudo ~/scripts/update-octodash', (err, _, stderr) => { + if (err || stderr) { + window.webContents.send('updateError', { + error: err ? err : { message: stderr }, + }); + } else { + window.webContents.send('updateInstalled'); + } + }); + }); + } else { + window.webContents.send('updateError', { + error: { + message: `Can't find matching package for architecture ${stdout}.`, + }, + }); + } + }) + .catch(error => { + error.message = `Can't load releases. ${error.message}`; + window.webContents.send('updateError', { error }); + }); + }); +} + +function sendVersionInfo(window, app) { + window.webContents.send('versionInformation', { + version: app.getVersion(), + }); +} + +module.exports = { downloadUpdate, sendVersionInfo }; diff --git a/main.js b/main.js index cee8ce0bc..e0b40c9f7 100644 --- a/main.js +++ b/main.js @@ -1,16 +1,7 @@ -/* eslint-disable no-undef */ -/* eslint-disable @typescript-eslint/no-var-requires */ const { app, BrowserWindow, ipcMain } = require('electron'); const electronStore = require('electron-store'); -const fs = require('fs'); -const got = require('got'); const path = require('path'); const url = require('url'); -const stream = require('stream'); -const { promisify } = require('util'); -const progress = require('progress-stream'); - -const exec = require('child_process').exec; const store = new electronStore(); @@ -18,6 +9,8 @@ const args = process.argv.slice(1); const big = args.some(val => val === '--big'); const dev = args.some(val => val === '--serve'); +const activateListeners = require('./helper/listener'); + app.commandLine.appendSwitch('touch-events', 'enabled'); app.allowRendererProcessReuse = true; @@ -74,163 +67,13 @@ function createWindow() { window.setFullScreen(true); } - activateAppInfoListener(); - activateScreenSleepListener(); - activateReloadListener(); - activateUpdateListener(); + activateListeners(ipcMain, window, app); window.on('closed', () => { window = null; }); } -function activateScreenSleepListener() { - ipcMain.on('screenSleep', () => { - exec('xset dpms force standby'); - }); - - ipcMain.on('screenWakeup', () => { - exec('xset s off'); - exec('xset -dpms'); - exec('xset s noblank'); - }); -} - -function activateReloadListener() { - ipcMain.on('reload', () => { - window.loadURL( - url.format({ - pathname: path.join(__dirname, 'dist/index.html'), - protocol: 'file:', - slashes: true, - }), - ); - }); -} - -function activateAppInfoListener() { - ipcMain.on('appInfo', () => { - sendCustomStyles(); - sendVersionInfo(); - }); -} - -function activateUpdateListener() { - ipcMain.on('update', (_, updateInfo) => { - downloadUpdate(updateInfo); - }); -} - -function sendCustomStyles() { - fs.readFile(path.join(app.getPath('userData'), 'custom-styles.css'), 'utf-8', (err, data) => { - if (err) { - if (err.code === 'ENOENT') { - fs.writeFile(path.join(app.getPath('userData'), 'custom-styles.css'), '', err => { - if (err) { - window.webContents.send('customStylesError', err); - } else { - window.webContents.send('customStyles', ''); - } - }); - } else { - window.webContents.send('customStylesError', err); - } - } else { - window.webContents.send('customStyles', data); - } - }); -} - -function sendVersionInfo() { - window.webContents.send('versionInformation', { - version: app.getVersion(), - }); -} - -function downloadUpdate(updateInfo) { - const downloadPath = '/tmp/octodash.deb'; - - exec('arch', (err, stdout, stderr) => { - if (err || stderr) { - window.webContents.send('updateError', { - error: err ? err : { message: stderr }, - }); - } - got(updateInfo.assetsURL) - .then(releaseFiles => { - const reducer = (accumulator, currentValue) => accumulator + currentValue; - let averageETA = []; - let downloadURL; - let packageSize; - for (let package of JSON.parse(releaseFiles.body)) { - if (package.name.includes(stdout.trim())) { - downloadURL = package.browser_download_url; - packageSize = package.size; - } - } - if (downloadURL) { - const downloadPipeline = promisify(stream.pipeline); - let downloadProgress = progress({ - length: packageSize, - time: 300, - }); - - downloadProgress.on('progress', progress => { - averageETA.push(progress.eta); - if (averageETA.length > 4) averageETA.shift(); - window.webContents.send('updateDownloadProgress', { - percentage: progress.percentage, - transferred: (progress.transferred / 100000).toFixed(1), - total: (progress.length / 1000000).toFixed(1), - remaining: (progress.remaining / 100000).toFixed(1), - eta: new Date(averageETA.reduce(reducer) * 1000).toISOString().substr(14, 5), - runtime: new Date(progress.runtime * 1000).toISOString().substr(14, 5), - delta: (progress.delta / 100000).toFixed(1), - speed: (progress.speed / 1000000).toFixed(2), - }); - }); - - try { - if (fs.existsSync(downloadPath)) fs.unlinkSync(downloadPath); - } catch { - // no need to handle this properly - } - - downloadPipeline(got.stream(downloadURL), downloadProgress, fs.createWriteStream(downloadPath)) - .catch(error => { - window.webContents.send('updateError', { - error: { - message: `Can't download package! ${error.message}.`, - }, - }); - }) - .then(() => { - window.webContents.send('updateDownloadFinished'); - exec('sudo ~/scripts/update-octodash', (err, _, stderr) => { - if (err || stderr) { - window.webContents.send('updateError', { - error: err ? err : { message: stderr }, - }); - } else { - window.webContents.send('updateInstalled'); - } - }); - }); - } else { - window.webContents.send('updateError', { - error: { - message: `Can't find matching package for architecture ${stdout}.`, - }, - }); - } - }) - .catch(error => { - error.message = `Can't load releases. ${error.message}`; - window.webContents.send('updateError', { error }); - }); - }); -} - app.on('ready', createWindow); app.on('window-all-closed', () => { diff --git a/package-lock.json b/package-lock.json index 0e804241d..9a16dea50 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3468,6 +3468,20 @@ "ast-types-flow": "0.0.7" } }, + "babel-eslint": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.1.0.tgz", + "integrity": "sha512-ifWaTHQ0ce+448CYop8AdrQiBsGrnC+bMgfyKFdi6EsPLTAWG+QfyDeM6OH+FmWnKvEq5NnBMLvlBUPKQZoDSg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.7.0", + "@babel/traverse": "^7.7.0", + "@babel/types": "^7.7.0", + "eslint-visitor-keys": "^1.0.0", + "resolve": "^1.12.0" + } + }, "babel-loader": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.1.0.tgz", @@ -6955,6 +6969,400 @@ } } }, + "eslint-config-esnext": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-esnext/-/eslint-config-esnext-4.1.0.tgz", + "integrity": "sha512-GhfVEXdqYKEIIj7j+Fw2SQdL9qyZMekgXfq6PyXM66cQw0B435ddjz3P3kxOBVihMRJ0xGYjosaveQz5Y6z0uA==", + "dev": true, + "requires": { + "babel-eslint": "^10.0.1", + "eslint": "^6.8.0", + "eslint-plugin-babel": "^5.2.1", + "eslint-plugin-import": "^2.14.0" + }, + "dependencies": { + "acorn": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", + "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", + "dev": true + }, + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "eslint": { + "version": "6.8.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", + "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "ajv": "^6.10.0", + "chalk": "^2.1.0", + "cross-spawn": "^6.0.5", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^1.4.3", + "eslint-visitor-keys": "^1.1.0", + "espree": "^6.1.2", + "esquery": "^1.0.1", + "esutils": "^2.0.2", + "file-entry-cache": "^5.0.1", + "functional-red-black-tree": "^1.0.1", + "glob-parent": "^5.0.0", + "globals": "^12.1.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "inquirer": "^7.0.0", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.14", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.3", + "progress": "^2.0.0", + "regexpp": "^2.0.1", + "semver": "^6.1.2", + "strip-ansi": "^5.2.0", + "strip-json-comments": "^3.0.1", + "table": "^5.2.3", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" + } + }, + "eslint-scope": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz", + "integrity": "sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint-utils": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", + "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.1.0" + } + }, + "espree": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz", + "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==", + "dev": true, + "requires": { + "acorn": "^7.1.1", + "acorn-jsx": "^5.2.0", + "eslint-visitor-keys": "^1.1.0" + } + }, + "globals": { + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", + "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", + "dev": true, + "requires": { + "type-fest": "^0.8.1" + } + }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, + "import-fresh": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", + "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "optionator": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "dev": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" + } + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "regexpp": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "dev": true + }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + } + } + }, + "eslint-config-node": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-node/-/eslint-config-node-4.1.0.tgz", + "integrity": "sha512-Wz17xV5O2WFG8fGdMYEBdbiL6TL7YNJSJvSX9V4sXQownewfYmoqlly7wxqLkOUv/57pq6LnnotMiQQrrPjCqQ==", + "dev": true, + "requires": { + "eslint": "^6.8.0", + "eslint-config-esnext": "^4.1.0" + }, + "dependencies": { + "acorn": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", + "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", + "dev": true + }, + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "eslint": { + "version": "6.8.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", + "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "ajv": "^6.10.0", + "chalk": "^2.1.0", + "cross-spawn": "^6.0.5", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^1.4.3", + "eslint-visitor-keys": "^1.1.0", + "espree": "^6.1.2", + "esquery": "^1.0.1", + "esutils": "^2.0.2", + "file-entry-cache": "^5.0.1", + "functional-red-black-tree": "^1.0.1", + "glob-parent": "^5.0.0", + "globals": "^12.1.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "inquirer": "^7.0.0", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.14", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.3", + "progress": "^2.0.0", + "regexpp": "^2.0.1", + "semver": "^6.1.2", + "strip-ansi": "^5.2.0", + "strip-json-comments": "^3.0.1", + "table": "^5.2.3", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" + } + }, + "eslint-scope": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz", + "integrity": "sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint-utils": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", + "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.1.0" + } + }, + "espree": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz", + "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==", + "dev": true, + "requires": { + "acorn": "^7.1.1", + "acorn-jsx": "^5.2.0", + "eslint-visitor-keys": "^1.1.0" + } + }, + "globals": { + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", + "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", + "dev": true, + "requires": { + "type-fest": "^0.8.1" + } + }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, + "import-fresh": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", + "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "optionator": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "dev": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" + } + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "regexpp": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "dev": true + }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + } + } + }, "eslint-import-resolver-node": { "version": "0.3.4", "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz", @@ -7061,6 +7469,15 @@ } } }, + "eslint-plugin-babel": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-babel/-/eslint-plugin-babel-5.3.1.tgz", + "integrity": "sha512-VsQEr6NH3dj664+EyxJwO4FCYm/00JhYb3Sk3ft8o+fpKuIfQ9TaW6uVUfvwMXHcf/lsnRIoyFPsLMyiWCSL/g==", + "dev": true, + "requires": { + "eslint-rule-composer": "^0.3.0" + } + }, "eslint-plugin-import": { "version": "2.22.0", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.0.tgz", @@ -7133,6 +7550,12 @@ "integrity": "sha512-1rf3AWiHeWNCQdAq0iXNnlccnH1UDnelGgrPbjBBHE8d2hXVtOudcmy0vTF4hri3iJ0MKz8jBhmH6lJ0ZWZLHQ==", "dev": true }, + "eslint-rule-composer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz", + "integrity": "sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==", + "dev": true + }, "eslint-scope": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", diff --git a/package.json b/package.json index f1e91929a..97248b82e 100644 --- a/package.json +++ b/package.json @@ -108,6 +108,7 @@ "electron-rebuild": "^2.0.0", "electron-reload": "^1.5.0", "eslint": "7.7.0", + "eslint-config-node": "^4.1.0", "eslint-plugin-import": "^2.22.0", "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-simple-import-sort": "^5.0.3", From 957cb03b0008f35dbe4433c69493b6a7c2c6e9df Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Mon, 31 Aug 2020 12:38:54 -0600 Subject: [PATCH 13/43] With the new changes newer node is working again --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 97248b82e..38302d7db 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "@angular/language-service": "~10.0.14", "@types/ajv": "^1.0.0", "@types/lodash": "^4.14.161", - "@types/node": "^12.12.54", + "@types/node": "^14.6.2", "@typescript-eslint/eslint-plugin": "^3.10.1", "@typescript-eslint/parser": "^3.10.1", "codelyzer": "^6.0.0", From 735f395b8f86df44a0e35cb08e0704c95baeac3e Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Mon, 31 Aug 2020 13:25:24 -0600 Subject: [PATCH 14/43] Use proper indentation --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 945f012ed..03156a093 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,8 @@ cache: - ./node_modules before_install: - - travis_retry sudo apt-get update - - travis_retry sudo apt-get install --no-install-recommends --no-upgrade -qq libavahi-compat-libdnssd-dev + - travis_retry sudo apt-get update + - travis_retry sudo apt-get install --no-install-recommends --no-upgrade -qq libavahi-compat-libdnssd-dev install: - npm install From 0e3d9a670d509a6f856cd631a4ccd03519e2437b Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Mon, 31 Aug 2020 14:55:43 -0600 Subject: [PATCH 15/43] Forgot to update package-lock with node update --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9a16dea50..cded05ecd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2449,9 +2449,9 @@ "dev": true }, "@types/node": { - "version": "12.12.54", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.54.tgz", - "integrity": "sha512-ge4xZ3vSBornVYlDnk7yZ0gK6ChHf/CHB7Gl1I0Jhah8DDnEQqBzgohYG4FX4p81TNirSETOiSyn+y1r9/IR6w==" + "version": "14.6.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.6.2.tgz", + "integrity": "sha512-onlIwbaeqvZyniGPfdw/TEhKIh79pz66L1q06WUQqJLnAb6wbjvOtepLYTGHTqzdXgBYIE3ZdmqHDGsRsbBz7A==" }, "@types/q": { "version": "1.5.4", From becd2c4a640050f402826d6e86c50b3ce7e5f2cd Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Mon, 31 Aug 2020 23:07:22 +0200 Subject: [PATCH 16/43] electron stuff finished --- .eslintrc.js | 7 +------ helper/discover.js | 35 +++++++++++++++++++++++++++++++++++ helper/listener.js | 11 +++++++++++ helper/styles.js | 3 +++ helper/update.js | 15 +++++++++------ main.js | 13 ++++--------- 6 files changed, 63 insertions(+), 21 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 523eca1f1..32c5c3570 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,7 +8,7 @@ module.exports = { 'plugin:import/errors', 'plugin:import/warnings', 'plugin:import/typescript', - 'node' + 'node', ], parserOptions: { ecmaVersion: 2020, @@ -42,16 +42,11 @@ module.exports = { }, ], }, - env: { - node: false, - typescript: true, - }, }, { files: '**/*.js', env: { node: true, - typescript: false, }, }, ], diff --git a/helper/discover.js b/helper/discover.js index e69de29bb..8ba52cc04 100644 --- a/helper/discover.js +++ b/helper/discover.js @@ -0,0 +1,35 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint-disable import/no-commonjs */ + +const mdns = require('mdns'); +const compareVersions = require('compare-versions'); + +const browser = mdns.createBrowser(mdns.tcp('octoprint')); +const minimumVersion = '1.3.5'; +let nodes = []; + +function discoverNodes(window) { + browser.on('serviceUp', service => { + nodes.push({ + id: service.interfaceIndex, + name: service.name, + version: service.txtRecord.version, + url: `${service.host.replace(/\.$/, '')}:${service.port}${service.txtRecord.path}api/`, + disable: compareVersions(minimumVersion, service.txtRecord.version) === -1, + }); + sendNodes(window); + }); + + browser.on('serviceDown', service => { + nodes = nodes.filter(node => node.id !== service.interfaceIndex); + sendNodes(window); + }); + + browser.start(); +} + +function sendNodes(window) { + window.webContents.send('discoveredNodes', nodes); +} + +module.exports = discoverNodes; diff --git a/helper/listener.js b/helper/listener.js index a45c537cf..c70d00885 100644 --- a/helper/listener.js +++ b/helper/listener.js @@ -1,3 +1,6 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint-disable import/no-commonjs */ + const path = require('path'); const url = require('url'); @@ -5,6 +8,7 @@ const exec = require('child_process').exec; const sendCustomStyles = require('./styles'); const { downloadUpdate, sendVersionInfo } = require('./update'); +const discoverNodes = require('./discover'); function activateScreenSleepListener(ipcMain) { ipcMain.on('screenSleep', () => { @@ -43,11 +47,18 @@ function activateUpdateListener(ipcMain, window) { }); } +function activateDiscoverListener(ipcMain, window) { + ipcMain.on('discover', () => { + discoverNodes(window); + }); +} + function activateListeners(ipcMain, window, app) { activateAppInfoListener(ipcMain, window, app); activateScreenSleepListener(ipcMain); activateReloadListener(ipcMain, window); activateUpdateListener(ipcMain, window); + activateDiscoverListener(ipcMain, window); } module.exports = activateListeners; diff --git a/helper/styles.js b/helper/styles.js index 673c29709..4be31c09d 100644 --- a/helper/styles.js +++ b/helper/styles.js @@ -1,3 +1,6 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint-disable import/no-commonjs */ + const fs = require('fs'); const path = require('path'); const { app } = require('electron'); diff --git a/helper/update.js b/helper/update.js index a9f4f1d10..f3d5aa776 100644 --- a/helper/update.js +++ b/helper/update.js @@ -1,3 +1,7 @@ +/* eslint-disable no-sync */ +/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint-disable import/no-commonjs */ + const fs = require('fs'); const got = require('got'); const stream = require('stream'); @@ -6,23 +10,22 @@ const progress = require('progress-stream'); const exec = require('child_process').exec; - function downloadUpdate(updateInfo, window) { const downloadPath = '/tmp/octodash.deb'; exec('arch', (err, stdout, stderr) => { if (err || stderr) { window.webContents.send('updateError', { - error: err ? err : { message: stderr }, + error: err || { message: stderr }, }); } got(updateInfo.assetsURL) .then(releaseFiles => { const reducer = (accumulator, currentValue) => accumulator + currentValue; - let averageETA = []; + const averageETA = []; let downloadURL; let packageSize; - for (let package of JSON.parse(releaseFiles.body)) { + for (const package of JSON.parse(releaseFiles.body)) { if (package.name.includes(stdout.trim())) { downloadURL = package.browser_download_url; packageSize = package.size; @@ -30,7 +33,7 @@ function downloadUpdate(updateInfo, window) { } if (downloadURL) { const downloadPipeline = promisify(stream.pipeline); - let downloadProgress = progress({ + const downloadProgress = progress({ length: packageSize, time: 300, }); @@ -69,7 +72,7 @@ function downloadUpdate(updateInfo, window) { exec('sudo ~/scripts/update-octodash', (err, _, stderr) => { if (err || stderr) { window.webContents.send('updateError', { - error: err ? err : { message: stderr }, + error: err || { message: stderr }, }); } else { window.webContents.send('updateInstalled'); diff --git a/main.js b/main.js index e0b40c9f7..e91a4be5e 100644 --- a/main.js +++ b/main.js @@ -1,10 +1,10 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint-disable import/no-commonjs */ + const { app, BrowserWindow, ipcMain } = require('electron'); -const electronStore = require('electron-store'); const path = require('path'); const url = require('url'); -const store = new electronStore(); - const args = process.argv.slice(1); const big = args.some(val => val === '--big'); const dev = args.some(val => val === '--serve'); @@ -17,11 +17,6 @@ app.allowRendererProcessReuse = true; let window; function createWindow() { - config = store.get('config'); - store.onDidChange('config', newValue => { - config = newValue; - }); - const { screen, session } = require('electron'); if (!dev) { @@ -41,7 +36,7 @@ function createWindow() { window = new BrowserWindow({ width: dev ? (big ? 1400 : 1080) : mainScreen.size.width, height: dev ? (big ? 502 : 342) : mainScreen.size.height, - frame: dev ? true : false, + frame: dev, backgroundColor: '#353b48', webPreferences: { nodeIntegration: true, From 540fc43a56b85bcbd43423e03d92144d0547046b Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Mon, 31 Aug 2020 15:11:25 -0600 Subject: [PATCH 17/43] Fix lint errors and warnings --- src/app/app.module.ts | 2 +- .../config/no-config/no-config.component.ts | 66 ++++++++++--------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 1977f0a3f..040eb3995 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -7,8 +7,8 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { FaIconLibrary, FontAwesomeModule } from '@fortawesome/angular-fontawesome'; 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 { NgxSpinnerModule } from 'ngx-spinner'; import { AppComponent } from './app.component'; import { AppRoutingModule } from './app.routing.module'; diff --git a/src/app/config/no-config/no-config.component.ts b/src/app/config/no-config/no-config.component.ts index e61f3aeec..3e30db83a 100644 --- a/src/app/config/no-config/no-config.component.ts +++ b/src/app/config/no-config/no-config.component.ts @@ -1,9 +1,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 compareVersions from 'compare-versions'; +import { ElectronService } from 'ngx-electron'; import { Config, ConfigService } from '../config.service'; @@ -23,23 +22,28 @@ export class NoConfigComponent implements OnInit { public configSaved: string; public objectvalues = Object.values; - private octoprintMinVers: string = '1.3.5'; - public octoprintNodes: any = { - 'other': { - 'display': 'Other (> ' + this.octoprintMinVers + ')', - 'name': 'other', - 'version': this.octoprintMinVers, - 'url': 'other', - 'disable': false - } + private octoprintMinVers = '1.3.5'; + public octoprintNodes = { + other: { + display: 'Other (> ' + this.octoprintMinVers + ')', + name: 'other', + version: this.octoprintMinVers, + url: 'other', + disable: false, + }, }; - public manualEntry: boolean = true; - public octoprintInstance: any = this.octoprintNodes['other']; - public octoprintApiMsg: string = ''; - public octoprintConnection: boolean = false; + public manualEntry = true; + public octoprintInstance = this.octoprintNodes['other']; + public octoprintApiMsg = ''; + public octoprintConnection = false; public octoprintConnectionError: string; - public constructor(private configService: ConfigService, private http: HttpClient, private router: Router, private _electronService: ElectronService) { + 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) { @@ -158,13 +162,13 @@ export class NoConfigComponent implements OnInit { 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/", + const 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': (compareVersions(this.octoprintMinVers, service.txtRecord.version) == -1 ? true : false) + disable: compareVersions(this.octoprintMinVers, service.txtRecord.version) == -1 ? true : false, }; this.octoprintNodes[service.host.replace(/\.$/, '').replace('.', '_')] = node; @@ -234,16 +238,18 @@ export class NoConfigComponent implements OnInit { this.page = 2; } else if (this.page > 2) { if (this.octoprintConnection === false) { - await this.testOctoprintAPI().then(res => { - this.octoprintApiMsg = ''; - if (this.octoprintInstance.name != 'other') { - this.config.printer.name = this.octoprintInstance.name; + await this.testOctoprintAPI().then(() => { + if (this.octoprintConnection === true) { + this.octoprintApiMsg = ''; + if (this.octoprintInstance.name != 'other') { + this.config.printer.name = this.octoprintInstance.name; + } else { + this.config.printer.name = ''; + } } else { - this.config.printer.name = ''; + this.octoprintApiMsg = 'API Error: ' + this.octoprintConnectionError; + this.page = 2; } - }, err => { - this.octoprintApiMsg = 'API Error: ' + this.octoprintConnectionError; - this.page = 2; }); } } From ab726d468cbb7db3cbc218c2b01d6142ad527129 Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Tue, 1 Sep 2020 00:35:14 +0200 Subject: [PATCH 18/43] finalise workflow --- .eslintrc.js | 1 - helper/discover.js | 8 +- helper/listener.js | 6 +- .../config/no-config/no-config.component.html | 156 +++++---- .../config/no-config/no-config.component.scss | 50 +++ .../config/no-config/no-config.component.ts | 318 +++++++++--------- src/app/settings/settings.component.html | 1 + src/assets/connect.svg | 1 + 8 files changed, 301 insertions(+), 240 deletions(-) create mode 100644 src/assets/connect.svg diff --git a/.eslintrc.js b/.eslintrc.js index 32c5c3570..5a45264d2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,7 +8,6 @@ module.exports = { 'plugin:import/errors', 'plugin:import/warnings', 'plugin:import/typescript', - 'node', ], parserOptions: { ecmaVersion: 2020, diff --git a/helper/discover.js b/helper/discover.js index 8ba52cc04..1276410bc 100644 --- a/helper/discover.js +++ b/helper/discover.js @@ -14,7 +14,7 @@ function discoverNodes(window) { id: service.interfaceIndex, name: service.name, version: service.txtRecord.version, - url: `${service.host.replace(/\.$/, '')}:${service.port}${service.txtRecord.path}api/`, + url: `http://${service.host.replace(/\.$/, '')}:${service.port}${service.txtRecord.path}api/`, disable: compareVersions(minimumVersion, service.txtRecord.version) === -1, }); sendNodes(window); @@ -28,8 +28,12 @@ function discoverNodes(window) { browser.start(); } +function stopDiscovery() { + browser.stop(); +} + function sendNodes(window) { window.webContents.send('discoveredNodes', nodes); } -module.exports = discoverNodes; +module.exports = { discoverNodes, stopDiscovery }; diff --git a/helper/listener.js b/helper/listener.js index c70d00885..f16fd6684 100644 --- a/helper/listener.js +++ b/helper/listener.js @@ -8,7 +8,7 @@ const exec = require('child_process').exec; const sendCustomStyles = require('./styles'); const { downloadUpdate, sendVersionInfo } = require('./update'); -const discoverNodes = require('./discover'); +const { discoverNodes, stopDiscovery } = require('./discover'); function activateScreenSleepListener(ipcMain) { ipcMain.on('screenSleep', () => { @@ -51,6 +51,10 @@ function activateDiscoverListener(ipcMain, window) { ipcMain.on('discover', () => { discoverNodes(window); }); + + ipcMain.on('stopDiscover', () => { + stopDiscovery(); + }); } function activateListeners(ipcMain, window, app) { diff --git a/src/app/config/no-config/no-config.component.html b/src/app/config/no-config/no-config.component.html index 1b333ee99..82b48d5f1 100644 --- a/src/app/config/no-config/no-config.component.html +++ b/src/app/config/no-config/no-config.component.html @@ -1,21 +1,23 @@
- - - -
- - back + +
+ + back +
- next - + +
+ next + +
@@ -41,6 +43,79 @@
+
+ + First things first: Please select your OctoPrint instance from the list below or enter the IP/URL manually. + + + +
+
+ +
+ {{ node.name }} +
+ + Version {{ node.version }}, URL: {{ node.url.replace('/api/', '') }} + +
+ +
+ searching ... +
+
enter manually
+
+
+
+ http:// + + : + +

Port 5000 for OctoPrint, Port 80 for OctoPi

+
+
+ search again +
+
+
+ +
+ + Now I need to know something about your OctoPrint setup, so I can talk to your printer. + +
+ + +
+
First, tell me some facts about your printer so I can personalize OctoDash for you. @@ -99,69 +174,6 @@
-
- - Now I need to know something about your OctoPrint setup, so I can talk to your printer. - -
- - -
-
-
- - Now I need to know something about your OctoPrint setup, so I can talk to your printer. - -
-
- - http:// - - : - -

Port 5000 for OctoPrint, Port 80 for OctoPi

-
- - -
- - {{ this.octoprintApiMsg }} - -
And now personalize me to your liking.
@@ -191,7 +203,7 @@
What plugins are you running? -
+
' + this.octoprintMinVers + ')', - name: 'other', - version: this.octoprintMinVers, - url: 'other', - disable: false, - }, - }; - public manualEntry = true; - public octoprintInstance = this.octoprintNodes['other']; - public octoprintApiMsg = ''; + public enterURLManually = false; + public octoprintNodes: OctoprintNodes; public octoprintConnection = false; public octoprintConnectionError: string; @@ -42,116 +32,22 @@ export class NoConfigComponent implements OnInit { private configService: ConfigService, private http: HttpClient, private router: Router, - private _electronService: ElectronService, + private notificationService: NotificationService, ) { + try { + this.ipc = window.require('electron').ipcRenderer; + } catch (e) { + this.notificationService.setError( + "Can't connect to backend", + 'Please restart your system. If the issue persists open an issue on GitHub.', + ); + } + 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/', - accessToken: '', - }, - printer: { - name: '', - xySpeed: 150, - zSpeed: 5, - defaultTemperatureFanSpeed: { - hotend: 200, - heatbed: 60, - fan: 100, - }, - }, - filament: { - thickness: 1.75, - density: 1.25, - feedLength: 0, - feedSpeed: 30, - feedSpeedSlow: 3, - purgeDistance: 30, - useM600: false, - }, - plugins: { - displayLayerProgress: { - enabled: true, - }, - enclosure: { - enabled: false, - ambientSensorID: null, - filament1SensorID: null, - filament2SensorID: null, - }, - filamentManager: { - enabled: true, - }, - preheatButton: { - enabled: true, - }, - printTimeGenius: { - enabled: true, - }, - psuControl: { - enabled: false, - turnOnPSUWhenExitingSleep: false, - }, - }, - octodash: { - customActions: [ - { - icon: 'home', - command: 'G28', - color: '#dcdde1', - confirm: false, - exit: true, - }, - { - icon: 'ruler-vertical', - command: 'G29', - color: '#44bd32', - confirm: false, - exit: true, - }, - { - 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, - preferPreviewWhilePrinting: false, - }, - }; + this.config = this.getDefaultConfig(); } this.config = this.configService.revertConfigForInput(this.config); } @@ -159,24 +55,25 @@ 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 => { - const 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: compareVersions(this.octoprintMinVers, service.txtRecord.version) == -1 ? true : false, - }; - - this.octoprintNodes[service.host.replace(/\.$/, '').replace('.', '_')] = node; + this.ipc.on('discoveredNodes', (_, nodes: OctoprintNodes) => { + this.octoprintNodes = nodes; }); - browser.on('serviceDown', service => { - delete this.octoprintNodes[service.host.replace(/\.$/, '').replace('.', '_')]; - }); - browser.start(); + } + + public discoverOctoprintInstances(): void { + this.ipc.send('discover'); + setTimeout(() => { + const searching = document.querySelector('.no-config__discovered-instances__searching'); + if (searching) { + searching.innerHTML = 'no instances found.'; + } + }, 5000); + } + + public setOctoprintInstance(node: OctoprintNodes): void { + this.config.octoprint.url = node.url; + this.config = this.configService.revertConfigForInput(this.config); + this.increasePage(); } public async testOctoprintAPI(): Promise { @@ -225,33 +122,12 @@ export class NoConfigComponent implements OnInit { } public async increasePage(): Promise { + if (this.page === 1) { + this.ipc.send('stopDiscover'); + } this.page += 1; - if (this.page <= 2) { - if (JSON.stringify(this.octoprintInstance) != JSON.stringify(this.octoprintNodes['other'])) { - this.config.octoprint.url = 'http://' + this.octoprintInstance['url']; - this.manualEntry = false; - } else { - this.config.octoprint.url = 'http://localhost:5000/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(() => { - if (this.octoprintConnection === true) { - this.octoprintApiMsg = ''; - if (this.octoprintInstance.name != 'other') { - this.config.printer.name = this.octoprintInstance.name; - } else { - this.config.printer.name = ''; - } - } else { - this.octoprintApiMsg = 'API Error: ' + this.octoprintConnectionError; - this.page = 2; - } - }); - } + if (this.page === 1) { + this.discoverOctoprintInstances(); } if (this.page === this.totalPages) { this.createConfig(); @@ -270,4 +146,118 @@ export class NoConfigComponent implements OnInit { public changeProgress(): void { document.getElementById('progressBar').style.width = this.page * (20 / this.totalPages) + 'vw'; } + + public getDefaultConfig(): Config { + return { + octoprint: { + url: 'http://localhost:5000/api/', + accessToken: '', + }, + printer: { + name: '', + xySpeed: 150, + zSpeed: 5, + defaultTemperatureFanSpeed: { + hotend: 200, + heatbed: 60, + fan: 100, + }, + }, + filament: { + thickness: 1.75, + density: 1.25, + feedLength: 0, + feedSpeed: 30, + feedSpeedSlow: 3, + purgeDistance: 30, + useM600: false, + }, + plugins: { + displayLayerProgress: { + enabled: true, + }, + enclosure: { + enabled: false, + ambientSensorID: null, + filament1SensorID: null, + filament2SensorID: null, + }, + filamentManager: { + enabled: true, + }, + preheatButton: { + enabled: true, + }, + printTimeGenius: { + enabled: true, + }, + psuControl: { + enabled: false, + turnOnPSUWhenExitingSleep: false, + }, + }, + octodash: { + customActions: [ + { + icon: 'home', + command: 'G28', + color: '#dcdde1', + confirm: false, + exit: true, + }, + { + icon: 'ruler-vertical', + command: 'G29', + color: '#44bd32', + confirm: false, + exit: true, + }, + { + 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, + preferPreviewWhilePrinting: false, + }, + }; + } +} + +interface OctoprintNodes { + id: number; + name: string; + version: string; + url: string; + disable: boolean; } diff --git a/src/app/settings/settings.component.html b/src/app/settings/settings.component.html index 0101548a4..1514202bd 100644 --- a/src/app/settings/settings.component.html +++ b/src/app/settings/settings.component.html @@ -650,6 +650,7 @@
  • "cubes" by artworkbean from thenounproject.com
  • "Sort" by Adrien Coquet from thenounproject.com
  • "height" by Ralf Schmitzer from thenounproject.com
  • +
  • "connect" by Sebastian Belalcazar Lareo from thenounproject.com
  • Special Thanks

    diff --git a/src/assets/connect.svg b/src/assets/connect.svg new file mode 100644 index 000000000..77bd16db7 --- /dev/null +++ b/src/assets/connect.svg @@ -0,0 +1 @@ + \ No newline at end of file From 8f91083d57292bbcc06829ad7e3a6e0ef2066cd7 Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Tue, 1 Sep 2020 00:38:29 +0200 Subject: [PATCH 19/43] small bugfix --- helper/discover.js | 11 ++++++----- main.js | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/helper/discover.js b/helper/discover.js index 1276410bc..15996bf64 100644 --- a/helper/discover.js +++ b/helper/discover.js @@ -4,12 +4,13 @@ const mdns = require('mdns'); const compareVersions = require('compare-versions'); -const browser = mdns.createBrowser(mdns.tcp('octoprint')); const minimumVersion = '1.3.5'; +let mdnsBrowser; let nodes = []; function discoverNodes(window) { - browser.on('serviceUp', service => { + mdnsBrowser = mdns.createBrowser(mdns.tcp('octoprint')); + mdnsBrowser.on('serviceUp', service => { nodes.push({ id: service.interfaceIndex, name: service.name, @@ -20,16 +21,16 @@ function discoverNodes(window) { sendNodes(window); }); - browser.on('serviceDown', service => { + mdnsBrowser.on('serviceDown', service => { nodes = nodes.filter(node => node.id !== service.interfaceIndex); sendNodes(window); }); - browser.start(); + mdnsBrowser.start(); } function stopDiscovery() { - browser.stop(); + mdnsBrowser.stop(); } function sendNodes(window) { diff --git a/main.js b/main.js index e91a4be5e..c217fd37e 100644 --- a/main.js +++ b/main.js @@ -34,7 +34,7 @@ function createWindow() { const mainScreen = screen.getPrimaryDisplay(); window = new BrowserWindow({ - width: dev ? (big ? 1400 : 1080) : mainScreen.size.width, + width: dev ? (big ? 1360 : 1080) : mainScreen.size.width, height: dev ? (big ? 502 : 342) : mainScreen.size.height, frame: dev, backgroundColor: '#353b48', From e2f64d2ba82d9565897d1b99462baca75652e390 Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Tue, 1 Sep 2020 00:41:24 +0200 Subject: [PATCH 20/43] prevent the same instance showing multiple times --- helper/discover.js | 1 + src/app/config/no-config/no-config.component.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/helper/discover.js b/helper/discover.js index 15996bf64..762080859 100644 --- a/helper/discover.js +++ b/helper/discover.js @@ -9,6 +9,7 @@ let mdnsBrowser; let nodes = []; function discoverNodes(window) { + nodes = []; mdnsBrowser = mdns.createBrowser(mdns.tcp('octoprint')); mdnsBrowser.on('serviceUp', service => { nodes.push({ diff --git a/src/app/config/no-config/no-config.component.ts b/src/app/config/no-config/no-config.component.ts index 8462956d2..8b0bac2ad 100644 --- a/src/app/config/no-config/no-config.component.ts +++ b/src/app/config/no-config/no-config.component.ts @@ -61,13 +61,14 @@ export class NoConfigComponent implements OnInit { } public discoverOctoprintInstances(): void { + this.octoprintNodes = null; this.ipc.send('discover'); setTimeout(() => { const searching = document.querySelector('.no-config__discovered-instances__searching'); if (searching) { searching.innerHTML = 'no instances found.'; } - }, 5000); + }, 10000); } public setOctoprintInstance(node: OctoprintNodes): void { From 6bafeb34810a0347fee5351287bf59920a7fe371 Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Tue, 1 Sep 2020 00:56:12 +0200 Subject: [PATCH 21/43] remove node from angular app --- package.json | 1 - src/app/app.module.ts | 2 -- src/app/filament/filament.component.ts | 4 ++-- src/app/files.service.ts | 2 +- src/app/standby/standby.component.ts | 2 +- src/app/update/update.component.ts | 2 +- 6 files changed, 5 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 38302d7db..a5cbad762 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,6 @@ "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", diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 040eb3995..b7657a9bf 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -7,7 +7,6 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { FaIconLibrary, FontAwesomeModule } from '@fortawesome/angular-fontawesome'; import { fas } from '@fortawesome/free-solid-svg-icons'; import { RoundProgressModule } from 'angular-svg-round-progressbar'; -import { NgxElectronModule } from 'ngx-electron'; import { NgxSpinnerModule } from 'ngx-spinner'; import { AppComponent } from './app.component'; @@ -66,7 +65,6 @@ import { URLSafePipe } from './url.pipe'; FormsModule, FontAwesomeModule, NgxSpinnerModule, - NgxElectronModule, BrowserAnimationsModule, MatRippleModule, ], diff --git a/src/app/filament/filament.component.ts b/src/app/filament/filament.component.ts index 481dbfd13..450f1dfaf 100644 --- a/src/app/filament/filament.component.ts +++ b/src/app/filament/filament.component.ts @@ -16,8 +16,8 @@ export class FilamentComponent implements OnInit { private totalPages = 5; public page: number; - private timeout: NodeJS.Timer; - private timeout2: NodeJS.Timer; + private timeout: number; + private timeout2: number; public filamentSpools: FilamentSpoolList; public isLoadingSpools = true; diff --git a/src/app/files.service.ts b/src/app/files.service.ts index 47712af95..bcf748971 100644 --- a/src/app/files.service.ts +++ b/src/app/files.service.ts @@ -13,7 +13,7 @@ import { OctoprintFilesAPI, OctoprintFolderAPI, OctoprintFolderContentAPI } from }) export class FilesService { private httpGETRequest: Subscription; - private httpGETRequestTimeout: NodeJS.Timer; + private httpGETRequestTimeout: number; private httpPOSTRequest: Subscription; private httpDELETERequest: Subscription; diff --git a/src/app/standby/standby.component.ts b/src/app/standby/standby.component.ts index 1f38bb115..c72157873 100644 --- a/src/app/standby/standby.component.ts +++ b/src/app/standby/standby.component.ts @@ -17,7 +17,7 @@ export class StandbyComponent implements OnInit { public connecting = false; public error = ''; private connectionRetries = 3; - private displaySleepTimeout: NodeJS.Timer; + private displaySleepTimeout: number; public constructor( private configService: ConfigService, diff --git a/src/app/update/update.component.ts b/src/app/update/update.component.ts index 1043a3afb..92b43263f 100644 --- a/src/app/update/update.component.ts +++ b/src/app/update/update.component.ts @@ -14,7 +14,7 @@ export class UpdateComponent implements OnInit { // eslint-disable-next-line @typescript-eslint/no-explicit-any private ipc: any; - private installationAnimationInterval: NodeJS.Timer; + private installationAnimationInterval: number; public updateProgress: UpdateDownloadProgress = { percentage: 0, transferred: 0, From d050ae02623fd8f4dc8e757d3f838af7f08ab5f2 Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Tue, 1 Sep 2020 01:15:30 +0200 Subject: [PATCH 22/43] Manually trigger change detection --- src/app/config/no-config/no-config.component.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/config/no-config/no-config.component.ts b/src/app/config/no-config/no-config.component.ts index 8b0bac2ad..e76db2fbb 100644 --- a/src/app/config/no-config/no-config.component.ts +++ b/src/app/config/no-config/no-config.component.ts @@ -1,5 +1,5 @@ import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http'; -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { NotificationService } from 'src/app/notification/notification.service'; @@ -33,6 +33,7 @@ export class NoConfigComponent implements OnInit { private http: HttpClient, private router: Router, private notificationService: NotificationService, + private changeDetector: ChangeDetectorRef, ) { try { this.ipc = window.require('electron').ipcRenderer; @@ -57,6 +58,7 @@ export class NoConfigComponent implements OnInit { this.ipc.on('discoveredNodes', (_, nodes: OctoprintNodes) => { this.octoprintNodes = nodes; + this.changeDetector.detectChanges(); }); } From 727ad51669c4cc987660ff2f93eb5e99adfee28e Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Tue, 1 Sep 2020 01:18:01 +0200 Subject: [PATCH 23/43] Also trigger change detection for Page changes to fix bug --- src/app/config/no-config/no-config.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/config/no-config/no-config.component.ts b/src/app/config/no-config/no-config.component.ts index e76db2fbb..1ebf1caee 100644 --- a/src/app/config/no-config/no-config.component.ts +++ b/src/app/config/no-config/no-config.component.ts @@ -148,6 +148,7 @@ export class NoConfigComponent implements OnInit { public changeProgress(): void { document.getElementById('progressBar').style.width = this.page * (20 / this.totalPages) + 'vw'; + this.changeDetector.detectChanges(); } public getDefaultConfig(): Config { From ad0c41b57db0042cc518c26f0f458bf52774e5d5 Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Tue, 1 Sep 2020 18:52:34 +0200 Subject: [PATCH 24/43] intial setup to load op script --- main.js | 1 + src/app/app.component.ts | 26 +++++++++++++--- src/app/app.module.ts | 3 +- src/app/octoprint-script.service.ts | 47 +++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 src/app/octoprint-script.service.ts diff --git a/main.js b/main.js index c217fd37e..f35eef838 100644 --- a/main.js +++ b/main.js @@ -41,6 +41,7 @@ function createWindow() { webPreferences: { nodeIntegration: true, enableRemoteModule: true, + worldSafeExecuteJavaScript: true, }, icon: path.join(__dirname, 'src', 'assets', 'icon', 'icon.png'), }); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 5b9b09aa0..b9b071f8f 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,9 +1,11 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import _ from 'lodash'; 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 { @@ -19,15 +21,31 @@ declare global { templateUrl: './app.component.html', styleUrls: ['./app.component.scss'], }) -export class AppComponent { - public constructor(private service: AppService, private configService: ConfigService, private router: Router) { +export class AppComponent implements OnInit { + public constructor( + private service: AppService, + private configService: ConfigService, + private octoprintScriptService: OctoprintScriptService, + private notificationService: NotificationService, + private router: Router, + ) {} + + public ngOnInit(): void { this.initialize(); } - private initialize(): void { + private async initialize(): Promise { if (this.configService && this.configService.isInitialized()) { if (this.configService.isLoaded()) { if (this.configService.isValid()) { + try { + await this.octoprintScriptService.initialize(this.configService.getURL('')); + } catch { + this.notificationService.setError( + "Can't get OctoPrint script!", + 'Please restart your machine. If the error persists open a new issue on GitHub.', + ); + } if (this.configService.isTouchscreen()) { this.router.navigate(['/main-screen']); } else { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index b7657a9bf..c0949f2b9 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -27,6 +27,7 @@ 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'; @@ -68,7 +69,7 @@ import { URLSafePipe } from './url.pipe'; BrowserAnimationsModule, MatRippleModule, ], - providers: [AppService, ConfigService, NotificationService, PrinterService, JobService], + providers: [AppService, ConfigService, NotificationService, PrinterService, JobService, OctoprintScriptService], bootstrap: [AppComponent], schemas: [CUSTOM_ELEMENTS_SCHEMA], }) diff --git a/src/app/octoprint-script.service.ts b/src/app/octoprint-script.service.ts new file mode 100644 index 000000000..9a4109c8d --- /dev/null +++ b/src/app/octoprint-script.service.ts @@ -0,0 +1,47 @@ +import { Injectable } from '@angular/core'; + +@Injectable() +export class OctoprintScriptService { + public loaded = false; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + private OctoPrint: any; + private octoprintURL: string; + + async initialize(octoprintURL: string): Promise { + this.octoprintURL = octoprintURL.replace('api/', ''); + const octoprintStaticURL = octoprintURL.replace('/api/', '/static/'); + const scripts: string[] = [ + `${octoprintStaticURL}js/lib/jquery/jquery.min.js`, + `${octoprintStaticURL}js/lib/lodash.min.js`, + `${octoprintStaticURL}webassets/packed_client.js`, + ]; + await this.load(scripts); + } + + private load(scripts: string[]): Promise { + const promises: Promise[] = []; + scripts.forEach(script => promises.push(this.loadScript(script))); + return Promise.all(promises); + } + + private loadScript(src: string): Promise { + return new Promise((resolve, reject) => { + const script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = src; + script.onload = () => resolve(); + script.onerror = () => reject(); + document.getElementsByTagName('head')[0].appendChild(script); + }); + } + + public authenticate(accessToken: string): void { + this.OctoPrint.options.baseurl = this.octoprintURL; + this.OctoPrint.options.apikey = accessToken; + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + public getInstance(): any { + return this.OctoPrint; + } +} From dd4816fbc24bba27d539d518c0186697fb3de012 Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Tue, 1 Sep 2020 19:04:19 +0200 Subject: [PATCH 25/43] Fix ngZone issue --- src/app/app.component.ts | 8 ++++++-- src/app/config/config.service.ts | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index b9b071f8f..4b871b6cf 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, NgZone } from '@angular/core'; import { Router } from '@angular/router'; import _ from 'lodash'; @@ -28,6 +28,7 @@ export class AppComponent implements OnInit { private octoprintScriptService: OctoprintScriptService, private notificationService: NotificationService, private router: Router, + private zone: NgZone, ) {} public ngOnInit(): void { @@ -39,7 +40,10 @@ export class AppComponent implements OnInit { if (this.configService.isLoaded()) { if (this.configService.isValid()) { try { - await this.octoprintScriptService.initialize(this.configService.getURL('')); + await this.zone.run(async () => { + await this.octoprintScriptService.initialize(this.configService.getURL('')); + // this.octoprintScriptService.authenticate(this.configService.getAccessKey()); + }); } catch { this.notificationService.setError( "Can't get OctoPrint script!", diff --git a/src/app/config/config.service.ts b/src/app/config/config.service.ts index b2d971a29..4c35533a6 100644 --- a/src/app/config/config.service.ts +++ b/src/app/config/config.service.ts @@ -254,6 +254,10 @@ export class ConfigService { public showThumbnailByDefault(): boolean { return this.config.octodash.preferPreviewWhilePrinting; } + + public getAccessKey(): string { + return this.config.octoprint.accessToken; + } } interface HttpHeader { From 5824236604ff6fa45b135d3350cc1d3de4d09465 Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Tue, 1 Sep 2020 12:41:06 -0600 Subject: [PATCH 26/43] Remove ngx-electron from package-lock --- package-lock.json | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index e0af3ba8b..ff021461c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10856,21 +10856,6 @@ "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", "dev": true }, - "ngx-electron": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/ngx-electron/-/ngx-electron-2.2.0.tgz", - "integrity": "sha512-Yl7Dsnvp97k0XpIuiB54X7Ij2+zU5x0pCAYnN//VZ9tF7c6S3//OZ9dN9Et7p/zIjCV3Hg9vyw68dPJEZGk+LQ==", - "requires": { - "tslib": "^1.9.0" - }, - "dependencies": { - "tslib": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", - "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==" - } - } - }, "ngx-spinner": { "version": "10.0.1", "resolved": "https://registry.npmjs.org/ngx-spinner/-/ngx-spinner-10.0.1.tgz", From 510bf8acf9c484fe245e0572aae09516ca5f6d85 Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Tue, 1 Sep 2020 15:00:04 -0600 Subject: [PATCH 27/43] Remove electron-rebuild, postinstall script and test if the travis changes are still needed since we are no longer rebuilding --- .travis.yml | 6 +- package-lock.json | 416 ---------------------------------------------- package.json | 2 - 3 files changed, 3 insertions(+), 421 deletions(-) diff --git a/.travis.yml b/.travis.yml index 03156a093..6c51b4f5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,9 +9,9 @@ cache: directories: - ./node_modules -before_install: - - travis_retry sudo apt-get update - - travis_retry sudo apt-get install --no-install-recommends --no-upgrade -qq libavahi-compat-libdnssd-dev +#before_install: +# - travis_retry sudo apt-get update +# - travis_retry sudo apt-get install --no-install-recommends --no-upgrade -qq libavahi-compat-libdnssd-dev install: - npm install diff --git a/package-lock.json b/package-lock.json index ff021461c..794476637 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2962,12 +2962,6 @@ "integrity": "sha512-Eu9ELJWCz/c1e9gTiCY+FceWxcqzjYEbqMgtndnuSqZSUCOL73TWNK2mHfIj4Cw2E/ongOp+JISVNCmovt2KYQ==", "dev": true }, - "abbrev": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", - "dev": true - }, "accepts": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", @@ -3308,16 +3302,6 @@ "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", "dev": true }, - "are-we-there-yet": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", - "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", - "dev": true, - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, "arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", @@ -4713,12 +4697,6 @@ "q": "^1.1.2" } }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true - }, "codelyzer": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/codelyzer/-/codelyzer-6.0.0.tgz", @@ -4818,12 +4796,6 @@ "simple-swizzle": "^0.2.2" } }, - "colors": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", - "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", - "dev": true - }, "combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -5000,12 +4972,6 @@ "integrity": "sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==", "dev": true }, - "console-control-strings": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true - }, "constants-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", @@ -5858,12 +5824,6 @@ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", "dev": true }, - "delegates": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", - "dev": true - }, "depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", @@ -5892,12 +5852,6 @@ "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", "dev": true }, - "detect-libc": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", - "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", - "dev": true - }, "detect-node": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.0.4.tgz", @@ -6496,137 +6450,6 @@ } } }, - "electron-rebuild": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/electron-rebuild/-/electron-rebuild-2.0.0.tgz", - "integrity": "sha512-A+acX+oU2g1ImoEuQGfsYWOGKCq757KyMN/INSVMiNvjqzE6tmZ4/xim6Q1Rca9aRhep+QdMVwoIVsp/jq0woQ==", - "dev": true, - "requires": { - "colors": "^1.3.3", - "debug": "^4.1.1", - "detect-libc": "^1.0.3", - "fs-extra": "^8.1.0", - "node-abi": "^2.11.0", - "node-gyp": "^7.1.0", - "ora": "^3.4.0", - "spawn-rx": "^3.0.0", - "yargs": "^14.2.0" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - }, - "cli-cursor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", - "dev": true, - "requires": { - "restore-cursor": "^2.0.0" - } - }, - "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "log-symbols": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", - "integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==", - "dev": true, - "requires": { - "chalk": "^2.0.1" - } - }, - "mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", - "dev": true - }, - "onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", - "dev": true, - "requires": { - "mimic-fn": "^1.0.0" - } - }, - "ora": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/ora/-/ora-3.4.0.tgz", - "integrity": "sha512-eNwHudNbO1folBP3JsZ19v9azXWtQZjICdr3Q0TDPIaeBQ3mXLrh54wM+er0+hSp+dWKf+Z8KM58CYzEyIYxYg==", - "dev": true, - "requires": { - "chalk": "^2.4.2", - "cli-cursor": "^2.1.0", - "cli-spinners": "^2.0.0", - "log-symbols": "^2.2.0", - "strip-ansi": "^5.2.0", - "wcwidth": "^1.0.1" - } - }, - "restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", - "dev": true, - "requires": { - "onetime": "^2.0.0", - "signal-exit": "^3.0.2" - } - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - }, - "yargs": { - "version": "14.2.3", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-14.2.3.tgz", - "integrity": "sha512-ZbotRWhF+lkjijC/VhmOT9wSgyBQ7+zr13+YLkhfsSiTriYsMzkTUFP18pFhWwBeMa5gUc1MzbhrO6/VB7c9Xg==", - "dev": true, - "requires": { - "cliui": "^5.0.0", - "decamelize": "^1.2.0", - "find-up": "^3.0.0", - "get-caller-file": "^2.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^3.0.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^15.0.1" - } - }, - "yargs-parser": { - "version": "15.0.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-15.0.1.tgz", - "integrity": "sha512-0OAMV2mAZQrs3FkNpDQcBk1x5HXb8X4twADss4S0Iuk+2dGnLOE/fRHrsYm542GduMveyA77OF4wrNJuanRCWw==", - "dev": true, - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - } - } - } - }, "electron-reload": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/electron-reload/-/electron-reload-1.5.0.tgz", @@ -8490,44 +8313,6 @@ "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "dev": true }, - "gauge": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", - "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", - "dev": true, - "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - }, - "dependencies": { - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - } - } - }, "genfun": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/genfun/-/genfun-5.0.0.tgz", @@ -8744,12 +8529,6 @@ "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", "dev": true }, - "has-unicode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", - "dev": true - }, "has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", @@ -10185,12 +9964,6 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==" }, - "lodash.assign": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz", - "integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=", - "dev": true - }, "lodash.clonedeep": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", @@ -10877,23 +10650,6 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, - "node-abi": { - "version": "2.19.1", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.19.1.tgz", - "integrity": "sha512-HbtmIuByq44yhAzK7b9j/FelKlHYISKQn0mtvcBrU5QBkhoCMp5bu8Hv5AI34DcKfOAcJBcOEMwLlwO62FFu9A==", - "dev": true, - "requires": { - "semver": "^5.4.1" - }, - "dependencies": { - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - } - } - }, "node-fetch-npm": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/node-fetch-npm/-/node-fetch-npm-2.0.4.tgz", @@ -10911,86 +10667,6 @@ "integrity": "sha512-7ASaDa3pD+lJ3WvXFsxekJQelBKRpne+GOVbLbtHYdd7pFspyeuJHnWfLplGf3SwKGbfs/aYl5V/JCIaHVUKKQ==", "dev": true }, - "node-gyp": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-7.1.0.tgz", - "integrity": "sha512-rjlHQlnl1dqiDZxZYiKqQdrjias7V+81OVR5PTzZioCBtWkNdrKy06M05HLKxy/pcKikKRCabeDRoZaEc6nIjw==", - "dev": true, - "requires": { - "env-paths": "^2.2.0", - "glob": "^7.1.4", - "graceful-fs": "^4.2.3", - "nopt": "^4.0.3", - "npmlog": "^4.1.2", - "request": "^2.88.2", - "rimraf": "^2.6.3", - "semver": "^7.3.2", - "tar": "^6.0.1", - "which": "^2.0.2" - }, - "dependencies": { - "chownr": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", - "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", - "dev": true - }, - "minizlib": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", - "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", - "dev": true, - "requires": { - "minipass": "^3.0.0", - "yallist": "^4.0.0" - } - }, - "mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "dev": true - }, - "rimraf": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", - "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - }, - "semver": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", - "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", - "dev": true - }, - "tar": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.0.5.tgz", - "integrity": "sha512-0b4HOimQHj9nXNEAA7zWwMM91Zhhba3pspja6sQbgTpynOJf+bkjBnfybNYzbpLbnwXnbyB4LOREvlyXLkCHSg==", - "dev": true, - "requires": { - "chownr": "^2.0.0", - "fs-minipass": "^2.0.0", - "minipass": "^3.0.0", - "minizlib": "^2.1.1", - "mkdirp": "^1.0.3", - "yallist": "^4.0.0" - } - }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - } - } - }, "node-libs-browser": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.2.1.tgz", @@ -11051,16 +10727,6 @@ "integrity": "sha512-gsO4vjEdQaTusZAEebUWp2a5d7dF5DYoIpDG7WySnk7BuZDW+GPpHXoXXuYawRBr/9t5q54tirPz79kFIWg4dA==", "dev": true }, - "nopt": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz", - "integrity": "sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg==", - "dev": true, - "requires": { - "abbrev": "1", - "osenv": "^0.1.4" - } - }, "normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", @@ -11310,18 +10976,6 @@ "path-key": "^2.0.0" } }, - "npmlog": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", - "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", - "dev": true, - "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, "nth-check": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", @@ -11337,12 +10991,6 @@ "integrity": "sha1-b2gragJ6Tp3fpFZM0lidHU5mnt4=", "dev": true }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true - }, "oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", @@ -14549,34 +14197,6 @@ "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", "dev": true }, - "spawn-rx": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/spawn-rx/-/spawn-rx-3.0.0.tgz", - "integrity": "sha512-dw4Ryg/KMNfkKa5ezAR5aZe9wNwPdKlnHEXtHOjVnyEDSPQyOpIPPRtcIiu7127SmtHhaCjw21yC43HliW0iIg==", - "dev": true, - "requires": { - "debug": "^2.5.1", - "lodash.assign": "^4.2.0", - "rxjs": "^6.3.1" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, "spdx-correct": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", @@ -16877,42 +16497,6 @@ "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "dev": true }, - "wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", - "dev": true, - "requires": { - "string-width": "^1.0.2 || 2" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - } - } - }, "widest-line": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-3.1.0.tgz", diff --git a/package.json b/package.json index b6804c18f..cba497120 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,6 @@ } }, "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", @@ -104,7 +103,6 @@ "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.8.0", "eslint-config-node": "^4.1.0", From 11ff0b52009bc2b3f00b3921a130818491e8af65 Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Tue, 1 Sep 2020 15:08:42 -0600 Subject: [PATCH 28/43] Tested and no longer required, was a rebuild only issue --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6c51b4f5d..083841bbf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,6 @@ cache: directories: - ./node_modules -#before_install: -# - travis_retry sudo apt-get update -# - travis_retry sudo apt-get install --no-install-recommends --no-upgrade -qq libavahi-compat-libdnssd-dev - install: - npm install From beabf321fbf744ee6f385e4977097725cfff458a Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Thu, 3 Sep 2020 00:08:36 +0200 Subject: [PATCH 29/43] fix OctoPrint var --- src/app/app.component.ts | 4 ++-- src/app/octoprint-script.service.ts | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 4b871b6cf..30f674503 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, NgZone } from '@angular/core'; +import { Component, NgZone, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import _ from 'lodash'; @@ -42,7 +42,7 @@ export class AppComponent implements OnInit { try { await this.zone.run(async () => { await this.octoprintScriptService.initialize(this.configService.getURL('')); - // this.octoprintScriptService.authenticate(this.configService.getAccessKey()); + this.octoprintScriptService.authenticate(this.configService.getAccessKey()); }); } catch { this.notificationService.setError( diff --git a/src/app/octoprint-script.service.ts b/src/app/octoprint-script.service.ts index 9a4109c8d..7c03dcf4d 100644 --- a/src/app/octoprint-script.service.ts +++ b/src/app/octoprint-script.service.ts @@ -1,10 +1,11 @@ import { Injectable } from '@angular/core'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +declare const OctoPrint: any; + @Injectable() export class OctoprintScriptService { public loaded = false; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - private OctoPrint: any; private octoprintURL: string; async initialize(octoprintURL: string): Promise { @@ -36,12 +37,12 @@ export class OctoprintScriptService { } public authenticate(accessToken: string): void { - this.OctoPrint.options.baseurl = this.octoprintURL; - this.OctoPrint.options.apikey = accessToken; + OctoPrint.options.baseurl = this.octoprintURL; + OctoPrint.options.apikey = accessToken; } // eslint-disable-next-line @typescript-eslint/no-explicit-any public getInstance(): any { - return this.OctoPrint; + return OctoPrint; } } From ae5a08737de22a8546607afa112d842edfd67289 Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Thu, 3 Sep 2020 01:06:07 +0200 Subject: [PATCH 30/43] finally get that freakin jQuery working not pretty, but it works --- angular.json | 41 +-- package-lock.json | 428 +--------------------------- package.json | 1 + src/app/octoprint-script.service.ts | 7 +- src/index.html | 4 + src/styles.scss | 14 +- tsconfig.json | 40 ++- 7 files changed, 50 insertions(+), 485 deletions(-) diff --git a/angular.json b/angular.json index 9dab8de8d..47afd9657 100644 --- a/angular.json +++ b/angular.json @@ -3,7 +3,7 @@ "version": 1, "newProjectRoot": "projects", "projects": { - "OctoPrintDash": { + "OctoDash": { "projectType": "application", "schematics": { "@schematics/angular:component": { @@ -18,6 +18,7 @@ "builder": "@angular-devkit/build-angular:browser", "options": { "aot": true, + "allowedCommonJsDependencies": ["angular-svg-round-progressbar"], "outputPath": "dist", "index": "src/index.html", "main": "src/main.ts", @@ -40,9 +41,7 @@ "output": "/" } ], - "styles": [ - "src/styles.scss" - ], + "styles": ["src/styles.scss"], "scripts": [] }, "configurations": { @@ -79,18 +78,18 @@ "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { - "browserTarget": "OctoPrintDash:build" + "browserTarget": "OctoDash:build" }, "configurations": { "production": { - "browserTarget": "OctoPrintDash:build:production" + "browserTarget": "OctoDash:build:production" } } }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { - "browserTarget": "OctoPrintDash:build" + "browserTarget": "OctoDash:build" } }, "test": { @@ -100,47 +99,35 @@ "polyfills": "src/polyfills.ts", "tsConfig": "tsconfig.spec.json", "karmaConfig": "karma.conf.js", - "assets": [ - "src/favicon.ico", - "src/assets", - "src/assets/icon/icon-main-title.svg" - ], - "styles": [ - "src/styles.scss" - ], + "assets": ["src/favicon.ico", "src/assets", "src/assets/icon/icon-main-title.svg"], + "styles": ["src/styles.scss"], "scripts": [] } }, "lint": { "builder": "@angular-devkit/build-angular:tslint", "options": { - "tsConfig": [ - "tsconfig.app.json", - "tsconfig.spec.json", - "tsconfig.json" - ], - "exclude": [ - "**/node_modules/**" - ] + "tsConfig": ["tsconfig.app.json", "tsconfig.spec.json", "tsconfig.json"], + "exclude": ["**/node_modules/**"] } }, "e2e": { "builder": "@angular-devkit/build-angular:protractor", "options": { "protractorConfig": "e2e/protractor.conf.js", - "devServerTarget": "OctoPrintDash:serve" + "devServerTarget": "OctoDash:serve" }, "configurations": { "production": { - "devServerTarget": "OctoPrintDash:serve:production" + "devServerTarget": "OctoDash:serve:production" } } } } } }, - "defaultProject": "OctoPrintDash", + "defaultProject": "OctoDash", "cli": { "analytics": "e1569209-2b82-4195-9c15-0669a78feccb" } -} \ No newline at end of file +} diff --git a/package-lock.json b/package-lock.json index 24b079744..63ef78aad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3612,20 +3612,6 @@ "ast-types-flow": "0.0.7" } }, - "babel-eslint": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.1.0.tgz", - "integrity": "sha512-ifWaTHQ0ce+448CYop8AdrQiBsGrnC+bMgfyKFdi6EsPLTAWG+QfyDeM6OH+FmWnKvEq5NnBMLvlBUPKQZoDSg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.7.0", - "@babel/traverse": "^7.7.0", - "@babel/types": "^7.7.0", - "eslint-visitor-keys": "^1.0.0", - "resolve": "^1.12.0" - } - }, "babel-loader": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.1.0.tgz", @@ -6953,400 +6939,6 @@ } } }, - "eslint-config-esnext": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/eslint-config-esnext/-/eslint-config-esnext-4.1.0.tgz", - "integrity": "sha512-GhfVEXdqYKEIIj7j+Fw2SQdL9qyZMekgXfq6PyXM66cQw0B435ddjz3P3kxOBVihMRJ0xGYjosaveQz5Y6z0uA==", - "dev": true, - "requires": { - "babel-eslint": "^10.0.1", - "eslint": "^6.8.0", - "eslint-plugin-babel": "^5.2.1", - "eslint-plugin-import": "^2.14.0" - }, - "dependencies": { - "acorn": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", - "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", - "dev": true - }, - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - }, - "eslint": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", - "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "ajv": "^6.10.0", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", - "debug": "^4.0.1", - "doctrine": "^3.0.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^1.4.3", - "eslint-visitor-keys": "^1.1.0", - "espree": "^6.1.2", - "esquery": "^1.0.1", - "esutils": "^2.0.2", - "file-entry-cache": "^5.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^5.0.0", - "globals": "^12.1.0", - "ignore": "^4.0.6", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "inquirer": "^7.0.0", - "is-glob": "^4.0.0", - "js-yaml": "^3.13.1", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.14", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", - "natural-compare": "^1.4.0", - "optionator": "^0.8.3", - "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^6.1.2", - "strip-ansi": "^5.2.0", - "strip-json-comments": "^3.0.1", - "table": "^5.2.3", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" - } - }, - "eslint-scope": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz", - "integrity": "sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==", - "dev": true, - "requires": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" - } - }, - "eslint-utils": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", - "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^1.1.0" - } - }, - "espree": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz", - "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==", - "dev": true, - "requires": { - "acorn": "^7.1.1", - "acorn-jsx": "^5.2.0", - "eslint-visitor-keys": "^1.1.0" - } - }, - "globals": { - "version": "12.4.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", - "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", - "dev": true, - "requires": { - "type-fest": "^0.8.1" - } - }, - "ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true - }, - "import-fresh": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", - "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", - "dev": true, - "requires": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - } - }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - } - }, - "optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "dev": true, - "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - } - }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "dev": true - }, - "regexpp": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", - "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", - "dev": true - }, - "resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - }, - "strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true - }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2" - } - }, - "type-fest": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", - "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", - "dev": true - } - } - }, - "eslint-config-node": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/eslint-config-node/-/eslint-config-node-4.1.0.tgz", - "integrity": "sha512-Wz17xV5O2WFG8fGdMYEBdbiL6TL7YNJSJvSX9V4sXQownewfYmoqlly7wxqLkOUv/57pq6LnnotMiQQrrPjCqQ==", - "dev": true, - "requires": { - "eslint": "^6.8.0", - "eslint-config-esnext": "^4.1.0" - }, - "dependencies": { - "acorn": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", - "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", - "dev": true - }, - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - }, - "eslint": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", - "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "ajv": "^6.10.0", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", - "debug": "^4.0.1", - "doctrine": "^3.0.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^1.4.3", - "eslint-visitor-keys": "^1.1.0", - "espree": "^6.1.2", - "esquery": "^1.0.1", - "esutils": "^2.0.2", - "file-entry-cache": "^5.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^5.0.0", - "globals": "^12.1.0", - "ignore": "^4.0.6", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "inquirer": "^7.0.0", - "is-glob": "^4.0.0", - "js-yaml": "^3.13.1", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.14", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", - "natural-compare": "^1.4.0", - "optionator": "^0.8.3", - "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^6.1.2", - "strip-ansi": "^5.2.0", - "strip-json-comments": "^3.0.1", - "table": "^5.2.3", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" - } - }, - "eslint-scope": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz", - "integrity": "sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==", - "dev": true, - "requires": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" - } - }, - "eslint-utils": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", - "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^1.1.0" - } - }, - "espree": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz", - "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==", - "dev": true, - "requires": { - "acorn": "^7.1.1", - "acorn-jsx": "^5.2.0", - "eslint-visitor-keys": "^1.1.0" - } - }, - "globals": { - "version": "12.4.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", - "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", - "dev": true, - "requires": { - "type-fest": "^0.8.1" - } - }, - "ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true - }, - "import-fresh": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", - "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", - "dev": true, - "requires": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - } - }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - } - }, - "optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "dev": true, - "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - } - }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "dev": true - }, - "regexpp": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", - "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", - "dev": true - }, - "resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - }, - "strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true - }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2" - } - }, - "type-fest": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", - "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", - "dev": true - } - } - }, "eslint-import-resolver-node": { "version": "0.3.4", "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz", @@ -7453,15 +7045,6 @@ } } }, - "eslint-plugin-babel": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-babel/-/eslint-plugin-babel-5.3.1.tgz", - "integrity": "sha512-VsQEr6NH3dj664+EyxJwO4FCYm/00JhYb3Sk3ft8o+fpKuIfQ9TaW6uVUfvwMXHcf/lsnRIoyFPsLMyiWCSL/g==", - "dev": true, - "requires": { - "eslint-rule-composer": "^0.3.0" - } - }, "eslint-plugin-import": { "version": "2.22.0", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.0.tgz", @@ -7534,12 +7117,6 @@ "integrity": "sha512-1rf3AWiHeWNCQdAq0iXNnlccnH1UDnelGgrPbjBBHE8d2hXVtOudcmy0vTF4hri3iJ0MKz8jBhmH6lJ0ZWZLHQ==", "dev": true }, - "eslint-rule-composer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz", - "integrity": "sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==", - "dev": true - }, "eslint-scope": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", @@ -9676,6 +9253,11 @@ "@hapi/topo": "^5.0.0" } }, + "jquery": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz", + "integrity": "sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==" + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", diff --git a/package.json b/package.json index 6b0c8e1dc..2fc050104 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,7 @@ "compare-versions": "^3.6.0", "electron-store": "^6.0.0", "got": "^11.5.2", + "jquery": "^3.5.1", "lodash": "^4.17.20", "mdns": "^2.5.1", "ngx-spinner": "^10.0.1", diff --git a/src/app/octoprint-script.service.ts b/src/app/octoprint-script.service.ts index 7c03dcf4d..31355d7d2 100644 --- a/src/app/octoprint-script.service.ts +++ b/src/app/octoprint-script.service.ts @@ -1,5 +1,4 @@ import { Injectable } from '@angular/core'; - // eslint-disable-next-line @typescript-eslint/no-explicit-any declare const OctoPrint: any; @@ -11,11 +10,7 @@ export class OctoprintScriptService { async initialize(octoprintURL: string): Promise { this.octoprintURL = octoprintURL.replace('api/', ''); const octoprintStaticURL = octoprintURL.replace('/api/', '/static/'); - const scripts: string[] = [ - `${octoprintStaticURL}js/lib/jquery/jquery.min.js`, - `${octoprintStaticURL}js/lib/lodash.min.js`, - `${octoprintStaticURL}webassets/packed_client.js`, - ]; + const scripts: string[] = [`${octoprintStaticURL}webassets/packed_client.js`]; await this.load(scripts); } diff --git a/src/index.html b/src/index.html index 7d0b73096..3c1c8de4f 100644 --- a/src/index.html +++ b/src/index.html @@ -12,6 +12,10 @@ rel="stylesheet" /> + diff --git a/src/styles.scss b/src/styles.scss index 57d4d745b..a5cff5936 100755 --- a/src/styles.scss +++ b/src/styles.scss @@ -1,17 +1,17 @@ // Custom Theming for Angular Material // For more information: https://material.angular.io/guide/theming -@import "~@angular/material/theming"; +@import '~@angular/material/theming'; @include mat-core(); // TODO: needed for ripple effect, need to check why -$OctoPrintDash-primary: mat-palette($mat-indigo); -$OctoPrintDash-accent: mat-palette($mat-pink, A200, A100, A400); -$OctoPrintDash-warn: mat-palette($mat-red); -$OctoPrintDash-theme: mat-dark-theme($OctoPrintDash-primary, $OctoPrintDash-accent, $OctoPrintDash-warn); -@include angular-material-theme($OctoPrintDash-theme); +$OctoDash-primary: mat-palette($mat-indigo); +$OctoDash-accent: mat-palette($mat-pink, A200, A100, A400); +$OctoDash-warn: mat-palette($mat-red); +$OctoDash-theme: mat-dark-theme($OctoDash-primary, $OctoDash-accent, $OctoDash-warn); +@include angular-material-theme($OctoDash-theme); *:not(path):not(svg) { - font-family: "Montserrat", sans-serif; + font-family: 'Montserrat', sans-serif; color: #f5f6fa; font-size: 4.3vw; margin: 0; diff --git a/tsconfig.json b/tsconfig.json index ae257c4d3..15a604cb1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,24 +1,20 @@ { - "compileOnSave": false, - "compilerOptions": { - "baseUrl": "./", - "outDir": "./dist", - "sourceMap": true, - "declaration": false, - "module": "esnext", - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "importHelpers": true, - "target": "ESNext", - "typeRoots": [ - "node_modules/@types" - ], - "types": [], - "lib": ["es2018", "dom"], - "esModuleInterop": true - }, - "exclude": [ - "**/node_modules/**" - ] + "compileOnSave": false, + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist", + "sourceMap": true, + "declaration": false, + "module": "ESNEXT", + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "importHelpers": true, + "target": "ES2015", + "typeRoots": ["node_modules/@types"], + "types": [], + "lib": ["ESNEXT", "dom"], + "esModuleInterop": true + }, + "exclude": ["**/node_modules/**"] } From 5f7fe8682793105db3d67a71244318f309d5faae Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Thu, 3 Sep 2020 01:24:35 +0200 Subject: [PATCH 31/43] cleanup + reset URL if manual input is opened. --- main.js | 5 ++--- package.json | 1 - src/app/config/no-config/no-config.component.html | 8 ++++---- src/app/config/no-config/no-config.component.ts | 10 +++++++++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/main.js b/main.js index f35eef838..7f9906bb4 100644 --- a/main.js +++ b/main.js @@ -42,14 +42,13 @@ function createWindow() { nodeIntegration: true, enableRemoteModule: true, worldSafeExecuteJavaScript: true, + // TODO: enable + contextBridge (probably electron-ngx before release 12) + contextIsolation: false, }, icon: path.join(__dirname, 'src', 'assets', 'icon', 'icon.png'), }); if (dev) { - require('electron-reload')(__dirname, { - electron: require(`${__dirname}/node_modules/electron`), - }); window.loadURL('http://localhost:4200'); window.webContents.openDevTools(); } else { diff --git a/package.json b/package.json index 2fc050104..ae83e1273 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,6 @@ "codelyzer": "^6.0.0", "electron": "^10.1.1", "electron-builder": "^22.8.0", - "electron-reload": "^1.5.0", "eslint": "7.8.1", "eslint-plugin-import": "^2.22.0", "eslint-plugin-prettier": "^3.1.4", diff --git a/src/app/config/no-config/no-config.component.html b/src/app/config/no-config/no-config.component.html index 82b48d5f1..1fed10928 100644 --- a/src/app/config/no-config/no-config.component.html +++ b/src/app/config/no-config/no-config.component.html @@ -49,7 +49,7 @@ -

    +
    searching ...
    -
    enter manually
    +
    enter manually
    -
    +
    http://

    Port 5000 for OctoPrint, Port 80 for OctoPi

    -
    +
    search again
    diff --git a/src/app/config/no-config/no-config.component.ts b/src/app/config/no-config/no-config.component.ts index 1ebf1caee..89ade35b2 100644 --- a/src/app/config/no-config/no-config.component.ts +++ b/src/app/config/no-config/no-config.component.ts @@ -23,7 +23,7 @@ export class NoConfigComponent implements OnInit { public configValid: boolean; public configSaved: string; - public enterURLManually = false; + public manualURL = false; public octoprintNodes: OctoprintNodes; public octoprintConnection = false; public octoprintConnectionError: string; @@ -79,6 +79,14 @@ export class NoConfigComponent implements OnInit { this.increasePage(); } + public enterURLManually(): void { + this.config.octoprint.urlSplit = { + url: 'localhost', + port: 5000, + }; + this.manualURL = true; + } + public async testOctoprintAPI(): Promise { const httpHeaders = { headers: new HttpHeaders({ From 2a62ccb0cd4e437f0aab1c1024cd06ac51419a68 Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Thu, 3 Sep 2020 01:56:50 +0200 Subject: [PATCH 32/43] Check OctoPrint connection and load client library --- .../config/no-config/no-config.component.html | 4 ++- .../config/no-config/no-config.component.ts | 28 +++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/app/config/no-config/no-config.component.html b/src/app/config/no-config/no-config.component.html index 1fed10928..82f07aa6a 100644 --- a/src/app/config/no-config/no-config.component.html +++ b/src/app/config/no-config/no-config.component.html @@ -101,8 +101,10 @@
    - Now I need to know something about your OctoPrint setup, so I can talk to your printer. + Please authenticate me now. You can either click the button below and confirm the request in your OctoPrint + webinterface or enter an API Key manually. + DO IT
    { + await this.octoprintScriptService.initialize( + `http://${this.config.octoprint.urlSplit.url}:${this.config.octoprint.urlSplit.port}/api/`, + ); + }); + } catch (e) { + this.notificationService.setError( + "Can't connect to OctoPrint!", + `Check the URL/IP and make sure that your firewall allows access to port ${this.config.octoprint.urlSplit.port} on host ${this.config.octoprint.urlSplit.url}.`, + ); + this.decreasePage(); + } + } + public async testOctoprintAPI(): Promise { const httpHeaders = { headers: new HttpHeaders({ @@ -132,9 +155,10 @@ export class NoConfigComponent implements OnInit { this.router.navigate(['/main-screen']); } - public async increasePage(): Promise { + public increasePage(): void { if (this.page === 1) { this.ipc.send('stopDiscover'); + this.loadOctoprintClient(); } this.page += 1; if (this.page === 1) { From dbc7db98ff1fee569de537ac4eaaacc74b16146c Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Wed, 2 Sep 2020 19:50:59 -0600 Subject: [PATCH 33/43] Update package-lock, fix a few navigation bugs --- package-lock.json | 9 --------- src/app/config/no-config/no-config.component.html | 4 ++-- src/app/config/no-config/no-config.component.ts | 15 +++++++++++---- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 63ef78aad..58f54f33a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6463,15 +6463,6 @@ } } }, - "electron-reload": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/electron-reload/-/electron-reload-1.5.0.tgz", - "integrity": "sha512-L9X6LzsL3Bt2j0eJ4/MBrI9Vt902KvVUtBB7J4qrL1A9sXqC2fE0lpvUAlOThpJYh6zWO1l86U/YiEN9bDURHw==", - "dev": true, - "requires": { - "chokidar": "^3.0.2" - } - }, "electron-store": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/electron-store/-/electron-store-6.0.0.tgz", diff --git a/src/app/config/no-config/no-config.component.html b/src/app/config/no-config/no-config.component.html index 82f07aa6a..c5ccc4244 100644 --- a/src/app/config/no-config/no-config.component.html +++ b/src/app/config/no-config/no-config.component.html @@ -2,7 +2,7 @@
    -
    +
    back
    @@ -13,7 +13,7 @@
    -
    +
    next
    diff --git a/src/app/config/no-config/no-config.component.ts b/src/app/config/no-config/no-config.component.ts index c33382033..15b18e15a 100644 --- a/src/app/config/no-config/no-config.component.ts +++ b/src/app/config/no-config/no-config.component.ts @@ -83,7 +83,7 @@ export class NoConfigComponent implements OnInit { public setOctoprintInstance(node: OctoprintNodes): void { this.config.octoprint.url = node.url; this.config = this.configService.revertConfigForInput(this.config); - this.increasePage(); + this.increasePage(true); } public enterURLManually(): void { @@ -106,7 +106,7 @@ export class NoConfigComponent implements OnInit { "Can't connect to OctoPrint!", `Check the URL/IP and make sure that your firewall allows access to port ${this.config.octoprint.urlSplit.port} on host ${this.config.octoprint.urlSplit.url}.`, ); - this.decreasePage(); + this.page = 1; } } @@ -155,7 +155,10 @@ export class NoConfigComponent implements OnInit { this.router.navigate(['/main-screen']); } - public increasePage(): void { + public increasePage(force = false): void { + if (this.page === this.totalPages || (!this.manualURL && this.page === 1 && force === false)) { + return; + } if (this.page === 1) { this.ipc.send('stopDiscover'); this.loadOctoprintClient(); @@ -171,7 +174,11 @@ export class NoConfigComponent implements OnInit { } public decreasePage(): void { - if (this.page == this.totalPages - 1) { +console.log(this.page); + if (this.page === 0) { + return; + } + if (this.page === this.totalPages - 1) { this.config = this.configService.revertConfigForInput(this.config); } this.page -= 1; From 4df9b9937a9e23987e4c58841b073c6ed4c9a0bf Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Wed, 2 Sep 2020 19:57:01 -0600 Subject: [PATCH 34/43] Make sure pages can't go below 0 or above totalPages --- src/app/config/no-config/no-config.component.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/config/no-config/no-config.component.ts b/src/app/config/no-config/no-config.component.ts index 15b18e15a..109190311 100644 --- a/src/app/config/no-config/no-config.component.ts +++ b/src/app/config/no-config/no-config.component.ts @@ -156,7 +156,10 @@ export class NoConfigComponent implements OnInit { } public increasePage(force = false): void { - if (this.page === this.totalPages || (!this.manualURL && this.page === 1 && force === false)) { + if (this.page >= this.totalPages || (!this.manualURL && this.page === 1 && force === false)) { + if (this.page > this.totalPages) { + this.page = this.totalPages; + } return; } if (this.page === 1) { @@ -174,8 +177,8 @@ export class NoConfigComponent implements OnInit { } public decreasePage(): void { -console.log(this.page); - if (this.page === 0) { + if (this.page <= 0) { + this.page = 0; return; } if (this.page === this.totalPages - 1) { From a913bd3f473252140b251583a770e6e3e38d564d Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Fri, 4 Sep 2020 18:06:11 +0200 Subject: [PATCH 35/43] refactor navigation controller + show next button after page 1 again --- .../config/no-config/no-config.component.html | 12 ++-- .../config/no-config/no-config.component.ts | 63 +++++++++++-------- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/src/app/config/no-config/no-config.component.html b/src/app/config/no-config/no-config.component.html index c5ccc4244..3f28dd606 100644 --- a/src/app/config/no-config/no-config.component.html +++ b/src/app/config/no-config/no-config.component.html @@ -1,8 +1,8 @@
    - -
    -
    +
    +
    back
    @@ -12,14 +12,15 @@
    -
    +
    +
    next
    +
    Hey there! @@ -43,12 +44,11 @@
    +
    First things first: Please select your OctoPrint instance from the list below or enter the IP/URL manually. - -
    = this.totalPages || (!this.manualURL && this.page === 1 && force === false)) { - if (this.page > this.totalPages) { - this.page = this.totalPages; - } + private changePage(value: number): void { + if (this.page + value > this.totalPages || this.page + value < 0) { return; } - if (this.page === 1) { - this.ipc.send('stopDiscover'); - this.loadOctoprintClient(); - } - this.page += 1; - if (this.page === 1) { - this.discoverOctoprintInstances(); - } - if (this.page === this.totalPages) { - this.createConfig(); - } + this.beforeNavigation(value); + this.page = this.page + value; + this.afterNavigation(); this.changeProgress(); + console.log(this.page); } - public decreasePage(): void { - if (this.page <= 0) { - this.page = 0; - return; + private beforeNavigation(value: number): void { + switch (this.page) { + case 1: + this.ipc.send('stopDiscover'); + if (value > 0) { + this.loadOctoprintClient(); + } + break; + case this.totalPages - 1: + if (value < 0) { + this.config = this.configService.revertConfigForInput(this.config); + } + break; } - if (this.page === this.totalPages - 1) { - this.config = this.configService.revertConfigForInput(this.config); + } + + private afterNavigation(): void { + switch (this.page) { + case 1: + this.discoverOctoprintInstances(); + break; + case this.totalPages: + this.createConfig; + break; } - this.page -= 1; - this.changeProgress(); + } + + public increasePage(): void { + this.changePage(1); + } + + public decreasePage(): void { + this.changePage(-1); } public changeProgress(): void { From 77bafa924ef76e9a2df6849cde229f1697a0dfdb Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Fri, 4 Sep 2020 18:46:51 +0200 Subject: [PATCH 36/43] login with request working --- .../config/no-config/no-config.component.html | 4 ++- .../config/no-config/no-config.component.scss | 5 +++ .../config/no-config/no-config.component.ts | 34 +++++++++++++++++-- .../notification/notification.component.ts | 5 +-- src/app/notification/notification.service.ts | 4 +++ src/app/octoprint-script.service.ts | 2 +- 6 files changed, 48 insertions(+), 6 deletions(-) diff --git a/src/app/config/no-config/no-config.component.html b/src/app/config/no-config/no-config.component.html index 3f28dd606..3ef94e915 100644 --- a/src/app/config/no-config/no-config.component.html +++ b/src/app/config/no-config/no-config.component.html @@ -104,7 +104,9 @@ Please authenticate me now. You can either click the button below and confirm the request in your OctoPrint webinterface or enter an API Key manually. - DO IT + { + this.notificationService.closeNotification(); + }, 3000); + + this.OctoPrint.plugins.appkeys + .authenticate('OctoDash') + .done((apiKey: string) => { + this.config.octoprint.accessToken = apiKey; + this.changeDetector.detectChanges(); + setTimeout(() => { + this.increasePage(); + }, 600); + }) + .fail(() => { + this.notificationService.setWarning( + 'Something went wrong!', + "Can' retrieve the API Key, please try again or create one manually and enter it down below.", + ); + }) + .always(() => { + clearTimeout(closeInfo); + }); + } + public async testOctoprintAPI(): Promise { const httpHeaders = { headers: new HttpHeaders({ @@ -163,7 +194,6 @@ export class NoConfigComponent implements OnInit { this.page = this.page + value; this.afterNavigation(); this.changeProgress(); - console.log(this.page); } private beforeNavigation(value: number): void { diff --git a/src/app/notification/notification.component.ts b/src/app/notification/notification.component.ts index e7d6e77cd..8c8f84ffd 100644 --- a/src/app/notification/notification.component.ts +++ b/src/app/notification/notification.component.ts @@ -1,4 +1,4 @@ -import { Component, OnDestroy } from '@angular/core'; +import { ChangeDetectorRef, Component, OnDestroy } from '@angular/core'; import { Subscription } from 'rxjs'; import { Notification, NotificationService } from './notification.service'; @@ -18,7 +18,7 @@ export class NotificationComponent implements OnDestroy { }; public show = false; - public constructor(private notificationService: NotificationService) { + public constructor(private notificationService: NotificationService, private changeDetector: ChangeDetectorRef) { this.subscriptions.add( this.notificationService .getObservable() @@ -37,6 +37,7 @@ export class NotificationComponent implements OnDestroy { this.notification = notification; this.show = true; } + this.changeDetector.detectChanges(); } public ngOnDestroy(): void { diff --git a/src/app/notification/notification.service.ts b/src/app/notification/notification.service.ts index d7fa69af8..a103452b6 100644 --- a/src/app/notification/notification.service.ts +++ b/src/app/notification/notification.service.ts @@ -32,6 +32,10 @@ export class NotificationService { this.observer.next('close'); } + public closeNotification(): void { + this.observer.next('close'); + } + public setError(heading: string, text: string): void { if ((!this.hideNotifications && !this.bootGrace) || (this.bootGrace && !text.endsWith('0 Unknown Error'))) { if (this.observer) { diff --git a/src/app/octoprint-script.service.ts b/src/app/octoprint-script.service.ts index 31355d7d2..84d31feec 100644 --- a/src/app/octoprint-script.service.ts +++ b/src/app/octoprint-script.service.ts @@ -12,6 +12,7 @@ export class OctoprintScriptService { const octoprintStaticURL = octoprintURL.replace('/api/', '/static/'); const scripts: string[] = [`${octoprintStaticURL}webassets/packed_client.js`]; await this.load(scripts); + OctoPrint.options.baseurl = this.octoprintURL; } private load(scripts: string[]): Promise { @@ -32,7 +33,6 @@ export class OctoprintScriptService { } public authenticate(accessToken: string): void { - OctoPrint.options.baseurl = this.octoprintURL; OctoPrint.options.apikey = accessToken; } From 4bc7f967e4d8cdd02683377392d0b42d406143c1 Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Fri, 4 Sep 2020 18:54:25 +0200 Subject: [PATCH 37/43] use printer name from printerprofile --- src/app/config/no-config/no-config.component.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/app/config/no-config/no-config.component.ts b/src/app/config/no-config/no-config.component.ts index 534f11860..a3aebef0b 100644 --- a/src/app/config/no-config/no-config.component.ts +++ b/src/app/config/no-config/no-config.component.ts @@ -125,6 +125,18 @@ export class NoConfigComponent implements OnInit { .authenticate('OctoDash') .done((apiKey: string) => { this.config.octoprint.accessToken = apiKey; + this.octoprintScriptService.authenticate(apiKey); + this.OctoPrint = this.octoprintScriptService.getInstance(); + + // FIXME: to be removed before merge + this.OctoPrint.printerprofiles + .list() + .done(profiles => { + this.config.printer.name = profiles.profiles._default.name; + }) + .fail(() => console.error('ERR')); + // END + this.changeDetector.detectChanges(); setTimeout(() => { this.increasePage(); From bf98a4a70d7a91a797cab5ccf42e6ac76fd3ed87 Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Fri, 4 Sep 2020 19:00:20 +0200 Subject: [PATCH 38/43] fix setup (all working) --- src/app/config/no-config/no-config.component.html | 4 ++-- src/app/config/no-config/no-config.component.ts | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/app/config/no-config/no-config.component.html b/src/app/config/no-config/no-config.component.html index 3ef94e915..a28e123cf 100644 --- a/src/app/config/no-config/no-config.component.html +++ b/src/app/config/no-config/no-config.component.html @@ -272,14 +272,14 @@
    - + Config Validation {{ error }}
    - + Octoprint Connection {{ octoprintConnectionError }} diff --git a/src/app/config/no-config/no-config.component.ts b/src/app/config/no-config/no-config.component.ts index a3aebef0b..b7694e5a7 100644 --- a/src/app/config/no-config/no-config.component.ts +++ b/src/app/config/no-config/no-config.component.ts @@ -153,7 +153,7 @@ export class NoConfigComponent implements OnInit { }); } - public async testOctoprintAPI(): Promise { + public testOctoprintAPI(): void { const httpHeaders = { headers: new HttpHeaders({ 'x-api-key': this.config.octoprint.accessToken, @@ -169,15 +169,14 @@ export class NoConfigComponent implements OnInit { this.octoprintConnectionError = error.message; }, ); - return true; } - public createConfig(): boolean { + public createConfig(): void { this.configErrors = []; this.octoprintConnectionError = null; this.config = this.configService.createConfigFromInput(this.config); this.validateConfig(); - return true; + this.testOctoprintAPI(); } public async validateConfig(): Promise { @@ -230,7 +229,7 @@ export class NoConfigComponent implements OnInit { this.discoverOctoprintInstances(); break; case this.totalPages: - this.createConfig; + this.createConfig(); break; } } From 6083fca23cad2ba3b4c67e164479e1cd16a51f4a Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Thu, 10 Sep 2020 22:10:34 -0600 Subject: [PATCH 39/43] Convert to range slider to numeric input is not required --- src/app/config/no-config/no-config.component.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/app/config/no-config/no-config.component.html b/src/app/config/no-config/no-config.component.html index a28e123cf..7fbeaa0b0 100644 --- a/src/app/config/no-config/no-config.component.html +++ b/src/app/config/no-config/no-config.component.html @@ -147,31 +147,33 @@ - mm + {{ config.filament.feedLength }} mm
    - mm/s + {{ config.filament.feedSpeed }} mm/s
    These values will be used during the Filament Change Process. Be sure to have your Feed Length (length between Extruder and Hotend) and Feed Speed configured correctly. From f6086dfdff2b5576910bdb52e5489f5da686f55e Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Thu, 10 Sep 2020 22:17:29 -0600 Subject: [PATCH 40/43] I think 150 would be fast enough to load --- src/app/config/no-config/no-config.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/config/no-config/no-config.component.html b/src/app/config/no-config/no-config.component.html index 7fbeaa0b0..b94a19c72 100644 --- a/src/app/config/no-config/no-config.component.html +++ b/src/app/config/no-config/no-config.component.html @@ -169,7 +169,7 @@ name="feedSpeed" step="0.5" min="0" - max="2000" + max="150" style="width: 38vw; padding: 0; margin-top: 8vh; margin-bottom: 3vh;" required /> From 159e418881116983da93183740aa7db2a594a5fe Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Tue, 15 Sep 2020 16:20:33 +0200 Subject: [PATCH 41/43] value selector for numbers --- src/app/app.module.ts | 20 +-- src/app/config/config.service.ts | 4 +- .../config/no-config/no-config.component.html | 140 ++++++++++++------ .../config/no-config/no-config.component.scss | 36 ++++- .../config/no-config/no-config.component.ts | 39 ++--- src/app/long-press.directive.ts | 50 +++++++ src/app/settings/settings.component.scss | 2 +- 7 files changed, 211 insertions(+), 80 deletions(-) create mode 100644 src/app/long-press.directive.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index c0949f2b9..ca825b1b4 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -22,6 +22,7 @@ import { FilesComponent } from './files/files.component'; import { JobStatusComponent } from './job-status/job-status.component'; import { JobService } from './job.service'; import { LayerProgressComponent } from './layer-progress/layer-progress.component'; +import { LongPress } from './long-press.directive'; import { MainMenuComponent } from './main-menu/main-menu.component'; import { MainScreenComponent } from './main-screen/main-screen.component'; import { MainScreenNoTouchComponent } from './main-screen/no-touch/main-screen-no-touch.component'; @@ -40,23 +41,24 @@ import { URLSafePipe } from './url.pipe'; declarations: [ AppComponent, BottomBarComponent, - PrinterStatusComponent, + ControlComponent, + FilamentComponent, + FilesComponent, + InvalidConfigComponent, JobStatusComponent, LayerProgressComponent, - InvalidConfigComponent, - NoConfigComponent, - PrintControlComponent, - NotificationComponent, + LongPress, MainMenuComponent, - ControlComponent, MainScreenComponent, MainScreenNoTouchComponent, - FilamentComponent, - FilesComponent, + NoConfigComponent, + NotificationComponent, + PrintControlComponent, + PrinterStatusComponent, SettingsComponent, - URLSafePipe, StandbyComponent, UpdateComponent, + URLSafePipe, ], imports: [ BrowserModule, diff --git a/src/app/config/config.service.ts b/src/app/config/config.service.ts index 4c35533a6..d62876369 100644 --- a/src/app/config/config.service.ts +++ b/src/app/config/config.service.ts @@ -431,11 +431,11 @@ const schema = { }, feedSpeed: { $id: '#/properties/filament/properties/feedSpeed', - type: 'integer', + type: 'number', }, feedSpeedSlow: { $id: '#/properties/filament/properties/feedSpeedSlow', - type: 'integer', + type: 'number', }, purgeDistance: { $id: '#/properties/filament/properties/purgeDistance', diff --git a/src/app/config/no-config/no-config.component.html b/src/app/config/no-config/no-config.component.html index b94a19c72..ae57fd5cf 100644 --- a/src/app/config/no-config/no-config.component.html +++ b/src/app/config/no-config/no-config.component.html @@ -91,7 +91,9 @@ required style="width: 14vw" /> -

    Port 5000 for OctoPrint, Port 80 for OctoPi

    +

    + Port 5000 for vanilla OctoPrint, Port 80 for OctoPi +

    search again @@ -120,9 +122,10 @@ />
    +
    - First, tell me some facts about your printer so I can personalize OctoDash for you. + Now tell me some facts about your printer so I can personalize OctoDash for you.
    @@ -146,37 +149,90 @@ I also need some information about your extruder. - - {{ config.filament.feedLength }} mm +
    + + - + + + + + + + mm +

    - - {{ config.filament.feedSpeed }} mm/s +
    + + - + + + + + + + mm/s +
    +
    - These values will be used during the Filament Change Process. Be sure to have your Feed Length (length between - Extruder and Hotend) and Feed Speed configured correctly. + These values will be used during the Filament Change Process. Make sure to have your Feed Length (distance + Extruder to Hotend) and Feed Speed configured correctly.
    @@ -190,6 +246,8 @@ Use Touchscreen

    + + Great! I'll check everything.
    + + + Octoprint Connection + - Config Validation + Validating Config {{ error }}
    - - - - Octoprint Connection - - {{ octoprintConnectionError }} -
    -
    @@ -294,13 +348,7 @@ {{ configSaved }}
    - - done - + done
    diff --git a/src/app/config/no-config/no-config.component.scss b/src/app/config/no-config/no-config.component.scss index 76f03a588..cd15057d0 100644 --- a/src/app/config/no-config/no-config.component.scss +++ b/src/app/config/no-config/no-config.component.scss @@ -30,12 +30,40 @@ &__input { background: transparent; - margin-top: 9vh; - padding: 1.5vw 3vh; + margin-top: 7vh; + padding: 3vh 2.5vw; border: 2px solid #dcdde1; border-radius: 2.5vw; width: 55vw; + &__numeric { + border-radius: 0; + + &-wrapper { + display: inline-table; + text-align: center; + } + + &-adjust { + display: inline-table; + padding: 3vh 3vw; + border: 2px solid #dcdde1; + border-radius: 2.5vw 0 0 2.5vw; + margin-right: -2px; + font-size: 4.4vw; + + &-increase { + border-radius: 0 2.5vw 2.5vw 0; + margin-left: -2px; + } + } + + &:focus { + border: 2px solid #dcdde1 !important; + border-bottom: 2px solid #44bd32 !important; + } + } + &:focus { outline: 0; border: 2px solid #44bd32; @@ -47,7 +75,9 @@ &-suffix { font-size: 3vw; - padding-left: 1vw; + display: inline-block; + opacity: 0.6; + margin-right: 10vw; } } diff --git a/src/app/config/no-config/no-config.component.ts b/src/app/config/no-config/no-config.component.ts index b7694e5a7..d92649068 100644 --- a/src/app/config/no-config/no-config.component.ts +++ b/src/app/config/no-config/no-config.component.ts @@ -1,4 +1,4 @@ -import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http'; +import { HttpClient } from '@angular/common/http'; import { ChangeDetectorRef, Component, NgZone, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { NotificationService } from 'src/app/notification/notification.service'; @@ -153,22 +153,24 @@ export class NoConfigComponent implements OnInit { }); } - public testOctoprintAPI(): void { - const httpHeaders = { - headers: new HttpHeaders({ - 'x-api-key': this.config.octoprint.accessToken, - }), - }; - this.http.get(this.config.octoprint.url + 'connection', httpHeaders).subscribe( - (): void => { - this.octoprintConnection = true; - this.saveConfig(); - }, - (error: HttpErrorResponse): void => { - this.octoprintConnection = false; - this.octoprintConnectionError = error.message; - }, - ); + changeFeedLength(amount: number): void { + if (this.config.filament.feedLength + amount < 0) { + this.config.filament.feedLength = 0; + } else if (this.config.filament.feedLength + amount > 9999) { + this.config.filament.feedLength = 9999; + } else { + this.config.filament.feedLength += amount; + } + } + + changeFeedSpeed(amount: number): void { + if (this.config.filament.feedSpeed + amount < 0) { + this.config.filament.feedSpeed = 0; + } else if (this.config.filament.feedSpeed + amount > 999) { + this.config.filament.feedSpeed = 999; + } else { + this.config.filament.feedSpeed += amount; + } } public createConfig(): void { @@ -176,7 +178,6 @@ export class NoConfigComponent implements OnInit { this.octoprintConnectionError = null; this.config = this.configService.createConfigFromInput(this.config); this.validateConfig(); - this.testOctoprintAPI(); } public async validateConfig(): Promise { @@ -267,7 +268,7 @@ export class NoConfigComponent implements OnInit { thickness: 1.75, density: 1.25, feedLength: 0, - feedSpeed: 30, + feedSpeed: 20, feedSpeedSlow: 3, purgeDistance: 30, useM600: false, diff --git a/src/app/long-press.directive.ts b/src/app/long-press.directive.ts new file mode 100644 index 000000000..063efaeb9 --- /dev/null +++ b/src/app/long-press.directive.ts @@ -0,0 +1,50 @@ +import { Directive, EventEmitter, HostListener, Input, Output } from '@angular/core'; + +@Directive({ + selector: '[long-press]', +}) +export class LongPress { + pressing: boolean; + longPressing: boolean; + timeout: number; + interval: number; + + @Input() duration = 500; + @Input() frequency = 100; + + @Output() + onShortPress = new EventEmitter(); + + @Output() + onLongPress = new EventEmitter(); + + @Output() + onLongPressing = new EventEmitter(); + + @HostListener('touchstart', ['$event']) + @HostListener('mousedown', ['$event']) + onMouseDown(event: EventSource): void { + this.pressing = true; + this.longPressing = false; + this.timeout = setTimeout(() => { + this.longPressing = true; + this.onLongPress.emit(event); + this.interval = setInterval(() => { + this.onLongPressing.emit(event); + }, this.frequency); + }, this.duration); + } + + @HostListener('touchend', ['$event']) + @HostListener('mouseup', ['$event']) + @HostListener('mouseleave', ['$event']) + endPress(event: EventSource): void { + clearTimeout(this.timeout); + clearInterval(this.interval); + if (!this.longPressing && this.pressing) { + this.onShortPress.emit(event); + } + this.longPressing = false; + this.pressing = false; + } +} diff --git a/src/app/settings/settings.component.scss b/src/app/settings/settings.component.scss index f35c85338..0ae315826 100644 --- a/src/app/settings/settings.component.scss +++ b/src/app/settings/settings.component.scss @@ -211,7 +211,7 @@ &__save { display: block; text-align: center; - margin: 2.5vh 0 4vh; + margin: 4vh 0; } &__scroll { From 3f33af417d0b18e9ace98daf1fbcd232e1db096a Mon Sep 17 00:00:00 2001 From: UnchartedBull Date: Tue, 15 Sep 2020 17:05:43 +0200 Subject: [PATCH 42/43] fix layout issue --- src/app/config/no-config/no-config.component.scss | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/config/no-config/no-config.component.scss b/src/app/config/no-config/no-config.component.scss index cd15057d0..47903fc88 100644 --- a/src/app/config/no-config/no-config.component.scss +++ b/src/app/config/no-config/no-config.component.scss @@ -35,6 +35,7 @@ border: 2px solid #dcdde1; border-radius: 2.5vw; width: 55vw; + line-height: 125%; &__numeric { border-radius: 0; @@ -50,7 +51,8 @@ border: 2px solid #dcdde1; border-radius: 2.5vw 0 0 2.5vw; margin-right: -2px; - font-size: 4.4vw; + font-size: 4.3vw; + line-height: 125%; &-increase { border-radius: 0 2.5vw 2.5vw 0; From be231ef8ab5ac0029d48f5526f657f26873b72be Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Tue, 15 Sep 2020 10:03:50 -0600 Subject: [PATCH 43/43] Fix alignemnt on large and small views --- src/app/config/no-config/no-config.component.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/config/no-config/no-config.component.scss b/src/app/config/no-config/no-config.component.scss index 47903fc88..dca8bfcd1 100644 --- a/src/app/config/no-config/no-config.component.scss +++ b/src/app/config/no-config/no-config.component.scss @@ -46,7 +46,7 @@ } &-adjust { - display: inline-table; + display: inline-flex; padding: 3vh 3vw; border: 2px solid #dcdde1; border-radius: 2.5vw 0 0 2.5vw;