Add endpoint for regenerating directly from the config page and add music content-type

This commit is contained in:
sabaimran 2023-06-17 15:47:33 -07:00
parent ded3100caf
commit c2d46de8bc
3 changed files with 50 additions and 2 deletions

View file

@ -7,7 +7,10 @@
</head>
<body class="khoj-configure">
<header>
<h1>Configure Khoj</h1>
<div>
<h1>Configure Khoj</h1>
<p>Check out our <a href="https://github.com/debanjum/khoj">source code on Github</a></p>
</div>
<div>
<h2>Ready?</h2>
<div id="actions">
@ -31,5 +34,11 @@
grid-template-columns: 1fr 1fr;
grid-gap: 12px;
}
@media screen and (max-width: 600px) {
header {
grid-template-columns: 1fr;
}
}
</style>
</html>

View file

@ -14,11 +14,16 @@
<button onclick="window.location.href='/config/content_type/ledger';">
Configure Ledger
</button>
<button onclick="window.location.href='/config/content_type/music';">
Configure Org Music
</button>
</div>
<h2>Processors</h2>
<button onclick="window.location.href='/config/processor/conversation/';">
Configure Conversation
</button>
<h1>Finalize</h1>
<button id="regenerate" type="submit">Regenerate</button>
<style>
body.khoj-configure {
padding: 0 10%
@ -28,5 +33,39 @@
grid-template-columns: 1fr 1fr;
grid-gap: 12px;
}
button#regenerate {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
</style>
<script>
var regenerate = document.getElementById("regenerate");
regenerate.addEventListener("click", function(event) {
event.preventDefault();
regenerate.disabled = true;
regenerate.innerHTML = "Regenerating...";
fetch('/api/update?force=true&client=web', {
method: 'GET',
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
alert("Regenerated!");
regenerate.disabled = false;
regenerate.innerHTML = "Regenerate";
})
.catch((error) => {
console.error('Error:', error);
alert("Regeneration was not successful. Check debug logs.");
regenerate.disabled = false;
regenerate.innerHTML = "Regenerate";
});
});
</script>
{% endblock %}

View file

@ -18,7 +18,7 @@ logger = logging.getLogger("khoj")
web_client = APIRouter()
templates = Jinja2Templates(directory=constants.web_directory)
VALID_CONTENT_TYPES = ["org", "ledger", "image", "music", "markdown", "pdf"]
VALID_CONTENT_TYPES = ["org", "ledger", "music", "markdown", "pdf"]
# Create Routes