fixed discovery
This commit is contained in:
parent
cb22bd642a
commit
c3ac713f99
|
@ -42,6 +42,11 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
|||
|
||||
settingSucceed$: any;
|
||||
discoveryResult$: any;
|
||||
|
||||
discoveryReq$: any;
|
||||
discoveryStart$: any;
|
||||
discoveryEnd$: any;
|
||||
|
||||
probe: Probe = null;
|
||||
started = false;
|
||||
|
||||
|
@ -92,11 +97,14 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
|||
) {
|
||||
this.settingSucceed$ = discoverdstore.pipe(select(SettingSelector.select('isStart')));
|
||||
this.discoveryResult$ = this.discoverstore.pipe(select(DiscoverSelector.select('zones')));
|
||||
this.discoveryReq$ = this.discoverstore.pipe(select(DiscoverSelector.select('isReq')));
|
||||
this.discoveryStart$ = this.discoverstore.pipe(select(DiscoverSelector.select('isStart')));
|
||||
this.discoveryEnd$ = this.discoverstore.pipe(select(DiscoverSelector.select('isEnd')));
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.treeNodes = this.convertViewHost(this.testObj);
|
||||
// this.treeNodes = this.convertViewHost(this.testObj);
|
||||
|
||||
this.settingSucceed$.subscribe(
|
||||
(succeed: boolean) => {
|
||||
|
@ -122,10 +130,53 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
|||
|
||||
this.discoveryResult$.subscribe(
|
||||
(zones: Map<string, Zone>) => {
|
||||
|
||||
if (zones !== undefined && zones !== null) {
|
||||
console.log('ZoneZoneZoneZoneZoneZoneZone');
|
||||
// console.log(JSON.stringify(zones));
|
||||
this.treeNodes = this.convertTreeViewZone(zones);
|
||||
this.zones = zones;
|
||||
}
|
||||
|
||||
},
|
||||
(error: RPCClientError) => {
|
||||
console.log(error.response.message);
|
||||
}
|
||||
);
|
||||
|
||||
this.discoveryReq$.subscribe(
|
||||
(isReq: boolean) => {
|
||||
|
||||
if (isReq !== undefined && isReq !== null) {
|
||||
console.log('isReqisReqisReqisReq');
|
||||
}
|
||||
|
||||
},
|
||||
(error: RPCClientError) => {
|
||||
console.log(error.response.message);
|
||||
}
|
||||
);
|
||||
|
||||
this.discoveryReq$.subscribe(
|
||||
(isStart: boolean) => {
|
||||
|
||||
if (isStart !== undefined && isStart !== null) {
|
||||
console.log('isStartisStartisStart');
|
||||
}
|
||||
|
||||
},
|
||||
(error: RPCClientError) => {
|
||||
console.log(error.response.message);
|
||||
}
|
||||
);
|
||||
|
||||
this.discoveryEnd$.subscribe(
|
||||
(isEnd: boolean) => {
|
||||
|
||||
if (isEnd !== undefined && isEnd !== null) {
|
||||
console.log('isEndisEndisEndisEnd');
|
||||
}
|
||||
|
||||
},
|
||||
(error: RPCClientError) => {
|
||||
console.log(error.response.message);
|
||||
|
@ -140,11 +191,11 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
|||
|
||||
isZone(zone: Zone): boolean {
|
||||
|
||||
for (let i = 0; i < this.treeNodes.length; ++i) {
|
||||
if (zone.iface === this.treeNodes[i].iface) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// for (let i = 0; i < this.treeNodes.length; ++i) {
|
||||
// if (zone.iface === this.treeNodes[i].iface) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -20,10 +20,17 @@ import {
|
|||
export function reducer(state = initialState, action: Actions): State {
|
||||
switch (action.type) {
|
||||
case ActionType.DiscoveryStart: {
|
||||
return state;
|
||||
|
||||
return {
|
||||
...state,
|
||||
isStart: true
|
||||
};
|
||||
}
|
||||
case ActionType.DiscoveryStop: {
|
||||
return state;
|
||||
return {
|
||||
...state,
|
||||
isEnd: true
|
||||
};
|
||||
}
|
||||
case ActionType.DiscoveredZone: {
|
||||
const zone: Zone = <Zone>action.payload;
|
||||
|
@ -160,24 +167,28 @@ export function reducer(state = initialState, action: Actions): State {
|
|||
zone.hosts = new Map();
|
||||
}
|
||||
|
||||
zone.hosts.set(service.port.host.ip, service.port.host);
|
||||
|
||||
// if (undefined === zone) {
|
||||
// console.error(`Discovery.DiscoveredService: Zone[${service.port.host.zone.network}] is not exist`);
|
||||
// }
|
||||
// if (null === zone.hosts || undefined === zone.hosts.get(service.port.host.ip)) {
|
||||
// console.error(`Discovery.DiscoveredPort: Host[${service.port.host.ip}] is not exist`);
|
||||
// }
|
||||
const host: Host = zone.hosts.get(service.port.host.ip);
|
||||
let host: Host = null;
|
||||
host = zone.hosts.get(service.port.host.ip);
|
||||
|
||||
if (null === host.ports || undefined === host.ports) {
|
||||
if (host === undefined || host === null) {
|
||||
zone.hosts.set(service.port.host.ip, service.port.host);
|
||||
host = service.port.host;
|
||||
}
|
||||
|
||||
if (undefined === host.ports || null === host.ports) {
|
||||
host.ports = new Map();
|
||||
host.ports.set(service.port.portNumber, service.port);
|
||||
}
|
||||
|
||||
const port: Port = host.ports.get(service.port.portNumber);
|
||||
|
||||
if (null === port.services || undefined === port.services) {
|
||||
if ( undefined === port.services || null === port.services) {
|
||||
port.services = new Map();
|
||||
}
|
||||
port.services.set(service.serviceName, service);
|
||||
|
|
|
@ -6,11 +6,17 @@ export interface State {
|
|||
error: RPCClientError | null;
|
||||
processing: boolean;
|
||||
zones: Map<string, Zone> | null;
|
||||
isReq: boolean;
|
||||
isStart: boolean;
|
||||
isEnd: boolean;
|
||||
}
|
||||
|
||||
export const initialState: State = {
|
||||
error: null,
|
||||
processing: false,
|
||||
zones: null,
|
||||
isReq: false,
|
||||
isStart: false,
|
||||
isEnd: false
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user