diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e0e9c9d..16080c3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -35,6 +35,6 @@ class ApplicationController < ActionController::Base def checkDir @current_dir = params[:path] - render :json => {:file => files(@current_dir) , :current => @current_dir} + render :json => {:dir => @current_dir} end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 18cd461..3e839b5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -83,4 +83,53 @@ module ApplicationHelper return files end + def file_manager_table(dir = "/mnt", id = "datatable", class_option = "table table-striped table-bordered jambo_table") + html = String.new + html << "" + + html << "" + html << "" + html << "" + html << "" + html << "" + html << "" + html << "" + html << "" + + html << "" + html << "" + html << "" + html << "" + html << "" + html << "" + html << "" + + files(dir).each do |file| + html << "" + if file["auth"][0]=='d' + html << "" + else + html << "" + end + html << "" + html << "" + html << "" + html << "" + end + + html << "" + html << "
NameauthSizeDate
" + html << "" + html << " " + dir + html << "" + html << "
" + html << " " + file['name'] + "" + html << "" + html << " " + file['name'] + "" + html << "" + file['auth'] + "" + file['size'] + "" + html << file["date"] + html << "" + html << "
" + return html + end end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index a359c8c..ea08f1f 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -125,47 +125,7 @@
- - - - - - - - - - - - - - - - - <% (files @current_dir).each do |t| %> - - <% if t["auth"][0]=='d'%> - - <% else %> - - <% end %> - - - - - <% end %> - -
NameauthSizeDate
- - <%= @current_dir %> - -
- ')"> <%=t["name"]%> - - "><%=t['name']%> - <%=t["auth"]%><%=t["size"]%> - <%=t["date"]%> - ')" href="#"> -
+ <%= raw file_manager_table %>
@@ -199,7 +159,7 @@ - <% (get_du(@current_dir)).each_with_index do |t, index| %> + <% get_du(@current_dir).each_with_index do |t, index| %>

@@ -361,57 +321,15 @@ function change_upper(directory){ if(lastindex == 0) lastindex++; change_directory(directory.substring(0, lastindex)); } -function change_directory(directory){ +function change_directory(dir){ $.ajax({ method: "POST", url: "/application/changeDir", - data: { path: directory }, + data: { path: dir }, success : function(result){ - $("#current-dir").val(directory); + $("#current-dir").val(dir); $("#table_div").empty(); - var new_table = ""; - new_table += ""; - new_table += ""; - new_table += ""; - new_table += ""; - new_table += ""; - new_table += ""; - new_table += ""; - new_table += ""; - new_table += ""; - new_table += ""; - - var new_tr = ""; - new_tr += ""; - new_tr += ""; - new_tr += "" - new_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 += ""; - if(result.file[i].auth[0] == "d"){ - new_tr += ""; - }else{ - new_tr += ""; - } - - new_tr += ""; - new_tr += ""; - new_tr += ""; - new_tr += ""; - } - - new_table += new_tr; - new_table += "
NameAuthSizeDate
"; - new_tr += " " + directory - new_tr += "
"; - new_tr += "" + result.file[i].name + ""; - new_tr += "" - new_tr += " " + result.file[i].name + "" - new_tr += ""+result.file[i].auth+""+result.file[i].size+""+result.file[i].date+"
" - $("#table_div").append(new_table); + $("#table_div").append("<%= file_manager_table @current_dir %>"); $('#datatable').dataTable( {"bSort": false}); // disk usage @@ -427,7 +345,7 @@ function change_directory(directory){ $("table .tile_info").append(new_tr); draw_chart(); } - }) + }); }