Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* Copyright (c) 2018, RTE (http://www.rte-france.com)
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import {createFeatureSelector, createSelector} from '@ngrx/store';
import * as fromCardOperations from './card-operation.reducer';
import {State as CardOperationsState} from './card-operation.reducer';
export const getCardOperationsState =
createFeatureSelector( 'cardOperation');
export const {
selectIds: getCardOperationIds,
selectAll: getAllCardOperations,
selectEntities: getCardOperationEntities
} = fromCardOperations.adapter.getSelectors(getCardOperationsState);
export const getSelectedCardOperationId = createSelector(
getCardOperationsState,
fromCardOperations.getSelectedId
);
export const getSelectedCardOperation = createSelector(
getSelectedCardOperationId,
getCardOperationEntities,
import { Injectable } from '@angular/core';
import { Store, createFeatureSelector, createSelector } from '@ngrx/store';
import { App } from '../../core';
import { AppState } from './reducer';
import { distinctUntilChanged, tap } from 'rxjs/operators';
import { initialState } from './reducer';
const getAppState = createFeatureSelector('appConfig');
// The following selector implementation guards against empty session state
// as happens when replay with redux dev tools
const getDataSource = createSelector(getAppState, (state: AppState) => (state ? state.session.dataSource : initialState.dataSource));
@Injectable()
export class AppSelectors {
constructor(private store: Store) {}
get dataSource$() {
return this.store.select(getDataSource).pipe(distinctUntilChanged());
}
}
view: fromViewUser.ViewUserState;
delete: fromDeleteUser.DeleteUserState
}
export const reducers: ActionReducerMap = {
load: fromLoadUsers.reducer,
create: fromCreateUser.reducer,
update: fromUpdateUser.reducer,
view: fromViewUser.reducer,
delete: fromDeleteUser.reducer
}
export const combinedReducers = combineReducers(reducers);
// Main Access User State
export const getAccessUserState = createFeatureSelector('accessUser');
// Load User States
export const getLoadUsersState = createSelector(getAccessUserState, (state: AccessUserState) => state.load);
export const getLoadUsersLoading = createSelector(getLoadUsersState, fromLoadUsers.getLoadUsersLoading);
export const getLoadUsersLoaded = createSelector(getLoadUsersState, fromLoadUsers.getLoadUsersLoaded);
export const getLoadUsersFailed = createSelector(getLoadUsersState, fromLoadUsers.getLoadUsersFailed);
export const getLoadUsersError = createSelector(getLoadUsersState, fromLoadUsers.getLoadUsersError);
export const getLoadUsersData = createSelector(getLoadUsersState, fromLoadUsers.getLoadUsersData);
// Create User States
export const getCreateUserState = createSelector(getAccessUserState, (state: AccessUserState) => state.create);
export const getCreateUserLoading = createSelector(getCreateUserState, fromCreateUser.getCreateUserLoading);
export const getCreateUserLoaded = createSelector(getCreateUserState, fromCreateUser.getCreateUserLoaded);
export const getCreateUserFailed = createSelector(getCreateUserState, fromCreateUser.getCreateUserFailed);
export const getCreateUserError = createSelector(getCreateUserState, fromCreateUser.getCreateUserError);
export const getCreatedUser = createSelector(getCreateUserState, fromCreateUser.getCreatedUser);
// additional entities state properties
currentId: string | null;
projectIdForLoadedRelatedData: string;
}
const sortByTitle = (p1: Project, p2: Project) => {
return p1.title.localeCompare(p2.title);
};
export const projectAdapter: EntityAdapter = createEntityAdapter({
// sortComparer: sortByTitle,
});
// SELECTORS
// ---------
export const selectProjectFeatureState = createFeatureSelector(PROJECT_FEATURE_NAME);
const {selectIds, selectEntities, selectAll, selectTotal} = projectAdapter.getSelectors();
export const selectCurrentProjectId = createSelector(selectProjectFeatureState, state => state.currentId);
export const selectProjectEntities = createSelector(selectProjectFeatureState, selectEntities);
export const selectAllProjects = createSelector(selectProjectFeatureState, selectAll);
export const selectUnarchivedProjects = createSelector(selectAllProjects, (projects) => projects.filter(p => !p.isArchived));
export const selectUnarchivedProjectsWithoutCurrent = createSelector(
selectProjectFeatureState,
(s) => {
const ids = s.ids as string[];
return ids.filter(id => id !== s.currentId).map(id => s.entities[id]).filter(p => !p.isArchived && p.id);
},
);
export const selectArchivedProjects = createSelector(selectAllProjects, (projects) => projects.filter(p => p.isArchived));
export const selectIsRelatedDataLoadedForCurrentProject = createSelector(
selectProjectFeatureState,
gameInvites: Game[]
userAnsweredQuestion: any,
saveReportQuestion: string
}
export const reducer: ActionReducerMap = {
currentGame: currentGame,
newGameId: newGameId,
currentGameQuestion: currentGameQuestion,
updateGame: updateGame,
gameInvites: gameInvites,
userAnsweredQuestion: userAnsweredQuestion,
saveReportQuestion: saveReportQuestion
};
export const gameplayState = createFeatureSelector('gameplay');
import { RouterReducerState } from '@ngrx/router-store';
import { createFeatureSelector, createSelector } from '@ngrx/store';
import { RouterStateUrl } from './router.interface';
export const selectReducerState = createFeatureSelector<
RouterReducerState
>('routerState');
export const getRouterInfo = createSelector(
selectReducerState,
state => state && state.state,
);
export const getRouterLanguage = createSelector(
getRouterInfo,
state => state && state.params && state.params.language,
);
...state,
...action.payload
};
}
case MetadataActions.RESET: {
return initialState;
}
default: {
return state;
}
}
}
export const selectMetadataState = createFeatureSelector(
'metadataState'
);
import {createFeatureSelector, createSelector} from '@ngrx/store';
import {LineChartData, Metric, MetricState, PieChartData} from '../metric.model';
import {sortWorklogDates} from '../../../util/sortWorklogDates';
import {METRIC_FEATURE_NAME, metricAdapter} from './metric.reducer';
import {
selectAllImprovementIds,
selectImprovementFeatureState,
selectRepeatedImprovementIds
} from '../improvement/store/improvement.reducer';
import {Improvement, ImprovementState} from '../improvement/improvement.model';
import {selectAllObstructionIds, selectObstructionFeatureState} from '../obstruction/store/obstruction.reducer';
import {ObstructionState} from '../obstruction/obstruction.model';
import {unique} from '../../../util/unique';
export const selectMetricFeatureState = createFeatureSelector(METRIC_FEATURE_NAME);
export const {selectIds, selectEntities, selectAll, selectTotal} = metricAdapter.getSelectors();
export const selectAllMetrics = createSelector(selectMetricFeatureState, selectAll);
export const selectLastTrackedMetric = createSelector(selectMetricFeatureState, (state: MetricState) => {
const ids = state.ids as string[];
const sorted = sortWorklogDates(ids);
const id = sorted[sorted.length - 1];
return state.entities[id];
});
export const selectMetricHasData = createSelector(selectMetricFeatureState, (state) => state && !!state.ids.length);
export const selectImprovementBannerImprovements = createSelector(
selectLastTrackedMetric,
selectImprovementFeatureState,
selectRepeatedImprovementIds,
(metric: Metric, improvementState: ImprovementState, repeatedImprovementIds: string[]): Improvement[] => {
export const getSwapState = createFeatureSelector('swap');
export const getInitiateError = createSelector(getSwapState,
fromSwap.getInititeError);
export const getInitiateLoading = createSelector(getSwapState,
fromSwap.getInitiateLoading);
export const getInitiateData = createSelector(getSwapState,
fromSwap.getInitiateData);
export const getSwapCoins = createSelector(getSwapState,
fromSwap.getSwapCoins);
export const getAuditState = createFeatureSelector('audit');
export const getAuditData = createSelector(getAuditState
, fromAudit.getAuditData);
export const getAuditLoading = createSelector(getAuditState
, fromAudit.getAuditLoading);
export interface BillingState {
billing: fromBilling.State;
}
export interface State {
billing: BillingState
}
export const reducers : ActionReducerMap = {
billing: fromBilling.reducer
}
/**
* Billing State
*/
export const selectBillingState: MemoizedSelector = createFeatureSelector('billing');
export const billingStateSelector = createSelector(
selectBillingState,
(state: BillingState) => state.billing
)
export const selectBillingAddressState: MemoizedSelector = createSelector(
billingStateSelector,
fromBilling.getBillingAddress
)
export const selectBillingAddressIsShippingAddressState: MemoizedSelector = createSelector(
billingStateSelector,
fromBilling.getBillingAddressIsShippingAddress
)