Prechádzať zdrojové kódy

HUE-2776 [oozie] Fix "View All Tasks" pagination in the Hue Jobbrowser

krish 10 rokov pred
rodič
commit
f90efe9

+ 72 - 53
apps/jobbrowser/src/jobbrowser/templates/tasks.mako

@@ -61,71 +61,90 @@ ${ comps.menubar() }
           />
         </form>
       </p>
-    </div>
 
-    % if not page.object_list:
-    <p>${_('There were no tasks that match your search criteria.')}</p>
-    % else:
-    <table class="datatables table table-condensed">
-      <thead>
-        <tr>
-          <th>${_('Logs')}</th>
-          <th>${_('Task ID')}</th>
-          <th>${_('Type')}</th>
-          <th>${_('Progress')}</th>
-          <th>${_('Status')}</th>
-          <th>${_('State')}</th>
-          <th>${_('Start Time')}</th>
-          <th>${_('End Time')}</th>
-          <th>${_('View Attempts')}</th>
-        </tr>
-      </thead>
-      <tbody>
-      %for t in page.object_list:
-        <tr>
-          <td data-row-selector-exclude="true">
-              %if t.taskAttemptIds:
-              <a href="${ url('jobbrowser.views.single_task_attempt_logs', job=t.jobId, taskid=t.taskId, attemptid=t.taskAttemptIds[-1]) }" data-row-selector-exclude="true"><i class="fa fa-tasks"></i></a>
-              %endif
-          </td>
-          <td>${t.taskId_short}</td>
-          <td>${t.taskType}</td>
-          <td>
-            <div class="bar">${ "%d" % (t.progress * 100) }%</div>
-          </td>
-          <td>
-            <a href="${ url('jobbrowser.views.tasks', job=job.jobId) }?${ get_state_link(request, 'taskstate', t.state.lower()) }"
-               title="${ _('Show only %(state)s tasks') % dict(state=t.state.lower()) }"
-               class="${ t.state.lower() }">${ t.state.lower() }
-            </a>
-          </td>
-          <td>${t.mostRecentState}</td>
-          <td>${t.execStartTimeFormatted}</td>
-          <td>${t.execFinishTimeFormatted}</td>
-          <td><a href="${ url('jobbrowser.views.single_task', job=job.jobId, taskid=t.taskId) }" data-row-selector="true">${_('Attempts')}</a></td>
-        </tr>
-      %endfor
-      </tbody>
-    </table>
-    %endif
+      <table class="datatables table table-condensed" id="all_tasks">
+        <thead>
+          <tr>
+            <th>${_('Logs')}</th>
+            <th>${_('Task ID')}</th>
+            <th>${_('Type')}</th>
+            <th>${_('Progress')}</th>
+            <th>${_('Status')}</th>
+            <th>${_('State')}</th>
+            <th>${_('Start Time')}</th>
+            <th>${_('End Time')}</th>
+            <th>${_('View Attempts')}</th>
+          </tr>
+        </thead>
+        <tbody>
+        %for t in task_list:
+          <tr>
+            <td data-row-selector-exclude="true">
+                %if t.taskAttemptIds:
+                <a href="${ url('jobbrowser.views.single_task_attempt_logs', job=t.jobId, taskid=t.taskId, attemptid=t.taskAttemptIds[-1]) }" data-row-selector-exclude="true"><i class="fa fa-tasks"></i></a>
+                %endif
+            </td>
+            <td>${t.taskId_short}</td>
+            <td>${t.taskType}</td>
+            <td>
+              <div class="bar">${ "%d" % (t.progress * 100) }%</div>
+            </td>
+            <td>
+              <a href="${ url('jobbrowser.views.tasks', job=job.jobId) }?${ get_state_link(request, 'taskstate', t.state.lower()) }"
+                 title="${ _('Show only %(state)s tasks') % dict(state=t.state.lower()) }"
+                 class="${ t.state.lower() }">${ t.state.lower() }
+              </a>
+            </td>
+            <td>${t.mostRecentState}</td>
+            <td>${t.execStartTimeFormatted}</td>
+            <td>${t.execFinishTimeFormatted}</td>
+            <td><a href="${ url('jobbrowser.views.single_task', job=job.jobId, taskid=t.taskId) }" data-row-selector="true">${_('Attempts')}</a></td>
+          </tr>
+        %endfor
+        </tbody>
+      </table>
+    </div>
   </div>
 </div>
 
+<script src="${ static('desktop/ext/js/datatables-paging-0.1.js') }" type="text/javascript" charset="utf-8"></script>
+
 <script type="text/javascript" charset="utf-8">
     $(document).ready(function(){
-        $(".datatables").dataTable({
-            "bPaginate": false,
+        $("#all_tasks").dataTable({
+            "sPaginationType":"bootstrap",
+            "iDisplayLength":100,
             "bLengthChange": false,
+            "sDom":"<'row'r>t<'row'<'span6'i><''p>>",
             "bFilter": false,
-            "bInfo": false,
             "aaSorting": [[ 1, "asc" ]],
+            "aoColumns":[
+              { "bSortable":false },
+              null,
+              null,
+              null,
+              null,
+              null,
+              null,
+              null,
+              { "bSortable":false }
+            ],
             "oLanguage": {
-                "sEmptyTable": "${_('No data available')}",
-                "sZeroRecords": "${_('No matching records')}",
+              "sEmptyTable": "${_('No data available')}",
+              "sZeroRecords": "${_('No matching records')}",
+              "sInfo":"${_('Showing _START_ to _END_ of _TOTAL_ entries')}",
+              "sInfoEmpty":"${_('Showing 0 to 0 of 0 entries')}",
+              "oPaginate":{
+                "sFirst":"${_('First')}",
+                "sLast":"${_('Last')}",
+                "sNext":"${_('Next')}",
+                "sPrevious":"${_('Previous')}"
+              }
+            },
+            "fnDrawCallback":function (oSettings) {
+              $("a[data-row-selector='true']").jHueRowSelector();
             }
         });
-
-        $("a[data-row-selector='true']").jHueRowSelector();
     });
 </script>
 

+ 1 - 2
apps/jobbrowser/src/jobbrowser/views.py

@@ -358,7 +358,6 @@ def tasks(request, job):
   jt = get_api(request.user, request.jt)
 
   task_list = jt.get_tasks(job.jobId, **filters)
-  page = jt.paginate_task(task_list, pagenum)
 
   filter_params = copy_query_dict(request.GET, ('tasktype', 'taskstate', 'tasktext')).urlencode()
 
@@ -366,7 +365,7 @@ def tasks(request, job):
     'request': request,
     'filter_params': filter_params,
     'job': job,
-    'page': page,
+    'task_list': task_list,
     'tasktype': ttypes,
     'taskstate': tstates,
     'tasktext': ttext