@ruc-lib/multi-file-upload 3.1.0 → 3.2.0
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 +210 -3
- package/esm2020/index.mjs +4 -0
- package/esm2020/lib/interfaces/multiFileUploadDefault.mjs +2 -0
- package/esm2020/lib/ruclib-multi-file-upload/ruclib-multi-file-upload.component.mjs +112 -0
- package/esm2020/lib/ruclib-multi-file-upload.module.mjs +48 -0
- package/esm2020/lib/services/ruclib-multi-file-upload.service.mjs +24 -0
- package/esm2020/ruc-lib-multi-file-upload.mjs +5 -0
- package/fesm2015/ruc-lib-multi-file-upload.mjs +184 -0
- package/fesm2015/ruc-lib-multi-file-upload.mjs.map +1 -0
- package/fesm2020/ruc-lib-multi-file-upload.mjs +181 -0
- package/fesm2020/ruc-lib-multi-file-upload.mjs.map +1 -0
- package/index.d.ts +3 -84
- package/lib/interfaces/multiFileUploadDefault.d.ts +27 -0
- package/lib/ruclib-multi-file-upload/ruclib-multi-file-upload.component.d.ts +43 -0
- package/lib/ruclib-multi-file-upload.module.d.ts +14 -0
- package/lib/services/ruclib-multi-file-upload.service.d.ts +11 -0
- package/package.json +22 -11
- package/fesm2022/ruc-lib-multi-file-upload.mjs +0 -152
- package/fesm2022/ruc-lib-multi-file-upload.mjs.map +0 -1
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, EventEmitter, inject, Output, Input, Component } from '@angular/core';
|
|
3
|
-
import * as i1$1 from '@angular/common';
|
|
4
|
-
import { CommonModule } from '@angular/common';
|
|
5
|
-
import * as i1 from '@angular/common/http';
|
|
6
|
-
import { HttpEventType, HttpResponse } from '@angular/common/http';
|
|
7
|
-
import * as i2 from '@angular/material/progress-bar';
|
|
8
|
-
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
9
|
-
import * as i3 from '@angular/material/card';
|
|
10
|
-
import { MatCardModule } from '@angular/material/card';
|
|
11
|
-
import * as i4 from '@angular/material/icon';
|
|
12
|
-
import { MatIconModule } from '@angular/material/icon';
|
|
13
|
-
import * as i5 from '@angular/material/button';
|
|
14
|
-
import { MatButtonModule } from '@angular/material/button';
|
|
15
|
-
import * as i6 from '@angular/material/form-field';
|
|
16
|
-
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
17
|
-
|
|
18
|
-
class RuclibMultiFileUploadService {
|
|
19
|
-
constructor(http) {
|
|
20
|
-
this.http = http;
|
|
21
|
-
}
|
|
22
|
-
uploadFile(formData, api) {
|
|
23
|
-
return this.http.post(api, formData, {
|
|
24
|
-
reportProgress: true,
|
|
25
|
-
observe: 'events',
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
deleteFile(id, deleteApi) {
|
|
29
|
-
return this.http.delete(deleteApi + '/' + id);
|
|
30
|
-
}
|
|
31
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: RuclibMultiFileUploadService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
32
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: RuclibMultiFileUploadService }); }
|
|
33
|
-
}
|
|
34
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: RuclibMultiFileUploadService, decorators: [{
|
|
35
|
-
type: Injectable
|
|
36
|
-
}], ctorParameters: () => [{ type: i1.HttpClient }] });
|
|
37
|
-
|
|
38
|
-
class RuclibMultiFileUploadComponent {
|
|
39
|
-
constructor() {
|
|
40
|
-
this.rucEvent = new EventEmitter();
|
|
41
|
-
this.service = inject(RuclibMultiFileUploadService);
|
|
42
|
-
this.selectedFileData = [];
|
|
43
|
-
this.files = [];
|
|
44
|
-
}
|
|
45
|
-
// constructor(public service: RuclibMultiFileUploadService) {}
|
|
46
|
-
ngOnInit() {
|
|
47
|
-
this.progress = 0; //initial value for the progress bar
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* To get the url
|
|
51
|
-
* of the thumbnail
|
|
52
|
-
* for png file type
|
|
53
|
-
*/
|
|
54
|
-
getUrlFromFile(file) {
|
|
55
|
-
return new Promise((resolve, reject) => {
|
|
56
|
-
const reader = new FileReader();
|
|
57
|
-
reader.readAsDataURL(file);
|
|
58
|
-
reader.onerror = (error) => {
|
|
59
|
-
reject(error);
|
|
60
|
-
};
|
|
61
|
-
reader.onloadend = () => {
|
|
62
|
-
try {
|
|
63
|
-
file['url'] = reader.result;
|
|
64
|
-
resolve(file);
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
reject(err);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* To choose the file
|
|
74
|
-
* and get the thumbnail
|
|
75
|
-
*/
|
|
76
|
-
async chooseFile(event) {
|
|
77
|
-
const filePromises = Array.from(event.target.files).map((file) => {
|
|
78
|
-
const selectedFile = file;
|
|
79
|
-
selectedFile['disableUploadFile'] = false;
|
|
80
|
-
if (selectedFile.type !== 'image/png') {
|
|
81
|
-
return selectedFile;
|
|
82
|
-
}
|
|
83
|
-
return this.getUrlFromFile(selectedFile);
|
|
84
|
-
});
|
|
85
|
-
const fileInfos = await Promise.all(filePromises);
|
|
86
|
-
if (fileInfos[0]) {
|
|
87
|
-
this.selectedFileData.push(fileInfos[0]);
|
|
88
|
-
}
|
|
89
|
-
this.rucEvent.emit({
|
|
90
|
-
eventName: 'onFileSelection',
|
|
91
|
-
eventOutput: fileInfos,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* To delete the selected file
|
|
96
|
-
*/
|
|
97
|
-
removeSelectedFile(index, selected) {
|
|
98
|
-
if (this.rucInputData.deleteUrl) {
|
|
99
|
-
this.service.deleteFile(index, this.rucInputData.deleteUrl).subscribe();
|
|
100
|
-
this.selectedFileData.splice(index, 1);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
this.selectedFileData.splice(index, 1);
|
|
104
|
-
}
|
|
105
|
-
this.rucEvent.emit({ eventName: 'onDeleting', eventOutput: selected });
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* To upload the file
|
|
109
|
-
* and see progress bar
|
|
110
|
-
*/
|
|
111
|
-
uploadSelectedFile(fileOne) {
|
|
112
|
-
this.rucEvent.emit({ eventName: 'onUploading', eventOutput: fileOne });
|
|
113
|
-
fileOne['disableUploadFile'] = true;
|
|
114
|
-
const formData = new FormData();
|
|
115
|
-
this.service
|
|
116
|
-
.uploadFile(formData, this.rucInputData.uploadUrl)
|
|
117
|
-
.subscribe((event) => {
|
|
118
|
-
if (event.type === HttpEventType.UploadProgress) {
|
|
119
|
-
this.progress = Math.round(((event.loaded || 1) / (event.total || 1)) * 100);
|
|
120
|
-
}
|
|
121
|
-
else if (event instanceof HttpResponse) {
|
|
122
|
-
this.progress = 0;
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: RuclibMultiFileUploadComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
127
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.9", type: RuclibMultiFileUploadComponent, isStandalone: true, selector: "uxp-ruclib-multi-file-upload", inputs: { rucInputData: "rucInputData", customTheme: "customTheme" }, outputs: { rucEvent: "rucEvent" }, providers: [RuclibMultiFileUploadService], ngImport: i0, template: "<p>ruclib-multi-file-upload works!</p>\r\n<div class=\"{{ customTheme }}\">\r\n <div class=\"colorcustomoverride\">\r\n @if (rucInputData) {\r\n <mat-card class=\"container\">\r\n <!--Label For Selecting File Starts-->\r\n <mat-card-title>\r\n <div>\r\n <mat-card class=\"matCard\">\r\n <input\r\n #attachments\r\n type=\"file\"\r\n (change)=\"chooseFile($event)\"\r\n #fileInput\r\n [multiple]=\"rucInputData.multifileSelection\"\r\n name=\"files\"\r\n id=\"img\"\r\n class=\"isDisplay\"\r\n />\r\n <label for=\"img\" class=\"containerlabel\"\r\n >{{ rucInputData.label }}\r\n <mat-icon class=\"attachfile\">attach_file</mat-icon></label\r\n >\r\n </mat-card>\r\n </div>\r\n </mat-card-title>\r\n <!--Label For Selecting File Starts-->\r\n <mat-card-content class=\"marCardTable\">\r\n @for (selected of selectedFileData; track selected; let index = $index) {\r\n <div\r\n class=\"row\"\r\n class=\"selectedFileList\"\r\n >\r\n <!--Thumbnail previewing of Image Starts-->\r\n @if (selected.type === 'image/png') {\r\n <div\r\n [ngClass]=\"rucInputData.displayThumbnail ? '' : 'isDisplay'\"\r\n >\r\n <img [src]=\"selected.url\" width=\"50px\" />\r\n </div>\r\n }\r\n <!--Thumbnail previewing of Image Ends-->\r\n <!--Name of Selected File Starts-->\r\n <mat-label class=\"selectedFileName\">{{ selected.name }}</mat-label>\r\n <!--Name of Selected File Ends-->\r\n <!--Button Starts-->\r\n <div class=\"floatRight\">\r\n <mat-icon\r\n (click)=\"removeSelectedFile(index, selected)\"\r\n class=\"deletebutton\"\r\n color=\"warn\"\r\n >delete_outline</mat-icon\r\n >\r\n </div>\r\n <div class=\"floatRightSubmit\">\r\n <button\r\n mat-raised-button\r\n color=\"primary\"\r\n class=\"uploadButton\"\r\n type=\"submit\"\r\n (click)=\"uploadSelectedFile(selected)\"\r\n [disabled]=\"selected.disableUploadFile\"\r\n >\r\n Submit\r\n </button>\r\n </div>\r\n <!--Button Ends-->\r\n <!--Progress Bar with Label Starts-->\r\n @if (selected.disableUploadFile) {\r\n <div class=\"progressbar\">\r\n <mat-label class=\"fileSize\"\r\n >{{ (selected.size / 1000).toFixed(2) }} KB</mat-label\r\n >\r\n <mat-label class=\"filePercentage\"> {{ progress }}% </mat-label>\r\n <mat-progress-bar\r\n mode=\"determinate\"\r\n [value]=\"progress\"\r\n class=\"displayInline\"\r\n ></mat-progress-bar>\r\n </div>\r\n }\r\n <!--Progress Bar with Label Ends-->\r\n </div>\r\n }\r\n </mat-card-content>\r\n </mat-card>\r\n }\r\n </div>\r\n </div>\r\n", styles: [".isDisplay{display:none}.colorcustomoverride mat-mdc-card{background-color:#fff!important;color:#000!important}.colorcustomoverride mat-mdc-card-content{padding-bottom:33px}.container{width:90%;padding:33px}.floatRight{float:right}.displayInline{display:inline-block}.uploadButton{margin-right:26px;display:inline-block}.matCard{border:2px solid #3f51b5}.marCardTable{max-height:300px;overflow:auto}.attachfile{float:right;cursor:pointer}.selectedFileList{padding-top:56px}.progressbar{width:76%}.fileSize{float:left;padding:10px}.filePercentage{float:right;padding:10px}.deletebutton{margin-top:4px;display:inline-block;cursor:pointer}.floatRightSubmit{float:right}.selectedFileName{display:inline-block;line-break:auto}@media (max-width: 800px){.fileSize{margin-top:31px;float:left}.filePercentage{padding:0;margin-top:41px}.floatRightSubmit{margin-right:-6px;float:right}.deletebutton{margin-right:-22px;cursor:pointer}.progressbar{width:100%}.attachfile{float:right;cursor:pointer;margin-top:-4px}.containerlabel{font-size:18px}.container{height:auto;overflow:scroll}.selectedFileName{margin-bottom:14px;line-break:auto;width:85px;margin-left:-17px}}@media only screen and (max-width: 740px) and (min-width: 360px){.floatRightSubmit{margin-right:-12px}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: MatProgressBarModule }, { kind: "component", type: i2.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "ngmodule", type: MatCardModule }, { kind: "component", type: i3.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: i3.MatCardContent, selector: "mat-card-content" }, { kind: "directive", type: i3.MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i4.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i5.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "directive", type: i6.MatLabel, selector: "mat-label" }] }); }
|
|
128
|
-
}
|
|
129
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: RuclibMultiFileUploadComponent, decorators: [{
|
|
130
|
-
type: Component,
|
|
131
|
-
args: [{ selector: 'uxp-ruclib-multi-file-upload', imports: [
|
|
132
|
-
CommonModule,
|
|
133
|
-
MatProgressBarModule,
|
|
134
|
-
MatCardModule,
|
|
135
|
-
MatIconModule,
|
|
136
|
-
MatButtonModule,
|
|
137
|
-
MatFormFieldModule,
|
|
138
|
-
], providers: [RuclibMultiFileUploadService], template: "<p>ruclib-multi-file-upload works!</p>\r\n<div class=\"{{ customTheme }}\">\r\n <div class=\"colorcustomoverride\">\r\n @if (rucInputData) {\r\n <mat-card class=\"container\">\r\n <!--Label For Selecting File Starts-->\r\n <mat-card-title>\r\n <div>\r\n <mat-card class=\"matCard\">\r\n <input\r\n #attachments\r\n type=\"file\"\r\n (change)=\"chooseFile($event)\"\r\n #fileInput\r\n [multiple]=\"rucInputData.multifileSelection\"\r\n name=\"files\"\r\n id=\"img\"\r\n class=\"isDisplay\"\r\n />\r\n <label for=\"img\" class=\"containerlabel\"\r\n >{{ rucInputData.label }}\r\n <mat-icon class=\"attachfile\">attach_file</mat-icon></label\r\n >\r\n </mat-card>\r\n </div>\r\n </mat-card-title>\r\n <!--Label For Selecting File Starts-->\r\n <mat-card-content class=\"marCardTable\">\r\n @for (selected of selectedFileData; track selected; let index = $index) {\r\n <div\r\n class=\"row\"\r\n class=\"selectedFileList\"\r\n >\r\n <!--Thumbnail previewing of Image Starts-->\r\n @if (selected.type === 'image/png') {\r\n <div\r\n [ngClass]=\"rucInputData.displayThumbnail ? '' : 'isDisplay'\"\r\n >\r\n <img [src]=\"selected.url\" width=\"50px\" />\r\n </div>\r\n }\r\n <!--Thumbnail previewing of Image Ends-->\r\n <!--Name of Selected File Starts-->\r\n <mat-label class=\"selectedFileName\">{{ selected.name }}</mat-label>\r\n <!--Name of Selected File Ends-->\r\n <!--Button Starts-->\r\n <div class=\"floatRight\">\r\n <mat-icon\r\n (click)=\"removeSelectedFile(index, selected)\"\r\n class=\"deletebutton\"\r\n color=\"warn\"\r\n >delete_outline</mat-icon\r\n >\r\n </div>\r\n <div class=\"floatRightSubmit\">\r\n <button\r\n mat-raised-button\r\n color=\"primary\"\r\n class=\"uploadButton\"\r\n type=\"submit\"\r\n (click)=\"uploadSelectedFile(selected)\"\r\n [disabled]=\"selected.disableUploadFile\"\r\n >\r\n Submit\r\n </button>\r\n </div>\r\n <!--Button Ends-->\r\n <!--Progress Bar with Label Starts-->\r\n @if (selected.disableUploadFile) {\r\n <div class=\"progressbar\">\r\n <mat-label class=\"fileSize\"\r\n >{{ (selected.size / 1000).toFixed(2) }} KB</mat-label\r\n >\r\n <mat-label class=\"filePercentage\"> {{ progress }}% </mat-label>\r\n <mat-progress-bar\r\n mode=\"determinate\"\r\n [value]=\"progress\"\r\n class=\"displayInline\"\r\n ></mat-progress-bar>\r\n </div>\r\n }\r\n <!--Progress Bar with Label Ends-->\r\n </div>\r\n }\r\n </mat-card-content>\r\n </mat-card>\r\n }\r\n </div>\r\n </div>\r\n", styles: [".isDisplay{display:none}.colorcustomoverride mat-mdc-card{background-color:#fff!important;color:#000!important}.colorcustomoverride mat-mdc-card-content{padding-bottom:33px}.container{width:90%;padding:33px}.floatRight{float:right}.displayInline{display:inline-block}.uploadButton{margin-right:26px;display:inline-block}.matCard{border:2px solid #3f51b5}.marCardTable{max-height:300px;overflow:auto}.attachfile{float:right;cursor:pointer}.selectedFileList{padding-top:56px}.progressbar{width:76%}.fileSize{float:left;padding:10px}.filePercentage{float:right;padding:10px}.deletebutton{margin-top:4px;display:inline-block;cursor:pointer}.floatRightSubmit{float:right}.selectedFileName{display:inline-block;line-break:auto}@media (max-width: 800px){.fileSize{margin-top:31px;float:left}.filePercentage{padding:0;margin-top:41px}.floatRightSubmit{margin-right:-6px;float:right}.deletebutton{margin-right:-22px;cursor:pointer}.progressbar{width:100%}.attachfile{float:right;cursor:pointer;margin-top:-4px}.containerlabel{font-size:18px}.container{height:auto;overflow:scroll}.selectedFileName{margin-bottom:14px;line-break:auto;width:85px;margin-left:-17px}}@media only screen and (max-width: 740px) and (min-width: 360px){.floatRightSubmit{margin-right:-12px}}\n"] }]
|
|
139
|
-
}], propDecorators: { rucInputData: [{
|
|
140
|
-
type: Input
|
|
141
|
-
}], customTheme: [{
|
|
142
|
-
type: Input
|
|
143
|
-
}], rucEvent: [{
|
|
144
|
-
type: Output
|
|
145
|
-
}] } });
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Generated bundle index. Do not edit.
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
export { RuclibMultiFileUploadComponent, RuclibMultiFileUploadService };
|
|
152
|
-
//# sourceMappingURL=ruc-lib-multi-file-upload.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ruc-lib-multi-file-upload.mjs","sources":["../../src/lib/services/ruclib-multi-file-upload.service.ts","../../src/lib/ruclib-multi-file-upload/ruclib-multi-file-upload.component.ts","../../src/lib/ruclib-multi-file-upload/ruclib-multi-file-upload.component.html","../../src/ruc-lib-multi-file-upload.ts"],"sourcesContent":["import { HttpClient } from '@angular/common/http';\r\nimport { Injectable } from '@angular/core';\r\n\r\n@Injectable()\r\nexport class RuclibMultiFileUploadService {\r\n progress: any;\r\n\r\n constructor(private http: HttpClient) {}\r\n\r\n uploadFile(formData: any, api: string) {\r\n return this.http.post(api, formData, {\r\n reportProgress: true,\r\n observe: 'events',\r\n });\r\n }\r\n deleteFile(id: number, deleteApi: string) {\r\n return this.http.delete(deleteApi + '/' + id);\r\n }\r\n}\r\n","import { Component, EventEmitter, inject, Input, Output } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { MultifiledefaultConfig } from '../interfaces/multiFileUploadDefault';\r\nimport { RuclibMultiFileUploadService } from '../services/ruclib-multi-file-upload.service';\r\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\r\nimport { MatCardModule } from '@angular/material/card';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { MatFormFieldModule } from '@angular/material/form-field';\r\nimport { HttpEventType, HttpResponse } from '@angular/common/http';\r\n\r\n@Component({\r\n selector: 'uxp-ruclib-multi-file-upload',\r\n imports: [\r\n CommonModule,\r\n MatProgressBarModule,\r\n MatCardModule,\r\n MatIconModule,\r\n MatButtonModule,\r\n MatFormFieldModule,\r\n ],\r\n templateUrl: './ruclib-multi-file-upload.component.html',\r\n styleUrl: './ruclib-multi-file-upload.component.scss',\r\n providers: [RuclibMultiFileUploadService]\r\n})\r\nexport class RuclibMultiFileUploadComponent {\r\n @Input() rucInputData!: MultifiledefaultConfig; // Input Json\r\n @Input() customTheme!: string;\r\n @Output() rucEvent = new EventEmitter<any>();\r\n public service = inject(RuclibMultiFileUploadService);\r\n index: any;\r\n result!: string; //used for url purpose\r\n selectedFileData: any[] = [];\r\n progress!: number; //initial value for the progress bar\r\n files: Array<{ name: string; url: string }> = [];\r\n uploadUrl!: string;\r\n\r\n // constructor(public service: RuclibMultiFileUploadService) {}\r\n\r\n ngOnInit() {\r\n this.progress = 0; //initial value for the progress bar\r\n }\r\n\r\n /**\r\n * To get the url\r\n * of the thumbnail\r\n * for png file type\r\n */\r\n getUrlFromFile(file: any): Promise<any> {\r\n return new Promise<any>((resolve, reject) => {\r\n const reader = new FileReader();\r\n reader.readAsDataURL(file);\r\n\r\n reader.onerror = (error) => {\r\n reject(error);\r\n };\r\n\r\n reader.onloadend = () => {\r\n try {\r\n file['url'] = reader.result;\r\n resolve(file);\r\n } catch (err) {\r\n reject(err);\r\n }\r\n };\r\n });\r\n }\r\n\r\n /**\r\n * To choose the file\r\n * and get the thumbnail\r\n */\r\n async chooseFile(event: any) {\r\n const filePromises = Array.from(event.target.files).map((file: any) => {\r\n const selectedFile = file;\r\n selectedFile['disableUploadFile'] = false;\r\n\r\n if (selectedFile.type !== 'image/png') {\r\n return selectedFile;\r\n }\r\n\r\n return this.getUrlFromFile(selectedFile);\r\n });\r\n const fileInfos = await Promise.all(filePromises);\r\n if (fileInfos[0]) {\r\n this.selectedFileData.push(fileInfos[0]);\r\n }\r\n this.rucEvent.emit({\r\n eventName: 'onFileSelection',\r\n eventOutput: fileInfos,\r\n });\r\n }\r\n\r\n /**\r\n * To delete the selected file\r\n */\r\n removeSelectedFile(index: number, selected: any) {\r\n if (this.rucInputData.deleteUrl) {\r\n this.service.deleteFile(index, this.rucInputData.deleteUrl).subscribe();\r\n this.selectedFileData.splice(index, 1);\r\n } else {\r\n this.selectedFileData.splice(index, 1);\r\n }\r\n this.rucEvent.emit({ eventName: 'onDeleting', eventOutput: selected });\r\n }\r\n\r\n /**\r\n * To upload the file\r\n * and see progress bar\r\n */\r\n uploadSelectedFile(fileOne: any) {\r\n this.rucEvent.emit({ eventName: 'onUploading', eventOutput: fileOne });\r\n fileOne['disableUploadFile'] = true;\r\n const formData = new FormData();\r\n this.service\r\n .uploadFile(formData, this.rucInputData.uploadUrl)\r\n .subscribe((event) => {\r\n if (event.type === HttpEventType.UploadProgress) {\r\n this.progress = Math.round(\r\n ((event.loaded || 1) / (event.total || 1)) * 100\r\n );\r\n } else if (event instanceof HttpResponse) {\r\n this.progress = 0;\r\n }\r\n });\r\n }\r\n}\r\n","<p>ruclib-multi-file-upload works!</p>\r\n<div class=\"{{ customTheme }}\">\r\n <div class=\"colorcustomoverride\">\r\n @if (rucInputData) {\r\n <mat-card class=\"container\">\r\n <!--Label For Selecting File Starts-->\r\n <mat-card-title>\r\n <div>\r\n <mat-card class=\"matCard\">\r\n <input\r\n #attachments\r\n type=\"file\"\r\n (change)=\"chooseFile($event)\"\r\n #fileInput\r\n [multiple]=\"rucInputData.multifileSelection\"\r\n name=\"files\"\r\n id=\"img\"\r\n class=\"isDisplay\"\r\n />\r\n <label for=\"img\" class=\"containerlabel\"\r\n >{{ rucInputData.label }}\r\n <mat-icon class=\"attachfile\">attach_file</mat-icon></label\r\n >\r\n </mat-card>\r\n </div>\r\n </mat-card-title>\r\n <!--Label For Selecting File Starts-->\r\n <mat-card-content class=\"marCardTable\">\r\n @for (selected of selectedFileData; track selected; let index = $index) {\r\n <div\r\n class=\"row\"\r\n class=\"selectedFileList\"\r\n >\r\n <!--Thumbnail previewing of Image Starts-->\r\n @if (selected.type === 'image/png') {\r\n <div\r\n [ngClass]=\"rucInputData.displayThumbnail ? '' : 'isDisplay'\"\r\n >\r\n <img [src]=\"selected.url\" width=\"50px\" />\r\n </div>\r\n }\r\n <!--Thumbnail previewing of Image Ends-->\r\n <!--Name of Selected File Starts-->\r\n <mat-label class=\"selectedFileName\">{{ selected.name }}</mat-label>\r\n <!--Name of Selected File Ends-->\r\n <!--Button Starts-->\r\n <div class=\"floatRight\">\r\n <mat-icon\r\n (click)=\"removeSelectedFile(index, selected)\"\r\n class=\"deletebutton\"\r\n color=\"warn\"\r\n >delete_outline</mat-icon\r\n >\r\n </div>\r\n <div class=\"floatRightSubmit\">\r\n <button\r\n mat-raised-button\r\n color=\"primary\"\r\n class=\"uploadButton\"\r\n type=\"submit\"\r\n (click)=\"uploadSelectedFile(selected)\"\r\n [disabled]=\"selected.disableUploadFile\"\r\n >\r\n Submit\r\n </button>\r\n </div>\r\n <!--Button Ends-->\r\n <!--Progress Bar with Label Starts-->\r\n @if (selected.disableUploadFile) {\r\n <div class=\"progressbar\">\r\n <mat-label class=\"fileSize\"\r\n >{{ (selected.size / 1000).toFixed(2) }} KB</mat-label\r\n >\r\n <mat-label class=\"filePercentage\"> {{ progress }}% </mat-label>\r\n <mat-progress-bar\r\n mode=\"determinate\"\r\n [value]=\"progress\"\r\n class=\"displayInline\"\r\n ></mat-progress-bar>\r\n </div>\r\n }\r\n <!--Progress Bar with Label Ends-->\r\n </div>\r\n }\r\n </mat-card-content>\r\n </mat-card>\r\n }\r\n </div>\r\n </div>\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1"],"mappings":";;;;;;;;;;;;;;;;;MAIa,4BAA4B,CAAA;AAGvC,IAAA,WAAA,CAAoB,IAAgB,EAAA;QAAhB,IAAA,CAAA,IAAI,GAAJ,IAAI;IAAe;IAEvC,UAAU,CAAC,QAAa,EAAE,GAAW,EAAA;QACnC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE;AACnC,YAAA,cAAc,EAAE,IAAI;AACpB,YAAA,OAAO,EAAE,QAAQ;AAClB,SAAA,CAAC;IACJ;IACA,UAAU,CAAC,EAAU,EAAE,SAAiB,EAAA;AACtC,QAAA,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,GAAG,GAAG,EAAE,CAAC;IAC/C;8GAbW,4BAA4B,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,UAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;kHAA5B,4BAA4B,EAAA,CAAA,CAAA;;2FAA5B,4BAA4B,EAAA,UAAA,EAAA,CAAA;kBADxC;;;MCsBY,8BAA8B,CAAA;AAd3C,IAAA,WAAA,GAAA;AAiBY,QAAA,IAAA,CAAA,QAAQ,GAAG,IAAI,Y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