You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2018/08/31 06:45:21 UTC

[GitHub] r39132 closed pull request #1875: [AIRFLOW-620] Add log refresh button to TI's log view page

r39132 closed pull request #1875: [AIRFLOW-620] Add log refresh button to TI's log view page
URL: https://github.com/apache/incubator-airflow/pull/1875
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/airflow/www/templates/airflow/log.html b/airflow/www/templates/airflow/log.html
new file mode 100644
index 0000000000..51cce6b98c
--- /dev/null
+++ b/airflow/www/templates/airflow/log.html
@@ -0,0 +1,76 @@
+{#
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+#}
+{% extends "airflow/task_instance.html" %}
+{% block title %}Airflow - DAGs{% endblock %}
+
+{% block body %}
+{{ super() }}
+
+<div id="error" style="display: none; margin-top: 10px;" class="alert alert-danger" role="alert">
+    <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
+    <span id="error_msg">Oops.</span>
+</div>
+<button class="btn btn-default pull-right refresh_button" style="display: inline-flex;">
+    <span class="glyphicon glyphicon-refresh" aria-hidden="true" title="Refresh Logs"></span>
+</button>
+<h4>Log</h4>
+
+{% if log %}
+<pre id="log_block">{{ log }}</pre>
+<img id="loading" alt="spinner" src="{{ url_for('static', filename='loading.gif') }}"
+     style="margin: auto; display: none;">
+<button class="btn btn-default pull-right refresh_button" style="margin-bottom: 10px;">
+    <span class="glyphicon glyphicon-refresh" aria-hidden="true" title="Refresh Logs"></span>
+</button>
+{% endif %}
+{% endblock %}
+
+{% block tail %}
+{{ super() }}
+<script>
+    function error(msg) {
+        $('#error_msg').html(msg);
+        $('#error').show();
+        reset();
+    }
+
+    function reset() {
+        $('#loading').css('display', 'none');
+        $('pre#log_block').show();
+        $(".refresh_button").removeClass('disabled');
+    }
+
+    $(".refresh_button").on("click", function() {
+        $("#loading").css('display', 'block');
+        $("pre#log_block").hide();
+        $('#error').hide();
+        $(".refresh_button").addClass('disabled');
+        $.get(decodeURIComponent(window.location.href)
+        ).done(
+            function(data) {
+                $("pre#log_block").html(data);
+                reset();
+                window.scrollTo(0, document.body.scrollHeight);
+            }
+        ).fail(function(jqxhr, textStatus, err) {
+            error(textStatus + ': ' + err);
+        });
+    });
+
+</script>
+{% endblock %}
diff --git a/airflow/www/views.py b/airflow/www/views.py
index de33843945..b85f7841b1 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -791,9 +791,14 @@ def log(self):
         if PY2 and not isinstance(log, unicode):
             log = log.decode('utf-8')
 
+        if request.is_xhr:
+            return log
+
+        title = "Log"
+
         return self.render(
-            'airflow/ti_code.html',
-            code=log, dag=dag, title="Log", task_id=task_id,
+            'airflow/log.html',
+            log=log, dag=dag, title=title, task_id=task_id,
             execution_date=execution_date, form=form)
 
     @expose('/task')


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services