Forráskód Böngészése

HUE-7743 [frontend] Support initial URL search parameters in embedded mode

Johan Ahlen 7 éve
szülő
commit
1a50f51

+ 12 - 2
desktop/core/src/desktop/static/desktop/ext/js/page.js

@@ -154,6 +154,8 @@
    * @api public
    */
 
+  page.baseSearch = '';
+
   page.start = function(options) {
     options = options || {};
     if (running) return;
@@ -166,7 +168,11 @@
     }
     if (true === options.hashbang) hashbang = true;
     if (!dispatch) return;
-    var url = (hashbang && ~location.hash.indexOf('#!')) ? location.hash.substr(2) + location.search : location.pathname + location.search + location.hash;
+    var search = location.search.replace(page.baseSearch, '').replace('&&', '&').replace('?&', '?');
+    if (search === '?') {
+      search = '';
+    }
+    var url = (hashbang && ~location.hash.indexOf('#!')) ? location.hash.substr(2) + search : location.pathname + search + location.hash;
     page.replace(url, null, true, dispatch);
   };
 
@@ -330,7 +336,11 @@
     if (hashbang) {
       current = base + location.hash.replace('#!', '');
     } else {
-      current = location.pathname + location.search;
+      var search = location.search.replace(page.baseSearch, '').replace('&&', '&').replace('?&', '?');
+      if (search === '?') {
+        search = '';
+      }
+      current = location.pathname + search;
     }
 
     if (current === ctx.canonicalPath) return;

+ 4 - 3
desktop/core/src/desktop/templates/hue.mako

@@ -1069,11 +1069,12 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
         });
 
         % if IS_EMBEDDED.get():
-        page.base(window.location.pathname);
-        page({ hashbang: true });
+        page.base(window.location.pathname + window.location.search);
+        page.baseSearch = window.location.search.replace('?', '');
         if (!window.location.hash) {
-          window.location.hash = '#!'
+          window.location.hash = '#!/editor?type=impala'
         }
+        page({ hashbang: true });
         % else:
         page.base('/hue');
         % endif