• 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.js";
17import {LitTable} from "../../../../../base-ui/table/lit-table.js";
18import {ColorUtils} from "../../base/ColorUtils.js";
19import {Utils} from "../../base/Utils.js";
20
21@element('tabpane-freq-limit')
22export class TabPaneFreqLimit extends BaseElement {
23    private tbl: LitTable | null | undefined;
24
25    set data(freq:any) {
26        if(freq){
27            this.tbl!.dataSource = [{
28                startNs:Utils.getTimeString(freq.startNs),
29                dur:Utils.getProbablyTime(freq.dur),
30                maxFreq:`${ColorUtils.formatNumberComma(freq.max!)} kHz`,
31                minFreq:`${ColorUtils.formatNumberComma(freq.min!)} kHz`,
32                cpu:`Cpu ${freq.cpu}`
33            }]
34        }
35    }
36
37    initElements(): void {
38        this.tbl = this.shadowRoot?.querySelector<LitTable>('#tb-freq');
39    }
40
41    connectedCallback() {
42        super.connectedCallback();
43        new ResizeObserver((entries) => {
44            if (this.parentElement?.clientHeight != 0) {
45                // @ts-ignore
46                this.tbl?.shadowRoot.querySelector(".table").style.height = (this.parentElement.clientHeight - 45) + "px"
47                this.tbl?.reMeauseHeight()
48            }
49        }).observe(this.parentElement!)
50    }
51
52    initHtml(): string {
53        return `
54        <style>
55        :host{
56            display: flex;
57            flex-direction: column;
58            padding: 10px 10px;
59        }
60        </style>
61        <lit-table id="tb-freq" style="height: auto">
62            <lit-table-column width="1fr" title="StartTime" data-index="startNs" key="startNs" align="flex-start">
63            </lit-table-column>
64            <lit-table-column width="1fr" title="Duration" data-index="dur" key="dur" align="flex-start" >
65            </lit-table-column>
66            <lit-table-column width="1fr" title="Cpu" data-index="cpu" key="cpu" align="flex-start" >
67            </lit-table-column>
68            <lit-table-column width="1fr" title="Max Frequency" data-index="maxFreq" key="maxFreq" align="flex-start" >
69            </lit-table-column>
70            <lit-table-column width="1fr" title="Min Frequency" data-index="minFreq" key="minFreq" align="flex-start" >
71            </lit-table-column>
72        </lit-table>
73        `;
74    }
75
76}