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 2019/09/04 22:02:42 UTC

[GitHub] [airflow] LucasMMota commented on a change in pull request #5997: [AIRFLOW-5396] - Add button Auto Refresh

LucasMMota commented on a change in pull request #5997: [AIRFLOW-5396] - Add button Auto Refresh
URL: https://github.com/apache/airflow/pull/5997#discussion_r320995048
 
 

 ##########
 File path: airflow/www/templates/airflow/dag.html
 ##########
 @@ -573,5 +581,59 @@ <h4 class="modal-title" id="dagModalLabel">
       $.post(url);
     });
 
+    // AutoRefresh
+    AUTO_REFRESH_COOKIE_NAME = 'airflow_auto_refresh_enabled'
+
+    setCookie = (cname, cvalue, exdays) => {
+    var d = new Date();
+      d.setTime(d.getTime() + (exdays*24*60*60*1000));
+      var expires = "expires="+ d.toUTCString();
+      document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
+    }
+
+    getCookie = (cname)=> {
+      var name = cname + "=";
+      var decodedCookie = decodeURIComponent(document.cookie);
+      var ca = decodedCookie.split(';');
+      for(var i = 0; i <ca.length; i++) {
+        var c = ca[i];
+        while (c.charAt(0) == ' ') {
+          c = c.substring(1);
+        }
+        if (c.indexOf(name) == 0) {
+          return c.substring(name.length, c.length);
+        }
+      }
+      return "";
+    }
+
+    rmCookie = (cname)=>{
+      setCookie(cname, '', 0)
+    }
+
+    isAutoRefreshEnabled = ()=>{
+        return getCookie(AUTO_REFRESH_COOKIE_NAME)==1
+    }
+
+    toggleAutoRefresh = ()=>{
+      if(isAutoRefreshEnabled()){
+        $('#label-auto-refresh').html('Auto Refresh')
+        rmCookie(AUTO_REFRESH_COOKIE_NAME)
+      }else{
+        setCookie(AUTO_REFRESH_COOKIE_NAME, 1)
+      }
+    }
+
+    setInterval(()=>{
+        if (isAutoRefreshEnabled())
+            location.reload()
 
 Review comment:
   @feluelle Yes, it could be done too. I see the refresh button uses this approach (reload the page), then I followed this idea. Actually, looking to the code I couldn't see how (or if it's possible) to only reload the view that renders the nodes. If you know a way to do that, we could try.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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