Browse Source

[oozie] Durability and progress sorting for workflows and coordinators

abec 13 years ago
parent
commit
84d3201f99

+ 19 - 19
apps/oozie/src/oozie/templates/dashboard/list_oozie_coordinators.mako

@@ -76,7 +76,7 @@ ${layout.menubar(section='dashboard')}
               </span>
             </td>
             <td>${ job.appName }</td>
-            <td>${ job.get_progress() }%</td>
+            <td data-sort-value="${ job.get_progress() }">${ job.get_progress() }%</td>
             <td>${ job.user }</td>
             <td><a href="${ job.get_absolute_url() }" data-row-selector="true"></a>${ job.id }</td>
             <td>
@@ -127,7 +127,7 @@ ${layout.menubar(section='dashboard')}
               </span>
             </td>
             <td>${ job.appName }</td>
-            <td>-</td>
+            <td data-sort-value="${ utils.job_duration(job) }">${ utils.format_job_duration(job) }</td>
             <td>${job.user}</td>
             <td><a href="${ job.get_absolute_url() }" data-row-selector="true"></a>${ job.id }</td>
           </tr>
@@ -160,15 +160,15 @@ ${layout.menubar(section='dashboard')}
       "bLengthChange": false,
       "sDom": "<'row'r>t<'row'<'span6'i><''p>>",
       "aoColumns": [
-           { "sType": "date" },
-            null,
-            null,
-            null,
-            null,
-            null,
-            { "bSortable": false }
-        ],
-        "aaSorting": [[ 0, "desc" ]]
+        { "sType": "date" },
+        null,
+        null,
+        { "sSortDataType": "dom-sort-value", "sType": "alt-numeric" },
+        null,
+        null,
+        { "bSortable": false }
+      ],
+      "aaSorting": [[ 0, "desc" ]]
     });
 
     var completedTable = $('#completed-table').dataTable( {
@@ -177,14 +177,14 @@ ${layout.menubar(section='dashboard')}
       "bLengthChange": false,
       "sDom": "<'row'r>t<'row'<'span6'i><''p>>",
       "aoColumns": [
-            { "sType": "date" },
-            null,
-            null,
-            null,
-            null,
-            null
-        ],
-        "aaSorting": [[ 0, "desc" ]]
+        { "sType": "date" },
+        null,
+        null,
+        { "sSortDataType": "dom-sort-value", "sType": "alt-numeric" },
+        null,
+        null
+      ],
+      "aaSorting": [[ 0, "desc" ]]
     });
 
     $('#filterInput').keydown(function(e) {

+ 5 - 4
apps/oozie/src/oozie/templates/dashboard/list_oozie_workflows.mako

@@ -22,6 +22,7 @@
 <%namespace name="layout" file="../navigation-bar.mako" />
 <%namespace name="utils" file="../utils.inc.mako" />
 
+
 ${ commonheader(_("Oozie App"), "oozie", "100px") }
 ${ layout.menubar(section='dashboard') }
 
@@ -76,7 +77,7 @@ ${ layout.menubar(section='dashboard') }
               </span>
             </td>
             <td>${ job.appName }</td>
-            <td>${ job.get_progress() }%</td>
+            <td data-sort-value="${ job.get_progress() }">${ job.get_progress() }%</td>
             <td>${ job.user }</td>
             <td><a href="${ job.get_absolute_url() }" data-row-selector="true"></a>${ job.id }</td>
             <td>
@@ -127,7 +128,7 @@ ${ layout.menubar(section='dashboard') }
               </span>
             </td>
             <td>${ job.appName }</td>
-            <td>-</td>
+            <td data-sort-value="${ utils.job_duration(job) }">${ utils.format_job_duration(job) }</td>
             <td>${ job.user }</td>
             <td><a href="${ job.get_absolute_url() }" data-row-selector="true"></a>${ job.id }</td>
           </tr>
@@ -163,7 +164,7 @@ ${ layout.menubar(section='dashboard') }
            { "sType": "date" },
             null,
             null,
-            null,
+            { "sSortDataType": "dom-sort-value", "sType": "alt-numeric" },
             null,
             null,
             { "bSortable": false }
@@ -180,7 +181,7 @@ ${ layout.menubar(section='dashboard') }
             { "sType": "date" },
             null,
             null,
-            null,
+            { "sSortDataType": "dom-sort-value", "sType": "alt-numeric" },
             null,
             null
         ],

+ 15 - 0
apps/oozie/src/oozie/templates/utils.inc.mako

@@ -27,6 +27,7 @@
   from django.template.defaultfilters import date, time as dtime
   from django.utils.translation import ugettext as _
 
+  from desktop.lib.view_util import format_duration_in_millis
   from hadoop.fs.hadoopfs import Hdfs
   from liboozie.utils import format_time
 %>
@@ -42,6 +43,20 @@
 </%def>
 
 
+<%def name="job_duration(job)">
+  <%
+    return time.mktime(job.endTime) - time.mktime(job.startTime)
+  %>
+</%def>
+
+
+<%def name="format_job_duration(job)">
+  <%
+    return format_duration_in_millis(job_duration(job))
+  %>
+</%def>
+
+
 <%def name="format_date(python_date)">
   <%
     try:

+ 18 - 10
desktop/core/static/js/Source/jHue/jquery.datatables.sorting.js

@@ -14,17 +14,25 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+$.fn.dataTableExt.afnSortData['dom-sort-value'] = function (oSettings, iColumn) {
+  var aData = [];
+  $( 'td:eq('+iColumn+')', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
+    aData.push( parseFloat($(this).attr('data-sort-value')) );
+  } );
+  return aData;
+};
+
 jQuery.extend(jQuery.fn.dataTableExt.oSort, {
-    "alt-numeric-pre": function (a) {
-        var x = a.match(/title="*(-?[0-9\.]+)/)[1];
-        return parseFloat(x);
-    },
+  "alt-numeric-pre": function (a) {
+    var x = a.match(/title="*(-?[0-9\.]+)/)[1];
+    return parseFloat(x);
+  },
 
-    "alt-numeric-asc":function (a, b) {
-        return ((a < b) ? -1 : ((a > b) ? 1 : 0));
-    },
+  "alt-numeric-asc":function (a, b) {
+    return ((a < b) ? -1 : ((a > b) ? 1 : 0));
+  },
 
-    "alt-numeric-desc":function (a, b) {
-        return ((a < b) ? 1 : ((a > b) ? -1 : 0));
-    }
+  "alt-numeric-desc":function (a, b) {
+    return ((a < b) ? 1 : ((a > b) ? -1 : 0));
+  }
 });