sensor store bug T T
This commit is contained in:
parent
ed245412a1
commit
740e245cd7
|
@ -3,7 +3,9 @@
|
||||||
<of-discovery-search-config (discoverySearchStartClick)="onDiscoveryStart()"></of-discovery-search-config>
|
<of-discovery-search-config (discoverySearchStartClick)="onDiscoveryStart()"></of-discovery-search-config>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-12 ui-md-9">
|
<div class="ui-g-12 ui-md-9">
|
||||||
bb
|
<div *ngIf="selectedProbe">
|
||||||
|
SELECTED_PROBE_DISPLAY_NAME : {{selectedProbe.probe.displayName}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
<of-probe-selector-container [probeHostID]="probeHostID" (select)="selectedProbe = $event"></of-probe-selector-container>
|
<of-probe-selector-container [probeHostID]="probeHostID" (select)="onProbeSelect($event)"></of-probe-selector-container>
|
||||||
<of-discovery [selectedProbe]="selectedProbe"></of-discovery>
|
<of-discovery [selectedProbe]="selectedProbe"></of-discovery>
|
||||||
|
|
|
@ -17,4 +17,8 @@ export class DiscoveryContainerComponent {
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onProbeSelect(probe: ProbeHost) {
|
||||||
|
this.selectedProbe = probe;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<div *ngIf="probeHostID else dropdown"></div>
|
<div *ngIf="!probeHostID">
|
||||||
<ng-template #dropdown>
|
|
||||||
<p-dropdown *ngIf="options.length > 0" [options]="options" [(ngModel)]="selected" optionLabel="displayName" placeholder="Select a Probe"
|
<p-dropdown *ngIf="options.length > 0" [options]="options" [(ngModel)]="selected" optionLabel="displayName" placeholder="Select a Probe"
|
||||||
(onChange)="onSelect($event.data)"></p-dropdown>
|
(onChange)="onSelect($event.value)"></p-dropdown>
|
||||||
</ng-template>
|
</div>
|
|
@ -17,7 +17,6 @@ export class ProbeSelectorComponent implements OnInit, OnChanges {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.onPreselected();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
@ -25,14 +24,17 @@ export class ProbeSelectorComponent implements OnInit, OnChanges {
|
||||||
for (const ph of this.probeHosts) {
|
for (const ph of this.probeHosts) {
|
||||||
this.options.push(ph.probe);
|
this.options.push(ph.probe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (changes['probeHosts'] !== null && changes['probeHosts'].currentValue.length > 0) {
|
||||||
|
this.checkPreselected();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onPreselected() {
|
checkPreselected() {
|
||||||
if (this.probeHostID) {
|
alert(this.probeHosts.length);
|
||||||
const preselected: ProbeHost = this.probeHosts.find(probeHost => probeHost.id === this.probeHostID);
|
const preselected: ProbeHost = this.probeHosts.find(probeHost => probeHost.id === this.probeHostID);
|
||||||
this.select.emit(preselected);
|
this.select.emit(preselected);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
onSelect(probe: Probe) {
|
onSelect(probe: Probe) {
|
||||||
const optionselected = this.probeHosts.find(probeHost => probeHost.id === probe.id);
|
const optionselected = this.probeHosts.find(probeHost => probeHost.id === probe.id);
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Observable } from 'rxjs';
|
||||||
import { Store, select } from '@ngrx/store';
|
import { Store, select } from '@ngrx/store';
|
||||||
import { Sensor } from '@overflow/commons-typescript/model/sensor';
|
import { Sensor } from '@overflow/commons-typescript/model/sensor';
|
||||||
import * as SensorEntityStore from '../store/entity/sensor';
|
import * as SensorEntityStore from '../store/entity/sensor';
|
||||||
import { SensorEntitySelector, SensorPageSelector } from '../store';
|
import { SensorListContainerSelector } from '../store';
|
||||||
import { AuthContainerSelector } from '@overflow/shared/auth/store';
|
import { AuthContainerSelector } from '@overflow/shared/auth/store';
|
||||||
import { PageParams } from '@overflow/commons-typescript/model/commons/PageParams';
|
import { PageParams } from '@overflow/commons-typescript/model/commons/PageParams';
|
||||||
import { Page } from '@overflow/commons-typescript/model/commons/Page';
|
import { Page } from '@overflow/commons-typescript/model/commons/Page';
|
||||||
|
@ -17,15 +17,19 @@ import { DomainMember } from '@overflow/commons-typescript/model/domain';
|
||||||
export class SensorListContainerComponent implements OnInit {
|
export class SensorListContainerComponent implements OnInit {
|
||||||
|
|
||||||
page$: Observable<Page<Sensor>>;
|
page$: Observable<Page<Sensor>>;
|
||||||
|
pending$: Observable<boolean>;
|
||||||
@Output() select = new EventEmitter<Sensor>();
|
@Output() select = new EventEmitter<Sensor>();
|
||||||
@Output() addSensor = new EventEmitter();
|
@Output() addSensor = new EventEmitter();
|
||||||
pageNo: number;
|
pageNo: number;
|
||||||
|
|
||||||
constructor(private store: Store<any>) {
|
constructor(private store: Store<any>) {
|
||||||
|
this.pageNo = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.page$ = this.store.pipe(select(SensorPageSelector));
|
this.page$ = this.store.pipe(select(SensorListContainerSelector.selectPage));
|
||||||
|
// this.page$ = this.store.pipe(select(SensorListContainerSelector.selectPage));
|
||||||
|
|
||||||
this.getSensors();
|
this.getSensors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { Observable } from 'rxjs';
|
||||||
import { Store, select } from '@ngrx/store';
|
import { Store, select } from '@ngrx/store';
|
||||||
import { Sensor } from '@overflow/commons-typescript/model/sensor';
|
import { Sensor } from '@overflow/commons-typescript/model/sensor';
|
||||||
import * as SensorEntityStore from '../store/entity/sensor';
|
import * as SensorEntityStore from '../store/entity/sensor';
|
||||||
import { SensorEntitySelector } from '../store';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'of-sensor-setting-container',
|
selector: 'of-sensor-setting-container',
|
||||||
|
|
|
@ -6,7 +6,6 @@ import {
|
||||||
RouterStateSerializer,
|
RouterStateSerializer,
|
||||||
} from '@ngrx/router-store';
|
} from '@ngrx/router-store';
|
||||||
import { EffectsModule } from '@ngrx/effects';
|
import { EffectsModule } from '@ngrx/effects';
|
||||||
import { combineReducers, ActionReducer, ActionReducerMap, MetaReducer } from '@ngrx/store';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
REDUCERS,
|
REDUCERS,
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
export const MODULE = {
|
export const MODULE = {
|
||||||
name: 'Sensor'
|
name: 'sensor'
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,23 +5,21 @@ import {
|
||||||
sensorListContainerAdapter,
|
sensorListContainerAdapter,
|
||||||
} from './sensor-list.state';
|
} from './sensor-list.state';
|
||||||
|
|
||||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
|
||||||
|
|
||||||
export function reducer(state = initialState, action: Actions): State {
|
export function reducer(state = initialState, action: Actions): State {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case ActionType.ReadAllByDomainID: {
|
case ActionType.ReadAllByDomainID: {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
error: null,
|
pending: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case ActionType.ReadAllByDomainIDSuccess: {
|
case ActionType.ReadAllByDomainIDSuccess: {
|
||||||
return sensorListContainerAdapter.setAll(action.payload.content, {...state, page: action.payload});
|
return sensorListContainerAdapter.setAll(action.payload.content, {...state, page: action.payload, pending: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
case ActionType.ReadAllByDomainIDFailure: {
|
case ActionType.ReadAllByDomainIDFailure: {
|
||||||
return sensorListContainerAdapter.setError(action.payload, state);
|
return sensorListContainerAdapter.setError(action.payload, {...state, page: null, pending: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
case ActionType.Read: {
|
case ActionType.Read: {
|
||||||
|
@ -32,11 +30,11 @@ export function reducer(state = initialState, action: Actions): State {
|
||||||
}
|
}
|
||||||
|
|
||||||
case ActionType.ReadSuccess: {
|
case ActionType.ReadSuccess: {
|
||||||
return sensorListContainerAdapter.setOne(action.payload, {...state, page: null});
|
return sensorListContainerAdapter.setOne(action.payload, {...state, page: null, pending: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
case ActionType.ReadFailure: {
|
case ActionType.ReadFailure: {
|
||||||
return sensorListContainerAdapter.setError(action.payload, state);
|
return sensorListContainerAdapter.setError(action.payload, {...state, pending: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
case ActionType.Modify: {
|
case ActionType.Modify: {
|
||||||
|
|
|
@ -19,5 +19,8 @@ export function getSelectors(selector: Selector<any, State>) {
|
||||||
return {
|
return {
|
||||||
...sensorListContainerAdapter.getSelectors(selector),
|
...sensorListContainerAdapter.getSelectors(selector),
|
||||||
selectPending: createSelector(selector, (state: State) => state.pending),
|
selectPending: createSelector(selector, (state: State) => state.pending),
|
||||||
|
selectPage: createSelector(selector, (state: State) => {
|
||||||
|
return state.page;
|
||||||
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ export interface State {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const REDUCERS = {
|
export const REDUCERS = {
|
||||||
sensor: SensorListContainerStore.reducer,
|
sensor_list: SensorListContainerStore.reducer,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const EFFECTS = [
|
export const EFFECTS = [
|
||||||
|
@ -22,12 +22,9 @@ export const EFFECTS = [
|
||||||
|
|
||||||
export const selectState = createFeatureSelector<State>(MODULE.name);
|
export const selectState = createFeatureSelector<State>(MODULE.name);
|
||||||
|
|
||||||
export const SensorEntitySelector = SensorListContainerStore.getSelectors(createSelector(
|
export const SensorListContainerSelector = SensorListContainerStore.getSelectors(createSelector(
|
||||||
selectState,
|
selectState,
|
||||||
(state: State) => state.sensor_list
|
(state: State) => {
|
||||||
|
return state.sensor_list;
|
||||||
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
export const SensorPageSelector = createSelector(
|
|
||||||
selectState,
|
|
||||||
(state: State) => state.sensor_list.page
|
|
||||||
);
|
|
||||||
|
|
3636
package-lock.json
generated
3636
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user