From d9b3482b1a03b83d00ec087caf67889de4d7e112 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Sat, 4 May 2024 11:10:49 +0530 Subject: [PATCH] Show error when required fields to create automation are not set --- src/khoj/interface/web/config_automation.html | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/khoj/interface/web/config_automation.html b/src/khoj/interface/web/config_automation.html index 80a929002..d307a463e 100644 --- a/src/khoj/interface/web/config_automation.html +++ b/src/khoj/interface/web/config_automation.html @@ -232,13 +232,25 @@

} async function saveAutomation(automationId, create=false) { - const queryToRun = encodeURIComponent(document.getElementById(`automation-queryToRun-${automationId}`).value); const scheduleEl = document.getElementById(`automation-schedule-${automationId}`); const notificationEl = document.getElementById(`automation-success-${automationId}`); const saveButtonEl = document.getElementById(`save-automation-button-${automationId}`); + const queryToRunEl = document.getElementById(`automation-queryToRun-${automationId}`); + const queryToRun = encodeURIComponent(queryToRunEl.value); const actOn = create ? "Create" : "Save"; if (queryToRun == "" || scheduleEl.value == "") { + notificationEl.textContent = `⚠️ Failed to automate. All input fields need to be filled.`; + notificationEl.style.display = "block"; + let originalQueryToRunElBorder = queryToRunEl.style.border; + if (queryToRun === "") queryToRunEl.style.border = "2px solid red"; + let originalScheduleElBorder = scheduleEl.style.border; + if (scheduleEl.value === "") scheduleEl.style.border = "2px solid red"; + setTimeout(function() { + if (queryToRun == "") queryToRunEl.style.border = originalQueryToRunElBorder; + if (scheduleEl.value == "") scheduleEl.style.border = originalScheduleElBorder; + }, 2000); + return; }