sensor store bug T T

This commit is contained in:
insanity 2018-05-29 13:13:28 +09:00
parent ed245412a1
commit 740e245cd7
13 changed files with 1857 additions and 1850 deletions

View File

@ -3,7 +3,9 @@
<of-discovery-search-config (discoverySearchStartClick)="onDiscoveryStart()"></of-discovery-search-config>
</div>
<div class="ui-g-12 ui-md-9">
bb
<div *ngIf="selectedProbe">
SELECTED_PROBE_DISPLAY_NAME : {{selectedProbe.probe.displayName}}
</div>
</div>
</div>

View File

@ -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>

View File

@ -17,4 +17,8 @@ export class DiscoveryContainerComponent {
) {
}
onProbeSelect(probe: ProbeHost) {
this.selectedProbe = probe;
}
}

View File

@ -1,5 +1,4 @@
<div *ngIf="probeHostID else dropdown"></div>
<ng-template #dropdown>
<div *ngIf="!probeHostID">
<p-dropdown *ngIf="options.length > 0" [options]="options" [(ngModel)]="selected" optionLabel="displayName" placeholder="Select a Probe"
(onChange)="onSelect($event.data)"></p-dropdown>
</ng-template>
(onChange)="onSelect($event.value)"></p-dropdown>
</div>

View File

@ -17,7 +17,6 @@ export class ProbeSelectorComponent implements OnInit, OnChanges {
}
ngOnInit() {
this.onPreselected();
}
ngOnChanges(changes: SimpleChanges): void {
@ -25,14 +24,17 @@ export class ProbeSelectorComponent implements OnInit, OnChanges {
for (const ph of this.probeHosts) {
this.options.push(ph.probe);
}
if (changes['probeHosts'] !== null && changes['probeHosts'].currentValue.length > 0) {
this.checkPreselected();
}
}
onPreselected() {
if (this.probeHostID) {
checkPreselected() {
alert(this.probeHosts.length);
const preselected: ProbeHost = this.probeHosts.find(probeHost => probeHost.id === this.probeHostID);
this.select.emit(preselected);
}
}
onSelect(probe: Probe) {
const optionselected = this.probeHosts.find(probeHost => probeHost.id === probe.id);

View File

@ -3,7 +3,7 @@ import { Observable } from 'rxjs';
import { Store, select } from '@ngrx/store';
import { Sensor } from '@overflow/commons-typescript/model/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 { PageParams } from '@overflow/commons-typescript/model/commons/PageParams';
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 {
page$: Observable<Page<Sensor>>;
pending$: Observable<boolean>;
@Output() select = new EventEmitter<Sensor>();
@Output() addSensor = new EventEmitter();
pageNo: number;
constructor(private store: Store<any>) {
this.pageNo = 0;
}
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();
}

View File

@ -3,7 +3,6 @@ import { Observable } from 'rxjs';
import { Store, select } from '@ngrx/store';
import { Sensor } from '@overflow/commons-typescript/model/sensor';
import * as SensorEntityStore from '../store/entity/sensor';
import { SensorEntitySelector } from '../store';
@Component({
selector: 'of-sensor-setting-container',

View File

@ -6,7 +6,6 @@ import {
RouterStateSerializer,
} from '@ngrx/router-store';
import { EffectsModule } from '@ngrx/effects';
import { combineReducers, ActionReducer, ActionReducerMap, MetaReducer } from '@ngrx/store';
import {
REDUCERS,

View File

@ -1,3 +1,3 @@
export const MODULE = {
name: 'Sensor'
name: 'sensor'
};

View File

@ -5,23 +5,21 @@ import {
sensorListContainerAdapter,
} from './sensor-list.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,
pending: true,
};
}
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: {
return sensorListContainerAdapter.setError(action.payload, state);
return sensorListContainerAdapter.setError(action.payload, {...state, page: null, pending: false});
}
case ActionType.Read: {
@ -32,11 +30,11 @@ export function reducer(state = initialState, action: Actions): State {
}
case ActionType.ReadSuccess: {
return sensorListContainerAdapter.setOne(action.payload, {...state, page: null});
return sensorListContainerAdapter.setOne(action.payload, {...state, page: null, pending: false});
}
case ActionType.ReadFailure: {
return sensorListContainerAdapter.setError(action.payload, state);
return sensorListContainerAdapter.setError(action.payload, {...state, pending: false});
}
case ActionType.Modify: {

View File

@ -19,5 +19,8 @@ export function getSelectors(selector: Selector<any, State>) {
return {
...sensorListContainerAdapter.getSelectors(selector),
selectPending: createSelector(selector, (state: State) => state.pending),
selectPage: createSelector(selector, (state: State) => {
return state.page;
})
};
}

View File

@ -13,7 +13,7 @@ export interface State {
}
export const REDUCERS = {
sensor: SensorListContainerStore.reducer,
sensor_list: SensorListContainerStore.reducer,
};
export const EFFECTS = [
@ -22,12 +22,9 @@ export const EFFECTS = [
export const selectState = createFeatureSelector<State>(MODULE.name);
export const SensorEntitySelector = SensorListContainerStore.getSelectors(createSelector(
export const SensorListContainerSelector = SensorListContainerStore.getSelectors(createSelector(
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

File diff suppressed because it is too large Load Diff