From c560de266caad6db97e58757ca43e8558c103c01 Mon Sep 17 00:00:00 2001 From: Anson Bridges Date: Sat, 18 Nov 2023 06:18:23 -0500 Subject: csv import, manual visiting --- dashboard_website/static/js/controls.js | 42 ++++++++++++++++++++++++++++++++ dashboard_website/static/js/dashboard.js | 20 +++++++++++++-- 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 dashboard_website/static/js/controls.js (limited to 'dashboard_website/static/js') diff --git a/dashboard_website/static/js/controls.js b/dashboard_website/static/js/controls.js new file mode 100644 index 0000000..3d81032 --- /dev/null +++ b/dashboard_website/static/js/controls.js @@ -0,0 +1,42 @@ +// uses functions in utils.js +var host = window.location.protocol + "//" + window.location.host; + +function downloadCurrent(){ + call("downloadSave"); +} + +// load and append dirty file +function loadDirty(){ + call("loadDirty", "dirty"); +} + +// load save file (clean) +function loadSave(){ + call("loadSave", "clean"); +} + +function call(command, formid=""){ + var formData; + if (formid == "") { + formData = new FormData(); + }else { + formData = new FormData(document.getElementById(formid)); + } + + formData.append("command", command); + console.log(formData); + + fetch(host+'/controls', { + method: "POST", + body: formData + }).then( res => res.blob() ) + .then( blob => { + var file = window.URL.createObjectURL(blob); + window.location.assign(file);}); + //.then((response) => response.json()) + //.then((json) => handleCallResponse(json)); +} + +function handleLatestInfo(json){ + if(json['status'] != "OK")alert("Error."); +} \ No newline at end of file diff --git a/dashboard_website/static/js/dashboard.js b/dashboard_website/static/js/dashboard.js index fba7196..4ce6fac 100644 --- a/dashboard_website/static/js/dashboard.js +++ b/dashboard_website/static/js/dashboard.js @@ -123,13 +123,28 @@ function drawClues(){ for (var i = 0; i < clues.length; i++) { var tempIcon = visitedIcon; if (clues[i]['clue_status'] == "UNVISITED") tempIcon = unvisitedIcon; - var clueMarker = L.marker([clues[i]['latitude'], clues[i]['longitude']], {icon: tempIcon}).bindPopup(clues[i]['clue_name'] + ": " + clues[i]['clue_info']); + var popupdiv = document.createElement('p'); + popupdiv.innerHTML = "" + clues[i]['clue_name'] + ": " + clues[i]['clue_info'] + "" + var clueMarker = L.marker([clues[i]['latitude'], clues[i]['longitude']], {icon: tempIcon}).bindPopup(popupdiv); clue_rels[clues[i]['clue_name']] = clueMarker; if (clues[i]['clue_status'] == "UNVISITED") unvisited_clues_m.addLayer(clueMarker); else visited_clues_m.addLayer(clueMarker); } } +function visitClue(clue_name){ + console.log("visiting: "+clue_name); + fetch(host+'/visitClueGeneric', { + method: "POST", + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ "clue_name" : clue_name })}) + .then((response) => response.json()) + .then((json) => console.log(json)); +} + function addClue(){ var long = parseFloat(document.getElementById("new_clue_longitude").value); var lat = parseFloat(document.getElementById("new_clue_latitude").value); @@ -252,4 +267,5 @@ window.onload = function() { layerControl.addOverlay(bikes_m, "Bikes"); layerControl.addTo(map); requestLatestInfo(); -} \ No newline at end of file +} + -- cgit v1.2.3