discovery ing
This commit is contained in:
parent
58e33421ad
commit
7e869cb965
11
src/ts/@overflow/discovery/api/model/Zone.ts
Normal file
11
src/ts/@overflow/discovery/api/model/Zone.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
export interface Zone {
|
||||
id: number;
|
||||
network: string;
|
||||
ip: string;
|
||||
iface: string;
|
||||
mac: string;
|
||||
firstScanRange: number;
|
||||
lastScanRange: number;
|
||||
}
|
||||
|
||||
export default Zone;
|
|
@ -5,6 +5,7 @@ import * as DiscoveryIngActions from '../../redux/action/ing';
|
|||
import Host from '../model/Host';
|
||||
import Port from '../model/Port';
|
||||
import DisService from '../model/Service';
|
||||
import Zone from '../model/Zone';
|
||||
|
||||
export class DiscoveryService extends Service {
|
||||
// tslint:disable-next-line:no-empty
|
||||
|
@ -21,6 +22,13 @@ export class DiscoveryService extends Service {
|
|||
console.log(params);
|
||||
}
|
||||
|
||||
public discoveryIngZone(params: any): void {
|
||||
let zone: Zone = params;
|
||||
|
||||
console.log('discoveryIngZone');
|
||||
this.dispatch(DiscoveryIngActions.RECEIVE_ZONE, zone);
|
||||
}
|
||||
|
||||
public discoveryIngHost(params: any): void {
|
||||
|
||||
let host: Host = params;
|
||||
|
|
|
@ -93,8 +93,6 @@ export class Discovery extends React.Component<Props, State> {
|
|||
|
||||
let idx: number = Math.floor(Math.random() * (max - min + 1) + min);
|
||||
|
||||
|
||||
|
||||
switch(idx) {
|
||||
case 1:
|
||||
this.testHost();
|
||||
|
|
|
@ -4,6 +4,7 @@ export type REQUEST = '@overflow/discovery/ing/REQUEST';
|
|||
export type REQUEST_SUCCESS = '@overflow/discovery/ing/REQUEST/SUCCESS';
|
||||
export type REQUEST_FAILURE = '@overflow/discovery/ing/REQUEST/FAILURE';
|
||||
|
||||
export type RECEIVE_ZONE = '@overflow/discovery/zone/RECEIVE';
|
||||
export type RECEIVE_HOST = '@overflow/discovery/host/RECEIVE';
|
||||
export type RECEIVE_PORT = '@overflow/discovery/port/RECEIVE';
|
||||
export type RECEIVE_SERVICE = '@overflow/discovery/service/RECEIVE';
|
||||
|
@ -12,6 +13,7 @@ export const REQUEST: REQUEST = '@overflow/discovery/ing/REQUEST';
|
|||
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/discovery/ing/REQUEST/SUCCESS';
|
||||
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/discovery/ing/REQUEST/FAILURE';
|
||||
|
||||
export const RECEIVE_ZONE: RECEIVE_ZONE = '@overflow/discovery/zone/RECEIVE';
|
||||
export const RECEIVE_HOST: RECEIVE_HOST = '@overflow/discovery/host/RECEIVE';
|
||||
export const RECEIVE_PORT: RECEIVE_PORT = '@overflow/discovery/port/RECEIVE';
|
||||
export const RECEIVE_SERVICE: RECEIVE_SERVICE = '@overflow/discovery/service/RECEIVE';
|
||||
|
|
|
@ -5,6 +5,7 @@ import * as _ from 'lodash';
|
|||
import Host from '../../api/model/Host';
|
||||
import Port from '../../api/model/Port';
|
||||
import Service from '../../api/model/Service';
|
||||
import Zone from '../../api/model/Zone';
|
||||
|
||||
import * as IngActionTypes from '../action/ing';
|
||||
import {
|
||||
|
@ -15,6 +16,13 @@ import {
|
|||
} from '../state/Ing';
|
||||
|
||||
const reducer: ReducersMapObject = {
|
||||
[IngActionTypes.RECEIVE_ZONE]: (state: DiscoveryIngState = DiscoveryIngDefaultState,
|
||||
action: Action<Zone>): DiscoveryIngState => {
|
||||
|
||||
return {
|
||||
...state,
|
||||
};
|
||||
},
|
||||
[IngActionTypes.RECEIVE_HOST]: (state: DiscoveryIngState = DiscoveryIngDefaultState,
|
||||
action: Action<Host>): DiscoveryIngState => {
|
||||
|
||||
|
@ -94,10 +102,11 @@ const reducer: ReducersMapObject = {
|
|||
let nPort: Port = _.clone(port);
|
||||
nPort.host = nHost;
|
||||
|
||||
let dIdx: number = hostList.indexOf(h, 0);
|
||||
if(dIdx > -1) {
|
||||
hostList.slice(dIdx, 1);
|
||||
}
|
||||
// let dIdx: number = hostList.indexOf(h, 0);
|
||||
// if(dIdx > -1) {
|
||||
// hostList.slice(dIdx, 1);
|
||||
// }
|
||||
hostList = removeArray(hostList, h);
|
||||
nHost.ports.push(nPort);
|
||||
hostList.push(nHost);
|
||||
}
|
||||
|
@ -176,14 +185,20 @@ const reducer: ReducersMapObject = {
|
|||
nPort.host = nHost;
|
||||
service.port = nPort;
|
||||
|
||||
let dIdx: number = hostList.indexOf(h, 0);
|
||||
if(dIdx > -1) {
|
||||
hostList.slice(dIdx, 1);
|
||||
}
|
||||
dIdx = nHost.ports.indexOf(p, 0);
|
||||
if(dIdx > -1) {
|
||||
nHost.ports.slice(dIdx, 1);
|
||||
}
|
||||
// let dIdx: number = hostList.indexOf(h, 0);
|
||||
// if(dIdx > -1) {
|
||||
// hostList.slice(dIdx, 1);
|
||||
// }
|
||||
|
||||
hostList = removeArray(hostList, h);
|
||||
|
||||
// dIdx = nHost.ports.indexOf(p, 0);
|
||||
// if(dIdx > -1) {
|
||||
// nHost.ports.slice(dIdx, 1);
|
||||
// }
|
||||
|
||||
nHost.ports = removeArray(nHost.ports, p);
|
||||
|
||||
nPort.services.push(service);
|
||||
nHost.ports.push(nPort);
|
||||
hostList.push(nHost);
|
||||
|
@ -222,10 +237,13 @@ const reducer: ReducersMapObject = {
|
|||
nPort.host = nHost;
|
||||
service.port = nPort;
|
||||
|
||||
let dIdx: number = hostList.indexOf(h, 0);
|
||||
if(dIdx > -1) {
|
||||
hostList.slice(dIdx, 1);
|
||||
}
|
||||
// let dIdx: number = hostList.indexOf(h, 0);
|
||||
// if(dIdx > -1) {
|
||||
// hostList.slice(dIdx, 1);
|
||||
// }
|
||||
|
||||
hostList = removeArray(hostList, h);
|
||||
|
||||
nPort.services.push(service);
|
||||
nHost.ports.push(nPort);
|
||||
hostList.push(nHost);
|
||||
|
@ -262,4 +280,14 @@ const reducer: ReducersMapObject = {
|
|||
},
|
||||
};
|
||||
|
||||
function removeArray(array: any[], obj: any): any[] {
|
||||
|
||||
let dIdx: number = array.indexOf(obj, 0);
|
||||
if(dIdx > -1) {
|
||||
array.slice(dIdx, 1);
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
export default reducer;
|
||||
|
|
Loading…
Reference in New Issue
Block a user