Repository: ambari Updated Branches: refs/heads/trunk 6b382fc70 -> 12fd6d8cd
AMBARI-11725. Tez UI: Bookmarking capabilities are broken. (Sreenath Somarajapuram via yusaku) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/12fd6d8c Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/12fd6d8c Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/12fd6d8c Branch: refs/heads/trunk Commit: 12fd6d8cdcc2235d3ff581928afcc26ed7941411 Parents: 6b382fc Author: Yusaku Sako <yus...@hortonworks.com> Authored: Fri Jun 5 12:12:31 2015 -0700 Committer: Yusaku Sako <yus...@hortonworks.com> Committed: Fri Jun 5 12:12:31 2015 -0700 ---------------------------------------------------------------------- .../resources/ui/scripts/init-ambari-view.js | 33 +++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/12fd6d8c/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js ---------------------------------------------------------------------- diff --git a/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js b/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js index 12e0da6..615c727 100644 --- a/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js +++ b/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js @@ -72,6 +72,11 @@ function getQueryString(object) { function redirectionCheck() { var href = window.location.href; + // Ember expects the url to have /#/ + if(href.indexOf('?') != -1 && href.indexOf('/#/') == -1) { + href = href.replace('?', '/#/?'); + } + // If opened outside ambari, redirect if(window.parent == window) { var hrefParts = href.split('/#/'), @@ -82,11 +87,17 @@ function redirectionCheck() { queryParams[PATH_PARAM_NAME] = '/#/' + pathParts[0]; } - window.location = '%@?%@'.fmt( + href = '%@?%@'.fmt( hrefParts[0].replace('/views/', '/#/main/views/'), getQueryString(queryParams) ); + } + // Normalize href + href = href.replace(/\/\//g, '/').replace(':/', '://'); + + if(href != window.location.href) { + window.location = href; return true; } } @@ -213,18 +224,15 @@ function loadParams() { } function onPathChange() { - var path = window.location.hash.substr(2).trim(), pathParts = path.split('?'), parentUrlParts = window.parent.location.href.split('?'), - parentQueryParam = getQueryObject(parentUrlParts[1]); + parentQueryParam = getQueryObject(pathParts[1]); - $.extend(parentQueryParam, getQueryObject(pathParts[1])); - delete parentQueryParam[PATH_PARAM_NAME]; - if(pathParts[0]) { - parentQueryParam[PATH_PARAM_NAME] = '/#/' + pathParts[0]; - } + if(pathParts[0]) { + parentQueryParam[PATH_PARAM_NAME] = '/#/' + pathParts[0]; + } path = getQueryString(parentQueryParam); window.parent.history.replaceState( @@ -234,12 +242,15 @@ function onPathChange() { ); } +function scheduleChangeHandler(arguments) { + setTimeout(onPathChange, 100); +} + if(!redirectionCheck()) { App.ApplicationRoute.reopen({ actions: { - didTransition: function (arguments) { - setTimeout(onPathChange, 100); - } + didTransition: scheduleChangeHandler, + queryParamsDidChange: scheduleChangeHandler } });