gluster-web-interface/app/views/volume/index.html.erb

375 lines
19 KiB
Plaintext
Raw Normal View History

2016-09-11 10:57:07 +00:00
<!-- create overlay page -->
<div id="popup_create" class="overlay">
<div class="popup">
<h2> Choose mount point </h2>
<a class="close" href="#">&times;</a>
<form id="form_volume_create" data-parsley-validate class="form-horizontal form-label-left">
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="volume-name">Volume Name <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" required="required" class="form-control col-md-7 col-xs-12">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Volume Type <span class="required">*</span>
</label>
<div class="col-md-9 col-sm-9 col-xs-12">
<select class="form-control">
<% ['Distribute', 'Stripe', 'Replica', 'Disperse', 'Disperse-data', 'Redundancy'].each do |types|%>
2016-09-11 10:57:07 +00:00
<option><%=types%></option>
<% end %>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Number of brick <span class="required">*</span>
</label>
<div class="col-md-9 col-sm-9 col-xs-12">
<select class="form-control">
<% for i in 1...11 do %>
<option><%=i%></option>
<% end %>
</select>
</div>
</div>
<div class="form-group">
<div class="row" style="margin:0 0 10px 0">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Bricks <span class="required">*</span>
</label>
<div class="col-md-3 col-sm-3 col-xs-4">
<select class="form-control">
2016-09-23 09:28:53 +00:00
<% get_conf_all.each do |t| %>
<option><%= t['host_name'] %></option>
<% end %>
2016-09-11 10:57:07 +00:00
</select>
</div>
<div class="col-md-1 col-sm-1 col-xs-1">
<label class="control-label col-md-12 col-sm-12 col-xs-12">/
</label>
</div>
<div class="col-md-5 col-sm-5 col-xs-7">
<input type="text" required="required" class="form-control col-md-7 col-xs-12">
</div>
</div>
</div>
<div class="ln_solid"></div>
<div class="form-group">
<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
<a href="#" class="btn btn-primary">Cancel</a>
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
</div>
2016-09-11 10:57:07 +00:00
</div>
<!-- mount overlay page -->
<div id="popup_mount" class="overlay">
<div class="popup">
<h2> Choose mount point </h2>
<a class="close" href="#">&times;</a>
<table id="datatable" class="table table-striped jambo_table">
<thead>
<tr class="headings">
<th>Name</th>
<th>auth</th>
<th></th>
</tr>
</thead>
<tbody id="datatable_body">
<tr>
2016-09-23 09:28:53 +00:00
<td><i class="fa fa-reply"></i> <a style="cursor: pointer" onclick="change_upper('<%= @current_dir %>')"> ..</a></td>
2016-09-11 10:57:07 +00:00
<td></td>
<td></td>
</tr>
2016-09-23 09:28:53 +00:00
<% @files.each do |t| %>
<% if t["auth"][0]=='d' %>
2016-09-11 10:57:07 +00:00
<tr>
<td style="color:#0d8ade;"><i class="fa fa-folder-open-o"></i>
2016-09-23 09:28:53 +00:00
<a style="cursor: pointer" onclick="change_directory('<%= @current_dir + "/" + t["name"] %>')"> <%= t["name"] %></a>
2016-09-11 10:57:07 +00:00
</td>
<td><%=t["auth"]%></td>
<td>
2016-09-14 07:23:13 +00:00
<form data-parsley-validate>
2016-09-23 09:28:53 +00:00
<input type="hidden" value='<%= @current_dir + "/" + t["name"] %>'>
2016-09-14 07:23:13 +00:00
<button type="submit" class="btn btn-primary pull-right">select</botton>
2016-09-23 09:28:53 +00:00
</form>
</td>
</tr>
<% end %>
<% end %>
2016-09-11 10:57:07 +00:00
</tbody>
</table>
2016-08-20 06:58:04 +00:00
</div>
</div>
2016-09-11 10:57:07 +00:00
<!-- page content -->
<div class="right_col" role="main">
<div class="page-title">
<div class="title_left">
<h3>Volume</h3>
2016-08-22 08:35:24 +00:00
</div>
2016-09-11 10:57:07 +00:00
<div class="title_right">
<div class="col-md-5 col-sm-5 col-xs-12 pull-right">
<a class="btn btn-success btn-lg pull-right" href="#popup_create">Create Volume</a>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="row">
2016-09-23 09:28:53 +00:00
<% volumes.each_with_index do |t, index| %>
2016-09-11 10:57:07 +00:00
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="x_panel">
<div class="x_title">
2016-09-15 11:14:39 +00:00
<!-- left title -->
2016-09-11 10:57:07 +00:00
<h2>Infomation <small><%=t["Volume Name"]%></small></h2>
2016-09-15 11:14:39 +00:00
<!-- right title -->
2016-09-11 10:57:07 +00:00
<ul class="nav navbar-right panel_toolbox">
2016-09-20 12:13:24 +00:00
<li><a class="collapse-link">
<% if index == 0 %>
<i class="fa fa-chevron-up"></i>
<% else %>
<i class="fa fa-chevron-down"></i>
<% end %></a>
2016-09-11 10:57:07 +00:00
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Settings 1</a>
</li>
<li><a href="#">Settings 2</a>
</li>
</ul>
</li>
2016-09-15 11:14:39 +00:00
<li>
<%if t['Mount State'].eql? "mounted" %>
<a><i class="fa fa-circle green"></i></a>
<% else %>
<a><i class="fa fa-circle"></i></a>
<% end %>
</li>
<li>
<%if !t['Mount State'].eql? "mounted" and t['Status'].eql? " Started" %>
<a><i class="fa fa-circle blue"></i></a>
<% else %>
<a><i class="fa fa-circle"></i></a>
<% end %>
</li>
<li>
2016-09-20 12:13:24 +00:00
<%if t['Status'].eql? " Stopped" or t['Status'].eql? " Created" %>
2016-09-15 11:14:39 +00:00
<a><i class="fa fa-circle red"></i></a>
<% else %>
<a><i class="fa fa-circle"></i></a>
<% end %>
2016-09-11 10:57:07 +00:00
</li>
</ul>
<div class="clearfix"></div>
</div>
2016-09-20 12:13:24 +00:00
<% if index == 0 %>
<div class="x_content">
2016-09-23 09:28:53 +00:00
<% else %>
<div class="x_content" style="display: none;">
2016-09-14 03:21:49 +00:00
<% end %>
2016-09-23 09:28:53 +00:00
<!-- left content -->
<div class="col-md-6 col-sm-6 col-xs-12">
<div style="margin: 10px">
<p class="text-muted font-13 m-b-30"><span class="badge bg-blue">Volume Info</span></p>
<%= volume_info t %>
</div>
<% if t["Mount State"] == "mounted" %>
<a class="btn btn-app" href="/volume/unmount/<%=t['Volume Name'].delete(' ')%>"><i class="fa fa-upload"></i> Unmount</a>
<% elsif t["Status"] == " Started" %>
<a class="btn btn-app" href="/volume/stop/<%=t['Volume Name'].delete(' ')%>">
<i class="fa fa-pause" style="color:#d9534f;"></i>
<p style="color:#d9534f;">Stop</p>
</a>
<a class="btn btn-app" href="?volume_name=<%=t['Volume Name'].delete(' ')%>#popup_mount"><i class="fa fa-download"></i> Mount</a>
<% else %>
<a class="btn btn-app" href="/volume/start/<%=t['Volume Name'].delete(' ')%>">
<i class="fa fa-play" style="color:#26B99A;"></i>
<p style="color:#26B99A;">Start</p>
</a>
<a class="btn btn-app" href="/volume/delete/<%=t['Volume Name'].delete(' ')%>">
<i class="fa fa-trash"></i> Delete
</a>
<% end %>
</div>
<!-- right content -->
<div class="col-md-6 col-sm-6 col-xs-12">
<% if t["Mount State"] == "mounted" %>
<p class="text-muted font-13 m-b-30"><span class="badge bg-green">Uploader</span> Activated</p>
<form action="/file_upload/<%=t['Volume Name'].delete(' ')%>" method="post" enctype="multipart/form-data" class="dropzone" style="border: 1px solid #e5e5e5; height: 300px; overflow:auto;">
</form>
<br/>
<% else %>
<p class="text-muted font-13 m-b-30"><span class="badge bg-red">Uploader</span> Inactivated</p>
<form style="border: 1px solid #e5e5e5; height: 300px; overflow:auto;">
</form>
<br/>
<% end %>
</div>
2016-09-11 10:57:07 +00:00
</div>
</div>
2016-09-03 08:25:09 +00:00
</div>
2016-09-23 09:28:53 +00:00
<%end%>
2016-08-20 06:58:04 +00:00
</div>
2016-08-22 08:35:24 +00:00
</div>
2016-09-23 09:28:53 +00:00
<!-- /page content -->
2016-09-15 11:14:39 +00:00
2016-09-23 09:28:53 +00:00
<!-- 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){
2016-09-15 09:22:55 +00:00
$.ajax({
2016-09-23 09:28:53 +00:00
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){
}
});
})
2016-09-15 09:22:55 +00:00
}
2016-09-23 09:28:53 +00:00
})
}
</script>
<!-- On document ready -->
<script>
$(document).ready(function(){
// Mount overlay functions
$("#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){
}
});
2016-09-15 09:22:55 +00:00
});
2016-09-23 09:28:53 +00:00
// Create overlay functions
$("#popup_create #form_volume_create").submit(function(){
var volume_name = $(this).find(".form-group:eq(0) input").val(),
2016-09-15 11:14:39 +00:00
volume_type = $(this).find(".form-group:eq(1) option:selected").val(),
num_of_brick = $(this).find(".form-group:eq(2) option:selected").val() * 1, // convert to Number type
bricks = [];
2016-09-23 09:28:53 +00:00
if(volume_name.indexOf(' ') >= 0){
alert("Volume name can't contains white spaces");
2016-09-15 11:14:39 +00:00
return;
}
2016-09-23 09:28:53 +00:00
<% volumes.each do |t| %>
if(volume_name == "<%=t["Volume Name"].delete(' ')%>"){
alert("Already has a volume which name is same");
2016-09-15 11:14:39 +00:00
return;
}
2016-09-23 09:28:53 +00:00
<% end %>
for(var i = 0; i < num_of_brick; i++){
var host_name = $(this).find(".form-group .row").eq(i).find("option:selected").val();
var brick_name = $(this).find(".form-group .row").eq(i).find("input").val();
if(brick_name.indexOf(' ') >= 0) {
alert("Brick name can't contain white spaces");
return;
}
if(brick_name.indexOf('/') == 0) {
alert("Brick name can't start with slash");
return;
}
var brick = host_name + ":/" + brick_name;
2016-09-15 11:14:39 +00:00
bricks.push(brick);
console.log(brick);
}
2016-09-23 09:28:53 +00:00
$.ajax({
method: "POST",
url: "/volume/create",
data: { volume_name : volume_name, volume_type : volume_type, num_of_brick : num_of_brick, bricks : bricks },
success : function(result){
}
});
});
// Volume type changed
$("#popup_create #form_volume_create .form-group").eq(1).change(function (){
var $type = $(this).find("option:selected").val();
switch ($type) {
case "Distribute":
case "Stripe":
case "Replica":
case "Disperse":
case "Disperse-data":
case "Redundancy":
console.log($type);
break;
default:
console.log("something goes wrong");
break;
2016-09-15 11:14:39 +00:00
}
2016-09-23 09:28:53 +00:00
});
// Number of bricks changed
$("#popup_create #form_volume_create .form-group").eq(2).change(function (){
var $num_of_brick = $(this).find("option:selected").val();
var $body = $("#form_volume_create .form-group").eq(3);
$body.empty();
var new_body = "";
for(var i = 0; i < $num_of_brick; ++i) {
new_body += "<div class='row' style='margin:0 0 10px 0'>";
new_body += "<label class='control-label col-md-3 col-sm-3 col-xs-12'>";
if(i == 0)
new_body += "Bricks <span class='required'>*</span>";
new_body += "</label>";
new_body += "<div class='col-md-3 col-sm-3 col-xs-4'>";
new_body += "<select class='form-control'>";
<% get_conf_all.each do |t| %>
new_body += "<option><%= t['host_name'] %></option>";
<% end %>
new_body += "</select>";
new_body += "</div>";
new_body += "<div class='col-md-1 col-sm-1 col-xs-1'>"
new_body += "<label class='control-label col-md-12 col-sm-12 col-xs-12'>/"
new_body += "</label>"
new_body += "</div>"
new_body += "<div class='col-md-5 col-sm-5 col-xs-7'>";
new_body += "<input type='text' required='required' class='form-control col-md-7 col-xs-12'>";
new_body += "</div>";
new_body += "</div>";
2016-09-15 11:14:39 +00:00
}
2016-09-23 09:28:53 +00:00
$body.append(new_body);
2016-09-15 11:14:39 +00:00
});
});
2016-09-23 09:28:53 +00:00
</script>