@servicemind.tis/tis-image-and-file-upload-and-view 1.0.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.
@@ -0,0 +1,1029 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, Component, Inject, EventEmitter, Output, Input, NgModule } from '@angular/core';
3
+ import * as i1 from '@angular/material/dialog';
4
+ import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
5
+ import * as i2 from '@angular/common';
6
+ import { CommonModule } from '@angular/common';
7
+ import * as i3 from '@angular/material/icon';
8
+ import { MatIconModule } from '@angular/material/icon';
9
+ import * as i4 from '@angular/material/progress-spinner';
10
+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
11
+ import { BehaviorSubject, map, shareReplay } from 'rxjs';
12
+ import * as i5 from '@angular/cdk/layout';
13
+ import { Breakpoints } from '@angular/cdk/layout';
14
+ import * as i1$2 from '@angular/common/http';
15
+ import { HttpHeaders } from '@angular/common/http';
16
+ import * as i1$1 from '@angular/material/snack-bar';
17
+ import { MatSnackBarModule } from '@angular/material/snack-bar';
18
+ import * as i4$1 from '@angular/material/button';
19
+ import { MatButtonModule } from '@angular/material/button';
20
+ import { MatTooltipModule } from '@angular/material/tooltip';
21
+
22
+ class TisImageAndFileUploadAndViewService {
23
+ constructor() { }
24
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisImageAndFileUploadAndViewService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
25
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisImageAndFileUploadAndViewService, providedIn: 'root' });
26
+ }
27
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisImageAndFileUploadAndViewService, decorators: [{
28
+ type: Injectable,
29
+ args: [{
30
+ providedIn: 'root'
31
+ }]
32
+ }], ctorParameters: () => [] });
33
+
34
+ class TisFileViewerComponent {
35
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisFileViewerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
36
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.6", type: TisFileViewerComponent, isStandalone: false, selector: "tis-file-viewer", ngImport: i0, template: "<p>tis-file-viewer works!</p>\n", styles: [""] });
37
+ }
38
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisFileViewerComponent, decorators: [{
39
+ type: Component,
40
+ args: [{ selector: 'tis-file-viewer', standalone: false, template: "<p>tis-file-viewer works!</p>\n" }]
41
+ }] });
42
+
43
+ class TisPreviewImageComponent {
44
+ dialogRef;
45
+ data;
46
+ width = 850;
47
+ height = 650;
48
+ isLoading = true;
49
+ isLandscape;
50
+ orientation;
51
+ imageWidth;
52
+ imageHeight;
53
+ constructor(dialogRef, data) {
54
+ this.dialogRef = dialogRef;
55
+ this.data = data;
56
+ }
57
+ ngOnInit() {
58
+ if (this.data.url) {
59
+ setTimeout(() => {
60
+ this.checkImageOrientation(this.data.url);
61
+ }, 500);
62
+ }
63
+ }
64
+ checkImageOrientation(imageUrl) {
65
+ const img = new Image();
66
+ img.src = imageUrl;
67
+ this.isLoading = true;
68
+ img.onload = () => {
69
+ this.imageWidth = img.naturalWidth;
70
+ this.imageHeight = img.naturalHeight;
71
+ this.isLandscape = img.naturalWidth > img.naturalHeight;
72
+ this.orientation = this.isLandscape ? 'landscape-image' : 'portrait-image';
73
+ this.isLoading = false;
74
+ };
75
+ img.onerror = () => {
76
+ console.error('Failed to load image.');
77
+ this.isLoading = false;
78
+ };
79
+ }
80
+ onClose() {
81
+ this.dialogRef.close();
82
+ }
83
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisPreviewImageComponent, deps: [{ token: i1.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
84
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.6", type: TisPreviewImageComponent, isStandalone: false, selector: "tis-preview-image", ngImport: i0, template: "@if(isLoading){\n <div style=\"width: 350px; height: 350px; display: flex; justify-content: center; align-items: center\">\n <mat-progress-spinner color=\"primary\" mode=\"indeterminate\" [diameter]=\"80\"></mat-progress-spinner>\n </div>\n}\n@else{\n <div class=\"w-100 dialog-container\" appScrolling style=\"--img-width: {{(imageWidth && imageWidth < 700) ? imageWidth : 650}}px; --img-height: {{(imageHeight && imageHeight < 600) ? imageHeight : 600}}px\">\n <mat-icon\n class=\"close-icon\"\n (click)=\"onClose()\">cancel</mat-icon>\n <img \n *ngIf=\"data.url\" \n [src]=\"data.url\" \n alt=\"preview-image\" \n class=\"preview-image {{orientation}}\">\n </div>\n}", styles: ["::ng-deep .mat-p-0 .mat-dialog-container{padding:0!important}.dialog-container{overflow:auto;max-height:calc(100vh - 15px);display:flex;justify-content:center;align-items:center}.landscape-image{width:var(--img-width);max-width:95vw;object-fit:contain}.portrait-image{height:var(--img-height);max-height:95vh;object-fit:contain}.close-icon{color:var(--tis-cancel, #bb333b);position:absolute;top:10px;right:10px;z-index:99;cursor:pointer}\n"], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i4.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }] });
85
+ }
86
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisPreviewImageComponent, decorators: [{
87
+ type: Component,
88
+ args: [{ selector: 'tis-preview-image', standalone: false, template: "@if(isLoading){\n <div style=\"width: 350px; height: 350px; display: flex; justify-content: center; align-items: center\">\n <mat-progress-spinner color=\"primary\" mode=\"indeterminate\" [diameter]=\"80\"></mat-progress-spinner>\n </div>\n}\n@else{\n <div class=\"w-100 dialog-container\" appScrolling style=\"--img-width: {{(imageWidth && imageWidth < 700) ? imageWidth : 650}}px; --img-height: {{(imageHeight && imageHeight < 600) ? imageHeight : 600}}px\">\n <mat-icon\n class=\"close-icon\"\n (click)=\"onClose()\">cancel</mat-icon>\n <img \n *ngIf=\"data.url\" \n [src]=\"data.url\" \n alt=\"preview-image\" \n class=\"preview-image {{orientation}}\">\n </div>\n}", styles: ["::ng-deep .mat-p-0 .mat-dialog-container{padding:0!important}.dialog-container{overflow:auto;max-height:calc(100vh - 15px);display:flex;justify-content:center;align-items:center}.landscape-image{width:var(--img-width);max-width:95vw;object-fit:contain}.portrait-image{height:var(--img-height);max-height:95vh;object-fit:contain}.close-icon{color:var(--tis-cancel, #bb333b);position:absolute;top:10px;right:10px;z-index:99;cursor:pointer}\n"] }]
89
+ }], ctorParameters: () => [{ type: i1.MatDialogRef }, { type: undefined, decorators: [{
90
+ type: Inject,
91
+ args: [MAT_DIALOG_DATA]
92
+ }] }] });
93
+
94
+ class TisErrorDialogComponent {
95
+ dialogRef;
96
+ data;
97
+ constructor(dialogRef, data) {
98
+ this.dialogRef = dialogRef;
99
+ this.data = data;
100
+ }
101
+ onClose() {
102
+ this.dialogRef.close();
103
+ }
104
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisErrorDialogComponent, deps: [{ token: i1.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
105
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.6", type: TisErrorDialogComponent, isStandalone: false, selector: "lib-tis-error-dialog", ngImport: i0, template: "<h1 mat-dialog-title>\n <mat-icon class=\"{{data?.iconClass}}\">{{data?.icon}}</mat-icon>\n {{data?.title}}\n</h1>\n<div mat-dialog-content>\n {{data?.message}}\n</div>\n<div mat-dialog-actions>\n <button mat-button class=\"tis-text-upper {{data?.buttonClass ?? 'tis-btn-primary'}}\" (click)=\"onClose()\" cdkFocusInitial *ngIf=\"data?.buttonText && data?.buttonText != ''\">{{data?.buttonText}}</button>\n</div>", styles: [""], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i4$1.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "directive", type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "directive", type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }] });
106
+ }
107
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisErrorDialogComponent, decorators: [{
108
+ type: Component,
109
+ args: [{ selector: 'lib-tis-error-dialog', standalone: false, template: "<h1 mat-dialog-title>\n <mat-icon class=\"{{data?.iconClass}}\">{{data?.icon}}</mat-icon>\n {{data?.title}}\n</h1>\n<div mat-dialog-content>\n {{data?.message}}\n</div>\n<div mat-dialog-actions>\n <button mat-button class=\"tis-text-upper {{data?.buttonClass ?? 'tis-btn-primary'}}\" (click)=\"onClose()\" cdkFocusInitial *ngIf=\"data?.buttonText && data?.buttonText != ''\">{{data?.buttonText}}</button>\n</div>" }]
110
+ }], ctorParameters: () => [{ type: i1.MatDialogRef }, { type: undefined, decorators: [{
111
+ type: Inject,
112
+ args: [MAT_DIALOG_DATA]
113
+ }] }] });
114
+
115
+ class TisHelperService {
116
+ snackBar;
117
+ dialog;
118
+ http;
119
+ constructor(snackBar, dialog, http) {
120
+ this.snackBar = snackBar;
121
+ this.dialog = dialog;
122
+ this.http = http;
123
+ }
124
+ showHttpErrorMsg(error, duration = 5000) {
125
+ console.log('httpError: ', error);
126
+ let errorMessage = 'Some Unknown Error Occurred.';
127
+ let errorCode = 'Unknown Error';
128
+ const httpError = error;
129
+ if (httpError.status >= 400) {
130
+ const errorFromServer = httpError.error;
131
+ if (Array.isArray(errorFromServer) && errorFromServer.length > 0) {
132
+ errorMessage = errorFromServer[0].message;
133
+ errorCode = errorFromServer[0].code;
134
+ }
135
+ }
136
+ else if (httpError.status < 100) {
137
+ errorMessage = httpError.message;
138
+ errorCode = httpError.statusText;
139
+ }
140
+ if (errorCode == "VALIDATION_ERROR" || errorCode == "NOT_FOUND_ERROR" || errorCode == "THIRD_PARTY_API_ERROR") {
141
+ let confirmBoxData = {
142
+ title: "Error !",
143
+ message: errorMessage,
144
+ icon: "error",
145
+ iconClass: "tis-text-danger",
146
+ buttonText: "Ok",
147
+ buttonClass: "tis-btn-primary",
148
+ };
149
+ const dialogRef = this.dialog.open(TisErrorDialogComponent, {
150
+ width: "550px",
151
+ panelClass: ['tis-simple-confirmation'],
152
+ data: confirmBoxData,
153
+ disableClose: false,
154
+ });
155
+ return dialogRef;
156
+ }
157
+ else {
158
+ const snackbarRef = this.snackBar.open(errorMessage, 'Error', { duration: duration });
159
+ return snackbarRef;
160
+ }
161
+ }
162
+ showSuccessMsg(message, title, duration = 5000) {
163
+ this.snackBar.open(message, title, {
164
+ duration: duration
165
+ });
166
+ }
167
+ showErrorMsg(message, title, duration = 5000) {
168
+ this.snackBar.open(message, title, {
169
+ duration: duration
170
+ });
171
+ }
172
+ async compressFile(image, mimeType) {
173
+ let imageData = image;
174
+ let imageBlob = this.dataURItoBlob(imageData.split(',')[1], mimeType);
175
+ return imageBlob;
176
+ }
177
+ dataURItoBlob(dataURI, mimeType) {
178
+ const byteString = window.atob(dataURI);
179
+ const arrayBuffer = new ArrayBuffer(byteString.length);
180
+ const int8Array = new Uint8Array(arrayBuffer);
181
+ for (let i = 0; i < byteString.length; i++) {
182
+ int8Array[i] = byteString.charCodeAt(i);
183
+ }
184
+ const blob = new Blob([int8Array], { type: mimeType });
185
+ return blob;
186
+ }
187
+ getDataUrlFromFile(file) {
188
+ return new Promise((resolve, reject) => {
189
+ var reader = new FileReader();
190
+ reader.onload = (e) => {
191
+ resolve(e.target.result);
192
+ };
193
+ reader.onerror = (e) => {
194
+ reject(e.target.error);
195
+ };
196
+ reader.readAsDataURL(file);
197
+ });
198
+ }
199
+ getUploadUrl(url, filename, mimeType, type) {
200
+ return this.http.post(url, { filename, mimeType, type });
201
+ }
202
+ attachImagesToEntity(url, data) {
203
+ return this.http.post(url, data);
204
+ }
205
+ uploadImageByEntity(url, data) {
206
+ return this.http.post(url, data);
207
+ }
208
+ putImage(url, file, contentType) {
209
+ // const headers = new HttpHeaders({ "content-type": contentType ? contentType : "binary/octet-stream"}).set(SkipAuthInterceptorHeader, "");
210
+ const headers = new HttpHeaders({ "content-type": contentType ? contentType : "binary/octet-stream" });
211
+ return this.http.put(url, file, { headers });
212
+ }
213
+ deleteUploadedImage(url, data) {
214
+ return this.http.post(url, data);
215
+ }
216
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisHelperService, deps: [{ token: i1$1.MatSnackBar }, { token: i1.MatDialog }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
217
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisHelperService, providedIn: 'root' });
218
+ }
219
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisHelperService, decorators: [{
220
+ type: Injectable,
221
+ args: [{
222
+ providedIn: 'root'
223
+ }]
224
+ }], ctorParameters: () => [{ type: i1$1.MatSnackBar }, { type: i1.MatDialog }, { type: i1$2.HttpClient }] });
225
+
226
+ class FileUploadService {
227
+ http;
228
+ constructor(http) {
229
+ this.http = http;
230
+ }
231
+ getUploadUrl(url, filename, mimeType, type) {
232
+ return this.http.post(url, { filename, mimeType, type });
233
+ }
234
+ attachFilesToEntity(url, data) {
235
+ return this.http.post(url, data);
236
+ }
237
+ putFile(url, file) {
238
+ // const headers = new HttpHeaders({ "content-type": "binary/octet-stream"}).set(SkipAuthInterceptorHeader, "");
239
+ const headers = new HttpHeaders({ "content-type": "binary/octet-stream" });
240
+ return this.http.put(url, file, { headers });
241
+ }
242
+ deleteUploadedFile(url, data) {
243
+ return this.http.post(url, data);
244
+ }
245
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: FileUploadService, deps: [{ token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
246
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: FileUploadService, providedIn: 'root' });
247
+ }
248
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: FileUploadService, decorators: [{
249
+ type: Injectable,
250
+ args: [{
251
+ providedIn: 'root'
252
+ }]
253
+ }], ctorParameters: () => [{ type: i1$2.HttpClient }] });
254
+
255
+ class ImageUploadService {
256
+ http;
257
+ constructor(http) {
258
+ this.http = http;
259
+ }
260
+ getUploadUrl(url, filename, mimeType, type) {
261
+ return this.http.post(url, { filename, mimeType, type });
262
+ }
263
+ attachImagesToEntity(url, data) {
264
+ return this.http.post(url, data);
265
+ }
266
+ // uploadImageByEntity(url: string, data: any): Observable<any> {
267
+ // return this.http.post(url, data);
268
+ // }
269
+ putImage(url, file, contentType) {
270
+ // const headers = new HttpHeaders({ "content-type": contentType ? contentType : "binary/octet-stream"}).set(SkipAuthInterceptorHeader, "");
271
+ const headers = new HttpHeaders({ "content-type": contentType ? contentType : "binary/octet-stream" });
272
+ return this.http.put(url, file, { headers });
273
+ }
274
+ deleteUploadedImage(url, data) {
275
+ return this.http.post(url, data);
276
+ }
277
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ImageUploadService, deps: [{ token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
278
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ImageUploadService, providedIn: 'root' });
279
+ }
280
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: ImageUploadService, decorators: [{
281
+ type: Injectable,
282
+ args: [{
283
+ providedIn: 'root'
284
+ }]
285
+ }], ctorParameters: () => [{ type: i1$2.HttpClient }] });
286
+
287
+ class TisConfirmationDialogComponent {
288
+ dialogRef;
289
+ data;
290
+ constructor(dialogRef, data) {
291
+ this.dialogRef = dialogRef;
292
+ this.data = data;
293
+ this.dialogRef.addPanelClass(['md-tis-w-400-px']);
294
+ }
295
+ onClose(status) {
296
+ this.dialogRef.close(status);
297
+ }
298
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisConfirmationDialogComponent, deps: [{ token: i1.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
299
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.6", type: TisConfirmationDialogComponent, isStandalone: false, selector: "tis-confirmation-dialog", ngImport: i0, template: "<h1 mat-dialog-title style=\"align-items: center; display: flex;\">\n <mat-icon class=\"{{data?.iconClass}}\">{{data?.icon}}</mat-icon>\n <span>{{data?.title}}</span>\n</h1>\n<div mat-dialog-content>\n @if(data?.html){\n <h5 class=\"title\">{{data?.message}}</h5>\n <div [innerHTML]=\"data.html\">\n </div>\n }\n @else {\n <span>{{data?.message}}</span>\n }\n</div>\n<div mat-dialog-actions>\n <button mat-button class=\"tis-text-upper {{data?.cancelButtonClass ?? 'tis-btn-primary'}}\" (click)=\"onClose(false)\" *ngIf=\"data?.cancelButtonText && data?.cancelButtonText != ''\">{{data?.cancelButtonText}}</button>\n <button mat-button class=\"tis-text-upper {{data?.approveButtonClass ?? 'tis-btn-primary'}}\" (click)=\"onClose(true)\" cdkFocusInitial *ngIf=\"data?.approveButtonText && data?.approveButtonText != ''\">{{data?.approveButtonText}}</button>\n</div>", styles: [""], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i4$1.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "directive", type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "directive", type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }] });
300
+ }
301
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisConfirmationDialogComponent, decorators: [{
302
+ type: Component,
303
+ args: [{ selector: 'tis-confirmation-dialog', standalone: false, template: "<h1 mat-dialog-title style=\"align-items: center; display: flex;\">\n <mat-icon class=\"{{data?.iconClass}}\">{{data?.icon}}</mat-icon>\n <span>{{data?.title}}</span>\n</h1>\n<div mat-dialog-content>\n @if(data?.html){\n <h5 class=\"title\">{{data?.message}}</h5>\n <div [innerHTML]=\"data.html\">\n </div>\n }\n @else {\n <span>{{data?.message}}</span>\n }\n</div>\n<div mat-dialog-actions>\n <button mat-button class=\"tis-text-upper {{data?.cancelButtonClass ?? 'tis-btn-primary'}}\" (click)=\"onClose(false)\" *ngIf=\"data?.cancelButtonText && data?.cancelButtonText != ''\">{{data?.cancelButtonText}}</button>\n <button mat-button class=\"tis-text-upper {{data?.approveButtonClass ?? 'tis-btn-primary'}}\" (click)=\"onClose(true)\" cdkFocusInitial *ngIf=\"data?.approveButtonText && data?.approveButtonText != ''\">{{data?.approveButtonText}}</button>\n</div>" }]
304
+ }], ctorParameters: () => [{ type: i1.MatDialogRef }, { type: undefined, decorators: [{
305
+ type: Inject,
306
+ args: [MAT_DIALOG_DATA]
307
+ }] }] });
308
+
309
+ class TisImageAndFileUploadAndViewComponent {
310
+ dialog;
311
+ fileUploadService;
312
+ imageUploadService;
313
+ helper;
314
+ breakpointObserver;
315
+ changeSubject = new BehaviorSubject(false);
316
+ urlConfig;
317
+ entityType;
318
+ entityId;
319
+ viewType = 'card';
320
+ type = 'image';
321
+ label = null;
322
+ disabled = false;
323
+ data;
324
+ hint = null;
325
+ accept = '';
326
+ selectedId = null;
327
+ options = null;
328
+ required = false;
329
+ previewOnly = false;
330
+ previewInFlex = false;
331
+ imageItemClass = '';
332
+ isEnableDeleteConfirmation = true;
333
+ deleteConfirmationMsg;
334
+ dialogConfig;
335
+ uploadInProgress = new EventEmitter();
336
+ onUploaded = new EventEmitter();
337
+ onFileSelect = new EventEmitter();
338
+ onFileRemoved = new EventEmitter();
339
+ isMobile = false;
340
+ isTab = false;
341
+ isHandset$;
342
+ isTab$;
343
+ config = {
344
+ isCompressed: false,
345
+ hiddenDeleteBtn: false,
346
+ hiddenPreview: false,
347
+ selectionMode: false,
348
+ isStoredDb: false,
349
+ isMultiple: false,
350
+ fileSize: null,
351
+ limit: 10,
352
+ cols: 5,
353
+ colsForTab: 5,
354
+ colsForMobile: 3,
355
+ height: '130px',
356
+ selectorId: 'choosing-img',
357
+ };
358
+ isSliderLoaded = true;
359
+ filesArray = [
360
+ // {
361
+ // "s3Url": "https://obk-servicemind-uat-resources.s3.ap-southeast-1.amazonaws.com/parcel_create/da226bf2-4e5f-4180-94d8-6746b1ce139b.jpg",
362
+ // "uploadData": {
363
+ // "isBase64Encoded": false,
364
+ // "headers": {
365
+ // "Access-Control-Allow-Origin": "*"
366
+ // },
367
+ // "uploadURL": "https://obk-servicemind-uat-resources.s3.ap-southeast-1.amazonaws.com/parcel_create/da226bf2-4e5f-4180-94d8-6746b1ce139b.jpg?Content-Type=image%2Fjpeg&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA37VN5NQI5HY4VFVN%2F20220617%2Fap-southeast-1%2Fs3%2Faws4_request&X-Amz-Date=20220617T152621Z&X-Amz-Expires=900&X-Amz-Signature=4004cfb10a740b9623d486de992a06f53b458ed6fc151c092eea88a3059eae8f&X-Amz-SignedHeaders=host%3Bx-amz-acl&x-amz-acl=public-read",
368
+ // "photoFilename": "f7a32cd0-d0c1-474a-838e-47402d80527a.jpeg",
369
+ // "fileName": "1452664590074.jpeg",
370
+ // "uploadPath": "/survey_orders/f7a32cd0-d0c1-474a-838e-47402d80527a.jpeg",
371
+ // "resourceUrl": "https://obk-servicemind-uat-resources.s3.ap-southeast-1.amazonaws.com/parcel_create/da226bf2-4e5f-4180-94d8-6746b1ce139b.jpg"
372
+ // }
373
+ // },
374
+ // {
375
+ // "s3Url": "https://obk-servicemind-uat-resources.s3.ap-southeast-1.amazonaws.com/parcel_create/31033a2a-5db6-450d-a541-58a94654dd0c.jpg",
376
+ // "uploadData": {
377
+ // "isBase64Encoded": false,
378
+ // "headers": {
379
+ // "Access-Control-Allow-Origin": "*"
380
+ // },
381
+ // "uploadURL": "https://servicemind-resources-staging.s3.ap-southeast-1.amazonaws.com/survey_orders/6c537889-c72a-48ca-9134-638e8d6a1aac.sql?Content-Type=application%2Fsql&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA37VN5NQI5HY4VFVN%2F20220617%2Fap-southeast-1%2Fs3%2Faws4_request&X-Amz-Date=20220617T152641Z&X-Amz-Expires=900&X-Amz-Signature=bcdf347df2a6495615bf48d619492e1deac2264231161da5dc3becaa7f45a796&X-Amz-SignedHeaders=host%3Bx-amz-acl&x-amz-acl=public-read",
382
+ // "photoFilename": "6c537889-c72a-48ca-9134-638e8d6a1aac.sql",
383
+ // "fileName": "eccom_bermuda.sql",
384
+ // "uploadPath": "/survey_orders/6c537889-c72a-48ca-9134-638e8d6a1aac.sql",
385
+ // "resourceUrl": "https://servicemind-resources-staging.s3.ap-southeast-1.amazonaws.com/survey_orders/6c537889-c72a-48ca-9134-638e8d6a1aac.sql"
386
+ // }
387
+ // },
388
+ // {
389
+ // "s3Url": "https://obk-servicemind-uat-resources.s3.ap-southeast-1.amazonaws.com/parcel_create/b8424185-30c6-4f44-ba1e-ff616dfd6576.jpg",
390
+ // "uploadData": {
391
+ // "isBase64Encoded": false,
392
+ // "headers": {
393
+ // "Access-Control-Allow-Origin": "*"
394
+ // },
395
+ // "uploadURL": "https://servicemind-resources-staging.s3.ap-southeast-1.amazonaws.com/survey_orders/232f2548-dc93-4204-8835-86b69f3005a7.pdf?Content-Type=application%2Fpdf&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA37VN5NQI5HY4VFVN%2F20220617%2Fap-southeast-1%2Fs3%2Faws4_request&X-Amz-Date=20220617T152656Z&X-Amz-Expires=900&X-Amz-Signature=85643479c3fbecc5bd1fee9783e3cb72e27e16a034921b52cf2f377eefb01ff9&X-Amz-SignedHeaders=host%3Bx-amz-acl&x-amz-acl=public-read",
396
+ // "photoFilename": "232f2548-dc93-4204-8835-86b69f3005a7.pdf",
397
+ // "fileName": "print-registration-4x6.pdf",
398
+ // "uploadPath": "/survey_orders/232f2548-dc93-4204-8835-86b69f3005a7.pdf",
399
+ // "resourceUrl": "https://servicemind-resources-staging.s3.ap-southeast-1.amazonaws.com/survey_orders/232f2548-dc93-4204-8835-86b69f3005a7.pdf"
400
+ // }
401
+ // }
402
+ ];
403
+ currentEntityId;
404
+ currentEntityType;
405
+ images = [];
406
+ loading = false;
407
+ status = false;
408
+ constructor(dialog, fileUploadService, imageUploadService, helper, breakpointObserver) {
409
+ this.dialog = dialog;
410
+ this.fileUploadService = fileUploadService;
411
+ this.imageUploadService = imageUploadService;
412
+ this.helper = helper;
413
+ this.breakpointObserver = breakpointObserver;
414
+ }
415
+ ngOnInit() {
416
+ this.isHandset$ = this.breakpointObserver.observe([Breakpoints.Handset])
417
+ .pipe(map(result => result.matches), shareReplay());
418
+ this.isTab$ = this.breakpointObserver.observe([Breakpoints.TabletPortrait])
419
+ .pipe(map(result => result.matches), shareReplay());
420
+ this.prepareConfig();
421
+ }
422
+ ngAfterViewInit() {
423
+ this.isHandset$.subscribe(r => {
424
+ console.log('IS HANDSET:', r);
425
+ this.isMobile = r;
426
+ this.changeSubject.next(true);
427
+ });
428
+ this.isTab$.subscribe(r => {
429
+ console.log('IS TAB:', r);
430
+ this.isTab = r;
431
+ this.changeSubject.next(true);
432
+ });
433
+ this.changeSubject.subscribe(status => {
434
+ let cols = 1;
435
+ if (this.isMobile) {
436
+ cols = this.options?.colsForMobile ?? 3;
437
+ }
438
+ else if (this.isTab) {
439
+ cols = this.options?.colsForTab ?? 4;
440
+ }
441
+ else {
442
+ cols = this.options?.cols ?? 5;
443
+ }
444
+ this.config.cols = cols;
445
+ });
446
+ }
447
+ ngOnChanges(changes) {
448
+ if (changes['entityId']) {
449
+ this.currentEntityId = changes['entityId'].currentValue;
450
+ }
451
+ if (changes['entityType']) {
452
+ this.currentEntityType = changes['entityType'].currentValue;
453
+ }
454
+ if (changes['options']) {
455
+ this.prepareConfig();
456
+ }
457
+ if (changes['data']) {
458
+ this.filesArray = changes['data']?.currentValue ?? [];
459
+ this.filesArray = this.filesArray?.map(r => {
460
+ r.loading = false;
461
+ return r;
462
+ });
463
+ console.log("this.filesArray", this.filesArray);
464
+ }
465
+ }
466
+ prepareConfig() {
467
+ if (this.options?.isCompressed) {
468
+ this.config.isCompressed = this.options?.isCompressed;
469
+ }
470
+ if (this.options?.isSliderPreview) {
471
+ this.config.isSliderPreview = this.options?.isSliderPreview;
472
+ }
473
+ if (this.options?.hiddenDeleteBtn) {
474
+ this.config.hiddenDeleteBtn = this.options?.hiddenDeleteBtn;
475
+ }
476
+ if (this.options?.hiddenPreview) {
477
+ this.config.hiddenPreview = this.options?.hiddenPreview;
478
+ }
479
+ if (this.options?.selectionMode) {
480
+ this.config.selectionMode = this.options?.selectionMode;
481
+ }
482
+ if (this.options?.isStoredDb) {
483
+ this.config.isStoredDb = this.options?.isStoredDb;
484
+ }
485
+ if (this.options?.isMultiple) {
486
+ this.config.isMultiple = this.options?.isMultiple;
487
+ }
488
+ if (this.options?.fileSize) {
489
+ this.config.fileSize = this.options?.fileSize;
490
+ }
491
+ if (this.options?.limit) {
492
+ this.config.limit = this.options?.limit;
493
+ }
494
+ if (this.options?.cols) {
495
+ this.config.cols = this.options?.cols;
496
+ }
497
+ if (this.options?.colsForTab) {
498
+ this.config.colsForTab = this.options?.colsForTab;
499
+ }
500
+ if (this.options?.colsForMobile) {
501
+ this.config.colsForMobile = this.options?.colsForMobile;
502
+ }
503
+ if (this.options?.height) {
504
+ this.config.height = this.options?.height;
505
+ }
506
+ if (this.options?.selectorId) {
507
+ this.config.selectorId = this.options?.selectorId;
508
+ }
509
+ }
510
+ setSliderLoading() {
511
+ this.isSliderLoaded = false;
512
+ setTimeout(() => {
513
+ this.isSliderLoaded = true;
514
+ }, 20);
515
+ }
516
+ openImageSelector() {
517
+ document.getElementById(this.config?.selectorId)?.click();
518
+ }
519
+ async detectImages(event) {
520
+ console.log('detectImages:', event);
521
+ event.preventDefault();
522
+ if (this.config?.limit === 1) {
523
+ this.filesArray = []; // Reset array for a single image
524
+ }
525
+ let files = event.target.files;
526
+ if (!files) {
527
+ this.helper.showErrorMsg('Please select an image', 'Error', 3000);
528
+ return;
529
+ }
530
+ if ((this.filesArray?.length + files.length) > this.config?.limit) {
531
+ this.helper.showErrorMsg(`You can upload a maximum of ${this.config?.limit} images`, 'Error', 3000);
532
+ return;
533
+ }
534
+ this.loading = true;
535
+ this.uploadInProgress.emit(true);
536
+ let uploadedImages = [];
537
+ // Process all images concurrently and wait for completion
538
+ await Promise.all([...files].map(file => this.processImage(file, uploadedImages)));
539
+ if (this.config?.isStoredDb) {
540
+ await this.uploadImages(uploadedImages);
541
+ }
542
+ this.loading = false;
543
+ this.uploadInProgress.emit(false);
544
+ this.onSubmit(); // Call once after all uploads
545
+ }
546
+ async processImage(file, uploadedImages) {
547
+ let fileSize = file.size / 1024;
548
+ if (this.config?.fileSize && fileSize > this.config?.fileSize) {
549
+ let maxSize = this.config.fileSize / 1024;
550
+ this.helper.showErrorMsg(`File size must be ≤ ${maxSize >= 1 ? maxSize : this.config.fileSize} ${maxSize >= 1 ? 'MB' : 'KB'}`, 'Error', 3000);
551
+ return;
552
+ }
553
+ return new Promise((resolve) => {
554
+ let reader = new FileReader();
555
+ reader.onload = async (e) => {
556
+ let mimeType = file.type;
557
+ let compressedImage = this.config?.isCompressed ? await this.helper.compressFile(e.target?.result, mimeType) : e.target.result;
558
+ try {
559
+ let uploadResponse = await this.imageUploadService.getUploadUrl(this.urlConfig.getUploadUrl, file.name, mimeType, this.currentEntityType).toPromise();
560
+ let uploadData = uploadResponse.data.uploadUrlData;
561
+ let dataUrl = await this.helper.getDataUrlFromFile(file);
562
+ let currentImageData = {
563
+ title: file.name, name: file.name, s3Url: dataUrl,
564
+ filename: file.name, s3Path: uploadData.uploadPath,
565
+ tempS3Url: uploadData.resourceUrl, id: null,
566
+ uploadData: uploadData, loading: true
567
+ };
568
+ this.filesArray = [currentImageData, ...this.filesArray];
569
+ this.setSliderLoading();
570
+ uploadedImages.push(currentImageData);
571
+ await this.imageUploadService.putImage(uploadData.uploadURL, compressedImage).toPromise();
572
+ // Final processing
573
+ currentImageData.s3Url = currentImageData.tempS3Url;
574
+ currentImageData.loading = !this.config?.isStoredDb;
575
+ this.setSliderLoading();
576
+ resolve();
577
+ }
578
+ catch (error) {
579
+ this.helper.showHttpErrorMsg(error);
580
+ resolve();
581
+ }
582
+ };
583
+ reader.readAsArrayBuffer(file);
584
+ });
585
+ }
586
+ uploadImages(data) {
587
+ return new Promise((resolve, reject) => {
588
+ if (data && data?.length > 0) {
589
+ console.log('There is a image pending to attach:', data);
590
+ let images = [];
591
+ let fa = data.map((r) => {
592
+ if (r?.uploadData) {
593
+ images.push({ fileName: r.uploadData?.fileName, resourceUrl: r.uploadData?.resourceUrl, uploadPath: r.uploadData?.uploadPath, uploadURL: r.uploadData?.uploadURL });
594
+ // delete r.uploadData;
595
+ }
596
+ return r;
597
+ });
598
+ this.imageUploadService.attachImagesToEntity(this.urlConfig.attachToEntity, { images: images, entityId: this.currentEntityId, entityType: this.currentEntityType }).subscribe({
599
+ next: (ir) => {
600
+ resolve(ir);
601
+ },
602
+ error: (imErr) => this.helper.showErrorMsg(imErr, "Error")
603
+ });
604
+ }
605
+ else {
606
+ resolve(false);
607
+ }
608
+ });
609
+ }
610
+ deleteImage(event, t, index, img) {
611
+ event.stopPropagation();
612
+ if (this.isEnableDeleteConfirmation) {
613
+ let confirmBoxData = {
614
+ title: this.dialogConfig.title,
615
+ message: this.deleteConfirmationMsg ?? this.dialogConfig.message,
616
+ iconClass: this.dialogConfig.iconClass,
617
+ icon: this.dialogConfig.icon,
618
+ approveButtonText: this.dialogConfig.approveButtonText,
619
+ approveButtonClass: this.dialogConfig.approveButtonClass,
620
+ cancelButtonText: this.dialogConfig.cancelButtonText,
621
+ cancelButtonClass: this.dialogConfig.cancelButtonClass
622
+ };
623
+ const dialogRef = this.dialog.open(TisConfirmationDialogComponent, {
624
+ width: "450px",
625
+ panelClass: ['tis-confirmation-dialog'],
626
+ data: confirmBoxData,
627
+ disableClose: true,
628
+ });
629
+ dialogRef.afterClosed().subscribe((result) => {
630
+ console.log("The dialog was closed with result:", result);
631
+ if (result) {
632
+ this.removeImage(event, index, img);
633
+ }
634
+ });
635
+ }
636
+ else {
637
+ this.removeImage(event, index, img);
638
+ }
639
+ }
640
+ /*REMOVE SELECTED IMAGE */
641
+ removeImage(event, index, img) {
642
+ this.loading = true;
643
+ this.filesArray[index].loading = true;
644
+ if (img?.id) {
645
+ delete img.uploadData;
646
+ this.removeUploadedImage(img, index, true);
647
+ }
648
+ else {
649
+ this.loading = false;
650
+ this.filesArray.splice(index, 1);
651
+ this.setSliderLoading();
652
+ this.onSubmit();
653
+ }
654
+ }
655
+ removeUploadedImage(img, index, silently = false) {
656
+ console.log("removeUploadedImage:", img);
657
+ this.imageUploadService.deleteUploadedImage(this.urlConfig.removeImage, img).subscribe((r) => {
658
+ console.log('Image Delete Res:', r);
659
+ this.loading = false;
660
+ this.filesArray.splice(index, 1);
661
+ this.setSliderLoading();
662
+ this.onSubmit();
663
+ if (!silently) {
664
+ this.helper.showSuccessMsg(r.message, 'Success', 3000);
665
+ }
666
+ }, (err) => { this.filesArray[index].loading = false; this.helper.showErrorMsg(err, "Error"); });
667
+ }
668
+ async detectFiles(event) {
669
+ console.log('detectFiles:', event);
670
+ event.preventDefault();
671
+ if (this.config?.limit === 1) {
672
+ this.filesArray = []; // Reset array for a single file
673
+ }
674
+ let files = event.target.files;
675
+ if (!files) {
676
+ this.helper.showErrorMsg('Please select a file', 'Error', 3000);
677
+ return;
678
+ }
679
+ if ((this.filesArray?.length + files.length) > this.config?.limit) {
680
+ this.helper.showErrorMsg(`You can upload a maximum of ${this.config?.limit} files`, 'Error', 3000);
681
+ return;
682
+ }
683
+ this.loading = true;
684
+ this.uploadInProgress.emit(true);
685
+ let uploadedFiles = [];
686
+ // Process all files concurrently and wait for completion
687
+ await Promise.all([...files].map(file => this.processFile(file, uploadedFiles)));
688
+ if (this.config?.isStoredDb) {
689
+ await this.uploadFiles(uploadedFiles);
690
+ }
691
+ this.loading = false;
692
+ this.uploadInProgress.emit(false);
693
+ this.onSubmit(); // Call once after all uploads
694
+ }
695
+ async processFile(file, uploadedFiles) {
696
+ let fileSize = file.size / 1024;
697
+ if (this.config?.fileSize && fileSize > this.config?.fileSize) {
698
+ let maxSize = this.config.fileSize / 1024;
699
+ this.helper.showErrorMsg(`File size must be ≤ ${maxSize >= 1 ? maxSize : this.config.fileSize} ${maxSize >= 1 ? 'MB' : 'KB'}`, 'Error', 3000);
700
+ return;
701
+ }
702
+ return new Promise((resolve) => {
703
+ let reader = new FileReader();
704
+ reader.onload = async (e) => {
705
+ let mimeType = file.type;
706
+ let buffer = new Uint8Array(reader.result);
707
+ try {
708
+ let uploadResponse = await this.fileUploadService.getUploadUrl(this.urlConfig.getUploadUrl, file.name, mimeType, this.currentEntityType).toPromise();
709
+ let uploadData = uploadResponse.data.uploadUrlData;
710
+ let currentFileData = {
711
+ title: file.name, name: file.name, s3Url: uploadData.resourceUrl,
712
+ s3Path: uploadData.uploadPath, filename: file.name, id: null,
713
+ uploadData: uploadData, loading: true, buffer: buffer
714
+ };
715
+ this.filesArray = [currentFileData, ...this.filesArray];
716
+ this.setSliderLoading();
717
+ uploadedFiles.push(currentFileData);
718
+ await this.fileUploadService.putFile(uploadData.uploadURL, e.target.result).toPromise();
719
+ // Final processing
720
+ currentFileData.s3Url = currentFileData.uploadData?.resourceUrl;
721
+ currentFileData.loading = !this.config?.isStoredDb;
722
+ this.setSliderLoading();
723
+ resolve();
724
+ }
725
+ catch (error) {
726
+ this.helper.showHttpErrorMsg(error);
727
+ resolve();
728
+ }
729
+ };
730
+ reader.readAsArrayBuffer(file);
731
+ });
732
+ }
733
+ uploadFiles(data) {
734
+ return new Promise((resolve, reject) => {
735
+ if (data && data.length > 0) {
736
+ console.log('There is a file pending to attach:', data);
737
+ let files = [];
738
+ let fa = data.map((r) => {
739
+ if (r?.uploadData) {
740
+ files.push({ fileName: r.uploadData?.fileName, resourceUrl: r.uploadData?.resourceUrl, uploadPath: r.uploadData?.uploadPath, uploadURL: r.uploadData?.uploadURL });
741
+ // delete r.uploadData;
742
+ }
743
+ return r;
744
+ });
745
+ this.fileUploadService.attachFilesToEntity(this.urlConfig.attachToEntity, { files: files, entityId: this.currentEntityId, entityType: this.currentEntityType }).subscribe({
746
+ next: (ir) => {
747
+ // this.filesArray = fa;
748
+ this.filesArray[0].loading = false;
749
+ this.onSubmit();
750
+ resolve(ir);
751
+ },
752
+ error: (imErr) => reject(imErr)
753
+ });
754
+ }
755
+ else {
756
+ resolve(false);
757
+ }
758
+ });
759
+ }
760
+ deleteFile(event, t, index, file) {
761
+ event.stopPropagation();
762
+ if (this.isEnableDeleteConfirmation) {
763
+ let confirmBoxData = {
764
+ title: this.dialogConfig.title,
765
+ message: this.deleteConfirmationMsg ?? this.dialogConfig.message,
766
+ iconClass: this.dialogConfig.iconClass,
767
+ icon: this.dialogConfig.icon,
768
+ approveButtonText: this.dialogConfig.approveButtonText,
769
+ approveButtonClass: this.dialogConfig.approveButtonClass,
770
+ cancelButtonText: this.dialogConfig.cancelButtonText,
771
+ cancelButtonClass: this.dialogConfig.cancelButtonClass
772
+ };
773
+ const dialogRef = this.dialog.open(TisConfirmationDialogComponent, {
774
+ width: "450px",
775
+ panelClass: ['tis-simple-confirmation'],
776
+ data: confirmBoxData,
777
+ disableClose: true,
778
+ });
779
+ dialogRef.afterClosed().subscribe((result) => {
780
+ console.log("The dialog was closed with result:", result);
781
+ if (result) {
782
+ this.removeFile(event, index, file);
783
+ }
784
+ });
785
+ }
786
+ else {
787
+ this.removeFile(event, index, file);
788
+ }
789
+ }
790
+ removeFile(event, index, file) {
791
+ this.loading = true;
792
+ this.filesArray[index].loading = true;
793
+ if (file?.id) {
794
+ delete file.uploadData;
795
+ this.removeUploadedFile(file, index, true);
796
+ }
797
+ else {
798
+ this.loading = false;
799
+ this.filesArray.splice(index, 1);
800
+ this.setSliderLoading();
801
+ this.onSubmit();
802
+ this.onFileRemoved.emit(true);
803
+ }
804
+ }
805
+ removeUploadedFile(file, index, silently = false) {
806
+ console.log("removeUploadedFile:", file);
807
+ this.fileUploadService.deleteUploadedFile(this.urlConfig.removeImage, file).subscribe((r) => {
808
+ console.log('File Delete Res:', r);
809
+ this.loading = false;
810
+ this.filesArray.splice(index, 1);
811
+ this.setSliderLoading();
812
+ this.onSubmit();
813
+ if (!silently) {
814
+ this.helper.showSuccessMsg(r.message, 'Success', 3000);
815
+ }
816
+ this.onSubmit();
817
+ }, (err) => { this.filesArray[index].loading = false; this.helper.showErrorMsg(err, "Error"); });
818
+ }
819
+ onSubmit() {
820
+ this.onUploaded.emit(this.filesArray);
821
+ }
822
+ async downloadFile(url, fileName) {
823
+ fetch(url)
824
+ .then(response => response.blob())
825
+ .then(blob => {
826
+ const blobUrl = URL.createObjectURL(blob);
827
+ const el = document.createElement("a");
828
+ el.href = blobUrl;
829
+ el.download = fileName;
830
+ document.body.appendChild(el);
831
+ el.click();
832
+ document.body.removeChild(el);
833
+ URL.revokeObjectURL(blobUrl); // Cleanup
834
+ })
835
+ .catch(error => console.error("Download failed", error));
836
+ }
837
+ clickTimeout = null;
838
+ clickDelay = 250; // Delay in milliseconds to distinguish single and double click
839
+ onSelectFile(file) {
840
+ if (this.config.selectionMode) {
841
+ if (this.clickTimeout) {
842
+ clearTimeout(this.clickTimeout);
843
+ this.clickTimeout = null;
844
+ this.openFile(file); // Double-click detected
845
+ }
846
+ else {
847
+ this.clickTimeout = setTimeout(() => {
848
+ this.clickTimeout = null;
849
+ if (this.config.selectionMode) {
850
+ this.onFileSelect.emit(file); // Single-click detected
851
+ }
852
+ }, this.clickDelay);
853
+ }
854
+ }
855
+ else {
856
+ this.clickTimeout = null;
857
+ this.openFile(file);
858
+ }
859
+ }
860
+ openFile(file) {
861
+ if (!this.config.hiddenPreview) {
862
+ this.openPreviewDialog(file.s3Url, file.title);
863
+ }
864
+ }
865
+ openPreviewDialog(url, title) {
866
+ if (url.indexOf('.jpg') != -1 || url.indexOf('.jpeg') != -1 || url.indexOf('.png') != -1) {
867
+ this.openImagePreviewDialog(url);
868
+ }
869
+ else if (url.indexOf('.pdf') != -1) {
870
+ this.openFileViewer(url, 'pdf');
871
+ }
872
+ // else if(url.indexOf('.csv') != -1){
873
+ // this.openFileViewer(url, 'csv');
874
+ // }
875
+ else if (url.indexOf('.xlxs') != -1 || url.indexOf('.xlx') != -1 || url.indexOf('.xls') != -1) {
876
+ this.openFileViewer(url, 'excel');
877
+ }
878
+ else {
879
+ this.downloadFile(url, title);
880
+ }
881
+ }
882
+ openImagePreviewDialog(url) {
883
+ const dialogRef = this.dialog.open(TisPreviewImageComponent, {
884
+ panelClass: ['mat-p-0', 'relative'],
885
+ data: { url },
886
+ });
887
+ dialogRef.afterClosed().subscribe((result) => {
888
+ console.log('The dialog was closed', result);
889
+ });
890
+ }
891
+ openFileViewer(pdfUrl, fileType) {
892
+ let dialogData = {
893
+ src: pdfUrl,
894
+ fileType: fileType
895
+ };
896
+ const dialogRef = this.dialog.open(TisFileViewerComponent, {
897
+ width: this.isMobile ? "100%" : "90%",
898
+ height: this.isMobile ? "100%" : "98%",
899
+ minHeight: this.isMobile ? "100%" : "80%",
900
+ maxWidth: this.isMobile ? "100%" : "100%",
901
+ panelClass: ['tis-file-viewer'],
902
+ data: dialogData,
903
+ disableClose: false,
904
+ });
905
+ dialogRef.afterClosed().subscribe((result) => {
906
+ console.log("FileViewer Dialog Closed");
907
+ });
908
+ }
909
+ checkingForPreview(img) {
910
+ let imageArray = img.split('.');
911
+ let imageType = imageArray[imageArray?.length - 1];
912
+ if (imageType == 'png' || imageType == 'jpg' || imageType == 'jpeg') {
913
+ return true;
914
+ }
915
+ else {
916
+ return false;
917
+ }
918
+ }
919
+ setHeight(id) {
920
+ let height = document.getElementById(id)?.offsetWidth;
921
+ return `${height}px`;
922
+ }
923
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisImageAndFileUploadAndViewComponent, deps: [{ token: i1.MatDialog }, { token: FileUploadService }, { token: ImageUploadService }, { token: TisHelperService }, { token: i5.BreakpointObserver }], target: i0.ɵɵFactoryTarget.Component });
924
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.6", type: TisImageAndFileUploadAndViewComponent, isStandalone: false, selector: "tis-image-and-file-upload-and-view", inputs: { urlConfig: "urlConfig", entityType: "entityType", entityId: "entityId", viewType: "viewType", type: "type", label: "label", disabled: "disabled", data: "data", hint: "hint", accept: "accept", selectedId: "selectedId", options: "options", required: "required", previewOnly: "previewOnly", previewInFlex: "previewInFlex", imageItemClass: "imageItemClass", isEnableDeleteConfirmation: "isEnableDeleteConfirmation", deleteConfirmationMsg: "deleteConfirmationMsg", dialogConfig: "dialogConfig" }, outputs: { uploadInProgress: "uploadInProgress", onUploaded: "onUploaded", onFileSelect: "onFileSelect", onFileRemoved: "onFileRemoved" }, usesOnChanges: true, ngImport: i0, template: "<div>\n <input type=\"file\" size=\"60\" *ngIf=\"!config?.isMultiple\" id=\"{{config.selectorId}}\" (change)=\"type == 'file'? detectFiles($event): detectImages($event)\" accept=\"{{accept}}\" style=\"display: none;\" />\n <input type=\"file\" size=\"60\" *ngIf=\"config?.isMultiple\" id=\"{{config.selectorId}}\" (change)=\"type == 'file'? detectFiles($event): detectImages($event)\" accept=\"{{accept}}\" multiple style=\"display: none;\" />\n <!-- <input type=\"file\" name=\"file\" id=\"file-picker\" style=\"display: none;\" *ngIf=\"(filesArray?.length < config?.limit) && !disabled\" [style.height]=\"config?.labelHeight\"> -->\n @if(viewType == 'card'){\n <div [class.image-picker-label]=\"!previewOnly\" [class.error]=\"required && (filesArray?.length || 0) <= 0\" [style.height]=\"filesArray?.length ? null : config?.height\" style=\"--tis-image-picker-height: {{config?.height ?? 0}}\">\n @if(filesArray?.length){\n <div [ngClass]=\"{'grid-cols-1': config?.cols == 1, 'grid-cols-2': config?.cols == 2, 'grid-cols-3': config?.cols == 3, 'grid-cols-4': config?.cols == 4, 'grid-cols-5': config?.cols == 5, 'grid-cols-6': config?.cols == 6}\" class=\"{{previewInFlex ? 'flex' : 'grid'}} image-list\" style=\"gap: 25px;\">\n @for(file of filesArray; track file.s3Url; let i = $index; let l = $last;){\n <!-- style=\"height: calc((var(--tis-image-picker-height) - 48px - 0.75rem) / 2); width: calc((var(--tis-image-picker-height) - 48px - 0.75rem) / 2);\" -->\n <div class=\"image-item {{imageItemClass}}\" [class.selected]=\"config?.selectionMode ? selectedId == file.id : false\" [class.tis-curser-pointer]=\"!config?.hiddenPreview || config?.selectionMode\" id=\"image-item-{{config.selectorId}}-{{i}}\" [style.height]=\"setHeight('image-item-'+config.selectorId+'-'+i)\" [style.background-image]=\"type == 'file'? '' : 'url('+file.s3Url+')'\" *ngIf=\"file?.loading\">\n <div class=\"shedded\" style=\"width: 100%; height: 100%; position: absolute; top: 0px; left: 0px; display: flex; justify-content: center; align-items: center;\">\n <mat-progress-spinner color=\"primary\" mode=\"indeterminate\" [diameter]=\"30\"></mat-progress-spinner>\n </div>\n <mat-icon *ngIf=\"type == 'file'\" class=\"active tis-mat-icon-2x\">description</mat-icon>\n </div>\n <div class=\"image-item {{imageItemClass}}\" [class.selected]=\"config?.selectionMode ? selectedId == file.id : false\" [class.tis-curser-pointer]=\"!config?.hiddenPreview || config?.selectionMode\" id=\"image-item-{{config.selectorId}}-{{i}}\" [style.height]=\"setHeight('image-item-'+config.selectorId+'-'+i)\" [style.background-image]=\"type == 'file'? '' : 'url('+file.s3Url+')'\" (click)=\"onSelectFile(file)\" *ngIf=\"!file?.loading\">\n <mat-icon *ngIf=\"type == 'file'\" class=\"active tis-mat-icon-2x\">description</mat-icon>\n <span class=\"material-icons cancel\" (click)=\"type == 'file'? deleteFile($event, {}, i, file) : deleteImage($event, {}, i, file)\" *ngIf=\"!disabled && !config.hiddenDeleteBtn\">highlight_off</span>\n <span class=\"material-icons download\" (click)=\"$event.stopPropagation(); downloadFile(file.s3Url, file.title)\" *ngIf=\"!disabled && !config.hiddenDownloadBtn\">download_for_offline</span>\n </div>\n @if(l && (config?.limit || 0) > (filesArray?.length || 0) && !disabled){\n <!-- style=\"height: calc((var(--tis-image-picker-height) - 48px - 0.75rem) / 2); width: calc((var(--tis-image-picker-height) - 48px - 0.75rem) / 2);\" -->\n <div class=\"image-item uploader\" id=\"image-item-{{config.selectorId}}-{{i}}-{{i}}\" [style.height]=\"setHeight('image-item-'+config.selectorId+'-'+i+'-'+i)\" (click)=\"loading? null : openImageSelector()\">\n <mat-icon class=\"active\">upload_file</mat-icon>\n </div>\n }\n }\n </div>\n }\n @else if(!disabled){\n <label style=\"display: flex; gap: 12px; flex-direction: column; justify-content: center; align-items: center; height: 100%; cursor: pointer;\" (click)=\"loading? null : openImageSelector()\">\n <mat-icon>upload_file</mat-icon>\n <p style=\"text-align: center; font-size: 14px;\">\n {{label}}\n @if(hint && hint != ''){\n <br>\n <small>{{hint}}</small>\n }\n </p>\n </label>\n }\n @else{\n <div style=\"display: flex; flex-direction: column; justify-content: center; align-items: center; width: 100%; cursor: pointer;\">\n <img src=\"assets/icons/norecordfound.png\" alt=\"data not found\" style=\"margin: auto; height: calc(var(--tis-image-picker-height) - 30px); max-height: 150px;\">\n </div>\n }\n </div>\n }\n @else if(viewType == 'list'){\n <div [class.error-border]=\"required && (filesArray?.length || 0) <= 0\" [style.height]=\"filesArray?.length ? null : config?.height\" style=\"width: 100%; display: flex; gap: 12px; flex-direction: column; --tis-image-picker-height: {{config?.height ?? 0}}\">\n @if(filesArray?.length){\n @for(file of filesArray; track file.s3Url; let i = $index; let l = $last;){\n <div style=\"position: relative; display: flex; align-items: center; gap: 10px; border-radius: 5px; border: 1px solid black; padding: 5px; height: 56px;\">\n <mat-icon style=\"width: 40px; min-width: 22px;\">description</mat-icon>\n <div style=\"white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%;\">{{file?.title}}</div>\n <div style=\"display: flex; align-items: center; gap: 4px;\" *ngIf=\"!file?.loading\">\n <button type=\"button\" mat-icon-button aria-label=\"Download File\" class=\"tis-icon-btn-sm tis-text-download\" style=\"margin: 0px !important;\" (click)=\"$event.stopPropagation(); downloadFile(file.s3Url, file.title)\" *ngIf=\"!disabled && !config.hiddenDownloadBtn\">\n <mat-icon>download_for_offline</mat-icon>\n </button>\n <button type=\"button\" mat-icon-button aria-label=\"View File\" class=\"tis-icon-btn-sm tis-text-view\" style=\"margin: 0px !important;\" (click)=\"openFile(file)\" *ngIf=\"!config.hiddenPreview\">\n <mat-icon>visibility</mat-icon>\n </button>\n <button type=\"button\" mat-icon-button aria-label=\"Remove File\" class=\"tis-icon-btn-sm tis-text-cancel\" style=\"margin: 0px !important;\" (click)=\"type == 'file'? deleteFile($event, {}, i, file) : deleteImage($event, {}, i, file)\" *ngIf=\"!disabled && !config.hiddenDeleteBtn\">\n <mat-icon>delete</mat-icon>\n </button>\n </div>\n <div style=\"display: flex; justify-content: center; align-items: center; gap: 4px;\" style=\"width: 50px;\" *ngIf=\"file?.loading\">\n <mat-progress-spinner color=\"primary\" mode=\"indeterminate\" [diameter]=\"20\"></mat-progress-spinner>\n </div>\n <!-- <span class=\"material-icons download\" (click)=\"$event.stopPropagation(); downloadFile(file.s3Url, file.title)\" *ngIf=\"!disabled && !config.hiddenDownloadBtn\">download_for_offline</span> -->\n </div>\n @if(l && (config?.limit || 0) > (filesArray?.length || 0) && !disabled){\n <div style=\"cursor: pointer; display: flex; align-items: center; gap: 4px; border: 1px solid black; border-radius: 5px; padding: 5px; height: 56px;\" (click)=\"loading? null : openImageSelector()\">\n <mat-icon style=\"width: 40px; min-width: 22px;\">upload_file</mat-icon>\n <div style=\"width: 100%;\">\n <div style=\"display: flex; flex-direction: column; align-items: start; font-size: 14px;\">\n {{label}}\n @if(hint && hint != ''){\n <small>{{hint}}</small>\n }\n </div>\n </div>\n </div>\n }\n }\n }\n @else if(!disabled){\n <div style=\"cursor: pointer; display: flex; align-items: center; gap: 4px; border: 1px solid black; border-radius: 5px; padding: 5px; height: 56px;\" (click)=\"loading? null : openImageSelector()\">\n <mat-icon style=\"width: 40px; min-width: 22px;\">upload_file</mat-icon>\n <div style=\"width: 100%;\">\n <div style=\"display: flex; flex-direction: column; align-items: start; font-size: 14px;\">\n {{label}}\n @if(hint && hint != ''){\n <small>{{hint}}</small>\n }\n </div>\n </div>\n </div>\n }\n </div>\n }\n</div>", styles: [".grid{display:grid}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.tis-mat-icon-5x{width:125px!important;height:125px!important;font-size:125px!important}.tis-mat-icon-4x{width:100px!important;height:100px!important;font-size:100px!important}.tis-mat-icon-3x{width:75px!important;height:75px!important;font-size:75px!important}.tis-mat-icon-2x{width:50px!important;height:50px!important;font-size:50px!important}.tis-icon-btn-sm{margin-top:7px!important;padding:5px!important;height:36px!important;width:36px!important}.tis-text-download{color:var(--tis-download, #3838a2)}.tis-text-view{color:var(--tis-primary, #3838a2)}.tis-text-cancel{color:var(--tis-cancel, #bb333b)}::ng-deep #upload-img-box{padding:0;border:2px dashed #717171;display:grid;color:#717171;justify-content:center;align-items:center;width:100%;height:160px;background:#eaeaea;cursor:pointer}::ng-deep #upload-img-box input[type=file]{display:none}.preview-img{display:flex;justify-content:center;position:absolute;align-items:center;top:0;width:100%;height:100%;background:#9e9e9e59;opacity:0}.preview-img:hover{opacity:1}.img-box{order:2px solid #b5b5b5!important;position:relative;padding:5px;display:flex;justify-content:center;align-content:center;align-items:center}.loading-img{display:flex;justify-content:center;position:absolute;align-items:center;top:0;width:100%;height:100%;background:#9e9e9e59}.image-picker-label{border:1px dashed rgba(0,0,0,.38);border-radius:4px;padding:24px}.image-picker-label.error{border:2px dashed var(--mat-form-field-error-text-color)}.image-list .image-item{height:100px;border-radius:5px;background-position:center;background-size:cover;position:relative;display:flex;justify-content:center;align-items:center;border:1px solid rgba(0,0,0,.38)}.image-list .image-item.uploader{border:1px dashed rgba(0,0,0,.38)!important;cursor:pointer}.image-list .image-item:hover .mat-icon{display:unset!important}.image-list .image-item.selected{border:3px solid var(--tis-item-selected, #3838a2)!important}.image-list .image-item .mat-icon{display:none}.image-list .image-item .mat-icon.active{display:unset!important}.image-list .image-item .cancel{color:var(--tis-cancel, #bb333b);background-color:#fff;border-radius:20px;position:absolute;top:-10px;right:-10px;cursor:pointer;box-shadow:0 0 5px #9e9e9e}.image-list .image-item .download{color:var(--tis-download, #3838a2);background-color:#fff;border-radius:20px;position:absolute;top:-10px;left:-10px;cursor:pointer;box-shadow:0 0 5px #9e9e9e}.image-list .image-item .shedded{background-color:#9e9e9ecc;border-radius:5px}.error-border{border:1px solid var(--mat-form-field-error-text-color)!important;border-radius:5px!important}.download{color:var(--tis-download, #3838a2);position:absolute;top:-10px;left:-10px;cursor:pointer}.tis-curser-pointer{cursor:pointer}::ng-deep .tis-confirmation-dialog mat-dialog-container .mat-mdc-dialog-title{padding:8px 16px;display:flex;gap:10px;justify-content:start;width:100%;align-items:center}::ng-deep .tis-confirmation-dialog mat-dialog-container .mat-mdc-dialog-title:before{content:unset}::ng-deep .tis-confirmation-dialog mat-dialog-container .mat-mdc-dialog-content{padding-top:15px;font-size:14px}::ng-deep .tis-confirmation-dialog mat-dialog-container .mat-mdc-dialog-actions{border-top:1px solid rgba(0,0,0,.12);justify-content:end}@media (max-width: 575.98px){.image-picker-label{padding:15px}}@media (min-width: 576px) and (max-width: 767.98px){.image-picker-label{padding:15px}}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i4.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "component", type: i4$1.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }] });
925
+ }
926
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisImageAndFileUploadAndViewComponent, decorators: [{
927
+ type: Component,
928
+ args: [{ selector: 'tis-image-and-file-upload-and-view', standalone: false, template: "<div>\n <input type=\"file\" size=\"60\" *ngIf=\"!config?.isMultiple\" id=\"{{config.selectorId}}\" (change)=\"type == 'file'? detectFiles($event): detectImages($event)\" accept=\"{{accept}}\" style=\"display: none;\" />\n <input type=\"file\" size=\"60\" *ngIf=\"config?.isMultiple\" id=\"{{config.selectorId}}\" (change)=\"type == 'file'? detectFiles($event): detectImages($event)\" accept=\"{{accept}}\" multiple style=\"display: none;\" />\n <!-- <input type=\"file\" name=\"file\" id=\"file-picker\" style=\"display: none;\" *ngIf=\"(filesArray?.length < config?.limit) && !disabled\" [style.height]=\"config?.labelHeight\"> -->\n @if(viewType == 'card'){\n <div [class.image-picker-label]=\"!previewOnly\" [class.error]=\"required && (filesArray?.length || 0) <= 0\" [style.height]=\"filesArray?.length ? null : config?.height\" style=\"--tis-image-picker-height: {{config?.height ?? 0}}\">\n @if(filesArray?.length){\n <div [ngClass]=\"{'grid-cols-1': config?.cols == 1, 'grid-cols-2': config?.cols == 2, 'grid-cols-3': config?.cols == 3, 'grid-cols-4': config?.cols == 4, 'grid-cols-5': config?.cols == 5, 'grid-cols-6': config?.cols == 6}\" class=\"{{previewInFlex ? 'flex' : 'grid'}} image-list\" style=\"gap: 25px;\">\n @for(file of filesArray; track file.s3Url; let i = $index; let l = $last;){\n <!-- style=\"height: calc((var(--tis-image-picker-height) - 48px - 0.75rem) / 2); width: calc((var(--tis-image-picker-height) - 48px - 0.75rem) / 2);\" -->\n <div class=\"image-item {{imageItemClass}}\" [class.selected]=\"config?.selectionMode ? selectedId == file.id : false\" [class.tis-curser-pointer]=\"!config?.hiddenPreview || config?.selectionMode\" id=\"image-item-{{config.selectorId}}-{{i}}\" [style.height]=\"setHeight('image-item-'+config.selectorId+'-'+i)\" [style.background-image]=\"type == 'file'? '' : 'url('+file.s3Url+')'\" *ngIf=\"file?.loading\">\n <div class=\"shedded\" style=\"width: 100%; height: 100%; position: absolute; top: 0px; left: 0px; display: flex; justify-content: center; align-items: center;\">\n <mat-progress-spinner color=\"primary\" mode=\"indeterminate\" [diameter]=\"30\"></mat-progress-spinner>\n </div>\n <mat-icon *ngIf=\"type == 'file'\" class=\"active tis-mat-icon-2x\">description</mat-icon>\n </div>\n <div class=\"image-item {{imageItemClass}}\" [class.selected]=\"config?.selectionMode ? selectedId == file.id : false\" [class.tis-curser-pointer]=\"!config?.hiddenPreview || config?.selectionMode\" id=\"image-item-{{config.selectorId}}-{{i}}\" [style.height]=\"setHeight('image-item-'+config.selectorId+'-'+i)\" [style.background-image]=\"type == 'file'? '' : 'url('+file.s3Url+')'\" (click)=\"onSelectFile(file)\" *ngIf=\"!file?.loading\">\n <mat-icon *ngIf=\"type == 'file'\" class=\"active tis-mat-icon-2x\">description</mat-icon>\n <span class=\"material-icons cancel\" (click)=\"type == 'file'? deleteFile($event, {}, i, file) : deleteImage($event, {}, i, file)\" *ngIf=\"!disabled && !config.hiddenDeleteBtn\">highlight_off</span>\n <span class=\"material-icons download\" (click)=\"$event.stopPropagation(); downloadFile(file.s3Url, file.title)\" *ngIf=\"!disabled && !config.hiddenDownloadBtn\">download_for_offline</span>\n </div>\n @if(l && (config?.limit || 0) > (filesArray?.length || 0) && !disabled){\n <!-- style=\"height: calc((var(--tis-image-picker-height) - 48px - 0.75rem) / 2); width: calc((var(--tis-image-picker-height) - 48px - 0.75rem) / 2);\" -->\n <div class=\"image-item uploader\" id=\"image-item-{{config.selectorId}}-{{i}}-{{i}}\" [style.height]=\"setHeight('image-item-'+config.selectorId+'-'+i+'-'+i)\" (click)=\"loading? null : openImageSelector()\">\n <mat-icon class=\"active\">upload_file</mat-icon>\n </div>\n }\n }\n </div>\n }\n @else if(!disabled){\n <label style=\"display: flex; gap: 12px; flex-direction: column; justify-content: center; align-items: center; height: 100%; cursor: pointer;\" (click)=\"loading? null : openImageSelector()\">\n <mat-icon>upload_file</mat-icon>\n <p style=\"text-align: center; font-size: 14px;\">\n {{label}}\n @if(hint && hint != ''){\n <br>\n <small>{{hint}}</small>\n }\n </p>\n </label>\n }\n @else{\n <div style=\"display: flex; flex-direction: column; justify-content: center; align-items: center; width: 100%; cursor: pointer;\">\n <img src=\"assets/icons/norecordfound.png\" alt=\"data not found\" style=\"margin: auto; height: calc(var(--tis-image-picker-height) - 30px); max-height: 150px;\">\n </div>\n }\n </div>\n }\n @else if(viewType == 'list'){\n <div [class.error-border]=\"required && (filesArray?.length || 0) <= 0\" [style.height]=\"filesArray?.length ? null : config?.height\" style=\"width: 100%; display: flex; gap: 12px; flex-direction: column; --tis-image-picker-height: {{config?.height ?? 0}}\">\n @if(filesArray?.length){\n @for(file of filesArray; track file.s3Url; let i = $index; let l = $last;){\n <div style=\"position: relative; display: flex; align-items: center; gap: 10px; border-radius: 5px; border: 1px solid black; padding: 5px; height: 56px;\">\n <mat-icon style=\"width: 40px; min-width: 22px;\">description</mat-icon>\n <div style=\"white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%;\">{{file?.title}}</div>\n <div style=\"display: flex; align-items: center; gap: 4px;\" *ngIf=\"!file?.loading\">\n <button type=\"button\" mat-icon-button aria-label=\"Download File\" class=\"tis-icon-btn-sm tis-text-download\" style=\"margin: 0px !important;\" (click)=\"$event.stopPropagation(); downloadFile(file.s3Url, file.title)\" *ngIf=\"!disabled && !config.hiddenDownloadBtn\">\n <mat-icon>download_for_offline</mat-icon>\n </button>\n <button type=\"button\" mat-icon-button aria-label=\"View File\" class=\"tis-icon-btn-sm tis-text-view\" style=\"margin: 0px !important;\" (click)=\"openFile(file)\" *ngIf=\"!config.hiddenPreview\">\n <mat-icon>visibility</mat-icon>\n </button>\n <button type=\"button\" mat-icon-button aria-label=\"Remove File\" class=\"tis-icon-btn-sm tis-text-cancel\" style=\"margin: 0px !important;\" (click)=\"type == 'file'? deleteFile($event, {}, i, file) : deleteImage($event, {}, i, file)\" *ngIf=\"!disabled && !config.hiddenDeleteBtn\">\n <mat-icon>delete</mat-icon>\n </button>\n </div>\n <div style=\"display: flex; justify-content: center; align-items: center; gap: 4px;\" style=\"width: 50px;\" *ngIf=\"file?.loading\">\n <mat-progress-spinner color=\"primary\" mode=\"indeterminate\" [diameter]=\"20\"></mat-progress-spinner>\n </div>\n <!-- <span class=\"material-icons download\" (click)=\"$event.stopPropagation(); downloadFile(file.s3Url, file.title)\" *ngIf=\"!disabled && !config.hiddenDownloadBtn\">download_for_offline</span> -->\n </div>\n @if(l && (config?.limit || 0) > (filesArray?.length || 0) && !disabled){\n <div style=\"cursor: pointer; display: flex; align-items: center; gap: 4px; border: 1px solid black; border-radius: 5px; padding: 5px; height: 56px;\" (click)=\"loading? null : openImageSelector()\">\n <mat-icon style=\"width: 40px; min-width: 22px;\">upload_file</mat-icon>\n <div style=\"width: 100%;\">\n <div style=\"display: flex; flex-direction: column; align-items: start; font-size: 14px;\">\n {{label}}\n @if(hint && hint != ''){\n <small>{{hint}}</small>\n }\n </div>\n </div>\n </div>\n }\n }\n }\n @else if(!disabled){\n <div style=\"cursor: pointer; display: flex; align-items: center; gap: 4px; border: 1px solid black; border-radius: 5px; padding: 5px; height: 56px;\" (click)=\"loading? null : openImageSelector()\">\n <mat-icon style=\"width: 40px; min-width: 22px;\">upload_file</mat-icon>\n <div style=\"width: 100%;\">\n <div style=\"display: flex; flex-direction: column; align-items: start; font-size: 14px;\">\n {{label}}\n @if(hint && hint != ''){\n <small>{{hint}}</small>\n }\n </div>\n </div>\n </div>\n }\n </div>\n }\n</div>", styles: [".grid{display:grid}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.tis-mat-icon-5x{width:125px!important;height:125px!important;font-size:125px!important}.tis-mat-icon-4x{width:100px!important;height:100px!important;font-size:100px!important}.tis-mat-icon-3x{width:75px!important;height:75px!important;font-size:75px!important}.tis-mat-icon-2x{width:50px!important;height:50px!important;font-size:50px!important}.tis-icon-btn-sm{margin-top:7px!important;padding:5px!important;height:36px!important;width:36px!important}.tis-text-download{color:var(--tis-download, #3838a2)}.tis-text-view{color:var(--tis-primary, #3838a2)}.tis-text-cancel{color:var(--tis-cancel, #bb333b)}::ng-deep #upload-img-box{padding:0;border:2px dashed #717171;display:grid;color:#717171;justify-content:center;align-items:center;width:100%;height:160px;background:#eaeaea;cursor:pointer}::ng-deep #upload-img-box input[type=file]{display:none}.preview-img{display:flex;justify-content:center;position:absolute;align-items:center;top:0;width:100%;height:100%;background:#9e9e9e59;opacity:0}.preview-img:hover{opacity:1}.img-box{order:2px solid #b5b5b5!important;position:relative;padding:5px;display:flex;justify-content:center;align-content:center;align-items:center}.loading-img{display:flex;justify-content:center;position:absolute;align-items:center;top:0;width:100%;height:100%;background:#9e9e9e59}.image-picker-label{border:1px dashed rgba(0,0,0,.38);border-radius:4px;padding:24px}.image-picker-label.error{border:2px dashed var(--mat-form-field-error-text-color)}.image-list .image-item{height:100px;border-radius:5px;background-position:center;background-size:cover;position:relative;display:flex;justify-content:center;align-items:center;border:1px solid rgba(0,0,0,.38)}.image-list .image-item.uploader{border:1px dashed rgba(0,0,0,.38)!important;cursor:pointer}.image-list .image-item:hover .mat-icon{display:unset!important}.image-list .image-item.selected{border:3px solid var(--tis-item-selected, #3838a2)!important}.image-list .image-item .mat-icon{display:none}.image-list .image-item .mat-icon.active{display:unset!important}.image-list .image-item .cancel{color:var(--tis-cancel, #bb333b);background-color:#fff;border-radius:20px;position:absolute;top:-10px;right:-10px;cursor:pointer;box-shadow:0 0 5px #9e9e9e}.image-list .image-item .download{color:var(--tis-download, #3838a2);background-color:#fff;border-radius:20px;position:absolute;top:-10px;left:-10px;cursor:pointer;box-shadow:0 0 5px #9e9e9e}.image-list .image-item .shedded{background-color:#9e9e9ecc;border-radius:5px}.error-border{border:1px solid var(--mat-form-field-error-text-color)!important;border-radius:5px!important}.download{color:var(--tis-download, #3838a2);position:absolute;top:-10px;left:-10px;cursor:pointer}.tis-curser-pointer{cursor:pointer}::ng-deep .tis-confirmation-dialog mat-dialog-container .mat-mdc-dialog-title{padding:8px 16px;display:flex;gap:10px;justify-content:start;width:100%;align-items:center}::ng-deep .tis-confirmation-dialog mat-dialog-container .mat-mdc-dialog-title:before{content:unset}::ng-deep .tis-confirmation-dialog mat-dialog-container .mat-mdc-dialog-content{padding-top:15px;font-size:14px}::ng-deep .tis-confirmation-dialog mat-dialog-container .mat-mdc-dialog-actions{border-top:1px solid rgba(0,0,0,.12);justify-content:end}@media (max-width: 575.98px){.image-picker-label{padding:15px}}@media (min-width: 576px) and (max-width: 767.98px){.image-picker-label{padding:15px}}\n"] }]
929
+ }], ctorParameters: () => [{ type: i1.MatDialog }, { type: FileUploadService }, { type: ImageUploadService }, { type: TisHelperService }, { type: i5.BreakpointObserver }], propDecorators: { urlConfig: [{
930
+ type: Input,
931
+ args: [{ required: true }]
932
+ }], entityType: [{
933
+ type: Input
934
+ }], entityId: [{
935
+ type: Input
936
+ }], viewType: [{
937
+ type: Input
938
+ }], type: [{
939
+ type: Input
940
+ }], label: [{
941
+ type: Input
942
+ }], disabled: [{
943
+ type: Input
944
+ }], data: [{
945
+ type: Input
946
+ }], hint: [{
947
+ type: Input
948
+ }], accept: [{
949
+ type: Input
950
+ }], selectedId: [{
951
+ type: Input
952
+ }], options: [{
953
+ type: Input
954
+ }], required: [{
955
+ type: Input
956
+ }], previewOnly: [{
957
+ type: Input
958
+ }], previewInFlex: [{
959
+ type: Input
960
+ }], imageItemClass: [{
961
+ type: Input
962
+ }], isEnableDeleteConfirmation: [{
963
+ type: Input
964
+ }], deleteConfirmationMsg: [{
965
+ type: Input
966
+ }], dialogConfig: [{
967
+ type: Input
968
+ }], uploadInProgress: [{
969
+ type: Output
970
+ }], onUploaded: [{
971
+ type: Output
972
+ }], onFileSelect: [{
973
+ type: Output
974
+ }], onFileRemoved: [{
975
+ type: Output
976
+ }] } });
977
+
978
+ const uiImports = [
979
+ MatTooltipModule,
980
+ MatIconModule,
981
+ MatSnackBarModule,
982
+ MatProgressSpinnerModule,
983
+ MatButtonModule,
984
+ MatDialogModule,
985
+ ];
986
+ class TisImageAndFileUploadAndViewModule {
987
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisImageAndFileUploadAndViewModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
988
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: TisImageAndFileUploadAndViewModule, declarations: [TisImageAndFileUploadAndViewComponent,
989
+ TisPreviewImageComponent,
990
+ TisFileViewerComponent,
991
+ TisErrorDialogComponent,
992
+ TisConfirmationDialogComponent], imports: [CommonModule, MatTooltipModule,
993
+ MatIconModule,
994
+ MatSnackBarModule,
995
+ MatProgressSpinnerModule,
996
+ MatButtonModule,
997
+ MatDialogModule], exports: [TisImageAndFileUploadAndViewComponent] });
998
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisImageAndFileUploadAndViewModule, imports: [CommonModule, uiImports] });
999
+ }
1000
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: TisImageAndFileUploadAndViewModule, decorators: [{
1001
+ type: NgModule,
1002
+ args: [{
1003
+ declarations: [
1004
+ TisImageAndFileUploadAndViewComponent,
1005
+ TisPreviewImageComponent,
1006
+ TisFileViewerComponent,
1007
+ TisErrorDialogComponent,
1008
+ TisConfirmationDialogComponent
1009
+ ],
1010
+ imports: [
1011
+ CommonModule,
1012
+ ...uiImports
1013
+ ],
1014
+ exports: [
1015
+ TisImageAndFileUploadAndViewComponent
1016
+ ]
1017
+ }]
1018
+ }] });
1019
+
1020
+ /*
1021
+ * Public API Surface of tis-image-and-file-upload-and-view
1022
+ */
1023
+
1024
+ /**
1025
+ * Generated bundle index. Do not edit.
1026
+ */
1027
+
1028
+ export { TisImageAndFileUploadAndViewComponent, TisImageAndFileUploadAndViewModule, TisImageAndFileUploadAndViewService };
1029
+ //# sourceMappingURL=servicemind.tis-tis-image-and-file-upload-and-view.mjs.map