-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use https://datatables.net to render the HTML table with the recipe i…
…ndex The benefit of using DataTables.net is that it renders the DOM dynamically showing just a subset/page of the data at a time. It also provides filtering, sorting and many more settings (https://datatables.net/reference/option/) Also on top I have added a small table that shows the number of recipes with additional platforms and their ratio to the total. Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
- Loading branch information
Showing
2 changed files
with
115 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
{# Template for domain indices (module index, ...). #} | ||
{%- extends "layout.html" %} | ||
{% set title = indextitle %} | ||
{% block extrahead %} | ||
{{ super() }} | ||
{% if not embedded and collapse_index %} | ||
<script> | ||
DOCUMENTATION_OPTIONS.COLLAPSE_INDEX = true; | ||
</script> | ||
{% endif %} | ||
<link rel="stylesheet" href="https://cdn.datatables.net/2.1.8/css/dataTables.dataTables.css" /> | ||
<link rel="stylesheet" href="https://cdn.datatables.net/rowgroup/1.5.1/css/rowGroup.dataTables.min.css"/> | ||
|
||
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> | ||
<script src="https://cdn.datatables.net/2.1.8/js/dataTables.js"></script> | ||
<script src="https://cdn.datatables.net/rowgroup/1.5.1/js/dataTables.rowGroup.min.js"></script> | ||
{% endblock %} | ||
{% block body %} | ||
|
||
{%- set groupid = idgen() %} | ||
|
||
<h1>{{ indextitle }}</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th></th> | ||
<th>Count</th> | ||
<th>Ratio</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>Total recipes:</td> | ||
<td id="total-count"></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>linux-aarch64 recipes:</td> | ||
<td id="linux-aarch64-count"></td> | ||
<td><span id="linux-aarch64-ratio"></span>%</td> | ||
</tr> | ||
<tr> | ||
<td>osx-arm64 recipes:</td> | ||
<td id="osx-arm64-count"></td> | ||
<td><span id="osx-arm64-ratio"></span>%</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
<table class="indextable modindextable" id="recipes-table"></table> | ||
|
||
<script> | ||
|
||
let dataset = [ | ||
{%- for (entry) in content %} | ||
["{{ entry.name }}", "{{ entry.archs }}"]{%- if not loop.last -%}{{ "," }}{%- endif -%} | ||
{%- endfor %} | ||
]; | ||
|
||
let aarch64Count = 0; | ||
let arm64Count = 0; | ||
for (let i=0; i<dataset.length; i++) { | ||
let entry = dataset[i]; | ||
if (entry[1].includes("linux-aarch64")) { | ||
aarch64Count += 1; | ||
} | ||
if (entry[1].includes("osx-arm64")) { | ||
arm64Count += 1; | ||
} | ||
} | ||
let totalCount = dataset.length; | ||
document.getElementById("linux-aarch64-count").textContent = aarch64Count; | ||
document.getElementById("linux-aarch64-ratio").textContent = (aarch64Count / totalCount * 100).toFixed(2); | ||
document.getElementById("osx-arm64-count").textContent = arm64Count; | ||
document.getElementById("osx-arm64-ratio").textContent = (arm64Count / totalCount * 100).toFixed(2); | ||
document.getElementById("total-count").textContent = totalCount; | ||
|
||
let table = new DataTable('#recipes-table', { | ||
data: dataset, | ||
columns: [ | ||
{ title: "Name" }, | ||
{ | ||
title: "Additional platforms", | ||
orderable: false | ||
}, | ||
], | ||
displayLength: 25, | ||
lengthMenu: [ | ||
[10, 25, 50, -1], | ||
[10, 25, 50, 'All'] | ||
], | ||
rowGroup: { | ||
enable: true, | ||
dataSrc: function(row) { | ||
return row[0].charAt(0).toLowerCase(); | ||
} | ||
} | ||
}); | ||
</script> | ||
|
||
{% endblock %} |