-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashboard): show velocity of memory
- Loading branch information
Showing
2 changed files
with
63 additions
and
24 deletions.
There are no files selected for viewing
62 changes: 40 additions & 22 deletions
62
src/app/components/key-value-table/key-value-table.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,66 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { Component, ContentChild, Input, OnInit, TemplateRef } from '@angular/core'; | ||
import { Columns, Config, DefaultConfig } from 'ngx-easy-table'; | ||
|
||
@Component({ | ||
selector: 'app-rng-kv-table', | ||
template: ` | ||
<table> | ||
<tr *ngFor="let k of keys"> | ||
<th>{{ k.title ? k.title : k.key }}</th> | ||
<td>{{ isDefine(data[k.key]) ? data[k.key] : ' ' }}</td> | ||
</tr> | ||
</table> | ||
<ngx-table | ||
[configuration]="configuration" | ||
[columns]="columns" | ||
[data]="keys" | ||
[pagination]="{ limit: 100, offset: 0, count: 100 }" | ||
> | ||
<ng-template let-row let-rowIndex="index"> | ||
<th style="border: none; padding: 0.25rem 3% 0.25rem 0.5rem;text-align: right;"> | ||
{{ row.title ? row.title : row.key }} | ||
</th> | ||
<td style="border: none; padding: 0.25rem 0.5rem;"> | ||
{{ isDefine(data[row.key]) ? data[row.key] : '??' }} | ||
</td> | ||
<ng-container | ||
*ngIf="addonTemplate" | ||
[ngTemplateOutlet]="addonTemplate" | ||
[ngTemplateOutletContext]="{ $implicit: row.key }" | ||
> | ||
</ng-container> | ||
</ng-template> | ||
</ngx-table> | ||
`, | ||
styles: [ | ||
` | ||
th { | ||
text-align: right; | ||
min-width: 20%; | ||
max-width: 40%; | ||
padding: 0.25rem 3% 0.25rem 0.5rem; | ||
} | ||
th::after { | ||
content: ':'; | ||
} | ||
td { | ||
min-width: 50%; | ||
word-break: break-word; | ||
padding: 0.25rem 0.5rem; | ||
} | ||
tr { | ||
vertical-align: top; | ||
} | ||
table { | ||
width: 100%; | ||
} | ||
`, | ||
], | ||
}) | ||
export class RngKeyValueTableComponent implements OnInit { | ||
constructor() {} | ||
@ContentChild(TemplateRef, { static: true }) public addonTemplate: TemplateRef<any>; | ||
|
||
public configuration: Config; | ||
|
||
columns: Columns[] = [ | ||
{ key: 'keys', title: 'keys' }, | ||
{ key: 'values', title: 'values' }, | ||
]; | ||
|
||
@Input() keys: { key: string; title?: string }[] = []; | ||
@Input() data: { [idx: string]: any } = {}; | ||
|
||
isDefine(val: any) { | ||
return typeof val !== 'undefined'; | ||
} | ||
ngOnInit() {} | ||
ngOnInit() { | ||
this.configuration = { ...DefaultConfig }; | ||
this.configuration.searchEnabled = false; | ||
this.configuration.isLoading = false; | ||
this.configuration.infiniteScroll = false; | ||
this.configuration.headerEnabled = false; | ||
this.configuration.paginationEnabled = false; | ||
this.configuration.paginationMaxSize = 100; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters