babeld.js 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. function renderTableXRoutes(ubus_data, target_div) {
  2. var data = ubus_data;
  3. for (var protocol in data) {
  4. var target = target_div;
  5. var title = document.createElement('h3');
  6. title.appendChild(document.createTextNode('X-Routes ' + protocol));
  7. target.appendChild(title);
  8. var table = document.createElement('table');
  9. table.setAttribute('class', 'table');
  10. table.setAttribute('id', 'babel_overview_xroutes_' + protocol);
  11. var headerRow = document.createElement('tr');
  12. headerRow.setAttribute('class', 'tr table-titles');
  13. var headerContent = '<th class="th" style="font-weight: 700;">' + '%h'.format(protocol) + ' Prefix</th>\
  14. <th class="th" style="font-weight: 700;">Metric</th>\
  15. <th class="th" style="font-weight: 700;">Source-Prefix</th>';
  16. headerRow.innerHTML = headerContent;
  17. table.appendChild(headerRow);
  18. for (var prefix in data[protocol]) {
  19. var prefixRow = document.createElement('tr');
  20. prefixRow.setAttribute('class', 'tr');
  21. var prefixContent = '<td class="td" data-title="xroutes_' + '%h'.format(protocol) + '_prefix">' + '%h'.format(data[protocol][prefix]["address"]) + '</td>\
  22. <td class="td" data-title="xroutes_' + '%h'.format(protocol) + '_metric">' + '%d'.format(data[protocol][prefix]["metric"]) + '</td>\
  23. <td class="td" data-title="xroutes_' + '%h'.format(protocol) + '_src_prefix">' + '%h'.format(data[protocol][prefix]["src_prefix"]) + '</td>';
  24. prefixRow.innerHTML = prefixContent;
  25. table.appendChild(prefixRow);
  26. }
  27. target.appendChild(table);
  28. }
  29. }
  30. function renderTableRoutes(ubus_data, target_div) {
  31. var data = ubus_data;
  32. for (var protocol in data) {
  33. var target = target_div;
  34. var title = document.createElement('h3');
  35. title.appendChild(document.createTextNode('Routes ' + protocol));
  36. target.appendChild(title);
  37. var table = document.createElement('table');
  38. table.setAttribute('class', 'table');
  39. table.setAttribute('id', 'babel_overview_routes_' + protocol);
  40. var headerRow = document.createElement('tr');
  41. headerRow.setAttribute('class', 'tr table-titles');
  42. var headerContent = '<th class="th" style="font-weight: 700;">' + '%h'.format(protocol) + ' Prefix</th>\
  43. <th class="th" style="font-weight: 700;">Source-Prefix</th>\
  44. <th class="th" style="font-weight: 700;">Route-Metric</th>\
  45. <th class="th" style="font-weight: 700;">Route Smoothed Metric</th>\
  46. <th class="th" style="font-weight: 700;">Refmetric</th>\
  47. <th class="th" style="font-weight: 700;">ID</th>\
  48. <th class="th" style="font-weight: 700;">Seq. No.</th>\
  49. <th class="th" style="font-weight: 700;">Age</th>\
  50. <th class="th" style="font-weight: 700;">Via</th>\
  51. <th class="th" style="font-weight: 700;">Nexthop</th>\
  52. <th class="th" style="font-weight: 700;">Installed</th>\
  53. <th class="th" style="font-weight: 700;">Feasible</th>';
  54. headerRow.innerHTML = headerContent;
  55. table.appendChild(headerRow);
  56. for (var prefix in data[protocol]) {
  57. var prefixRow = document.createElement('tr');
  58. prefixRow.setAttribute('class', 'tr');
  59. var prefixContent = '<td class="td" data-title="routes_' + '%h'.format(protocol) + '_prefix">' + '%h'.format(data[protocol][prefix]["address"]) + '</td>\
  60. <td class="td" data-title="routes_' + '%h'.format(protocol) + '_src_prefix">' + '%h'.format(data[protocol][prefix]["src_prefix"]) + '</td>\
  61. <td class="td" data-title="routes_' + '%h'.format(protocol) + '_metric">' + '%d'.format(data[protocol][prefix]["route_metric"]) + '</td>\
  62. <td class="td" data-title="routes_' + '%h'.format(protocol) + '_rout_smoothed_metric">' + '%d'.format(data[protocol][prefix]["route_smoothed_metric"]) + '</td>\
  63. <td class="td" data-title="routes_' + '%h'.format(protocol) + '_refmetric">' + '%d'.format(data[protocol][prefix]["refmetric"]) + '</td>\
  64. <td class="td" data-title="routes_' + '%h'.format(protocol) + '_id">' + '%h'.format(data[protocol][prefix]["id"]) + '</td>\
  65. <td class="td" data-title="routes_' + '%h'.format(protocol) + '_seqno">' + '%d'.format(data[protocol][prefix]["seqno"]) + '</td>\
  66. <td class="td" data-title="routes_' + '%h'.format(protocol) + '_age">' + '%d'.format(data[protocol][prefix]["age"]) + '</td>\
  67. <td class="td" data-title="routes_' + '%h'.format(protocol) + '_via">' + '%h'.format(data[protocol][prefix]["via"]) + '</td>\
  68. <td class="td" data-title="routes_' + '%h'.format(protocol) + '_nexthop">' + '%h'.format(data[protocol][prefix]["nexthop"]) + '</td>\
  69. <td class="td" data-title="routes_' + '%h'.format(protocol) + '_installed">' + '%b'.format(data[protocol][prefix]["installed"]) + '</td>\
  70. <td class="td" data-title="routes_' + '%h'.format(protocol) + '_feasible">' + '%b'.format(data[protocol][prefix]["feasible"]) + '</td>';
  71. prefixRow.innerHTML = prefixContent;
  72. table.appendChild(prefixRow);
  73. }
  74. target.appendChild(table);
  75. }
  76. }
  77. function renderTableNeighbours(ubus_data, target_div) {
  78. var data = ubus_data;
  79. for (var protocol in data) {
  80. var target = target_div;
  81. var title = document.createElement('h3');
  82. title.appendChild(document.createTextNode('Neighbours ' + protocol));
  83. target.appendChild(title);
  84. var table = document.createElement('table');
  85. table.setAttribute('class', 'table');
  86. table.setAttribute('id', 'babel_overview_neighbours_' + protocol);
  87. var headerRow = document.createElement('tr');
  88. headerRow.setAttribute('class', 'tr table-titles');
  89. var headerContent = '<th class="th" style="font-weight: 700;">' + '%h'.format(protocol) + ' Neighbour</th>\
  90. <th class="th" style="font-weight: 700;">Device</th>\
  91. <th class="th" style="font-weight: 700;">Multicast Hellos</th>\
  92. <th class="th" style="font-weight: 700;">Unicast Hellos</th>\
  93. <th class="th" style="font-weight: 700;">RX cost</th>\
  94. <th class="th" style="font-weight: 700;">TX cost</th>\
  95. <th class="th" style="font-weight: 700;">RTT</th>\
  96. <th class="th" style="font-weight: 700;">Interface up</th>';
  97. headerRow.innerHTML = headerContent;
  98. table.appendChild(headerRow);
  99. for (var neighbour in data[protocol]) {
  100. var neighbourRow = document.createElement('tr');
  101. neighbourRow.setAttribute('class', 'tr');
  102. var neighbourContent = '<td class="td" data-title="neighbours_' + '%h'.format(protocol) + '_neighbour">' + '%h'.format(data[protocol][neighbour]["address"]) + '</td>\
  103. <td class="td" data-title="neighbours_' + '%h'.format(protocol) + '_dev">' + '%h'.format(data[protocol][neighbour]["dev"]) + '</td>\
  104. <td class="td" data-title="neighbours_' + '%h'.format(protocol) + '_hello_reach">' + '%d'.format(data[protocol][neighbour]["hello_reach"]) + '</td>\
  105. <td class="td" data-title="neighbours_' + '%h'.format(protocol) + '_uhello_reach">' + '%d'.format(data[protocol][neighbour]["uhello_reach"]) + '</td>\
  106. <td class="td" data-title="neighbours_' + '%h'.format(protocol) + '_rxcost">' + '%d'.format(data[protocol][neighbour]["rxcost"]) + '</td>\
  107. <td class="td" data-title="neighbours_' + '%h'.format(protocol) + '_txcost">' + '%d'.format(data[protocol][neighbour]["txcost"]) + '</td>\
  108. <td class="td" data-title="neighbours_' + '%h'.format(protocol) + '_rtt">' + '%d'.format(data[protocol][neighbour]["rtt"]) + '</td>\
  109. <td class="td" data-title="neighbours_' + '%h'.format(protocol) + '_if_up">' + '%b'.format(data[protocol][neighbour]["if_up"]) + '</td>';
  110. neighbourRow.innerHTML = neighbourContent;
  111. table.appendChild(neighbourRow);
  112. }
  113. target.appendChild(table);
  114. }
  115. }
  116. function renderTableInfo(ubus_data, target_div) {
  117. var data = ubus_data;
  118. var target = target_div;
  119. var title = document.createElement('h3');
  120. title.appendChild(document.createTextNode('Info'));
  121. target.appendChild(title);
  122. var table = document.createElement('table');
  123. table.setAttribute('class', 'table');
  124. table.setAttribute('id', 'babel_overview_info');
  125. var headerRow = document.createElement('tr');
  126. headerRow.setAttribute('class', 'tr table-titles');
  127. var headerContent = '<th class="th" style="font-weight: 700;">Babeld Version</th>\
  128. <th class="th" style="font-weight: 700;">My-ID</th>\
  129. <th class="th" style="font-weight: 700;">Host</th>';
  130. headerRow.innerHTML = headerContent;
  131. table.appendChild(headerRow);
  132. var neighbourRow = document.createElement('tr');
  133. neighbourRow.setAttribute('class', 'tr');
  134. var neighbourContent = '<td class="td" data-title="info_babeld_version">' + '%h'.format(data["babeld_version"]) + '</td>\
  135. <td class="td" data-title="info_dev">' + '%h'.format(data["my_id"]) + '</td>\
  136. <td class="td" data-title="info_host">' + '%h'.format(data["host"]) + '</td>';
  137. neighbourRow.innerHTML = neighbourContent;
  138. table.appendChild(neighbourRow);
  139. target.appendChild(table);
  140. }