[full-line] ML-2785 use table in double click eval

GitOrigin-RevId: 641dc763de1b9b827675e78ead77abe4adc45a52
This commit is contained in:
Petr Surkov
2024-02-20 21:41:34 +01:00
committed by intellij-monorepo-bot
parent a34970eb76
commit ac16eeda3a

View File

@@ -158,11 +158,11 @@ function addCommonFeatures(sessionDiv, popup, lookup) {
}
}
addTriggerModelBlock(popup, lookup)
addDiagnosticsBlock("RAW SUGGESTIONS:", "raw_proposals", popup, lookup)
addDiagnosticsBlock("RAW FILTERED:", "raw_filtered", popup, lookup)
addDiagnosticsBlock("ANALYZED SUGGESTIONS:", "analyzed_proposals", popup, lookup)
addDiagnosticsBlock("ANALYZED FILTERED:", "analyzed_filtered", popup, lookup)
addDiagnosticsBlock("RESULT SUGGESTIONS:", "result_proposals", popup, lookup)
addDiagnosticsBlock("RAW SUGGESTIONS", "raw_proposals", popup, lookup)
addDiagnosticsBlock("RAW FILTERED", "raw_filtered", popup, lookup)
addDiagnosticsBlock("ANALYZED SUGGESTIONS", "analyzed_proposals", popup, lookup)
addDiagnosticsBlock("ANALYZED FILTERED", "analyzed_filtered", popup, lookup)
addDiagnosticsBlock("RESULT SUGGESTIONS", "result_proposals", popup, lookup)
}
function addSuggestions(sessionDiv, popup, lookup) {
@@ -193,21 +193,76 @@ function addTriggerModelBlock(popup, lookup) {
popup.appendChild(triggerModelResults)
}
// thanks to AI Assistant
function addDiagnosticsBlock(description, field, popup, lookup) {
if (!(field in lookup["additionalInfo"])) return
let diagnosticsDiv = document.createElement("DIV")
diagnosticsDiv.innerHTML = description
popup.appendChild(diagnosticsDiv)
const diagnostics = lookup["additionalInfo"][field];
// Create a table if it doesn't exist yet
let table = popup.querySelector("table")
if (!table) {
table = document.createElement("table")
table.style.borderCollapse = "collapse"
popup.appendChild(table)
}
// Create a new row
let row = table.insertRow()
// Cell for the header
let headerCell = document.createElement("th")
let headerSpan = document.createElement("span")
headerSpan.innerHTML = description
headerSpan.style.fontWeight = "normal"
headerSpan.style.fontSize = "small"
headerCell.appendChild(headerSpan)
row.appendChild(headerCell)
// Cell for the text
let textCell = row.insertCell()
textCell.style.paddingLeft = "10px"
textCell.style.verticalAlign = "top"
let ul = document.createElement("ul")
ul.style.listStyleType = "disc"
ul.style.marginTop = "0"
ul.style.marginBottom = "0"
let elements = 0
for (let i = 0; i < diagnostics.length; i++) {
if (diagnostics[i]["second"] == null) continue
let textDiv = document.createElement("DIV")
textDiv.setAttribute("class", "suggestion")
let p = document.createElement("code")
p.setAttribute("class", "suggestion-p")
p.innerHTML = diagnostics[i]["first"].replace(/</g, '&lt;').replace(/>/g, '&gt;') + " (" + diagnostics[i]["second"] + ")"
textDiv.appendChild(p)
popup.appendChild(textDiv)
elements++
let li = document.createElement("li")
let code = document.createElement("code")
code.innerHTML = diagnostics[i]["first"] + " (" + diagnostics[i]["second"] + ")"
li.appendChild(code)
ul.appendChild(li)
}
if (elements === 0) {
row.style.color = "#CCC"
}
row.style.backgroundColor = "#FFF"
textCell.appendChild(ul)
// Add thin gray lines between rows
let rows = table.rows
for (let i = 1; i < rows.length; i++) {
let row = rows[i]
row.style.borderTop = "1px solid #CCC"
// Add spacing between rows
let cells = row.cells
for (let j = 0; j < cells.length; j++) {
cells[j].style.paddingTop = "5px"
}
}
}