@eqproject/eqp-attachments 0.1.12 → 0.1.13
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 +1 -0
- package/bundles/eqproject-eqp-attachments.umd.js +208 -54
- 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 +198 -68
- package/esm5/lib/eqp-attachments.component.js +211 -57
- package/fesm2015/eqproject-eqp-attachments.js +197 -67
- package/fesm2015/eqproject-eqp-attachments.js.map +1 -1
- package/fesm5/eqproject-eqp-attachments.js +210 -56
- package/fesm5/eqproject-eqp-attachments.js.map +1 -1
- package/lib/eqp-attachments.component.d.ts +41 -5
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate, __awaiter } from 'tslib';
|
|
2
|
-
import { ɵɵdefineInjectable, Injectable, EventEmitter, Input, Output, ViewChild, Component, NgModule } from '@angular/core';
|
|
2
|
+
import { ɵɵdefineInjectable, Injectable, EventEmitter, ChangeDetectorRef, Input, Output, ViewChild, Component, NgModule } from '@angular/core';
|
|
3
3
|
import { Validators, FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
4
4
|
import { base64ToFile, ImageCropperComponent, ImageCropperModule } from 'ngx-image-cropper';
|
|
5
5
|
import imageCompression from 'browser-image-compression';
|
|
@@ -211,11 +211,12 @@ const toBase64 = file => new Promise((resolve, reject) => {
|
|
|
211
211
|
});
|
|
212
212
|
const ɵ0 = toBase64;
|
|
213
213
|
let EqpAttachmentsComponent = class EqpAttachmentsComponent {
|
|
214
|
-
constructor(dialog, formBuilder, sanitizer, http) {
|
|
214
|
+
constructor(dialog, formBuilder, sanitizer, http, cd) {
|
|
215
215
|
this.dialog = dialog;
|
|
216
216
|
this.formBuilder = formBuilder;
|
|
217
217
|
this.sanitizer = sanitizer;
|
|
218
218
|
this.http = http;
|
|
219
|
+
this.cd = cd;
|
|
219
220
|
//#region @Input del componente
|
|
220
221
|
/**
|
|
221
222
|
* Se TRUE allora nasconde la colonna per le azioni sull'allegato (nel caso "multipleAttachment" è TRUE).
|
|
@@ -242,6 +243,11 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
|
|
|
242
243
|
* Se TRUE allora il componente mostra l'elenco di tutti gli allegati ricevuto nel parametro "attachmentsList".
|
|
243
244
|
*/
|
|
244
245
|
this.multipleAttachment = true;
|
|
246
|
+
/**
|
|
247
|
+
* Se assume il valore TRUE allora sarà possibile caricare più file per volta. Questa funzionalità è attiva
|
|
248
|
+
* SOLO se si gestiscono allegati multipli, quindi se l'input 'multipleAttachment' assume il valore TRUE, altrimenti è sempre disabilitata.
|
|
249
|
+
*/
|
|
250
|
+
this.loadMultipleFiles = false;
|
|
245
251
|
/**
|
|
246
252
|
* Configurazione delle colonne della eqp-table per la visualizzazione degli allegati (caso "multipleAttachment" è TRUE).
|
|
247
253
|
*/
|
|
@@ -329,8 +335,10 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
|
|
|
329
335
|
//#endregion
|
|
330
336
|
//#region Proprietà per gestione caricamento nuovo allegato
|
|
331
337
|
this.newAttachment = {};
|
|
338
|
+
this.newMultipleAttachments = [];
|
|
332
339
|
this.attachmentType = AttachmentType;
|
|
333
340
|
this.selectedFile = null;
|
|
341
|
+
this.selectedFiles = null;
|
|
334
342
|
this.showCropImage = false;
|
|
335
343
|
//#endregion
|
|
336
344
|
//#region Proprietà per gestione ridimensionamento file di tipo image
|
|
@@ -361,8 +369,6 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
|
|
|
361
369
|
if (this.attachmentsList == null)
|
|
362
370
|
this.attachmentsList = new Array();
|
|
363
371
|
this.checkAttachmentImage();
|
|
364
|
-
// if (!this.compressionOptions || !this.compressionOptions.maxSizeMB || !this.compressionOptions.maxWidthOrHeight)
|
|
365
|
-
// this.compressionOptions = { maxSizeMB: 0.5, maxWidthOrHeight: 1920, useWebWorker: true };
|
|
366
372
|
}
|
|
367
373
|
reloadData() {
|
|
368
374
|
if (this.attachmentTable)
|
|
@@ -473,9 +479,25 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
|
|
|
473
479
|
* Apre la modale per la definizione dei parametri del nuovo file
|
|
474
480
|
*/
|
|
475
481
|
openModalAddAttachment(attachmentType) {
|
|
482
|
+
//Se è stato richiesto il caricamento di un LINK o è impostato il caricamento di FILE SINGOLO allora apre la modale per
|
|
483
|
+
//il caricamento singolo del file altrimenti apre quella per il caricamento multiplo
|
|
484
|
+
// if (attachmentType == AttachmentType.LINK || (attachmentType == AttachmentType.FILE && this.loadMultipleFiles != true)) {
|
|
476
485
|
this.newAttachment = {};
|
|
477
486
|
this.newAttachment.IsImage = false;
|
|
478
487
|
this.newAttachment.AttachmentType = attachmentType;
|
|
488
|
+
this.newMultipleAttachments = new Array();
|
|
489
|
+
if (attachmentType == AttachmentType.LINK)
|
|
490
|
+
this.newMultipleAttachments.push(this.newAttachment);
|
|
491
|
+
this.createAttachmentForm();
|
|
492
|
+
//Apre la modale
|
|
493
|
+
this.dialofRefAddAttachment = this.dialog.open(this.dialogAddAttachment, {
|
|
494
|
+
disableClose: true,
|
|
495
|
+
hasBackdrop: true,
|
|
496
|
+
width: '60%',
|
|
497
|
+
maxHeight: '80%'
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
createAttachmentForm() {
|
|
479
501
|
//Crea la form per la validazione dei campi
|
|
480
502
|
this.newAttachmentForm = this.formBuilder.group({
|
|
481
503
|
type: [this.newAttachment.AttachmentType, Validators.required],
|
|
@@ -484,18 +506,13 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
|
|
|
484
506
|
customHeight: [this.customHeight],
|
|
485
507
|
customWidth: [this.customWidth]
|
|
486
508
|
});
|
|
487
|
-
//Apre la modale
|
|
488
|
-
this.dialofRefAddAttachment = this.dialog.open(this.dialogAddAttachment, {
|
|
489
|
-
disableClose: true,
|
|
490
|
-
hasBackdrop: true,
|
|
491
|
-
width: '60%',
|
|
492
|
-
maxHeight: '80%'
|
|
493
|
-
});
|
|
494
509
|
}
|
|
495
510
|
close() {
|
|
496
511
|
this.newAttachment = {};
|
|
512
|
+
this.newMultipleAttachments = new Array();
|
|
497
513
|
this.abortFile();
|
|
498
|
-
this.newAttachmentForm
|
|
514
|
+
if (this.newAttachmentForm)
|
|
515
|
+
this.newAttachmentForm.reset();
|
|
499
516
|
this.dialofRefAddAttachment.close();
|
|
500
517
|
}
|
|
501
518
|
/**
|
|
@@ -504,23 +521,37 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
|
|
|
504
521
|
* @returns
|
|
505
522
|
*/
|
|
506
523
|
disableSave() {
|
|
507
|
-
if (this.
|
|
508
|
-
|
|
524
|
+
if (this.loadMultipleFiles != true) {
|
|
525
|
+
if (this.newAttachment.AttachmentType == AttachmentType.FILE) {
|
|
526
|
+
return !this.newAttachment.FileDataBase64;
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
return !this.newAttachment.FilePath;
|
|
530
|
+
}
|
|
509
531
|
}
|
|
510
532
|
else {
|
|
511
|
-
return
|
|
533
|
+
return this.newMultipleAttachments.filter(p => (p.AttachmentType == AttachmentType.FILE && !p.FileDataBase64) || (p.AttachmentType == AttachmentType.LINK && !p.FilePath)).length > 0;
|
|
512
534
|
}
|
|
513
535
|
}
|
|
514
536
|
confirmAddAttachment() {
|
|
515
|
-
if (this.
|
|
516
|
-
this.newAttachment.
|
|
517
|
-
|
|
518
|
-
this.attachmentsList
|
|
519
|
-
|
|
537
|
+
if (this.loadMultipleFiles != true) {
|
|
538
|
+
if (this.newAttachment.AttachmentType == AttachmentType.LINK && !this.newAttachment.FileName)
|
|
539
|
+
this.newAttachment.FileName = this.newAttachment.FilePath;
|
|
540
|
+
if (this.attachmentsList == null)
|
|
541
|
+
this.attachmentsList = new Array();
|
|
542
|
+
this.attachmentsList.push(this.newAttachment);
|
|
543
|
+
}
|
|
544
|
+
else {
|
|
545
|
+
if (this.newMultipleAttachments == null || this.newMultipleAttachments.length == 0)
|
|
546
|
+
return;
|
|
547
|
+
if (this.attachmentsList == null)
|
|
548
|
+
this.attachmentsList = new Array();
|
|
549
|
+
this.attachmentsList = this.attachmentsList.concat(this.newMultipleAttachments);
|
|
550
|
+
}
|
|
520
551
|
if (this.attachmentTable)
|
|
521
552
|
this.attachmentTable.reloadDatatable();
|
|
522
553
|
this.localEditedAttachments.emit(this.attachmentsList);
|
|
523
|
-
this.
|
|
554
|
+
this.close();
|
|
524
555
|
}
|
|
525
556
|
/**
|
|
526
557
|
* Apre il dialog per l'anteprima dell'allegato selezionato.
|
|
@@ -578,68 +609,140 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
|
|
|
578
609
|
}
|
|
579
610
|
//#region Gestione caricamento file
|
|
580
611
|
/**
|
|
581
|
-
*
|
|
582
|
-
*
|
|
612
|
+
* Evento scatenato alla selezione del file (o dei file).
|
|
613
|
+
* 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
|
|
614
|
+
* mostrare le funzionalità del croppie (per ritagliare l'immagine) oppure no.
|
|
615
|
+
* Se il file caricato non è un immagine allora genera direttamente il base64 e lo associa all'allegato da salvare.
|
|
616
|
+
* Se invece il caricamento dei file è MULTIPLO e sono presenti più file allora esegue le stesse operazioni ignorando però il contrllo
|
|
617
|
+
* immagine per il croppie (in caso di caricamento multiplo le funzionalità del croppie sono disabilitate).
|
|
583
618
|
*/
|
|
584
619
|
onFileInputChange(event) {
|
|
585
620
|
return __awaiter(this, void 0, void 0, function* () {
|
|
586
621
|
this.showCropImage = false;
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
622
|
+
//Se è stato richiesto il caricamento SINGOLO oppure se il caricamento è MULTIPLO ma è stato selezionato un solo file
|
|
623
|
+
//allora verifica se il file è un immagine (per mostrare il CROPPIE)
|
|
624
|
+
if ([...event.target.files].length == 1 || this.loadMultipleFiles != true) {
|
|
625
|
+
this.selectedFile = event.target.files[0];
|
|
626
|
+
this.selectedFiles = event.target.files;
|
|
627
|
+
if (!this.selectedFile)
|
|
628
|
+
return;
|
|
629
|
+
//Memorizza i dati per l'allegato
|
|
630
|
+
this.newAttachment = yield this.createAttachmentFromUploadedFile(this.selectedFile, false);
|
|
631
|
+
this.newMultipleAttachments = new Array();
|
|
632
|
+
this.newMultipleAttachments.push(this.newAttachment);
|
|
633
|
+
//Se è stata richiesta la gestione delle sole immagini ma per errore è stato selezionato un file che non è un immagine
|
|
634
|
+
let checkOnlyImage = this.checkAllowOnlyImageFile(this.newAttachment);
|
|
635
|
+
if (checkOnlyImage == false)
|
|
636
|
+
return;
|
|
637
|
+
if (this.loadMultipleFiles == true && [...event.target.files].length == 1)
|
|
638
|
+
this.createAttachmentForm();
|
|
639
|
+
//Verifica se il file caricato è un'immagine oppure no. Se è un immagine, prima di caricarla mostra il croppie per il resize.
|
|
640
|
+
//Se non è un immagine allora genera il Base64
|
|
641
|
+
if (this.newAttachment.IsImage == true) {
|
|
642
|
+
this.getImageDimensions(event.target.files[0]);
|
|
643
|
+
//Mostra il croppie e disabilita la form finchè non termina la modifica dell'immagine
|
|
644
|
+
this.newAttachmentForm.disable();
|
|
645
|
+
this.newAttachmentForm.controls["customWidth"].enable();
|
|
646
|
+
this.newAttachmentForm.controls["customHeight"].enable();
|
|
647
|
+
this.showCropImage = true;
|
|
648
|
+
this.imageChangedEvent = event;
|
|
649
|
+
}
|
|
650
|
+
else {
|
|
651
|
+
this.showCropImage = false;
|
|
652
|
+
let base64Result = yield this.getBase64FromFile(this.selectedFile);
|
|
653
|
+
this.newAttachment.FileDataBase64 = base64Result.Base64File;
|
|
654
|
+
this.newAttachment.FileContentType = base64Result.ContentType;
|
|
655
|
+
}
|
|
616
656
|
}
|
|
617
657
|
else {
|
|
618
|
-
this.
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
658
|
+
this.selectedFiles = event.target.files;
|
|
659
|
+
if (!this.selectedFiles || this.selectedFiles.length == 0)
|
|
660
|
+
return;
|
|
661
|
+
this.newMultipleAttachments = new Array();
|
|
662
|
+
for (let i = 0; i < this.selectedFiles.length; i++) {
|
|
663
|
+
let newAttachment = yield this.createAttachmentFromUploadedFile(this.selectedFiles[i], true);
|
|
664
|
+
//Se è stata richiesta la gestione delle sole immagini ma per errore è stato selezionato un file che non è un immagine
|
|
665
|
+
let checkOnlyImage = this.checkAllowOnlyImageFile(newAttachment);
|
|
666
|
+
if (checkOnlyImage == false)
|
|
667
|
+
return;
|
|
668
|
+
this.newMultipleAttachments.push(newAttachment);
|
|
628
669
|
}
|
|
629
670
|
}
|
|
630
671
|
});
|
|
631
672
|
}
|
|
673
|
+
/**
|
|
674
|
+
* A partire dal FILE ricevuto in input ricostruisce l'oggetto IAttachmentDTO e lo restituisce.
|
|
675
|
+
* Se il parametro getBase64 viene passato a TRUE allora, sempre a partire dal file,genera il base64 e
|
|
676
|
+
* ricava il ContentType da associare all'oggetto IAttachmentDTO da restituire
|
|
677
|
+
* @param currentFile Oggetto FILE da processare
|
|
678
|
+
* @param getBase64 Se TRUE allora calcola base64 e ContentType del file passato in input
|
|
679
|
+
* @returns Restituisce un oggetto di tipo IAttachmentDTO
|
|
680
|
+
*/
|
|
681
|
+
createAttachmentFromUploadedFile(currentFile, getBase64 = true) {
|
|
682
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
683
|
+
let newAttachment = {};
|
|
684
|
+
//Memorizza i dati per l'allegato
|
|
685
|
+
newAttachment.AttachmentType = AttachmentType.FILE;
|
|
686
|
+
newAttachment.FileContentType = currentFile.type;
|
|
687
|
+
newAttachment.FileName = currentFile.name;
|
|
688
|
+
newAttachment.FileExtension = currentFile.name.substr(currentFile.name.lastIndexOf('.') + 1);
|
|
689
|
+
newAttachment.IsImage = AttachmentHelperService.checkImageFromMimeType(currentFile.type);
|
|
690
|
+
if (getBase64 == true) {
|
|
691
|
+
let base64Result = yield this.getBase64FromFile(currentFile);
|
|
692
|
+
newAttachment.FileDataBase64 = base64Result.Base64File;
|
|
693
|
+
newAttachment.FileContentType = base64Result.ContentType;
|
|
694
|
+
}
|
|
695
|
+
return newAttachment;
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* A partire dal file passato in input restituisce un oggetto
|
|
700
|
+
* contenente il base64 del file e il suo contentType
|
|
701
|
+
* @param currentFile Oggetto File da cui estrapolare base64 e contentType
|
|
702
|
+
* @returns Restituisce un oggetto avente le proprietà Base64File e ContentType
|
|
703
|
+
*/
|
|
704
|
+
getBase64FromFile(currentFile) {
|
|
705
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
706
|
+
let base64File = yield toBase64(currentFile);
|
|
707
|
+
let contentType = null;
|
|
708
|
+
if (base64File) {
|
|
709
|
+
// Loris 20/01/2022: PROBLEMA - Quando eseguo l'upload di un file .sql non viene salvato/scaricato correttamente.
|
|
710
|
+
// Questo succede perchè non viene popolato il FileContentType. Per risolvere il problema
|
|
711
|
+
// faccio un controllo e se non esiste il FileContentType allora lo recupero dal base64 ottenuto.
|
|
712
|
+
contentType = base64File.split(",")[0].split(":")[1].split(";")[0];
|
|
713
|
+
// Un altro metodo per leggere il ccontent type del file è tramite una regular expression:
|
|
714
|
+
base64File = base64File.split(",")[1];
|
|
715
|
+
}
|
|
716
|
+
let result = {
|
|
717
|
+
Base64File: base64File,
|
|
718
|
+
ContentType: contentType
|
|
719
|
+
};
|
|
720
|
+
return result;
|
|
721
|
+
});
|
|
722
|
+
}
|
|
632
723
|
/**
|
|
633
724
|
* Controlla se il file che si sta caricando è supportato dal sistema.
|
|
634
725
|
* @returns
|
|
635
726
|
*/
|
|
636
727
|
checkAcceptedFiles() {
|
|
637
|
-
if (this.selectedFile.type.startsWith("video"))
|
|
728
|
+
if ((this.loadMultipleFiles != true && this.selectedFile.type.startsWith("video"))
|
|
729
|
+
|| (this.loadMultipleFiles == true && [...this.selectedFiles].filter(p => p.type.startsWith("video")).length > 0))
|
|
638
730
|
return false;
|
|
639
731
|
if (this.acceptedFileTypes == "*")
|
|
640
732
|
return true;
|
|
641
|
-
|
|
642
|
-
|
|
733
|
+
//Verifica che i tipi del file (o dei file) caricati siano coerenti con quelli accettati dalla direttiva
|
|
734
|
+
let accepted = true;
|
|
735
|
+
if (this.loadMultipleFiles != true)
|
|
736
|
+
accepted = this.acceptedFileTypes.includes(this.selectedFile.type);
|
|
737
|
+
else {
|
|
738
|
+
let uploadedFileTypes = [...this.selectedFiles].map(p => p.type);
|
|
739
|
+
uploadedFileTypes.forEach(type => {
|
|
740
|
+
if (!this.acceptedFileTypes.includes(type))
|
|
741
|
+
accepted = false;
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
//Questo controllo permette di gestire le casistiche per cui vengono indicati come tipi validi, ad esempio, 'image/*'
|
|
745
|
+
if (!accepted && this.loadMultipleFiles != true) {
|
|
643
746
|
for (let t of this.acceptedFileTypes.split(",").filter(t => t.includes("*"))) {
|
|
644
747
|
accepted = this.selectedFile.type.startsWith(t.split("*")[0]);
|
|
645
748
|
if (accepted)
|
|
@@ -648,6 +751,24 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
|
|
|
648
751
|
}
|
|
649
752
|
return accepted;
|
|
650
753
|
}
|
|
754
|
+
/**
|
|
755
|
+
* Se eqp-attachments è stata configurata per il caricamento delle sole immagini allora verifica che il file passato in
|
|
756
|
+
* input sia effettivamente un immagine o no.
|
|
757
|
+
* Se il controllo va a buon fine restituisce TRUE altrimenti mostra un messaggio d'errore e restituisce FALSE
|
|
758
|
+
*/
|
|
759
|
+
checkAllowOnlyImageFile(newAttachment) {
|
|
760
|
+
if (this.allowOnlyImages == true && newAttachment.IsImage != true) {
|
|
761
|
+
EqpAttachmentDialogService.Error(this.noImageSelectedErrorMessage);
|
|
762
|
+
this.abortFile();
|
|
763
|
+
return false;
|
|
764
|
+
}
|
|
765
|
+
else if (!this.checkAcceptedFiles()) {
|
|
766
|
+
EqpAttachmentDialogService.Error(this.wrongTypeSelectedErrorMessage);
|
|
767
|
+
this.abortFile();
|
|
768
|
+
return false;
|
|
769
|
+
}
|
|
770
|
+
return true;
|
|
771
|
+
}
|
|
651
772
|
getImageDimensions(img) {
|
|
652
773
|
const reader = new FileReader();
|
|
653
774
|
reader.onload = (e) => {
|
|
@@ -715,12 +836,14 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
|
|
|
715
836
|
if (this.imageInput)
|
|
716
837
|
this.imageInput.nativeElement.value = '';
|
|
717
838
|
this.selectedFile = null;
|
|
839
|
+
this.selectedFiles = null;
|
|
718
840
|
this.showCropImage = false;
|
|
719
841
|
this.newAttachment.IsImage = false;
|
|
720
842
|
this.newAttachment.FileDataBase64 = null;
|
|
721
843
|
this.newAttachment.FileName = null;
|
|
722
844
|
this.newAttachment.FileExtension = null;
|
|
723
845
|
this.newAttachment.FileContentType = null;
|
|
846
|
+
this.newMultipleAttachments = new Array();
|
|
724
847
|
this.customHeight = null;
|
|
725
848
|
this.customWidth = null;
|
|
726
849
|
this.originalHeight = null;
|
|
@@ -731,7 +854,8 @@ EqpAttachmentsComponent.ctorParameters = () => [
|
|
|
731
854
|
{ type: MatDialog },
|
|
732
855
|
{ type: FormBuilder },
|
|
733
856
|
{ type: DomSanitizer },
|
|
734
|
-
{ type: HttpClient }
|
|
857
|
+
{ type: HttpClient },
|
|
858
|
+
{ type: ChangeDetectorRef }
|
|
735
859
|
];
|
|
736
860
|
__decorate([
|
|
737
861
|
Input("disableAction")
|
|
@@ -751,6 +875,9 @@ __decorate([
|
|
|
751
875
|
__decorate([
|
|
752
876
|
Input("multipleAttachment")
|
|
753
877
|
], EqpAttachmentsComponent.prototype, "multipleAttachment", void 0);
|
|
878
|
+
__decorate([
|
|
879
|
+
Input("loadMultipleFiles")
|
|
880
|
+
], EqpAttachmentsComponent.prototype, "loadMultipleFiles", void 0);
|
|
754
881
|
__decorate([
|
|
755
882
|
Input("attachmentsColumns")
|
|
756
883
|
], EqpAttachmentsComponent.prototype, "attachmentsColumns", void 0);
|
|
@@ -853,6 +980,9 @@ __decorate([
|
|
|
853
980
|
__decorate([
|
|
854
981
|
ViewChild('dialogAddAttachment', { static: true })
|
|
855
982
|
], EqpAttachmentsComponent.prototype, "dialogAddAttachment", void 0);
|
|
983
|
+
__decorate([
|
|
984
|
+
ViewChild('dialogAddMultipleAttachment', { static: true })
|
|
985
|
+
], EqpAttachmentsComponent.prototype, "dialogAddMultipleAttachment", void 0);
|
|
856
986
|
__decorate([
|
|
857
987
|
ViewChild(ImageCropperComponent)
|
|
858
988
|
], EqpAttachmentsComponent.prototype, "imageCropper", void 0);
|
|
@@ -871,7 +1001,7 @@ __decorate([
|
|
|
871
1001
|
EqpAttachmentsComponent = __decorate([
|
|
872
1002
|
Component({
|
|
873
1003
|
selector: 'eqp-attachments',
|
|
874
|
-
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>",
|
|
1004
|
+
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 [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>",
|
|
875
1005
|
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}"]
|
|
876
1006
|
})
|
|
877
1007
|
], EqpAttachmentsComponent);
|