From 2aaed333e50c0fdd841ea506a52ac930ae24c179 Mon Sep 17 00:00:00 2001 From: snoop Date: Mon, 19 Mar 2018 13:09:00 +0900 Subject: [PATCH] tree ing --- .../sensor/component/list/list.component.html | 26 ++++++-- .../sensor/component/list/list.component.ts | 64 +++++++++++++++++++ src/packages/sensor/sensor.module.ts | 4 +- src/theme/theme.scss | 1 + 4 files changed, 90 insertions(+), 5 deletions(-) diff --git a/src/packages/sensor/component/list/list.component.html b/src/packages/sensor/component/list/list.component.html index 2775fe5..749fc4e 100644 --- a/src/packages/sensor/component/list/list.component.html +++ b/src/packages/sensor/component/list/list.component.html @@ -6,7 +6,7 @@ -
+ -
+ + + + +
+ + +
+ {{ index }} + {{ node.data.title }} +
+ +
+
+
\ 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 d231e35..4203f8a 100644 --- a/src/packages/sensor/component/list/list.component.ts +++ b/src/packages/sensor/component/list/list.component.ts @@ -11,7 +11,13 @@ import * as SensorStore from '../../store'; import { RPCError } from 'packages/core/rpc/error'; import * as ReadAllByDomainStore from '../../store/readallbydomain'; import { ReadAllByMemberSelector } from '../../store'; + +import * as TargetStore from 'packages/target/store/target'; +import { ReadAllByDomainSelector as TargetReadAllByDomainSelector } from 'packages/target/store'; + import { Domain } from '../../../domain/model'; +import { Target } from '../../../target/model'; +import { ITreeOptions } from 'angular-tree-component'; @Component({ selector: 'of-sensor-list', @@ -21,15 +27,58 @@ import { Domain } from '../../../domain/model'; export class ListComponent implements OnInit, AfterContentInit { sensorList$ = this.store.pipe(select(ReadAllByMemberSelector.select('sensorList'))); + targetList$ = this.store.pipe(select(ReadAllByMemberSelector.select('sensorList'))); displayedColumns = ['crawler', 'type', 'name', 'sensors']; dataSource: MatTableDataSource; @ViewChild(MatSort) sort: MatSort; + displayedColumnsTarget = ['createDate', 'displayName', 'description']; + dataSourceTarget: MatTableDataSource; + @ViewChild(MatSort) sortTarget: MatSort; + + + nodes2 = [ + { + title: 'root1', + className: 'root1Class' + }, + { + title: 'root2', + className: 'root2Class', + children: [ + { title: 'child1', className: 'child1Class' }, + { title: 'child2', className: 'child1Class' }, + { title: 'child3', className: 'child1Class' } + ] + } + ]; + /** * Set the sort after the view init since this component will * be able to query its view for the initialized sort. */ + + clickCheck(node) { + + // console.log(node); + + console.log(node.isActive); + + const active: boolean = !node.isActive; + + if (node.visibleChildren.length > 0) { + node.visibleChildren.map(cn => { + (function (cc) { + cc.setIsActive(active); + }(cn)); + }); + } + + node.toggleActivated(true); + + } + ngAfterContentInit() { // temporary data // const data: Sensor[] = new Array(); @@ -57,6 +106,12 @@ export class ListComponent implements OnInit, AfterContentInit { } ); + // this.store.select(TargetReadAllByDomainSelector.select('target')).subscribe( + // (domain: Domain) => { + // this.store.dispatch(new TargetStore.ReadAllByDomain(domain)); + // }, + // ); + // const domain: Domain = { // id: 1 // }; @@ -74,6 +129,15 @@ export class ListComponent implements OnInit, AfterContentInit { } ); + this.targetList$.subscribe( + (targets: Target[]) => { + + }, + (error: RPCError) => { + console.log(error.message); + } + ); + // this.dataSource = new MatTableDataSource(data); // this.dataSource.sort = this.sort; diff --git a/src/packages/sensor/sensor.module.ts b/src/packages/sensor/sensor.module.ts index 8da94dc..052b806 100644 --- a/src/packages/sensor/sensor.module.ts +++ b/src/packages/sensor/sensor.module.ts @@ -7,13 +7,15 @@ import { MaterialModule } from 'packages/commons/material/material.module'; import { COMPONENTS } from './component'; import { SERVICES } from './service'; import { SensorStoreModule } from './sensor-store.module'; +import { TreeModule } from 'angular-tree-component'; @NgModule({ imports: [ CommonModule, MaterialModule, FormsModule, - SensorStoreModule + SensorStoreModule, + TreeModule ], declarations: [ COMPONENTS, diff --git a/src/theme/theme.scss b/src/theme/theme.scss index e50ff81..0461cf8 100644 --- a/src/theme/theme.scss +++ b/src/theme/theme.scss @@ -4,6 +4,7 @@ @import '~packages/commons/component/menu-item/menu-item.component.scss'; @import '~packages/commons/component/dashboard-card/dashboard-card.component.scss'; @import '~packages/commons/component/sensor-summary/sensor-summary.component.scss'; +@import '~angular-tree-component/dist/angular-tree-component.css'; $mat-light-theme-background: ( status-bar: map_get($mat-grey, 300),