inframap test
This commit is contained in:
parent
ce6f0c1f08
commit
31cd802b0f
|
@ -3,8 +3,7 @@
|
||||||
<div class="ui-g-12 ui-g-nopad">
|
<div class="ui-g-12 ui-g-nopad">
|
||||||
<div class="ui-g">
|
<div class="ui-g">
|
||||||
<div class="ui-g-12 ui-md-5 ui-g-nopad ui-bottom-space-10">
|
<div class="ui-g-12 ui-md-5 ui-g-nopad ui-bottom-space-10">
|
||||||
<button pButton type="button" class="ui-button-large ui-button-width-fit"
|
<button pButton type="button" class="ui-button-large ui-button-width-fit" icon="ui-icon-play-arrow" label="Discovery" (click)="discovery.emit()"></button>
|
||||||
icon="ui-icon-play-arrow" label="Discovery" (click)="discovery.emit()"></button>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-12 ui-md-7 ui-g-nopad">
|
<div class="ui-g-12 ui-md-7 ui-g-nopad">
|
||||||
<div style="float: right;">
|
<div style="float: right;">
|
||||||
|
@ -22,13 +21,16 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p-tabView (onChange)="onProbeChange($event)" [activeIndex]="probeTabIdx" class="ui-tab-bgcolor">
|
<of-block-progressbar [target]="content" [pending]="pending$ | async"></of-block-progressbar>
|
||||||
<p-tabPanel [header]="item.label" *ngFor="let item of tabs; let i = index" [selected]="i == 0" cache="true">
|
<p-panel #content [showHeader]="false" class="block-panel">
|
||||||
<ng-template pTemplate="content">
|
<p-tabView (onChange)="onProbeChange($event)" [activeIndex]="probeTabIdx" class="ui-tab-bgcolor">
|
||||||
<div>
|
<p-tabPanel [header]="item.label" *ngFor="let item of tabs; let i = index" [selected]="i == 0" cache="true">
|
||||||
<of-infra-tree></of-infra-tree>
|
<ng-template pTemplate="content">
|
||||||
</div>
|
<div>
|
||||||
</ng-template>
|
<of-infra-tree [probeHost]="selectedProbeHost"></of-infra-tree>
|
||||||
</p-tabPanel>
|
</div>
|
||||||
</p-tabView>
|
</ng-template>
|
||||||
|
</p-tabPanel>
|
||||||
|
</p-tabView>
|
||||||
|
</p-panel>
|
||||||
</div>
|
</div>
|
|
@ -9,9 +9,6 @@ import { DomainMember } from '@overflow/commons-typescript/model/domain';
|
||||||
import { Observable, Subscription, of } from 'rxjs';
|
import { Observable, Subscription, of } from 'rxjs';
|
||||||
import { ProbeHost } from '@overflow/commons-typescript/model/probe';
|
import { ProbeHost } from '@overflow/commons-typescript/model/probe';
|
||||||
import { MenuItem } from 'primeng/primeng';
|
import { MenuItem } from 'primeng/primeng';
|
||||||
import { InfraService } from '../service/infra.service';
|
|
||||||
import { Page, PageParams } from '@overflow/commons-typescript/core/model';
|
|
||||||
import { Infra } from '@overflow/commons-typescript/model/infra';
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -23,7 +20,6 @@ import { Infra } from '@overflow/commons-typescript/model/infra';
|
||||||
})
|
})
|
||||||
export class InfraMapComponent implements OnInit {
|
export class InfraMapComponent implements OnInit {
|
||||||
|
|
||||||
infras: Infra[];
|
|
||||||
pending$: Observable<boolean>;
|
pending$: Observable<boolean>;
|
||||||
error$: Observable<any>;
|
error$: Observable<any>;
|
||||||
|
|
||||||
|
@ -31,12 +27,13 @@ export class InfraMapComponent implements OnInit {
|
||||||
probeHosts: ProbeHost[];
|
probeHosts: ProbeHost[];
|
||||||
probeTabIdx: number;
|
probeTabIdx: number;
|
||||||
|
|
||||||
|
selectedProbeHost: ProbeHost;
|
||||||
|
|
||||||
@Output() discovery = new EventEmitter();
|
@Output() discovery = new EventEmitter();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private store: Store<any>,
|
private store: Store<any>,
|
||||||
private probeHostService: ProbeHostService,
|
private probeHostService: ProbeHostService,
|
||||||
private infraService: InfraService,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,8 +52,8 @@ export class InfraMapComponent implements OnInit {
|
||||||
.pipe(
|
.pipe(
|
||||||
map((probeHosts: ProbeHost[]) => {
|
map((probeHosts: ProbeHost[]) => {
|
||||||
this.probeHosts = probeHosts;
|
this.probeHosts = probeHosts;
|
||||||
|
this.selectedProbeHost = probeHosts[0];
|
||||||
this.generateTabs();
|
this.generateTabs();
|
||||||
this.getInfras(probeHosts[0].probe.id);
|
|
||||||
}),
|
}),
|
||||||
catchError(error => {
|
catchError(error => {
|
||||||
this.error$ = of(error);
|
this.error$ = of(error);
|
||||||
|
@ -78,37 +75,18 @@ export class InfraMapComponent implements OnInit {
|
||||||
label: ph.probe.cidr
|
label: ph.probe.cidr
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.tabs.push({
|
||||||
|
label: 'fake probe1'
|
||||||
|
});
|
||||||
|
|
||||||
|
this.tabs.push({
|
||||||
|
label: 'fake probe2'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onProbeChange(event) {
|
onProbeChange(event) {
|
||||||
this.getInfras(this.probeHosts[event.index].probe.id);
|
this.selectedProbeHost = this.probeHosts[event.index];
|
||||||
}
|
|
||||||
|
|
||||||
getInfras(probeID: number) {
|
|
||||||
const pageParams: PageParams = {
|
|
||||||
pageNo: 0,
|
|
||||||
countPerPage: 99999,
|
|
||||||
sortCol: 'id',
|
|
||||||
sortDirection: 'descending'
|
|
||||||
};
|
|
||||||
this.infraService.readAllByProbeID(probeID, pageParams)
|
|
||||||
.pipe(
|
|
||||||
tap(() => {
|
|
||||||
this.pending$ = of(true);
|
|
||||||
}),
|
|
||||||
map((infraPage: Page<Infra>) => {
|
|
||||||
this.infras = infraPage.content;
|
|
||||||
console.log(this.infras);
|
|
||||||
}),
|
|
||||||
catchError(error => {
|
|
||||||
this.error$ = of(error);
|
|
||||||
return of();
|
|
||||||
}),
|
|
||||||
tap(() => {
|
|
||||||
this.pending$ = of(false);
|
|
||||||
}),
|
|
||||||
take(1),
|
|
||||||
).subscribe();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1,66 @@
|
||||||
TREE
|
<of-block-progressbar [target]="content" [pending]="pending$ | async"></of-block-progressbar>
|
||||||
|
<p-panel #content [showHeader]="false" class="block-panel">
|
||||||
|
|
||||||
|
<p-tree [value]="zoneNode" layout="horizontal">
|
||||||
|
<!-- ZONE node template -->
|
||||||
|
<ng-template let-node pTemplate="ZONE">
|
||||||
|
<div>
|
||||||
|
{{node.label}}
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
<!-- HOST node template -->
|
||||||
|
<ng-template let-node pTemplate="HOST">
|
||||||
|
{{node.label}}
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
<!-- SERVICE node template -->
|
||||||
|
<ng-template let-node pTemplate="SERVICE">
|
||||||
|
{{node.label}}
|
||||||
|
</ng-template>
|
||||||
|
</p-tree>
|
||||||
|
|
||||||
|
</p-panel>
|
||||||
|
|
||||||
|
<!-- <p-tree [value]="infraTree" selectionMode="single" [(selection)]="selectedTree" (onNodeSelect)="onNodeSelect($event)">
|
||||||
|
|
||||||
|
<ng-template let-node pTemplate="default">
|
||||||
|
<div>{{node.label}}</div>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
<ng-template let-node pTemplate="infra">
|
||||||
|
<div (contextmenu)="nodeMenu($event, node)">
|
||||||
|
<div>{{node.label}}</div>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
<ng-template let-node pTemplate="probe">
|
||||||
|
<div (contextmenu)="nodeMenu($event, node)">
|
||||||
|
<div>{{node.label}}</div>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
<ng-template let-node pTemplate="host">
|
||||||
|
<div (contextmenu)="nodeMenu($event, node)">
|
||||||
|
<div>{{node.label}}</div>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
<ng-template let-node pTemplate="service">
|
||||||
|
<div (contextmenu)="nodeMenu($event, node)">
|
||||||
|
<div>{{node.label}}</div>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
<ng-template let-node pTemplate="sensor">
|
||||||
|
<div (contextmenu)="nodeMenu($event, node)">
|
||||||
|
<div>
|
||||||
|
<i class="fa ui-icon-stop ui-status-icon ui-status-success"></i>{{node.label}}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{{node.obj.itemCount}} SensorItems
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
</p-tree> -->
|
|
@ -1,15 +1,112 @@
|
||||||
import {
|
import {
|
||||||
Component
|
Component, Input, OnChanges, SimpleChanges, OnInit
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
import { Infra } from '@overflow/commons-typescript/model/infra';
|
||||||
|
import { InfraHost as InfraTypeHost } from '@overflow/commons-typescript/model/infra';
|
||||||
|
import { InfraService as InfraTypeService } from '@overflow/commons-typescript/model/infra';
|
||||||
|
import { Observable, of } from 'rxjs';
|
||||||
|
import { catchError, exhaustMap, map, tap, take } from 'rxjs/operators';
|
||||||
|
import { TreeNode } from 'primeng/primeng';
|
||||||
|
import { PageParams, Page } from '@overflow/commons-typescript/core/model';
|
||||||
|
import { ProbeHost } from '@overflow/commons-typescript';
|
||||||
|
import { InfraService } from '../service/infra.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'of-infra-tree',
|
selector: 'of-infra-tree',
|
||||||
templateUrl: './infra-tree.component.html',
|
templateUrl: './infra-tree.component.html',
|
||||||
})
|
})
|
||||||
export class InfraTreeComponent {
|
export class InfraTreeComponent implements OnInit, OnChanges {
|
||||||
|
|
||||||
|
@Input() probeHost: ProbeHost;
|
||||||
|
|
||||||
|
infras: Infra[];
|
||||||
|
pending$: Observable<boolean>;
|
||||||
|
error$: Observable<any>;
|
||||||
|
|
||||||
|
zoneNode: TreeNode[] = [];
|
||||||
|
hostNode: TreeNode[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private infraService: InfraService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.zoneNode.push({
|
||||||
|
label: this.probeHost.probe.cidr,
|
||||||
|
type: 'ZONE',
|
||||||
|
data: {
|
||||||
|
},
|
||||||
|
children: this.hostNode,
|
||||||
|
expanded: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
this.getInfras();
|
||||||
|
}
|
||||||
|
|
||||||
|
getInfras() {
|
||||||
|
const pageParams: PageParams = {
|
||||||
|
pageNo: 0,
|
||||||
|
countPerPage: 99999,
|
||||||
|
sortCol: 'id',
|
||||||
|
sortDirection: 'descending'
|
||||||
|
};
|
||||||
|
this.infraService.readAllByProbeID(this.probeHost.probe.id, pageParams)
|
||||||
|
.pipe(
|
||||||
|
tap(() => {
|
||||||
|
this.pending$ = of(true);
|
||||||
|
}),
|
||||||
|
map((infraPage: Page<Infra>) => {
|
||||||
|
this.infras = infraPage.content;
|
||||||
|
this.generateTreeData(this.infras);
|
||||||
|
}),
|
||||||
|
catchError(error => {
|
||||||
|
this.error$ = of(error);
|
||||||
|
return of();
|
||||||
|
}),
|
||||||
|
tap(() => {
|
||||||
|
this.pending$ = of(false);
|
||||||
|
}),
|
||||||
|
take(1),
|
||||||
|
).subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
|
generateTreeData(infras: Infra[]) {
|
||||||
|
infras.forEach(infra => {
|
||||||
|
switch (infra.metaInfraType.id) { // TODO: fix to enum
|
||||||
|
case 2: // InfraHost
|
||||||
|
this.addHost(infra);
|
||||||
|
break;
|
||||||
|
case 7: // InfraService
|
||||||
|
// this.addService(infra);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
addHost(infraHost: InfraTypeHost) {
|
||||||
|
this.hostNode.push({
|
||||||
|
type: 'HOST',
|
||||||
|
label: infraHost.ipv4,
|
||||||
|
data: {
|
||||||
|
target: infraHost
|
||||||
|
},
|
||||||
|
expanded: true,
|
||||||
|
children: []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
addService(infraService: InfraTypeService) {
|
||||||
|
this.hostNode[0].children.push({
|
||||||
|
type: 'SERVICE',
|
||||||
|
label: 'TODO',
|
||||||
|
data: {
|
||||||
|
target: infraService
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,11 +61,9 @@ export class ListComponent implements OnInit, OnChanges {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
console.log(changes);
|
|
||||||
if (changes['pageIdx'] && this.paginator) {
|
if (changes['pageIdx'] && this.paginator) {
|
||||||
|
|
||||||
const pageParams: PageParams = {
|
const pageParams: PageParams = {
|
||||||
pageNo: this.pageIdx - 1,
|
pageNo: this.pageIdx,
|
||||||
countPerPage: 2,
|
countPerPage: 2,
|
||||||
sortCol: 'id',
|
sortCol: 'id',
|
||||||
sortDirection: 'descending',
|
sortDirection: 'descending',
|
||||||
|
|
3638
package-lock.json
generated
3638
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user