Task 13: Create Automation Controller with IPC handlers
Implements the automation controller with three IPC handlers for automation operations: - automation:clean - Returns NOT_IMPLEMENTED (TODO: later phase) - automation:extract - Returns NOT_IMPLEMENTED (TODO: later phase) - automation:stop - Returns success (TODO: task cancellation in later phase) Each handler: - Logs requests via LoggerService - Returns structured AutomationResponse with success/error fields - Uses proper TypeScript typing Updates: - Created src/main/controllers/automation.controller.ts - Updated src/main/index.ts to register automation handlers - Updated src/main/models/ipc.types.ts with AutomationResponse interface Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
32
src/main/controllers/automation.controller.ts
Normal file
32
src/main/controllers/automation.controller.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { ipcMain, IpcMainInvokeEvent } from 'electron';
|
||||
import { LoggerService } from '../services/logger.service';
|
||||
|
||||
export function registerAutomationHandlers(): void {
|
||||
LoggerService.info('Registering automation handlers');
|
||||
|
||||
ipcMain.handle('automation:clean', async (event: IpcMainInvokeEvent, params: any) => {
|
||||
LoggerService.info('Clean automation requested');
|
||||
// TODO: Implement in Phase 4
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'NOT_IMPLEMENTED', message: 'Not yet implemented' },
|
||||
};
|
||||
});
|
||||
|
||||
ipcMain.handle('automation:extract', async (event: IpcMainInvokeEvent, params: any) => {
|
||||
LoggerService.info('Extract automation requested');
|
||||
// TODO: Implement in Phase 4
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'NOT_IMPLEMENTED', message: 'Not yet implemented' },
|
||||
};
|
||||
});
|
||||
|
||||
ipcMain.handle('automation:stop', async (event: IpcMainInvokeEvent, params: any) => {
|
||||
LoggerService.info('Stop automation requested');
|
||||
// TODO: Implement task cancellation
|
||||
return {
|
||||
success: true,
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { app, shell, BrowserWindow, ipcMain } from 'electron'
|
||||
import { join } from 'path'
|
||||
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
||||
import icon from '../../resources/icon.png?asset'
|
||||
import { registerAutomationHandlers } from './controllers/automation.controller'
|
||||
|
||||
function createWindow(): void {
|
||||
// Create the browser window.
|
||||
@@ -53,8 +54,9 @@ app.whenReady().then(() => {
|
||||
ipcMain.on('ping', () => console.log('pong'))
|
||||
|
||||
// IPC Handler Registration
|
||||
registerAutomationHandlers()
|
||||
// TODO: Register IPC handlers for:
|
||||
// - automation:clean, automation:extract, automation:stop, automation:progress
|
||||
// - automation:progress
|
||||
// - database:query-production-orders, database:query-materials-to-delete
|
||||
// - auth:login, auth:logout
|
||||
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
/**
|
||||
* Response structure for automation IPC handlers
|
||||
*/
|
||||
export interface AutomationResponse {
|
||||
success: boolean;
|
||||
error?: {
|
||||
code: string;
|
||||
message: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IPCChannels {
|
||||
'automation:clean': any;
|
||||
'automation:extract': any;
|
||||
'automation:stop': any;
|
||||
'automation:clean': () => Promise<AutomationResponse>;
|
||||
'automation:extract': () => Promise<AutomationResponse>;
|
||||
'automation:stop': () => Promise<AutomationResponse>;
|
||||
'automation:progress': any;
|
||||
'database:query-production-orders': any;
|
||||
'database:query-materials-to-delete': any;
|
||||
|
||||
Reference in New Issue
Block a user