From a4134bb515aee0b58e23afacaeb961032b45189b Mon Sep 17 00:00:00 2001 From: insanity Date: Fri, 2 Feb 2018 15:00:40 +0900 Subject: [PATCH] sensor setting ready --- src/app/packages/sensor/sensor.module.ts | 5 +- .../target/component/list/list.component.html | 60 ++++++++++++++++++- .../target/component/list/list.component.scss | 14 +++++ .../target/component/list/list.component.ts | 55 +++++++++++++++-- src/app/packages/target/target.module.ts | 4 +- .../pages/targets/targets-page.component.html | 4 +- src/app/pages/targets/targets-page.module.ts | 3 +- 7 files changed, 132 insertions(+), 13 deletions(-) diff --git a/src/app/packages/sensor/sensor.module.ts b/src/app/packages/sensor/sensor.module.ts index acba77d..a525091 100644 --- a/src/app/packages/sensor/sensor.module.ts +++ b/src/app/packages/sensor/sensor.module.ts @@ -10,6 +10,9 @@ import { SettingComponent } from 'app/packages/sensor/component/setting/setting. CommonModule, MaterialModule ], - declarations: [SettingComponent] + declarations: [SettingComponent], + exports: [ + SettingComponent + ] }) export class SensorModule { } diff --git a/src/app/packages/target/component/list/list.component.html b/src/app/packages/target/component/list/list.component.html index 2c78552..02a3e93 100644 --- a/src/app/packages/target/component/list/list.component.html +++ b/src/app/packages/target/component/list/list.component.html @@ -1,3 +1,57 @@ -

- list works! -

+
+ + +
+ Filter Area +
+ + +
+ + + + + Name + {{element.name}} + + + + IP + {{element.ip}} + + + + OS + {{element.os}} + + + + CIDR + {{element.cidr}} + + + + Targets + {{element.targetCnt}} + + + + Date + {{element.date}} + + + + AuthBy + {{element.authBy}} + + + + + + + + + +
+ +
\ No newline at end of file diff --git a/src/app/packages/target/component/list/list.component.scss b/src/app/packages/target/component/list/list.component.scss index e69de29..54b8a22 100644 --- a/src/app/packages/target/component/list/list.component.scss +++ b/src/app/packages/target/component/list/list.component.scss @@ -0,0 +1,14 @@ +.example-container { + display: flex; + flex-direction: column; + min-width: 300px; + } + + .mat-table { + overflow: auto; + max-height: 500px; + } + + .mat-header-cell.mat-sort-header-sorted { + color: black; + } \ No newline at end of file diff --git a/src/app/packages/target/component/list/list.component.ts b/src/app/packages/target/component/list/list.component.ts index fa28354..2d05372 100644 --- a/src/app/packages/target/component/list/list.component.ts +++ b/src/app/packages/target/component/list/list.component.ts @@ -1,15 +1,62 @@ -import { Component, OnInit } 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'; + +export interface Probe { + id: string; + name: string; + ip: string; + os: string; + cidr: string; + targetCnt: number; + date: string; + authBy: string; +} + @Component({ - selector: 'of-list', + selector: 'of-target-list', templateUrl: './list.component.html', styleUrls: ['./list.component.scss'] }) -export class ListComponent implements OnInit { +export class ListComponent implements OnInit, AfterContentInit { - constructor() { } + displayedColumns = ['name', 'ip', 'os', 'cidr', 'targetCnt', 'date', 'authBy']; + dataSource: MatTableDataSource; + @ViewChild(MatSort) sort: MatSort; + + /** + * Set the sort after the view init since this component will + * be able to query its view for the initialized sort. + */ + ngAfterContentInit() { + // temporary data + const data: Probe[] = new Array(); + for (let i = 0; i < 10; i++) { + const p: Probe = { + id: String('id' + i), + name: String('name' + i), + ip: String('ip' + i), + os: String('os' + i), + cidr: String('cidr' + i), + targetCnt: i, + date: String('date' + i), + authBy: String('insanity') + }; + data.push(p); + } + + this.dataSource = new MatTableDataSource(data); + this.dataSource.sort = this.sort; + } + + constructor(private router: Router) { } ngOnInit() { } + handleRowClick(obj: Probe) { + this.router.navigate(['probe', obj.id]); + } } diff --git a/src/app/packages/target/target.module.ts b/src/app/packages/target/target.module.ts index ca43aa6..d8f558c 100644 --- a/src/app/packages/target/target.module.ts +++ b/src/app/packages/target/target.module.ts @@ -1,10 +1,12 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { ListComponent } from 'app/packages/target/component/list/list.component'; +import { MaterialModule } from 'app/commons/ui/material/material.module'; @NgModule({ imports: [ - CommonModule + CommonModule, + MaterialModule ], declarations: [ListComponent], exports: [ diff --git a/src/app/pages/targets/targets-page.component.html b/src/app/pages/targets/targets-page.component.html index c827d68..3ac3bad 100644 --- a/src/app/pages/targets/targets-page.component.html +++ b/src/app/pages/targets/targets-page.component.html @@ -1,3 +1 @@ -
- target page -
\ No newline at end of file + \ No newline at end of file diff --git a/src/app/pages/targets/targets-page.module.ts b/src/app/pages/targets/targets-page.module.ts index 6648c2b..2f572ff 100644 --- a/src/app/pages/targets/targets-page.module.ts +++ b/src/app/pages/targets/targets-page.module.ts @@ -10,7 +10,8 @@ import { TargetsPageRoutingModule } from 'app/pages/targets/targets-page-routing imports: [ CommonModule, MaterialModule, - TargetsPageRoutingModule + TargetsPageRoutingModule, + TargetModule ], declarations: [ TargetsPageComponent