From d11770821e9785e49518b793973516c2b50812ad Mon Sep 17 00:00:00 2001 From: insanity Date: Fri, 15 Jun 2018 21:31:44 +0900 Subject: [PATCH] map in progress --- .../component/search-config.component.html | 1 + .../infra/component/infra-tree.component.html | 14 +++- .../infra/component/infra-tree.component.ts | 70 +++++++++++-------- .../meta-service-type-selector.component.html | 38 ++++++---- .../meta-service-type-selector.component.ts | 40 ++++++++--- .../meta/service/meta-target-type.service.ts | 4 +- .../component/probe-general.component.html | 7 +- .../component/probe-general.component.ts | 19 +++-- .../probe/component/probe-host.component.html | 4 +- 9 files changed, 127 insertions(+), 70 deletions(-) diff --git a/@overflow/discovery/component/search-config.component.html b/@overflow/discovery/component/search-config.component.html index b66bf19..c2e3211 100644 --- a/@overflow/discovery/component/search-config.component.html +++ b/@overflow/discovery/component/search-config.component.html @@ -86,6 +86,7 @@
+
diff --git a/@overflow/infra/component/infra-tree.component.html b/@overflow/infra/component/infra-tree.component.html index a1cdf99..d8e90f6 100644 --- a/@overflow/infra/component/infra-tree.component.html +++ b/@overflow/infra/component/infra-tree.component.html @@ -5,14 +5,24 @@
- {{node.label}} +
+ {{node.label}} +
+
+ {{node.data.subLabel}} +
- {{node.label}} +
+ {{node.label}} +
+
+ {{node.data.subLabel}} +
diff --git a/@overflow/infra/component/infra-tree.component.ts b/@overflow/infra/component/infra-tree.component.ts index 73125fe..210eb51 100644 --- a/@overflow/infra/component/infra-tree.component.ts +++ b/@overflow/infra/component/infra-tree.component.ts @@ -1,15 +1,13 @@ import { Component, Input, OnChanges, SimpleChanges, OnInit, ViewChild } 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 { InfraService, InfraHost, InfraZone, Infra } from '@overflow/commons-typescript/model/infra'; import { Observable, of } from 'rxjs'; import { catchError, exhaustMap, map, tap, take } from 'rxjs/operators'; import { TreeNode, MenuItem, ContextMenu } from 'primeng/primeng'; import { PageParams, Page } from '@overflow/commons-typescript/core/model'; -import { ProbeHost } from '@overflow/commons-typescript'; -import { InfraService } from '../service/infra.service'; +import { ProbeHost, MetaInfraTypeEnum } from '@overflow/commons-typescript'; +import { InfraService as InfraCRUDService } from '../service/infra.service'; @Component({ selector: 'of-infra-tree', @@ -36,19 +34,11 @@ export class InfraTreeComponent implements OnInit, OnChanges { @ViewChild('cmService') cmService: ContextMenu; constructor( - private infraService: InfraService, + private infraService: InfraCRUDService, ) { } ngOnInit(): void { - this.zoneNode.push({ - label: this.probeHost.probe.cidr, - type: 'ZONE', - data: { - }, - children: this.hostNode, - expanded: true - }); this.initContextMenu(); } @@ -73,8 +63,7 @@ export class InfraTreeComponent implements OnInit, OnChanges { } ngOnChanges(changes: SimpleChanges): void { - console.log(changes); - if (changes['probeHost'].isFirstChange ) { + if (changes['probeHost'].isFirstChange) { this.zoneNode = []; this.hostNode = []; this.getInfras(); @@ -111,11 +100,14 @@ export class InfraTreeComponent implements OnInit, OnChanges { generateTreeData(infras: Infra[]) { infras.forEach(infra => { - switch (infra.metaInfraType.id) { // TODO: fix to enum - case 2: // InfraHost + switch (infra.metaInfraType.key) { + case MetaInfraTypeEnum.ZONE: + this.addZone(infra); + break; + case MetaInfraTypeEnum.HOST: this.addHost(infra); break; - case 7: // InfraService + case MetaInfraTypeEnum.HOST: this.addService(infra); break; default: @@ -124,19 +116,36 @@ export class InfraTreeComponent implements OnInit, OnChanges { }); } - addHost(infraHost: InfraTypeHost) { + addZone(infraZone: InfraZone) { + this.zoneNode.push({ + label: infraZone.network + '(' + infraZone.iface + ')', + type: 'ZONE', + data: { + target: infraZone, + subLabel: 'Something to display' + }, + children: this.hostNode, + expanded: true + }); + } + + addHost(infraHost: InfraHost) { + let ipAddr = infraHost.infraHostIPs[0].address.split('/')[0]; + if (infraHost.infraHostOS && infraHost.infraHostOS.name) { + ipAddr += '(' + infraHost.infraHostOS.name + ')'; + } this.hostNode.push({ type: 'HOST', - label: infraHost.infraHostIPs[0].address, + label: ipAddr, data: { - target: infraHost + target: infraHost, }, expanded: true, children: [] }); } - addService(infraService: InfraTypeService) { + addService(infraService: InfraService) { const idx = this.findHostIndex(infraService); if (idx === -1) { // this.addHost(infraService.infraHost); @@ -152,13 +161,16 @@ export class InfraTreeComponent implements OnInit, OnChanges { }); } - findHostIndex(infraService: InfraTypeService): number { - const idx = -1; + findHostIndex(infraService: InfraService): number { + let idx = -1; this.hostNode.forEach((node, index) => { - // if (node.data.target.id === infraService.infraHost.id) { - // idx = index; - // return; - // } + const infraHost: InfraHost = node.data.target; + for (const infraHostIP of infraHost.infraHostIPs) { + if (infraHostIP.id === infraService.infraHostPort.infraHostIP.id) { + idx = index; + return; + } + } }); return idx; } diff --git a/@overflow/meta/component/meta-service-type-selector.component.html b/@overflow/meta/component/meta-service-type-selector.component.html index b50a77c..bd37ca8 100644 --- a/@overflow/meta/component/meta-service-type-selector.component.html +++ b/@overflow/meta/component/meta-service-type-selector.component.html @@ -1,15 +1,27 @@ - - +
+ + + +
+ + +
- -
- - -
-
{{service.name}}
-
+ + + + + + + {{rowData.name}} + + -
-
-
\ No newline at end of file + +
+
\ No newline at end of file diff --git a/@overflow/meta/component/meta-service-type-selector.component.ts b/@overflow/meta/component/meta-service-type-selector.component.ts index 4199f71..8bd7149 100644 --- a/@overflow/meta/component/meta-service-type-selector.component.ts +++ b/@overflow/meta/component/meta-service-type-selector.component.ts @@ -3,7 +3,6 @@ import { Store, select } from '@ngrx/store'; import { Observable, of, Subscription } from 'rxjs'; import { catchError, exhaustMap, map, tap, take } from 'rxjs/operators'; - import { MetaCrawler, MetaTargetServiceType, MetaInfraTypeEnum, toMetaInfraTypeEnum, toMetaInfraType, MetaTargetType } from '@overflow/commons-typescript/model/meta'; import { MetaCrawlerService } from '../service/meta-crawler.service'; import { MetaTargetTypeService } from '../service/meta-target-type.service'; @@ -15,9 +14,12 @@ import { MetaTargetTypeService } from '../service/meta-target-type.service'; }) export class MetaServiceTypeSelectorComponent implements OnInit { - @Output() selected = new EventEmitter(); + includeServices: MetaTargetType[]; - metaTargetServiceTypes: MetaTargetServiceType[]; + @Output() change = new EventEmitter(); + @Input() disabled: boolean; + + metaTargetTypes: MetaTargetType[]; pending$: Observable; error$: Observable; @@ -26,25 +28,47 @@ export class MetaServiceTypeSelectorComponent implements OnInit { ) { } ngOnInit() { - this.metaTargetTypeService.readAllByMetaInfraType - (toMetaInfraType(MetaInfraTypeEnum.SERVICE)) + this.metaTargetTypeService.readAllByMetaInfraTypeKey("SERVICE") .pipe( tap(() => { this.pending$ = of(true); }), map((metaTargetTypes: MetaTargetType[]) => { - this.metaTargetServiceTypes = metaTargetTypes; - console.log(this.metaTargetServiceTypes); + console.log(metaTargetTypes); + this.metaTargetTypes = metaTargetTypes; }), catchError(error => { this.error$ = of(error); - return of(); + return of(null); }), tap(() => { this.pending$ = of(false); + this.includeServices = this.metaTargetTypes.slice(); + this.change.emit(this.includeServices); }), take(1), ).subscribe(); } + + onSelectAll() { + this.includeServices = []; + this.metaTargetTypes.forEach((value) => { + this.includeServices.push(value); + }); + this.change.emit(this.includeServices); + } + + onUnselectAll() { + this.includeServices = []; + this.change.emit(this.includeServices); + } + + onSelect(service: MetaTargetType) { + this.change.emit(this.includeServices); + } + onUnselect(service: MetaTargetType) { + this.change.emit(this.includeServices); + } + } diff --git a/@overflow/meta/service/meta-target-type.service.ts b/@overflow/meta/service/meta-target-type.service.ts index ad7babc..c71e454 100644 --- a/@overflow/meta/service/meta-target-type.service.ts +++ b/@overflow/meta/service/meta-target-type.service.ts @@ -20,7 +20,7 @@ export class MetaTargetTypeService { return this.rpcService.call('MetaTargetTypeService.readAll'); } - public readAllByMetaInfraType(metaInfraType: MetaInfraType): Observable { - return this.rpcService.call('MetaTargetTypeService.readAllByMetaInfraType', metaInfraType); + public readAllByMetaInfraTypeKey(key: string): Observable { + return this.rpcService.call('MetaTargetTypeService.readAllByMetaInfraTypeKey', key); } } diff --git a/@overflow/probe/component/probe-general.component.html b/@overflow/probe/component/probe-general.component.html index ec448ea..1a5d626 100644 --- a/@overflow/probe/component/probe-general.component.html +++ b/@overflow/probe/component/probe-general.component.html @@ -10,7 +10,7 @@
- +
@@ -25,9 +25,8 @@
Name - -
{{displayNameErrMsg}}
+ +
{{nameErrMsg}}
diff --git a/@overflow/probe/component/probe-general.component.ts b/@overflow/probe/component/probe-general.component.ts index 1b1f166..65781e5 100644 --- a/@overflow/probe/component/probe-general.component.ts +++ b/@overflow/probe/component/probe-general.component.ts @@ -22,9 +22,9 @@ export class ProbeGeneralComponent implements OnInit { pending$: Observable; editMode = false; - displayNameErrMsg: string; + nameErrMsg: string; descriptionErrMsg: string; - displayName: string; + name: string; description: string; constructor( @@ -61,13 +61,13 @@ export class ProbeGeneralComponent implements OnInit { } } - onDisplayNameEditing(value: string) { - const msg: string = this.checkValidDisplayName(value); + onNameEditing(value: string) { + const msg: string = this.checkValidName(value); if (msg !== null) { - this.displayNameErrMsg = msg; + this.nameErrMsg = msg; } else { - this.displayNameErrMsg = null; - this.displayName = value.trim(); + this.nameErrMsg = null; + this.name = value.trim(); } } @@ -82,7 +82,7 @@ export class ProbeGeneralComponent implements OnInit { } onEditSave() { - this.probe.name = this.displayName ? this.displayName : this.probe.name; + this.probe.name = this.name ? this.name : this.probe.name; this.probe.description = this.description ? this.description : this.probe.description; this.probeService.modify(this.probe) @@ -106,7 +106,7 @@ export class ProbeGeneralComponent implements OnInit { ).subscribe(); } - checkValidDisplayName(value: string): string | null { + checkValidName(value: string): string | null { if (value.length <= 2 || value.length > 20) { return 'displayname length : 3 ~ 20'; } @@ -128,4 +128,3 @@ export class ProbeGeneralComponent implements OnInit { return null; } } - diff --git a/@overflow/probe/component/probe-host.component.html b/@overflow/probe/component/probe-host.component.html index 05dd1e5..0184bce 100644 --- a/@overflow/probe/component/probe-host.component.html +++ b/@overflow/probe/component/probe-host.component.html @@ -19,7 +19,7 @@
- +
@@ -31,7 +31,7 @@
- +