Enhanced UI

This commit is contained in:
Saifeddine ALOUI 2023-04-16 21:58:51 +02:00
parent 13bd38105b
commit ad71fb1967
3 changed files with 13 additions and 9 deletions

View File

@ -2,4 +2,5 @@ flask
nomic
pytest
pyllamacpp
pyyaml
pyyaml
markdown

View File

@ -150,16 +150,20 @@ function addMessage(sender, message, id, rank = 0, can_edit = false) {
editButton.appendChild(editImg)
editButton.addEventListener('click', () => {
const inputField = document.createElement('input');
const inputBlock = document.createElement('div')
inputBlock.classList.add('flex','flex-col');
const inputField = document.createElement('textarea');
inputField.type = 'text';
inputField.classList.add('font-medium', 'text-md', 'border', 'border-gray-300', 'p-1');
inputField.classList.add('font-medium', 'resize-y','h-24', 'text-md', 'border', 'border-gray-300', 'p-1');
inputField.value = messageTextElement.innerHTML;
buttonsContainer.style.display = "none"
//buttonsContainer.style.display = "none"
const saveButton = document.createElement('button');
saveButton.classList.add('bg-green-500', 'hover:bg-green-700', 'text-white', 'font-bold', 'py-2', 'px-4', 'rounded', 'my-2', 'ml-2');
saveButton.innerHTML = 'Save';
inputBlock.appendChild(inputField)
inputBlock.appendChild(saveButton)
saveButton.addEventListener('click', () => {
const newText = inputField.value;
messageTextElement.innerHTML = newText;
@ -177,14 +181,13 @@ function addMessage(sender, message, id, rank = 0, can_edit = false) {
.catch(error => {
console.error('There was a problem updating the message:', error);
});
buttonsContainer.style.display = 'inline-block'
messageElement.replaceChild(messageTextElement, inputField);
//buttonsContainer.style.display = 'block'
messageElement.replaceChild(messageTextElement, inputBlock);
//messageElement.removeChild(inputField);
messageElement.removeChild(saveButton);
});
messageElement.replaceChild(inputField, messageTextElement);
messageElement.appendChild(saveButton);
messageElement.replaceChild(inputBlock, messageTextElement);
inputField.focus();
});

View File

@ -30,7 +30,7 @@
</div>
<div class="flex w-full mt-auto flex-row">
<form id="chat-form" class="flex w-full mt-auto">
<input type="text" id="user-input" placeholder="Type your message..." class="bg-secondary my-1 mx-1 outline-none drop-shadow-sm w-full rounded-md p-2">
<textarea id="user-input" placeholder="Type your message..." class="bg-secondary my-1 mx-1 outline-none drop-shadow-sm w-full rounded-md p-2"></textarea>
<div id="wait-animation" style="display: none;" class="lds-facebook bg-secondary my-1 mx-1 outline-none drop-shadow-sm w-full rounded-md p-2"><div></div><div></div><div></div></div>
<input type="submit" value="Send" id="submit-input" class="my-1 mx-1 outline-none px-4 bg-accent text-black rounded-md hover:bg-[#7ba0ea] active:bg-[#3d73e1] transition-colors ease-in-out">
</form>