From 27b3490d39b44c61852aa85bb12d7488ea11c182 Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 5 Jun 2018 20:29:35 +0900 Subject: [PATCH] ing --- @overflow/meta/component/index.ts | 6 +- .../meta-crawler-input-item.component.html | 17 +++ .../meta-crawler-input-item.component.spec.ts | 25 +++++ .../meta-crawler-input-item.component.ts | 105 ++++++++++++++++++ .../component/meta-crawler.component.html | 16 +++ .../component/meta-crawler.component.spec.ts | 25 +++++ .../meta/component/meta-crawler.component.ts | 49 ++++++++ .../component/sensor-detail.component.ts | 48 +++++--- .../crawler-auth/crawler-auth.component.ts | 8 +- @overflow/sensor/sensor.module.ts | 2 + package.json | 2 +- 11 files changed, 279 insertions(+), 24 deletions(-) create mode 100644 @overflow/meta/component/meta-crawler-input-item.component.html create mode 100644 @overflow/meta/component/meta-crawler-input-item.component.spec.ts create mode 100644 @overflow/meta/component/meta-crawler-input-item.component.ts create mode 100644 @overflow/meta/component/meta-crawler.component.html create mode 100644 @overflow/meta/component/meta-crawler.component.spec.ts create mode 100644 @overflow/meta/component/meta-crawler.component.ts diff --git a/@overflow/meta/component/index.ts b/@overflow/meta/component/index.ts index 033775b..a28a435 100644 --- a/@overflow/meta/component/index.ts +++ b/@overflow/meta/component/index.ts @@ -1,3 +1,7 @@ -export const COMPONENTS = [ +import { MetaCrawlerInputItemComponent } from './meta-crawler-input-item.component'; +import { MetaCrawlerComponent } from './meta-crawler.component'; +export const COMPONENTS = [ + MetaCrawlerInputItemComponent, + MetaCrawlerComponent, ]; diff --git a/@overflow/meta/component/meta-crawler-input-item.component.html b/@overflow/meta/component/meta-crawler-input-item.component.html new file mode 100644 index 0000000..3951766 --- /dev/null +++ b/@overflow/meta/component/meta-crawler-input-item.component.html @@ -0,0 +1,17 @@ + +
+
+ + + + +
+
+ + +
개발자의 배려가 돋보이는 친절한 안내 메시지
+
+
+ +
+
\ No newline at end of file diff --git a/@overflow/meta/component/meta-crawler-input-item.component.spec.ts b/@overflow/meta/component/meta-crawler-input-item.component.spec.ts new file mode 100644 index 0000000..8439bf1 --- /dev/null +++ b/@overflow/meta/component/meta-crawler-input-item.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MetaCrawlerInputItemComponent } from './meta-crawler-input-item.component'; + +describe('MetaCrawlerInputItemComponent', () => { + let component: MetaCrawlerInputItemComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ MetaCrawlerInputItemComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MetaCrawlerInputItemComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/@overflow/meta/component/meta-crawler-input-item.component.ts b/@overflow/meta/component/meta-crawler-input-item.component.ts new file mode 100644 index 0000000..0521f2d --- /dev/null +++ b/@overflow/meta/component/meta-crawler-input-item.component.ts @@ -0,0 +1,105 @@ +import { Component, OnInit, Input, OnChanges, Output, EventEmitter } from '@angular/core'; +import { Store, select } from '@ngrx/store'; + +import { Observable, of, Subscription } from 'rxjs'; +import { catchError, exhaustMap, map, tap, take } from 'rxjs/operators'; + +import { RPCClientError } from '@loafer/ng-rpc'; + +import { MetaCrawlerInputItem } from '@overflow/commons-typescript/model/meta'; +import { MetaCrawler } from '@overflow/commons-typescript/model/meta'; +import { MetaCrawlerInputItemService } from '../service/meta-crawler-input-item.service'; + + +@Component({ + selector: 'of-meta-crawler-input-item', + templateUrl: './meta-crawler-input-item.component.html', +}) +export class MetaCrawlerInputItemComponent implements OnInit, OnChanges { + @Input() metaCrawler: MetaCrawler; + @Output() credentialPassed = new EventEmitter(); + + + pending$: Observable; + error$: Observable; + + metaCrawlerInputItems: MetaCrawlerInputItem[]; + title: string; + + + constructor( + private store: Store, + private metaCrawlerInputItemService: MetaCrawlerInputItemService + ) { } + + ngOnInit() { + } + + ngOnChanges() { + // this.getCrawlerAuthInputItems(); + this.title = '3. Credentials'; + + // Temporary data + if (null == this.metaCrawler) { + return; + } + // this.title += ' for ' + this.metaCrawler.name; + // for (let i = 0; i < 10; i++) { + // const item: MetaCrawlerInputItem = { + // id: i, + // // inputType: { + // // id: i, + // // name: '', + // // description: '', + // // }, + // crawler: null, + // description: '', + // name: '', + // createDate: new Date(), + // required: true, + // defaultValue: '', + // pattern: '', + // keyName: '', + // keyValue: '', + // }; + // this.inputItems.push(item); + // } + + this.metaCrawlerInputItemService.readAllByMetaCrawler(this.metaCrawler) + .pipe( + tap(() => { + this.pending$ = of(true); + }), + map((metaCrawlerInputItems: MetaCrawlerInputItem[]) => { + this.metaCrawlerInputItems = metaCrawlerInputItems; + }), + catchError(error => { + this.error$ = of(error); + return of(); + }), + tap(() => { + this.pending$ = of(false); + }), + take(1), + ).subscribe(); + + } + + getCrawlerAuthInputItems() { + // this.listStore.dispatch(new ListStore.ReadAll(this.crawler)); + } + + testCredentials() { + // switch (this.crawler.id) { + // case 1: + // break; + // case 2: + // break; + // case 3: + // break; + // default : + // break; + // } + this.credentialPassed.emit(true); + } +} diff --git a/@overflow/meta/component/meta-crawler.component.html b/@overflow/meta/component/meta-crawler.component.html new file mode 100644 index 0000000..e8851ee --- /dev/null +++ b/@overflow/meta/component/meta-crawler.component.html @@ -0,0 +1,16 @@ +
+ + +
+
{{crawler.name}}
+
+
+
+
+ + + +
개발자의 배려가 돋보이는 친절한 안내 메시지
+
+
\ No newline at end of file diff --git a/@overflow/meta/component/meta-crawler.component.spec.ts b/@overflow/meta/component/meta-crawler.component.spec.ts new file mode 100644 index 0000000..1321dbc --- /dev/null +++ b/@overflow/meta/component/meta-crawler.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MetaCrawlerComponent } from './meta-crawler.component'; + +describe('MetaCrawlerComponent', () => { + let component: MetaCrawlerComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ MetaCrawlerComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MetaCrawlerComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/@overflow/meta/component/meta-crawler.component.ts b/@overflow/meta/component/meta-crawler.component.ts new file mode 100644 index 0000000..53563d9 --- /dev/null +++ b/@overflow/meta/component/meta-crawler.component.ts @@ -0,0 +1,49 @@ +import { Component, OnInit, Input, OnChanges, Output, EventEmitter } from '@angular/core'; +import { Store, select } from '@ngrx/store'; +import { Observable, of, Subscription } from 'rxjs'; +import { catchError, exhaustMap, map, tap, take } from 'rxjs/operators'; + +import { RPCClientError } from '@loafer/ng-rpc'; + +import { Target } from '@overflow/commons-typescript/model/target'; +import { MetaCrawler } from '@overflow/commons-typescript/model/meta'; +import { MetaCrawlerService } from '../service/meta-crawler.service'; + + +@Component({ + selector: 'of-meta-crawler', + templateUrl: './meta-crawler.component.html', +}) +export class MetaCrawlerComponent implements OnInit { + @Input() target: Target; + @Output() selected = new EventEmitter(); + + metaCrawlers: MetaCrawler[]; + pending$: Observable; + error$: Observable; + + constructor( + private metaCrawlerService: MetaCrawlerService, + ) { } + + ngOnInit() { + this.metaCrawlerService.readAll() + .pipe( + tap(() => { + this.pending$ = of(true); + }), + map((metaCrawlers: MetaCrawler[]) => { + this.metaCrawlers = metaCrawlers; + }), + catchError(error => { + this.error$ = of(error); + return of(); + }), + tap(() => { + this.pending$ = of(false); + }), + take(1), + ).subscribe(); + } + +} diff --git a/@overflow/sensor/component/sensor-detail.component.ts b/@overflow/sensor/component/sensor-detail.component.ts index c627fcf..f4eede2 100644 --- a/@overflow/sensor/component/sensor-detail.component.ts +++ b/@overflow/sensor/component/sensor-detail.component.ts @@ -12,6 +12,7 @@ import { RPCClientError } from '@loafer/ng-rpc'; import { Sensor } from '@overflow/commons-typescript/model/sensor'; import { SensorService } from '../service/sensor.service'; import { Target } from '@overflow/commons-typescript/model/target'; +import { MetaCrawler } from '@overflow/commons-typescript/model/meta'; @Component({ selector: 'of-sensor-detail', @@ -28,6 +29,8 @@ export class SensorDetailComponent implements OnInit, OnDestroy { pending$: Observable; error$: Observable; + metaCrawler: MetaCrawler; + constructor( private confirmationService: ConfirmationService, private store: Store, @@ -37,23 +40,30 @@ export class SensorDetailComponent implements OnInit, OnDestroy { } ngOnInit() { - this.sensorService.read(this.sensorID) - .pipe( - tap(() => { - this.pending$ = of(true); - }), - map((sensor: Sensor) => { - this.sensor = sensor; - }), - catchError(error => { - this.error$ = of(error); - return of(); - }), - tap(() => { - this.pending$ = of(false); - }), - take(1), - ).subscribe(); + if (0 < this.sensorID) { + // get sensor + this.sensorService.read(this.sensorID) + .pipe( + tap(() => { + this.pending$ = of(true); + }), + map((sensor: Sensor) => { + this.sensor = sensor; + }), + catchError(error => { + this.error$ = of(error); + return of(); + }), + tap(() => { + this.pending$ = of(false); + }), + take(1), + ).subscribe(); + + } else { + // new sensor + this.sensor = {}; + } } ngOnDestroy() { @@ -77,5 +87,9 @@ export class SensorDetailComponent implements OnInit, OnDestroy { } }); } + + onMetaCrawlerSelected(metaCrawler: MetaCrawler) { + this.metaCrawler = metaCrawler; + } } diff --git a/@overflow/sensor/component/setting/crawler-auth/crawler-auth.component.ts b/@overflow/sensor/component/setting/crawler-auth/crawler-auth.component.ts index 6a0b3d9..5cfaa4c 100644 --- a/@overflow/sensor/component/setting/crawler-auth/crawler-auth.component.ts +++ b/@overflow/sensor/component/setting/crawler-auth/crawler-auth.component.ts @@ -4,8 +4,6 @@ import { MetaCrawler } from '@overflow/commons-typescript/model/meta'; import { Store, select } from '@ngrx/store'; import { RPCClientError } from '@loafer/ng-rpc'; -import * as ListStore from '@overflow/meta/crawler-input-item/store/list'; -import { ReadCrawlerInputItemSelector } from '@overflow/meta/crawler-input-item/store'; import { MetaCrawlerInputItem } from '@overflow/commons-typescript/model/meta'; @@ -15,7 +13,7 @@ import { MetaCrawlerInputItem } from '@overflow/commons-typescript/model/meta'; }) export class CrawlerAuthComponent implements OnInit, OnChanges { - inputItems$ = this.listStore.pipe(select(ReadCrawlerInputItemSelector.select('inputs'))); + inputItems$; inputItems: MetaCrawlerInputItem[]; title: string; @@ -24,7 +22,7 @@ export class CrawlerAuthComponent implements OnInit, OnChanges { constructor( private router: Router, - private listStore: Store, + private store: Store, ) { } ngOnInit() { @@ -77,7 +75,7 @@ export class CrawlerAuthComponent implements OnInit, OnChanges { } getCrawlerAuthInputItems() { - this.listStore.dispatch(new ListStore.ReadAll(this.crawler)); + // this.listStore.dispatch(new ListStore.ReadAll(this.crawler)); } testCredentials() { diff --git a/@overflow/sensor/sensor.module.ts b/@overflow/sensor/sensor.module.ts index 13e4460..cf85ac7 100644 --- a/@overflow/sensor/sensor.module.ts +++ b/@overflow/sensor/sensor.module.ts @@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { UIModule } from '@overflow/shared/ui/ui.module'; +import { MetaModule } from '@overflow/meta/meta.module'; import { COMPONENTS } from './component'; import { SERVICES } from './service'; @@ -13,6 +14,7 @@ import { SensorItemModule } from '../sensor-item/sensor-item.module'; CommonModule, FormsModule, UIModule, + MetaModule, SensorItemModule, ], declarations: [ diff --git a/package.json b/package.json index f34fd7d..8354735 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "@ngrx/router-store": "^5.2.0", "@ngrx/store": "^5.2.0", "@ngrx/store-devtools": "^5.2.0", - "@overflow/commons-typescript": "^0.0.7", + "@overflow/commons-typescript": "^0.0.8", "angular-google-recaptcha": "^1.0.3", "angular-l10n": "^5.0.0", "angularx-qrcode": "^1.1.7",