@cbm-common/view-report
v0.0.1
Published
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 20.1.0.
Readme
ViewReport
This project was generated using Angular CLI version 20.1.0.
Code scaffolding
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
ng generate component component-nameFor a complete list of available schematics (such as components, directives, or pipes), run:
ng generate --helpBuilding
To build the library, run:
ng build view-reportThis command will compile your project, and the build artifacts will be placed in the dist/ directory.
Publishing the Library
Once the project is built, you can publish your library by following these steps:
- Navigate to the
distdirectory:cd dist/view-report - Run the
npm publishcommand to publish your library to the npm registry:npm publish
Running unit tests
To execute unit tests with the Karma test runner, use the following command:
ng testRunning end-to-end tests
For end-to-end (e2e) testing, run:
ng e2eAngular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
Additional Resources
For more information on using the Angular CLI, including detailed command references, visit the Angular CLI Overview and Command Reference page.
@cbm-common/view-report
Documentación en español para la librería @cbm-common/view-report.
Resumen
- Propósito: Componente standalone que muestra y gestiona la visualización de reportes generados por
general-report-repository. Ofrece descarga, impresión y metadatos del reporte. - Paquete:
@cbm-common/view-report(verpackage.json). - Requisitos: Angular 20.1.5 y las librerías peer definidas en
package.json(general-report-repository,record-detail-metadata,upload-repository,user-history,notification-service).
Qué exporta
- Export públicos:
CbmViewReportComponenty el namespaceCbmViewReportModel(versrc/lib/index.ts).
Comportamiento y responsabilidades
CbmViewReportComponentes un componente standalone (ShadowDom, OnPush) que:- Recibe un
reportId(obligatorio) y obtiene el reporte correspondiente medianteCbmGeneralReportRepository. - Muestra metadata (a través de
CbmRecordDetailMetadataComponent) y un historial de auditoría (CbmUserHistoryComponent). - Permite descargar/print el archivo asociado (
upload-repository) y muestra estados de carga/errores mediantenotification-service. - Soporta refresh vía
onRefresh(Observable) para actualizar el estado del reporte en tiempo real.
- Recibe un
Inputs principales del componente
reportId: string(required) — id del reporte a mostrar.collectionName: string(required) — nombre de la colección origen para traducciones.translateCollectionNames: Record<string,string>(required) — mapa para localizar nombres de colección.othersFn?: (request: any) => CbmViewReportModel.ReportData.Others[]— función opcional para derivar campos auxiliares desde el request original.routeToReturn?: string— ruta a la lista de reportes (por defecto../../list).onRefresh?: Observable<CbmViewReportModel.WebSocketReport>— observable para actualizaciones en vivo.
Modelos y tipos
CbmViewReportModel.ReportData— representación enriquecida del reporte (extiende tipos deCbmGeneralReportModel).CbmViewReportModel.WebSocketReport— payload esperado para actualizaciones websocket.CbmViewReportModel.ReportStatusType— 'completed' | 'generating' | 'error'.CbmViewReportModel.Status— 'init' | 'loading' | 'success' | 'failed'.
Ejemplo de uso
import { Component } from '@angular/core';
import { CbmViewReportComponent } from '@cbm-common/view-report';
@Component({
selector: 'app-demo',
template: `
<cbm-view-report
[reportId]="'report-123'"
[collectionName]="'items'"
[translateCollectionNames]="{ items: 'Items' }"
></cbm-view-report>
`,
standalone: true,
imports: [CbmViewReportComponent],
})
export class DemoComponent {}Notas de implementación
- El componente depende de varias librerías internas:
@g2-common/general-report-repositorypara obtener datos del reporte.@g2-common/upload-repositorypara descargar el archivo asociado (blob).@g2-common/record-detail-metadatay@g2-common/user-historypara mostrar metadata y auditoría.@g2-common/notification-servicepara mostrar notificaciones de error/éxito.
- Manejo de archivos: descarga de blob y apertura/impresión se implementa en
downloadExcel,downloadPdfyprintPdf.
Build y publicación
Para compilar la librería (desde la raíz del workspace):
ng build view-reportLos artefactos estarán en dist/view-report. Para publicar:
cd dist/view-report
npm publishTests
- Ejecutar tests unitarios con
ng testsi están configurados.
Siguientes pasos sugeridos
- Documentar los contratos exactos de respuesta en
general-report-repositorypara garantizar compatibilidad dereport.request. - Añadir tests unitarios para
CbmViewReportComponent(simular repositorios con mocks yHttpClientTestingModulesi es necesario). - Añadir ejemplos de integración (story/stackblitz) si quieres una demo rápida.
Estado: README.md actualizado en español, alineado con el código fuente del paquete.
ViewReport
This project was generated using Angular CLI version 20.1.0.
Code scaffolding
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
ng generate component component-nameFor a complete list of available schematics (such as components, directives, or pipes), run:
ng generate --helpBuilding
To build the library, run:
ng build view-reportThis command will compile your project, and the build artifacts will be placed in the dist/ directory.
Publishing the Library
Once the project is built, you can publish your library by following these steps:
Navigate to the
distdirectory:cd dist/view-reportRun the
npm publishcommand to publish your library to the npm registry:npm publish
Running unit tests
To execute unit tests with the Karma test runner, use the following command:
ng testRunning end-to-end tests
For end-to-end (e2e) testing, run:
ng e2eAngular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
Additional Resources
For more information on using the Angular CLI, including detailed command references, visit the Angular CLI Overview and Command Reference page.
