浏览代码

HUE-5279 Bundle text filtering should call oozie rest API to display jobs list

krish 9 年之前
父节点
当前提交
64533ac

+ 26 - 8
apps/oozie/src/oozie/templates/dashboard/list_oozie_bundles.mako

@@ -185,6 +185,7 @@ ${layout.menubar(section='bundles', dashboard=True)}
   var runningTableOffset = 1, completedTableOffset = 1;
   var totalRunningJobs = 0, totalCompletedJobs = 0;
   var PAGE_SIZE = 50;
+  var filterTimeout = null;
 
   $(document).ready(function () {
 
@@ -266,14 +267,17 @@ ${layout.menubar(section='bundles', dashboard=True)}
     });
 
     $("#filterInput").keyup(function () {
-      runningTable.fnFilter($(this).val());
-      completedTable.fnFilter($(this).val());
+      if (filterTimeout != null) {
+        clearTimeout(filterTimeout);
+      }
+      filterTimeout = setTimeout(refreshTables, 500);
 
       var hash = "#";
       if ($("a.btn-date.active").length > 0) {
         hash += "date=" + $("a.btn-date.active").text();
       }
       window.location.hash = hash;
+      refreshPagination();
     });
 
     $("a.btn-pagination").on("click", function () {
@@ -315,6 +319,22 @@ ${layout.menubar(section='bundles', dashboard=True)}
       $("a.btn-date[data-value='" + hash.split("=")[1] + "']").click();
     }
 
+    function refreshTables() {
+      refreshRunning();
+      refreshCompleted();
+      refreshProgress();
+    }
+
+
+    function getTextFilter() {
+      var filterBtn = $("#filterInput");
+      var textFilter = '';
+      if (filterBtn.val()) {
+        textFilter = '&text=' + filterBtn.val();
+      }
+      return textFilter;
+    }
+
     function refreshPagination() {
       runningTableOffset = 1;
       completedTableOffset = 1;
@@ -385,7 +405,7 @@ ${layout.menubar(section='bundles', dashboard=True)}
     var numRunning = 0;
 
     refreshRunning = function () {
-      $.getJSON(window.location.pathname + "?format=json&offset=" + runningTableOffset + getStatuses('running'), function (data) {
+      $.getJSON(window.location.pathname + "?format=json&offset=" + runningTableOffset + getStatuses('running') + getTextFilter(), function (data) {
         // Refresh pagination buttons
         totalRunningJobs = data.total_jobs;
         refreshPaginationButtons("running", totalRunningJobs);
@@ -479,7 +499,7 @@ ${layout.menubar(section='bundles', dashboard=True)}
     }
 
     function refreshCompleted() {
-      $.getJSON(window.location.pathname + "?format=json&offset=" + completedTableOffset + getStatuses('completed'), function (data) {
+      $.getJSON(window.location.pathname + "?format=json&offset=" + completedTableOffset + getStatuses('completed') + getTextFilter(), function (data) {
         // Refresh pagination buttons
         totalCompletedJobs = data.total_jobs;
         refreshPaginationButtons("completed", totalCompletedJobs);
@@ -506,7 +526,7 @@ ${layout.menubar(section='bundles', dashboard=True)}
     }
 
     function refreshProgress() {
-      $.getJSON(window.location.pathname + "?format=json&type=progress" + getStatuses('running'), function (data) {
+      $.getJSON(window.location.pathname + "?format=json&type=progress" + getStatuses('running') + getTextFilter(), function (data) {
         var nNodes = runningTable.fnGetNodes();
         $(data.jobs).each(function (iWf, item) {
             var bundle = new Bundle(item);
@@ -530,9 +550,7 @@ ${layout.menubar(section='bundles', dashboard=True)}
       });
     }
 
-    refreshRunning();
-    refreshCompleted();
-    refreshProgress();
+    refreshTables();
 
   });
 </script>

+ 1 - 2
apps/oozie/src/oozie/templates/dashboard/list_oozie_coordinators.mako

@@ -313,8 +313,7 @@ ${layout.menubar(section='coordinators', dashboard=True)}
         clearTimeout(filterTimeout);
       }
       filterTimeout = setTimeout(refreshTables, 500);
-      refreshRunning();
-      refreshCompleted();
+      refreshPagination();
     });
 
     $("a.btn-pagination").on("click", function () {

+ 1 - 0
apps/oozie/src/oozie/templates/dashboard/list_oozie_workflows.mako

@@ -307,6 +307,7 @@ ${ layout.menubar(section='workflows', dashboard=True) }
         clearTimeout(filterTimeout);
       }
       filterTimeout = setTimeout(refreshTables, 500);
+      refreshPagination();
     });
 
 

+ 3 - 0
apps/oozie/src/oozie/views/dashboard.py

@@ -271,6 +271,9 @@ def list_oozie_bundles(request):
     if request.GET.get('offset'):
       kwargs['offset'] = request.GET.get('offset')
 
+    if request.GET.get('text'):
+      kwargs['filters'].extend([('text', request.GET.get('text'))])
+
     json_jobs = []
     total_jobs = 0
     if request.GET.getlist('status'):