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