HDFS-5934. New Namenode UI back button doesn't work as expected. Contributed by Travis Thompson

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1568165 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brandon Li 2014-02-13 23:47:11 +00:00
parent 9d89fb8ca1
commit 2ccc1daacf
3 changed files with 47 additions and 11 deletions

View File

@ -442,6 +442,9 @@ Release 2.4.0 - UNRELEASED
HDFS-5913. Nfs3Utils#getWccAttr() should check attr parameter against null HDFS-5913. Nfs3Utils#getWccAttr() should check attr parameter against null
(brandonli) (brandonli)
HDFS-5934. New Namenode UI back button doesn't work as expected
(Travis Thompson via brandonli)
Release 2.3.1 - UNRELEASED Release 2.3.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -166,14 +166,29 @@
$('#ui-tabs a[href="#tab-snapshot"]').click(load_snapshot_info); $('#ui-tabs a[href="#tab-snapshot"]').click(load_snapshot_info);
function load_page() {
var hash = window.location.hash; var hash = window.location.hash;
if (hash === "#tab-datanode") { switch(hash) {
case "#tab-datanode":
load_datanode_info(); load_datanode_info();
} else if (hash === "#tab-snapshot") { break;
case "#tab-snapshot":
load_snapshot_info(); load_snapshot_info();
} else if (hash === "#tab-startup-progress") { break;
case "#tab-startup-progress":
load_startup_progress(); load_startup_progress();
} else { break;
case "#tab-overview":
load_overview(); load_overview();
break;
default:
window.location.hash = "tab-overview";
break;
} }
}
load_page();
$(window).bind('hashchange', function () {
load_page();
});
})(); })();

View File

@ -52,6 +52,18 @@
$('#alert-panel').show(); $('#alert-panel').show();
} }
$(window).bind('hashchange', function () {
$('#alert-panel').hide();
var dir = window.location.hash.slice(1);
if(dir == "") {
dir = "/";
}
if(current_directory != dir) {
browse_directory(dir);
}
});
function network_error_handler(url) { function network_error_handler(url) {
return function (jqxhr, text, err) { return function (jqxhr, text, err) {
var msg = '<p>Failed to retreive data from ' + url + ', cause: ' + err + '</p>'; var msg = '<p>Failed to retreive data from ' + url + ', cause: ' + err + '</p>';
@ -145,6 +157,7 @@
current_directory = dir; current_directory = dir;
$('#directory').val(dir); $('#directory').val(dir);
window.location.hash = dir;
dust.render('explorer', base.push(d), function(err, out) { dust.render('explorer', base.push(d), function(err, out) {
$('#panel').html(out); $('#panel').html(out);
@ -169,7 +182,12 @@
var b = function() { browse_directory($('#directory').val()); }; var b = function() { browse_directory($('#directory').val()); };
$('#btn-nav-directory').click(b); $('#btn-nav-directory').click(b);
browse_directory('/'); var dir = window.location.hash.slice(1);
if(dir == "") {
window.location.hash = "/";
} else {
browse_directory(dir);
}
} }
init(); init();