changed key
This commit is contained in:
parent
b235498bf1
commit
d895efd684
|
@ -75,18 +75,8 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery
|
|||
this.setState({ serviceState: newServiceStateMap });
|
||||
}
|
||||
|
||||
public onCheckHost = (host: Host, key: string) => {
|
||||
console.log('aa');
|
||||
}
|
||||
public onCheckPort = (port: Port, key: string) => {
|
||||
console.log('aa');
|
||||
}
|
||||
public onCheckService = (service: Service, key: string) => {
|
||||
console.log('aa');
|
||||
}
|
||||
|
||||
public onCheck = (checkProps: CheckboxProps, checkState: Map<string, boolean>, key: string, stateKey: string,
|
||||
selectedMap: Map<string, any>, selectedObj: any) => {
|
||||
selectedMap: Map<string, any>, selectedObj: Host | Port | Service) => {
|
||||
let newCheckState = _.clone(checkState);
|
||||
newCheckState[key] = !newCheckState[key];
|
||||
let state: any = {};
|
||||
|
@ -98,6 +88,10 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery
|
|||
} else {
|
||||
delete selectedMap[key];
|
||||
}
|
||||
|
||||
// if(selectedObj instanceof Host) {
|
||||
// console.log(selectedObj);
|
||||
// }
|
||||
}
|
||||
|
||||
public renderDiscovery(): JSX.Element[] {
|
||||
|
@ -108,7 +102,7 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery
|
|||
let host: Host;
|
||||
for (let index: number = 0; index < hostList.length; ++index) {
|
||||
host = hostList[index];
|
||||
let key: string = String(index);
|
||||
let key: string = String(host.ip);
|
||||
elems.push(
|
||||
<List.Item key={key} >
|
||||
<List.Icon name={host.ports ? (this.state.portState[key] ? 'chevron up' : 'chevron down') : 'file'}
|
||||
|
@ -123,7 +117,7 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery
|
|||
}} />
|
||||
</List.Header>
|
||||
<List.Description style={{ marginLeft: '26px' }}>Host</List.Description>
|
||||
{host.ports ? (this.state.portState[key] ? this.renderPort(host.ports, index) : null) : null}
|
||||
{host.ports ? (this.state.portState[key] ? this.renderPort(host.ports, key) : null) : null}
|
||||
</List.Content>
|
||||
</List.Item>,
|
||||
);
|
||||
|
@ -131,7 +125,7 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery
|
|||
return elems;
|
||||
}
|
||||
|
||||
public renderPort(portList: Port[], hostIndex: number): JSX.Element[] {
|
||||
public renderPort(portList: Port[], hostKey: string): JSX.Element[] {
|
||||
|
||||
if (portList === undefined) {
|
||||
return null;
|
||||
|
@ -141,7 +135,7 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery
|
|||
let port: Port;
|
||||
for (let index: number = 0; index < portList.length; ++index) {
|
||||
port = portList[index];
|
||||
let key: string = String(hostIndex) + '-' + String(index);
|
||||
let key: string = hostKey + '-' + String(port.portNumber);
|
||||
elems.push(
|
||||
<List.List key={key}>
|
||||
<List.Item >
|
||||
|
@ -170,7 +164,7 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery
|
|||
let service: Service;
|
||||
for (let index: number = 0; index < serviceList.length; ++index) {
|
||||
service = serviceList[index];
|
||||
let key: string = portKey + '-' + String(index);
|
||||
let key: string = portKey + '-' + service.serviceName;
|
||||
elems.push(
|
||||
<List.List key={key}>
|
||||
<List.Item >
|
||||
|
@ -209,6 +203,16 @@ export class DiscoveryTree extends React.Component<DiscoveryTreeProps, Discovery
|
|||
);
|
||||
}
|
||||
|
||||
private getHostKey(host: Host): string {
|
||||
return String(host.ip);
|
||||
}
|
||||
private getPortKey(host: Host, port: Port): string {
|
||||
return String(host.ip) + '-' + String(port.portNumber);
|
||||
}
|
||||
private GetServiceKey(host: Host, port: Port, service: Service): string {
|
||||
return String(host.ip) + '-' + String(port.portNumber) + '-' + service.serviceName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user