This commit is contained in:
parent
089add1a80
commit
52ad5199b4
|
@ -172,6 +172,10 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
|
||||||
const data = await response.text();
|
const data = await response.text();
|
||||||
uploadResultDiv.textContent = 'Upload successful: ' + JSON.parse(data)['message'];
|
uploadResultDiv.textContent = 'Upload successful: ' + JSON.parse(data)['message'];
|
||||||
|
setTimeout(function () {
|
||||||
|
uploadResultDiv.textContent = '';
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
sessionStorage.setItem("helloComputerSessionLoaded", true);
|
sessionStorage.setItem("helloComputerSessionLoaded", true);
|
||||||
|
|
||||||
addAIManualMessage('File uploaded and processed!');
|
addAIManualMessage('File uploaded and processed!');
|
||||||
|
@ -192,6 +196,9 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||||
const loadResultDiv = document.getElementById('loadResultDiv');
|
const loadResultDiv = document.getElementById('loadResultDiv');
|
||||||
|
|
||||||
sessionsButton.addEventListener('click', async function fetchSessions() {
|
sessionsButton.addEventListener('click', async function fetchSessions() {
|
||||||
|
// Display a loading message
|
||||||
|
sessions.innerHTML = '<div class="text-center"><div class="spinner-border" role="status"><span class="sr-only"></span></div></div>';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/sessions');
|
const response = await fetch('/sessions');
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
@ -200,19 +207,24 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||||
const data = JSON.parse(await response.text());
|
const data = JSON.parse(await response.text());
|
||||||
sessions.innerHTML = '';
|
sessions.innerHTML = '';
|
||||||
data.forEach(item => {
|
data.forEach(item => {
|
||||||
const listItem = document.createElement('li');
|
const row = document.createElement('div');
|
||||||
|
row.className = 'row mb-2';
|
||||||
const button = document.createElement('button');
|
const button = document.createElement('button');
|
||||||
button.textContent = item.session_name;
|
button.textContent = item.session_name;
|
||||||
|
button.className = 'btn btn-primary btn-block';
|
||||||
button.addEventListener("click", function () {
|
button.addEventListener("click", function () {
|
||||||
sessionStorage.setItem("helloComputerSession", item.sid);
|
sessionStorage.setItem("helloComputerSession", item.sid);
|
||||||
sessionStorage.setItem("helloComputerSessionLoaded", true);
|
sessionStorage.setItem("helloComputerSessionLoaded", true);
|
||||||
loadResultDiv.textContent = 'Session loaded';
|
loadResultDiv.textContent = 'Session loaded';
|
||||||
|
setTimeout(function () {
|
||||||
|
loadResultDiv.textContent = '';
|
||||||
|
}, 1000);
|
||||||
});
|
});
|
||||||
listItem.appendChild(button);
|
row.appendChild(button);
|
||||||
sessions.appendChild(listItem);
|
sessions.appendChild(row);
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
sessions.innerHTML = 'Error: ' + error.message;
|
sessions.innerHTML = '<div class="alert alert-danger">Error: ' + error.message + '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue