Test mount check
This commit is contained in:
parent
d95f04f3ba
commit
0a576e4e99
@ -32,17 +32,17 @@ class ApplicationController < ActionController::Base
|
|||||||
file = Hash.new
|
file = Hash.new
|
||||||
|
|
||||||
@total_list = parsing_list[0]
|
@total_list = parsing_list[0]
|
||||||
for t in 1..(parsing_list.length-1)
|
for t in 1..(parsing_list.length-1)
|
||||||
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 << file
|
@files << file
|
||||||
file = Hash.new
|
file = Hash.new
|
||||||
end
|
end
|
||||||
puts @files
|
puts @files
|
||||||
return @files
|
return @files
|
||||||
end
|
end
|
||||||
|
|
||||||
def checkDir
|
def checkDir
|
||||||
|
@ -10,21 +10,35 @@ class VolumeController < ApplicationController
|
|||||||
if get_info.blank?
|
if get_info.blank?
|
||||||
flash[:danger] = "Check Server"
|
flash[:danger] = "Check Server"
|
||||||
else
|
else
|
||||||
output = get_info.split("\n")
|
info = get_info.split("\n")
|
||||||
for t in 1..(output.length-1)
|
df = get_df
|
||||||
if output[t].include? ":"
|
puts df
|
||||||
temp = output[t].split(":")
|
|
||||||
volume[temp[0]] = temp[1]
|
for t in 1..(info.length-1)
|
||||||
else
|
if info[t].include? ":"
|
||||||
@volumes << volume
|
temp = info[t].split(":")
|
||||||
volume = Hash.new
|
volume[temp[0]] = temp[1]
|
||||||
end
|
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
|
end
|
||||||
@volumes << volume
|
@volumes << volume
|
||||||
# puts @volumes
|
# puts @volumes
|
||||||
end
|
end
|
||||||
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
|
def get_info
|
||||||
@config = get_conf
|
@config = get_conf
|
||||||
|
@ -110,10 +110,10 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody id="tbody_volume1">
|
<tbody id="datatable_body">
|
||||||
<tr>
|
<tr>
|
||||||
<td><i class="fa fa-reply"></i>
|
<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></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
@ -156,19 +156,10 @@
|
|||||||
<!-- file manager functions -->
|
<!-- file manager functions -->
|
||||||
<script>
|
<script>
|
||||||
function change_upper(directory){
|
function change_upper(directory){
|
||||||
if(directory != "/"){
|
if(directory == "/") return;
|
||||||
var path = directory.split("/");
|
var lastindex = directory.lastIndexOf("/");
|
||||||
var upper_path = "";
|
if(lastindex == 0) lastindex++;
|
||||||
if(path.length == 2){
|
change_directory(directory.substring(0, lastindex));
|
||||||
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){
|
function change_directory(directory){
|
||||||
@ -178,7 +169,8 @@
|
|||||||
data: { path: directory },
|
data: { path: directory },
|
||||||
success : function(result){
|
success : function(result){
|
||||||
$("#table_div").empty();
|
$("#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>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 += "<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'>";
|
new_table += "<table id='datatable' class='table table-striped table-bordered jambo_table'>";
|
||||||
@ -190,10 +182,11 @@
|
|||||||
new_table += "<th>Date</th>";
|
new_table += "<th>Date</th>";
|
||||||
new_table += "</tr>";
|
new_table += "</tr>";
|
||||||
new_table += "</thead>";
|
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>";
|
var new_tr = "";
|
||||||
new_tr += "<a onclick='change_upper(" + '"' + directory + '"' +")'> ..</a>";
|
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>";
|
new_tr += "</td><td> </td><td> </td><td> </td></tr>";
|
||||||
|
|
||||||
for( var i = 0; i < result.file.length; i++){
|
for( var i = 0; i < result.file.length; i++){
|
||||||
@ -201,6 +194,7 @@
|
|||||||
new_tr += "<tr role='row' class='odd'>";
|
new_tr += "<tr role='row' class='odd'>";
|
||||||
else
|
else
|
||||||
new_tr += "<tr role='row' class='even'>";
|
new_tr += "<tr role='row' class='even'>";
|
||||||
|
|
||||||
if(result.file[i].auth[0] == "d"){
|
if(result.file[i].auth[0] == "d"){
|
||||||
new_tr += "<td style='color:#0d8ade;' class='sorting_1'><i class='fa fa-folder-open-o'></i> ";
|
new_tr += "<td style='color:#0d8ade;' class='sorting_1'><i class='fa fa-folder-open-o'></i> ";
|
||||||
if(result.current != "/")
|
if(result.current != "/")
|
||||||
@ -219,7 +213,6 @@
|
|||||||
new_table += new_tr;
|
new_table += new_tr;
|
||||||
new_table += "</tbody></table>"
|
new_table += "</tbody></table>"
|
||||||
$("#table_div").append(new_table);
|
$("#table_div").append(new_table);
|
||||||
|
|
||||||
$('#datatable').dataTable();
|
$('#datatable').dataTable();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="tbody_volume1">
|
<tbody id="datatable_body">
|
||||||
<tr>
|
<tr>
|
||||||
<td><i class="fa fa-reply"></i> <a style="cursor: pointer" onclick="change_upper('<%=@current_dir%>')"> ..</a></td>
|
<td><i class="fa fa-reply"></i> <a style="cursor: pointer" onclick="change_upper('<%=@current_dir%>')"> ..</a></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
@ -88,7 +88,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td><%=t["auth"]%></td>
|
<td><%=t["auth"]%></td>
|
||||||
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<%end%>
|
<%end%>
|
||||||
@ -197,6 +197,19 @@
|
|||||||
function volume_create() {
|
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>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
@ -211,87 +224,42 @@
|
|||||||
<!-- file manager functions -->
|
<!-- file manager functions -->
|
||||||
<script>
|
<script>
|
||||||
function change_upper(directory){
|
function change_upper(directory){
|
||||||
if(directory != "/"){
|
if(directory == "/") return;
|
||||||
var path = directory.split("/");
|
var lastindex = directory.lastIndexOf("/");
|
||||||
var upper_path = "";
|
if(lastindex == 0) lastindex++;
|
||||||
if(path.length == 2){
|
change_directory(directory.substring(0, lastindex));
|
||||||
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){
|
function change_directory(directory){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/application/changeDir",
|
url: "/application/changeDir",
|
||||||
data: { path: directory },
|
data: { path: directory },
|
||||||
success : function(result){
|
success : function(result){
|
||||||
$("#tbody_volume1").empty();
|
$("#datatable_body").empty();
|
||||||
|
var new_tr = "";
|
||||||
var new_tr = "<tr role='row' class='odd'> <td><i class='fa fa-reply'></i>";
|
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 += "<a style='cursor: pointer' onclick='change_upper(" + '"' + directory + '"' +")'> ..</a>";
|
||||||
new_tr += "</td><td> </td><td> </td><td> </td></tr>";
|
new_tr += "</td><td> </td><td> </td><td> </td></tr>";
|
||||||
|
|
||||||
for( var i = 0; i < result.file.length; i++){
|
for( var i = 0; i < result.file.length; i++){
|
||||||
if(i % 2 == 0)
|
if(result.file[i].auth[0] != "d") continue;
|
||||||
new_tr += "<tr role='row' class='odd'>";
|
var row_class = i % 2 == 0 ? 'odd' : 'even';
|
||||||
else
|
var cur = result.current != "/" ? result.current : '';
|
||||||
new_tr += "<tr role='row' class='even'>";
|
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> ";
|
||||||
if(result.file[i].auth[0] == "d"){
|
new_tr += "<a style='cursor: pointer' onclick='change_directory(" +'"' + cur + "/" + result.file[i].name +'"'+ ")'>" + result.file[i].name + "</a></td>";
|
||||||
new_tr += "<td style='color:#0d8ade;' class='sorting_1'><i class='fa fa-folder-open-o'></i> ";
|
new_tr += "<td>"+result.file[i].auth+"</td>";
|
||||||
if(result.current != "/")
|
new_tr += "<td><button class='btn btn-primary pull-right'>select</botton></td>";
|
||||||
new_tr += "<a style='cursor: pointer' onclick='change_directory(" +'"' + result.current + "/" + result.file[i].name +'"'+ ")'>" + result.file[i].name + "</a></td>";
|
new_tr += "</tr>";
|
||||||
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>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
$("#datatable_body").append(new_tr);
|
||||||
$("#tbody_volume1").append(new_tr);
|
|
||||||
|
|
||||||
$('#datatable').dataTable();
|
$('#datatable').dataTable();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<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 (){
|
$("#form_volume_create").change(function (){
|
||||||
console.log($("#form_volume_create option:selected").val());
|
console.log($("#form_volume_create option:selected").val());
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue
Block a user