add ActiveAdmin
This commit is contained in:
4
app/views/admin/useful_links/_index.html.erb
Normal file
4
app/views/admin/useful_links/_index.html.erb
Normal file
@ -0,0 +1,4 @@
|
||||
<%= link_to 'List Email Addresses', admin_emails_path %>
|
||||
<br><br>
|
||||
<%= link_to 'List Users by Day (CSV)', admin_signups_path(:format => :csv) %>
|
||||
|
4
app/views/admin/users/emails.html.erb
Normal file
4
app/views/admin/users/emails.html.erb
Normal file
@ -0,0 +1,4 @@
|
||||
<% @users.each do |u| %>
|
||||
<%= u.email %><br>
|
||||
<% end %>
|
||||
|
2
app/views/admin/users/signups.csv.erb
Normal file
2
app/views/admin/users/signups.csv.erb
Normal file
@ -0,0 +1,2 @@
|
||||
<%= CSV.generate_line @csv_headers %><% @days.each do |day| %><% row = [] %><% @csv_headers.each do |attr| %><% row.push(day.to_json) %><% end %><%= CSV.generate_line(day).html_safe %><% end %>
|
||||
|
@ -45,7 +45,7 @@
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<% if is_admin? %>
|
||||
<% if current_admin_user.present? %>
|
||||
<div class="apps">
|
||||
<%= link_to scheduled_thinghttps_path do %>
|
||||
<%= image_tag 'scheduled_thinghttp.png', :size => '104x104' %>
|
||||
|
@ -41,7 +41,7 @@
|
||||
<%= d.submit t(:channel_create), :class => 'btn btn-primary' %>
|
||||
<% end %>
|
||||
|
||||
<% if is_admin? %>
|
||||
<% if current_admin_user.present? %>
|
||||
|
||||
<br><br><br>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
||||
<%= javascript_include_tag 'application' %>
|
||||
|
||||
<script type="text/javascript">
|
||||
@ -11,10 +11,10 @@
|
||||
|
||||
// converts date format from JSON
|
||||
function getChartDate(d) {
|
||||
// get the data using javascript's date object (year, month, day, hour, minute, second)
|
||||
// months in javascript start at 0, so remember to subtract 1 when specifying the month
|
||||
// offset in minutes is converted to milliseconds and subtracted so that chart's x-axis is correct
|
||||
return Date.UTC(d.substring(0,4), d.substring(5,7)-1, d.substring(8,10), d.substring(11,13), d.substring(14,16), d.substring(17,19)) - (myOffset * 60000);
|
||||
// get the data using javascript's date object (year, month, day, hour, minute, second)
|
||||
// months in javascript start at 0, so remember to subtract 1 when specifying the month
|
||||
// offset in minutes is converted to milliseconds and subtracted so that chart's x-axis is correct
|
||||
return Date.UTC(d.substring(0,4), d.substring(5,7)-1, d.substring(8,10), d.substring(11,13), d.substring(14,16), d.substring(17,19)) - (myOffset * 60000);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
@ -26,61 +26,51 @@
|
||||
var last_date;
|
||||
|
||||
// get the data with a webservice call
|
||||
|
||||
$.getJSON('<%= "#{@domain}channels/#{params[:channel_id]}/field/#{params[:id]}.json?callback=?&offset=0#{@qs}" %>', function(data) {
|
||||
|
||||
// if no access
|
||||
if (data == '-1') {
|
||||
$('#chart-container').append('<%= t(:chart_no_access) %>');
|
||||
}
|
||||
if (data == '-1') { $('#chart-container').append('<%= t(:chart_no_access) %>'); }
|
||||
|
||||
// iterate through each feed
|
||||
$.each(data.feeds, function() {
|
||||
var p = new Highcharts.Point();
|
||||
// set the proper values
|
||||
var v = this.field<%= params[:id] %>;
|
||||
p.x = getChartDate(this.created_at);
|
||||
p.y = parseFloat(v);
|
||||
// add location if possible
|
||||
if (this.location) { p.name = this.location; }
|
||||
// if a numerical value exists add it
|
||||
if (!isNaN(parseInt(v))<% if params[:max] %> && p.y <= <%= params[:max]%><% end %><% if params[:min] %> && p.y >= <%= params[:min]%><% end %>) { chartData.push(p); }
|
||||
});
|
||||
var p = new Highcharts.Point();
|
||||
// set the proper values
|
||||
var v = this.field<%= params[:id] %>;
|
||||
p.x = getChartDate(this.created_at);
|
||||
p.y = parseFloat(v);
|
||||
// add location if possible
|
||||
if (this.location) { p.name = this.location; }
|
||||
// if a numerical value exists add it
|
||||
if (!isNaN(parseInt(v))<% if params[:max] %> && p.y <= <%= params[:max]%><% end %><% if params[:min] %> && p.y >= <%= params[:min]%><% end %>) { chartData.push(p); }
|
||||
});
|
||||
|
||||
// specify the chart options
|
||||
var chartOptions = {
|
||||
chart: {
|
||||
chart: {
|
||||
renderTo: 'chart-container',
|
||||
defaultSeriesType: '<%= params[:type] ? "#{params[:type]}" : "line" %>',
|
||||
backgroundColor: '<%= params[:bgcolor] || "#ffffff" %>',
|
||||
events: {
|
||||
load: function() {
|
||||
//if dynamic and no "timeslice" options are set
|
||||
// GAK 02/16/2013 Let's try to add the last "average" slice if params[:average]
|
||||
|
||||
renderTo: 'chart-container',
|
||||
defaultSeriesType: '<%= params[:type] ? "#{params[:type]}" : "line" %>',
|
||||
backgroundColor: '<%= params[:bgcolor] || "#ffffff" %>',
|
||||
events: {
|
||||
load: function() {
|
||||
//if dynamic and no "timeslice" options are set
|
||||
// GAK 02/16/2013 Let's try to add the last "average" slice if params[:average]
|
||||
var url = '<%= "#{@domain}channels/#{params[:channel_id]}/feed/last.json?callback=?&offset=0&location=true#{@qs}" %>' ;
|
||||
if ("<%= params[:average] %>".length > 0) {
|
||||
url = '<%= "#{@domain}channels/#{params[:channel_id]}/feed/last_average.json?callback=?&offset=0&location=true&average=#{params[:average]}#{@qs}" %>' ;
|
||||
} else if ("<%= params[:median] %>".length > 0) {
|
||||
url = '<%= "#{@domain}channels/#{params[:channel_id]}/feed/last_median.json?callback=?&offset=0&location=true&median=#{params[:median]}#{@qs}" %>' ;
|
||||
} else if ("<%= params[:sum] %>".length > 0) {
|
||||
url = '<%= "#{@domain}channels/#{params[:channel_id]}/feed/last_sum.json?callback=?&offset=0&location=true&sum=#{params[:sum]}#{@qs}" %>' ;
|
||||
}
|
||||
|
||||
var url = '<%= "#{@domain}channels/#{params[:channel_id]}/feed/last.json?callback=?&offset=0&location=true#{@qs}" %>' ;
|
||||
if ("<%= params[:average] %>".length > 0) {
|
||||
url = '<%= "#{@domain}channels/#{params[:channel_id]}/feed/last_average.json?callback=?&offset=0&location=true&average=#{params[:average]}#{@qs}" %>' ;
|
||||
}
|
||||
else if ("<%= params[:median] %>".length > 0) {
|
||||
url = '<%= "#{@domain}channels/#{params[:channel_id]}/feed/last_median.json?callback=?&offset=0&location=true&median=#{params[:median]}#{@qs}" %>' ;
|
||||
}
|
||||
else if ("<%= params[:sum] %>".length > 0) {
|
||||
url = '<%= "#{@domain}channels/#{params[:channel_id]}/feed/last_sum.json?callback=?&offset=0&location=true&sum=#{params[:sum]}#{@qs}" %>' ;
|
||||
}
|
||||
|
||||
if ('true' === '<%= params[:dynamic] %>' && (
|
||||
'<%= params[:timescale] %>'.length < 1
|
||||
)) {
|
||||
// push data every 15 seconds
|
||||
|
||||
setInterval(function() {
|
||||
// get the data with a webservice call if we're just getting the last channel
|
||||
|
||||
$.getJSON(url, function(data) {
|
||||
// if data exists
|
||||
if (data && data.field<%= params[:id] %>) {
|
||||
if ('true' === '<%= params[:dynamic] %>' && ('<%= params[:timescale] %>'.length < 1)) {
|
||||
// push data every 15 seconds
|
||||
setInterval(function() {
|
||||
// get the data with a webservice call if we're just getting the last channel
|
||||
$.getJSON(url, function(data) {
|
||||
// if data exists
|
||||
if (data && data.field<%= params[:id] %>) {
|
||||
|
||||
var p = new Highcharts.Point();
|
||||
// set the proper values
|
||||
@ -92,7 +82,7 @@
|
||||
if (data.location) { p.name = data.location; }
|
||||
// get the last date if possible
|
||||
if (dynamicChart.series[0].data.length > 0) {
|
||||
last_date = dynamicChart.series[0].data[dynamicChart.series[0].data.length-1].x;
|
||||
last_date = dynamicChart.series[0].data[dynamicChart.series[0].data.length-1].x;
|
||||
}
|
||||
var shift = <%= (@push=='true') ? 'true' : 'false' %> ; //default for shift
|
||||
|
||||
@ -101,19 +91,17 @@
|
||||
var results = <%= (@results) ? @results : 60 %>;
|
||||
|
||||
if ( results && dynamicChart.series[0].data.length+1 >= results ) {
|
||||
shift = true ;
|
||||
shift = true ;
|
||||
}
|
||||
// if a numerical value exists and it is a new date, add it
|
||||
if (!isNaN(parseInt(v)) && (p.x != last_date)<% if params[:max] %> && p.y <= <%= params[:max]%><% end %><% if params[:min] %> && p.y >= <%= params[:min]%><% end %>) {
|
||||
dynamicChart.series[0].addPoint(p, true, shift);
|
||||
dynamicChart.series[0].addPoint(p, true, shift);
|
||||
}
|
||||
else {
|
||||
dynamicChart.series[0].data[dynamicChart.series[0].data.length-1].update(p);
|
||||
dynamicChart.series[0].data[dynamicChart.series[0].data.length-1].update(p);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}, 15000);
|
||||
}
|
||||
@ -169,9 +157,9 @@
|
||||
enabled: false
|
||||
},
|
||||
series: [{
|
||||
name: data.channel.field<%= params[:id] %>
|
||||
}]
|
||||
};
|
||||
name: data.channel.field<%= params[:id] %>
|
||||
}]
|
||||
};
|
||||
|
||||
// add the data to the chart
|
||||
chartOptions.series[0].data = chartData;
|
||||
@ -184,14 +172,16 @@
|
||||
// draw the chart
|
||||
var dynamicChart = new Highcharts.Chart(chartOptions);
|
||||
|
||||
});
|
||||
}); // end getJSON ajax call
|
||||
|
||||
});
|
||||
}); // end document.ready
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body style='background-color: <%= params[:bgcolor] ? params[:bgcolor] : 'white' %>;'>
|
||||
<div id="chart-container" style="width: <%= params[:width] ? params[:width].to_i - 25 : @width.to_i - 25 %>px; height: <%= params[:height] ? params[:height].to_i - 25 : @height.to_i - 25 %>px;"></div>
|
||||
<div id="chart-container" style="width: <%= params[:width] ? params[:width].to_i - 25 : @width.to_i - 25 %>px; height: <%= params[:height] ? params[:height].to_i - 25 : @height.to_i - 25 %>px; display: table-cell; vertical-align: middle;">
|
||||
<%= image_tag 'ajax-loader.gif', :style => "margin: auto; display: block;" %>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -10,11 +10,10 @@
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post, :class => 'form-horizontal' }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
<input name='userlogin' class='userlogin' />
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 col-xs-3 control-label"><%= t(:email) %></label>
|
||||
<div class="col-sm-9 col-xs-9"><%= f.text_field :login, :class => 'form-control' %></div>
|
||||
<div class="col-sm-9 col-xs-9"><%= f.text_field :email, :class => 'form-control' %></div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -30,6 +29,6 @@
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
document.getElementById('user_login').focus();
|
||||
document.getElementById('user_email').focus();
|
||||
</script>
|
||||
|
||||
|
@ -34,6 +34,9 @@
|
||||
<li><%= link_to t(:profile_edit), edit_profile_path %></li>
|
||||
</ul>
|
||||
</li>
|
||||
<% if current_admin_user.present? %>
|
||||
<li><%= link_to t(:admin), "/admin" %></li>
|
||||
<% end %>
|
||||
|
||||
<% else %>
|
||||
<li <%= "class=active" if @menu == 'channels' %>><%= link_to t(:channels), public_channels_path %></li>
|
||||
|
Reference in New Issue
Block a user