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 { Injectable, Inject } from '@angular/core'; | |
import { BehaviorSubject, Observable } from 'rxjs'; | |
import { TranslateService } from '@ngx-translate/core'; | |
import { DOCUMENT } from '@angular/common'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class LanguageService { | |
private readonly DEFAULT_LANGUAGE = 'en'; |
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 { FormControl } from "@angular/forms"; | |
export function noWhitespaceValidator(control: FormControl) { | |
const isWhitespace = (control.value || '').trim().length === 0; | |
const isValid = !isWhitespace; | |
return isValid ? null : { 'whitespace': true }; | |
} |
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 { Injectable } from '@angular/core'; | |
import { MatSnackBar } from '@angular/material/snack-bar'; | |
import { SwUpdate } from '@angular/service-worker'; | |
@Injectable() | |
export class UpdateService { | |
constructor(private swUpdate: SwUpdate, | |
private snackbar: MatSnackBar) { | |
this.swUpdate.available.subscribe(event => { |
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 { Component, HostListener, OnInit } from '@angular/core'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent { |
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 { writeFileSync } = require('fs') | |
const { join } = require('path') | |
const BUILD_DATE_TIME_STAMP_PATH = join(__dirname, 'build-date.json'); | |
const createBuildDate = { | |
buildDate: new Date() | |
} | |
writeFileSync(TIME_STAMP_PATH, JSON.stringify(createBuildDate, null, 2)); |
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
private itersection(textOne: string, textTwo: string): string { | |
let textOneIndex: number = 0; | |
let textTwoIndex: number = 0; | |
let matchedText: string = ''; | |
textOne = textOne.toLowerCase(); | |
textTwo = textTwo.toLowerCase(); | |
while (textOneIndex < textOne.length && textTwoIndex < textTwo.length) { | |
if (textOne[textOneIndex] < textTwo[textTwoIndex]) { |
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 { Injectable } from "@angular/core"; | |
export enum LogLevel { | |
DEBUG, | |
INFO, | |
ERROR, | |
} | |
@Injectable() | |
export class LogService { | |
minimumLevel: LogLevel = LogLevel.INFO; | |
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 CACHE_IT = new HttpContextToken<boolean>(() => false); | |
export function cacheIt() { | |
return new HttpContext().set(CACHE_IT, true); | |
} | |
@Injectable() | |
export class CacheInterceptor implements HttpInterceptor { | |
intercept(request: HttpRequest, next: HttpHandler): Observable<HttpEvent> { |
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 { User } from '@amaleyat/shared/models/user'; | |
import { isPlatformBrowser } from '@angular/common'; | |
import { HttpInterceptorFn } from '@angular/common/http'; | |
import { inject, PLATFORM_ID } from '@angular/core'; | |
export const authInterceptor: HttpInterceptorFn = (req, next) => { | |
const platformId: Object = inject(PLATFORM_ID); | |
if (isPlatformBrowser(platformId)) { |
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 { environment } from '@amaleyat/environments/dev.environment'; | |
import { HttpClient, HttpErrorResponse } from '@angular/common/http'; | |
import { Inject, Injectable, PLATFORM_ID } from '@angular/core'; | |
import { Observable } from 'rxjs/internal/Observable'; | |
import { throwError } from 'rxjs/internal/observable/throwError'; | |
import { catchError } from 'rxjs/internal/operators/catchError'; | |
import { isPlatformBrowser } from '@angular/common'; | |
import { LanguageService } from './language.service'; | |
@Injectable({ |