Skip to content

Commit 964936e

Browse files
committed
Add populate_riscv_overview.js
1 parent 7d5bd80 commit 964936e

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* Copyright 2023-2023 Ghent University
3+
*
4+
*
5+
* SPDX license identifier: GPL-3.0-or-later
6+
*
7+
* @author: Michiel Lachaert, Kenneth Hoste (HPC-UGent)
8+
*/
9+
10+
/**
11+
* A function that populates the table on the module overview page with information about all the available modules.
12+
*/
13+
function populate_riscv_overview(riscv_json_data) {
14+
fetch(json_data)
15+
.then((response) => response.json())
16+
.then((json) => {
17+
// Set generated time
18+
const p = document.getElementById("time")
19+
p.innerText = `This data was automatically generated ${json.time_generated}`
20+
21+
22+
// CONSTRUCT TABLE
23+
24+
// list with all the names of the targets
25+
const all_targets = json.targets.map(x => {
26+
//Todo: split up the strings of the targets to automate the hierarchy of the table header
27+
console.log(x)
28+
let pathArray = x.split("/")
29+
pathArray = pathArray.slice(7)
30+
console.log(pathArray)
31+
console.log(pathArray[pathArray.length -1])
32+
x = pathArray[pathArray.length -1]
33+
//x = pathArray
34+
return ({"title": x})
35+
})
36+
console.log(all_targets)
37+
console.log([...[{"title": "name"}], ...all_targets])
38+
const table = new DataTable('#overview_table', {
39+
columns: [...[{"title": "name"}], ...all_targets],
40+
paging: true,
41+
columnDefs: [
42+
{
43+
targets: "_all",
44+
className: 'dt-body-center'
45+
}
46+
],
47+
scrollX: true,
48+
});
49+
console.log(table)
50+
51+
52+
// ADD DATA
53+
let new_rows = [];
54+
55+
// list_avaible contains a list with booleans.
56+
// These booleans indicates if the software is available on the corresponding cluster.
57+
for (const [software, list_available] of Object.entries(json.modules)) {
58+
let new_row = [`<a href="../detail/${software}">${software}</a>`];
59+
list_available.forEach(bool => new_row.push(bool ? "x" : "-"));
60+
new_rows.push(new_row);
61+
}
62+
63+
table.rows.add(new_rows).draw();
64+
})
65+
}
66+
67+
// Only start populating the table if the correct page has been loaded.
68+
document$.subscribe(function() {
69+
if (document.getElementById("riscv_overview_table")) {
70+
populate_overview("../data/riscv_json_data.json")
71+
}
72+
})

0 commit comments

Comments
 (0)