• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this 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 */
15
16import { BaseElement, element } from '../../../../../base-ui/BaseElement';
17import { LitTable } from '../../../../../base-ui/table/lit-table';
18import { ColorUtils } from '../../base/ColorUtils';
19import { Utils } from '../../base/Utils';
20import { resizeObserver } from '../SheetUtils';
21
22@element('tabpane-freq')
23export class TabPaneFreq extends BaseElement {
24  private freqTbl: LitTable | null | undefined;
25
26  set data(freqData: unknown) {
27    if (freqData) {
28      this.freqTbl!.recycleDataSource = [
29        {
30          // @ts-ignore
31          startNS: Utils.getTimeString(freqData.startNS >= 0 ? freqData.startNS : 0),
32          // @ts-ignore
33          absoluteTime: (freqData.startNS + (window as unknown).recordStartNS) / 1000000000 + 's',
34          // @ts-ignore
35          dur: Utils.getProbablyTime(freqData.dur),
36          // @ts-ignore
37          freq: `${ColorUtils.formatNumberComma(freqData.value!)} kHz`,
38          // @ts-ignore
39          cpu: `Cpu ${freqData.cpu}`,
40        },
41      ];
42    }
43  }
44
45  initElements(): void {
46    this.freqTbl = this.shadowRoot?.querySelector<LitTable>('#tb-freq');
47  }
48
49  connectedCallback(): void {
50    super.connectedCallback();
51    resizeObserver(this.parentElement!, this.freqTbl!);
52  }
53
54  initHtml(): string {
55    return `
56        <style>
57        .freq-table{
58            height: auto;
59        }
60        :host{
61            padding: 10px 10px;
62            display: flex;
63            flex-direction: column;
64        }
65        </style>
66        <lit-table id="tb-freq" class="freq-table">
67            <lit-table-column class="freq-column" width="1fr" title="StartTime(Relative)" data-index="startNS" key="startNS" align="flex-start">
68            </lit-table-column>
69            <lit-table-column class="freq-column" width="1fr" title="StartTime(Absolute)" data-index="absoluteTime" key="absoluteTime" align="flex-start">
70            </lit-table-column>
71            <lit-table-column class="freq-column" width="1fr" title="Duration" data-index="dur" key="dur" align="flex-start" >
72            </lit-table-column>
73            <lit-table-column class="freq-column" width="1fr" title="Cpu" data-index="cpu" key="cpu" align="flex-start" >
74            </lit-table-column>
75            <lit-table-column class="freq-column" width="1fr" title="Freq" data-index="freq" key="freq" align="flex-start" >
76            </lit-table-column>
77        </lit-table>
78        `;
79  }
80}
81