Kaynağa Gözat

HUE-3822 [pig] Display logs when found

If there are any logs in the response from the watch endpoint it will display them, if not it won't touch any existing logs.
Johan Ahlen 10 yıl önce
ebeveyn
işleme
f75c05e

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

@@ -353,6 +353,7 @@ var PigViewModel = function (props) {
   };
   };
 
 
   self.runScript = function () {
   self.runScript = function () {
+    $("#withLogs").empty();
     callRun(self.currentScript());
     callRun(self.currentScript());
   };
   };
 
 

+ 16 - 5
apps/pig/src/pig/templates/app.mako

@@ -1205,17 +1205,28 @@ ${ commonshare() | n,unicode }
     function refreshLogs() {
     function refreshLogs() {
       if (viewModel.currentScript().watchUrl() != "") {
       if (viewModel.currentScript().watchUrl() != "") {
         $.getJSON(viewModel.currentScript().watchUrl(), function (data) {
         $.getJSON(viewModel.currentScript().watchUrl(), function (data) {
-          if (data.logs.pig) {
+          var logs = data.logs.pig || '';
+          if (data.workflow && data.workflow.actions) {
+            data.workflow.actions.forEach(function (action) {
+              if (data.logs[action.name]) {
+                if (logs !== '') {
+                  logs += '\n';
+                }
+                logs += data.logs[action.name];
+              }
+            });
+          }
+          if (logs !== '') {
             if ($("#withLogs").is(":hidden")) {
             if ($("#withLogs").is(":hidden")) {
               $("#withoutLogs").addClass("hide");
               $("#withoutLogs").addClass("hide");
               $("#withLogs").removeClass("hide");
               $("#withLogs").removeClass("hide");
               resizeLogs();
               resizeLogs();
             }
             }
             var _logsEl = $("#withLogs");
             var _logsEl = $("#withLogs");
-            var newLines = data.logs.pig.split("\n").slice(_logsEl.html().split("<br>").length);
-            if (newLines.length > 0){
-              _logsEl.html(_logsEl.html() + newLines.join("<br>") + "<br>");
-              checkForErrors(newLines);
+            var lines = logs.split("\n");
+            if (lines.length > 0){
+              _logsEl.html(lines.join("<br>") + "<br>");
+              checkForErrors(lines);
             }
             }
             window.setTimeout(function () {
             window.setTimeout(function () {
               resizeLogs();
               resizeLogs();