• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2019 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use size file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15import m from 'mithril';
16
17import {tpTimeToCode} from '../common/time';
18import {globals} from './globals';
19import {Panel} from './panel';
20
21interface CounterDetailsPanelAttrs {}
22
23export class CounterDetailsPanel extends Panel<CounterDetailsPanelAttrs> {
24  view() {
25    const counterInfo = globals.counterDetails;
26    if (counterInfo && counterInfo.startTime &&
27        counterInfo.name !== undefined && counterInfo.value !== undefined &&
28        counterInfo.delta !== undefined && counterInfo.duration !== undefined) {
29      return m(
30          '.details-panel',
31          m('.details-panel-heading', m('h2', `Counter Details`)),
32          m(
33              '.details-table',
34              [m('table',
35                 [
36                   m('tr', m('th', `Name`), m('td', `${counterInfo.name}`)),
37                   m('tr',
38                     m('th', `Start time`),
39                     m('td',
40                       `${
41                           tpTimeToCode(
42                               counterInfo.startTime -
43                               globals.state.traceTime.start)}`)),
44                   m('tr',
45                     m('th', `Value`),
46                     m('td', `${counterInfo.value.toLocaleString()}`)),
47                   m('tr',
48                     m('th', `Delta`),
49                     m('td', `${counterInfo.delta.toLocaleString()}`)),
50                   m('tr',
51                     m('th', `Duration`),
52                     m('td', `${tpTimeToCode(counterInfo.duration)}`)),
53                 ])],
54              ));
55    } else {
56      return m(
57          '.details-panel',
58          m('.details-panel-heading', m('h2', `Counter Details`)));
59    }
60  }
61
62  renderCanvas() {}
63}
64