meta arranging

This commit is contained in:
insanity 2018-03-20 14:48:56 +09:00
parent 2d0ff36638
commit d8536ef011
19 changed files with 105 additions and 72 deletions

View File

@ -66,7 +66,9 @@ export class MapComponent implements OnInit, AfterContentInit {
const dialogRef = this.dialog.open(SettingComponent, {
width: '80%',
data: { }
data: {
'infra': infra
}
});
dialogRef.afterClosed().subscribe(result => {

View File

@ -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 './meta.constant';
@NgModule({
imports: [
StoreModule.forFeature(MODULE.name, REDUCERS),
EffectsModule.forFeature(EFFECTS),
],
})
export class MetaStoreModule { }

View File

@ -0,0 +1,22 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MaterialModule } from 'packages/commons/material/material.module';
import { SERVICES } from './service';
@NgModule({
imports: [
CommonModule,
MaterialModule,
],
declarations: [
],
exports: [
],
providers: [
SERVICES,
],
})
export class MetaModule { }

View File

@ -1,15 +0,0 @@
import { TestBed, inject } from '@angular/core/testing';
import { CrawlerService } from './crawler.service';
describe('MemberService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [CrawlerService]
});
});
it('should be created', inject([CrawlerService], (service: CrawlerService) => {
expect(service).toBeTruthy();
}));
});

View File

@ -16,16 +16,7 @@ export class CrawlerService {
}
public signin(email: string, password: string): Observable<MetaCrawler> {
const body = {
signinId: email,
signinPw: password,
};
return this.rpcClient.call<MetaCrawler>('CrawlerService.', body);
}
public readAll(): Observable<MetaCrawler[]> {
return this.rpcClient.call<MetaCrawler[]>('CrawlerService.');
return this.rpcClient.call<MetaCrawler[]>('CrawlerService.readAll');
}
}

View File

@ -1,4 +0,0 @@
export * from './readall.action';
export * from './readall.effect';
export * from './readall.reducer';
export * from './readall.state';

View File

@ -0,0 +1,4 @@
export * from './list.action';
export * from './list.effect';
export * from './list.reducer';
export * from './list.state';

View File

@ -3,7 +3,7 @@ import { Action } from '@ngrx/store';
import { RPCError } from 'packages/core/rpc/error';
import { MetaCrawler } from '../../model';
import { MetaCrawler } from '../../../model';
export enum ActionType {
ReadAll = '[meta.crawler-readall] ReadAll',

View File

@ -1,8 +1,8 @@
import { TestBed, inject } from '@angular/core/testing';
import { Effects } from './readall.effect';
import { Effects } from './list.effect';
describe('Auth.Effects', () => {
describe('List.Effects', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [Effects]

View File

@ -18,15 +18,15 @@ import { RPCError } from 'packages/core/rpc/error';
import { DomainMember } from 'packages/domain/model';
import { MetaCrawler } from '../../model';
import { CrawlerService } from '../../service/crawler.service';
import { MetaCrawler } from '../../../model';
import { CrawlerService } from '../../../service/crawler.service';
import {
ReadAll,
ReadAllSuccess,
ReadAllFailure,
ActionType,
} from './readall.action';
} from './list.action';
@Injectable()
export class Effects {
@ -38,20 +38,15 @@ export class Effects {
) { }
@Effect()
signin$: Observable<Action> = this.actions$
readAll$: Observable<Action> = this.actions$
.ofType(ActionType.ReadAll)
.map((action: ReadAll) => action.payload)
.switchMap(payload => this.crawlerService.readAll())
.map((metaCrawlerList: MetaCrawler[]) => {
return new ReadAllSuccess(metaCrawlerList);
.map(list => {
return new ReadAllSuccess(list);
})
.catch((error: RPCError) => {
return of(new ReadAllFailure(error));
});
@Effect({ dispatch: false })
signinSuccess$ = this.actions$
.ofType(ActionType.ReadAllSuccess)
.do(() => this.router.navigate(['/']));
}

View File

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

View File

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

View File

@ -8,24 +8,24 @@ import {
import { MODULE } from '../meta.constant';
import * as CrawlerReadAllStore from './crawler-readall';
import * as ListStore from './crawler/list';
export interface State {
readAll: CrawlerReadAllStore.State;
list: ListStore.State;
}
export const REDUCERS = {
readAll: CrawlerReadAllStore.reducer,
list: ListStore.reducer,
};
export const EFFECTS = [
CrawlerReadAllStore.Effects,
ListStore.Effects,
];
export const selectCrawlerReadAllState = createFeatureSelector<State>(MODULE.name);
export const selectCrawlerListState = createFeatureSelector<State>(MODULE.name);
export const CrawlerReadAllSelector = new StateSelector<CrawlerReadAllStore.State>(createSelector(
selectCrawlerReadAllState,
(state: State) => state.readAll
export const CrawlerListSelector = new StateSelector<ListStore.State>(createSelector(
selectCrawlerListState,
(state: State) => state.list
));

View File

@ -58,7 +58,6 @@ export class Effects {
return new MarkAllAsReadSuccess(page);
})
.catch((error: RPCError) => {
console.log('errrrrrrrrrrrrrr : ' + error.response.message);
return of(new MarkAllAsReadFailure(error));
});
}

View File

@ -1,4 +1,4 @@
import { Component, OnInit, Input, OnChanges } from '@angular/core';
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';
@ -9,7 +9,7 @@ import { MetaCrawler } from '../../../../meta/model';
templateUrl: './crawler-selector.component.html',
styleUrls: ['./crawler-selector.component.scss']
})
export class CrawlerSelectorComponent implements OnInit, OnChanges {
export class CrawlerSelectorComponent implements OnInit, OnChanges, AfterContentInit {
@Input() selectedTarget: Target;
crawlers: MetaCrawler[];
@ -20,6 +20,10 @@ export class CrawlerSelectorComponent implements OnInit, OnChanges {
ngOnInit() {
}
ngAfterContentInit() {
}
ngOnChanges() {
if (this.selectedTarget) {
console.log('Getting valid crawlers for ' + this.selectedTarget.displayName);

View File

@ -3,7 +3,7 @@
<mat-grid-list cols="2" rowHeight="5:1">
<mat-grid-tile [colspan]="1" [rowspan]="3" style="background-color: lightblue">
<of-target-selector (targetSelectEvent)="handleTargetSelection($event)"></of-target-selector>
<of-target-selector [target]="selectedTarget" (targetSelectEvent)="handleTargetSelection($event)" [target]="target"></of-target-selector>
</mat-grid-tile>
<mat-grid-tile [colspan]="1" [rowspan]="2" style="background-color: lightcoral">

View File

@ -1,6 +1,8 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, Input, Inject } from '@angular/core';
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';
@Component({
@ -13,7 +15,13 @@ export class SettingComponent implements OnInit, AfterContentInit {
selectedTarget: Target = null;
step = 1;
constructor() { }
constructor(
@Inject(MAT_DIALOG_DATA) public data: any
) {
if (data !== null) {
this.selectedTarget = data.infra.target;
}
}
ngOnInit() {

View File

@ -9,8 +9,8 @@
<perfect-scrollbar style="height: 150px">
<mat-radio-group class="radio-group" >
<mat-radio-button class="radio-button" *ngFor="let target of targets" value={{target.id}} (change)="targetSelected(target)">
{{target.displayName}}
<mat-radio-button class="radio-button" *ngFor="let t of targets" value={{t.id}} (change)="targetSelected(t)" [checked]="t.id === target.id">
{{t.displayName}}
</mat-radio-button>
</mat-radio-group>

View File

@ -1,4 +1,4 @@
import { Component, OnInit, Output, EventEmitter } from '@angular/core';
import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core';
import { Router } from '@angular/router';
import { MatRadioButton } from '@angular/material';
import { Target } from 'packages/target/model';
@ -11,6 +11,7 @@ import { Target } from 'packages/target/model';
})
export class TargetSelectorComponent implements OnInit {
@Input() target: Target = null;
@Output() targetSelectEvent = new EventEmitter<Target>();
targets: Target[] = null;
@ -18,16 +19,18 @@ export class TargetSelectorComponent implements OnInit {
ngOnInit() {
this.targets = new Array();
for (let i = 0; i < 10; i++) {
const t: Target = {
id: i,
displayName: 'Target' + i,
};
this.targets.push(t);
}
this.targets.push(this.target);
// for (let i = 0; i < 10; i++) {
// const t: Target = {
// id: i,
// displayName: 'Target' + i,
// };
// this.targets.push(t);
// }
}
targetSelected(t: Target) {
this.targetSelectEvent.emit(t);
}
}