@eqproject/eqp-attachments 0.1.12 → 0.1.15
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.
- package/README.md +5 -0
- package/bundles/eqproject-eqp-attachments.umd.js +237 -56
- package/bundles/eqproject-eqp-attachments.umd.js.map +1 -1
- package/bundles/eqproject-eqp-attachments.umd.min.js +1 -1
- package/bundles/eqproject-eqp-attachments.umd.min.js.map +1 -1
- package/eqproject-eqp-attachments.metadata.json +1 -1
- package/esm2015/lib/eqp-attachments.component.js +226 -70
- package/esm5/lib/eqp-attachments.component.js +240 -59
- package/fesm2015/eqproject-eqp-attachments.js +225 -69
- package/fesm2015/eqproject-eqp-attachments.js.map +1 -1
- package/fesm5/eqproject-eqp-attachments.js +239 -58
- package/fesm5/eqproject-eqp-attachments.js.map +1 -1
- package/lib/eqp-attachments.component.d.ts +58 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -55,6 +55,7 @@ export class AppModule {}
|
|
|
55
55
|
| [attachmentsList] | `Array<IAttachmentDTO>` | `null` | no | Defines the initial array of attachments. If not passed it is instantiated as an empty array. Even in case `multipleAttachment` is set to FALSE you need to pass the eventual attachment as an Array. |
|
|
56
56
|
| [showMatCard] | `boolean` | `true` | no | If TRUE applies the `box-shadow` style of the mat-card |
|
|
57
57
|
| [multipleAttachment] | `boolean` | `true` | no | Defines how many attachments the directive needs to handle. If TRUE shows an eqp-table containing the values of `attachmentsList` with the possibility to download/open or delete any row. With any other value it shows only a button to upload one IAttachmentDTO (link or file). |
|
|
58
|
+
| [loadMultipleFiles] | `boolean` | `false` | no | If it assumes the value TRUE then it will be possible to load multiple files at the same time. This feature is active ONLY if you manage multiple attachments, so if the `multipleAttachment` input takes on the value TRUE, otherwise it is always disabled. |
|
|
58
59
|
| [attachmentsColumns] | `Array<ConfigColumn>` | `null` | no | Has effect only if `[multipleAttachment]="true"`. Columns configuration for the eqp-table showing the list of IAttachmentDTO.
|
|
59
60
|
| [emptyTableMessage] | `string` | `"Nessun dato trovato"` | no | Has effect only if `[multipleAttachment]="true"`. Sets the message to show if the eqp-table contains no elements. |
|
|
60
61
|
| [allowOnlyImages] | `boolean` | `false` | no | If TRUE allows the user to upload only image files of the following types: `["image/bmp", "image/gif", "image/jpeg", "image/tiff", "image/png"]`. If FALSE the user can upload a file of any type. |
|
|
@@ -83,12 +84,16 @@ export class AppModule {}
|
|
|
83
84
|
| [wrongTypeSelectedErrorMessage] | `string` | `"Non è possibile caricare il file selezionato."` | no | Sets the error dialog message when user tries to upload a not allowed file . |
|
|
84
85
|
| [videoPreviewErrorMessage] | `string` | `Impossibile aprire l'anteprima di un file video.` | no | Sets the warning dialog merrage when the user tries to open the preview of a video file. |
|
|
85
86
|
| [audioPreviewErrorMessage] | `string` | `Impossibile aprire l'anteprima di un file audio.` | no | Sets the warning dialog merrage when the user tries to open the preview of an audio file. |
|
|
87
|
+
| [isEqpTableMultiLanguage] | `boolean` | `false` | no | It allows you to establish whether the eqp-table containing the list of attachments uses multilanguage or not |
|
|
88
|
+
| [tablePaginatorVisible] | `boolean` | `true` | no | It allows you to establish, in the case of multiple attachments management, whether the table containing the list of attachments must be paged or not (default: true) |
|
|
89
|
+
| [tablePaginatorSize] | `number` | `null` | no | In case of managing multiple attachments, it allows you to establish the default page size for the table containing the list of attachments (default: null) |
|
|
86
90
|
|
|
87
91
|
|
|
88
92
|
### Outputs
|
|
89
93
|
| Output | Event Arguments | Required | Description |
|
|
90
94
|
| ------------- | ------------- | ------------- | ------------- |
|
|
91
95
|
| (localEditedAttachments) | `EventEmitter<Array<IAttachmentDTO>>` | no | Invoked when an IAttachmentDTO is created and added to `attachmentsList` or is deleted. It always return an Array of IAttachmentDTO, even if `[multipleAttachment]="true"`. |
|
|
96
|
+
| (abortAddAttachment) | `EventEmitter<any>` | no | Event triggered by pressing the EXIT button of the file upload modal. |
|
|
92
97
|
| (downloadAttachment) | EventEmitter<IAttachmentDTO> | no | Invoked when the user tries to download an IAttachmentDTO with at least one of the following properties not defined: `"FileDataBase64", "FileContentType", "FileName"`. It returns the user selected object. |
|
|
93
98
|
| (onDeleteAttachment) | `EventEmitter<IAttachmentDTO>` | no | Invoked when an IAttachmentDTO is deleted from `attachmentsList`. It returns the deleted element. |
|
|
94
99
|
|
|
@@ -406,11 +406,12 @@
|
|
|
406
406
|
}); };
|
|
407
407
|
var ɵ0 = toBase64;
|
|
408
408
|
var EqpAttachmentsComponent = /** @class */ (function () {
|
|
409
|
-
function EqpAttachmentsComponent(dialog, formBuilder, sanitizer, http) {
|
|
409
|
+
function EqpAttachmentsComponent(dialog, formBuilder, sanitizer, http, cd) {
|
|
410
410
|
this.dialog = dialog;
|
|
411
411
|
this.formBuilder = formBuilder;
|
|
412
412
|
this.sanitizer = sanitizer;
|
|
413
413
|
this.http = http;
|
|
414
|
+
this.cd = cd;
|
|
414
415
|
//#region @Input del componente
|
|
415
416
|
/**
|
|
416
417
|
* Se TRUE allora nasconde la colonna per le azioni sull'allegato (nel caso "multipleAttachment" è TRUE).
|
|
@@ -437,6 +438,11 @@
|
|
|
437
438
|
* Se TRUE allora il componente mostra l'elenco di tutti gli allegati ricevuto nel parametro "attachmentsList".
|
|
438
439
|
*/
|
|
439
440
|
this.multipleAttachment = true;
|
|
441
|
+
/**
|
|
442
|
+
* Se assume il valore TRUE allora sarà possibile caricare più file per volta. Questa funzionalità è attiva
|
|
443
|
+
* SOLO se si gestiscono allegati multipli, quindi se l'input 'multipleAttachment' assume il valore TRUE, altrimenti è sempre disabilitata.
|
|
444
|
+
*/
|
|
445
|
+
this.loadMultipleFiles = false;
|
|
440
446
|
/**
|
|
441
447
|
* Configurazione delle colonne della eqp-table per la visualizzazione degli allegati (caso "multipleAttachment" è TRUE).
|
|
442
448
|
*/
|
|
@@ -482,9 +488,20 @@
|
|
|
482
488
|
*/
|
|
483
489
|
this.allowedTypes = [exports.AttachmentType.FILE, exports.AttachmentType.LINK];
|
|
484
490
|
/**
|
|
485
|
-
*
|
|
491
|
+
* Permette di stabilire se la eqp-table contenente l'elenco degli allegati utilizza
|
|
492
|
+
* il multilingua oppure no
|
|
486
493
|
*/
|
|
487
494
|
this.isEqpTableMultiLanguage = false;
|
|
495
|
+
/**
|
|
496
|
+
* Permette di stabilire, in caso di gestione allegati multipli, se la tabella contenente l'elenco
|
|
497
|
+
* degli allegati deve essere paginata oppure no
|
|
498
|
+
*/
|
|
499
|
+
this.tablePaginatorVisible = true;
|
|
500
|
+
/**
|
|
501
|
+
* In caso di gestione allegati multipli, permette di stabilire la dimensione pagina di default
|
|
502
|
+
* per la tabella contenente l'elenco degli allegati
|
|
503
|
+
*/
|
|
504
|
+
this.tablePaginatorSize = null;
|
|
488
505
|
/**
|
|
489
506
|
* Input per definire le label da usare nel componente
|
|
490
507
|
*/
|
|
@@ -513,6 +530,10 @@
|
|
|
513
530
|
* Restituisce la lista aggiornata degli allegati.
|
|
514
531
|
*/
|
|
515
532
|
this.localEditedAttachments = new core.EventEmitter();
|
|
533
|
+
/**
|
|
534
|
+
* Evento scatenato alla pressione del pulsante ESCI della modale di caricamento file.
|
|
535
|
+
*/
|
|
536
|
+
this.abortAddAttachment = new core.EventEmitter();
|
|
516
537
|
/**
|
|
517
538
|
* Evento di output che restituisce l'IAttachmentDTO selezionato per il download nel caso FileDataBase64, FileContentType o FileName non fossero specificati.
|
|
518
539
|
*/
|
|
@@ -524,8 +545,10 @@
|
|
|
524
545
|
//#endregion
|
|
525
546
|
//#region Proprietà per gestione caricamento nuovo allegato
|
|
526
547
|
this.newAttachment = {};
|
|
548
|
+
this.newMultipleAttachments = [];
|
|
527
549
|
this.attachmentType = exports.AttachmentType;
|
|
528
550
|
this.selectedFile = null;
|
|
551
|
+
this.selectedFiles = null;
|
|
529
552
|
this.showCropImage = false;
|
|
530
553
|
//#endregion
|
|
531
554
|
//#region Proprietà per gestione ridimensionamento file di tipo image
|
|
@@ -556,8 +579,6 @@
|
|
|
556
579
|
if (this.attachmentsList == null)
|
|
557
580
|
this.attachmentsList = new Array();
|
|
558
581
|
this.checkAttachmentImage();
|
|
559
|
-
// if (!this.compressionOptions || !this.compressionOptions.maxSizeMB || !this.compressionOptions.maxWidthOrHeight)
|
|
560
|
-
// this.compressionOptions = { maxSizeMB: 0.5, maxWidthOrHeight: 1920, useWebWorker: true };
|
|
561
582
|
};
|
|
562
583
|
EqpAttachmentsComponent.prototype.reloadData = function () {
|
|
563
584
|
if (this.attachmentTable)
|
|
@@ -670,9 +691,25 @@
|
|
|
670
691
|
* Apre la modale per la definizione dei parametri del nuovo file
|
|
671
692
|
*/
|
|
672
693
|
EqpAttachmentsComponent.prototype.openModalAddAttachment = function (attachmentType) {
|
|
694
|
+
//Se è stato richiesto il caricamento di un LINK o è impostato il caricamento di FILE SINGOLO allora apre la modale per
|
|
695
|
+
//il caricamento singolo del file altrimenti apre quella per il caricamento multiplo
|
|
696
|
+
// if (attachmentType == AttachmentType.LINK || (attachmentType == AttachmentType.FILE && this.loadMultipleFiles != true)) {
|
|
673
697
|
this.newAttachment = {};
|
|
674
698
|
this.newAttachment.IsImage = false;
|
|
675
699
|
this.newAttachment.AttachmentType = attachmentType;
|
|
700
|
+
this.newMultipleAttachments = new Array();
|
|
701
|
+
if (attachmentType == exports.AttachmentType.LINK)
|
|
702
|
+
this.newMultipleAttachments.push(this.newAttachment);
|
|
703
|
+
this.createAttachmentForm();
|
|
704
|
+
//Apre la modale
|
|
705
|
+
this.dialofRefAddAttachment = this.dialog.open(this.dialogAddAttachment, {
|
|
706
|
+
disableClose: true,
|
|
707
|
+
hasBackdrop: true,
|
|
708
|
+
width: '60%',
|
|
709
|
+
maxHeight: '80%'
|
|
710
|
+
});
|
|
711
|
+
};
|
|
712
|
+
EqpAttachmentsComponent.prototype.createAttachmentForm = function () {
|
|
676
713
|
//Crea la form per la validazione dei campi
|
|
677
714
|
this.newAttachmentForm = this.formBuilder.group({
|
|
678
715
|
type: [this.newAttachment.AttachmentType, forms.Validators.required],
|
|
@@ -681,19 +718,17 @@
|
|
|
681
718
|
customHeight: [this.customHeight],
|
|
682
719
|
customWidth: [this.customWidth]
|
|
683
720
|
});
|
|
684
|
-
//Apre la modale
|
|
685
|
-
this.dialofRefAddAttachment = this.dialog.open(this.dialogAddAttachment, {
|
|
686
|
-
disableClose: true,
|
|
687
|
-
hasBackdrop: true,
|
|
688
|
-
width: '60%',
|
|
689
|
-
maxHeight: '80%'
|
|
690
|
-
});
|
|
691
721
|
};
|
|
692
|
-
EqpAttachmentsComponent.prototype.close = function () {
|
|
722
|
+
EqpAttachmentsComponent.prototype.close = function (emitCloseEvent) {
|
|
723
|
+
if (emitCloseEvent === void 0) { emitCloseEvent = true; }
|
|
693
724
|
this.newAttachment = {};
|
|
725
|
+
this.newMultipleAttachments = new Array();
|
|
694
726
|
this.abortFile();
|
|
695
|
-
this.newAttachmentForm
|
|
727
|
+
if (this.newAttachmentForm)
|
|
728
|
+
this.newAttachmentForm.reset();
|
|
696
729
|
this.dialofRefAddAttachment.close();
|
|
730
|
+
if (emitCloseEvent == true && this.abortAddAttachment)
|
|
731
|
+
this.abortAddAttachment.emit();
|
|
697
732
|
};
|
|
698
733
|
/**
|
|
699
734
|
* In base al tipo di allegato controlla se disabilitare o meno il pulsante per salvare.
|
|
@@ -701,23 +736,37 @@
|
|
|
701
736
|
* @returns
|
|
702
737
|
*/
|
|
703
738
|
EqpAttachmentsComponent.prototype.disableSave = function () {
|
|
704
|
-
if (this.
|
|
705
|
-
|
|
739
|
+
if (this.loadMultipleFiles != true) {
|
|
740
|
+
if (this.newAttachment.AttachmentType == exports.AttachmentType.FILE) {
|
|
741
|
+
return !this.newAttachment.FileDataBase64;
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
return !this.newAttachment.FilePath;
|
|
745
|
+
}
|
|
706
746
|
}
|
|
707
747
|
else {
|
|
708
|
-
return
|
|
748
|
+
return this.newMultipleAttachments.filter(function (p) { return (p.AttachmentType == exports.AttachmentType.FILE && !p.FileDataBase64) || (p.AttachmentType == exports.AttachmentType.LINK && !p.FilePath); }).length > 0;
|
|
709
749
|
}
|
|
710
750
|
};
|
|
711
751
|
EqpAttachmentsComponent.prototype.confirmAddAttachment = function () {
|
|
712
|
-
if (this.
|
|
713
|
-
this.newAttachment.
|
|
714
|
-
|
|
715
|
-
this.attachmentsList
|
|
716
|
-
|
|
752
|
+
if (this.loadMultipleFiles != true) {
|
|
753
|
+
if (this.newAttachment.AttachmentType == exports.AttachmentType.LINK && !this.newAttachment.FileName)
|
|
754
|
+
this.newAttachment.FileName = this.newAttachment.FilePath;
|
|
755
|
+
if (this.attachmentsList == null)
|
|
756
|
+
this.attachmentsList = new Array();
|
|
757
|
+
this.attachmentsList.push(this.newAttachment);
|
|
758
|
+
}
|
|
759
|
+
else {
|
|
760
|
+
if (this.newMultipleAttachments == null || this.newMultipleAttachments.length == 0)
|
|
761
|
+
return;
|
|
762
|
+
if (this.attachmentsList == null)
|
|
763
|
+
this.attachmentsList = new Array();
|
|
764
|
+
this.attachmentsList = this.attachmentsList.concat(this.newMultipleAttachments);
|
|
765
|
+
}
|
|
717
766
|
if (this.attachmentTable)
|
|
718
767
|
this.attachmentTable.reloadDatatable();
|
|
719
768
|
this.localEditedAttachments.emit(this.attachmentsList);
|
|
720
|
-
this.
|
|
769
|
+
this.close(false);
|
|
721
770
|
};
|
|
722
771
|
/**
|
|
723
772
|
* Apre il dialog per l'anteprima dell'allegato selezionato.
|
|
@@ -787,36 +836,39 @@
|
|
|
787
836
|
};
|
|
788
837
|
//#region Gestione caricamento file
|
|
789
838
|
/**
|
|
790
|
-
*
|
|
791
|
-
*
|
|
839
|
+
* Evento scatenato alla selezione del file (o dei file).
|
|
840
|
+
* 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
|
|
841
|
+
* mostrare le funzionalità del croppie (per ritagliare l'immagine) oppure no.
|
|
842
|
+
* Se il file caricato non è un immagine allora genera direttamente il base64 e lo associa all'allegato da salvare.
|
|
843
|
+
* Se invece il caricamento dei file è MULTIPLO e sono presenti più file allora esegue le stesse operazioni ignorando però il contrllo
|
|
844
|
+
* immagine per il croppie (in caso di caricamento multiplo le funzionalità del croppie sono disabilitate).
|
|
792
845
|
*/
|
|
793
846
|
EqpAttachmentsComponent.prototype.onFileInputChange = function (event) {
|
|
794
847
|
return __awaiter(this, void 0, void 0, function () {
|
|
795
|
-
var
|
|
796
|
-
return __generator(this, function (
|
|
797
|
-
switch (
|
|
848
|
+
var _a, checkOnlyImage, base64Result, i, newAttachment, checkOnlyImage;
|
|
849
|
+
return __generator(this, function (_b) {
|
|
850
|
+
switch (_b.label) {
|
|
798
851
|
case 0:
|
|
799
852
|
this.showCropImage = false;
|
|
853
|
+
if (!(__spread(event.target.files).length == 1 || this.loadMultipleFiles != true)) return [3 /*break*/, 5];
|
|
800
854
|
this.selectedFile = event.target.files[0];
|
|
855
|
+
this.selectedFiles = event.target.files;
|
|
801
856
|
if (!this.selectedFile)
|
|
802
857
|
return [2 /*return*/];
|
|
803
858
|
//Memorizza i dati per l'allegato
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
}
|
|
814
|
-
else if (!this.checkAcceptedFiles()) {
|
|
815
|
-
EqpAttachmentDialogService.Error(this.wrongTypeSelectedErrorMessage);
|
|
816
|
-
this.abortFile();
|
|
859
|
+
_a = this;
|
|
860
|
+
return [4 /*yield*/, this.createAttachmentFromUploadedFile(this.selectedFile, false)];
|
|
861
|
+
case 1:
|
|
862
|
+
//Memorizza i dati per l'allegato
|
|
863
|
+
_a.newAttachment = _b.sent();
|
|
864
|
+
this.newMultipleAttachments = new Array();
|
|
865
|
+
this.newMultipleAttachments.push(this.newAttachment);
|
|
866
|
+
checkOnlyImage = this.checkAllowOnlyImageFile(this.newAttachment);
|
|
867
|
+
if (checkOnlyImage == false)
|
|
817
868
|
return [2 /*return*/];
|
|
818
|
-
|
|
819
|
-
|
|
869
|
+
if (this.loadMultipleFiles == true && __spread(event.target.files).length == 1)
|
|
870
|
+
this.createAttachmentForm();
|
|
871
|
+
if (!(this.newAttachment.IsImage == true)) return [3 /*break*/, 2];
|
|
820
872
|
this.getImageDimensions(event.target.files[0]);
|
|
821
873
|
//Mostra il croppie e disabilita la form finchè non termina la modifica dell'immagine
|
|
822
874
|
this.newAttachmentForm.disable();
|
|
@@ -824,23 +876,103 @@
|
|
|
824
876
|
this.newAttachmentForm.controls["customHeight"].enable();
|
|
825
877
|
this.showCropImage = true;
|
|
826
878
|
this.imageChangedEvent = event;
|
|
827
|
-
return [3 /*break*/,
|
|
828
|
-
case 1:
|
|
829
|
-
this.showCropImage = false;
|
|
830
|
-
return [4 /*yield*/, toBase64(this.selectedFile)];
|
|
879
|
+
return [3 /*break*/, 4];
|
|
831
880
|
case 2:
|
|
881
|
+
this.showCropImage = false;
|
|
882
|
+
return [4 /*yield*/, this.getBase64FromFile(this.selectedFile)];
|
|
883
|
+
case 3:
|
|
884
|
+
base64Result = _b.sent();
|
|
885
|
+
this.newAttachment.FileDataBase64 = base64Result.Base64File;
|
|
886
|
+
this.newAttachment.FileContentType = base64Result.ContentType;
|
|
887
|
+
_b.label = 4;
|
|
888
|
+
case 4: return [3 /*break*/, 9];
|
|
889
|
+
case 5:
|
|
890
|
+
this.selectedFiles = event.target.files;
|
|
891
|
+
if (!this.selectedFiles || this.selectedFiles.length == 0)
|
|
892
|
+
return [2 /*return*/];
|
|
893
|
+
this.newMultipleAttachments = new Array();
|
|
894
|
+
i = 0;
|
|
895
|
+
_b.label = 6;
|
|
896
|
+
case 6:
|
|
897
|
+
if (!(i < this.selectedFiles.length)) return [3 /*break*/, 9];
|
|
898
|
+
return [4 /*yield*/, this.createAttachmentFromUploadedFile(this.selectedFiles[i], true)];
|
|
899
|
+
case 7:
|
|
900
|
+
newAttachment = _b.sent();
|
|
901
|
+
checkOnlyImage = this.checkAllowOnlyImageFile(newAttachment);
|
|
902
|
+
if (checkOnlyImage == false)
|
|
903
|
+
return [2 /*return*/];
|
|
904
|
+
this.newMultipleAttachments.push(newAttachment);
|
|
905
|
+
_b.label = 8;
|
|
906
|
+
case 8:
|
|
907
|
+
i++;
|
|
908
|
+
return [3 /*break*/, 6];
|
|
909
|
+
case 9: return [2 /*return*/];
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
});
|
|
913
|
+
};
|
|
914
|
+
/**
|
|
915
|
+
* A partire dal FILE ricevuto in input ricostruisce l'oggetto IAttachmentDTO e lo restituisce.
|
|
916
|
+
* Se il parametro getBase64 viene passato a TRUE allora, sempre a partire dal file,genera il base64 e
|
|
917
|
+
* ricava il ContentType da associare all'oggetto IAttachmentDTO da restituire
|
|
918
|
+
* @param currentFile Oggetto FILE da processare
|
|
919
|
+
* @param getBase64 Se TRUE allora calcola base64 e ContentType del file passato in input
|
|
920
|
+
* @returns Restituisce un oggetto di tipo IAttachmentDTO
|
|
921
|
+
*/
|
|
922
|
+
EqpAttachmentsComponent.prototype.createAttachmentFromUploadedFile = function (currentFile, getBase64) {
|
|
923
|
+
if (getBase64 === void 0) { getBase64 = true; }
|
|
924
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
925
|
+
var newAttachment, base64Result;
|
|
926
|
+
return __generator(this, function (_a) {
|
|
927
|
+
switch (_a.label) {
|
|
928
|
+
case 0:
|
|
929
|
+
newAttachment = {};
|
|
930
|
+
//Memorizza i dati per l'allegato
|
|
931
|
+
newAttachment.AttachmentType = exports.AttachmentType.FILE;
|
|
932
|
+
newAttachment.FileContentType = currentFile.type;
|
|
933
|
+
newAttachment.FileName = currentFile.name;
|
|
934
|
+
newAttachment.FileExtension = currentFile.name.substr(currentFile.name.lastIndexOf('.') + 1);
|
|
935
|
+
newAttachment.IsImage = AttachmentHelperService.checkImageFromMimeType(currentFile.type);
|
|
936
|
+
if (!(getBase64 == true)) return [3 /*break*/, 2];
|
|
937
|
+
return [4 /*yield*/, this.getBase64FromFile(currentFile)];
|
|
938
|
+
case 1:
|
|
939
|
+
base64Result = _a.sent();
|
|
940
|
+
newAttachment.FileDataBase64 = base64Result.Base64File;
|
|
941
|
+
newAttachment.FileContentType = base64Result.ContentType;
|
|
942
|
+
_a.label = 2;
|
|
943
|
+
case 2: return [2 /*return*/, newAttachment];
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
});
|
|
947
|
+
};
|
|
948
|
+
/**
|
|
949
|
+
* A partire dal file passato in input restituisce un oggetto
|
|
950
|
+
* contenente il base64 del file e il suo contentType
|
|
951
|
+
* @param currentFile Oggetto File da cui estrapolare base64 e contentType
|
|
952
|
+
* @returns Restituisce un oggetto avente le proprietà Base64File e ContentType
|
|
953
|
+
*/
|
|
954
|
+
EqpAttachmentsComponent.prototype.getBase64FromFile = function (currentFile) {
|
|
955
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
956
|
+
var base64File, contentType, result;
|
|
957
|
+
return __generator(this, function (_a) {
|
|
958
|
+
switch (_a.label) {
|
|
959
|
+
case 0: return [4 /*yield*/, toBase64(currentFile)];
|
|
960
|
+
case 1:
|
|
832
961
|
base64File = _a.sent();
|
|
962
|
+
contentType = null;
|
|
833
963
|
if (base64File) {
|
|
834
964
|
// Loris 20/01/2022: PROBLEMA - Quando eseguo l'upload di un file .sql non viene salvato/scaricato correttamente.
|
|
835
965
|
// Questo succede perchè non viene popolato il FileContentType. Per risolvere il problema
|
|
836
966
|
// faccio un controllo e se non esiste il FileContentType allora lo recupero dal base64 ottenuto.
|
|
837
|
-
|
|
967
|
+
contentType = base64File.split(",")[0].split(":")[1].split(";")[0];
|
|
838
968
|
// Un altro metodo per leggere il ccontent type del file è tramite una regular expression:
|
|
839
|
-
|
|
840
|
-
this.newAttachment.FileDataBase64 = base64File.split(",")[1];
|
|
969
|
+
base64File = base64File.split(",")[1];
|
|
841
970
|
}
|
|
842
|
-
|
|
843
|
-
|
|
971
|
+
result = {
|
|
972
|
+
Base64File: base64File,
|
|
973
|
+
ContentType: contentType
|
|
974
|
+
};
|
|
975
|
+
return [2 /*return*/, result];
|
|
844
976
|
}
|
|
845
977
|
});
|
|
846
978
|
});
|
|
@@ -851,12 +983,25 @@
|
|
|
851
983
|
*/
|
|
852
984
|
EqpAttachmentsComponent.prototype.checkAcceptedFiles = function () {
|
|
853
985
|
var e_1, _a;
|
|
854
|
-
|
|
986
|
+
var _this = this;
|
|
987
|
+
if ((this.loadMultipleFiles != true && this.selectedFile.type.startsWith("video"))
|
|
988
|
+
|| (this.loadMultipleFiles == true && __spread(this.selectedFiles).filter(function (p) { return p.type.startsWith("video"); }).length > 0))
|
|
855
989
|
return false;
|
|
856
990
|
if (this.acceptedFileTypes == "*")
|
|
857
991
|
return true;
|
|
858
|
-
|
|
859
|
-
|
|
992
|
+
//Verifica che i tipi del file (o dei file) caricati siano coerenti con quelli accettati dalla direttiva
|
|
993
|
+
var accepted = true;
|
|
994
|
+
if (this.loadMultipleFiles != true)
|
|
995
|
+
accepted = this.acceptedFileTypes.includes(this.selectedFile.type);
|
|
996
|
+
else {
|
|
997
|
+
var uploadedFileTypes = __spread(this.selectedFiles).map(function (p) { return p.type; });
|
|
998
|
+
uploadedFileTypes.forEach(function (type) {
|
|
999
|
+
if (!_this.acceptedFileTypes.includes(type))
|
|
1000
|
+
accepted = false;
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
//Questo controllo permette di gestire le casistiche per cui vengono indicati come tipi validi, ad esempio, 'image/*'
|
|
1004
|
+
if (!accepted && this.loadMultipleFiles != true) {
|
|
860
1005
|
try {
|
|
861
1006
|
for (var _b = __values(this.acceptedFileTypes.split(",").filter(function (t) { return t.includes("*"); })), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
862
1007
|
var t = _c.value;
|
|
@@ -875,6 +1020,24 @@
|
|
|
875
1020
|
}
|
|
876
1021
|
return accepted;
|
|
877
1022
|
};
|
|
1023
|
+
/**
|
|
1024
|
+
* Se eqp-attachments è stata configurata per il caricamento delle sole immagini allora verifica che il file passato in
|
|
1025
|
+
* input sia effettivamente un immagine o no.
|
|
1026
|
+
* Se il controllo va a buon fine restituisce TRUE altrimenti mostra un messaggio d'errore e restituisce FALSE
|
|
1027
|
+
*/
|
|
1028
|
+
EqpAttachmentsComponent.prototype.checkAllowOnlyImageFile = function (newAttachment) {
|
|
1029
|
+
if (this.allowOnlyImages == true && newAttachment.IsImage != true) {
|
|
1030
|
+
EqpAttachmentDialogService.Error(this.noImageSelectedErrorMessage);
|
|
1031
|
+
this.abortFile();
|
|
1032
|
+
return false;
|
|
1033
|
+
}
|
|
1034
|
+
else if (!this.checkAcceptedFiles()) {
|
|
1035
|
+
EqpAttachmentDialogService.Error(this.wrongTypeSelectedErrorMessage);
|
|
1036
|
+
this.abortFile();
|
|
1037
|
+
return false;
|
|
1038
|
+
}
|
|
1039
|
+
return true;
|
|
1040
|
+
};
|
|
878
1041
|
EqpAttachmentsComponent.prototype.getImageDimensions = function (img) {
|
|
879
1042
|
var _this = this;
|
|
880
1043
|
var reader = new FileReader();
|
|
@@ -943,12 +1106,14 @@
|
|
|
943
1106
|
if (this.imageInput)
|
|
944
1107
|
this.imageInput.nativeElement.value = '';
|
|
945
1108
|
this.selectedFile = null;
|
|
1109
|
+
this.selectedFiles = null;
|
|
946
1110
|
this.showCropImage = false;
|
|
947
1111
|
this.newAttachment.IsImage = false;
|
|
948
1112
|
this.newAttachment.FileDataBase64 = null;
|
|
949
1113
|
this.newAttachment.FileName = null;
|
|
950
1114
|
this.newAttachment.FileExtension = null;
|
|
951
1115
|
this.newAttachment.FileContentType = null;
|
|
1116
|
+
this.newMultipleAttachments = new Array();
|
|
952
1117
|
this.customHeight = null;
|
|
953
1118
|
this.customWidth = null;
|
|
954
1119
|
this.originalHeight = null;
|
|
@@ -958,7 +1123,8 @@
|
|
|
958
1123
|
{ type: dialog.MatDialog },
|
|
959
1124
|
{ type: forms.FormBuilder },
|
|
960
1125
|
{ type: platformBrowser.DomSanitizer },
|
|
961
|
-
{ type: http.HttpClient }
|
|
1126
|
+
{ type: http.HttpClient },
|
|
1127
|
+
{ type: core.ChangeDetectorRef }
|
|
962
1128
|
]; };
|
|
963
1129
|
__decorate([
|
|
964
1130
|
core.Input("disableAction")
|
|
@@ -978,6 +1144,9 @@
|
|
|
978
1144
|
__decorate([
|
|
979
1145
|
core.Input("multipleAttachment")
|
|
980
1146
|
], EqpAttachmentsComponent.prototype, "multipleAttachment", void 0);
|
|
1147
|
+
__decorate([
|
|
1148
|
+
core.Input("loadMultipleFiles")
|
|
1149
|
+
], EqpAttachmentsComponent.prototype, "loadMultipleFiles", void 0);
|
|
981
1150
|
__decorate([
|
|
982
1151
|
core.Input("attachmentsColumns")
|
|
983
1152
|
], EqpAttachmentsComponent.prototype, "attachmentsColumns", void 0);
|
|
@@ -1011,6 +1180,12 @@
|
|
|
1011
1180
|
__decorate([
|
|
1012
1181
|
core.Input("isEqpTableMultiLanguage")
|
|
1013
1182
|
], EqpAttachmentsComponent.prototype, "isEqpTableMultiLanguage", void 0);
|
|
1183
|
+
__decorate([
|
|
1184
|
+
core.Input("tablePaginatorVisible")
|
|
1185
|
+
], EqpAttachmentsComponent.prototype, "tablePaginatorVisible", void 0);
|
|
1186
|
+
__decorate([
|
|
1187
|
+
core.Input("tablePaginatorSize")
|
|
1188
|
+
], EqpAttachmentsComponent.prototype, "tablePaginatorSize", void 0);
|
|
1014
1189
|
__decorate([
|
|
1015
1190
|
core.Input("downloadTooltipPosition")
|
|
1016
1191
|
], EqpAttachmentsComponent.prototype, "downloadTooltipPosition", void 0);
|
|
@@ -1071,6 +1246,9 @@
|
|
|
1071
1246
|
__decorate([
|
|
1072
1247
|
core.Output()
|
|
1073
1248
|
], EqpAttachmentsComponent.prototype, "localEditedAttachments", void 0);
|
|
1249
|
+
__decorate([
|
|
1250
|
+
core.Output()
|
|
1251
|
+
], EqpAttachmentsComponent.prototype, "abortAddAttachment", void 0);
|
|
1074
1252
|
__decorate([
|
|
1075
1253
|
core.Output("downloadAttachment")
|
|
1076
1254
|
], EqpAttachmentsComponent.prototype, "downloadAttachment", void 0);
|
|
@@ -1080,6 +1258,9 @@
|
|
|
1080
1258
|
__decorate([
|
|
1081
1259
|
core.ViewChild('dialogAddAttachment', { static: true })
|
|
1082
1260
|
], EqpAttachmentsComponent.prototype, "dialogAddAttachment", void 0);
|
|
1261
|
+
__decorate([
|
|
1262
|
+
core.ViewChild('dialogAddMultipleAttachment', { static: true })
|
|
1263
|
+
], EqpAttachmentsComponent.prototype, "dialogAddMultipleAttachment", void 0);
|
|
1083
1264
|
__decorate([
|
|
1084
1265
|
core.ViewChild(ngxImageCropper.ImageCropperComponent)
|
|
1085
1266
|
], EqpAttachmentsComponent.prototype, "imageCropper", void 0);
|
|
@@ -1098,7 +1279,7 @@
|
|
|
1098
1279
|
EqpAttachmentsComponent = __decorate([
|
|
1099
1280
|
core.Component({
|
|
1100
1281
|
selector: 'eqp-attachments',
|
|
1101
|
-
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\" [isMultiLanguage]=\"isEqpTableMultiLanguage\"\r\n [data]=\"attachmentsList\" [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\" name=\"file_attachment\" type=\"file\"\r\n (change)=\"onFileInputChange($event)\" [accept]=\"acceptedFileTypes\" />\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=\"!newAttachment.FileDataBase64\">\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=\"newAttachment.FileDataBase64\" 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\">\r\n <mat-form-field>\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>\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 <div class=\"row\"\r\n *ngIf=\"showCropImage != true && newAttachment.FileDataBase64 && newAttachment.IsImage == true\"\r\n 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 <div class=\"row mt-2 mb-2\" *ngIf=\"showCropImage == true\">\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\" *ngIf=\"showCropImage == true\">\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\" *ngIf=\"showCropImage == true\">\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\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 || 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\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.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.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>",
|
|
1282
|
+
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>",
|
|
1102
1283
|
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}"]
|
|
1103
1284
|
})
|
|
1104
1285
|
], EqpAttachmentsComponent);
|