Fix file remove
This commit is contained in:
parent
ca09f4f113
commit
3c86832958
@ -38,10 +38,17 @@ class HomeController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def rmdir
|
def rmdir
|
||||||
file_name = params[:file_name]
|
@current_dir = params[:current_dir]
|
||||||
|
file_name = params[:target]
|
||||||
command = String.new
|
command = String.new
|
||||||
command << "sudo rm -rf #{file_name}"
|
command << "sudo rm -rf #{file_name}"
|
||||||
puts command
|
puts command
|
||||||
`#{command}`
|
`#{command}`
|
||||||
|
render :json => {
|
||||||
|
:dir => @current_dir,
|
||||||
|
:file_manager_table => html_file_manager_table(@current_dir),
|
||||||
|
:disk_usage_table => html_disk_usage_table(@current_dir),
|
||||||
|
:du => get_du(@current_dir),
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -38,7 +38,7 @@ module HomeHelper
|
|||||||
html << "<td>#{file['auth']}</td>"
|
html << "<td>#{file['auth']}</td>"
|
||||||
html << "<td>#{file['size']}</td>"
|
html << "<td>#{file['size']}</td>"
|
||||||
html << "<td>#{file["date"]}"
|
html << "<td>#{file["date"]}"
|
||||||
html << "<a class='pull-right rmdir' href='#'><i class='fa fa-trash'></i></a>"
|
html << "<a class='pull-right rmdir' href='#' data-name='#{file['name']}'><i class='fa fa-trash'></i></a>"
|
||||||
html << "</td>"
|
html << "</td>"
|
||||||
html << "</tr>"
|
html << "</tr>"
|
||||||
end
|
end
|
||||||
|
@ -310,15 +310,10 @@
|
|||||||
<% if nodes.length != 0 %>
|
<% if nodes.length != 0 %>
|
||||||
<% nodes.each do |node| %>
|
<% nodes.each do |node| %>
|
||||||
<li class="media event">
|
<li class="media event">
|
||||||
<% if node["ping"].eql? "true" %>
|
<% color = ((node["ping"].eql? "true") ? ((node["gluster"].eql? "on" and node["ssh"].eql? "on") ? "green" : "aero") : "red")%>
|
||||||
<a class="pull-left border-green profile_thumb">
|
<a class="pull-left border-<%= color %> profile_thumb">
|
||||||
<i class="fa fa-cube green"></i>
|
<i class="fa fa-cube <%= color %>"></i>
|
||||||
</a>
|
</a>
|
||||||
<% else %>
|
|
||||||
<a class="pull-left border-red profile_thumb">
|
|
||||||
<i class="fa fa-cube red"></i>
|
|
||||||
</a>
|
|
||||||
<% end %>
|
|
||||||
<div class="media-body">
|
<div class="media-body">
|
||||||
<a class="title" onclick="loading();" href="/node/detail/<%= node["id"] %>"><%= node["host_name"] %></a>
|
<a class="title" onclick="loading();" href="/node/detail/<%= node["id"] %>"><%= node["host_name"] %></a>
|
||||||
<p><strong><%= node["host_ip"] %> </strong> <%= node["user_name"] %> </p>
|
<p><strong><%= node["host_ip"] %> </strong> <%= node["user_name"] %> </p>
|
||||||
@ -514,14 +509,14 @@ $(document).on("click", "#file_manager_div .chupper", function(){
|
|||||||
})
|
})
|
||||||
// remove directory
|
// remove directory
|
||||||
$(document).on("click", "#file_manager_div .rmdir", function(){
|
$(document).on("click", "#file_manager_div .rmdir", function(){
|
||||||
var file_name = $(this).text().trim();
|
var file_name = $(this).data("name").trim();
|
||||||
var current_dir = $("#file_manager_div span").text().trim();
|
var current_dir = $("#file_manager_div span").text().trim();
|
||||||
var target = current_dir + "/" + file_name;
|
var target = current_dir + "/" + file_name;
|
||||||
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: "/home/rmdir",
|
url: "/home/rmdir",
|
||||||
data: { target : target },
|
data: { target : target , current_dir : current_dir},
|
||||||
beforeSend : function(){
|
beforeSend : function(){
|
||||||
$(location).attr('href',"#loading");
|
$(location).attr('href',"#loading");
|
||||||
},
|
},
|
||||||
|
@ -13,7 +13,7 @@ Rails.application.routes.draw do
|
|||||||
get 'home/index' => 'home#index'
|
get 'home/index' => 'home#index'
|
||||||
post 'home/chdir' => 'home#chdir'
|
post 'home/chdir' => 'home#chdir'
|
||||||
post 'home/mkdir' => 'home#make_directory'
|
post 'home/mkdir' => 'home#make_directory'
|
||||||
post 'home/delete' => 'home#delete_file'
|
post 'home/rmdir' => 'home#rmdir'
|
||||||
|
|
||||||
#Volume
|
#Volume
|
||||||
get 'volume/index' => 'volume#index'
|
get 'volume/index' => 'volume#index'
|
||||||
|
Loading…
Reference in New Issue
Block a user