Skip to content

Commit

Permalink
Fix text wrap and switch to bonjour (UnchartedBull#1041)
Browse files Browse the repository at this point in the history
* some fixes

* fix scrollbar

* fix linter issue
  • Loading branch information
UnchartedBull authored and kantlivelong committed May 5, 2021
1 parent 02ba238 commit 91989de
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 120 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
plugins: ['@typescript-eslint', 'import', 'simple-import-sort', 'prettier'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/errors',
'plugin:import/warnings',
Expand All @@ -17,7 +18,9 @@ module.exports = {
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'import/no-unresolved': 'off',
'camelcase': 'warn',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars-experimental': 'warn',
camelcase: 'warn',
'simple-import-sort/sort': 'warn',
'sort-imports': 'off',
'import/first': 'warn',
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"htmlWhitespaceSensitivity": "ignore"
"htmlWhitespaceSensitivity": "css"
}
22 changes: 11 additions & 11 deletions helper/discover.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable import/no-commonjs */

const mdns = require('mdns');
const compareVersions = require('compare-versions');

const minimumVersion = '1.3.5';
let mdnsBrowser;
let browser;
let nodes = [];

function discoverNodes(window) {
const bonjour = require('bonjour')();
nodes = [];
mdnsBrowser = mdns.createBrowser(mdns.tcp('octoprint'));
mdnsBrowser.on('serviceUp', service => {
browser = bonjour.find({ type: 'octoprint' });
browser.on('up', service => {
nodes.push({
id: service.interfaceIndex,
id: service.addresses[0] + service.port,
name: service.name,
version: service.txtRecord.version,
url: `http://${service.host.replace(/\.$/, '')}:${service.port}${service.txtRecord.path}api/`,
disable: compareVersions(minimumVersion, service.txtRecord.version) === -1,
version: service.txt.version,
url: `http://${service.host.replace(/\.$/, '')}:${service.port}${service.txt.path}api/`,
disable: compareVersions(minimumVersion, service.txt.version) === -1,
});
sendNodes(window);
});

mdnsBrowser.on('serviceDown', service => {
browser.on('down', service => {
nodes = nodes.filter(node => node.id !== service.interfaceIndex);
sendNodes(window);
});

mdnsBrowser.start();
browser.start();
}

function stopDiscovery() {
mdnsBrowser.stop();
browser.stop();
}

function sendNodes(window) {
Expand Down
74 changes: 16 additions & 58 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,12 @@
"@fortawesome/free-solid-svg-icons": "^5.14.0",
"ajv": "^6.12.5",
"angular-svg-round-progressbar": "^4.0.0",
"bonjour": "^3.5.0",
"compare-versions": "^3.6.0",
"electron-store": "^6.0.0",
"got": "^11.7.0",
"jquery": "^3.5.1",
"got": "^11.6.2",
"lodash": "^4.17.20",
"mdns": "^2.5.1",
"ngx-spinner": "^10.0.1",
"progress-stream": "^2.0.0",
"rxjs": "~6.6.3",
Expand Down
Loading

0 comments on commit 91989de

Please sign in to comment.