Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web pages update #768

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
2 changes: 1 addition & 1 deletion server/app/controllers/analyses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def index
def show
logger.debug "analyses_controller.show enter"
# for pagination
per_page = 50
per_page = 200

@analysis = Analysis.find(params[:id])

Expand Down
14 changes: 11 additions & 3 deletions server/app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,33 @@ def dashboard
unless @current.nil?
# aggregate results of current analysis
aggregated_results = DataPoint.collection.aggregate(
[{ '$match' => { 'analysis_id' => @current.id } }, { '$group' => { '_id' => { 'analysis_id' => '$analysis_id', 'status' => '$status' }, count: { '$sum' => 1 } } }], :allow_disk_use => true
[{ '$match' => { 'analysis_id' => @current.id } }, { '$group' => { '_id' => { 'analysis_id' => '$analysis_id', 'status' => '$status', 'status_message' => '$status_message' }, count: { '$sum' => 1 } } }, { '$sort' => { '_id.status' => 1 } }], :allow_disk_use => true
)
end
# for js
cnt = 0
complete = 0
@js_res = []
@total = 0
@percent_complete = 0

unless @current.nil?
aggregated_results.each do |res|
# this is the format D3 wants the data in
rec = {}
rec['label'] = res['_id']['status']
rec['label'] = res['_id']['status'] + ' ' + res['_id']['status_message']
rec['label'].gsub!('completed completed', 'completed')
rec['label'] = rec['label'].rstrip
rec['value'] = res['count']
cnt += res['count'].to_i
@js_res << rec
if res['_id']['status'] == 'completed'
complete += res['count'].to_i
end
cnt += res['count'].to_i
end

@total = cnt
@percent_complete = 100.0 * complete / cnt
end
end
end
10 changes: 9 additions & 1 deletion server/app/views/analyses/show.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,13 @@
*/

$("#<%= @status %>simulations").html('
<%= escape_javascript render(:partial => "analyses/table", :locals => { users: @status_simulations, status: @status, :all_page => @all_page, :completed_page => @completed_page, :running_page => @running_page, :queued_page => @queued_page, :na_page => @na_page, :page => params[:page] }) %>
<%= escape_javascript render(:partial => "analyses/table",
:locals => { users: @status_simulations,
status: @status,
:all_page => @all_page,
:completed_page => @completed_page,
:running_page => @running_page,
:queued_page => @queued_page,
:na_page => @na_page,
:page => params[:page] }) %>
');
42 changes: 29 additions & 13 deletions server/app/views/pages/dashboard.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

<!-- vars for javascript -->
<%= javascript_tag do %>
statuses = <%= raw @js_res.to_json %>;
total = <%= raw @total.to_json %>;
const statuses = <%= raw @js_res.to_json %>;
const total = <%= raw @total.to_json %>;
<% end %>

<div class="row-fluid gray-header">
Expand Down Expand Up @@ -47,7 +47,18 @@
<% unless @current.start_time.nil? %><%= @current.start_time.strftime("%m/%d/%Y %H:%M:%S") %>
<% end %>
</p>
<p><% unless @current.end_time.nil? %>End: <%= @current.end_time.strftime("%m/%d/%Y %H:%M:%S") %><% end %></p>
<p>
<% if not @current.end_time.nil? %>
End: <%= @current.end_time.strftime("%m/%d/%Y %H:%M:%S") %>
<% elsif @percent_complete > 10 %>
<% etf = Time.at(([email protected]_time)/(@percent_complete/100.0)) %>
Estimated time to completion (H:M): <%= etf.strftime("%H:%M") %>
</p><p>Current time: <%= Time.now.strftime("%m/%d/%Y %H:%M:%S") %>
<% else %>
Estimated time to completion (H:M): ...calculating...
</p><p>Current time: <%= Time.now.strftime("%m/%d/%Y %H:%M:%S") %>
<% end %>
</p>
<p><% unless @current.end_time.nil? || @current.start_time.nil? %>Duration: <%= distance_of_time_in_words(@current.start_time, @current.end_time) %> <% end %></p>
<p>Status: <span class="label <% if @current.status == 'completed' %>label-success<% end %>"><%[email protected] %></span></p>
<p><span class="badge badge-info"><%= @current.data_points.count %></span> Datapoints</p>
Expand Down Expand Up @@ -139,11 +150,14 @@

<script type="text/javascript">
function make_pie_chart(data, cnt) {
var w = 230, //width
h = 230, //height
r = 110, //radius
radius = 115, //to center on svg
color = d3.scale.category20(); //builtin range of colors
var w = 230, //width
h = 230, //height
r = 110, //radius
radius = 115, //to center on svg
defaultColor = "#333333", //default color for values not in domain
color = d3.scale.ordinal() //builtin range of colors
.domain(["completed normal", "completed datapoint failure", "started", "queued", "na"]) //all possible labels
.range (["#449d44", "#d9534f", "#ec971f", "#428bca", "#5bc0de"]); //colors

var vis = d3.select("#pie")
.append("svg:svg") //create the SVG element inside the <body>
Expand All @@ -169,7 +183,7 @@

arcs.append("svg:path")
.attr("fill", function (d, i) {
return color(i);
return color(d.data.label) || defaultColor;
}) //set the color for each slice to be chosen from the color function defined above
.attr("d", arc); //this creates the actual SVG path using the associated data (pie) with the arc drawing function

Expand All @@ -188,7 +202,7 @@
.attr("width", w)
.attr("height", 100)
.selectAll("g")
.data(color.domain().slice())
.data(data)
.enter().append("g")
.attr("transform", function (d, i) {
return "translate(10," + (i * 20 + 20) + ")";
Expand All @@ -197,14 +211,16 @@
legend.append("rect")
.attr("width", 18)
.attr("height", 18)
.style("fill", color);
.style("fill", function (d) {
return color(d.label);
});

legend.append("text")
.attr("x", 24)
.attr("y", 9)
.attr("dy", ".35em")
.text(function (d, i) {
return data[i].label + " (" + data[i].value + ")";
.text(function (d) {
return d.label + " (" + d.value + ")";
});

var total = d3.select("#pie").append("svg")
Expand Down
14 changes: 14 additions & 0 deletions server/config/initializers/kaminari_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

Kaminari.configure do |config|
config.default_per_page = 200
# config.max_per_page = nil
# config.window = 4
# config.outer_window = 0
# config.left = 0
# config.right = 0
# config.page_method_name = :page
# config.param_name = :page
# config.max_pages = nil
# config.params_on_first_page = false
end
Loading