UNPKG

@versatiledatakit/shared

Version:

Versatile Data Kit Shared library enables reusability of shared features like: NgRx Redux, Error Handlers, Utils, Generic Components, etc.

321 lines (320 loc) 15.3 kB
import { ElementRef, OnChanges, OnInit, Renderer2, SimpleChanges, TemplateRef } from '@angular/core'; import { ApiErrorMessage, ErrorRecord, TaurusObject } from '../../../common'; import { PlaceholderConfig } from '../model'; import { PlaceholderService } from '../services'; import * as i0 from "@angular/core"; interface IdentifiedErrorRecordWithMessage { record: ErrorRecord[]; problem: string; description: string; mitigation: string; escalation: string; impactedServices: string; apiMessage: ApiErrorMessage; imageSrc: string; imageWidth: string; imageOpacity: number; } /** * ** Generic placeholder component. * * - Could be use in generic Component template but also, inside Clarity Datagrid as content projection of <clr-dg-placeholder> component. * - Handles empty state and error state according provided parameters (instructions). */ export declare class PlaceholderComponent extends TaurusObject implements OnInit, OnChanges { private readonly elementRef; private readonly renderer2; private readonly placeholderService; private readonly featureConfig; /** * ** Template ref for system default Error Template. * * - Fallback for any Error that doesn't match any of provided custom Error Templates. */ errorTemplateRefSystemDefault: TemplateRef<never>; /** * ** Content projection child query for custom Error Template with ID #errorTemplate. * * - Template is generic and if provided will be used for every error that doesn't match any other template. * - If not provided will execute next resolution * - fallback to system default Error Template. */ errorTemplateRefGeneric: TemplateRef<never>; /** * ** Content projection child query for custom Error Template with ID #errorTemplate4xx. * * - Template if provided will be use only for errors that are HttpErrorResponse with status 4xx. * - If not provided will execute next resolution * - try fallback to generic custom Error Template if found, if not go to next resolution * - fallback to system default Error Template. */ errorTemplateRefClientErrors: TemplateRef<never>; /** * ** Content projection child query for custom Error Template with ID #errorTemplate400. * * - Template if provided will be use only for errors that are HttpErrorResponse with status 400. * - If not provided will execute next resolution * - try fallback to custom Error Template for HttpStatusCodes 4xx if found, if not go to next resolution * - try fallback to generic custom Error Template if found, if not go to next resolution * - fallback to system default Error Template. */ errorTemplateRefBadRequest: TemplateRef<never>; /** * ** Content projection child query for custom Error Template with ID #errorTemplate401. * * - Template if provided will be use only for errors that are HttpErrorResponse with status 401. * - If not provided will execute next resolution * - try fallback to custom Error Template for HttpStatusCodes 4xx if found, if not go to next resolution * - try fallback to generic custom Error Template if found, if not go to next resolution * - fallback to system default Error Template. */ errorTemplateRefUnauthorized: TemplateRef<never>; /** * ** Content projection child query for custom Error Template with ID #errorTemplate403. * * - Template if provided will be use only for errors that are HttpErrorResponse with status 403. * - If not provided will execute next resolution * - try fallback to custom Error Template for HttpStatusCodes 4xx if found, if not go to next resolution * - try fallback to generic custom Error Template if found, if not go to next resolution * - fallback to system default Error Template. */ errorTemplateRefForbidden: TemplateRef<never>; /** * ** Content projection child query for custom Error Template with ID #errorTemplate404. * * - Template if provided will be use only for errors that are HttpErrorResponse with status 404. * - If not provided will execute next resolution * - try fallback to custom Error Template for HttpStatusCodes 4xx if found, if not go to next resolution * - try fallback to generic custom Error Template if found, if not go to next resolution * - fallback to system default Error Template. */ errorTemplateRefNotFound: TemplateRef<never>; /** * ** Content projection child query for custom Error Template with ID #errorTemplate405. * * - Template if provided will be use only for errors that are HttpErrorResponse with status 405. * - If not provided will execute next resolution * - try fallback to custom Error Template for HttpStatusCodes 4xx if found, if not go to next resolution * - try fallback to generic custom Error Template if found, if not go to next resolution * - fallback to system default Error Template. */ errorTemplateRefMethodNotAllowed: TemplateRef<never>; /** * ** Content projection child query for custom Error Template with ID #errorTemplate409. * * - Template if provided will be use only for errors that are HttpErrorResponse with status 409. * - If not provided will execute next resolution * - try fallback to custom Error Template for HttpStatusCodes 4xx if found, if not go to next resolution * - try fallback to generic custom Error Template if found, if not go to next resolution * - fallback to system default Error Template. */ errorTemplateRefConflict: TemplateRef<never>; /** * ** Content projection child query for custom Error Template with ID #errorTemplate422. * * - Template if provided will be use only for errors that are HttpErrorResponse with status 422. * - If not provided will execute next resolution * - try fallback to custom Error Template for HttpStatusCodes 4xx if found, if not go to next resolution * - try fallback to generic custom Error Template if found, if not go to next resolution * - fallback to system default Error Template. */ errorTemplateRefUnprocessableEntity: TemplateRef<never>; /** * ** Content projection child query for custom Error Template with ID #errorTemplate5xx. * * - Template if provided will be use only for errors that are HttpErrorResponse with status 5xx. * - If not provided will execute next resolution * - try fallback to generic custom Error Template if found, if not go to next resolution * - fallback to system default Error Template. */ errorTemplateRefServerErrors: TemplateRef<never>; /** * ** Content projection child query for custom Error Template with ID #errorTemplate500. * * - Template if provided will be use only for errors that are HttpErrorResponse with status 500. * - If not provided will execute next resolution * - try fallback to custom Error Template for HttpStatusCodes 5xx if found, if not go to next resolution * - try fallback to generic custom Error Template if found, if not go to next resolution * - fallback to system default Error Template. */ errorTemplateRefInternalServerError: TemplateRef<never>; /** * ** Content projection child query for custom Error Template with ID #errorTemplate503. * * - Template if provided will be use only for errors that are HttpErrorResponse with status 503. * - If not provided will execute next resolution * - try fallback to custom Error Template for HttpStatusCodes 5xx if found, if not go to next resolution * - try fallback to generic custom Error Template if found, if not go to next resolution * - fallback to system default Error Template. */ errorTemplateRefServiceUnavailable: TemplateRef<never>; /** * ** Content projection child query for custom Empty Template with ID #emptyTemplate. * * - Template if provided will be use for empty state otherwise fallback to system default Empty State Template. */ emptyTemplateRef: TemplateRef<never>; /** * ** Boolean flag that identifies if parent is loading data. */ loading: boolean; /** * ** Text for empty state, if component is rendered without errors or there is no listened error code(s). */ set emptyMessage(value: string); /** * ** Text for empty state. * * - Visualized only if component is rendered without errors or there is no listened error code(s). */ get emptyMessage(): string; /** * ** Empty state image source url. * * - Visualized only if component is rendered without errors or there is no listened error code(s). */ set emptyImgSrc(value: string); /** * ** Empty state image source url. * * - Visualized only if component is rendered without errors or there is no listened error code(s). */ get emptyImgSrc(): string; /** * ** Empty state image width. * * - Visualized only if component is rendered without errors or there is no listened error code(s). */ set emptyImgWidth(value: string); /** * ** Empty state image width. * * - Visualized only if component is rendered without errors or there is no listened error code(s). */ get emptyImgWidth(): string; /** * ** Empty state image opacity. * * - Visualized only if component is rendered without errors or there is no listened error code(s). */ set emptyImgOpacity(value: number); /** * ** Empty state image opacity. * * - Visualized only if component is rendered without errors or there is no listened error code(s). */ get emptyImgOpacity(): number; /** * ** Flag to show or hide custom empty state image. * * - default value is FALSE. */ showCustomEmptyStateImage: boolean; /** * ** Flag to show or hide default empty state image in grid. * * - default value is FALSE. */ hideDefaultEmptyStateImageInGrid: boolean; /** * ** Errors queue of ErrorRecords injected from parents transitive. */ set errorsQueue(value: ErrorRecord[]); /** * ** Errors queue of ErrorRecords injected from parents transitive. */ get errorsQueue(): ErrorRecord[]; /** * ** Flag to instruct component to show all processed error or to peak the most important one, which is latest, according the HTTP Status code. */ renderAllErrors: boolean; /** * ** Array of error codes for which Placeholder should listen and on ChangeDetection cycle to look for exact match into errorsQueue. */ listenForErrors: string[]; /** * ** Array of error codes pattern for which Placeholder should listen and on ChangeDetection cycle to look for match into errorsQueue. */ listenForErrorPatterns: string[]; /** * ** Error context. * * - Visualized only if listened error code(s) exist in errorsQueue. */ get errorContext(): string; /** * ** Error context. */ set errorContext(value: string); /** * ** Context singular or plural. * * - If true - it's plural * - If false - it's singular */ plural: boolean; /** * ** Flag that identifies if error ot empty state template should be rendered. */ showError: boolean; /** * ** Flag that indicates for error template is used system default. */ isErrorTemplateSystemDefault: boolean; /** * ** Identified ErrorRecords in {@link errorsQueue} that exact match {@link listenForErrors} or match {@link listenForErrorPatterns} * * - injected to custom error template if provided * - used when only one error should be shown */ identifiedErrors: ErrorRecord[]; /** * ** Identified ErrorRecord in {@link errorsQueue} that exact match {@link listenForErrors} or match {@link listenForErrorPatterns} * * - injected to custom error template if provided * - used when only one error should be shown */ identifiedErrorWithApiMessage: IdentifiedErrorRecordWithMessage; /** * ** Identified ErrorRecords in {@link errorsQueue} that exact match {@link listenForErrors} or match {@link listenForErrorPatterns} * * - injected to custom error template if provided * - used if iteration of errors is requested */ identifiedErrorsWithApiMessage: IdentifiedErrorRecordWithMessage[]; private _emptyMessage; private _isEmptyMessageExternal; private _emptyImgSrc; private _isEmptyImgSrcExternal; private _emptyImgWidth; private _emptyImgOpacity; private _hideDefaultEmptyStateImageInGrid; private _errorsQueue; private _errorContext; /** * ** Constructor. */ constructor(elementRef: ElementRef<HTMLElement>, renderer2: Renderer2, placeholderService: PlaceholderService, featureConfig: PlaceholderConfig); /** * ** Resolves custom or system error for identified Error. */ resolveErrorTemplate(identifiedErrorRecordWithMessage: IdentifiedErrorRecordWithMessage): TemplateRef<never>; /** * @inheritDoc */ ngOnChanges(changes: SimpleChanges): void; /** * @inheritDoc */ ngOnInit(): void; private _executeRefineCycle; private _refineErrorState; private _resetTransportBuffers; private _populateTransportBuffers; private _getErrorToIdentifiedError; private _getErrorsToIdentifiedError; private static _isPropertyChanged; static ɵfac: i0.ɵɵFactoryDeclaration<PlaceholderComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<PlaceholderComponent, "shared-placeholder", never, { "loading": "loading"; "emptyMessage": "emptyMessage"; "emptyImgSrc": "emptyImgSrc"; "emptyImgWidth": "emptyImgWidth"; "emptyImgOpacity": "emptyImgOpacity"; "showCustomEmptyStateImage": "showCustomEmptyStateImage"; "hideDefaultEmptyStateImageInGrid": "hideDefaultEmptyStateImageInGrid"; "errorsQueue": "errorsQueue"; "renderAllErrors": "renderAllErrors"; "listenForErrors": "listenForErrors"; "listenForErrorPatterns": "listenForErrorPatterns"; "errorContext": "errorContext"; "plural": "plural"; }, {}, ["errorTemplateRefGeneric", "errorTemplateRefClientErrors", "errorTemplateRefBadRequest", "errorTemplateRefUnauthorized", "errorTemplateRefForbidden", "errorTemplateRefNotFound", "errorTemplateRefMethodNotAllowed", "errorTemplateRefConflict", "errorTemplateRefUnprocessableEntity", "errorTemplateRefServerErrors", "errorTemplateRefInternalServerError", "errorTemplateRefServiceUnavailable", "emptyTemplateRef"], never>; } export {};