Просмотр исходного кода

HUE-1000 [oozie] Ajax refresh of the running workflows and coordinators in the dashboard

Fixed data-row-selector problem
Enrico Berti 13 лет назад
Родитель
Сommit
791539f486

+ 43 - 39
apps/oozie/src/oozie/templates/dashboard/list_oozie_coordinators.mako

@@ -129,9 +129,9 @@ ${layout.menubar(section='dashboard')}
   }
 
   $(document).ready(function () {
-    var runningTable = $('#running-table').dataTable({
-      'sPaginationType':'bootstrap',
-      'iDisplayLength':50,
+    var runningTable = $("#running-table").dataTable({
+      "sPaginationType":"bootstrap",
+      "iDisplayLength":50,
       "bLengthChange":false,
       "sDom":"<'row'r>t<'row'<'span6'i><''p>>",
       "aoColumns":[
@@ -158,12 +158,15 @@ ${layout.menubar(section='dashboard')}
           "sNext":"${_('Next')}",
           "sPrevious":"${_('Previous')}"
         }
+      },
+      "fnDrawCallback":function (oSettings) {
+        $("a[data-row-selector='true']").jHueRowSelector();
       }
     });
 
-    var completedTable = $('#completed-table').dataTable({
-      'sPaginationType':'bootstrap',
-      'iDisplayLength':50,
+    var completedTable = $("#completed-table").dataTable({
+      "sPaginationType":"bootstrap",
+      "iDisplayLength":50,
       "bLengthChange":false,
       "sDom":"<'row'r>t<'row'<'span6'i><''p>>",
       "aoColumns":[
@@ -189,10 +192,13 @@ ${layout.menubar(section='dashboard')}
           "sNext":"${_('Next')}",
           "sPrevious":"${_('Previous')}"
         }
+      },
+      "fnDrawCallback":function (oSettings) {
+        $("a[data-row-selector='true']").jHueRowSelector();
       }
     });
 
-    $('#filterInput').keydown(function (e) {
+    $("#filterInput").keydown(function (e) {
       if (e.which == 13) {
         e.preventDefault();
         return false;
@@ -212,13 +218,13 @@ ${layout.menubar(section='dashboard')}
 
 
     $("a.btn-status").click(function () {
-      $(this).toggleClass('active');
+      $(this).toggleClass("active");
       drawTable();
     });
 
     $("a.btn-date").click(function () {
-      $("a.btn-date").not(this).removeClass('active');
-      $(this).toggleClass('active');
+      $("a.btn-date").not(this).removeClass("active");
+      $(this).toggleClass("active");
       drawTable();
     });
 
@@ -234,41 +240,39 @@ ${layout.menubar(section='dashboard')}
     }
 
     $.fn.dataTableExt.afnFiltering.push(
-            function (oSettings, aData, iDataIndex) {
-              var urlHashes = ""
-
-              var statusBtn = $('a.btn-status.active');
-              var statusFilter = true;
-              if (statusBtn.length > 0) {
-                var statuses = []
-                $.each(statusBtn, function () {
-                  statuses.push($(this).attr('data-value'));
-                });
-                statusFilter = aData[1].match(RegExp(statuses.join('|'), "i")) != null;
-              }
+      function (oSettings, aData, iDataIndex) {
+        var urlHashes = ""
+
+        var statusBtn = $("a.btn-status.active");
+        var statusFilter = true;
+        if (statusBtn.length > 0) {
+          var statuses = []
+          $.each(statusBtn, function () {
+            statuses.push($(this).attr("data-value"));
+          });
+          statusFilter = aData[1].match(RegExp(statuses.join('|'), "i")) != null;
+        }
 
-              var dateBtn = $('a.btn-date.active');
-              var dateFilter = true;
-              if (dateBtn.length > 0) {
-                var minAge = new Date() - parseInt(dateBtn.attr('data-value')) * 1000 * 60 * 60 * 24;
-                dateFilter = Date.parse(aData[0]) >= minAge;
-              }
+        var dateBtn = $("a.btn-date.active");
+        var dateFilter = true;
+        if (dateBtn.length > 0) {
+          var minAge = new Date() - parseInt(dateBtn.attr("data-value")) * 1000 * 60 * 60 * 24;
+          dateFilter = Date.parse(aData[0]) >= minAge;
+        }
 
-              return statusFilter && dateFilter;
-            }
+        return statusFilter && dateFilter;
+      }
     );
 
-    $("a[data-row-selector='true']").jHueRowSelector();
-
     $(document).on("click", ".confirmationModal", function () {
       var _this = $(this);
-      _this.bind('confirmation', function () {
+      _this.bind("confirmation", function () {
         var _this = this;
         $.post($(this).attr("data-url"),
-                { 'notification':$(this).attr("data-message") },
+                { "notification":$(this).attr("data-message") },
                 function (response) {
-                  if (response['status'] != 0) {
-                    $.jHueNotify.error("${ _('Problem: ') }" + response['data']);
+                  if (response["status"] != 0) {
+                    $.jHueNotify.error("${ _('Problem: ') }" + response["data"]);
                   } else {
                     window.location.reload();
                   }
@@ -279,7 +283,7 @@ ${layout.menubar(section='dashboard')}
       $("#confirmation .message").text(_this.attr("data-confirmation-message"));
       $("#confirmation").modal("show");
       $("#confirmation a.btn-danger").click(function () {
-        _this.trigger('confirmation');
+        _this.trigger("confirmation");
       });
     });
 
@@ -329,7 +333,7 @@ ${layout.menubar(section='dashboard')}
               }
               if (['RUNNING', 'PREP', 'WAITING', 'SUSPENDED', 'PREPSUSPENDED', 'PREPPAUSED', 'PAUSED'].indexOf(coord.status) > -1) {
                 runningTable.fnAddData([coord.endTime, '<span class="' + coord.statusClass + '">' + coord.status + '</span>', coord.appName,
-                  '<div class="progress"><div class="' + coord.progressClass + '" style="width:' + coord.progress + '%">' + coord.progress + '%</div></div>', coord.user, '<a href="' + coord.absoluteUrl + '">' + coord.id + '</a>',
+                  '<div class="progress"><div class="' + coord.progressClass + '" style="width:' + coord.progress + '%">' + coord.progress + '%</div></div>', coord.user, '<a href="' + coord.absoluteUrl + '" data-row-selector="true">' + coord.id + '</a>',
                   killCell]);
               }
 
@@ -359,7 +363,7 @@ ${layout.menubar(section='dashboard')}
         $(data).each(function (iWf, item) {
           var coord = new Coordinator(item);
           completedTable.fnAddData([coord.endTime, '<span class="' + coord.statusClass + '">' + coord.status + '</span>', coord.appName,
-            coord.duration, coord.user, '<a href="' + coord.absoluteUrl + '">' + coord.id + '</a>'], false);
+            coord.duration, coord.user, '<a href="' + coord.absoluteUrl + '" data-row-selector="true">' + coord.id + '</a>'], false);
         });
         completedTable.fnDraw();
       });

+ 43 - 39
apps/oozie/src/oozie/templates/dashboard/list_oozie_workflows.mako

@@ -132,9 +132,9 @@ ${ layout.menubar(section='dashboard') }
   }
 
   $(document).ready(function () {
-    var runningTable = $('#running-table').dataTable({
-      'sPaginationType':'bootstrap',
-      'iDisplayLength':50,
+    var runningTable = $("#running-table").dataTable({
+      "sPaginationType":"bootstrap",
+      "iDisplayLength":50,
       "bLengthChange":false,
       "sDom":"<'row'r>t<'row'<'span6'i><''p>>",
       "aoColumns":[
@@ -161,12 +161,15 @@ ${ layout.menubar(section='dashboard') }
           "sNext":"${_('Next')}",
           "sPrevious":"${_('Previous')}"
         }
+      },
+      "fnDrawCallback":function (oSettings) {
+        $("a[data-row-selector='true']").jHueRowSelector();
       }
     });
 
-    var completedTable = $('#completed-table').dataTable({
-      'sPaginationType':'bootstrap',
-      'iDisplayLength':50,
+    var completedTable = $("#completed-table").dataTable({
+      "sPaginationType":"bootstrap",
+      "iDisplayLength":50,
       "bLengthChange":false,
       "sDom":"<'row'r>t<'row'<'span6'i><''p>>",
       "aoColumns":[
@@ -192,10 +195,13 @@ ${ layout.menubar(section='dashboard') }
           "sNext":"${_('Next')}",
           "sPrevious":"${_('Previous')}"
         }
+      },
+      "fnDrawCallback":function (oSettings) {
+        $("a[data-row-selector='true']").jHueRowSelector();
       }
     });
 
-    $('#filterInput').keydown(function (e) {
+    $("#filterInput").keydown(function (e) {
       if (e.which == 13) {
         e.preventDefault();
         return false;
@@ -210,13 +216,13 @@ ${ layout.menubar(section='dashboard') }
 
 
     $("a.btn-status").click(function () {
-      $(this).toggleClass('active');
+      $(this).toggleClass("active");
       drawTable();
     });
 
     $("a.btn-date").click(function () {
-      $("a.btn-date").not(this).removeClass('active');
-      $(this).toggleClass('active');
+      $("a.btn-date").not(this).removeClass("active");
+      $(this).toggleClass("active");
       drawTable();
     });
 
@@ -232,41 +238,39 @@ ${ layout.menubar(section='dashboard') }
     }
 
     $.fn.dataTableExt.afnFiltering.push(
-            function (oSettings, aData, iDataIndex) {
-              var urlHashes = ""
-
-              var statusBtn = $('a.btn-status.active');
-              var statusFilter = true;
-              if (statusBtn.length > 0) {
-                var statuses = []
-                $.each(statusBtn, function () {
-                  statuses.push($(this).attr('data-value'));
-                });
-                statusFilter = aData[1].match(RegExp(statuses.join('|'), "i")) != null;
-              }
+      function (oSettings, aData, iDataIndex) {
+        var urlHashes = ""
+
+        var statusBtn = $("a.btn-status.active");
+        var statusFilter = true;
+        if (statusBtn.length > 0) {
+          var statuses = []
+          $.each(statusBtn, function () {
+            statuses.push($(this).attr("data-value"));
+          });
+          statusFilter = aData[1].match(RegExp(statuses.join('|'), "i")) != null;
+        }
 
-              var dateBtn = $('a.btn-date.active');
-              var dateFilter = true;
-              if (dateBtn.length > 0) {
-                var minAge = new Date() - parseInt(dateBtn.attr('data-value')) * 1000 * 60 * 60 * 24;
-                dateFilter = Date.parse(aData[0]) >= minAge;
-              }
+        var dateBtn = $("a.btn-date.active");
+        var dateFilter = true;
+        if (dateBtn.length > 0) {
+          var minAge = new Date() - parseInt(dateBtn.attr("data-value")) * 1000 * 60 * 60 * 24;
+          dateFilter = Date.parse(aData[0]) >= minAge;
+        }
 
-              return statusFilter && dateFilter;
-            }
+        return statusFilter && dateFilter;
+      }
     );
 
-    $("a[data-row-selector='true']").jHueRowSelector();
-
     $(document).on("click", ".confirmationModal", function () {
       var _this = $(this);
-      _this.bind('confirmation', function () {
+      _this.bind("confirmation", function () {
         var _this = this;
         $.post($(this).attr("data-url"),
-                { 'notification':$(this).attr("data-message") },
+                { "notification":$(this).attr("data-message") },
                 function (response) {
-                  if (response['status'] != 0) {
-                    $.jHueNotify.error("${ _('Problem: ') }" + response['data']);
+                  if (response["status"] != 0) {
+                    $.jHueNotify.error("${ _('Problem: ') }" + response["data"]);
                   } else {
                     window.location.reload();
                   }
@@ -277,7 +281,7 @@ ${ layout.menubar(section='dashboard') }
       $("#confirmation .message").text(_this.attr("data-confirmation-message"));
       $("#confirmation").modal("show");
       $("#confirmation a.btn-danger").click(function () {
-        _this.trigger('confirmation');
+        _this.trigger("confirmation");
       });
     });
 
@@ -327,7 +331,7 @@ ${ layout.menubar(section='dashboard') }
               }
               if (['RUNNING', 'PREP', 'WAITING', 'SUSPENDED', 'PREPSUSPENDED', 'PREPPAUSED', 'PAUSED'].indexOf(wf.status) > -1) {
                 runningTable.fnAddData([wf.lastModTime, '<span class="' + wf.statusClass + '">' + wf.status + '</span>', wf.appName,
-                  '<div class="progress"><div class="' + wf.progressClass + '" style="width:' + wf.progress + '%">' + wf.progress + '%</div></div>', wf.user, '<a href="' + wf.absoluteUrl + '">' + wf.id + '</a>',
+                  '<div class="progress"><div class="' + wf.progressClass + '" style="width:' + wf.progress + '%">' + wf.progress + '%</div></div>', wf.user, '<a href="' + wf.absoluteUrl + '" data-row-selector="true">' + wf.id + '</a>',
                   killCell]);
               }
             }
@@ -356,7 +360,7 @@ ${ layout.menubar(section='dashboard') }
         $(data).each(function (iWf, item) {
           var wf = new Workflow(item);
           completedTable.fnAddData([wf.endTime, '<span class="' + wf.statusClass + '">' + wf.status + '</span>', decodeURIComponent(wf.appName),
-            wf.duration, wf.user, '<a href="' + wf.absoluteUrl + '">' + wf.id + '</a>'], false);
+            wf.duration, wf.user, '<a href="' + wf.absoluteUrl + '" data-row-selector="true">' + wf.id + '</a>'], false);
         });
         completedTable.fnDraw();
       });