-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added dbxAppContextStateModule, dbxAppAuthRouterModule
- Updated demo to use these new modules
- Loading branch information
Showing
61 changed files
with
854 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
apps/demo/src/app/modules/demo/modules/app/container/layout.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
<ui-view></ui-view> | ||
<ng-container dbxAppContextState="app"> | ||
<ui-view></ui-view> | ||
</ng-container> |
2 changes: 1 addition & 1 deletion
2
apps/demo/src/app/modules/demo/modules/auth/container/layout.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/demo/src/app/modules/demo/modules/onboard/container/layout.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
apps/demo/src/app/modules/doc/modules/action/container/layout.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
apps/demo/src/app/modules/doc/modules/auth/container/layout.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
apps/demo/src/app/modules/doc/modules/form/container/layout.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
apps/demo/src/app/modules/doc/modules/interaction/container/layout.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
apps/demo/src/app/modules/doc/modules/layout/container/layout.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
apps/demo/src/app/modules/doc/modules/router/container/layout.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
apps/demo/src/app/modules/landing/container/layout.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { | ||
ActionReducer, | ||
createReducer, | ||
MetaReducer | ||
} from '@ngrx/store'; | ||
import { environment } from '../../environments/environment'; | ||
|
||
// tslint:disable-next-line: no-empty-interface | ||
export interface State { | ||
// None | ||
} | ||
|
||
export const initialState: State = {}; | ||
|
||
export const ROOT_REDUCER = createReducer( | ||
initialState | ||
); | ||
|
||
// console.log all actions | ||
export function logger(reducer: ActionReducer<State>): ActionReducer<State> { | ||
return (state, action) => { | ||
const result = reducer(state, action); | ||
console.groupCollapsed(action.type); | ||
console.log('prev state', state); | ||
console.log('action', action); | ||
console.log('next state', result); | ||
console.groupEnd(); | ||
return result; | ||
}; | ||
} | ||
|
||
/** | ||
* By default, @ngrx/store uses combineReducers with the reducer map to compose | ||
* the root meta-reducer. To add more meta-reducers, provide an array of meta-reducers | ||
* that will be composed to form the root meta-reducer. | ||
*/ | ||
export const metaReducers: MetaReducer<State>[] = !environment.production | ||
? [logger] | ||
: []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { EntityMetadataMap, EntityDataModuleConfig } from '@ngrx/data'; | ||
|
||
const entityMetadata: EntityMetadataMap = {}; | ||
|
||
const pluralNames = { }; | ||
|
||
export const entityConfig: EntityDataModuleConfig = { | ||
entityMetadata, | ||
pluralNames | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { fromDbxAppAuth } from './state'; | ||
import { NgModule } from '@angular/core'; | ||
import { EffectsModule } from '@ngrx/effects'; | ||
import { StoreModule } from '@ngrx/store'; | ||
import { DbxAppAuthEffects } from './state/effect/auth.effect'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
StoreModule.forFeature(fromDbxAppAuth.featureKey, fromDbxAppAuth.reducers), | ||
EffectsModule.forFeature([DbxAppAuthEffects]) | ||
], | ||
declarations: [], | ||
exports: [] | ||
}) | ||
export class DbxAppAuthStateModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Injectable } from "@angular/core"; | ||
import { Store } from "@ngrx/store"; | ||
import { fromDbxAppAuth } from './state'; | ||
import { DbxAppAuthFullState } from "./state/state"; | ||
|
||
|
||
/** | ||
* State for accessing the app's DbxAppAuthState defined within the DbxAppAuthFullState for the ngrx store. | ||
*/ | ||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class DbxAppAuthStateService { | ||
|
||
readonly authStateUser$ = this.store.select(fromDbxAppAuth.selectDbxAppAuthUser); | ||
|
||
constructor(readonly store: Store<DbxAppAuthFullState>) { } | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Maybe } from "@dereekb/util"; | ||
|
||
|
||
/** | ||
* An application user state. | ||
* | ||
* Generic states that define the current state of the user: | ||
* - none: the user is not logged in | ||
* - anon: the user is logged in as an anonymous account | ||
* - error: there was an error loading the correct user state | ||
* - new: the user has a full account but has not completed onboarding/setup | ||
* - user: the user has a full account and has completed setup | ||
*/ | ||
export type AuthUserState = 'none' | 'anon' | 'new' | 'user' | 'error'; | ||
|
||
/** | ||
* Arbitrary identifier used to differentiate users. | ||
*/ | ||
export type AuthUserIdentifier = string; | ||
|
||
export const NO_AUTH_USER_IDENTIFIER = '0'; | ||
|
||
/** | ||
* AuthUserIdentifier used to indicate that the user cannot be uniquely identifier. | ||
*/ | ||
export type NoAuthUserIdentifier = typeof NO_AUTH_USER_IDENTIFIER; | ||
|
||
|
||
/** | ||
* Creates an AuthUserIdentifier from the input. If the input is undefined, returns the NoAuthUserIdentifier. | ||
* | ||
* @param inputId | ||
* @returns | ||
*/ | ||
export function authUserIdentifier(inputId: Maybe<AuthUserIdentifier>): AuthUserIdentifier { | ||
return (inputId) ? inputId : NO_AUTH_USER_IDENTIFIER; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
export * from './router'; | ||
export * from './service'; | ||
export * from './auth.state'; | ||
export * from './auth.user'; | ||
export * from './auth.role'; | ||
export * from './auth.module'; | ||
export * from './auth.role.any.directive'; | ||
export * from './auth.role.has.directive'; | ||
export * from './auth.state.module'; | ||
export * from './auth.state.service'; |
Oops, something went wrong.