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