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