NodeJS version and 1/8th default on calculator

pull/110/head
openbuilds-engineer 2018-08-23 22:09:27 +02:00
rodzic 00d36ea5a6
commit 365488ddaf
4 zmienionych plików z 350 dodań i 358 usunięć

Wyświetl plik

@ -32,8 +32,8 @@ var grblcalctemplate = `<div>
<td style="width: 70%;">
<select data-role="select" data-filter="false" id="microstepselect" data-on-change="processpreset();">
<option value="32">1/32 Step</option>
<option value="16" selected>1/16 Step</option>
<option value="8">1/8 Step</option>
<option value="16">1/16 Step</option>
<option value="8" selected>1/8 Step</option>
<option value="4">1/4 Step</option>
<option value="1">Full Step</option>
</select>

675
index.js
Wyświetl plik

@ -48,7 +48,9 @@ var lastsentuploadprogress = 0;
// Electron app
const electron = require('electron');
const electronApp = electron.app;
console.log("Local User Data: " + electronApp.getPath('userData'))
if (isElectron()) {
console.log("Local User Data: " + electronApp.getPath('userData'))
}
const BrowserWindow = electron.BrowserWindow;
const Tray = electron.Tray;
const nativeImage = require('electron').nativeImage
@ -58,89 +60,18 @@ var appIcon = null,
jogWindow = null,
mainWindow = null
const autoUpdater = require("electron-updater").autoUpdater
var availversion = '0.0.0'
autoUpdater.on('checking-for-update', () => {
var string = 'Starting update... Please wait';
var output = {
'command': 'autoupdate',
'response': string
}
io.sockets.emit('updatedata', output);
if (jogWindow && !jogWindow.isFocused()) {
appIcon.displayBalloon({
icon: nativeImage.createFromPath(iconPath),
title: "OpenBuilds Machine Driver",
content: string
})
}
})
autoUpdater.on('update-available', (ev, info) => {
var string = "Starting Download: v" + ev.version;
availversion = ev.version
var output = {
'command': 'autoupdate',
'response': string
}
io.sockets.emit('updatedata', output);
console.log(JSON.stringify(ev))
if (jogWindow && !jogWindow.isFocused()) {
appIcon.displayBalloon({
icon: nativeImage.createFromPath(iconPath),
title: "OpenBuilds Machine Driver",
content: string
})
}
})
autoUpdater.on('update-not-available', (ev, info) => {
var string = 'Update not available. Installed version: ' + require('./package').version + " / Available version: " + ev.version + ".\n";
if (require('./package').version === ev.version) {
string += "You are already running the latest version!"
}
var output = {
'command': 'autoupdate',
'response': string
}
io.sockets.emit('updatedata', output);
console.log(JSON.stringify(ev))
if (jogWindow && !jogWindow.isFocused()) {
appIcon.displayBalloon({
icon: nativeImage.createFromPath(iconPath),
title: "OpenBuilds Machine Driver",
content: string
})
}
})
autoUpdater.on('error', (ev, err) => {
if (err) {
var string = 'Error in auto-updater: \n' + err.split('SyntaxError')[0];
} else {
var string = 'Error in auto-updater';
}
var output = {
'command': 'autoupdate',
'response': string
}
io.sockets.emit('updatedata', output);
if (jogWindow && !jogWindow.isFocused()) {
appIcon.displayBalloon({
icon: nativeImage.createFromPath(iconPath),
title: "OpenBuilds Machine Driver",
content: string
})
}
})
autoUpdater.on('download-progress', (ev, progressObj) => {
var string = 'Download update ... ' + ev.percent.toFixed(1) + '%';
console.log(string)
var output = {
'command': 'autoupdate',
'response': string
}
io.sockets.emit('updatedata', output);
io.sockets.emit('updateprogress', ev.percent.toFixed(0));
if (ev.percent % 10 === 0) {
if (isElectron()) {
const autoUpdater = require("electron-updater").autoUpdater
var availversion = '0.0.0'
autoUpdater.on('checking-for-update', () => {
var string = 'Starting update... Please wait';
var output = {
'command': 'autoupdate',
'response': string
}
io.sockets.emit('updatedata', output);
if (jogWindow && !jogWindow.isFocused()) {
appIcon.displayBalloon({
icon: nativeImage.createFromPath(iconPath),
@ -148,31 +79,109 @@ autoUpdater.on('download-progress', (ev, progressObj) => {
content: string
})
}
}
})
})
autoUpdater.on('update-available', (ev, info) => {
var string = "Starting Download: v" + ev.version;
availversion = ev.version
var output = {
'command': 'autoupdate',
'response': string
}
io.sockets.emit('updatedata', output);
console.log(JSON.stringify(ev))
if (jogWindow && !jogWindow.isFocused()) {
appIcon.displayBalloon({
icon: nativeImage.createFromPath(iconPath),
title: "OpenBuilds Machine Driver",
content: string
})
}
})
autoUpdater.on('update-not-available', (ev, info) => {
var string = 'Update not available. Installed version: ' + require('./package').version + " / Available version: " + ev.version + ".\n";
if (require('./package').version === ev.version) {
string += "You are already running the latest version!"
}
var output = {
'command': 'autoupdate',
'response': string
}
io.sockets.emit('updatedata', output);
console.log(JSON.stringify(ev))
if (jogWindow && !jogWindow.isFocused()) {
appIcon.displayBalloon({
icon: nativeImage.createFromPath(iconPath),
title: "OpenBuilds Machine Driver",
content: string
})
}
})
autoUpdater.on('error', (ev, err) => {
if (err) {
var string = 'Error in auto-updater: \n' + err.split('SyntaxError')[0];
} else {
var string = 'Error in auto-updater';
}
var output = {
'command': 'autoupdate',
'response': string
}
io.sockets.emit('updatedata', output);
if (jogWindow && !jogWindow.isFocused()) {
appIcon.displayBalloon({
icon: nativeImage.createFromPath(iconPath),
title: "OpenBuilds Machine Driver",
content: string
})
}
})
autoUpdater.on('download-progress', (ev, progressObj) => {
var string = 'Download update ... ' + ev.percent.toFixed(1) + '%';
console.log(string)
var output = {
'command': 'autoupdate',
'response': string
}
io.sockets.emit('updatedata', output);
io.sockets.emit('updateprogress', ev.percent.toFixed(0));
if (ev.percent % 10 === 0) {
if (jogWindow && !jogWindow.isFocused()) {
appIcon.displayBalloon({
icon: nativeImage.createFromPath(iconPath),
title: "OpenBuilds Machine Driver",
content: string
})
}
}
})
autoUpdater.on('update-downloaded', (info) => {
var string = "New update ready";
var output = {
'command': 'autoupdate',
'response': string
}
io.sockets.emit('updatedata', output);
io.sockets.emit('updateready', availversion);
// repeat every minute
setTimeout(function() {
autoUpdater.on('update-downloaded', (info) => {
var string = "New update ready";
var output = {
'command': 'autoupdate',
'response': string
}
io.sockets.emit('updatedata', output);
io.sockets.emit('updateready', availversion);
}, 15 * 60 * 1000) // 5 mins
if (jogWindow && !jogWindow.isFocused()) {
appIcon.displayBalloon({
icon: nativeImage.createFromPath(iconPath),
title: "OpenBuilds Machine Driver",
content: string
})
}
});
// repeat every minute
setTimeout(function() {
io.sockets.emit('updateready', availversion);
}, 15 * 60 * 1000) // 5 mins
if (jogWindow && !jogWindow.isFocused()) {
appIcon.displayBalloon({
icon: nativeImage.createFromPath(iconPath),
title: "OpenBuilds Machine Driver",
content: string
})
}
});
}
var uploadsDir = electronApp.getPath('userData') + '/upload/';
if (isElectron()) {
var uploadsDir = electronApp.getPath('userData') + '/upload/';
} else {
var uploadsDir = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + 'Library/Preferences' : '/var/local')
}
// fs.existsSync(uploadsDir) || fs.mkdirSync(uploadsDir)
mkdirp(uploadsDir, function(err) {
@ -1845,246 +1854,248 @@ function isElectron() {
return false;
}
const shouldQuit = electronApp.makeSingleInstance((commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (jogWindow === null) {
createJogWindow();
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
} else {
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
}
});
if (shouldQuit) {
console.log("Already running! Check the System Tray")
electronApp.exit(0);
electronApp.quit();
}
if (electronApp) {
// Module to create native browser window.
function createApp() {
createTrayIcon();
if (process.platform == 'darwin') {
if (jogWindow === null) {
createJogWindow();
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
} else {
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
}
}
// createWindow();
// createJogWindow();
}
function createTrayIcon() {
if (process.platform !== 'darwin') {
appIcon = new Tray(
nativeImage.createFromPath(iconPath)
)
const contextMenu = Menu.buildFromTemplate([{
label: 'Quit Machine Driver (Disables all integration until started again)',
click() {
appIcon.destroy();
electronApp.exit(0);
}
}])
appIcon.on('click', function() {
// console.log("Clicked Systray")
if (jogWindow === null) {
createJogWindow();
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
} else {
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
}
})
appIcon.on('balloon-click', function() {
// console.log("Clicked Systray")
if (jogWindow === null) {
createJogWindow();
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
} else {
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
}
})
// Call this again for Linux because we modified the context menu
appIcon.setContextMenu(contextMenu)
appIcon.displayBalloon({
icon: nativeImage.createFromPath(iconPath),
title: "Driver Started",
content: "OpenBuilds Machine Driver has started successfully: Active on " + ip.address() + ":" + config.webPort
})
} else {
const dockMenu = Menu.buildFromTemplate([{
label: 'Quit Machine Driver (Disables all integration until started again)',
click() {
// appIcon.destroy();
electronApp.exit(0);
}
}])
electronApp.dock.setMenu(dockMenu)
};
}
function createJogWindow() {
// Create the browser window.
jogWindow = new BrowserWindow({
width: 660,
height: 730,
fullscreen: false,
center: true,
resizable: true,
title: "OpenBuilds Machine Driver ",
frame: false,
autoHideMenuBar: true,
icon: '/app/favicon.png'
});
jogWindow.setOverlayIcon(nativeImage.createFromPath(iconPath), 'Icon');
var ipaddr = ip.address();
// jogWindow.loadURL(`//` + ipaddr + `:3000/`)
jogWindow.loadURL("http://localhost:3000/");
jogWindow.on('close', function(event) {
event.preventDefault();
jogWindow.hide();
return false;
});
// Emitted when the window is closed.
jogWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
jogWindow = null;
});
jogWindow.once('ready-to-show', () => {
if (isElectron()) {
const shouldQuit = electronApp.makeSingleInstance((commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (jogWindow === null) {
createJogWindow();
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
})
// jogWindow.maximize()
// jogWindow.webContents.openDevTools()
} else {
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
}
});
if (shouldQuit) {
console.log("Already running! Check the System Tray")
electronApp.exit(0);
electronApp.quit();
}
function createWindow() {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 1200,
height: 900,
fullscreen: false,
center: true,
resizable: true,
title: "OpenBuilds Machine Driver ",
frame: true,
autoHideMenuBar: true,
icon: '/app/favicon.png'
if (electronApp) {
// Module to create native browser window.
function createApp() {
createTrayIcon();
if (process.platform == 'darwin') {
if (jogWindow === null) {
createJogWindow();
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
} else {
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
}
}
// createWindow();
// createJogWindow();
}
function createTrayIcon() {
if (process.platform !== 'darwin') {
appIcon = new Tray(
nativeImage.createFromPath(iconPath)
)
const contextMenu = Menu.buildFromTemplate([{
label: 'Quit Machine Driver (Disables all integration until started again)',
click() {
appIcon.destroy();
electronApp.exit(0);
}
}])
appIcon.on('click', function() {
// console.log("Clicked Systray")
if (jogWindow === null) {
createJogWindow();
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
} else {
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
}
})
appIcon.on('balloon-click', function() {
// console.log("Clicked Systray")
if (jogWindow === null) {
createJogWindow();
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
} else {
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
}
})
// Call this again for Linux because we modified the context menu
appIcon.setContextMenu(contextMenu)
appIcon.displayBalloon({
icon: nativeImage.createFromPath(iconPath),
title: "Driver Started",
content: "OpenBuilds Machine Driver has started successfully: Active on " + ip.address() + ":" + config.webPort
})
} else {
const dockMenu = Menu.buildFromTemplate([{
label: 'Quit Machine Driver (Disables all integration until started again)',
click() {
// appIcon.destroy();
electronApp.exit(0);
}
}])
electronApp.dock.setMenu(dockMenu)
};
}
function createJogWindow() {
// Create the browser window.
jogWindow = new BrowserWindow({
width: 660,
height: 730,
fullscreen: false,
center: true,
resizable: true,
title: "OpenBuilds Machine Driver ",
frame: false,
autoHideMenuBar: true,
icon: '/app/favicon.png'
});
jogWindow.setOverlayIcon(nativeImage.createFromPath(iconPath), 'Icon');
var ipaddr = ip.address();
// jogWindow.loadURL(`//` + ipaddr + `:3000/`)
jogWindow.loadURL("http://localhost:3000/");
jogWindow.on('close', function(event) {
event.preventDefault();
jogWindow.hide();
return false;
});
// Emitted when the window is closed.
jogWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
jogWindow = null;
});
jogWindow.once('ready-to-show', () => {
jogWindow.show()
jogWindow.setAlwaysOnTop(true);
jogWindow.focus();
jogWindow.setAlwaysOnTop(false);
})
// jogWindow.maximize()
// jogWindow.webContents.openDevTools()
}
function createWindow() {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 1200,
height: 900,
fullscreen: false,
center: true,
resizable: true,
title: "OpenBuilds Machine Driver ",
frame: true,
autoHideMenuBar: true,
icon: '/app/favicon.png'
});
// and load the index.html of the app.
// mainWindow.loadURL('file://' + __dirname + '/app/index.html');
// mainWindow.loadURL(`file://${__dirname}/app/index.html`)
var ipaddr = ip.address();
// mainWindow.loadURL(`//` + ipaddr + `:3000/`)
mainWindow.loadURL("http://localhost:3000");
mainWindow.on('close', function(event) {
event.preventDefault();
mainWindow.hide();
return false;
});
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
mainWindow.once('ready-to-show', () => {
mainWindow.show()
})
mainWindow.maximize()
// mainWindow.webContents.openDevTools()
};
// electronApp.commandLine.appendSwitch("--ignore-gpu-blacklist");
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
electronApp.on('ready', createApp);
electronApp.on('will-quit', function(event) {
event.preventDefault()
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
electronApp.quit();
appIcon.destroy();
}
electronApp.quit();
appIcon.destroy();
});
// and load the index.html of the app.
// mainWindow.loadURL('file://' + __dirname + '/app/index.html');
// mainWindow.loadURL(`file://${__dirname}/app/index.html`)
var ipaddr = ip.address();
// mainWindow.loadURL(`//` + ipaddr + `:3000/`)
mainWindow.loadURL("http://localhost:3000");
mainWindow.on('close', function(event) {
event.preventDefault();
mainWindow.hide();
return false;
// Quit when all windows are closed.
electronApp.on('window-all-closed', function() {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
electronApp.quit();
appIcon.destroy();
}
electronApp.quit();
appIcon.destroy();
});
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
electronApp.on('activate', function() {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createApp();
}
});
mainWindow.once('ready-to-show', () => {
mainWindow.show()
// Autostart on Login
electronApp.setLoginItemSettings({
openAtLogin: true,
args: []
})
mainWindow.maximize()
// mainWindow.webContents.openDevTools()
};
// electronApp.commandLine.appendSwitch("--ignore-gpu-blacklist");
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
electronApp.on('ready', createApp);
electronApp.on('will-quit', function(event) {
event.preventDefault()
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
electronApp.quit();
appIcon.destroy();
}
electronApp.quit();
appIcon.destroy();
});
// Quit when all windows are closed.
electronApp.on('window-all-closed', function() {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
electronApp.quit();
appIcon.destroy();
}
electronApp.quit();
appIcon.destroy();
});
electronApp.on('activate', function() {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createApp();
}
});
// Autostart on Login
electronApp.setLoginItemSettings({
openAtLogin: true,
args: []
})
}
}
process.on('exit', () => console.log('exit'))

27
package-lock.json wygenerowano
Wyświetl plik

@ -1,6 +1,6 @@
{
"name": "OpenBuildsMachineDriver",
"version": "1.0.70",
"version": "1.0.74",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -1443,11 +1443,6 @@
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
},
"growly": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE="
},
"har-schema": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
@ -1716,7 +1711,8 @@
"isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA="
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
"dev": true
},
"isstream": {
"version": "0.1.2",
@ -2057,17 +2053,6 @@
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz",
"integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk="
},
"node-notifier": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-5.2.1.tgz",
"integrity": "sha512-MIBs+AAd6dJ2SklbbE8RUDRlIVhU8MaNLh1A9SUZDUHPiZkWLFde6UNwG41yQHZEToHgJMXqyVZ9UcS/ReOVTg==",
"requires": {
"growly": "1.3.0",
"semver": "5.5.0",
"shellwords": "0.1.1",
"which": "1.3.1"
}
},
"noms": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/noms/-/noms-0.0.0.tgz",
@ -3761,11 +3746,6 @@
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
"dev": true
},
"shellwords": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww=="
},
"signal-exit": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
@ -4263,6 +4243,7 @@
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
"integrity": "sha1-pFBD1U9YBTFtqNYvn1CRjT2nCwo=",
"dev": true,
"requires": {
"isexe": "2.0.0"
}

Wyświetl plik

@ -1,6 +1,6 @@
{
"name": "OpenBuildsMachineDriver",
"version": "1.0.74",
"version": "1.0.75",
"license": "AGPL-3.0",
"description": "Machine Interface Driver for OpenBuilds",
"author": "github.com/openbuilds <webmaster@openbuilds.com>",