diff --git a/src/packages/sensor/component/list/list.component.html b/src/packages/sensor/component/list/list.component.html
index cd72483..2775fe5 100644
--- a/src/packages/sensor/component/list/list.component.html
+++ b/src/packages/sensor/component/list/list.component.html
@@ -19,7 +19,7 @@
-
+
diff --git a/src/packages/sensor/component/list/list.component.ts b/src/packages/sensor/component/list/list.component.ts
index 40520e8..d231e35 100644
--- a/src/packages/sensor/component/list/list.component.ts
+++ b/src/packages/sensor/component/list/list.component.ts
@@ -4,6 +4,14 @@ import { AfterContentInit } from '@angular/core/src/metadata/lifecycle_hooks';
import { Router } from '@angular/router';
import { Sensor } from '../../model';
+import { Store, select } from '@ngrx/store';
+
+import * as SensorStore from '../../store';
+
+import { RPCError } from 'packages/core/rpc/error';
+import * as ReadAllByDomainStore from '../../store/readallbydomain';
+import { ReadAllByMemberSelector } from '../../store';
+import { Domain } from '../../../domain/model';
@Component({
selector: 'of-sensor-list',
@@ -12,6 +20,8 @@ import { Sensor } from '../../model';
})
export class ListComponent implements OnInit, AfterContentInit {
+ sensorList$ = this.store.pipe(select(ReadAllByMemberSelector.select('sensorList')));
+
displayedColumns = ['crawler', 'type', 'name', 'sensors'];
dataSource: MatTableDataSource;
@ViewChild(MatSort) sort: MatSort;
@@ -22,27 +32,55 @@ export class ListComponent implements OnInit, AfterContentInit {
*/
ngAfterContentInit() {
// temporary data
- const data: Sensor[] = new Array();
- for (let i = 0; i < 3; i++) {
- const t: Sensor = {
- id: i,
- target: {
- id: 1,
- displayName: '192.168.1.1',
- },
- crawler: {
- id: 1,
- name: 'WMI'
- },
- };
- data.push(t);
- }
+ // const data: Sensor[] = new Array();
+ // for (let i = 0; i < 3; i++) {
+ // const t: Sensor = {
+ // id: i,
+ // target: {
+ // id: 1,
+ // displayName: '192.168.1.1',
+ // },
+ // crawler: {
+ // id: 1,
+ // name: 'WMI'
+ // },
+ // };
+ // data.push(t);
+ // }
- this.dataSource = new MatTableDataSource(data);
- this.dataSource.sort = this.sort;
+ this.store.select(ReadAllByMemberSelector.select('domain')).subscribe(
+ (domain: Domain) => {
+ this.store.dispatch(new ReadAllByDomainStore.ReadAllByDomain(domain));
+ },
+ (error) => {
+ console.log(error);
+ }
+ );
+
+ // const domain: Domain = {
+ // id: 1
+ // };
+
+ // this.store.dispatch(new ReadAllByDomainStore.ReadAllByDomain(domain));
+
+ this.sensorList$.subscribe(
+ (probes: Sensor[]) => {
+ console.log(probes);
+ this.dataSource = new MatTableDataSource(probes);
+ this.dataSource.sort = this.sort;
+ },
+ (error: RPCError) => {
+ console.log(error.message);
+ }
+ );
+
+
+ // this.dataSource = new MatTableDataSource(data);
+ // this.dataSource.sort = this.sort;
}
- constructor(private router: Router) { }
+ constructor(private router: Router,
+ private store: Store) { }
ngOnInit() {
}
diff --git a/src/packages/settings/member/member.module.ts b/src/packages/settings/member/member.module.ts
index f410004..df1f0e0 100644
--- a/src/packages/settings/member/member.module.ts
+++ b/src/packages/settings/member/member.module.ts
@@ -6,6 +6,7 @@ import { MaterialModule } from 'app/commons/ui/material/material.module';
import { QRCodeModule } from 'angularx-qrcode';
import { COMPONENTS } from './component';
+import {SERVICES} from "../../probe/service";
@NgModule({
imports: [
CommonModule,
@@ -18,6 +19,9 @@ import { COMPONENTS } from './component';
],
declarations: [
COMPONENTS,
- ]
+ ],
+ providers: [
+ SERVICES,
+ ],
})
export class MemberModule { }
diff --git a/src/packages/settings/member/service/index.ts b/src/packages/settings/member/service/index.ts
index e69de29..0c73f8e 100644
--- a/src/packages/settings/member/service/index.ts
+++ b/src/packages/settings/member/service/index.ts
@@ -0,0 +1,5 @@
+import {MemberTotpService} from './member-totp.service';
+
+export const SERVICES = [
+ MemberTotpService,
+];
diff --git a/src/packages/settings/member/service/member-totp.service.spec.ts b/src/packages/settings/member/service/member-totp.service.spec.ts
new file mode 100644
index 0000000..a8305ef
--- /dev/null
+++ b/src/packages/settings/member/service/member-totp.service.spec.ts
@@ -0,0 +1,15 @@
+import { TestBed, inject } from '@angular/core/testing';
+
+import { MemberTotpService } from './member-totp.service';
+
+describe('MemberTotpService', () => {
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ providers: [MemberTotpService]
+ });
+ });
+
+ it('should be created', inject([MemberTotpService], (service: MemberTotpService) => {
+ expect(service).toBeTruthy();
+ }));
+});
diff --git a/src/packages/settings/member/service/member-totp.service.ts b/src/packages/settings/member/service/member-totp.service.ts
new file mode 100644
index 0000000..407f557
--- /dev/null
+++ b/src/packages/settings/member/service/member-totp.service.ts
@@ -0,0 +1,30 @@
+import { Injectable } from '@angular/core';
+import { RPCClient } from '../../../core/rpc/client/RPCClient';
+import { Observable } from 'rxjs/Observable';
+import { MemberTotp } from '../model/MemberTotp';
+import { Member } from '../../../member/model';
+
+@Injectable()
+export class MemberTotpService {
+
+ public constructor(
+ private rpcClient: RPCClient,
+ ) {
+
+ }
+
+ public createTotp(): Observable {
+ // Todo Store get member object
+
+ return this.rpcClient.call('MemberTotpService.createTotp', {id: '1'});
+ }
+
+ public regist(): Observable {
+ const param = {
+ Member: {id: 1,},
+ MemberTotp: {id: 1, secretCode: 'dkdkdkdk'},
+ code: '123123'
+ };
+ return this.rpcClient.call('MemberTotpService.regist', param);
+ }
+}
diff --git a/src/packages/settings/member/store/totp/index.ts b/src/packages/settings/member/store/totp/index.ts
new file mode 100644
index 0000000..297fc8b
--- /dev/null
+++ b/src/packages/settings/member/store/totp/index.ts
@@ -0,0 +1,4 @@
+export * from './totp.action';
+// export * from './totp.effect';
+// export * from './totp.reducer';
+// export * from './totp.state';
diff --git a/src/packages/settings/member/store/totp/totp.action.ts b/src/packages/settings/member/store/totp/totp.action.ts
new file mode 100644
index 0000000..3b9ae8a
--- /dev/null
+++ b/src/packages/settings/member/store/totp/totp.action.ts
@@ -0,0 +1,63 @@
+import { Action } from '@ngrx/store';
+
+import { RESTError } from 'packages/core/rest/error';
+
+import { DomainMember } from 'packages/domain/model';
+import {Member} from "../../../../member/model";
+
+export enum ActionType {
+ CreateTotp = '[member.totp] CreateTotp',
+ CreateTotpSuccess = '[member.totp] CreateTotpSuccess',
+ CreateTotpFailure = '[member.totp] CreateTotpFailure',
+
+ Regist = '[member.auth] SigninCookie',
+ RegistSuccess = '[member.auth] SigninCookieSuccess',
+ RegistFailure = '[member.auth] SigninCookieFailure',
+}
+
+export class CreateTotp implements Action {
+ readonly type = ActionType.CreateTotp;
+
+ constructor(public payload: {key: string, uri: string}) {}
+}
+
+export class CreateTotpSuccess implements Action {
+ readonly type = ActionType.CreateTotpSuccess;
+
+ constructor(public payload: {key: string, uri: string}) {}
+}
+
+export class CreateTotpFailure implements Action {
+ readonly type = ActionType.CreateTotpFailure;
+
+ constructor(public payload: RESTError) {}
+}
+
+// ----------------------------------------------------------------------------------------
+
+export class Regist implements Action {
+ readonly type = ActionType.Regist;
+
+ constructor(public payload: {member: Member, secretCode: string, code: string}) {}
+}
+
+export class RegistSuccess implements Action {
+ readonly type = ActionType.RegistSuccess;
+
+ constructor(public payload: void) {}
+}
+
+export class RegistFailure implements Action {
+ readonly type = ActionType.RegistFailure;
+
+ constructor(public payload: RESTError) {}
+}
+
+export type Actions =
+ | CreateTotp
+ | CreateTotpSuccess
+ | CreateTotpFailure
+ | Regist
+ | RegistSuccess
+ | RegistFailure
+ ;
diff --git a/src/packages/settings/member/store/totp/totp.effect.spec.ts b/src/packages/settings/member/store/totp/totp.effect.spec.ts
new file mode 100644
index 0000000..e69de29
diff --git a/src/packages/settings/member/store/totp/totp.effect.ts b/src/packages/settings/member/store/totp/totp.effect.ts
new file mode 100644
index 0000000..e69de29
diff --git a/src/packages/settings/member/store/totp/totp.reducer.ts b/src/packages/settings/member/store/totp/totp.reducer.ts
new file mode 100644
index 0000000..e69de29
diff --git a/src/packages/settings/member/store/totp/totp.state.ts b/src/packages/settings/member/store/totp/totp.state.ts
new file mode 100644
index 0000000..e69de29