<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[176497] trunk/Websites/perf.webkit.org</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/176497">176497</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2014-11-21 19:42:26 -0800 (Fri, 21 Nov 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>The dashboard on new perf monitor should be configurable
https://bugs.webkit.org/show_bug.cgi?id=138994

Reviewed by Benjamin Poulain.

For now, make it configurable via config.json. We should eventually make it configurable via
an administrative page but this will do for now.

* config.json: Added the empty dashboard configuration.

* public/include/manifest.php: Include the dashboard configuration in the manifest file.

* public/v2/app.js:
(App.IndexController): Removed defaultTable since this is now dynamically obtained via App.Manifest.
(App.IndexController.gridChanged): Use App.Dashboard to parse the dashboard configuration.
Also obtain the default configuration from App.Manifest.
(App.IndexController._normalizeTable): Moved to App.Dashboard.

* public/v2/manifest.js:
(App.Repository.urlForRevision): Fixed the position of the open curly bracket.
(App.Repository.urlForRevisionRange): Ditto.
(App.Dashboard): Added.
(App.Dashboard.table): Extracted from App.IndexController.gridChanged.
(App.Dashboard.rows): Ditto.
(App.Dashboard.headerColumns): Ditto.
(App.Dashboard._normalizeTable): Moved from App.IndexController._normalizeTable.
(App.MetricSerializer.normalizePayload): Synthesize a dashboard record from the configuration.
Since there is exactly one dashboard object per app, it's okay to hard code an id here.
(App.Manifest._fetchedManifest): Set defaultDashboard to the one and only one dashboard we have.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebsitesperfwebkitorgChangeLog">trunk/Websites/perf.webkit.org/ChangeLog</a></li>
<li><a href="#trunkWebsitesperfwebkitorgconfigjson">trunk/Websites/perf.webkit.org/config.json</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicincludemanifestphp">trunk/Websites/perf.webkit.org/public/include/manifest.php</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv2appjs">trunk/Websites/perf.webkit.org/public/v2/app.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv2manifestjs">trunk/Websites/perf.webkit.org/public/v2/manifest.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebsitesperfwebkitorgChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/ChangeLog (176496 => 176497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/ChangeLog        2014-11-22 03:29:58 UTC (rev 176496)
+++ trunk/Websites/perf.webkit.org/ChangeLog        2014-11-22 03:42:26 UTC (rev 176497)
</span><span class="lines">@@ -1,5 +1,37 @@
</span><span class="cx"> 2014-11-21  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span><span class="cx"> 
</span><ins>+        The dashboard on new perf monitor should be configurable
+        https://bugs.webkit.org/show_bug.cgi?id=138994
+
+        Reviewed by Benjamin Poulain.
+
+        For now, make it configurable via config.json. We should eventually make it configurable via
+        an administrative page but this will do for now.
+
+        * config.json: Added the empty dashboard configuration.
+
+        * public/include/manifest.php: Include the dashboard configuration in the manifest file.
+
+        * public/v2/app.js:
+        (App.IndexController): Removed defaultTable since this is now dynamically obtained via App.Manifest.
+        (App.IndexController.gridChanged): Use App.Dashboard to parse the dashboard configuration.
+        Also obtain the default configuration from App.Manifest.
+        (App.IndexController._normalizeTable): Moved to App.Dashboard.
+
+        * public/v2/manifest.js:
+        (App.Repository.urlForRevision): Fixed the position of the open curly bracket.
+        (App.Repository.urlForRevisionRange): Ditto.
+        (App.Dashboard): Added.
+        (App.Dashboard.table): Extracted from App.IndexController.gridChanged.
+        (App.Dashboard.rows): Ditto.
+        (App.Dashboard.headerColumns): Ditto.
+        (App.Dashboard._normalizeTable): Moved from App.IndexController._normalizeTable.
+        (App.MetricSerializer.normalizePayload): Synthesize a dashboard record from the configuration.
+        Since there is exactly one dashboard object per app, it's okay to hard code an id here.
+        (App.Manifest._fetchedManifest): Set defaultDashboard to the one and only one dashboard we have.
+
+2014-11-21  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
</ins><span class="cx">         There should be a way to associate bugs with analysis tasks
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=138977
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgconfigjson"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/config.json (176496 => 176497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/config.json        2014-11-22 03:29:58 UTC (rev 176496)
+++ trunk/Websites/perf.webkit.org/config.json        2014-11-22 03:42:26 UTC (rev 176497)
</span><span class="lines">@@ -12,5 +12,6 @@
</span><span class="cx">     &quot;testServer&quot;: {
</span><span class="cx">         &quot;hostname&quot;: &quot;localhost&quot;,
</span><span class="cx">         &quot;port&quot;: 80
</span><del>-    }
</del><ins>+    },
+    &quot;defaultDashboard&quot;: [[]]
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicincludemanifestphp"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/include/manifest.php (176496 => 176497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/include/manifest.php        2014-11-22 03:29:58 UTC (rev 176496)
+++ trunk/Websites/perf.webkit.org/public/include/manifest.php        2014-11-22 03:42:26 UTC (rev 176497)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx">             'repositories' =&gt; $this-&gt;repositories($repositories_table, $repositories_with_commit),
</span><span class="cx">             'builders' =&gt; $this-&gt;builders(),
</span><span class="cx">             'bugTrackers' =&gt; $this-&gt;bug_trackers($repositories_table),
</span><ins>+            'defaultDashboard' =&gt; config('defaultDashboard'),
</ins><span class="cx">         );
</span><span class="cx">         return $this-&gt;manifest;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv2appjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v2/app.js (176496 => 176497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v2/app.js        2014-11-22 03:29:58 UTC (rev 176496)
+++ trunk/Websites/perf.webkit.org/public/v2/app.js        2014-11-22 03:42:26 UTC (rev 176497)
</span><span class="lines">@@ -57,7 +57,6 @@
</span><span class="cx"> App.IndexController = Ember.Controller.extend({
</span><span class="cx">     queryParams: ['grid', 'numberOfDays'],
</span><span class="cx">     _previousGrid: {},
</span><del>-    defaultTable: [],
</del><span class="cx">     headerColumns: [],
</span><span class="cx">     rows: [],
</span><span class="cx">     numberOfDays: 30,
</span><span class="lines">@@ -69,27 +68,24 @@
</span><span class="cx">         if (grid === this._previousGrid)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><del>-        var table = null;
-        try {
-            if (grid)
-                table = JSON.parse(grid);
-        } catch (error) {
-            console.log(&quot;Failed to parse the grid:&quot;, error, grid);
</del><ins>+        var dashboard = null;
+        if (grid) {
+            dashboard = App.Dashboard.create({serialized: grid});
+            if (!dashboard.get('headerColumns').length)
+                dashboard = null;
</ins><span class="cx">         }
</span><ins>+        if (!dashboard)
+            dashboard = App.Manifest.get('defaultDashboard');
+        if (!dashboard)
+            return;
</ins><span class="cx"> 
</span><del>-        if (!table || !table.length) // FIXME: We should fetch this from the manifest.
-            table = this.get('defaultTable');
-
-        table = this._normalizeTable(table);
-        var columnCount = table[0].length;
</del><ins>+        var headerColumns = dashboard.get('headerColumns');
+        this.set('headerColumns', headerColumns);
+        var columnCount = headerColumns.length;
</ins><span class="cx">         this.set('columnCount', columnCount);
</span><span class="cx"> 
</span><del>-        this.set('headerColumns', table[0].map(function (name, index) {
-            return {label:name, index: index};
-        }));
-
</del><span class="cx">         var store = this.store;
</span><del>-        this.set('rows', table.slice(1).map(function (rowParam) {
</del><ins>+        this.set('rows', dashboard.get('rows').map(function (rowParam) {
</ins><span class="cx">             return App.DashboardRow.create({
</span><span class="cx">                 store: store,
</span><span class="cx">                 header: rowParam[0],
</span><span class="lines">@@ -99,23 +95,8 @@
</span><span class="cx">         }));
</span><span class="cx"> 
</span><span class="cx">         this.set('emptyRow', new Array(columnCount));
</span><del>-    }.observes('grid').on('init'),
</del><ins>+    }.observes('grid', 'App.Manifest.defaultDashboard').on('init'),
</ins><span class="cx"> 
</span><del>-    _normalizeTable: function (table)
-    {
-        var maxColumnCount = Math.max(table.map(function (column) { return column.length; }));
-        for (var i = 1; i &lt; table.length; i++) {
-            var row = table[i];
-            for (var j = 1; j &lt; row.length; j++) {
-                if (row[j] &amp;&amp; !(row[j] instanceof Array)) {
-                    console.log('Unrecognized (platform, metric) pair at column ' + i + ' row ' + j + ':' + row[j]);
-                    row[j] = [];
-                }
-            }
-        }
-        return table;
-    },
-
</del><span class="cx">     updateGrid: function()
</span><span class="cx">     {
</span><span class="cx">         var headers = this.get('headerColumns').map(function (header) { return header.label; });
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv2manifestjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v2/manifest.js (176496 => 176497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v2/manifest.js        2014-11-22 03:29:58 UTC (rev 176496)
+++ trunk/Websites/perf.webkit.org/public/v2/manifest.js        2014-11-22 03:42:26 UTC (rev 176497)
</span><span class="lines">@@ -82,14 +82,63 @@
</span><span class="cx">     url: DS.attr('string'),
</span><span class="cx">     blameUrl: DS.attr('string'),
</span><span class="cx">     hasReportedCommits: DS.attr('boolean'),
</span><del>-    urlForRevision: function (currentRevision) {
</del><ins>+    urlForRevision: function (currentRevision)
+    {
</ins><span class="cx">         return (this.get('url') || '').replace(/\$1/g, currentRevision);
</span><span class="cx">     },
</span><del>-    urlForRevisionRange: function (from, to) {
</del><ins>+    urlForRevisionRange: function (from, to)
+    {
</ins><span class="cx">         return (this.get('blameUrl') || '').replace(/\$1/g, from).replace(/\$2/g, to);
</span><span class="cx">     },
</span><span class="cx"> });
</span><span class="cx"> 
</span><ins>+App.Dashboard = App.Model.extend({
+    serialized: DS.attr('string'),
+    table: function ()
+    {
+        var json = this.get('serialized');
+        try {
+            var parsed = JSON.parse(json);
+        } catch (error) {
+            console.log(&quot;Failed to parse the grid:&quot;, error, json);
+            return [];
+        }
+        if (!parsed)
+            return [];
+        return this._normalizeTable(parsed);
+    }.property('serialized'),
+
+    rows: function ()
+    {
+        return this.get('table').slice(1);
+    }.property('table'),
+
+    headerColumns: function ()
+    {
+        var table = this.get('table');
+        if (!table || !table.length)
+            return [];
+        return table[0].map(function (name, index) {
+            return {label:name, index: index};
+        });
+    }.property('table'),
+
+    _normalizeTable: function (table)
+    {
+        var maxColumnCount = Math.max(table.map(function (column) { return column.length; }));
+        for (var i = 1; i &lt; table.length; i++) {
+            var row = table[i];
+            for (var j = 1; j &lt; row.length; j++) {
+                if (row[j] &amp;&amp; !(row[j] instanceof Array)) {
+                    console.log('Unrecognized (platform, metric) pair at column ' + i + ' row ' + j + ':' + row[j]);
+                    row[j] = [];
+                }
+            }
+        }
+        return table;
+    },
+});
+
</ins><span class="cx"> App.MetricSerializer = App.PlatformSerializer = DS.RESTSerializer.extend({
</span><span class="cx">     normalizePayload: function (payload)
</span><span class="cx">     {
</span><span class="lines">@@ -103,6 +152,7 @@
</span><span class="cx">             metrics: this._normalizeIdMap(payload['metrics']),
</span><span class="cx">             repositories: this._normalizeIdMap(payload['repositories']),
</span><span class="cx">             bugTrackers: this._normalizeIdMap(payload['bugTrackers']),
</span><ins>+            dashboards: [{id: 1, serialized: JSON.stringify(payload['defaultDashboard'])}],
</ins><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         for (var testId in payload['tests']) {
</span><span class="lines">@@ -208,6 +258,8 @@
</span><span class="cx">             repositories.filter(function (repository) { return repository.get('hasReportedCommits'); }));
</span><span class="cx"> 
</span><span class="cx">         this.set('bugTrackers', store.all('bugTracker').sortBy('name'));
</span><ins>+
+        this.set('defaultDashboard', store.all('dashboard').objectAt(0));
</ins><span class="cx">     },
</span><span class="cx">     fetchRunsWithPlatformAndMetric: function (store, platformId, metricId)
</span><span class="cx">     {
</span></span></pre>
</div>
</div>

</body>
</html>