cat-documents-ng 0.1.30 → 0.1.32

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.
Files changed (92) hide show
  1. package/{src/Shared/constant/ERROR.ts → Shared/constant/ERROR.d.ts} +43 -38
  2. package/Shared/constant/PERMISSIONS.d.ts +20 -0
  3. package/Shared/constant/SHARED.d.ts +215 -0
  4. package/{src/Shared/constant/URLS.ts → Shared/constant/URLS.d.ts} +60 -65
  5. package/Shared/services/app-config.service.d.ts +51 -0
  6. package/{src/Shared/services/global-error.handler.ts → Shared/services/global-error.handler.d.ts} +27 -29
  7. package/Shared/services/session.service.d.ts +46 -0
  8. package/fesm2022/cat-documents-ng.mjs +2623 -0
  9. package/fesm2022/cat-documents-ng.mjs.map +1 -0
  10. package/index.d.ts +5 -0
  11. package/lib/document/components/document-container/document-container.component.d.ts +101 -0
  12. package/lib/document/components/document-list/document-list.component.d.ts +193 -0
  13. package/lib/document/components/document-list-item/document-list-item.component.d.ts +28 -0
  14. package/lib/document/components/document-upload/document-upload.component.d.ts +120 -0
  15. package/lib/document/components/document-viewer/document-viewer.component.d.ts +77 -0
  16. package/{src/lib/document/components/folder-block/folder-block.component.ts → lib/document/components/folder-block/folder-block.component.d.ts} +37 -53
  17. package/lib/document/components/folder-container/folder-container.component.d.ts +29 -0
  18. package/lib/document/components/linked-document/linked-document.component.d.ts +38 -0
  19. package/lib/document/directives/document.directive.d.ts +20 -0
  20. package/lib/document/directives/permission.directive.d.ts +38 -0
  21. package/lib/document/document.module.d.ts +40 -0
  22. package/{src/lib/document/models/document-alert.model.ts → lib/document/models/document-alert.model.d.ts} +38 -45
  23. package/lib/document/models/document-type.model.d.ts +37 -0
  24. package/lib/document/models/document.model.d.ts +44 -0
  25. package/{src/lib/document/models/folder.model.ts → lib/document/models/folder.model.d.ts} +29 -35
  26. package/lib/document/services/document-http.service.d.ts +69 -0
  27. package/lib/document/services/document-upload.service.d.ts +67 -0
  28. package/lib/document/services/document.service.d.ts +20 -0
  29. package/lib/document/services/file-format.service.d.ts +23 -0
  30. package/lib/document/state/document.query.d.ts +50 -0
  31. package/{src/lib/document/state/document.service.ts → lib/document/state/document.service.d.ts} +64 -95
  32. package/{src/lib/document/state/document.state.ts → lib/document/state/document.state.d.ts} +36 -52
  33. package/lib/document/state/document.store.d.ts +29 -0
  34. package/package.json +25 -20
  35. package/{src/public-api.ts → public-api.d.ts} +6 -10
  36. package/ng-package.json +0 -11
  37. package/src/Shared/constant/PERMISSIONS.ts +0 -16
  38. package/src/Shared/constant/SHARED.ts +0 -312
  39. package/src/Shared/services/app-config.service.spec.ts +0 -19
  40. package/src/Shared/services/app-config.service.ts +0 -73
  41. package/src/Shared/services/session.service.spec.ts +0 -16
  42. package/src/Shared/services/session.service.ts +0 -76
  43. package/src/assets/config/api.config.json +0 -20
  44. package/src/lib/document/components/document-container/document-container.component.html +0 -14
  45. package/src/lib/document/components/document-container/document-container.component.scss +0 -8
  46. package/src/lib/document/components/document-container/document-container.component.spec.ts +0 -110
  47. package/src/lib/document/components/document-container/document-container.component.ts +0 -173
  48. package/src/lib/document/components/document-list/document-list.component.html +0 -81
  49. package/src/lib/document/components/document-list/document-list.component.scss +0 -82
  50. package/src/lib/document/components/document-list/document-list.component.spec.ts +0 -96
  51. package/src/lib/document/components/document-list/document-list.component.ts +0 -244
  52. package/src/lib/document/components/document-list-item/document-list-item.component.html +0 -36
  53. package/src/lib/document/components/document-list-item/document-list-item.component.scss +0 -34
  54. package/src/lib/document/components/document-list-item/document-list-item.component.spec.ts +0 -75
  55. package/src/lib/document/components/document-list-item/document-list-item.component.ts +0 -40
  56. package/src/lib/document/components/document-upload/document-upload.component.html +0 -56
  57. package/src/lib/document/components/document-upload/document-upload.component.scss +0 -32
  58. package/src/lib/document/components/document-upload/document-upload.component.spec.ts +0 -95
  59. package/src/lib/document/components/document-upload/document-upload.component.ts +0 -162
  60. package/src/lib/document/components/document-viewer/document-viewer.component.html +0 -98
  61. package/src/lib/document/components/document-viewer/document-viewer.component.scss +0 -54
  62. package/src/lib/document/components/document-viewer/document-viewer.component.spec.ts +0 -79
  63. package/src/lib/document/components/document-viewer/document-viewer.component.ts +0 -106
  64. package/src/lib/document/components/folder-block/folder-block.component.html +0 -46
  65. package/src/lib/document/components/folder-block/folder-block.component.scss +0 -9
  66. package/src/lib/document/components/folder-block/folder-block.component.spec.ts +0 -70
  67. package/src/lib/document/components/folder-container/folder-container.component.html +0 -2
  68. package/src/lib/document/components/folder-container/folder-container.component.scss +0 -0
  69. package/src/lib/document/components/folder-container/folder-container.component.spec.ts +0 -27
  70. package/src/lib/document/components/folder-container/folder-container.component.ts +0 -37
  71. package/src/lib/document/components/linked-document/linked-document.component.html +0 -23
  72. package/src/lib/document/components/linked-document/linked-document.component.scss +0 -10
  73. package/src/lib/document/components/linked-document/linked-document.component.spec.ts +0 -61
  74. package/src/lib/document/components/linked-document/linked-document.component.ts +0 -49
  75. package/src/lib/document/directives/document.directive.ts +0 -32
  76. package/src/lib/document/directives/permission.directive.spec.ts +0 -0
  77. package/src/lib/document/directives/permission.directive.ts +0 -66
  78. package/src/lib/document/document.module.ts +0 -241
  79. package/src/lib/document/models/document-type.model.ts +0 -44
  80. package/src/lib/document/models/document.model.ts +0 -53
  81. package/src/lib/document/services/document-http.service.spec.ts +0 -119
  82. package/src/lib/document/services/document-http.service.ts +0 -125
  83. package/src/lib/document/services/document-upload.service.spec.ts +0 -99
  84. package/src/lib/document/services/document-upload.service.ts +0 -127
  85. package/src/lib/document/services/document.service.ts +0 -29
  86. package/src/lib/document/services/file-format.service.spec.ts +0 -16
  87. package/src/lib/document/services/file-format.service.ts +0 -41
  88. package/src/lib/document/state/document.query.ts +0 -52
  89. package/src/lib/document/state/document.store.ts +0 -51
  90. package/tsconfig.lib.json +0 -15
  91. package/tsconfig.lib.prod.json +0 -11
  92. package/tsconfig.spec.json +0 -15
@@ -1,36 +0,0 @@
1
- <div class="grid m-0">
2
- <div
3
- class="col-12 flex align-items-center justify-content-between md:col-12 xl:col-12"
4
- >
5
- <div
6
- class="col-5 flex cursor-pointer align-items-center pl-0"
7
- (click)="handleOpenDocument(document)"
8
- >
9
- <img src="../../../../assets/images/Frame.png" alt="" />
10
- <span class="ml-4 file-name-wrapper document-text-wrapper">{{ document.fileName }}</span>
11
- </div>
12
- <div class="col-4 flex align-items-center justify-content-center">
13
- <span
14
- [class]="'product-badge status-' + document.status?.toLowerCase()"
15
- class="flex align-items-center justify-content-center pl-2 pr-2 pt-1 pb-1"
16
- >
17
- <ng-container *ngIf="document.status?.toLowerCase() === 'pending'">
18
- <i class="pi pi-clock pr-1" style="font-size: 12px;"></i>
19
- Pending
20
- </ng-container>
21
- <ng-container *ngIf="document.status?.toLowerCase() === 'verified'">
22
- <i class="pi pi-check-circle pr-1" style="font-size: 12px;"></i>
23
- Verified
24
- </ng-container>
25
- <ng-container *ngIf="document.status?.toLowerCase() === 'alert'">
26
- <i class="pi pi-bell pr-1" style="font-size: 12px;"></i>
27
- Alert
28
- </ng-container>
29
- </span>
30
- </div>
31
- <div class="document-type file-name-wrapper document-text-wrapper">
32
- {{document.documentTypeName}}
33
- </div>
34
- </div>
35
- </div>
36
-
@@ -1,34 +0,0 @@
1
- .product-badge.status-pending {
2
- background: #e9b127;
3
- color: #ffffff;
4
- border-radius: 4px;
5
- }
6
- .product-badge.status-verified {
7
- background: #4caf50;
8
- color: #ffffff;
9
- border-radius: 4px;
10
- }
11
- .product-badge.status-alert {
12
- background: #f57c00;
13
- color: #ffffff;
14
- border-radius: 4px;
15
- }
16
- .product-badge {
17
- text-transform: none;
18
- font-weight: 500;
19
- font-size: 12px;
20
-
21
- }
22
-
23
- .file-name-wrapper{
24
- font-size: 15px;
25
- font-weight: 500;
26
- }
27
-
28
- .document-text-wrapper{
29
- display: -webkit-box;
30
- -webkit-line-clamp: 1;
31
- -webkit-box-orient: vertical;
32
- overflow: hidden;
33
- text-overflow: ellipsis;
34
- }
@@ -1,75 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
- import { DocumentListItemComponent } from './document-list-item.component';
3
- import { CommonModule } from '@angular/common';
4
- import { By } from '@angular/platform-browser';
5
- import { DocumentModel } from '../../models/document.model';
6
-
7
- describe('DocumentListItemComponent', () => {
8
- let component: DocumentListItemComponent;
9
- let fixture: ComponentFixture<DocumentListItemComponent>;
10
-
11
- beforeEach(async () => {
12
- await TestBed.configureTestingModule({
13
- declarations: [DocumentListItemComponent],
14
- imports: [CommonModule],
15
- }).compileComponents();
16
-
17
- fixture = TestBed.createComponent(DocumentListItemComponent);
18
- component = fixture.componentInstance;
19
- component.document = {
20
- _id : "1",
21
- fileName : 'test',
22
- }
23
- fixture.detectChanges();
24
- });
25
-
26
- it('should create', () => {
27
- expect(component).toBeTruthy();
28
- });
29
-
30
- it('should emit the selected document when handleOpenDocument is called', () => {
31
- spyOn(component.documentClick, 'emit');
32
- const mockDocument = { _id: "1", fileName: 'test' } as DocumentModel;
33
- component.handleOpenDocument(mockDocument);
34
- expect(component.documentClick.emit).toHaveBeenCalledWith(mockDocument);
35
- });
36
-
37
- it('should log an error when handleOpenDocument is called with null', () => {
38
- spyOn(console, 'error');
39
- component.handleOpenDocument(null as unknown as DocumentModel);
40
-
41
- expect(console.error).toHaveBeenCalledWith('Error: Document is null or undefined:', null);
42
- });
43
-
44
- it('should emit documentClick event when document is clicked', () => {
45
- spyOn(component.documentClick, 'emit');
46
- const clickableElement = fixture.debugElement.query(By.css('.cursor-pointer'));
47
- clickableElement.triggerEventHandler('click', null);
48
-
49
- expect(component.documentClick.emit).toHaveBeenCalledWith(component.document);
50
- });
51
-
52
- it('should display Pending status with the correct icon', () => {
53
- component.document.status = 'Pending';
54
- fixture.detectChanges();
55
-
56
- const statusElement = fixture.debugElement.query(By.css('.status-pending')).nativeElement;
57
- const iconElement = fixture.debugElement.query(By.css('.pi-clock')).nativeElement;
58
-
59
- expect(statusElement.textContent).toContain('Pending');
60
- expect(iconElement).toBeTruthy();
61
- });
62
-
63
- it('should display Verified status with the correct icon', () => {
64
- component.document.status = 'Verified';
65
- fixture.detectChanges();
66
-
67
- const statusElement = fixture.debugElement.query(By.css('.status-verified')).nativeElement;
68
- const iconElement = fixture.debugElement.query(By.css('.pi-check-circle')).nativeElement;
69
-
70
- expect(statusElement.textContent).toContain('Verified');
71
- expect(iconElement).toBeTruthy();
72
- });
73
-
74
-
75
- });
@@ -1,40 +0,0 @@
1
- import { Component, EventEmitter, Input, Output } from '@angular/core';
2
- import { DocumentModel } from '../../models/document.model';
3
-
4
- /**
5
- * DocumentListItemComponent
6
- *
7
- * This component displays individual document items within a list.
8
- * It accepts a list of documents as input and handles interactions with documents.
9
- */
10
- @Component({
11
- selector: 'lib-document-list-item',
12
- standalone: false,
13
- templateUrl: './document-list-item.component.html',
14
- styleUrls: ['./document-list-item.component.scss']
15
- })
16
- export class DocumentListItemComponent {
17
- /**
18
- * Emit the selected document.
19
- * @type {EventEmitter<DocumentModel>}
20
- */
21
- @Output() documentClick = new EventEmitter<DocumentModel>();
22
-
23
- /**
24
- * The document to display.
25
- * @type {DocumentModel[]}
26
- */
27
- @Input() document!: DocumentModel;
28
-
29
- /**
30
- * Handles interactions with a document.
31
- * @param {DocumentModel} document - The document to be opened or interacted with.
32
- */
33
- handleOpenDocument(document: DocumentModel): void {
34
- if (!document) {
35
- console.error('Error: Document is null or undefined:', document);
36
- return;
37
- }
38
- this.documentClick.emit(document);
39
- }
40
- }
@@ -1,56 +0,0 @@
1
- <div class="grid">
2
- <div class="col-12 md:col-12">
3
- <p-fileUpload #fileUploader [multiple]="true" auto="true" accept="image/png,application/pdf" maxFileSize="26214400"
4
- (onSelect)="onSelectedFiles($event)">
5
- <ng-template pTemplate="header" let-chooseCallback="chooseCallback" let-clearCallback="clearCallback">
6
- <div class="docHeader p-2 flex flex-wrap justify-content-between align-items-center flex-1 gap-2">
7
- <div class="flex gap-2">
8
- <p-button (onClick)="choose($event, chooseCallback)" icon="pi pi-images" [rounded]="true"
9
- [outlined]="true" />
10
- </div>
11
- </div>
12
- </ng-template>
13
- <ng-template pTemplate="content" let-removeFileCallback="removeFileCallback"
14
- let-removeUploadedFileCallback="removeUploadedFileCallback">
15
- <div class="col-12 md:col-12 p-0">
16
- <div class="col-12 md:col-12 p-0" *ngIf="uploadedFiles.length > 0">
17
- <div *ngFor="let uploadedFile of uploadedFiles; let i = index"
18
- class="m-0 flex flex-column align-items-center gap-1 mt-3">
19
- <div class="col-12 md:col-12 p-0 flex documentInfo">
20
- <div class="documentImage">
21
- <img src="../../../../assets/images/document.png" [alt]="uploadedFile.file.name" width="45" height="50"
22
- class="object-contain" />
23
- </div>
24
- <div class="flex w-full flex-column mt-2 ml-2">
25
- <div class="flex justify-content-between">
26
- <div style=" font-weight: bold;font-size: 14px">
27
- {{ uploadedFile.file.name }}
28
- </div>
29
- <i class="pi pi-times cursor-pointer" (click)="handleDocumentRemove(uploadedFile.file,i)"></i>
30
- </div>
31
- <div class="flex justify-content-between mt-1">
32
- <div style="color: #676B89; font-size: 12px; color: green;" class="pi pi-verified "> {{ uploadedFile.formattedSize }}</div>
33
- <div class="white-space-nowrap" style="color: #0F8BFD; font-family: 14px;"> {{ uploadedFile.progress }} %</div>
34
- </div>
35
- </div>
36
- </div>
37
- <div class="col-12 md:col-12 p-0">
38
- <p-progressBar [value]="totalSizePercent" [showValue]="false" styleClass="h-1/2rem md:ml-auto relative"
39
- [ngClass]="{ 'exceeded-progress-bar': totalSizePercent > 100 }">
40
- </p-progressBar>
41
- </div>
42
- </div>
43
- </div>
44
- </div>
45
- </ng-template>
46
- <ng-template pTemplate="empty" let-chooseCallback="chooseCallback">
47
- <div *ngIf="!uploadedFiles.length" class="flex align-items-center justify-content-center flex-column"
48
- (click)="triggerFileUpload()">
49
- <i class="pi pi-cloud-upload border-2 border-circle p-5 text-8xl text-400 border-400"></i>
50
- <p class="mt-4 mb-0">Drag and drop files here to upload.</p>
51
- </div>
52
- </ng-template>
53
- <ng-template pTemplate="file"> </ng-template>
54
- </p-fileUpload>
55
- </div>
56
- </div>
@@ -1,32 +0,0 @@
1
- .flex {
2
- display: flex;
3
- }
4
- .items-center {
5
- align-items: center;
6
- }
7
- .justify-center {
8
- justify-content: center;
9
- }
10
- .flex-col {
11
- flex-direction: column;
12
- }
13
- .text-muted-color {
14
- color: #6c757d; // Adjust to match your theme
15
- }
16
- .p-fileupload-buttonbar {
17
- padding: 0px;
18
- }
19
- .p-fileupload-content {
20
- background-color: #0f8bfd1a;
21
- }
22
- .p-fileupload {
23
- .p-fileupload-content {
24
- padding: 1rem 1rem;
25
- }
26
-
27
- }
28
- .docHeader{
29
- .p-button-icon{
30
- padding: 0.5rem;
31
- }
32
- }
@@ -1,95 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
- import { DocumentUploadComponent } from './document-upload.component';
3
- import { FileUploadModule } from 'primeng/fileupload';
4
- import { HttpClientTestingModule } from '@angular/common/http/testing';
5
- import { MessageService, PrimeNGConfig } from 'primeng/api';
6
- import { ChangeDetectorRef } from '@angular/core';
7
- import { FileFormatService } from '../../services/file-format.service';
8
- import { DocumentService } from '../../state/document.service';
9
- import { DocumentUploadService } from '../../services/document-upload.service';
10
-
11
- describe('DocumentUploadComponent', () => {
12
- let component: DocumentUploadComponent;
13
- let fixture: ComponentFixture<DocumentUploadComponent>;
14
- let mockFileFormatService: jasmine.SpyObj<FileFormatService>;
15
- let mockDocumentService: jasmine.SpyObj<DocumentService>;
16
- let mockDocumentUploadService: jasmine.SpyObj<DocumentUploadService>;
17
-
18
- beforeEach(async () => {
19
- mockFileFormatService = jasmine.createSpyObj('FileFormatService', ['formatFileSize']);
20
- mockDocumentService = jasmine.createSpyObj('DocumentService', ['uploadDocument']);
21
- mockDocumentUploadService = jasmine.createSpyObj('DocumentUploadService', ['getUploadFileData']);
22
-
23
- await TestBed.configureTestingModule({
24
- declarations: [DocumentUploadComponent],
25
- imports: [FileUploadModule, HttpClientTestingModule],
26
- providers: [
27
- MessageService,
28
- PrimeNGConfig,
29
- ChangeDetectorRef,
30
- { provide: FileFormatService, useValue: mockFileFormatService },
31
- { provide: DocumentService, useValue: mockDocumentService },
32
- { provide: DocumentUploadService, useValue: mockDocumentUploadService },
33
- ],
34
- }).compileComponents();
35
-
36
- fixture = TestBed.createComponent(DocumentUploadComponent);
37
- component = fixture.componentInstance;
38
- fixture.detectChanges();
39
- });
40
-
41
- it('should create', () => {
42
- expect(component).toBeTruthy();
43
- });
44
-
45
- it('should trigger file upload dialog when triggerFileUpload is called', () => {
46
- spyOn(component.fileUploader, 'choose');
47
- component.triggerFileUpload();
48
- expect(component.fileUploader.choose).toHaveBeenCalled();
49
- });
50
-
51
- it('should handle file selection and upload', () => {
52
- const mockFile = new File(['content'], 'test.pdf', { type: 'application/pdf' });
53
- const event = { currentFiles: [mockFile] };
54
- mockFileFormatService.formatFileSize.and.returnValue('10 KB');
55
- component.onSelectedFiles(event);
56
- expect(mockDocumentUploadService.getUploadFileData).toHaveBeenCalledWith(mockFile, component.contextId);
57
- expect(component.uploadedFiles.length).toBe(1);
58
- expect(component.uploadedFiles[0].file).toBe(mockFile);
59
- expect(component.uploadedFiles[0].formattedSize).toBe('10 KB');
60
- expect(component.uploadedFiles[0].progress).toBe(100);
61
- });
62
-
63
- it('should remove a file from the uploaded files list', () => {
64
- const mockFile = new File(['content'], 'test.pdf', { type: 'application/pdf' });
65
- component.uploadedFiles = [
66
- { file: mockFile, formattedSize: '10 KB', progress: 100 },
67
- ];
68
- const fileProgressSpy = spyOn(component.fileProgress, 'delete');
69
- component.handleDocumentRemove(mockFile, 0);
70
- expect(component.uploadedFiles.length).toBe(0);
71
- expect(fileProgressSpy).toHaveBeenCalledWith(mockFile);
72
- });
73
-
74
- it('should calculate and return file progress', () => {
75
- const mockFile = new File(['content'], 'test.pdf', { type: 'application/pdf' });
76
- component.fileProgress.set(mockFile, 75);
77
- const progress = component.getProgress(mockFile);
78
- expect(progress).toBe(75);
79
- });
80
-
81
- it('should format file size correctly', () => {
82
- mockFileFormatService.formatFileSize.and.returnValue('10 KB');
83
- component.formatSize(10240);
84
- expect(component.fileSize).toBe('10 KB');
85
- expect(mockFileFormatService.formatFileSize).toHaveBeenCalledWith(10240, jasmine.any(PrimeNGConfig));
86
- });
87
-
88
- it('should clear files after selection', () => {
89
- spyOn(component.fileUploader, 'clear');
90
- const mockFile = new File(['content'], 'test.pdf', { type: 'application/pdf' });
91
- const event = { currentFiles: [mockFile] };
92
- component.onSelectedFiles(event);
93
- expect(component.fileUploader.clear).toHaveBeenCalled();
94
- });
95
- });
@@ -1,162 +0,0 @@
1
- import { ChangeDetectorRef, Component, Input, ViewChild, ViewEncapsulation } from '@angular/core';
2
- import { FileUpload } from 'primeng/fileupload';
3
- import { MessageService } from 'primeng/api';
4
- import { PrimeNGConfig } from 'primeng/api';
5
- import { SHARED } from '../../../../Shared/constant/SHARED';
6
- import { FileFormatService } from '../../services/file-format.service';
7
- import { DocumentService } from '../../state/document.service';
8
- import { DocumentUploadService } from '../../services/document-upload.service';
9
-
10
- /**
11
- * A component for handling document uploads, including file selection, removal, and progress tracking.
12
- * @class DocumentUploadComponent
13
- */
14
- @Component({
15
- selector: 'lib-document-upload',
16
- templateUrl: './document-upload.component.html',
17
- styleUrls: ['./document-upload.component.scss'],
18
- standalone: false,
19
- encapsulation: ViewEncapsulation.None
20
- })
21
- export class DocumentUploadComponent {
22
-
23
-
24
- /**
25
- * Represents the file size.
26
- * @type {number}
27
- */
28
- fileSize: string = SHARED.EMPTY;
29
- /**
30
- * Represent contextId
31
- * @type {string}
32
- */
33
- @Input() contextId: string = SHARED.EMPTY
34
-
35
- /**
36
- * To make file explorer visible.
37
- * @type {!FileUpload}
38
- */
39
- @ViewChild('fileUploader') fileUploader!: FileUpload;
40
-
41
- fileProgress: Map<File, number> = new Map();
42
-
43
- /**
44
- * List of files selected for upload.
45
- * @type {File[]}
46
- */
47
- uploadedFiles: { file: File; formattedSize: string; progress: number }[] = [];
48
-
49
-
50
- /**
51
- * Percentage of the total size calculated for displaying upload progress.
52
- * @type {number}
53
- */
54
- totalSizePercent: number = SHARED.INITIAL_COUNT;
55
-
56
- /**
57
- * The current upload progress percentage (SHARED.INITIAL_VALUE-100).
58
- * @type {number}
59
- */
60
- uploadProgress: number = SHARED.INITIAL_COUNT;
61
-
62
-
63
- /**
64
- * Creates an instance of DocumentUploadComponent.
65
- * @class
66
- * @param {DocumentUploadService} documentUpload - Service for handling document upload.
67
- * @param {DocumentService} uploadService - Service for handling document upload.
68
- * @param {PrimeNGConfig} config - PrimeNG configuration.
69
- * @param {FileFormatService} fileFormatService - Service for formatting file sizes.
70
- * @param {MessageService} messageService - Service for displaying messages.
71
- * @param {ChangeDetectorRef} cdr - Service for detecting changes.
72
- */
73
- constructor(public documentUpload : DocumentUploadService,public uploadService: DocumentService, private config: PrimeNGConfig, public fileFormatService: FileFormatService, public messageService: MessageService, public cdr: ChangeDetectorRef) { }
74
-
75
- /**
76
- * Open the file explorer.
77
- * @param {*} event - The triggering event.
78
- * @param {() => void} callback - A callback function to execute.
79
- * @returns {void} - No return value.
80
- */
81
- choose(event: any, callback: () => void) {
82
- callback();
83
- }
84
-
85
- /**
86
- * Prepares the files for upload by creating a FormData object.
87
- * This method appends each file to the FormData for submission.
88
- * @param {File} file - The file to upload.
89
- * @returns {void}
90
- */
91
- handleTemplatedUpload(file: File) {
92
- this.documentUpload.getUploadFileData(file, this.contextId)
93
- const formattedSize = this.fileFormatService.formatFileSize(file.size, this.config);
94
- const progress = 100;
95
- this.uploadedFiles.push({ file, formattedSize, progress });
96
- this.fileProgress.set(file, progress);
97
- this.totalSizePercent = 100;
98
- }
99
-
100
- /**
101
- * Handle the creation of formdata.
102
- * @param {File} file - The file to append in formdata.
103
- * @returns {*} - The formdata object.
104
- */
105
- handleCreateFormData(file: File) {
106
- const formData = new FormData();
107
- formData.append(SHARED.FILE, file, file.name);
108
- formData.append(SHARED.CONTEXT_ID, this.contextId)
109
- return formData;
110
- }
111
- /**
112
- * Handles the event when new files are selected.
113
- * @param { { currentFiles: File[] } } event - The event containing the newly selected files.
114
- * @returns {void} - No return value.
115
- */
116
- onSelectedFiles(event: { currentFiles: File[] }): void {
117
- event.currentFiles.forEach((file: File) => {
118
- this.handleTemplatedUpload(file);
119
- });
120
- this.fileUploader.clear();
121
- }
122
-
123
- /**
124
- * Formats the given file size in bytes into a readable format (e.g., KB, MB).
125
- * @param {number} bytes - The size of the file in bytes.
126
- * @returns {string} The formatted file size (e.g., '1.2 KB', '2.3 MB').
127
- */
128
- formatSize(bytes: number) {
129
- this.fileSize = this.fileFormatService.formatFileSize(bytes, this.config)
130
- }
131
-
132
- /**
133
- * Handles the removal of a file from the uploaded files list.
134
- * @param {File} file - The file to be removed.
135
- * @param {number} index - The index of the file in the uploaded files list.
136
- */
137
- handleDocumentRemove(file: File, index: number): void {
138
- this.uploadedFiles.splice(index, 1);
139
- this.fileProgress.delete(file);
140
- this.cdr.detectChanges();
141
- }
142
-
143
- /**
144
- * Major progress for the progress bar.
145
- * @param {File} file - File to check progress for.
146
- * @returns {number} - The progress percentage for the file.
147
- */
148
- getProgress(file: File): number {
149
- return this.fileProgress.get(file) || SHARED.INITIAL_COUNT;
150
- }
151
-
152
- /**
153
- * Triggers the file upload dialog.
154
- * Opens the file explorer for selecting files.
155
- * @returns {void}
156
- */
157
- triggerFileUpload() {
158
- this.fileUploader.choose();
159
- }
160
-
161
- }
162
-
@@ -1,98 +0,0 @@
1
- <div class="grid">
2
- <div class="col-12">
3
- <div class="p-fluid p-formgrid grid m-0">
4
- <div class="col-12 md:col-12 md:flex justify-content-evenly">
5
- @if(selectedDocument){
6
- <div id="outerContainer col-12 md:col-7">
7
- <div
8
- *ngIf="isImage(selectedDocument?.contentType)"
9
- class="img-container"
10
- >
11
- <img
12
- [src]="selectedDocument?.documentUrl || ''"
13
- class="uploadedImages"
14
- alt="Document Image"
15
- />
16
- </div>
17
- @if(selectedDocument?.contentType && selectedDocument?.contentType === "application/pdf"){
18
- <div class="pdf-container">
19
- <pdf-viewer
20
- [src]="selectedDocument?.documentUrl || ''"
21
- [rotation]="0"
22
- [original-size]="false"
23
- [show-all]="true"
24
- [fit-to-page]="false"
25
- [zoom]="1"
26
- [zoom-scale]="'page-width'"
27
- [stick-to-page]="false"
28
- [render-text]="true"
29
- [external-link-target]="'blank'"
30
- [autoresize]="true"
31
- [show-borders]="false"
32
- style="width: 50vw; height: 75vh"
33
- ></pdf-viewer>
34
- </div>
35
- }@else{
36
- <div class="incorrect-docType">
37
- ContentType is incorrect.
38
- </div>
39
- }
40
- </div>
41
- }
42
-
43
- <div class="left-part col-12 md:col-3 pt-0">
44
- <div class="alerts mb-4 pb-1">
45
- <button
46
- type="button"
47
- *ngIf="
48
- (alertData?.status !== 'Pending' && !!alertData?.status) ||
49
- alertData?.isAlert === false
50
- "
51
- class="bg-green-500 border-none border-round-md flex align-items-center mb-3 p-2 px-3"
52
- >
53
- <i
54
- class="pi pi-verified mr-2 cursor-pointer"
55
- [ngStyle]="{
56
- color:
57
- alertData?.status === 'Pending' &&
58
- alertData?.isAlert !== false
59
- ? '#FFFFFF'
60
- : '#8A8EA6'
61
- }"
62
- style="font-size: 20px"
63
- ></i>
64
- <span class="font-semibold text-white">Verified</span>
65
- </button>
66
- <div
67
- class="card mb-0"
68
- [ngClass]="
69
- (alertData?.status === 'Pending' || !alertData?.status) &&
70
- alertData?.isAlert !== false
71
- ? 'alert-card'
72
- : 'success-alert'
73
- "
74
- >
75
- <div class="flex align-items-center mb-2 pb-1" *ngIf="alertData?.status !== 'Verified'">
76
- <h4 class="mr-3 mt-0 mb-0 text-color font-bold" style="font-size: 21px; font-weight: bold; border-color: rgba(68, 72, 109, 0.2) ;" >Alerts</h4>
77
- <i
78
- class="pi pi-exclamation-triangle"
79
- style="font-size: 20px"
80
- [ngStyle]="{
81
- color:
82
- (alertData?.status === 'Pending' || !alertData?.status) &&
83
- alertData?.isAlert !== false
84
- ? '#FB392D'
85
- : '#8A8EA6'
86
- }"
87
- ></i>
88
- </div>
89
- <p class="text-color mb-0">{{ alertData?.alertMessage }}</p>
90
- </div>
91
- </div>
92
- <ng-content></ng-content>
93
- <app-linked-document (selectedDocumentChange)="handleSelectedDocument($event)" [selectedDocument]="selectedDocument" [documentList]="documentList"></app-linked-document>
94
- </div>
95
- </div>
96
- </div>
97
- </div>
98
- </div>