mirror of
https://github.com/frappe/books.git
synced 2026-08-24 02:24:17 -05:00
feat: schedule ERPNext data sync using Bree cron jobs
This commit is contained in:
@@ -82,6 +82,10 @@ const ipc = {
|
||||
)) as TemplateFile[];
|
||||
},
|
||||
|
||||
async initScheduler(time: string) {
|
||||
await ipcRenderer.invoke(IPC_ACTIONS.INIT_SHEDULER, time);
|
||||
},
|
||||
|
||||
async selectFile(options: SelectFileOptions): Promise<SelectFileReturn> {
|
||||
return (await ipcRenderer.invoke(
|
||||
IPC_ACTIONS.SELECT_FILE,
|
||||
@@ -210,6 +214,10 @@ const ipc = {
|
||||
ipcRenderer.on(IPC_CHANNELS.LOG_MAIN_PROCESS_ERROR, listener);
|
||||
},
|
||||
|
||||
registerTriggerFrontendActionListener(listener: IPCRendererListener) {
|
||||
ipcRenderer.on(IPC_CHANNELS.TRIGGER_FRONTEND_ACTION, listener);
|
||||
},
|
||||
|
||||
registerConsoleLogListener(listener: IPCRendererListener) {
|
||||
ipcRenderer.on(IPC_CHANNELS.CONSOLE_LOG, listener);
|
||||
},
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
} from './helpers';
|
||||
import { saveHtmlAsPdf } from './saveHtmlAsPdf';
|
||||
import { sendAPIRequest } from './api';
|
||||
import { initScheduler } from './initSheduler';
|
||||
|
||||
export default function registerIpcMainActionListeners(main: Main) {
|
||||
ipcMain.handle(IPC_ACTIONS.CHECK_DB_ACCESS, async (_, filePath: string) => {
|
||||
@@ -246,6 +247,10 @@ export default function registerIpcMainActionListeners(main: Main) {
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.handle(IPC_ACTIONS.INIT_SHEDULER, async (_, interval: string) => {
|
||||
return initScheduler(interval);
|
||||
});
|
||||
|
||||
ipcMain.handle(
|
||||
IPC_ACTIONS.SEND_API_REQUEST,
|
||||
async (e, endpoint: string, options: RequestInit | undefined) => {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"@codemirror/lang-vue": "^0.1.1",
|
||||
"@popperjs/core": "^2.10.2",
|
||||
"better-sqlite3": "^9.2.2",
|
||||
"bree": "^9.2.4",
|
||||
"codemirror": "^6.0.1",
|
||||
"core-js": "^3.19.0",
|
||||
"electron-store": "^8.0.1",
|
||||
|
||||
+3
-2
@@ -71,7 +71,6 @@ import { routeTo } from './utils/ui';
|
||||
import { useKeys } from './utils/vueUtils';
|
||||
import { setDarkMode } from 'src/utils/theme';
|
||||
import {
|
||||
initERPNSync,
|
||||
registerInstanceToERPNext,
|
||||
updateERPNSyncSettings,
|
||||
} from './utils/erpnextSync';
|
||||
@@ -231,7 +230,9 @@ export default defineComponent({
|
||||
await updatePrintTemplates(fyo);
|
||||
await registerInstanceToERPNext(fyo);
|
||||
await updateERPNSyncSettings(fyo);
|
||||
initERPNSync(fyo);
|
||||
await ipc.initScheduler(
|
||||
`${fyo.singles.ERPNextSyncSettings?.dataSyncInterval as string}m`
|
||||
);
|
||||
await this.setDesk(filePath);
|
||||
},
|
||||
async handleConnectionFailed(error: Error, actionSymbol: symbol) {
|
||||
|
||||
@@ -32,6 +32,7 @@ export enum IPC_ACTIONS {
|
||||
GET_CREDS = 'get-creds',
|
||||
GET_DB_LIST = 'get-db-list',
|
||||
GET_TEMPLATES = 'get-templates',
|
||||
INIT_SHEDULER = 'init-scheduler',
|
||||
DELETE_FILE = 'delete-file',
|
||||
GET_DB_DEFAULT_PATH = 'get-db-default-path',
|
||||
SEND_API_REQUEST = 'send-api-request',
|
||||
@@ -47,6 +48,7 @@ export enum IPC_ACTIONS {
|
||||
export enum IPC_CHANNELS {
|
||||
LOG_MAIN_PROCESS_ERROR = 'main-process-error',
|
||||
CONSOLE_LOG = 'console-log',
|
||||
TRIGGER_FRONTEND_ACTION = 'trigger-frontend-action',
|
||||
}
|
||||
|
||||
export enum DB_CONN_FAILURE {
|
||||
|
||||
Reference in New Issue
Block a user