Krinkle has uploaded a new change for review.
https://gerrit.wikimedia.org/r/205766
Change subject: performance: Implement hash permalinks for tabs
......................................................................
performance: Implement hash permalinks for tabs
Follows-up 9de0ae8.
Change-Id: I6e46dcd42d3ca39c67bef46a99bb38e603a456e1
---
M files/performance/index.html
M files/performance/js/app.js
2 files changed, 28 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/66/205766/1
diff --git a/files/performance/index.html b/files/performance/index.html
index 5281174..ae7c252 100644
--- a/files/performance/index.html
+++ b/files/performance/index.html
@@ -2,7 +2,7 @@
<html lang=en>
<meta charset=utf-8>
<title>Coal :: Wikimedia Performance Metrics</title>
- <link href='//fonts.googleapis.com/css?family=Open+Sans:400,300,700'
rel=stylesheet>
+ <link href="//fonts.googleapis.com/css?family=Open+Sans:400,300,700"
rel=stylesheet>
<link href=css/metricsgraphics.css rel=stylesheet>
<link href=css/bootstrap.3.3.4.min.css rel=stylesheet>
<style>
@@ -19,10 +19,10 @@
<div id=container class=container>
<div id=content-body>
<ul class="nav nav-justified nav-tabs">
- <li role=presentation id=hour class="active"><a href="#">Past
Hour</a></li>
- <li role=presentation id=day><a href="#">Past Day</a></li>
- <li role=presentation id=week><a href="#">Past Week</a></li>
- <li role=presentation id=month><a href="#">Past Month</a></li>
+ <li role=presentation id=hour class="active"><a href="#!/hour">Past
Hour</a></li>
+ <li role=presentation id=day><a href="#!/day">Past Day</a></li>
+ <li role=presentation id=week><a href="#!/week">Past Week</a></li>
+ <li role=presentation id=month><a href="#!/month">Past Month</a></li>
</ul>
<div id=metrics></div>
</div>
diff --git a/files/performance/js/app.js b/files/performance/js/app.js
index cce5acf..e0fe73d 100644
--- a/files/performance/js/app.js
+++ b/files/performance/js/app.js
@@ -1,3 +1,4 @@
+/*global d3, MG */
function drawCharts( period ) {
d3.json( '/coal/v1/metrics?period=' + period, function ( data ) {
var metric, div, points;
@@ -32,11 +33,28 @@
} );
}
+function selectTab( tab ) {
+ d3.select( 'li.active' ).classed( 'active', false );
+ tab.className = 'active';
+ drawCharts( tab.id );
+}
+
d3.selectAll( '.nav li:not(.active)' ).on( 'click', function () {
- d3.select( 'li.active' ).classed( 'active', false );
- this.className = 'active';
- drawCharts( this.id );
- d3.event.preventDefault();
+ selectTab( this );
} );
-drawCharts( 'hour' );
+function init() {
+ if ( /^#!\/./.test( location.hash ) ) {
+ // Handle permalink
+ var id = location.hash.slice( 3 );
+ var navItem = document.getElementById( id );
+ if ( navItem ) {
+ selectTab( navItem );
+ }
+ } else {
+ // Default
+ drawCharts( 'hour' );
+ }
+}
+
+init();
--
To view, visit https://gerrit.wikimedia.org/r/205766
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6e46dcd42d3ca39c67bef46a99bb38e603a456e1
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Krinkle <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits