Loading .eslintrc.js 0 → 100644 +24 −0 Original line number Diff line number Diff line module.exports = { root: true, env: { node: true }, extends: [ "plugin:vue/recommended", "eslint:recommended", "prettier/vue", "plugin:prettier/recommended" ], rules: { "vue/component-name-in-template-casing": ["error", "PascalCase"], "no-console": process.env.NODE_ENV === "production" ? "error" : "off", "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off" }, globals: { $nuxt: true }, parserOptions: { parser: "babel-eslint" } }; No newline at end of file app/app.dev.js +14 −14 Original line number Diff line number Diff line const electron = require('electron') const contextMenu = require('electron-context-menu') const path = require('path') const electron = require("electron"); const contextMenu = require("electron-context-menu"); const path = require("path"); const app = electron.app const BrowserWindow = electron.BrowserWindow const app = electron.app; const BrowserWindow = electron.BrowserWindow; let url = 'http://localhost:8080/' let url = "http://localhost:8080/"; // Set the application menu require('./menu.js') require("./menu.js"); app.on('ready', () => { app.on("ready", () => { let window = new BrowserWindow({ width: 1124, height: 800, icon: path.join(__dirname, '/icons/png/64x64.png') }) icon: path.join(__dirname, "/icons/png/64x64.png") }); contextMenu({ showCopyImageAddress: true, showSaveImageAs: true, showInspectElement: true, showInspectElement: true }); window.loadURL(url) }) No newline at end of file window.loadURL(url); }); app/app.js +83 −68 Original line number Diff line number Diff line // Required packages const electron = require('electron') const { dialog } = require('electron') const electron = require("electron"); const { dialog } = require("electron"); const updater = require("electron-updater"); const autoUpdater = updater.autoUpdater; const contextMenu = require('electron-context-menu') const path = require('path') const contextMenu = require("electron-context-menu"); const path = require("path"); // Attach settings store const { store } = require('./store') const { store } = require("./store"); // Auto upadater autoUpdater.autoDownload = false; autoUpdater.on('checking-for-update', function () {}); autoUpdater.on('update-available', function (info) { sendStatusToWindow('Update available.' + info) dialog.showMessageBox(mainWindow, { type: 'info', title: 'Update available', message: 'A new version of OpenFlexure eV is available.', buttons: ['Download', 'Later'] }, (buttonIndex) => { autoUpdater.on("checking-for-update", function() {}); autoUpdater.on("update-available", function(info) { sendStatusToWindow("Update available." + info); dialog.showMessageBox( mainWindow, { type: "info", title: "Update available", message: "A new version of OpenFlexure eV is available.", buttons: ["Download", "Later"] }, buttonIndex => { if (buttonIndex === 0) { autoUpdater.downloadUpdate() autoUpdater.downloadUpdate(); } } }) ); }); autoUpdater.on('update-downloaded', function (info) { sendStatusToWindow('Update downloaded.' + info) dialog.showMessageBox(mainWindow, { type: 'info', autoUpdater.on("update-downloaded", function(info) { sendStatusToWindow("Update downloaded." + info); dialog.showMessageBox( mainWindow, { type: "info", title: "Update downloaded", message: 'Please restart the application to apply the update.', buttons: ['Update', 'Later'] }, (buttonIndex) => { message: "Please restart the application to apply the update.", buttons: ["Update", "Later"] }, buttonIndex => { if (buttonIndex === 0) { autoUpdater.quitAndInstall(); } }) } ); }); autoUpdater.on('update-not-available', function (info) { sendStatusToWindow('Update not available.'); autoUpdater.on("update-not-available", function() { sendStatusToWindow("Update not available."); }); autoUpdater.on('error', function (err) { sendStatusToWindow('Error in auto-updater.'); autoUpdater.on("error", function() { sendStatusToWindow("Error in auto-updater."); }); autoUpdater.on('download-progress', function (progressObj) { autoUpdater.on("download-progress", function(progressObj) { let log_message = "Download speed: " + progressObj.bytesPerSecond; log_message = log_message + ' - Downloaded ' + parseInt(progressObj.percent) + '%'; log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')'; log_message = log_message + " - Downloaded " + parseInt(progressObj.percent) + "%"; log_message = log_message + " (" + progressObj.transferred + "/" + progressObj.total + ")"; sendStatusToWindow(log_message); }); Loading @@ -62,83 +77,83 @@ function sendStatusToWindow(message) { } // Set up the app const app = electron.app const BrowserWindow = electron.BrowserWindow const app = electron.app; const BrowserWindow = electron.BrowserWindow; // Set the window content let url = `file://${path.join(__dirname, '/dist/index.html')}` let mainWindow let url = `file://${path.join(__dirname, "/dist/index.html")}`; let mainWindow; // Set the application menu require('./menu.js') require("./menu.js"); // Handle redrawing the mainWindow let recreatingWindowInProgress = false; function toggleCustomTitleBar() { // Mark window as being recreated, to prevent stopping the application recreatingWindowInProgress = true recreatingWindowInProgress = true; // Invert the drawCustomTitleBar setting store.set('drawCustomTitleBar', !store.get('drawCustomTitleBar')) store.set("drawCustomTitleBar", !store.get("drawCustomTitleBar")); // Destroy old window mainWindow.destroy() mainWindow.destroy(); // Create new window createWindow() createWindow(); // Mark window as no longer being recreated recreatingWindowInProgress = false recreatingWindowInProgress = false; } function createWindow() { // Create the browser window. mainWindow = new BrowserWindow({ frame: !store.get('drawCustomTitleBar'), frame: !store.get("drawCustomTitleBar"), width: 1124, height: 800, icon: path.join(__dirname, '/icons/png/64x64.png'), icon: path.join(__dirname, "/icons/png/64x64.png"), webPreferences: { nodeIntegration: true } }) }); // Make a context menu contextMenu({ showCopyImageAddress: true, showSaveImageAs: true, showInspectElement: false, showInspectElement: false }); // Load window contents mainWindow.loadURL(url) mainWindow.loadURL(url); // Check for updates autoUpdater.checkForUpdates(); // Emitted when the window is closed. mainWindow.on('closed', function() { mainWindow = null // Dereference the window object }) mainWindow.on("closed", function() { mainWindow = null; // Dereference the window object }); } // Some APIs can only be used after this event occurs. app.on('ready', () => { createWindow() }) app.on("ready", () => { createWindow(); }); // Quit when all windows are closed. app.on('window-all-closed', function() { if ((process.platform !== 'darwin') && recreatingWindowInProgress != true) { app.quit() app.on("window-all-closed", function() { if (process.platform !== "darwin" && recreatingWindowInProgress != true) { app.quit(); } }) }); app.on('activate', function() { app.on("activate", function() { if (mainWindow === null) { createWindow() createWindow(); } }) }); // Export toggleCustomTitleBar for use in ./menu.js module.exports.toggleCustomTitleBar = toggleCustomTitleBar No newline at end of file module.exports.toggleCustomTitleBar = toggleCustomTitleBar; app/menu.js +72 −79 Original line number Diff line number Diff line const { app, shell, Menu } = require('electron') const { app, shell, Menu } = require("electron"); const updater = require("electron-updater"); const autoUpdater = updater.autoUpdater; const path = require('path') const path = require("path"); const openAboutWindow = require('about-window').default const openAboutWindow = require("about-window").default; const main = require('./app') const { store } = require('./store') const main = require("./app"); const { store } = require("./store"); const template = [ { label: 'Edit', label: "Edit", submenu: [ { role: 'undo' }, { role: 'redo' }, { type: 'separator' }, { role: 'cut' }, { role: 'copy' }, { role: 'paste' }, { role: 'delete' }, { role: 'selectall' } { role: "undo" }, { role: "redo" }, { type: "separator" }, { role: "cut" }, { role: "copy" }, { role: "paste" }, { role: "delete" }, { role: "selectall" } ] }, { label: 'View', label: "View", submenu: [ { role: 'reload' }, { role: 'forcereload' }, { role: 'toggledevtools' }, { type: 'separator' }, { role: 'togglefullscreen' }, { type: 'separator' }, { role: "reload" }, { role: "forcereload" }, { role: "toggledevtools" }, { type: "separator" }, { role: "togglefullscreen" }, { type: "separator" }, { type: 'checkbox', checked: store.get('drawCustomTitleBar'), label: 'Custom titlebar', type: "checkbox", checked: store.get("drawCustomTitleBar"), label: "Custom titlebar", click() { main.toggleCustomTitleBar() main.toggleCustomTitleBar(); } } ] }, { role: 'window', submenu: [ { role: 'minimize' }, { role: 'close' } ] role: "window", submenu: [{ role: "minimize" }, { role: "close" }] }, { role: 'help', role: "help", submenu: [ { label: 'About', label: "About", click() { openAboutWindow({ package_json_dir: path.join(__dirname, '..'), icon_path: path.join(__dirname, '/icons/png/512x512.png'), bug_report_url: "https://gitlab.com/openflexure/openflexure-microscope-jsclient/issues", homepage: "https://gitlab.com/openflexure/openflexure-microscope-jsclient", }) package_json_dir: path.join(__dirname, ".."), icon_path: path.join(__dirname, "/icons/png/512x512.png"), bug_report_url: "https://gitlab.com/openflexure/openflexure-microscope-jsclient/issues", homepage: "https://gitlab.com/openflexure/openflexure-microscope-jsclient" }); } }, { label: 'Homepage', label: "Homepage", click() { shell.openExternal('https://openflexure.org') shell.openExternal("https://openflexure.org"); } }, { type: 'separator' }, { type: "separator" }, { label: 'Check for Updates', label: "Check for Updates", click() { autoUpdater.checkForUpdates(); } } ] } ] ]; if (process.platform === 'darwin') { if (process.platform === "darwin") { template.unshift({ label: app.getName(), submenu: [ { role: 'about' }, { type: 'separator' }, { role: 'services' }, { type: 'separator' }, { role: 'hide' }, { role: 'hideothers' }, { role: 'unhide' }, { type: 'separator' }, { role: 'quit' } { role: "about" }, { type: "separator" }, { role: "services" }, { type: "separator" }, { role: "hide" }, { role: "hideothers" }, { role: "unhide" }, { type: "separator" }, { role: "quit" } ] }) }); // Edit menu template[1].submenu.push( { type: 'separator' }, { type: "separator" }, { label: 'Speech', submenu: [ { role: 'startspeaking' }, { role: 'stopspeaking' } ] label: "Speech", submenu: [{ role: "startspeaking" }, { role: "stopspeaking" }] } ) ); // Window menu template[3].submenu = [ { role: 'close' }, { role: 'minimize' }, { role: 'zoom' }, { type: 'separator' }, { role: 'front' } ] } else { { role: "close" }, { role: "minimize" }, { role: "zoom" }, { type: "separator" }, { role: "front" } ]; } else { template.unshift({ label: 'File', submenu: [ { role: 'quit' } ] }) label: "File", submenu: [{ role: "quit" }] }); } const menu = Menu.buildFromTemplate(template) Menu.setApplicationMenu(menu) No newline at end of file const menu = Menu.buildFromTemplate(template); Menu.setApplicationMenu(menu); app/store.js +4 −4 Original line number Diff line number Diff line const Store = require('electron-store'); const Store = require("electron-store"); const store = new Store(); if (store.has('drawCustomTitleBar') !== true) { if (store.has("drawCustomTitleBar") !== true) { // Default to false if on MacOS, otherwise true store.set('drawCustomTitleBar', (process.platform === 'win32') ? true : false) store.set("drawCustomTitleBar", process.platform === "win32" ? true : false); } module.exports.store = store No newline at end of file module.exports.store = store; Loading
.eslintrc.js 0 → 100644 +24 −0 Original line number Diff line number Diff line module.exports = { root: true, env: { node: true }, extends: [ "plugin:vue/recommended", "eslint:recommended", "prettier/vue", "plugin:prettier/recommended" ], rules: { "vue/component-name-in-template-casing": ["error", "PascalCase"], "no-console": process.env.NODE_ENV === "production" ? "error" : "off", "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off" }, globals: { $nuxt: true }, parserOptions: { parser: "babel-eslint" } }; No newline at end of file
app/app.dev.js +14 −14 Original line number Diff line number Diff line const electron = require('electron') const contextMenu = require('electron-context-menu') const path = require('path') const electron = require("electron"); const contextMenu = require("electron-context-menu"); const path = require("path"); const app = electron.app const BrowserWindow = electron.BrowserWindow const app = electron.app; const BrowserWindow = electron.BrowserWindow; let url = 'http://localhost:8080/' let url = "http://localhost:8080/"; // Set the application menu require('./menu.js') require("./menu.js"); app.on('ready', () => { app.on("ready", () => { let window = new BrowserWindow({ width: 1124, height: 800, icon: path.join(__dirname, '/icons/png/64x64.png') }) icon: path.join(__dirname, "/icons/png/64x64.png") }); contextMenu({ showCopyImageAddress: true, showSaveImageAs: true, showInspectElement: true, showInspectElement: true }); window.loadURL(url) }) No newline at end of file window.loadURL(url); });
app/app.js +83 −68 Original line number Diff line number Diff line // Required packages const electron = require('electron') const { dialog } = require('electron') const electron = require("electron"); const { dialog } = require("electron"); const updater = require("electron-updater"); const autoUpdater = updater.autoUpdater; const contextMenu = require('electron-context-menu') const path = require('path') const contextMenu = require("electron-context-menu"); const path = require("path"); // Attach settings store const { store } = require('./store') const { store } = require("./store"); // Auto upadater autoUpdater.autoDownload = false; autoUpdater.on('checking-for-update', function () {}); autoUpdater.on('update-available', function (info) { sendStatusToWindow('Update available.' + info) dialog.showMessageBox(mainWindow, { type: 'info', title: 'Update available', message: 'A new version of OpenFlexure eV is available.', buttons: ['Download', 'Later'] }, (buttonIndex) => { autoUpdater.on("checking-for-update", function() {}); autoUpdater.on("update-available", function(info) { sendStatusToWindow("Update available." + info); dialog.showMessageBox( mainWindow, { type: "info", title: "Update available", message: "A new version of OpenFlexure eV is available.", buttons: ["Download", "Later"] }, buttonIndex => { if (buttonIndex === 0) { autoUpdater.downloadUpdate() autoUpdater.downloadUpdate(); } } }) ); }); autoUpdater.on('update-downloaded', function (info) { sendStatusToWindow('Update downloaded.' + info) dialog.showMessageBox(mainWindow, { type: 'info', autoUpdater.on("update-downloaded", function(info) { sendStatusToWindow("Update downloaded." + info); dialog.showMessageBox( mainWindow, { type: "info", title: "Update downloaded", message: 'Please restart the application to apply the update.', buttons: ['Update', 'Later'] }, (buttonIndex) => { message: "Please restart the application to apply the update.", buttons: ["Update", "Later"] }, buttonIndex => { if (buttonIndex === 0) { autoUpdater.quitAndInstall(); } }) } ); }); autoUpdater.on('update-not-available', function (info) { sendStatusToWindow('Update not available.'); autoUpdater.on("update-not-available", function() { sendStatusToWindow("Update not available."); }); autoUpdater.on('error', function (err) { sendStatusToWindow('Error in auto-updater.'); autoUpdater.on("error", function() { sendStatusToWindow("Error in auto-updater."); }); autoUpdater.on('download-progress', function (progressObj) { autoUpdater.on("download-progress", function(progressObj) { let log_message = "Download speed: " + progressObj.bytesPerSecond; log_message = log_message + ' - Downloaded ' + parseInt(progressObj.percent) + '%'; log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')'; log_message = log_message + " - Downloaded " + parseInt(progressObj.percent) + "%"; log_message = log_message + " (" + progressObj.transferred + "/" + progressObj.total + ")"; sendStatusToWindow(log_message); }); Loading @@ -62,83 +77,83 @@ function sendStatusToWindow(message) { } // Set up the app const app = electron.app const BrowserWindow = electron.BrowserWindow const app = electron.app; const BrowserWindow = electron.BrowserWindow; // Set the window content let url = `file://${path.join(__dirname, '/dist/index.html')}` let mainWindow let url = `file://${path.join(__dirname, "/dist/index.html")}`; let mainWindow; // Set the application menu require('./menu.js') require("./menu.js"); // Handle redrawing the mainWindow let recreatingWindowInProgress = false; function toggleCustomTitleBar() { // Mark window as being recreated, to prevent stopping the application recreatingWindowInProgress = true recreatingWindowInProgress = true; // Invert the drawCustomTitleBar setting store.set('drawCustomTitleBar', !store.get('drawCustomTitleBar')) store.set("drawCustomTitleBar", !store.get("drawCustomTitleBar")); // Destroy old window mainWindow.destroy() mainWindow.destroy(); // Create new window createWindow() createWindow(); // Mark window as no longer being recreated recreatingWindowInProgress = false recreatingWindowInProgress = false; } function createWindow() { // Create the browser window. mainWindow = new BrowserWindow({ frame: !store.get('drawCustomTitleBar'), frame: !store.get("drawCustomTitleBar"), width: 1124, height: 800, icon: path.join(__dirname, '/icons/png/64x64.png'), icon: path.join(__dirname, "/icons/png/64x64.png"), webPreferences: { nodeIntegration: true } }) }); // Make a context menu contextMenu({ showCopyImageAddress: true, showSaveImageAs: true, showInspectElement: false, showInspectElement: false }); // Load window contents mainWindow.loadURL(url) mainWindow.loadURL(url); // Check for updates autoUpdater.checkForUpdates(); // Emitted when the window is closed. mainWindow.on('closed', function() { mainWindow = null // Dereference the window object }) mainWindow.on("closed", function() { mainWindow = null; // Dereference the window object }); } // Some APIs can only be used after this event occurs. app.on('ready', () => { createWindow() }) app.on("ready", () => { createWindow(); }); // Quit when all windows are closed. app.on('window-all-closed', function() { if ((process.platform !== 'darwin') && recreatingWindowInProgress != true) { app.quit() app.on("window-all-closed", function() { if (process.platform !== "darwin" && recreatingWindowInProgress != true) { app.quit(); } }) }); app.on('activate', function() { app.on("activate", function() { if (mainWindow === null) { createWindow() createWindow(); } }) }); // Export toggleCustomTitleBar for use in ./menu.js module.exports.toggleCustomTitleBar = toggleCustomTitleBar No newline at end of file module.exports.toggleCustomTitleBar = toggleCustomTitleBar;
app/menu.js +72 −79 Original line number Diff line number Diff line const { app, shell, Menu } = require('electron') const { app, shell, Menu } = require("electron"); const updater = require("electron-updater"); const autoUpdater = updater.autoUpdater; const path = require('path') const path = require("path"); const openAboutWindow = require('about-window').default const openAboutWindow = require("about-window").default; const main = require('./app') const { store } = require('./store') const main = require("./app"); const { store } = require("./store"); const template = [ { label: 'Edit', label: "Edit", submenu: [ { role: 'undo' }, { role: 'redo' }, { type: 'separator' }, { role: 'cut' }, { role: 'copy' }, { role: 'paste' }, { role: 'delete' }, { role: 'selectall' } { role: "undo" }, { role: "redo" }, { type: "separator" }, { role: "cut" }, { role: "copy" }, { role: "paste" }, { role: "delete" }, { role: "selectall" } ] }, { label: 'View', label: "View", submenu: [ { role: 'reload' }, { role: 'forcereload' }, { role: 'toggledevtools' }, { type: 'separator' }, { role: 'togglefullscreen' }, { type: 'separator' }, { role: "reload" }, { role: "forcereload" }, { role: "toggledevtools" }, { type: "separator" }, { role: "togglefullscreen" }, { type: "separator" }, { type: 'checkbox', checked: store.get('drawCustomTitleBar'), label: 'Custom titlebar', type: "checkbox", checked: store.get("drawCustomTitleBar"), label: "Custom titlebar", click() { main.toggleCustomTitleBar() main.toggleCustomTitleBar(); } } ] }, { role: 'window', submenu: [ { role: 'minimize' }, { role: 'close' } ] role: "window", submenu: [{ role: "minimize" }, { role: "close" }] }, { role: 'help', role: "help", submenu: [ { label: 'About', label: "About", click() { openAboutWindow({ package_json_dir: path.join(__dirname, '..'), icon_path: path.join(__dirname, '/icons/png/512x512.png'), bug_report_url: "https://gitlab.com/openflexure/openflexure-microscope-jsclient/issues", homepage: "https://gitlab.com/openflexure/openflexure-microscope-jsclient", }) package_json_dir: path.join(__dirname, ".."), icon_path: path.join(__dirname, "/icons/png/512x512.png"), bug_report_url: "https://gitlab.com/openflexure/openflexure-microscope-jsclient/issues", homepage: "https://gitlab.com/openflexure/openflexure-microscope-jsclient" }); } }, { label: 'Homepage', label: "Homepage", click() { shell.openExternal('https://openflexure.org') shell.openExternal("https://openflexure.org"); } }, { type: 'separator' }, { type: "separator" }, { label: 'Check for Updates', label: "Check for Updates", click() { autoUpdater.checkForUpdates(); } } ] } ] ]; if (process.platform === 'darwin') { if (process.platform === "darwin") { template.unshift({ label: app.getName(), submenu: [ { role: 'about' }, { type: 'separator' }, { role: 'services' }, { type: 'separator' }, { role: 'hide' }, { role: 'hideothers' }, { role: 'unhide' }, { type: 'separator' }, { role: 'quit' } { role: "about" }, { type: "separator" }, { role: "services" }, { type: "separator" }, { role: "hide" }, { role: "hideothers" }, { role: "unhide" }, { type: "separator" }, { role: "quit" } ] }) }); // Edit menu template[1].submenu.push( { type: 'separator' }, { type: "separator" }, { label: 'Speech', submenu: [ { role: 'startspeaking' }, { role: 'stopspeaking' } ] label: "Speech", submenu: [{ role: "startspeaking" }, { role: "stopspeaking" }] } ) ); // Window menu template[3].submenu = [ { role: 'close' }, { role: 'minimize' }, { role: 'zoom' }, { type: 'separator' }, { role: 'front' } ] } else { { role: "close" }, { role: "minimize" }, { role: "zoom" }, { type: "separator" }, { role: "front" } ]; } else { template.unshift({ label: 'File', submenu: [ { role: 'quit' } ] }) label: "File", submenu: [{ role: "quit" }] }); } const menu = Menu.buildFromTemplate(template) Menu.setApplicationMenu(menu) No newline at end of file const menu = Menu.buildFromTemplate(template); Menu.setApplicationMenu(menu);
app/store.js +4 −4 Original line number Diff line number Diff line const Store = require('electron-store'); const Store = require("electron-store"); const store = new Store(); if (store.has('drawCustomTitleBar') !== true) { if (store.has("drawCustomTitleBar") !== true) { // Default to false if on MacOS, otherwise true store.set('drawCustomTitleBar', (process.platform === 'win32') ? true : false) store.set("drawCustomTitleBar", process.platform === "win32" ? true : false); } module.exports.store = store No newline at end of file module.exports.store = store;