@eqproject/eqp-attachments 0.1.12 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/bundles/eqproject-eqp-attachments.umd.js +237 -56
- package/bundles/eqproject-eqp-attachments.umd.js.map +1 -1
- package/bundles/eqproject-eqp-attachments.umd.min.js +1 -1
- package/bundles/eqproject-eqp-attachments.umd.min.js.map +1 -1
- package/eqproject-eqp-attachments.metadata.json +1 -1
- package/esm2015/lib/eqp-attachments.component.js +226 -70
- package/esm5/lib/eqp-attachments.component.js +240 -59
- package/fesm2015/eqproject-eqp-attachments.js +225 -69
- package/fesm2015/eqproject-eqp-attachments.js.map +1 -1
- package/fesm5/eqproject-eqp-attachments.js +239 -58
- package/fesm5/eqproject-eqp-attachments.js.map +1 -1
- package/lib/eqp-attachments.component.d.ts +58 -7
- package/package.json +2 -2
|
@@ -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
|
*/
|
|
@@ -297,9 +303,20 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
297
303
|
*/
|
|
298
304
|
this.allowedTypes = [AttachmentType.FILE, AttachmentType.LINK];
|
|
299
305
|
/**
|
|
300
|
-
*
|
|
306
|
+
* Permette di stabilire se la eqp-table contenente l'elenco degli allegati utilizza
|
|
307
|
+
* il multilingua oppure no
|
|
301
308
|
*/
|
|
302
309
|
this.isEqpTableMultiLanguage = false;
|
|
310
|
+
/**
|
|
311
|
+
* Permette di stabilire, in caso di gestione allegati multipli, se la tabella contenente l'elenco
|
|
312
|
+
* degli allegati deve essere paginata oppure no
|
|
313
|
+
*/
|
|
314
|
+
this.tablePaginatorVisible = true;
|
|
315
|
+
/**
|
|
316
|
+
* In caso di gestione allegati multipli, permette di stabilire la dimensione pagina di default
|
|
317
|
+
* per la tabella contenente l'elenco degli allegati
|
|
318
|
+
*/
|
|
319
|
+
this.tablePaginatorSize = null;
|
|
303
320
|
/**
|
|
304
321
|
* Input per definire le label da usare nel componente
|
|
305
322
|
*/
|
|
@@ -328,6 +345,10 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
328
345
|
* Restituisce la lista aggiornata degli allegati.
|
|
329
346
|
*/
|
|
330
347
|
this.localEditedAttachments = new EventEmitter();
|
|
348
|
+
/**
|
|
349
|
+
* Evento scatenato alla pressione del pulsante ESCI della modale di caricamento file.
|
|
350
|
+
*/
|
|
351
|
+
this.abortAddAttachment = new EventEmitter();
|
|
331
352
|
/**
|
|
332
353
|
* Evento di output che restituisce l'IAttachmentDTO selezionato per il download nel caso FileDataBase64, FileContentType o FileName non fossero specificati.
|
|
333
354
|
*/
|
|
@@ -339,8 +360,10 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
339
360
|
//#endregion
|
|
340
361
|
//#region Proprietà per gestione caricamento nuovo allegato
|
|
341
362
|
this.newAttachment = {};
|
|
363
|
+
this.newMultipleAttachments = [];
|
|
342
364
|
this.attachmentType = AttachmentType;
|
|
343
365
|
this.selectedFile = null;
|
|
366
|
+
this.selectedFiles = null;
|
|
344
367
|
this.showCropImage = false;
|
|
345
368
|
//#endregion
|
|
346
369
|
//#region Proprietà per gestione ridimensionamento file di tipo image
|
|
@@ -371,8 +394,6 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
371
394
|
if (this.attachmentsList == null)
|
|
372
395
|
this.attachmentsList = new Array();
|
|
373
396
|
this.checkAttachmentImage();
|
|
374
|
-
// if (!this.compressionOptions || !this.compressionOptions.maxSizeMB || !this.compressionOptions.maxWidthOrHeight)
|
|
375
|
-
// this.compressionOptions = { maxSizeMB: 0.5, maxWidthOrHeight: 1920, useWebWorker: true };
|
|
376
397
|
};
|
|
377
398
|
EqpAttachmentsComponent.prototype.reloadData = function () {
|
|
378
399
|
if (this.attachmentTable)
|
|
@@ -485,9 +506,25 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
485
506
|
* Apre la modale per la definizione dei parametri del nuovo file
|
|
486
507
|
*/
|
|
487
508
|
EqpAttachmentsComponent.prototype.openModalAddAttachment = function (attachmentType) {
|
|
509
|
+
//Se è stato richiesto il caricamento di un LINK o è impostato il caricamento di FILE SINGOLO allora apre la modale per
|
|
510
|
+
//il caricamento singolo del file altrimenti apre quella per il caricamento multiplo
|
|
511
|
+
// if (attachmentType == AttachmentType.LINK || (attachmentType == AttachmentType.FILE && this.loadMultipleFiles != true)) {
|
|
488
512
|
this.newAttachment = {};
|
|
489
513
|
this.newAttachment.IsImage = false;
|
|
490
514
|
this.newAttachment.AttachmentType = attachmentType;
|
|
515
|
+
this.newMultipleAttachments = new Array();
|
|
516
|
+
if (attachmentType == AttachmentType.LINK)
|
|
517
|
+
this.newMultipleAttachments.push(this.newAttachment);
|
|
518
|
+
this.createAttachmentForm();
|
|
519
|
+
//Apre la modale
|
|
520
|
+
this.dialofRefAddAttachment = this.dialog.open(this.dialogAddAttachment, {
|
|
521
|
+
disableClose: true,
|
|
522
|
+
hasBackdrop: true,
|
|
523
|
+
width: '60%',
|
|
524
|
+
maxHeight: '80%'
|
|
525
|
+
});
|
|
526
|
+
};
|
|
527
|
+
EqpAttachmentsComponent.prototype.createAttachmentForm = function () {
|
|
491
528
|
//Crea la form per la validazione dei campi
|
|
492
529
|
this.newAttachmentForm = this.formBuilder.group({
|
|
493
530
|
type: [this.newAttachment.AttachmentType, Validators.required],
|
|
@@ -496,19 +533,17 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
496
533
|
customHeight: [this.customHeight],
|
|
497
534
|
customWidth: [this.customWidth]
|
|
498
535
|
});
|
|
499
|
-
//Apre la modale
|
|
500
|
-
this.dialofRefAddAttachment = this.dialog.open(this.dialogAddAttachment, {
|
|
501
|
-
disableClose: true,
|
|
502
|
-
hasBackdrop: true,
|
|
503
|
-
width: '60%',
|
|
504
|
-
maxHeight: '80%'
|
|
505
|
-
});
|
|
506
536
|
};
|
|
507
|
-
EqpAttachmentsComponent.prototype.close = function () {
|
|
537
|
+
EqpAttachmentsComponent.prototype.close = function (emitCloseEvent) {
|
|
538
|
+
if (emitCloseEvent === void 0) { emitCloseEvent = true; }
|
|
508
539
|
this.newAttachment = {};
|
|
540
|
+
this.newMultipleAttachments = new Array();
|
|
509
541
|
this.abortFile();
|
|
510
|
-
this.newAttachmentForm
|
|
542
|
+
if (this.newAttachmentForm)
|
|
543
|
+
this.newAttachmentForm.reset();
|
|
511
544
|
this.dialofRefAddAttachment.close();
|
|
545
|
+
if (emitCloseEvent == true && this.abortAddAttachment)
|
|
546
|
+
this.abortAddAttachment.emit();
|
|
512
547
|
};
|
|
513
548
|
/**
|
|
514
549
|
* In base al tipo di allegato controlla se disabilitare o meno il pulsante per salvare.
|
|
@@ -516,23 +551,37 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
516
551
|
* @returns
|
|
517
552
|
*/
|
|
518
553
|
EqpAttachmentsComponent.prototype.disableSave = function () {
|
|
519
|
-
if (this.
|
|
520
|
-
|
|
554
|
+
if (this.loadMultipleFiles != true) {
|
|
555
|
+
if (this.newAttachment.AttachmentType == AttachmentType.FILE) {
|
|
556
|
+
return !this.newAttachment.FileDataBase64;
|
|
557
|
+
}
|
|
558
|
+
else {
|
|
559
|
+
return !this.newAttachment.FilePath;
|
|
560
|
+
}
|
|
521
561
|
}
|
|
522
562
|
else {
|
|
523
|
-
return
|
|
563
|
+
return this.newMultipleAttachments.filter(function (p) { return (p.AttachmentType == AttachmentType.FILE && !p.FileDataBase64) || (p.AttachmentType == AttachmentType.LINK && !p.FilePath); }).length > 0;
|
|
524
564
|
}
|
|
525
565
|
};
|
|
526
566
|
EqpAttachmentsComponent.prototype.confirmAddAttachment = function () {
|
|
527
|
-
if (this.
|
|
528
|
-
this.newAttachment.
|
|
529
|
-
|
|
530
|
-
this.attachmentsList
|
|
531
|
-
|
|
567
|
+
if (this.loadMultipleFiles != true) {
|
|
568
|
+
if (this.newAttachment.AttachmentType == AttachmentType.LINK && !this.newAttachment.FileName)
|
|
569
|
+
this.newAttachment.FileName = this.newAttachment.FilePath;
|
|
570
|
+
if (this.attachmentsList == null)
|
|
571
|
+
this.attachmentsList = new Array();
|
|
572
|
+
this.attachmentsList.push(this.newAttachment);
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
if (this.newMultipleAttachments == null || this.newMultipleAttachments.length == 0)
|
|
576
|
+
return;
|
|
577
|
+
if (this.attachmentsList == null)
|
|
578
|
+
this.attachmentsList = new Array();
|
|
579
|
+
this.attachmentsList = this.attachmentsList.concat(this.newMultipleAttachments);
|
|
580
|
+
}
|
|
532
581
|
if (this.attachmentTable)
|
|
533
582
|
this.attachmentTable.reloadDatatable();
|
|
534
583
|
this.localEditedAttachments.emit(this.attachmentsList);
|
|
535
|
-
this.
|
|
584
|
+
this.close(false);
|
|
536
585
|
};
|
|
537
586
|
/**
|
|
538
587
|
* Apre il dialog per l'anteprima dell'allegato selezionato.
|
|
@@ -602,36 +651,39 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
602
651
|
};
|
|
603
652
|
//#region Gestione caricamento file
|
|
604
653
|
/**
|
|
605
|
-
*
|
|
606
|
-
*
|
|
654
|
+
* Evento scatenato alla selezione del file (o dei file).
|
|
655
|
+
* 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
|
|
656
|
+
* mostrare le funzionalità del croppie (per ritagliare l'immagine) oppure no.
|
|
657
|
+
* Se il file caricato non è un immagine allora genera direttamente il base64 e lo associa all'allegato da salvare.
|
|
658
|
+
* Se invece il caricamento dei file è MULTIPLO e sono presenti più file allora esegue le stesse operazioni ignorando però il contrllo
|
|
659
|
+
* immagine per il croppie (in caso di caricamento multiplo le funzionalità del croppie sono disabilitate).
|
|
607
660
|
*/
|
|
608
661
|
EqpAttachmentsComponent.prototype.onFileInputChange = function (event) {
|
|
609
662
|
return __awaiter(this, void 0, void 0, function () {
|
|
610
|
-
var
|
|
611
|
-
return __generator(this, function (
|
|
612
|
-
switch (
|
|
663
|
+
var _a, checkOnlyImage, base64Result, i, newAttachment, checkOnlyImage;
|
|
664
|
+
return __generator(this, function (_b) {
|
|
665
|
+
switch (_b.label) {
|
|
613
666
|
case 0:
|
|
614
667
|
this.showCropImage = false;
|
|
668
|
+
if (!(__spread(event.target.files).length == 1 || this.loadMultipleFiles != true)) return [3 /*break*/, 5];
|
|
615
669
|
this.selectedFile = event.target.files[0];
|
|
670
|
+
this.selectedFiles = event.target.files;
|
|
616
671
|
if (!this.selectedFile)
|
|
617
672
|
return [2 /*return*/];
|
|
618
673
|
//Memorizza i dati per l'allegato
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
}
|
|
629
|
-
else if (!this.checkAcceptedFiles()) {
|
|
630
|
-
EqpAttachmentDialogService.Error(this.wrongTypeSelectedErrorMessage);
|
|
631
|
-
this.abortFile();
|
|
674
|
+
_a = this;
|
|
675
|
+
return [4 /*yield*/, this.createAttachmentFromUploadedFile(this.selectedFile, false)];
|
|
676
|
+
case 1:
|
|
677
|
+
//Memorizza i dati per l'allegato
|
|
678
|
+
_a.newAttachment = _b.sent();
|
|
679
|
+
this.newMultipleAttachments = new Array();
|
|
680
|
+
this.newMultipleAttachments.push(this.newAttachment);
|
|
681
|
+
checkOnlyImage = this.checkAllowOnlyImageFile(this.newAttachment);
|
|
682
|
+
if (checkOnlyImage == false)
|
|
632
683
|
return [2 /*return*/];
|
|
633
|
-
|
|
634
|
-
|
|
684
|
+
if (this.loadMultipleFiles == true && __spread(event.target.files).length == 1)
|
|
685
|
+
this.createAttachmentForm();
|
|
686
|
+
if (!(this.newAttachment.IsImage == true)) return [3 /*break*/, 2];
|
|
635
687
|
this.getImageDimensions(event.target.files[0]);
|
|
636
688
|
//Mostra il croppie e disabilita la form finchè non termina la modifica dell'immagine
|
|
637
689
|
this.newAttachmentForm.disable();
|
|
@@ -639,23 +691,103 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
639
691
|
this.newAttachmentForm.controls["customHeight"].enable();
|
|
640
692
|
this.showCropImage = true;
|
|
641
693
|
this.imageChangedEvent = event;
|
|
642
|
-
return [3 /*break*/,
|
|
643
|
-
case 1:
|
|
644
|
-
this.showCropImage = false;
|
|
645
|
-
return [4 /*yield*/, toBase64(this.selectedFile)];
|
|
694
|
+
return [3 /*break*/, 4];
|
|
646
695
|
case 2:
|
|
696
|
+
this.showCropImage = false;
|
|
697
|
+
return [4 /*yield*/, this.getBase64FromFile(this.selectedFile)];
|
|
698
|
+
case 3:
|
|
699
|
+
base64Result = _b.sent();
|
|
700
|
+
this.newAttachment.FileDataBase64 = base64Result.Base64File;
|
|
701
|
+
this.newAttachment.FileContentType = base64Result.ContentType;
|
|
702
|
+
_b.label = 4;
|
|
703
|
+
case 4: return [3 /*break*/, 9];
|
|
704
|
+
case 5:
|
|
705
|
+
this.selectedFiles = event.target.files;
|
|
706
|
+
if (!this.selectedFiles || this.selectedFiles.length == 0)
|
|
707
|
+
return [2 /*return*/];
|
|
708
|
+
this.newMultipleAttachments = new Array();
|
|
709
|
+
i = 0;
|
|
710
|
+
_b.label = 6;
|
|
711
|
+
case 6:
|
|
712
|
+
if (!(i < this.selectedFiles.length)) return [3 /*break*/, 9];
|
|
713
|
+
return [4 /*yield*/, this.createAttachmentFromUploadedFile(this.selectedFiles[i], true)];
|
|
714
|
+
case 7:
|
|
715
|
+
newAttachment = _b.sent();
|
|
716
|
+
checkOnlyImage = this.checkAllowOnlyImageFile(newAttachment);
|
|
717
|
+
if (checkOnlyImage == false)
|
|
718
|
+
return [2 /*return*/];
|
|
719
|
+
this.newMultipleAttachments.push(newAttachment);
|
|
720
|
+
_b.label = 8;
|
|
721
|
+
case 8:
|
|
722
|
+
i++;
|
|
723
|
+
return [3 /*break*/, 6];
|
|
724
|
+
case 9: return [2 /*return*/];
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
});
|
|
728
|
+
};
|
|
729
|
+
/**
|
|
730
|
+
* A partire dal FILE ricevuto in input ricostruisce l'oggetto IAttachmentDTO e lo restituisce.
|
|
731
|
+
* Se il parametro getBase64 viene passato a TRUE allora, sempre a partire dal file,genera il base64 e
|
|
732
|
+
* ricava il ContentType da associare all'oggetto IAttachmentDTO da restituire
|
|
733
|
+
* @param currentFile Oggetto FILE da processare
|
|
734
|
+
* @param getBase64 Se TRUE allora calcola base64 e ContentType del file passato in input
|
|
735
|
+
* @returns Restituisce un oggetto di tipo IAttachmentDTO
|
|
736
|
+
*/
|
|
737
|
+
EqpAttachmentsComponent.prototype.createAttachmentFromUploadedFile = function (currentFile, getBase64) {
|
|
738
|
+
if (getBase64 === void 0) { getBase64 = true; }
|
|
739
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
740
|
+
var newAttachment, base64Result;
|
|
741
|
+
return __generator(this, function (_a) {
|
|
742
|
+
switch (_a.label) {
|
|
743
|
+
case 0:
|
|
744
|
+
newAttachment = {};
|
|
745
|
+
//Memorizza i dati per l'allegato
|
|
746
|
+
newAttachment.AttachmentType = AttachmentType.FILE;
|
|
747
|
+
newAttachment.FileContentType = currentFile.type;
|
|
748
|
+
newAttachment.FileName = currentFile.name;
|
|
749
|
+
newAttachment.FileExtension = currentFile.name.substr(currentFile.name.lastIndexOf('.') + 1);
|
|
750
|
+
newAttachment.IsImage = AttachmentHelperService.checkImageFromMimeType(currentFile.type);
|
|
751
|
+
if (!(getBase64 == true)) return [3 /*break*/, 2];
|
|
752
|
+
return [4 /*yield*/, this.getBase64FromFile(currentFile)];
|
|
753
|
+
case 1:
|
|
754
|
+
base64Result = _a.sent();
|
|
755
|
+
newAttachment.FileDataBase64 = base64Result.Base64File;
|
|
756
|
+
newAttachment.FileContentType = base64Result.ContentType;
|
|
757
|
+
_a.label = 2;
|
|
758
|
+
case 2: return [2 /*return*/, newAttachment];
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
});
|
|
762
|
+
};
|
|
763
|
+
/**
|
|
764
|
+
* A partire dal file passato in input restituisce un oggetto
|
|
765
|
+
* contenente il base64 del file e il suo contentType
|
|
766
|
+
* @param currentFile Oggetto File da cui estrapolare base64 e contentType
|
|
767
|
+
* @returns Restituisce un oggetto avente le proprietà Base64File e ContentType
|
|
768
|
+
*/
|
|
769
|
+
EqpAttachmentsComponent.prototype.getBase64FromFile = function (currentFile) {
|
|
770
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
771
|
+
var base64File, contentType, result;
|
|
772
|
+
return __generator(this, function (_a) {
|
|
773
|
+
switch (_a.label) {
|
|
774
|
+
case 0: return [4 /*yield*/, toBase64(currentFile)];
|
|
775
|
+
case 1:
|
|
647
776
|
base64File = _a.sent();
|
|
777
|
+
contentType = null;
|
|
648
778
|
if (base64File) {
|
|
649
779
|
// Loris 20/01/2022: PROBLEMA - Quando eseguo l'upload di un file .sql non viene salvato/scaricato correttamente.
|
|
650
780
|
// Questo succede perchè non viene popolato il FileContentType. Per risolvere il problema
|
|
651
781
|
// faccio un controllo e se non esiste il FileContentType allora lo recupero dal base64 ottenuto.
|
|
652
|
-
|
|
782
|
+
contentType = base64File.split(",")[0].split(":")[1].split(";")[0];
|
|
653
783
|
// Un altro metodo per leggere il ccontent type del file è tramite una regular expression:
|
|
654
|
-
|
|
655
|
-
this.newAttachment.FileDataBase64 = base64File.split(",")[1];
|
|
784
|
+
base64File = base64File.split(",")[1];
|
|
656
785
|
}
|
|
657
|
-
|
|
658
|
-
|
|
786
|
+
result = {
|
|
787
|
+
Base64File: base64File,
|
|
788
|
+
ContentType: contentType
|
|
789
|
+
};
|
|
790
|
+
return [2 /*return*/, result];
|
|
659
791
|
}
|
|
660
792
|
});
|
|
661
793
|
});
|
|
@@ -666,12 +798,25 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
666
798
|
*/
|
|
667
799
|
EqpAttachmentsComponent.prototype.checkAcceptedFiles = function () {
|
|
668
800
|
var e_1, _a;
|
|
669
|
-
|
|
801
|
+
var _this = this;
|
|
802
|
+
if ((this.loadMultipleFiles != true && this.selectedFile.type.startsWith("video"))
|
|
803
|
+
|| (this.loadMultipleFiles == true && __spread(this.selectedFiles).filter(function (p) { return p.type.startsWith("video"); }).length > 0))
|
|
670
804
|
return false;
|
|
671
805
|
if (this.acceptedFileTypes == "*")
|
|
672
806
|
return true;
|
|
673
|
-
|
|
674
|
-
|
|
807
|
+
//Verifica che i tipi del file (o dei file) caricati siano coerenti con quelli accettati dalla direttiva
|
|
808
|
+
var accepted = true;
|
|
809
|
+
if (this.loadMultipleFiles != true)
|
|
810
|
+
accepted = this.acceptedFileTypes.includes(this.selectedFile.type);
|
|
811
|
+
else {
|
|
812
|
+
var uploadedFileTypes = __spread(this.selectedFiles).map(function (p) { return p.type; });
|
|
813
|
+
uploadedFileTypes.forEach(function (type) {
|
|
814
|
+
if (!_this.acceptedFileTypes.includes(type))
|
|
815
|
+
accepted = false;
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
//Questo controllo permette di gestire le casistiche per cui vengono indicati come tipi validi, ad esempio, 'image/*'
|
|
819
|
+
if (!accepted && this.loadMultipleFiles != true) {
|
|
675
820
|
try {
|
|
676
821
|
for (var _b = __values(this.acceptedFileTypes.split(",").filter(function (t) { return t.includes("*"); })), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
677
822
|
var t = _c.value;
|
|
@@ -690,6 +835,24 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
690
835
|
}
|
|
691
836
|
return accepted;
|
|
692
837
|
};
|
|
838
|
+
/**
|
|
839
|
+
* Se eqp-attachments è stata configurata per il caricamento delle sole immagini allora verifica che il file passato in
|
|
840
|
+
* input sia effettivamente un immagine o no.
|
|
841
|
+
* Se il controllo va a buon fine restituisce TRUE altrimenti mostra un messaggio d'errore e restituisce FALSE
|
|
842
|
+
*/
|
|
843
|
+
EqpAttachmentsComponent.prototype.checkAllowOnlyImageFile = function (newAttachment) {
|
|
844
|
+
if (this.allowOnlyImages == true && newAttachment.IsImage != true) {
|
|
845
|
+
EqpAttachmentDialogService.Error(this.noImageSelectedErrorMessage);
|
|
846
|
+
this.abortFile();
|
|
847
|
+
return false;
|
|
848
|
+
}
|
|
849
|
+
else if (!this.checkAcceptedFiles()) {
|
|
850
|
+
EqpAttachmentDialogService.Error(this.wrongTypeSelectedErrorMessage);
|
|
851
|
+
this.abortFile();
|
|
852
|
+
return false;
|
|
853
|
+
}
|
|
854
|
+
return true;
|
|
855
|
+
};
|
|
693
856
|
EqpAttachmentsComponent.prototype.getImageDimensions = function (img) {
|
|
694
857
|
var _this = this;
|
|
695
858
|
var reader = new FileReader();
|
|
@@ -758,12 +921,14 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
758
921
|
if (this.imageInput)
|
|
759
922
|
this.imageInput.nativeElement.value = '';
|
|
760
923
|
this.selectedFile = null;
|
|
924
|
+
this.selectedFiles = null;
|
|
761
925
|
this.showCropImage = false;
|
|
762
926
|
this.newAttachment.IsImage = false;
|
|
763
927
|
this.newAttachment.FileDataBase64 = null;
|
|
764
928
|
this.newAttachment.FileName = null;
|
|
765
929
|
this.newAttachment.FileExtension = null;
|
|
766
930
|
this.newAttachment.FileContentType = null;
|
|
931
|
+
this.newMultipleAttachments = new Array();
|
|
767
932
|
this.customHeight = null;
|
|
768
933
|
this.customWidth = null;
|
|
769
934
|
this.originalHeight = null;
|
|
@@ -773,7 +938,8 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
773
938
|
{ type: MatDialog },
|
|
774
939
|
{ type: FormBuilder },
|
|
775
940
|
{ type: DomSanitizer },
|
|
776
|
-
{ type: HttpClient }
|
|
941
|
+
{ type: HttpClient },
|
|
942
|
+
{ type: ChangeDetectorRef }
|
|
777
943
|
]; };
|
|
778
944
|
__decorate([
|
|
779
945
|
Input("disableAction")
|
|
@@ -793,6 +959,9 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
793
959
|
__decorate([
|
|
794
960
|
Input("multipleAttachment")
|
|
795
961
|
], EqpAttachmentsComponent.prototype, "multipleAttachment", void 0);
|
|
962
|
+
__decorate([
|
|
963
|
+
Input("loadMultipleFiles")
|
|
964
|
+
], EqpAttachmentsComponent.prototype, "loadMultipleFiles", void 0);
|
|
796
965
|
__decorate([
|
|
797
966
|
Input("attachmentsColumns")
|
|
798
967
|
], EqpAttachmentsComponent.prototype, "attachmentsColumns", void 0);
|
|
@@ -826,6 +995,12 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
826
995
|
__decorate([
|
|
827
996
|
Input("isEqpTableMultiLanguage")
|
|
828
997
|
], EqpAttachmentsComponent.prototype, "isEqpTableMultiLanguage", void 0);
|
|
998
|
+
__decorate([
|
|
999
|
+
Input("tablePaginatorVisible")
|
|
1000
|
+
], EqpAttachmentsComponent.prototype, "tablePaginatorVisible", void 0);
|
|
1001
|
+
__decorate([
|
|
1002
|
+
Input("tablePaginatorSize")
|
|
1003
|
+
], EqpAttachmentsComponent.prototype, "tablePaginatorSize", void 0);
|
|
829
1004
|
__decorate([
|
|
830
1005
|
Input("downloadTooltipPosition")
|
|
831
1006
|
], EqpAttachmentsComponent.prototype, "downloadTooltipPosition", void 0);
|
|
@@ -886,6 +1061,9 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
886
1061
|
__decorate([
|
|
887
1062
|
Output()
|
|
888
1063
|
], EqpAttachmentsComponent.prototype, "localEditedAttachments", void 0);
|
|
1064
|
+
__decorate([
|
|
1065
|
+
Output()
|
|
1066
|
+
], EqpAttachmentsComponent.prototype, "abortAddAttachment", void 0);
|
|
889
1067
|
__decorate([
|
|
890
1068
|
Output("downloadAttachment")
|
|
891
1069
|
], EqpAttachmentsComponent.prototype, "downloadAttachment", void 0);
|
|
@@ -895,6 +1073,9 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
895
1073
|
__decorate([
|
|
896
1074
|
ViewChild('dialogAddAttachment', { static: true })
|
|
897
1075
|
], EqpAttachmentsComponent.prototype, "dialogAddAttachment", void 0);
|
|
1076
|
+
__decorate([
|
|
1077
|
+
ViewChild('dialogAddMultipleAttachment', { static: true })
|
|
1078
|
+
], EqpAttachmentsComponent.prototype, "dialogAddMultipleAttachment", void 0);
|
|
898
1079
|
__decorate([
|
|
899
1080
|
ViewChild(ImageCropperComponent)
|
|
900
1081
|
], EqpAttachmentsComponent.prototype, "imageCropper", void 0);
|
|
@@ -913,7 +1094,7 @@ var EqpAttachmentsComponent = /** @class */ (function () {
|
|
|
913
1094
|
EqpAttachmentsComponent = __decorate([
|
|
914
1095
|
Component({
|
|
915
1096
|
selector: 'eqp-attachments',
|
|
916
|
-
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>",
|
|
1097
|
+
template: "<!-- Se richiesta la gestione multipla mostra il pulsante di aggiunta e la tabella con l'elenco allegati -->\r\n<div *ngIf=\"multipleAttachment == true\">\r\n <mat-card [ngStyle]=\"{ 'box-shadow': showMatCard == false ? 'none' : null }\">\r\n <mat-card-header>\r\n <div class=\"col-md-6\">\r\n <div class=\"text-nowrap eqp-attachments-header-title\" *ngIf=\"showHeader == true\">\r\n {{headerTitle}}\r\n </div>\r\n </div>\r\n <div class=\"col-md-6 text-right\">\r\n <div class=\"row justify-content-end\">\r\n <!-- Template del button per l'aggiunta di un allegato -->\r\n <ng-container *ngTemplateOutlet=\"addAttachmentButton\"></ng-container>\r\n </div>\r\n </div>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <eqp-table #attachmentTable [createMatCard]=\"false\" #table [columns]=\"attachmentsColumns\"\r\n [isMultiLanguage]=\"isEqpTableMultiLanguage\" [data]=\"attachmentsList\"\r\n [paginatorVisible]=\"tablePaginatorVisible\" [matPaginatorSize]=\"tablePaginatorSize\"\r\n [emptyTableMessage]=\"emptyTableMessage\" [searchText]=\"eqpTableSearchText\">\r\n </eqp-table>\r\n </mat-card-content>\r\n </mat-card>\r\n</div>\r\n\r\n<!-- Se richiesta la gestione singola mostra il pulsante di caricamento di un singolo file -->\r\n<div *ngIf=\"multipleAttachment != true\">\r\n <!-- Template del button per l'aggiunta di un allegato -->\r\n <ng-container *ngTemplateOutlet=\"addAttachmentButton\"></ng-container>\r\n\r\n <button class=\"mb-2 mr-2 eqp-attachments-download-btn\" (click)=\"viewAttachment(attachmentsList[0])\" type=\"button\"\r\n mat-raised-button *ngIf=\"attachmentsList && attachmentsList.length > 0 && attachmentsList[0]\" color=\"primary\">\r\n <mat-icon *ngIf=\"attachmentsList[0].AttachmentType == AttachmentType.FILE\">download</mat-icon>\r\n <mat-icon *ngIf=\"attachmentsList[0].AttachmentType != AttachmentType.FILE\">open_in_new</mat-icon>\r\n {{attachmentsList[0].AttachmentType == AttachmentType.FILE ? downloadLabel : openLinkLabel}}\r\n </button>\r\n <button class=\"mb-2 mr-2 eqp-attachments-preview-btn\" (click)=\"openPreviewDialog(attachmentsList[0])\" type=\"button\"\r\n mat-raised-button color=\"primary\"\r\n *ngIf=\"attachmentsList && attachmentsList.length > 0 && attachmentsList[0] && (!attachmentsList[0].FileContentType || (!attachmentsList[0].FileContentType.startsWith('video') && !attachmentsList[0].FileContentType.startsWith('audio')))\">\r\n <mat-icon>visibility</mat-icon> {{previewLabel}}\r\n </button>\r\n <button class=\"mb-2 eqp-attachments-delete-btn\" (click)=\"deleteAttachment(attachmentsList[0])\" type=\"button\"\r\n mat-raised-button *ngIf=\"attachmentsList && attachmentsList.length > 0 && attachmentsList[0]\"\r\n [disabled]=\"isDisabled\">\r\n <mat-icon>delete</mat-icon> {{deleteLabel}}\r\n </button>\r\n\r\n <div class=\"row\" style=\"margin-top: 10px;\"\r\n *ngIf=\"attachmentsList.length > 0 && attachmentsList[0] && attachmentsList[0].FileDataBase64 && attachmentsList[0].IsImage == true\">\r\n <div class=\"col-sm-12\">\r\n <div class=\"single-attachment-inline-preview-container\">\r\n <img src=\"data:image/png;base64,{{attachmentsList[0].FileDataBase64}}\">\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"row\" *ngIf=\"attachmentsList.length > 0 && attachmentsList[0] && attachmentsList[0].IsImage != true\">\r\n <div class=\"col-sm-12\">\r\n <mat-form-field>\r\n <mat-label>{{fileNameLabel}}</mat-label>\r\n <input readonly matInput [(ngModel)]=\"attachmentsList[0].FileName\">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n\r\n\r\n<ng-template #dialogAddAttachment>\r\n <div class=\"container-fluid eqp-attachments-dialog-add-container\"\r\n style=\"max-height: 70vh !important; overflow-x: hidden; overflow-y: auto;\">\r\n <form [formGroup]=\"newAttachmentForm\" (ngSubmit)=\"confirmAddAttachment()\" *ngIf=\"newAttachmentForm\">\r\n <div class=\"row\">\r\n <div class=\"header-title-standard\"> {{addButtonLabel}} {{ newAttachment.AttachmentType ==\r\n attachmentType.FILE ?\r\n 'File' : 'Link'}} </div>\r\n </div>\r\n <div class=\"row\" style=\"margin-top: 20px;\">\r\n <div class=\"col-sm-12\" *ngIf=\"newAttachment.AttachmentType == attachmentType.FILE\">\r\n <input #imageInput style=\"display:none;\" id=\"file_attachment\"\r\n name=\"file_attachment\" type=\"file\" (change)=\"onFileInputChange($event)\"\r\n [accept]=\"acceptedFileTypes\" [multiple]=\"loadMultipleFiles\"/>\r\n <button (click)=\"imageInput.click()\" type=\"button\" style=\"margin-left: 10px;\" id=\"file_attachment\"\r\n mat-raised-button color=\"primary\" [disabled]=\"showCropImage == true\"\r\n class=\"mb-2 btn btn-primary eqp-attachments-upload-btn\" *ngIf=\"(loadMultipleFiles != true && !newAttachment.FileDataBase64) || (loadMultipleFiles == true && newMultipleAttachments && newMultipleAttachments.length == 0)\">\r\n <mat-icon>cloud_upload</mat-icon>\r\n {{uploadFileLabel}}\r\n </button>\r\n <button (click)=\"abortFile()\" type=\"button\" style=\"margin-left: 10px;\" mat-raised-button\r\n *ngIf=\"(loadMultipleFiles != true && newAttachment.FileDataBase64) || (loadMultipleFiles == true && newMultipleAttachments && newMultipleAttachments.length > 0)\" class=\"mb-2 eqp-attachments-delete-btn\">\r\n <mat-icon>delete</mat-icon> {{deleteLabel}}\r\n </button>\r\n </div>\r\n <div class=\"col-sm-12\" *ngIf=\"newAttachment.AttachmentType == 2 || (selectedFile && loadMultipleFiles != true)\">\r\n <mat-form-field style=\"width: 100%;\">\r\n <mat-label> {{fileNameLabel}} </mat-label>\r\n <input formControlName=\"name\" matInput [(ngModel)]=\"newAttachment.FileName\">\r\n </mat-form-field>\r\n </div>\r\n <div class=\"col-sm-12\" *ngIf=\"newAttachment.AttachmentType == 2\">\r\n <mat-form-field style=\"width: 100%;\">\r\n <mat-label> Link </mat-label>\r\n <input formControlName=\"path\" required matInput [(ngModel)]=\"newAttachment.FilePath\">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n\r\n <!-- Riporta l'elenco dei nomi dei file caricati contemporaneamente (visibile solo se loadMultipleFiles = TRUE e se ci sono realmente pi\u00F9 file senza link) -->\r\n <div class=\"row\" *ngIf=\"loadMultipleFiles == true && newMultipleAttachments && newMultipleAttachments.length > 0 && newMultipleAttachments[0].AttachmentType != attachmentType.LINK\">\r\n <div class=\"col-12\" *ngFor=\"let attach of newMultipleAttachments\">\r\n <mat-form-field style=\"width: 100%\">\r\n <mat-label> {{fileNameLabel}} </mat-label>\r\n <input disabled matInput [(ngModel)]=\"attach.FileName\" [ngModelOptions]=\"{standalone: true}\">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n\r\n <!-- Riporta la preview dell'immagine quando \u00E8 richiesto il caricamento MULTIPLO ma \u00E8 stata selezionata una sola immagine (quindi \u00E8 entrato in gioco anche il croppie) -->\r\n <div class=\"row\" *ngIf=\"loadMultipleFiles == true && showCropImage != true && newMultipleAttachments && newMultipleAttachments.length == 1 && newMultipleAttachments[0].IsImage == true\" style=\"margin-top: 10px;\">\r\n <div class=\"col-4\">\r\n <div class=\"single-attachment-inline-preview-container\">\r\n <img src=\"data:image/png;base64,{{newMultipleAttachments[0].FileDataBase64}}\">\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- Riporta la preview dell'immagine quando \u00E8 richiesto il caricamento SINGOLO ed \u00E8 stata selezionata un'immagine -->\r\n <div class=\"row\" *ngIf=\"loadMultipleFiles != true && showCropImage != true && newAttachment.FileDataBase64 && newAttachment.IsImage == true\" style=\"margin-top: 10px;\">\r\n <div class=\"col-4\">\r\n <div class=\"single-attachment-inline-preview-container\">\r\n <img src=\"data:image/png;base64,{{newAttachment.FileDataBase64}}\">\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- Richiama il template per le funzionalit\u00E0 del CROPPIE -->\r\n <ng-container [ngTemplateOutlet]=\"croppieTemplate\" [ngTemplateOutletContext]=\"{form: newAttachmentForm}\" *ngIf=\"showCropImage == true\"></ng-container>\r\n\r\n <div class=\"row mt-2\">\r\n <div class=\"col-sm-12 text-right\">\r\n <button class=\"btn btn-primary mat-raised-button eqp-attachments-save-btn mr-2\" type=\"submit\"\r\n [disabled]=\"showCropImage == true || (loadMultipleFiles != true && newAttachmentForm?.disabled == true) || disableSave()\">\r\n {{saveLabel}}\r\n </button>\r\n <button class=\"btn mat-raised-button eqp-attachments-exit-btn\" (click)=\"close()\"\r\n [disabled]=\"showCropImage == true\" type=\"button\">\r\n {{exitLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n </form>\r\n </div>\r\n</ng-template>\r\n\r\n<ng-template #inlinePreviewTemplate let-row=\"row\">\r\n <div class=\"inline-preview-container\" *ngIf=\"row.AttachmentType != AttachmentType.LINK && row.IsImage\" (click)=\"openPreviewDialog(row)\">\r\n <img src=\"data:image/png;base64,{{row.FileThumbnailBase64 ? row.FileThumbnailBase64 : row.FileDataBase64}}\">\r\n </div>\r\n <div class=\"inline-preview-container\" *ngIf=\"row.AttachmentType != AttachmentType.LINK && !row.IsImage\" (click)=\"openPreviewDialog(row)\">\r\n <i [ngClass]=\"getAttachmentIcon(row)\"></i>\r\n </div>\r\n</ng-template>\r\n\r\n\r\n<ng-template #dialogPreview>\r\n <div class=\"container-fluid\" style=\"max-height: 70vh !important;\" *ngIf=\"selectedAttachment\">\r\n <div class=\"row\">\r\n <div class=\"header-title-standard\">\r\n {{previewLabel}} {{ selectedAttachment?.AttachmentType == attachmentType.FILE ? 'File' : 'Link'}}\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mt-2\">\r\n <!-- ANTEPRIMA IMMAGINE -->\r\n <div class=\"col-12 text-center preview-container\" *ngIf=\"selectedAttachment.IsImage\">\r\n <img class=\"image-preview\"\r\n src=\"data:image/png;base64,{{selectedAttachment.FileDataBase64 ? selectedAttachment.FileDataBase64 : selectedAttachment.FileThumbnailBase64}}\">\r\n </div>\r\n\r\n <!-- ANTEPRIMA LINK -->\r\n <div class=\"col-12 preview-container\" *ngIf=\"!selectedAttachment.IsImage\">\r\n <iframe class=\"link-preview\" [src]=\"selectedAttachment.TrustedUrl\"\r\n [title]=\"selectedAttachment.FileName\"></iframe>\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mt-3\">\r\n <div class=\"col-sm-12 text-right\">\r\n <button class=\"btn btn-primary mat-raised-button eqp-attachments-save-btn mr-2\" type=\"submit\"\r\n (click)=\"viewAttachment(selectedAttachment)\"\r\n *ngIf=\"selectedAttachment.AttachmentType != AttachmentType.LINK\">\r\n {{downloadLabel}}\r\n </button>\r\n <button class=\"btn mat-raised-button eqp-attachments-exit-btn\" mat-dialog-close type=\"button\"\r\n (click)=\"selectedAttachment = null\">\r\n {{exitLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n</ng-template>\r\n\r\n\r\n<!-- TEMPLATE PER IL PULSANTE DI AGGIUNTA NUOVO ALLEGATO -->\r\n<ng-template #addAttachmentButton>\r\n\r\n <!-- \r\n Pulsanti per l'aggiunta di un file o un link. Ne viene visualizzato uno se:\r\n - gli allowedTypes sono stati specificati, nell'array ne \u00E8 presente uno solo, quello inserito \u00E8 AttachmentType.FILE (o AttachmentType.LINK) \r\n e sono nella gestione di pi\u00F9 allegati (multipleAttachment == true)\r\n OPPURE\r\n - gli allowedTypes sono stati specificati, nell'array ne \u00E8 presente uno solo, quello inserito \u00E8 AttachmentType.FILE (o AttachmentType.LINK) \r\n e sono nella gestione di un singolo allegato (multipleAttachment == true) e non ne \u00E8 ancora stato selezionato uno (ovvero attachmentsList non esiste o non ha elementi)\r\n -->\r\n <button class=\"btn btn-primary mb-4 mr-5 eqp-attachments-add-btn\" mat-raised-button color=\"primary\" type=\"button\"\r\n *ngIf=\"allowedTypes && allowedTypes.length == 1 && (multipleAttachment == true || (!attachmentsList || attachmentsList.length == 0 || (attachmentsList.length > 0 && !attachmentsList[0])))\"\r\n (click)=\"openModalAddAttachment(allowedTypes[0])\" [disabled]=\"isDisabled\">\r\n <!-- Per l'aggiunta dei file mostro un'icona diversa dall'aggiunta dei link -->\r\n <mat-icon *ngIf=\"allowedTypes[0] == 1\">cloud_upload</mat-icon>\r\n <i class=\"fas fa-link\" *ngIf=\"allowedTypes[0] == 2\"></i>\r\n <span style=\"margin-left: 10px;\">{{addButtonLabel}} {{allowedTypes[0] == 1 ? \"file\" : \"link\"}}</span>\r\n </button>\r\n\r\n\r\n <!-- Pulsante per aprire il menu per la scelta del tipo di Attachment da creare -->\r\n <button class=\"btn btn-primary mb-4 mr-5 eqp-attachments-add-btn\" mat-raised-button color=\"primary\" type=\"button\"\r\n [matMenuTriggerFor]=\"attachmentTypeMenu\" [disabled]=\"isDisabled\"\r\n *ngIf=\"allowedTypes && allowedTypes.length > 1 && (multipleAttachment == true || (!attachmentsList || attachmentsList.length == 0 || (attachmentsList.length > 0 && !attachmentsList[0])))\">\r\n <mat-icon *ngIf=\"multipleAttachment != true\">cloud_upload</mat-icon>\r\n <mat-icon *ngIf=\"multipleAttachment == true\">add</mat-icon>\r\n <span style=\"margin-left: 0px;\"> {{addButtonLabel}} </span>\r\n </button>\r\n <mat-menu #attachmentTypeMenu=\"matMenu\">\r\n <button mat-menu-item (click)=\"openModalAddAttachment(1)\" class=\"eqp-attachments-file-btn\">\r\n <i class=\"fas fa-file\"></i>\r\n <span style=\"margin-left: 10px;\">File</span>\r\n </button>\r\n <button mat-menu-item (click)=\"openModalAddAttachment(2)\" class=\"eqp-attachments-link-btn\">\r\n <i class=\"fas fa-link\"></i>\r\n <span style=\"margin-left: 10px;\">Link</span>\r\n </button>\r\n </mat-menu>\r\n</ng-template>\r\n\r\n\r\n<ng-template #croppieTemplate let-form=\"form\">\r\n <div class=\"row mt-2 mb-2\" [formGroup]=\"form\">\r\n <div class=\"col-md-12 d-flex align-items-center justify-content-center\">\r\n <span class=\"mr-1\">Max H(px):</span>\r\n <mat-form-field>\r\n <input formControlName=\"customHeight\" type=\"number\" matInput [(ngModel)]=\"customHeight\"\r\n (change)=\"onDimensionsChange('H')\">\r\n </mat-form-field>\r\n\r\n <span class=\"ml-2 mr-1\">Max W(px):</span>\r\n <mat-form-field>\r\n <input formControlName=\"customWidth\" type=\"number\" matInput [(ngModel)]=\"customWidth\"\r\n (change)=\"onDimensionsChange('W')\">\r\n </mat-form-field>\r\n\r\n <button class=\"btn btn-primary mat-raised-button ml-2\" (click)=\"restoreOriginalDimensions()\"\r\n [disabled]=\"customWidth == originalWidth && customHeight == originalHeight\">\r\n <mat-icon style=\"vertical-align: middle;\">replay</mat-icon>\r\n </button>\r\n </div>\r\n </div>\r\n <div class=\"row justify-content-center\">\r\n <div style=\"max-height: 450px; max-width: 450px;\">\r\n <image-cropper [imageChangedEvent]=\"imageChangedEvent\" [maintainAspectRatio]=\"false\"\r\n [autoCrop]=\"false\" [containWithinAspectRatio]=\"false\" [aspectRatio]=\"4/3\"\r\n [cropperMinWidth]=\"128\" [onlyScaleDown]=\"true\" [roundCropper]=\"false\" [canvasRotation]=\"0\"\r\n [transform]=\"transform\" [alignImage]=\"'left'\" format=\"png\" (imageCropped)=\"imageCropped($event)\"\r\n [resizeToWidth]=\"customWidth\" [resizeToHeight]=\"customHeight\">\r\n </image-cropper>\r\n </div>\r\n </div>\r\n <div class=\"row justify-content-center mt-2\">\r\n <div style=\"max-height: 450px; max-width: 450px;\">\r\n <button class=\"btn btn-primary mat-raised-button eqp-attachments-confirm-btn mr-2\" type=\"button\"\r\n (click)=\"confirmCrop()\">\r\n {{confirmLabel}}\r\n </button>\r\n <button class=\"btn mat-raised-button eqp-attachments-abort-btn\" type=\"button\" (click)=\"abortFile()\">\r\n {{abortLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n</ng-template>",
|
|
917
1098
|
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}"]
|
|
918
1099
|
})
|
|
919
1100
|
], EqpAttachmentsComponent);
|