1// This function accomplishes drag-and-drop gestures by attaching temporary onmouse{up,move} events to the document 2// Only the header is draggable, the content is not 3function DragElement(elt) { 4 var x1=0, y1=0, x2=0, y2=0; 5 let header = document.getElementById(elt.id + "_header"); 6 if (header == undefined) { 7 return; 8 } 9 header.onmousedown = DragMouseDown; 10 11 function DragMouseDown(e) { 12 e = e || window.event; 13 e.preventDefault(); 14 // get the mouse cursor position at startup: 15 x2 = e.clientX; 16 y2 = e.clientY; 17 document.onmouseup = MouseUp; 18 // call a function whenever the cursor moves: 19 document.onmousemove = MouseMove; 20 } 21 22 function MouseMove(e) { 23 e = e || window.event; 24 e.preventDefault(); 25 x1 = x2 - e.clientX; y1 = y2 - e.clientY; 26 x2 = e.clientX; y2 = e.clientY; 27 elt.style.top = (elt.offsetTop - y1) + "px"; 28 elt.style.left= (elt.offsetLeft- x1) + "px"; 29 } 30 31 function MouseUp() { 32 document.onmouseup = null; 33 document.onmousemove = null; 34 } 35} 36 37function GetTotalCount(titles_and_intervals) { 38 let ret = 0; 39 titles_and_intervals.forEach((ti) => { 40 ret += ti[1].length; 41 }); 42 return ret; 43} 44 45var g_info_panel_table = undefined; 46 47// 6 rows 48// Serial, Sender, Dest, Path, Iface, Member 49function AddOneRowToTable(t, content) { 50 let tr = document.createElement("tr"); 51 let td = document.createElement("td"); 52 td.colSpan = 6; 53 t.appendChild(tr); 54 tr.appendChild(td); 55 td.innerText = content; 56} 57 58function AddDBusRowHeaderToTable(t) { 59 const headers = [ "Serial", "Sender", "Destination", "Path", "Iface", "Member" ]; 60 let tr = document.createElement("tr"); 61 headers.forEach((h) => { 62 let td = document.createElement("td"); 63 td.innerText = h; 64 td.style.backgroundColor = "#888"; 65 tr.appendChild(td); 66 }); 67 t.appendChild(tr); 68} 69 70function AddDBusMessageToTable(t, m) { 71 const minfo = m[2]; 72 const cols = [ 73 minfo[2], // serial 74 minfo[3], // sender 75 minfo[4], // destination 76 minfo[5], // path 77 minfo[6], // iface 78 minfo[7], // member 79 ]; 80 let tr = document.createElement("tr"); 81 cols.forEach((c) => { 82 let td = document.createElement("td"); 83 td.innerText = c; 84 td.onclick = () => { 85 console.log(m); 86 }; 87 tr.appendChild(td); 88 }); 89 t.appendChild(tr); 90} 91 92function UpdateHighlightedMessagesInfoPanel() { 93 const MAX_ENTRIES_SHOWN = 10000; // Show a maximum of this many 94 const ti_dbus = dbus_timeline_view.HighlightedMessages(); 95 const ti_ipmi = ipmi_timeline_view.HighlightedMessages(); 96 97 if (g_info_panel_table != undefined) { 98 g_info_panel_table.remove(); // Remove from DOM tree 99 } 100 101 g_info_panel_table = document.createElement("table"); 102 103 const p = document.getElementById("highlighted_messages"); 104 p.style.display = "block"; 105 106 const x = document.getElementById("highlighted_messages_content"); 107 x.appendChild(g_info_panel_table); 108 109 let nshown = 0; 110 const count_dbus = GetTotalCount(ti_dbus); 111 if (count_dbus > 0) { 112 AddOneRowToTable(g_info_panel_table, count_dbus + " DBus messages"); 113 AddDBusRowHeaderToTable(g_info_panel_table); 114 for (let i=0; i<ti_dbus.length; i++) { 115 const title_and_msgs = ti_dbus[i]; 116 // Title 117 AddOneRowToTable(g_info_panel_table, title_and_msgs[0]); 118 for (let j=0; j<title_and_msgs[1].length; j++) { 119 nshown ++; 120 if (nshown > MAX_ENTRIES_SHOWN) break; 121 AddDBusMessageToTable(g_info_panel_table, title_and_msgs[1][j]); 122 // Messages 123 } 124 } 125 } 126 const count_ipmi = GetTotalCount(ti_ipmi); 127 if (count_ipmi > 0) { 128 AddOneRowToTable(g_info_panel_table, count_ipmi + " IPMI messages"); 129 } 130 if (nshown > MAX_ENTRIES_SHOWN) { 131 AddOneRowToTable(g_info_panel_table, "Showing only " + MAX_ENTRIES_SHOWN + " entries"); 132 } 133}