From 471ec7e467090bea965ef719ec36ded662edee07 Mon Sep 17 00:00:00 2001 From: Adam Shapiro Date: Mon, 10 Jun 2024 17:18:56 -0400 Subject: [PATCH 1/3] Added content filter control to event log display. --- .../fusion_engine_client/analysis/analyzer.py | 56 ++++++++++++++----- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/python/fusion_engine_client/analysis/analyzer.py b/python/fusion_engine_client/analysis/analyzer.py index 77dc172b..0e6dce49 100755 --- a/python/fusion_engine_client/analysis/analyzer.py +++ b/python/fusion_engine_client/analysis/analyzer.py @@ -49,15 +49,15 @@ } -def _data_to_table(col_titles: List[str], values: List[List[Any]], row_major: bool = False): +def _data_to_table(col_titles: List[str], values: List[List[Any]], row_major: bool = False, id='table'): if row_major: # If values is row major (outer index is the table rows), transpose it. col_values = list(map(list, zip(*values))) else: col_values = values - table_html = '''\ - + table_html = f'''\ +
''' @@ -909,21 +909,21 @@ def _plot_data(name, idx, source_id, marker_style=None): if marker_style is not None: style['marker'].update(marker_style) + # Only put default source ID on map by default. + legendgroup = None if len(self.source_ids) == 1 else source_id + visible = None if source_id == min(self.source_ids) else 'legendonly' + if np.any(idx): text = ["Time: %.3f sec (%.3f sec)
Std (ENU): (%.2f, %.2f, %.2f) m" % (t, t + float(self.t0), std[0], std[1], std[2]) for t, std in zip(time[idx], std_enu_m[:, idx].T)] - # Only put default source ID on map by default. - if source_id == min(self.source_ids): - map_data.append(go.Scattermapbox(lat=lla_deg[0, idx], lon=lla_deg[1, idx], name=name, text=text, - legendgroup=source_id, **style)) - else: - map_data.append(go.Scattermapbox(lat=lla_deg[0, idx], lon=lla_deg[1, idx], name=name, text=text, - legendgroup=source_id, visible='legendonly', **style)) + map_data.append(go.Scattermapbox(lat=lla_deg[0, idx], lon=lla_deg[1, idx], name=name, text=text, + legendgroup=legendgroup, visible=visible, **style)) else: # If there's no data, draw a dummy trace so it shows up in the legend anyway. - map_data.append(go.Scattermapbox(lat=[np.nan], lon=[np.nan], name=name, visible='legendonly', **style)) + map_data.append(go.Scattermapbox(lat=[np.nan], lon=[np.nan], name=name, legendgroup=legendgroup, + visible='legendonly', **style)) # Read the pose data. for source_id in self.source_ids: @@ -2213,9 +2213,39 @@ def plot_events(self): if system_time_ns in times_before_resets: rows[-1][2] = f'{(times_before_resets[system_time_ns]):.3f}' - table_html = _data_to_table(table_columns, rows, row_major=True) - body_html = f"""\ + table_html = _data_to_table(table_columns, rows, row_major=True, id='event_log') + body_html = """\ + +""" + f"""\

Device Event Log

+
+ +
{table_html}
""" From af878f3e1cca080378e9a95f47f5eebb122fd916 Mon Sep 17 00:00:00 2001 From: Adam Shapiro Date: Tue, 11 Jun 2024 18:31:15 -0400 Subject: [PATCH 2/3] Display the number of visible events. --- python/fusion_engine_client/analysis/analyzer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/fusion_engine_client/analysis/analyzer.py b/python/fusion_engine_client/analysis/analyzer.py index 0e6dce49..e8e447f8 100755 --- a/python/fusion_engine_client/analysis/analyzer.py +++ b/python/fusion_engine_client/analysis/analyzer.py @@ -2221,6 +2221,7 @@ def plot_events(self): var invert = document.getElementById("invert").checked; var table = document.getElementById("event_log"); var tr = table.getElementsByTagName("tr"); + var visible_count = 0; for (var i = 0; i < tr.length; ++i) { var tds = tr[i].getElementsByTagName("td"); if (tds.length < 6) { @@ -2233,11 +2234,13 @@ def plot_events(self): description_td.innerText.toLowerCase().indexOf(filter) > -1; if (filter == "" || (matches && !invert) || (!matches && invert)) { tr[i].style.display = ""; + ++visible_count; } else { tr[i].style.display = "none"; } } + document.getElementById("visible_count").innerText = visible_count; } """ + f"""\ @@ -2246,6 +2249,7 @@ def plot_events(self): placeholder="Filter by event type or description..." style="width: 100%;">
+
Displaying
{len(rows)}
/{len(rows)} event notifications.
{table_html}
""" From c5c9923cc85561782716b7c437f24bef4a03de91 Mon Sep 17 00:00:00 2001 From: Adam Shapiro Date: Tue, 11 Jun 2024 19:43:57 -0400 Subject: [PATCH 3/3] Optimized table using native JS for filtering. --- .../fusion_engine_client/analysis/analyzer.py | 178 +++++++++++++++--- 1 file changed, 150 insertions(+), 28 deletions(-) diff --git a/python/fusion_engine_client/analysis/analyzer.py b/python/fusion_engine_client/analysis/analyzer.py index e8e447f8..6ffaa9df 100755 --- a/python/fusion_engine_client/analysis/analyzer.py +++ b/python/fusion_engine_client/analysis/analyzer.py @@ -2213,44 +2213,166 @@ def plot_events(self): if system_time_ns in times_before_resets: rows[-1][2] = f'{(times_before_resets[system_time_ns]):.3f}' - table_html = _data_to_table(table_columns, rows, row_major=True, id='event_log') + table_data = ',\n '.join([repr(row) for row in rows]) body_html = """\ """ + f"""\

Device Event Log

-
- - -
Displaying
{len(rows)}
/{len(rows)} event notifications. -
{table_html}
+
+
+ """ self._add_page(name='event_log', html_body=body_html, title="Event Log")