irisa-helpers
v0.0.8
Published
rxjs pipe: changeRouteOnSuccess(router: Router, route: ActivatedRoute, path: string) handleErrors(n: UntypedFormGroup) recordErrors(n: BusinessError[]) streamErrors(n: Subject<BusinessError>) recordState(n: ObservableState)
Downloads
264
Readme
rxjs pipe: changeRouteOnSuccess(router: Router, route: ActivatedRoute, path: string) handleErrors(n: UntypedFormGroup) recordErrors(n: BusinessError[]) streamErrors(n: Subject) recordState(n: ObservableState)
example of ObservableState loadState = new ObservableState(); this.loadState.Wait(); this.service.getDate() .pipe(this.recordState()) .subscrbe()
if(this.loadState.IsWait){ //do something }
functions:
toFormData(obj: any, form: FormData = null, namespace: string = null, ignoreList: boolean = false); toHttpParams(obj: any, params: HttpParams = null, namespace: string = null, ignoreList: boolean = false); makeAllControlsTouched(formGroup: UntypedFormGroup);
function wordifyfa(input: string | number, level: number = 0): string function wordifyRials(num: string | number): string function wordifyRialsInTomans(num: string | number): string function wordifyMomentApprox(date: Date | string | null, baseDate?: Date | string | null, suffixBefore: string = "پیش", suffixAfter: string = "بعد", doWordify: boolean = true): string function momentPrecise(date: Date | string | null, baseDate?: Date | string | null, suffixBefore: string = "پیش", suffixAfter: string = "بعد"): string function wordifyMomentPrecise(date: Date | string | null, baseDate?: Date | string | null, suffixBefore: string = "پیش", suffixAfter: string = "بعد", doWordify: boolean = true): string
import { Injectable } from '@angular/core'; import jwt_decode from 'jwt-decode'; import { CookieService } from 'ngx-cookie-service'; import { UserModel } from 'irisa-common-models';
@Injectable({ providedIn: 'root', }) export class SecurityHelper {
static access_token_key = 'access_token'; static refresh_token_key = 'refresh_token'; static exp_time_key = 'exp'; static role_claim_key = 'roles'; static username_claim_key = 'username'; static displayname_claim_key = 'displayname'; public domain: string;
saveAccessToken(token: string): void saveRefreshToken(token: string): void getAccessToken(): string getRefreshToken(): string clearAccessToken() isAuthenticated(): boolean getUserPayload() getUserRoles(): string[] getUserName(): string getDisplayName(): string getUserExpTime(): number getExpTime(token: string): number getPayload(token: string) isUserInRole(rolename: string): boolean hasUserAnyRoles(rolenames: string[]): boolean getUserInfo(): UserModel
}
EncryptionService: {
// ENCRYPTION USING CBC TRIPLE DES encryptUsingTripleDES(res: any, key: string, typeObj: boolean): string
// DECRYPTION USING CBC TRIPLE DES decryptUsingTripleDES(encrypted: string, key: string): string
// ENCRYPTION USING CBC DES encryptUsingDES(res: any, key: string, typeObj: boolean): string
// DECRYPTION USING CBC DES decryptUsingDES(encrypted: string, key: string): string
// ENCRYPTION USING AES encryptUsingAES(res: any, key: string, typeObj: boolean): string
// DECRYPTION USING AES decryptUsingAES(encrypted: string, key: string): string
}