@eqproject/eqp-attachments 3.0.3 → 3.1.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.
@@ -3,14 +3,13 @@ import { ChangeDetectorRef, EventEmitter, OnInit, TemplateRef } from "@angular/c
3
3
  import { FormBuilder, FormGroup } from "@angular/forms";
4
4
  import { MatDialog, MatDialogRef } from "@angular/material/dialog";
5
5
  import { DomSanitizer } from "@angular/platform-browser";
6
- import { ConfigColumn, TooltipPositionType } from "@eqproject/eqp-common";
7
6
  import { ImageCroppedEvent, ImageCropperComponent, ImageTransform } from "ngx-image-cropper";
8
- import { AttachmentType, CropOptionEnum, IAttachmentDTO } from "./interfaces/IAttachment";
7
+ import { AttachmentCardSize, AttachmentType, CropOptionEnum, IAttachmentDTO } from "./interfaces/IAttachment";
9
8
  import { IOptions } from "./interfaces/IOptions";
10
9
  import { EqpAttachmentService } from "./services/eqp-attachment.service";
11
- import { EqpTableComponent } from "@eqproject/eqp-table";
12
10
  import * as i0 from "@angular/core";
13
11
  export declare class EqpAttachmentsComponent implements OnInit {
12
+ #private;
14
13
  private dialog;
15
14
  private formBuilder;
16
15
  private sanitizer;
@@ -33,6 +32,10 @@ export declare class EqpAttachmentsComponent implements OnInit {
33
32
  * Sorgente dati da visualizzare. Nel caso si vuole gestire un singolo allegato va passato in ogni caso come Array.
34
33
  */
35
34
  attachmentsList: Array<IAttachmentDTO>;
35
+ /**
36
+ * Nel caso si vuole gestire un solo elemento senza passarlo come array, lo passo come singolo allegato e gestisco nella libreria l'array.
37
+ */
38
+ singleAttachment: IAttachmentDTO;
36
39
  /**
37
40
  * Se TRUE non mostra la MatCard (nel caso in cui "multipleAttachment" è TRUE).
38
41
  */
@@ -47,10 +50,6 @@ export declare class EqpAttachmentsComponent implements OnInit {
47
50
  * SOLO se si gestiscono allegati multipli, quindi se l'input 'multipleAttachment' assume il valore TRUE, altrimenti è sempre disabilitata.
48
51
  */
49
52
  loadMultipleFiles: boolean;
50
- /**
51
- * Configurazione delle colonne della eqp-table per la visualizzazione degli allegati (caso "multipleAttachment" è TRUE).
52
- */
53
- attachmentsColumns: Array<ConfigColumn>;
54
53
  /**
55
54
  * Imposta il messaggio da visualizzare nel caso in cui la tabella degli allegati (nel caso in cui "multipleAttachment" è TRUE) è vuota.
56
55
  */
@@ -138,10 +137,13 @@ export declare class EqpAttachmentsComponent implements OnInit {
138
137
  * Classe custom da assegnare al dialog del crop immagini
139
138
  */
140
139
  cropDialogClass: string;
140
+ maxFileSizeMB: number;
141
+ cardSize: AttachmentCardSize;
142
+ customCardWidthPx: number;
143
+ customCardHeightPx: number;
141
144
  /**
142
145
  * Input per definire le label da usare nel componente
143
146
  */
144
- downloadTooltipPosition: TooltipPositionType;
145
147
  openLinkLabel: string;
146
148
  addButtonLabel: string;
147
149
  downloadLabel: string;
@@ -155,7 +157,6 @@ export declare class EqpAttachmentsComponent implements OnInit {
155
157
  exitLabel: string;
156
158
  uploadWithDropboxLabel: string;
157
159
  cropLabel: string;
158
- eqpTableSearchText: string;
159
160
  deleteDialogTitle: string;
160
161
  deleteDialogMessage: string;
161
162
  noImageSelectedErrorMessage: string;
@@ -166,6 +167,20 @@ export declare class EqpAttachmentsComponent implements OnInit {
166
167
  flipVerticalLabel: string;
167
168
  rotateRightLabel: string;
168
169
  rotateLeftLabel: string;
170
+ uploadTitle: string;
171
+ uploadSubtitle: string;
172
+ dropHereLabel: string;
173
+ supportedFormatsLabel: string;
174
+ browseFilesLabel: string;
175
+ uploadSummaryLabel: string;
176
+ filesLabel: string;
177
+ totalSizeLabel: string;
178
+ emptyStateLabel: string;
179
+ addedSuccessfullyLabel: string;
180
+ removedLabel: string;
181
+ chooseView: boolean;
182
+ showSummary: boolean;
183
+ viewMode: 'card' | 'table';
169
184
  /**
170
185
  * Restituisce la lista aggiornata degli allegati.
171
186
  */
@@ -194,6 +209,7 @@ export declare class EqpAttachmentsComponent implements OnInit {
194
209
  dialogAddMultipleAttachment: TemplateRef<any>;
195
210
  dialogRefCropImage: MatDialogRef<TemplateRef<any>>;
196
211
  dialogCropImage: TemplateRef<any>;
212
+ addingLinkTemplate: TemplateRef<any>;
197
213
  imageChangedEvent: any;
198
214
  croppedImage: any;
199
215
  transform: ImageTransform;
@@ -206,19 +222,29 @@ export declare class EqpAttachmentsComponent implements OnInit {
206
222
  originalHeight: number;
207
223
  customWidth: number;
208
224
  customHeight: number;
209
- attachmentTable: EqpTableComponent;
210
225
  inlinePreviewTemplate: TemplateRef<any>;
211
226
  dialogPreview: TemplateRef<any>;
212
227
  imageFile: File;
213
228
  addingLinkMode: boolean;
229
+ dragOver: boolean;
230
+ toast: {
231
+ visible: boolean;
232
+ type: "error" | "success";
233
+ text: string;
234
+ timeoutId: any;
235
+ };
236
+ progressPercent: number;
237
+ totalSizeBytes: number;
238
+ get totalSizeFormatted(): string;
239
+ formatFileSize(bytes: number): string;
240
+ showToast(message: string, type?: 'success' | 'error', durationMs?: number): void;
214
241
  constructor(dialog: MatDialog, formBuilder: FormBuilder, sanitizer: DomSanitizer, http: HttpClient, cd: ChangeDetectorRef, eqpAttachmentService: EqpAttachmentService);
215
- ngOnInit(): Promise<void>;
216
- reloadData(): void;
242
+ ngOnInit(): void;
243
+ setViewMode(mode: 'card' | 'table'): void;
244
+ private recomputeTotalsAndProgress;
245
+ ngOnDestroy(): void;
246
+ bytesFromBase64(base64: string): number;
217
247
  checkAttachmentImage(): void;
218
- /**
219
- * Configura le colonne per l'eqp-table nel caso in cui il parametro "multipleAttachments" è TRUE.
220
- */
221
- configureColumns(): void;
222
248
  /**
223
249
  * Elimina un allegato eliminando anche il file presente nello storage di archiviazione utilizzato (AWS o cartella progetto)
224
250
  * @param element IAttachmentDTO da cancellare
@@ -229,6 +255,7 @@ export declare class EqpAttachmentsComponent implements OnInit {
229
255
  * @param attachmentIndex Indice dell'attachment da rimuovere
230
256
  */
231
257
  removeAttachmentFromList(attachmentIndex: number): void;
258
+ private simulateProgress;
232
259
  /**
233
260
  * Scarica l'allegato o apre il link
234
261
  * @param element Allegato da mostrare
@@ -269,6 +296,7 @@ export declare class EqpAttachmentsComponent implements OnInit {
269
296
  * immagine per il croppie (in caso di caricamento multiplo le funzionalità del croppie sono disabilitate).
270
297
  */
271
298
  onFileAdded(event: any, isFileDropped?: boolean): Promise<void>;
299
+ private validationFile;
272
300
  /**
273
301
  * A partire dal FILE ricevuto in input ricostruisce l'oggetto IAttachmentDTO e lo restituisce.
274
302
  * Se il parametro getBase64 viene passato a TRUE allora, sempre a partire dal file,genera il base64 e
@@ -310,10 +338,19 @@ export declare class EqpAttachmentsComponent implements OnInit {
310
338
  * Annulla la selezione del file, svuotando l'input e resettando tutte le proprietà dell'IAttachmentDTO
311
339
  */
312
340
  abortFile(): void;
313
- fileDropped(files: any): void;
341
+ fileDropped(event: DragEvent): void;
314
342
  chooseDropboxFile(): void;
315
343
  onSelectFile(event: any, fileInput: any): void;
344
+ /**
345
+ * Apre il dialogo per l'inserimento del link.
346
+ */
316
347
  switchToAddingLinkMode(): void;
348
+ getCardClass(att: IAttachmentDTO): {
349
+ [key: string]: boolean;
350
+ };
351
+ getPreviewsContainerStyle(): {
352
+ [key: string]: string;
353
+ };
317
354
  static ɵfac: i0.ɵɵFactoryDeclaration<EqpAttachmentsComponent, never>;
318
- static ɵcmp: i0.ɵɵComponentDeclaration<EqpAttachmentsComponent, "eqp-attachments", never, { "disableAction": { "alias": "disableAction"; "required": false; }; "showHeader": { "alias": "showHeader"; "required": false; }; "headerTitle": { "alias": "headerTitle"; "required": false; }; "attachmentsList": { "alias": "attachmentsList"; "required": false; }; "showMatCard": { "alias": "showMatCard"; "required": false; }; "multipleAttachment": { "alias": "multipleAttachment"; "required": false; }; "loadMultipleFiles": { "alias": "loadMultipleFiles"; "required": false; }; "attachmentsColumns": { "alias": "attachmentsColumns"; "required": false; }; "emptyTableMessage": { "alias": "emptyTableMessage"; "required": false; }; "allowOnlyImages": { "alias": "allowOnlyImages"; "required": false; }; "acceptedFileTypes": { "alias": "acceptedFileTypes"; "required": false; }; "isDisabled": { "alias": "isDisabled"; "required": false; }; "showInlinePreview": { "alias": "showInlinePreview"; "required": false; }; "getAttachmentEndpoint": { "alias": "getAttachmentEndpoint"; "required": false; }; "productionBaseUrl": { "alias": "productionBaseUrl"; "required": false; }; "compressionOptions": { "alias": "compressionOptions"; "required": false; }; "allowedTypes": { "alias": "allowedTypes"; "required": false; }; "isEqpTableMultiLanguage": { "alias": "isEqpTableMultiLanguage"; "required": false; }; "tablePaginatorVisible": { "alias": "tablePaginatorVisible"; "required": false; }; "isTableSearcheable": { "alias": "isTableSearcheable"; "required": false; }; "tablePaginatorSize": { "alias": "tablePaginatorSize"; "required": false; }; "separatedUploadButtons": { "alias": "separatedUploadButtons"; "required": false; }; "showPreview": { "alias": "showPreview"; "required": false; }; "singleAttachmentDragAndDrop": { "alias": "singleAttachmentDragAndDrop"; "required": false; }; "cropOptions": { "alias": "cropOptions"; "required": false; }; "cropDialogClass": { "alias": "cropDialogClass"; "required": false; }; "downloadTooltipPosition": { "alias": "downloadTooltipPosition"; "required": false; }; "openLinkLabel": { "alias": "openLinkLabel"; "required": false; }; "addButtonLabel": { "alias": "addButtonLabel"; "required": false; }; "downloadLabel": { "alias": "downloadLabel"; "required": false; }; "deleteLabel": { "alias": "deleteLabel"; "required": false; }; "fileNameLabel": { "alias": "fileNameLabel"; "required": false; }; "previewLabel": { "alias": "previewLabel"; "required": false; }; "uploadFileLabel": { "alias": "uploadFileLabel"; "required": false; }; "confirmLabel": { "alias": "confirmLabel"; "required": false; }; "abortLabel": { "alias": "abortLabel"; "required": false; }; "saveLabel": { "alias": "saveLabel"; "required": false; }; "exitLabel": { "alias": "exitLabel"; "required": false; }; "uploadWithDropboxLabel": { "alias": "uploadWithDropboxLabel"; "required": false; }; "cropLabel": { "alias": "cropLabel"; "required": false; }; "eqpTableSearchText": { "alias": "eqpTableSearchText"; "required": false; }; "deleteDialogTitle": { "alias": "deleteDialogTitle"; "required": false; }; "deleteDialogMessage": { "alias": "deleteDialogMessage"; "required": false; }; "noImageSelectedErrorMessage": { "alias": "noImageSelectedErrorMessage"; "required": false; }; "wrongTypeSelectedErrorMessage": { "alias": "wrongTypeSelectedErrorMessage"; "required": false; }; "videoPreviewErrorMessage": { "alias": "videoPreviewErrorMessage"; "required": false; }; "audioPreviewErrorMessage": { "alias": "videoPreviewErrorMessage"; "required": false; }; "flipHorinzontalLabel": { "alias": "flipHorinzontalLabel"; "required": false; }; "flipVerticalLabel": { "alias": "flipVerticalLabel"; "required": false; }; "rotateRightLabel": { "alias": "rotateRightLabel"; "required": false; }; "rotateLeftLabel": { "alias": "rotateLeftLabel"; "required": false; }; }, { "localEditedAttachments": "localEditedAttachments"; "abortAddAttachment": "abortAddAttachment"; "downloadAttachment": "downloadAttachment"; "onDeleteAttachment": "onDeleteAttachment"; }, never, never, false, never>;
355
+ static ɵcmp: i0.ɵɵComponentDeclaration<EqpAttachmentsComponent, "eqp-attachments", never, { "disableAction": { "alias": "disableAction"; "required": false; }; "showHeader": { "alias": "showHeader"; "required": false; }; "headerTitle": { "alias": "headerTitle"; "required": false; }; "attachmentsList": { "alias": "attachmentsList"; "required": false; }; "singleAttachment": { "alias": "singleAttachment"; "required": false; }; "showMatCard": { "alias": "showMatCard"; "required": false; }; "multipleAttachment": { "alias": "multipleAttachment"; "required": false; }; "loadMultipleFiles": { "alias": "loadMultipleFiles"; "required": false; }; "emptyTableMessage": { "alias": "emptyTableMessage"; "required": false; }; "allowOnlyImages": { "alias": "allowOnlyImages"; "required": false; }; "acceptedFileTypes": { "alias": "acceptedFileTypes"; "required": false; }; "isDisabled": { "alias": "isDisabled"; "required": false; }; "showInlinePreview": { "alias": "showInlinePreview"; "required": false; }; "getAttachmentEndpoint": { "alias": "getAttachmentEndpoint"; "required": false; }; "productionBaseUrl": { "alias": "productionBaseUrl"; "required": false; }; "compressionOptions": { "alias": "compressionOptions"; "required": false; }; "allowedTypes": { "alias": "allowedTypes"; "required": false; }; "isEqpTableMultiLanguage": { "alias": "isEqpTableMultiLanguage"; "required": false; }; "tablePaginatorVisible": { "alias": "tablePaginatorVisible"; "required": false; }; "isTableSearcheable": { "alias": "isTableSearcheable"; "required": false; }; "tablePaginatorSize": { "alias": "tablePaginatorSize"; "required": false; }; "separatedUploadButtons": { "alias": "separatedUploadButtons"; "required": false; }; "showPreview": { "alias": "showPreview"; "required": false; }; "singleAttachmentDragAndDrop": { "alias": "singleAttachmentDragAndDrop"; "required": false; }; "cropOptions": { "alias": "cropOptions"; "required": false; }; "cropDialogClass": { "alias": "cropDialogClass"; "required": false; }; "maxFileSizeMB": { "alias": "maxFileSizeMB"; "required": false; }; "cardSize": { "alias": "cardSize"; "required": false; }; "customCardWidthPx": { "alias": "customCardWidthPx"; "required": false; }; "customCardHeightPx": { "alias": "customCardHeightPx"; "required": false; }; "openLinkLabel": { "alias": "openLinkLabel"; "required": false; }; "addButtonLabel": { "alias": "addButtonLabel"; "required": false; }; "downloadLabel": { "alias": "downloadLabel"; "required": false; }; "deleteLabel": { "alias": "deleteLabel"; "required": false; }; "fileNameLabel": { "alias": "fileNameLabel"; "required": false; }; "previewLabel": { "alias": "previewLabel"; "required": false; }; "uploadFileLabel": { "alias": "uploadFileLabel"; "required": false; }; "confirmLabel": { "alias": "confirmLabel"; "required": false; }; "abortLabel": { "alias": "abortLabel"; "required": false; }; "saveLabel": { "alias": "saveLabel"; "required": false; }; "exitLabel": { "alias": "exitLabel"; "required": false; }; "uploadWithDropboxLabel": { "alias": "uploadWithDropboxLabel"; "required": false; }; "cropLabel": { "alias": "cropLabel"; "required": false; }; "deleteDialogTitle": { "alias": "deleteDialogTitle"; "required": false; }; "deleteDialogMessage": { "alias": "deleteDialogMessage"; "required": false; }; "noImageSelectedErrorMessage": { "alias": "noImageSelectedErrorMessage"; "required": false; }; "wrongTypeSelectedErrorMessage": { "alias": "wrongTypeSelectedErrorMessage"; "required": false; }; "videoPreviewErrorMessage": { "alias": "videoPreviewErrorMessage"; "required": false; }; "audioPreviewErrorMessage": { "alias": "videoPreviewErrorMessage"; "required": false; }; "flipHorinzontalLabel": { "alias": "flipHorinzontalLabel"; "required": false; }; "flipVerticalLabel": { "alias": "flipVerticalLabel"; "required": false; }; "rotateRightLabel": { "alias": "rotateRightLabel"; "required": false; }; "rotateLeftLabel": { "alias": "rotateLeftLabel"; "required": false; }; "uploadTitle": { "alias": "uploadTitle"; "required": false; }; "uploadSubtitle": { "alias": "uploadSubtitle"; "required": false; }; "dropHereLabel": { "alias": "dropHereLabel"; "required": false; }; "supportedFormatsLabel": { "alias": "supportedFormatsLabel"; "required": false; }; "browseFilesLabel": { "alias": "browseFilesLabel"; "required": false; }; "uploadSummaryLabel": { "alias": "uploadSummaryLabel"; "required": false; }; "filesLabel": { "alias": "filesLabel"; "required": false; }; "totalSizeLabel": { "alias": "totalSizeLabel"; "required": false; }; "emptyStateLabel": { "alias": "emptyStateLabel"; "required": false; }; "addedSuccessfullyLabel": { "alias": "addedSuccessfullyLabel"; "required": false; }; "removedLabel": { "alias": "removedLabel"; "required": false; }; "chooseView": { "alias": "chooseView"; "required": false; }; "showSummary": { "alias": "showSummary"; "required": false; }; "viewMode": { "alias": "viewMode"; "required": false; }; }, { "localEditedAttachments": "localEditedAttachments"; "abortAddAttachment": "abortAddAttachment"; "downloadAttachment": "downloadAttachment"; "onDeleteAttachment": "onDeleteAttachment"; }, never, never, false, never>;
319
356
  }
@@ -4,10 +4,8 @@ import * as i2 from "./modules/material.module";
4
4
  import * as i3 from "@angular/forms";
5
5
  import * as i4 from "@angular/common";
6
6
  import * as i5 from "ngx-image-cropper";
7
- import * as i6 from "@eqproject/eqp-table";
8
- import * as i7 from "ngx-file-drop";
9
7
  export declare class EqpAttachmentsModule {
10
8
  static ɵfac: i0.ɵɵFactoryDeclaration<EqpAttachmentsModule, never>;
11
- static ɵmod: i0.ɵɵNgModuleDeclaration<EqpAttachmentsModule, [typeof i1.EqpAttachmentsComponent], [typeof i2.MaterialModule, typeof i3.FormsModule, typeof i4.CommonModule, typeof i3.ReactiveFormsModule, typeof i5.ImageCropperModule, typeof i6.EqpTableModule, typeof i7.NgxFileDropModule], [typeof i1.EqpAttachmentsComponent]>;
9
+ static ɵmod: i0.ɵɵNgModuleDeclaration<EqpAttachmentsModule, [typeof i1.EqpAttachmentsComponent], [typeof i2.MaterialModule, typeof i3.FormsModule, typeof i4.CommonModule, typeof i3.ReactiveFormsModule, typeof i5.ImageCropperComponent], [typeof i1.EqpAttachmentsComponent]>;
12
10
  static ɵinj: i0.ɵɵInjectorDeclaration<EqpAttachmentsModule>;
13
11
  }
@@ -9,6 +9,7 @@ export interface IAttachmentDTO {
9
9
  IsImage?: boolean;
10
10
  FileThumbnailBase64?: string;
11
11
  TrustedUrl?: any;
12
+ isUploading?: boolean;
12
13
  }
13
14
  export declare enum AttachmentType {
14
15
  FILE = 1,
@@ -19,3 +20,4 @@ export declare enum CropOptionEnum {
19
20
  ROTATE = 1,
20
21
  FLIP = 2
21
22
  }
23
+ export type AttachmentCardSize = 'small' | 'medium' | 'large' | 'custom';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eqproject/eqp-attachments",
3
- "version": "3.0.3",
3
+ "version": "3.1.0",
4
4
  "description": "Dynamic attachments component - Angular Material based",
5
5
  "author": {
6
6
  "name": "EqProject"
@@ -8,14 +8,11 @@
8
8
  "peerDependencies": {
9
9
  "@angular/cdk": "^17.0.1",
10
10
  "@angular/common": "^17.0.4",
11
- "@angular/core": "^17.0.4",
12
- "@eqproject/eqp-common": "latest"
11
+ "@angular/core": "^17.0.4"
13
12
  },
14
13
  "dependencies": {
15
- "@eqproject/eqp-table": "latest",
16
14
  "browser-image-compression": "^2.0.2",
17
- "ngx-file-drop": "^16.0.0",
18
- "ngx-image-cropper": "^7.1.2",
15
+ "ngx-image-cropper": "^9.1.5",
19
16
  "sweetalert2": "^11.10.1",
20
17
  "tslib": "^2.6.2"
21
18
  },