Skip to content

Commit

Permalink
[app] Cleanup TODOs in search page
Browse files Browse the repository at this point in the history
  • Loading branch information
TheChristophe committed Mar 11, 2022
1 parent 4beb17f commit 52d03a4
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions service_frontend/pages/search/result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ import { useRouter } from 'next/router';
import { Funnel, Save2 } from 'react-bootstrap-icons';
import { fetchSubkey } from '../../components/resultSearch/jsonKeyHelpers';

function saveFile(contents: string, filename: string = 'export.csv') {
const blob = new Blob([contents], { type: 'text/plain;charset=utf-8' });
let a = document.createElement('a'),
url = URL.createObjectURL(blob);
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function () {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}

/**
* Search page for ran benchmarks
* @returns {React.ReactElement}
Expand Down Expand Up @@ -244,9 +258,6 @@ function ResultSearch(): ReactElement {

function exportResults() {
let lines = [];
// TODO: include other ids? they can be retrieved using result id
// let header = 'id,site_id,flavor_id,benchmark_id';
// let header = 'id';
let header = 'id,site,flavor,benchmark';
if (customColumns.length !== 0) {
header = header.concat(',', customColumns.join(','));
Expand All @@ -265,18 +276,7 @@ function ResultSearch(): ReactElement {
lines.push(entry);
}

// TODO: more elemgant way to save stuff?
const blob = new Blob([lines.join('\n')], { type: 'text/plain;charset=utf-8' });
let a = document.createElement('a'),
url = URL.createObjectURL(blob);
a.href = url;
a.download = 'export.csv';
document.body.appendChild(a);
a.click();
setTimeout(function () {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
saveFile(lines.join('\n'), 'export.csv');
}

return (
Expand Down

0 comments on commit 52d03a4

Please sign in to comment.