| Index: tracing/tracing/ui/side_panel/metrics_side_panel.html
|
| diff --git a/tracing/tracing/ui/side_panel/metrics_side_panel.html b/tracing/tracing/ui/side_panel/metrics_side_panel.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ca4423f8049a14daee2a863adbc71d9b12174d58
|
| --- /dev/null
|
| +++ b/tracing/tracing/ui/side_panel/metrics_side_panel.html
|
| @@ -0,0 +1,128 @@
|
| +<!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/metrics/metric_registry.html">
|
| +<link rel="import" href="/tracing/metrics/value_list.html">
|
| +<link rel="import" href="/tracing/model/event_set.html">
|
| +<link rel="import" href="/tracing/ui/base/dom_helpers.html">
|
| +<link rel="import" href="/tracing/ui/side_panel/side_panel.html">
|
| +<link rel="import" href="/tracing/ui/value_set_view.html">
|
| +
|
| +<polymer-element name='tr-ui-sp-metrics-side-panel'
|
| + extends='tr-ui-side-panel'>
|
| + <template>
|
| + <style>
|
| + :host {
|
| + display: flex;
|
| + flex-direction: column;
|
| + width: 400px;
|
| + }
|
| + table-container {
|
| + display: flex;
|
| + min-height: 0px;
|
| + overflow-y: auto;
|
| + }
|
| + div#error {
|
| + color: red;
|
| + }
|
| + </style>
|
| +
|
| + <top-left-controls id="top_left_controls"></top-left-controls>
|
| + <tr-ui-value-set-view id="results"></tr-ui-value-set-view>
|
| + </template>
|
| +</polymer-element>
|
| +
|
| +<script>
|
| +'use strict';
|
| +tr.exportTo('tr.ui', function() {
|
| + Polymer('tr-ui-sp-metrics-side-panel', {
|
| + ready: function() {
|
| + this.model_ = undefined;
|
| +
|
| + this.metrics_ = [];
|
| + tr.metrics.MetricRegistry.getAllRegisteredTypeInfos().forEach(
|
| + function(m) {
|
| + if (m.constructor.name === 'sampleMetric')
|
| + return;
|
| + this.metrics_.push({
|
| + label: m.constructor.name,
|
| + value: m.constructor.name
|
| + });
|
| + }, this);
|
| +
|
| + this.settingsKey_ = 'metrics-side-panel-metric-name';
|
| + this.currentMetricName_ = 'SystemHealthMetrics';
|
| + var metricSelector = tr.ui.b.createSelector(
|
| + this, 'currentMetricName_',
|
| + this.settingsKey_,
|
| + this.currentMetricName_,
|
| + this.metrics_);
|
| + this.$.top_left_controls.appendChild(metricSelector);
|
| + metricSelector.addEventListener('change',
|
| + this.updateContents_.bind(this));
|
| + },
|
| +
|
| + get textLabel() {
|
| + return 'Metrics';
|
| + },
|
| +
|
| + supportsModel: function(m) {
|
| + if (!m) {
|
| + return {
|
| + supported: false,
|
| + reason: 'No model available'
|
| + };
|
| + }
|
| +
|
| + return {
|
| + supported: true
|
| + };
|
| + },
|
| +
|
| + get model() {
|
| + return this.model_;
|
| + },
|
| +
|
| + set model(model) {
|
| + this.model_ = model;
|
| + this.updateContents_();
|
| + },
|
| +
|
| + get selection() {
|
| + // Not applicable to metrics.
|
| + },
|
| +
|
| + set selection(selection) {
|
| + // Not applicable to metrics.
|
| + },
|
| +
|
| + set rangeOfInterest(_) {
|
| + // Not applicable to metrics.
|
| + },
|
| +
|
| + updateContents_: function() {
|
| + if (!this.model_) {
|
| + this.$.results.error = 'Missing model';
|
| + return;
|
| + }
|
| +
|
| + var metric = tr.metrics.MetricRegistry.findTypeInfoWithName(
|
| + this.currentMetricName_);
|
| + var valueList = new tr.metrics.ValueList();
|
| + try {
|
| + metric.constructor(valueList, this.model_);
|
| + } catch (err) {
|
| + this.$.results.error = err;
|
| + return;
|
| + }
|
| + this.$.results.values = valueList;
|
| + }
|
| + });
|
| +
|
| + return {};
|
| +});
|
| +</script>
|
|
|