Test mount check

This commit is contained in:
Youngkyun Kim 2016-09-03 10:03:45 +00:00
parent d95f04f3ba
commit 0a576e4e99
4 changed files with 79 additions and 104 deletions

View File

@ -32,17 +32,17 @@ class ApplicationController < ActionController::Base
file = Hash.new
@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]
@files << file
file = Hash.new
end
puts @files
return @files
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]
@files << file
file = Hash.new
end
puts @files
return @files
end
def checkDir

View File

@ -10,21 +10,35 @@ class VolumeController < ApplicationController
if get_info.blank?
flash[:danger] = "Check Server"
else
output = get_info.split("\n")
for t in 1..(output.length-1)
if output[t].include? ":"
temp = output[t].split(":")
volume[temp[0]] = temp[1]
else
@volumes << volume
volume = Hash.new
end
info = get_info.split("\n")
df = get_df
puts df
for t in 1..(info.length-1)
if info[t].include? ":"
temp = info[t].split(":")
volume[temp[0]] = temp[1]
else
if df.include? volume['Volume Name']
volume['Mount State'] = "Mounted"
else
volume['Mount State'] = "UnMounted"
end
puts volume['Volume Name'] + ": " + volume['Mount State']
@volumes << volume
volume = Hash.new
end
end
@volumes << volume
# puts @volumes
end
end
def get_df
@config = get_conf
return `sshpass -p#{@config["host_password"]} ssh #{@config["host_port"]} #{@config["host_user"]}@#{@config["host_ip"]} df -P`
end
def get_info
@config = get_conf

View File

@ -110,10 +110,10 @@
</tr>
</thead>
<tbody id="tbody_volume1">
<tbody id="datatable_body">
<tr>
<td><i class="fa fa-reply"></i>
<a onclick="change_upper('<%=@current_dir%>')"> ..</a>
<a style='cursor: pointer' onclick="change_upper('<%=@current_dir%>')"> ..</a>
</td>
<td></td>
<td></td>
@ -156,19 +156,10 @@
<!-- file manager functions -->
<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);
}
}
if(directory == "/") return;
var lastindex = directory.lastIndexOf("/");
if(lastindex == 0) lastindex++;
change_directory(directory.substring(0, lastindex));
}
function change_directory(directory){
@ -178,7 +169,8 @@
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>";
var new_table = "";
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 += "<p style='text-align:right;'><a class='btn btn-app' href='/home/mkdir/<%=@current_dir%>'><i class='fa fa-plus'></i>Make Directory</a></p>"
new_table += "<table id='datatable' class='table table-striped table-bordered jambo_table'>";
@ -190,10 +182,11 @@
new_table += "<th>Date</th>";
new_table += "</tr>";
new_table += "</thead>";
new_table += "<tbody id='tbody_volume1'>";
new_table += "<tbody id='datatable_body'>";
var new_tr = "<tr role='row' class='odd'> <td><i class='fa fa-reply'></i>";
new_tr += "<a onclick='change_upper(" + '"' + directory + '"' +")'> ..</a>";
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> </td><td> </td></tr>";
for( var i = 0; i < result.file.length; i++){
@ -201,6 +194,7 @@
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 != "/")
@ -219,7 +213,6 @@
new_table += new_tr;
new_table += "</tbody></table>"
$("#table_div").append(new_table);
$('#datatable').dataTable();
}
})

View File

@ -74,7 +74,7 @@
<th></th>
</tr>
</thead>
<tbody id="tbody_volume1">
<tbody id="datatable_body">
<tr>
<td><i class="fa fa-reply"></i> <a style="cursor: pointer" onclick="change_upper('<%=@current_dir%>')"> ..</a></td>
<td></td>
@ -88,7 +88,7 @@
</td>
<td><%=t["auth"]%></td>
<td>
<button class="btn btn-primary pull-right" onclick="mount_selected('<%=@current_dir + "/" + t["name"]%>')">select</botton>
<button class="btn btn-primary pull-right" onclick="volume_mount('<%=@current_dir + "/" + t["name"]%>')">select</botton>
</td>
</tr>
<%end%>
@ -197,6 +197,19 @@
function volume_create() {
}
function volume_mount(mnt_point) {
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(data){
console.log("mount success");
window.location.replace(url.split("?")[0]);
}
});
}
</script>
@ -211,87 +224,42 @@
<!-- file manager functions -->
<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);
}
}
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){
$("#tbody_volume1").empty();
var new_tr = "<tr role='row' class='odd'> <td><i class='fa fa-reply'></i>";
$("#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> </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 style='cursor: pointer' onclick='change_directory(" +'"' + result.current + "/" + result.file[i].name +'"'+ ")'>" + result.file[i].name + "</a></td>";
else
new_tr += "<a style='cursor: pointer' onclick='change_directory(" +'"' + "/" + result.file[i].name +'"'+ ")'>" + result.file[i].name + "</a></td>";
new_tr += "<td>"+result.file[i].auth+"</td>";
new_tr += "<td><button class='btn btn-primary pull-right'>select</botton></td>";
new_tr += "</tr>";
}
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><button class='btn btn-primary pull-right'>select</botton></td>";
new_tr += "</tr>";
}
$("#tbody_volume1").append(new_tr);
$("#datatable_body").append(new_tr);
$('#datatable').dataTable();
}
})
}
</script>
<script>
function mount_selected(mnt_point) {
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(data){
console.log("mount success");
}
});
}
</script>
<script>
$("#form_volume_create").change(function (){
console.log($("#form_volume_create option:selected").val());
})
</script>