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
Credit to https://gist.github.com/iansinnott/3d0ba1e9edc3e6967bc51da7020926b0 | |
export class UploadComponent { | |
@ViewChild('file') file: ElementRef; | |
imagePreview$: Observable<ArrayBuffer | string>; | |
onFile(event) { | |
event.preventDefault(); | |
event.stopPropagation(); | |
this.file.nativeElement.click(); |
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
export interface State {} | |
const state: State = {}; | |
export class Store { | |
private subject = new BehaviorSubject<State>(state); | |
private store = this.subject.asObservable().distinctUntilChanged(); | |
get value() { |
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
import { Injectable } from '@angular/core'; | |
import { select, Store } from '@ngrx/store'; | |
import { Credentials } from '../../models'; | |
import { State } from '../reducers'; | |
import { | |
selectError, | |
selectLoading, | |
selectIsAuthenticated, | |
selectToken |
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
import { Inject, Injectable } from '@angular/core'; | |
import { HttpClient } from '@angular/common/http'; | |
import { CONFIG, Config } from '../config.module'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class ConfigLoaderService { | |
configUrl: string; |
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
import { TestBed, async, inject } from '@angular/core/testing'; | |
import { StoreModule, Store, ActionReducerMap } from '@ngrx/store'; | |
export const accountReducer: ActionReducerMap<{}> = { | |
status: {} | |
}; | |
import { AccountGuard } from './account.guard'; | |
describe('AccountGuard', () => { | |
let store: Store<{}>; |
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
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class AuthGuard implements CanActivate, CanLoad { | |
constructor(private store: Store<AuthState>) {} | |
canActivate(): Observable<boolean> { | |
return this.store.pipe( | |
select(selectIsAuthenticated), | |
map(isValidToken => { |
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
import { Injectable } from '@angular/core'; | |
import { select, Store } from '@ngrx/store'; | |
import { Credentials } from '../../models'; | |
import { AuthState } from '../reducers'; | |
import { | |
selectError, | |
selectLoading, | |
selectLoggedIn, | |
selectToken |
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
import { Component, OnInit } from '@angular/core'; | |
import { RouterOutlet } from '@angular/router'; | |
import { | |
animate, | |
animateChild, | |
group, | |
query, | |
style, | |
transition, | |
trigger } from '@angular/animations'; |
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
export enum AuthActionTypes { | |
Login = '[Auth] Page Login', | |
LoginFailure = '[Auth] Api Login Failure', | |
LoginSuccess = '[Auth] Api Login Success', | |
Logout = '[Auth] Page Logout', | |
LogoutFailure = '[Auth] Api Logout Failure', | |
LogoutSuccess = '[Auth] Api Logout Success' | |
} |
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
// These are important and needed before anything else | |
import 'zone.js/dist/zone-node'; | |
import 'reflect-metadata'; | |
import { join } from 'path'; | |
import * as express from 'express'; | |
import * as cookieParser from 'cookie-parser'; | |
import * as helmet from 'helmet'; | |
import { enableProdMode } from '@angular/core'; | |
// Faster server renders w/ Prod mode (dev mode never needed) |