Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { HttpClient } from '@angular/common/http';
import { Inject, Injectable, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { TranslateCompiler, TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler';
import { AppComponent } from './app.component';
import { routes } from './app.routes';
import { getDefaultLanguage } from './common/utilities/get-default-language';
import { CoreModule } from './core/core.module';
import { CustomHttpTranslationLoader } from './core/providers/i18n/custom-http-loader';
import { I18nService } from './core/providers/i18n/i18n.service';
import { DataService } from './data/providers/data.service';
@Injectable()
export class BaseHrefHolder {
constructor(@Inject(APP_BASE_HREF) public addBaseHref: string) {}
}
export function HttpLoaderFactory(http: HttpClient, location: PlatformLocation) {
// Dynamically get the baseHref, which is configured in the angular.json file
const baseHref = location.getBaseHrefFromDOM();
return new CustomHttpTranslationLoader(http, baseHref + 'i18n-messages/');
}
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
RouterModule.forRoot(routes, { useHash: false }),
TranslateModule.forRoot({
import { Injectable } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
import { AuthProvider } from '@firebase/auth-types';
import { Effect } from '@ngrx/effects';
import { AngularFireAuth } from 'angularfire2/auth';
import { Observable } from 'rxjs/Observable';
import { StateService } from '../../state-service/state.service';
import { LogInActions } from 'app/store/user/logIn/logIn.actions';
import { LogInActionTypes } from 'app/store/user/logIn/logIn.actionTypes';
import { EmailPasswordCredentials } from 'app/store/user/signUp/signUp.actions';
@Injectable()
export class LogInEffects {
@Effect()
logIn$: Observable<
LogInActions.Failure | LogInActions.Success
> = this.state.actions$
.ofType(LogInActionTypes.LogIn)
.switchMap((action: LogInActions.LogIn) => {
let request;
if ((action.payload as any).providerId) {
request = this.auth.auth.signInWithPopup(
action.payload as AuthProvider
);
} else {
request = this.auth.auth.signInWithEmailAndPassword(
(action.payload as EmailPasswordCredentials).email,
collection: EntityCollection
): EntityCollection {
return collection.loading ? { ...collection, loading: false } : collection;
}
protected setLoadingTrue(
collection: EntityCollection
): EntityCollection {
return collection.loading ? collection : { ...collection, loading: true };
}
}
/**
* Creates default {EntityCollectionReducerMethods} for a given entity type.
*/
@Injectable()
export class DefaultEntityCollectionReducerMethodsFactory
implements EntityCollectionReducerMethodsFactory {
constructor(protected entityDefinitionService: EntityDefinitionService) {}
/** Create the {EntityCollectionReducerMethods} for the named entity type */
create(entityName: string): EntityCollectionReducerMethods {
const definition = this.entityDefinitionService.getDefinition(
entityName
);
const methodsClass = new DefaultEntityCollectionReducerMethods(
entityName,
definition
);
return methodsClass.getMethods();
}
}
import {Injectable} from '@angular/core';
import {TokenDecoder} from 'ngx-api-utils';
import * as jwt_decode from 'jwt-decode';
import {JwtTokenPayload} from '../jwt-token-payload';
@Injectable({
providedIn: 'root'
})
export class JwtTokenDecoderService extends TokenDecoder {
decode(token: string) {
return new JwtTokenPayload(jwt_decode(token));
}
}
import { Injectable } from '@angular/core';
import { AbstractControl, FormArray, FormGroup } from '@angular/forms';
import { FieldsService } from './fields.service';
import { FormlyConfig, FormlyFieldConfig } from '@ngx-formly/core';
import { FormlyDesignerConfig } from './formly-designer-config';
import { BehaviorSubject, Observable } from 'rxjs';
import { cloneDeep, get, isArray, isEmpty, isFunction, isString, set, unset } from './util';
@Injectable()
export class FormlyDesignerService {
constructor(
private designerConfig: FormlyDesignerConfig,
private fieldsService: FieldsService,
private formlyConfig: FormlyConfig
) { }
private readonly _disabled = new BehaviorSubject(false);
private readonly _fields = new BehaviorSubject([]);
private readonly _model = new BehaviorSubject({});
get disabled(): boolean {
return this._disabled.value;
}
set disabled(value: boolean) {
import { PostPacket, SubmissionPacket, PacketStatus } from './post-packet';
import { Submission } from 'src/app/database/models/submission.model';
import { Subscription, Subject, Observable } from 'rxjs';
import { filter } from 'rxjs/operators';
import { TabManager } from './tab-manager.service';
import { PostManagerService } from './post-manager.service';
import { SubmissionDBService } from 'src/app/database/model-services/submission.service';
import { GeneratedThumbnailDBService } from 'src/app/database/model-services/generated-thumbnail.service';
import { TranslateService } from '@ngx-translate/core';
import { SnotifyService } from 'ng-snotify';
import { PostLoggerService } from './post-logger.service';
import { blobToUint8Array } from 'src/app/utils/helpers/file.helper';
import { SubmissionFileType } from 'src/app/database/tables/submission-file.table';
import { PostResult } from 'src/app/websites/interfaces/website-service.interface';
@Injectable({
providedIn: 'root'
})
export class PostBucket {
private buckets: any = {};
private packetQueue: SubmissionPacket[] = [];
private queueStatus: Subject = new Subject();
public readonly queueUpdates: Observable = this.queueStatus.asObservable();
constructor(
private _tabManager: TabManager,
private _submissionDB: SubmissionDBService,
private _generatedThumbnailDB: GeneratedThumbnailDBService,
private _postLogger: PostLoggerService,
private _translate: TranslateService,
public _postManager: PostManagerService,
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache Software License 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*/
import { Injectable } from '@angular/core';
import { NgRedux } from '@angular-redux/store';
import { AppState } from '../store/app-state.model';
import { ConfigurationActions } from './configuration-actions';
import { ApplicationManagementActions } from '../application-management/application-management-actions';
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
@Injectable()
export class ConfigurationService {
constructor(private http: HttpClient,
private ngRedux: NgRedux) {
}
isRepositoryAvailable(url: string): Observable {
const httpOptions = {
headers: new HttpHeaders({
'Accept': 'application/json'
})
};
return this.http.get(url, { ...httpOptions, responseType: 'text', observe: 'response' }).pipe(
map((response: HttpResponse) => (response.status >= 200 && response.status < 400)),
catchError(() => of(false))
);
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { shareReplay } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class MediaQueryService {
private readonly queryObservables: Map>;
constructor() {
this.queryObservables = new Map();
}
get isXs(): Observable {
return this.query('(max-width: 1087px)');
}
query(query: string): Observable {
if (!this.queryObservables.has(query)) {
const observable = this.getQueryObservable(query);
import { Injectable, NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { RestangularHandler, RestangularInterceptingHandler } from './handler';
import { Restangular } from './restangular';
import { DefaultRestangularConfig, RestangularConfig } from './config';
import { RestangularClient } from './client';
import { RestangularBuilder } from './builder';
@Injectable()
export class InitialRestangular {
constructor(private handler: RestangularHandler) {
}
one(routeOrId, id?) {
let route = routeOrId;
if (typeof id === 'undefined') {
id = routeOrId;
route = undefined;
}
const builder = new RestangularBuilder({id, route, isCollection: false});
return new RestangularClient(builder, this.handler);
}
all(route) {
* `duplicatesBehaviour` - determines how to threat the toasts duplication.
* Compare with the previous message `previous`
* or with all visible messages `all`.
*
* @stacked-example(Prevent duplicates behaviour , toastr/toastr-prevent-duplicates-behaviour.component)
*
* `limit` - the number of visible toasts in the toast container. The number of toasts is unlimited by default.
*
* @stacked-example(Prevent duplicates behaviour , toastr/toastr-limit.component)
*
* `hasIcon` - if true then render toast icon.
* `icon` - you can pass icon class that will be applied into the toast.
*
* @stacked-example(Has icon, toastr/toastr-icon.component)
* */
@Injectable()
export class NbToastrService {
constructor(@Inject(NB_TOASTR_CONFIG) protected globalConfig: NbToastrConfig,
protected containerRegistry: NbToastrContainerRegistry) {
}
/**
* Shows toast with message, title and user config.
* */
show(message, title?, userConfig?: Partial): NbToastRef {
const config = new NbToastrConfig({ ...this.globalConfig, ...userConfig });
const container = this.containerRegistry.get(config.position);
const toast = { message, title, config };
return container.attach(toast);
}
/**