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