@versatiledatakit/shared
Version:
Versatile Data Kit Shared library enables reusability of shared features like: NgRx Redux, Error Handlers, Utils, Generic Components, etc.
108 lines (107 loc) • 5.69 kB
TypeScript
import { CookieService } from 'ngx-cookie-service';
import { TaurusObject } from '../../../common';
import { NavigationService } from '../../../core';
import { ConfirmationService } from '../../confirmation';
import { UrlOpenerModel, UrlOpenerTarget } from '../model';
import * as i0 from "@angular/core";
/**
* ** Url Opener Service that opens internal and external urls depends on provided instructions.
*
* - Utilizes <code>Promise<boolean></code> for communication to invoker that is resolved after navigation.
* - Internal urls could be open directly without confirmation or explicitly with confirmation,
* while external are always prompt for confirmation it there is no option to skip confirmation for next navigations,
* and User prompt such confirmation to be skipped.
* - Skipped confirmation are persisted in Cookie storage as Origin for external urls and as Url for internal urls.
* - Returned Promise is resolved upon navigation ends with true (successful navigation) or false (unsuccessful navigation),
* or rejected with value string if it's on User behalf,
* or if there is some internal handled error it will be rejected with instance of Error and message of the specific problem.
*/
export declare class UrlOpenerService extends TaurusObject {
private readonly navigationService;
private readonly confirmationService;
private readonly cookieService;
/**
* @inheritDoc
*/
static readonly CLASS_NAME: string;
/**
* ** Application origin, resolved upon service declaration.
*
* @private
*/
private readonly _origin;
/**
* ** Cookie key where service state is persisted, resolved upon service declaration.
*
* - It's service Class Name encoded to Base64.
*
* @private
*/
private readonly _cookieKey;
/**
* ** Application state, for which origins/urls confirmation should be skipped.
*
* @private
*/
private _skippedOriginsUrlsMap;
/**
* ** Constructor.
*/
constructor(navigationService: NavigationService, confirmationService: ConfirmationService, cookieService: CookieService);
/**
* ** Open provided Url to default _blank target.
*
* - Internal urls are open directly without confirmation, while external are always prompt for confirmation.
* - Returned Promise is resolved upon navigation ends with true (successful navigation) or false (unsuccessful navigation),
* or if there is some internal handled error it will be rejected with instance of Error and message of the specific problem.
* - Every url which starts with pattern http:// or https:// and its origin is different from Application origin is marked as external url.
* - Everything else is internal url.
*/
open(url: string): Promise<boolean>;
/**
* ** Open provided Url using provided target _self or _blank
*
* - Internal urls are open directly without confirmation, while external are always prompt for confirmation.
* - Returned Promise is resolved upon navigation ends with true (successful navigation) or false (unsuccessful navigation),
* or if there is some internal handled error it will be rejected with instance of Error and message of the specific problem.
* - Every url which starts with pattern http:// or https:// and its origin is different from Application origin is marked as external url.
* - Everything else is internal url.
*/
open(url: string, target: UrlOpenerTarget): Promise<boolean>;
/**
* ** Open provided Url using provided target _self or _blank and utilizing provided model and service will set some defaults for optional fields.
*
* - Internal urls could be open directly without confirmation or explicitly with confirmation depend on provided model,
* while external are always prompt for confirmation it there is no option to skip confirmation for next navigations,
* and User prompt such confirmation to be skipped.
* - Skipped confirmation are persisted in Cookie storage as Origin for external urls and as Url for internal urls.
* - Returned Promise is resolved upon navigation ends with true (successful navigation) or false (unsuccessful navigation),
* or rejected with value string if it's on User behalf when confirmation is closable or with button cancel,
* or if there is some internal handled error it will be rejected with instance of Error and message of the specific problem.
*/
open(url: string, target: UrlOpenerTarget, model: UrlOpenerModel): Promise<boolean>;
/**
* ** Initialize service.
*
* - Should be invoked only once.
* - Ideal place for invoking is <code>AppComponent.ngOnInit()</code>.
*/
initialize(): void;
private _resolveNextStep;
private _executeExternalNavigation;
private _executeInternalNavigation;
private _getExternalUrlOriginData;
private _persistSkippedExternalUrlOrigin;
private _getInternalUrlData;
private _persistSkippedInternalUrl;
private _extractSkippedUrlsMap;
private _persistSkippedUrlsMap;
private static _openExternalUrl;
private static _getUrlOrigin;
private static _encodeBase64;
private static _decodeBase64;
private static _serializeObject;
private static _parseToJSON;
static ɵfac: i0.ɵɵFactoryDeclaration<UrlOpenerService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<UrlOpenerService>;
}