HDFS-8678. Bring back the feature to view chunks of files in the HDFS file browser. Contributed by Ivo Udelsmann.
(cherry picked from commit 625df87c7b
)
This commit is contained in:
parent
376a2439db
commit
fdf5394b2a
|
@ -57,8 +57,17 @@
|
||||||
<h4 class="modal-title" id="file-info-title">File information</h4>
|
<h4 class="modal-title" id="file-info-title">File information</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body" id="file-info-body">
|
<div class="modal-body" id="file-info-body">
|
||||||
|
<div class=row>
|
||||||
|
<span class="col-xs-4">
|
||||||
<a id="file-info-download">Download</a>
|
<a id="file-info-download">Download</a>
|
||||||
<!--<a id="file-info-preview" style="cursor:pointer">Tail the file (last 32K)</a>-->
|
</span>
|
||||||
|
<span class="col-xs-4">
|
||||||
|
<a id="file-info-preview-head" style="cursor:pointer">Head the file (first 32K)</a>
|
||||||
|
</span>
|
||||||
|
<span class="col-xs-4">
|
||||||
|
<a id="file-info-preview-tail" style="cursor:pointer">Tail the file (last 32K)</a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
<div class="panel panel-success" id="file-info-blockinfo-panel">
|
<div class="panel panel-success" id="file-info-blockinfo-panel">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
|
|
|
@ -192,13 +192,40 @@
|
||||||
var download_url = '/webhdfs/v1' + abs_path + '?op=OPEN';
|
var download_url = '/webhdfs/v1' + abs_path + '?op=OPEN';
|
||||||
|
|
||||||
$('#file-info-download').attr('href', download_url);
|
$('#file-info-download').attr('href', download_url);
|
||||||
$('#file-info-preview').click(function() {
|
|
||||||
|
var processPreview = function(url) {
|
||||||
|
url += "&noredirect=true";
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: url,
|
||||||
|
processData: false,
|
||||||
|
crossDomain: true
|
||||||
|
}).done(function(data) {
|
||||||
|
url = data.Location;
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: url,
|
||||||
|
processData: false,
|
||||||
|
crossDomain: true
|
||||||
|
}).complete(function(data) {
|
||||||
|
$('#file-info-preview-body').val(data.responseText);
|
||||||
|
$('#file-info-tail').show();
|
||||||
|
}).error(function(jqXHR, textStatus, errorThrown) {
|
||||||
|
show_err_msg("Couldn't preview the file. " + errorThrown);
|
||||||
|
});
|
||||||
|
}).error(function(jqXHR, textStatus, errorThrown) {
|
||||||
|
show_err_msg("Couldn't find datanode to read file from. " + errorThrown);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#file-info-preview-tail').click(function() {
|
||||||
var offset = d.fileLength - TAIL_CHUNK_SIZE;
|
var offset = d.fileLength - TAIL_CHUNK_SIZE;
|
||||||
var url = offset > 0 ? download_url + '&offset=' + offset : download_url;
|
var url = offset > 0 ? download_url + '&offset=' + offset : download_url;
|
||||||
$.get(url, function(t) {
|
processPreview(url);
|
||||||
$('#file-info-preview-body').val(t);
|
});
|
||||||
$('#file-info-tail').show();
|
$('#file-info-preview-head').click(function() {
|
||||||
}, "text").error(network_error_handler(url));
|
var url = d.fileLength > TAIL_CHUNK_SIZE ? download_url + '&length=' + TAIL_CHUNK_SIZE : download_url;
|
||||||
|
processPreview(url);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (d.fileLength > 0) {
|
if (d.fileLength > 0) {
|
||||||
|
|
Loading…
Reference in New Issue