cat-documents-ng 1.0.2 → 1.0.4
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.
- package/README.md +298 -35
- package/Shared/components/confirmation-dialog/confirmation-dialog.component.d.ts +44 -0
- package/Shared/components/table-primary/table-primary.component.d.ts +31 -0
- package/Shared/components/table-primary/table-primary.model.d.ts +19 -0
- package/Shared/constant/ERROR.d.ts +52 -0
- package/Shared/constant/SHARED.d.ts +546 -0
- package/Shared/constant/URLS.d.ts +123 -0
- package/Shared/services/app-config.service.d.ts +51 -0
- package/{projects/cat-document-lib/src/shared/services/global-error.handler.ts → Shared/services/global-error.handler.d.ts} +9 -11
- package/Shared/services/session.service.d.ts +46 -0
- package/Shared/shared.module.d.ts +14 -0
- package/fesm2022/cat-documents-ng.mjs +11392 -0
- package/fesm2022/cat-documents-ng.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/document/components/document-actions/document-actions.component.d.ts +78 -0
- package/lib/document/components/document-container/document-container.component.d.ts +162 -0
- package/lib/document/components/document-content-viewer/document-content-viewer.component.d.ts +291 -0
- package/lib/document/components/document-history/document-history.component.d.ts +160 -0
- package/lib/document/components/document-list/document-list.component.d.ts +299 -0
- package/lib/document/components/document-list-item/document-list-item.component.d.ts +28 -0
- package/lib/document/components/document-search/document-search.component.d.ts +77 -0
- package/lib/document/components/document-status/document-status.component.d.ts +24 -0
- package/lib/document/components/document-upload/document-upload.component.d.ts +321 -0
- package/lib/document/components/document-viewer/document-viewer.component.d.ts +137 -0
- package/lib/document/components/document-zoom-controls/document-zoom-controls.component.d.ts +33 -0
- package/lib/document/components/documents-menu/documents-menu.component.d.ts +110 -0
- package/{projects/cat-document-lib/src/lib/document/components/folder-block/folder-block.component.ts → lib/document/components/folder-block/folder-block.component.d.ts} +12 -26
- package/lib/document/components/folder-container/folder-container.component.d.ts +162 -0
- package/lib/document/components/linked-document/linked-document.component.d.ts +39 -0
- package/lib/document/components/request-document/request-document.component.d.ts +69 -0
- package/lib/document/components/sidebar/sidebar.component.d.ts +109 -0
- package/lib/document/components/user-list/user-list.component.d.ts +34 -0
- package/lib/document/constant/DOCUMENT_HISTORY.d.ts +41 -0
- package/lib/document/directives/document.directive.d.ts +20 -0
- package/lib/document/directives/permission.directive.d.ts +38 -0
- package/lib/document/document.module.d.ts +60 -0
- package/lib/document/models/document-alert.model.d.ts +38 -0
- package/lib/document/models/document-category.model.d.ts +24 -0
- package/lib/document/models/document-history.model.d.ts +94 -0
- package/lib/document/models/document-list-response.model.d.ts +33 -0
- package/lib/document/models/document-type.model.d.ts +37 -0
- package/lib/document/models/document.model.d.ts +44 -0
- package/{projects/cat-document-lib/src/lib/document/models/folder.model.ts → lib/document/models/folder.model.d.ts} +7 -13
- package/lib/document/models/status-data.model.d.ts +27 -0
- package/lib/document/models/uploaded-file-response.model.d.ts +7 -0
- package/lib/document/models/user-list.model.d.ts +8 -0
- package/lib/document/services/csv-parser.service.d.ts +88 -0
- package/lib/document/services/document-actions.service.d.ts +48 -0
- package/lib/document/services/document-content-type.service.d.ts +85 -0
- package/lib/document/services/document-history-style.service.d.ts +34 -0
- package/lib/document/services/document-history.service.d.ts +42 -0
- package/lib/document/services/document-http.service.d.ts +179 -0
- package/lib/document/services/document-list.service.d.ts +74 -0
- package/lib/document/services/document-menu.service.d.ts +122 -0
- package/lib/document/services/document-scroll.service.d.ts +55 -0
- package/lib/document/services/document-table-builder.service.d.ts +38 -0
- package/lib/document/services/document-upload-business.service.d.ts +107 -0
- package/lib/document/services/document-upload-data.service.d.ts +40 -0
- package/lib/document/services/document-upload-form.service.d.ts +41 -0
- package/lib/document/services/document-upload.service.d.ts +99 -0
- package/lib/document/services/document-viewer.service.d.ts +97 -0
- package/lib/document/services/document-zoom.service.d.ts +81 -0
- package/lib/document/services/document.service.d.ts +161 -0
- package/lib/document/services/eml-parser.service.d.ts +116 -0
- package/lib/document/services/excel-parser.service.d.ts +169 -0
- package/lib/document/services/file-format.service.d.ts +34 -0
- package/lib/document/services/status-calculator.service.d.ts +20 -0
- package/lib/document/services/user-list.service.d.ts +29 -0
- package/lib/document/state/document.query.d.ts +243 -0
- package/{projects/cat-document-lib/src/lib/document/state/document.service.ts → lib/document/state/document.service.d.ts} +15 -46
- package/lib/document/state/document.state.d.ts +61 -0
- package/lib/document/state/document.store.d.ts +56 -0
- package/package.json +19 -57
- package/public-api.d.ts +27 -0
- package/src/assets/images/Document interface.png +0 -0
- package/src/assets/images/Document upload.png +0 -0
- package/src/assets/images/Pdf viewer dialog.png +0 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -32
- package/.husky/pre-commit +0 -4
- package/angular.json +0 -119
- package/eslint.config.cjs +0 -148
- package/projects/cat-document-lib/README.md +0 -63
- package/projects/cat-document-lib/ng-package.json +0 -11
- package/projects/cat-document-lib/package.json +0 -16
- package/projects/cat-document-lib/setup-jest.ts +0 -1
- package/projects/cat-document-lib/src/lib/document/components/document-container/document-container.component.html +0 -6
- package/projects/cat-document-lib/src/lib/document/components/document-container/document-container.component.scss +0 -0
- package/projects/cat-document-lib/src/lib/document/components/document-container/document-container.component.spec.ts +0 -0
- package/projects/cat-document-lib/src/lib/document/components/document-container/document-container.component.ts +0 -82
- package/projects/cat-document-lib/src/lib/document/components/document-list/document-list.component.html +0 -35
- package/projects/cat-document-lib/src/lib/document/components/document-list/document-list.component.scss +0 -12
- package/projects/cat-document-lib/src/lib/document/components/document-list/document-list.component.spec.ts +0 -0
- package/projects/cat-document-lib/src/lib/document/components/document-list/document-list.component.ts +0 -73
- package/projects/cat-document-lib/src/lib/document/components/document-list-item/document-list-item.component.html +0 -33
- package/projects/cat-document-lib/src/lib/document/components/document-list-item/document-list-item.component.scss +0 -22
- package/projects/cat-document-lib/src/lib/document/components/document-list-item/document-list-item.component.spec.ts +0 -23
- package/projects/cat-document-lib/src/lib/document/components/document-list-item/document-list-item.component.ts +0 -40
- package/projects/cat-document-lib/src/lib/document/components/document-upload/document-upload.component.html +0 -56
- package/projects/cat-document-lib/src/lib/document/components/document-upload/document-upload.component.scss +0 -26
- package/projects/cat-document-lib/src/lib/document/components/document-upload/document-upload.component.spec.ts +0 -24
- package/projects/cat-document-lib/src/lib/document/components/document-upload/document-upload.component.ts +0 -184
- package/projects/cat-document-lib/src/lib/document/components/document-viewer/document-viewer.component.html +0 -244
- package/projects/cat-document-lib/src/lib/document/components/document-viewer/document-viewer.component.scss +0 -36
- package/projects/cat-document-lib/src/lib/document/components/document-viewer/document-viewer.component.spec.ts +0 -21
- package/projects/cat-document-lib/src/lib/document/components/document-viewer/document-viewer.component.ts +0 -125
- package/projects/cat-document-lib/src/lib/document/components/folder-block/folder-block.component.html +0 -46
- package/projects/cat-document-lib/src/lib/document/components/folder-block/folder-block.component.scss +0 -0
- package/projects/cat-document-lib/src/lib/document/components/folder-block/folder-block.component.spec.ts +0 -0
- package/projects/cat-document-lib/src/lib/document/components/folder-container/folder-container.component.html +0 -2
- package/projects/cat-document-lib/src/lib/document/components/folder-container/folder-container.component.scss +0 -0
- package/projects/cat-document-lib/src/lib/document/components/folder-container/folder-container.component.spec.ts +0 -0
- package/projects/cat-document-lib/src/lib/document/components/folder-container/folder-container.component.ts +0 -29
- package/projects/cat-document-lib/src/lib/document/document.module.ts +0 -187
- package/projects/cat-document-lib/src/lib/document/models/document.model.ts +0 -39
- package/projects/cat-document-lib/src/lib/document/services/file-format.service.spec.ts +0 -16
- package/projects/cat-document-lib/src/lib/document/services/file-format.service.ts +0 -41
- package/projects/cat-document-lib/src/lib/document/state/document.query.ts +0 -23
- package/projects/cat-document-lib/src/lib/document/state/document.state.ts +0 -39
- package/projects/cat-document-lib/src/lib/document/state/document.store.ts +0 -23
- package/projects/cat-document-lib/src/public-api.ts +0 -8
- package/projects/cat-document-lib/src/shared/constant/SHARED.ts +0 -232
- package/projects/cat-document-lib/src/shared/constant/URLS.ts +0 -31
- package/projects/cat-document-lib/src/shared/services/app-config.service.spec.ts +0 -16
- package/projects/cat-document-lib/src/shared/services/app-config.service.ts +0 -73
- package/projects/cat-document-lib/tsconfig.lib.json +0 -15
- package/projects/cat-document-lib/tsconfig.lib.prod.json +0 -11
- package/projects/cat-document-lib/tsconfig.spec.json +0 -15
- package/public/favicon.ico +0 -0
- package/src/app/app.component.html +0 -1
- package/src/app/app.component.scss +0 -0
- package/src/app/app.component.spec.ts +0 -29
- package/src/app/app.component.ts +0 -15
- package/src/app/app.module.ts +0 -60
- package/src/app/app.routing.module.ts +0 -19
- package/src/index.html +0 -13
- package/src/main.ts +0 -5
- package/src/styles.scss +0 -39
- package/tsconfig.app.json +0 -15
- package/tsconfig.json +0 -32
- /package/{projects/cat-document-lib/src → src}/assets/images/FolderImg.png +0 -0
- /package/{projects/cat-document-lib/src → src}/assets/images/Frame.png +0 -0
- /package/{projects/cat-document-lib/src → src}/assets/images/document.png +0 -0
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<div class="document-viewer">
|
|
2
|
-
<p-dialog [(visible)]="isdialogVisible" [modal]="true" (onHide)="handleCloseModel()" [style]="{ width: '100vw' }"
|
|
3
|
-
[draggable]="false" [closable]="true">
|
|
4
|
-
<document-viewer [selectedDocument]="selectedDocument"></document-viewer>
|
|
5
|
-
</p-dialog>
|
|
6
|
-
</div>
|
|
7
|
-
|
|
8
|
-
<div class="col-12 p-0">
|
|
9
|
-
<div class="card p-0 document-list-wrapper">
|
|
10
|
-
<p-accordion>
|
|
11
|
-
<p-accordionTab [selected]="true" class="line-height-2 m-0">
|
|
12
|
-
<ng-template pTemplate="header" let-active="active">
|
|
13
|
-
<div class="flex align-items-center justify-content-between w-full">
|
|
14
|
-
<span class="flex align-items-center gap-2">
|
|
15
|
-
Documents
|
|
16
|
-
</span>
|
|
17
|
-
<button pButton pRipple class="p-button-raised" type="button" label="Upload File"
|
|
18
|
-
style="border-radius: 10px;" (click)="handleFileUploadClick($event)"></button>
|
|
19
|
-
</div>
|
|
20
|
-
</ng-template>
|
|
21
|
-
@for(document of documentList; track document){
|
|
22
|
-
<lib-document-list-item [document]="document"
|
|
23
|
-
(documentClick)="handleClickForDocument($event)"></lib-document-list-item>
|
|
24
|
-
}
|
|
25
|
-
</p-accordionTab>
|
|
26
|
-
</p-accordion>
|
|
27
|
-
</div>
|
|
28
|
-
</div>
|
|
29
|
-
<div class="grid">
|
|
30
|
-
<div class="col-12">
|
|
31
|
-
<p-sidebar [(visible)]="isSidebarVisible" position="right" [styleClass]="'right-sidebar'">
|
|
32
|
-
<lib-document-upload [contextId]="contextId"></lib-document-upload>
|
|
33
|
-
</p-sidebar>
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
File without changes
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Component, Input, ViewEncapsulation } from '@angular/core';
|
|
2
|
-
import { DocumentModel } from '../../models/document.model';
|
|
3
|
-
import { SHARED } from '../../../../Shared/constant/SHARED';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* This component is responsible for displaying a list of documents.
|
|
8
|
-
* @class DocumentListComponent
|
|
9
|
-
* @typedef {DocumentListComponent}
|
|
10
|
-
*/
|
|
11
|
-
@Component({
|
|
12
|
-
selector: 'lib-document-list',
|
|
13
|
-
standalone: false,
|
|
14
|
-
templateUrl: './document-list.component.html',
|
|
15
|
-
styleUrls: ['./document-list.component.scss'],
|
|
16
|
-
encapsulation: ViewEncapsulation.None
|
|
17
|
-
})
|
|
18
|
-
export class DocumentListComponent {
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Represent contextId
|
|
22
|
-
* @type {string}
|
|
23
|
-
*/
|
|
24
|
-
@Input() contextId : string = SHARED.EMPTY
|
|
25
|
-
|
|
26
|
-
selectedDocument !: DocumentModel
|
|
27
|
-
/**
|
|
28
|
-
* Default visbility of sidebar
|
|
29
|
-
* @type {boolean}
|
|
30
|
-
*/
|
|
31
|
-
isSidebarVisible: boolean = SHARED.FALSE
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Default visbility of dialog
|
|
35
|
-
* @type {boolean}
|
|
36
|
-
*/
|
|
37
|
-
isdialogVisible: boolean = SHARED.FALSE
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* The list of documents to display.
|
|
41
|
-
* @type {DocumentModel[]}
|
|
42
|
-
*/
|
|
43
|
-
@Input() documentList: DocumentModel[] = [];
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Handles the click event for file upload.
|
|
48
|
-
* Prevents event propagation and displays the sidebar.
|
|
49
|
-
* @param {MouseEvent} event - The click event triggered by the user.
|
|
50
|
-
*/
|
|
51
|
-
handleFileUploadClick(event: MouseEvent): void {
|
|
52
|
-
event.stopPropagation();
|
|
53
|
-
this.isSidebarVisible = SHARED.TRUE;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Select a individual document.
|
|
59
|
-
* @param {*} docuemnt - The document that was clicked by the user.
|
|
60
|
-
*/
|
|
61
|
-
handleClickForDocument(docuemnt: DocumentModel) {
|
|
62
|
-
this.isdialogVisible = SHARED.TRUE
|
|
63
|
-
this.selectedDocument = docuemnt
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Close dialog.
|
|
68
|
-
*/
|
|
69
|
-
handleCloseModel(){
|
|
70
|
-
this.selectedDocument = {_id : SHARED.INITIAL_VALUE};
|
|
71
|
-
this.isdialogVisible = SHARED.FALSE
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
<div class="grid">
|
|
2
|
-
<div
|
|
3
|
-
class="col-12 flex align-items-center justify-content-between md:col-6 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">{{ 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() === 'sentreminder'">
|
|
26
|
-
<i class="pi pi-bell pr-1" style="font-size: 12px;"></i>
|
|
27
|
-
Sent Reminder
|
|
28
|
-
</ng-container>
|
|
29
|
-
</span>
|
|
30
|
-
</div>
|
|
31
|
-
</div>
|
|
32
|
-
</div>
|
|
33
|
-
|
|
@@ -1,22 +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-sentreminder {
|
|
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
|
-
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { DocumentListItemComponent } from './document-list-item.component';
|
|
4
|
-
|
|
5
|
-
describe('DocumentListItemComponent', () => {
|
|
6
|
-
let component: DocumentListItemComponent;
|
|
7
|
-
let fixture: ComponentFixture<DocumentListItemComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(async () => {
|
|
10
|
-
await TestBed.configureTestingModule({
|
|
11
|
-
imports: [DocumentListItemComponent]
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
14
|
-
|
|
15
|
-
fixture = TestBed.createComponent(DocumentListItemComponent);
|
|
16
|
-
component = fixture.componentInstance;
|
|
17
|
-
fixture.detectChanges();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should create', () => {
|
|
21
|
-
expect(component).toBeTruthy();
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -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="1000000"
|
|
4
|
-
(onSelect)="onSelectedFiles($event)">
|
|
5
|
-
<ng-template pTemplate="header" let-chooseCallback="chooseCallback" let-clearCallback="clearCallback">
|
|
6
|
-
<div class="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 file 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]="file.name" width="45"
|
|
22
|
-
height="50" 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
|
-
{{ file.fileName }}
|
|
28
|
-
</div>
|
|
29
|
-
<i class="pi pi-times cursor-pointer" (click)="handleDocumentRemove(file,i)"></i>
|
|
30
|
-
</div>
|
|
31
|
-
<div class="flex justify-content-between mt-1">
|
|
32
|
-
<div style="color: #676B89; font-size: 12px;"></div>
|
|
33
|
-
<div class="white-space-nowrap" style="color: #0F8BFD; font-family: 14px;">{{ getProgress(file) }} %
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
<div class="col-12 md:col-12 p-0">
|
|
39
|
-
<p-progressBar [value]="totalSizePercent" [showValue]="false" styleClass="h-1/2rem md:ml-auto relative"
|
|
40
|
-
[ngClass]="{ 'exceeded-progress-bar': totalSizePercent > 100 }">
|
|
41
|
-
</p-progressBar>
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
</ng-template>
|
|
47
|
-
<ng-template pTemplate="empty" let-chooseCallback="chooseCallback" >
|
|
48
|
-
<div *ngIf="!uploadedFiles.length" class="flex align-items-center justify-content-center flex-column" (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,26 +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
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { DocumentUploadComponent } from './document-upload.component';
|
|
4
|
-
|
|
5
|
-
describe('DocumentUploadComponent', () => {
|
|
6
|
-
let component: DocumentUploadComponent;
|
|
7
|
-
let fixture: ComponentFixture<DocumentUploadComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(async () => {
|
|
10
|
-
await TestBed.configureTestingModule({
|
|
11
|
-
imports: [DocumentUploadComponent]
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
14
|
-
|
|
15
|
-
fixture = TestBed.createComponent(DocumentUploadComponent);
|
|
16
|
-
component = fixture.componentInstance;
|
|
17
|
-
fixture.detectChanges();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should create', () => {
|
|
21
|
-
expect(component).toBeTruthy();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
});
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectorRef, Component, EventEmitter, Input, input, Output, 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
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A component for handling document uploads, including file selection, removal, and progress tracking.
|
|
11
|
-
* @class DocumentUploadComponent
|
|
12
|
-
*/
|
|
13
|
-
@Component({
|
|
14
|
-
selector: 'lib-document-upload',
|
|
15
|
-
templateUrl: './document-upload.component.html',
|
|
16
|
-
styleUrls: ['./document-upload.component.scss'],
|
|
17
|
-
standalone: false,
|
|
18
|
-
encapsulation: ViewEncapsulation.None
|
|
19
|
-
})
|
|
20
|
-
export class DocumentUploadComponent {
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Represent contextId
|
|
24
|
-
* @type {string}
|
|
25
|
-
*/
|
|
26
|
-
@Input() contextId: string = SHARED.EMPTY
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Provide id of file after upload.
|
|
30
|
-
* @type {*}
|
|
31
|
-
*/
|
|
32
|
-
@Output() onInput = new EventEmitter();
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* To make file explorer visible.
|
|
36
|
-
* @type {!FileUpload}
|
|
37
|
-
*/
|
|
38
|
-
@ViewChild('fileUploader') fileUploader!: FileUpload;
|
|
39
|
-
|
|
40
|
-
fileProgress: Map<File, number> = new Map();
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* List of files selected for upload.
|
|
44
|
-
* @type {File[]}
|
|
45
|
-
*/
|
|
46
|
-
uploadedFiles: any[] = [];
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Percentage of the total size calculated for displaying upload progress.
|
|
50
|
-
* @type {number}
|
|
51
|
-
*/
|
|
52
|
-
totalSizePercent: number = SHARED.INITIAL_COUNT;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* The current upload progress percentage (SHARED.INITIAL_VALUE-100).
|
|
56
|
-
* @type {number}
|
|
57
|
-
*/
|
|
58
|
-
uploadProgress: number = SHARED.INITIAL_COUNT;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Creates an instance of DocumentUploadComponent.
|
|
63
|
-
* @class
|
|
64
|
-
* @param {DocumentService} uploadService - Service for handling document upload.
|
|
65
|
-
* @param {PrimeNGConfig} config - PrimeNG configuration.
|
|
66
|
-
* @param {FileFormatService} fileFormatService - Service for formatting file sizes.
|
|
67
|
-
* @param {MessageService} messageService - Service for displaying messages.
|
|
68
|
-
* @param {ChangeDetectorRef} cdr - Service for detecting changes.
|
|
69
|
-
*/
|
|
70
|
-
constructor(public uploadService: DocumentService, private config: PrimeNGConfig, public fileFormatService: FileFormatService, public messageService: MessageService, public cdr: ChangeDetectorRef) { }
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Open the file explorer.
|
|
74
|
-
* @param {*} event - The triggering event.
|
|
75
|
-
* @param {() => void} callback - A callback function to execute.
|
|
76
|
-
* @returns {void} - No return value.
|
|
77
|
-
*/
|
|
78
|
-
choose(event: any, callback: () => void) {
|
|
79
|
-
callback();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Prepares the files for upload by creating a FormData object.
|
|
86
|
-
* This method appends each file to the FormData for submission.
|
|
87
|
-
* @param {File} file - The file to upload.
|
|
88
|
-
* @returns {void}
|
|
89
|
-
*/
|
|
90
|
-
handleTemplatedUpload(file: File) {
|
|
91
|
-
let formData = this.handleCreateFormData(file)
|
|
92
|
-
this.uploadService.create(formData)
|
|
93
|
-
.subscribe({
|
|
94
|
-
/**
|
|
95
|
-
* Handles the successful upload event.
|
|
96
|
-
* Updates the list of uploaded files and emits the file ID.
|
|
97
|
-
* @param {any} event - The event emitted by the upload service on success.
|
|
98
|
-
*/
|
|
99
|
-
next: (event) => {
|
|
100
|
-
this.uploadedFiles.push(event);
|
|
101
|
-
this.fileProgress.set(event, 100);
|
|
102
|
-
this.onInput.emit(event._id)
|
|
103
|
-
this.totalSizePercent = 100;
|
|
104
|
-
},
|
|
105
|
-
/**
|
|
106
|
-
* Handles the error event during file upload.
|
|
107
|
-
* Updates the progress of the file to indicate failure.
|
|
108
|
-
* @param {any} error - The error object returned by the upload service.
|
|
109
|
-
*/
|
|
110
|
-
error: (error) => {
|
|
111
|
-
this.fileProgress.set(file, SHARED.INITIAL_COUNT);
|
|
112
|
-
this.messageService.add({
|
|
113
|
-
severity: SHARED.SEVERITY,
|
|
114
|
-
summary: SHARED.UPLOAD_SUMMERY,
|
|
115
|
-
detail: error?.message,
|
|
116
|
-
});
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Handle the creation of formdata.
|
|
124
|
-
* @param {File} file - The file to append in formdata.
|
|
125
|
-
* @returns {*}
|
|
126
|
-
*/
|
|
127
|
-
handleCreateFormData(file: File) {
|
|
128
|
-
const formData = new FormData();
|
|
129
|
-
formData.append(SHARED.FILE, file, file.name);
|
|
130
|
-
formData.append(SHARED.CONTEXT_ID, this.contextId)
|
|
131
|
-
return formData;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Handles the event when new files are selected.
|
|
135
|
-
* @param { { currentFiles: File[] } } event - The event containing the newly selected files.
|
|
136
|
-
* @returns {void}
|
|
137
|
-
*/
|
|
138
|
-
onSelectedFiles(event: { currentFiles: File[] }): void {
|
|
139
|
-
event.currentFiles.forEach((file: File) => {
|
|
140
|
-
this.handleTemplatedUpload(file);
|
|
141
|
-
});
|
|
142
|
-
this.fileUploader.clear();
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Formats the given file size in bytes into a readable format (e.g., KB, MB).
|
|
147
|
-
* @param {number} bytes - The size of the file in bytes.
|
|
148
|
-
* @returns {string} The formatted file size (e.g., '1.2 KB', '2.3 MB').
|
|
149
|
-
*/
|
|
150
|
-
formatSize(bytes: number): string {
|
|
151
|
-
return this.fileFormatService.formatFileSize(bytes, this.config)
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Handles the removal of a file from the uploaded files list.
|
|
156
|
-
* @param {File} file - The file to be removed.
|
|
157
|
-
* @param {number} index - The index of the file in the uploaded files list.
|
|
158
|
-
*/
|
|
159
|
-
handleDocumentRemove(file: File, index: number): void {
|
|
160
|
-
this.uploadedFiles.splice(index, 1);
|
|
161
|
-
this.fileProgress.delete(file);
|
|
162
|
-
this.cdr.detectChanges();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Major progress for the progress bar.
|
|
167
|
-
* @param {File} file - File to check progress for.
|
|
168
|
-
* @returns {number} - The progress percentage for the file.
|
|
169
|
-
*/
|
|
170
|
-
getProgress(file: File): number {
|
|
171
|
-
return this.fileProgress.get(file) || SHARED.INITIAL_COUNT;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Triggers the file upload dialog.
|
|
176
|
-
* Opens the file explorer for selecting files.
|
|
177
|
-
* @returns {void}
|
|
178
|
-
*/
|
|
179
|
-
triggerFileUpload() {
|
|
180
|
-
this.fileUploader.choose();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|