@eqproject/eqp-attachments 0.1.15 → 0.1.17

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.
@@ -1,13 +1,13 @@
1
1
  import { __decorate, __awaiter } from 'tslib';
2
+ import { HttpClient } from '@angular/common/http';
2
3
  import { ɵɵdefineInjectable, Injectable, EventEmitter, ChangeDetectorRef, Input, Output, ViewChild, Component, NgModule } from '@angular/core';
3
4
  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
5
  import { MatDialog, MatDialogModule } from '@angular/material/dialog';
8
- import Swal from 'sweetalert2';
9
6
  import { DomSanitizer } from '@angular/platform-browser';
10
- import { HttpClient } from '@angular/common/http';
7
+ import { TooltipPositionType, TypeColumn, EqpTableModule } from '@eqproject/eqp-table';
8
+ import imageCompression from 'browser-image-compression';
9
+ import { base64ToFile, ImageCropperComponent, ImageCropperModule } from 'ngx-image-cropper';
10
+ import Swal from 'sweetalert2';
11
11
  import { CommonModule } from '@angular/common';
12
12
  import { MatCheckboxModule } from '@angular/material/checkbox';
13
13
  import { MatButtonModule } from '@angular/material/button';
@@ -40,12 +40,6 @@ import { MatSortModule } from '@angular/material/sort';
40
40
  import { MatPaginatorModule } from '@angular/material/paginator';
41
41
  import { MatNativeDateModule } from '@angular/material/core';
42
42
 
43
- var AttachmentType;
44
- (function (AttachmentType) {
45
- AttachmentType[AttachmentType["FILE"] = 1] = "FILE";
46
- AttachmentType[AttachmentType["LINK"] = 2] = "LINK";
47
- })(AttachmentType || (AttachmentType = {}));
48
-
49
43
  let AttachmentHelperService = class AttachmentHelperService {
50
44
  constructor() {
51
45
  }
@@ -104,6 +98,12 @@ AttachmentHelperService = __decorate([
104
98
  })
105
99
  ], AttachmentHelperService);
106
100
 
101
+ var AttachmentType;
102
+ (function (AttachmentType) {
103
+ AttachmentType[AttachmentType["FILE"] = 1] = "FILE";
104
+ AttachmentType[AttachmentType["LINK"] = 2] = "LINK";
105
+ })(AttachmentType || (AttachmentType = {}));
106
+
107
107
  let EqpAttachmentDialogService = class EqpAttachmentDialogService {
108
108
  constructor() {
109
109
  }
@@ -203,11 +203,11 @@ EqpAttachmentDialogService = __decorate([
203
203
  })
204
204
  ], EqpAttachmentDialogService);
205
205
 
206
- const toBase64 = file => new Promise((resolve, reject) => {
206
+ const toBase64 = (file) => new Promise((resolve, reject) => {
207
207
  const reader = new FileReader();
208
208
  reader.readAsDataURL(file);
209
209
  reader.onload = () => resolve(reader.result.toString());
210
- reader.onerror = error => reject(error);
210
+ reader.onerror = (error) => reject(error);
211
211
  });
212
212
  const ɵ0 = toBase64;
213
213
  let EqpAttachmentsComponent = class EqpAttachmentsComponent {
@@ -287,7 +287,11 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
287
287
  /**
288
288
  * Opzioni per la compressione delle immagini caricate.
289
289
  */
290
- this.compressionOptions = { maxSizeMB: 0.5, maxWidthOrHeight: 1920, useWebWorker: true };
290
+ this.compressionOptions = {
291
+ maxSizeMB: 0.5,
292
+ maxWidthOrHeight: 1920,
293
+ useWebWorker: true
294
+ };
291
295
  /**
292
296
  * Array di AttachmentType che si possono aggiungere
293
297
  */
@@ -307,6 +311,10 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
307
311
  * per la tabella contenente l'elenco degli allegati
308
312
  */
309
313
  this.tablePaginatorSize = null;
314
+ /**
315
+ * Abilitare caricamento video
316
+ */
317
+ this.allowVideo = false;
310
318
  /**
311
319
  * Input per definire le label da usare nel componente
312
320
  */
@@ -347,6 +355,14 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
347
355
  * Evento di output che restituisce l'elemento eliminato prima che questo venga effettivamente rismosso dalla lista.
348
356
  */
349
357
  this.onDeleteAttachment = new EventEmitter();
358
+ /**
359
+ * Evento di output scatenato durante l'AfterViewInit del componente che restituisce l'istanza corrente del componente.
360
+ * Questo evento avvisa quando il componente è stato renderizzato, utile per esempio quando si vogliono aggiungere delle colonne
361
+ * alla visualizzazione con allegati multipli lasciando però quelle pre esistenti. Questo si può fare intervenendo sulla
362
+ * proprietà "attachmentsColumns" di questo componente tramite l'istanza passata come paramentro oppure tramite ViewChild
363
+ * dal componente che lo ospita.
364
+ */
365
+ this.onComponentLoaded = new EventEmitter();
350
366
  //#endregion
351
367
  //#region Proprietà per gestione caricamento nuovo allegato
352
368
  this.newAttachment = {};
@@ -357,8 +373,8 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
357
373
  this.showCropImage = false;
358
374
  //#endregion
359
375
  //#region Proprietà per gestione ridimensionamento file di tipo image
360
- this.imageChangedEvent = '';
361
- this.croppedImage = '';
376
+ this.imageChangedEvent = "";
377
+ this.croppedImage = "";
362
378
  this.transform = {};
363
379
  //#endregion
364
380
  this.AttachmentType = AttachmentType;
@@ -373,8 +389,8 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
373
389
  // Se non sono stati specificati i tipi da gestire ma è stato passato null o un array vuoto imposto i tipi di default.
374
390
  if (!this.allowedTypes || this.allowedTypes.length == 0)
375
391
  this.allowedTypes = [AttachmentType.FILE, AttachmentType.LINK];
376
- else if (this.allowedTypes.find(t => t != AttachmentType.FILE && t != AttachmentType.LINK)) {
377
- EqpAttachmentDialogService.Warning("Almeno uno degli AttachmentType selezionati nel parametro \"allowedTypes\" non esiste.");
392
+ else if (this.allowedTypes.find((t) => t != AttachmentType.FILE && t != AttachmentType.LINK)) {
393
+ EqpAttachmentDialogService.Warning('Almeno uno degli AttachmentType selezionati nel parametro "allowedTypes" non esiste.');
378
394
  this.allowedTypes = [AttachmentType.FILE, AttachmentType.LINK];
379
395
  }
380
396
  //Se è stata richiesta la gestione multipla degli allegati allora configura l'eqp-table
@@ -385,12 +401,15 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
385
401
  this.attachmentsList = new Array();
386
402
  this.checkAttachmentImage();
387
403
  }
404
+ ngAfterViewInit() {
405
+ this.onComponentLoaded.emit(this);
406
+ }
388
407
  reloadData() {
389
408
  if (this.attachmentTable)
390
409
  this.attachmentTable.reloadDatatable();
391
410
  }
392
411
  checkAttachmentImage() {
393
- this.attachmentsList.forEach(a => {
412
+ this.attachmentsList.forEach((a) => {
394
413
  a.IsImage = AttachmentHelperService.checkImageFromMimeType(a.FileContentType);
395
414
  });
396
415
  }
@@ -402,27 +421,45 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
402
421
  this.attachmentsColumns = [];
403
422
  if (this.disableAction != true) {
404
423
  this.attachmentsColumns.push({
405
- key: "action", display: "",
406
- type: TypeColumn.MenuAction, buttonMenuIcon: "more_vert", styles: { flex: "0 0 6%" },
424
+ key: "action",
425
+ display: "",
426
+ type: TypeColumn.MenuAction,
427
+ buttonMenuIcon: "more_vert",
428
+ styles: { flex: "0 0 6%" },
407
429
  actions: [
408
- { name: this.deleteLabel, icon: "delete", fn: (element, index, col) => this.deleteAttachment(element) },
409
- ],
430
+ { name: this.deleteLabel, icon: "delete", fn: (element, index, col) => this.deleteAttachment(element) }
431
+ ]
410
432
  });
411
433
  }
412
434
  let downloadColumn = {
413
- key: "attachment", display: "",
414
- type: TypeColumn.SimpleAction, styles: { flex: "0 0 6%" },
435
+ key: "attachment",
436
+ display: "",
437
+ type: TypeColumn.SimpleAction,
438
+ styles: { flex: "0 0 6%" },
415
439
  actions: [
416
440
  {
417
- name: '', fontawesome: true,
418
- icon: (element) => { return this.showInlinePreview ? (element.AttachmentType == AttachmentType.FILE ? "fas fa-cloud-download-alt" : "fas fa-external-link-alt") : this.getAttachmentIcon(element); },
441
+ name: "",
442
+ fontawesome: true,
443
+ icon: (element) => {
444
+ return this.showInlinePreview
445
+ ? element.AttachmentType == AttachmentType.FILE
446
+ ? "fas fa-cloud-download-alt"
447
+ : "fas fa-external-link-alt"
448
+ : this.getAttachmentIcon(element);
449
+ },
419
450
  fn: (element, col, elementIndex) => this.viewAttachment(element),
420
- tooltip: { tooltipText: (element) => { return element.AttachmentType == AttachmentType.FILE ? this.downloadLabel : this.openLinkLabel; }, tooltipPosition: this.downloadTooltipPosition }
421
- },
451
+ tooltip: {
452
+ tooltipText: (element) => {
453
+ return element.AttachmentType == AttachmentType.FILE ? this.downloadLabel : this.openLinkLabel;
454
+ },
455
+ tooltipPosition: this.downloadTooltipPosition
456
+ }
457
+ }
422
458
  ]
423
459
  };
424
460
  let inlinePreviewColumn = {
425
- key: "InlinePreview", display: this.previewLabel,
461
+ key: "InlinePreview",
462
+ display: this.previewLabel,
426
463
  type: TypeColumn.ExternalTemplate,
427
464
  externalTemplate: this.inlinePreviewTemplate,
428
465
  styles: { flex: "0 0 10%" }
@@ -464,7 +501,7 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
464
501
  */
465
502
  viewAttachment(attachment) {
466
503
  if (attachment.AttachmentType == AttachmentType.LINK) {
467
- window.open(attachment.FilePath, '_blank');
504
+ window.open(attachment.FilePath, "_blank");
468
505
  return;
469
506
  }
470
507
  if (attachment.FileDataBase64 && attachment.FileContentType && attachment.FileName) {
@@ -508,8 +545,8 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
508
545
  this.dialofRefAddAttachment = this.dialog.open(this.dialogAddAttachment, {
509
546
  disableClose: true,
510
547
  hasBackdrop: true,
511
- width: '60%',
512
- maxHeight: '80%'
548
+ width: "60%",
549
+ maxHeight: "80%"
513
550
  });
514
551
  }
515
552
  createAttachmentForm() {
@@ -547,7 +584,8 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
547
584
  }
548
585
  }
549
586
  else {
550
- return this.newMultipleAttachments.filter(p => (p.AttachmentType == AttachmentType.FILE && !p.FileDataBase64) || (p.AttachmentType == AttachmentType.LINK && !p.FilePath)).length > 0;
587
+ return (this.newMultipleAttachments.filter((p) => (p.AttachmentType == AttachmentType.FILE && !p.FileDataBase64) ||
588
+ (p.AttachmentType == AttachmentType.LINK && !p.FilePath)).length > 0);
551
589
  }
552
590
  }
553
591
  confirmAddAttachment() {
@@ -590,13 +628,19 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
590
628
  }
591
629
  if (this.getAttachmentEndpoint && this.selectedAttachment.IsImage && !this.selectedAttachment.FileDataBase64) {
592
630
  yield this.getAttachmentByID()
593
- .then((res) => { this.selectedAttachment.FileDataBase64 = res.FileDataBase64; })
594
- .catch((err) => { EqpAttachmentDialogService.Error(err); });
631
+ .then((res) => {
632
+ this.selectedAttachment.FileDataBase64 = res.FileDataBase64;
633
+ })
634
+ .catch((err) => {
635
+ EqpAttachmentDialogService.Error(err);
636
+ });
595
637
  }
596
638
  if (this.selectedAttachment.AttachmentType == AttachmentType.LINK) {
597
639
  this.selectedAttachment.TrustedUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.selectedAttachment.FilePath);
598
640
  }
599
- else if (this.selectedAttachment.IsImage && !this.selectedAttachment.FileDataBase64 && !this.selectedAttachment.FileThumbnailBase64) {
641
+ else if (this.selectedAttachment.IsImage &&
642
+ !this.selectedAttachment.FileDataBase64 &&
643
+ !this.selectedAttachment.FileThumbnailBase64) {
600
644
  EqpAttachmentDialogService.Info("Impossibile aprire l'anteprima dell'allegato, file mancante.");
601
645
  return;
602
646
  }
@@ -615,7 +659,7 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
615
659
  }
616
660
  this.dialog.open(this.dialogPreview, {
617
661
  disableClose: true,
618
- hasBackdrop: true,
662
+ hasBackdrop: true
619
663
  });
620
664
  });
621
665
  }
@@ -643,7 +687,7 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
643
687
  this.selectedFiles = event.target.files;
644
688
  if (!this.selectedFile)
645
689
  return;
646
- //Memorizza i dati per l'allegato
690
+ //Memorizza i dati per l'allegato
647
691
  this.newAttachment = yield this.createAttachmentFromUploadedFile(this.selectedFile, false);
648
692
  this.newMultipleAttachments = new Array();
649
693
  this.newMultipleAttachments.push(this.newAttachment);
@@ -654,7 +698,7 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
654
698
  if (this.loadMultipleFiles == true && [...event.target.files].length == 1)
655
699
  this.createAttachmentForm();
656
700
  //Verifica se il file caricato è un'immagine oppure no. Se è un immagine, prima di caricarla mostra il croppie per il resize.
657
- //Se non è un immagine allora genera il Base64
701
+ //Se non è un immagine allora genera il Base64
658
702
  if (this.newAttachment.IsImage == true) {
659
703
  this.getImageDimensions(event.target.files[0]);
660
704
  //Mostra il croppie e disabilita la form finchè non termina la modifica dell'immagine
@@ -698,11 +742,11 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
698
742
  createAttachmentFromUploadedFile(currentFile, getBase64 = true) {
699
743
  return __awaiter(this, void 0, void 0, function* () {
700
744
  let newAttachment = {};
701
- //Memorizza i dati per l'allegato
745
+ //Memorizza i dati per l'allegato
702
746
  newAttachment.AttachmentType = AttachmentType.FILE;
703
747
  newAttachment.FileContentType = currentFile.type;
704
748
  newAttachment.FileName = currentFile.name;
705
- newAttachment.FileExtension = currentFile.name.substr(currentFile.name.lastIndexOf('.') + 1);
749
+ newAttachment.FileExtension = currentFile.name.substr(currentFile.name.lastIndexOf(".") + 1);
706
750
  newAttachment.IsImage = AttachmentHelperService.checkImageFromMimeType(currentFile.type);
707
751
  if (getBase64 == true) {
708
752
  let base64Result = yield this.getBase64FromFile(currentFile);
@@ -742,9 +786,11 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
742
786
  * @returns
743
787
  */
744
788
  checkAcceptedFiles() {
745
- if ((this.loadMultipleFiles != true && this.selectedFile.type.startsWith("video"))
746
- || (this.loadMultipleFiles == true && [...this.selectedFiles].filter(p => p.type.startsWith("video")).length > 0))
747
- return false;
789
+ if (!this.allowVideo) {
790
+ if ((this.loadMultipleFiles != true && this.selectedFile.type.startsWith("video")) ||
791
+ (this.loadMultipleFiles == true && [...this.selectedFiles].filter((p) => p.type.startsWith("video")).length > 0))
792
+ return false;
793
+ }
748
794
  if (this.acceptedFileTypes == "*")
749
795
  return true;
750
796
  //Verifica che i tipi del file (o dei file) caricati siano coerenti con quelli accettati dalla direttiva
@@ -752,15 +798,15 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
752
798
  if (this.loadMultipleFiles != true)
753
799
  accepted = this.acceptedFileTypes.includes(this.selectedFile.type);
754
800
  else {
755
- let uploadedFileTypes = [...this.selectedFiles].map(p => p.type);
756
- uploadedFileTypes.forEach(type => {
801
+ let uploadedFileTypes = [...this.selectedFiles].map((p) => p.type);
802
+ uploadedFileTypes.forEach((type) => {
757
803
  if (!this.acceptedFileTypes.includes(type))
758
804
  accepted = false;
759
805
  });
760
806
  }
761
807
  //Questo controllo permette di gestire le casistiche per cui vengono indicati come tipi validi, ad esempio, 'image/*'
762
808
  if (!accepted && this.loadMultipleFiles != true) {
763
- for (let t of this.acceptedFileTypes.split(",").filter(t => t.includes("*"))) {
809
+ for (let t of this.acceptedFileTypes.split(",").filter((t) => t.includes("*"))) {
764
810
  accepted = this.selectedFile.type.startsWith(t.split("*")[0]);
765
811
  if (accepted)
766
812
  break;
@@ -791,16 +837,16 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
791
837
  reader.onload = (e) => {
792
838
  const image = new Image();
793
839
  image.src = e.target.result;
794
- image.onload = rs => {
795
- this.originalHeight = rs.currentTarget['height'];
796
- this.originalWidth = rs.currentTarget['width'];
840
+ image.onload = (rs) => {
841
+ this.originalHeight = rs.currentTarget["height"];
842
+ this.originalWidth = rs.currentTarget["width"];
797
843
  if (this.originalWidth > 1280) {
798
844
  this.customWidth = 1280;
799
845
  this.customHeight = Math.round((1280 * this.originalHeight) / this.originalWidth);
800
846
  }
801
847
  else {
802
- this.customHeight = rs.currentTarget['height'];
803
- this.customWidth = rs.currentTarget['width'];
848
+ this.customHeight = rs.currentTarget["height"];
849
+ this.customWidth = rs.currentTarget["width"];
804
850
  }
805
851
  };
806
852
  };
@@ -829,18 +875,18 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
829
875
  /**
830
876
  * Comprime l'immagine passando come parametri le options create nell'oggetto sopra, e il file dal reader principale
831
877
  */
832
- imageCompression(file, options).then((fileCompressed => {
878
+ imageCompression(file, options).then((fileCompressed) => {
833
879
  let fileReader = new FileReader();
834
880
  //Faccio la push di ogni file all'interno dell'array di file dell'item da mandare al server
835
881
  fileReader.onload = function () {
836
882
  let resultReader = fileReader.result;
837
- var marker = ';base64,';
883
+ var marker = ";base64,";
838
884
  self.newAttachment.FileDataBase64 = resultReader.substring(resultReader.indexOf(marker) + marker.length);
839
885
  self.showCropImage = false;
840
886
  self.newAttachmentForm.enable();
841
887
  };
842
888
  fileReader.readAsDataURL(fileCompressed);
843
- }));
889
+ });
844
890
  }
845
891
  confirmCrop() {
846
892
  this.imageCropper.crop();
@@ -849,9 +895,9 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
849
895
  * Annulla la selezione del file, svuotando l'input e resettando tutte le proprietà dell'IAttachmentDTO
850
896
  */
851
897
  abortFile() {
852
- this.imageChangedEvent = '';
898
+ this.imageChangedEvent = "";
853
899
  if (this.imageInput)
854
- this.imageInput.nativeElement.value = '';
900
+ this.imageInput.nativeElement.value = "";
855
901
  this.selectedFile = null;
856
902
  this.selectedFiles = null;
857
903
  this.showCropImage = false;
@@ -934,6 +980,9 @@ __decorate([
934
980
  __decorate([
935
981
  Input("tablePaginatorSize")
936
982
  ], EqpAttachmentsComponent.prototype, "tablePaginatorSize", void 0);
983
+ __decorate([
984
+ Input("allowVideo")
985
+ ], EqpAttachmentsComponent.prototype, "allowVideo", void 0);
937
986
  __decorate([
938
987
  Input("downloadTooltipPosition")
939
988
  ], EqpAttachmentsComponent.prototype, "downloadTooltipPosition", void 0);
@@ -1004,29 +1053,32 @@ __decorate([
1004
1053
  Output("onDeleteAttachment")
1005
1054
  ], EqpAttachmentsComponent.prototype, "onDeleteAttachment", void 0);
1006
1055
  __decorate([
1007
- ViewChild('dialogAddAttachment', { static: true })
1056
+ Output("onComponentLoaded")
1057
+ ], EqpAttachmentsComponent.prototype, "onComponentLoaded", void 0);
1058
+ __decorate([
1059
+ ViewChild("dialogAddAttachment", { static: true })
1008
1060
  ], EqpAttachmentsComponent.prototype, "dialogAddAttachment", void 0);
1009
1061
  __decorate([
1010
- ViewChild('dialogAddMultipleAttachment', { static: true })
1062
+ ViewChild("dialogAddMultipleAttachment", { static: true })
1011
1063
  ], EqpAttachmentsComponent.prototype, "dialogAddMultipleAttachment", void 0);
1012
1064
  __decorate([
1013
1065
  ViewChild(ImageCropperComponent)
1014
1066
  ], EqpAttachmentsComponent.prototype, "imageCropper", void 0);
1015
1067
  __decorate([
1016
- ViewChild('imageInput')
1068
+ ViewChild("imageInput")
1017
1069
  ], EqpAttachmentsComponent.prototype, "imageInput", void 0);
1018
1070
  __decorate([
1019
- ViewChild('attachmentTable', { static: false })
1071
+ ViewChild("attachmentTable", { static: false })
1020
1072
  ], EqpAttachmentsComponent.prototype, "attachmentTable", void 0);
1021
1073
  __decorate([
1022
- ViewChild('inlinePreviewTemplate', { static: true })
1074
+ ViewChild("inlinePreviewTemplate", { static: true })
1023
1075
  ], EqpAttachmentsComponent.prototype, "inlinePreviewTemplate", void 0);
1024
1076
  __decorate([
1025
- ViewChild('dialogPreview', { static: true })
1077
+ ViewChild("dialogPreview", { static: true })
1026
1078
  ], EqpAttachmentsComponent.prototype, "dialogPreview", void 0);
1027
1079
  EqpAttachmentsComponent = __decorate([
1028
1080
  Component({
1029
- selector: 'eqp-attachments',
1081
+ selector: "eqp-attachments",
1030
1082
  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>",
1031
1083
  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}"]
1032
1084
  })