Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding table filtering and searching #32

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions website/create_asset_inventory_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import plotly.express as px
import plotly
import folium
from folium.plugins import Search


def write_html_index(template, configs, org_config):
Expand Down Expand Up @@ -68,7 +69,7 @@ def map_plot(gdf):

columns = gdf.columns.tolist()
columns.remove('geometry')
#print(columns)

for name, group in gdf.groupby(by='RA'):
#group["ref"] = [f"<a href=\"{url}\" target=\"_blank\">{url}</a>" for url in group["url"]]

Expand All @@ -81,11 +82,20 @@ def map_plot(gdf):
# aliases=["",""],
),
popup=folium.features.GeoJsonPopup(
fields=columns,
fields=["RA","Latitude","Longitude","station_long_name","Platform","Operational","station_deployment","RA_Funded","Raw_Vars"]#columns,
#aliases=[""],
), show=True,
).add_to(m)

# statesearch = Search(
# layer=gdf,
# geom_type="Polygon",
# placeholder="Search for an RA",
# collapsed=False,
# search_label="RA",
# weight=3,
# ).add_to(m)

folium.LayerControl(collapsed=True).add_to(m)

m.fit_bounds(m.get_bounds())
Expand All @@ -108,8 +118,10 @@ def main(org_config):
fig = map_plot(gdf)

#print(fig)
columns = ["RA","Latitude","Longitude","station_long_name","Platform","Operational","station_deployment","RA_Funded","Raw_Vars"]

configs = {'table': gdf.to_html(), 'figure': fig}
configs = {'table': gdf.to_html(table_id="table", index=False, columns=columns),
'figure': fig}

write_templates(configs, org_config)

Expand Down
14 changes: 14 additions & 0 deletions website/templates/asset_inventory_page.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<header>
<link href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css" rel="stylesheet">
</header>
<head>
{#<!-- Global site tag (gtag.js) - Google Analytics --> #}
<script async src="{{org_config.google_analytics}}"></script>
Expand Down Expand Up @@ -50,8 +53,19 @@ <h2 class="title">{{org_config.general_title}} <a href=https://github.com/ioos/i

<div>
{{configs.table}}
{% raw %}
<script src="https://code.jquery.com/jquery-3.6.0.slim.min.js" integrity="sha256-u7e5khyithlIdTpu22PHhENmPcRdFiHRjhAuHcs05RI=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready( function () {
$('#table').DataTable();
} );
let table = new DataTable('#table');
</script>
{% endraw %}
</div>


<div class="divider_thin"></div>


Expand Down