1<!DOCTYPE html> 2<!-- 3Copyright (c) 2013 The Chromium Authors. All rights reserved. 4Use of this source code is governed by a BSD-style license that can be 5found in the LICENSE file. 6--> 7 8<link rel="import" href="/tracing/base/base.html"> 9<link rel="import" href="/tracing/ui/base/table.html"> 10<link rel="import" href="/tracing/value/ui/scalar_span.html"> 11<link rel="import" href="/tracing/value/unit.html"> 12 13<polymer-element name='tr-ui-a-selection-summary-table'> 14 <template> 15 <style> 16 :host { 17 display: flex; 18 } 19 #table { 20 flex: 1 1 auto; 21 align-self: stretch; 22 } 23 </style> 24 <tr-ui-b-table id="table"> 25 </tr-ui-b-table> 26 </div> 27 </template> 28 <script> 29 'use strict'; 30 31 Polymer({ 32 created: function() { 33 this.selection_ = new tr.b.Range(); 34 }, 35 36 ready: function() { 37 this.$.table.showHeader = false; 38 this.$.table.tableColumns = [ 39 { 40 title: 'Name', 41 value: function(row) { return row.title; }, 42 width: '350px' 43 }, 44 { 45 title: 'Value', 46 width: '100%', 47 value: function(row) { 48 return row.value; 49 } 50 } 51 ]; 52 }, 53 54 get selection() { 55 return this.selection_; 56 }, 57 58 set selection(selection) { 59 this.selection_ = selection; 60 this.updateContents_(); 61 }, 62 63 updateContents_: function() { 64 var selection = this.selection_; 65 var rows = []; 66 var hasRange; 67 if (this.selection_ && (!selection.bounds.isEmpty)) 68 hasRange = true; 69 else 70 hasRange = false; 71 72 rows.push({ 73 title: 'Selection start', 74 value: hasRange ? tr.v.ui.createScalarSpan( 75 selection.bounds.min, { 76 unit: tr.v.Unit.byName.timeStampInMs, 77 ownerDocument: this.ownerDocument 78 }) : '<empty>' 79 }); 80 rows.push({ 81 title: 'Selection extent', 82 value: hasRange ? tr.v.ui.createScalarSpan( 83 selection.bounds.range, { 84 unit: tr.v.Unit.byName.timeDurationInMs, 85 ownerDocument: this.ownerDocument 86 }) : '<empty>' 87 }); 88 89 this.$.table.tableRows = rows; 90 this.$.table.rebuild(); 91 } 92 }); 93 </script> 94</polymer-element> 95