Explorar o código

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

krish %!s(int64=9) %!d(string=hai) anos
pai
achega
e4eb56d

+ 26 - 15
apps/oozie/src/oozie/templates/dashboard/list_oozie_workflows.mako

@@ -217,6 +217,7 @@ ${ layout.menubar(section='workflows', dashboard=True) }
   var runningTableOffset = 1, completedTableOffset = 1;
   var totalRunningJobs = 0, totalCompletedJobs = 0;
   var PAGE_SIZE = 50;
+  var filterTimeout = null;
 
   $(document).ready(function () {
 
@@ -302,9 +303,10 @@ ${ layout.menubar(section='workflows', dashboard=True) }
     });
 
     $("#filterInput").keyup(function () {
-      runningTable.fnFilter($(this).val());
-      completedTable.fnFilter($(this).val());
-      drawTable();
+      if (filterTimeout != null) {
+        clearTimeout(filterTimeout);
+      }
+      filterTimeout = setTimeout(refreshTables, 500);
     });
 
 
@@ -332,9 +334,7 @@ ${ layout.menubar(section='workflows', dashboard=True) }
     $("a.btn-status").click(function () {
       refreshPagination();
       $(this).toggleClass("active");
-      refreshRunning();
-      refreshCompleted();
-      refreshProgress();
+      refreshTables;
     });
 
     $("a.btn-submitted").click(function () {
@@ -347,9 +347,7 @@ ${ layout.menubar(section='workflows', dashboard=True) }
       refreshPagination();
       $("a.btn-date").not(this).removeClass("active");
       $(this).toggleClass("active");
-      refreshRunning();
-      refreshCompleted();
-      refreshProgress();
+      refreshTables();
     });
 
     var hash = window.location.hash.replace(/(<([^>]+)>)/ig, "");
@@ -357,6 +355,12 @@ ${ layout.menubar(section='workflows', dashboard=True) }
       $("a.btn-date[data-value='" + hash.split("=")[1] + "']").click();
     }
 
+    function refreshTables() {
+      refreshRunning();
+      refreshCompleted();
+      refreshProgress();
+    }
+
     function refreshPagination() {
       runningTableOffset = 1;
       completedTableOffset = 1;
@@ -407,6 +411,15 @@ ${ layout.menubar(section='workflows', dashboard=True) }
       return daysFilter;
     }
 
+    function getTextFilter() {
+      var filterBtn = $("#filterInput");
+      var textFilter = '';
+      if (filterBtn.val()) {
+        textFilter = '&text=' + filterBtn.val();
+      }
+      return textFilter;
+    }
+
     $.fn.dataTableExt.sErrMode = "throw";
 
     $.fn.dataTableExt.afnFiltering.push(PersistedButtonsFilters); // from dashboard-utils.js
@@ -441,7 +454,7 @@ ${ layout.menubar(section='workflows', dashboard=True) }
 
     refreshRunning = function () {
       window.clearTimeout(runningTimeout);
-      $.getJSON(window.location.pathname + "?format=json&offset=" + runningTableOffset + getStatuses('running') + getDaysFilter(), function (data) {
+      $.getJSON(window.location.pathname + "?format=json&offset=" + runningTableOffset + getStatuses('running') + getDaysFilter() + getTextFilter(), function (data) {
         if (data.jobs.length > 0) {
           totalRunningJobs = data.total_jobs;
           refreshPaginationButtons("running", totalRunningJobs);
@@ -549,7 +562,7 @@ ${ layout.menubar(section='workflows', dashboard=True) }
     }
 
     function refreshCompleted() {
-      $.getJSON(window.location.pathname + "?format=json&offset=" + completedTableOffset + getStatuses('completed') + getDaysFilter(), function (data) {
+      $.getJSON(window.location.pathname + "?format=json&offset=" + completedTableOffset + getStatuses('completed') + getDaysFilter() + getTextFilter(), function (data) {
         if(data.jobs.length > 0) {
           totalCompletedJobs = data.total_jobs;
           refreshPaginationButtons("completed", totalCompletedJobs);
@@ -578,7 +591,7 @@ ${ layout.menubar(section='workflows', dashboard=True) }
 
     function refreshProgress() {
       window.clearTimeout(progressTimeout);
-      $.getJSON(window.location.pathname + "?format=json&type=progress&offset=" + runningTableOffset + getStatuses('running') + getDaysFilter(), function (data) {
+      $.getJSON(window.location.pathname + "?format=json&type=progress&offset=" + runningTableOffset + getStatuses('running') + getDaysFilter() + getTextFilter(), function (data) {
         var nNodes = runningTable.fnGetNodes();
         $(data.jobs).each(function (iWf, item) {
             var wf = new Workflow(item);
@@ -605,9 +618,7 @@ ${ layout.menubar(section='workflows', dashboard=True) }
       });
     }
 
-    refreshRunning();
-    refreshCompleted();
-    refreshProgress();
+    refreshTables();
 
   });
 

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

@@ -194,6 +194,9 @@ def list_oozie_workflows(request):
     if request.GET.get('startcreatedtime'):
       kwargs['filters'].extend([('startcreatedtime', request.GET.get('startcreatedtime'))])
 
+    if request.GET.get('text'):
+      kwargs['filters'].extend([('text', request.GET.get('text'))])
+
     if request.GET.get('offset'):
       kwargs['offset'] = request.GET.get('offset')
 

+ 1 - 1
desktop/libs/liboozie/src/liboozie/oozie_api.py

@@ -89,7 +89,7 @@ class OozieApi(object):
 
     return defaults
 
-  VALID_JOB_FILTERS = ('name', 'user', 'group', 'status', 'startcreatedtime')
+  VALID_JOB_FILTERS = ('name', 'user', 'group', 'status', 'startcreatedtime', 'text')
   VALID_LOG_FILTERS = set(('recent', 'limit', 'loglevel', 'text'))
 
   def get_jobs(self, jobtype, offset=None, cnt=None, filters=None):