@eqproject/eqp-attachments 0.1.16 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +0 -1
  2. package/esm2020/eqproject-eqp-attachments.mjs +5 -0
  3. package/esm2020/lib/eqp-attachments.component.mjs +830 -0
  4. package/esm2020/lib/eqp-attachments.module.mjs +39 -0
  5. package/esm2020/lib/helpers/attachment.helper.mjs +61 -0
  6. package/esm2020/lib/interfaces/IAttachment.mjs +6 -0
  7. package/esm2020/lib/interfaces/IOptions.mjs +2 -0
  8. package/esm2020/lib/modules/material.module.mjs +231 -0
  9. package/esm2020/lib/services/eqp-attachment-dialog.service.mjs +103 -0
  10. package/esm2020/public-api.mjs +10 -0
  11. package/fesm2015/eqproject-eqp-attachments.mjs +1275 -0
  12. package/fesm2015/eqproject-eqp-attachments.mjs.map +1 -0
  13. package/fesm2020/eqproject-eqp-attachments.mjs +1264 -0
  14. package/fesm2020/eqproject-eqp-attachments.mjs.map +1 -0
  15. package/{eqproject-eqp-attachments.d.ts → index.d.ts} +1 -1
  16. package/lib/eqp-attachments.component.d.ts +5 -11
  17. package/lib/eqp-attachments.module.d.ts +10 -0
  18. package/lib/helpers/attachment.helper.d.ts +3 -0
  19. package/lib/modules/material.module.d.ts +35 -0
  20. package/lib/services/eqp-attachment-dialog.service.d.ts +3 -0
  21. package/package.json +30 -18
  22. package/bundles/eqproject-eqp-attachments.umd.js +0 -1409
  23. package/bundles/eqproject-eqp-attachments.umd.js.map +0 -1
  24. package/bundles/eqproject-eqp-attachments.umd.min.js +0 -2
  25. package/bundles/eqproject-eqp-attachments.umd.min.js.map +0 -1
  26. package/eqproject-eqp-attachments.metadata.json +0 -1
  27. package/esm2015/eqproject-eqp-attachments.js +0 -6
  28. package/esm2015/lib/eqp-attachments.component.js +0 -857
  29. package/esm2015/lib/eqp-attachments.module.js +0 -26
  30. package/esm2015/lib/helpers/attachment.helper.js +0 -62
  31. package/esm2015/lib/interfaces/IAttachment.js +0 -6
  32. package/esm2015/lib/interfaces/IOptions.js +0 -1
  33. package/esm2015/lib/modules/material.module.js +0 -108
  34. package/esm2015/lib/services/eqp-attachment-dialog.service.js +0 -104
  35. package/esm2015/public-api.js +0 -9
  36. package/esm5/eqproject-eqp-attachments.js +0 -6
  37. package/esm5/lib/eqp-attachments.component.js +0 -916
  38. package/esm5/lib/eqp-attachments.module.js +0 -29
  39. package/esm5/lib/helpers/attachment.helper.js +0 -63
  40. package/esm5/lib/interfaces/IAttachment.js +0 -6
  41. package/esm5/lib/interfaces/IOptions.js +0 -1
  42. package/esm5/lib/modules/material.module.js +0 -111
  43. package/esm5/lib/services/eqp-attachment-dialog.service.js +0 -113
  44. package/esm5/public-api.js +0 -9
  45. package/fesm2015/eqproject-eqp-attachments.js +0 -1148
  46. package/fesm2015/eqproject-eqp-attachments.js.map +0 -1
  47. package/fesm5/eqproject-eqp-attachments.js +0 -1223
  48. package/fesm5/eqproject-eqp-attachments.js.map +0 -1
@@ -1,1223 +0,0 @@
1
- import { __decorate, __awaiter, __generator, __spread, __values } from 'tslib';
2
- import { ɵɵdefineInjectable, Injectable, EventEmitter, ChangeDetectorRef, Input, Output, ViewChild, Component, NgModule } from '@angular/core';
3
- import { Validators, FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
4
- import { base64ToFile, ImageCropperComponent, ImageCropperModule } from 'ngx-image-cropper';
5
- import imageCompression from 'browser-image-compression';
6
- import { TooltipPositionType, TypeColumn, EqpTableModule } from '@eqproject/eqp-table';
7
- import { MatDialog, MatDialogModule } from '@angular/material/dialog';
8
- import Swal from 'sweetalert2';
9
- import { DomSanitizer } from '@angular/platform-browser';
10
- import { HttpClient } from '@angular/common/http';
11
- import { CommonModule } from '@angular/common';
12
- import { MatCheckboxModule } from '@angular/material/checkbox';
13
- import { MatButtonModule } from '@angular/material/button';
14
- import { MatInputModule } from '@angular/material/input';
15
- import { MatAutocompleteModule } from '@angular/material/autocomplete';
16
- import { MatDatepickerModule } from '@angular/material/datepicker';
17
- import { MatFormFieldModule } from '@angular/material/form-field';
18
- import { MatRadioModule } from '@angular/material/radio';
19
- import { MatSelectModule } from '@angular/material/select';
20
- import { MatSliderModule } from '@angular/material/slider';
21
- import { MatSlideToggleModule } from '@angular/material/slide-toggle';
22
- import { MatMenuModule } from '@angular/material/menu';
23
- import { MatSidenavModule } from '@angular/material/sidenav';
24
- import { MatToolbarModule } from '@angular/material/toolbar';
25
- import { MatListModule } from '@angular/material/list';
26
- import { MatGridListModule } from '@angular/material/grid-list';
27
- import { MatCardModule } from '@angular/material/card';
28
- import { MatStepperModule } from '@angular/material/stepper';
29
- import { MatTabsModule } from '@angular/material/tabs';
30
- import { MatExpansionModule } from '@angular/material/expansion';
31
- import { MatButtonToggleModule } from '@angular/material/button-toggle';
32
- import { MatChipsModule } from '@angular/material/chips';
33
- import { MatIconModule } from '@angular/material/icon';
34
- import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
35
- import { MatProgressBarModule } from '@angular/material/progress-bar';
36
- import { MatTooltipModule } from '@angular/material/tooltip';
37
- import { MatSnackBarModule } from '@angular/material/snack-bar';
38
- import { MatTableModule } from '@angular/material/table';
39
- import { MatSortModule } from '@angular/material/sort';
40
- import { MatPaginatorModule } from '@angular/material/paginator';
41
- import { MatNativeDateModule } from '@angular/material/core';
42
-
43
- var AttachmentType;
44
- (function (AttachmentType) {
45
- AttachmentType[AttachmentType["FILE"] = 1] = "FILE";
46
- AttachmentType[AttachmentType["LINK"] = 2] = "LINK";
47
- })(AttachmentType || (AttachmentType = {}));
48
-
49
- var AttachmentHelperService = /** @class */ (function () {
50
- function AttachmentHelperService() {
51
- }
52
- /**
53
- * Restituisce TRUE se il mime type passato nel parametro corrisponde ad un mime type di un'immagine
54
- * @param mimeType Mime Type da verificare
55
- */
56
- AttachmentHelperService.checkImageFromMimeType = function (mimeType) {
57
- return this.imageMimeTypes.find(function (s) { return s == mimeType; }) != null;
58
- };
59
- /**
60
- * In base all'estensione passata come parametro, restituisce la FontAwesome corretta da utilizzare.
61
- * Se l'estensione non viene trovata nella costante riportata dentro common.model.ts restituisce un icona standard
62
- * @param extension Estensione del file per cui restituire l'icona corretta
63
- */
64
- AttachmentHelperService.getIconFromFileExtensione = function (extension) {
65
- var fileIcon = this.fileExtensionIcon[extension];
66
- return (fileIcon !== null && fileIcon !== void 0 ? fileIcon : "fas fa-file");
67
- };
68
- AttachmentHelperService.imageMimeTypes = ["image/bmp", "image/gif", "image/jpeg", "image/tiff", "image/png"];
69
- AttachmentHelperService.fileExtensionIcon = {
70
- "txt": "fas fa-file-text",
71
- "pdf": "fas fa-file-pdf",
72
- "doc": "fas fa-file-word",
73
- "docx": "fas fa-file-word",
74
- "xls": "fas fa-file-excel",
75
- "xlsx": "fas fa-file-excel",
76
- "jpg": "fas fa-file-image",
77
- "jpeg": "fas fa-file-image",
78
- "png": "fas fa-file-image",
79
- "bmp": "fas fa-file-image",
80
- "mkv": "fas fa-file-video",
81
- "flv": "fas fa-file-video",
82
- "gif": "fas fa-file-video",
83
- "gifv": "fas fa-file-video",
84
- "avi": "fas fa-file-video",
85
- "wmv": "fas fa-file-video",
86
- "mp4": "fas fa-file-video",
87
- "m4p": "fas fa-file-video",
88
- "m4v": "fas fa-file-video",
89
- "mpg": "fas fa-file-video",
90
- "mp2": "fas fa-file-video",
91
- "mpeg": "fas fa-file-video",
92
- "mpe": "fas fa-file-video",
93
- "mpv": "fas fa-file-video",
94
- "m2v": "fas fa-file-video",
95
- "3gp": "fas fa-file-video",
96
- "3g2": "fas fa-file-video",
97
- "mp3": "fas fa-file-audio",
98
- };
99
- AttachmentHelperService.ɵprov = ɵɵdefineInjectable({ factory: function AttachmentHelperService_Factory() { return new AttachmentHelperService(); }, token: AttachmentHelperService, providedIn: "root" });
100
- AttachmentHelperService = __decorate([
101
- Injectable({
102
- providedIn: 'root'
103
- })
104
- ], AttachmentHelperService);
105
- return AttachmentHelperService;
106
- }());
107
-
108
- var EqpAttachmentDialogService = /** @class */ (function () {
109
- function EqpAttachmentDialogService() {
110
- }
111
- /**
112
- * Mostra uno sweet alert di tipo ERROR con il messaggio passato come parametro.
113
- * @param message Messaggio d'errore da mostrare nello sweetalert
114
- * @param title Titolo dello sweetalert (di default mostra 'Errore')
115
- */
116
- EqpAttachmentDialogService.Error = function (message, title) {
117
- if (title === void 0) { title = null; }
118
- var currentTitle = title != null ? title : 'Errore';
119
- if (Array.isArray(message)) {
120
- currentTitle = title != null ? title : 'Errore';
121
- var htmlErrors = message.join("<br>");
122
- Swal.fire({
123
- title: currentTitle,
124
- html: htmlErrors,
125
- icon: 'error'
126
- });
127
- }
128
- else {
129
- Swal.fire(currentTitle, message, 'error');
130
- }
131
- };
132
- /**
133
- * Mostra uno sweetalert di tipo CONFIRM con il messaggio passato come parametro e se viene premuto
134
- * CONFERMA lancia la funzione di callback passata come parametro
135
- * @param message Messaggio da mostrare nello sweetalert
136
- * @param title Titolo dello sweetalert (di default mostra 'Info')
137
- */
138
- EqpAttachmentDialogService.Confirm = function (message, confirmCallback, isWarning, title, customWidth) {
139
- if (isWarning === void 0) { isWarning = false; }
140
- if (title === void 0) { title = null; }
141
- if (customWidth === void 0) { customWidth = null; }
142
- var currentTitle = title != null ? title : 'Sei sicuro di voler procedere?';
143
- if (Array.isArray(message)) {
144
- var htmlErrors = message.join("<br>");
145
- Swal.fire({
146
- title: currentTitle,
147
- html: htmlErrors,
148
- width: customWidth ? customWidth : '32rem',
149
- icon: !isWarning ? 'question' : 'warning',
150
- showCancelButton: true,
151
- allowOutsideClick: false,
152
- allowEscapeKey: false
153
- }).then(function (result) {
154
- if (result.value && confirmCallback) {
155
- confirmCallback();
156
- }
157
- });
158
- }
159
- else {
160
- Swal.fire({
161
- title: currentTitle,
162
- text: message,
163
- width: customWidth ? customWidth : '32rem',
164
- icon: !isWarning ? 'question' : 'warning',
165
- showCancelButton: true,
166
- allowOutsideClick: false,
167
- allowEscapeKey: false
168
- }).then(function (result) {
169
- if (result.value && confirmCallback) {
170
- confirmCallback();
171
- }
172
- });
173
- }
174
- };
175
- /**
176
- * Mostra uno sweetalert di tipo INFO con il messaggio passato come parametro
177
- * @param message Messaggio da mostrare nello sweetalert
178
- * @param title Titolo dello sweetalert (di default mostra 'Info')
179
- */
180
- EqpAttachmentDialogService.Info = function (message, title, isToast) {
181
- if (title === void 0) { title = null; }
182
- if (isToast === void 0) { isToast = null; }
183
- var currentTitle = title != null ? title : "Informazione:";
184
- Swal.fire(currentTitle, message, 'info');
185
- };
186
- /**
187
- * Mostra uno sweetalert di tipo WARNING con il messaggio passato come parametro
188
- * @param message Messaggio da mostrare nello sweetalert
189
- * @param title Titolo dello sweetalert (di default mostra 'Attenzione!')
190
- */
191
- EqpAttachmentDialogService.Warning = function (message, title, isToast) {
192
- if (title === void 0) { title = null; }
193
- if (isToast === void 0) { isToast = null; }
194
- var currentTitle = title != null ? title : "Attenzione!";
195
- if (Array.isArray(message)) {
196
- var htmlWarnings = message.join("<br>");
197
- Swal.fire({
198
- title: currentTitle,
199
- html: htmlWarnings,
200
- icon: 'warning'
201
- });
202
- }
203
- else {
204
- Swal.fire(currentTitle, message, 'warning');
205
- }
206
- };
207
- EqpAttachmentDialogService.ɵprov = ɵɵdefineInjectable({ factory: function EqpAttachmentDialogService_Factory() { return new EqpAttachmentDialogService(); }, token: EqpAttachmentDialogService, providedIn: "root" });
208
- EqpAttachmentDialogService = __decorate([
209
- Injectable({
210
- providedIn: 'root'
211
- })
212
- ], EqpAttachmentDialogService);
213
- return EqpAttachmentDialogService;
214
- }());
215
-
216
- var toBase64 = function (file) { return new Promise(function (resolve, reject) {
217
- var reader = new FileReader();
218
- reader.readAsDataURL(file);
219
- reader.onload = function () { return resolve(reader.result.toString()); };
220
- reader.onerror = function (error) { return reject(error); };
221
- }); };
222
- var ɵ0 = toBase64;
223
- var EqpAttachmentsComponent = /** @class */ (function () {
224
- function EqpAttachmentsComponent(dialog, formBuilder, sanitizer, http, cd) {
225
- this.dialog = dialog;
226
- this.formBuilder = formBuilder;
227
- this.sanitizer = sanitizer;
228
- this.http = http;
229
- this.cd = cd;
230
- //#region @Input del componente
231
- /**
232
- * Se TRUE allora nasconde la colonna per le azioni sull'allegato (nel caso "multipleAttachment" è TRUE).
233
- */
234
- this.disableAction = false;
235
- /**
236
- * Se TRUE mostra il titolo nell'header nel caso in cui "multipleAttachment" è TRUE ("Elenco allegati" di default).
237
- */
238
- this.showHeader = true;
239
- /**
240
- * Titolo da visualizzare se il parametro "showHeader" è TRUE. Di devault viene visualizzato "Elenco allegati".
241
- */
242
- this.headerTitle = "Elenco allegati";
243
- /**
244
- * Sorgente dati da visualizzare. Nel caso si vuole gestire un singolo allegato va passato in ogni caso come Array.
245
- */
246
- this.attachmentsList = null;
247
- /**
248
- * Se TRUE non mostra la MatCard (nel caso in cui "multipleAttachment" è TRUE).
249
- */
250
- this.showMatCard = true;
251
- /**
252
- * Se FALSE allora il componente mostra solo il pulsante di caricamento di un singolo file, una volta caricato il file invoca l'evento di output "localEditedAttachments".
253
- * Se TRUE allora il componente mostra l'elenco di tutti gli allegati ricevuto nel parametro "attachmentsList".
254
- */
255
- this.multipleAttachment = true;
256
- /**
257
- * Se assume il valore TRUE allora sarà possibile caricare più file per volta. Questa funzionalità è attiva
258
- * SOLO se si gestiscono allegati multipli, quindi se l'input 'multipleAttachment' assume il valore TRUE, altrimenti è sempre disabilitata.
259
- */
260
- this.loadMultipleFiles = false;
261
- /**
262
- * Configurazione delle colonne della eqp-table per la visualizzazione degli allegati (caso "multipleAttachment" è TRUE).
263
- */
264
- this.attachmentsColumns = null;
265
- /**
266
- * Imposta il messaggio da visualizzare nel caso in cui la tabella degli allegati (nel caso in cui "multipleAttachment" è TRUE) è vuota.
267
- */
268
- this.emptyTableMessage = "Nessun dato trovato";
269
- /**
270
- * Se TRUE allora permette di selezionare soltanto file di tipo immagine, avente uno dei mimetype
271
- * specificati dentro AttachmentHelperService.
272
- * Se FALSE permette di selezionare qualsiasi tipo di file
273
- */
274
- this.allowOnlyImages = false;
275
- /**
276
- * Se TRUE disabilita il pulsante di Aggiunta allegato (a prescindere dal valore del parametro "multipleAttachment").
277
- */
278
- this.isDisabled = false;
279
- /**
280
- * Mostra/nasconde la colonna per visualizzare l'anteprima dei file nella tabella (caso multipleAtatchments = true).
281
- */
282
- this.showInlinePreview = false;
283
- /**
284
- * Endpoint da chiamare per recueprare l'IAttachmentDTO completo da vedere nell'anteprima. La chiamata sarà in POST e nel body
285
- * conterrà l'IAttachmentDTO selezionato dall'utente.
286
- * La chiamata viene eseguita solo per l'anteprima delle immagini essendo necessario il base64 completo dell'immagine a dimensione reale.
287
- * Per documenti/link basta che sia popolata la proprietà FilePath di IAttachmentDTO.
288
- */
289
- this.getAttachmentEndpoint = null;
290
- /**
291
- * Hostname dell'ambiente di produzione dell'applicativo. Necessario per visualizzare l'anteprima dei documenti
292
- * tramite il viewer di google.
293
- * NOTA: Per visualizzare l'anteprima è necessario che la prorietà FilePath dell'IAttachmentDTO sia popolata e che
294
- * sia abilitato l'accesso alla cartella sul server tramite hostname.
295
- */
296
- this.productionBaseUrl = null;
297
- /**
298
- * Opzioni per la compressione delle immagini caricate.
299
- */
300
- this.compressionOptions = { maxSizeMB: 0.5, maxWidthOrHeight: 1920, useWebWorker: true };
301
- /**
302
- * Array di AttachmentType che si possono aggiungere
303
- */
304
- this.allowedTypes = [AttachmentType.FILE, AttachmentType.LINK];
305
- /**
306
- * Permette di stabilire se la eqp-table contenente l'elenco degli allegati utilizza
307
- * il multilingua oppure no
308
- */
309
- this.isEqpTableMultiLanguage = false;
310
- /**
311
- * Permette di stabilire, in caso di gestione allegati multipli, se la tabella contenente l'elenco
312
- * degli allegati deve essere paginata oppure no
313
- */
314
- this.tablePaginatorVisible = true;
315
- /**
316
- * In caso di gestione allegati multipli, permette di stabilire la dimensione pagina di default
317
- * per la tabella contenente l'elenco degli allegati
318
- */
319
- this.tablePaginatorSize = null;
320
- /**
321
- * Input per definire le label da usare nel componente
322
- */
323
- this.downloadTooltipPosition = TooltipPositionType.Below;
324
- this.openLinkLabel = "Apri link";
325
- this.addButtonLabel = "Aggiungi";
326
- this.downloadLabel = "Download";
327
- this.deleteLabel = "Elimina";
328
- this.fileNameLabel = "Nome file";
329
- this.previewLabel = "Anteprima";
330
- this.uploadFileLabel = "Carica file";
331
- this.confirmLabel = "Conferma";
332
- this.abortLabel = "Annulla";
333
- this.saveLabel = "Salva";
334
- this.exitLabel = "Esci";
335
- this.eqpTableSearchText = "Cerca";
336
- this.deleteDialogTitle = null;
337
- this.deleteDialogMessage = "Sei sicuro di voler cancellare quest'allegato?";
338
- this.noImageSelectedErrorMessage = "Non è possibile selezionare un file che non sia un'immagine.";
339
- this.wrongTypeSelectedErrorMessage = "Non è possibile caricare il file selezionato.";
340
- this.videoPreviewErrorMessage = "Impossibile aprire l'anteprima di un file video.";
341
- this.audioPreviewErrorMessage = "Impossibile aprire l'anteprima di un file audio.";
342
- //#endregion
343
- //#region @Output del componente
344
- /**
345
- * Restituisce la lista aggiornata degli allegati.
346
- */
347
- this.localEditedAttachments = new EventEmitter();
348
- /**
349
- * Evento scatenato alla pressione del pulsante ESCI della modale di caricamento file.
350
- */
351
- this.abortAddAttachment = new EventEmitter();
352
- /**
353
- * Evento di output che restituisce l'IAttachmentDTO selezionato per il download nel caso FileDataBase64, FileContentType o FileName non fossero specificati.
354
- */
355
- this.downloadAttachment = new EventEmitter();
356
- /**
357
- * Evento di output che restituisce l'elemento eliminato prima che questo venga effettivamente rismosso dalla lista.
358
- */
359
- this.onDeleteAttachment = new EventEmitter();
360
- /**
361
- * Evento di output scatenato durante l'AfterViewInit del componente che restituisce l'istanza corrente del componente.
362
- * Questo evento avvisa quando il componente è stato renderizzato, utile per esempio quando si vogliono aggiungere delle colonne
363
- * alla visualizzazione con allegati multipli lasciando però quelle pre esistenti. Questo si può fare intervenendo sulla
364
- * proprietà "attachmentsColumns" di questo componente tramite l'istanza passata come paramentro oppure tramite ViewChild
365
- * dal componente che lo ospita.
366
- */
367
- this.onComponentLoaded = new EventEmitter();
368
- //#endregion
369
- //#region Proprietà per gestione caricamento nuovo allegato
370
- this.newAttachment = {};
371
- this.newMultipleAttachments = [];
372
- this.attachmentType = AttachmentType;
373
- this.selectedFile = null;
374
- this.selectedFiles = null;
375
- this.showCropImage = false;
376
- //#endregion
377
- //#region Proprietà per gestione ridimensionamento file di tipo image
378
- this.imageChangedEvent = '';
379
- this.croppedImage = '';
380
- this.transform = {};
381
- //#endregion
382
- this.AttachmentType = AttachmentType;
383
- }
384
- EqpAttachmentsComponent.prototype.ngOnInit = function () {
385
- //Se è stata richiesta la gestione delle sole immagini allora imposta il filtro per le estensioni possibili da caricare
386
- if (!this.acceptedFileTypes)
387
- if (this.allowOnlyImages == true)
388
- this.acceptedFileTypes = "image/*";
389
- else
390
- this.acceptedFileTypes = "*";
391
- // Se non sono stati specificati i tipi da gestire ma è stato passato null o un array vuoto imposto i tipi di default.
392
- if (!this.allowedTypes || this.allowedTypes.length == 0)
393
- this.allowedTypes = [AttachmentType.FILE, AttachmentType.LINK];
394
- else if (this.allowedTypes.find(function (t) { return t != AttachmentType.FILE && t != AttachmentType.LINK; })) {
395
- EqpAttachmentDialogService.Warning("Almeno uno degli AttachmentType selezionati nel parametro \"allowedTypes\" non esiste.");
396
- this.allowedTypes = [AttachmentType.FILE, AttachmentType.LINK];
397
- }
398
- //Se è stata richiesta la gestione multipla degli allegati allora configura l'eqp-table
399
- if (this.multipleAttachment == true && (!this.attachmentsColumns || this.attachmentsColumns.length == 0)) {
400
- this.configureColumns();
401
- }
402
- if (this.attachmentsList == null)
403
- this.attachmentsList = new Array();
404
- this.checkAttachmentImage();
405
- };
406
- EqpAttachmentsComponent.prototype.ngAfterViewInit = function () {
407
- this.onComponentLoaded.emit(this);
408
- };
409
- EqpAttachmentsComponent.prototype.reloadData = function () {
410
- if (this.attachmentTable)
411
- this.attachmentTable.reloadDatatable();
412
- };
413
- EqpAttachmentsComponent.prototype.checkAttachmentImage = function () {
414
- this.attachmentsList.forEach(function (a) {
415
- a.IsImage = AttachmentHelperService.checkImageFromMimeType(a.FileContentType);
416
- });
417
- };
418
- //#region Gestione elenco allegati
419
- /**
420
- * Configura le colonne per l'eqp-table nel caso in cui il parametro "multipleAttachments" è TRUE.
421
- */
422
- EqpAttachmentsComponent.prototype.configureColumns = function () {
423
- var _this = this;
424
- this.attachmentsColumns = [];
425
- if (this.disableAction != true) {
426
- this.attachmentsColumns.push({
427
- key: "action", display: "",
428
- type: TypeColumn.MenuAction, buttonMenuIcon: "more_vert", styles: { flex: "0 0 6%" },
429
- actions: [
430
- { name: this.deleteLabel, icon: "delete", fn: function (element, index, col) { return _this.deleteAttachment(element); } },
431
- ],
432
- });
433
- }
434
- var downloadColumn = {
435
- key: "attachment", display: "",
436
- type: TypeColumn.SimpleAction, styles: { flex: "0 0 6%" },
437
- actions: [
438
- {
439
- name: '', fontawesome: true,
440
- icon: function (element) { return _this.showInlinePreview ? (element.AttachmentType == AttachmentType.FILE ? "fas fa-cloud-download-alt" : "fas fa-external-link-alt") : _this.getAttachmentIcon(element); },
441
- fn: function (element, col, elementIndex) { return _this.viewAttachment(element); },
442
- tooltip: { tooltipText: function (element) { return element.AttachmentType == AttachmentType.FILE ? _this.downloadLabel : _this.openLinkLabel; }, tooltipPosition: this.downloadTooltipPosition }
443
- },
444
- ]
445
- };
446
- var inlinePreviewColumn = {
447
- key: "InlinePreview", display: this.previewLabel,
448
- type: TypeColumn.ExternalTemplate,
449
- externalTemplate: this.inlinePreviewTemplate,
450
- styles: { flex: "0 0 10%" }
451
- };
452
- var fileNameColumn = { key: "FileName", display: this.fileNameLabel };
453
- if (this.showInlinePreview) {
454
- this.attachmentsColumns.push(inlinePreviewColumn);
455
- this.attachmentsColumns.push(fileNameColumn);
456
- this.attachmentsColumns.push(downloadColumn);
457
- }
458
- else {
459
- this.attachmentsColumns.push(downloadColumn);
460
- this.attachmentsColumns.push(fileNameColumn);
461
- }
462
- };
463
- /**
464
- * Elimina un allegato eliminando anche il file presente nello storage di archiviazione utilizzato (AWS o cartella progetto)
465
- * @param element IAttachmentDTO da cancellare
466
- */
467
- EqpAttachmentsComponent.prototype.deleteAttachment = function (element) {
468
- var _this = this;
469
- EqpAttachmentDialogService.Confirm(this.deleteDialogMessage, function () {
470
- _this.removeAttachmentFromList(_this.attachmentsList.indexOf(element));
471
- }, true, this.deleteDialogTitle);
472
- };
473
- /**
474
- * Rimuove l'allegato selezionato dalla lista "attachmentsList" e invoca l'evento di output che restituisce la lista aggiornata.
475
- * @param attachmentIndex Indice dell'attachment da rimuovere
476
- */
477
- EqpAttachmentsComponent.prototype.removeAttachmentFromList = function (attachmentIndex) {
478
- this.onDeleteAttachment.emit(this.attachmentsList[attachmentIndex]);
479
- this.attachmentsList.splice(attachmentIndex, 1);
480
- if (this.attachmentTable)
481
- this.attachmentTable.reloadDatatable();
482
- this.localEditedAttachments.emit(this.attachmentsList);
483
- };
484
- /**
485
- * Scarica l'allegato o apre il link
486
- * @param element Allegato da mostrare
487
- */
488
- EqpAttachmentsComponent.prototype.viewAttachment = function (attachment) {
489
- if (attachment.AttachmentType == AttachmentType.LINK) {
490
- window.open(attachment.FilePath, '_blank');
491
- return;
492
- }
493
- if (attachment.FileDataBase64 && attachment.FileContentType && attachment.FileName) {
494
- var source = "data:" + attachment.FileContentType + ";base64," + attachment.FileDataBase64;
495
- var link = document.createElement("a");
496
- link.href = source;
497
- link.download = "" + attachment.FileName;
498
- link.click();
499
- }
500
- else {
501
- this.downloadAttachment.emit(attachment);
502
- }
503
- };
504
- /**
505
- * Ridefinisce l'icona da mostrare nella colonna dell'eqp-table per ogni file.
506
- * L'icona varia in base all'estensione del file
507
- * @param attachment
508
- */
509
- EqpAttachmentsComponent.prototype.getAttachmentIcon = function (attachment) {
510
- if (attachment.AttachmentType == AttachmentType.LINK)
511
- return "fas fa-link";
512
- else
513
- return AttachmentHelperService.getIconFromFileExtensione(attachment.FileExtension);
514
- };
515
- //#endregion
516
- /**
517
- * Apre la modale per la definizione dei parametri del nuovo file
518
- */
519
- EqpAttachmentsComponent.prototype.openModalAddAttachment = function (attachmentType) {
520
- //Se è stato richiesto il caricamento di un LINK o è impostato il caricamento di FILE SINGOLO allora apre la modale per
521
- //il caricamento singolo del file altrimenti apre quella per il caricamento multiplo
522
- // if (attachmentType == AttachmentType.LINK || (attachmentType == AttachmentType.FILE && this.loadMultipleFiles != true)) {
523
- this.newAttachment = {};
524
- this.newAttachment.IsImage = false;
525
- this.newAttachment.AttachmentType = attachmentType;
526
- this.newMultipleAttachments = new Array();
527
- if (attachmentType == AttachmentType.LINK)
528
- this.newMultipleAttachments.push(this.newAttachment);
529
- this.createAttachmentForm();
530
- //Apre la modale
531
- this.dialofRefAddAttachment = this.dialog.open(this.dialogAddAttachment, {
532
- disableClose: true,
533
- hasBackdrop: true,
534
- width: '60%',
535
- maxHeight: '80%'
536
- });
537
- };
538
- EqpAttachmentsComponent.prototype.createAttachmentForm = function () {
539
- //Crea la form per la validazione dei campi
540
- this.newAttachmentForm = this.formBuilder.group({
541
- type: [this.newAttachment.AttachmentType, Validators.required],
542
- name: [this.newAttachment.FileName],
543
- path: [this.newAttachment.FilePath],
544
- customHeight: [this.customHeight],
545
- customWidth: [this.customWidth]
546
- });
547
- };
548
- EqpAttachmentsComponent.prototype.close = function (emitCloseEvent) {
549
- if (emitCloseEvent === void 0) { emitCloseEvent = true; }
550
- this.newAttachment = {};
551
- this.newMultipleAttachments = new Array();
552
- this.abortFile();
553
- if (this.newAttachmentForm)
554
- this.newAttachmentForm.reset();
555
- this.dialofRefAddAttachment.close();
556
- if (emitCloseEvent == true && this.abortAddAttachment)
557
- this.abortAddAttachment.emit();
558
- };
559
- /**
560
- * In base al tipo di allegato controlla se disabilitare o meno il pulsante per salvare.
561
- * Funzione usata nel [disable] del pulsante "Salva" del dialog per l'aggiunta di un allegato.
562
- * @returns
563
- */
564
- EqpAttachmentsComponent.prototype.disableSave = function () {
565
- if (this.loadMultipleFiles != true) {
566
- if (this.newAttachment.AttachmentType == AttachmentType.FILE) {
567
- return !this.newAttachment.FileDataBase64;
568
- }
569
- else {
570
- return !this.newAttachment.FilePath;
571
- }
572
- }
573
- else {
574
- return this.newMultipleAttachments.filter(function (p) { return (p.AttachmentType == AttachmentType.FILE && !p.FileDataBase64) || (p.AttachmentType == AttachmentType.LINK && !p.FilePath); }).length > 0;
575
- }
576
- };
577
- EqpAttachmentsComponent.prototype.confirmAddAttachment = function () {
578
- if (this.loadMultipleFiles != true) {
579
- if (this.newAttachment.AttachmentType == AttachmentType.LINK && !this.newAttachment.FileName)
580
- this.newAttachment.FileName = this.newAttachment.FilePath;
581
- if (this.attachmentsList == null)
582
- this.attachmentsList = new Array();
583
- this.attachmentsList.push(this.newAttachment);
584
- }
585
- else {
586
- if (this.newMultipleAttachments == null || this.newMultipleAttachments.length == 0)
587
- return;
588
- if (this.attachmentsList == null)
589
- this.attachmentsList = new Array();
590
- this.attachmentsList = this.attachmentsList.concat(this.newMultipleAttachments);
591
- }
592
- if (this.attachmentTable)
593
- this.attachmentTable.reloadDatatable();
594
- this.localEditedAttachments.emit(this.attachmentsList);
595
- this.close(false);
596
- };
597
- /**
598
- * Apre il dialog per l'anteprima dell'allegato selezionato.
599
- * @param row
600
- * @returns
601
- */
602
- EqpAttachmentsComponent.prototype.openPreviewDialog = function (row) {
603
- return __awaiter(this, void 0, void 0, function () {
604
- var _this = this;
605
- return __generator(this, function (_a) {
606
- switch (_a.label) {
607
- case 0:
608
- this.selectedAttachment = JSON.parse(JSON.stringify(row));
609
- if (this.selectedAttachment.AttachmentType == AttachmentType.FILE) {
610
- if (this.selectedAttachment.FileContentType.startsWith("video")) {
611
- EqpAttachmentDialogService.Warning(this.videoPreviewErrorMessage);
612
- return [2 /*return*/];
613
- }
614
- else if (this.selectedAttachment.FileContentType.startsWith("audio")) {
615
- EqpAttachmentDialogService.Warning(this.audioPreviewErrorMessage);
616
- return [2 /*return*/];
617
- }
618
- }
619
- if (!(this.getAttachmentEndpoint && this.selectedAttachment.IsImage && !this.selectedAttachment.FileDataBase64)) return [3 /*break*/, 2];
620
- return [4 /*yield*/, this.getAttachmentByID()
621
- .then(function (res) { _this.selectedAttachment.FileDataBase64 = res.FileDataBase64; })
622
- .catch(function (err) { EqpAttachmentDialogService.Error(err); })];
623
- case 1:
624
- _a.sent();
625
- _a.label = 2;
626
- case 2:
627
- if (this.selectedAttachment.AttachmentType == AttachmentType.LINK) {
628
- this.selectedAttachment.TrustedUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.selectedAttachment.FilePath);
629
- }
630
- else if (this.selectedAttachment.IsImage && !this.selectedAttachment.FileDataBase64 && !this.selectedAttachment.FileThumbnailBase64) {
631
- EqpAttachmentDialogService.Info("Impossibile aprire l'anteprima dell'allegato, file mancante.");
632
- return [2 /*return*/];
633
- }
634
- else if (!this.selectedAttachment.IsImage) {
635
- if (this.selectedAttachment.FilePath && this.productionBaseUrl) {
636
- this.selectedAttachment.TrustedUrl = this.sanitizer.bypassSecurityTrustResourceUrl("https://docs.google.com/gview?url=" +
637
- this.productionBaseUrl +
638
- "/" +
639
- this.selectedAttachment.FilePath +
640
- "&embedded=true");
641
- }
642
- else {
643
- EqpAttachmentDialogService.Info("Impossibile aprire l'anteprima del documento!");
644
- return [2 /*return*/];
645
- }
646
- }
647
- this.dialog.open(this.dialogPreview, {
648
- disableClose: true,
649
- hasBackdrop: true,
650
- });
651
- return [2 /*return*/];
652
- }
653
- });
654
- });
655
- };
656
- EqpAttachmentsComponent.prototype.getAttachmentByID = function () {
657
- return __awaiter(this, void 0, void 0, function () {
658
- return __generator(this, function (_a) {
659
- return [2 /*return*/, this.http.post(this.getAttachmentEndpoint, this.selectedAttachment).toPromise()];
660
- });
661
- });
662
- };
663
- //#region Gestione caricamento file
664
- /**
665
- * Evento scatenato alla selezione del file (o dei file).
666
- * Se il caricamento è SINGOLO o se comunque è stato selezionato un solo file allora si occupa di controllare se si tratta di un immagine in modo da
667
- * mostrare le funzionalità del croppie (per ritagliare l'immagine) oppure no.
668
- * Se il file caricato non è un immagine allora genera direttamente il base64 e lo associa all'allegato da salvare.
669
- * Se invece il caricamento dei file è MULTIPLO e sono presenti più file allora esegue le stesse operazioni ignorando però il contrllo
670
- * immagine per il croppie (in caso di caricamento multiplo le funzionalità del croppie sono disabilitate).
671
- */
672
- EqpAttachmentsComponent.prototype.onFileInputChange = function (event) {
673
- return __awaiter(this, void 0, void 0, function () {
674
- var _a, checkOnlyImage, base64Result, i, newAttachment, checkOnlyImage;
675
- return __generator(this, function (_b) {
676
- switch (_b.label) {
677
- case 0:
678
- this.showCropImage = false;
679
- if (!(__spread(event.target.files).length == 1 || this.loadMultipleFiles != true)) return [3 /*break*/, 5];
680
- this.selectedFile = event.target.files[0];
681
- this.selectedFiles = event.target.files;
682
- if (!this.selectedFile)
683
- return [2 /*return*/];
684
- //Memorizza i dati per l'allegato
685
- _a = this;
686
- return [4 /*yield*/, this.createAttachmentFromUploadedFile(this.selectedFile, false)];
687
- case 1:
688
- //Memorizza i dati per l'allegato
689
- _a.newAttachment = _b.sent();
690
- this.newMultipleAttachments = new Array();
691
- this.newMultipleAttachments.push(this.newAttachment);
692
- checkOnlyImage = this.checkAllowOnlyImageFile(this.newAttachment);
693
- if (checkOnlyImage == false)
694
- return [2 /*return*/];
695
- if (this.loadMultipleFiles == true && __spread(event.target.files).length == 1)
696
- this.createAttachmentForm();
697
- if (!(this.newAttachment.IsImage == true)) return [3 /*break*/, 2];
698
- this.getImageDimensions(event.target.files[0]);
699
- //Mostra il croppie e disabilita la form finchè non termina la modifica dell'immagine
700
- this.newAttachmentForm.disable();
701
- this.newAttachmentForm.controls["customWidth"].enable();
702
- this.newAttachmentForm.controls["customHeight"].enable();
703
- this.showCropImage = true;
704
- this.imageChangedEvent = event;
705
- return [3 /*break*/, 4];
706
- case 2:
707
- this.showCropImage = false;
708
- return [4 /*yield*/, this.getBase64FromFile(this.selectedFile)];
709
- case 3:
710
- base64Result = _b.sent();
711
- this.newAttachment.FileDataBase64 = base64Result.Base64File;
712
- this.newAttachment.FileContentType = base64Result.ContentType;
713
- _b.label = 4;
714
- case 4: return [3 /*break*/, 9];
715
- case 5:
716
- this.selectedFiles = event.target.files;
717
- if (!this.selectedFiles || this.selectedFiles.length == 0)
718
- return [2 /*return*/];
719
- this.newMultipleAttachments = new Array();
720
- i = 0;
721
- _b.label = 6;
722
- case 6:
723
- if (!(i < this.selectedFiles.length)) return [3 /*break*/, 9];
724
- return [4 /*yield*/, this.createAttachmentFromUploadedFile(this.selectedFiles[i], true)];
725
- case 7:
726
- newAttachment = _b.sent();
727
- checkOnlyImage = this.checkAllowOnlyImageFile(newAttachment);
728
- if (checkOnlyImage == false)
729
- return [2 /*return*/];
730
- this.newMultipleAttachments.push(newAttachment);
731
- _b.label = 8;
732
- case 8:
733
- i++;
734
- return [3 /*break*/, 6];
735
- case 9: return [2 /*return*/];
736
- }
737
- });
738
- });
739
- };
740
- /**
741
- * A partire dal FILE ricevuto in input ricostruisce l'oggetto IAttachmentDTO e lo restituisce.
742
- * Se il parametro getBase64 viene passato a TRUE allora, sempre a partire dal file,genera il base64 e
743
- * ricava il ContentType da associare all'oggetto IAttachmentDTO da restituire
744
- * @param currentFile Oggetto FILE da processare
745
- * @param getBase64 Se TRUE allora calcola base64 e ContentType del file passato in input
746
- * @returns Restituisce un oggetto di tipo IAttachmentDTO
747
- */
748
- EqpAttachmentsComponent.prototype.createAttachmentFromUploadedFile = function (currentFile, getBase64) {
749
- if (getBase64 === void 0) { getBase64 = true; }
750
- return __awaiter(this, void 0, void 0, function () {
751
- var newAttachment, base64Result;
752
- return __generator(this, function (_a) {
753
- switch (_a.label) {
754
- case 0:
755
- newAttachment = {};
756
- //Memorizza i dati per l'allegato
757
- newAttachment.AttachmentType = AttachmentType.FILE;
758
- newAttachment.FileContentType = currentFile.type;
759
- newAttachment.FileName = currentFile.name;
760
- newAttachment.FileExtension = currentFile.name.substr(currentFile.name.lastIndexOf('.') + 1);
761
- newAttachment.IsImage = AttachmentHelperService.checkImageFromMimeType(currentFile.type);
762
- if (!(getBase64 == true)) return [3 /*break*/, 2];
763
- return [4 /*yield*/, this.getBase64FromFile(currentFile)];
764
- case 1:
765
- base64Result = _a.sent();
766
- newAttachment.FileDataBase64 = base64Result.Base64File;
767
- newAttachment.FileContentType = base64Result.ContentType;
768
- _a.label = 2;
769
- case 2: return [2 /*return*/, newAttachment];
770
- }
771
- });
772
- });
773
- };
774
- /**
775
- * A partire dal file passato in input restituisce un oggetto
776
- * contenente il base64 del file e il suo contentType
777
- * @param currentFile Oggetto File da cui estrapolare base64 e contentType
778
- * @returns Restituisce un oggetto avente le proprietà Base64File e ContentType
779
- */
780
- EqpAttachmentsComponent.prototype.getBase64FromFile = function (currentFile) {
781
- return __awaiter(this, void 0, void 0, function () {
782
- var base64File, contentType, result;
783
- return __generator(this, function (_a) {
784
- switch (_a.label) {
785
- case 0: return [4 /*yield*/, toBase64(currentFile)];
786
- case 1:
787
- base64File = _a.sent();
788
- contentType = null;
789
- if (base64File) {
790
- // Loris 20/01/2022: PROBLEMA - Quando eseguo l'upload di un file .sql non viene salvato/scaricato correttamente.
791
- // Questo succede perchè non viene popolato il FileContentType. Per risolvere il problema
792
- // faccio un controllo e se non esiste il FileContentType allora lo recupero dal base64 ottenuto.
793
- contentType = base64File.split(",")[0].split(":")[1].split(";")[0];
794
- // Un altro metodo per leggere il ccontent type del file è tramite una regular expression:
795
- base64File = base64File.split(",")[1];
796
- }
797
- result = {
798
- Base64File: base64File,
799
- ContentType: contentType
800
- };
801
- return [2 /*return*/, result];
802
- }
803
- });
804
- });
805
- };
806
- /**
807
- * Controlla se il file che si sta caricando è supportato dal sistema.
808
- * @returns
809
- */
810
- EqpAttachmentsComponent.prototype.checkAcceptedFiles = function () {
811
- var e_1, _a;
812
- var _this = this;
813
- if ((this.loadMultipleFiles != true && this.selectedFile.type.startsWith("video"))
814
- || (this.loadMultipleFiles == true && __spread(this.selectedFiles).filter(function (p) { return p.type.startsWith("video"); }).length > 0))
815
- return false;
816
- if (this.acceptedFileTypes == "*")
817
- return true;
818
- //Verifica che i tipi del file (o dei file) caricati siano coerenti con quelli accettati dalla direttiva
819
- var accepted = true;
820
- if (this.loadMultipleFiles != true)
821
- accepted = this.acceptedFileTypes.includes(this.selectedFile.type);
822
- else {
823
- var uploadedFileTypes = __spread(this.selectedFiles).map(function (p) { return p.type; });
824
- uploadedFileTypes.forEach(function (type) {
825
- if (!_this.acceptedFileTypes.includes(type))
826
- accepted = false;
827
- });
828
- }
829
- //Questo controllo permette di gestire le casistiche per cui vengono indicati come tipi validi, ad esempio, 'image/*'
830
- if (!accepted && this.loadMultipleFiles != true) {
831
- try {
832
- for (var _b = __values(this.acceptedFileTypes.split(",").filter(function (t) { return t.includes("*"); })), _c = _b.next(); !_c.done; _c = _b.next()) {
833
- var t = _c.value;
834
- accepted = this.selectedFile.type.startsWith(t.split("*")[0]);
835
- if (accepted)
836
- break;
837
- }
838
- }
839
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
840
- finally {
841
- try {
842
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
843
- }
844
- finally { if (e_1) throw e_1.error; }
845
- }
846
- }
847
- return accepted;
848
- };
849
- /**
850
- * Se eqp-attachments è stata configurata per il caricamento delle sole immagini allora verifica che il file passato in
851
- * input sia effettivamente un immagine o no.
852
- * Se il controllo va a buon fine restituisce TRUE altrimenti mostra un messaggio d'errore e restituisce FALSE
853
- */
854
- EqpAttachmentsComponent.prototype.checkAllowOnlyImageFile = function (newAttachment) {
855
- if (this.allowOnlyImages == true && newAttachment.IsImage != true) {
856
- EqpAttachmentDialogService.Error(this.noImageSelectedErrorMessage);
857
- this.abortFile();
858
- return false;
859
- }
860
- else if (!this.checkAcceptedFiles()) {
861
- EqpAttachmentDialogService.Error(this.wrongTypeSelectedErrorMessage);
862
- this.abortFile();
863
- return false;
864
- }
865
- return true;
866
- };
867
- EqpAttachmentsComponent.prototype.getImageDimensions = function (img) {
868
- var _this = this;
869
- var reader = new FileReader();
870
- reader.onload = function (e) {
871
- var image = new Image();
872
- image.src = e.target.result;
873
- image.onload = function (rs) {
874
- _this.originalHeight = rs.currentTarget['height'];
875
- _this.originalWidth = rs.currentTarget['width'];
876
- if (_this.originalWidth > 1280) {
877
- _this.customWidth = 1280;
878
- _this.customHeight = Math.round((1280 * _this.originalHeight) / _this.originalWidth);
879
- }
880
- else {
881
- _this.customHeight = rs.currentTarget['height'];
882
- _this.customWidth = rs.currentTarget['width'];
883
- }
884
- };
885
- };
886
- reader.readAsDataURL(img);
887
- };
888
- EqpAttachmentsComponent.prototype.restoreOriginalDimensions = function () {
889
- this.customWidth = this.originalWidth;
890
- this.customHeight = this.originalHeight;
891
- };
892
- EqpAttachmentsComponent.prototype.onDimensionsChange = function (dimension) {
893
- if (dimension == "H") {
894
- this.customWidth = Math.round((this.customHeight * this.originalWidth) / this.originalHeight);
895
- }
896
- else if (dimension == "W") {
897
- this.customHeight = Math.round((this.customWidth * this.originalHeight) / this.originalWidth);
898
- }
899
- };
900
- EqpAttachmentsComponent.prototype.imageCropped = function (event) {
901
- this.croppedImage = event.base64;
902
- this.getCroppedAndUpload(this.croppedImage);
903
- };
904
- EqpAttachmentsComponent.prototype.getCroppedAndUpload = function (file) {
905
- var self = this;
906
- var file = base64ToFile(file);
907
- var options = this.compressionOptions;
908
- /**
909
- * Comprime l'immagine passando come parametri le options create nell'oggetto sopra, e il file dal reader principale
910
- */
911
- imageCompression(file, options).then((function (fileCompressed) {
912
- var fileReader = new FileReader();
913
- //Faccio la push di ogni file all'interno dell'array di file dell'item da mandare al server
914
- fileReader.onload = function () {
915
- var resultReader = fileReader.result;
916
- var marker = ';base64,';
917
- self.newAttachment.FileDataBase64 = resultReader.substring(resultReader.indexOf(marker) + marker.length);
918
- self.showCropImage = false;
919
- self.newAttachmentForm.enable();
920
- };
921
- fileReader.readAsDataURL(fileCompressed);
922
- }));
923
- };
924
- EqpAttachmentsComponent.prototype.confirmCrop = function () {
925
- this.imageCropper.crop();
926
- };
927
- /**
928
- * Annulla la selezione del file, svuotando l'input e resettando tutte le proprietà dell'IAttachmentDTO
929
- */
930
- EqpAttachmentsComponent.prototype.abortFile = function () {
931
- this.imageChangedEvent = '';
932
- if (this.imageInput)
933
- this.imageInput.nativeElement.value = '';
934
- this.selectedFile = null;
935
- this.selectedFiles = null;
936
- this.showCropImage = false;
937
- this.newAttachment.IsImage = false;
938
- this.newAttachment.FileDataBase64 = null;
939
- this.newAttachment.FileName = null;
940
- this.newAttachment.FileExtension = null;
941
- this.newAttachment.FileContentType = null;
942
- this.newMultipleAttachments = new Array();
943
- this.customHeight = null;
944
- this.customWidth = null;
945
- this.originalHeight = null;
946
- this.originalWidth = null;
947
- };
948
- EqpAttachmentsComponent.ctorParameters = function () { return [
949
- { type: MatDialog },
950
- { type: FormBuilder },
951
- { type: DomSanitizer },
952
- { type: HttpClient },
953
- { type: ChangeDetectorRef }
954
- ]; };
955
- __decorate([
956
- Input("disableAction")
957
- ], EqpAttachmentsComponent.prototype, "disableAction", void 0);
958
- __decorate([
959
- Input("showHeader")
960
- ], EqpAttachmentsComponent.prototype, "showHeader", void 0);
961
- __decorate([
962
- Input("headerTitle")
963
- ], EqpAttachmentsComponent.prototype, "headerTitle", void 0);
964
- __decorate([
965
- Input("attachmentsList")
966
- ], EqpAttachmentsComponent.prototype, "attachmentsList", void 0);
967
- __decorate([
968
- Input("showMatCard")
969
- ], EqpAttachmentsComponent.prototype, "showMatCard", void 0);
970
- __decorate([
971
- Input("multipleAttachment")
972
- ], EqpAttachmentsComponent.prototype, "multipleAttachment", void 0);
973
- __decorate([
974
- Input("loadMultipleFiles")
975
- ], EqpAttachmentsComponent.prototype, "loadMultipleFiles", void 0);
976
- __decorate([
977
- Input("attachmentsColumns")
978
- ], EqpAttachmentsComponent.prototype, "attachmentsColumns", void 0);
979
- __decorate([
980
- Input("emptyTableMessage")
981
- ], EqpAttachmentsComponent.prototype, "emptyTableMessage", void 0);
982
- __decorate([
983
- Input("allowOnlyImages")
984
- ], EqpAttachmentsComponent.prototype, "allowOnlyImages", void 0);
985
- __decorate([
986
- Input("acceptedFileTypes")
987
- ], EqpAttachmentsComponent.prototype, "acceptedFileTypes", void 0);
988
- __decorate([
989
- Input("isDisabled")
990
- ], EqpAttachmentsComponent.prototype, "isDisabled", void 0);
991
- __decorate([
992
- Input("showInlinePreview")
993
- ], EqpAttachmentsComponent.prototype, "showInlinePreview", void 0);
994
- __decorate([
995
- Input("getAttachmentEndpoint")
996
- ], EqpAttachmentsComponent.prototype, "getAttachmentEndpoint", void 0);
997
- __decorate([
998
- Input("productionBaseUrl")
999
- ], EqpAttachmentsComponent.prototype, "productionBaseUrl", void 0);
1000
- __decorate([
1001
- Input("compressionOptions")
1002
- ], EqpAttachmentsComponent.prototype, "compressionOptions", void 0);
1003
- __decorate([
1004
- Input("allowedTypes")
1005
- ], EqpAttachmentsComponent.prototype, "allowedTypes", void 0);
1006
- __decorate([
1007
- Input("isEqpTableMultiLanguage")
1008
- ], EqpAttachmentsComponent.prototype, "isEqpTableMultiLanguage", void 0);
1009
- __decorate([
1010
- Input("tablePaginatorVisible")
1011
- ], EqpAttachmentsComponent.prototype, "tablePaginatorVisible", void 0);
1012
- __decorate([
1013
- Input("tablePaginatorSize")
1014
- ], EqpAttachmentsComponent.prototype, "tablePaginatorSize", void 0);
1015
- __decorate([
1016
- Input("downloadTooltipPosition")
1017
- ], EqpAttachmentsComponent.prototype, "downloadTooltipPosition", void 0);
1018
- __decorate([
1019
- Input("openLinkLabel")
1020
- ], EqpAttachmentsComponent.prototype, "openLinkLabel", void 0);
1021
- __decorate([
1022
- Input("addButtonLabel")
1023
- ], EqpAttachmentsComponent.prototype, "addButtonLabel", void 0);
1024
- __decorate([
1025
- Input("downloadLabel")
1026
- ], EqpAttachmentsComponent.prototype, "downloadLabel", void 0);
1027
- __decorate([
1028
- Input("deleteLabel")
1029
- ], EqpAttachmentsComponent.prototype, "deleteLabel", void 0);
1030
- __decorate([
1031
- Input("fileNameLabel")
1032
- ], EqpAttachmentsComponent.prototype, "fileNameLabel", void 0);
1033
- __decorate([
1034
- Input("previewLabel")
1035
- ], EqpAttachmentsComponent.prototype, "previewLabel", void 0);
1036
- __decorate([
1037
- Input("uploadFileLabel")
1038
- ], EqpAttachmentsComponent.prototype, "uploadFileLabel", void 0);
1039
- __decorate([
1040
- Input("confirmLabel")
1041
- ], EqpAttachmentsComponent.prototype, "confirmLabel", void 0);
1042
- __decorate([
1043
- Input("abortLabel")
1044
- ], EqpAttachmentsComponent.prototype, "abortLabel", void 0);
1045
- __decorate([
1046
- Input("saveLabel")
1047
- ], EqpAttachmentsComponent.prototype, "saveLabel", void 0);
1048
- __decorate([
1049
- Input("exitLabel")
1050
- ], EqpAttachmentsComponent.prototype, "exitLabel", void 0);
1051
- __decorate([
1052
- Input("eqpTableSearchText")
1053
- ], EqpAttachmentsComponent.prototype, "eqpTableSearchText", void 0);
1054
- __decorate([
1055
- Input("deleteDialogTitle")
1056
- ], EqpAttachmentsComponent.prototype, "deleteDialogTitle", void 0);
1057
- __decorate([
1058
- Input("deleteDialogMessage")
1059
- ], EqpAttachmentsComponent.prototype, "deleteDialogMessage", void 0);
1060
- __decorate([
1061
- Input("noImageSelectedErrorMessage")
1062
- ], EqpAttachmentsComponent.prototype, "noImageSelectedErrorMessage", void 0);
1063
- __decorate([
1064
- Input("wrongTypeSelectedErrorMessage")
1065
- ], EqpAttachmentsComponent.prototype, "wrongTypeSelectedErrorMessage", void 0);
1066
- __decorate([
1067
- Input("videoPreviewErrorMessage")
1068
- ], EqpAttachmentsComponent.prototype, "videoPreviewErrorMessage", void 0);
1069
- __decorate([
1070
- Input("videoPreviewErrorMessage")
1071
- ], EqpAttachmentsComponent.prototype, "audioPreviewErrorMessage", void 0);
1072
- __decorate([
1073
- Output()
1074
- ], EqpAttachmentsComponent.prototype, "localEditedAttachments", void 0);
1075
- __decorate([
1076
- Output()
1077
- ], EqpAttachmentsComponent.prototype, "abortAddAttachment", void 0);
1078
- __decorate([
1079
- Output("downloadAttachment")
1080
- ], EqpAttachmentsComponent.prototype, "downloadAttachment", void 0);
1081
- __decorate([
1082
- Output("onDeleteAttachment")
1083
- ], EqpAttachmentsComponent.prototype, "onDeleteAttachment", void 0);
1084
- __decorate([
1085
- Output("onComponentLoaded")
1086
- ], EqpAttachmentsComponent.prototype, "onComponentLoaded", void 0);
1087
- __decorate([
1088
- ViewChild('dialogAddAttachment', { static: true })
1089
- ], EqpAttachmentsComponent.prototype, "dialogAddAttachment", void 0);
1090
- __decorate([
1091
- ViewChild('dialogAddMultipleAttachment', { static: true })
1092
- ], EqpAttachmentsComponent.prototype, "dialogAddMultipleAttachment", void 0);
1093
- __decorate([
1094
- ViewChild(ImageCropperComponent)
1095
- ], EqpAttachmentsComponent.prototype, "imageCropper", void 0);
1096
- __decorate([
1097
- ViewChild('imageInput')
1098
- ], EqpAttachmentsComponent.prototype, "imageInput", void 0);
1099
- __decorate([
1100
- ViewChild('attachmentTable', { static: false })
1101
- ], EqpAttachmentsComponent.prototype, "attachmentTable", void 0);
1102
- __decorate([
1103
- ViewChild('inlinePreviewTemplate', { static: true })
1104
- ], EqpAttachmentsComponent.prototype, "inlinePreviewTemplate", void 0);
1105
- __decorate([
1106
- ViewChild('dialogPreview', { static: true })
1107
- ], EqpAttachmentsComponent.prototype, "dialogPreview", void 0);
1108
- EqpAttachmentsComponent = __decorate([
1109
- Component({
1110
- selector: 'eqp-attachments',
1111
- template: "<!-- Se richiesta la gestione multipla mostra il pulsante di aggiunta e la tabella con l'elenco allegati -->\r\n<div *ngIf=\"multipleAttachment == true\">\r\n <mat-card [ngStyle]=\"{ 'box-shadow': showMatCard == false ? 'none' : null }\">\r\n <mat-card-header>\r\n <div class=\"col-md-6\">\r\n <div class=\"text-nowrap eqp-attachments-header-title\" *ngIf=\"showHeader == true\">\r\n {{headerTitle}}\r\n </div>\r\n </div>\r\n <div class=\"col-md-6 text-right\">\r\n <div class=\"row justify-content-end\">\r\n <!-- Template del button per l'aggiunta di un allegato -->\r\n <ng-container *ngTemplateOutlet=\"addAttachmentButton\"></ng-container>\r\n </div>\r\n </div>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <eqp-table #attachmentTable [createMatCard]=\"false\" #table [columns]=\"attachmentsColumns\"\r\n [isMultiLanguage]=\"isEqpTableMultiLanguage\" [data]=\"attachmentsList\"\r\n [paginatorVisible]=\"tablePaginatorVisible\" [matPaginatorSize]=\"tablePaginatorSize\"\r\n [emptyTableMessage]=\"emptyTableMessage\" [searchText]=\"eqpTableSearchText\">\r\n </eqp-table>\r\n </mat-card-content>\r\n </mat-card>\r\n</div>\r\n\r\n<!-- Se richiesta la gestione singola mostra il pulsante di caricamento di un singolo file -->\r\n<div *ngIf=\"multipleAttachment != true\">\r\n <!-- Template del button per l'aggiunta di un allegato -->\r\n <ng-container *ngTemplateOutlet=\"addAttachmentButton\"></ng-container>\r\n\r\n <button class=\"mb-2 mr-2 eqp-attachments-download-btn\" (click)=\"viewAttachment(attachmentsList[0])\" type=\"button\"\r\n mat-raised-button *ngIf=\"attachmentsList && attachmentsList.length > 0 && attachmentsList[0]\" color=\"primary\">\r\n <mat-icon *ngIf=\"attachmentsList[0].AttachmentType == AttachmentType.FILE\">download</mat-icon>\r\n <mat-icon *ngIf=\"attachmentsList[0].AttachmentType != AttachmentType.FILE\">open_in_new</mat-icon>\r\n {{attachmentsList[0].AttachmentType == AttachmentType.FILE ? downloadLabel : openLinkLabel}}\r\n </button>\r\n <button class=\"mb-2 mr-2 eqp-attachments-preview-btn\" (click)=\"openPreviewDialog(attachmentsList[0])\" type=\"button\"\r\n mat-raised-button color=\"primary\"\r\n *ngIf=\"attachmentsList && attachmentsList.length > 0 && attachmentsList[0] && (!attachmentsList[0].FileContentType || (!attachmentsList[0].FileContentType.startsWith('video') && !attachmentsList[0].FileContentType.startsWith('audio')))\">\r\n <mat-icon>visibility</mat-icon> {{previewLabel}}\r\n </button>\r\n <button class=\"mb-2 eqp-attachments-delete-btn\" (click)=\"deleteAttachment(attachmentsList[0])\" type=\"button\"\r\n mat-raised-button *ngIf=\"attachmentsList && attachmentsList.length > 0 && attachmentsList[0]\"\r\n [disabled]=\"isDisabled\">\r\n <mat-icon>delete</mat-icon> {{deleteLabel}}\r\n </button>\r\n\r\n <div class=\"row\" style=\"margin-top: 10px;\"\r\n *ngIf=\"attachmentsList.length > 0 && attachmentsList[0] && attachmentsList[0].FileDataBase64 && attachmentsList[0].IsImage == true\">\r\n <div class=\"col-sm-12\">\r\n <div class=\"single-attachment-inline-preview-container\">\r\n <img src=\"data:image/png;base64,{{attachmentsList[0].FileDataBase64}}\">\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"row\" *ngIf=\"attachmentsList.length > 0 && attachmentsList[0] && attachmentsList[0].IsImage != true\">\r\n <div class=\"col-sm-12\">\r\n <mat-form-field>\r\n <mat-label>{{fileNameLabel}}</mat-label>\r\n <input readonly matInput [(ngModel)]=\"attachmentsList[0].FileName\">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n\r\n\r\n<ng-template #dialogAddAttachment>\r\n <div class=\"container-fluid eqp-attachments-dialog-add-container\"\r\n style=\"max-height: 70vh !important; overflow-x: hidden; overflow-y: auto;\">\r\n <form [formGroup]=\"newAttachmentForm\" (ngSubmit)=\"confirmAddAttachment()\" *ngIf=\"newAttachmentForm\">\r\n <div class=\"row\">\r\n <div class=\"header-title-standard\"> {{addButtonLabel}} {{ newAttachment.AttachmentType ==\r\n attachmentType.FILE ?\r\n 'File' : 'Link'}} </div>\r\n </div>\r\n <div class=\"row\" style=\"margin-top: 20px;\">\r\n <div class=\"col-sm-12\" *ngIf=\"newAttachment.AttachmentType == attachmentType.FILE\">\r\n <input #imageInput style=\"display:none;\" id=\"file_attachment\"\r\n name=\"file_attachment\" type=\"file\" (change)=\"onFileInputChange($event)\"\r\n [accept]=\"acceptedFileTypes\" [multiple]=\"loadMultipleFiles\"/>\r\n <button (click)=\"imageInput.click()\" type=\"button\" style=\"margin-left: 10px;\" id=\"file_attachment\"\r\n mat-raised-button color=\"primary\" [disabled]=\"showCropImage == true\"\r\n class=\"mb-2 btn btn-primary eqp-attachments-upload-btn\" *ngIf=\"(loadMultipleFiles != true && !newAttachment.FileDataBase64) || (loadMultipleFiles == true && newMultipleAttachments && newMultipleAttachments.length == 0)\">\r\n <mat-icon>cloud_upload</mat-icon>\r\n {{uploadFileLabel}}\r\n </button>\r\n <button (click)=\"abortFile()\" type=\"button\" style=\"margin-left: 10px;\" mat-raised-button\r\n *ngIf=\"(loadMultipleFiles != true && newAttachment.FileDataBase64) || (loadMultipleFiles == true && newMultipleAttachments && newMultipleAttachments.length > 0)\" class=\"mb-2 eqp-attachments-delete-btn\">\r\n <mat-icon>delete</mat-icon> {{deleteLabel}}\r\n </button>\r\n </div>\r\n <div class=\"col-sm-12\" *ngIf=\"newAttachment.AttachmentType == 2 || (selectedFile && loadMultipleFiles != true)\">\r\n <mat-form-field style=\"width: 100%;\">\r\n <mat-label> {{fileNameLabel}} </mat-label>\r\n <input formControlName=\"name\" matInput [(ngModel)]=\"newAttachment.FileName\">\r\n </mat-form-field>\r\n </div>\r\n <div class=\"col-sm-12\" *ngIf=\"newAttachment.AttachmentType == 2\">\r\n <mat-form-field style=\"width: 100%;\">\r\n <mat-label> Link </mat-label>\r\n <input formControlName=\"path\" required matInput [(ngModel)]=\"newAttachment.FilePath\">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n\r\n <!-- Riporta l'elenco dei nomi dei file caricati contemporaneamente (visibile solo se loadMultipleFiles = TRUE e se ci sono realmente pi\u00F9 file senza link) -->\r\n <div class=\"row\" *ngIf=\"loadMultipleFiles == true && newMultipleAttachments && newMultipleAttachments.length > 0 && newMultipleAttachments[0].AttachmentType != attachmentType.LINK\">\r\n <div class=\"col-12\" *ngFor=\"let attach of newMultipleAttachments\">\r\n <mat-form-field style=\"width: 100%\">\r\n <mat-label> {{fileNameLabel}} </mat-label>\r\n <input disabled matInput [(ngModel)]=\"attach.FileName\" [ngModelOptions]=\"{standalone: true}\">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n\r\n <!-- Riporta la preview dell'immagine quando \u00E8 richiesto il caricamento MULTIPLO ma \u00E8 stata selezionata una sola immagine (quindi \u00E8 entrato in gioco anche il croppie) -->\r\n <div class=\"row\" *ngIf=\"loadMultipleFiles == true && showCropImage != true && newMultipleAttachments && newMultipleAttachments.length == 1 && newMultipleAttachments[0].IsImage == true\" style=\"margin-top: 10px;\">\r\n <div class=\"col-4\">\r\n <div class=\"single-attachment-inline-preview-container\">\r\n <img src=\"data:image/png;base64,{{newMultipleAttachments[0].FileDataBase64}}\">\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- Riporta la preview dell'immagine quando \u00E8 richiesto il caricamento SINGOLO ed \u00E8 stata selezionata un'immagine -->\r\n <div class=\"row\" *ngIf=\"loadMultipleFiles != true && showCropImage != true && newAttachment.FileDataBase64 && newAttachment.IsImage == true\" style=\"margin-top: 10px;\">\r\n <div class=\"col-4\">\r\n <div class=\"single-attachment-inline-preview-container\">\r\n <img src=\"data:image/png;base64,{{newAttachment.FileDataBase64}}\">\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- Richiama il template per le funzionalit\u00E0 del CROPPIE -->\r\n <ng-container [ngTemplateOutlet]=\"croppieTemplate\" [ngTemplateOutletContext]=\"{form: newAttachmentForm}\" *ngIf=\"showCropImage == true\"></ng-container>\r\n\r\n <div class=\"row mt-2\">\r\n <div class=\"col-sm-12 text-right\">\r\n <button class=\"btn btn-primary mat-raised-button eqp-attachments-save-btn mr-2\" type=\"submit\"\r\n [disabled]=\"showCropImage == true || (loadMultipleFiles != true && newAttachmentForm?.disabled == true) || disableSave()\">\r\n {{saveLabel}}\r\n </button>\r\n <button class=\"btn mat-raised-button eqp-attachments-exit-btn\" (click)=\"close()\"\r\n [disabled]=\"showCropImage == true\" type=\"button\">\r\n {{exitLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n </form>\r\n </div>\r\n</ng-template>\r\n\r\n<ng-template #inlinePreviewTemplate let-row=\"row\">\r\n <div class=\"inline-preview-container\" *ngIf=\"row.AttachmentType != AttachmentType.LINK && row.IsImage\" (click)=\"openPreviewDialog(row)\">\r\n <img src=\"data:image/png;base64,{{row.FileThumbnailBase64 ? row.FileThumbnailBase64 : row.FileDataBase64}}\">\r\n </div>\r\n <div class=\"inline-preview-container\" *ngIf=\"row.AttachmentType != AttachmentType.LINK && !row.IsImage\" (click)=\"openPreviewDialog(row)\">\r\n <i [ngClass]=\"getAttachmentIcon(row)\"></i>\r\n </div>\r\n</ng-template>\r\n\r\n\r\n<ng-template #dialogPreview>\r\n <div class=\"container-fluid\" style=\"max-height: 70vh !important;\" *ngIf=\"selectedAttachment\">\r\n <div class=\"row\">\r\n <div class=\"header-title-standard\">\r\n {{previewLabel}} {{ selectedAttachment?.AttachmentType == attachmentType.FILE ? 'File' : 'Link'}}\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mt-2\">\r\n <!-- ANTEPRIMA IMMAGINE -->\r\n <div class=\"col-12 text-center preview-container\" *ngIf=\"selectedAttachment.IsImage\">\r\n <img class=\"image-preview\"\r\n src=\"data:image/png;base64,{{selectedAttachment.FileDataBase64 ? selectedAttachment.FileDataBase64 : selectedAttachment.FileThumbnailBase64}}\">\r\n </div>\r\n\r\n <!-- ANTEPRIMA LINK -->\r\n <div class=\"col-12 preview-container\" *ngIf=\"!selectedAttachment.IsImage\">\r\n <iframe class=\"link-preview\" [src]=\"selectedAttachment.TrustedUrl\"\r\n [title]=\"selectedAttachment.FileName\"></iframe>\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mt-3\">\r\n <div class=\"col-sm-12 text-right\">\r\n <button class=\"btn btn-primary mat-raised-button eqp-attachments-save-btn mr-2\" type=\"submit\"\r\n (click)=\"viewAttachment(selectedAttachment)\"\r\n *ngIf=\"selectedAttachment.AttachmentType != AttachmentType.LINK\">\r\n {{downloadLabel}}\r\n </button>\r\n <button class=\"btn mat-raised-button eqp-attachments-exit-btn\" mat-dialog-close type=\"button\"\r\n (click)=\"selectedAttachment = null\">\r\n {{exitLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n</ng-template>\r\n\r\n\r\n<!-- TEMPLATE PER IL PULSANTE DI AGGIUNTA NUOVO ALLEGATO -->\r\n<ng-template #addAttachmentButton>\r\n\r\n <!-- \r\n Pulsanti per l'aggiunta di un file o un link. Ne viene visualizzato uno se:\r\n - gli allowedTypes sono stati specificati, nell'array ne \u00E8 presente uno solo, quello inserito \u00E8 AttachmentType.FILE (o AttachmentType.LINK) \r\n e sono nella gestione di pi\u00F9 allegati (multipleAttachment == true)\r\n OPPURE\r\n - gli allowedTypes sono stati specificati, nell'array ne \u00E8 presente uno solo, quello inserito \u00E8 AttachmentType.FILE (o AttachmentType.LINK) \r\n e sono nella gestione di un singolo allegato (multipleAttachment == true) e non ne \u00E8 ancora stato selezionato uno (ovvero attachmentsList non esiste o non ha elementi)\r\n -->\r\n <button class=\"btn btn-primary mb-4 mr-5 eqp-attachments-add-btn\" mat-raised-button color=\"primary\" type=\"button\"\r\n *ngIf=\"allowedTypes && allowedTypes.length == 1 && (multipleAttachment == true || (!attachmentsList || attachmentsList.length == 0 || (attachmentsList.length > 0 && !attachmentsList[0])))\"\r\n (click)=\"openModalAddAttachment(allowedTypes[0])\" [disabled]=\"isDisabled\">\r\n <!-- Per l'aggiunta dei file mostro un'icona diversa dall'aggiunta dei link -->\r\n <mat-icon *ngIf=\"allowedTypes[0] == 1\">cloud_upload</mat-icon>\r\n <i class=\"fas fa-link\" *ngIf=\"allowedTypes[0] == 2\"></i>\r\n <span style=\"margin-left: 10px;\">{{addButtonLabel}} {{allowedTypes[0] == 1 ? \"file\" : \"link\"}}</span>\r\n </button>\r\n\r\n\r\n <!-- Pulsante per aprire il menu per la scelta del tipo di Attachment da creare -->\r\n <button class=\"btn btn-primary mb-4 mr-5 eqp-attachments-add-btn\" mat-raised-button color=\"primary\" type=\"button\"\r\n [matMenuTriggerFor]=\"attachmentTypeMenu\" [disabled]=\"isDisabled\"\r\n *ngIf=\"allowedTypes && allowedTypes.length > 1 && (multipleAttachment == true || (!attachmentsList || attachmentsList.length == 0 || (attachmentsList.length > 0 && !attachmentsList[0])))\">\r\n <mat-icon *ngIf=\"multipleAttachment != true\">cloud_upload</mat-icon>\r\n <mat-icon *ngIf=\"multipleAttachment == true\">add</mat-icon>\r\n <span style=\"margin-left: 0px;\"> {{addButtonLabel}} </span>\r\n </button>\r\n <mat-menu #attachmentTypeMenu=\"matMenu\">\r\n <button mat-menu-item (click)=\"openModalAddAttachment(1)\" class=\"eqp-attachments-file-btn\">\r\n <i class=\"fas fa-file\"></i>\r\n <span style=\"margin-left: 10px;\">File</span>\r\n </button>\r\n <button mat-menu-item (click)=\"openModalAddAttachment(2)\" class=\"eqp-attachments-link-btn\">\r\n <i class=\"fas fa-link\"></i>\r\n <span style=\"margin-left: 10px;\">Link</span>\r\n </button>\r\n </mat-menu>\r\n</ng-template>\r\n\r\n\r\n<ng-template #croppieTemplate let-form=\"form\">\r\n <div class=\"row mt-2 mb-2\" [formGroup]=\"form\">\r\n <div class=\"col-md-12 d-flex align-items-center justify-content-center\">\r\n <span class=\"mr-1\">Max H(px):</span>\r\n <mat-form-field>\r\n <input formControlName=\"customHeight\" type=\"number\" matInput [(ngModel)]=\"customHeight\"\r\n (change)=\"onDimensionsChange('H')\">\r\n </mat-form-field>\r\n\r\n <span class=\"ml-2 mr-1\">Max W(px):</span>\r\n <mat-form-field>\r\n <input formControlName=\"customWidth\" type=\"number\" matInput [(ngModel)]=\"customWidth\"\r\n (change)=\"onDimensionsChange('W')\">\r\n </mat-form-field>\r\n\r\n <button class=\"btn btn-primary mat-raised-button ml-2\" (click)=\"restoreOriginalDimensions()\"\r\n [disabled]=\"customWidth == originalWidth && customHeight == originalHeight\">\r\n <mat-icon style=\"vertical-align: middle;\">replay</mat-icon>\r\n </button>\r\n </div>\r\n </div>\r\n <div class=\"row justify-content-center\">\r\n <div style=\"max-height: 450px; max-width: 450px;\">\r\n <image-cropper [imageChangedEvent]=\"imageChangedEvent\" [maintainAspectRatio]=\"false\"\r\n [autoCrop]=\"false\" [containWithinAspectRatio]=\"false\" [aspectRatio]=\"4/3\"\r\n [cropperMinWidth]=\"128\" [onlyScaleDown]=\"true\" [roundCropper]=\"false\" [canvasRotation]=\"0\"\r\n [transform]=\"transform\" [alignImage]=\"'left'\" format=\"png\" (imageCropped)=\"imageCropped($event)\"\r\n [resizeToWidth]=\"customWidth\" [resizeToHeight]=\"customHeight\">\r\n </image-cropper>\r\n </div>\r\n </div>\r\n <div class=\"row justify-content-center mt-2\">\r\n <div style=\"max-height: 450px; max-width: 450px;\">\r\n <button class=\"btn btn-primary mat-raised-button eqp-attachments-confirm-btn mr-2\" type=\"button\"\r\n (click)=\"confirmCrop()\">\r\n {{confirmLabel}}\r\n </button>\r\n <button class=\"btn mat-raised-button eqp-attachments-abort-btn\" type=\"button\" (click)=\"abortFile()\">\r\n {{abortLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n</ng-template>",
1112
- styles: [".eqp-attachments-header-title{font-weight:700;font-size:19px;line-height:24px;margin-bottom:auto}.single-attachment-inline-preview-container{max-height:400px;max-width:400px;display:flex;align-items:center}.single-attachment-inline-preview-container img{max-width:100%;max-height:120px}.inline-preview-container{max-height:100px;max-width:100px;display:flex;align-items:center;justify-content:center;width:100%;cursor:pointer}.inline-preview-container img{max-width:100%;max-height:100px}.inline-preview-container i{font-size:25px;margin:auto}.preview-container{max-height:60vh;max-width:100%}.preview-container .image-preview{max-width:100%;max-height:100%}.preview-container .link-preview{width:70vw;height:55vh}"]
1113
- })
1114
- ], EqpAttachmentsComponent);
1115
- return EqpAttachmentsComponent;
1116
- }());
1117
-
1118
- var MaterialModule = /** @class */ (function () {
1119
- function MaterialModule() {
1120
- }
1121
- MaterialModule = __decorate([
1122
- NgModule({
1123
- imports: [
1124
- MatCheckboxModule,
1125
- MatButtonModule,
1126
- MatInputModule,
1127
- MatAutocompleteModule,
1128
- MatDatepickerModule,
1129
- MatFormFieldModule,
1130
- MatRadioModule,
1131
- MatSelectModule,
1132
- MatSliderModule,
1133
- MatSlideToggleModule,
1134
- MatMenuModule,
1135
- MatSidenavModule,
1136
- MatToolbarModule,
1137
- MatListModule,
1138
- MatGridListModule,
1139
- MatCardModule,
1140
- MatStepperModule,
1141
- MatTabsModule,
1142
- MatExpansionModule,
1143
- MatButtonToggleModule,
1144
- MatChipsModule,
1145
- MatIconModule,
1146
- MatProgressSpinnerModule,
1147
- MatProgressBarModule,
1148
- MatDialogModule,
1149
- MatTooltipModule,
1150
- MatSnackBarModule,
1151
- MatTableModule,
1152
- MatSortModule,
1153
- MatPaginatorModule,
1154
- MatDatepickerModule,
1155
- MatNativeDateModule
1156
- ],
1157
- exports: [
1158
- MatCheckboxModule,
1159
- MatButtonModule,
1160
- MatInputModule,
1161
- MatAutocompleteModule,
1162
- MatDatepickerModule,
1163
- MatFormFieldModule,
1164
- MatRadioModule,
1165
- MatSelectModule,
1166
- MatSliderModule,
1167
- MatSlideToggleModule,
1168
- MatMenuModule,
1169
- MatSidenavModule,
1170
- MatToolbarModule,
1171
- MatListModule,
1172
- MatGridListModule,
1173
- MatCardModule,
1174
- MatStepperModule,
1175
- MatTabsModule,
1176
- MatExpansionModule,
1177
- MatButtonToggleModule,
1178
- MatChipsModule,
1179
- MatIconModule,
1180
- MatProgressSpinnerModule,
1181
- MatProgressBarModule,
1182
- MatDialogModule,
1183
- MatTooltipModule,
1184
- MatSnackBarModule,
1185
- MatTableModule,
1186
- MatSortModule,
1187
- MatPaginatorModule
1188
- ],
1189
- })
1190
- ], MaterialModule);
1191
- return MaterialModule;
1192
- }());
1193
-
1194
- var EqpAttachmentsModule = /** @class */ (function () {
1195
- function EqpAttachmentsModule() {
1196
- }
1197
- EqpAttachmentsModule = __decorate([
1198
- NgModule({
1199
- declarations: [EqpAttachmentsComponent],
1200
- imports: [
1201
- MaterialModule,
1202
- FormsModule,
1203
- CommonModule,
1204
- ReactiveFormsModule,
1205
- ImageCropperModule,
1206
- EqpTableModule
1207
- ],
1208
- exports: [EqpAttachmentsComponent]
1209
- })
1210
- ], EqpAttachmentsModule);
1211
- return EqpAttachmentsModule;
1212
- }());
1213
-
1214
- /*
1215
- * Public API Surface of eqp-attachments
1216
- */
1217
-
1218
- /**
1219
- * Generated bundle index. Do not edit.
1220
- */
1221
-
1222
- export { AttachmentHelperService, AttachmentType, EqpAttachmentDialogService, EqpAttachmentsComponent, EqpAttachmentsModule, ɵ0, MaterialModule as ɵa };
1223
- //# sourceMappingURL=eqproject-eqp-attachments.js.map