This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
spark-art-dashboard/ingestion-rate.js

23 lines
794 B
JavaScript
Raw Normal View History

var current_ingestion_rate = document.getElementById("ingestion-rate").value;
var ws = new WebSocket('ws://localhost:3030/');
ws.addEventListener('open', function open() {
console.log('connected');
ws.send(Date.now().toString(), {mask: true});
});
ws.addEventListener('close', function close() {
console.log('disconnected');
});
ws.addEventListener('message', function message(data, flags) {
console.log('Server response: ' + data.data, flags);
});
document.getElementById("ingestion-rate-update").addEventListener('click', function() {
if (document.getElementById("ingestion-rate").value != current_ingestion_rate) {
ws.send(document.getElementById("ingestion-rate").value, {mask: true});
current_ingestion_rate = document.getElementById("ingestion-rate").value;
}
});