HDFS-7987. Allow files / directories to be moved (Ravi Prakash via aw)
This commit is contained in:
parent
0b7b8a3776
commit
d44f4745b4
@ -179,6 +179,13 @@ <h4 class="modal-title" id="delete-modal-title">Delete</h4>
|
||||
data-target="#modal-upload-file" title="Upload Files">
|
||||
<span class="glyphicon glyphicon-cloud-upload"></span>
|
||||
</button>
|
||||
<button class="btn btn-default dropdown-toggle" type="button"
|
||||
data-toggle="dropdown" title="Cut & Paste">
|
||||
<span class="glyphicon glyphicon-list-alt"></span></button>
|
||||
<ul class="dropdown-menu cut-paste">
|
||||
<li><a id="explorer-cut">Cut</a></li>
|
||||
<li><a id="explorer-paste">Paste</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -236,6 +243,7 @@ <h4 class="modal-title" id="delete-modal-title">Delete</h4>
|
||||
<table class="table" id="table-explorer">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><input type="checkbox" id="file-selector-all"></th>
|
||||
<th title="Permissions">Permission</th>
|
||||
<th>Owner</th>
|
||||
<th>Group</th>
|
||||
@ -251,6 +259,7 @@ <h4 class="modal-title" id="delete-modal-title">Delete</h4>
|
||||
{#FileStatus}
|
||||
<tr inode-path="{pathSuffix}" data-permission="{permission}"
|
||||
class="explorer-entry">
|
||||
<td><input type="checkbox" class="file_selector"> </td>
|
||||
<td><span class="explorer-perm-links editable-click">
|
||||
{type|helper_to_directory}{permission|helper_to_permission}
|
||||
{aclBit|helper_to_acl_bit}
|
||||
|
@ -310,22 +310,28 @@
|
||||
var absolute_file_path = append_path(current_directory, inode_name);
|
||||
delete_path(inode_name, absolute_file_path);
|
||||
});
|
||||
|
||||
$('#table-explorer').dataTable( {
|
||||
'lengthMenu': [ [25, 50, 100, -1], [25, 50, 100, "All"] ],
|
||||
'columns': [
|
||||
{'searchable': false }, //Permissions
|
||||
null, //Owner
|
||||
null, //Group
|
||||
{ 'searchable': false, 'render': func_size_render}, //Size
|
||||
{ 'searchable': false, 'render': func_time_render}, //Last Modified
|
||||
{ 'searchable': false }, //Replication
|
||||
null, //Block Size
|
||||
null, //Name
|
||||
{ 'sortable' : false } //Trash
|
||||
],
|
||||
"deferRender": true
|
||||
});
|
||||
|
||||
$('#file-selector-all').click(function() {
|
||||
$('.file_selector').prop('checked', $('#file-selector-all')[0].checked );
|
||||
});
|
||||
|
||||
//This needs to be last because it repaints the table
|
||||
$('#table-explorer').dataTable( {
|
||||
'lengthMenu': [ [25, 50, 100, -1], [25, 50, 100, "All"] ],
|
||||
'columns': [
|
||||
{ 'orderable' : false }, //select
|
||||
{'searchable': false }, //Permissions
|
||||
null, //Owner
|
||||
null, //Group
|
||||
{ 'searchable': false, 'render': func_size_render}, //Size
|
||||
{ 'searchable': false, 'render': func_time_render}, //Last Modified
|
||||
{ 'searchable': false }, //Replication
|
||||
null, //Block Size
|
||||
null, //Name
|
||||
{ 'orderable' : false } //Trash
|
||||
],
|
||||
"deferRender": true
|
||||
});
|
||||
});
|
||||
}).error(network_error_handler(url));
|
||||
}
|
||||
@ -417,5 +423,50 @@
|
||||
}
|
||||
});
|
||||
|
||||
//Store the list of files which have been checked into session storage
|
||||
function store_selected_files(current_directory) {
|
||||
sessionStorage.setItem("source_directory", current_directory);
|
||||
var selected_files = $("input:checked.file_selector");
|
||||
var selected_file_names = new Array();
|
||||
selected_files.each(function(index) {
|
||||
selected_file_names[index] = $(this).closest('tr').attr('inode-path');
|
||||
})
|
||||
sessionStorage.setItem("selected_file_names", JSON.stringify(selected_file_names));
|
||||
alert("Cut " + selected_file_names.length + " files/directories");
|
||||
}
|
||||
|
||||
//Retrieve the list of files from session storage and rename them to the current
|
||||
//directory
|
||||
function paste_selected_files() {
|
||||
var files = JSON.parse(sessionStorage.getItem("selected_file_names"));
|
||||
var source_directory = sessionStorage.getItem("source_directory");
|
||||
$.each(files, function(index, value) {
|
||||
var url = "/webhdfs/v1"
|
||||
+ encode_path(append_path(source_directory, value))
|
||||
+ '?op=RENAME&destination='
|
||||
+ encode_path(append_path(current_directory, value));
|
||||
$.ajax({
|
||||
type: 'PUT',
|
||||
url: url
|
||||
}).done(function(data) {
|
||||
if(index == files.length - 1) {
|
||||
browse_directory(current_directory);
|
||||
}
|
||||
}).error(function(jqXHR, textStatus, errorThrown) {
|
||||
show_err_msg("Couldn't move file " + value + ". " + errorThrown);
|
||||
});
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
$('#explorer-cut').click(function() {
|
||||
store_selected_files(current_directory);
|
||||
});
|
||||
|
||||
$('#explorer-paste').click(function() {
|
||||
paste_selected_files();
|
||||
});
|
||||
|
||||
|
||||
init();
|
||||
})();
|
||||
|
@ -285,4 +285,11 @@ header.bs-docs-nav, header.bs-docs-nav .navbar-brand {
|
||||
margin-bottom: 0;
|
||||
font-weight: normal;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cut-paste {
|
||||
width: 75px;
|
||||
min-width: 75px;
|
||||
float: right;
|
||||
left: 75px;
|
||||
}
|
Loading…
Reference in New Issue
Block a user