From c739b82f04969d5c52c22a7416b63681801069c7 Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 8 Mar 2018 18:18:06 +0900 Subject: [PATCH] sensor ing --- .../pages/probe/probe-page-routing.module.ts | 2 +- .../pages/sensors/sensors-page.component.html | 6 +- src/app/pages/sensors/sensors-page.module.ts | 4 +- src/packages/sensor/component/index.ts | 4 ++ .../list/filter/filter.component.html | 30 ++++++++++ .../list/filter/filter.component.scss | 9 +++ .../list/filter/filter.component.spec.ts | 25 ++++++++ .../component/list/filter/filter.component.ts | 24 ++++++++ .../sensor/component/list/list.component.html | 57 +++++++++++++++++++ .../sensor/component/list/list.component.scss | 14 +++++ .../component/list/list.component.spec.ts | 25 ++++++++ .../sensor/component/list/list.component.ts | 53 +++++++++++++++++ .../list/filter/filter.component.html | 2 - 13 files changed, 248 insertions(+), 7 deletions(-) create mode 100644 src/packages/sensor/component/list/filter/filter.component.html create mode 100644 src/packages/sensor/component/list/filter/filter.component.scss create mode 100644 src/packages/sensor/component/list/filter/filter.component.spec.ts create mode 100644 src/packages/sensor/component/list/filter/filter.component.ts create mode 100644 src/packages/sensor/component/list/list.component.html create mode 100644 src/packages/sensor/component/list/list.component.scss create mode 100644 src/packages/sensor/component/list/list.component.spec.ts create mode 100644 src/packages/sensor/component/list/list.component.ts diff --git a/src/app/pages/probe/probe-page-routing.module.ts b/src/app/pages/probe/probe-page-routing.module.ts index 75df806..58d1493 100644 --- a/src/app/pages/probe/probe-page-routing.module.ts +++ b/src/app/pages/probe/probe-page-routing.module.ts @@ -11,7 +11,7 @@ const routes: Routes = [ children: [ { path: ':id', component: ProbeDetailComponent }, { path: ':id/targets', loadChildren: 'app/pages/targets/targets-page.module#TargetsPageModule'}, - { path: ':id/history', component: ProbeDetailComponent }, + { path: ':id/history', component: null }, ] } ]; diff --git a/src/app/pages/sensors/sensors-page.component.html b/src/app/pages/sensors/sensors-page.component.html index 33ea338..869c69a 100644 --- a/src/app/pages/sensors/sensors-page.component.html +++ b/src/app/pages/sensors/sensors-page.component.html @@ -1,3 +1,3 @@ -

- sensors works! -

+
+ +
\ No newline at end of file diff --git a/src/app/pages/sensors/sensors-page.module.ts b/src/app/pages/sensors/sensors-page.module.ts index 7192a9d..98c2d20 100644 --- a/src/app/pages/sensors/sensors-page.module.ts +++ b/src/app/pages/sensors/sensors-page.module.ts @@ -3,12 +3,14 @@ import { CommonModule } from '@angular/common'; import { MaterialModule } from '../../commons/ui/material/material.module'; import { SensorsPageComponent } from './sensors-page.component'; import { SensorsPageRoutingModule } from './sensors-page-routing.module'; +import { SensorModule } from 'packages/sensor/sensor.module'; @NgModule({ imports: [ CommonModule, MaterialModule, - SensorsPageRoutingModule + SensorsPageRoutingModule, + SensorModule ], declarations: [ SensorsPageComponent diff --git a/src/packages/sensor/component/index.ts b/src/packages/sensor/component/index.ts index 0743a7d..ccb2864 100644 --- a/src/packages/sensor/component/index.ts +++ b/src/packages/sensor/component/index.ts @@ -1,7 +1,11 @@ import { DiscoverySettingComponent } from './setting/setting.component'; import { SettingResultComponent } from './setting-result/setting-result.component'; +import { FilterComponent } from './list/filter/filter.component'; +import { ListComponent } from './list/list.component'; export const COMPONENTS = [ DiscoverySettingComponent, SettingResultComponent, + ListComponent, + FilterComponent ]; diff --git a/src/packages/sensor/component/list/filter/filter.component.html b/src/packages/sensor/component/list/filter/filter.component.html new file mode 100644 index 0000000..b71faba --- /dev/null +++ b/src/packages/sensor/component/list/filter/filter.component.html @@ -0,0 +1,30 @@ +
+ + + +
+
+ + + + {{ crawler.name }} + + + +
+
+
Status
+ + All + Active + Inactive + +
+
+
Type
+ + All + Host + Application + +
\ No newline at end of file diff --git a/src/packages/sensor/component/list/filter/filter.component.scss b/src/packages/sensor/component/list/filter/filter.component.scss new file mode 100644 index 0000000..97910d9 --- /dev/null +++ b/src/packages/sensor/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/sensor/component/list/filter/filter.component.spec.ts b/src/packages/sensor/component/list/filter/filter.component.spec.ts new file mode 100644 index 0000000..fc30049 --- /dev/null +++ b/src/packages/sensor/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/sensor/component/list/filter/filter.component.ts b/src/packages/sensor/component/list/filter/filter.component.ts new file mode 100644 index 0000000..9ca9b1f --- /dev/null +++ b/src/packages/sensor/component/list/filter/filter.component.ts @@ -0,0 +1,24 @@ +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 { + + crawlers = [ + {value: 'ALL', name: 'All'}, + {value: 'WMI', name: 'WMI'}, + {value: 'SSH', name: 'SSH'}, + {value: 'MySQL', name: 'MySQL'}, + {value: 'Redis', name: 'Redis'}, + ]; + + constructor(private router: Router) { } + + ngOnInit() { + } +} diff --git a/src/packages/sensor/component/list/list.component.html b/src/packages/sensor/component/list/list.component.html new file mode 100644 index 0000000..cd72483 --- /dev/null +++ b/src/packages/sensor/component/list/list.component.html @@ -0,0 +1,57 @@ +
+ + +
+ +
+ + +
+
+
Target :
+
Sensor :
+
Activated Sensor :
+
Inactivated Sensor :
+
+ +
+
+ + +
+ + +
+ +
+ +
\ No newline at end of file diff --git a/src/packages/sensor/component/list/list.component.scss b/src/packages/sensor/component/list/list.component.scss new file mode 100644 index 0000000..54b8a22 --- /dev/null +++ b/src/packages/sensor/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/packages/sensor/component/list/list.component.spec.ts b/src/packages/sensor/component/list/list.component.spec.ts new file mode 100644 index 0000000..beacd15 --- /dev/null +++ b/src/packages/sensor/component/list/list.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ListComponent } from './list.component'; + +describe('ListComponent', () => { + let component: ListComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ListComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/packages/sensor/component/list/list.component.ts b/src/packages/sensor/component/list/list.component.ts new file mode 100644 index 0000000..40520e8 --- /dev/null +++ b/src/packages/sensor/component/list/list.component.ts @@ -0,0 +1,53 @@ +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 { Sensor } from '../../model'; + + +@Component({ + selector: 'of-sensor-list', + templateUrl: './list.component.html', + styleUrls: ['./list.component.scss'] +}) +export class ListComponent implements OnInit, AfterContentInit { + + displayedColumns = ['crawler', 'type', 'name', 'sensors']; + 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: 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; + } + + constructor(private router: Router) { } + + ngOnInit() { + } + + handleRowClick(obj: Sensor) { + this.router.navigate(['target', obj.id]); + } +} diff --git a/src/packages/target/component/list/filter/filter.component.html b/src/packages/target/component/list/filter/filter.component.html index 7833e71..586dd09 100644 --- a/src/packages/target/component/list/filter/filter.component.html +++ b/src/packages/target/component/list/filter/filter.component.html @@ -4,7 +4,6 @@
-
Status
All Active @@ -12,7 +11,6 @@
-
Type
All Host