add discovery notification
This commit is contained in:
parent
7668875fb2
commit
9100dddacd
|
@ -4,13 +4,14 @@ import { Store, select } from '@ngrx/store';
|
|||
import { RPCError } from 'packages/core/rpc/error';
|
||||
import {
|
||||
DiscoveryStartInfo,
|
||||
DiscoveryZone
|
||||
DiscoveryZone,
|
||||
Zone
|
||||
} from '../../model';
|
||||
import * as CIDR from 'ip-cidr';
|
||||
import * as DiscoveredStore from '../../store/setting';
|
||||
import * as DiscoverStore from '../../store/notification';
|
||||
|
||||
import { SettingSelector } from '../../store';
|
||||
import { SettingSelector, NotificationSelector } from '../../store';
|
||||
|
||||
@Component({
|
||||
selector: 'of-setting',
|
||||
|
@ -20,6 +21,8 @@ import { SettingSelector } from '../../store';
|
|||
export class SettingComponent implements OnInit, AfterContentInit {
|
||||
|
||||
settingSucceed$ = this.discoverdstore.pipe(select(SettingSelector.select('isStart')));
|
||||
discoveryResult$ = this.discoverstore.pipe(select(NotificationSelector.select('getDiscoveryResult')));
|
||||
|
||||
started = false;
|
||||
|
||||
cidr;
|
||||
|
@ -60,6 +63,17 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
|||
console.log(error.response.message);
|
||||
}
|
||||
);
|
||||
|
||||
this.discoveryResult$.subscribe(
|
||||
(zone: Zone) => {
|
||||
this.convertTreeView(zone);
|
||||
},
|
||||
(error: RPCError) => {
|
||||
console.log(error.response.message);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
ngAfterContentInit() {
|
||||
|
@ -143,7 +157,18 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
|||
console.log(this.checkedSet);
|
||||
}
|
||||
|
||||
findHost(host) {
|
||||
convertTreeView(zone: Zone) {
|
||||
|
||||
const treeNodes = this.convertViewHost(zone.hosts);
|
||||
|
||||
console.log(treeNodes);
|
||||
}
|
||||
|
||||
convertViewHost(hosts): any[] {
|
||||
|
||||
const treeNodes: any[] = [];
|
||||
|
||||
hosts.forEach((host, hostKey) => {
|
||||
|
||||
const jHost: any = {
|
||||
title: 'Host - ' + host.ip,
|
||||
|
@ -151,9 +176,25 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
|||
};
|
||||
jHost.obj = host;
|
||||
|
||||
jHost.children = this.convertViewPort(host.ports);
|
||||
|
||||
treeNodes.push(jHost);
|
||||
|
||||
});
|
||||
|
||||
return treeNodes;
|
||||
|
||||
}
|
||||
|
||||
findPort(port) {
|
||||
convertViewPort(ports): any[] {
|
||||
|
||||
if (ports === undefined && ports.size <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const portChildren: any[] = [];
|
||||
|
||||
ports.forEach((port, portKey) => {
|
||||
|
||||
const jPort: any = {
|
||||
title: 'Port - ' + port.portNumber,
|
||||
|
@ -161,20 +202,41 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
|||
};
|
||||
jPort.obj = port;
|
||||
|
||||
jPort.children = this.convertViewService(port.services);
|
||||
|
||||
portChildren.push(jPort);
|
||||
} );
|
||||
|
||||
|
||||
return portChildren;
|
||||
}
|
||||
|
||||
findService(service) {
|
||||
convertViewService(services): any[] {
|
||||
|
||||
if (services === undefined && services.size <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const serviceChildren: any[] = [];
|
||||
|
||||
services.forEach((service, serviceKey) => {
|
||||
const jService: any = {
|
||||
title: 'Service - ' + service.serviceName,
|
||||
className : 'cn' + service.serviceName,
|
||||
};
|
||||
jService.obj = service;
|
||||
|
||||
serviceChildren.push(jService);
|
||||
});
|
||||
|
||||
return serviceChildren;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const nodes = [
|
||||
{
|
||||
title: 'host - 3232235781',
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { Effects } from './notification.effect';
|
||||
|
||||
describe('Notification.Effects', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [Effects]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([Effects], (effects: Effects) => {
|
||||
expect(effects).toBeTruthy();
|
||||
}));
|
||||
});
|
|
@ -13,3 +13,6 @@ export const initialState: State = {
|
|||
processing: false,
|
||||
zones: null,
|
||||
};
|
||||
|
||||
|
||||
export const getDiscoveryResult = (state: State) => state.zones;
|
||||
|
|
Loading…
Reference in New Issue
Block a user