diff --git a/src/khoj/interface/web/assets/icons/confirm-icon.svg b/src/khoj/interface/web/assets/icons/confirm-icon.svg new file mode 100644 index 00000000..98d30500 --- /dev/null +++ b/src/khoj/interface/web/assets/icons/confirm-icon.svg @@ -0,0 +1 @@ +confirm diff --git a/src/khoj/interface/web/base_config.html b/src/khoj/interface/web/base_config.html index d15f63e4..6d3d8655 100644 --- a/src/khoj/interface/web/base_config.html +++ b/src/khoj/interface/web/base_config.html @@ -55,7 +55,7 @@ gap: 8px; padding: 24px 16px; width: 320px; - height: 160px; + height: 180px; background: white; border: 1px solid rgb(229, 229, 229); border-radius: 4px; @@ -114,6 +114,22 @@ font-size: 16px; } + button.card-button { + color: rgb(255, 136, 136); + background: transparent; + font-size: 16px; + cursor: pointer; + margin: 0; + padding: 0; + height: 32px; + text-align: right; + text-align: left; + } + + img.configured-icon { + max-width: 16px; + } + @media screen and (max-width: 600px) { .section-cards { grid-template-columns: 1fr; diff --git a/src/khoj/interface/web/config.html b/src/khoj/interface/web/config.html index 01718fdf..2e6f6fdd 100644 --- a/src/khoj/interface/web/config.html +++ b/src/khoj/interface/web/config.html @@ -8,62 +8,127 @@
Github -

Github

+

+ Github + {% if current_config.content_type.github %} + Configured + {% endif %} +

+

Set repositories for Khoj to index

- Setup + {% if current_config.content_type.github %} + Update + {% else %} + Setup + {% endif %}
+ {% if current_config.content_type.github %} +
+ +
+ {% endif %}
markdown -

Markdown

+

+ Markdown + {% if current_config.content_type.markdown %} + Configured + {% endif %} +

Set markdown files for Khoj to index

- Setup + {% if current_config.content_type.markdown %} + Update + {% else %} + Setup + {% endif %}
+ {% if current_config.content_type.markdown %} +
+ +
+ {% endif %}
org -

Org

+

+ Org + {% if current_config.content_type.org %} + Configured + {% endif %} +

Set org files for Khoj to index

- Setup + {% if current_config.content_type.org %} + Update + {% else %} + Setup + {% endif %}
+ {% if current_config.content_type.org %} +
+ +
+ {% endif %}
PDF -

PDF

+

+ PDF + {% if current_config.content_type.pdf %} + Configured + {% endif %} +

Set PDF files for Khoj to index

- Setup + {% if current_config.content_type.pdf %} + Update + {% else %} + Setup + {% endif %}
+ {% if current_config.content_type.pdf %} +
+ +
+ {% endif %}
@@ -73,26 +138,85 @@
Chat -

Chat

+

+ Chat + {% if current_config.processor and current_config.processor.conversation %} + Configured + {% endif %} +

-

Setup Khoj Chat

+

Setup Khoj Chat with OpenAI

- - Setup - - + + {% if current_config.processor and current_config.processor.conversation %} + Update + {% else %} + Setup + {% endif %} + +
+ {% if current_config.processor and current_config.processor.conversation %} +
+ +
+ {% endif %}
+
{% endblock %} diff --git a/src/khoj/interface/web/content_type_github_input.html b/src/khoj/interface/web/content_type_github_input.html index f22f00cf..27263532 100644 --- a/src/khoj/interface/web/content_type_github_input.html +++ b/src/khoj/interface/web/content_type_github_input.html @@ -35,9 +35,9 @@ {% endfor %} -

You probably don't need to edit these.

+

You probably don't need to edit these.

- +
@@ -160,7 +160,7 @@ .then(response => response.json()) .then(data => { if (data["status"] == "ok") { - document.getElementById("success").innerHTML = "✅ Successfully updated. Click Configure on your settings page to complete your Khoj setup."; + document.getElementById("success").innerHTML = "✅ Successfully updated. Go to your settings page to complete setup."; document.getElementById("success").style.display = "block"; } else { document.getElementById("success").innerHTML = "⚠️ Failed to update settings."; diff --git a/src/khoj/interface/web/content_type_input.html b/src/khoj/interface/web/content_type_input.html index 369a5e51..17566149 100644 --- a/src/khoj/interface/web/content_type_input.html +++ b/src/khoj/interface/web/content_type_input.html @@ -44,9 +44,9 @@
-

You probably don't need to edit these.

+

You probably don't need to edit these.

- +
@@ -149,7 +149,7 @@ .then(response => response.json()) .then(data => { if (data["status"] == "ok") { - document.getElementById("success").innerHTML = "✅ Successfully updated. Click Configure on your settings page to complete your Khoj setup."; + document.getElementById("success").innerHTML = "✅ Successfully updated. Go to your settings page to complete setup."; document.getElementById("success").style.display = "block"; } else { document.getElementById("success").innerHTML = "⚠️ Failed to update settings."; diff --git a/src/khoj/interface/web/processor_conversation_input.html b/src/khoj/interface/web/processor_conversation_input.html index f07b8bba..46c96b12 100644 --- a/src/khoj/interface/web/processor_conversation_input.html +++ b/src/khoj/interface/web/processor_conversation_input.html @@ -17,11 +17,8 @@
- -

You probably don't need to edit these.

- - - +
+ @@ -78,7 +75,7 @@ .then(response => response.json()) .then(data => { if (data["status"] == "ok") { - document.getElementById("success").innerHTML = "✅ Successfully updated. Click Configure on your settings page to complete your Khoj setup."; + document.getElementById("success").innerHTML = "✅ Successfully updated. Go to your settings page to complete setup."; document.getElementById("success").style.display = "block"; } else { document.getElementById("success").innerHTML = "⚠️ Failed to update settings."; diff --git a/src/khoj/routers/api.py b/src/khoj/routers/api.py index bec66ac8..259919bc 100644 --- a/src/khoj/routers/api.py +++ b/src/khoj/routers/api.py @@ -54,7 +54,7 @@ if not state.demo: return state.config @api.post("/config/data/content_type/github", status_code=200) - async def set_content_config_github_data(updated_config: GithubContentConfig): + async def set_content_config_github_data(updated_config: Union[GithubContentConfig, None]): if not state.config: state.config = FullConfig() state.config.search_type = SearchConfig.parse_obj(constants.default_config["search-type"]) @@ -70,8 +70,35 @@ if not state.demo: except Exception as e: return {"status": "error", "message": str(e)} + @api.post("/delete/config/data/content_type/{content_type}", status_code=200) + async def remove_content_config_data(content_type: str): + if not state.config or not state.config.content_type: + return {"status": "ok"} + + if state.config.content_type: + state.config.content_type[content_type] = None + + try: + save_config_to_file_updated_state() + return {"status": "ok"} + except Exception as e: + return {"status": "error", "message": str(e)} + + @api.post("/delete/config/data/processor/conversation", status_code=200) + async def remove_processor_conversation_config_data(): + if not state.config or not state.config.processor or not state.config.processor.conversation: + return {"status": "ok"} + + state.config.processor.conversation = None + + try: + save_config_to_file_updated_state() + return {"status": "ok"} + except Exception as e: + return {"status": "error", "message": str(e)} + @api.post("/config/data/content_type/{content_type}", status_code=200) - async def set_content_config_data(content_type: str, updated_config: TextContentConfig): + async def set_content_config_data(content_type: str, updated_config: Union[TextContentConfig, None]): if not state.config: state.config = FullConfig() state.config.search_type = SearchConfig.parse_obj(constants.default_config["search-type"]) @@ -88,7 +115,7 @@ if not state.demo: return {"status": "error", "message": str(e)} @api.post("/config/data/processor/conversation", status_code=200) - async def set_processor_conversation_config_data(updated_config: ConversationProcessorConfig): + async def set_processor_conversation_config_data(updated_config: Union[ConversationProcessorConfig, None]): if not state.config: state.config = FullConfig() state.config.search_type = SearchConfig.parse_obj(constants.default_config["search-type"]) diff --git a/src/khoj/routers/web_client.py b/src/khoj/routers/web_client.py index 6ab94181..72070fb0 100644 --- a/src/khoj/routers/web_client.py +++ b/src/khoj/routers/web_client.py @@ -34,7 +34,8 @@ if not state.demo: @web_client.get("/config", response_class=HTMLResponse) def config_page(request: Request): - return templates.TemplateResponse("config.html", context={"request": request}) + current_config = state.config if state.config else constants.default_config + return templates.TemplateResponse("config.html", context={"request": request, "current_config": current_config}) @web_client.get("/config/content_type/github", response_class=HTMLResponse) def github_config_page(request: Request):