viral-sequences-table.html 2.84 KB
Newer Older
1
2
3
<p>
  This section shows the samples sequenced from Severe acute respiratory syndrome coronavirus 2 (taxon: 2697049) in Spain. These results are periodically retrieved from ENA.
</p>
4
<p class="text-right">
5
6
  Powered by <a href="https://www.ebi.ac.uk/ena/browser/home"><img src="{{ .Site.Params.images.logos.ena }}" alt="ENA" style="max-height: 3rem;"></a>
</p>
7
8
9
10
<div class="container-fluid">
  <div class="row mb-2" id="viral-actions">
  </div>
</div>
11
<table class="table table-hover table-sm table-responsive w-100" id="viral-sequences-table" style="display: table;">
12
13
14
15
16
17
18
19
20
21
22
23
  <thead class="thead-light">
    <tr>
      <th scope="col">{{ i18n "accession_id" }}</th>
      <th scope="col">{{ i18n "collection_date" }}</th>
      <th scope="col">{{ i18n "country" }}</th>
      <th scope="col">{{ i18n "host" }}</th>
      <th scope="col">{{ i18n "isolate" }}</th>
      <th scope="col">{{ i18n "molecule_type" }}</th>
      <th scope="col">{{ i18n "taxon" }}</th>
    </tr>
  </thead>
  <tbody>
24
    {{ range $index, $entry := $.Site.Data.c19dpes_genomics_viral_sequences.viral_sequences }}
25
26
    <tr>
      <td><a target="_blank" href='{{print "https://www.ebi.ac.uk/ena/browser/view/" .accession_id}}'>{{ .accession_id }}</a></td>
27
28
      {{ $col_date := print (substr .collection_date 0 4) "-" (substr .collection_date 4 2) "-" (substr .collection_date  6 2)}}
      <td>{{ dateFormat "Jan 2, 2006" $col_date  }}</td>
29
30
31
32
33
34
35
36
37
38
39
40
      <td>{{ .country }}</td>
      <td>{{ .host }}</td>
      <td>{{ .isolate }}</td>
      <td>{{ .molecule_type }}</td>
      <td>{{ .taxon }}</td>
    </tr>
    {{ end }}
  </tbody>
</table>

<script>
  $(document).ready(() => {
41
    var tableViralSequences = $('#viral-sequences-table').DataTable({
42
      dom: `
43
        <".container-fluid"
44
          <".row my-2"
45
46
47
48
49
50
51
52
            <".mr-auto"i>
            <"#search-viral-sequences.mr-2"f>
          >
          <".row"t>
          <".row"
            <".mr-auto"l>
            <".ml-auto"p>
          >
53
        >
54
55
56
57
58
59
      `,
      buttons: [
        {
          extend: 'csv',
          text: 'Download as CSV',
          titleAttr: 'Download tables in comma-separated-values format',
60
          className: 'btn btn-primary',
61
62
63
64
65
66
67
68
          filename: 'cv19dpes_genomic_viral_sequences_search',
        },
      ],
      processing: true,
      ordering: true,
      initComplete: () => {
        console.log("init complete");
      }
69
70
    });

71
72
73
    // When used with Bootstrap, datatables buttons must be appended to DOM to make them visible.
    tableViralSequences.buttons().container().prependTo('#viral-actions');

74
    // Move download button next to filter search box.
75
76
    const downloadButtonViralSequences = document.querySelector('#viral-actions .dt-buttons');
    const searchViralSequences = document.querySelector('#search-viral-sequences');
77
    searchViralSequences.insertAdjacentElement('afterend', downloadButtonViralSequences);
78
  });
79
80


81
</script>