Update for dashboard and Fix site.rake,new_site.rake for missing "menu_enabled_for"
This commit is contained in:
		
							parent
							
								
									9d7af2ccac
								
							
						
					
					
						commit
						7401a6ae59
					
				| 
						 | 
				
			
			@ -5,42 +5,62 @@
 | 
			
		|||
        <%= t(:server_usage) %>
 | 
			
		||||
    </h2>
 | 
			
		||||
</div>
 | 
			
		||||
<div class="box-content" style='overflow: hidden;'>
 | 
			
		||||
    <span id="cpu_usage" style="display:inline-block;margin: 0 auto"></span>
 | 
			
		||||
    <span id="mem_usage" style="display:inline-block;margin: 0 auto"></span>
 | 
			
		||||
    <span id="disk_usage" style="display:inline-block;margin: 0 auto"></span>
 | 
			
		||||
<div class="box-content" style='overflow: hidden; text-align:center;'>
 | 
			
		||||
    <div id="cpu_usage" class="pull-left" style="width:200px; height:160px; display: inline-block;"></div>
 | 
			
		||||
    <div id="mem_usage" style="width:200px; height:160px; display: inline-block;"></div>
 | 
			
		||||
    <div id="disk_usage" class="pull-right" style="width:200px; height:160px; display: inline-block;"></div>
 | 
			
		||||
</div>
 | 
			
		||||
<script type="text/javascript">
 | 
			
		||||
google.load('visualization', '1', {packages:['gauge']});
 | 
			
		||||
 | 
			
		||||
var UsageTpye = {'CPU':{'fn':'get_cpu_usage','chart':null,'id':'cpu_usage','interval':2000},
 | 
			
		||||
                                'Mem':{'fn':'get_mem_usage','chart':null,'id':'mem_usage','interval':5000},
 | 
			
		||||
                                'Disk':{'fn':'get_disk_usage','chart':null,'id':'disk_usage','interval':30000}};
 | 
			
		||||
var Gages = { 'CPU':{
 | 
			
		||||
                          'JustGage': null,
 | 
			
		||||
                          'container': 'cpu_usage',
 | 
			
		||||
                          'title': 'CPU Usage',
 | 
			
		||||
                          'fn': 'get_cpu_usage',
 | 
			
		||||
                          'update_interval': 2000
 | 
			
		||||
                        },
 | 
			
		||||
                        'Mem':{
 | 
			
		||||
                          'JustGage': null,
 | 
			
		||||
                          'container': 'mem_usage',
 | 
			
		||||
                          'title': 'Memory Usage',
 | 
			
		||||
                          'fn': 'get_mem_usage',
 | 
			
		||||
                          'update_interval': 10000
 | 
			
		||||
                        },
 | 
			
		||||
                        'Disk':{
 | 
			
		||||
                          'JustGage': null,
 | 
			
		||||
                          'container': 'disk_usage',
 | 
			
		||||
                          'title': 'Disk Usage',
 | 
			
		||||
                          'fn': 'get_disk_usage',
 | 
			
		||||
                          'update_interval': 30000
 | 
			
		||||
                        }
 | 
			
		||||
                      };
 | 
			
		||||
 | 
			
		||||
$(function () {
 | 
			
		||||
    $.each(UsageTpye,function(type,option){
 | 
			
		||||
        option['chart'] = new google.visualization.Gauge(document.getElementById(option['id']));
 | 
			
		||||
        update_usage(type,option);
 | 
			
		||||
    $.each(Gages,function(id,Gage){
 | 
			
		||||
      Gage['JustGage'] = new JustGage({
 | 
			
		||||
          id: Gage['container'], 
 | 
			
		||||
          value: 0, 
 | 
			
		||||
          min: 0,
 | 
			
		||||
          max: 100,
 | 
			
		||||
          title: Gage['title'],
 | 
			
		||||
          shadowVerticalOffset: 10,
 | 
			
		||||
          levelColors: ['#39D824','#FFC33F','#F51F1F'],
 | 
			
		||||
          titleFontColor: '#666',
 | 
			
		||||
          valueFontColor: '#666',
 | 
			
		||||
          labelFontColor: '#666',
 | 
			
		||||
          label: '%',
 | 
			
		||||
          refreshAnimationTime: 200
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
        setInterval(function() { update_usage(type,option); }, option['interval']);
 | 
			
		||||
       update_usage(Gage);
 | 
			
		||||
 | 
			
		||||
       setInterval(function() { update_usage(Gage); }, Gage['update_interval']);
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
function update_usage(type,option){
 | 
			
		||||
    $.get('/admin/dashboards/'+option['fn'],function(usage){
 | 
			
		||||
        var data = google.visualization.arrayToDataTable([
 | 
			
		||||
          ['Label', 'Value'],
 | 
			
		||||
          [type, parseInt(usage)]
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        var options = {
 | 
			
		||||
          width: 400, height: 180,
 | 
			
		||||
          redFrom: 80, redTo: 100,
 | 
			
		||||
          yellowFrom:60, yellowTo: 80,
 | 
			
		||||
          minorTicks: 5
 | 
			
		||||
        };
 | 
			
		||||
        
 | 
			
		||||
        option['chart'].draw(data, options);
 | 
			
		||||
    });
 | 
			
		||||
function update_usage(Gage){
 | 
			
		||||
  $.get('/admin/dashboards/'+Gage['fn'],function(usage){
 | 
			
		||||
    Gage['JustGage'].refresh(parseInt(usage));
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			@ -16,19 +16,3 @@
 | 
			
		|||
                     } %>
 | 
			
		||||
    </div>
 | 
			
		||||
</div>
 | 
			
		||||
<script type="text/javascript">
 | 
			
		||||
    renderLineChart = function (element, series, opts) {
 | 
			
		||||
      waitForLoaded(function () {
 | 
			
		||||
        var options = jsOptions(series, opts);
 | 
			
		||||
        var data = createDataTable(series, "datetime");
 | 
			
		||||
        var formatter = new google.visualization.DateFormat({ 
 | 
			
		||||
             pattern: options.pattern 
 | 
			
		||||
        }); 
 | 
			
		||||
        formatter.format(data, 0);
 | 
			
		||||
        var chart = new google.visualization.LineChart(element);
 | 
			
		||||
        resize(function () {
 | 
			
		||||
          chart.draw(data, options);
 | 
			
		||||
        });
 | 
			
		||||
      });
 | 
			
		||||
    };
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,15 +1,18 @@
 | 
			
		|||
<%= javascript_include_tag "//www.google.com/jsapi", "chartkick" %>
 | 
			
		||||
<%= javascript_include_tag "/static/justgage.1.0.1.min.js" %>
 | 
			
		||||
<%= javascript_include_tag "/static/raphael.2.1.0.min.js" %>
 | 
			
		||||
 | 
			
		||||
<section id="main-wrap">
 | 
			
		||||
  <div class="wrap-inner initial">
 | 
			
		||||
  <div class="row-fluid">
 | 
			
		||||
      <% if is_admin? %>
 | 
			
		||||
      <div class="box span6">
 | 
			
		||||
      <div class="box span7">
 | 
			
		||||
        <div id='server_loading'>
 | 
			
		||||
          <%= render 'server_loading' %>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
      <% end %>
 | 
			
		||||
      <div class="box span6">  
 | 
			
		||||
      <div class="box span5">  
 | 
			
		||||
        <div id='traffic'>
 | 
			
		||||
          <%= render 'traffic' %>
 | 
			
		||||
        </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -93,7 +93,7 @@ def unzip_design(file, zip_name)
 | 
			
		|||
    site.design = design
 | 
			
		||||
    site.save
 | 
			
		||||
    theme = design.themes.first
 | 
			
		||||
    home = Page.new(  :design_id => design.id, :name => 'home', :is_published => true, :theme_id => theme.id, :menu_enabled_for => [] )
 | 
			
		||||
    home = Page.new(  :design_id => design.id, :name => 'home', :is_published => true, :theme_id => nil, :menu_enabled_for => {"zh_tw"=>"true", "en"=>"true"} )
 | 
			
		||||
 | 
			
		||||
    home.title_translations = {"zh_tw"=>"首頁", "en"=>"Home"}
 | 
			
		||||
    home.save 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ namespace :site do
 | 
			
		|||
    site.design = design
 | 
			
		||||
    site.save
 | 
			
		||||
    theme = design.themes.first
 | 
			
		||||
    home = Page.new(  :design_id => design.id, :name => 'home', :is_published => true, :theme_id => theme.id, :menu_enabled_for => [] )
 | 
			
		||||
    home = Page.new(  :design_id => design.id, :name => 'home', :is_published => true, :theme_id => nil, :menu_enabled_for => {"zh_tw"=>"true", "en"=>"true"} )
 | 
			
		||||
 | 
			
		||||
    home.title_translations = {"zh_tw"=>"首頁", "en"=>"Home"}
 | 
			
		||||
    home.save 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Loading…
	
		Reference in New Issue