Update file_manager
This commit is contained in:
parent
962f6ff8f7
commit
397710c882
@ -35,6 +35,6 @@ class ApplicationController < ActionController::Base
|
|||||||
|
|
||||||
def checkDir
|
def checkDir
|
||||||
@current_dir = params[:path]
|
@current_dir = params[:path]
|
||||||
render :json => {:file => files(@current_dir) , :current => @current_dir}
|
render :json => {:dir => @current_dir}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -83,4 +83,53 @@ module ApplicationHelper
|
|||||||
return files
|
return files
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def file_manager_table(dir = "/mnt", id = "datatable", class_option = "table table-striped table-bordered jambo_table")
|
||||||
|
html = String.new
|
||||||
|
html << "<table id='" + id + "' class='" + class_option + "'>"
|
||||||
|
|
||||||
|
html << "<thead>"
|
||||||
|
html << "<tr class='headings'>"
|
||||||
|
html << "<th>Name</th>"
|
||||||
|
html << "<th>auth</th>"
|
||||||
|
html << "<th>Size</th>"
|
||||||
|
html << "<th>Date</th>"
|
||||||
|
html << "</tr>"
|
||||||
|
html << "</thead>"
|
||||||
|
|
||||||
|
html << "<tbody id='" + id + "_body'>"
|
||||||
|
html << "<tr>"
|
||||||
|
html << "<td>"
|
||||||
|
html << "<a style='cursor: pointer' onclick='change_upper(" + "\"" + dir + "\"" + ")'><i class='fa fa-reply'></i></a>"
|
||||||
|
html << " " + dir
|
||||||
|
html << "<a class='pull-right' href='#popup_mkdir'><i class='fa fa-plus'></i><i class='fa fa-folder'></i></a>"
|
||||||
|
html << "</td>"
|
||||||
|
html << "<td></td>"
|
||||||
|
html << "<td></td>"
|
||||||
|
html << "<td></td>"
|
||||||
|
html << "</tr>"
|
||||||
|
|
||||||
|
files(dir).each do |file|
|
||||||
|
html << "<tr class='dir_delete'>"
|
||||||
|
if file["auth"][0]=='d'
|
||||||
|
html << "<td style='color:#0d8ade;'><i class='fa fa-folder-open-o'></i>"
|
||||||
|
html << "<a style='cursor: pointer' onclick='change_directory(" + "\"" + dir + "/" + file['name'] + "\"" + ")'> " + file['name'] + "</a>"
|
||||||
|
html << "</td>"
|
||||||
|
else
|
||||||
|
html << "<td><i class='fa fa-file-o'></i>"
|
||||||
|
html << "<a href='/file_download?file_name=" + (dir + '/' + file['name']).gsub("/", "+") + "'> " + file['name'] + "</a>"
|
||||||
|
html << "</td>"
|
||||||
|
end
|
||||||
|
html << "<td>" + file['auth'] + "</td>"
|
||||||
|
html << "<td>" + file['size'] + "</td>"
|
||||||
|
html << "<td>"
|
||||||
|
html << file["date"]
|
||||||
|
html << "<a class='pull-right' onclick='delete_file(" + "\"" + dir + "/" + file["name"] + "\"" + ")' href='#'><i class='fa fa-trash'></i></a>"
|
||||||
|
html << "</td>"
|
||||||
|
html << "</tr>"
|
||||||
|
end
|
||||||
|
|
||||||
|
html << "</tbody>"
|
||||||
|
html << "</table>"
|
||||||
|
return html
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -125,47 +125,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="x_content">
|
<div class="x_content">
|
||||||
<div class="col-md-12 col-sm-12 col-xs-12" id="table_div">
|
<div class="col-md-12 col-sm-12 col-xs-12" id="table_div">
|
||||||
<table id="datatable" class="table table-striped table-bordered jambo_table">
|
<%= raw file_manager_table %>
|
||||||
<thead>
|
|
||||||
<tr class="headings">
|
|
||||||
<th>Name</th>
|
|
||||||
<th>auth</th>
|
|
||||||
<th>Size</th>
|
|
||||||
<th>Date</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody id="datatable_body">
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<a style='cursor: pointer' onclick="change_upper('<%= @current_dir %>')"><i class="fa fa-reply"></i></a>
|
|
||||||
<%= @current_dir %>
|
|
||||||
<a class='pull-right' href="#popup_mkdir"><i class="fa fa-plus"></i><i class="fa fa-folder"></i></a>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<% (files @current_dir).each do |t| %>
|
|
||||||
<tr class="dir_delete">
|
|
||||||
<% if t["auth"][0]=='d'%>
|
|
||||||
<td style="color:#0d8ade;"><i class="fa fa-folder-open-o"></i>
|
|
||||||
<a style="cursor: pointer" onclick="change_directory('<%=@current_dir + "/" + t["name"]%>')"> <%=t["name"]%></a>
|
|
||||||
</td>
|
|
||||||
<% else %>
|
|
||||||
<td><i class="fa fa-file-o"></i>
|
|
||||||
<a href="/file_download?file_name=<%=(@current_dir+'/'+t['name']).gsub("/", "+")%>"><%=t['name']%></a>
|
|
||||||
</td>
|
|
||||||
<% end %>
|
|
||||||
<td><%=t["auth"]%></td>
|
|
||||||
<td><%=t["size"]%></td>
|
|
||||||
<td>
|
|
||||||
<%=t["date"]%>
|
|
||||||
<a class='pull-right' onclick="delete_file('<%=@current_dir + "/" + t["name"]%>')" href="#"><i class="fa fa-trash"></i></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -199,7 +159,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<table class="tile_info">
|
<table class="tile_info">
|
||||||
<% (get_du(@current_dir)).each_with_index do |t, index| %>
|
<% get_du(@current_dir).each_with_index do |t, index| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p>
|
<p>
|
||||||
@ -361,57 +321,15 @@ function change_upper(directory){
|
|||||||
if(lastindex == 0) lastindex++;
|
if(lastindex == 0) lastindex++;
|
||||||
change_directory(directory.substring(0, lastindex));
|
change_directory(directory.substring(0, lastindex));
|
||||||
}
|
}
|
||||||
function change_directory(directory){
|
function change_directory(dir){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/application/changeDir",
|
url: "/application/changeDir",
|
||||||
data: { path: directory },
|
data: { path: dir },
|
||||||
success : function(result){
|
success : function(result){
|
||||||
$("#current-dir").val(directory);
|
$("#current-dir").val(dir);
|
||||||
$("#table_div").empty();
|
$("#table_div").empty();
|
||||||
var new_table = "";
|
$("#table_div").append("<%= file_manager_table @current_dir %>");
|
||||||
new_table += "<table id='datatable' class='table table-striped table-bordered jambo_table'>";
|
|
||||||
new_table += "<thead>";
|
|
||||||
new_table += "<tr class='headings'>";
|
|
||||||
new_table += "<th>Name</th>";
|
|
||||||
new_table += "<th>Auth</th>";
|
|
||||||
new_table += "<th>Size</th>";
|
|
||||||
new_table += "<th>Date</th>";
|
|
||||||
new_table += "</tr>";
|
|
||||||
new_table += "</thead>";
|
|
||||||
new_table += "<tbody id='datatable_body'>";
|
|
||||||
|
|
||||||
var new_tr = "";
|
|
||||||
new_tr += "<tr role='row' class='odd'>";
|
|
||||||
new_tr += "<td><a style='cursor: pointer' onclick='change_upper(" + '"' + directory + '"' +")'><i class='fa fa-reply'></i></a>";
|
|
||||||
new_tr += " " + directory
|
|
||||||
new_tr += "<a class='pull-right' href='#popup_mkdir'><i class='fa fa-plus'></i><i class='fa fa-folder'></i></a></td>";
|
|
||||||
new_tr += "<td></td> <td></td> <td></td>"
|
|
||||||
new_tr += "</tr>";
|
|
||||||
|
|
||||||
for( var i = 0; i < result.file.length; i++){
|
|
||||||
var row_class = i % 2 == 0 ? 'odd' : 'even';
|
|
||||||
var cur = result.current != "/" ? result.current : '';
|
|
||||||
new_tr += "<tr role='row' class='dir_delete' class='" + row_class + "'>";
|
|
||||||
if(result.file[i].auth[0] == "d"){
|
|
||||||
new_tr += "<td style='color:#0d8ade;' class='sorting_1'><i class='fa fa-folder-open-o'></i> ";
|
|
||||||
new_tr += "<a style='cursor: pointer' onclick='change_directory(" +'"' + cur + "/" + result.file[i].name +'"'+ ")'>" + result.file[i].name + "</a></td>";
|
|
||||||
}else{
|
|
||||||
new_tr += "<td>";
|
|
||||||
new_tr += "<i class='fa fa-file-o'></i>"
|
|
||||||
new_tr += "<a href='/file_download?file_name="+ (cur + "/" + result.file[i].name).replace(/\//, "+") + "'> " + result.file[i].name + "</a>"
|
|
||||||
new_tr += "</td>";
|
|
||||||
}
|
|
||||||
|
|
||||||
new_tr += "<td>"+result.file[i].auth+"</td>";
|
|
||||||
new_tr += "<td>"+result.file[i].size+"</td>";
|
|
||||||
new_tr += "<td>"+result.file[i].date+" <a class='pull-right' onclick='delete_file(" +'"' + cur + "/" + result.file[i].name +'"'+ ")' href='#'><i class='fa fa-trash'></i></a></td>";
|
|
||||||
new_tr += "</tr>";
|
|
||||||
}
|
|
||||||
|
|
||||||
new_table += new_tr;
|
|
||||||
new_table += "</tbody></table>"
|
|
||||||
$("#table_div").append(new_table);
|
|
||||||
$('#datatable').dataTable( {"bSort": false});
|
$('#datatable').dataTable( {"bSort": false});
|
||||||
|
|
||||||
// disk usage
|
// disk usage
|
||||||
@ -427,7 +345,7 @@ function change_directory(directory){
|
|||||||
$("table .tile_info").append(new_tr);
|
$("table .tile_info").append(new_tr);
|
||||||
draw_chart();
|
draw_chart();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user