Resolve button name, anchor tag feedback. Add status message to settings page

- Use "Configure" name for settings config action
- Use more standard anchor tag instead of button
- Add configure status message
This commit is contained in:
Debanjum Singh Solanky 2023-06-23 09:48:38 -07:00
parent 26abafa658
commit 4744d69221
2 changed files with 25 additions and 19 deletions

View file

@ -14,10 +14,10 @@
<p class="card-description">Set repositories for Khoj to index</p> <p class="card-description">Set repositories for Khoj to index</p>
</div> </div>
<div class="card-action-row"> <div class="card-action-row">
<button class="card-button" onclick="window.location.href='/config/content_type/github';"> <a class="card-button" href="/config/content_type/github">
Setup Setup
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"></path></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"></path></svg>
</button> </a>
</div> </div>
</div> </div>
<div class="card"> <div class="card">
@ -29,10 +29,10 @@
<p class="card-description">Set markdown files for Khoj to index</p> <p class="card-description">Set markdown files for Khoj to index</p>
</div> </div>
<div class="card-action-row"> <div class="card-action-row">
<button class="card-button" onclick="window.location.href='/config/content_type/markdown';"> <a class="card-button" href="/config/content_type/markdown">
Setup Setup
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"></path></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"></path></svg>
</button> </a>
</div> </div>
</div> </div>
<div class="card"> <div class="card">
@ -44,10 +44,10 @@
<p class="card-description">Set org files for Khoj to index</p> <p class="card-description">Set org files for Khoj to index</p>
</div> </div>
<div class="card-action-row"> <div class="card-action-row">
<button class="card-button" onclick="window.location.href='/config/content_type/org';"> <a class="card-button" href="/config/content_type/org">
Setup Setup
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"></path></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"></path></svg>
</button> </a>
</div> </div>
</div> </div>
<div class="card"> <div class="card">
@ -59,10 +59,10 @@
<p class="card-description">Set PDF files for Khoj to index</p> <p class="card-description">Set PDF files for Khoj to index</p>
</div> </div>
<div class="card-action-row"> <div class="card-action-row">
<button class="card-button" onclick="window.location.href='/config/content_type/pdf';"> <a class="card-button" href="/config/content_type/pdf">
Setup Setup
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"></path></svg> <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"></path></svg>
</button> </a>
</div> </div>
</div> </div>
</div> </div>
@ -79,36 +79,42 @@
<p class="card-description">Setup Khoj Chat</p> <p class="card-description">Setup Khoj Chat</p>
</div> </div>
<div class="card-action-row"> <div class="card-action-row">
<button class="card-button" onclick="window.location.href='/config/processor/conversation';">Setup <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"></path></svg></button> <a class="card-button" href="/config/processor/conversation">
Setup
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"></path></svg>
</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="section"> <div class="section">
<button id="save" type="submit">⚙️ Configure</button> <div id="status" style="display: none;"></div>
<button id="configure" type="submit">⚙️ Configure</button>
</div> </div>
</div> </div>
<script> <script>
var regenerate = document.getElementById("save"); var configure = document.getElementById("configure");
regenerate.addEventListener("click", function(event) { configure.addEventListener("click", function(event) {
event.preventDefault(); event.preventDefault();
regenerate.disabled = true; configure.disabled = true;
regenerate.innerHTML = "Saving..."; configure.innerHTML = "Configuring...";
fetch('/api/update?force=true&client=web', { fetch('/api/update?force=true&client=web', {
method: 'GET', method: 'GET',
}) })
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
console.log('Success:', data); console.log('Success:', data);
alert("Saved!"); document.getElementById("status").innerHTML = "Configured successfully!";
document.getElementById("status").style.display = "block";
regenerate.disabled = false; regenerate.disabled = false;
regenerate.innerHTML = "Save"; regenerate.innerHTML = "Configured";
}) })
.catch((error) => { .catch((error) => {
console.error('Error:', error); console.error('Error:', error);
alert("Unable to save configuration. Check debug logs."); document.getElementById("status").innerHTML = "Unable to save configuration. Raise issue on Khoj Discord or Github.";
document.getElementById("status").style.display = "block";
regenerate.disabled = false; regenerate.disabled = false;
regenerate.innerHTML = "Save"; regenerate.innerHTML = "Configure";
}); });
}); });
</script> </script>

View file

@ -7,7 +7,6 @@
<span class="card-title-text">{{ content_type|capitalize }}</span> <span class="card-title-text">{{ content_type|capitalize }}</span>
</h2> </h2>
<form id="config-form"> <form id="config-form">
<div id="success" style="display: none;" ></div>
<table> <table>
<tr> <tr>
<td> <td>
@ -73,6 +72,7 @@
</td> </td>
</tr> </tr>
</table> </table>
<div id="success" style="display: none;" ></div>
<button id="submit" type="submit">Save</button> <button id="submit" type="submit">Save</button>
</form> </form>
</div> </div>