This is an automated email from the ASF dual-hosted git repository.

srowen pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-2.4 by this push:
     new 2516128  [SPARK-32886][WEBUI] fix 'undefined' link in event timeline 
view
2516128 is described below

commit 2516128e466c489effc20e72d06c26a2d2f7faed
Author: Zhen Li <z...@microsoft.com>
AuthorDate: Mon Sep 21 09:05:40 2020 -0500

    [SPARK-32886][WEBUI] fix 'undefined' link in event timeline view
    
    ### What changes were proposed in this pull request?
    
    Fix ".../jobs/undefined" link from "Event Timeline" in jobs page. Job page 
link in "Event Timeline" view is constructed by fetching job page link defined 
in job list below. when job count exceeds page size of job table, only links of 
jobs in job table can be fetched from page. Other jobs' link would be 
'undefined', and links of them in "Event Timeline" are broken, they are 
redirected to some wired URL like ".../jobs/undefined". This PR is fixing this 
wrong link issue. With this PR, jo [...]
    
    ### Why are the changes needed?
    
    Wrong link (".../jobs/undefined") in "Event Timeline" of jobs page. for 
example, the first job in below page is not in table below, as job count(116) 
exceeds page size(100). When clicking it's item in "Event Timeline", page is 
redirected to ".../jobs/undefined", which is wrong. Links in "Event Timeline" 
should always be correct.
    
![undefinedlink](https://user-images.githubusercontent.com/10524738/93184779-83fa6d80-f6f1-11ea-8a80-1a304ca9cbb2.JPG)
    
    ### Does this PR introduce _any_ user-facing change?
    
    No
    
    ### How was this patch tested?
    
    Manually tested.
    
    Closes #29757 from zhli1142015/fix-link-event-timeline-view.
    
    Authored-by: Zhen Li <z...@microsoft.com>
    Signed-off-by: Sean Owen <sro...@gmail.com>
    (cherry picked from commit d01594e8d186e63a6c3ce361e756565e830d5237)
    Signed-off-by: Sean Owen <sro...@gmail.com>
---
 .../org/apache/spark/ui/static/timeline-view.js    | 53 ++++++++++++++--------
 1 file changed, 33 insertions(+), 20 deletions(-)

diff --git 
a/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js 
b/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js
index 5be8cff..220b76a 100644
--- a/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js
+++ b/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js
@@ -42,26 +42,31 @@ function drawApplicationTimeline(groupArray, eventObjArray, 
startTime, offset) {
   setupZoomable("#application-timeline-zoom-lock", applicationTimeline);
   setupExecutorEventAction();
 
+  function getIdForJobEntry(baseElem) {
+    var jobIdText = 
$($(baseElem).find(".application-timeline-content")[0]).text();
+    var jobId = jobIdText.match("\\(Job (\\d+)\\)$")[1];
+    return jobId;
+  }
+
+  function getSelectorForJobEntry(jobId) {
+    return "#job-" + jobId;
+  }
+
   function setupJobEventAction() {
     $(".vis-item.vis-range.job.application-timeline-object").each(function() {
-      var getSelectorForJobEntry = function(baseElem) {
-        var jobIdText = 
$($(baseElem).find(".application-timeline-content")[0]).text();
-        var jobId = jobIdText.match("\\(Job (\\d+)\\)$")[1];
-       return "#job-" + jobId;
-      };
-
       $(this).click(function() {
-        var jobPagePath = 
$(getSelectorForJobEntry(this)).find("a.name-link").attr("href");
-          window.location.href = jobPagePath
+        var jobId = getIdForJobEntry(this);
+        var jobPagePath = uiRoot + appBasePath + "/jobs/job/?id=" + jobId;
+        window.location.href = jobPagePath;
       });
 
       $(this).hover(
         function() {
-          $(getSelectorForJobEntry(this)).addClass("corresponding-item-hover");
+          
$(getSelectorForJobEntry(getIdForJobEntry(this))).addClass("corresponding-item-hover");
           
$($(this).find("div.application-timeline-content")[0]).tooltip("show");
         },
         function() {
-          
$(getSelectorForJobEntry(this)).removeClass("corresponding-item-hover");
+          
$(getSelectorForJobEntry(getIdForJobEntry(this))).removeClass("corresponding-item-hover");
           
$($(this).find("div.application-timeline-content")[0]).tooltip("hide");
         }
       );
@@ -125,26 +130,34 @@ function drawJobTimeline(groupArray, eventObjArray, 
startTime, offset) {
   setupZoomable("#job-timeline-zoom-lock", jobTimeline);
   setupExecutorEventAction();
 
+  function getStageIdAndAttemptForStageEntry(baseElem) {
+    var stageIdText = $($(baseElem).find(".job-timeline-content")[0]).text();
+    var stageIdAndAttempt = stageIdText.match("\\(Stage 
(\\d+\\.\\d+)\\)$")[1].split(".");
+    return stageIdAndAttempt;
+  }
+
+  function getSelectorForStageEntry(stageIdAndAttempt) {
+    return "#stage-" + stageIdAndAttempt[0] + "-" + stageIdAndAttempt[1];
+  }
+
   function setupStageEventAction() {
     $(".vis-item.vis-range.stage.job-timeline-object").each(function() {
-      var getSelectorForStageEntry = function(baseElem) {
-        var stageIdText = 
$($(baseElem).find(".job-timeline-content")[0]).text();
-        var stageIdAndAttempt = stageIdText.match("\\(Stage 
(\\d+\\.\\d+)\\)$")[1].split(".");
-        return "#stage-" + stageIdAndAttempt[0] + "-" + stageIdAndAttempt[1];
-      };
-
       $(this).click(function() {
-        var stagePagePath = 
$(getSelectorForStageEntry(this)).find("a.name-link").attr("href")
-        window.location.href = stagePagePath
+        var stageIdAndAttempt = getStageIdAndAttemptForStageEntry(this);
+        var stagePagePath = uiRoot + appBasePath +
+          "/stages/stage/?id=" + stageIdAndAttempt[0] + "&attempt=" + 
stageIdAndAttempt[1];
+        window.location.href = stagePagePath;
       });
 
       $(this).hover(
         function() {
-          
$(getSelectorForStageEntry(this)).addClass("corresponding-item-hover");
+          $(getSelectorForStageEntry(getStageIdAndAttemptForStageEntry(this)))
+            .addClass("corresponding-item-hover");
           $($(this).find("div.job-timeline-content")[0]).tooltip("show");
         },
         function() {
-          
$(getSelectorForStageEntry(this)).removeClass("corresponding-item-hover");
+          $(getSelectorForStageEntry(getStageIdAndAttemptForStageEntry(this)))
+            .removeClass("corresponding-item-hover");
           $($(this).find("div.job-timeline-content")[0]).tooltip("hide");
         }
       );


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to