Skip to content

Commit

Permalink
explanations added, seemingly final dashboard update for a while
Browse files Browse the repository at this point in the history
  • Loading branch information
kauevestena committed Oct 19, 2024
1 parent bdec699 commit 01d42a0
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 4 deletions.
35 changes: 31 additions & 4 deletions dashboard/statistics_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,18 +438,45 @@ def create_rev_date(row):

dashboard_main_page_insertions = {
"<body>": """
<body>
<h1 style="text-align: center;">Welcome to the OSWM Node Dashboard!</h1>
<h1 style="text-align: center;font-family: 'Poppins', sans-serif;">Welcome to the OSWM Node Dashboard!</h1>
<div style="text-align: center; padding: 5px;">
<img src="https://kauevestena.github.io/oswm_codebase/assets/homepage/project_logo.png" alt="OSWM Project Logo">
</div>
<h3 style="text-align: center; font-weight: normal;"><b>Select a category of data</b> or the aggregated on "All Data Charts"<br><br>Or click the blue button to go back to the node homepage!<br><br>Most <b>charts are interactive</b>, so try out some pan and zoom!<br></form></h3>
<h4 style="text-align: center; font-weight: normal;">They're made with the amazing Altair library!<br> so <b>you can click on the 3 dots on the upper right corner</b>,<br> to export to different formats and edit on the Vega Editor!</h4>
<br>
<footer>
<p style="text-align: center; font-weight: normal;">&copy; <span id="year"></span> OSWM Project</p>
<p style="text-align: center; font-weight: normal;">want to report an issue? <a href="https://github.com/kauevestena/opensidewalkmap/issues">here</a></p>
</footer>
<script>
document.getElementById("year").textContent = new Date().getFullYear();
</script>
</body>"""
"""
}


explanation_base = '<h1 style="padding-left: 14%;"> Explanation: {} </h1>'
# stuff for the explanation
explanation_base = '<h4 style="padding-left: 14%;font-weight: normal;font-family: sans-serif;"> - Explanation: {} </h4>'

# the webpage links
surface_link = "<a href='https://wiki.openstreetmap.org/wiki/Key:surface'>surface</a>"
smoothness_link = (
"<a href='https://wiki.openstreetmap.org/wiki/Key:smoothness'>smoothness</a>"
)
lit_link = "<a href='https://wiki.openstreetmap.org/wiki/Key:lit'>lit</a>"
tactile_paving_link = "<a href='https://wiki.openstreetmap.org/wiki/Key:tactile_paving'>Tactile Paving</a>"
width_link = "<a href='https://wiki.openstreetmap.org/wiki/Key:width'>width</a>"
crossing_link = (
"<a href='https://wiki.openstreetmap.org/wiki/Key:crossing'>crossing</a>"
)
kerb_link = "<a href='https://wiki.openstreetmap.org/wiki/Key:kerb'>kerb</a>"
wheelchair_link = (
"<a href='https://wiki.openstreetmap.org/wiki/Key:wheelchair'>wheelchair</a>"
)
traffic_calming_link = "<a href='https://wiki.openstreetmap.org/wiki/Key:traffic_calming'>Traffic Calming</a>"
incline_link = "<a href='https://wiki.openstreetmap.org/wiki/Key:incline'>incline</a>"
17 changes: 17 additions & 0 deletions dashboard/statistics_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
# storing chart infos:
generated_list_dict = {}
charts_titles = {}
charts_explanations = {}

# generating the charts by using the specifications
with open(os.path.join(statistics_basepath, "failed_gen.txt"), "w+") as error_report:
Expand Down Expand Up @@ -88,7 +89,16 @@
chart_obj.save(json_outpath)

generated_list_dict[category].append(outpath)

# # extra charts info:
# Title:
charts_titles[outpath] = spec["title"]

# Explanation:
charts_explanations[outpath] = explanation_base.format(
spec["explanation"]
)

except Exception as e:
print(
"failed ",
Expand Down Expand Up @@ -151,11 +161,14 @@
# iterating again to modify pages only once:
for category in generated_list_dict:
for i, rel_path in enumerate(generated_list_dict[category]):
# creating the file handler object
fileObj = fileAsStrHandler(rel_path)

# global insertions, they are meant to be inserted in every file
for insertpoint in global_insertions:
fileObj.simple_replace(insertpoint, global_insertions[insertpoint])

# global exclusions, they are meant to be removed in every file
for exclusion_specs in global_exclusions:
to_remove = find_between_strings(
fileObj.content,
Expand All @@ -169,8 +182,12 @@
+ exclusion_specs["points"][1]
)

# category specific insertions (topbar and sidebar)
fileObj.simple_replace("<head>", "<head>\n" + category_bars[category])

# inserting the explanations:
fileObj.simple_replace("</body>", charts_explanations[rel_path] + "\n</body>")

fileObj.rewrite()

# # # dashboard homepage writing:
Expand Down
Loading

0 comments on commit 01d42a0

Please sign in to comment.