mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Make the updates page interactive
This commit is contained in:
parent
35c9a3c558
commit
03ca1ff634
3 changed files with 102 additions and 29 deletions
|
@ -1,13 +1,19 @@
|
|||
$(window).on('load', function () {
|
||||
let url = 'ws://' + window.location.hostname + ':' + window.location.port + '/updates/ws';
|
||||
let wsProtcol = "ws";
|
||||
if (window.location.protocol === 'https') {
|
||||
wsProtcol = 'wss';
|
||||
}
|
||||
|
||||
let url = wsProtcol + '://' + window.location.hostname + ':' + window.location.port + '/updates/ws';
|
||||
var socket = new WebSocket(url);
|
||||
|
||||
socket.onmessage = function (event) {
|
||||
console.log(event.data);
|
||||
let status = JSON.parse(event.data);
|
||||
|
||||
if (event.data.endsWith("processed")) {
|
||||
if (status.type == 'Pending') {
|
||||
const elem = document.createElement('li');
|
||||
elem.classList.add("document");
|
||||
elem.setAttribute("id", 'update-' + status.update_id);
|
||||
|
||||
const ol = document.createElement('ol');
|
||||
const field = document.createElement('li');
|
||||
|
@ -19,7 +25,7 @@ $(window).on('load', function () {
|
|||
|
||||
const content = document.createElement('div');
|
||||
content.classList.add("content");
|
||||
content.innerHTML = event.data;
|
||||
content.innerHTML = 'Pending ' + status.update_id;
|
||||
|
||||
field.appendChild(attribute);
|
||||
field.appendChild(content);
|
||||
|
@ -29,6 +35,18 @@ $(window).on('load', function () {
|
|||
|
||||
prependChild(results, elem);
|
||||
}
|
||||
|
||||
if (status.type == "Processing") {
|
||||
const id = 'update-' + status.update_id;
|
||||
const content = $(`#${id} .content`);
|
||||
content.html('Processing ' + status.update_id);
|
||||
}
|
||||
|
||||
if (status.type == "Processed") {
|
||||
const id = 'update-' + status.update_id;
|
||||
const content = $(`#${id} .content`);
|
||||
content.html('Processed ' + status.update_id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue