move toaster service
This commit is contained in:
parent
b6670a75c8
commit
02a4b46476
@ -1,6 +1,6 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Toast, ToastPackage, ToastrService } from 'ngx-toastr';
|
||||
import { ToasterOptions } from '@services/toaster.service';
|
||||
import { ToasterOptions } from '@iqser/common-ui';
|
||||
|
||||
@Component({
|
||||
templateUrl: './toast.component.html',
|
||||
|
||||
@ -3,7 +3,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { DictionaryControllerService, TypeValue } from '@redaction/red-ui-http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { TypeValueWrapper } from '@models/file/type-value.wrapper';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
|
||||
@ -4,7 +4,7 @@ import { DossierAttributeConfig, FileAttributeConfig } from '@redaction/red-ui-h
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { LoadingService } from '@services/loading.service';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { DossierAttributesService } from '@shared/services/controller-wrappers/dossier-attributes.service';
|
||||
import { dossierAttributeTypesTranslations } from '../../translations/dossier-attribute-types-translations';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { Colors, DictionaryControllerService } from '@redaction/red-ui-http';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { DefaultColorType } from '@models/default-color-key.model';
|
||||
|
||||
@ -5,7 +5,7 @@ import * as Papa from 'papaparse';
|
||||
import { FileAttributeConfig, FileAttributesConfig, FileAttributesControllerService } from '@redaction/red-ui-http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, startWith } from 'rxjs/operators';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { DefaultListingServices, Listable, ListingComponent, TableColumnConfig } from '@iqser/common-ui';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { DigitalSignature, DigitalSignatureControllerService } from '@redaction/red-ui-http';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { lastIndexOfEnd } from '@utils/functions';
|
||||
import { AutoUnsubscribe, IconButtonTypes } from '@iqser/common-ui';
|
||||
import { LoadingService } from '@services/loading.service';
|
||||
|
||||
@ -9,7 +9,7 @@ import {
|
||||
} from '@redaction/red-ui-http';
|
||||
import { AppConfigService } from '@app-config/app-config.service';
|
||||
import { AutoUnsubscribe, IconButtonTypes } from '@iqser/common-ui';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { LoadingService } from '@services/loading.service';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { UserService } from '@services/user.service';
|
||||
|
||||
@ -10,7 +10,7 @@ import {
|
||||
placeholdersDescriptionsTranslations
|
||||
} from '../../translations/placeholders-descriptions-translations';
|
||||
import { removeBraces } from '@utils/functions';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { ConfirmationDialogInput } from '@shared/dialogs/confirmation-dialog/confirmation-dialog.component';
|
||||
import { AdminDialogService } from '../../services/admin-dialog.service';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { RulesControllerService } from '@redaction/red-ui-http';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { saveAs } from 'file-saver';
|
||||
import { ComponentHasChanges } from '@guards/can-deactivate.guard';
|
||||
|
||||
@ -7,7 +7,7 @@ import { HttpClient } from '@angular/common/http';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { Debounce, IconButtonTypes } from '@iqser/common-ui';
|
||||
import { WatermarkControllerService, WatermarkModelRes } from '@redaction/red-ui-http';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { BASE_HREF } from '../../../../tokens';
|
||||
import { stampPDFPage } from '@utils/page-stamper';
|
||||
|
||||
@ -5,7 +5,7 @@ import { DoughnutChartConfig } from '@shared/components/simple-doughnut-chart/si
|
||||
import { TranslateChartService } from '@services/translate-chart.service';
|
||||
import { StatusSorter } from '@utils/sorters/status-sorter';
|
||||
import { UserService, UserWrapper } from '@services/user.service';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { FilterService } from '@iqser/common-ui';
|
||||
import { DossierAttributeWithValue } from '@models/dossier-attributes.model';
|
||||
import { fileStatusTranslations } from '../../translations/file-status-translations';
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import {Component, EventEmitter, Input, OnChanges, Output} from '@angular/core';
|
||||
import {PermissionsService} from '@services/permissions.service';
|
||||
import {FormBuilder, FormGroup} from '@angular/forms';
|
||||
import {PageRange, ReanalysisControllerService} from '@redaction/red-ui-http';
|
||||
import {Toaster} from '@services/toaster.service';
|
||||
import {LoadingService} from '@services/loading.service';
|
||||
import {marker as _} from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import {FileStatusWrapper} from '../../../../models/file/file-status.wrapper';
|
||||
import { Component, EventEmitter, Input, OnChanges, Output } from '@angular/core';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { PageRange, ReanalysisControllerService } from '@redaction/red-ui-http';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { LoadingService } from '@services/loading.service';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { FileStatusWrapper } from '@models/file/file-status.wrapper';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-page-exclusion',
|
||||
@ -35,13 +35,13 @@ export class PageExclusionComponent implements OnChanges {
|
||||
const excludedPages = (this.fileStatus?.excludedPages || []).sort((p1, p2) => p1 - p2);
|
||||
this.excludedPagesRanges = excludedPages.reduce((ranges, page) => {
|
||||
if (!ranges.length) {
|
||||
return [{startPage: page, endPage: page}];
|
||||
return [{ startPage: page, endPage: page }];
|
||||
}
|
||||
|
||||
if (page === ranges[ranges.length - 1].endPage + 1) {
|
||||
ranges[ranges.length - 1].endPage = page;
|
||||
} else {
|
||||
ranges.push({startPage: page, endPage: page});
|
||||
ranges.push({ startPage: page, endPage: page });
|
||||
}
|
||||
return ranges;
|
||||
}, []);
|
||||
|
||||
@ -2,7 +2,7 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { Dossier } from '@redaction/red-ui-http';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { DossierWrapper } from '@state/model/dossier.wrapper';
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import { StatusControllerService } from '@redaction/red-ui-http';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { FileStatusWrapper } from '@models/file/file-status.wrapper';
|
||||
import { DossierWrapper } from '@state/model/dossier.wrapper';
|
||||
|
||||
@ -4,7 +4,7 @@ import { DossierWrapper } from '@state/model/dossier.wrapper';
|
||||
import { EditDossierGeneralInfoComponent } from './general-info/edit-dossier-general-info.component';
|
||||
import { EditDossierDownloadPackageComponent } from './download-package/edit-dossier-download-package.component';
|
||||
import { EditDossierSectionInterface } from './edit-dossier-section.interface';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { EditDossierDictionaryComponent } from './dictionary/edit-dossier-dictionary.component';
|
||||
import { EditDossierTeamMembersComponent } from './team-members/edit-dossier-team-members.component';
|
||||
import { EditDossierAttributesComponent } from './attributes/edit-dossier-attributes.component';
|
||||
|
||||
@ -3,14 +3,14 @@ import { DossierTemplateModel } from '@redaction/red-ui-http';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { AppStateService } from '../../../../../state/app-state.service';
|
||||
import * as moment from 'moment';
|
||||
import { DossierWrapper } from '../../../../../state/model/dossier.wrapper';
|
||||
import { DossierWrapper } from '@state/model/dossier.wrapper';
|
||||
import { EditDossierSectionInterface } from '../edit-dossier-section.interface';
|
||||
import { DossiersDialogService } from '../../../services/dossiers-dialog.service';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { MatDialogRef } from '@angular/material/dialog';
|
||||
import { EditDossierDialogComponent } from '../edit-dossier-dialog.component';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { IconButtonTypes } from '@iqser/common-ui';
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { MatDialogRef } from '@angular/material/dialog';
|
||||
import { ForceRedactionRequest, LegalBasisMappingControllerService } from '@redaction/red-ui-http';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { ManualAnnotationService } from '../../services/manual-annotation.service';
|
||||
|
||||
@ -3,7 +3,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { AddRedactionRequest, LegalBasisMappingControllerService } from '@redaction/red-ui-http';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { ManualRedactionEntryWrapper } from '@models/file/manual-redaction-entry.wrapper';
|
||||
|
||||
@ -1,16 +1,5 @@
|
||||
import {
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
ElementRef,
|
||||
HostListener,
|
||||
Injector,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
Renderer2,
|
||||
TemplateRef,
|
||||
ViewChild
|
||||
} from '@angular/core';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { ChangeDetectorRef, Component, ElementRef, HostListener, Injector, OnDestroy, OnInit, TemplateRef, ViewChild } from '@angular/core';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { FileDropOverlayService } from '@upload-download/services/file-drop-overlay.service';
|
||||
import { FileUploadModel } from '@upload-download/model/file-upload.model';
|
||||
|
||||
@ -12,7 +12,7 @@ import { AnnotationData, FileDataModel } from '@models/file/file-data.model';
|
||||
import { FileActionService } from '../../services/file-action.service';
|
||||
import { AnnotationDrawService } from '../../services/annotation-draw.service';
|
||||
import { AnnotationProcessingService } from '../../services/annotation-processing.service';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { FileStatusWrapper } from '@models/file/file-status.wrapper';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { timer } from 'rxjs';
|
||||
|
||||
@ -7,7 +7,7 @@ import {
|
||||
ManualRedactionControllerService
|
||||
} from '@redaction/red-ui-http';
|
||||
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { UserService } from '@services/user.service';
|
||||
|
||||
@ -3,7 +3,7 @@ import { PermissionsService } from '@services/permissions.service';
|
||||
import { DossierWrapper } from '@state/model/dossier.wrapper';
|
||||
import { FileStatusWrapper } from '@models/file/file-status.wrapper';
|
||||
import { FileDownloadService } from '@upload-download/services/file-download.service';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { AutoUnsubscribe, CircleButtonType, CircleButtonTypes } from '@iqser/common-ui';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { DictionaryControllerService } from '@redaction/red-ui-http';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
|
||||
@ -9,7 +9,7 @@ import { UploadDownloadDialogService } from './upload-download-dialog.service';
|
||||
import { toNumber } from '@utils/functions';
|
||||
import { UploadControllerService } from '@redaction/red-ui-http';
|
||||
import { isCsv } from '@utils/file-drop-utils';
|
||||
import { ErrorMessageService } from '@services/error-message.service';
|
||||
import { ErrorMessageService } from '@iqser/common-ui';
|
||||
|
||||
export interface ActiveUpload {
|
||||
subscription: Subscription;
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ErrorMessageService {
|
||||
constructor(private readonly _translateService: TranslateService) {}
|
||||
|
||||
_parseErrorResponse(err: HttpErrorResponse): string {
|
||||
return err?.error?.message?.includes('message') ? ` ${err.error.message.match('"message":"(.*?)\\"')[1]}` : '';
|
||||
}
|
||||
|
||||
getMessage(error: HttpErrorResponse, defaultMessage: string): string {
|
||||
return this._translateService.instant(defaultMessage) + this._parseErrorResponse(error);
|
||||
}
|
||||
}
|
||||
@ -1,82 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActiveToast, ToastrService } from 'ngx-toastr';
|
||||
import { IndividualConfig } from 'ngx-toastr/toastr/toastr-config';
|
||||
import { NavigationStart, Router } from '@angular/router';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { ErrorMessageService } from '@services/error-message.service';
|
||||
import { filter } from 'rxjs/operators';
|
||||
|
||||
const enum NotificationType {
|
||||
SUCCESS = 'SUCCESS',
|
||||
WARNING = 'WARNING',
|
||||
INFO = 'INFO'
|
||||
}
|
||||
|
||||
export interface ToasterOptions extends IndividualConfig {
|
||||
readonly title?: string;
|
||||
/**
|
||||
* These params are used as interpolateParams for translate service
|
||||
*/
|
||||
readonly params?: object;
|
||||
readonly actions?: { readonly title?: string; readonly action: () => void }[];
|
||||
}
|
||||
|
||||
export interface ErrorToasterOptions extends ToasterOptions {
|
||||
/**
|
||||
* Pass an http error that will be processed by error message service and shown in toast
|
||||
*/
|
||||
readonly error?: HttpErrorResponse;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class Toaster {
|
||||
constructor(
|
||||
private readonly _toastr: ToastrService,
|
||||
private readonly _router: Router,
|
||||
private readonly _translateService: TranslateService,
|
||||
private readonly _errorMessageService: ErrorMessageService
|
||||
) {
|
||||
_router.events.pipe(filter(event => event instanceof NavigationStart)).subscribe(() => {
|
||||
_toastr.clear();
|
||||
});
|
||||
}
|
||||
|
||||
error(message: string, options?: Partial<ErrorToasterOptions>) {
|
||||
if (options?.error) message = this._errorMessageService.getMessage(options.error, message);
|
||||
else message = this._translateService.instant(message, options?.params);
|
||||
|
||||
return this._toastr.error(message, options?.title, options);
|
||||
}
|
||||
|
||||
info(message: string, options?: Partial<ToasterOptions>) {
|
||||
return this._showToastNotification(message, NotificationType.INFO, options);
|
||||
}
|
||||
|
||||
success(message: string, options?: Partial<ToasterOptions>) {
|
||||
return this._showToastNotification(message, NotificationType.SUCCESS, options);
|
||||
}
|
||||
|
||||
warning(message: string, options?: Partial<ToasterOptions>) {
|
||||
return this._showToastNotification(message, NotificationType.WARNING, options);
|
||||
}
|
||||
|
||||
private _showToastNotification(
|
||||
message: string,
|
||||
notificationType = NotificationType.INFO,
|
||||
options?: Partial<ToasterOptions>
|
||||
): ActiveToast<unknown> {
|
||||
message = this._translateService.instant(message, options?.params);
|
||||
|
||||
switch (notificationType) {
|
||||
case NotificationType.SUCCESS:
|
||||
return this._toastr.success(message, options?.title, options);
|
||||
case NotificationType.WARNING:
|
||||
return this._toastr.warning(message, options?.title, options);
|
||||
case NotificationType.INFO:
|
||||
return this._toastr.info(message, options?.title, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9,7 +9,7 @@ import {
|
||||
ReanalysisControllerService,
|
||||
StatusControllerService
|
||||
} from '@redaction/red-ui-http';
|
||||
import { Toaster } from '@services/toaster.service';
|
||||
import { Toaster } from '@iqser/common-ui';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { Event, NavigationEnd, ResolveStart, Router } from '@angular/router';
|
||||
import { UserService } from '@services/user.service';
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit c20bac823277e659c1c9797bdd034a9f5b2fc539
|
||||
Subproject commit 844e2657774200f14f79ed5c75e06f2c6c554bb4
|
||||
Loading…
x
Reference in New Issue
Block a user