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