Explorar el Código

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 hace 13 años
padre
commit
d74462ff39
Se han modificado 2 ficheros con 8 adiciones y 1 borrados
  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");