瀏覽代碼

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

krish 9 年之前
父節點
當前提交
2e6ce60

+ 28 - 9
apps/oozie/src/oozie/templates/dashboard/list_oozie_coordinators.mako

@@ -212,6 +212,7 @@ ${layout.menubar(section='coordinators', dashboard=True)}
   var runningTableOffset = 1, completedTableOffset = 1;
   var totalRunningJobs = 0, totalCompletedJobs = 0;
   var PAGE_SIZE = 50;
+  var filterTimeout = null;
 
   $(document).ready(function () {
 
@@ -302,14 +303,18 @@ ${layout.menubar(section='coordinators', dashboard=True)}
     });
 
     $("#filterInput").keyup(function () {
-      runningTable.fnFilter($(this).val());
-      completedTable.fnFilter($(this).val());
-
       var hash = "#";
       if ($("a.btn-date.active").length > 0) {
         hash += "date=" + $("a.btn-date.active").text();
       }
       window.location.hash = hash;
+
+      if (filterTimeout != null) {
+        clearTimeout(filterTimeout);
+      }
+      filterTimeout = setTimeout(refreshTables, 500);
+      refreshRunning();
+      refreshCompleted();
     });
 
     $("a.btn-pagination").on("click", function () {
@@ -351,6 +356,22 @@ ${layout.menubar(section='coordinators', 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;
@@ -423,7 +444,7 @@ ${layout.menubar(section='coordinators', 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);
@@ -535,7 +556,7 @@ ${layout.menubar(section='coordinators', 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;
@@ -570,7 +591,7 @@ ${layout.menubar(section='coordinators', 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 (iCoord, item) {
             var coord = new Coordinator(item);
@@ -602,9 +623,7 @@ ${layout.menubar(section='coordinators', dashboard=True)}
       });
     }
 
-    refreshRunning();
-    refreshCompleted();
-    refreshProgress();
+    refreshTables();
   });
 </script>
 ${ utils.bulk_dashboard_functions() }

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

@@ -235,6 +235,9 @@ def list_oozie_coordinators(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'):