diff options
| author | Anson Bridges <bridges.anson@gmail.com> | 2024-07-02 16:47:39 +0200 |
|---|---|---|
| committer | Anson Bridges <bridges.anson@gmail.com> | 2024-07-02 16:47:39 +0200 |
| commit | 9690fc0e4a319941f3103b1c43d8509c22c20a4f (patch) | |
| tree | 38918f34d453a42f203f5522eb6737d05894ea16 | |
| parent | 80cfb271b27bceb9e357d77d34449cd368d72240 (diff) | |
slight improvements
| -rw-r--r-- | dashboard_website/__pycache__/datastructs.cpython-312.pyc | bin | 0 -> 7576 bytes | |||
| -rw-r--r-- | dashboard_website/__pycache__/db.cpython-312.pyc | bin | 0 -> 11011 bytes | |||
| -rw-r--r-- | dashboard_website/__pycache__/router.cpython-312.pyc | bin | 0 -> 15831 bytes | |||
| -rw-r--r-- | dashboard_website/all_clues.csv | 170 | ||||
| -rw-r--r-- | dashboard_website/dashboard.py | 18 | ||||
| -rw-r--r-- | dashboard_website/datastructs.py | 15 | ||||
| -rw-r--r-- | dashboard_website/db.py | 19 | ||||
| -rw-r--r-- | dashboard_website/static/js/dashboard.js | 30 | ||||
| -rw-r--r-- | dashboard_website/templates/index.html | 2 |
9 files changed, 72 insertions, 182 deletions
diff --git a/dashboard_website/__pycache__/datastructs.cpython-312.pyc b/dashboard_website/__pycache__/datastructs.cpython-312.pyc Binary files differnew file mode 100644 index 0000000..1436e72 --- /dev/null +++ b/dashboard_website/__pycache__/datastructs.cpython-312.pyc diff --git a/dashboard_website/__pycache__/db.cpython-312.pyc b/dashboard_website/__pycache__/db.cpython-312.pyc Binary files differnew file mode 100644 index 0000000..99f804e --- /dev/null +++ b/dashboard_website/__pycache__/db.cpython-312.pyc diff --git a/dashboard_website/__pycache__/router.cpython-312.pyc b/dashboard_website/__pycache__/router.cpython-312.pyc Binary files differnew file mode 100644 index 0000000..7252768 --- /dev/null +++ b/dashboard_website/__pycache__/router.cpython-312.pyc diff --git a/dashboard_website/all_clues.csv b/dashboard_website/all_clues.csv index f7a5ceb..84b6c30 100644 --- a/dashboard_website/all_clues.csv +++ b/dashboard_website/all_clues.csv @@ -1,169 +1 @@ -521 Commercial Street #525,"42.3688272,-71.0553792" -Acorn St,"42.3576234,-71.0688746" -Arlington's Great Meadows,"42.4299758,-71.2038948" -Arthur Fiedler Statue,"42.3565057,-71.0754527" -BU Beach,"42.3511927,-71.1060828" -Blaze Pizza,"42.3446263,-71.0969274" -Bonchon Allston,"42.35304,-71.130887" -Boston Athenaeum,"42.3579151,-71.0620802" -Boston Green Academy,"42.3501823,-71.1459593" -Boston Irish Famine Memorial,"42.357357,-71.0586014" -Boston Massacre Site,"42.3587627,-71.0572023" -Bova's Bakery,"42.36521,-71.0556268" -Brighton High School,"42.3495825,-71.1460435" -Brookline Booksmith,"42.3426377,-71.1217152" -Citrus & Salt Boston,"42.3489004,-71.0720926" -Cocoanut Grove Memorial Plaque,"42.3500079,-71.067859" -Commodore John Barry Memorial,"42.3556154,-71.0632036" -Cypress Street Playground,"42.331864,-71.1258765" -Dana-Farber Cancer Institute,"42.3364675,-71.1095021" -Danehy Park,"42.3890049,-71.133103" -Dave's Hot Chicken,"42.3248471,-71.0620134" -Domingo F. Sarmiento Statue,"42.3500031,-71.0851891" -Dutch House,"42.3360385,-71.1123834" -Earl of Sandwich,"42.354296,-71.066414" -Echo Bridge,"42.3145041,-71.2273649" -Farmers Horse Coffee,"42.341987,-71.0834061" -Fenway High School,"42.3306454,-71.0992038" -Isabella Stewart Gardner Museum,"42.3381442,-71.0990577" -James Michael Curley Statues,"42.3604952,-71.0569649" -James P. Kelleher Rose Garden,"42.3419564,-71.0949218" -Japanese Bell,"42.3413301,-71.0942861" -Joe Moakley Park,"42.3256817,-71.0498714" -John Eliot Square,"42.329969,-71.0908104" -Lafayette City Center,"42.3537983,-71.0616035" -Leader Bank Pavilion,"42.3485465,-71.0359433" -Leif Erikson Statue,"42.3490205,-71.0913583" -Lilly's Gourmet Pasta Express,"42.3323776,-71.1000217" -LimeRed Teahouse (Boston),"42.3518397,-71.1241295" -Longyear Museum,"42.3245965,-71.1618052" -Massachusetts State House,"42.3587772,-71.0638101" -"McMullen Museum of Art, Boston College","42.340795,-71.1625829" -Menotomy Rocks Park,"42.4107892,-71.167854" -Metropolitan Waterworks Museum,"42.3317473,-71.155555" -Mr. Crêpe,"42.3965778,-71.1227278" -Muffin House Cafe,"42.3140229,-71.3598149" -Petsi Pies,"42.3836229,-71.1126695" -Polcari’s Coffee,"42.3640137,-71.0555003" -Porter,"42.3884,-71.119149" -Puerto Rican Veterans Memorial,"42.3407613,-71.0712561" -"Skinny House (Spite House) Boston, MA","42.3668968,-71.0561781" -Soldiers and Sailors Monument,"42.3554589,-71.0664019" -Starbucks,"42.359349,-71.059228" -Steinert Hall,"42.3524116,-71.0668408" -Sugar and Spice Ice Cream Cafe,"42.2961434,-71.0872846" -TD Garden,"42.366198,-71.062146" -Tasca Restaurant,"42.3433772,-71.1427371" -The Bagel Table,"42.3569102,-71.1438455" -The Great Elm,"42.3553972,-71.0651214" -Tiananmen Memorial,"42.3509517,-71.0596124" -Yankee Lobster,"42.3478381,-71.0359354" -Yas Chicken - Allston,"42.3525708,-71.1313443" -swissbakers,"42.3631904,-71.1284677" -"""The Charlestown Bells"" by Paul Matisse","42.3691906,-71.061757" -"42°23'18.8""N 71°07'09.5""W","42.388547,-71.119301" -Bow Market,"42.381008,-71.097883" -Cambridge Public Library,"42.3741209,-71.1107166" -Charlestown High School,"42.3803747,-71.0609962" -Christopher Columbus Waterfront Park,"42.3609921,-71.0516339" -Dawes Island,"42.3754427,-71.1194344" -Desfina Restaurant,"42.3675275,-71.0809932" -Dino Safari Boston: A Walk-Thru Adventure,"42.3597994,-71.0545357" -F. A. Kennedy Steam Bakery,"42.3627462,-71.1013044" -Forge Baking Co & Ice Cream Bar,"42.3838224,-71.1108423" -Greentown Labs,"42.3820702,-71.1026937" -Harvard Square,"42.373465,-71.1189467" -Igor Fokin memorial,"42.3732344,-71.1208817" -John F. Kennedy Presidential Library and Museum,"42.316274,-71.0342146" -Lechmere Canal Park,"42.3695046,-71.0756902" -Lynch Family Skatepark,"42.3701829,-71.0678704" -Machu Chicken,"42.3799095,-71.0968274" -Millers River Potato Monument,"42.3718401,-71.0656594" -"Museum of Fine Arts, Boston","42.339381,-71.094048" -P & E Microcomputer Systems Inc,"42.3621177,-71.1854722" -Peabody Museum of Archaeology and Ethnology,"42.3782386,-71.1146697" -Prospect Hill Monument,"42.3817274,-71.0935443" -Spirit Halloween,"42.3551807,-71.0611749" -Stata Center,"42.3616095,-71.0906355" -The Collection of Historical Scientific Instruments at the Putnam Gallery,"42.3766442,-71.1161887" -The Engine,"42.3627993,-71.0962734" -The Harvard Museum of Natural History,"42.3784629,-71.1155576" -The Mµseum (tiny museum),"42.3797674,-71.0949101" -The Nu Do' Society,"42.3640287,-71.1087411" -USS Constitution Museum,"42.3739796,-71.0554239" -Union Square,"42.37736,-71.09476" -University Park Commons,"42.3614115,-71.1014951" -Veggie Crust - Somerville,"42.3822934,-71.1024769" -Veggie Galaxy,"42.3636597,-71.1011111" -Warren Tavern,"42.3741694,-71.0631664" -"42°21'41.5""N 71°03'24.6""W","42.361531,-71.056823" -All Saints Church,"42.2857047,-71.0632852" -Ashmont,"42.2845163,-71.0637877" -Boston Children's Museum,"42.3519736,-71.0496839" -Boston College High School,"42.3162356,-71.0454645" -Boston Design Center,"42.3441918,-71.0336324" -Boston Fire Museum,"42.3508756,-71.0487437" -Boston Tea Party Ships & Museum,"42.3521821,-71.0512911" -Braintree,"42.2075316,-71.0013637" -Bunker Hill Monument,"42.3763541,-71.0607764" -Calf Pasture Pumping Station,"42.316031,-71.0374911" -Castle Island,"42.3378699,-71.0125206" -Edgar Allan Poe Statue,"42.3523158,-71.0672898" -Forbes Hill Standpipe,"42.2576602,-71.02832" -Glenn’s Kreme&Kone at the Hood Milk Bottle,"42.3516479,-71.0502126" -ICA Watershed,"42.3639107,-71.0331956" -Institute of Contemporary Art,"42.3528151,-71.0432778" -John Adams Birthplace - Adams National Historical Park,"42.2392354,-71.0035279" -John Joseph Moakley United States Courthouse,"42.3537343,-71.0470633" -L Street Bathhouse,"42.3291218,-71.0352443" -Massachusetts Historical Society,"42.3463992,-71.0898829" -O B's Cafe,"42.2743442,-71.0240951" -Pleasure Bay,"42.3358743,-71.0234949" -Revere Beach,"42.420226,-70.985881" -Schoolhouse Pizza,"42.2454086,-71.0005483" -"South Boston Korean War Memorial, Castle Island, South Boston, - Massachusetts, USA","42.3367603,-71.0096371" -Taiyaki NYC - Boston,"42.3509709,-71.0447796" -Tavern of Tales: Café & Bar,"42.3319001,-71.0983169" -The Clam Box,"42.2763168,-71.0092883" -The Partisans,"42.3478375,-71.0404428" -Union Oyster House,"42.361288,-71.056908" -Victoria's Diner,"42.3270498,-71.0667744" -Wollaston Beach,"42.2806539,-71.0119933" -Abbondanza,"42.4074484,-71.0618764" -Aeronaut Cannery & Taproom,"42.3986053,-71.0612182" -Andrew McArdle Bridge,"42.3855456,-71.0392667" -BearMoose Brewing Company,"42.4025721,-71.0515875" -Belle Isle Observation Tower,"42.3917606,-70.9903023" -Brasil On Ferry,"42.4206339,-71.055873" -Broadway Dairy Maid,"42.4222989,-71.0433886" -Colonel William Prescott Statue,"42.3761612,-71.06088" -Consulado de Honduras en Boston,"42.3936888,-71.0412802" -Costco Wholesale,"42.3968978,-71.0714924" -East Boston Branch of the Boston Public Library,"42.3778389,-71.0282154" -East Boston High School,"42.3809511,-71.0350852" -East Boston YMCA,"42.3734483,-71.0331398" -Fort Heath Park,"42.3895122,-70.9693867" -Fort Hill Tower,"42.3253252,-71.0945712" -Governor Bellingham-Cary House,"42.398422,-71.0280157" -Harry Della Russo Stadium,"42.4114215,-71.0155516" -Hook & Reel Cajun Seafood & Bar,"42.4110462,-70.993656" -Judie Dyer Park,"42.3976519,-71.0355621" -Madonna Queen of the Universe Shrine,"42.390191,-71.0056995" -Marao Burgers Everett,"42.403759,-71.0589219" -Maverick House Tavern,"42.3698284,-71.037937" -My Guatemala Bakery 2,"42.3903823,-71.0386285" -Newbridge Cafe,"42.4122481,-71.0316196" -PORT Park,"42.3861321,-71.0328839" -Paws & Play Dog Park,"42.4213082,-71.0270609" -Peach's & Cream,"42.391236,-71.0366491" -Piers Park,"42.3649623,-71.0361399" -Porrazzo Skating Rink,"42.3827415,-71.0116946" -Revere Karate Academy,"42.4183123,-70.9973058" -Sphere Luxury Apartments,"42.4008442,-71.1122037" -Suffolk Downs,"42.390501,-70.997123" -Super Burritos Mexican Grill,"42.41826,-71.0506461" -The Quiet Few,"42.3670906,-71.0359889" -The Tall Ship Boston,"42.3649544,-71.0414523" -Toasted Flats,"42.3711266,-71.0371343" -Vega Market,"42.3891835,-71.033703" -Winthrop High School,"42.3803348,-70.9799864" +name,latitude,longitude,info,status
diff --git a/dashboard_website/dashboard.py b/dashboard_website/dashboard.py index b9b8bbc..90bd718 100644 --- a/dashboard_website/dashboard.py +++ b/dashboard_website/dashboard.py @@ -180,6 +180,22 @@ def visitGeneric(): return jsonify({'status' : f"ERROR {result}"}) return jsonify({'status' : "OK"}) +@app.route("/enableClue", methods=['POST']) +# Expected JSON +# {"clue_name" : xxxx, str} +# Returns JSON +# {"status" : "OK"/"ERROR XX" } +# ERROR CODES: 1 = missing fields, 2 = clue doesn't exist, 3 = already marked as visited +def enableClueToggle(): + content = request.get_json() + if not ('clue_name' in content): + return jsonify({'status' : "ERROR 1"}) + + result = db.toggleEnableClue(content['clue_name']) + if result != 0: + return jsonify({'status' : f"ERROR {result}"}) + return jsonify({'status' : "OK"}) + # # WEB / DASHBOARD API # @@ -223,7 +239,7 @@ def addClueWeb(): if not ('clue_name' in content and 'longitude' in content and 'latitude' in content and 'clue_info' in content): return jsonify({'status' : "ERROR 1"}) - + #db.addClue() return jsonify({'status' : "OK",}) diff --git a/dashboard_website/datastructs.py b/dashboard_website/datastructs.py index 0171d8f..997d3e7 100644 --- a/dashboard_website/datastructs.py +++ b/dashboard_website/datastructs.py @@ -43,22 +43,31 @@ class Point: class Clue(Point): - def __init__(self, lat, long, name, info, status): + def __init__(self, lat, long, name, info, status, pool_index = 0, required=False): self.longitude = long self.latitude = lat self.name = name self.info = info - self.status = status # UNVISITED | ASSIGNED | VISITED + self.status = status # UNVISITED | VISITED | DISABLED | ASSIGNED + self.pool_inbex = pool_index + self.required = required def visit(self): self.status = "VISITED" + + def toggle_enable(self): + if self.status == "UNVISITED" or self.status == "ASSIGNED": + self.status = "DISABLED" + elif self.status == "DISABLED": + self.status = "UNVISITED" def toJSON(self): json_dict = {'longitude' : self.longitude, 'latitude' : self.latitude, 'clue_name' : self.name.replace('"', "'"), 'clue_info' : self.info.replace('"', "'"), - 'clue_status' : self.status} + 'clue_status' : self.status, + 'clue_required' : self.required} return json_dict class Bike(Point): diff --git a/dashboard_website/db.py b/dashboard_website/db.py index 7e81680..6991121 100644 --- a/dashboard_website/db.py +++ b/dashboard_website/db.py @@ -29,7 +29,7 @@ startup = False # # a bike is added/removed # determines/assigns clusters, and assigns routes to bikes def updateRoutes_background(): # run in thread due to long runtime - global currently_updating, routes_last_changed, routes + global currently_updating, routes_last_changed, routes, clusters print("Calculating clusters...") routes = {"clusters": [], "cluster_times": {}, "individual_routes": []} # reset clusters, paths, times = router.getClusters(bikes, clues, homeBase) @@ -140,8 +140,8 @@ def getCluesJSON(timestamp): return False -def addClue(clue_name, clue_info, longitude, latitude, visited="UNVISITED"): - newClue = Clue(latitude, longitude, clue_name, clue_info, visited) +def addClue(clue_name, clue_info, longitude, latitude, status="UNVISITED"): + newClue = Clue(latitude, longitude, clue_name, clue_info, status) clues.append(newClue) clues_last_changed = time.time() @@ -165,7 +165,18 @@ def visitClue(clue_name): clues_last_changed = time.time() updateRoutes() return 0 # OK - return 2 # no clue found + return 2 # no clue + + +def toggleEnableClue(clue_name): + global clues_last_changed + for clue in clues: + if clue.name == clue_name: + clue.toggle_enable() + clues_last_changed = time.time() + updateRoutes() + return 0 # OK + return 2 # no clue def visitClueTeam(team_name, clue_name): diff --git a/dashboard_website/static/js/dashboard.js b/dashboard_website/static/js/dashboard.js index 4ce6fac..3ff0de9 100644 --- a/dashboard_website/static/js/dashboard.js +++ b/dashboard_website/static/js/dashboard.js @@ -124,16 +124,23 @@ function drawClues(){ var tempIcon = visitedIcon; if (clues[i]['clue_status'] == "UNVISITED") tempIcon = unvisitedIcon; var popupdiv = document.createElement('p'); - popupdiv.innerHTML = "<span style='color:black'>" + clues[i]['clue_name'] + ": " + clues[i]['clue_info'] + "</span><button style='margin-left:2px' onclick=\"visitClue('"+clues[i]['clue_name']+"')\">Visit</button>" - var clueMarker = L.marker([clues[i]['latitude'], clues[i]['longitude']], {icon: tempIcon}).bindPopup(popupdiv); + var toggleVisitText = clues[i]['clue_status'] == "UNVISITED" ? "Visit" : "Unvisit"; + var toggleDisableText = clues[i]['clue_status'] != "DISABLED" ? "Disable" : "Enable"; + popupdiv.innerHTML = "<span style='color:black'>" + clues[i]['clue_name'] + ": " + clues[i]['clue_info'] + "</span>"; + popupdiv.innerHTML += "<button id=\"visitbutton_"+clues[i]['clue_name']+"style='margin-left:2px' onclick=\"toggleVisitClue('"+clues[i]['clue_name']+"')\""+(clues[i]['clue_status'] == "DISABLED" ? "disabled" : "")+">"+toggleVisitText+"</button>"; + popupdiv.innerHTML += "<button id=\"enablebutton_"+clues[i]['clue_name']+"style='margin-left:2px' onclick=\"toggleEnableClue('"+clues[i]['clue_name']+"')\""+(clues[i]['clue_status'] == "VISITED" ? "disabled" : "")+">"+toggleDisableText+"</button>"; + var clueMarker = L.marker([clues[i]['latitude'], clueVisits[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); +function toggleVisitClue(clue_name){ + if(!confirm("Are you sure you want to visit/unvisit this clue?")) return; + console.log("toggling visited status for "+clue_name); + document.getElementById("visitbutton_"+clues[i]['clue_name']).disabled = true; // temporarily disable buttons until new server frame received + document.getElementById("enablebutton_"+clues[i]['clue_name']).disabled = true; fetch(host+'/visitClueGeneric', { method: "POST", headers: { @@ -145,6 +152,21 @@ function visitClue(clue_name){ .then((json) => console.log(json)); } +function toggleEnableClue(clue_name){ + console.log("toggling enabled status for "+clue_name); + document.getElementById("visitbutton_"+clues[i]['clue_name']).disabled = true; // temporarily disable buttons until new server frame received + document.getElementById("enablebutton_"+clues[i]['clue_name']).disabled = true; + fetch(host+'/enableClue', { + 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); diff --git a/dashboard_website/templates/index.html b/dashboard_website/templates/index.html index 68a85be..fc61472 100644 --- a/dashboard_website/templates/index.html +++ b/dashboard_website/templates/index.html @@ -196,7 +196,7 @@ onkeyup="previewZoom()" id="new_clue_latitude" style="flex:1;" - placeholder="e.g., 40.3587273"/> + placeholder="e.g., 42.3587273"/> </div> <div id="previewmap" style="height:70%; margin:5px;"></div> <div style="margin:5px;display:flex;flex-direction:row; justify-content: center;"> |
