add directory
This commit is contained in:
parent
404e72f01c
commit
f38432f3bc
@ -1,9 +1,11 @@
|
|||||||
class VolumeController < ApplicationController
|
class VolumeController < ApplicationController
|
||||||
|
helper_method :file_directory
|
||||||
|
|
||||||
def info
|
def info
|
||||||
|
file_directory('/home/ubuntu')
|
||||||
@volumes = Array.new
|
@volumes = Array.new
|
||||||
volume = Hash.new
|
volume = Hash.new
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
if get_info.blank?
|
if get_info.blank?
|
||||||
flash[:danger] = "Check Server"
|
flash[:danger] = "Check Server"
|
||||||
else
|
else
|
||||||
@ -35,38 +37,51 @@ class VolumeController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def get_files(name)
|
def file_directory(dir)
|
||||||
mnt_path = "/opt/gluster-web-interface/app/mntpoint" + "/" + name.delete(' ')
|
@current_dir = dir
|
||||||
files = Array.new
|
dir_list = `ls #{@current_dir} -l`
|
||||||
file = Hash.new
|
|
||||||
|
|
||||||
puts "start///////"
|
|
||||||
puts "path: " + mnt_path
|
|
||||||
|
|
||||||
`sudo mkdir #{dir}`
|
|
||||||
`sudo mount.glusterfs gluster-1:/#{dir_name} #{dir}`
|
|
||||||
|
|
||||||
dir_list = `ls #{dir} -l`
|
|
||||||
puts dir_list
|
|
||||||
|
|
||||||
parsing_list = dir_list.split("\n")
|
parsing_list = dir_list.split("\n")
|
||||||
@total = parsing_list[0]
|
@files = Array.new
|
||||||
@cur_dir = dir
|
file = Hash.new
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
|
@total_list = parsing_list[0]
|
||||||
for t in 1..(parsing_list.length-1)
|
for t in 1..(parsing_list.length-1)
|
||||||
puts "@@@@@@@@@@@" + parsing_list[t]
|
|
||||||
parsing_file = parsing_list[t].split(" ")
|
parsing_file = parsing_list[t].split(" ")
|
||||||
file["auth"] = parsing_file[0]
|
file["auth"] = parsing_file[0]
|
||||||
file["size"] = parsing_file[4]
|
file["size"] = parsing_file[4]
|
||||||
file["date"] = parsing_file[5] + " " + parsing_file[6] + " "+ parsing_file[7]
|
file["date"] = parsing_file[5] + " " + parsing_file[6] + " "+ parsing_file[7]
|
||||||
file["name"] = parsing_file[8]
|
file["name"] = parsing_file[8]
|
||||||
files[i] = file
|
@files[i] = file
|
||||||
file = Hash.new
|
file = Hash.new
|
||||||
i+=1
|
i+=1
|
||||||
end
|
end
|
||||||
puts files
|
puts @files
|
||||||
|
end
|
||||||
|
|
||||||
return files
|
|
||||||
|
def change_file_directory(dir)
|
||||||
|
@change_dir = dir
|
||||||
|
dir_list = `ls #{@change_dir} -l`
|
||||||
|
parsing_list = dir_list.split("\n")
|
||||||
|
@change_files = Array.new
|
||||||
|
file = Hash.new
|
||||||
|
i = 0
|
||||||
|
@change_total_list = parsing_list[0]
|
||||||
|
for t in 1..(parsing_list.length-1)
|
||||||
|
parsing_file = parsing_list[t].split(" ")
|
||||||
|
file["auth"] = parsing_file[0]
|
||||||
|
file["size"] = parsing_file[4]
|
||||||
|
file["date"] = parsing_file[5] + " " + parsing_file[6] + " "+ parsing_file[7]
|
||||||
|
file["name"] = parsing_file[8]
|
||||||
|
@change_files[i] = file
|
||||||
|
file = Hash.new
|
||||||
|
i+=1
|
||||||
|
end
|
||||||
|
puts @change_files
|
||||||
|
end
|
||||||
|
|
||||||
|
def checkDir
|
||||||
|
file_directory(params[:path])
|
||||||
|
render :json => {:file => @files , :current => @current_dir}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<div class="">
|
<div class="">
|
||||||
<div class="page-title">
|
<div class="page-title">
|
||||||
<div class="title_left">
|
<div class="title_left">
|
||||||
<h3>Volume</h3>
|
<h3>Volume Info </h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="title_right">
|
<div class="title_right">
|
||||||
<div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">
|
<div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">
|
||||||
@ -67,14 +67,9 @@
|
|||||||
<br/>
|
<br/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%f = get_files(t["Volume Name"])%>
|
<div class="col-md-12 col-sm-12 col-xs-12" id="table_div">
|
||||||
<%f.each do |t|%>
|
|
||||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
|
||||||
Current directory : <%=@cur_dir%></br>
|
|
||||||
Numbers : <%=@total%></br>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
|
||||||
<p class="text-muted font-13 m-b-30"><code>File Manager</code></p>
|
<p class="text-muted font-13 m-b-30"><code>File Manager</code></p>
|
||||||
|
<p> Current directory : <%=@current_dir%></p></br>
|
||||||
<table id="datatable" class="table table-striped table-bordered jambo_table">
|
<table id="datatable" class="table table-striped table-bordered jambo_table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="headings">
|
<tr class="headings">
|
||||||
@ -85,20 +80,32 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody id="tbody_volume1">
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><%=t["name"]%></td>
|
<td><i class="fa fa-reply"></i>
|
||||||
<td><%=t["auth"][0]%></td>
|
<a onclick="change_upper('<%=@current_dir%>')"> ..</a>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<%@files.each do |t|%>
|
||||||
|
<tr>
|
||||||
|
<% if t["auth"][0]=='d'%>
|
||||||
|
<td style="color:#0d8ade;"><i class="fa fa-folder-open-o"></i>
|
||||||
|
<a onclick="change_directory('<%=@current_dir + "/" + t["name"]%>')"><%=t["name"]%></a>
|
||||||
|
</td>
|
||||||
|
<% else %>
|
||||||
|
<td><i class="fa fa-file-o"></i> <%=t["name"]%></td>
|
||||||
|
<% end %>
|
||||||
|
<td><%=t["auth"]%></td>
|
||||||
<td><%=t["size"]%></td>
|
<td><%=t["size"]%></td>
|
||||||
<td><%=t["date"]%></td>
|
<td><%=t["date"]%></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<%end%>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<%end%>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -144,20 +151,79 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#datatable').dataTable();
|
$('#datatable').dataTable();
|
||||||
$('#datatable-keytable').DataTable({
|
|
||||||
keys: true
|
|
||||||
});
|
|
||||||
$('#datatable-responsive').DataTable();
|
|
||||||
$('#datatable-scroller').DataTable({
|
|
||||||
ajax: "js/datatables/json/scroller-demo.json",
|
|
||||||
deferRender: true,
|
|
||||||
scrollY: 380,
|
|
||||||
scrollCollapse: true,
|
|
||||||
scroller: true
|
|
||||||
});
|
|
||||||
var table = $('#datatable-fixed-header').DataTable({
|
|
||||||
fixedHeader: true
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
TableManageButtons.init();
|
TableManageButtons.init();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function change_upper(directory){
|
||||||
|
if(directory != "/"){
|
||||||
|
var path = directory.split("/");
|
||||||
|
var upper_path = "";
|
||||||
|
if(path.length == 2){
|
||||||
|
change_directory("/");
|
||||||
|
} else {
|
||||||
|
for(var i = 1; i < path.length - 1 ; i++){
|
||||||
|
if(path[i] != "")
|
||||||
|
upper_path += "/" + path[i];
|
||||||
|
}
|
||||||
|
change_directory(upper_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function change_directory(directory){
|
||||||
|
$.ajax({
|
||||||
|
method: "POST",
|
||||||
|
url: "/volume/changeDir",
|
||||||
|
data: { path: directory },
|
||||||
|
success : function(result){
|
||||||
|
$("#table_div").empty();
|
||||||
|
var new_table = "<p class='text-muted font-13 m-b-30'><code>File Manager</code></p>"
|
||||||
|
new_table += "<p>Current directory : " + directory + "</p></br>";
|
||||||
|
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='tbody_volume1'>"
|
||||||
|
|
||||||
|
var new_tr = "<tr role='row' class='odd'> <td><i class='fa fa-reply'></i>";
|
||||||
|
new_tr += "<a onclick='change_upper(" + '"' + directory + '"' +")'> ..</a>"
|
||||||
|
new_tr += "</td><td> </td><td> </td><td> </td></tr>"
|
||||||
|
for( var i = 0; i < result.file.length; i++){
|
||||||
|
if(i % 2 == 0)
|
||||||
|
new_tr += "<tr role='row' class='odd'>";
|
||||||
|
else
|
||||||
|
new_tr += "<tr role='row' class='even'>";
|
||||||
|
if(result.file[i].auth[0] == "d"){
|
||||||
|
new_tr += "<td style='color:#0d8ade;' class='sorting_1'><i class='fa fa-folder-open-o'></i> ";
|
||||||
|
if(result.current != "/")
|
||||||
|
new_tr += "<a onclick='change_directory(" +'"' + result.current + "/" + result.file[i].name +'"'+ ")'>" + result.file[i].name + "</a></td>";
|
||||||
|
else
|
||||||
|
new_tr += "<a onclick='change_directory(" +'"' + "/" + result.file[i].name +'"'+ ")'>" + result.file[i].name + "</a></td>";
|
||||||
|
}else{
|
||||||
|
new_tr += "<td><i class='fa fa-file-o'></i> " + result.file[i].name + "</td>";
|
||||||
|
}
|
||||||
|
new_tr += "<td>"+result.file[i].auth+"</td>";
|
||||||
|
new_tr += "<td>"+result.file[i].size+"</td>";
|
||||||
|
new_tr += "<td>"+result.file[i].date+"</td>";
|
||||||
|
new_tr += "</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
new_table += new_tr;
|
||||||
|
new_table += "</tbody></table>"
|
||||||
|
$("#table_div").append(new_table);
|
||||||
|
|
||||||
|
$('#datatable').dataTable();
|
||||||
|
TableManageButtons.init();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@ -17,6 +17,7 @@ Rails.application.routes.draw do
|
|||||||
get 'volume/info' => 'volume#info'
|
get 'volume/info' => 'volume#info'
|
||||||
get 'peer/index' => 'peer#index'
|
get 'peer/index' => 'peer#index'
|
||||||
post 'file_upload' => 'volume#file_upload'
|
post 'file_upload' => 'volume#file_upload'
|
||||||
|
post 'volume/changeDir' => 'volume#checkDir'
|
||||||
|
|
||||||
# Example of regular route:
|
# Example of regular route:
|
||||||
# get 'products/:id' => 'catalog#view'
|
# get 'products/:id' => 'catalog#view'
|
||||||
|
Loading…
Reference in New Issue
Block a user