The dashboard on new perf monitor should be configurable
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Nov 2014 03:42:26 +0000 (03:42 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Nov 2014 03:42:26 +0000 (03:42 +0000)
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176497 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/config.json
Websites/perf.webkit.org/public/include/manifest.php
Websites/perf.webkit.org/public/v2/app.js
Websites/perf.webkit.org/public/v2/manifest.js

index ef47817..c42213d 100644 (file)
@@ -1,5 +1,37 @@
 2014-11-21  Ryosuke Niwa  <rniwa@webkit.org>
 
+        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  <rniwa@webkit.org>
+
         There should be a way to associate bugs with analysis tasks
         https://bugs.webkit.org/show_bug.cgi?id=138977
 
index 486664f..3bb3e0c 100644 (file)
@@ -12,5 +12,6 @@
     "testServer": {
         "hostname": "localhost",
         "port": 80
-    }
+    },
+    "defaultDashboard": [[]]
 }
index 4678e95..516cf97 100644 (file)
@@ -32,6 +32,7 @@ class ManifestGenerator {
             'repositories' => $this->repositories($repositories_table, $repositories_with_commit),
             'builders' => $this->builders(),
             'bugTrackers' => $this->bug_trackers($repositories_table),
+            'defaultDashboard' => config('defaultDashboard'),
         );
         return $this->manifest;
     }
index afb5869..5392614 100755 (executable)
@@ -57,7 +57,6 @@ App.DashboardPaneProxyForPicker = Ember.ObjectProxy.extend({
 App.IndexController = Ember.Controller.extend({
     queryParams: ['grid', 'numberOfDays'],
     _previousGrid: {},
-    defaultTable: [],
     headerColumns: [],
     rows: [],
     numberOfDays: 30,
@@ -69,27 +68,24 @@ App.IndexController = Ember.Controller.extend({
         if (grid === this._previousGrid)
             return;
 
-        var table = null;
-        try {
-            if (grid)
-                table = JSON.parse(grid);
-        } catch (error) {
-            console.log("Failed to parse the grid:", error, grid);
+        var dashboard = null;
+        if (grid) {
+            dashboard = App.Dashboard.create({serialized: grid});
+            if (!dashboard.get('headerColumns').length)
+                dashboard = null;
         }
+        if (!dashboard)
+            dashboard = App.Manifest.get('defaultDashboard');
+        if (!dashboard)
+            return;
 
-        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;
+        var headerColumns = dashboard.get('headerColumns');
+        this.set('headerColumns', headerColumns);
+        var columnCount = headerColumns.length;
         this.set('columnCount', columnCount);
 
-        this.set('headerColumns', table[0].map(function (name, index) {
-            return {label:name, index: index};
-        }));
-
         var store = this.store;
-        this.set('rows', table.slice(1).map(function (rowParam) {
+        this.set('rows', dashboard.get('rows').map(function (rowParam) {
             return App.DashboardRow.create({
                 store: store,
                 header: rowParam[0],
@@ -99,22 +95,7 @@ App.IndexController = Ember.Controller.extend({
         }));
 
         this.set('emptyRow', new Array(columnCount));
-    }.observes('grid').on('init'),
-
-    _normalizeTable: function (table)
-    {
-        var maxColumnCount = Math.max(table.map(function (column) { return column.length; }));
-        for (var i = 1; i < table.length; i++) {
-            var row = table[i];
-            for (var j = 1; j < row.length; j++) {
-                if (row[j] && !(row[j] instanceof Array)) {
-                    console.log('Unrecognized (platform, metric) pair at column ' + i + ' row ' + j + ':' + row[j]);
-                    row[j] = [];
-                }
-            }
-        }
-        return table;
-    },
+    }.observes('grid', 'App.Manifest.defaultDashboard').on('init'),
 
     updateGrid: function()
     {
index 0bae01b..8ba348a 100755 (executable)
@@ -82,14 +82,63 @@ App.Repository = App.NameLabelModel.extend({
     url: DS.attr('string'),
     blameUrl: DS.attr('string'),
     hasReportedCommits: DS.attr('boolean'),
-    urlForRevision: function (currentRevision) {
+    urlForRevision: function (currentRevision)
+    {
         return (this.get('url') || '').replace(/\$1/g, currentRevision);
     },
-    urlForRevisionRange: function (from, to) {
+    urlForRevisionRange: function (from, to)
+    {
         return (this.get('blameUrl') || '').replace(/\$1/g, from).replace(/\$2/g, to);
     },
 });
 
+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("Failed to parse the grid:", 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 < table.length; i++) {
+            var row = table[i];
+            for (var j = 1; j < row.length; j++) {
+                if (row[j] && !(row[j] instanceof Array)) {
+                    console.log('Unrecognized (platform, metric) pair at column ' + i + ' row ' + j + ':' + row[j]);
+                    row[j] = [];
+                }
+            }
+        }
+        return table;
+    },
+});
+
 App.MetricSerializer = App.PlatformSerializer = DS.RESTSerializer.extend({
     normalizePayload: function (payload)
     {
@@ -103,6 +152,7 @@ App.MetricSerializer = App.PlatformSerializer = DS.RESTSerializer.extend({
             metrics: this._normalizeIdMap(payload['metrics']),
             repositories: this._normalizeIdMap(payload['repositories']),
             bugTrackers: this._normalizeIdMap(payload['bugTrackers']),
+            dashboards: [{id: 1, serialized: JSON.stringify(payload['defaultDashboard'])}],
         };
 
         for (var testId in payload['tests']) {
@@ -208,6 +258,8 @@ App.Manifest = Ember.Controller.extend({
             repositories.filter(function (repository) { return repository.get('hasReportedCommits'); }));
 
         this.set('bugTrackers', store.all('bugTracker').sortBy('name'));
+
+        this.set('defaultDashboard', store.all('dashboard').objectAt(0));
     },
     fetchRunsWithPlatformAndMetric: function (store, platformId, metricId)
     {