source: XIOS/trunk/xios_test_suite/HTML/generate_test_table.js @ 1814

Last change on this file since 1814 was 1814, checked in by yushan, 4 years ago

trunk : update on html rendering

File size: 15.6 KB
Line 
1var dict = {"-1": "❌", "0": "❎", "1": "✅"}
2
3function generateTestTable()
4{
5  var machine_list=[];
6  var machine_revision_list=[];
7  var machine_full_name_list=[];
8  var machine_info_list=[];
9
10  if(typeof test_jeanzay_revision_list != 'undefined') 
11  {
12    machine_list.push("jeanzay");
13    machine_revision_list.push("test_jeanzay_revision_list")
14    machine_full_name_list.push("Jean-Zay")
15    machine_info_list.push("test_jeanzay_info_list")
16  }
17 
18  if (typeof test_irene_revision_list != 'undefined') 
19  {
20    machine_list.push("irene");
21    machine_revision_list.push("test_irene_revision_list")
22    machine_full_name_list.push("Irene")
23    machine_info_list.push("test_irene_info_list")
24  }
25 
26  if (typeof test_other_revision_list != 'undefined') 
27  {
28    machine_list.push("other");
29    machine_revision_list.push("test_other_revision_list")
30    machine_full_name_list.push("Other")
31    machine_info_list.push("test_other_info_list")
32  }
33
34  var revision_list=[]
35
36  for (var i=0; i<machine_list.length; i++)
37  {
38    tmp_list = eval(machine_revision_list[i])
39
40    for (var j=0; j<tmp_list.length; j++)
41    {
42      if (revision_list.includes(tmp_list[j]) == false)
43      {
44        revision_list.push(tmp_list[j])
45      }
46    }
47  }
48
49  revision_list.sort(function(a, b){return b-a});
50
51  // Generate select list for test table
52
53  var sel = document.getElementById("revision");
54
55  var sel_options = sel.children
56 
57  var new_options=[]
58  for(var i=0; i<sel_options.length-1; i++)
59  {
60    new_options[i] = sel_options[i+1].value
61  }
62 
63  for(var i=0; i<revision_list.length; i++)
64  {
65    if (!new_options.includes(revision_list[i]))
66    {
67      new_options.push(revision_list[i])
68    }
69  }
70 
71  new_options.sort(function(a, b){return b-a})
72 
73  while (sel.lastChild && sel.children.length>1) {
74    sel.removeChild(sel.lastChild);
75  }
76
77  for(var i=0; i<new_options.length; i++)
78  {
79    var opt = document.createElement('option');
80    opt.appendChild( document.createTextNode(new_options[i]));
81    opt.value = new_options[i]; 
82    sel.appendChild(opt);
83  }
84 
85
86
87 
88  // Generate content of test table
89 
90  var table = document.getElementById("test_table")
91  table.style.backgroundColor = "#84c5ff";
92  table.setAttribute("class", "test_table")
93  table.setAttribute("id", "test_table")
94
95  var titelRow = document.getElementById("test_table_row0")
96  var myCell = document.createElement("TD");
97  myCell.style.minWidth="150px"
98  myCell.style.maxWidth="150px"
99  myCell.innerHTML = ("Revision");
100  titelRow.appendChild(myCell)
101
102  for (var machine_index=0; machine_index<machine_list.length; machine_index++)
103  {
104    var myCell = document.createElement("TD");
105    myCell.style.minWidth="50px"
106    myCell.innerHTML = (machine_full_name_list[machine_index]);
107    titelRow.appendChild(myCell)
108  }
109
110  var emptyRow = document.createElement("tr")
111  emptyRow.setAttribute("id", "empty_test_row")
112  emptyRow.style.display="none"
113  table.appendChild(emptyRow)
114 
115  var myCell = document.createElement("TD");
116  myCell.setAttribute("id", "empty_test_row_revision")
117  myCell.style.fontWeight="bold"
118  emptyRow.appendChild(myCell)
119
120  for (var machine_index=0; machine_index<machine_list.length; machine_index++)
121  {
122    var myCell = document.createElement("TD");
123    myCell.innerHTML="No Test Information"
124    myCell.style.color="white"
125    emptyRow.appendChild(myCell)
126  }
127
128
129  for (var i=0; i<revision_list.length; i++)
130  {
131    var revision = revision_list[i]
132
133    var myRow = document.createElement("TR");
134    myRow.setAttribute("id", "test_table_"+revision);
135    myRow.setAttribute("class", "test_table_row");
136    table.appendChild(myRow)
137   
138    var myCell = document.createElement("TD");
139    myCell.innerHTML = (revision);
140    myCell.style.fontWeight = "bold";
141    myRow.appendChild(myCell)
142   
143    for( var j=0; j<machine_list.length; j++)
144    {
145      var machine = machine_list[j]
146      var myCell = document.createElement("TD");
147      myCell.setAttribute("id", "test_table_"+revision+"_"+machine);
148      myRow.appendChild(myCell)
149      myRow.appendChild(myCell)
150    }       
151  }
152
153  for (var i=0; i<revision_list.length; i++)
154  {
155    var revision = revision_list[i]
156    for (var j=0; j<machine_list.length; j++)
157    {
158      var machine = machine_list[j]
159      var has_test_info=false
160      tmp_info = eval(machine_info_list[j])
161      for (var k=0; k<eval(machine_info_list[j]).length; k++)
162      {
163        target_info = tmp_info[k]
164        if (target_info[0] == revision && target_info[1] == machine)
165        {
166          fillSubTestTable(revision, machine, target_info[2], target_info[3], target_info[4], target_info[5], target_info[6], target_info[7])
167          has_test_info = true
168        }
169      }
170      if (!has_test_info)
171      {
172        var myTD = document.getElementById("test_table_"+revision+"_"+machine);
173        myTD.innerHTML = "No Test Information"
174        myTD.style.color = "white"
175      }
176    }
177  }
178  update_status()
179}
180
181function fillSubTestTable(revision, machine, build_dir, branch_name, machine_name, arch_name, mode_name, full_dir)
182{
183  var info_list = eval("test_"+machine+"_"+revision+"_"+build_dir.replace("build_",""))
184
185  var myTD = document.getElementById("test_table_"+revision+"_"+machine);
186  var mySubTable = document.createElement("table")
187  myTD.appendChild(mySubTable)
188  mySubTable.style.minWidth="200px"
189  mySubTable.setAttribute("class", "test_sub_table")
190  mySubTable.setAttribute("id", "test_sub_table_"+revision+"_"+machine+"_"+build_dir)
191
192  myRow = document.createElement("tr")
193  myRow.setAttribute("id","test_sub_table_row_"+revision+"_"+machine+"_"+build_dir)
194  myRow.setAttribute("class","test_sub_table_row_"+revision+"_"+machine)
195  myRow.classList.add("build_level")
196  myCell = document.createElement("td")
197  myCell.innerHTML = build_dir.replace("build_","")
198  myCell.onclick=function() {mytoggle("test_sub_table_"+revision+"_"+machine+"_"+build_dir)}
199  myRow.appendChild(myCell)
200  mySubTable.append(myRow)
201
202  myCell = document.createElement("td")
203  myCell_1 = document.createElement("div")
204  myCell_1.setAttribute("class", "dropdown")
205  myCell_2 = document.createElement("button")
206  myCell_2.onclick = function() {show_dropdown("test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_dropdown")}
207  myCell_2.onmouseleave = function() {hide_dropdown("test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_dropdown")}
208  myCell_2.innerHTML=("&#128270;")
209  myCell_3 = document.createElement("div")
210  myCell_3.setAttribute("class", "dropdown-content")
211  myCell_3.setAttribute("id", "test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_dropdown")
212  myCell_4 = document.createElement("a")
213  myCell_4.innerHTML = ("show plain report")
214  myCell_4.onclick = function() {show_plain_report(machine, revision, build_dir)}
215  myCell_5 = document.createElement("a")
216  myCell_5.innerHTML = ("show xios info")
217  myCell_5.onclick = function() {show_text("<table><tr><td>Branch</td><td><em>"+branch_name+"</em></td></tr><tr><td>Revision</td><td><em>"+revision+"</em></td></tr><tr><td>Machine</td><td><em>"+machine_name+"</em></td></tr><tr><td>Architecture</td><td><em>"+arch_name+"</em></td></tr><tr><td>Compile mode</td><td><em>"+mode_name+"</em></td></tr><tr><td>Full build directory</td><td><em>"+full_dir+"</em></td></tr><tr><td>Short build directory</td><td><em>"+build_dir+"</em></td></tr></table>")}
218  myCell_2.appendChild(myCell_3)
219  myCell_3.appendChild(myCell_4)
220  myCell_3.appendChild(myCell_5)
221  myCell_1.appendChild(myCell_2)
222  myCell.appendChild(myCell_1)
223  myRow.appendChild(myCell)
224
225  for (var i=0; i<2; i++)
226  {
227    myCell = document.createElement("td")
228    myRow.appendChild(myCell)
229  }
230
231  myCell = document.createElement("td")
232  myCell.setAttribute("class", "cell_to_update")
233  myCell.setAttribute("id","test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_status")
234  myCell.innerHTML = 1
235  myRow.appendChild(myCell)
236
237  for (var i=0; i<3; i++)
238  {
239    myCell = document.createElement("td")
240    myRow.appendChild(myCell)
241  }
242
243  var previous_status=["","","",""]
244  var current_status=info_list[0]
245  for(var i=0; i<info_list.length; i++)
246  {
247    current_status = info_list[i]
248    if (current_status[0] != previous_status[0])
249    {
250      create_rows(3, revision, machine, build_dir, current_status, full_dir)
251    }
252    else if (current_status[1] != previous_status[1])
253    {
254      create_rows(2, revision, machine, build_dir, current_status, full_dir)
255    }
256    else if (current_status[2] != previous_status[2])
257    {
258      create_rows(1, revision, machine, build_dir, current_status, full_dir)
259    }
260    previous_status = current_status
261  }
262
263
264}
265
266
267function create_rows(nb, revision, machine, build_dir, status, full_dir)
268{
269  tt = document.getElementById("test_sub_table_"+revision+"_"+machine+"_"+build_dir)
270  if(nb==3)
271  {
272    // algo level
273
274    myRow = document.createElement("tr")
275    myRow.setAttribute("class", "test_sub_table_"+revision+"_"+machine+"_"+build_dir)
276    myRow.classList.add('algo_level');
277    myRow.setAttribute("id", "test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0])
278    myRow.style.display = "none";
279    tt.appendChild(myRow)
280   
281   
282    myCell = document.createElement("td")
283    myRow.appendChild(myCell)
284
285
286    myCell = document.createElement("td")
287    myCell.innerHTML = status[0]
288    myCell.onclick=function() {mytoggle("test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0])}
289    myRow.appendChild(myCell)
290
291    myCell = document.createElement("td")
292    myCell_1 = document.createElement("div")
293    myCell_1.setAttribute("class", "dropdown")
294    myCell_2 = document.createElement("button")
295    myCell_2.onclick = function() {show_dropdown("test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0]+"_dropdown")}
296    myCell_2.onmouseleave = function() {hide_dropdown("test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0]+"_dropdown")}
297    myCell_2.innerHTML=("&#128270;")
298    myCell_3 = document.createElement("div")
299    myCell_3.setAttribute("class", "dropdown-content")
300    myCell_3.setAttribute("id", "test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0]+"_dropdown")
301    myCell_4 = document.createElement("a")
302    myCell_4.innerHTML = ("show user_params.def")
303    myCell_4.onclick = function() {show_user_params(machine, revision, build_dir, status[0])}
304    myCell_5 = document.createElement("a")
305    myCell_5.innerHTML = ("show location")
306    myCell_5.onclick = function() {show_text(full_dir.replace(build_dir, "GENERIC_TESTCASE/")+status[0])}
307    myCell_2.appendChild(myCell_3)
308    myCell_3.appendChild(myCell_4)
309    myCell_3.appendChild(myCell_5)
310    myCell_1.appendChild(myCell_2)
311    myCell.appendChild(myCell_1)
312    myRow.appendChild(myCell)
313
314    for (var i=0; i<2; i++)
315    {
316      myCell = document.createElement("td")
317      myRow.appendChild(myCell)
318    }
319
320    myCell = document.createElement("td")
321    myCell.innerHTML = 1
322    myCell.setAttribute("id", "test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0]+"_status")
323    myCell.setAttribute("class", "cell_to_update")
324    myRow.appendChild(myCell)
325   
326    for (var i=0; i<2; i++)
327    {
328      myCell = document.createElement("td")
329      myRow.appendChild(myCell)
330    }
331  }
332
333  if(nb>=2)
334  {
335    // config level
336
337    myRow = document.createElement("tr")
338    myRow.setAttribute("class", "test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0])
339    myRow.classList.add("config_level")
340    myRow.setAttribute("id", "test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0]+"_"+status[1])
341    myRow.style.display = "none";
342    tt.appendChild(myRow)
343   
344    for (var i=0; i<2; i++)
345    {
346      myCell = document.createElement("td")
347      myRow.appendChild(myCell)
348    }
349
350    myCell = document.createElement("td")
351    myCell.innerHTML = status[1]
352    myCell.onclick=function() {mytoggle("test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0]+"_"+status[1])}
353    myRow.appendChild(myCell)
354
355    myCell = document.createElement("td")
356    myCell_1 = document.createElement("div")
357    myCell_1.setAttribute("class", "dropdown")
358    myCell_2 = document.createElement("button")
359    myCell_2.onclick = function() {show_dropdown("test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0]+"_"+status[1]+"_dropdown")}
360    myCell_2.onmouseleave = function() {hide_dropdown("test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0]+"_"+status[1]+"_dropdown")}
361    myCell_2.innerHTML=("&#128270;")
362    myCell_3 = document.createElement("div")
363    myCell_3.setAttribute("class", "dropdown-content")
364    myCell_3.setAttribute("id", "test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0]+"_"+status[1]+"_dropdown")
365    myCell_4 = document.createElement("a")
366    myCell_4.innerHTML = ("show all_param.def")
367    myCell_4.onclick = function() {show_all_params(machine, revision, build_dir, status[0], status[1])}
368    myCell_5 = document.createElement("a")
369    myCell_5.innerHTML = ("show location")
370    myCell_5.onclick = function() {show_text(full_dir.replace(build_dir, "GENERIC_TESTCASE/")+status[0]+"/"+status[1])}
371    myCell_2.appendChild(myCell_3)
372    myCell_3.appendChild(myCell_4)
373    myCell_3.appendChild(myCell_5)
374    myCell_1.appendChild(myCell_2)
375    myCell.appendChild(myCell_1)
376    myRow.appendChild(myCell)
377
378
379    for (var i=0; i<2; i++)
380    {
381      myCell = document.createElement("td")
382      myRow.appendChild(myCell)
383    }
384
385    myCell = document.createElement("td")
386    myCell.innerHTML = 1
387    myCell.setAttribute("id", "test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0]+"_"+status[1]+"_status")   
388    myCell.setAttribute("class", "cell_to_update")
389    myRow.appendChild(myCell)
390   
391    myCell = document.createElement("td")
392    myRow.appendChild(myCell)
393  }
394
395  // file level
396
397  myRow = document.createElement("tr")
398  myRow.setAttribute("class", "test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0]+"_"+status[1])
399  myRow.classList.add("file_level")
400  myRow.setAttribute("id", "test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0]+"_"+status[1]+"_"+status[2])
401  myRow.style.display = "none";
402  tt.appendChild(myRow)
403   
404  for (var i=0; i<3; i++)
405  {
406    myCell = document.createElement("td")
407    myRow.appendChild(myCell)
408  }
409
410  myCell = document.createElement("td")
411  myCell.innerHTML = status[2]
412  myRow.appendChild(myCell)
413
414  for (var i=0; i<3; i++)
415  {
416    myCell = document.createElement("td")
417    myRow.appendChild(myCell)
418  }
419
420  myCell = document.createElement("td")
421  myCell.setAttribute("class", "cell_to_update")
422  myCell.innerHTML = status[3]
423  myRow.appendChild(myCell)
424
425  var cell = document.getElementById("test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0]+"_"+status[1]+"_status")
426  cell.innerHTML = Math.min(cell.innerHTML, status[3])
427   
428  var cell = document.getElementById("test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_"+status[0]+"_status")
429  cell.innerHTML = Math.min(cell.innerHTML, status[3])
430
431  var cell = document.getElementById("test_sub_table_"+revision+"_"+machine+"_"+build_dir+"_status")
432  cell.innerHTML = Math.min(cell.innerHTML, status[3])
433
434}
435
436function update_status()
437{
438  var cells = document.getElementsByClassName("cell_to_update")
439  for (var i=0; i<cells.length; i++)
440  {
441    cells[i].innerHTML = dict[cells[i].innerHTML]
442  }
443}
444
445function mytoggle(classname)
446{
447  var myCells = document.getElementsByClassName(classname)
448  for (var i=0; i<myCells.length; i++)
449  {
450    var mySubCells = document.getElementsByClassName(myCells[i].id)
451    if (myCells[i].style.display=="table-row")
452    {
453      myCells[i].style.display="none" 
454      for(var j=0; j<mySubCells.length; j++)
455      {
456        mySubCells[j].style.display="none"
457        var mySubSubCells = document.getElementsByClassName(mySubCells[j].id)
458        for(var k=0; k<mySubSubCells.length; k++)
459        {
460          mySubSubCells[k].style.display="none"
461        }
462      }
463    }
464    else
465    {
466      myCells[i].style.display="table-row"
467    }
468  }
469}
470
Note: See TracBrowser for help on using the repository browser.