@eqproject/eqp-attachments 0.1.10 → 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 +215 -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 +205 -68
- package/esm5/lib/eqp-attachments.component.js +218 -57
- package/fesm2015/eqproject-eqp-attachments.js +204 -67
- package/fesm2015/eqproject-eqp-attachments.js.map +1 -1
- package/fesm5/eqproject-eqp-attachments.js +217 -56
- package/fesm5/eqproject-eqp-attachments.js.map +1 -1
- package/lib/eqp-attachments.component.d.ts +45 -5
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __decorate, __awaiter, __generator, __values } from 'tslib';
|
|
2
|
-
import { ɵɵdefineInjectable, Injectable, EventEmitter, Input, Output, ViewChild, Component, NgModule } from '@angular/core';
|
|
1
|
+
import { __decorate, __awaiter, __generator, __spread, __values } from 'tslib';
|
|
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';
|
|
@@ -221,11 +221,12 @@ var toBase64 = function (file) { return new Promise(function (resolve, reject) {
|
|
|
221
221
|
}); };
|
|
222
222
|
var ɵ0 = toBase64;
|
|
223
223
|
var EqpAttachmentsComponent = /** @class */ (function () {
|
|
224
|
-
function EqpAttachmentsComponent(dialog, formBuilder, sanitizer, http) {
|
|
224
|
+
function EqpAttachmentsComponent(dialog, formBuilder, sanitizer, http, cd) {
|
|
225
225
|
this.dialog = dialog;
|
|
226
226
|
this.formBuilder = formBuilder;
|
|
227
227
|
this.sanitizer = sanitizer;
|
|
228
228
|
this.http = http;
|
|
229
|
+
this.cd = cd;
|
|
229
230
|
//#region @Input del componente
|
|
230
231
|
/**
|
|
231
232
|
* Se TRUE allora nasconde la colonna per le azioni sull'allegato (nel caso "multipleAttachment" è TRUE).
|
|
@@ -252,6 +253,11 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
252
253
|
* Se TRUE allora il componente mostra l'elenco di tutti gli allegati ricevuto nel parametro "attachmentsList".
|
|
253
254
|
*/
|
|
254
255
|
this.multipleAttachment = true;
|
|
256
|
+
/**
|
|
257
|
+
* Se assume il valore TRUE allora sarà possibile caricare più file per volta. Questa funzionalità è attiva
|
|
258
|
+
* SOLO se si gestiscono allegati multipli, quindi se l'input 'multipleAttachment' assume il valore TRUE, altrimenti è sempre disabilitata.
|
|
259
|
+
*/
|
|
260
|
+
this.loadMultipleFiles = false;
|
|
255
261
|
/**
|
|
256
262
|
* Configurazione delle colonne della eqp-table per la visualizzazione degli allegati (caso "multipleAttachment" è TRUE).
|
|
257
263
|
*/
|
|
@@ -296,6 +302,10 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
296
302
|
* Array di AttachmentType che si possono aggiungere
|
|
297
303
|
*/
|
|
298
304
|
this.allowedTypes = [AttachmentType.FILE, AttachmentType.LINK];
|
|
305
|
+
/**
|
|
306
|
+
* Booleano per impostare la eqp-table nella modalità multilingua
|
|
307
|
+
*/
|
|
308
|
+
this.isEqpTableMultiLanguage = false;
|
|
299
309
|
/**
|
|
300
310
|
* Input per definire le label da usare nel componente
|
|
301
311
|
*/
|
|
@@ -335,8 +345,10 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
335
345
|
//#endregion
|
|
336
346
|
//#region Proprietà per gestione caricamento nuovo allegato
|
|
337
347
|
this.newAttachment = {};
|
|
348
|
+
this.newMultipleAttachments = [];
|
|
338
349
|
this.attachmentType = AttachmentType;
|
|
339
350
|
this.selectedFile = null;
|
|
351
|
+
this.selectedFiles = null;
|
|
340
352
|
this.showCropImage = false;
|
|
341
353
|
//#endregion
|
|
342
354
|
//#region Proprietà per gestione ridimensionamento file di tipo image
|
|
@@ -367,8 +379,6 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
367
379
|
if (this.attachmentsList == null)
|
|
368
380
|
this.attachmentsList = new Array();
|
|
369
381
|
this.checkAttachmentImage();
|
|
370
|
-
// if (!this.compressionOptions || !this.compressionOptions.maxSizeMB || !this.compressionOptions.maxWidthOrHeight)
|
|
371
|
-
// this.compressionOptions = { maxSizeMB: 0.5, maxWidthOrHeight: 1920, useWebWorker: true };
|
|
372
382
|
};
|
|
373
383
|
EqpAttachmentsComponent.prototype.reloadData = function () {
|
|
374
384
|
if (this.attachmentTable)
|
|
@@ -481,9 +491,25 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
481
491
|
* Apre la modale per la definizione dei parametri del nuovo file
|
|
482
492
|
*/
|
|
483
493
|
EqpAttachmentsComponent.prototype.openModalAddAttachment = function (attachmentType) {
|
|
494
|
+
//Se è stato richiesto il caricamento di un LINK o è impostato il caricamento di FILE SINGOLO allora apre la modale per
|
|
495
|
+
//il caricamento singolo del file altrimenti apre quella per il caricamento multiplo
|
|
496
|
+
// if (attachmentType == AttachmentType.LINK || (attachmentType == AttachmentType.FILE && this.loadMultipleFiles != true)) {
|
|
484
497
|
this.newAttachment = {};
|
|
485
498
|
this.newAttachment.IsImage = false;
|
|
486
499
|
this.newAttachment.AttachmentType = attachmentType;
|
|
500
|
+
this.newMultipleAttachments = new Array();
|
|
501
|
+
if (attachmentType == AttachmentType.LINK)
|
|
502
|
+
this.newMultipleAttachments.push(this.newAttachment);
|
|
503
|
+
this.createAttachmentForm();
|
|
504
|
+
//Apre la modale
|
|
505
|
+
this.dialofRefAddAttachment = this.dialog.open(this.dialogAddAttachment, {
|
|
506
|
+
disableClose: true,
|
|
507
|
+
hasBackdrop: true,
|
|
508
|
+
width: '60%',
|
|
509
|
+
maxHeight: '80%'
|
|
510
|
+
});
|
|
511
|
+
};
|
|
512
|
+
EqpAttachmentsComponent.prototype.createAttachmentForm = function () {
|
|
487
513
|
//Crea la form per la validazione dei campi
|
|
488
514
|
this.newAttachmentForm = this.formBuilder.group({
|
|
489
515
|
type: [this.newAttachment.AttachmentType, Validators.required],
|
|
@@ -492,18 +518,13 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
492
518
|
customHeight: [this.customHeight],
|
|
493
519
|
customWidth: [this.customWidth]
|
|
494
520
|
});
|
|
495
|
-
//Apre la modale
|
|
496
|
-
this.dialofRefAddAttachment = this.dialog.open(this.dialogAddAttachment, {
|
|
497
|
-
disableClose: true,
|
|
498
|
-
hasBackdrop: true,
|
|
499
|
-
width: '60%',
|
|
500
|
-
maxHeight: '80%'
|
|
501
|
-
});
|
|
502
521
|
};
|
|
503
522
|
EqpAttachmentsComponent.prototype.close = function () {
|
|
504
523
|
this.newAttachment = {};
|
|
524
|
+
this.newMultipleAttachments = new Array();
|
|
505
525
|
this.abortFile();
|
|
506
|
-
this.newAttachmentForm
|
|
526
|
+
if (this.newAttachmentForm)
|
|
527
|
+
this.newAttachmentForm.reset();
|
|
507
528
|
this.dialofRefAddAttachment.close();
|
|
508
529
|
};
|
|
509
530
|
/**
|
|
@@ -512,23 +533,37 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
512
533
|
* @returns
|
|
513
534
|
*/
|
|
514
535
|
EqpAttachmentsComponent.prototype.disableSave = function () {
|
|
515
|
-
if (this.
|
|
516
|
-
|
|
536
|
+
if (this.loadMultipleFiles != true) {
|
|
537
|
+
if (this.newAttachment.AttachmentType == AttachmentType.FILE) {
|
|
538
|
+
return !this.newAttachment.FileDataBase64;
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
return !this.newAttachment.FilePath;
|
|
542
|
+
}
|
|
517
543
|
}
|
|
518
544
|
else {
|
|
519
|
-
return
|
|
545
|
+
return this.newMultipleAttachments.filter(function (p) { return (p.AttachmentType == AttachmentType.FILE && !p.FileDataBase64) || (p.AttachmentType == AttachmentType.LINK && !p.FilePath); }).length > 0;
|
|
520
546
|
}
|
|
521
547
|
};
|
|
522
548
|
EqpAttachmentsComponent.prototype.confirmAddAttachment = function () {
|
|
523
|
-
if (this.
|
|
524
|
-
this.newAttachment.
|
|
525
|
-
|
|
526
|
-
this.attachmentsList
|
|
527
|
-
|
|
549
|
+
if (this.loadMultipleFiles != true) {
|
|
550
|
+
if (this.newAttachment.AttachmentType == AttachmentType.LINK && !this.newAttachment.FileName)
|
|
551
|
+
this.newAttachment.FileName = this.newAttachment.FilePath;
|
|
552
|
+
if (this.attachmentsList == null)
|
|
553
|
+
this.attachmentsList = new Array();
|
|
554
|
+
this.attachmentsList.push(this.newAttachment);
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
if (this.newMultipleAttachments == null || this.newMultipleAttachments.length == 0)
|
|
558
|
+
return;
|
|
559
|
+
if (this.attachmentsList == null)
|
|
560
|
+
this.attachmentsList = new Array();
|
|
561
|
+
this.attachmentsList = this.attachmentsList.concat(this.newMultipleAttachments);
|
|
562
|
+
}
|
|
528
563
|
if (this.attachmentTable)
|
|
529
564
|
this.attachmentTable.reloadDatatable();
|
|
530
565
|
this.localEditedAttachments.emit(this.attachmentsList);
|
|
531
|
-
this.
|
|
566
|
+
this.close();
|
|
532
567
|
};
|
|
533
568
|
/**
|
|
534
569
|
* Apre il dialog per l'anteprima dell'allegato selezionato.
|
|
@@ -598,36 +633,39 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
598
633
|
};
|
|
599
634
|
//#region Gestione caricamento file
|
|
600
635
|
/**
|
|
601
|
-
*
|
|
602
|
-
*
|
|
636
|
+
* Evento scatenato alla selezione del file (o dei file).
|
|
637
|
+
* 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
|
|
638
|
+
* mostrare le funzionalità del croppie (per ritagliare l'immagine) oppure no.
|
|
639
|
+
* Se il file caricato non è un immagine allora genera direttamente il base64 e lo associa all'allegato da salvare.
|
|
640
|
+
* Se invece il caricamento dei file è MULTIPLO e sono presenti più file allora esegue le stesse operazioni ignorando però il contrllo
|
|
641
|
+
* immagine per il croppie (in caso di caricamento multiplo le funzionalità del croppie sono disabilitate).
|
|
603
642
|
*/
|
|
604
643
|
EqpAttachmentsComponent.prototype.onFileInputChange = function (event) {
|
|
605
644
|
return __awaiter(this, void 0, void 0, function () {
|
|
606
|
-
var
|
|
607
|
-
return __generator(this, function (
|
|
608
|
-
switch (
|
|
645
|
+
var _a, checkOnlyImage, base64Result, i, newAttachment, checkOnlyImage;
|
|
646
|
+
return __generator(this, function (_b) {
|
|
647
|
+
switch (_b.label) {
|
|
609
648
|
case 0:
|
|
610
649
|
this.showCropImage = false;
|
|
650
|
+
if (!(__spread(event.target.files).length == 1 || this.loadMultipleFiles != true)) return [3 /*break*/, 5];
|
|
611
651
|
this.selectedFile = event.target.files[0];
|
|
652
|
+
this.selectedFiles = event.target.files;
|
|
612
653
|
if (!this.selectedFile)
|
|
613
654
|
return [2 /*return*/];
|
|
614
655
|
//Memorizza i dati per l'allegato
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
}
|
|
625
|
-
else if (!this.checkAcceptedFiles()) {
|
|
626
|
-
EqpAttachmentDialogService.Error(this.wrongTypeSelectedErrorMessage);
|
|
627
|
-
this.abortFile();
|
|
656
|
+
_a = this;
|
|
657
|
+
return [4 /*yield*/, this.createAttachmentFromUploadedFile(this.selectedFile, false)];
|
|
658
|
+
case 1:
|
|
659
|
+
//Memorizza i dati per l'allegato
|
|
660
|
+
_a.newAttachment = _b.sent();
|
|
661
|
+
this.newMultipleAttachments = new Array();
|
|
662
|
+
this.newMultipleAttachments.push(this.newAttachment);
|
|
663
|
+
checkOnlyImage = this.checkAllowOnlyImageFile(this.newAttachment);
|
|
664
|
+
if (checkOnlyImage == false)
|
|
628
665
|
return [2 /*return*/];
|
|
629
|
-
|
|
630
|
-
|
|
666
|
+
if (this.loadMultipleFiles == true && __spread(event.target.files).length == 1)
|
|
667
|
+
this.createAttachmentForm();
|
|
668
|
+
if (!(this.newAttachment.IsImage == true)) return [3 /*break*/, 2];
|
|
631
669
|
this.getImageDimensions(event.target.files[0]);
|
|
632
670
|
//Mostra il croppie e disabilita la form finchè non termina la modifica dell'immagine
|
|
633
671
|
this.newAttachmentForm.disable();
|
|
@@ -635,23 +673,103 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
635
673
|
this.newAttachmentForm.controls["customHeight"].enable();
|
|
636
674
|
this.showCropImage = true;
|
|
637
675
|
this.imageChangedEvent = event;
|
|
638
|
-
return [3 /*break*/,
|
|
639
|
-
case 1:
|
|
640
|
-
this.showCropImage = false;
|
|
641
|
-
return [4 /*yield*/, toBase64(this.selectedFile)];
|
|
676
|
+
return [3 /*break*/, 4];
|
|
642
677
|
case 2:
|
|
678
|
+
this.showCropImage = false;
|
|
679
|
+
return [4 /*yield*/, this.getBase64FromFile(this.selectedFile)];
|
|
680
|
+
case 3:
|
|
681
|
+
base64Result = _b.sent();
|
|
682
|
+
this.newAttachment.FileDataBase64 = base64Result.Base64File;
|
|
683
|
+
this.newAttachment.FileContentType = base64Result.ContentType;
|
|
684
|
+
_b.label = 4;
|
|
685
|
+
case 4: return [3 /*break*/, 9];
|
|
686
|
+
case 5:
|
|
687
|
+
this.selectedFiles = event.target.files;
|
|
688
|
+
if (!this.selectedFiles || this.selectedFiles.length == 0)
|
|
689
|
+
return [2 /*return*/];
|
|
690
|
+
this.newMultipleAttachments = new Array();
|
|
691
|
+
i = 0;
|
|
692
|
+
_b.label = 6;
|
|
693
|
+
case 6:
|
|
694
|
+
if (!(i < this.selectedFiles.length)) return [3 /*break*/, 9];
|
|
695
|
+
return [4 /*yield*/, this.createAttachmentFromUploadedFile(this.selectedFiles[i], true)];
|
|
696
|
+
case 7:
|
|
697
|
+
newAttachment = _b.sent();
|
|
698
|
+
checkOnlyImage = this.checkAllowOnlyImageFile(newAttachment);
|
|
699
|
+
if (checkOnlyImage == false)
|
|
700
|
+
return [2 /*return*/];
|
|
701
|
+
this.newMultipleAttachments.push(newAttachment);
|
|
702
|
+
_b.label = 8;
|
|
703
|
+
case 8:
|
|
704
|
+
i++;
|
|
705
|
+
return [3 /*break*/, 6];
|
|
706
|
+
case 9: return [2 /*return*/];
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
});
|
|
710
|
+
};
|
|
711
|
+
/**
|
|
712
|
+
* A partire dal FILE ricevuto in input ricostruisce l'oggetto IAttachmentDTO e lo restituisce.
|
|
713
|
+
* Se il parametro getBase64 viene passato a TRUE allora, sempre a partire dal file,genera il base64 e
|
|
714
|
+
* ricava il ContentType da associare all'oggetto IAttachmentDTO da restituire
|
|
715
|
+
* @param currentFile Oggetto FILE da processare
|
|
716
|
+
* @param getBase64 Se TRUE allora calcola base64 e ContentType del file passato in input
|
|
717
|
+
* @returns Restituisce un oggetto di tipo IAttachmentDTO
|
|
718
|
+
*/
|
|
719
|
+
EqpAttachmentsComponent.prototype.createAttachmentFromUploadedFile = function (currentFile, getBase64) {
|
|
720
|
+
if (getBase64 === void 0) { getBase64 = true; }
|
|
721
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
722
|
+
var newAttachment, base64Result;
|
|
723
|
+
return __generator(this, function (_a) {
|
|
724
|
+
switch (_a.label) {
|
|
725
|
+
case 0:
|
|
726
|
+
newAttachment = {};
|
|
727
|
+
//Memorizza i dati per l'allegato
|
|
728
|
+
newAttachment.AttachmentType = AttachmentType.FILE;
|
|
729
|
+
newAttachment.FileContentType = currentFile.type;
|
|
730
|
+
newAttachment.FileName = currentFile.name;
|
|
731
|
+
newAttachment.FileExtension = currentFile.name.substr(currentFile.name.lastIndexOf('.') + 1);
|
|
732
|
+
newAttachment.IsImage = AttachmentHelperService.checkImageFromMimeType(currentFile.type);
|
|
733
|
+
if (!(getBase64 == true)) return [3 /*break*/, 2];
|
|
734
|
+
return [4 /*yield*/, this.getBase64FromFile(currentFile)];
|
|
735
|
+
case 1:
|
|
736
|
+
base64Result = _a.sent();
|
|
737
|
+
newAttachment.FileDataBase64 = base64Result.Base64File;
|
|
738
|
+
newAttachment.FileContentType = base64Result.ContentType;
|
|
739
|
+
_a.label = 2;
|
|
740
|
+
case 2: return [2 /*return*/, newAttachment];
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
});
|
|
744
|
+
};
|
|
745
|
+
/**
|
|
746
|
+
* A partire dal file passato in input restituisce un oggetto
|
|
747
|
+
* contenente il base64 del file e il suo contentType
|
|
748
|
+
* @param currentFile Oggetto File da cui estrapolare base64 e contentType
|
|
749
|
+
* @returns Restituisce un oggetto avente le proprietà Base64File e ContentType
|
|
750
|
+
*/
|
|
751
|
+
EqpAttachmentsComponent.prototype.getBase64FromFile = function (currentFile) {
|
|
752
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
753
|
+
var base64File, contentType, result;
|
|
754
|
+
return __generator(this, function (_a) {
|
|
755
|
+
switch (_a.label) {
|
|
756
|
+
case 0: return [4 /*yield*/, toBase64(currentFile)];
|
|
757
|
+
case 1:
|
|
643
758
|
base64File = _a.sent();
|
|
759
|
+
contentType = null;
|
|
644
760
|
if (base64File) {
|
|
645
761
|
// Loris 20/01/2022: PROBLEMA - Quando eseguo l'upload di un file .sql non viene salvato/scaricato correttamente.
|
|
646
762
|
// Questo succede perchè non viene popolato il FileContentType. Per risolvere il problema
|
|
647
763
|
// faccio un controllo e se non esiste il FileContentType allora lo recupero dal base64 ottenuto.
|
|
648
|
-
|
|
764
|
+
contentType = base64File.split(",")[0].split(":")[1].split(";")[0];
|
|
649
765
|
// Un altro metodo per leggere il ccontent type del file è tramite una regular expression:
|
|
650
|
-
|
|
651
|
-
this.newAttachment.FileDataBase64 = base64File.split(",")[1];
|
|
766
|
+
base64File = base64File.split(",")[1];
|
|
652
767
|
}
|
|
653
|
-
|
|
654
|
-
|
|
768
|
+
result = {
|
|
769
|
+
Base64File: base64File,
|
|
770
|
+
ContentType: contentType
|
|
771
|
+
};
|
|
772
|
+
return [2 /*return*/, result];
|
|
655
773
|
}
|
|
656
774
|
});
|
|
657
775
|
});
|
|
@@ -662,12 +780,25 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
662
780
|
*/
|
|
663
781
|
EqpAttachmentsComponent.prototype.checkAcceptedFiles = function () {
|
|
664
782
|
var e_1, _a;
|
|
665
|
-
|
|
783
|
+
var _this = this;
|
|
784
|
+
if ((this.loadMultipleFiles != true && this.selectedFile.type.startsWith("video"))
|
|
785
|
+
|| (this.loadMultipleFiles == true && __spread(this.selectedFiles).filter(function (p) { return p.type.startsWith("video"); }).length > 0))
|
|
666
786
|
return false;
|
|
667
787
|
if (this.acceptedFileTypes == "*")
|
|
668
788
|
return true;
|
|
669
|
-
|
|
670
|
-
|
|
789
|
+
//Verifica che i tipi del file (o dei file) caricati siano coerenti con quelli accettati dalla direttiva
|
|
790
|
+
var accepted = true;
|
|
791
|
+
if (this.loadMultipleFiles != true)
|
|
792
|
+
accepted = this.acceptedFileTypes.includes(this.selectedFile.type);
|
|
793
|
+
else {
|
|
794
|
+
var uploadedFileTypes = __spread(this.selectedFiles).map(function (p) { return p.type; });
|
|
795
|
+
uploadedFileTypes.forEach(function (type) {
|
|
796
|
+
if (!_this.acceptedFileTypes.includes(type))
|
|
797
|
+
accepted = false;
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
//Questo controllo permette di gestire le casistiche per cui vengono indicati come tipi validi, ad esempio, 'image/*'
|
|
801
|
+
if (!accepted && this.loadMultipleFiles != true) {
|
|
671
802
|
try {
|
|
672
803
|
for (var _b = __values(this.acceptedFileTypes.split(",").filter(function (t) { return t.includes("*"); })), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
673
804
|
var t = _c.value;
|
|
@@ -686,6 +817,24 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
686
817
|
}
|
|
687
818
|
return accepted;
|
|
688
819
|
};
|
|
820
|
+
/**
|
|
821
|
+
* Se eqp-attachments è stata configurata per il caricamento delle sole immagini allora verifica che il file passato in
|
|
822
|
+
* input sia effettivamente un immagine o no.
|
|
823
|
+
* Se il controllo va a buon fine restituisce TRUE altrimenti mostra un messaggio d'errore e restituisce FALSE
|
|
824
|
+
*/
|
|
825
|
+
EqpAttachmentsComponent.prototype.checkAllowOnlyImageFile = function (newAttachment) {
|
|
826
|
+
if (this.allowOnlyImages == true && newAttachment.IsImage != true) {
|
|
827
|
+
EqpAttachmentDialogService.Error(this.noImageSelectedErrorMessage);
|
|
828
|
+
this.abortFile();
|
|
829
|
+
return false;
|
|
830
|
+
}
|
|
831
|
+
else if (!this.checkAcceptedFiles()) {
|
|
832
|
+
EqpAttachmentDialogService.Error(this.wrongTypeSelectedErrorMessage);
|
|
833
|
+
this.abortFile();
|
|
834
|
+
return false;
|
|
835
|
+
}
|
|
836
|
+
return true;
|
|
837
|
+
};
|
|
689
838
|
EqpAttachmentsComponent.prototype.getImageDimensions = function (img) {
|
|
690
839
|
var _this = this;
|
|
691
840
|
var reader = new FileReader();
|
|
@@ -754,12 +903,14 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
754
903
|
if (this.imageInput)
|
|
755
904
|
this.imageInput.nativeElement.value = '';
|
|
756
905
|
this.selectedFile = null;
|
|
906
|
+
this.selectedFiles = null;
|
|
757
907
|
this.showCropImage = false;
|
|
758
908
|
this.newAttachment.IsImage = false;
|
|
759
909
|
this.newAttachment.FileDataBase64 = null;
|
|
760
910
|
this.newAttachment.FileName = null;
|
|
761
911
|
this.newAttachment.FileExtension = null;
|
|
762
912
|
this.newAttachment.FileContentType = null;
|
|
913
|
+
this.newMultipleAttachments = new Array();
|
|
763
914
|
this.customHeight = null;
|
|
764
915
|
this.customWidth = null;
|
|
765
916
|
this.originalHeight = null;
|
|
@@ -769,7 +920,8 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
769
920
|
{ type: MatDialog },
|
|
770
921
|
{ type: FormBuilder },
|
|
771
922
|
{ type: DomSanitizer },
|
|
772
|
-
{ type: HttpClient }
|
|
923
|
+
{ type: HttpClient },
|
|
924
|
+
{ type: ChangeDetectorRef }
|
|
773
925
|
]; };
|
|
774
926
|
__decorate([
|
|
775
927
|
Input("disableAction")
|
|
@@ -789,6 +941,9 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
789
941
|
__decorate([
|
|
790
942
|
Input("multipleAttachment")
|
|
791
943
|
], EqpAttachmentsComponent.prototype, "multipleAttachment", void 0);
|
|
944
|
+
__decorate([
|
|
945
|
+
Input("loadMultipleFiles")
|
|
946
|
+
], EqpAttachmentsComponent.prototype, "loadMultipleFiles", void 0);
|
|
792
947
|
__decorate([
|
|
793
948
|
Input("attachmentsColumns")
|
|
794
949
|
], EqpAttachmentsComponent.prototype, "attachmentsColumns", void 0);
|
|
@@ -819,6 +974,9 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
819
974
|
__decorate([
|
|
820
975
|
Input("allowedTypes")
|
|
821
976
|
], EqpAttachmentsComponent.prototype, "allowedTypes", void 0);
|
|
977
|
+
__decorate([
|
|
978
|
+
Input("isEqpTableMultiLanguage")
|
|
979
|
+
], EqpAttachmentsComponent.prototype, "isEqpTableMultiLanguage", void 0);
|
|
822
980
|
__decorate([
|
|
823
981
|
Input("downloadTooltipPosition")
|
|
824
982
|
], EqpAttachmentsComponent.prototype, "downloadTooltipPosition", void 0);
|
|
@@ -888,6 +1046,9 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
888
1046
|
__decorate([
|
|
889
1047
|
ViewChild('dialogAddAttachment', { static: true })
|
|
890
1048
|
], EqpAttachmentsComponent.prototype, "dialogAddAttachment", void 0);
|
|
1049
|
+
__decorate([
|
|
1050
|
+
ViewChild('dialogAddMultipleAttachment', { static: true })
|
|
1051
|
+
], EqpAttachmentsComponent.prototype, "dialogAddMultipleAttachment", void 0);
|
|
891
1052
|
__decorate([
|
|
892
1053
|
ViewChild(ImageCropperComponent)
|
|
893
1054
|
], EqpAttachmentsComponent.prototype, "imageCropper", void 0);
|
|
@@ -906,7 +1067,7 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
906
1067
|
EqpAttachmentsComponent = __decorate([
|
|
907
1068
|
Component({
|
|
908
1069
|
selector: 'eqp-attachments',
|
|
909
|
-
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 [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>",
|
|
1070
|
+
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>",
|
|
910
1071
|
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}"]
|
|
911
1072
|
})
|
|
912
1073
|
], EqpAttachmentsComponent);
|