gluster-web-interface/app/controllers/home_controller.rb

32 lines
739 B
Ruby
Raw Normal View History

2016-08-20 06:41:37 +00:00
class HomeController < ApplicationController
def index
2016-09-04 06:29:32 +00:00
@current_dir = "/mnt"
2016-09-02 05:56:12 +00:00
file_directory(@current_dir)
2016-08-20 06:41:37 +00:00
end
2016-09-19 10:57:10 +00:00
def file_download
@file_name = params[:file_name].gsub(" ", "/")
if !@file_name.nil?
send_file @file_name
else
puts "file name is nil"
redirect_to '/home/index'
2016-09-19 10:57:10 +00:00
end
end
2016-09-02 07:20:14 +00:00
def make_directory
current_dir = params[:current_dir]
directory_name = params[:directory_name]
2016-09-04 06:17:44 +00:00
puts "mkdir #{current_dir}/#{directory_name}"
2016-09-11 10:57:07 +00:00
`sudo mkdir #{current_dir}/#{directory_name}`
2016-09-04 05:37:33 +00:00
redirect_to '/home/index'
2016-09-02 07:20:14 +00:00
end
2016-09-19 10:57:10 +00:00
2016-09-04 16:10:49 +00:00
def delete_file
file_name = params[:file_name]
puts "rm #{file_name} -rf"
2016-09-11 10:57:07 +00:00
`sudo rm #{file_name} -rf`
2016-09-04 16:10:49 +00:00
redirect_to '/home/index'
end
2016-08-20 06:41:37 +00:00
end