diff --git a/src-electron/main.js b/src-electron/main.js index fef49d00..ae7a5b9d 100644 --- a/src-electron/main.js +++ b/src-electron/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow } = require('electron'); +const { app, BrowserWindow, ipcMain } = require('electron'); const setupMenu = require('./menu'); let mainWindow; @@ -27,7 +27,7 @@ function createWindow() { mainWindow = new BrowserWindow({ vibrancy: 'sidebar', transparent: true, - backgroundColor: "#80FFFFFF", + backgroundColor: '#80FFFFFF', width: 1200, height: 907, frame: false, @@ -48,6 +48,10 @@ function createWindow() { setupMenu(); } +ipcMain.on('reload-main-window', () => { + mainWindow.reload(); +}); + app.on('ready', createWindow); app.on('window-all-closed', () => { diff --git a/src/main-electron.js b/src/main-electron.js index 045021e9..9a149f2d 100644 --- a/src/main-electron.js +++ b/src/main-electron.js @@ -6,6 +6,7 @@ import common from 'frappejs/common'; import coreModels from 'frappejs/models'; import models from '../models'; import postStart from '../server/postStart'; +import { ipcRenderer } from 'electron'; import { getSettings, saveSettings } from '../electron/settings'; // vue imports @@ -57,6 +58,10 @@ import Toasted from 'vue-toasted'; } }); + frappe.events.on('reload-main-window', () => { + ipcRenderer.send('reload-main-window'); + }); + frappe.events.on('SetupWizard:setup-complete', async setupWizardValues => { const countryList = require('../fixtures/countryInfo.json'); const { diff --git a/src/pages/DatabaseSelector.vue b/src/pages/DatabaseSelector.vue index 52496ba7..153e2d6f 100644 --- a/src/pages/DatabaseSelector.vue +++ b/src/pages/DatabaseSelector.vue @@ -53,9 +53,7 @@ + diff --git a/src/router.js b/src/router.js index 0600c073..8003b836 100644 --- a/src/router.js +++ b/src/router.js @@ -110,4 +110,8 @@ const routes = [ let router = new Router({ routes }); +if (process.env.NODE_ENV === 'development') { + window.router = router +} + export default router; diff --git a/src/utils.js b/src/utils.js new file mode 100644 index 00000000..584ed20a --- /dev/null +++ b/src/utils.js @@ -0,0 +1,40 @@ +import { _ } from 'frappejs'; +import { remote } from 'electron'; + +export function createNewDatabase() { + return new Promise(resolve => { + remote.dialog.showSaveDialog( + remote.getCurrentWindow(), + { + title: _('Select folder'), + defaultPath: 'frappe-accounting.db' + }, + filePath => { + if (filePath) { + if (!filePath.endsWith('.db')) { + filePath = filePath + '.db'; + } + resolve(filePath); + } + } + ); + }); +} + +export function loadExistingDatabase() { + return new Promise(resolve => { + remote.dialog.showOpenDialog( + remote.getCurrentWindow(), + { + title: _('Select file'), + properties: ['openFile'], + filters: [{ name: 'SQLite DB File', extensions: ['db'] }] + }, + files => { + if (files && files[0]) { + resolve(files[0]); + } + } + ); + }); +}