From 9f0e97e29d4afa8bdae03028a2ef9a28c079209d Mon Sep 17 00:00:00 2001 From: Mees Fix Date: Wed, 7 Apr 2021 11:30:36 -0400 Subject: [PATCH] Adding html and js updates for view all headers in single table. UI is still buggy with displaying tables. --- jwql/utils/utils.py | 24 +++++++++ jwql/website/apps/jwql/static/js/jwql.js | 12 +++++ .../apps/jwql/templates/combined_table.html | 54 +++++++++++++++++++ .../apps/jwql/templates/view_header.html | 52 +++++++++++------- jwql/website/apps/jwql/views.py | 5 +- 5 files changed, 125 insertions(+), 22 deletions(-) create mode 100644 jwql/website/apps/jwql/templates/combined_table.html diff --git a/jwql/utils/utils.py b/jwql/utils/utils.py index f16dd31b3..32d9c5f1a 100644 --- a/jwql/utils/utils.py +++ b/jwql/utils/utils.py @@ -29,6 +29,7 @@ - JWST TR JWST-STScI-004800, SM-12 """ +from bs4 import BeautifulSoup import datetime import getpass import json @@ -110,6 +111,29 @@ def _validate_config(config_file_dict): ) +def combine_header_tables(header_info): + """Take file header and combine all html headers into one. + """ + + html_list = [] + + for header_ext in range(len(header_info)): + html = header_info[header_ext]['table'] + soup = BeautifulSoup(html, features="lxml") + html_list += soup.findAll('tr') + + with open('/Users/mfix/Desktop/jwql/jwql/website/apps/jwql/templates/combined_table.html', 'r') as f: + contents = f.read() + soup = BeautifulSoup(contents, 'lxml') + + for thead in soup.findAll('thead'): + [thead.insert_after(tag) for tag in html_list] + + html_string = str(soup) + + return html_string + + def get_config(): """Return a dictionary that holds the contents of the ``jwql`` config file. diff --git a/jwql/website/apps/jwql/static/js/jwql.js b/jwql/website/apps/jwql/static/js/jwql.js index b46ebd9c9..65af4ca97 100644 --- a/jwql/website/apps/jwql/static/js/jwql.js +++ b/jwql/website/apps/jwql/static/js/jwql.js @@ -549,3 +549,15 @@ function version_url(version_string) { a_line += '">JWQL v' + version_string + ''; return a_line; }; + +/** + * Show div that is hidden by radio button + * @param {String} version_string - The x.y.z version number + */ + +function display_div(div_name, button_name) { + $("[name="+button_name+"]").click(function(){ + $('.toHide').hide(); + $("#"+div_name).show('slow'); + }); + }; diff --git a/jwql/website/apps/jwql/templates/combined_table.html b/jwql/website/apps/jwql/templates/combined_table.html new file mode 100644 index 000000000..b02fe1885 --- /dev/null +++ b/jwql/website/apps/jwql/templates/combined_table.html @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + +
KeyValue
+ + \ No newline at end of file diff --git a/jwql/website/apps/jwql/templates/view_header.html b/jwql/website/apps/jwql/templates/view_header.html index da9ee76d8..07dd1beaf 100644 --- a/jwql/website/apps/jwql/templates/view_header.html +++ b/jwql/website/apps/jwql/templates/view_header.html @@ -16,32 +16,44 @@

{{ filename }}

View Proposal

+ Show Headers By Extension      + Show All Header Extensions      +
-
-
+ -
- {% for extension in header_info %} - {% set extname = header_info[extension]['EXTNAME'] %} - {% set header_table = header_info[extension]['table'] %} - {% if extension == 0 %} -

Extension: {{ header_info[0]['EXTNAME'] }}

-
{{header_info[0]['table']|safe}}
- {% else %} -

Extension: {{ header_info[extension]['EXTNAME'] }}

-
{{header_info[extension]['table']|safe}}
- {% endif %} - {% endfor %} + + +
diff --git a/jwql/website/apps/jwql/views.py b/jwql/website/apps/jwql/views.py index bbf11e493..518935c9b 100644 --- a/jwql/website/apps/jwql/views.py +++ b/jwql/website/apps/jwql/views.py @@ -49,7 +49,7 @@ from jwql.database.database_interface import load_connection from jwql.utils import anomaly_query_config from jwql.utils.constants import JWST_INSTRUMENT_NAMES_MIXEDCASE, MONITORS -from jwql.utils.utils import filesystem_path, get_base_url, get_config, query_unformat +from jwql.utils.utils import combine_header_tables, filesystem_path, get_base_url, get_config, query_unformat from .data_containers import build_table from .data_containers import data_trending @@ -734,7 +734,8 @@ def view_header(request, inst, filename): context = {'inst': inst, 'filename': filename, 'file_root': file_root, - 'header_info': get_header_info(filename)} + 'header_info': get_header_info(filename), + 'all_headers_table': combine_header_tables(get_header_info(filename))} return render(request, template, context)