From 2a4e370f8c072b4f453b7e99ae79a508ff0c4796 Mon Sep 17 00:00:00 2001 From: snoop Date: Thu, 8 Mar 2018 14:39:07 +0900 Subject: [PATCH 1/2] added infra store --- src/app/commons/model/Page.ts | 13 ++++++++ src/app/commons/model/PageParams.ts | 8 +++++ src/app/commons/model/index.ts | 2 ++ src/packages/infra/infra-store.module.ts | 0 src/packages/infra/infra.constant.ts | 0 .../infra/service/infra.service.spec.ts | 0 src/packages/infra/service/infra.service.ts | 32 +++++++++++++++++++ src/packages/infra/store/index.ts | 0 .../infra/store/readbydomain/index.ts | 4 +++ .../store/readbydomain/readbydomain.action.ts | 0 .../readbydomain/readbydomain.effect.spec.ts | 0 .../store/readbydomain/readbydomain.effect.ts | 0 .../readbydomain/readbydomain.reducer.ts | 0 .../store/readbydomain/readbydomain.state.ts | 20 ++++++++++++ 14 files changed, 79 insertions(+) create mode 100644 src/app/commons/model/Page.ts create mode 100644 src/app/commons/model/PageParams.ts create mode 100644 src/app/commons/model/index.ts create mode 100644 src/packages/infra/infra-store.module.ts create mode 100644 src/packages/infra/infra.constant.ts create mode 100644 src/packages/infra/service/infra.service.spec.ts create mode 100644 src/packages/infra/service/infra.service.ts create mode 100644 src/packages/infra/store/index.ts create mode 100644 src/packages/infra/store/readbydomain/index.ts create mode 100644 src/packages/infra/store/readbydomain/readbydomain.action.ts create mode 100644 src/packages/infra/store/readbydomain/readbydomain.effect.spec.ts create mode 100644 src/packages/infra/store/readbydomain/readbydomain.effect.ts create mode 100644 src/packages/infra/store/readbydomain/readbydomain.reducer.ts create mode 100644 src/packages/infra/store/readbydomain/readbydomain.state.ts diff --git a/src/app/commons/model/Page.ts b/src/app/commons/model/Page.ts new file mode 100644 index 0000000..e64070a --- /dev/null +++ b/src/app/commons/model/Page.ts @@ -0,0 +1,13 @@ +export interface Page { + content: any; + first: boolean; + last: boolean; + number: number; + numberOfElements: number; + size: number; + sort: any; + totalElements: number; + totalPages: number; +} + +// export default Page; diff --git a/src/app/commons/model/PageParams.ts b/src/app/commons/model/PageParams.ts new file mode 100644 index 0000000..1ab0d14 --- /dev/null +++ b/src/app/commons/model/PageParams.ts @@ -0,0 +1,8 @@ +export interface PageParams { + pageNo: string; + countPerPage: string; + sortCol?: string; + sortDirection?: string; +} + +// export default PageParams; diff --git a/src/app/commons/model/index.ts b/src/app/commons/model/index.ts new file mode 100644 index 0000000..46f7171 --- /dev/null +++ b/src/app/commons/model/index.ts @@ -0,0 +1,2 @@ +export * from './Page'; +export * from './PageParams'; diff --git a/src/packages/infra/infra-store.module.ts b/src/packages/infra/infra-store.module.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/packages/infra/infra.constant.ts b/src/packages/infra/infra.constant.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/packages/infra/service/infra.service.spec.ts b/src/packages/infra/service/infra.service.spec.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/packages/infra/service/infra.service.ts b/src/packages/infra/service/infra.service.ts new file mode 100644 index 0000000..feddf80 --- /dev/null +++ b/src/packages/infra/service/infra.service.ts @@ -0,0 +1,32 @@ +// import { Injectable } from '@angular/core'; +// import { Observable } from 'rxjs/Observable'; + +// import 'rxjs/add/operator/map'; + +// import { RESTService } from 'packages/commons/service/rest.service'; +// import { DomainMember } from 'packages/domain/model'; + +// import { Infra } from '../model'; + +// @Injectable() +// export class MemberService { + +// public constructor( +// private restService: RESTService, +// ) { + +// } + +// public signin(email: string, password: string): Observable { +// const body = { +// signinId: email, +// signinPw: password, +// }; + +// return this.restService.post('/account/signin', body); +// } + +// public signup(member: Member): Observable { +// return this.restService.post('/account/signup', member); +// } +// } diff --git a/src/packages/infra/store/index.ts b/src/packages/infra/store/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/packages/infra/store/readbydomain/index.ts b/src/packages/infra/store/readbydomain/index.ts new file mode 100644 index 0000000..aee2667 --- /dev/null +++ b/src/packages/infra/store/readbydomain/index.ts @@ -0,0 +1,4 @@ +// export * from './readbydomain.action'; +// export * from './readbydomain.effect'; +// export * from './readbydomain.reducer'; +// export * from './readbydomain.state'; diff --git a/src/packages/infra/store/readbydomain/readbydomain.action.ts b/src/packages/infra/store/readbydomain/readbydomain.action.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/packages/infra/store/readbydomain/readbydomain.effect.spec.ts b/src/packages/infra/store/readbydomain/readbydomain.effect.spec.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/packages/infra/store/readbydomain/readbydomain.effect.ts b/src/packages/infra/store/readbydomain/readbydomain.effect.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/packages/infra/store/readbydomain/readbydomain.reducer.ts b/src/packages/infra/store/readbydomain/readbydomain.reducer.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/packages/infra/store/readbydomain/readbydomain.state.ts b/src/packages/infra/store/readbydomain/readbydomain.state.ts new file mode 100644 index 0000000..00c4c33 --- /dev/null +++ b/src/packages/infra/store/readbydomain/readbydomain.state.ts @@ -0,0 +1,20 @@ +import { ErrorResponse } from 'packages/commons/service/error-response'; + +import { Infra } from '../../model'; +import { Page } from '../../../../app/commons/model'; + +export interface State { + error: ErrorResponse | null; + isPending: boolean; + infraList: Infra[] | null; +} + +export const initialState: State = { + error: null, + isPending: false, + infraList: null, +}; + +export const getInfraList = (state: State) => state.infraList; +export const getError = (state: State) => state.error; +export const isPending = (state: State) => state.isPending; From 3b4bbd9c95f2fff7a8bc414390e281b9f42be826 Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 8 Mar 2018 15:25:57 +0900 Subject: [PATCH 2/2] target filter --- .../noauth/component/list/list.component.html | 2 +- .../component/detail/detail.component.html | 2 +- .../probe/component/list/list.component.html | 2 +- .../probe/component/list/list.component.ts | 5 +- src/packages/target/component/index.ts | 2 + .../list/filter/filter.component.html | 21 ++++++++ .../list/filter/filter.component.scss | 9 ++++ .../list/filter/filter.component.spec.ts | 25 +++++++++ .../component/list/filter/filter.component.ts | 17 +++++++ .../target/component/list/list.component.html | 51 +++++++------------ .../target/component/list/list.component.ts | 46 ++++++++--------- 11 files changed, 120 insertions(+), 62 deletions(-) create mode 100644 src/packages/target/component/list/filter/filter.component.html create mode 100644 src/packages/target/component/list/filter/filter.component.scss create mode 100644 src/packages/target/component/list/filter/filter.component.spec.ts create mode 100644 src/packages/target/component/list/filter/filter.component.ts diff --git a/src/packages/noauth/component/list/list.component.html b/src/packages/noauth/component/list/list.component.html index cba3b01..d84e594 100644 --- a/src/packages/noauth/component/list/list.component.html +++ b/src/packages/noauth/component/list/list.component.html @@ -26,7 +26,7 @@ Created At - {{element.createDate}} + {{element.createDate.toLocaleString()}} diff --git a/src/packages/probe/component/detail/detail.component.html b/src/packages/probe/component/detail/detail.component.html index 7992ad1..1fb8fc9 100644 --- a/src/packages/probe/component/detail/detail.component.html +++ b/src/packages/probe/component/detail/detail.component.html @@ -1,7 +1,7 @@

{{probeAlias}}

- Status: UP + Status: UP
diff --git a/src/packages/probe/component/list/list.component.html b/src/packages/probe/component/list/list.component.html index 422fbd3..f489401 100644 --- a/src/packages/probe/component/list/list.component.html +++ b/src/packages/probe/component/list/list.component.html @@ -40,6 +40,6 @@ - +
\ No newline at end of file diff --git a/src/packages/probe/component/list/list.component.ts b/src/packages/probe/component/list/list.component.ts index c994fb2..ab4e547 100644 --- a/src/packages/probe/component/list/list.component.ts +++ b/src/packages/probe/component/list/list.component.ts @@ -14,6 +14,9 @@ import { Domain } from '../../../domain/model'; }) export class ListComponent implements OnInit, AfterContentInit { + pageSize = '25'; + length = '100'; + displayedColumns = ['name', 'ip', 'os', 'cidr', 'targetCnt', 'date', 'authBy']; dataSource: MatTableDataSource; @ViewChild(MatSort) sort: MatSort; @@ -31,7 +34,7 @@ export class ListComponent implements OnInit, AfterContentInit { // temporary data const data: Probe[] = new Array(); - for (let i = 0; i < 10; i++) { + for (let i = 0; i < 100; i++) { const p: Probe = { id: i, displayName: String('displayName' + i), diff --git a/src/packages/target/component/index.ts b/src/packages/target/component/index.ts index 8898b9a..9e79653 100644 --- a/src/packages/target/component/index.ts +++ b/src/packages/target/component/index.ts @@ -1,7 +1,9 @@ import { DetailComponent } from './detail/detail.component'; import { ListComponent } from './list/list.component'; +import { FilterComponent } from './list/filter/filter.component'; export const COMPONENTS = [ ListComponent, DetailComponent, + FilterComponent ]; diff --git a/src/packages/target/component/list/filter/filter.component.html b/src/packages/target/component/list/filter/filter.component.html new file mode 100644 index 0000000..7833e71 --- /dev/null +++ b/src/packages/target/component/list/filter/filter.component.html @@ -0,0 +1,21 @@ +
+ + + +
+
+
Status
+ + All + Active + Inactive + +
+
+
Type
+ + All + Host + Application + +
\ No newline at end of file diff --git a/src/packages/target/component/list/filter/filter.component.scss b/src/packages/target/component/list/filter/filter.component.scss new file mode 100644 index 0000000..97910d9 --- /dev/null +++ b/src/packages/target/component/list/filter/filter.component.scss @@ -0,0 +1,9 @@ +.radio-group { + display: inline-flex; + flex-direction: column; + } + + .radio-button { + margin: 5px; + } + \ No newline at end of file diff --git a/src/packages/target/component/list/filter/filter.component.spec.ts b/src/packages/target/component/list/filter/filter.component.spec.ts new file mode 100644 index 0000000..fc30049 --- /dev/null +++ b/src/packages/target/component/list/filter/filter.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FilterComponent } from './filter.component'; + +describe('FilterComponent', () => { + let component: FilterComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ FilterComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(FilterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/packages/target/component/list/filter/filter.component.ts b/src/packages/target/component/list/filter/filter.component.ts new file mode 100644 index 0000000..2a9a63a --- /dev/null +++ b/src/packages/target/component/list/filter/filter.component.ts @@ -0,0 +1,17 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; + + +@Component({ + selector: 'of-target-filter', + templateUrl: './filter.component.html', + styleUrls: ['./filter.component.scss'] +}) +export class FilterComponent implements OnInit { + + + constructor(private router: Router) { } + + ngOnInit() { + } +} diff --git a/src/packages/target/component/list/list.component.html b/src/packages/target/component/list/list.component.html index c670bbe..2c0e619 100644 --- a/src/packages/target/component/list/list.component.html +++ b/src/packages/target/component/list/list.component.html @@ -1,49 +1,34 @@
-
- Filter Area +
+
-
+
+ + Status + ? + + + + Type + {{element.infraType.name}} + + Name - {{element.name}} + {{element.target.displayName}} - - IP - {{element.ip}} - - - - OS - {{element.os}} - - - - CIDR - {{element.cidr}} - - - - Targets - {{element.targetCnt}} - - - - Date - {{element.date}} - - - - AuthBy - {{element.authBy}} - + + Sensors + ? + diff --git a/src/packages/target/component/list/list.component.ts b/src/packages/target/component/list/list.component.ts index 005f86f..42bac62 100644 --- a/src/packages/target/component/list/list.component.ts +++ b/src/packages/target/component/list/list.component.ts @@ -2,17 +2,7 @@ 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; -} +import { Infra } from '../../../infra/model'; @Component({ @@ -22,8 +12,8 @@ export interface Probe { }) export class ListComponent implements OnInit, AfterContentInit { - displayedColumns = ['name', 'ip', 'os', 'cidr', 'targetCnt', 'date', 'authBy']; - dataSource: MatTableDataSource; + displayedColumns = ['status', 'type', 'name', 'sensors']; + dataSource: MatTableDataSource; @ViewChild(MatSort) sort: MatSort; /** @@ -32,19 +22,25 @@ export class ListComponent implements OnInit, AfterContentInit { */ ngAfterContentInit() { // temporary data - const data: Probe[] = new Array(); + const data: Infra[] = new Array(); for (let i = 0; i < 10; i++) { - const p: Probe = { - id: String(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') + const t: Infra = { + id: i, + infraType: { + id: 1, + name: 'Host' + }, + childId: 1, + createDate: new Date(), + probe: { + id: 1, + }, + target: { + id: 1, + displayName: 'Target Name' + } }; - data.push(p); + data.push(t); } this.dataSource = new MatTableDataSource(data); @@ -56,7 +52,7 @@ export class ListComponent implements OnInit, AfterContentInit { ngOnInit() { } - handleRowClick(obj: Probe) { + handleRowClick(obj: Infra) { this.router.navigate(['target', obj.id]); } }