ngx-dsxlibrary 1.21.24 → 1.21.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2165,6 +2165,32 @@ function createTypedCacheProvider(tokenName) {
|
|
|
2165
2165
|
return { token, provider };
|
|
2166
2166
|
}
|
|
2167
2167
|
|
|
2168
|
+
class DteService {
|
|
2169
|
+
/** Servicio HttpClient para realizar peticiones HTTP */
|
|
2170
|
+
http = inject(HttpClient);
|
|
2171
|
+
/**
|
|
2172
|
+
* Configuración del entorno inyectada mediante el token ENVIRONMENT.
|
|
2173
|
+
* La validación se realiza automáticamente al usar provideEnvironment().
|
|
2174
|
+
*/
|
|
2175
|
+
environment = inject(ENVIRONMENT);
|
|
2176
|
+
/** URL base de la API JWT construida desde la configuración del entorno */
|
|
2177
|
+
SeguridadITApi = `${this.environment.SeguridadITApiUrl}api/dte`;
|
|
2178
|
+
pdfDTE(UUID) {
|
|
2179
|
+
// Realiza una solicitud POST al endpoint de refresco de token
|
|
2180
|
+
return this.http.get(`${this.SeguridadITApi}/pdf-dte/${UUID}`, {
|
|
2181
|
+
responseType: 'blob',
|
|
2182
|
+
});
|
|
2183
|
+
}
|
|
2184
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: DteService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2185
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: DteService, providedIn: 'root' });
|
|
2186
|
+
}
|
|
2187
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: DteService, decorators: [{
|
|
2188
|
+
type: Injectable,
|
|
2189
|
+
args: [{
|
|
2190
|
+
providedIn: 'root',
|
|
2191
|
+
}]
|
|
2192
|
+
}] });
|
|
2193
|
+
|
|
2168
2194
|
class EndpointService {
|
|
2169
2195
|
http = inject(HttpClient);
|
|
2170
2196
|
environment = inject(ENVIRONMENT);
|
|
@@ -2421,7 +2447,7 @@ class UtilityAddService {
|
|
|
2421
2447
|
* @param actionId 0 para abrir en nueva ventana, 1 para descargar
|
|
2422
2448
|
* @param fileName Nombre del archivo sin extensión
|
|
2423
2449
|
*/
|
|
2424
|
-
handleFileResponse(fileObservable, actionId, fileName) {
|
|
2450
|
+
handleFileResponse(fileObservable, actionId = 0, fileName) {
|
|
2425
2451
|
fileObservable.subscribe({
|
|
2426
2452
|
next: (fileBlob) => {
|
|
2427
2453
|
const fileUrl = URL.createObjectURL(fileBlob);
|
|
@@ -2453,6 +2479,67 @@ class UtilityAddService {
|
|
|
2453
2479
|
break;
|
|
2454
2480
|
}
|
|
2455
2481
|
}
|
|
2482
|
+
/**
|
|
2483
|
+
* Abre un archivo PDF en una nueva pestaña del navegador.
|
|
2484
|
+
*
|
|
2485
|
+
* @param blob - Objeto Blob que contiene los datos del archivo PDF.
|
|
2486
|
+
*
|
|
2487
|
+
* @example
|
|
2488
|
+
* // Uso típico con respuesta de servicio HTTP
|
|
2489
|
+
* this.pdfService.getPdf(id).subscribe(blob => {
|
|
2490
|
+
* this.utilityAddService.PdfView(blob);
|
|
2491
|
+
* });
|
|
2492
|
+
*
|
|
2493
|
+
* @description
|
|
2494
|
+
* Este método crea un URL temporal para el Blob del PDF y lo abre en una nueva
|
|
2495
|
+
* pestaña del navegador. El URL se revoca automáticamente después de 100ms para
|
|
2496
|
+
* liberar memoria.
|
|
2497
|
+
*/
|
|
2498
|
+
PdfView(blob) {
|
|
2499
|
+
// Crear un URL temporal para el Blob
|
|
2500
|
+
const pdfUrl = URL.createObjectURL(blob);
|
|
2501
|
+
// Abrir el PDF en una nueva pestaña
|
|
2502
|
+
window.open(pdfUrl, '_blank');
|
|
2503
|
+
// Liberar el URL del Blob una vez que la pestaña ha sido abierta
|
|
2504
|
+
// Esperar un poco para asegurarse de que el archivo se ha abierto
|
|
2505
|
+
setTimeout(() => {
|
|
2506
|
+
window.URL.revokeObjectURL(pdfUrl);
|
|
2507
|
+
}, 100);
|
|
2508
|
+
}
|
|
2509
|
+
/**
|
|
2510
|
+
* Descarga un archivo PDF con un nombre personalizado que incluye el prefijo "DTE_".
|
|
2511
|
+
*
|
|
2512
|
+
* @param blob - Objeto Blob que contiene los datos del archivo PDF a descargar.
|
|
2513
|
+
* @param filename - Nombre base del archivo sin extensión (se agregará automáticamente ".pdf" y el prefijo "DTE_").
|
|
2514
|
+
*
|
|
2515
|
+
* @example
|
|
2516
|
+
* // Uso típico con respuesta de servicio HTTP
|
|
2517
|
+
* this.dteService.getDTE(operacionId).subscribe(blob => {
|
|
2518
|
+
* this.utilityAddService.downloadPdfFile(blob, '12345');
|
|
2519
|
+
* // Descarga el archivo como: DTE_12345.pdf
|
|
2520
|
+
* });
|
|
2521
|
+
*
|
|
2522
|
+
* @description
|
|
2523
|
+
* Este método crea un URL temporal para el Blob y simula un clic en un enlace de
|
|
2524
|
+
* descarga para iniciar la descarga automática del archivo. El nombre del archivo
|
|
2525
|
+
* sigue el formato: DTE_{filename}.pdf. El URL se revoca después de 100ms para
|
|
2526
|
+
* liberar memoria.
|
|
2527
|
+
*/
|
|
2528
|
+
downloadPdfFile(blob, filename) {
|
|
2529
|
+
// Crear un URL temporal para el Blob
|
|
2530
|
+
const pdfUrl = URL.createObjectURL(blob);
|
|
2531
|
+
// Crear un enlace de descarga
|
|
2532
|
+
const link = document.createElement('a');
|
|
2533
|
+
link.href = pdfUrl;
|
|
2534
|
+
// Establecer el nombre del archivo utilizando el operacionId
|
|
2535
|
+
link.download = `DTE_${filename}.pdf`;
|
|
2536
|
+
// Simular un clic en el enlace para iniciar la descarga
|
|
2537
|
+
link.click();
|
|
2538
|
+
// Liberar el URL del Blob después de un pequeño retraso
|
|
2539
|
+
setTimeout(() => {
|
|
2540
|
+
window.URL.revokeObjectURL(pdfUrl);
|
|
2541
|
+
}, 100);
|
|
2542
|
+
}
|
|
2456
2543
|
forceDownload(fileUrl, fullFileName) {
|
|
2457
2544
|
const downloadLink = document.createElement('a');
|
|
2458
2545
|
downloadLink.href = fileUrl;
|
|
@@ -2893,5 +2980,5 @@ function CUICorrecto(cui) {
|
|
|
2893
2980
|
* Generated bundle index. Do not edit.
|
|
2894
2981
|
*/
|
|
2895
2982
|
|
|
2896
|
-
export { AlertaService, AppMessageErrorComponent, AuthorizeService, CACHE_KEYS, CacheService, CssV2Component, DsxAddToolsModule, ENVIRONMENT, EndpointService, ErrorHandlerService, INITIAL_PARAMETERS, IconDsxComponent, JsonHighlightPipe, JsonValuesDebujComponent, KpicardComponent, LoadingComponent, LoadingLottieComponent, NavbarDsxComponent, OnlyRangoPatternDirective, ParameterValuesService, PrimeNgModule, SWEET_ALERT_THEMES, SecurityService, SelectAllOnFocusDirective, TruncatePipe, UtilityAddService, atLeastOneFieldRequiredValidator, createInitialCache, createTypedCacheProvider, cuiValidator, dateMinMaxValidator, dateRangeValidator, httpAuthorizeInterceptor, nitValidator, provideEnvironment, validateEnvironmentConfig };
|
|
2983
|
+
export { AlertaService, AppMessageErrorComponent, AuthorizeService, CACHE_KEYS, CacheService, CssV2Component, DsxAddToolsModule, DteService, ENVIRONMENT, EndpointService, ErrorHandlerService, INITIAL_PARAMETERS, IconDsxComponent, JsonHighlightPipe, JsonValuesDebujComponent, KpicardComponent, LoadingComponent, LoadingLottieComponent, NavbarDsxComponent, OnlyRangoPatternDirective, ParameterValuesService, PrimeNgModule, SWEET_ALERT_THEMES, SecurityService, SelectAllOnFocusDirective, TruncatePipe, UtilityAddService, atLeastOneFieldRequiredValidator, createInitialCache, createTypedCacheProvider, cuiValidator, dateMinMaxValidator, dateRangeValidator, httpAuthorizeInterceptor, nitValidator, provideEnvironment, validateEnvironmentConfig };
|
|
2897
2984
|
//# sourceMappingURL=ngx-dsxlibrary.mjs.map
|