accept deny button
This commit is contained in:
parent
77ade80fd7
commit
c4989c94df
|
@ -2,10 +2,14 @@ import { Component, OnInit, AfterContentInit } from '@angular/core';
|
|||
import { MatCheckboxChange } from '@angular/material';
|
||||
import { Store, select } from '@ngrx/store';
|
||||
import { RPCError } from 'packages/core/rpc/error';
|
||||
import * as DiscoverySettingStore from '../../store/setting';
|
||||
import { DiscoveryStartInfo } from '../../model';
|
||||
import {
|
||||
DiscoveryStartInfo,
|
||||
DiscoveryZone
|
||||
} from '../../model';
|
||||
import * as CIDR from 'ip-cidr';
|
||||
import * as DiscoveryStore from '../../store/setting';
|
||||
import * as DiscoveredStore from '../../store/setting';
|
||||
import * as DiscoverStore from '../../store/notification';
|
||||
|
||||
import { SettingSelector } from '../../store';
|
||||
|
||||
@Component({
|
||||
|
@ -15,7 +19,7 @@ import { SettingSelector } from '../../store';
|
|||
})
|
||||
export class SettingComponent implements OnInit, AfterContentInit {
|
||||
|
||||
settingSucceed$ = this.store.pipe(select(SettingSelector.select('isStart')));
|
||||
settingSucceed$ = this.discoverdstore.pipe(select(SettingSelector.select('isStart')));
|
||||
started = false;
|
||||
|
||||
cidr;
|
||||
|
@ -35,7 +39,8 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
|||
{ name: 'Nginx' },
|
||||
];
|
||||
constructor(
|
||||
private store: Store<DiscoverySettingStore.State>,
|
||||
private discoverdstore: Store<DiscoveredStore.State>,
|
||||
private discoverstore: Store<DiscoverStore.State>,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -99,7 +104,16 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
|||
startPort: this.startPort,
|
||||
endPort: this.endPort
|
||||
};
|
||||
this.store.dispatch(new DiscoverySettingStore.Setting(startInfo));
|
||||
|
||||
const discoveryZone: DiscoveryZone = {
|
||||
discoveryHost: {
|
||||
firstScanRange: this.startIP,
|
||||
lastScanRange: this.endIP,
|
||||
}
|
||||
};
|
||||
|
||||
// this.store.dispatch(new DiscoverySettingStore.Setting(startInfo));
|
||||
this.discoverstore.dispatch(new DiscoverStore.DiscoverZone({probeID: '52abd6fd57e511e7ac52080027658d13', discoveryZone: discoveryZone}));
|
||||
this.started = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { DiscoveryPort } from './DiscoveryPort';
|
||||
|
||||
export interface DiscoveryHost {
|
||||
firstScanRange: string;
|
||||
lastScanRange: string;
|
||||
excludeHosts: string[];
|
||||
includeHosts: string[];
|
||||
firstScanRange?: string;
|
||||
lastScanRange?: string;
|
||||
excludeHosts?: string[];
|
||||
includeHosts?: string[];
|
||||
|
||||
discoveryPort?: DiscoveryPort;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ export const REDUCERS = {
|
|||
|
||||
export const EFFECTS = [
|
||||
SettingStore.Effects,
|
||||
NotificationStore.Effects,
|
||||
];
|
||||
|
||||
export const selectDiscoveryState = createFeatureSelector<State>(MODULE.name);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
export * from './notification.action';
|
||||
export * from './notification.reducer';
|
||||
export * from './notification.state';
|
||||
export * from './notification.effect';
|
||||
|
|
|
@ -8,15 +8,47 @@ import {
|
|||
Host,
|
||||
Port,
|
||||
Service,
|
||||
DiscoveryZone,
|
||||
DiscoveryHost,
|
||||
DiscoveryPort,
|
||||
DiscoveryService as MDiscoveryService,
|
||||
} from '../../model';
|
||||
|
||||
export enum ActionType {
|
||||
DiscoverZone = '[@@NOTIFICATION] DiscoveryService.discoverZone',
|
||||
DiscoverHost = '[@@NOTIFICATION] DiscoveryService.discoverHost',
|
||||
DiscoverPort = '[@@NOTIFICATION] DiscoveryService.discoverPort',
|
||||
DiscoverService = '[@@NOTIFICATION] DiscoveryService.discoverService',
|
||||
DiscoveredZone = '[@@NOTIFICATION] DiscoveryService.discoveredZone',
|
||||
DiscoveredHost = '[@@NOTIFICATION] DiscoveryService.discoveredHost',
|
||||
DiscoveredPort = '[@@NOTIFICATION] DiscoveryService.discoveredPort',
|
||||
DiscoveredService = '[@@NOTIFICATION] DiscoveryService.discoveredService',
|
||||
}
|
||||
|
||||
export class DiscoverZone implements Action {
|
||||
readonly type = ActionType.DiscoverZone;
|
||||
|
||||
constructor(public payload: {probeID: string, discoveryZone: DiscoveryZone}) {}
|
||||
}
|
||||
|
||||
export class DiscoverHost implements Action {
|
||||
readonly type = ActionType.DiscoverHost;
|
||||
|
||||
constructor(public payload: {probeID: string, zone: Zone, discoveryHost: DiscoveryHost}) {}
|
||||
}
|
||||
|
||||
export class DiscoverPort implements Action {
|
||||
readonly type = ActionType.DiscoverPort;
|
||||
|
||||
constructor(public payload: {probeID: string, host: Host, discoveryPort: DiscoveryPort}) {}
|
||||
}
|
||||
|
||||
export class DiscoverService implements Action {
|
||||
readonly type = ActionType.DiscoverService;
|
||||
constructor(public payload: {probeID: string, port: Port, discoveryService: MDiscoveryService}) {}
|
||||
}
|
||||
|
||||
|
||||
export class DiscoveredZone implements Action {
|
||||
readonly type = ActionType.DiscoveredZone;
|
||||
|
||||
|
@ -41,6 +73,10 @@ export class DiscoveredService implements Action {
|
|||
}
|
||||
|
||||
export type Actions =
|
||||
| DiscoverZone
|
||||
| DiscoverHost
|
||||
| DiscoverPort
|
||||
| DiscoverService
|
||||
| DiscoveredZone
|
||||
| DiscoveredHost
|
||||
| DiscoveredPort
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { Effect, Actions, ofType } from '@ngrx/effects';
|
||||
import { Action } from '@ngrx/store';
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { of } from 'rxjs/observable/of';
|
||||
|
||||
import 'rxjs/add/operator/catch';
|
||||
import 'rxjs/add/operator/do';
|
||||
import 'rxjs/add/operator/exhaustMap';
|
||||
import 'rxjs/add/operator/switchMap';
|
||||
import 'rxjs/add/operator/map';
|
||||
import 'rxjs/add/operator/take';
|
||||
|
||||
import { RPCError } from 'packages/core/rpc/error';
|
||||
import {
|
||||
DiscoverZone,
|
||||
DiscoverHost,
|
||||
DiscoverPort,
|
||||
DiscoverService,
|
||||
ActionType
|
||||
} from './notification.action';
|
||||
import {DiscoveryService} from '../../service/discovery.service';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class Effects {
|
||||
|
||||
constructor(private actions$: Actions,
|
||||
private discoveryService: DiscoveryService,
|
||||
private router: Router) {
|
||||
}
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
discoveryZone$ = this.actions$
|
||||
.ofType(ActionType.DiscoverZone)
|
||||
.map((action: DiscoverZone) => action.payload)
|
||||
.do(payload => {
|
||||
this.discoveryService.discoverZone(payload.probeID, payload.discoveryZone);
|
||||
});
|
||||
|
||||
}
|
|
@ -47,4 +47,5 @@ export class Effects {
|
|||
console.log(error.response.message);
|
||||
return of(new SettingFailure(error));
|
||||
});
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user