From e3013e95a62fb47bb5aa37182da7054cd744e09a Mon Sep 17 00:00:00 2001 From: insanity Date: Tue, 17 Apr 2018 18:40:42 +0900 Subject: [PATCH] sensor / filter --- .../layout/topbar/app.topbar.component.html | 11 ++- .../layout/topbar/app.topbar.component.ts | 27 +++++- .../commons/prime-ng/prime-ng.module.ts | 8 +- .../sensor/component/list/list.component.html | 90 ++++++++++++++----- .../sensor/component/list/list.component.ts | 73 +++++++++++++-- .../target/component/list/list.component.html | 3 +- 6 files changed, 173 insertions(+), 39 deletions(-) diff --git a/src/app/commons/component/layout/topbar/app.topbar.component.html b/src/app/commons/component/layout/topbar/app.topbar.component.html index 18cf8a0..a2d510d 100644 --- a/src/app/commons/component/layout/topbar/app.topbar.component.html +++ b/src/app/commons/component/layout/topbar/app.topbar.component.html @@ -133,7 +133,14 @@ Messages
  • diff --git a/src/app/commons/component/layout/topbar/app.topbar.component.ts b/src/app/commons/component/layout/topbar/app.topbar.component.ts index 46badcc..57e8a6c 100644 --- a/src/app/commons/component/layout/topbar/app.topbar.component.ts +++ b/src/app/commons/component/layout/topbar/app.topbar.component.ts @@ -1,13 +1,32 @@ -import {Component} from '@angular/core'; -import {AppComponent} from 'app/app.component'; +import { Component, OnInit } from '@angular/core'; +import { AppComponent } from 'app/app.component'; import { PagesComponent } from '../../../../pages/pages.component'; @Component({ selector: 'of-topbar', templateUrl: './app.topbar.component.html' }) -export class AppTopbarComponent { +export class AppTopbarComponent implements OnInit { - constructor(public app: PagesComponent) {} + notis; + + constructor(public app: PagesComponent) { } + + ngOnInit() { + this.notis = [ + { + title: 'Notification 1', + content: 'Noti content11111111111111111111111111111111111111111111', + }, + { + title: 'Notification 2', + content: 'Noti content22222222222', + }, + { + title: 'Notification 3', + content: 'content3', + } + ]; + } } diff --git a/src/packages/commons/prime-ng/prime-ng.module.ts b/src/packages/commons/prime-ng/prime-ng.module.ts index 6de4f7e..0dfa422 100644 --- a/src/packages/commons/prime-ng/prime-ng.module.ts +++ b/src/packages/commons/prime-ng/prime-ng.module.ts @@ -66,7 +66,8 @@ import { ToolbarModule } from 'primeng/primeng'; import { TooltipModule } from 'primeng/primeng'; import { TreeModule } from 'primeng/primeng'; import { TreeTableModule } from 'primeng/primeng'; -import {CardModule} from 'primeng/card'; +import { CardModule } from 'primeng/card'; +import {DataViewModule} from 'primeng/dataview'; const PRIME_NG_MODULES: any[] = [ @@ -137,7 +138,8 @@ const PRIME_NG_MODULES: any[] = [ TooltipModule, TreeModule, TreeTableModule, - CardModule + CardModule, + DataViewModule, ]; @NgModule({ @@ -148,4 +150,4 @@ const PRIME_NG_MODULES: any[] = [ PRIME_NG_MODULES ], }) -export class PrimeNGModules {} +export class PrimeNGModules { } diff --git a/src/packages/sensor/component/list/list.component.html b/src/packages/sensor/component/list/list.component.html index c521f4f..eda3029 100644 --- a/src/packages/sensor/component/list/list.component.html +++ b/src/packages/sensor/component/list/list.component.html @@ -10,26 +10,72 @@ +
    - - - - No. - Description - Status - Crawler - Items - Created at - - - - - {{rowIndex + 1}} - {{sensor.Description}} - {{sensor.status.name}} - {{sensor.crawler.name}} - ??? - {{sensor.createDate | date: 'dd.MM.yyyy'}} - - - \ No newline at end of file + + +
    + + + + +
    + +
    + + +
    + + +
    + +
    +
    + +
    +
    + +
    + +
    + + + +
    +
    {{item.target.id}} - {{item.target.displayName}}
    + + +
    +
    +
    +
    + + +
    \ No newline at end of file diff --git a/src/packages/sensor/component/list/list.component.ts b/src/packages/sensor/component/list/list.component.ts index 3ce652e..6ceec7c 100644 --- a/src/packages/sensor/component/list/list.component.ts +++ b/src/packages/sensor/component/list/list.component.ts @@ -15,6 +15,7 @@ import { AuthSelector } from 'packages/member/store'; import { Page, PageParams } from 'app/commons/model'; import { Target } from 'packages/target/model'; import { SettingComponent } from '../setting/setting.component'; +import { SelectItem } from 'primeng/primeng'; @Component({ selector: 'of-sensor-list', @@ -24,13 +25,19 @@ import { SettingComponent } from '../setting/setting.component'; export class ListComponent implements OnInit, AfterContentInit { sensorList$ = this.store.pipe(select(sensorListSelector.select('page'))); - PAGE_SIZE = '10'; + PAGE_SIZE = '99999'; totalLength = 0; sensorSettingDisplay = false; sensors: Sensor[]; target: Target = null; + targetSensor; + + // filter + targetOptions: SelectItem[]; + selectedTargets: string[] = []; + constructor(private router: Router, private store: Store, ) { } @@ -40,7 +47,7 @@ export class ListComponent implements OnInit, AfterContentInit { (page: Page) => { if (page != null) { this.sensors = page.content; - this.totalLength = page.totalElements; + this.generateSensorMap(); } }, (error: RPCClientError) => { @@ -71,8 +78,48 @@ export class ListComponent implements OnInit, AfterContentInit { ); } - onRowSelect(event) { - this.router.navigate(['sensor', event.data.id, 'info']); + generateSensorMap() { + const tempList = []; + for (const sensor of this.sensors) { + const targetNode = this.existTarget(sensor, tempList); + if (targetNode === null) { + const sensorsNode = []; + sensorsNode.push(sensor); + const node = { + target: sensor.target, + sensors: sensorsNode, + }; + + tempList.push(node); + } else { + targetNode.sensors.push(sensor); + } + } + this.totalLength = tempList.length; + this.targetSensor = tempList; + + this.generateTargetFilter(); + } + + generateTargetFilter() { + if (this.targetOptions) { + return; + } + const tempList = []; + for (const data of this.targetSensor) { + tempList.push({ label: data.target.displayName, value: data.target.id }); + } + this.targetOptions = tempList; + } + + existTarget(sensor: Sensor, tempList) { + let targetNode = null; + for (const node of tempList) { + if (node.target.id === sensor.target.id) { + targetNode = node; + } + } + return targetNode; } onAddSensor() { @@ -80,6 +127,21 @@ export class ListComponent implements OnInit, AfterContentInit { this.sensorSettingDisplay = true; } + onSensorSettingClose() { + this.sensorSettingDisplay = false; + } + onSensorClick(sensor) { + this.router.navigate(['sensor', sensor.id, 'info']); + } + + onSearch() { + + } + + + + + // Test onAddSensorWithTarget() { this.target = { id: 1, @@ -99,8 +161,5 @@ export class ListComponent implements OnInit, AfterContentInit { }; this.sensorSettingDisplay = true; } - onSensorSettingClose() { - this.sensorSettingDisplay = false; - } } diff --git a/src/packages/target/component/list/list.component.html b/src/packages/target/component/list/list.component.html index f811849..78a7585 100644 --- a/src/packages/target/component/list/list.component.html +++ b/src/packages/target/component/list/list.component.html @@ -1,4 +1,5 @@

    Targets

    + @@ -20,7 +21,7 @@ ?? {{infra.createDate | date: 'dd.MM.yyyy'}} - +