diff --git a/src/khoj/interface/web/config.html b/src/khoj/interface/web/config.html index b808ef33..64841f97 100644 --- a/src/khoj/interface/web/config.html +++ b/src/khoj/interface/web/config.html @@ -635,85 +635,6 @@ // List user's API keys on page load listApiKeys(); - function deleteAutomation(automationId) { - const AutomationList = document.getElementById("automations-list"); - fetch(`/api/automation?automation_id=${automationId}`, { - method: 'DELETE', - }) - .then(response => { - if (response.status == 200) { - const AutomationItem = document.getElementById(`automation-item-${automationId}`); - AutomationList.removeChild(AutomationItem); - } - }); - } - - function generateAutomationRow(automationObj) { - let automationId = automationObj.id; - let automationNextRun = `Next run at ${automationObj.next}`; - return ` - - ${automationObj.subject} - ${automationObj.scheduling_request} - ${automationObj.query_to_run} - ${automationObj.schedule} - - Delete Automation - Edit Automation - - - `; - } - - function listAutomations() { - const AutomationsList = document.getElementById("automations-list"); - fetch('/api/automations') - .then(response => response.json()) - .then(automations => { - if (!automations?.length > 0) return; - AutomationsList.innerHTML = automations.map(generateAutomationRow).join(""); - }); - } - - async function createAutomation() { - const scheduling_request = window.prompt("Describe the automation you want to create"); - if (!scheduling_request) return; - - const ip_response = await fetch("https://ipapi.co/json"); - const ip_data = await ip_response.json(); - - const query_string = `q=${scheduling_request}&city=${ip_data.city}®ion=${ip_data.region}&country=${ip_data.country_name}&timezone=${ip_data.timezone}`; - const automation_response = await fetch(`/api/automation?${query_string}`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - }); - if (!automation_response.ok) { - throw new Error(`Failed to create automation: ${automation_response.status}`); - } - - listAutomations(); - } - document.getElementById("create-automation").addEventListener("click", async () => { await createAutomation(); }); - - function editAutomation(automationId) { - const query_to_run = window.prompt("What is the query you want to run on this automation's schedule?"); - if (!query_to_run) return; - - fetch(`/api/automation?automation_id=${automationId}&query_to_run=${query_to_run}`, { - method: 'PATCH', - headers: { - 'Content-Type': 'application/json', - }, - }).then(response => { - if (response.ok) { - const automationQueryToRunColumn = document.getElementById(`automation-query-to-run-${automationId}`); - automationQueryToRunColumn.innerHTML = `${query_to_run}`; - } - }); - } - function getIndexedDataSize() { document.getElementById("indexed-data-size").innerHTML = "Calculating..."; fetch('/api/config/index/size') @@ -723,9 +644,6 @@ }); } - // List user's automations on page load - listAutomations(); - function removeFile(path) { fetch('/api/config/data/file?filename=' + path, { method: 'DELETE',