crawler auth
This commit is contained in:
parent
928c09eb7f
commit
eec3f25bce
|
@ -0,0 +1,24 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { StoreModule } from '@ngrx/store';
|
||||
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
|
||||
import {
|
||||
StoreRouterConnectingModule,
|
||||
RouterStateSerializer,
|
||||
} from '@ngrx/router-store';
|
||||
import { EffectsModule } from '@ngrx/effects';
|
||||
import { combineReducers, ActionReducer, ActionReducerMap, MetaReducer } from '@ngrx/store';
|
||||
|
||||
import {
|
||||
REDUCERS,
|
||||
EFFECTS,
|
||||
} from './store';
|
||||
|
||||
import { MODULE } from './crawler-input.constant';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
StoreModule.forFeature(MODULE.name, REDUCERS),
|
||||
EffectsModule.forFeature(EFFECTS),
|
||||
],
|
||||
})
|
||||
export class MetaCrawlerInputItemStoreModule { }
|
|
@ -0,0 +1,3 @@
|
|||
export const MODULE = {
|
||||
name: 'metaCrawlerInputItem'
|
||||
};
|
23
src/packages/meta/crawler-input-item/crawler-input.module.ts
Normal file
23
src/packages/meta/crawler-input-item/crawler-input.module.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { } from './crawler.module';
|
||||
|
||||
import { MaterialModule } from 'packages/commons/material/material.module';
|
||||
import { SERVICES } from './service';
|
||||
import { MetaCrawlerInputItemStoreModule } from './crawler-input-store.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
MetaCrawlerInputItemStoreModule
|
||||
],
|
||||
declarations: [
|
||||
],
|
||||
exports: [
|
||||
],
|
||||
providers: [
|
||||
SERVICES,
|
||||
]
|
||||
})
|
||||
export class MetaCrawlerInputItemModule { }
|
|
@ -0,0 +1,23 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
import { RPCClient } from 'packages/core/rpc/client/RPCClient';
|
||||
import { MetaCrawlerInputItem } from '../model/MetaCrawlerInputItem';
|
||||
import { MetaCrawler } from '../../crawler/model/MetaCrawler';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class MetaCrawlerInputItemService {
|
||||
|
||||
public constructor(
|
||||
private rpcClient: RPCClient,
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
public readAllByMetaCrawler(c: MetaCrawler): Observable<MetaCrawlerInputItem[]> {
|
||||
return this.rpcClient.call('MetaCrawlerInputItemService.readAllByMetaCrawler', c);
|
||||
}
|
||||
}
|
5
src/packages/meta/crawler-input-item/service/index.ts
Normal file
5
src/packages/meta/crawler-input-item/service/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { MetaCrawlerInputItemService } from './crawler-input-item.service';
|
||||
|
||||
export const SERVICES = [
|
||||
MetaCrawlerInputItemService,
|
||||
];
|
30
src/packages/meta/crawler-input-item/store/index.ts
Normal file
30
src/packages/meta/crawler-input-item/store/index.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import {
|
||||
createSelector,
|
||||
createFeatureSelector,
|
||||
ActionReducerMap,
|
||||
} from '@ngrx/store';
|
||||
|
||||
import { StateSelector } from 'packages/core/ngrx/store';
|
||||
|
||||
|
||||
import * as ListStore from './list';
|
||||
import { MODULE } from '../crawler-input.constant';
|
||||
|
||||
export interface State {
|
||||
list: ListStore.State;
|
||||
}
|
||||
|
||||
export const REDUCERS = {
|
||||
list: ListStore.reducer,
|
||||
};
|
||||
|
||||
export const EFFECTS = [
|
||||
ListStore.Effects,
|
||||
];
|
||||
|
||||
export const selectState = createFeatureSelector<State>(MODULE.name);
|
||||
|
||||
export const ReadCrawlerInputItemSelector = new StateSelector<ListStore.State>(createSelector(
|
||||
selectState,
|
||||
(state: State) => state.list
|
||||
));
|
4
src/packages/meta/crawler-input-item/store/list/index.ts
Normal file
4
src/packages/meta/crawler-input-item/store/list/index.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
export * from './list.action';
|
||||
export * from './list.effect';
|
||||
export * from './list.reducer';
|
||||
export * from './list.state';
|
|
@ -0,0 +1,37 @@
|
|||
import { Action } from '@ngrx/store';
|
||||
|
||||
import { RPCError } from 'packages/core/rpc/error';
|
||||
import { MetaCrawler } from '../../../crawler/model/MetaCrawler';
|
||||
import { MetaCrawlerInputItem } from '../../model/MetaCrawlerInputItem';
|
||||
|
||||
|
||||
export enum ActionType {
|
||||
ReadAll = '[meta.crawler-input-list] ReadAll',
|
||||
ReadAllSuccess = '[meta.crawler-input-list] ReadAllSuccess',
|
||||
ReadAllFailure = '[meta.crawler-input-list] ReadAllFailure',
|
||||
}
|
||||
|
||||
export class ReadAll implements Action {
|
||||
readonly type = ActionType.ReadAll;
|
||||
|
||||
constructor(public payload: MetaCrawler) {}
|
||||
}
|
||||
|
||||
export class ReadAllSuccess implements Action {
|
||||
readonly type = ActionType.ReadAllSuccess;
|
||||
|
||||
constructor(public payload: MetaCrawlerInputItem[]) {}
|
||||
}
|
||||
|
||||
export class ReadAllFailure implements Action {
|
||||
readonly type = ActionType.ReadAllFailure;
|
||||
|
||||
constructor(public payload: RPCError) {}
|
||||
}
|
||||
|
||||
export type Actions =
|
||||
| ReadAll
|
||||
| ReadAllSuccess
|
||||
| ReadAllFailure
|
||||
|
||||
;
|
|
@ -0,0 +1,15 @@
|
|||
import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { Effects } from './list.effect';
|
||||
|
||||
describe('List.Effects', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [Effects]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([Effects], (effects: Effects) => {
|
||||
expect(effects).toBeTruthy();
|
||||
}));
|
||||
});
|
|
@ -0,0 +1,51 @@
|
|||
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 { DomainMember } from 'packages/domain/model';
|
||||
|
||||
|
||||
import {
|
||||
ReadAll,
|
||||
ReadAllSuccess,
|
||||
ReadAllFailure,
|
||||
ActionType,
|
||||
} from './list.action';
|
||||
import { MetaCrawlerInputItemService } from '../../service/crawler-input-item.service';
|
||||
|
||||
@Injectable()
|
||||
export class Effects {
|
||||
|
||||
constructor(
|
||||
private actions$: Actions,
|
||||
private service: MetaCrawlerInputItemService,
|
||||
private router: Router
|
||||
) { }
|
||||
|
||||
@Effect()
|
||||
readAll$: Observable<Action> = this.actions$
|
||||
.ofType(ActionType.ReadAll)
|
||||
.map((action: ReadAll) => action.payload)
|
||||
.switchMap(payload => this.service.readAllByMetaCrawler(payload))
|
||||
.map(list => {
|
||||
return new ReadAllSuccess(list);
|
||||
})
|
||||
.catch((error: RPCError) => {
|
||||
return of(new ReadAllFailure(error));
|
||||
});
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
import {
|
||||
Actions,
|
||||
ActionType,
|
||||
} from './list.action';
|
||||
|
||||
import {
|
||||
State,
|
||||
initialState,
|
||||
} from './list.state';
|
||||
|
||||
export function reducer(state = initialState, action: Actions): State {
|
||||
switch (action.type) {
|
||||
case ActionType.ReadAll: {
|
||||
return {
|
||||
...state,
|
||||
error: null,
|
||||
pending: true,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.ReadAllSuccess: {
|
||||
return {
|
||||
...state,
|
||||
error: null,
|
||||
pending: false,
|
||||
inputs: action.payload
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.ReadAllFailure: {
|
||||
return {
|
||||
...state,
|
||||
error: action.payload,
|
||||
pending: false,
|
||||
inputs: null,
|
||||
};
|
||||
}
|
||||
|
||||
default: {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
import { RPCError } from 'packages/core/rpc/error';
|
||||
import { MetaCrawlerInputItem } from '../../model/MetaCrawlerInputItem';
|
||||
|
||||
|
||||
export interface State {
|
||||
error: RPCError | null;
|
||||
pending: boolean;
|
||||
inputs: MetaCrawlerInputItem[] | null;
|
||||
}
|
||||
|
||||
export const initialState: State = {
|
||||
error: null,
|
||||
pending: false,
|
||||
inputs: null,
|
||||
};
|
|
@ -22,9 +22,9 @@ export const EFFECTS = [
|
|||
ListStore.Effects,
|
||||
];
|
||||
|
||||
export const selectNotificationState = createFeatureSelector<State>(MODULE.name);
|
||||
export const selectCrawlerState = createFeatureSelector<State>(MODULE.name);
|
||||
|
||||
export const ReadAllCrawlerSelector = new StateSelector<ListStore.State>(createSelector(
|
||||
selectNotificationState,
|
||||
selectCrawlerState,
|
||||
(state: State) => state.crawlers
|
||||
));
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, Input, OnChanges } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { MetaCrawler } from '../../../../meta/crawler/model/MetaCrawler';
|
||||
|
||||
import { Store, select } from '@ngrx/store';
|
||||
import { RPCError } from 'packages/core/rpc/error';
|
||||
import * as ListStore from 'packages/meta/crawler-input-item/store/list';
|
||||
import { ReadCrawlerInputItemSelector } from 'packages/meta/crawler-input-item/store';
|
||||
import { MetaCrawlerInputItem } from '../../../../meta/crawler-input-item/model/MetaCrawlerInputItem';
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -7,10 +14,37 @@ import { Router } from '@angular/router';
|
|||
templateUrl: './crawler-auth.component.html',
|
||||
styleUrls: ['./crawler-auth.component.scss']
|
||||
})
|
||||
export class CrawlerAuthComponent implements OnInit {
|
||||
export class CrawlerAuthComponent implements OnInit, OnChanges {
|
||||
|
||||
constructor(private router: Router) { }
|
||||
inputItems$ = this.listStore.pipe(select(ReadCrawlerInputItemSelector.select('inputs')));
|
||||
inputItems: MetaCrawlerInputItem[];
|
||||
|
||||
@Input() selectedCrawler: MetaCrawler;
|
||||
constructor(
|
||||
private router: Router,
|
||||
private listStore: Store<ListStore.State>,
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.inputItems$.subscribe(
|
||||
(list: MetaCrawlerInputItem[]) => {
|
||||
if (list !== null) {
|
||||
this.inputItems = list;
|
||||
console.log(list);
|
||||
}
|
||||
},
|
||||
(error: RPCError) => {
|
||||
console.log(error.response.message);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
if (this.selectedCrawler === null) { return; }
|
||||
this.getCrawlerAuthInputItems();
|
||||
}
|
||||
|
||||
getCrawlerAuthInputItems() {
|
||||
this.listStore.dispatch(new ListStore.ReadAll(this.selectedCrawler));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Component, OnInit, Input, OnChanges, AfterContentInit } from '@angular/core';
|
||||
import { Component, OnInit, Input, OnChanges, AfterContentInit, Output, EventEmitter } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { Target } from 'packages/target/model';
|
||||
|
||||
|
@ -21,6 +21,9 @@ export class CrawlerSelectorComponent implements OnInit, OnChanges, AfterContent
|
|||
@Input() selectedTarget: Target;
|
||||
crawlers: MetaCrawler[];
|
||||
|
||||
@Output() crawlerSelectEvent = new EventEmitter<MetaCrawler>();
|
||||
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private listStore: Store<ListStore.State>,
|
||||
|
@ -50,6 +53,6 @@ export class CrawlerSelectorComponent implements OnInit, OnChanges, AfterContent
|
|||
}
|
||||
|
||||
crawlerSelected(crawler: MetaCrawler) {
|
||||
// console.log(crawler);
|
||||
this.crawlerSelectEvent.emit(crawler);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,23 @@
|
|||
<mat-card-content>
|
||||
<perfect-scrollbar style="height: 150px">
|
||||
|
||||
트리 들어가야됨
|
||||
<tree-root id="tree2" [focused]="true" [nodes]="nodes">
|
||||
<ng-template #treeNodeFullTemplate let-node let-index="index" let-templates="templates">
|
||||
<div class="tree-node">
|
||||
<mat-checkbox [checked]="node.isActive" (change)="checkDiscoveryResult(node)"></mat-checkbox>
|
||||
<tree-node-expander [node]="node"></tree-node-expander>
|
||||
<div
|
||||
class="node-content-wrapper"
|
||||
[class.node-content-wrapper-active]="node.isActive"
|
||||
[class.node-content-wrapper-focused]="node.isFocused"
|
||||
(click)="checkDiscoveryResult(node)">
|
||||
<span [class]="node.data.className" [class.title]="true">{{ node.data.title }}</span>
|
||||
|
||||
</div>
|
||||
<tree-node-children [node]="node" [templates]="templates"></tree-node-children>
|
||||
</div>
|
||||
</ng-template>
|
||||
</tree-root>
|
||||
|
||||
</perfect-scrollbar>
|
||||
</mat-card-content>
|
||||
|
|
|
@ -9,6 +9,117 @@ import { Router } from '@angular/router';
|
|||
})
|
||||
export class SensorItemSelectorComponent implements OnInit {
|
||||
|
||||
nodes = [
|
||||
{
|
||||
title: 'host - 3232235781',
|
||||
className: 'className3232235781',
|
||||
children: [
|
||||
{
|
||||
title: 'Port - 22',
|
||||
className: 'className22',
|
||||
children: [
|
||||
{
|
||||
title: 'SSH',
|
||||
className: 'classNameSSH'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'Port - 80',
|
||||
className: 'className80',
|
||||
children: [
|
||||
{
|
||||
title: 'HTTP',
|
||||
className: 'classNameHTTP'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'Port - 1936',
|
||||
className: 'className1936',
|
||||
children: [
|
||||
{
|
||||
title: 'HTTP',
|
||||
className: 'classNameHTTP'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'host - 3232235781',
|
||||
className: 'className3232235781',
|
||||
children: [
|
||||
{
|
||||
title: 'Port - 22',
|
||||
className: 'className22',
|
||||
children: [
|
||||
{
|
||||
title: 'SSH',
|
||||
className: 'classNameSSH'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'Port - 80',
|
||||
className: 'className80',
|
||||
children: [
|
||||
{
|
||||
title: 'HTTP',
|
||||
className: 'classNameHTTP'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'Port - 1936',
|
||||
className: 'className1936',
|
||||
children: [
|
||||
{
|
||||
title: 'HTTP',
|
||||
className: 'classNameHTTP'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'host - 3232235781',
|
||||
className: 'className3232235781',
|
||||
children: [
|
||||
{
|
||||
title: 'Port - 22',
|
||||
className: 'className22',
|
||||
children: [
|
||||
{
|
||||
title: 'SSH',
|
||||
className: 'classNameSSH'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'Port - 80',
|
||||
className: 'className80',
|
||||
children: [
|
||||
{
|
||||
title: 'HTTP',
|
||||
className: 'classNameHTTP'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'Port - 1936',
|
||||
className: 'className1936',
|
||||
children: [
|
||||
{
|
||||
title: 'HTTP',
|
||||
className: 'classNameHTTP'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
constructor(private router: Router) { }
|
||||
|
||||
ngOnInit() {
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
<mat-grid-list cols="2" rowHeight="5:1">
|
||||
|
||||
<mat-grid-tile [colspan]="1" [rowspan]="3" style="background-color: lightblue">
|
||||
<of-target-selector [target]="selectedTarget" (targetSelectEvent)="handleTargetSelection($event)" [target]="target"></of-target-selector>
|
||||
<of-target-selector [target]="selectedTarget" (targetSelectEvent)="handleTargetSelection($event)" ></of-target-selector>
|
||||
</mat-grid-tile>
|
||||
|
||||
<mat-grid-tile [colspan]="1" [rowspan]="2" style="background-color: lightcoral">
|
||||
<of-crawler-auth></of-crawler-auth>
|
||||
<of-crawler-auth [selectedCrawler]="selectedCrawler"></of-crawler-auth>
|
||||
</mat-grid-tile>
|
||||
|
||||
<mat-grid-tile [colspan]="1" [rowspan]="3" style="background-color: lightgrey">
|
||||
|
@ -15,7 +15,7 @@
|
|||
</mat-grid-tile>
|
||||
|
||||
<mat-grid-tile [colspan]="1" [rowspan]="2" style="background-color: lightpink">
|
||||
<of-crawler-selector [selectedTarget]="selectedTarget"></of-crawler-selector>
|
||||
<of-crawler-selector [selectedTarget]="selectedTarget" (crawlerSelectEvent)="handleCrawlerSelection($event)"></of-crawler-selector>
|
||||
</mat-grid-tile>
|
||||
|
||||
</mat-grid-list>
|
||||
|
|
|
@ -3,6 +3,7 @@ import { AfterContentInit } from '@angular/core/src/metadata/lifecycle_hooks';
|
|||
import { Target } from '../../../target/model';
|
||||
import { MAT_DIALOG_DATA } from '@angular/material';
|
||||
import { Infra } from '../../../infra/model';
|
||||
import { MetaCrawler } from '../../../meta/crawler/model/MetaCrawler';
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -13,6 +14,7 @@ import { Infra } from '../../../infra/model';
|
|||
export class SettingComponent implements OnInit, AfterContentInit {
|
||||
|
||||
selectedTarget: Target = null;
|
||||
selectedCrawler: MetaCrawler = null;
|
||||
step = 1;
|
||||
|
||||
constructor(
|
||||
|
@ -46,4 +48,7 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
|||
handleTargetSelection(t: Target) {
|
||||
this.selectedTarget = t;
|
||||
}
|
||||
handleCrawlerSelection(c: MetaCrawler) {
|
||||
this.selectedCrawler = c;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import { SettingComponent } from './component/setting/setting.component';
|
|||
import { TreeModule } from 'angular-tree-component';
|
||||
import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';
|
||||
import { MetaCrawlerModule } from '../meta/crawler/crawler.module';
|
||||
import { MetaCrawlerInputItemModule } from '../meta/crawler-input-item/crawler-input.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -20,7 +21,8 @@ import { MetaCrawlerModule } from '../meta/crawler/crawler.module';
|
|||
SensorStoreModule,
|
||||
TreeModule,
|
||||
PerfectScrollbarModule,
|
||||
MetaCrawlerModule
|
||||
MetaCrawlerModule,
|
||||
MetaCrawlerInputItemModule
|
||||
],
|
||||
declarations: [
|
||||
COMPONENTS,
|
||||
|
|
Loading…
Reference in New Issue
Block a user