| <!DOCTYPE html> |
| <!-- |
| Copyright 2016 The Chromium Authors. All rights reserved. |
| Use of this source code is governed by a BSD-style license that can be |
| found in the LICENSE file. |
| --> |
| |
| <link rel="import" href="/tracing/ui/base/table.html"> |
| <link rel="import" href="/tracing/value/ui/diagnostic_span.html"> |
| |
| <dom-module id="tr-v-ui-diagnostic-map-table"> |
| <template> |
| <tr-ui-b-table id="table"></tr-ui-b-table> |
| </template> |
| |
| <script> |
| 'use strict'; |
| |
| Polymer({ |
| is: 'tr-v-ui-diagnostic-map-table', |
| |
| created: function() { |
| this.diagnosticMaps_ = undefined; |
| }, |
| |
| /** |
| * The |title| will be used as the heading for the column containing |
| * diagnostic-spans for |diagnosticMap|'s Diagnostics. |
| * |
| * @param {!Array.<!Object>} maps |
| * @param {!string} maps[].title |
| * @param {!tr.v.d.DiagnosticMap} maps[].diagnosticMap |
| */ |
| set diagnosticMaps(maps) { |
| this.diagnosticMaps_ = maps; |
| this.updateContents_(); |
| }, |
| |
| updateContents_: function() { |
| if (this.diagnosticMaps_ === undefined || |
| this.diagnosticMaps_.length === 0) { |
| this.$.table.tableRows = []; |
| this.$.table.tableColumns = []; |
| return; |
| } |
| |
| var columnTitles = new Set(); |
| for (var map of this.diagnosticMaps_) |
| for (var [name, diagnostic] of map) |
| columnTitles.add(name); |
| |
| columnTitles = [...columnTitles].sort(); |
| |
| var columns = []; |
| function makeColumn(title) { |
| return { |
| title: title, |
| value: function(map) { |
| return tr.v.ui.createDiagnosticSpan(map.get(title)); |
| } |
| }; |
| } |
| for (var title of columnTitles) |
| columns.push(makeColumn(title)); |
| |
| this.$.table.tableColumns = columns; |
| this.$.table.tableRows = this.diagnosticMaps_; |
| this.$.table.rebuild(); |
| } |
| }); |
| </script> |
| </dom-module> |