Browse Source

HUE-1176 [jb] Move workflow specific code to a method

Romain Rigaux 8 years ago
parent
commit
9307c94
1 changed files with 46 additions and 49 deletions
  1. 46 49
      apps/jobbrowser/src/jobbrowser/templates/job_browser.mako

+ 46 - 49
apps/jobbrowser/src/jobbrowser/templates/job_browser.mako

@@ -281,6 +281,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
       <!-- ko if: $index() == 0 -->
         <a href="javascript:void(0)" data-bind="text: name, click: function() { $root.selectInterface(name); }" style="text-transform: capitalize"></a>
       <!-- /ko -->
+
       <!-- ko if: $index() != 0 -->
         <!-- ko if: $index() != $parent.breadcrumbs().length - 1 -->
           <a href="javascript:void(0)" data-bind="click: function() { $parent.breadcrumbs.splice($index()); $root.job().id(id); $root.job().fetchJob(); }">
@@ -997,55 +998,6 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
 
   (function () {
 
-/**  cf. updateWorkflowGraph()
-
-    var Workflow = function(vm, job) {
-
-            var lastPosition = {
-              top: 0,
-              left: 0
-            }
-
-            var updateArrowPosition = function () {
-              huePubSub.publish('draw.graph.arrows');
-              if ($('canvas').position().top !== lastPosition.top && $('canvas').position().left !== lastPosition.left) {
-                lastPosition = $('canvas').position();
-                window.setTimeout(updateArrowPosition, 100);
-              }
-            }
-
-            var arrowsPolling = function () {
-              if ($('#workflow-page-graph').is(':visible')){
-                window.setTimeout(arrowsPolling, 100);
-              }
-              else {
-                $('canvas').remove();
-              }
-            }
-
-            $('canvas').remove();
-
-            if (vm.job().type() === 'workflow') {
-              $('#workflow-page-graph').empty();
-              $.ajax({
-                url: "/oozie/list_oozie_workflow/" + vm.job().id(),
-                data: {
-                  'graph': true,
-                  'element': 'workflow-page-graph'
-                },
-                beforeSend: function (xhr) {
-                  xhr.setRequestHeader("X-Requested-With", "Hue");
-                },
-                dataType: "html",
-                success: function (response) {
-                  $('#workflow-page-graph').html(response);
-                  updateArrowPosition();
-                  arrowsPolling();
-                }
-              });
-            }
-    }
-*/
     var Job = function (vm, job) {
       var self = this;
 
@@ -1256,6 +1208,51 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
           }
         });
       };
+
+      self.updateWorkflowGraph = function() {
+        var lastPosition = {
+          top: 0,
+          left: 0
+        }
+
+        var updateArrowPosition = function () {
+          huePubSub.publish('draw.graph.arrows');
+          if ($('canvas').position().top !== lastPosition.top && $('canvas').position().left !== lastPosition.left) {
+            lastPosition = $('canvas').position();
+            window.setTimeout(updateArrowPosition, 100);
+          }
+        }
+
+        var arrowsPolling = function () {
+          if ($('#workflow-page-graph').is(':visible')){
+            window.setTimeout(arrowsPolling, 100);
+          }
+          else {
+            $('canvas').remove();
+          }
+        }
+
+        $('canvas').remove();
+
+        if (vm.job().type() === 'workflow') {
+          $('#workflow-page-graph').empty();
+          $.ajax({
+            url: "/oozie/list_oozie_workflow/" + vm.job().id(),
+            data: {
+              'graph': true,
+              'element': 'workflow-page-graph'
+            },
+            beforeSend: function (xhr) {
+              xhr.setRequestHeader("X-Requested-With", "Hue");
+            },
+            dataType: "html",
+            success: function (response) {
+              $('#workflow-page-graph').html(response);
+              updateArrowPosition();
+              arrowsPolling();
+            }
+          });
+        }
     };
 
     var Jobs = function (vm) {