Преглед изворни кода

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 пре 9 година
родитељ
комит
f75c05e
2 измењених фајлова са 17 додато и 5 уклоњено
  1. 1 0
      apps/pig/src/pig/static/pig/js/pig.ko.js
  2. 16 5
      apps/pig/src/pig/templates/app.mako

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

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

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

@@ -1205,17 +1205,28 @@ ${ commonshare() | n,unicode }
     function refreshLogs() {
       if (viewModel.currentScript().watchUrl() != "") {
         $.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")) {
               $("#withoutLogs").addClass("hide");
               $("#withLogs").removeClass("hide");
               resizeLogs();
             }
             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 () {
               resizeLogs();