From 8f0ed1b34400df125a9b75fc2c7aefae84b29ac4 Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 8 Mar 2018 12:06:14 +0900 Subject: [PATCH] noauth --- .../noauth/component/list/list.component.html | 41 +++++++++++++- .../noauth/component/list/list.component.ts | 55 +++++++++++++++---- src/packages/noauth/noauth.module.ts | 2 + 3 files changed, 83 insertions(+), 15 deletions(-) diff --git a/src/packages/noauth/component/list/list.component.html b/src/packages/noauth/component/list/list.component.html index 2c78552..cba3b01 100644 --- a/src/packages/noauth/component/list/list.component.html +++ b/src/packages/noauth/component/list/list.component.html @@ -1,3 +1,38 @@ -

- list works! -

+
+ + +
+
+ + + + + + + + + + + + + ID + {{element.id}} + + + + Description + {{element.description}} + + + + Created At + {{element.createDate}} + + + + + + + + +
\ No newline at end of file diff --git a/src/packages/noauth/component/list/list.component.ts b/src/packages/noauth/component/list/list.component.ts index bf43799..6fb50cc 100644 --- a/src/packages/noauth/component/list/list.component.ts +++ b/src/packages/noauth/component/list/list.component.ts @@ -1,10 +1,11 @@ -import { Component, OnInit, AfterContentInit } from '@angular/core'; - +import { Component, OnInit, AfterViewInit, ViewChild } from '@angular/core'; +import { MatTableDataSource, MatSort } from '@angular/material'; +import { AfterContentInit } from '@angular/core/src/metadata/lifecycle_hooks'; import { Router } from '@angular/router'; import { Store } from '@ngrx/store'; -import * as NoAuthProbeStore from '../../store/noauth-probe'; - -import { Domain } from 'packages/domain/model'; +import * as ListStore from '../../store/noauth-probe'; +import { Domain } from '../../../domain/model'; +import { NoAuthProbe } from '../../model'; @Component({ selector: 'of-noauth-list', @@ -13,20 +14,50 @@ import { Domain } from 'packages/domain/model'; }) export class ListComponent implements OnInit, AfterContentInit { + selected: NoAuthProbe = null; + + displayedColumns = ['select', 'id', 'description', 'createDate']; + dataSource: MatTableDataSource; + @ViewChild(MatSort) sort: MatSort; + constructor( private router: Router, - private store: Store, - + private store: Store ) { } + ngAfterContentInit() { + // const domain: Domain = { + // id: 1, + // }; + // this.store.dispatch(new ListStore.ReadAllByDomain(domain)); + + // temporary data + const data: NoAuthProbe[] = new Array(); + for (let i = 0; i < 5; i++) { + const p: NoAuthProbe = { + id: i, + description: String('desc' + i), + createDate: new Date() + }; + data.push(p); + } + + this.dataSource = new MatTableDataSource(data); + this.dataSource.sort = this.sort; + } + ngOnInit() { } - ngAfterContentInit() { - const domain: Domain = { - id: 1, - }; - this.store.dispatch(new NoAuthProbeStore.ReadAllByDomain(domain)); + handleSelect(selected: NoAuthProbe) { + this.selected = selected; } + handleAccept() { + console.log(this.selected.id + ' accept'); + } + + handleDeny() { + console.log(this.selected.id + ' deny'); + } } diff --git a/src/packages/noauth/noauth.module.ts b/src/packages/noauth/noauth.module.ts index 9a11791..64cfe1c 100644 --- a/src/packages/noauth/noauth.module.ts +++ b/src/packages/noauth/noauth.module.ts @@ -5,11 +5,13 @@ import { NoAuthProbeStoreModule } from './noauth-probe-store.module'; import { COMPONENTS } from './component'; import { SERVICES } from './service'; +import { MaterialModule } from 'app/commons/ui/material/material.module'; @NgModule({ imports: [ CommonModule, NoAuthProbeStoreModule, + MaterialModule ], declarations: [ COMPONENTS,