This commit is contained in:
kyg516 2016-09-24 18:00:27 +09:00
parent fc39111d1a
commit bf7244b273
11 changed files with 335 additions and 256 deletions

View File

@ -12,10 +12,8 @@
//
//= require jquery
//= require bootstrap-sprockets
//= require jquery_ujs
//= require turbolinks
//= require js/bootstrap.min.js
//= require js/flot/jquery.flot.js
//= require js/flot/jquery.flot.pie.js
@ -26,7 +24,6 @@
//= require js/flot/jquery.flot.stack.js
//= require js/flot/curvedLines.js
//= require js/flot/jquery.flot.resize.js
//= require js/progressbar/bootstrap-progressbar.min.js
//= require js/icheck/icheck.min.js
//= require js/moment/moment.min.js
@ -35,8 +32,10 @@
//= require js/pace/pace.min.js
//= require js/nprogress.js
//= require flash.js
//= require js/knob/jquery.knob.min.js
//= require js/dropzone/dropzone.js
//= require js/validator/validator.js
//= require js/easypie/jquery.easypiechart.min.js
// Datatables
@ -53,9 +52,3 @@
//= require js/datatables/dataTables.responsive.min.js
//= require js/datatables/responsive.bootstrap.min.js
//= require js/datatables/dataTables.scroller.min.js
// Right Click Event
//= require contextmenu
//= require js/validator/validator.js

View File

@ -16,14 +16,10 @@
*/
//Right Click Event
@import "contextmenu";
@import "loading";
@import "bootstrap-sprockets";
@import "bootstrap";
@import "font-awesome";
@import "css/animate.min";
@import "css/custom";
@import "css/icheck/flat/green";
@ -35,7 +31,6 @@
@import "pace";
//DataTable
@import "js/datatables/jquery.dataTables.min";
@import "js/datatables/buttons.bootstrap.min";
@import "js/datatables/responsive.bootstrap.min";

View File

@ -2,7 +2,6 @@ class HomeController < ApplicationController
before_action :require_login
def index
@current_dir = "/mnt"
file_directory(@current_dir)
end
@ -28,7 +27,6 @@ class HomeController < ApplicationController
redirect_to '/home/index'
end
def delete_file
file_name = params[:file_name]
# delete file

View File

@ -4,7 +4,6 @@ class NodeController < ApplicationController
def index
@hosts = Array.new
@nodes = Node.all.order("id asc")
if get_hosts.blank?
flash[:danger] = "Check Server"
else

View File

@ -1,30 +1,30 @@
module ApplicationHelper
def get_conf
config = Hash.new
one_node = Node.take
if !one_node.nil?
config["host_name"] = one_node.host_name
config["host_ip"] = one_node.host_ip
config["user_name"] = one_node.user_name
config["user_password"] = one_node.user_password
conf = Hash.new
node = Node.take
if !node.nil?
conf["host_name"] = node.host_name
conf["host_ip"] = node.host_ip
conf["user_name"] = node.user_name
conf["user_password"] = node.user_password
end
return config
return conf
end
def get_conf_all
config = Array.new
config_each = Hash.new
all_node = Node.all
all_node.each do |one_node|
config_each["host_name"] = one_node.host_name
config_each["host_ip"] = one_node.host_ip
config_each["user_name"] = one_node.user_name
config_each["user_password"] = one_node.user_password
config << config_each
config_each = Hash.new
conf_all = Array.new
conf = Hash.new
nodes = Node.all
nodes.each do |node|
conf["host_name"] = node.host_name
conf["host_ip"] = node.host_ip
conf["user_name"] = node.user_name
conf["user_password"] = node.user_password
conf_all << conf
conf = Hash.new
end
return config
return conf_all
end
def get_df
@ -49,4 +49,44 @@ module ApplicationHelper
return df
end
def users
users = User.all
return users
end
def nodes
nodes = Node.all
return nodes
end
def volumes
volumes = Array.new
volume = Hash.new
conf = get_conf
df = get_df
command = String.new
command << "sshpass -p#{conf['user_password']} "
command << "ssh #{conf['user_name']}@#{conf['host_ip']} "
command << "gluster volume info"
puts command
output = `#{command}`.split("\n")
output << "\n"
output.each do |t|
next if t.equal? output.first
if t.include? ":"
temp = t.split(":")
volume[temp[0]] = temp[1]
else
volume['Mount State'] = "unmounted"
df.each do |u|
next if !u['Filesystem'].include? volume['Volume Name'].delete(' ')
volume['Mount State'] = "mounted"
volume['Mount Point'] = u['Mounted on']
end
volumes << volume
volume = Hash.new
end
end
return volumes
end
end

View File

@ -1,36 +1,5 @@
module VolumeHelper
def volumes
volumes = Array.new
volume = Hash.new
conf = get_conf
df = get_df
command = String.new
command << "sshpass -p#{conf['user_password']} "
command << "ssh #{conf['user_name']}@#{conf['host_ip']} "
command << "gluster volume info"
puts command
output = `#{command}`.split("\n")
output << "\n"
output.each do |t|
next if t.equal? output.first
if t.include? ":"
temp = t.split(":")
volume[temp[0]] = temp[1]
else
volume['Mount State'] = "unmounted"
df.each do |u|
next if !u['Filesystem'].include? volume['Volume Name'].delete(' ')
volume['Mount State'] = "mounted"
volume['Mount Point'] = u['Mounted on']
end
volumes << volume
volume = Hash.new
end
end
return volumes
end
def volume_info(volume)
params = ['Type', 'Volume ID', 'Status', 'Number of Bricks', 'Transport-type', 'Bricks', 'Options Reconfigured', 'Mount State', 'Mount Point']
html = ''

View File

@ -1,4 +1,5 @@
<!-- create overlay page -->
<div id="popup_mkdir" class="overlay">
<div class="popup">
<h2> Make Directory </h2>
@ -33,47 +34,44 @@
<div class="page-title">
</div>
<div class="clearfix"></div>
<div class="row">
<!-- top tiles -->
<div class="row tile_count">
<div class="animated flipInY col-md-2 col-sm-4 col-xs-4 tile_stats_count">
<div class="left"></div>
<div class="right">
<span class="count_top"><i class="fa fa-user"></i> Total Users</span>
<div class="count">2500</div>
<span class="count_bottom"><i class="green">4% </i> From last Week</span>
<span class="count_top"><i class="fa fa-clock-o"></i> Current signed in</span>
<div class="count"><%= current_user.current_sign_in_at.strftime("%a, %H:%M") %></div>
<span class="count_bottom"> From <i class="green"><%= current_user.current_sign_in_ip %></i></span>
</div>
</div>
<div class="animated flipInY col-md-2 col-sm-4 col-xs-4 tile_stats_count">
<div class="left"></div>
<div class="right">
<span class="count_top"><i class="fa fa-clock-o"></i> Average Time</span>
<div class="count">123.50</div>
<span class="count_bottom"><i class="green"><i class="fa fa-sort-asc"></i>3% </i> From last Week</span>
<span class="count_top"><i class="fa fa-clock-o"></i> Last signed in</span>
<div class="count"><%= current_user.last_sign_in_at.strftime("%a, %H:%M") %></div>
<span class="count_bottom"> From <i class="red"><%= current_user.last_sign_in_ip %></i></span>
</div>
</div>
<div class="animated flipInY col-md-2 col-sm-4 col-xs-4 tile_stats_count">
<div class="left"></div>
<div class="right">
<span class="count_top"><i class="fa fa-user"></i> Total Males</span>
<div class="count green">2,500</div>
<span class="count_bottom"><i class="green"><i class="fa fa-sort-asc"></i>34% </i> From last Week</span>
<span class="count_top"><i class="fa fa-user"></i> Members</span>
<div class="count"><%= users.length %></div>
</div>
</div>
<div class="animated flipInY col-md-2 col-sm-4 col-xs-4 tile_stats_count">
<div class="left"></div>
<div class="right">
<span class="count_top"><i class="fa fa-user"></i> Total Females</span>
<div class="count">4,567</div>
<span class="count_bottom"><i class="red"><i class="fa fa-sort-desc"></i>12% </i> From last Week</span>
<span class="count_top"><i class="fa fa-cubes"></i> Total Nodes</span>
<div class="count"><%= nodes.length %></div>
</div>
</div>
<div class="animated flipInY col-md-2 col-sm-4 col-xs-4 tile_stats_count">
<div class="left"></div>
<div class="right">
<span class="count_top"><i class="fa fa-user"></i> Total Collections</span>
<div class="count">2,315</div>
<span class="count_bottom"><i class="green"><i class="fa fa-sort-asc"></i>34% </i> From last Week</span>
<span class="count_top"><i class="fa fa-database"></i> Total volumes</span>
<div class="count"><%= volumes.length %></div>
</div>
</div>
<div class="animated flipInY col-md-2 col-sm-4 col-xs-4 tile_stats_count">
@ -87,8 +85,9 @@
</div>
<!-- /top tiles -->
<div class="row">
<!-- file manager -->
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="col-md-8 col-sm-8 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>File Manager</h2>
@ -158,10 +157,42 @@
<!-- /file manager -->
<!-- disk usage -->
<div class="col-md-4 col-sm-4 col-xs-12">
<div class="panel panel-body">
<div class="x_title">
<h4>Easy Pie Chart</h4>
</div>
<p>Easy pie chart is a jQuery plugin that uses the canvas element to render highly customizable, very easy to implement, simple pie charts for single values.</p>
<div class="row">
<div class="col-xs-4">
<span class="chart" data-percent="86">
<span class="percent"></span>
</span>
</div>
<div class="col-xs-4">
<span class="chart" data-percent="73">
<span class="percent"></span>
</span>
</div>
<div class="col-xs-4">
<span class="chart" data-percent="60">
<span class="percent"></span>
</span>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
<!-- /disk usage -->
</div>
<div class ="row">
<!-- node status -->
<div class="col-md-4 col-sm-4 col-xs-12">
<div class="x_panel tile fixed_height_320">
<div class="x_title">
<h2>App Versions</h2>
<h2>Nodes</h2>
<ul class="nav navbar-right panel_toolbox">
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li>
@ -174,8 +205,6 @@
</li>
</ul>
</li>
<li><a class="close-link"><i class="fa fa-close"></i></a>
</li>
</ul>
<div class="clearfix"></div>
</div>
@ -266,9 +295,10 @@
</div>
</div>
</div>
<!-- /disk usage -->
<!-- /node status -->
</div>
</div>
</div>
<!-- /page content -->
@ -349,9 +379,60 @@ function change_directory(directory){
})
}
</script>
<!-- On document ready -->
<script>
$(document).ready(function() {
$('#datatable').dataTable( {"bSort": false});
});
</script>
<!-- Easy pie chart -->
<script>
$(function() {
$('.chart').easyPieChart({
easing: 'easeOutBounce',
lineWidth: '6',
barColor: '#75BCDD',
onStep: function(from, to, percent) {
$(this.el).find('.percent').text(Math.round(percent));
}
});
var chart = window.chart = $('.chart').data('easyPieChart');
$('.js_update').on('click', function() {
chart.update(Math.random() * 200 - 100);
});
//hover and retain popover when on popover content
var originalLeave = $.fn.popover.Constructor.prototype.leave;
$.fn.popover.Constructor.prototype.leave = function(obj) {
var self = obj instanceof this.constructor ?
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
var container, timeout;
originalLeave.call(this, obj);
if (obj.currentTarget) {
container = $(obj.currentTarget).siblings('.popover')
timeout = self.timeout;
container.one('mouseenter', function() {
//We entered the actual popover call off the dogs
clearTimeout(timeout);
//Let's monitor popover content instead
container.one('mouseleave', function() {
$.fn.popover.Constructor.prototype.leave.call(self, self);
});
})
}
};
$('body').popover({
selector: '[data-popover]',
trigger: 'click hover',
delay: {
show: 50,
hide: 400
}
});
});
</script>

View File

@ -46,5 +46,5 @@
<%= render "partials/footer" %>
<%= javascript_include_tag 'footermanifest', 'data-turbolinks-track' => false %>
</body>
</html>
</body>
</html>

View File

@ -37,7 +37,8 @@
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Host Name <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="name" class="form-control col-md-7 col-xs-12" data-validate-length-range="10" data-validate-words="1" name="host_name" placeholder="Host Name" required="required" type="text">
<input id="name" class="form-control col-md-7 col-xs-12" data-validate-length-range="10" data-validate-words="1" name="host_name" placeholder="Host Name" required="required" type="text"
data-toggle="tooltip" data-placement="top" title="Put node's representative name">
</div>
</div>
@ -45,7 +46,8 @@
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="ip">Host IP <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="ip" class="form-control col-md-7 col-xs-12" data-validate-length-range="10" data-validate-words="1" name="host_ip" placeholder="127.0.0.1" required="required" type="text">
<input id="ip" class="form-control col-md-7 col-xs-12" data-validate-length-range="10" data-validate-words="1" name="host_ip" placeholder="127.0.0.1" required="required" type="text"
data-toggle="tooltip" data-placement="top" title="Put node's ip">
</div>
</div>
@ -53,13 +55,15 @@
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">User Name <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="occupation" type="text" name="user_name" required="required" data-validate-length-range="5,20" class="form-control col-md-7 col-xs-12">
<input id="occupation" type="text" name="user_name" placeholder="root" required="required" data-validate-length-range="5,20" class="form-control col-md-7 col-xs-12"
data-toggle="tooltip" data-placement="top" title="Put user name for ssh connection. client must have ssh key">
</div>
</div>
<div class="item form-group">
<label for="password" class="control-label col-md-3">User Password <span class="required">*</span></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="password" type="password" name="user_password" data-validate-length="1,10" class="form-control col-md-7 col-xs-12" required="required">
<input id="password" type="password" name="user_password" placeholder="secret" data-validate-length="1,10" class="form-control col-md-7 col-xs-12" required="required"
data-toggle="tooltip" data-placement="top" title="Put user password for ssh connection. client must have ssh key">
</div>
</div>
<!--<div class="ln_solid"></div>-->
@ -131,24 +135,24 @@
</div>
<!-- /page content -->
<script>
// initialize the validator function
validator.message['date'] = 'not a real date';
// initialize the validator function
validator.message['date'] = 'not a real date';
// validate a field on "blur" event, a 'select' on 'change' event & a '.reuired' classed multifield on 'keyup':
$('form')
.on('blur', 'input[required], input.optional, select.required', validator.checkField)
.on('change', 'select.required', validator.checkField)
.on('keypress', 'input[required][pattern]', validator.keypress);
// validate a field on "blur" event, a 'select' on 'change' event & a '.reuired' classed multifield on 'keyup':
$('form')
.on('blur', 'input[required], input.optional, select.required', validator.checkField)
.on('change', 'select.required', validator.checkField)
.on('keypress', 'input[required][pattern]', validator.keypress);
$('.multi.required')
.on('keyup blur', 'input', function() {
$('.multi.required')
.on('keyup blur', 'input', function() {
validator.checkField.apply($(this).siblings().last()[0]);
});
});
// bind the validation to the form submit event
//$('#send').click('submit');//.prop('disabled', true);
// bind the validation to the form submit event
//$('#send').click('submit');//.prop('disabled', true);
$('form').submit(function(e) {
$('form').submit(function(e) {
e.preventDefault();
var submit = true;
// evaluate the form using generic validaing
@ -159,16 +163,16 @@
if (submit)
this.submit();
return false;
});
});
/* FOR DEMO ONLY */
$('#vfields').change(function() {
/* FOR DEMO ONLY */
$('#vfields').change(function() {
$('form').toggleClass('mode2');
}).prop('checked', false);
}).prop('checked', false);
$('#alerts').change(function() {
$('#alerts').change(function() {
validator.defaults.alerts = (this.checked) ? false : true;
if (this.checked)
$('form .alert').remove();
}).prop('checked', false);
</script>
}).prop('checked', false);
</script>

View File

@ -10,7 +10,7 @@
<li class="">
<a href="javascript:;" class="user-profile" aria-expanded="false">
<span class="glyphicon glyphicon-user" aria-hidden="true"></span>
Hello, <%=current_user.username%> admin!
Hello, <%= current_user.username %> admin!
</a>
</li>
</ul>