Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

Commit

Permalink
Updates search
Browse files Browse the repository at this point in the history
  • Loading branch information
davidshumway committed Jul 11, 2021
1 parent 561c2b6 commit 9245b83
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 31 deletions.
15 changes: 4 additions & 11 deletions mdb/files/templates/files/file_upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@
-->
</div>

<table class="card-text" id="file-listing" style="width: 100% !important;">
<table class="table table-sm card-text table-bordered table-striped"
id="file-listing" style="width: 100% !important;">
</table>
<table class="card-text" id="file-listing-preprocessing"
<table class="table table-sm card-text table-bordered table-striped"
id="file-listing-preprocessing"
style="width: 100% !important; display:none;"></table>

<div class="alert alert-danger toggle-display" id="file-error">
Expand Down Expand Up @@ -189,18 +191,9 @@
<!-- end card body 1 -->

<div class="card-body" id="nss-card-2" style="display:none;">
<div id="cosine-status" style="" class="alert alert-info">
<b>Status</b><br />
<span id="stat2-title">Task: Calculating cosine similarity measure...</span><br />
<span id="stat2-complete"></span>
</div>
<table class="card-text" id="file-listing2" style="width: 100% !important;">
</table>
</div>

<div class="card-body" id="nss-card-3" style="display:none;">
<div class="alert alert-info">Comparing spectra from 3k-15k only</div>
<table id="data-table" style="width: 100% !important;"></table>
</div>

</div>
Expand Down
38 changes: 22 additions & 16 deletions mdb/libs/static/js/spectra_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ function toggleNavSearch(e) {
e.preventDefault();
e.stopPropagation();

d3.select('#dendro-viz').selectAll('*').remove();
d3.select('#svg-histo').selectAll('*').remove();
d3.select('#spectra-viz').selectAll('*').remove();

$('#nav-search-source a').removeClass('active');
$(this).addClass('active');

Expand All @@ -99,6 +95,16 @@ function toggleNavSearch(e) {
var n = $(this).attr('id').split('-')[1]; // e.g. "nss-1"
$('#nss-card-' + n).css('display', 'block');

if (n != 3) { // hides result tab
$('#nss-3').css('display', 'none');
d3.select('#dendro-viz').selectAll('*').remove();
d3.select('#svg-histo').selectAll('*').remove();
d3.select('#spectra-viz').selectAll('*').remove();
$('#col-right').css('display', 'none');
$('#container-dendro').css('display', 'none');
} else if (n == 3) {
//~ $('#col-right').css('display', '');
}
return false;
}
function toggleUploadOpts(e) {
Expand Down Expand Up @@ -280,8 +286,6 @@ window.addEventListener('DOMContentLoaded', (event) => {
}
}
}

// post-load styling

});

Expand Down Expand Up @@ -739,13 +743,13 @@ socket.onmessage = function(e) {
var t = $('#file-listing2').DataTable({
data: data.data.results,
columns: [
{data: 'id', title: 'Spectra ID'},
{data: 'strain_id', title: 'Strain ID'},
{data: 'strain_id__strain_id', title: 'Strain Name'},
//~ {data: 'id', title: 'Spectra ID'},
//~ {data: 'strain_id', title: 'Strain ID'},
{data: 'strain_id__strain_id', title: 'Unknown Strain Name'},
{data: 'id', title: 'Top scores (Strain Name, Genus / Species)',
render: function(data, type) {
// e.g. top-scores-8373
return '<table id="top-scores-'+data+'" style=""></table>'; //width: 500px;white-space: pre-line;
return '<table id="top-scores-'+data+'" class="table table-sm"></table>'; //width: 500px;white-space: pre-line;
}
},
{data: 'id', title: '',
Expand Down Expand Up @@ -788,10 +792,7 @@ socket.onmessage = function(e) {
for (var i=0; i<5; i++) {
if (x[i])
output.push(x[i]);
//~ } catch(e) {}
}
//~ console.log('output',output);
//~ console.log('here1');
var t = $('#top-scores-'+data.data.spectra1).DataTable({
data: output,
paging: false,
Expand All @@ -803,11 +804,14 @@ socket.onmessage = function(e) {
{data: 'strain', title: ''},
{data: 'genus', title: ''},
{data: 'species', title: ''},
]
],
'headerCallback': function( thead, data, start, end, display ) {
thead.remove();
//$(thead).find('th').eq(0).html( 'Displaying '+(end-start)+' records' );
}
});
t.order([0, 'desc']) // reorders in correct direction
.draw();
//~ console.log('here');
}

return;
Expand Down Expand Up @@ -835,12 +839,14 @@ function singleScore(id) {
$('#nss-card-2').css('display', 'none');
$('#nss-card-3').css('display', 'block');

$('#col-right').css('display', '');

var t = $('#data-table').DataTable({
data: data.scores,
destroy: true, // https://datatables.net/manual/tech-notes/3
columns: [
{data: 'score', title: 'Score'},
{data: 'id', title: 'Spectra ID'},
//~ {data: 'id', title: 'Spectra ID'},
{data: 'strain', title: 'Strain Name',
render: function(data, type) {
return '<span style="color:steelblue;font-weight:400;cursor:pointer;" data-id="'+data+'" onclick="sp(this);">'
Expand Down
8 changes: 4 additions & 4 deletions mdb/spectra_search/templates/spectra_search/basic_search.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@
<button onclick="javascript:updateFileList()"></button>
-->
</div>
<table class="card-text" id="file-listing" style="width: 100% !important;">
<table class="table table-sm card-text table-bordered table-striped" id="file-listing" style="width: 100% !important;">
</table>
<table class="card-text" id="file-listing-preprocessing"
<table class="table table-sm card-text table-bordered table-striped" id="file-listing-preprocessing"
style="width: 100% !important; display:none;"></table>

<div class="alert alert-danger toggle-display" id="file-error">
Expand Down Expand Up @@ -342,13 +342,13 @@
<span id="stat2-title">Task: Calculating cosine similarity measure...</span><br />
<span id="stat2-complete"></span>
</div>
<table class="card-text" id="file-listing2" style="width: 100% !important;">
<table class="table table-sm card-text table-bordered" id="file-listing2" style="width: 100% !important;">
</table>
</div>

<div class="card-body" id="nss-card-3" style="display:none;">
<div class="alert alert-info">Comparing spectra from 3k-15k only</div>
<table id="data-table" style="width: 100% !important;"></table>
<table class="table table-sm table-bordered table-striped" id="data-table" style="width: 100% !important;"></table>
</div>

</div>
Expand Down

0 comments on commit 9245b83

Please sign in to comment.