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 { Target } from 'packages/target/model';
import { MetaInfraType } from '../../meta/infra-type/model/MetaInfraType';
export interface Infra {
id?: number;

View File

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

View File

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

View File

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

View File

@ -13,7 +13,7 @@ import {
EFFECTS,
} from './store';
import { MODULE } from './meta.constant';
import { MODULE } from './crawler.constant';
@NgModule({
imports: [
@ -21,4 +21,4 @@ import { MODULE } from './meta.constant';
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 { CommonModule } from '@angular/common';
import { } from './crawler.module';
import { MaterialModule } from 'packages/commons/material/material.module';
import { SERVICES } from './service';
import { MetaCrawlerStoreModule } from './crawler-store.module';
@NgModule({
imports: [
CommonModule,
MaterialModule,
MetaCrawlerStoreModule
],
declarations: [
],
@ -17,6 +18,6 @@ import { SERVICES } from './service';
],
providers: [
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 { MetaCrawler } from '../model';
import { MetaCrawler } from '../model/MetaCrawler';
@Injectable()
export class CrawlerService {
export class MetaCrawlerService {
public constructor(
private rpcClient: RPCClient,
@ -17,6 +17,6 @@ export class CrawlerService {
}
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 { RPCError } from 'packages/core/rpc/error';
import { MetaCrawler } from '../../model/MetaCrawler';
import { MetaCrawler } from '../../../model';
export enum ActionType {
ReadAll = '[meta.crawler-readall] ReadAll',
ReadAllSuccess = '[meta.crawler-readall] ReadAllSuccess',
@ -14,7 +13,7 @@ export enum ActionType {
export class ReadAll implements Action {
readonly type = ActionType.ReadAll;
constructor(public payload: {}) {}
constructor() {}
}
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 { MetaCrawler } from '../../../model';
import { CrawlerService } from '../../../service/crawler.service';
import {
ReadAll,
@ -27,20 +25,21 @@ import {
ReadAllFailure,
ActionType,
} from './list.action';
import { MetaCrawlerService } from '../../service/crawler.service';
@Injectable()
export class Effects {
constructor(
private actions$: Actions,
private crawlerService: CrawlerService,
private crawlerService: MetaCrawlerService,
private router: Router
) { }
@Effect()
readAll$: Observable<Action> = this.actions$
.ofType(ActionType.ReadAll)
.map((action: ReadAll) => action.payload)
.map((action: ReadAll) => action)
.switchMap(payload => this.crawlerService.readAll())
.map(list => {
return new ReadAllSuccess(list);

View File

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

View File

@ -1,5 +1,5 @@
import { RPCError } from 'packages/core/rpc/error';
import { MetaCrawler } from '../../../model';
import { MetaCrawler } from '../../model/MetaCrawler';
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 {
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 {
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 { MetaSensorItemUnit } from './MetaSensorItemUnit';
import { MetaSensorItemType } from './MetaSensorItemType';
import { MetaCrawler } from 'packages/meta/crawler/model/MetaCrawler';
import { MetaSensorItemUnit } from 'packages/meta/sensor-item-unit/model/MetaSensorItemUnit';
import { MetaSensorItemType } from 'packages/meta/sensor-item-type/model/MetaSensorItemType';
export interface MetaSensorDisplayItem {
id?: number;

View File

@ -1,5 +1,5 @@
import { MetaSensorItem } from './MetaSensorItem';
import { MetaCrawler } from './MetaCrawler';
import { MetaSensorItem } from 'packages/meta/sensor-item/model/MetaSensorItem';
import { MetaCrawler } from 'packages/meta/crawler/model/MetaCrawler';
export interface MetaSensorItemKey {
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 {
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 { MetaNoAuthProbeStatus } from 'packages/meta/model';
import { Domain } from 'packages/domain/model';
import { MetaNoAuthProbeStatus } from 'packages/meta/noauth-probe-status/model/MetaNoAuthProbeStatus';
export interface NoAuthProbe {
// id?: number;

View File

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

View File

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

View File

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

View File

@ -1,5 +1,6 @@
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 {
id?: number;

View File

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

View File

@ -1,6 +1,7 @@
import { MetaCrawler, MetaSensorDisplayItem } from 'packages/meta/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 {
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 { TreeModule } from 'angular-tree-component';
import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';
import { MetaCrawlerModule } from '../meta/crawler/crawler.module';
@NgModule({
imports: [
@ -18,7 +19,8 @@ import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';
FormsModule,
SensorStoreModule,
TreeModule,
PerfectScrollbarModule
PerfectScrollbarModule,
MetaCrawlerModule
],
declarations: [
COMPONENTS,