diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 3bca962..c75ae12 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -3,8 +3,8 @@ import { Routes, RouterModule, PreloadAllModules } from '@angular/router'; import { AuthGuard } from './commons/guard/auth.guard'; const routes: Routes = [ - { path: '', loadChildren: './pages/pages.module#PagesModule', canActivate: [AuthGuard] }, - // { path: '', loadChildren: './pages/pages.module#PagesModule'}, + // { path: '', loadChildren: './pages/pages.module#PagesModule', canActivate: [AuthGuard] }, + { path: '', loadChildren: './pages/pages.module#PagesModule'}, { path: 'auth', loadChildren: './pages/auth/auth-page.module#AuthPageModule' }, // { path: 'errors', loadChildren: './pages/errors/errors-page.module#ErrorsPageModule' }, ]; diff --git a/src/packages/meta/crawler-input-item/model/MetaCrawlerInputItem.ts b/src/packages/meta/crawler-input-item/model/MetaCrawlerInputItem.ts index b63ebc6..ee70e51 100644 --- a/src/packages/meta/crawler-input-item/model/MetaCrawlerInputItem.ts +++ b/src/packages/meta/crawler-input-item/model/MetaCrawlerInputItem.ts @@ -4,14 +4,14 @@ import { MetaCrawler } from 'packages/meta/crawler/model/MetaCrawler'; export interface MetaCrawlerInputItem { id?: number; - inputType: MetaInputType; - crawler: MetaCrawler; - description: string; - name: string; - createDate: Date; - required: boolean; - defaultValue: string; - pattern: string; - keyName: string; - keyValue: string; + inputType?: MetaInputType; + crawler?: MetaCrawler; + description?: string; + name?: string; + createDate?: Date; + required?: boolean; + defaultValue?: string; + pattern?: string; + keyName?: string; + keyValue?: string; } diff --git a/src/packages/sensor/component/list/list.component.html b/src/packages/sensor/component/list/list.component.html index ec52d7d..22b01e3 100644 --- a/src/packages/sensor/component/list/list.component.html +++ b/src/packages/sensor/component/list/list.component.html @@ -1,6 +1,6 @@
- - + + diff --git a/src/packages/sensor/component/list/list.component.ts b/src/packages/sensor/component/list/list.component.ts index 09cb8e5..dddda4d 100644 --- a/src/packages/sensor/component/list/list.component.ts +++ b/src/packages/sensor/component/list/list.component.ts @@ -10,9 +10,10 @@ import * as SensorStore from '../../store'; import { RPCClientError } from '@loafer/ng-rpc/protocol'; import * as ListStore from '../../store/list'; import { sensorListSelector } from '../../store'; -import { Domain } from '../../../domain/model'; +import { Domain } from 'packages/domain/model'; import { AuthSelector } from 'packages/member/store'; import { Page, PageParams } from 'app/commons/model'; +import { Target } from 'packages/target/model'; @Component({ selector: 'of-sensor-list', @@ -26,6 +27,8 @@ export class ListComponent implements OnInit, AfterContentInit { totalLength = 0; sensorSettingDisplay = false; + target: Target = null; + constructor(private router: Router, private store: Store, ) { } @@ -41,6 +44,14 @@ export class ListComponent implements OnInit, AfterContentInit { // console.log(error.response.message); // } // ); + + // Test + // this.target = { + // id: 1, + // createDate: new Date(), + // displayName: 'Alredy selected target', + // description: 'Desc..', + // }; } ngAfterContentInit() { @@ -73,4 +84,8 @@ export class ListComponent implements OnInit, AfterContentInit { this.sensorSettingDisplay = true; } + onSensorSettingClose() { + this.sensorSettingDisplay = false; + } + } diff --git a/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.html b/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.html index e78bfec..9d98ba5 100644 --- a/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.html +++ b/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.html @@ -1,41 +1,13 @@ - +
-
+ +
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
- + + \ No newline at end of file diff --git a/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.ts b/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.ts index 07a5632..9268cf9 100644 --- a/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.ts +++ b/src/packages/sensor/component/setting/crawler-auth/crawler-auth.component.ts @@ -17,50 +17,66 @@ export class CrawlerAuthComponent implements OnInit, OnChanges { inputItems$ = this.listStore.pipe(select(ReadCrawlerInputItemSelector.select('inputs'))); inputItems: MetaCrawlerInputItem[]; + title: string; - @Output() testPassEvent = new EventEmitter(); + @Output() credentialPassed = new EventEmitter(); + @Input() crawler: MetaCrawler; - @Input() selectedCrawler: MetaCrawler; constructor( private router: Router, private listStore: Store, ) { } ngOnInit() { - this.inputItems$.subscribe( - (list: MetaCrawlerInputItem[]) => { - if (list !== null) { - if (this.inputItems !== list) { - this.testPassEvent.emit(false); - } - this.inputItems = list; - } - }, - (error: RPCClientError) => { - console.log(error.response.message); - } - ); + // this.inputItems$.subscribe( + // (list: MetaCrawlerInputItem[]) => { + // if (list !== null) { + // if (this.inputItems !== list) { + // this.testPassEvent.emit(false); + // } + // this.inputItems = list; + // } + // }, + // (error: RPCClientError) => { + // console.log(error.response.message); + // } + // ); } ngOnChanges() { - this.getCrawlerAuthInputItems(); + // this.getCrawlerAuthInputItems(); + this.title = '3. Credentials'; + + this.inputItems = []; + // Temporary data + if (null == this.crawler) { + return; + } + this.title += ' for ' + this.crawler.name; + for (let i = 0; i < 10; i++) { + const item: MetaCrawlerInputItem = { + + }; + this.inputItems.push(item); + } + } getCrawlerAuthInputItems() { - this.listStore.dispatch(new ListStore.ReadAll(this.selectedCrawler)); -} + this.listStore.dispatch(new ListStore.ReadAll(this.crawler)); + } - testConnect() { - switch (this.selectedCrawler.id) { - case 1: - break; - case 2: - break; - case 3: - break; - default : - break; - } - this.testPassEvent.emit(true); + testCredentials() { + // switch (this.crawler.id) { + // case 1: + // break; + // case 2: + // break; + // case 3: + // break; + // default : + // break; + // } + this.credentialPassed.emit(true); } } diff --git a/src/packages/sensor/component/setting/crawler-selector/crawler-selector.component.html b/src/packages/sensor/component/setting/crawler-selector/crawler-selector.component.html index 342d992..8b2fe80 100644 --- a/src/packages/sensor/component/setting/crawler-selector/crawler-selector.component.html +++ b/src/packages/sensor/component/setting/crawler-selector/crawler-selector.component.html @@ -1,7 +1,7 @@ - +
-
{{crawler.name}}
diff --git a/src/packages/sensor/component/setting/crawler-selector/crawler-selector.component.ts b/src/packages/sensor/component/setting/crawler-selector/crawler-selector.component.ts index fb355de..daeba04 100644 --- a/src/packages/sensor/component/setting/crawler-selector/crawler-selector.component.ts +++ b/src/packages/sensor/component/setting/crawler-selector/crawler-selector.component.ts @@ -17,14 +17,14 @@ import { MetaCrawler } from 'packages/meta/crawler/model/MetaCrawler'; export class CrawlerSelectorComponent implements OnInit, OnChanges, AfterContentInit { crawlers$ = this.listStore.pipe(select(ReadAllCrawlerSelector.select('metaCrawlerList'))); - @Input() selectedTarget: Target; + @Input() target: Target; crawlers: MetaCrawler[]; - @Output() crawlerSelectEvent = new EventEmitter(); + @Output() crawlerSelected = new EventEmitter(); constructor( private router: Router, private listStore: Store, - ) {} + ) { } ngOnInit() { // this.crawlers$.subscribe( @@ -38,26 +38,31 @@ export class CrawlerSelectorComponent implements OnInit, OnChanges, AfterContent // } // ); - // Temporary Data - this.crawlers = []; - for (let i = 0; i < 10; i++) { - const c: MetaCrawler = { - id: i, - name: 'CrawlerName' + i, - description: 'Description' + i, - }; - this.crawlers.push(c); - } } ngAfterContentInit() { - this.listStore.dispatch(new ListStore.ReadAll()); + // this.listStore.dispatch(new ListStore.ReadAll()); } ngOnChanges() { + + this.crawlers = []; + if (null == this.target) { + return; + } + + // Temporary Data + for (let i = 0; i < 4; i++) { + const c: MetaCrawler = { + id: i, + name: 'CrawlerName' + i + ' For ' + this.target.displayName, + }; + this.crawlers.push(c); + } + } - crawlerSelected(crawler: MetaCrawler) { - this.crawlerSelectEvent.emit(crawler); + onSelectionChange(event) { + this.crawlerSelected.emit(event.value[0]); } } diff --git a/src/packages/sensor/component/setting/sensor-item-selector/sensor-item-selector.component.html b/src/packages/sensor/component/setting/sensor-item-selector/sensor-item-selector.component.html index 31280b5..abea8b6 100644 --- a/src/packages/sensor/component/setting/sensor-item-selector/sensor-item-selector.component.html +++ b/src/packages/sensor/component/setting/sensor-item-selector/sensor-item-selector.component.html @@ -1,4 +1,9 @@ - + +
+ +
+
-
- +
- +
- +
- +
+
+ +
+ +
\ No newline at end of file diff --git a/src/packages/sensor/component/setting/setting.component.ts b/src/packages/sensor/component/setting/setting.component.ts index 3ef0b56..a8d6ff0 100644 --- a/src/packages/sensor/component/setting/setting.component.ts +++ b/src/packages/sensor/component/setting/setting.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input, Inject, DoCheck, ViewEncapsulation } from '@angular/core'; +import { Component, OnInit, Input, Inject, DoCheck, ViewEncapsulation, Output, EventEmitter, OnDestroy } from '@angular/core'; import { Target } from 'packages/target/model'; import { Infra } from 'packages/infra/model'; import { MetaCrawler } from 'packages/meta/crawler/model/MetaCrawler'; @@ -9,6 +9,7 @@ import { RPCClientError } from '@loafer/ng-rpc/protocol'; import * as SensorItemKeyListStore from 'packages/sensor-item/store/key-list'; import { ReadSensorItemKeySelector } from 'packages/sensor-item/store'; import { MetaSensorItemKey } from 'packages/meta/sensor-item-key/model/MetaSensorItemKey'; +import { TreeNode } from 'primeng/primeng'; @Component({ selector: 'of-sensor-setting', @@ -17,22 +18,16 @@ import { MetaSensorItemKey } from 'packages/meta/sensor-item-key/model/MetaSenso }) export class SettingComponent implements OnInit, DoCheck { + @Output() close = new EventEmitter(); + nextable = false; sensorItemKeys$ = this.keyListStore.pipe(select(ReadSensorItemKeySelector.select('list'))); - stepsItems = [ - { - label: 'Target' - }, - { - label: 'Crawler' - }, - { - label: 'Credentials' - }, - { - label: 'Sensor Items' - } - ]; - activeIndex = 1; + + @Input() selectedTarget: Target; + selectedCrawler: MetaCrawler; + credentialPassed: boolean; + selectedSensorDisplayItems: MetaSensorDisplayItem[]; + + itemNodes: TreeNode[]; constructor( private keyListStore: Store, @@ -40,18 +35,62 @@ export class SettingComponent implements OnInit, DoCheck { } ngOnInit() { - this.sensorItemKeys$.subscribe( - (list: MetaSensorItemKey[]) => { - if (list !== null) { - console.log(list); - } - }, - (error: RPCClientError) => { - console.log(error.response.message); - } - ); + // this.sensorItemKeys$.subscribe( + // (list: MetaSensorItemKey[]) => { + // if (list !== null) { + // console.log(list); + // } + // }, + // (error: RPCClientError) => { + // console.log(error.response.message); + // } + // ); } ngDoCheck() { + try { + if ( + this.selectedTarget === null || + this.selectedCrawler === null || + this.itemNodes === null || + this.itemNodes.length === 0 || + !this.credentialPassed + ) { + this.nextable = false; + } else { + this.nextable = true; + } + } catch (exception) {} + } + + onCancel() { + this.selectedTarget = null; + this.selectedCrawler = null; + this.credentialPassed = false; + this.selectedSensorDisplayItems = null; + this.close.emit(); + } + + onNext() { + this.selectedSensorDisplayItems = []; + for (const node of this.itemNodes) { + if (node.data && node.data !== undefined) { + this.selectedSensorDisplayItems.push(node.data); + } + } + console.log(this.selectedSensorDisplayItems); + } + + onTargetSelect(t: Target) { + this.selectedTarget = t; + } + onCrawlerSelect(c: MetaCrawler) { + this.selectedCrawler = c; + } + onCredentialPass(b: boolean) { + this.credentialPassed = b; + } + onItemsSelect(nodes: TreeNode[]) { + this.itemNodes = nodes; } } diff --git a/src/packages/sensor/component/setting/target-selector/target-selector.component.html b/src/packages/sensor/component/setting/target-selector/target-selector.component.html index dfdab6f..d812e94 100644 --- a/src/packages/sensor/component/setting/target-selector/target-selector.component.html +++ b/src/packages/sensor/component/setting/target-selector/target-selector.component.html @@ -1,11 +1,25 @@ - - -
- -
{{target.displayName}}
+
+ + +
+ +
{{target.displayName}}
+
+
+
+
+ +