// How often to query the server? const REFRESH_INTERVAL_SEC = 60; // Storage for the spot data that the server gives us. var spots = [] // Storage for the options that the server gives us. This will define our filters. var options = {}; // Last time we updated the spots list on display. var lastUpdateTime; // Load spots and populate the table. function loadSpots() { $.getJSON('/api/spots', function(jsonData) { // Store last updated time lastUpdateTime = moment.utc(); updateRefreshDisplay(); // Store data spots = jsonData; // Update table updateTable(); }); } // Update the spots table function updateTable() { // Populate table with headers let headers = Object.keys(spots[0]); let table = $('
| ${header} | `)); spots.forEach(s => { // Create row let $tr = $('|||||||
|---|---|---|---|---|---|---|---|
| ${time_formatted} | `); $tr.append(`${s["dx_flag"]}${s["dx_call"]} | `); $tr.append(`■${freq_string} | `); $tr.append(`${mode_string} | `); $tr.append('' + escapeHtml(`${s["comment"]}`) + ' | '); $tr.append(`${s["source"]} | `); $tr.append(`${sig_refs} | `); $tr.append(`${de_flag}${s["de_call"]} | `); table.find('tbody').append($tr); }); // Update DOM $('#table-container').html(table); } // Load server status function loadStatus() { $.getJSON('/api/status', function(jsonData) { $("#status-container").append(generateStatusCard("Server Information", [ `Software Version: ${jsonData["software-version"]}`, `Server Owner Callsign: ${jsonData["server-owner-callsign"]}`, `Server Uptime: ${jsonData["uptime"]}`, `Memory Use: ${jsonData["mem_use_mb"]} MB`, `Total Spots: ${jsonData["num_spots"]}` ])); $("#status-container").append(generateStatusCard("Web Server", [ `Status: ${jsonData["webserver"]["status"]}`, `Last API Access: ${moment.utc(jsonData["webserver"]["last_api_access"], moment.ISO_8601).format("HH:mm")}`, `Last Page Access: ${moment.utc(jsonData["webserver"]["last_page_access"], moment.ISO_8601).format("HH:mm")}` ])); $("#status-container").append(generateStatusCard("Cleanup Service", [ `Status: ${jsonData["cleanup"]["status"]}`, `Last Ran: ${moment.utc(jsonData["cleanup"]["last_ran"], moment.ISO_8601).format("HH:mm")}` ])); jsonData["providers"].forEach(p => { $("#status-container").append(generateStatusCard("Provider: " + p["name"], [ `Status: ${p["status"]}`, `Last Updated: ${p["enabled"] ? moment.utc(p["last_updated"], moment.ISO_8601).format("HH:mm") : "N/A"}`, `Latest Spot: ${p["enabled"] ? moment.utc(p["last_spot"], moment.ISO_8601).format("HH:mm YYYY-MM-DD") : "N/A"}` ])); }); }); } // Generate a status card function generateStatusCard(title, textLines) { let $col = $("