Skip to content
This repository was archived by the owner on Mar 24, 2023. It is now read-only.

Commit fa9d240

Browse files
committed
Add PageSpeed link and onClick descriptions
1 parent 87f2f09 commit fa9d240

File tree

5 files changed

+96
-65
lines changed

5 files changed

+96
-65
lines changed

_includes/listAllProfiles

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{% capture currentProfile %}{% include getCurrentProfile %}{% endcapture %}[{% for profile in site.profiles %}{slug:{{ profile.slug | jsonify }},name:{{ profile.name | jsonify }},wptUrl:{{ profile.wptUrl | jsonify }},budgets:{{ profile.budgets | jsonify }}{% if profile.slug == currentProfile %},active:true{% endif %}},{% endfor %}]
1+
{% capture currentProfile %}{% include getCurrentProfile %}{% endcapture %}[{% for profile in site.profiles %}{slug:{{ profile.slug | jsonify }},name:{{ profile.name | jsonify }},wptUrl:{{ profile.wptUrl | jsonify }},parameters:{{ profile.parameters | jsonify }},budgets:{{ profile.budgets | jsonify }}{% if profile.slug == currentProfile %},active:true{% endif %}},{% endfor %}]

_sass/components/_components.Chart.scss

+6
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,10 @@
2121
text-align: center;
2222
content: 'We need some more tests results to draw a chart.'
2323
}
24+
}
25+
26+
.c-Chart__footer {
27+
text-align: center;
28+
font-size: 13px;
29+
opacity: 0.5;
2430
}

app/Chart.js

+6-11
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,7 @@ class Chart extends React.Component {
104104
budgets: this.props.budgets
105105
},
106106
options: {
107-
onClick: function (event, data) {
108-
if (!data.length || !wptUrl) return
109-
110-
const index = data[0]._index
111-
const timestamp = timestamps[index]
112-
const result = results[timestamp]
113-
const testUrl = `${wptUrl}/result/${result.id}/`
114-
115-
window.open(testUrl, '_blank')
116-
},
107+
onClick: this.props.onClick,
117108
scales: {
118109
xAxes: [{
119110
type: 'time',
@@ -168,10 +159,14 @@ class Chart extends React.Component {
168159

169160
render() {
170161
const placeholderClass = (Object.keys(this.props.results) < 2) ? ' c-Chart--placeholder' : ''
171-
162+
172163
return (
173164
<div className={`c-Chart${placeholderClass}`}>
174165
<canvas id={`chart${this.props.id}`} width="400" height="250"></canvas>
166+
167+
{this.props.onClickDescription &&
168+
<p className="c-Chart__footer">{this.props.onClickDescription}</p>
169+
}
175170
</div>
176171
)
177172
}

app/Dashboard.js

+76-46
Original file line numberDiff line numberDiff line change
@@ -15,64 +15,94 @@ class Dashboard extends React.Component {
1515
const wptUrl = this.props.profile.wptUrl
1616
? (this.props.profile.wptUrl.indexOf('http') === 0 ? this.props.profile.wptUrl : null)
1717
: 'https://www.webpagetest.org'
18+
const profileUrl = this.props.profile.parameters.url
19+
20+
const onClickPagespeed = function (event, data) {
21+
const encodedUrl = encodeURIComponent(profileUrl)
22+
const insightsUrl = `https://developers.google.com/speed/pagespeed/insights/?url=${encodedUrl}`
23+
24+
window.open(insightsUrl, '_blank')
25+
}
26+
27+
const onClickWpt = function (event, data) {
28+
if (!data.length || !wptUrl) return
29+
30+
const index = data[0]._index
31+
const timestamp = timestamps[index]
32+
const result = results[timestamp]
33+
const testUrl = `${wptUrl}/result/${result.id}/`
34+
35+
window.open(testUrl, '_blank')
36+
}
1837

1938
return (
2039
<div className="u-wrapper">
2140
<Section {...this.props}
22-
id="loadTimes"
23-
lastResult={lastResult}
24-
metrics={['TTFB', 'loadTime', 'fullyLoaded']}
25-
title="Load times"
26-
yLabel="Time (seconds)"
27-
wptUrl={wptUrl}/>
41+
id="loadTimes"
42+
lastResult={lastResult}
43+
metrics={['TTFB', 'loadTime', 'fullyLoaded']}
44+
onClick={onClickWpt}
45+
onClickDescription="Click on a data point to see the corresponding WebPageTest result"
46+
title="Load times"
47+
yLabel="Time (seconds)"
48+
/>
2849

2950
<Section {...this.props}
30-
id="rendering"
31-
lastResult={lastResult}
32-
metrics={['firstPaint', 'SpeedIndex', 'visualComplete']}
33-
title="Rendering"
34-
yLabel="Time (seconds)"
35-
wptUrl={wptUrl}/>
51+
id="rendering"
52+
lastResult={lastResult}
53+
onClick={onClickWpt}
54+
onClickDescription="Click on a data point to see the WebPageTest result"
55+
metrics={['firstPaint', 'SpeedIndex', 'visualComplete']}
56+
title="Rendering"
57+
yLabel="Time (seconds)"
58+
/>
3659

3760
<Section {...this.props}
38-
id="pagespeed"
39-
lastResult={lastResult}
40-
maxValue={100}
41-
metrics={['pagespeed']}
42-
title="Google PageSpeed"
43-
yLabel="Score"/>
61+
id="pagespeed"
62+
lastResult={lastResult}
63+
maxValue={100}
64+
metrics={['pagespeed']}
65+
onClick={onClickPagespeed}
66+
onClickDescription="Click on a data point to see the Google PageSpeed Insights report"
67+
title="Google PageSpeed"
68+
yLabel="Score"
69+
/>
4470

4571
<Section {...this.props}
46-
id="contentBreakdownBytes"
47-
lastResult={lastResult}
48-
metrics={[
49-
'breakdown.html.bytes',
50-
'breakdown.js.bytes',
51-
'breakdown.css.bytes',
52-
'breakdown.image.bytes',
53-
'breakdown.flash.bytes',
54-
'breakdown.font.bytes',
55-
'breakdown.other.bytes'
56-
]}
57-
title="Content breakdown (size)"
58-
yLabel="Traffic (kilobytes)"
59-
wptUrl={wptUrl}/>
72+
id="contentBreakdownBytes"
73+
lastResult={lastResult}
74+
onClick={onClickWpt}
75+
onClickDescription="Click on a data point to see the WebPageTest result"
76+
metrics={[
77+
'breakdown.html.bytes',
78+
'breakdown.js.bytes',
79+
'breakdown.css.bytes',
80+
'breakdown.image.bytes',
81+
'breakdown.flash.bytes',
82+
'breakdown.font.bytes',
83+
'breakdown.other.bytes'
84+
]}
85+
title="Content breakdown (size)"
86+
yLabel="Traffic (kilobytes)"
87+
/>
6088

6189
<Section {...this.props}
62-
id="contentBreakdownRequests"
63-
lastResult={lastResult}
64-
metrics={[
65-
'breakdown.html.requests',
66-
'breakdown.js.requests',
67-
'breakdown.css.requests',
68-
'breakdown.image.requests',
69-
'breakdown.flash.requests',
70-
'breakdown.font.requests',
71-
'breakdown.other.requests'
72-
]}
73-
title="Content breakdown (requests)"
74-
yLabel="Requests"
75-
wptUrl={wptUrl}/>
90+
id="contentBreakdownRequests"
91+
lastResult={lastResult}
92+
onClick={onClickWpt}
93+
onClickDescription="Click on a data point to see the WebPageTest result"
94+
metrics={[
95+
'breakdown.html.requests',
96+
'breakdown.js.requests',
97+
'breakdown.css.requests',
98+
'breakdown.image.requests',
99+
'breakdown.flash.requests',
100+
'breakdown.font.requests',
101+
'breakdown.other.requests'
102+
]}
103+
title="Content breakdown (requests)"
104+
yLabel="Requests"
105+
/>
76106

77107
{videoFrames.length && wptUrl &&
78108
<div className="c-Section">

bundle.js

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)