From 947a6b75cb9d2d431d23ecfd98ec20cc1a27e855 Mon Sep 17 00:00:00 2001 From: RohitR311 Date: Thu, 19 Dec 2024 16:16:47 +0530 Subject: [PATCH] feat: check for time input field and emit socket event --- .../workflow-management/classes/Generator.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/server/src/workflow-management/classes/Generator.ts b/server/src/workflow-management/classes/Generator.ts index 3395e9a1..9ff4922e 100644 --- a/server/src/workflow-management/classes/Generator.ts +++ b/server/src/workflow-management/classes/Generator.ts @@ -295,6 +295,26 @@ export class WorkflowGenerator { await this.addPairToWorkflowAndNotifyClient(pair, page); }; + public onTimeSelection = async (page: Page, data: { selector: string, value: string }) => { + const { selector, value } = data; + + try { + await page.fill(selector, value); + } catch (error) { + console.error("Failed to set time value:", error); + } + + const pair: WhereWhatPair = { + where: { url: this.getBestUrl(page.url()) }, + what: [{ + action: 'fill', + args: [selector, value], + }], + }; + + await this.addPairToWorkflowAndNotifyClient(pair, page); + }; + /** * Generates a pair for the click event. * @param coordinates The coordinates of the click event. @@ -360,6 +380,16 @@ export class WorkflowGenerator { return; } + const isTimeInput = elementInfo?.tagName === 'INPUT' && elementInfo?.attributes?.type === 'time'; + + if (isTimeInput) { + this.socket.emit('showTimePicker', { + coordinates, + selector + }); + return; + } + //const element = await getElementMouseIsOver(page, coordinates); //logger.log('debug', `Element: ${JSON.stringify(element, null, 2)}`); if (selector) {