Browse Source

HUE-1657 [oozie] SLA search page

Romain Rigaux 12 years ago
parent
commit
b1de2facee

+ 6 - 22
apps/oozie/src/oozie/templates/dashboard/list_oozie_sla.mako

@@ -37,9 +37,9 @@ ${ layout.menubar(section='sla', dashboard=True) }
   </h1>
 
   <ul class="nav nav-tabs">
-      <form class="form-search" id="search" method="GET" action=".">
-        <input type="text" name="job" class="searchFilter input-xlarge search-query" placeholder="${_('Job Name or Id (required)')}">
-        <input type="checkbox" name="isParent" placeholder="${_('Text Filter')}">
+      <form class="form-search" id="searchForm" method="GET" action=".">
+        <input type="text" name="job_name" class="searchFilter input-xlarge search-query" placeholder="${_('Job Name or Id (required)')}">
+        <input type="checkbox" name="isParent" class="searchFilter" placeholder="${_('Text Filter')}">
         ${ _('Parent ID') }
         Start
         <input type="text" name="start" class="searchFilter input-xlarge search-query" placeholder="${_('Start in GMT')}">
@@ -115,22 +115,6 @@ ${ layout.menubar(section='sla', dashboard=True) }
 
     $("*[rel=tooltip]").tooltip();
 
-/**
-        var _metadataTable = $("#graphTable").dataTable({
-            "bPaginate": false,
-            "bLengthChange": false,
-            "bInfo": false,
-            "bAutoWidth": false,
-            "aoColumns": [
-                { "sWidth": "30%" },
-                { "sWidth": "70%" }
-            ],
-            "oLanguage": {
-                "sEmptyTable": "${_('No data available')}",
-                "sZeroRecords": "${_('No matching records')}",
-            }
-        });
-*/
         var slaList = $("#intrumentationTable").dataTable({
             "bPaginate": false,
             "bLengthChange": false,
@@ -144,9 +128,9 @@ ${ layout.menubar(section='sla', dashboard=True) }
         });
 
     $(".searchFilter").keyup(function(){
-      ("form#search").submit();
-       // _metadataTable.fnFilter($(this).val());
-       // slaList.fnFilter($(".searchFilter").val());
+      $.post("${ url('oozie:list_oozie_sla') }", $("#searchForm").serialize(), function(data) {
+        $( ".result" ).html( data );
+      });
     });
 
     $(".dataTables_wrapper").css("min-height","0");

+ 21 - 19
apps/oozie/src/oozie/views/dashboard.py

@@ -332,29 +332,31 @@ def list_oozie_sla(request):
   api = get_oozie(request.user, api_version="v2")
 
   if request.method == 'POST':
-  # filter=nominal_start=2013-06-18T00:01Z;nominal_end=2013-06-23T00:01Z;app_name=my-sla-app
-    print request.POST
-    job_name = request.POST
+    # filter=nominal_start=2013-06-18T00:01Z;nominal_end=2013-06-23T00:01Z;app_name=my-sla-app
     params = {}
-    params['app_name'] = 'tt'
+    print request.POST
+    
+    job_name = request.POST.get('job_name')
+    if job_name.endswith('-oozie-oozi-W'):
+      if 'isParent' in request.POST:
+        params['parent_id'] = job_name
+      else:    
+        params['id'] = job_name
+    else:
+      params['app_name'] = job_name
+      
+    if request.POST.get('start'):
+      params['nominal_start'] = request.POST.get('start')
+    if request.POST.get('end'):
+      params['nominal_end'] = request.POST.get('end')
+      
     oozie_slas = api.get_oozie_slas(**params)  
+    
   else:
-    oozie_slas = []
+    oozie_slas = [] # or get latest?
   
-  # query matches Oozie id
-  # if parent checkbox:
-  #  parent_id = query
-  # else:
-  #   id = query
-  # else if query:
-  # app_name = query
-  
-  # if start
-  #   nominal_start=2013-06-18T00:01Z
-  # if end
-  #   nominal_end=2013-06-23T00:01Z
-
-
+  if request.REQUEST.get('format') == 'json':
+    return HttpResponse(json.dumps({'oozie_slas': oozie_slas}), content_type="text/plain")
 
   return render('dashboard/list_oozie_sla.mako', request, {
     'oozie_slas': oozie_slas,

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

@@ -40,7 +40,7 @@ _api_cache = None
 _api_cache_lock = threading.Lock()
 
 
-def get_oozie(user, api_version=API_VERSION):
+def get_oozie(user, api_version=API_VERSION): # cf. cache version pb
   global _api_cache
   if _api_cache is None:
     _api_cache_lock.acquire()