summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/catapult/tracing/tracing/ui/analysis/user_expectation_related_samples_table.html
blob: 3c2bfdbd9cfd540d2c661cf977e9c3d4a664ad27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!DOCTYPE html>
<!--
Copyright (c) 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/analysis/analysis_link.html">
<link rel="import" href="/tracing/ui/base/table.html">

<dom-module id='tr-ui-a-user-expectation-related-samples-table'>
  <template>
    <style>
    #table {
      flex: 1 1 auto;
      align-self: stretch;
      font-size: 12px;
    }
    </style>
    <tr-ui-b-table id="table"></tr-ui-b-table>
  </template>
</dom-module>
<script>
'use strict';

Polymer({
  is: 'tr-ui-a-user-expectation-related-samples-table',

  ready() {
    this.samples_ = [];
    this.$.table.tableColumns = [
      {
        title: 'Event(s)',
        value(row) {
          const typeEl = document.createElement('span');
          typeEl.innerText = row.type;
          if (row.tooltip) {
            typeEl.title = row.tooltip;
          }
          return typeEl;
        },
        width: '150px'
      },
      {
        title: 'Link',
        width: '100%',
        value(row) {
          const linkEl = document.createElement('tr-ui-a-analysis-link');
          if (row.name) {
            linkEl.setSelectionAndContent(row.selection, row.name);
          } else {
            linkEl.selection = row.selection;
          }
          return linkEl;
        }
      }
    ];
  },

  hasRelatedSamples() {
    return (this.samples_ && this.samples_.length > 0);
  },

  set selection(eventSet) {
    this.samples_ = [];
    const samples = new tr.model.EventSet;
    eventSet.forEach(function(ue) {
      samples.addEventSet(ue.associatedSamples);
    }.bind(this));

    if (samples.length > 0) {
      this.samples_.push({
        type: 'Overlapping samples',
        tooltip: 'All samples overlapping the selected user expectation(s).',
        selection: samples
      });
    }
    this.updateContents_();
  },

  updateContents_() {
    const table = this.$.table;
    if (this.samples_ && this.samples_.length > 0) {
      table.tableRows = this.samples_.slice();
    } else {
      table.tableRows = [];
    }
    table.rebuild();
  }
});
</script>