meta model arrange

This commit is contained in:
insanity 2018-03-20 15:53:54 +09:00
parent d8536ef011
commit 9c1f768d30
55 changed files with 126 additions and 131 deletions

View File

@ -1,7 +1,7 @@
import { MetaInfraType } from 'packages/meta/model';
import { Probe } from 'packages/probe/model'; import { Probe } from 'packages/probe/model';
import { Target } from 'packages/target/model'; import { Target } from 'packages/target/model';
import { MetaInfraType } from '../../meta/infra-type/model/MetaInfraType';
export interface Infra { export interface Infra {
id?: number; id?: number;

View File

@ -1,6 +1,6 @@
import { InfraMachine } from './InfraMachine'; import { InfraMachine } from './InfraMachine';
import { MetaInfraVendor } from 'packages/meta/model';
import { Infra } from './Infra'; import { Infra } from './Infra';
import { MetaInfraVendor } from '../../meta/infra-vendor/model/MetaInfraVendor';
export interface InfraOS extends Infra { export interface InfraOS extends Infra {
// id?: number; // id?: number;

View File

@ -1,6 +1,6 @@
import { InfraOS } from './InfraOS'; import { InfraOS } from './InfraOS';
import { MetaInfraVendor } from 'packages/meta/model';
import { Infra } from './Infra'; import { Infra } from './Infra';
import { MetaInfraVendor } from 'packages/meta/infra-vendor/model/MetaInfraVendor';
export interface InfraOSPort extends Infra { export interface InfraOSPort extends Infra {
// id?: number; // id?: number;

View File

@ -1,6 +1,6 @@
import { InfraHost } from './InfraHost'; import { InfraHost } from './InfraHost';
import { MetaInfraVendor } from 'packages/meta/model';
import { Infra } from './Infra'; import { Infra } from './Infra';
import { MetaInfraVendor } from 'packages/meta/infra-vendor/model/MetaInfraVendor';
export interface InfraService extends Infra { export interface InfraService extends Infra {
// id?: number; // id?: number;

View File

@ -1,4 +1,4 @@
import { MetaMemberStatus } from 'packages/meta/model'; import { MetaMemberStatus } from 'packages/meta/member-status/model/MetaMemberStatus';
export interface Member { export interface Member {
id?: number; id?: number;

View File

@ -1,6 +1,6 @@
import { MetaInputType } from 'packages/meta/input-type/model/MetaInputType';
import { MetaCrawler } from 'packages/meta/crawler/model/MetaCrawler';
import { MetaInputType } from './MetaInputType';
import { MetaCrawler } from './MetaCrawler';
export interface MetaCrawlerInputItem { export interface MetaCrawlerInputItem {
id?: number; id?: number;

View File

@ -13,7 +13,7 @@ import {
EFFECTS, EFFECTS,
} from './store'; } from './store';
import { MODULE } from './meta.constant'; import { MODULE } from './crawler.constant';
@NgModule({ @NgModule({
imports: [ imports: [
@ -21,4 +21,4 @@ import { MODULE } from './meta.constant';
EffectsModule.forFeature(EFFECTS), EffectsModule.forFeature(EFFECTS),
], ],
}) })
export class MetaStoreModule { } export class MetaCrawlerStoreModule { }

View File

@ -0,0 +1,3 @@
export const MODULE = {
name: 'metaCrawler'
};

View File

@ -1,15 +1,16 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { } from './crawler.module';
import { MaterialModule } from 'packages/commons/material/material.module'; import { MaterialModule } from 'packages/commons/material/material.module';
import { SERVICES } from './service'; import { SERVICES } from './service';
import { MetaCrawlerStoreModule } from './crawler-store.module';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
MaterialModule, MetaCrawlerStoreModule
], ],
declarations: [ declarations: [
], ],
@ -17,6 +18,6 @@ import { SERVICES } from './service';
], ],
providers: [ providers: [
SERVICES, SERVICES,
], ]
}) })
export class MetaModule { } export class MetaCrawlerModule { }

View File

@ -5,10 +5,10 @@ import 'rxjs/add/operator/map';
import { RPCClient } from 'packages/core/rpc/client/RPCClient'; import { RPCClient } from 'packages/core/rpc/client/RPCClient';
import { MetaCrawler } from '../model'; import { MetaCrawler } from '../model/MetaCrawler';
@Injectable() @Injectable()
export class CrawlerService { export class MetaCrawlerService {
public constructor( public constructor(
private rpcClient: RPCClient, private rpcClient: RPCClient,
@ -17,6 +17,6 @@ export class CrawlerService {
} }
public readAll(): Observable<MetaCrawler[]> { public readAll(): Observable<MetaCrawler[]> {
return this.rpcClient.call<MetaCrawler[]>('CrawlerService.readAll'); return this.rpcClient.call('CrawlerService.readAll');
} }
} }

View File

@ -0,0 +1,5 @@
import { MetaCrawlerService } from './crawler.service';
export const SERVICES = [
MetaCrawlerService,
];

View File

@ -0,0 +1,30 @@
import {
createSelector,
createFeatureSelector,
ActionReducerMap,
} from '@ngrx/store';
import { StateSelector } from 'packages/core/ngrx/store';
import { MODULE } from '../crawler.constant';
import * as ListStore from './list';
export interface State {
crawlers: ListStore.State;
}
export const REDUCERS = {
crawlers: ListStore.reducer,
};
export const EFFECTS = [
ListStore.Effects,
];
export const selectNotificationState = createFeatureSelector<State>(MODULE.name);
export const ReadAllCrawlerSelector = new StateSelector<ListStore.State>(createSelector(
selectNotificationState,
(state: State) => state.crawlers
));

View File

@ -1,10 +1,9 @@
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { RPCError } from 'packages/core/rpc/error'; import { RPCError } from 'packages/core/rpc/error';
import { MetaCrawler } from '../../model/MetaCrawler';
import { MetaCrawler } from '../../../model';
export enum ActionType { export enum ActionType {
ReadAll = '[meta.crawler-readall] ReadAll', ReadAll = '[meta.crawler-readall] ReadAll',
ReadAllSuccess = '[meta.crawler-readall] ReadAllSuccess', ReadAllSuccess = '[meta.crawler-readall] ReadAllSuccess',
@ -14,7 +13,7 @@ export enum ActionType {
export class ReadAll implements Action { export class ReadAll implements Action {
readonly type = ActionType.ReadAll; readonly type = ActionType.ReadAll;
constructor(public payload: {}) {} constructor() {}
} }
export class ReadAllSuccess implements Action { export class ReadAllSuccess implements Action {

View File

@ -18,8 +18,6 @@ import { RPCError } from 'packages/core/rpc/error';
import { DomainMember } from 'packages/domain/model'; import { DomainMember } from 'packages/domain/model';
import { MetaCrawler } from '../../../model';
import { CrawlerService } from '../../../service/crawler.service';
import { import {
ReadAll, ReadAll,
@ -27,20 +25,21 @@ import {
ReadAllFailure, ReadAllFailure,
ActionType, ActionType,
} from './list.action'; } from './list.action';
import { MetaCrawlerService } from '../../service/crawler.service';
@Injectable() @Injectable()
export class Effects { export class Effects {
constructor( constructor(
private actions$: Actions, private actions$: Actions,
private crawlerService: CrawlerService, private crawlerService: MetaCrawlerService,
private router: Router private router: Router
) { } ) { }
@Effect() @Effect()
readAll$: Observable<Action> = this.actions$ readAll$: Observable<Action> = this.actions$
.ofType(ActionType.ReadAll) .ofType(ActionType.ReadAll)
.map((action: ReadAll) => action.payload) .map((action: ReadAll) => action)
.switchMap(payload => this.crawlerService.readAll()) .switchMap(payload => this.crawlerService.readAll())
.map(list => { .map(list => {
return new ReadAllSuccess(list); return new ReadAllSuccess(list);

View File

@ -8,8 +8,6 @@ import {
initialState, initialState,
} from './list.state'; } from './list.state';
import { MetaCrawler } from '../../../model';
export function reducer(state = initialState, action: Actions): State { export function reducer(state = initialState, action: Actions): State {
switch (action.type) { switch (action.type) {
case ActionType.ReadAll: { case ActionType.ReadAll: {

View File

@ -1,5 +1,5 @@
import { RPCError } from 'packages/core/rpc/error'; import { RPCError } from 'packages/core/rpc/error';
import { MetaCrawler } from '../../../model'; import { MetaCrawler } from '../../model/MetaCrawler';
export interface State { export interface State {

View File

@ -1,5 +1,5 @@
import { MetaInfraType } from 'packages/meta/infra-type/model/MetaInfraType';
import { MetaInfraType } from './MetaInfraType';
export interface MetaInfraVendor { export interface MetaInfraVendor {
id?: number; id?: number;

View File

@ -1,3 +0,0 @@
export const MODULE = {
name: 'meta'
};

View File

@ -0,0 +1,10 @@
import { MetaCrawler } from 'packages/meta/crawler/model/MetaCrawler';
import { MetaInfraVendor } from 'packages/meta/infra-vendor/model/MetaInfraVendor';
export interface MetaVendorCrawler {
id?: number;
crawler: MetaCrawler;
infraVendor: MetaInfraVendor;
createDate: Date;
}

View File

@ -1,6 +1,6 @@
import { MetaSensorItem } from 'packages/meta/sensor-item/model/MetaSensorItem';
import { MetaInfraVendor } from 'packages/meta/infra-vendor/model/MetaInfraVendor';
import { MetaInfraVendor } from './MetaInfraVendor';
import { MetaSensorItem } from './MetaSensorItem';
export interface MetaVendorCrawlerSensorItem { export interface MetaVendorCrawlerSensorItem {
id?: number; id?: number;

View File

View File

@ -1,11 +0,0 @@
import { MetaProbeVersion } from './MetaProbeVersion';
import { MetaProbeOs } from './MetaProbeOs';
import { MetaProbeArchitecture } from './MetaProbeArchitecture';
export interface MetaProbePackage {
id?: number;
version: MetaProbeVersion;
os: MetaProbeOs;
architecture: MetaProbeArchitecture;
createDate: Date;
}

View File

@ -1,10 +0,0 @@
import { MetaInfraVendor } from './MetaInfraVendor';
import { MetaCrawler } from './MetaCrawler';
export interface MetaVendorCrawler {
id?: number;
crawler: MetaCrawler;
infraVendor: MetaInfraVendor;
createDate: Date;
}

View File

@ -1,23 +0,0 @@
export * from './MetaCrawlerInputItem';
export * from './MetaCrawler';
export * from './MetaHistoryType';
export * from './MetaInfraType';
export * from './MetaInfraVendor';
export * from './MetaInputType';
export * from './MetaMemberStatus';
export * from './MetaNoAuthProbeStatus';
export * from './MetaNotification';
export * from './MetaProbeArchitecture';
export * from './MetaProbeOs';
export * from './MetaProbePackage';
export * from './MetaProbeStatus';
export * from './MetaProbeTaskType';
export * from './MetaProbeVersion';
export * from './MetaSensorDisplayItem';
export * from './MetaSensorItemKey';
export * from './MetaSensorItem';
export * from './MetaSensorItemType';
export * from './MetaSensorItemUnit';
export * from './MetaSensorStatus';
export * from './MetaVendorCrawlerSensorItem';
export * from './MetaVendorCrawler';

View File

@ -0,0 +1,11 @@
import { MetaProbeVersion } from 'packages/meta/probe-version/model/MetaProbeVersion';
import { MetaProbeOs } from 'packages/meta/probe-os/model/MetaProbeOs';
import { MetaProbeArchitecture } from 'packages/meta/probe-architecture/model/MetaProbeArchitecture';
export interface MetaProbePackage {
id?: number;
version: MetaProbeVersion;
os: MetaProbeOs;
architecture: MetaProbeArchitecture;
createDate: Date;
}

View File

@ -1,6 +1,6 @@
import { MetaCrawler } from './MetaCrawler'; import { MetaCrawler } from 'packages/meta/crawler/model/MetaCrawler';
import { MetaSensorItemUnit } from './MetaSensorItemUnit'; import { MetaSensorItemUnit } from 'packages/meta/sensor-item-unit/model/MetaSensorItemUnit';
import { MetaSensorItemType } from './MetaSensorItemType'; import { MetaSensorItemType } from 'packages/meta/sensor-item-type/model/MetaSensorItemType';
export interface MetaSensorDisplayItem { export interface MetaSensorDisplayItem {
id?: number; id?: number;

View File

@ -1,5 +1,5 @@
import { MetaSensorItem } from './MetaSensorItem'; import { MetaSensorItem } from 'packages/meta/sensor-item/model/MetaSensorItem';
import { MetaCrawler } from './MetaCrawler'; import { MetaCrawler } from 'packages/meta/crawler/model/MetaCrawler';
export interface MetaSensorItemKey { export interface MetaSensorItemKey {
id: number; id: number;

View File

@ -1,6 +1,5 @@
import { MetaSensorItemType } from 'packages/meta/sensor-item-type/model/MetaSensorItemType';
import { MetaProbeArchitecture } from './MetaProbeArchitecture';
import { MetaSensorItemType } from './MetaSensorItemType';
export interface MetaSensorItem { export interface MetaSensorItem {
id?: number; id?: number;

View File

@ -1,5 +0,0 @@
import { CrawlerService } from './crawler.service';
export const SERVICES = [
CrawlerService,
];

View File

@ -1,31 +0,0 @@
import {
createSelector,
createFeatureSelector,
ActionReducerMap,
} from '@ngrx/store';
import { StateSelector } from 'packages/core/ngrx/store';
import { MODULE } from '../meta.constant';
import * as ListStore from './crawler/list';
export interface State {
list: ListStore.State;
}
export const REDUCERS = {
list: ListStore.reducer,
};
export const EFFECTS = [
ListStore.Effects,
];
export const selectCrawlerListState = createFeatureSelector<State>(MODULE.name);
export const CrawlerListSelector = new StateSelector<ListStore.State>(createSelector(
selectCrawlerListState,
(state: State) => state.list
));

View File

@ -1,6 +1,6 @@
import { Probe } from 'packages/probe/model'; import { Probe } from 'packages/probe/model';
import { MetaNoAuthProbeStatus } from 'packages/meta/model';
import { Domain } from 'packages/domain/model'; import { Domain } from 'packages/domain/model';
import { MetaNoAuthProbeStatus } from 'packages/meta/noauth-probe-status/model/MetaNoAuthProbeStatus';
export interface NoAuthProbe { export interface NoAuthProbe {
// id?: number; // id?: number;

View File

@ -1,7 +1,7 @@
import { MetaProbeStatus } from 'packages/meta/model';
import { Domain } from 'packages/domain/model'; import { Domain } from 'packages/domain/model';
import { Member } from 'packages/member/model'; import { Member } from 'packages/member/model';
import { Infra } from 'packages/infra/model'; import { Infra } from 'packages/infra/model';
import { MetaProbeStatus } from 'packages/meta/probe-status/model/MetaProbeStatus';
export interface Probe { export interface Probe {
id?: number; id?: number;

View File

@ -1,5 +1,5 @@
import { Probe } from './Probe'; import { Probe } from './Probe';
import { MetaProbeTaskType } from 'packages/meta/model'; import { MetaProbeTaskType } from 'packages/meta/probe-task-type/model/MetaProbeTaskType';
export interface ProbeTask { export interface ProbeTask {
id?: number; id?: number;

View File

@ -1,7 +1,12 @@
import { Component, OnInit, Input, OnChanges, AfterContentInit } from '@angular/core'; import { Component, OnInit, Input, OnChanges, AfterContentInit } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Target } from 'packages/target/model'; import { Target } from 'packages/target/model';
import { MetaCrawler } from '../../../../meta/model';
import { Store, select } from '@ngrx/store';
import { RPCError } from 'packages/core/rpc/error';
import * as ListStore from 'packages/meta/crawler/store/list';
import { ReadAllCrawlerSelector } from 'packages/meta/crawler/store';
import { MetaCrawler } from 'packages/meta/crawler/model/MetaCrawler';
@Component({ @Component({
@ -11,17 +16,31 @@ import { MetaCrawler } from '../../../../meta/model';
}) })
export class CrawlerSelectorComponent implements OnInit, OnChanges, AfterContentInit { export class CrawlerSelectorComponent implements OnInit, OnChanges, AfterContentInit {
crawlers$ = this.listStore.pipe(select(ReadAllCrawlerSelector.select('list')));
@Input() selectedTarget: Target; @Input() selectedTarget: Target;
crawlers: MetaCrawler[]; crawlers: MetaCrawler[];
constructor(private router: Router) { constructor(
} private router: Router,
private listStore: Store<ListStore.State>,
) {}
ngOnInit() { ngOnInit() {
this.crawlers$.subscribe(
(list: MetaCrawler[]) => {
if (list !== null) {
console.log(list);
}
},
(error: RPCError) => {
console.log(error.response.message);
}
);
} }
ngAfterContentInit() { ngAfterContentInit() {
this.listStore.dispatch(new ListStore.ReadAll());
} }
ngOnChanges() { ngOnChanges() {

View File

@ -1,5 +1,6 @@
import { Target } from 'packages/target/model'; import { Target } from 'packages/target/model';
import { MetaCrawler, MetaSensorStatus } from 'packages/meta/model'; import { MetaSensorStatus } from 'packages/meta/sensor-status/model/MetaSensorStatus';
import { MetaCrawler } from 'packages/meta/crawler/model/MetaCrawler';
export interface Sensor { export interface Sensor {
id?: number; id?: number;

View File

@ -1,5 +1,5 @@
import { Sensor } from './Sensor'; import { Sensor } from './Sensor';
import { MetaSensorDisplayItem } from 'packages/meta/model'; import { MetaSensorDisplayItem } from 'packages/meta/sensor-display-item/model/MetaSensorDisplayItem';
export interface SensorItem { export interface SensorItem {
id?: number; id?: number;

View File

@ -1,6 +1,7 @@
import { MetaCrawler, MetaSensorDisplayItem } from 'packages/meta/model';
import { Infra } from 'packages/infra/model'; import { Infra } from 'packages/infra/model';
import { MetaCrawler } from 'packages/meta/crawler/model/MetaCrawler';
import { MetaSensorDisplayItem } from 'packages/meta/sensor-display-item/model/MetaSensorDisplayItem';
export interface SensorRegistInfo { export interface SensorRegistInfo {
sensorItemMap: Map<number, Array<MetaSensorDisplayItem>>; sensorItemMap: Map<number, Array<MetaSensorDisplayItem>>;

View File

@ -10,6 +10,7 @@ import { SensorStoreModule } from './sensor-store.module';
import { SettingComponent } from './component/setting/setting.component'; import { SettingComponent } from './component/setting/setting.component';
import { TreeModule } from 'angular-tree-component'; import { TreeModule } from 'angular-tree-component';
import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar'; import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';
import { MetaCrawlerModule } from '../meta/crawler/crawler.module';
@NgModule({ @NgModule({
imports: [ imports: [
@ -18,7 +19,8 @@ import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';
FormsModule, FormsModule,
SensorStoreModule, SensorStoreModule,
TreeModule, TreeModule,
PerfectScrollbarModule PerfectScrollbarModule,
MetaCrawlerModule
], ],
declarations: [ declarations: [
COMPONENTS, COMPONENTS,