Add mount table to volume index
This commit is contained in:
parent
e62a1eed16
commit
ac1527acf0
@ -13,23 +13,4 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def chdir
|
|
||||||
@current_dir = params[:next_dir]
|
|
||||||
puts "current_dir : " + @current_dir
|
|
||||||
render :json => {
|
|
||||||
:dir => @current_dir,
|
|
||||||
:file_manager_table => file_manager_table(@current_dir),
|
|
||||||
:disk_usage_table => disk_usage_table(@current_dir),
|
|
||||||
:du => get_du(@current_dir),
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def rmdir
|
|
||||||
file_name = params[:file_name]
|
|
||||||
command = String.new
|
|
||||||
command << "sudo rm -rf #{file_name}"
|
|
||||||
puts command
|
|
||||||
`#{command}`
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -26,4 +26,22 @@ class HomeController < ApplicationController
|
|||||||
redirect_to '/home/index'
|
redirect_to '/home/index'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def chdir
|
||||||
|
@current_dir = params[:next_dir]
|
||||||
|
puts "current_dir : " + @current_dir
|
||||||
|
render :json => {
|
||||||
|
:dir => @current_dir,
|
||||||
|
:file_manager_table => file_manager_table(@current_dir),
|
||||||
|
:disk_usage_table => disk_usage_table(@current_dir),
|
||||||
|
:du => get_du(@current_dir),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def rmdir
|
||||||
|
file_name = params[:file_name]
|
||||||
|
command = String.new
|
||||||
|
command << "sudo rm -rf #{file_name}"
|
||||||
|
puts command
|
||||||
|
`#{command}`
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -5,6 +5,15 @@ class VolumeController < ApplicationController
|
|||||||
@current_dir = "/mnt"
|
@current_dir = "/mnt"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def chdir
|
||||||
|
@current_dir = params[:next_dir]
|
||||||
|
puts "current_dir : " + @current_dir
|
||||||
|
render :json => {
|
||||||
|
:dir => @current_dir,
|
||||||
|
:mount_table => mount_table(@current_dir),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def file_upload
|
def file_upload
|
||||||
df = get_df
|
df = get_df
|
||||||
mnt_dir = String.new
|
mnt_dir = String.new
|
||||||
|
@ -21,20 +21,16 @@ module VolumeHelper
|
|||||||
html << "<tr class='headings'>"
|
html << "<tr class='headings'>"
|
||||||
html << "<th>Name</th>"
|
html << "<th>Name</th>"
|
||||||
html << "<th>auth</th>"
|
html << "<th>auth</th>"
|
||||||
#html << "<th>Size</th>"
|
|
||||||
#html << "<th>Date</th>"
|
|
||||||
html << "<th></th>"
|
html << "<th></th>"
|
||||||
html << "</tr>"
|
html << "</tr>"
|
||||||
html << "</thead>"
|
html << "</thead>"
|
||||||
html << "<tbody id='#{id}_body'>"
|
html << "<tbody id='#{id}_body'>"
|
||||||
html << "<tr>"
|
html << "<tr>"
|
||||||
html << "<td>"
|
html << "<td>"
|
||||||
#html << "<a class='chupper' style='cursor: pointer'><i class='fa fa-reply'></i></a>"
|
html << "<a class='chupper' style='cursor: pointer'><i class='fa fa-reply'></i></a> #{@current_dir}"
|
||||||
html << "<i class='fa fa-reply'></i> <a style='cursor: pointer'> ..</a>"
|
|
||||||
html << "</td>"
|
html << "</td>"
|
||||||
html << "<td></td>"
|
html << "<td></td>"
|
||||||
html << "<td></td>"
|
html << "<td></td>"
|
||||||
#html << "<td></td>"
|
|
||||||
html << "</tr>"
|
html << "</tr>"
|
||||||
|
|
||||||
files(dir).each do |file|
|
files(dir).each do |file|
|
||||||
@ -46,7 +42,7 @@ module VolumeHelper
|
|||||||
html << "</td>"
|
html << "</td>"
|
||||||
html << "<td>"
|
html << "<td>"
|
||||||
html << "<form data-parsley-validate>"
|
html << "<form data-parsley-validate>"
|
||||||
hmtl << "<input type='hidden' value='#{@current_dir}/#{file["name"]}'>"
|
html << "<input type='hidden' value='#{@current_dir}/#{file["name"]}'>"
|
||||||
html << "<button type='submit' class='btn btn-primary pull-right'>select</button>"
|
html << "<button type='submit' class='btn btn-primary pull-right'>select</button>"
|
||||||
html << "</form>"
|
html << "</form>"
|
||||||
html << "</td>"
|
html << "</td>"
|
||||||
|
@ -347,7 +347,7 @@ $(document).on("click", "#file_manager_div .chdir", function(){
|
|||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "post",
|
method: "post",
|
||||||
url: "/application/chdir",
|
url: "/home/chdir",
|
||||||
data: { next_dir : next_dir },
|
data: { next_dir : next_dir },
|
||||||
success : function(result){
|
success : function(result){
|
||||||
$("#current_dir").val(next_dir);
|
$("#current_dir").val(next_dir);
|
||||||
@ -375,7 +375,7 @@ $(document).on("click", "#file_manager_div .chupper", function(){
|
|||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/application/chdir",
|
url: "/home/chdir",
|
||||||
data: { next_dir : next_dir },
|
data: { next_dir : next_dir },
|
||||||
success : function(result){
|
success : function(result){
|
||||||
$("#current_dir").val(next_dir);
|
$("#current_dir").val(next_dir);
|
||||||
@ -399,7 +399,7 @@ $(document).on("click", "#file_manager_div .rmdir", function(){
|
|||||||
if(confirm("Are you sure you want to delete '"+ file_name +"' ?")) {
|
if(confirm("Are you sure you want to delete '"+ file_name +"' ?")) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/application/rmdir",
|
url: "/home/rmdir",
|
||||||
data: { target : target },
|
data: { target : target },
|
||||||
success : function(result){
|
success : function(result){
|
||||||
$("#current_dir").val(current_dir);
|
$("#current_dir").val(current_dir);
|
||||||
|
@ -69,8 +69,10 @@
|
|||||||
<div class="popup">
|
<div class="popup">
|
||||||
<h2> Choose mount point </h2>
|
<h2> Choose mount point </h2>
|
||||||
<a class="close" href="#">×</a>
|
<a class="close" href="#">×</a>
|
||||||
|
<div id="mount_table_div">
|
||||||
<%= raw mount_table %>
|
<%= raw mount_table %>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- page content -->
|
<!-- page content -->
|
||||||
<div class="right_col" role="main">
|
<div class="right_col" role="main">
|
||||||
@ -185,63 +187,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- /page content -->
|
<!-- /page content -->
|
||||||
|
|
||||||
<!-- File manager functions -->
|
|
||||||
<script>
|
|
||||||
function change_upper(directory){
|
|
||||||
if(directory == "/") return;
|
|
||||||
var lastindex = directory.lastIndexOf("/");
|
|
||||||
if(lastindex == 0) lastindex++;
|
|
||||||
change_directory(directory.substring(0, lastindex));
|
|
||||||
}
|
|
||||||
function change_directory(directory){
|
|
||||||
$.ajax({
|
|
||||||
method: "POST",
|
|
||||||
url: "/application/changeDir",
|
|
||||||
data: { path: directory },
|
|
||||||
success : function(result){
|
|
||||||
$("#datatable_body").empty();
|
|
||||||
var new_tr = "";
|
|
||||||
new_tr += "<tr role='row' class='odd'> <td><i class='fa fa-reply'></i>";
|
|
||||||
new_tr += "<a style='cursor: pointer' onclick='change_upper(" + '"' + directory + '"' +")'> ..</a>";
|
|
||||||
new_tr += "</td><td> </td><td>";
|
|
||||||
for( var i = 0; i < result.file.length; i++){
|
|
||||||
if(result.file[i].auth[0] != "d") continue;
|
|
||||||
var row_class = i % 2 == 0 ? 'odd' : 'even';
|
|
||||||
var cur = result.current != "/" ? result.current : '';
|
|
||||||
new_tr += "<tr role='row' class='" + row_class + "'>";
|
|
||||||
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>";
|
|
||||||
new_tr += "<td>"+result.file[i].auth+"</td>";
|
|
||||||
new_tr += "<td><form data-parsley-validate>";
|
|
||||||
new_tr += "<input type='hidden' value='" + cur + "/" + result.file[i].name + "'>";
|
|
||||||
new_tr += "<button type='submit' class='btn btn-primary pull-right'>select</botton>";
|
|
||||||
new_tr += "</form></td>"
|
|
||||||
new_tr += "</tr>";
|
|
||||||
}
|
|
||||||
$("#datatable_body").append(new_tr);
|
|
||||||
// Add mount overlay functions again
|
|
||||||
$("#popup_mount #datatable_body form").submit(function(){
|
|
||||||
var mnt_point = $(this).find("input").val();
|
|
||||||
var url = window.location + '';
|
|
||||||
var vol_name = url.match(/volume_name=([^#]+)/)[1];
|
|
||||||
$.ajax({
|
|
||||||
type: 'post',
|
|
||||||
url: '/volume/mount',
|
|
||||||
data: {mount_point: mnt_point, volume_name: vol_name},
|
|
||||||
success: function(result){
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<!-- On document ready -->
|
<!-- On document ready -->
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
// Mount overlay functions
|
// Mount overlay functions
|
||||||
$("#popup_mount #datatable_body form").submit(function(){
|
$("#popup_mount #mount_table_body form").submit(function(){
|
||||||
var mnt_point = $(this).find("input").val();
|
var mnt_point = $(this).find("input").val();
|
||||||
var url = window.location + '';
|
var url = window.location + '';
|
||||||
var vol_name = url.match(/volume_name=([^#]+)/)[1];
|
var vol_name = url.match(/volume_name=([^#]+)/)[1];
|
||||||
@ -341,3 +291,45 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<!-- File manager functions -->
|
||||||
|
<script>
|
||||||
|
// change directory
|
||||||
|
$(document).on("click", "#mount_table_div .chdir", function(){
|
||||||
|
var file_name = $(this).text().trim();
|
||||||
|
var current_dir = $("#mount_table_div span").text().trim();
|
||||||
|
if(current_dir == "/") current_dir = "";
|
||||||
|
var next_dir = current_dir + "/" + file_name;
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
method: "post",
|
||||||
|
url: "/volume/chdir",
|
||||||
|
data: { next_dir : next_dir },
|
||||||
|
success : function(result){
|
||||||
|
$("#mount_table_div").empty();
|
||||||
|
$("#mount_table_div").append(result.mount_table);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
// change upper
|
||||||
|
$(document).on("click", "#mount_table_div .chupper", function(){
|
||||||
|
var current_dir = $("#mount_table_div span").text().trim();
|
||||||
|
if(current_dir == "/") return;
|
||||||
|
var lastindex = current_dir.lastIndexOf("/");
|
||||||
|
console.log("curdir : " + current_dir);
|
||||||
|
console.log("last idx : " + lastindex);
|
||||||
|
if(lastindex == 0) lastindex++;
|
||||||
|
var next_dir = current_dir.substring(0, lastindex);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
method: "POST",
|
||||||
|
url: "/volume/chdir",
|
||||||
|
data: { next_dir : next_dir },
|
||||||
|
success : function(result){
|
||||||
|
$("#mount_table_div").empty();
|
||||||
|
$("#mount_table_div").append(result.mount_table);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
<!-- /File manager functions -->
|
||||||
|
@ -6,25 +6,26 @@ Rails.application.routes.draw do
|
|||||||
# You can have the root of your site routed with "root"
|
# You can have the root of your site routed with "root"
|
||||||
root 'home#index'
|
root 'home#index'
|
||||||
|
|
||||||
post 'application/chdir' => 'application#chdir'
|
|
||||||
post 'application/rmdir' => 'application#rmdir'
|
|
||||||
|
|
||||||
get 'index' => 'plainpage#index'
|
get 'index' => 'plainpage#index'
|
||||||
|
|
||||||
#Home
|
#Home
|
||||||
get 'file_download' => 'home#file_download'
|
get 'file_download' => 'home#file_download'
|
||||||
get 'home/index' => 'home#index'
|
get 'home/index' => 'home#index'
|
||||||
post 'home/mkdir' => 'home#make_directory'
|
post 'home/mkdir' => 'home#make_directory'
|
||||||
|
post 'home/chdir' => 'home#chdir'
|
||||||
|
post 'home/rmdir' => 'home#rmdir'
|
||||||
|
|
||||||
#Volume
|
#Volume
|
||||||
get 'volume/index' => 'volume#index'
|
get 'volume/index' => 'volume#index'
|
||||||
post 'file_upload/:volume_name' => 'volume#file_upload'
|
|
||||||
post 'volume/mount' => "volume#volume_mount"
|
|
||||||
post 'volume/create' => "volume#volume_create"
|
|
||||||
get 'volume/unmount/:volume_name' => "volume#volume_unmount"
|
get 'volume/unmount/:volume_name' => "volume#volume_unmount"
|
||||||
get 'volume/start/:volume_name' => "volume#volume_start"
|
get 'volume/start/:volume_name' => "volume#volume_start"
|
||||||
get 'volume/stop/:volume_name' => "volume#volume_stop"
|
get 'volume/stop/:volume_name' => "volume#volume_stop"
|
||||||
get 'volume/delete/:volume_name' => "volume#volume_delete"
|
get 'volume/delete/:volume_name' => "volume#volume_delete"
|
||||||
|
post 'file_upload/:volume_name' => 'volume#file_upload'
|
||||||
|
post 'volume/mount' => "volume#volume_mount"
|
||||||
|
post 'volume/create' => "volume#volume_create"
|
||||||
|
post 'volume/chdir' => 'volume#chdir'
|
||||||
|
|
||||||
|
|
||||||
#Node
|
#Node
|
||||||
get 'node/index' => 'node#index'
|
get 'node/index' => 'node#index'
|
||||||
|
Loading…
Reference in New Issue
Block a user