This commit is contained in:
snoop 2018-03-21 19:48:54 +09:00
commit 3d82f212b2
12 changed files with 134 additions and 62 deletions

View File

@ -62,7 +62,6 @@ export class MapComponent implements OnInit, AfterContentInit {
addSensor(infra: Infra) { addSensor(infra: Infra) {
const targetId = infra.target.id; const targetId = infra.target.id;
console.log(targetId);
const dialogRef = this.dialog.open(SettingComponent, { const dialogRef = this.dialog.open(SettingComponent, {
width: '80%', width: '80%',

View File

@ -29,9 +29,6 @@ export class CrawlerAuthComponent implements OnInit, OnChanges {
this.inputItems$.subscribe( this.inputItems$.subscribe(
(list: MetaCrawlerInputItem[]) => { (list: MetaCrawlerInputItem[]) => {
if (list !== null) { if (list !== null) {
console.log('###Auth Inputs###');
console.log(list);
console.log('###################');
this.inputItems = list; this.inputItems = list;
this.generateAuthComponent(); this.generateAuthComponent();
} }

View File

@ -9,7 +9,7 @@
<perfect-scrollbar style="height: 150px"> <perfect-scrollbar style="height: 150px">
<mat-radio-group class="radio-group"> <mat-radio-group class="radio-group">
<mat-radio-button class="radio-button" *ngFor="let crawler of crawlers" value={{crawler.id}} (change)="crawlerSelected(crawler)"> <mat-radio-button class="radio-button" *ngFor="let crawler of crawlers" value={{crawler.id}} (change)="crawlerSelected(crawler)" [checked]="crawler.id === selectedCrawlerId">
{{crawler.name}} {{crawler.name}}
</mat-radio-button> </mat-radio-button>
</mat-radio-group> </mat-radio-group>

View File

@ -17,13 +17,10 @@ import { MetaCrawler } from 'packages/meta/crawler/model/MetaCrawler';
export class CrawlerSelectorComponent implements OnInit, OnChanges, AfterContentInit { export class CrawlerSelectorComponent implements OnInit, OnChanges, AfterContentInit {
crawlers$ = this.listStore.pipe(select(ReadAllCrawlerSelector.select('metaCrawlerList'))); crawlers$ = this.listStore.pipe(select(ReadAllCrawlerSelector.select('metaCrawlerList')));
@Input() selectedTarget: Target; @Input() selectedTarget: Target;
crawlers: MetaCrawler[]; crawlers: MetaCrawler[];
@Output() crawlerSelectEvent = new EventEmitter<MetaCrawler>(); @Output() crawlerSelectEvent = new EventEmitter<MetaCrawler>();
constructor( constructor(
private router: Router, private router: Router,
private listStore: Store<ListStore.State>, private listStore: Store<ListStore.State>,
@ -47,9 +44,6 @@ export class CrawlerSelectorComponent implements OnInit, OnChanges, AfterContent
} }
ngOnChanges() { ngOnChanges() {
// if (this.selectedTarget) {
// console.log('Getting valid crawlers for ' + this.selectedTarget.displayName);
// }
} }
crawlerSelected(crawler: MetaCrawler) { crawlerSelected(crawler: MetaCrawler) {

View File

@ -12,12 +12,13 @@
<ng-template #treeNodeFullTemplate let-node let-index="index" let-templates="templates"> <ng-template #treeNodeFullTemplate let-node let-index="index" let-templates="templates">
<div class="tree-node"> <div class="tree-node">
<tree-node-expander [node]="node" ></tree-node-expander> <tree-node-expander [node]="node" ></tree-node-expander>
<mat-checkbox [checked]="node.data.default" (change)="checkItem(node)"></mat-checkbox> <mat-checkbox [checked]="node.isActive" (change)="checkItem(node)"></mat-checkbox>
<div <div
class="node-content-wrapper" class="node-content-wrapper"
[class.node-content-wrapper-active]="node.isActive" [class.node-content-wrapper-active]="node.isActive"
[class.node-content-wrapper-focused]="node.isFocused" [class.node-content-wrapper-focused]="node.isFocused"
(click)="checkItem(node)"> (click)="checkItem(node)">
<mat-chip *ngIf="node.data.default" color="primary" (click)="checkItem(node)" >Recommend!</mat-chip>
<span [class]="node.data.className" [class.title]="true">{{ node.data.title }} {{node.data.key}}</span> <span [class]="node.data.className" [class.title]="true">{{ node.data.title }} {{node.data.key}}</span>
</div> </div>

View File

@ -1,4 +1,4 @@
import { Component, OnInit, OnChanges, Input, Output, EventEmitter, ViewChild, AfterViewInit } from '@angular/core'; import { Component, OnInit, OnChanges, Input, Output, EventEmitter, ViewChild, AfterViewInit, OnDestroy } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Store, select } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
import { RPCError } from 'packages/core/rpc/error'; import { RPCError } from 'packages/core/rpc/error';
@ -14,14 +14,13 @@ import { ITreeOptions } from 'angular-tree-component';
templateUrl: './sensor-item-selector.component.html', templateUrl: './sensor-item-selector.component.html',
styleUrls: ['./sensor-item-selector.component.scss'] styleUrls: ['./sensor-item-selector.component.scss']
}) })
export class SensorItemSelectorComponent implements OnInit, AfterViewInit, OnChanges { export class SensorItemSelectorComponent implements OnInit, OnChanges {
@Input() selectedCrawler: MetaCrawler; @Input() selectedCrawler: MetaCrawler;
@Output() selectedItems = new EventEmitter<MetaSensorDisplayItem[]>(); @Output() itemSelectEvent = new EventEmitter<Set<MetaSensorDisplayItem>>();
items$ = this.listStore.pipe(select(ReadAllSensorDisplayItemByCrawlerSelector.select('list'))); items$ = this.listStore.pipe(select(ReadAllSensorDisplayItemByCrawlerSelector.select('list')));
sensorDisplayItems: MetaSensorDisplayItem[];
@ViewChild('tree') tree;
nodes; nodes;
checkedSet: Set<MetaSensorDisplayItem>;
constructor( constructor(
private router: Router, private router: Router,
@ -29,13 +28,10 @@ export class SensorItemSelectorComponent implements OnInit, AfterViewInit, OnCha
) { } ) { }
ngOnInit() { ngOnInit() {
this.checkedSet = new Set();
this.items$.subscribe( this.items$.subscribe(
(list: MetaSensorDisplayItem[]) => { (list: MetaSensorDisplayItem[]) => {
if (list !== null) { if (list !== null) {
console.log('###Display Items###');
console.log(list);
console.log('###################');
this.sensorDisplayItems = list;
this.generateTreeNode(list); this.generateTreeNode(list);
} }
}, },
@ -45,9 +41,6 @@ export class SensorItemSelectorComponent implements OnInit, AfterViewInit, OnCha
); );
} }
ngAfterViewInit() {
}
ngOnChanges() { ngOnChanges() {
this.listStore.dispatch(new ListStore.ReadAllByCrawler(this.selectedCrawler)); this.listStore.dispatch(new ListStore.ReadAllByCrawler(this.selectedCrawler));
} }
@ -62,20 +55,21 @@ export class SensorItemSelectorComponent implements OnInit, AfterViewInit, OnCha
const node = { const node = {
title: item.itemType.name, title: item.itemType.name,
children: childrenNode, children: childrenNode,
isExpanded: true
}; };
this.nodes.push(node); this.nodes.push(node);
} else { } else {
categoryNode.children.push(this.getChildNode(item)); categoryNode.children.push(this.getChildNode(item));
} }
} }
this.itemSelectEvent.emit(this.checkedSet);
} }
getChildNode(item) { getChildNode(item) {
const childNode = { const childNode = {
title: item.displayName, title: item.displayName,
key: ' - ' + item.key, key: ' - ' + item.key,
default: item.default default: item.default,
displayItem: item
}; };
return childNode; return childNode;
} }
@ -92,16 +86,16 @@ export class SensorItemSelectorComponent implements OnInit, AfterViewInit, OnCha
checkItem(node) { checkItem(node) {
node.toggleActivated(true); node.toggleActivated(true);
console.log(node); if (node.isActive) {
// if (node.isActive) { if (this.checkedSet.has(node.data.displayItem) === false) {
// if (this.checkedSet.has(node.data) === false) { this.checkedSet.add(node.data.displayItem);
// this.checkedSet.add(node.data); }
// } } else {
// } else { if (this.checkedSet.has(node.data.displayItem)) {
// if (this.checkedSet.has(node.data)) { this.checkedSet.delete(node.data.displayItem);
// this.checkedSet.delete(node.data); }
// } }
// } this.itemSelectEvent.emit(this.checkedSet);
} }
onTreeDataLoad(tree) { onTreeDataLoad(tree) {

View File

@ -1,5 +1,5 @@
<div> <div>
<div *ngIf="step === 1"> <div [hidden]="step !== 1">
<mat-grid-list cols="2" rowHeight="5:1"> <mat-grid-list cols="2" rowHeight="5:1">
<mat-grid-tile [colspan]="1" [rowspan]="3" style="background-color: lightblue"> <mat-grid-tile [colspan]="1" [rowspan]="3" style="background-color: lightblue">

View File

@ -1,9 +1,9 @@
import { Component, OnInit, Input, Inject } 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 { Target } from '../../../target/model';
import { MAT_DIALOG_DATA } from '@angular/material'; import { MAT_DIALOG_DATA } from '@angular/material';
import { Infra } from '../../../infra/model'; import { Infra } from '../../../infra/model';
import { MetaCrawler } from '../../../meta/crawler/model/MetaCrawler'; import { MetaCrawler } from '../../../meta/crawler/model/MetaCrawler';
import { MetaSensorDisplayItem } from '../../../meta/sensor-display-item/model/MetaSensorDisplayItem';
@Component({ @Component({
@ -11,10 +11,11 @@ import { MetaCrawler } from '../../../meta/crawler/model/MetaCrawler';
templateUrl: './setting.component.html', templateUrl: './setting.component.html',
styleUrls: ['./setting.component.scss'] styleUrls: ['./setting.component.scss']
}) })
export class SettingComponent implements OnInit, AfterContentInit { export class SettingComponent implements OnInit {
selectedTarget: Target = null; selectedTarget: Target = null;
selectedCrawler: MetaCrawler = null; selectedCrawler: MetaCrawler = null;
selectedSensorDisplayItems: Set<MetaSensorDisplayItem> = null;
step = 1; step = 1;
constructor( constructor(
@ -25,16 +26,30 @@ export class SettingComponent implements OnInit, AfterContentInit {
} }
} }
ngOnInit() { ngOnInit() {
} }
ngAfterContentInit() { onNext() {
const valid = this.validateSelection();
if (valid !== null) {
alert(valid);
return;
}
this.step += 1;
} }
onNext() { validateSelection() {
this.step += 1; let message = null;
if (this.selectedTarget === null) {
message = 'Target is not selected.';
}
if (this.selectedCrawler === null) {
message = 'Crawler is not selected.';
}
if (this.selectedSensorDisplayItems === null || this.selectedSensorDisplayItems.size === 0) {
message = 'SensorItem is not selected.';
}
return message;
} }
onPrev() { onPrev() {
@ -51,4 +66,7 @@ export class SettingComponent implements OnInit, AfterContentInit {
handleCrawlerSelection(c: MetaCrawler) { handleCrawlerSelection(c: MetaCrawler) {
this.selectedCrawler = c; this.selectedCrawler = c;
} }
handleItemSelection(itemSet: Set<MetaSensorDisplayItem>) {
this.selectedSensorDisplayItems = itemSet;
}
} }

View File

@ -3,9 +3,12 @@ import { ActivatedRoute, Router } from '@angular/router';
import * as TotpStore from '../../store/totp'; import * as TotpStore from '../../store/totp';
import { Store, select } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { AuthSelector } from 'packages/member/store';
import { TotpSelector } from '../../store'; import { TotpSelector } from '../../store';
import {AuthSelector} from "../../../../member/store/index"; import { Member } from 'packages/member/model/Member';
import {Member} from "../../../../member/model/Member";
@Component({ @Component({
selector: 'of-totp', selector: 'of-totp',
@ -51,6 +54,29 @@ export class TotpComponent implements OnInit {
}); });
} }
// ngAfterContentInit() {
//
// this.listStore.select(AuthSelector.select('member')).subscribe(
// (member: Member) => {
// this.store.dispatch(new TotpRegistStore.createTotp(member));
// },
// (error) => {
// console.log(error);
// }
// );
//
// this.probes$.subscribe(
// (probes: boo) => {
// console.log(probes);
// this.dataSource = new MatTableDataSource(probes);
// this.dataSource.sort = this.sort;
// },
// (error: RPCError) => {
// console.log(error.response.message);
// }
// );
//
// }
registClick() { registClick() {
const code = this.totpForm.value['code']; const code = this.totpForm.value['code'];
const secretCode = 'X6AWAK573M5372NM'; const secretCode = 'X6AWAK573M5372NM';

View File

@ -16,7 +16,7 @@ export class MemberTotpService {
public createTotp(member: Member): Observable<MemberTotp[]> { public createTotp(member: Member): Observable<MemberTotp[]> {
// Todo Store get member object // Todo Store get member object
return this.rpcClient.call<MemberTotp[]>('MemberTotpService.createTotp', {Member: {id:1}}); return this.rpcClient.call<MemberTotp[]>('MemberTotpService.createTotp', {Member: member});
} }
public regist(member: Member, secretCode: string, code: string): Observable<boolean> { public regist(member: Member, secretCode: string, code: string): Observable<boolean> {
@ -27,4 +27,8 @@ export class MemberTotpService {
// }; // };
return this.rpcClient.call<boolean>('MemberTotpService.regist', member, secretCode, code); return this.rpcClient.call<boolean>('MemberTotpService.regist', member, secretCode, code);
} }
public checkCodeForMember(member: Member, code: string): Observable<boolean> {
return this.rpcClient.call<boolean>('MemberTotpService.checkCodeForMember', member, code);
}
} }

View File

@ -12,6 +12,10 @@ export enum ActionType {
Regist = '[member.totp] Regist', Regist = '[member.totp] Regist',
RegistSuccess = '[member.totp] RegistSuccess', RegistSuccess = '[member.totp] RegistSuccess',
RegistFailure = '[member.totp] RegistFailure', RegistFailure = '[member.totp] RegistFailure',
CheckCodeForMember = '[member.totp] CheckCodeForMember',
CheckCodeForMemberSuccess = '[member.totp] CheckCodeForMemberSuccess',
CheckCodeForMemberFailure = '[member.totp] CheckCodeForMemberFailure',
} }
export class CreateTotp implements Action { export class CreateTotp implements Action {
@ -52,6 +56,26 @@ export class RegistFailure implements Action {
constructor(public payload: RESTError) {} constructor(public payload: RESTError) {}
} }
// ----------------------------------------------------------------------------------------
export class CheckCodeForMember implements Action {
readonly type = ActionType.CheckCodeForMember;
constructor(public payload: {member: Member, code: string}) {}
}
export class CheckCodeForMemberSuccess implements Action {
readonly type = ActionType.CheckCodeForMemberSuccess;
constructor(public payload: void) {}
}
export class CheckCodeForMemberFailure implements Action {
readonly type = ActionType.CheckCodeForMemberFailure;
constructor(public payload: RESTError) {}
}
export type Actions = export type Actions =
| CreateTotp | CreateTotp
| CreateTotpSuccess | CreateTotpSuccess
@ -59,4 +83,7 @@ export type Actions =
| Regist | Regist
| RegistSuccess | RegistSuccess
| RegistFailure | RegistFailure
| CheckCodeForMember
| CheckCodeForMemberSuccess
| CheckCodeForMemberFailure
; ;

View File

@ -26,6 +26,10 @@ import {
RegistSuccess, RegistSuccess,
RegistFailure, RegistFailure,
CheckCodeForMember,
CheckCodeForMemberSuccess,
CheckCodeForMemberFailure,
ActionType, ActionType,
} from './totp.action'; } from './totp.action';
@ -56,14 +60,6 @@ export class Effects {
return of(new CreateTotpFailure(error)); return of(new CreateTotpFailure(error));
}); });
@Effect({ dispatch: false })
createTotpSuccess$ = this.actions$
.ofType(ActionType.CreateTotpSuccess)
.do(() => {
// Todo TOTP View Print
this.router.navigateByUrl(this._returnURL);
});
@Effect() @Effect()
regist: Observable<Action> = this.actions$ regist: Observable<Action> = this.actions$
.ofType(ActionType.Regist) .ofType(ActionType.Regist)
@ -78,4 +74,20 @@ export class Effects {
.catch((error: RESTError) => { .catch((error: RESTError) => {
return of(new RegistFailure(error)); return of(new RegistFailure(error));
}); });
@Effect()
checkCodeForMember: Observable<Action> = this.actions$
.ofType(ActionType.CheckCodeForMember)
.map((action: Regist) => action.payload)
.switchMap((payload) => {
// this._returnURL = payload.returnURL;
return this.memberTotpService.checkCodeForMember(payload.member, payload.code);
})
.map((result: any) => {
return new CheckCodeForMemberSuccess(result);
})
.catch((error: RESTError) => {
return of(new CheckCodeForMemberFailure(error));
});
} }