فهرست منبع

HUE-1125 [pig] Reduce the amount of ajax calls to the dashboard service

Calls are now made just when there are running scripts
Enrico Berti 12 سال پیش
والد
کامیت
d74462f
2فایلهای تغییر یافته به همراه8 افزوده شده و 1 حذف شده
  1. 7 1
      apps/pig/src/pig/templates/app.mako
  2. 1 0
      apps/pig/static/js/pig.ko.js

+ 7 - 1
apps/pig/src/pig/templates/app.mako

@@ -373,6 +373,10 @@ ${ commonheader(_('Pig'), "pig", user, "100px") | n,unicode }
       showAlert("<b>${_('There was an error with your request!')}</b>", "error");
     });
 
+    $(document).on("refreshDashboard", function () {
+      refreshDashboard();
+    });
+
     $(document).on("showDashboard", function () {
       routie("dashboard");
     });
@@ -417,7 +421,9 @@ ${ commonheader(_('Pig'), "pig", user, "100px") | n,unicode }
     refreshDashboard();
 
     var dashboardRefreshInterval = window.setInterval(function () {
-      refreshDashboard();
+      if (viewModel.runningScripts().length > 0) {
+        refreshDashboard();
+      }
     }, 1000);
 
     function refreshDashboard() {

+ 1 - 0
apps/pig/static/js/pig.ko.js

@@ -274,6 +274,7 @@ var PigViewModel = function (scripts, props) {
           script.isRunning(true);
           script.watchUrl(data.watchUrl);
           $(document).trigger("startLogsRefresh");
+          $(document).trigger("refreshDashboard");
           $(document).trigger("showLogs");
           self.updateScripts();
         }, "json");