diff --git a/src/main/ipc-handlers/schedulers.js b/src/main/ipc-handlers/schedulers.js index 4133fbed..f270beb3 100644 --- a/src/main/ipc-handlers/schedulers.js +++ b/src/main/ipc-handlers/schedulers.js @@ -40,4 +40,17 @@ export default (connections) => { return { status: 'error', response: err.toString() }; } }); + + ipcMain.handle('toggle-scheduler', async (event, params) => { + try { + if (!params.enabled) + await connections[params.uid].enableEvent({ ...params }); + else + await connections[params.uid].disableEvent({ ...params }); + return { status: 'success' }; + } + catch (err) { + return { status: 'error', response: err.toString() }; + } + }); }; diff --git a/src/main/ipc-handlers/triggers.js b/src/main/ipc-handlers/triggers.js index 00ad9834..89df9a15 100644 --- a/src/main/ipc-handlers/triggers.js +++ b/src/main/ipc-handlers/triggers.js @@ -45,10 +45,8 @@ export default (connections) => { try { if (!params.enabled) await connections[params.uid].enableTrigger(params); - else await connections[params.uid].disableTrigger(params); - return { status: 'success' }; } catch (err) { diff --git a/src/main/libs/clients/MySQLClient.js b/src/main/libs/clients/MySQLClient.js index e9c9a081..d5b79b2d 100644 --- a/src/main/libs/clients/MySQLClient.js +++ b/src/main/libs/clients/MySQLClient.js @@ -1072,6 +1072,16 @@ export class MySQLClient extends AntaresCore { return await this.raw(sql, { split: false }); } + async enableEvent ({ schema, scheduler }) { + const sql = `ALTER EVENT \`${schema}\`.\`${scheduler}\` ENABLE`; + return await this.raw(sql, { split: false }); + } + + async disableEvent ({ schema, scheduler }) { + const sql = `ALTER EVENT \`${schema}\`.\`${scheduler}\` DISABLE`; + return await this.raw(sql, { split: false }); + } + /** * SHOW COLLATION * diff --git a/src/renderer/components/WorkspaceExploreBarMiscContext.vue b/src/renderer/components/WorkspaceExploreBarMiscContext.vue index 864e4221..f9807613 100644 --- a/src/renderer/components/WorkspaceExploreBarMiscContext.vue +++ b/src/renderer/components/WorkspaceExploreBarMiscContext.vue @@ -22,6 +22,18 @@ {{ $t('word.disable') }} +