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 * as m from 'mithril'; 16 17import {fromNs, timeToCode} from '../common/time'; 18 19import {globals} from './globals'; 20import {Panel} from './panel'; 21 22interface CounterDetailsPanelAttrs {} 23 24export class CounterDetailsPanel extends Panel<CounterDetailsPanelAttrs> { 25 view() { 26 const counterInfo = globals.counterDetails; 27 if (counterInfo && counterInfo.startTime && 28 counterInfo.value !== undefined && counterInfo.delta !== undefined && 29 counterInfo.duration !== undefined) { 30 return m( 31 '.details-panel', 32 m('.details-panel-heading', m('h2', `Counter Details`)), 33 m( 34 '.details-table', 35 [m('table.half-width', 36 [ 37 m('tr', 38 m('th', `Start time`), 39 m('td', `${timeToCode(counterInfo.startTime)}`)), 40 m('tr', 41 m('th', `Value`), 42 m('td', `${counterInfo.value.toLocaleString()}`)), 43 m('tr', 44 m('th', `Delta`), 45 m('td', `${counterInfo.delta.toLocaleString()}`)), 46 m('tr', 47 m('th', `Duration`), 48 m('td', `${timeToCode(fromNs(counterInfo.duration))}`)), 49 ])], 50 )); 51 } else { 52 return m( 53 '.details-panel', 54 m('.details-panel-heading', m('h2', `Counter Details`))); 55 } 56 } 57 58 renderCanvas() {} 59} 60