diff --git a/auto_rx/autorx/templates/historical.html b/auto_rx/autorx/templates/historical.html index a845d04..a986a2d 100644 --- a/auto_rx/autorx/templates/historical.html +++ b/auto_rx/autorx/templates/historical.html @@ -9,7 +9,6 @@ - @@ -24,8 +23,6 @@ - - @@ -76,6 +73,7 @@ columns:[ //define the table columns {title:"Type", field:"type", width:190, resizable:false}, {title:"Serial", field:"serial", width:105, resizable:false}, + {title:"Count", field:"lines", width:80, resizable:false}, {title:"Date", field:"datetime", width:205, resizable:false, formatter:function(cell, formatterParams, onRendered){ if (getCookie('UTC') == 'false') { var temp_time = new Date(cell.getValue()); @@ -93,7 +91,6 @@ }); async function disableMenu () { - console.log("test1") $("#select-all").prop('disabled', true); $("#deselect-all").prop('disabled', true); $("#showsonde-map").prop('disabled', true); @@ -103,7 +100,6 @@ } async function enableMenu () { - console.log("test2") $("#select-all").prop('disabled', false); $("#deselect-all").prop('disabled', false); $("#showsonde-map").prop('disabled', false); @@ -115,12 +111,12 @@ function showSondeMap () { selectedrows = table.getSelectedData(); if (selectedrows.length > 0) { - var i; - for (i = 0; i < selectedrows.length; i++) { + var i = 0; + function processLog(i) { $.ajax({ url: "/get_log_by_serial/" + selectedrows[i]['serial'], dataType: 'json', - async: false, + async: true, success: function(data) { var sonde_path = L.polyline([]); var max_alt = -99999.0; @@ -163,9 +159,9 @@ }); if (getCookie('imperial') == 'true') { - launchIconTitle = 'First Observed Position (' + launch_lat + ', ' + launch_lon+ ', ' + Math.floor(launch_alt) + 'ft)
at ' + launch_time; + launchIconTitle = selectedrows[i]['serial'] + ' First Observed Position (' + launch_lat + ', ' + launch_lon+ ', ' + Math.floor(launch_alt) + 'ft)
at ' + launch_time; } else { - launchIconTitle = 'First Observed Position (' + launch_lat + ', ' + launch_lon+ ', ' + Math.floor(launch_alt) + 'm)
at ' + launch_time; + launchIconTitle = selectedrows[i]['serial'] + ' First Observed Position (' + launch_lat + ', ' + launch_lon+ ', ' + Math.floor(launch_alt) + 'm)
at ' + launch_time; } launchMarker = L.marker([launch_lat, launch_lon], @@ -198,9 +194,9 @@ }); if (getCookie('imperial') == 'true') { - landingIconTitle = 'Last Observed Position (' + landing_lat + ', ' + landing_lon+ ',' + Math.floor(landing_alt) + 'ft)
at ' + landing_time; + landingIconTitle = selectedrows[i]['serial'] + ' Last Observed Position (' + landing_lat + ', ' + landing_lon+ ',' + Math.floor(landing_alt) + 'ft)
at ' + landing_time; } else { - landingIconTitle = 'Last Observed Position (' + landing_lat + ', ' + landing_lon+ ',' + Math.floor(landing_alt) + 'm)
at ' + landing_time; + landingIconTitle = selectedrows[i]['serial'] + ' Last Observed Position (' + landing_lat + ', ' + landing_lon+ ',' + Math.floor(landing_alt) + 'm)
at ' + landing_time; } landingMarker = L.marker([landing_lat, landing_lon], @@ -233,9 +229,9 @@ }); if (getCookie('imperial') == 'true') { - burstIconTitle = 'Burst at ' + Math.floor(burst_alt) + 'ft'; + burstIconTitle = selectedrows[i]['serial'] + ' Burst at ' + Math.floor(burst_alt) + 'ft'; } else { - burstIconTitle = 'Burst at ' + Math.floor(burst_alt) + 'm'; + burstIconTitle = selectedrows[i]['serial'] + ' Burst at ' + Math.floor(burst_alt) + 'm'; } burstMarker = L.marker([burst_lat, burst_lon], @@ -251,12 +247,18 @@ historicalsonde.addLayer(sonde_path) - historicalsonde.addTo(mymap); + if (i == selectedrows.length-1) { + enableMenu(); + } } }); + if (i < (selectedrows.length-1)) { + i++; + setTimeout(processLog(i), 1); + } } + processLog(0); } - enableMenu(); } //select row on "select all" button click @@ -269,8 +271,6 @@ table.deselectRow(); }); - var historicalsonde = new L.LayerGroup(); - $("#showsonde-map").click(function(){ disableMenu(); setTimeout(showSondeMap, 500); @@ -279,13 +279,71 @@ $("#hidesonde-map").click(function(){ historicalsonde.clearLayers(); }); + + var skewt; + + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + function showSkewT () { + selectedrows = table.getSelectedData(); + if (selectedrows.length > 0) { + var i; + _serial = selectedrows[0]['serial']; + _type = selectedrows[0]['type']; + console.log(_serial); + $.ajax({ + url: "/get_log_by_serial/" + _serial, + dataType: 'json', + async: true, + success: async function(data) { + try { + skewt.clear() + } catch(e) { + //sidebar needs to be open first time + if (document.getElementById("mySettings").style.width == "0px" || document.getElementById("mySettings").style.width == 0) { + if ((window.innerWidth/window.innerHeight) > 1) { + document.getElementById("mySettings").style.width = "100vh"; + } else { + document.getElementById("mySettings").style.width = "100%"; + } + await sleep(500); + } + skewt = new SkewT('#skewt'); + } + + if (getCookie('UTC') == 'false') { + launch_time = new Date(data['first_time']).toLocaleString("en-AU"); + } else { + launch_time = data['first_time']; + } + $('#skewt-header').html("

Skew-T - "+_type + " " + _serial + " " + launch_time + "

"); + + try { + skewt.plot(data.skewt); + enableMenu(); + } + catch(err) { + console.log(err); + enableMenu(); + } + } + }); + } + } + $("#showsonde-skew").click(function(){ - //generate + disableMenu(); + showSkewT(); }); $("#hidesonde-skew").click(function(){ - //hide + disableMenu(); + $('#skewt-header').html("

Skew-T

"); + skewt.clear(); + enableMenu(); }); // List of available map layers. @@ -350,6 +408,9 @@ L.control.layers(baseMaps).addTo(mymap); baseMaps[mapTheme].addTo(mymap); + + var historicalsonde = new L.LayerGroup(); + historicalsonde.addTo(mymap); // Update preffered them cookie on layer change. mymap.on('baselayerchange', function(e) { @@ -456,8 +517,8 @@ if ((window.innerWidth/window.innerHeight) > 1) { // 500px wide on desktop. x.style.display = "none"; y.style.display = "block"; - document.getElementById("mySidenav").style.width = "500px"; - document.getElementById("main").style.marginLeft = "500px"; + document.getElementById("mySidenav").style.width = "560px"; + document.getElementById("main").style.marginLeft = "560px"; document.getElementById("mySidenav").style.borderRadius = "0px 25px 25px 0px"; mymap.invalidateSize(); } else { // Fullsize on mobile. @@ -524,6 +585,7 @@ let vh = window.innerHeight * 0.01; document.documentElement.style.setProperty('--vh', `${vh}px`); + @@ -551,8 +613,9 @@
-

Skew Plot

+

Skew-T Plot

+