Skip to content

Commit 878e3b8

Browse files
committed
Fixed a bug that tooltip remains
1 parent b9d8f1b commit 878e3b8

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

core/src/main/resources/org/apache/spark/ui/static/timeline-view.js

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,40 @@ function drawTaskAssignmentTimeline(groupArray, eventObjArray, minLaunchTime, zo
159159
curEnd = minLaunchTime + zoomMax;
160160
}
161161
taskTimeline.setWindow(minLaunchTime, curEnd);
162+
taskTimeline.on("rangechange", function(prop) {
163+
if (currentDisplayedTooltip !== null) {
164+
$(currentDisplayedTooltip).tooltip("hide");
165+
}
166+
});
167+
168+
function getTaskIdxAndAttempt(selector) {
169+
var taskIdxText = $(selector).attr("data-title");
170+
var taskIdxAndAttempt = taskIdxText.match("Task (\\d+) \\(attempt (\\d+)");
171+
var taskIdx = taskIdxAndAttempt[1];
172+
var taskAttempt = taskIdxAndAttempt[2];
173+
return taskIdx + "-" + taskAttempt;
174+
}
175+
176+
// If we zoom up and a box moves away when the corresponding tooltip is shown,
177+
// the tooltip can be remain.
178+
// So, we need to hide tooltips using another mechanism.
179+
var currentDisplayedTooltip = null;
180+
181+
$("#task-assignment-timeline").on({
182+
"mouseenter": function() {
183+
var taskIdxAndAttempt = getTaskIdxAndAttempt(this);
184+
$("#task-" + taskIdxAndAttempt).addClass("corresponding-item-hover");
185+
$(this).tooltip("show");
186+
currentDisplayedTooltip = this;
187+
},
188+
"mouseleave" : function() {
189+
var taskIdxAndAttempt = getTaskIdxAndAttempt(this);
190+
$("#task-" + taskIdxAndAttempt).removeClass("corresponding-item-hover");
191+
$(this).tooltip("hide");
192+
currentDisplayedTooltip = null;
193+
}
194+
}, ".task-assignment-timeline-content");
195+
162196
setupZoomable('#task-assignment-timeline-zoom-lock', taskTimeline);
163197

164198
$("span.expand-task-assignment-timeline").click(function() {
@@ -170,16 +204,6 @@ function drawTaskAssignmentTimeline(groupArray, eventObjArray, minLaunchTime, zo
170204
});
171205
}
172206

173-
function setupTaskEventActionOnMouseOver(taskIdAndAttempt) {
174-
$("#task-" + taskIdAndAttempt).addClass("corresponding-item-hover");
175-
$("#task-event-" + taskIdAndAttempt).tooltip("show");
176-
}
177-
178-
function setupTaskEventActionOnMouseOut(taskIdAndAttempt) {
179-
$("#task-" + taskIdAndAttempt).removeClass("corresponding-item-hover");
180-
$("#task-" + taskIdAndAttempt).tooltip("hide");
181-
}
182-
183207
function setupExecutorEventAction() {
184208
$(".item.box.executor").each(function () {
185209
$(this).hover(

core/src/main/scala/org/apache/spark/ui/jobs/StagePage.scala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,19 +582,15 @@ private[ui] class StagePage(parent: StagesTab) extends WebUIPage("stage") {
582582

583583
val index = taskInfo.index
584584
val attempt = taskInfo.attempt
585-
val indexAndAttempt = index + "-" + attempt
586585
val timelineObject =
587586
s"""
588587
{
589588
'className': 'task task-assignment-timeline-object ${classNameByStatus}',
590589
'group': '${executorId}',
591-
'content': '<div id="task-event-${indexAndAttempt}"' +
592-
'onmouseover="setupTaskEventActionOnMouseOver(\\'${indexAndAttempt}\\')"' +
593-
'onmouseout="setupTaskEventActionOnMouseOut(\\'${indexAndAttempt}\\')"' +
594-
'class="task-assignment-timeline-content"' +
590+
'content': '<div class="task-assignment-timeline-content"' +
595591
'data-toggle="tooltip" data-placement="top"' +
596592
'data-html="true" data-container="body"' +
597-
'data-title="${s"Task" + index + "(attempt " + attempt + ")"}<br>' +
593+
'data-title="${s"Task " + index + " (attempt " + attempt + ")"}<br>' +
598594
'Status: ${taskInfo.status}<br>' +
599595
'Launch Time: ${UIUtils.formatDate(new Date(launchTime))}' +
600596
'${

0 commit comments

Comments
 (0)