Skip to content

Instantly share code, notes, and snippets.

View amcdnl's full-sized avatar

Austin amcdnl

View GitHub Profile
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;
@NgModule({
imports: [
NgxsModule.forRoot([]),
NgxsStoragePluginModule.forRoot({
migrations: [
{
version: 1,
key: 'zoo',
versionKey: 'myVersion',
migrate: (state) => {
const reduxAdapter = (middleware) => {
return (state, action, next) => {
const storeAdapter = {
getState: () => {
return state;
}
};
const nextAdapter = (fn) => {
const result = next(state, fn);
@Component({
selector: 'app'
})
export class AppComponent {
constructor(private actions: Actions, private router: Router) {}
ngOnInit() {
this.actions.pipe(ofActionDispatched(Logout)).subscribe(() => this.router.navigate(['/login']));
}
export const routes: Routes = [
{
path: 'admin',
loadChildren: './admin/admin.module#AdminModule',
canActivate: [AuthGuard]
}
];
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private store: Store) {}
canActivate() {
return this.store.select(AuthState.token);
}
}
@NgModule({
imports: [
NgxsModule.forRoot([AuthState]),
NgxsStoragePluginModule.forRoot({
keys: 'auth.token'
})
]
})
export class AppModule {}
@State<AuthStateModel>({
name: 'auth'
})
export class AuthState {
@Selector()
static token(state: AuthStateModel) { return state.token; }
constructor(private authService: AuthService) {}
export class AuthStateModel {
token: string;
username: string;
}
export class Login {
static readonly type = '[Auth] Login';
constructor(public payload: { username: string, password: string }) {}
}
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 {