Skip to content

Commit

Permalink
fix: #17 Time and Size display
Browse files Browse the repository at this point in the history
and fix frame of DOCS into left panel
  • Loading branch information
RFbkak37y3kIY committed Jul 6, 2022
1 parent 5790222 commit cea18e6
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 22 deletions.
1 change: 1 addition & 0 deletions src/app/components/ch-help/ch-help.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div>
<mat-icon class="mat-18" style="float: right;" (click)="onClose();">close</mat-icon>
</div>
<div style="display: inline-block; width:1px; height: 80vh; position:absolute;"></div>
<iframe [src]="link | safe" class="frame"></iframe>
5 changes: 3 additions & 2 deletions src/app/components/ch-help/ch-help.component.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
:host {
position: relative;
background-color: #fafafa;
max-height: calc(100% - 1rem);
overflow: hidden;
flex: 1;
// flex: 1;
}
.frame {
border: 0;
width: calc(100% - 1rem);
height: 100%;
height: calc(100vh - 13.3rem);
margin: 0 0 0 1rem;
}
57 changes: 39 additions & 18 deletions src/app/pages/home.page/home.page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,17 @@
[ngClass]="{ dark: isDarkMode }"
style="width: 100%; height: calc(100vh - 4rem)"
>
<as-split direction="horizontal" >
<as-split-area [size]="15" [visible]="isLeftPanel" [useTransition]="true" [order]="0">
<as-split direction="horizontal">
<as-split-area
[size]="15"
[visible]="isLeftPanel"
[useTransition]="true"
[order]="0"
>
<mat-accordion>
<mat-expansion-panel [expanded]="!!this.dbTreeData && this.dbTreeData.length > 0">
<mat-expansion-panel
[expanded]="!!this.dbTreeData && this.dbTreeData.length > 0"
>
<mat-expansion-panel-header>
<mat-panel-title> DB Tree </mat-panel-title>
</mat-expansion-panel-header>
Expand Down Expand Up @@ -83,13 +90,26 @@
{{ item }}
</div>
</mat-expansion-panel>
<mat-expansion-panel *ngIf="currentRow.size > 0">
<!-- <mat-expansion-panel *ngIf="currentRow.size > 0">
{{ currentRow.size }}
<mat-expansion-panel-header>
<mat-panel-title> Row Details </mat-panel-title>
</mat-expansion-panel-header>
<app-row-details [row]="currentRow"> </app-row-details>
</mat-expansion-panel> -->
<mat-expansion-panel
*ngIf="isDocsShows"
[expanded]="isDocsShows"
>
<mat-expansion-panel-header>
<mat-panel-title> Docs </mat-panel-title>
</mat-expansion-panel-header>

<!-- <app-row-details [row]="currentRow"> </app-row-details> -->
<app-ch-help
style="height: calc(100% - 8rem)"
></app-ch-help>
</mat-expansion-panel>
</mat-accordion>
</as-split-area>
Expand Down Expand Up @@ -131,13 +151,12 @@ <h1>No Data</h1>
<div class="short-stat">
<div>
<strong>Elapsed: </strong>
<span
>{{
dataForFile?.statistics?.elapsed
| number
}}
sec</span
>
<span>{{
timeShorter(
dataForFile?.statistics?.elapsed ||
0
)
}}</span>
</div>
<div>
<strong>Rows: </strong>
Expand All @@ -147,12 +166,14 @@ <h1>No Data</h1>
</div>
<div>
<strong>Size: </strong>
<span
>{{
dataForFile?.statistics?.bytes_read
<span>
{{
bytesToSize(
dataForFile?.statistics
?.bytes_read || 0
)
}}
B.</span
>
</span>
</div>
</div>
<custom-ag-grid
Expand Down Expand Up @@ -181,14 +202,14 @@ <h1>No Data</h1>
</as-split-area>
</as-split>
</as-split-area>
<as-split-area
<!-- <as-split-area
[visible]="isDocsShows"
[size]="15"
[order]="2"
style="display: flex; overflow: hidden"
>
<app-ch-help></app-ch-help>
</as-split-area>
</as-split-area> -->
</as-split>
</div>

Expand Down
5 changes: 5 additions & 0 deletions src/app/pages/home.page/home.page.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ h1 {
:host ::ng-deep .mat-expansion-panel-body {
padding: 0;
}
mat-expansion-panel {
mat-expansion-panel-header {
height: auto !important;
}
}
.example-table-container {
position: relative;
height: 100%;
Expand Down
35 changes: 33 additions & 2 deletions src/app/pages/home.page/home.page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class HomePageComponent implements OnInit {
console.log(this.currentRow.size)
this.docsService.listen().subscribe(doc_link => {
this.isDocsShows = !!doc_link;
this.isLeftPanel = !doc_link;
// this.isLeftPanel = !doc_link;
})
}
getDynamicDictionary() {
Expand All @@ -83,7 +83,7 @@ export class HomePageComponent implements OnInit {
const bool = query.includes('system.functions');
const r: Dictionary[] = data?.map((value: any) => ({
name: value[0] + '()',
icon: bool ? 1: 2,
icon: bool ? 1 : 2,
type: bool ? 'function' : 'format'
}));

Expand Down Expand Up @@ -331,6 +331,37 @@ export class HomePageComponent implements OnInit {
}
})
}
bytesToSize(bytes: any): string {
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes === 0) {
return 'n/a';
}
const i = Math.floor(+Math.log(bytes) / +Math.log(1024))
if (i === 0) {
return `${bytes} ${sizes[i]}`;
}
return `${(bytes / (1024 ** i)).toFixed(1)} ${sizes[i]}`
}
timeShorter(sec: number): string {
const ms = Math.round((sec) * 1000);
const _ = (n: number) => (n + '').length === 1 ? '0' + n : n;
const o = {
'hours': _(Math.floor(ms / (1000 * 60 * 60))),
'min': _(Math.floor(ms / (1000 * 60) % 60)),
'sec': _(Math.floor((ms / 1000) % 60)),
'ms': ((ms % 1000) / 1000) ? ((ms % 1000) / 1000).toString().replace('0.', '') : '000'
};
if (ms < 1000) { // ms
return `${ms} ms`;
} else if (ms < 1000 * 60) { // sec
return `${o.sec}.${o.ms} sec`;
} else if (ms < 1000 * 60 * 60) { // min
return `${o.min}:${o.sec}.${o.ms} min`;
} else { // hours
return `${o.hours}:${o.min}:${o.sec}.${o.ms} hour(s)`;
}

}
}

export function promiseWait(sec = 1000): Promise<any> {
Expand Down

0 comments on commit cea18e6

Please sign in to comment.