Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

refactor controller and view

  • Loading branch information...
commit 47794ec6f04e07374f8917739a885c4eee64e73d 1 parent e2cafd1
@marutosi marutosi authored
View
17 app/controllers/ratios_controller.rb
@@ -3,8 +3,19 @@ class RatiosController < ApplicationController
include IndicatorsLogic
def index
- @project = Project.find(params[:id])
- @proj_or_vers_data = IndicatorsLogic::retrive_data(@project)
- @proj_or_vers_indicators = IndicatorsLogic::calc_indicators(@project, @proj_or_vers_data[0], @proj_or_vers_data[1])
+ project = Project.find(params[:id])
+ data = IndicatorsLogic::retrive_data(project)
+ @evms = []
+ @evms << {
+ :name => project.name,
+ :indicators => IndicatorsLogic::calc_indicators(project, data[0], data[1])
+ }
+ project.versions.where(:status=>"open").each do |my_version|
+ data = IndicatorsLogic::retrive_data(my_version)
+ @evms << {
+ :name => my_version.name,
+ :indicators => IndicatorsLogic::calc_indicators(my_version, data[0], data[1])
+ }
+ end
end
end
View
20 app/views/ratios/_bottom_js.html.erb
@@ -1,6 +1,6 @@
-<div id="chart <%= name %>" class="goocharts"></div>
-<div id="gauge_cpi <%= name %>" class="googauges"></div>
-<div id="gauge_spi <%= name %>" class="googauges"></div>
+<div id="chart <%= evm[:name] %>" class="goocharts"></div>
+<div id="gauge_cpi <%= evm[:name] %>" class="googauges"></div>
+<div id="gauge_spi <%= evm[:name] %>" class="googauges"></div>
<div style="clear:both;"></div>
<%= javascript_tag do %>
drawChart();
@@ -8,15 +8,15 @@
drawSpi();
function drawChart() {
- var data = new google.visualization.arrayToDataTable(<%=raw @proj_or_vers_indicators[0].to_json %>);
+ var data = new google.visualization.arrayToDataTable(<%= raw evm[:indicators][0].to_json %>);
var options = {
- title: 'EVM Indicators - <%= name %>',
+ title: 'EVM Indicators - <%= evm[:name] %>',
series: {0:{color: 'red'},
1:{color: 'blue'},
2:{color: 'green'}},
vAxis: {title: 'Hours', titleTextStyle: {color: 'red'}}
};
- var chart = new google.visualization.LineChart(document.getElementById("chart <%= name %>"));
+ var chart = new google.visualization.LineChart(document.getElementById("chart <%= evm[:name] %>"));
chart.draw(data, options);
}
@@ -24,7 +24,7 @@
// Create and populate the data table.
var data_gauge = new google.visualization.arrayToDataTable([
['Label', 'Value'],
- ['CPI', <%= (@proj_or_vers_indicators[1] * 1000).round / 1000.0 %>]
+ ['CPI', <%= (evm[:indicators][1] * 1000).round / 1000.0 %>]
]);
var options_g = {
redFrom: 0, redTo: 0.85,
@@ -34,7 +34,7 @@
min:0, max:2
};
// Create and draw the visualization.
- var gauge= new google.visualization.Gauge(document.getElementById("gauge_cpi <%= name %>"));
+ var gauge= new google.visualization.Gauge(document.getElementById("gauge_cpi <%= evm[:name] %>"));
gauge.draw(data_gauge, options_g);
}
@@ -42,7 +42,7 @@
// Create and populate the data table.
var data_gauges = new google.visualization.arrayToDataTable([
['Label', 'Value'],
- ['SPI', <%= (@proj_or_vers_indicators[2] * 1000).round / 1000.0 %>]
+ ['SPI', <%= (evm[:indicators][2] * 1000).round / 1000.0 %>]
]);
var options_gs = {
redFrom: 0, redTo: 0.85,
@@ -52,7 +52,7 @@
min:0, max:2
};
// Create and draw the visualization.
- var gauge= new google.visualization.Gauge(document.getElementById("gauge_spi <%= name %>"));
+ var gauge= new google.visualization.Gauge(document.getElementById("gauge_spi <%= evm[:name] %>"));
gauge.draw(data_gauges, options_gs);
}
<% end %>
View
10 app/views/ratios/index.html.erb
@@ -6,13 +6,7 @@
<%= stylesheet_link_tag 'ratios', :plugin => 'redmine_evm' %>
<% end %>
-<!--- Load javascript functions --->
-<%= render :partial=>"ratios/bottom_js", :locals => {:name => @project.name} %>
-
-<!--- Iterate through versions and render indicators --->
-<% @project.versions.where(:status=>"open").each do |my_version| %>
+<% @evms.each do |evm| %>
<%= render "ratios/head_js" %>
- <% proj_or_vers_data = IndicatorsLogic::retrive_data(my_version) %>
- <% @proj_or_vers_indicators = IndicatorsLogic::calc_indicators(my_version, proj_or_vers_data[0], proj_or_vers_data[1]) %>
- <%= render :partial=>"ratios/bottom_js", :locals => {:name => my_version.name} %>
+ <%= render :partial=>"ratios/bottom_js", :locals => {:evm => evm} %>
<% end %>

1 comment on commit 47794ec

@gamafranco
Owner

For some reason, the main menu disappeared on the EVM view with this commit. Just made a git bisect.

Please sign in to comment.
Something went wrong with that request. Please try again.