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

fix: reset overview table formatter to older version #448

Merged
merged 1 commit into from
Jan 13, 2022
Merged
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
163 changes: 82 additions & 81 deletions resources/report-table-formatter.js
Original file line number Diff line number Diff line change
@@ -1,100 +1,101 @@
{
"Pango Lineage" : function format(value) { // prettier-ignore
$(function () {
$('[data-toggle="tooltip"]').tooltip();
});
"Pango Lineage": function format(value) {
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})

if (value !== "no strain called") {
var link = `<a data-toggle="tooltip" data-placement="top" title="View ${value} on outbreak.info" href='https://outbreak.info/situation-reports?pango=${value}' target='_blank'>${value}</a>`;
return link;
} else {
return value;
}
}
"variant helper" : function format(value, voi) {
$(function () {
$('[data-toggle="popover"]').popover();
});
if (value !== "no strain called") {
var link = `<a data-toggle="tooltip" data-placement="top" title="View ${value} on outbreak.info" href='https://outbreak.info/situation-reports?pango=${value}' target='_blank'>${value}</a>`;
return link;
} else {
return value;
}
},
"variant helper": function format(value, voi) {
$(function () {
$('[data-toggle="popover"]').popover()
})

$(function () {
$('[data-toggle="tooltip"]').tooltip();
});
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})

$('.popover-dismiss').popover({
trigger: 'focus'
})

var variants = value.split(' ');
var genes = [];
var vafs = {};
var vats = {};
for (var v of variants) {
var split = v.split(':');
genes.push(split[0]);
}

$(".popover-dismiss").popover({
trigger: "focus",
});
for (var g of genes) {
vafs[g] = [];
vats[g] = [];
}

var variants = value.split(" ");
var genes = [];
var vafs = {};
var vats = {};
for (var v of variants) {
var split = v.split(":");
genes.push(split[0]);
}
for (var v of variants) {
var split = v.split(':');
vafs[split[0]].push(split[2]);
vats[split[0]].push(split[1]);
}

for (var g of genes) {
vafs[g] = [];
vats[g] = [];
}
const table = `<table class="table">
<thead>
<tr>
<th scope="col">Variant</th>
<th scope="col">VAF</th>
</tr>
</thead>
<tbody>`;

for (var v of variants) {
var split = v.split(":");
vafs[split[0]].push(split[2]);
vats[split[0]].push(split[1]);
}
const table_end = "</tbody></table>";

const table = `<table class="table">
<thead>
<tr>
<th scope="col">Variant</th>
<th scope="col">VAF</th>
</tr>
</thead>
<tbody>`;
var tables = {};

const table_end = "</tbody></table>";
for (g of genes) {
var body = "";
for (let i = 0; i < vafs[g].length; i++) {
var row = `<tr><td scope="col">${vats[g][i]}</td><td>${vafs[g][i]}</td></tr>`;
body = body + row;
}
tables[g] = table + body + table_end;
}

var tables = {};
let result = [];
let unique_genes = [...new Set(genes)];

for (g of genes) {
var body = "";
for (let i = 0; i < vafs[g].length; i++) {
var row = `<tr><td scope="col">${vats[g][i]}</td><td>${vafs[g][i]}</td></tr>`;
body = body + row;
for (g of unique_genes) {
if (voi) {
var x = "";
for (let i = 0; i < vats[g].length; i++) {
var x = `<a href="#" data-toggle="popover" data-trigger="focus" data-html='true' title='Gene: <a data-html="true" data-toggle="tooltip" data-placement="bottom" title="Linkout to gene in Ensembl genome browser" href="https://covid-19.ensembl.org/Sars_cov_2/Gene/Summary?g=${g}" target="_blank">${g}:${vats[g][i]}</a>' data-content='${tables[g]}'>${g}:${vats[g][i]}</a>`;
result.push(x);
}
} else {
var x = `<a href="#" data-toggle="popover" data-trigger="focus" data-html='true' title='Gene: <a data-html="true" data-toggle="tooltip" data-placement="bottom" title="Linkout to gene in Ensembl genome browser" href="https://covid-19.ensembl.org/Sars_cov_2/Gene/Summary?g=${g}" target="_blank">${g}</a>' data-content='${tables[g]}'>${g}</a>`;
result.push(x);
}
}
tables[g] = table + body + table_end;
}

let result = [];
let unique_genes = [...new Set(genes)];
result = result.join(", ");

for (g of unique_genes) {
if (voi) {
var x = "";
for (let i = 0; i < vats[g].length; i++) {
var x = `<a href="#" data-toggle="popover" data-trigger="focus" data-html='true' title='Gene: <a data-html="true" data-toggle="tooltip" data-placement="bottom" title="Linkout to gene in Ensembl genome browser" href="https://covid-19.ensembl.org/Sars_cov_2/Gene/Summary?g=${g}" target="_blank">${g}:${vats[g][i]}</a>' data-content='${tables[g]}'>${g}:${vats[g][i]}</a>`;
result.push(x);
}
if (value.trim() !== "") {
return result;
} else {
var x = `<a href="#" data-toggle="popover" data-trigger="focus" data-html='true' title='Gene: <a data-html="true" data-toggle="tooltip" data-placement="bottom" title="Linkout to gene in Ensembl genome browser" href="https://covid-19.ensembl.org/Sars_cov_2/Gene/Summary?g=${g}" target="_blank">${g}</a>' data-content='${tables[g]}'>${g}</a>`;
result.push(x);
return "";
}
}

result = result.join(", ");

if (value.trim() !== "") {
},
"VOC Mutations": function format(value) {
return this["variant helper"](value, true);
},
"Other Mutations": function format(value) {
let result = this["variant helper"](value, false);
return result;
} else {
return "";
}
}
"VOC Mutations" : function format(value) {
return this["variant helper"](value, true);
}
"Other Mutations" : function format(value) {
let result = this["variant helper"](value, false);
return result;
}
}
}