diff --git a/src/packages/sensor/component/list/list.component.html b/src/packages/sensor/component/list/list.component.html index 749fc4e..975670d 100644 --- a/src/packages/sensor/component/list/list.component.html +++ b/src/packages/sensor/component/list/list.component.html @@ -6,19 +6,19 @@ - + - - - - - - - - - {{ 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 37a2d91..69d1c59 100644 --- a/src/packages/sensor/component/list/list.component.ts +++ b/src/packages/sensor/component/list/list.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, AfterViewInit, ViewChild } from '@angular/core'; -import { MatTableDataSource, MatSort } from '@angular/material'; +import { MatTableDataSource, MatSort, MatDialog } from '@angular/material'; import { AfterContentInit } from '@angular/core/src/metadata/lifecycle_hooks'; import { Router } from '@angular/router'; import { Sensor } from '../../model'; @@ -11,13 +11,8 @@ 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'; +import { SettingComponent } from '../setting/setting.component'; @Component({ selector: 'of-sensor-list', @@ -27,58 +22,15 @@ import { ITreeOptions } from 'angular-tree-component'; 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(); @@ -106,12 +58,6 @@ 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 // }; @@ -125,16 +71,7 @@ export class ListComponent implements OnInit, AfterContentInit { this.dataSource.sort = this.sort; }, (error: RPCError) => { - // console.log(error.response.message); - } - ); - - this.targetList$.subscribe( - (targets: Target[]) => { - - }, - (error: RPCError) => { - // console.log(error.message); + console.log(error.response.message); } ); @@ -144,7 +81,9 @@ export class ListComponent implements OnInit, AfterContentInit { } constructor(private router: Router, - private store: Store) { } + private store: Store, + private dialog: MatDialog, + ) { } ngOnInit() { } @@ -152,4 +91,15 @@ export class ListComponent implements OnInit, AfterContentInit { handleRowClick(obj: Sensor) { this.router.navigate(['target', obj.id]); } + + addSensor() { + const dialogRef = this.dialog.open(SettingComponent, { + width: '80%', + }); + + dialogRef.afterClosed().subscribe(result => { + console.log('The dialog was closed'); + + }); + } } diff --git a/src/packages/sensor/sensor.module.ts b/src/packages/sensor/sensor.module.ts index 052b806..62a5d34 100644 --- a/src/packages/sensor/sensor.module.ts +++ b/src/packages/sensor/sensor.module.ts @@ -7,6 +7,7 @@ import { MaterialModule } from 'packages/commons/material/material.module'; import { COMPONENTS } from './component'; import { SERVICES } from './service'; import { SensorStoreModule } from './sensor-store.module'; +import { SettingComponent } from './component/setting/setting.component'; import { TreeModule } from 'angular-tree-component'; @NgModule({ @@ -26,5 +27,9 @@ import { TreeModule } from 'angular-tree-component'; providers: [ SERVICES, ], + entryComponents: [ + SettingComponent + ] }) export class SensorModule { } +