This commit is contained in:
insanity 2018-09-12 11:53:28 +09:00
parent f5e98b36dc
commit 57ae73ea43
5 changed files with 28 additions and 7 deletions

View File

@ -1,2 +1,7 @@
import { ObjectKeys } from "./object-keys";
import { stringPrettify } from "./string-prettify";
export const PIPES = [
ObjectKeys,
stringPrettify
];

View File

@ -0,0 +1,8 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'objectKeys' })
export class ObjectKeys implements PipeTransform {
transform(value: any, args: any[] = null): any {
return Object.keys(value);
}
}

View File

@ -0,0 +1,10 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'stringPrettify' })
export class stringPrettify implements PipeTransform {
transform(value: string): any {
value = value.replace('-', ' ');
value = value.replace('_', ' ');
return value.charAt(0).toUpperCase() + value.slice(1);
}
}

View File

@ -30,16 +30,14 @@
<span class="meta-value">{{host.mac}}</span>
</li>
<li *ngIf="host.discoveredBy">
Discovered by
<span class="meta-value">{{host.discoveredBy.join(',')}}</span>
</li>
</ul>
</p-tabPanel>
<p-tabPanel header="Metadata" *ngIf="host.meta && host.meta.length > 0">
<p-tabPanel header="Metadata" *ngIf="host.meta">
<div *ngFor="let key of host.meta | objectKeys">
{{key | stringPrettify}}: {{host.meta[key]}}
</div>
</p-tabPanel>
<p-tabPanel header="Ports" *ngIf="host.portList">

View File

@ -12,11 +12,11 @@ export class HostDetailComponent {
@Input() host: Host;
ports: Port[];
selectedPort: Port;
discoveredBy: string;
constructor(
) {
}
}