This commit is contained in:
insanity 2018-05-10 17:56:30 +09:00
parent 6a45d012b3
commit 158da96319
24 changed files with 1055 additions and 12 deletions

6
package-lock.json generated
View File

@ -1,5 +1,5 @@
{ {
"name": "overflow-member-wepapp", "name": "@overflow/member-wepapp",
"version": "0.0.0", "version": "0.0.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
@ -259,8 +259,7 @@
"@overflow/commons-typescript": { "@overflow/commons-typescript": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://nexus.loafle.net/repository/npm-all/@overflow/commons-typescript/-/commons-typescript-0.0.1.tgz", "resolved": "https://nexus.loafle.net/repository/npm-all/@overflow/commons-typescript/-/commons-typescript-0.0.1.tgz",
"integrity": "sha512-ExzlR7RsCu3nPn1m1ADJEFV9fYr2rVg3Oyge8MogHOjDa1BoeUx9OLwluL7IOuBEHA5tVX6BucRIeaNFOME8TQ==", "integrity": "sha512-ExzlR7RsCu3nPn1m1ADJEFV9fYr2rVg3Oyge8MogHOjDa1BoeUx9OLwluL7IOuBEHA5tVX6BucRIeaNFOME8TQ=="
"dev": true
}, },
"@schematics/angular": { "@schematics/angular": {
"version": "0.1.17", "version": "0.1.17",
@ -1881,7 +1880,6 @@
"dev": true "dev": true
}, },
"common-tags": { "common-tags": {
"version": "1.7.2", "version": "1.7.2",
"resolved": "https://nexus.loafle.net/repository/npm-all/common-tags/-/common-tags-1.7.2.tgz", "resolved": "https://nexus.loafle.net/repository/npm-all/common-tags/-/common-tags-1.7.2.tgz",
"integrity": "sha512-joj9ZlUOjCrwdbmiLqafeUSgkUM74NqhLsZtSqDmhKudaIY197zTrb8JMl31fMnCUuxwFT23eC/oWvrZzDLRJQ==", "integrity": "sha512-joj9ZlUOjCrwdbmiLqafeUSgkUM74NqhLsZtSqDmhKudaIY197zTrb8JMl31fMnCUuxwFT23eC/oWvrZzDLRJQ==",

View File

@ -0,0 +1,190 @@
import { Component, OnInit, Input, AfterContentInit, Output, EventEmitter, OnDestroy } from '@angular/core';
import { Store, select, StateObservable } from '@ngrx/store';
import { RPCClientError } from '@loafer/ng-rpc/protocol';
import { Subscription } from 'rxjs/Subscription';
import { TreeNode } from 'primeng/primeng';
import * as DiscoveredStore from 'packages/discovery/store/setting';
import { SettingSelector, DiscoverSelector } from 'packages/discovery/store';
import * as DiscoverStore from 'packages/discovery/store/discover';
import * as RegistStore from 'packages/discovery/store/regist';
import { Zone } from '@overflow/commons-typescript/model/discovery';
import { Host } from '@overflow/commons-typescript/model/discovery';
import { Port } from '@overflow/commons-typescript/model/discovery';
import { Service } from '@overflow/commons-typescript/model/discovery';
@Component({
selector: 'of-discovery-result',
templateUrl: './result.component.html',
})
export class ResultComponent implements OnInit, AfterContentInit, OnDestroy {
treeNodes = [];
selectedNodes = [];
zones: Map<string, Zone> = null;
checkedSet = new Set();
resultSubscription$: Subscription;
result$: any;
startedSubscription$: Subscription;
started$: any;
endedSubscription$: Subscription;
ended$: any;
inProgress = false;
selectedDiscoveryResult: TreeNode[];
constructor(
private discoverdStore: Store<DiscoveredStore.State>,
private discoverStore: Store<DiscoverStore.State>,
private registStore: Store<RegistStore.State>,
) {
this.result$ = discoverStore.pipe(select(DiscoverSelector.select('zones')));
this.started$ = discoverStore.pipe(select(DiscoverSelector.select('isStart')));
this.ended$ = discoverStore.pipe(select(DiscoverSelector.select('isEnd')));
}
ngOnInit() {
this.resultSubscription$ = this.result$.subscribe(
(zones: Map<string, Zone>) => {
if (zones !== undefined && zones !== null) {
console.log(zones);
this.treeNodes = this.convertTreeViewZone(zones);
this.zones = zones;
}
},
(error: RPCClientError) => {
console.log(error.response.message);
}
);
this.startedSubscription$ = this.started$.subscribe(
(isStart: boolean) => {
if (isStart !== undefined && isStart !== null && isStart) {
this.inProgress = true;
console.log('##Discovery has started.##');
}
},
(error: RPCClientError) => {
console.log(error.response.message);
}
);
this.endedSubscription$ = this.ended$.subscribe(
(isEnd: boolean) => {
if (isEnd !== undefined && isEnd !== null && isEnd) {
console.log('##Discovery has done.##');
}
},
(error: RPCClientError) => {
console.log(error.response.message);
}
);
}
ngAfterContentInit() {
}
ngOnDestroy() {
if (this.startedSubscription$) {
this.startedSubscription$.unsubscribe();
}
if (this.endedSubscription$) {
this.endedSubscription$.unsubscribe();
}
if (this.resultSubscription$) {
this.resultSubscription$.unsubscribe();
}
}
save() {
}
convertTreeViewZone(zones: Map<string, Zone>) {
if (zones === undefined || zones === null) {
return;
}
const treeNodes: any[] = [];
zones.forEach((value: Zone, key: string, map) => {
const jZone: any = {
label: 'Zone - ' + value.iface,
// className: 'cn' + value.ip,
expandedIcon: 'fa-folder-open',
collapsedIcon: 'fa-folder',
};
jZone.obj = value;
jZone.children = this.convertViewHost(value.hosts);
treeNodes.push(jZone);
});
return treeNodes;
}
convertViewHost(hosts): any[] {
if (hosts === undefined || hosts === null) {
return null;
}
const hostNodes: any[] = [];
hosts.forEach((host, hostKey) => {
const jHost: any = {
label: 'Host - ' + host.ipv4,
// className: 'cn' + host.ip
expandedIcon: 'fa-folder-open',
collapsedIcon: 'fa-folder',
};
jHost.obj = host;
jHost.children = this.convertViewPort(host.ports);
hostNodes.push(jHost);
});
return hostNodes;
}
convertViewPort(ports): any[] {
if (ports === undefined || ports === null || ports.size < 0) {
return null;
}
const portChildren: any[] = [];
ports.forEach((port, portKey) => {
const jPort: any = {
label: 'Port - ' + port.portNumber,
// className: 'cn' + port.portNumber,
expandedIcon: 'fa-folder-open',
collapsedIcon: 'fa-folder',
};
jPort.obj = port;
jPort.children = this.convertViewService(port.services);
portChildren.push(jPort);
});
return portChildren;
}
convertViewService(services): any[] {
if (services === undefined || services === null || services.size <= 0) {
return null;
}
const serviceChildren: any[] = [];
services.forEach((service, serviceKey) => {
const jService: any = {
label: 'Service - ' + service.serviceName,
// className: 'cn' + service.serviceName,
};
jService.obj = service;
serviceChildren.push(jService);
});
return serviceChildren;
}
}

View File

@ -37,7 +37,7 @@
<p-panel [showHeader]="false"> <p-panel [showHeader]="false">
<div class="ui-g form-group ui-key-value"> <div class="ui-g form-group ui-key-value">
<of-key-value [key]="'ID'" [value]="sensor.id"></of-key-value> <of-key-value [key]="'ID'" [value]="sensor.id"></of-key-value>
<of-key-value [key]="'Location'" [value]="sensor.target.displayName" [clickable]="true" (click)="onTargetClick(sensor.target)" ></of-key-value> <of-key-value [key]="'Location'" [value]="sensor.target.displayName" [clickable]="true" (click)="onTargetClick(sensor.target)"></of-key-value>
<of-key-value [key]="'Description'" [value]="sensor.description"></of-key-value> <of-key-value [key]="'Description'" [value]="sensor.description"></of-key-value>
<of-key-value [key]="'Crawler Type'" [value]="sensor.crawler.name"></of-key-value> <of-key-value [key]="'Crawler Type'" [value]="sensor.crawler.name"></of-key-value>
<of-key-value [key]="'Sensor Items'" [value]="sensor.itemCount"></of-key-value> <of-key-value [key]="'Sensor Items'" [value]="sensor.itemCount"></of-key-value>
@ -51,4 +51,9 @@
</div> </div>
</div> </div>
<p-confirmDialog header="Confirmation" icon="fa ui-icon-warning" width="425"></p-confirmDialog> <p-confirmDialog header="Confirmation" icon="fa ui-icon-warning" width="425"></p-confirmDialog>
</div> </div>
<p-dialog [modal]="true" [width]="800" [(visible)]="sensorSettingDisplay" [showHeader]="true" [closeOnEscape]="false">
<of-sensor-setting [visible]="sensorSettingDisplay" (close)="onSensorSettingClose()"></of-sensor-setting>
</p-dialog>

View File

@ -18,13 +18,16 @@ export class DetailComponent implements OnInit, AfterContentInit, OnDestroy {
sensorSubscription$: Subscription; sensorSubscription$: Subscription;
sensor$ = this.detailStore.pipe(select(sensorSelector.select('sensor'))); sensor$ = this.detailStore.pipe(select(sensorSelector.select('sensor')));
sensor: Sensor; sensor: Sensor;
sensorSettingDisplay: boolean;
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private confirmationService: ConfirmationService, private confirmationService: ConfirmationService,
private detailStore: Store<DetailStore.State>, private detailStore: Store<DetailStore.State>,
) { } ) {
this.sensorSettingDisplay = false;
}
ngOnInit() { ngOnInit() {
this.sensorSubscription$ = this.sensor$.subscribe( this.sensorSubscription$ = this.sensor$.subscribe(
@ -55,7 +58,9 @@ export class DetailComponent implements OnInit, AfterContentInit, OnDestroy {
onStartOrStop() { } onStartOrStop() { }
onEdit() { } onEdit() {
this.sensorSettingDisplay = true;
}
onRemove() { onRemove() {
this.confirmationService.confirm({ this.confirmationService.confirm({

View File

@ -0,0 +1,17 @@
<p-panel [showHeader]="false">
<div *ngIf="crawler; else info" class="ui-g ui-width-100-" style="height: 180px; overflow: auto">
<div class="ui-g-12" *ngFor="let item of inputItems">
<span class="md-inputfield">
<input id="name" type="text" pInputText />
<label for="name">User</label>
</span>
</div>
</div>
<ng-template #info>
<div>개발자의 배려가 돋보이는 친절한 안내 메시지</div>
</ng-template>
<div dir="rtl">
<button *ngIf="crawler" type="button" label="Test" icon="ui-icon-send" pButton class="ui-button-width-fit" (click)="testCredentials()"></button>
</div>
</p-panel>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CrawlerAuthComponent } from './crawler-auth.component';
describe('FilterComponent', () => {
let component: CrawlerAuthComponent;
let fixture: ComponentFixture<CrawlerAuthComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CrawlerAuthComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CrawlerAuthComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,96 @@
import { Component, OnInit, Input, OnChanges, Output, EventEmitter } from '@angular/core';
import { Router } from '@angular/router';
import { MetaCrawler } from '@overflow/commons-typescript/model/meta';
import { Store, select } from '@ngrx/store';
import { RPCClientError } from '@loafer/ng-rpc/protocol';
import * as ListStore from 'packages/meta/crawler-input-item/store/list';
import { ReadCrawlerInputItemSelector } from 'packages/meta/crawler-input-item/store';
import { MetaCrawlerInputItem } from '@overflow/commons-typescript/model/meta';
@Component({
selector: 'of-crawler-auth',
templateUrl: './crawler-auth.component.html',
})
export class CrawlerAuthComponent implements OnInit, OnChanges {
inputItems$ = this.listStore.pipe(select(ReadCrawlerInputItemSelector.select('inputs')));
inputItems: MetaCrawlerInputItem[];
title: string;
@Output() credentialPassed = new EventEmitter<boolean>();
@Input() crawler: MetaCrawler;
constructor(
private router: Router,
private listStore: Store<ListStore.State>,
) { }
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);
// }
// );
}
ngOnChanges() {
// 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 = {
id: i,
// inputType: {
// id: i,
// name: '',
// description: '',
// },
crawler: null,
description: '',
name: '',
createDate: new Date(),
required: true,
defaultValue: '',
pattern: '',
keyName: '',
keyValue: '',
};
this.inputItems.push(item);
}
}
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);
}
}

View File

@ -0,0 +1,16 @@
<div *ngIf="target; else info" class="ui-width-100-">
<p-orderList [value]="crawlers" [listStyle]="{'height':'200px'}" [responsive]="true" filterBy="name"
(onSelectionChange)="onSelectionChange($event)" class="ui_orderlist_controls_none">
<ng-template let-crawler pTemplate="item">
<div class="ui-helper-clearfix">
<div style="font-size:14px;margin:0">{{crawler.name}}</div>
</div>
</ng-template>
</p-orderList>
</div>
<ng-template #info>
<p-panel [showHeader]="false">
<div>개발자의 배려가 돋보이는 친절한 안내 메시지</div>
</p-panel>
</ng-template>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CrawlerSelectorComponent } from './crawler-selector.component';
describe('FilterComponent', () => {
let component: CrawlerSelectorComponent;
let fixture: ComponentFixture<CrawlerSelectorComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CrawlerSelectorComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CrawlerSelectorComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,67 @@
import { Component, OnInit, Input, OnChanges, AfterContentInit, Output, EventEmitter } from '@angular/core';
import { Router } from '@angular/router';
import { Target } from '@overflow/commons-typescript/model/target';
import { Store, select } from '@ngrx/store';
import { RPCClientError } from '@loafer/ng-rpc/protocol';
import * as ListStore from 'packages/meta/crawler/store/list';
import { ReadAllCrawlerSelector } from 'packages/meta/crawler/store';
import { MetaCrawler } from '@overflow/commons-typescript/model/meta';
@Component({
selector: 'of-crawler-selector',
templateUrl: './crawler-selector.component.html',
})
export class CrawlerSelectorComponent implements OnInit, OnChanges, AfterContentInit {
crawlers$ = this.listStore.pipe(select(ReadAllCrawlerSelector.select('metaCrawlerList')));
@Input() target: Target;
crawlers: MetaCrawler[];
@Output() crawlerSelected = new EventEmitter<MetaCrawler>();
constructor(
private router: Router,
private listStore: Store<ListStore.State>,
) { }
ngOnInit() {
// this.crawlers$.subscribe(
// (list: MetaCrawler[]) => {
// if (list !== null) {
// this.crawlers = list;
// }
// },
// (error: RPCClientError) => {
// console.log(error.response.message);
// }
// );
}
ngAfterContentInit() {
// 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);
}
}
onSelectionChange(event) {
this.crawlerSelected.emit(event.value[0]);
}
}

View File

@ -0,0 +1,10 @@
<p-panel [showHeader]="false">
<div *ngIf="crawler && target; else info" class="ui-g ui-width-100- ui-no-border" style="height: 200px; overflow: auto">
<p-tree [value]="itemTreeNode" selectionMode="checkbox" [(selection)]="selectedItems" (onNodeSelect)="onNodeSelect($event)"
(onNodeUnselect)="onNodeUnselect($event)"></p-tree>
</div>
<ng-template #info>
<div>개발자의 배려가 돋보이는 친절한 안내 메시지</div>
</ng-template>
</p-panel>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SensorItemSelectorComponent } from './sensor-item-selector.component';
describe('SensorItemSelectorComponent', () => {
let component: SensorItemSelectorComponent;
let fixture: ComponentFixture<SensorItemSelectorComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SensorItemSelectorComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SensorItemSelectorComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,126 @@
import { Component, OnInit, OnChanges, Input, Output, EventEmitter, ViewChild, AfterViewInit, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';
import { Store, select } from '@ngrx/store';
import { RPCClientError } from '@loafer/ng-rpc/protocol';
import * as ListStore from 'packages/meta/sensor-display-item/store/list';
import { ReadAllSensorDisplayItemByCrawlerSelector } from 'packages/meta/sensor-display-item/store';
import { MetaSensorDisplayItem } from '@overflow/commons-typescript/model/meta';
import { MetaCrawler } from '@overflow/commons-typescript/model/meta';
import { MetaSensorItemType } from '@overflow/commons-typescript/model/meta';
import { TreeNode } from 'primeng/primeng';
import { Target } from '@overflow/commons-typescript/model/target';
@Component({
selector: 'of-sensor-item-selector',
templateUrl: './sensor-item-selector.component.html',
})
export class SensorItemSelectorComponent implements OnInit, OnChanges {
@Input() target: Target;
@Input() crawler: MetaCrawler;
@Output() sensorItemsSelected = new EventEmitter<TreeNode[]>();
items$ = this.listStore.pipe(select(ReadAllSensorDisplayItemByCrawlerSelector.select('list')));
selectedItems: TreeNode[];
itemTreeNode: TreeNode[];
constructor(
private router: Router,
private listStore: Store<ListStore.State>,
) { }
ngOnInit() {
// this.selectedItems = new Set();
// this.items$.subscribe(
// (list: MetaSensorDisplayItem[]) => {
// if (list !== null) {
// }
// },
// (error: RPCClientError) => {
// console.log(error.response.message);
// }
// );
}
ngOnChanges() {
// this.selectedItems.clear();
// this.listStore.dispatch(new ListStore.ReadAllByCrawler(this.crawler));
this.itemTreeNode = [];
if (!this.target || !this.crawler) {
return;
}
// Temporary data
const displayItems = [];
for (let i = 0; i < 10; i++) {
let isDefault = false;
const t: MetaSensorItemType = {
name: 'CPU'
};
if (i % 2) {
isDefault = true;
t.name = 'Memory';
}
const si: MetaSensorDisplayItem = {
id: i,
key: 'SensorDisplayItemKey' + i,
displayName: 'this.is.display.item.name' + i,
description: 'Description' + i,
default: isDefault,
itemType: t
};
displayItems.push(si);
}
this.generateTreeData(displayItems);
}
generateTreeData(items) {
this.itemTreeNode = [];
for (const item of items) {
const categoryNode = this.existCategory(item);
if (categoryNode === null) {
const childrenNode = [];
childrenNode.push(this.getChildNode(item));
const node = {
label: item.itemType.name,
children: childrenNode,
expanded: true,
};
this.itemTreeNode.push(node);
} else {
categoryNode.children.push(this.getChildNode(item));
}
}
}
getChildNode(item) {
const childNode = {
label: item.displayName,
expandedIcon: item.default ? 'ui-icon-star' : '',
collapsedIcon: item.default ? 'ui-icon-star' : '',
expanded: true,
data: item
};
return childNode;
}
existCategory(item: MetaSensorDisplayItem) {
let categoryNode = null;
for (const node of this.itemTreeNode) {
if (node.label === item.itemType.name) {
categoryNode = node;
}
}
return categoryNode;
}
onNodeSelect(event) {
this.sensorItemsSelected.emit(this.selectedItems);
}
onNodeUnselect(event) {
this.sensorItemsSelected.emit(this.selectedItems);
}
}

View File

@ -0,0 +1,3 @@
<div style="height: 70%;">
page 2222222
</div>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SettingETCComponent } from './setting-etc.component';
describe('SettingETCComponent', () => {
let component: SettingETCComponent;
let fixture: ComponentFixture<SettingETCComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SettingETCComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SettingETCComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,32 @@
import { Component, OnInit, Input } from '@angular/core';
import { Router } from '@angular/router';
import { MetaCrawler } from '@overflow/commons-typescript/model/meta';
import { MetaSensorDisplayItem } from '@overflow/commons-typescript/model/meta';
import { Target } from '@overflow/commons-typescript/model/target';
@Component({
selector: 'of-sensor-setting-etc',
templateUrl: './setting-etc.component.html',
})
export class SettingETCComponent implements OnInit {
@Input() selectedTarget: Target;
@Input() selectedCrawler: MetaCrawler;
@Input() selectedItems: MetaSensorDisplayItem[];
intervals = [
'600 sec',
'400 sec',
'200 sec',
];
constructor(
private router: Router,
) { }
ngOnInit() {
}
}

View File

@ -0,0 +1,60 @@
<h1>Add Sensor</h1>
<div *ngIf="page === 1; else etc">
<p-accordion [multiple]="false" [activeIndex]="step" (onOpen)="onTabOpen($event)">
<p-accordionTab header="{{getTitle(0)}}" [disabled]="preTarget" class="ui-nopad">
<of-target-selector [visible]="visible" [preTarget]="preTarget" (targetSelected)="onTargetSelect($event)"></of-target-selector>
</p-accordionTab>
<p-accordionTab header="{{getTitle(1)}}" class="ui-nopad">
<of-crawler-selector [target]="selectedTarget" (crawlerSelected)="onCrawlerSelect($event)"></of-crawler-selector>
</p-accordionTab>
<p-accordionTab header="{{getTitle(2)}}" class="ui-nopad">
<of-crawler-auth [crawler]="selectedCrawler" (credentialPassed)="onCredentialPass($event)"></of-crawler-auth>
</p-accordionTab>
<p-accordionTab header="{{getTitle(3)}}" class="ui-nopad">
<of-sensor-item-selector [target]="selectedTarget" [crawler]="selectedCrawler" (sensorItemsSelected)="onItemsSelect($event)"></of-sensor-item-selector>
</p-accordionTab>
</p-accordion>
</div>
<ng-template #etc>
<of-sensor-setting-etc></of-sensor-setting-etc>
</ng-template>
<div class="ui-top-space-10" dir="rtl">
<button pButton *ngIf="page === 1" class=" ui-button-width-fit" [disabled]="!nextable" type="button" label="Next" icon="fa-check" (click)="onNext()"></button>
<button pButton *ngIf="page === 2" class=" ui-button-width-fit" type="button" label="Done" icon="fa-check" (click)="onDone()"></button>
<button pButton *ngIf="page === 1" class="ui-button-danger ui-button-width-fit" type="button" label="Cancel" icon="ui-icon-close" (click)="onCancel()"></button>
<button pButton *ngIf="page === 2" class="ui-button-danger ui-button-width-fit" type="button" label="Prev" icon="ui-icon-close" (click)="onPrev()"></button>
</div>
<!-- <div [hidden]="step !== 1">
<div class="ui-g">
<div class="ui-g-6">
<of-target-selector [preTarget]="preTarget" (targetSelected)="onTargetSelect($event)"></of-target-selector>
</div>
<div class="ui-g-6">
<of-crawler-auth [crawler]="selectedCrawler" (credentialPassed)="onCredentialPass($event)"></of-crawler-auth>
</div>
<div class="ui-g-6">
<of-crawler-selector [target]="selectedTarget" (crawlerSelected)="onCrawlerSelect($event)"></of-crawler-selector>
</div>
<div class="ui-g-6">
<of-sensor-item-selector [target]="selectedTarget" [crawler]="selectedCrawler" (sensorItemsSelected)="onItemsSelect($event)"></of-sensor-item-selector>
</div>
</div>
</div>
<div *ngIf="step === 2">
<of-sensor-setting-etc [selectedTarget]="selectedTarget" [selectedCrawler]="selectedCrawler" [selectedItems]="selectedSensorDisplayItems"></of-sensor-setting-etc>
</div>
<div>
<button pButton *ngIf="step === 1" class="ui-button-danger" type="button" label="Cancel" icon="ui-icon-close" (click)="onCancel()"></button>
<button pButton *ngIf="step === 2" class="ui-button-danger" type="button" label="Prev" icon="ui-icon-close" (click)="onPrev()"></button>
<button pButton *ngIf="step === 1" [disabled]="!nextable" type="button" label="Next" icon="fa-check" (click)="onNext()"></button>
<button pButton *ngIf="step === 2" type="button" label="Done" icon="fa-check" (click)="onDone()"></button>
</div> -->

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SettingComponent } from './setting.component';
describe('SensorSettingComponent', () => {
let component: SettingComponent;
let fixture: ComponentFixture<SettingComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SettingComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SettingComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,159 @@
import { Component, OnInit, Input, Inject, DoCheck, ViewEncapsulation, Output, EventEmitter, OnChanges } from '@angular/core';
import { Target } from '@overflow/commons-typescript/model/target';
import { Infra } from '@overflow/commons-typescript/model/infra';
import { MetaCrawler } from '@overflow/commons-typescript/model/meta';
import { MetaSensorDisplayItem } from '@overflow/commons-typescript/model/meta';
import { Store, select, StateObservable } from '@ngrx/store';
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 '@overflow/commons-typescript/model/meta';
import { TreeNode } from 'primeng/primeng';
@Component({
selector: 'of-sensor-setting',
templateUrl: './setting.component.html',
encapsulation: ViewEncapsulation.None
})
export class SettingComponent implements OnInit, DoCheck, OnChanges {
@Input() preTarget: Target;
@Output() close = new EventEmitter();
@Input() visible;
nextable = false;
selectedTarget: Target;
selectedCrawler: MetaCrawler;
credentialPassed: boolean;
selectedSensorDisplayItems: MetaSensorDisplayItem[];
itemNodes: TreeNode[];
step = 0;
page = 1;
sensorItemKeys$: StateObservable;
constructor(
private keyListStore: Store<SensorItemKeyListStore.State>
) {
keyListStore.pipe(select(ReadSensorItemKeySelector.select('list')));
}
ngOnInit() {
this.step = this.preTarget ? 1 : 0;
// this.sensorItemKeys$.subscribe(
// (list: MetaSensorItemKey[]) => {
// if (list !== null) {
// console.log(list);
// }
// },
// (error: RPCClientError) => {
// console.log(error.response.message);
// }
// );
}
ngOnChanges(changes) {
this.step = this.preTarget ? 1 : 0;
}
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) {
this.nextable = false;
}
}
onCancel() {
this.page = 1;
this.step = 0;
this.visible = false;
this.nextable = false;
this.selectedTarget = null;
this.selectedCrawler = null;
this.credentialPassed = false;
this.selectedSensorDisplayItems = null;
this.close.emit();
}
onNext() {
this.page += 1;
}
onPrev() {
this.page -= 1;
}
onDone() {
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;
this.step = 1;
}
onCrawlerSelect(c: MetaCrawler) {
this.selectedCrawler = c;
this.step = 2;
}
onCredentialPass(b: boolean) {
if (!b) {
return;
}
this.credentialPassed = b;
this.step = 3;
}
onItemsSelect(nodes: TreeNode[]) {
this.itemNodes = nodes;
}
onTabOpen(event) {
this.step = event.index;
}
getTitle(index) {
if (index === 0 && this.preTarget) {
return this.preTarget.displayName;
}
let title = '';
switch (index) {
case 0:
title = this.selectedTarget && this.step !== index ?
this.selectedTarget.displayName :
'Choose a Target to monitor.';
break;
case 1:
title = this.selectedCrawler && this.step !== index ?
this.selectedCrawler.name :
'Choose a Crawler.';
break;
case 2:
title = this.credentialPassed && this.step !== index ?
'Credentials test succeed.' :
'Credentials';
break;
case 3:
title = 'Choose Sensor Items.';
break;
}
return title;
}
}

View File

@ -0,0 +1,11 @@
<div *ngIf="preTarget === null" class="ui-width-100-">
<p-orderList [value]="targets" [listStyle]="{'height':'200px'}" [responsive]="true" filterBy="displayName"
(onSelectionChange)="onSelectionChange($event)" class="ui_orderlist_controls_none">
<ng-template let-target pTemplate="item">
<div class="ui-helper-clearfix">
<img src="assets/demo/images/car/BMW.gif" style="display:inline-block;margin:2px 0 2px 2px" />
<div style="font-size:14px;float:right;margin:15px 5px 0 0">{{ target.displayName }}</div>
</div>
</ng-template>
</p-orderList>
</div>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TargetSelectorComponent } from './target-selector.component';
describe('FilterComponent', () => {
let component: TargetSelectorComponent;
let fixture: ComponentFixture<TargetSelectorComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TargetSelectorComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TargetSelectorComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,92 @@
import { Component, OnInit, Output, EventEmitter, Input, AfterContentInit, OnChanges } from '@angular/core';
import { Router } from '@angular/router';
import { Target } from '@overflow/commons-typescript/model/target';
import { RPCClientError } from '@loafer/ng-rpc/protocol';
import { Domain } from '@overflow/commons-typescript/model/domain';
import { AuthSelector } from 'packages/member/store';
import * as ListStore from 'packages/infra/store/list';
import { ListSelector } from 'packages/infra/store';
import { Store, select } from '@ngrx/store';
import { Page, PageParams } from 'app/commons/model';
import { SelectItem } from 'primeng/primeng';
@Component({
selector: 'of-target-selector',
templateUrl: './target-selector.component.html',
})
export class TargetSelectorComponent implements OnInit, OnChanges {
targets$ = this.store.pipe(select(ListSelector.select('page')));
@Input() preTarget: Target = null;
@Input() visible;
@Output() targetSelected = new EventEmitter<Target>();
targets: Target[] = null;
constructor(
private router: Router,
private store: Store<ListStore.State>
) { }
ngOnInit() {
// this.targets$.subscribe(
// (page: Page) => {
// if (page !== null) {
// this.convertInfraToTarget(page);
// }
// },
// (error: RPCClientError) => {
// console.log(error.response.message);
// }
// );
}
ngOnChanges(changes) {
this.targets = [];
if (this.preTarget === null) {
this.getTargetList();
} else {
this.targets.push(this.preTarget);
this.targetSelected.emit(this.preTarget);
}
}
convertInfraToTarget(page: Page) {
for (const infra of page.content) {
this.targets.push(infra.target);
}
}
getTargetList() {
// this.store.select(AuthSelector.select('domain')).subscribe(
// (domain: Domain) => {
// const pageParams: PageParams = {
// pageNo: '0',
// countPerPage: '9999',
// sortCol: 'id',
// sortDirection: 'descending'
// };
// this.store.dispatch(new ListStore.ReadAllByDomain({ domain, pageParams }));
// },
// (error) => {
// console.log(error);
// }
// );
// Temporary data
for (let i = 0; i < 10; i++) {
const t: Target = {
id: i,
displayName: 'DisplayName' + i,
createDate: new Date(),
description: 'Description' + i,
};
this.targets.push(t);
}
}
onSelectionChange(event) {
this.targetSelected.emit(event.value[0]);
}
}

View File

@ -62,6 +62,9 @@ export class CrawlerSelectorComponent implements OnInit, OnChanges, AfterContent
} }
onSelectionChange(event) { onSelectionChange(event) {
// FIXME: 이미 해당 크롤러를 사용하는 센서가 있는지 확인해야 함
// 있다면, 사용자에 알려주고 수정 모드로 변경
// 기존 SensorDisplayItem 목록 조회
this.crawlerSelected.emit(event.value[0]); this.crawlerSelected.emit(event.value[0]);
} }
} }

View File

@ -4,7 +4,7 @@ import { Infra } from '@overflow/commons-typescript/model/infra';
import { MetaCrawler } from '@overflow/commons-typescript/model/meta'; import { MetaCrawler } from '@overflow/commons-typescript/model/meta';
import { MetaSensorDisplayItem } from '@overflow/commons-typescript/model/meta'; import { MetaSensorDisplayItem } from '@overflow/commons-typescript/model/meta';
import { Store, select } from '@ngrx/store'; import { Store, select, StateObservable } from '@ngrx/store';
import { RPCClientError } from '@loafer/ng-rpc/protocol'; import { RPCClientError } from '@loafer/ng-rpc/protocol';
import * as SensorItemKeyListStore from 'packages/sensor-item/store/key-list'; import * as SensorItemKeyListStore from 'packages/sensor-item/store/key-list';
import { ReadSensorItemKeySelector } from 'packages/sensor-item/store'; import { ReadSensorItemKeySelector } from 'packages/sensor-item/store';
@ -20,7 +20,8 @@ export class SettingComponent implements OnInit, DoCheck, OnChanges {
@Input() preTarget: Target; @Input() preTarget: Target;
@Output() close = new EventEmitter(); @Output() close = new EventEmitter();
@Input() visible; @Input() visible: boolean;
@Input() editMode: boolean;
nextable = false; nextable = false;
selectedTarget: Target; selectedTarget: Target;
@ -31,12 +32,14 @@ export class SettingComponent implements OnInit, DoCheck, OnChanges {
step = 0; step = 0;
page = 1; page = 1;
sensorItemKeys$ = this.keyListStore.pipe(select(ReadSensorItemKeySelector.select('list'))); sensorItemKeys$: StateObservable;
constructor( constructor(
private keyListStore: Store<SensorItemKeyListStore.State>, private keyListStore: Store<SensorItemKeyListStore.State>
) { ) {
keyListStore.pipe(select(ReadSensorItemKeySelector.select('list')));
this.editMode = true;
} }
ngOnInit() { ngOnInit() {