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 "../../../../base-ui/table/lit-table-column.js"; 17import {BaseElement, element} from "../../../../base-ui/BaseElement.js"; 18import {LitTable} from "../../../../base-ui/table/lit-table.js"; 19import {SelectionParam} from "../../../bean/BoxSelection.js"; 20import {queryHeapTable} from "../../../database/SqlLite.js"; 21import {Utils} from "../base/Utils.js"; 22 23@element('tabpane-heap') 24export class TabPaneHeap extends BaseElement { 25 private tbl: LitTable | null | undefined; 26 private range: HTMLLabelElement | null | undefined; 27 28 set data(val: SelectionParam | any) { 29 queryHeapTable(val.leftNs, val.rightNs, val.heapIds).then((result) => { 30 result.forEach((item) => { 31 console.log(item); 32 item.AllocationSize = Utils.getByteWithUnit(Number(item.AllocationSize)) 33 item.DeAllocationSize = Utils.getByteWithUnit(Number(item.DeAllocationSize)) 34 item.RemainingSize = Utils.getByteWithUnit(Number(item.RemainingSize)) 35 }) 36 console.log(result); 37 this.tbl!.dataSource = result 38 }) 39 } 40 41 initElements(): void { 42 this.tbl = this.shadowRoot?.querySelector<LitTable>('#tb-heap'); 43 this.range = this.shadowRoot?.querySelector('#time-range') 44 } 45 46 initHtml(): string { 47 return ` 48<style> 49:host{ 50 display: flex; 51 flex-direction: column; 52 padding: 10px 10px; 53} 54</style> 55 56<lit-table id="tb-heap" style="height: auto"> 57 <lit-table-column width="170px" title="Allocation Function" data-index="AllocationFunction" key="AllocationFunction" align="center" > 58 <template><div style="font-size:0.8rem;padding: 0 5px">{{AllocationFunction}}</div></template> 59</lit-table-column> 60 <lit-table-column width="170px" title="Moudle Name" data-index="MoudleName" key="MoudleName" align="center"> 61 <template><div style="font-size:0.8rem;padding: 0 5px;word-break: break-word">{{MoudleName}}</div></template> 62</lit-table-column> 63 <lit-table-column width="1fr" title="Allocations" data-index="Allocations" key="Allocations" align="center" > 64 <template><div style="font-size:0.8rem;padding: 0 5px">{{Allocations}}</div></template> 65</lit-table-column> 66 <lit-table-column width="1fr" title="Deallocations" data-index="Deallocations" key="Deallocations" align="center" > 67 <template><div style="font-size:0.8rem;padding: 0 5px">{{Deallocations}}</div></template> 68</lit-table-column> 69 <lit-table-column width="1fr" title="Allocation Size" data-index="AllocationSize" key="AllocationSize" align="center" > 70 <template><div style="font-size:0.8rem;padding: 0 5px">{{AllocationSize}}</div></template> 71</lit-table-column> 72 <lit-table-column width="1fr" title="DeAllocation Size" data-index="DeAllocationSize" key="DeAllocationSize" align="center" > 73 <template><div style="font-size:0.8rem;padding: 0 5px">{{DeAllocationSize}}</div></template> 74</lit-table-column> 75 <lit-table-column title="Total Count" data-index="Total" key="Total" align="center" > 76 <template><div style="font-size:0.8rem;padding: 0 5px">{{Total}}</div></template> 77</lit-table-column> 78 <lit-table-column width="1fr" title="Remaining Size" data-index="RemainingSize" key="RemainingSize" align="center" > 79 <template><div style="font-size:0.8rem;padding: 0 5px">{{RemainingSize}}</div></template> 80</lit-table-column> 81</lit-table> 82 `; 83 } 84 85}