@@ -15,64 +15,94 @@ class Dashboard extends React.Component {
15
15
const wptUrl = this . props . profile . wptUrl
16
16
? ( this . props . profile . wptUrl . indexOf ( 'http' ) === 0 ? this . props . profile . wptUrl : null )
17
17
: '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
+ }
18
37
19
38
return (
20
39
< div className = "u-wrapper" >
21
40
< 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
+ />
28
49
29
50
< 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
+ />
36
59
37
60
< 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
+ />
44
70
45
71
< 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
+ />
60
88
61
89
< 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
+ />
76
106
77
107
{ videoFrames . length && wptUrl &&
78
108
< div className = "c-Section" >
0 commit comments