Browse Source

[frontend] Fix Knox related issues with the ajax interceptors

Johan Åhlén 4 years ago
parent
commit
2072ae34bd

+ 20 - 24
desktop/core/src/desktop/templates/common_header_footer_components.mako

@@ -61,8 +61,27 @@ else:
   </script>
 </%def>
 
-<%def name="ajax_interceptors()">
+<%def name="header_pollers(user, is_s3_enabled, apps)">
   <script type="text/javascript">
+    Dropzone.autoDiscover = false;
+    moment.locale(window.navigator.userLanguage || window.navigator.language);
+    localeFormat = function (time) {
+      var mTime = time;
+      if (typeof ko !== 'undefined' && ko.isObservable(time)) {
+        mTime = time();
+      }
+      try {
+        mTime = new Date(mTime);
+        if (moment(mTime).isValid()) {
+          return moment.utc(mTime).local().format("L LT Z"); // [Local Date] [Local Time] [Timezone offset]
+        }
+      }
+      catch (e) {
+        return mTime;
+      }
+      return mTime;
+    };
+
     // Catches HTTP 502 errors
     function xhrOnreadystatechange() {
       if (this.readyState === 4 && this.status === 502) {
@@ -101,29 +120,6 @@ else:
       return xhrSend.apply(this, arguments);
     };
     XMLHttpRequest.prototype.isAugmented = true;
-  </script>
-</%def>
-
-<%def name="header_pollers(user, is_s3_enabled, apps)">
-  <script type="text/javascript">
-    Dropzone.autoDiscover = false;
-    moment.locale(window.navigator.userLanguage || window.navigator.language);
-    localeFormat = function (time) {
-      var mTime = time;
-      if (typeof ko !== 'undefined' && ko.isObservable(time)) {
-        mTime = time();
-      }
-      try {
-        mTime = new Date(mTime);
-        if (moment(mTime).isValid()) {
-          return moment.utc(mTime).local().format("L LT Z"); // [Local Date] [Local Time] [Timezone offset]
-        }
-      }
-      catch (e) {
-        return mTime;
-      }
-      return mTime;
-    };
 
     $.fn.dataTableExt.sErrMode = "throw";
 

+ 0 - 1
desktop/core/src/desktop/templates/hue.mako

@@ -77,7 +77,6 @@
   <link rel="stylesheet" href="${ static('desktop/ext/css/bootstrap-fileupload.css') }" >
 
   ${ commonHeaderFooterComponents.header_i18n_redirection() }
-  ${ commonHeaderFooterComponents.ajax_interceptors() }
   <%
     global_constants_url = '/desktop/globalJsConstants.js?v=' + hue_version()
   %>