antares/src/main/ipc-handlers/routines.ts

45 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-04-15 14:56:13 +02:00
import * as antares from 'common/interfaces/antares';
2021-01-05 17:25:18 +01:00
import { ipcMain } from 'electron';
2022-04-15 14:56:13 +02:00
export default (connections: {[key: string]: antares.Client}) => {
2021-01-05 17:25:18 +01:00
ipcMain.handle('get-routine-informations', async (event, params) => {
try {
const result = await connections[params.uid].getRoutineInformations(params);
return { status: 'success', response: result };
}
catch (err) {
return { status: 'error', response: err.toString() };
}
});
ipcMain.handle('drop-routine', async (event, params) => {
try {
await connections[params.uid].dropRoutine(params);
return { status: 'success' };
}
catch (err) {
return { status: 'error', response: err.toString() };
}
});
ipcMain.handle('alter-routine', async (event, params) => {
try {
await connections[params.uid].alterRoutine(params);
return { status: 'success' };
}
catch (err) {
return { status: 'error', response: err.toString() };
}
});
ipcMain.handle('create-routine', async (event, params) => {
try {
await connections[params.uid].createRoutine(params);
return { status: 'success' };
}
catch (err) {
return { status: 'error', response: err.toString() };
}
});
};