@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, __generator, __spread, __values } 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
  var AttachmentHelperService = /** @class */ (function () {
50
44
  function AttachmentHelperService() {
51
45
  }
@@ -105,6 +99,12 @@ var AttachmentHelperService = /** @class */ (function () {
105
99
  return AttachmentHelperService;
106
100
  }());
107
101
 
102
+ var AttachmentType;
103
+ (function (AttachmentType) {
104
+ AttachmentType[AttachmentType["FILE"] = 1] = "FILE";
105
+ AttachmentType[AttachmentType["LINK"] = 2] = "LINK";
106
+ })(AttachmentType || (AttachmentType = {}));
107
+
108
108
  var EqpAttachmentDialogService = /** @class */ (function () {
109
109
  function EqpAttachmentDialogService() {
110
110
  }
@@ -213,12 +213,14 @@ var EqpAttachmentDialogService = /** @class */ (function () {
213
213
  return EqpAttachmentDialogService;
214
214
  }());
215
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
- }); };
216
+ var toBase64 = function (file) {
217
+ return new Promise(function (resolve, reject) {
218
+ var reader = new FileReader();
219
+ reader.readAsDataURL(file);
220
+ reader.onload = function () { return resolve(reader.result.toString()); };
221
+ reader.onerror = function (error) { return reject(error); };
222
+ });
223
+ };
222
224
  var ɵ0 = toBase64;
223
225
  var EqpAttachmentsComponent = /** @class */ (function () {
224
226
  function EqpAttachmentsComponent(dialog, formBuilder, sanitizer, http, cd) {
@@ -297,7 +299,11 @@ var EqpAttachmentsComponent = /** @class */ (function () {
297
299
  /**
298
300
  * Opzioni per la compressione delle immagini caricate.
299
301
  */
300
- this.compressionOptions = { maxSizeMB: 0.5, maxWidthOrHeight: 1920, useWebWorker: true };
302
+ this.compressionOptions = {
303
+ maxSizeMB: 0.5,
304
+ maxWidthOrHeight: 1920,
305
+ useWebWorker: true
306
+ };
301
307
  /**
302
308
  * Array di AttachmentType che si possono aggiungere
303
309
  */
@@ -317,6 +323,10 @@ var EqpAttachmentsComponent = /** @class */ (function () {
317
323
  * per la tabella contenente l'elenco degli allegati
318
324
  */
319
325
  this.tablePaginatorSize = null;
326
+ /**
327
+ * Abilitare caricamento video
328
+ */
329
+ this.allowVideo = false;
320
330
  /**
321
331
  * Input per definire le label da usare nel componente
322
332
  */
@@ -357,6 +367,14 @@ var EqpAttachmentsComponent = /** @class */ (function () {
357
367
  * Evento di output che restituisce l'elemento eliminato prima che questo venga effettivamente rismosso dalla lista.
358
368
  */
359
369
  this.onDeleteAttachment = new EventEmitter();
370
+ /**
371
+ * Evento di output scatenato durante l'AfterViewInit del componente che restituisce l'istanza corrente del componente.
372
+ * Questo evento avvisa quando il componente è stato renderizzato, utile per esempio quando si vogliono aggiungere delle colonne
373
+ * alla visualizzazione con allegati multipli lasciando però quelle pre esistenti. Questo si può fare intervenendo sulla
374
+ * proprietà "attachmentsColumns" di questo componente tramite l'istanza passata come paramentro oppure tramite ViewChild
375
+ * dal componente che lo ospita.
376
+ */
377
+ this.onComponentLoaded = new EventEmitter();
360
378
  //#endregion
361
379
  //#region Proprietà per gestione caricamento nuovo allegato
362
380
  this.newAttachment = {};
@@ -367,8 +385,8 @@ var EqpAttachmentsComponent = /** @class */ (function () {
367
385
  this.showCropImage = false;
368
386
  //#endregion
369
387
  //#region Proprietà per gestione ridimensionamento file di tipo image
370
- this.imageChangedEvent = '';
371
- this.croppedImage = '';
388
+ this.imageChangedEvent = "";
389
+ this.croppedImage = "";
372
390
  this.transform = {};
373
391
  //#endregion
374
392
  this.AttachmentType = AttachmentType;
@@ -384,7 +402,7 @@ var EqpAttachmentsComponent = /** @class */ (function () {
384
402
  if (!this.allowedTypes || this.allowedTypes.length == 0)
385
403
  this.allowedTypes = [AttachmentType.FILE, AttachmentType.LINK];
386
404
  else if (this.allowedTypes.find(function (t) { return t != AttachmentType.FILE && t != AttachmentType.LINK; })) {
387
- EqpAttachmentDialogService.Warning("Almeno uno degli AttachmentType selezionati nel parametro \"allowedTypes\" non esiste.");
405
+ EqpAttachmentDialogService.Warning('Almeno uno degli AttachmentType selezionati nel parametro "allowedTypes" non esiste.');
388
406
  this.allowedTypes = [AttachmentType.FILE, AttachmentType.LINK];
389
407
  }
390
408
  //Se è stata richiesta la gestione multipla degli allegati allora configura l'eqp-table
@@ -395,6 +413,9 @@ var EqpAttachmentsComponent = /** @class */ (function () {
395
413
  this.attachmentsList = new Array();
396
414
  this.checkAttachmentImage();
397
415
  };
416
+ EqpAttachmentsComponent.prototype.ngAfterViewInit = function () {
417
+ this.onComponentLoaded.emit(this);
418
+ };
398
419
  EqpAttachmentsComponent.prototype.reloadData = function () {
399
420
  if (this.attachmentTable)
400
421
  this.attachmentTable.reloadDatatable();
@@ -413,27 +434,45 @@ var EqpAttachmentsComponent = /** @class */ (function () {
413
434
  this.attachmentsColumns = [];
414
435
  if (this.disableAction != true) {
415
436
  this.attachmentsColumns.push({
416
- key: "action", display: "",
417
- type: TypeColumn.MenuAction, buttonMenuIcon: "more_vert", styles: { flex: "0 0 6%" },
437
+ key: "action",
438
+ display: "",
439
+ type: TypeColumn.MenuAction,
440
+ buttonMenuIcon: "more_vert",
441
+ styles: { flex: "0 0 6%" },
418
442
  actions: [
419
- { name: this.deleteLabel, icon: "delete", fn: function (element, index, col) { return _this.deleteAttachment(element); } },
420
- ],
443
+ { name: this.deleteLabel, icon: "delete", fn: function (element, index, col) { return _this.deleteAttachment(element); } }
444
+ ]
421
445
  });
422
446
  }
423
447
  var downloadColumn = {
424
- key: "attachment", display: "",
425
- type: TypeColumn.SimpleAction, styles: { flex: "0 0 6%" },
448
+ key: "attachment",
449
+ display: "",
450
+ type: TypeColumn.SimpleAction,
451
+ styles: { flex: "0 0 6%" },
426
452
  actions: [
427
453
  {
428
- name: '', fontawesome: true,
429
- icon: function (element) { return _this.showInlinePreview ? (element.AttachmentType == AttachmentType.FILE ? "fas fa-cloud-download-alt" : "fas fa-external-link-alt") : _this.getAttachmentIcon(element); },
454
+ name: "",
455
+ fontawesome: true,
456
+ icon: function (element) {
457
+ return _this.showInlinePreview
458
+ ? element.AttachmentType == AttachmentType.FILE
459
+ ? "fas fa-cloud-download-alt"
460
+ : "fas fa-external-link-alt"
461
+ : _this.getAttachmentIcon(element);
462
+ },
430
463
  fn: function (element, col, elementIndex) { return _this.viewAttachment(element); },
431
- tooltip: { tooltipText: function (element) { return element.AttachmentType == AttachmentType.FILE ? _this.downloadLabel : _this.openLinkLabel; }, tooltipPosition: this.downloadTooltipPosition }
432
- },
464
+ tooltip: {
465
+ tooltipText: function (element) {
466
+ return element.AttachmentType == AttachmentType.FILE ? _this.downloadLabel : _this.openLinkLabel;
467
+ },
468
+ tooltipPosition: this.downloadTooltipPosition
469
+ }
470
+ }
433
471
  ]
434
472
  };
435
473
  var inlinePreviewColumn = {
436
- key: "InlinePreview", display: this.previewLabel,
474
+ key: "InlinePreview",
475
+ display: this.previewLabel,
437
476
  type: TypeColumn.ExternalTemplate,
438
477
  externalTemplate: this.inlinePreviewTemplate,
439
478
  styles: { flex: "0 0 10%" }
@@ -476,7 +515,7 @@ var EqpAttachmentsComponent = /** @class */ (function () {
476
515
  */
477
516
  EqpAttachmentsComponent.prototype.viewAttachment = function (attachment) {
478
517
  if (attachment.AttachmentType == AttachmentType.LINK) {
479
- window.open(attachment.FilePath, '_blank');
518
+ window.open(attachment.FilePath, "_blank");
480
519
  return;
481
520
  }
482
521
  if (attachment.FileDataBase64 && attachment.FileContentType && attachment.FileName) {
@@ -520,8 +559,8 @@ var EqpAttachmentsComponent = /** @class */ (function () {
520
559
  this.dialofRefAddAttachment = this.dialog.open(this.dialogAddAttachment, {
521
560
  disableClose: true,
522
561
  hasBackdrop: true,
523
- width: '60%',
524
- maxHeight: '80%'
562
+ width: "60%",
563
+ maxHeight: "80%"
525
564
  });
526
565
  };
527
566
  EqpAttachmentsComponent.prototype.createAttachmentForm = function () {
@@ -560,7 +599,10 @@ var EqpAttachmentsComponent = /** @class */ (function () {
560
599
  }
561
600
  }
562
601
  else {
563
- return this.newMultipleAttachments.filter(function (p) { return (p.AttachmentType == AttachmentType.FILE && !p.FileDataBase64) || (p.AttachmentType == AttachmentType.LINK && !p.FilePath); }).length > 0;
602
+ return (this.newMultipleAttachments.filter(function (p) {
603
+ return (p.AttachmentType == AttachmentType.FILE && !p.FileDataBase64) ||
604
+ (p.AttachmentType == AttachmentType.LINK && !p.FilePath);
605
+ }).length > 0);
564
606
  }
565
607
  };
566
608
  EqpAttachmentsComponent.prototype.confirmAddAttachment = function () {
@@ -607,8 +649,12 @@ var EqpAttachmentsComponent = /** @class */ (function () {
607
649
  }
608
650
  if (!(this.getAttachmentEndpoint && this.selectedAttachment.IsImage && !this.selectedAttachment.FileDataBase64)) return [3 /*break*/, 2];
609
651
  return [4 /*yield*/, this.getAttachmentByID()
610
- .then(function (res) { _this.selectedAttachment.FileDataBase64 = res.FileDataBase64; })
611
- .catch(function (err) { EqpAttachmentDialogService.Error(err); })];
652
+ .then(function (res) {
653
+ _this.selectedAttachment.FileDataBase64 = res.FileDataBase64;
654
+ })
655
+ .catch(function (err) {
656
+ EqpAttachmentDialogService.Error(err);
657
+ })];
612
658
  case 1:
613
659
  _a.sent();
614
660
  _a.label = 2;
@@ -616,7 +662,9 @@ var EqpAttachmentsComponent = /** @class */ (function () {
616
662
  if (this.selectedAttachment.AttachmentType == AttachmentType.LINK) {
617
663
  this.selectedAttachment.TrustedUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.selectedAttachment.FilePath);
618
664
  }
619
- else if (this.selectedAttachment.IsImage && !this.selectedAttachment.FileDataBase64 && !this.selectedAttachment.FileThumbnailBase64) {
665
+ else if (this.selectedAttachment.IsImage &&
666
+ !this.selectedAttachment.FileDataBase64 &&
667
+ !this.selectedAttachment.FileThumbnailBase64) {
620
668
  EqpAttachmentDialogService.Info("Impossibile aprire l'anteprima dell'allegato, file mancante.");
621
669
  return [2 /*return*/];
622
670
  }
@@ -635,7 +683,7 @@ var EqpAttachmentsComponent = /** @class */ (function () {
635
683
  }
636
684
  this.dialog.open(this.dialogPreview, {
637
685
  disableClose: true,
638
- hasBackdrop: true,
686
+ hasBackdrop: true
639
687
  });
640
688
  return [2 /*return*/];
641
689
  }
@@ -670,11 +718,11 @@ var EqpAttachmentsComponent = /** @class */ (function () {
670
718
  this.selectedFiles = event.target.files;
671
719
  if (!this.selectedFile)
672
720
  return [2 /*return*/];
673
- //Memorizza i dati per l'allegato
721
+ //Memorizza i dati per l'allegato
674
722
  _a = this;
675
723
  return [4 /*yield*/, this.createAttachmentFromUploadedFile(this.selectedFile, false)];
676
724
  case 1:
677
- //Memorizza i dati per l'allegato
725
+ //Memorizza i dati per l'allegato
678
726
  _a.newAttachment = _b.sent();
679
727
  this.newMultipleAttachments = new Array();
680
728
  this.newMultipleAttachments.push(this.newAttachment);
@@ -742,11 +790,11 @@ var EqpAttachmentsComponent = /** @class */ (function () {
742
790
  switch (_a.label) {
743
791
  case 0:
744
792
  newAttachment = {};
745
- //Memorizza i dati per l'allegato
793
+ //Memorizza i dati per l'allegato
746
794
  newAttachment.AttachmentType = AttachmentType.FILE;
747
795
  newAttachment.FileContentType = currentFile.type;
748
796
  newAttachment.FileName = currentFile.name;
749
- newAttachment.FileExtension = currentFile.name.substr(currentFile.name.lastIndexOf('.') + 1);
797
+ newAttachment.FileExtension = currentFile.name.substr(currentFile.name.lastIndexOf(".") + 1);
750
798
  newAttachment.IsImage = AttachmentHelperService.checkImageFromMimeType(currentFile.type);
751
799
  if (!(getBase64 == true)) return [3 /*break*/, 2];
752
800
  return [4 /*yield*/, this.getBase64FromFile(currentFile)];
@@ -799,9 +847,11 @@ var EqpAttachmentsComponent = /** @class */ (function () {
799
847
  EqpAttachmentsComponent.prototype.checkAcceptedFiles = function () {
800
848
  var e_1, _a;
801
849
  var _this = this;
802
- if ((this.loadMultipleFiles != true && this.selectedFile.type.startsWith("video"))
803
- || (this.loadMultipleFiles == true && __spread(this.selectedFiles).filter(function (p) { return p.type.startsWith("video"); }).length > 0))
804
- return false;
850
+ if (!this.allowVideo) {
851
+ if ((this.loadMultipleFiles != true && this.selectedFile.type.startsWith("video")) ||
852
+ (this.loadMultipleFiles == true && __spread(this.selectedFiles).filter(function (p) { return p.type.startsWith("video"); }).length > 0))
853
+ return false;
854
+ }
805
855
  if (this.acceptedFileTypes == "*")
806
856
  return true;
807
857
  //Verifica che i tipi del file (o dei file) caricati siano coerenti con quelli accettati dalla direttiva
@@ -860,15 +910,15 @@ var EqpAttachmentsComponent = /** @class */ (function () {
860
910
  var image = new Image();
861
911
  image.src = e.target.result;
862
912
  image.onload = function (rs) {
863
- _this.originalHeight = rs.currentTarget['height'];
864
- _this.originalWidth = rs.currentTarget['width'];
913
+ _this.originalHeight = rs.currentTarget["height"];
914
+ _this.originalWidth = rs.currentTarget["width"];
865
915
  if (_this.originalWidth > 1280) {
866
916
  _this.customWidth = 1280;
867
917
  _this.customHeight = Math.round((1280 * _this.originalHeight) / _this.originalWidth);
868
918
  }
869
919
  else {
870
- _this.customHeight = rs.currentTarget['height'];
871
- _this.customWidth = rs.currentTarget['width'];
920
+ _this.customHeight = rs.currentTarget["height"];
921
+ _this.customWidth = rs.currentTarget["width"];
872
922
  }
873
923
  };
874
924
  };
@@ -897,18 +947,18 @@ var EqpAttachmentsComponent = /** @class */ (function () {
897
947
  /**
898
948
  * Comprime l'immagine passando come parametri le options create nell'oggetto sopra, e il file dal reader principale
899
949
  */
900
- imageCompression(file, options).then((function (fileCompressed) {
950
+ imageCompression(file, options).then(function (fileCompressed) {
901
951
  var fileReader = new FileReader();
902
952
  //Faccio la push di ogni file all'interno dell'array di file dell'item da mandare al server
903
953
  fileReader.onload = function () {
904
954
  var resultReader = fileReader.result;
905
- var marker = ';base64,';
955
+ var marker = ";base64,";
906
956
  self.newAttachment.FileDataBase64 = resultReader.substring(resultReader.indexOf(marker) + marker.length);
907
957
  self.showCropImage = false;
908
958
  self.newAttachmentForm.enable();
909
959
  };
910
960
  fileReader.readAsDataURL(fileCompressed);
911
- }));
961
+ });
912
962
  };
913
963
  EqpAttachmentsComponent.prototype.confirmCrop = function () {
914
964
  this.imageCropper.crop();
@@ -917,9 +967,9 @@ var EqpAttachmentsComponent = /** @class */ (function () {
917
967
  * Annulla la selezione del file, svuotando l'input e resettando tutte le proprietà dell'IAttachmentDTO
918
968
  */
919
969
  EqpAttachmentsComponent.prototype.abortFile = function () {
920
- this.imageChangedEvent = '';
970
+ this.imageChangedEvent = "";
921
971
  if (this.imageInput)
922
- this.imageInput.nativeElement.value = '';
972
+ this.imageInput.nativeElement.value = "";
923
973
  this.selectedFile = null;
924
974
  this.selectedFiles = null;
925
975
  this.showCropImage = false;
@@ -1001,6 +1051,9 @@ var EqpAttachmentsComponent = /** @class */ (function () {
1001
1051
  __decorate([
1002
1052
  Input("tablePaginatorSize")
1003
1053
  ], EqpAttachmentsComponent.prototype, "tablePaginatorSize", void 0);
1054
+ __decorate([
1055
+ Input("allowVideo")
1056
+ ], EqpAttachmentsComponent.prototype, "allowVideo", void 0);
1004
1057
  __decorate([
1005
1058
  Input("downloadTooltipPosition")
1006
1059
  ], EqpAttachmentsComponent.prototype, "downloadTooltipPosition", void 0);
@@ -1071,29 +1124,32 @@ var EqpAttachmentsComponent = /** @class */ (function () {
1071
1124
  Output("onDeleteAttachment")
1072
1125
  ], EqpAttachmentsComponent.prototype, "onDeleteAttachment", void 0);
1073
1126
  __decorate([
1074
- ViewChild('dialogAddAttachment', { static: true })
1127
+ Output("onComponentLoaded")
1128
+ ], EqpAttachmentsComponent.prototype, "onComponentLoaded", void 0);
1129
+ __decorate([
1130
+ ViewChild("dialogAddAttachment", { static: true })
1075
1131
  ], EqpAttachmentsComponent.prototype, "dialogAddAttachment", void 0);
1076
1132
  __decorate([
1077
- ViewChild('dialogAddMultipleAttachment', { static: true })
1133
+ ViewChild("dialogAddMultipleAttachment", { static: true })
1078
1134
  ], EqpAttachmentsComponent.prototype, "dialogAddMultipleAttachment", void 0);
1079
1135
  __decorate([
1080
1136
  ViewChild(ImageCropperComponent)
1081
1137
  ], EqpAttachmentsComponent.prototype, "imageCropper", void 0);
1082
1138
  __decorate([
1083
- ViewChild('imageInput')
1139
+ ViewChild("imageInput")
1084
1140
  ], EqpAttachmentsComponent.prototype, "imageInput", void 0);
1085
1141
  __decorate([
1086
- ViewChild('attachmentTable', { static: false })
1142
+ ViewChild("attachmentTable", { static: false })
1087
1143
  ], EqpAttachmentsComponent.prototype, "attachmentTable", void 0);
1088
1144
  __decorate([
1089
- ViewChild('inlinePreviewTemplate', { static: true })
1145
+ ViewChild("inlinePreviewTemplate", { static: true })
1090
1146
  ], EqpAttachmentsComponent.prototype, "inlinePreviewTemplate", void 0);
1091
1147
  __decorate([
1092
- ViewChild('dialogPreview', { static: true })
1148
+ ViewChild("dialogPreview", { static: true })
1093
1149
  ], EqpAttachmentsComponent.prototype, "dialogPreview", void 0);
1094
1150
  EqpAttachmentsComponent = __decorate([
1095
1151
  Component({
1096
- selector: 'eqp-attachments',
1152
+ selector: "eqp-attachments",
1097
1153
  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>",
1098
1154
  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}"]
1099
1155
  })