Skip to content

Commit aba7bec

Browse files
committed
Fixing graph loading issues from upstream:
Implement upstream fixes suggested my mkouhei: - OWASP/railsgoat#438 - OWASP/railsgoat#439 - OWASP/railsgoat#440
1 parent 34bcd89 commit aba7bec

File tree

5 files changed

+245
-271
lines changed

5 files changed

+245
-271
lines changed
Lines changed: 41 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,46 @@
1-
<div id="column_chart"></div>
2-
<!-- Google Visualization JS -->
3-
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
1+
<div id="column_chart"></div>
2+
<!-- Google Visualization JS -->
43

54
<script type="text/javascript">
6-
// google.load("visualization", "1", {packages:["corechart"]});
7-
8-
5+
google.charts.load('current', {'packages':['corechart']});
6+
google.charts.setOnLoadCallback(drawChart3);
97

10-
function drawChart3() {
11-
var data = google.visualization.arrayToDataTable([
12-
['Year', 'Visitors', 'Orders', 'Income', 'Expenses'],
13-
['2007', 300, 800, 900, 300],
14-
['2008', 1170, 860, 1220, 564],
15-
['2009', 260, 1120, 2870, 2340],
16-
['2010', 1030, 540, 3430, 1200],
17-
['2011', 200, 700, 1700, 770],
18-
['2012', 1170, 2160, 3920, 800], ]);
8+
function drawChart3() {
9+
var data = google.visualization.arrayToDataTable([
10+
['Year', 'Visitors', 'Orders', 'Income', 'Expenses'],
11+
['2007', 300, 800, 900, 300],
12+
['2008', 1170, 860, 1220, 564],
13+
['2009', 260, 1120, 2870, 2340],
14+
['2010', 1030, 540, 3430, 1200],
15+
['2011', 200, 700, 1700, 770],
16+
['2012', 1170, 2160, 3920, 800], ]);
1917

20-
var options = {
21-
width: 'auto',
22-
height: '160',
23-
backgroundColor: 'transparent',
24-
colors: ['#b5799e', '#579da9', '#e26666', '#1e825e', '#dba26b'],
25-
tooltip: {
26-
textStyle: {
27-
color: '#666666',
28-
fontSize: 11
29-
},
30-
showColorCode: true
31-
},
32-
legend: {
33-
textStyle: {
34-
color: 'black',
35-
fontSize: 12
36-
}
37-
},
38-
chartArea: {
39-
left: 60,
40-
top: 10,
41-
height: '80%'
42-
},
43-
};
18+
var options = {
19+
width: 'auto',
20+
height: '160',
21+
backgroundColor: 'transparent',
22+
colors: ['#b5799e', '#579da9', '#e26666', '#1e825e', '#dba26b'],
23+
tooltip: {
24+
textStyle: {
25+
color: '#666666',
26+
fontSize: 11
27+
},
28+
showColorCode: true
29+
},
30+
legend: {
31+
textStyle: {
32+
color: 'black',
33+
fontSize: 12
34+
}
35+
},
36+
chartArea: {
37+
left: 60,
38+
top: 10,
39+
height: '80%'
40+
},
41+
};
4442

45-
var chart = new google.visualization.ColumnChart(document.getElementById('column_chart'));
46-
chart.draw(data, options);
47-
}
48-
49-
50-
$(document).ready(
51-
drawChart3()
52-
);
53-
54-
</script>
43+
var chart = new google.visualization.ColumnChart(document.getElementById('column_chart'));
44+
chart.draw(data, options);
45+
}
46+
</script>

app/views/dashboard/home.html.erb

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,38 @@
11
<div class="dashboard-wrapper">
22
<div class="main-container">
33
<div class="row-fluid">
4-
<div class="span12"> <!--begin span12 -->
5-
<div class="widget">
6-
<div class="widget-header">
7-
<div class="title">
8-
<span class="fs1" aria-hidden="true" data-icon="&#xe0a0;"></span> Current Statistics
9-
</div>
10-
<!-- Begin Title Buttons-->
11-
<div class="tools pull-right">
12-
<div class="btn-group">
13-
<a id="change_to_bar_graph" class="btn btn-small">
14-
<span data-icon="&#xe14b;"></span>
15-
</a>
16-
<a id="change_to_pie_charts" class="btn btn-small">
17-
<span data-icon="&#xe096;"></span>
18-
</a>
19-
</div>
20-
</div>
21-
<!-- End Title Buttons-->
22-
</div>
23-
<div id="charts_body" class="widget-body">
24-
<%#= render partial: "dashboard_stats" %>
25-
</div>
26-
<div class="clearfix">
27-
</div>
28-
</div>
29-
</div>
30-
<center><b>Need help using this portal? Check out the <a href="doc?doc=README_FOR_APP">Readme</a></b></center>
31-
</div> <!-- end span12 -->
4+
<div class="span12"> <!--begin span12 -->
5+
<div class="widget">
6+
<div class="widget-header">
7+
<div class="title">
8+
<span class="fs1" aria-hidden="true" data-icon="&#xe0a0;"></span> Current Statistics
9+
</div>
10+
<!-- Begin Title Buttons-->
11+
<div class="tools pull-right">
12+
<div class="btn-group">
13+
<button id="change_to_bar_graph" class="btn btn-small">
14+
<span aria-label="change to bar graph" data-icon="&#xe14b;"></span>
15+
</button>
16+
<button id="change_to_pie_charts" class="btn btn-small">
17+
<span aria-label="change to pie charts" data-icon="&#xe096;"></span>
18+
</button>
19+
</div>
20+
</div>
21+
<!-- End Title Buttons-->
22+
</div>
23+
<div id="charts_body" class="widget-body">
24+
<%#= render partial: "dashboard_stats" %>
25+
</div>
26+
<div class="clearfix">
27+
</div>
28+
</div>
29+
</div> <!-- end span12 -->
3230
</div>
3331
</div>
3432
</div>
3533

36-
37-
38-
34+
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
3935
<script type="text/javascript">
40-
4136
function makeActive(){
4237
$('li[id="home"]').addClass('active');
4338
};
@@ -60,7 +55,3 @@ $(document).ready(
6055
$("#charts_body").load(<%= sanitize change_graph_dashboard_index_path(:graph => "pie_charts").inspect %>)
6156
);
6257
</script>
63-
64-
65-
66-

app/views/layouts/application.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<html>
33
<head>
44
<title>RailsGoat</title>
5-
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6-
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
5+
<%= stylesheet_link_tag "application", media: "all" %>
6+
<%= javascript_include_tag "application" %>
77
<%#= csrf_meta_tags %> <!-- <~ What is this for? I hear it helps w/ JS and Sea-surfing.....whatevz -->
88
<!-- bootstrap css -->
99
<%

0 commit comments

Comments
 (0)