Merge remote-tracking branch 'origin/master'
# Conflicts: # @overflow/member/container/index.ts
This commit is contained in:
commit
fada7b057a
|
@ -2,14 +2,14 @@
|
||||||
<!-- <div class="ui-g-12">
|
<!-- <div class="ui-g-12">
|
||||||
<p-panel [showHeader]="false" >Temp Area</p-panel>
|
<p-panel [showHeader]="false" >Temp Area</p-panel>
|
||||||
</div> -->
|
</div> -->
|
||||||
|
|
||||||
<div class="ui-g">
|
<div class="ui-g">
|
||||||
<div class="ui-g-12 ui-md-3">
|
<div class="ui-g-12 ui-md-3">
|
||||||
<p-accordion (onClose)="onTabClose($event)" (onOpen)="OnTabOpen($event)">
|
<p-accordion (onClose)="onTabClose($event)" (onOpen)="OnTabOpen($event)">
|
||||||
<p-accordionTab header="Probe Select Area" [selected]="true">
|
<p-accordionTab header="Probe Select Area" [selected]="true">
|
||||||
<of-probe-selector
|
<!-- <of-probe-selector
|
||||||
[preProbe]="probeHosts"
|
[preProbe]="selectedProbeHost"
|
||||||
(probeSelected)="onSelectedProbe($event)"
|
[probeHosts]="probeHosts"></of-probe-selector> -->
|
||||||
></of-probe-selector>
|
|
||||||
</p-accordionTab>
|
</p-accordionTab>
|
||||||
<p-accordionTab header="Discovery Search Config Area" >
|
<p-accordionTab header="Discovery Search Config Area" >
|
||||||
<of-discovery-search-config
|
<of-discovery-search-config
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {
|
||||||
AfterContentInit, Component, Input,
|
AfterContentInit, Component, Input,
|
||||||
OnInit
|
OnInit
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import {Probe} from '@overflow/commons-typescript/model/probe';
|
import { Probe, ProbeHost } from '@overflow/commons-typescript/model/probe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'of-discovery',
|
selector: 'of-discovery',
|
||||||
|
@ -10,16 +10,19 @@ import {Probe} from '@overflow/commons-typescript/model/probe';
|
||||||
})
|
})
|
||||||
export class DiscoveryComponent implements OnInit, AfterContentInit {
|
export class DiscoveryComponent implements OnInit, AfterContentInit {
|
||||||
|
|
||||||
@Input() probeHosts;
|
@Input() probeHostID: number;
|
||||||
|
|
||||||
private tabIdx: number;
|
private tabIdx: number;
|
||||||
selectedProbe: Probe;
|
selectedProbeHost: ProbeHost;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
// if (this.probeHostID) {
|
||||||
|
// this.selectedProbeHost = this.probeHosts.find(probeHost => probeHost.id === this.probeHostID);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterContentInit() {
|
ngAfterContentInit() {
|
||||||
|
@ -43,7 +46,7 @@ export class DiscoveryComponent implements OnInit, AfterContentInit {
|
||||||
|
|
||||||
onSelectedProbe(probe) {
|
onSelectedProbe(probe) {
|
||||||
console.log(probe);
|
console.log(probe);
|
||||||
this.selectedProbe = probe;
|
// this.selectedProbe = probe;
|
||||||
}
|
}
|
||||||
|
|
||||||
onProbeSelect(probe) {
|
onProbeSelect(probe) {
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<div *ngIf="!preProbe">
|
|
||||||
<p-dropdown #dropdown [options]="probes"
|
|
||||||
optionLabel="displayName"
|
|
||||||
placeholder="Select a Probe"
|
|
||||||
[(ngModel)]="selected"
|
|
||||||
(onChange)="onProbeSelect($event)"
|
|
||||||
[style]="{'width':'100%'}">
|
|
||||||
</p-dropdown>
|
|
||||||
</div>
|
|
|
@ -1,59 +0,0 @@
|
||||||
import {
|
|
||||||
Component, OnInit, Input, AfterContentInit, Output,
|
|
||||||
EventEmitter, OnDestroy, ViewChild
|
|
||||||
} from '@angular/core';
|
|
||||||
|
|
||||||
import { Subscription } from 'rxjs/Subscription';
|
|
||||||
import {Probe, ProbeHost} from '@overflow/commons-typescript/model/probe';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'of-probe-selector',
|
|
||||||
templateUrl: './probe-selector.component.html',
|
|
||||||
})
|
|
||||||
export class ProbeSelectorComponent implements OnInit, AfterContentInit, OnDestroy {
|
|
||||||
|
|
||||||
@Input() preProbe: ProbeHost;
|
|
||||||
probes: Probe[];
|
|
||||||
selected: Probe;
|
|
||||||
|
|
||||||
@Output() probeSelected = new EventEmitter<Probe>();
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ngAfterContentInit() {
|
|
||||||
this.getProbes();
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy() {
|
|
||||||
this.selected = null;
|
|
||||||
this.probes = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
getProbes() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
onProbeSelect(event) {
|
|
||||||
this.selected = event.value;
|
|
||||||
this.probeSelected.emit(this.selected);
|
|
||||||
}
|
|
||||||
|
|
||||||
registerOnChange(fn: any): void {
|
|
||||||
}
|
|
||||||
|
|
||||||
registerOnTouched(fn: any): void {
|
|
||||||
}
|
|
||||||
|
|
||||||
setDisabledState(isDisabled: boolean): void {
|
|
||||||
}
|
|
||||||
|
|
||||||
writeValue(obj: any): void {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { ProbeSelectorComponent } from './discovery/probe-selector/probe-selector.component';
|
|
||||||
import { ServiceSelectorComponent } from './discovery/service-selector/service-selector.component';
|
import { ServiceSelectorComponent } from './discovery/service-selector/service-selector.component';
|
||||||
import { DiscoveryComponent } from './discovery/discovery.component';
|
import { DiscoveryComponent } from './discovery/discovery.component';
|
||||||
import { SearchConfigComponent } from './discovery/search-config/search-config.component';
|
import { SearchConfigComponent } from './discovery/search-config/search-config.component';
|
||||||
|
@ -8,7 +7,6 @@ import { IpInputComponent } from './discovery/search-config/ip-input.component';
|
||||||
|
|
||||||
export const COMPONENTS = [
|
export const COMPONENTS = [
|
||||||
ServiceSelectorComponent,
|
ServiceSelectorComponent,
|
||||||
ProbeSelectorComponent,
|
|
||||||
DiscoveryComponent,
|
DiscoveryComponent,
|
||||||
SearchConfigComponent,
|
SearchConfigComponent,
|
||||||
SearchFilterComponent,
|
SearchFilterComponent,
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
<of-discovery [probeHosts]="probeHosts$ | async"></of-discovery>
|
<of-probe-selector-container [probeHostID]="probeHostID"></of-probe-selector-container>
|
||||||
|
<of-discovery [probeHostID]="probeHostID"></of-discovery>
|
||||||
|
|
|
@ -1,53 +1,19 @@
|
||||||
import {
|
import {
|
||||||
AfterContentInit, Component, Input,
|
Component,
|
||||||
OnInit
|
Input,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { select, Store} from '@ngrx/store';
|
|
||||||
import { ActivatedRoute } from '@angular/router';
|
|
||||||
import { Probe, ProbeHost } from '@overflow/commons-typescript/model/probe';
|
|
||||||
|
|
||||||
import { AuthSelector } from '@overflow/member/store';
|
|
||||||
import { Domain } from '@overflow/commons-typescript/model/domain';
|
|
||||||
import * as ProbeEntityStore from '@overflow/probe/store/entity/probe';
|
|
||||||
import {Observable} from 'rxjs';
|
|
||||||
import { ProbeEntitySelector } from '@overflow/probe/store';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'of-discovery-container',
|
selector: 'of-discovery-container',
|
||||||
templateUrl: './discovery-container.component.html',
|
templateUrl: './discovery-container.component.html',
|
||||||
})
|
})
|
||||||
export class DiscoveryContainerComponent implements OnInit, AfterContentInit {
|
export class DiscoveryContainerComponent {
|
||||||
|
|
||||||
// probe select ?
|
@Input() probeHostID;
|
||||||
// get probe list for server
|
|
||||||
// discovery start
|
|
||||||
// discovery stop
|
|
||||||
// get service list
|
|
||||||
@Input() hostID;
|
|
||||||
|
|
||||||
probeHosts$: Observable<Probe[]>;
|
|
||||||
selectProbes?: Probe[];
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private activatedRoute: ActivatedRoute,
|
|
||||||
private store: Store<ProbeEntityStore.State>
|
|
||||||
) {
|
) {
|
||||||
this.probeHosts$ = store.pipe(select(ProbeEntitySelector.selectAll));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.store.select(AuthSelector.select('domain')).subscribe(
|
|
||||||
(domain: Domain) => {
|
|
||||||
this.store.dispatch(new ProbeEntityStore.ReadAllByDomainID(domain.id));
|
|
||||||
},
|
|
||||||
(error) => {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
ngAfterContentInit() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import { SERVICES } from './service';
|
||||||
import { PrimeNGModules } from '@overflow/commons/prime-ng/prime-ng.module';
|
import { PrimeNGModules } from '@overflow/commons/prime-ng/prime-ng.module';
|
||||||
import { KeyValueModule } from '@overflow/commons/component/key-value/key-value.module';
|
import { KeyValueModule } from '@overflow/commons/component/key-value/key-value.module';
|
||||||
import { CONTAINER_COMPONENTS } from './container';
|
import { CONTAINER_COMPONENTS } from './container';
|
||||||
|
import { ProbeModule } from '../probe/probe.module';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -21,7 +22,8 @@ import { CONTAINER_COMPONENTS } from './container';
|
||||||
DiscoveryStoreModule,
|
DiscoveryStoreModule,
|
||||||
DiscoveryRPCModule,
|
DiscoveryRPCModule,
|
||||||
DiscoveryLoggerModule,
|
DiscoveryLoggerModule,
|
||||||
KeyValueModule
|
KeyValueModule,
|
||||||
|
ProbeModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
COMPONENTS,
|
COMPONENTS,
|
||||||
|
|
|
@ -8,4 +8,5 @@ export const CONTAINERS = [
|
||||||
MemberSignupContainerComponent,
|
MemberSignupContainerComponent,
|
||||||
MemberTermsContainerComponent,
|
MemberTermsContainerComponent,
|
||||||
MemberTotpContainerComponent,
|
MemberTotpContainerComponent,
|
||||||
|
// MemberSignupContainerComponent,
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import { ProbeDetailComponent } from './detail/detail.component';
|
import { ProbeDetailComponent } from './detail/detail.component';
|
||||||
import { ProbeListComponent } from './list/list.component';
|
import { ProbeListComponent } from './list/list.component';
|
||||||
import { ProbeDownloadComponent } from './download/download.component';
|
import { ProbeDownloadComponent } from './download/download.component';
|
||||||
|
import { ProbeSelectorComponent } from './selector/selector.component';
|
||||||
|
|
||||||
export const COMPONENTS = [
|
export const COMPONENTS = [
|
||||||
ProbeListComponent,
|
ProbeListComponent,
|
||||||
ProbeDetailComponent,
|
ProbeDetailComponent,
|
||||||
ProbeDownloadComponent,
|
ProbeDownloadComponent,
|
||||||
|
ProbeSelectorComponent,
|
||||||
];
|
];
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<p-dropdown *ngIf="probeHosts.length > 0" [options]="options" [(ngModel)]="selected" optionLabel="displayName" placeholder="Select a Probe"></p-dropdown>
|
29
@overflow/probe/component/selector/selector.component.ts
Normal file
29
@overflow/probe/component/selector/selector.component.ts
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
import { Component, Input, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
|
||||||
|
import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'of-probe-selector',
|
||||||
|
templateUrl: './selector.component.html',
|
||||||
|
})
|
||||||
|
export class ProbeSelectorComponent implements OnChanges {
|
||||||
|
|
||||||
|
@Output() select = new EventEmitter<ProbeHost>();
|
||||||
|
@Input() probeHosts: ProbeHost[];
|
||||||
|
@Input() probeHostID: number;
|
||||||
|
|
||||||
|
options: Probe[];
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
this.options = [];
|
||||||
|
for (const ph of this.probeHosts) {
|
||||||
|
this.options.push(ph.probe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onProbeSelect(event) {
|
||||||
|
this.select.emit(event.data);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,9 @@
|
||||||
import { ProbeListContainerComponent } from '../container/probe-list-container.component';
|
import { ProbeListContainerComponent } from '../container/probe-list-container.component';
|
||||||
import { ProbeDetailContainerComponent } from '../container/probe-detail-container.component';
|
import { ProbeDetailContainerComponent } from '../container/probe-detail-container.component';
|
||||||
|
import { ProbeSelectorContainerComponent } from './probe-selector-container.component';
|
||||||
|
|
||||||
export const CONTAINER_COMPONENTS = [
|
export const CONTAINER_COMPONENTS = [
|
||||||
ProbeListContainerComponent,
|
ProbeListContainerComponent,
|
||||||
ProbeDetailContainerComponent,
|
ProbeDetailContainerComponent,
|
||||||
|
ProbeSelectorContainerComponent
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { Component, OnInit, Input, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
|
import { Component, OnInit, Input, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe';
|
import { ProbeHost } from '@overflow/commons-typescript/model/probe';
|
||||||
import { Store, select } from '@ngrx/store';
|
import { Store, select } from '@ngrx/store';
|
||||||
import * as ProbeStore from '../store/entity/probe';
|
import * as ProbeStore from '../store/entity/probe';
|
||||||
import { ProbeEntitySelector, ProbeDetailContainerSelector } from '../store';
|
import { ProbeDetailContainerSelector } from '../store';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -19,15 +19,15 @@ export class ProbeDetailContainerComponent implements OnInit, OnChanges {
|
||||||
error$: Observable<any>;
|
error$: Observable<any>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private store: Store<ProbeStore.State>,
|
private store: Store<any>,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
) {
|
) {
|
||||||
this.pending$ = this.store.pipe(select(ProbeDetailContainerSelector.selectPending));
|
|
||||||
this.error$ = this.store.pipe(select(ProbeEntitySelector.selectError));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.probeHost$ = this.store.pipe(select(ProbeEntitySelector.selectOne(this.probeHostID)));
|
this.pending$ = this.store.pipe(select(ProbeDetailContainerSelector.selectPending));
|
||||||
|
this.error$ = this.store.pipe(select(ProbeDetailContainerSelector.selectError));
|
||||||
|
this.probeHost$ = this.store.pipe(select(ProbeDetailContainerSelector.selectOne(this.probeHostID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
|
|
@ -3,9 +3,9 @@ import { ProbeHost } from '@overflow/commons-typescript/model/probe';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { Store, select } from '@ngrx/store';
|
import { Store, select } from '@ngrx/store';
|
||||||
import * as ProbeEntityStore from '../store/entity/probe';
|
import * as ProbeEntityStore from '../store/entity/probe';
|
||||||
import { ProbeEntitySelector, ProbeListContainerSelector } from '../store';
|
import { ProbeListContainerSelector } from '../store';
|
||||||
import { AuthSelector } from '@overflow/member/store';
|
import { AuthContainerSelector } from '../../shared/auth/store';
|
||||||
import { Domain } from '@overflow/commons-typescript/model/domain';
|
import { DomainMember } from '@overflow/commons-typescript/model/domain';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'of-probe-list-container',
|
selector: 'of-probe-list-container',
|
||||||
|
@ -15,22 +15,20 @@ export class ProbeListContainerComponent implements OnInit {
|
||||||
|
|
||||||
probeHosts$: Observable<ProbeHost[]>;
|
probeHosts$: Observable<ProbeHost[]>;
|
||||||
pending$: Observable<boolean>;
|
pending$: Observable<boolean>;
|
||||||
|
error$: Observable<any>;
|
||||||
@Output() select = new EventEmitter();
|
@Output() select = new EventEmitter();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private store: Store<ProbeEntityStore.State>,
|
private store: Store<any>,
|
||||||
) {
|
) {
|
||||||
this.probeHosts$ = store.pipe(select(ProbeEntitySelector.selectAll));
|
|
||||||
this.pending$ = store.pipe(select(ProbeListContainerSelector.selectPending));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.store.select(AuthSelector.select('domain')).subscribe(
|
this.probeHosts$ = this.store.pipe(select(ProbeListContainerSelector.selectAll));
|
||||||
(domain: Domain) => {
|
this.pending$ = this.store.pipe(select(ProbeListContainerSelector.selectPending));
|
||||||
this.store.dispatch(new ProbeEntityStore.ReadAllByDomainID(domain.id));
|
this.store.select(AuthContainerSelector.selectDomainMember).subscribe(
|
||||||
},
|
(domainMember: DomainMember) => {
|
||||||
(error) => {
|
this.store.dispatch(new ProbeEntityStore.ReadAllByDomainID(domainMember.domain.id));
|
||||||
console.log(error);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<of-probe-selector (select)="onSelect($event)" [probeHosts]="probeHosts$ | async" [probeHostID]="probeHostID"></of-probe-selector>
|
|
@ -0,0 +1,39 @@
|
||||||
|
import { Component, EventEmitter, Output, OnInit, Input } from '@angular/core';
|
||||||
|
import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { Store, select } from '@ngrx/store';
|
||||||
|
import * as ProbeEntityStore from '@overflow/probe/store/entity/probe';
|
||||||
|
import { ProbeListContainerSelector } from '@overflow/probe/store';
|
||||||
|
import { AuthContainerSelector } from '@overflow/shared/auth/store';
|
||||||
|
import { DomainMember } from '@overflow/commons-typescript/model/domain';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'of-probe-selector-container',
|
||||||
|
templateUrl: './probe-selector-container.component.html',
|
||||||
|
})
|
||||||
|
export class ProbeSelectorContainerComponent implements OnInit {
|
||||||
|
|
||||||
|
probeHosts$: Observable<ProbeHost[]>;
|
||||||
|
@Output() select = new EventEmitter();
|
||||||
|
@Input() probeHostID: number;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private store: Store<any>,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.probeHosts$ = this.store.pipe(select(ProbeListContainerSelector.selectAll));
|
||||||
|
this.store.select(AuthContainerSelector.selectDomainMember).subscribe(
|
||||||
|
(domainMember: DomainMember) => {
|
||||||
|
this.store.dispatch(new ProbeEntityStore.ReadAllByDomainID(domainMember.domain.id));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onSelect(probeHost: ProbeHost) {
|
||||||
|
alert(probeHost.probe.displayName);
|
||||||
|
// this.select.emit(probeHost);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -7,7 +7,6 @@ import { ProbeStoreModule } from './probe-store.module';
|
||||||
import { SERVICES } from './service';
|
import { SERVICES } from './service';
|
||||||
import { PrimeNGModules } from '../commons/prime-ng/prime-ng.module';
|
import { PrimeNGModules } from '../commons/prime-ng/prime-ng.module';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { DiscoveryModule } from '@overflow/discovery/discovery.module';
|
|
||||||
import { MetaCrawlerModule } from '@overflow/meta/crawler/crawler.module';
|
import { MetaCrawlerModule } from '@overflow/meta/crawler/crawler.module';
|
||||||
import { KeyValueModule } from '@overflow/commons/component/key-value/key-value.module';
|
import { KeyValueModule } from '@overflow/commons/component/key-value/key-value.module';
|
||||||
|
|
||||||
|
@ -17,7 +16,6 @@ import { KeyValueModule } from '@overflow/commons/component/key-value/key-value.
|
||||||
PrimeNGModules,
|
PrimeNGModules,
|
||||||
ProbeStoreModule,
|
ProbeStoreModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
DiscoveryModule,
|
|
||||||
KeyValueModule,
|
KeyValueModule,
|
||||||
MetaCrawlerModule
|
MetaCrawlerModule
|
||||||
],
|
],
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { ActionType, Actions } from '../../entity/probe';
|
||||||
import {
|
import {
|
||||||
State,
|
State,
|
||||||
initialState,
|
initialState,
|
||||||
|
probeListContainerAdapter
|
||||||
} from './probe-detail.state';
|
} from './probe-detail.state';
|
||||||
|
|
||||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||||
|
@ -16,17 +17,11 @@ export function reducer(state = initialState, action: Actions): State {
|
||||||
}
|
}
|
||||||
|
|
||||||
case ActionType.ReadSuccess: {
|
case ActionType.ReadSuccess: {
|
||||||
return {
|
return probeListContainerAdapter.setOne(action.payload, {...state, pending: false});
|
||||||
...state,
|
|
||||||
pending: false,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case ActionType.ReadFailure: {
|
case ActionType.ReadFailure: {
|
||||||
return {
|
return probeListContainerAdapter.setError(action.payload, {...state, pending: false});
|
||||||
...state,
|
|
||||||
pending: true,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
|
import { RPCClientError } from '@loafer/ng-rpc';
|
||||||
|
import { ProbeHost } from '@overflow/commons-typescript/model/probe';
|
||||||
import { Selector, createSelector } from '@ngrx/store';
|
import { Selector, createSelector } from '@ngrx/store';
|
||||||
import { createEntityAdapter, EntityState } from '@loafer/ng-entity';
|
import { createEntityAdapter, EntityState } from '@loafer/ng-entity';
|
||||||
|
|
||||||
export interface State {
|
export const probeListContainerAdapter = createEntityAdapter<ProbeHost, RPCClientError>();
|
||||||
|
export interface State extends EntityState<ProbeHost, RPCClientError> {
|
||||||
pending: boolean;
|
pending: boolean;
|
||||||
}
|
}
|
||||||
export const initialState: State = {
|
export const initialState: State = probeListContainerAdapter.getInitialState({
|
||||||
pending: false,
|
pending: false,
|
||||||
};
|
});
|
||||||
|
|
||||||
export function getSelectors<S>(selector: Selector<any, State>) {
|
export function getSelectors<S>(selector: Selector<any, State>) {
|
||||||
return {
|
return {
|
||||||
|
...probeListContainerAdapter.getSelectors(selector),
|
||||||
selectPending: createSelector(selector, (state: State) => state.pending),
|
selectPending: createSelector(selector, (state: State) => state.pending),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { ActionType, Actions } from '../../entity/probe';
|
||||||
import {
|
import {
|
||||||
State,
|
State,
|
||||||
initialState,
|
initialState,
|
||||||
|
probeListContainerAdapter
|
||||||
} from './probe-list.state';
|
} from './probe-list.state';
|
||||||
|
|
||||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||||
|
@ -16,17 +17,11 @@ export function reducer(state = initialState, action: Actions): State {
|
||||||
}
|
}
|
||||||
|
|
||||||
case ActionType.ReadAllByDomainIDSuccess: {
|
case ActionType.ReadAllByDomainIDSuccess: {
|
||||||
return {
|
return probeListContainerAdapter.setAll(action.payload, {...state, pending: false});
|
||||||
...state,
|
|
||||||
pending: false,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case ActionType.ReadAllByDomainIDFailure: {
|
case ActionType.ReadAllByDomainIDFailure: {
|
||||||
return {
|
return probeListContainerAdapter.setError(action.payload, {...state, pending: false});
|
||||||
...state,
|
|
||||||
pending: true,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
|
|
@ -1,15 +1,21 @@
|
||||||
|
import { RPCClientError } from '@loafer/ng-rpc';
|
||||||
|
import { ProbeHost } from '@overflow/commons-typescript/model/probe';
|
||||||
import { Selector, createSelector } from '@ngrx/store';
|
import { Selector, createSelector } from '@ngrx/store';
|
||||||
import { createEntityAdapter, EntityState } from '@loafer/ng-entity';
|
import { createEntityAdapter, EntityState } from '@loafer/ng-entity';
|
||||||
|
|
||||||
export interface State {
|
export const probeListContainerAdapter = createEntityAdapter<ProbeHost, RPCClientError>();
|
||||||
|
export interface State extends EntityState<ProbeHost, RPCClientError> {
|
||||||
pending: boolean;
|
pending: boolean;
|
||||||
}
|
}
|
||||||
export const initialState: State = {
|
export const initialState: State = probeListContainerAdapter.getInitialState({
|
||||||
pending: false,
|
pending: false,
|
||||||
};
|
});
|
||||||
|
|
||||||
export function getSelectors<S>(selector: Selector<any, State>) {
|
export function getSelectors<S>(selector: Selector<any, State>) {
|
||||||
return {
|
return {
|
||||||
|
...probeListContainerAdapter.getSelectors(selector),
|
||||||
selectPending: createSelector(selector, (state: State) => state.pending),
|
selectPending: createSelector(selector, (state: State) => state.pending),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,2 @@
|
||||||
export * from './probe.action';
|
export * from './probe.action';
|
||||||
export * from './probe.effect';
|
export * from './probe.effect';
|
||||||
export * from './probe.reducer';
|
|
||||||
export * from './probe.state';
|
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
import {
|
|
||||||
ActionType,
|
|
||||||
Actions,
|
|
||||||
} from './probe.action';
|
|
||||||
|
|
||||||
import {
|
|
||||||
State,
|
|
||||||
initialState,
|
|
||||||
probeAdapter,
|
|
||||||
} from './probe.state';
|
|
||||||
|
|
||||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
|
||||||
|
|
||||||
export function reducer(state = initialState, action: Actions): State {
|
|
||||||
switch (action.type) {
|
|
||||||
case ActionType.ReadAllByDomainID: {
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
error: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
case ActionType.ReadAllByDomainIDSuccess: {
|
|
||||||
return probeAdapter.setAll(action.payload, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
case ActionType.ReadAllByDomainIDFailure: {
|
|
||||||
return probeAdapter.setError(action.payload, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
case ActionType.Read: {
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
error: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
case ActionType.ReadSuccess: {
|
|
||||||
return probeAdapter.setOne(action.payload, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
case ActionType.ReadFailure: {
|
|
||||||
return probeAdapter.setError(action.payload, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
case ActionType.Modify: {
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
error: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
case ActionType.ModifySuccess: {
|
|
||||||
return probeAdapter.upsertOne(action.payload, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
case ActionType.ModifyFailure: {
|
|
||||||
return probeAdapter.setError(action.payload, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
import { RPCClientError } from '@loafer/ng-rpc';
|
|
||||||
import { ProbeHost } from '@overflow/commons-typescript/model/probe';
|
|
||||||
import { Selector, createSelector } from '@ngrx/store';
|
|
||||||
import { createEntityAdapter, EntityState } from '@loafer/ng-entity';
|
|
||||||
|
|
||||||
export const probeAdapter = createEntityAdapter<ProbeHost, RPCClientError>();
|
|
||||||
export interface State extends EntityState<ProbeHost, RPCClientError> {
|
|
||||||
}
|
|
||||||
export const initialState: State = probeAdapter.getInitialState();
|
|
||||||
|
|
||||||
export function getSelectors<S>(selector: Selector<any, State>) {
|
|
||||||
return probeAdapter.getSelectors(selector);
|
|
||||||
}
|
|
||||||
|
|
|
@ -13,13 +13,11 @@ import * as ProbeListContainerStore from './container/probe-list';
|
||||||
import * as ProbeDetailContainerStore from './container/probe-detail';
|
import * as ProbeDetailContainerStore from './container/probe-detail';
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
probe: ProbeEntityStore.State;
|
|
||||||
probe_list_container: ProbeListContainerStore.State;
|
probe_list_container: ProbeListContainerStore.State;
|
||||||
probe_detail_container: ProbeDetailContainerStore.State;
|
probe_detail_container: ProbeDetailContainerStore.State;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const REDUCERS = {
|
export const REDUCERS = {
|
||||||
probe: ProbeEntityStore.reducer,
|
|
||||||
probe_list_container: ProbeListContainerStore.reducer,
|
probe_list_container: ProbeListContainerStore.reducer,
|
||||||
probe_detail_container: ProbeDetailContainerStore.reducer
|
probe_detail_container: ProbeDetailContainerStore.reducer
|
||||||
};
|
};
|
||||||
|
@ -30,11 +28,6 @@ export const EFFECTS = [
|
||||||
|
|
||||||
export const selectState = createFeatureSelector<State>(MODULE.name);
|
export const selectState = createFeatureSelector<State>(MODULE.name);
|
||||||
|
|
||||||
export const ProbeEntitySelector = ProbeEntityStore.getSelectors(createSelector(
|
|
||||||
selectState,
|
|
||||||
(state: State) => state.probe
|
|
||||||
));
|
|
||||||
|
|
||||||
export const ProbeListContainerSelector = ProbeListContainerStore.getSelectors(createSelector(
|
export const ProbeListContainerSelector = ProbeListContainerStore.getSelectors(createSelector(
|
||||||
selectState,
|
selectState,
|
||||||
(state: State) => state.probe_list_container
|
(state: State) => state.probe_list_container
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<div *ngIf="sensor">
|
SENSOR_DETAIL_COMPONENT
|
||||||
|
<!-- <div *ngIf="sensor">
|
||||||
<h1>{{sensor.crawler.name}}</h1>
|
<h1>{{sensor.crawler.name}}</h1>
|
||||||
|
|
||||||
<div class="ui-g">
|
<div class="ui-g">
|
||||||
|
@ -52,4 +53,4 @@
|
||||||
</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>
|
||||||
|
-->
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
<div class="ui-g-10">
|
<div class="ui-g-10">
|
||||||
<div *ngFor="let sensor of item.sensors" class="ui-g-12">
|
<div *ngFor="let sensor of item.sensors" class="ui-g-12">
|
||||||
<i class="fa ui-icon-stop ui-status-icon ui-status-warn"></i>
|
<i class="fa ui-icon-stop ui-status-icon ui-status-warn"></i>
|
||||||
<a href="javascript:void(0)" (click)="onSensorClick(sensor)">{{sensor.crawler.name}} | {{sensor.itemCount}} items | {{sensor.status.name}}</a>
|
<a href="javascript:void(0)" (click)="select.emit(sensor)">{{sensor.crawler.name}} | {{sensor.itemCount}} items | {{sensor.status.name}}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-2" style="text-align: center !important">
|
<div class="ui-g-2" style="text-align: center !important">
|
||||||
|
|
|
@ -11,6 +11,7 @@ export class SensorListComponent implements OnChanges {
|
||||||
|
|
||||||
@Input() page: Page<Sensor>;
|
@Input() page: Page<Sensor>;
|
||||||
@Output() addSensor = new EventEmitter();
|
@Output() addSensor = new EventEmitter();
|
||||||
|
@Output() select = new EventEmitter<Sensor>();
|
||||||
|
|
||||||
totalLength: number;
|
totalLength: number;
|
||||||
targetSensors: Object;
|
targetSensors: Object;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<of-sensor-list [page]="page$ | async" (addSensor)="addSensor.emit($event)"></of-sensor-list>
|
<of-sensor-list [page]="page$ | async" (addSensor)="addSensor.emit($event)" (select)="select.emit($event)"></of-sensor-list>
|
|
@ -6,55 +6,60 @@ import {
|
||||||
RouterStateSnapshot,
|
RouterStateSnapshot,
|
||||||
Router,
|
Router,
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import { Store } from '@ngrx/store';
|
|
||||||
|
|
||||||
import { Observable } from 'rxjs/Observable';
|
|
||||||
import 'rxjs/add/operator/take';
|
|
||||||
import 'rxjs/add/operator/map';
|
|
||||||
|
|
||||||
|
import { Store, select } from '@ngrx/store';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { map, take } from 'rxjs/operators';
|
||||||
import { CookieService } from 'ngx-cookie-service';
|
import { CookieService } from 'ngx-cookie-service';
|
||||||
|
|
||||||
import * as AuthStore from '@overflow/member/store/auth';
|
import { AuthContainerSelector } from '@overflow/shared/auth/store';
|
||||||
import { AuthSelector } from '@overflow/member/store';
|
import * as MemberEntityStore from '@overflow/member/store/entity/member';
|
||||||
|
import * as SigninContaifnerStore from '../store/container/signin';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AuthGuard implements CanActivate, CanActivateChild {
|
export class AuthGuard implements CanActivate, CanActivateChild {
|
||||||
constructor(
|
constructor(
|
||||||
private store: Store<AuthStore.State>,
|
private store: Store<any>,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private cookieService: CookieService,
|
private cookieService: CookieService,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
|
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
|
||||||
return this.store
|
return this.store.pipe(
|
||||||
.select(AuthSelector.select('signined'))
|
select(AuthContainerSelector.selectSignined),
|
||||||
.map(signined => {
|
map(signined => {
|
||||||
if (!signined) {
|
if (!signined) {
|
||||||
if (this.cookieService.check('authToken')) {
|
if (this.cookieService.check('authToken')) {
|
||||||
this.store.dispatch(new AuthStore.SigninCookie({authToken: this.cookieService.get('authToken'), returnURL: state.url}));
|
this.store.dispatch(new MemberEntityStore.SigninCookie({authToken: this.cookieService.get('authToken'), returnURL: state.url}));
|
||||||
} else {
|
} else {
|
||||||
// this.store.dispatch(new AuthStore.SigninRedirect(state.url));
|
this.store.dispatch(new SigninContaifnerStore.SigninRedirect({returnURL: state.url}));
|
||||||
this.router.navigateByUrl(state.url);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
})
|
}),
|
||||||
.take(1);
|
take(1)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
canActivateChild(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
|
canActivateChild(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
|
||||||
return this.store
|
return this.store.pipe(
|
||||||
.select(AuthSelector.select('signined'))
|
select(AuthContainerSelector.selectSignined),
|
||||||
.map(signined => {
|
map(signined => {
|
||||||
if (!signined) {
|
if (!signined) {
|
||||||
this.store.dispatch(new AuthStore.SigninRedirect(state.url));
|
if (this.cookieService.check('authToken')) {
|
||||||
|
this.store.dispatch(new MemberEntityStore.SigninCookie({authToken: this.cookieService.get('authToken'), returnURL: state.url}));
|
||||||
|
} else {
|
||||||
|
this.store.dispatch(new SigninContaifnerStore.SigninRedirect({returnURL: state.url}));
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
})
|
}),
|
||||||
.take(1);
|
take(1)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
15
src/app/commons/store/container/signin/app-signin.action.ts
Normal file
15
src/app/commons/store/container/signin/app-signin.action.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import { Action } from '@ngrx/store';
|
||||||
|
|
||||||
|
export enum ActionType {
|
||||||
|
SigninRedirect = '[app.signin] SigninRedirect',
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SigninRedirect implements Action {
|
||||||
|
readonly type = ActionType.SigninRedirect;
|
||||||
|
|
||||||
|
constructor(public payload: {returnURL: string}) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Actions =
|
||||||
|
| SigninRedirect
|
||||||
|
;
|
|
@ -1,8 +1,8 @@
|
||||||
import { TestBed, inject } from '@angular/core/testing';
|
import { TestBed, inject } from '@angular/core/testing';
|
||||||
|
|
||||||
import { Effects } from './signin-init.effect';
|
import { Effects } from './app-signin.effect';
|
||||||
|
|
||||||
describe('SigninInit.Effects', () => {
|
describe('app-signin-container.Effects', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
providers: [Effects]
|
providers: [Effects]
|
72
src/app/commons/store/container/signin/app-signin.effect.ts
Normal file
72
src/app/commons/store/container/signin/app-signin.effect.ts
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
|
import { Effect, Actions, ofType } from '@ngrx/effects';
|
||||||
|
|
||||||
|
import { map, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
|
import { CookieService } from 'ngx-cookie-service';
|
||||||
|
import { RPCService } from '@loafer/ng-rpc';
|
||||||
|
|
||||||
|
import {
|
||||||
|
SigninSuccess,
|
||||||
|
SigninCookieSuccess,
|
||||||
|
ActionType as AuthActionType,
|
||||||
|
} from '@overflow/shared/auth/store/container/auth';
|
||||||
|
|
||||||
|
import {
|
||||||
|
SigninRedirect,
|
||||||
|
ActionType,
|
||||||
|
} from './app-signin.action';
|
||||||
|
|
||||||
|
import { DomainMember } from '@overflow/commons-typescript/model/domain';
|
||||||
|
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class Effects {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private actions$: Actions,
|
||||||
|
private rpcService: RPCService,
|
||||||
|
private cookieService: CookieService,
|
||||||
|
private router: Router
|
||||||
|
) { }
|
||||||
|
|
||||||
|
@Effect({ dispatch: false })
|
||||||
|
signinSuccess$ = this.actions$.pipe(
|
||||||
|
ofType(AuthActionType.SigninSuccess),
|
||||||
|
map((action: SigninSuccess) => action.payload),
|
||||||
|
tap((info: {authToken: string, domainMember: DomainMember, returnURL: string}) => {
|
||||||
|
const expires = new Date();
|
||||||
|
expires.setDate(expires.getDate() + 1);
|
||||||
|
this.cookieService.set('authToken', info.authToken, expires, '/');
|
||||||
|
const queryString = `authToken=${info.authToken}`;
|
||||||
|
this.rpcService.connect(queryString);
|
||||||
|
|
||||||
|
this.router.navigateByUrl(info.returnURL);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
@Effect({ dispatch: false })
|
||||||
|
signinCookieSuccess$ = this.actions$.pipe(
|
||||||
|
ofType(AuthActionType.SigninCookieSuccess),
|
||||||
|
map((action: SigninCookieSuccess) => action.payload),
|
||||||
|
tap((info: {domainMember: DomainMember, returnURL: string}) => {
|
||||||
|
const authToken = this.cookieService.get('authToken');
|
||||||
|
const queryString = `authToken=${authToken}`;
|
||||||
|
this.rpcService.connect(queryString);
|
||||||
|
|
||||||
|
this.router.navigateByUrl(info.returnURL);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
@Effect({ dispatch: false })
|
||||||
|
signinRedirect$ = this.actions$.pipe(
|
||||||
|
ofType(ActionType.SigninRedirect),
|
||||||
|
map((action: SigninRedirect) => action.payload),
|
||||||
|
tap((info: {returnURL: string}) => {
|
||||||
|
this.router.navigate(['/auth/signin'], {queryParams: {returnURL: info.returnURL}});
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
2
src/app/commons/store/container/signin/index.ts
Normal file
2
src/app/commons/store/container/signin/index.ts
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
export * from './app-signin.action';
|
||||||
|
export * from './app-signin.effect';
|
|
@ -1,6 +1,6 @@
|
||||||
import { ActionReducerMap } from '@ngrx/store';
|
import { ActionReducerMap } from '@ngrx/store';
|
||||||
|
|
||||||
import * as SigninInitStore from './signin-init';
|
import * as SigninContainerStore from './container/signin';
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
}
|
}
|
||||||
|
@ -9,5 +9,5 @@ export const REDUCERS: ActionReducerMap<State> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const EFFECTS = [
|
export const EFFECTS = [
|
||||||
SigninInitStore.Effects,
|
SigninContainerStore.Effects,
|
||||||
];
|
];
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
export * from './signin-init.effect';
|
|
|
@ -1,68 +0,0 @@
|
||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { Router } from '@angular/router';
|
|
||||||
|
|
||||||
import { Effect, Actions, ofType } from '@ngrx/effects';
|
|
||||||
import { Action } from '@ngrx/store';
|
|
||||||
|
|
||||||
import { Observable } from 'rxjs/Observable';
|
|
||||||
import { of } from 'rxjs/observable/of';
|
|
||||||
|
|
||||||
import 'rxjs/add/operator/catch';
|
|
||||||
import 'rxjs/add/operator/do';
|
|
||||||
import 'rxjs/add/operator/exhaustMap';
|
|
||||||
import 'rxjs/add/operator/switchMap';
|
|
||||||
import 'rxjs/add/operator/map';
|
|
||||||
import 'rxjs/add/operator/take';
|
|
||||||
|
|
||||||
import { CookieService } from 'ngx-cookie-service';
|
|
||||||
|
|
||||||
import { RPCService } from '@loafer/ng-rpc';
|
|
||||||
|
|
||||||
import {
|
|
||||||
SigninSuccess,
|
|
||||||
SigninCookieSuccess,
|
|
||||||
ActionType,
|
|
||||||
} from '@overflow/member/store/auth';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class Effects {
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private actions$: Actions,
|
|
||||||
private rpcService: RPCService,
|
|
||||||
private cookieService: CookieService,
|
|
||||||
) { }
|
|
||||||
|
|
||||||
@Effect({ dispatch: false })
|
|
||||||
signinSuccess$ = this.actions$
|
|
||||||
.ofType(ActionType.SigninSuccess)
|
|
||||||
.map((action: SigninSuccess) => action.payload)
|
|
||||||
.do(
|
|
||||||
(result) => {
|
|
||||||
const authToken = result.authToken;
|
|
||||||
// console.log(`authToken: ${authToken}`);
|
|
||||||
|
|
||||||
const expires = new Date();
|
|
||||||
expires.setDate(expires.getDate() + 1);
|
|
||||||
this.cookieService.set('authToken', authToken, expires, '/');
|
|
||||||
|
|
||||||
const queryString = `authToken=${authToken}`;
|
|
||||||
|
|
||||||
this.rpcService.connect(queryString);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
@Effect({ dispatch: false })
|
|
||||||
signinCookieSuccess$ = this.actions$
|
|
||||||
.ofType(ActionType.SigninCookieSuccess)
|
|
||||||
.map((action: SigninCookieSuccess) => action.payload)
|
|
||||||
.do(
|
|
||||||
(result) => {
|
|
||||||
const authToken = this.cookieService.get('authToken');
|
|
||||||
// console.log(`authToken: ${authToken}`);
|
|
||||||
const queryString = `authToken=${authToken}`;
|
|
||||||
|
|
||||||
this.rpcService.connect(queryString);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -3,7 +3,7 @@
|
||||||
<div class="ui-g-12">
|
<div class="ui-g-12">
|
||||||
<div class="card no-margin">
|
<div class="card no-margin">
|
||||||
<!--<of-discovery></of-discovery>-->
|
<!--<of-discovery></of-discovery>-->
|
||||||
<of-discovery-container (hostID)="hostId"></of-discovery-container>
|
<of-discovery-container [probeHostID]="probeHostID"></of-discovery-container>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { ActivatedRoute } from '@angular/router';
|
||||||
})
|
})
|
||||||
export class DiscoveryPageComponent implements OnInit {
|
export class DiscoveryPageComponent implements OnInit {
|
||||||
|
|
||||||
hostId: number;
|
probeHostID: number;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute
|
private route: ActivatedRoute
|
||||||
|
@ -15,8 +15,7 @@ export class DiscoveryPageComponent implements OnInit {
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.route.params.subscribe((params: any) => {
|
this.route.params.subscribe((params: any) => {
|
||||||
this.hostId = params['probeHostID'];
|
this.probeHostID = params['probeHostID'];
|
||||||
// console.log('probeHostID : ' + probeHostID);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { NgModule } from '@angular/core';
|
||||||
import { Routes, RouterModule } from '@angular/router';
|
import { Routes, RouterModule } from '@angular/router';
|
||||||
import { NoAuthProbePageComponent } from './noauth-probe-page.component';
|
import { NoAuthProbePageComponent } from './noauth-probe-page.component';
|
||||||
import { ProbeListComponent } from '@overflow/probe/component/list/list.component';
|
import { ProbeListComponent } from '@overflow/probe/component/list/list.component';
|
||||||
import { NoAuthProbeListComponent } from '@overflow/noauth-probe/component/list/list.component';
|
|
||||||
import { ProbeDownloadComponent } from '@overflow/probe/component/download/download.component';
|
import { ProbeDownloadComponent } from '@overflow/probe/component/download/download.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
<div *ngIf="!isDetail; else detailView">
|
<of-sensor-list-container *ngIf="containerType === 1" (select)="onSensorSelect($event)" (addSensor)="onAddSensor($event)">
|
||||||
<of-sensor-list-container *ngIf="router.url === '/sensor/list'" (select)="onSensorSelect($event)" (addSensor)="onAddSensor($event)"> </of-sensor-list-container>
|
</of-sensor-list-container>
|
||||||
<of-sensor-setting-container *ngIf="router.url === '/sensor/setting'"></of-sensor-setting-container>
|
<of-sensor-detail-container *ngIf="containerType === 2"></of-sensor-detail-container>
|
||||||
</div>
|
<of-sensor-setting-container *ngIf="containerType === 3"></of-sensor-setting-container>
|
||||||
|
|
||||||
<ng-template #detailView>
|
|
||||||
<of-sensor-detail-container></of-sensor-detail-container>
|
|
||||||
</ng-template>
|
|
|
@ -4,13 +4,19 @@ import { Sensor } from '@overflow/commons-typescript/model/sensor';
|
||||||
import { BreadcrumbService } from '@app/commons/service/breadcrumb.service';
|
import { BreadcrumbService } from '@app/commons/service/breadcrumb.service';
|
||||||
import { Target } from '@overflow/commons-typescript/model/target';
|
import { Target } from '@overflow/commons-typescript/model/target';
|
||||||
|
|
||||||
|
enum CONTAINER_TYPES {
|
||||||
|
List = 1,
|
||||||
|
Detail,
|
||||||
|
Setting,
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'of-pages-sensor',
|
selector: 'of-pages-sensor',
|
||||||
templateUrl: './sensor-page.component.html',
|
templateUrl: './sensor-page.component.html',
|
||||||
})
|
})
|
||||||
export class SensorPageComponent {
|
export class SensorPageComponent {
|
||||||
|
|
||||||
isDetail: boolean;
|
containerType: CONTAINER_TYPES;
|
||||||
sensorID: string;
|
sensorID: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -31,7 +37,11 @@ export class SensorPageComponent {
|
||||||
this.breadcrumbService.setItems([
|
this.breadcrumbService.setItems([
|
||||||
{ label: 'Sensor', routerLink: ['/sensor/list'], }
|
{ label: 'Sensor', routerLink: ['/sensor/list'], }
|
||||||
]);
|
]);
|
||||||
this.isDetail = false;
|
if (this.router.url === '/sensor/list') {
|
||||||
|
this.containerType = CONTAINER_TYPES.List;
|
||||||
|
} else {
|
||||||
|
this.containerType = CONTAINER_TYPES.Setting;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onDetailContainer(sensorID: string) {
|
onDetailContainer(sensorID: string) {
|
||||||
|
@ -40,7 +50,7 @@ export class SensorPageComponent {
|
||||||
{ label: 'Sensor', routerLink: ['/sensor/list'] },
|
{ label: 'Sensor', routerLink: ['/sensor/list'] },
|
||||||
{ label: this.sensorID }
|
{ label: this.sensorID }
|
||||||
]);
|
]);
|
||||||
this.isDetail = true;
|
this.containerType = CONTAINER_TYPES.Detail;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSensorSelect(sensor: Sensor) {
|
onSensorSelect(sensor: Sensor) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user