This file contains hidden or 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
const avgSize = 20; | |
const scrollOffset = 225; | |
function measureRangeSize({ start, end }) { | |
const size = 15; | |
return (start + end) * size; | |
} | |
function getOffset(range, index) { | |
const isInView = index > range.start && index < range.end; |
This file contains hidden or 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
@NgModule({ | |
imports: [ | |
NgxsModule.forRoot([]), | |
NgxsStoragePluginModule.forRoot({ | |
migrations: [ | |
{ | |
version: 1, | |
key: 'zoo', | |
versionKey: 'myVersion', | |
migrate: (state) => { |
This file contains hidden or 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
const reduxAdapter = (middleware) => { | |
return (state, action, next) => { | |
const storeAdapter = { | |
getState: () => { | |
return state; | |
} | |
}; | |
const nextAdapter = (fn) => { | |
const result = next(state, fn); |
This file contains hidden or 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
@Component({ | |
selector: 'app' | |
}) | |
export class AppComponent { | |
constructor(private actions: Actions, private router: Router) {} | |
ngOnInit() { | |
this.actions.pipe(ofActionDispatched(Logout)).subscribe(() => this.router.navigate(['/login'])); | |
} |
This file contains hidden or 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
export const routes: Routes = [ | |
{ | |
path: 'admin', | |
loadChildren: './admin/admin.module#AdminModule', | |
canActivate: [AuthGuard] | |
} | |
]; |
This file contains hidden or 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
@Injectable() | |
export class AuthGuard implements CanActivate { | |
constructor(private store: Store) {} | |
canActivate() { | |
return this.store.select(AuthState.token); | |
} | |
} |
This file contains hidden or 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
@NgModule({ | |
imports: [ | |
NgxsModule.forRoot([AuthState]), | |
NgxsStoragePluginModule.forRoot({ | |
keys: 'auth.token' | |
}) | |
] | |
}) | |
export class AppModule {} |
This file contains hidden or 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
@State<AuthStateModel>({ | |
name: 'auth' | |
}) | |
export class AuthState { | |
@Selector() | |
static token(state: AuthStateModel) { return state.token; } | |
constructor(private authService: AuthService) {} |
This file contains hidden or 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
export class AuthStateModel { | |
token: string; | |
username: string; | |
} | |
export class Login { | |
static readonly type = '[Auth] Login'; | |
constructor(public payload: { username: string, password: string }) {} | |
} |
This file contains hidden or 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
import { Directive, AfterContentInit, ContentChildren, QueryList, Output, EventEmitter, Inject, forwardRef } from '@angular/core'; | |
import { GridResizeHandleComponent } from './grid-resize-handle.component'; | |
import { GridHeaderCellComponent } from '../cell/grid-header-cell.component'; | |
import { ColumnWidthHelper } from '../../column-width'; | |
import { GridHeaderRowComponent } from '../grid-header-row.component'; | |
@Directive({ | |
selector: '[dfGridResize]' | |
}) | |
export class GridResizeDirective implements AfterContentInit { |