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

[WIP] Display All Header Content in Single Table. #721

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
24 changes: 24 additions & 0 deletions jwql/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- JWST TR JWST-STScI-004800, SM-12
"""

from bs4 import BeautifulSoup
import datetime
import getpass
import glob
Expand Down Expand Up @@ -113,6 +114,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.
Expand Down
12 changes: 12 additions & 0 deletions jwql/website/apps/jwql/static/js/jwql.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,3 +549,15 @@ function version_url(version_string) {
a_line += '">JWQL v' + version_string + '</a>';
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');
});
};
54 changes: 54 additions & 0 deletions jwql/website/apps/jwql/templates/combined_table.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

<html>
<head>
<meta charset="utf-8"/>
<meta content="text/html;charset=UTF-8" http-equiv="Content-type"/>
<style>
body {font-family: sans-serif;}
table.dataTable {width: auto !important; margin: 0 !important;}
.dataTables_filter, .dataTables_paginate {float: left !important; margin-left:1em}
</style>
<link href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.css" rel="stylesheet" type="text/css"/>
<script src="https://code.jquery.com/jquery-3.1.1.min.js">
</script>
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js">
</script>
</head>
<body>
<script>
var astropy_sort_num = function(a, b) {
var a_num = parseFloat(a);
var b_num = parseFloat(b);

if (isNaN(a_num) && isNaN(b_num))
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
else if (!isNaN(a_num) && !isNaN(b_num))
return ((a_num < b_num) ? -1 : ((a_num > b_num) ? 1 : 0));
else
return isNaN(a_num) ? -1 : 1;
}

jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"optionalnum-asc": astropy_sort_num,
"optionalnum-desc": function (a,b) { return -astropy_sort_num(a, b); }
});

$(document).ready(function() {
$('#table140564226469648').dataTable({
order: [],
pageLength: 20,
lengthMenu: [[20, 10, 25, 50, 100, 500, 1000, -1], [20, 10, 25, 50, 100, 500, 1000, 'All']],
pagingType: "full_numbers",
columnDefs: [{targets: [], type: "optionalnum"}]
});
} ); </script>
<table class="display compact" id="table140564226469648">
<thead>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
</table>
</body>
</html>
36 changes: 28 additions & 8 deletions jwql/website/apps/jwql/templates/view_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,37 @@ <h4>{{ filename }}_{{file_type}}</h4><h>
<a class="btn btn-primary my-2 mx-2" role="button" href={{ url('jwql:archive_thumb', args=[inst, file_root[2:7]]) }}> View Proposal</a>
</p>

<input type="radio" name="header-radio" onclick="display_div('by-extension', 'header-radio')" checked> Show Headers By Extension &nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="header-radio" onclick="display_div('all-headers', 'header-radio')"> Show All Header Extensions &nbsp;&nbsp;&nbsp;&nbsp;
<hr>
<!-- Allow the user to change the header type that is being displayed -->
<div id="header-options">
<form class="my-2">
<div id="by-extension" class="toHide" style="display:none">
<div id="header-options">
<form class="my-2">
{% for extension in header_info %}
{% set num_extensions = header_info|length %}
{% set extname = header_info[extension]['EXTNAME'] %}
{% if extension == 0 %}
<input type="radio" name="header_extension" id="extension0" onclick="update_header_display('0', '{{num_extensions}}')" checked="checked"> {{ extname }} &nbsp;&nbsp;&nbsp;&nbsp;
{% else %}
<input type="radio" name="header_extension" id="extension{{extension}}" onclick="update_header_display('{{extension}}', '{{num_extensions}}')"> {{ extname }} &nbsp;&nbsp;&nbsp;&nbsp;
{% endif %}
{% endfor %}
</div>
<div id="header-tables">
{% for extension in header_info %}
{% set num_extensions = header_info|length %}
{% set extname = header_info[extension]['EXTNAME'] %}
{% if extension == 0 %}
<input type="radio" name="header_extension" id="extension0" onclick="update_header_display('0', '{{num_extensions}}')" checked="checked"> {{ extname }} &nbsp;&nbsp;&nbsp;&nbsp;
{% else %}
<input type="radio" name="header_extension" id="extension{{extension}}" onclick="update_header_display('{{extension}}', '{{num_extensions}}')"> {{ extname }} &nbsp;&nbsp;&nbsp;&nbsp;
{% endif %}
{% set header_table = header_info[extension]['table'] %}
{% if extension == 0 %}
<h4 id="header-display-name-extension0">Extension: {{ header_info[0]['EXTNAME'] }}</h4><h>
<div id="header-table-extension0">{{header_info[0]['table']|safe}}</div>
{% else %}
<h4 id="header-display-name-extension{{extension}}" display="none">Extension: {{ header_info[extension]['EXTNAME'] }}</h4><h>
<div id="header-table-extension{{extension}}" display="none">{{header_info[extension]['table']|safe}}</div>
{% endif %}
{% endfor %}
</div>
<br>
</div>
<div id="header-tables">
{% for extension in header_info %}
Expand Down Expand Up @@ -82,6 +101,7 @@ <h4 id="header-display-name-extension{{extension}}" style="display: none">Extens
{% endif %}
{% endfor %}
</div>

<br>

</main>
Expand Down