@eqproject/eqp-attachments 0.1.14 → 2.0.0
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 +3 -0
- package/esm2020/eqproject-eqp-attachments.mjs +5 -0
- package/esm2020/lib/eqp-attachments.component.mjs +830 -0
- package/esm2020/lib/eqp-attachments.module.mjs +39 -0
- package/esm2020/lib/helpers/attachment.helper.mjs +61 -0
- package/esm2020/lib/interfaces/IAttachment.mjs +6 -0
- package/esm2020/lib/interfaces/IOptions.mjs +2 -0
- package/esm2020/lib/modules/material.module.mjs +231 -0
- package/esm2020/lib/services/eqp-attachment-dialog.service.mjs +103 -0
- package/esm2020/public-api.mjs +10 -0
- package/fesm2015/eqproject-eqp-attachments.mjs +1275 -0
- package/fesm2015/eqproject-eqp-attachments.mjs.map +1 -0
- package/fesm2020/eqproject-eqp-attachments.mjs +1264 -0
- package/fesm2020/eqproject-eqp-attachments.mjs.map +1 -0
- package/{eqproject-eqp-attachments.d.ts → index.d.ts} +1 -1
- package/lib/eqp-attachments.component.d.ts +15 -1
- package/lib/eqp-attachments.module.d.ts +10 -0
- package/lib/helpers/attachment.helper.d.ts +3 -0
- package/lib/modules/material.module.d.ts +35 -0
- package/lib/services/eqp-attachment-dialog.service.d.ts +3 -0
- package/package.json +29 -16
- package/bundles/eqproject-eqp-attachments.umd.js +0 -1378
- package/bundles/eqproject-eqp-attachments.umd.js.map +0 -1
- package/bundles/eqproject-eqp-attachments.umd.min.js +0 -2
- package/bundles/eqproject-eqp-attachments.umd.min.js.map +0 -1
- package/eqproject-eqp-attachments.metadata.json +0 -1
- package/esm2015/eqproject-eqp-attachments.js +0 -6
- package/esm2015/lib/eqp-attachments.component.js +0 -826
- package/esm2015/lib/eqp-attachments.module.js +0 -26
- package/esm2015/lib/helpers/attachment.helper.js +0 -62
- package/esm2015/lib/interfaces/IAttachment.js +0 -6
- package/esm2015/lib/interfaces/IOptions.js +0 -1
- package/esm2015/lib/modules/material.module.js +0 -108
- package/esm2015/lib/services/eqp-attachment-dialog.service.js +0 -104
- package/esm2015/public-api.js +0 -9
- package/esm5/eqproject-eqp-attachments.js +0 -6
- package/esm5/lib/eqp-attachments.component.js +0 -885
- package/esm5/lib/eqp-attachments.module.js +0 -29
- package/esm5/lib/helpers/attachment.helper.js +0 -63
- package/esm5/lib/interfaces/IAttachment.js +0 -6
- package/esm5/lib/interfaces/IOptions.js +0 -1
- package/esm5/lib/modules/material.module.js +0 -111
- package/esm5/lib/services/eqp-attachment-dialog.service.js +0 -113
- package/esm5/public-api.js +0 -9
- package/fesm2015/eqproject-eqp-attachments.js +0 -1117
- package/fesm2015/eqproject-eqp-attachments.js.map +0 -1
- package/fesm5/eqproject-eqp-attachments.js +0 -1192
- package/fesm5/eqproject-eqp-attachments.js.map +0 -1
|
@@ -1,1117 +0,0 @@
|
|
|
1
|
-
import { __decorate, __awaiter } from 'tslib';
|
|
2
|
-
import { ɵɵdefineInjectable, Injectable, EventEmitter, ChangeDetectorRef, Input, Output, ViewChild, Component, NgModule } from '@angular/core';
|
|
3
|
-
import { Validators, FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
4
|
-
import { base64ToFile, ImageCropperComponent, ImageCropperModule } from 'ngx-image-cropper';
|
|
5
|
-
import imageCompression from 'browser-image-compression';
|
|
6
|
-
import { TooltipPositionType, TypeColumn, EqpTableModule } from '@eqproject/eqp-table';
|
|
7
|
-
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
|
8
|
-
import Swal from 'sweetalert2';
|
|
9
|
-
import { DomSanitizer } from '@angular/platform-browser';
|
|
10
|
-
import { HttpClient } from '@angular/common/http';
|
|
11
|
-
import { CommonModule } from '@angular/common';
|
|
12
|
-
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
13
|
-
import { MatButtonModule } from '@angular/material/button';
|
|
14
|
-
import { MatInputModule } from '@angular/material/input';
|
|
15
|
-
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
|
16
|
-
import { MatDatepickerModule } from '@angular/material/datepicker';
|
|
17
|
-
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
18
|
-
import { MatRadioModule } from '@angular/material/radio';
|
|
19
|
-
import { MatSelectModule } from '@angular/material/select';
|
|
20
|
-
import { MatSliderModule } from '@angular/material/slider';
|
|
21
|
-
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
22
|
-
import { MatMenuModule } from '@angular/material/menu';
|
|
23
|
-
import { MatSidenavModule } from '@angular/material/sidenav';
|
|
24
|
-
import { MatToolbarModule } from '@angular/material/toolbar';
|
|
25
|
-
import { MatListModule } from '@angular/material/list';
|
|
26
|
-
import { MatGridListModule } from '@angular/material/grid-list';
|
|
27
|
-
import { MatCardModule } from '@angular/material/card';
|
|
28
|
-
import { MatStepperModule } from '@angular/material/stepper';
|
|
29
|
-
import { MatTabsModule } from '@angular/material/tabs';
|
|
30
|
-
import { MatExpansionModule } from '@angular/material/expansion';
|
|
31
|
-
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
|
32
|
-
import { MatChipsModule } from '@angular/material/chips';
|
|
33
|
-
import { MatIconModule } from '@angular/material/icon';
|
|
34
|
-
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
35
|
-
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
36
|
-
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
37
|
-
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
|
38
|
-
import { MatTableModule } from '@angular/material/table';
|
|
39
|
-
import { MatSortModule } from '@angular/material/sort';
|
|
40
|
-
import { MatPaginatorModule } from '@angular/material/paginator';
|
|
41
|
-
import { MatNativeDateModule } from '@angular/material/core';
|
|
42
|
-
|
|
43
|
-
var AttachmentType;
|
|
44
|
-
(function (AttachmentType) {
|
|
45
|
-
AttachmentType[AttachmentType["FILE"] = 1] = "FILE";
|
|
46
|
-
AttachmentType[AttachmentType["LINK"] = 2] = "LINK";
|
|
47
|
-
})(AttachmentType || (AttachmentType = {}));
|
|
48
|
-
|
|
49
|
-
let AttachmentHelperService = class AttachmentHelperService {
|
|
50
|
-
constructor() {
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Restituisce TRUE se il mime type passato nel parametro corrisponde ad un mime type di un'immagine
|
|
54
|
-
* @param mimeType Mime Type da verificare
|
|
55
|
-
*/
|
|
56
|
-
static checkImageFromMimeType(mimeType) {
|
|
57
|
-
return this.imageMimeTypes.find(s => s == mimeType) != null;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* In base all'estensione passata come parametro, restituisce la FontAwesome corretta da utilizzare.
|
|
61
|
-
* Se l'estensione non viene trovata nella costante riportata dentro common.model.ts restituisce un icona standard
|
|
62
|
-
* @param extension Estensione del file per cui restituire l'icona corretta
|
|
63
|
-
*/
|
|
64
|
-
static getIconFromFileExtensione(extension) {
|
|
65
|
-
let fileIcon = this.fileExtensionIcon[extension];
|
|
66
|
-
return (fileIcon !== null && fileIcon !== void 0 ? fileIcon : "fas fa-file");
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
AttachmentHelperService.imageMimeTypes = ["image/bmp", "image/gif", "image/jpeg", "image/tiff", "image/png"];
|
|
70
|
-
AttachmentHelperService.fileExtensionIcon = {
|
|
71
|
-
"txt": "fas fa-file-text",
|
|
72
|
-
"pdf": "fas fa-file-pdf",
|
|
73
|
-
"doc": "fas fa-file-word",
|
|
74
|
-
"docx": "fas fa-file-word",
|
|
75
|
-
"xls": "fas fa-file-excel",
|
|
76
|
-
"xlsx": "fas fa-file-excel",
|
|
77
|
-
"jpg": "fas fa-file-image",
|
|
78
|
-
"jpeg": "fas fa-file-image",
|
|
79
|
-
"png": "fas fa-file-image",
|
|
80
|
-
"bmp": "fas fa-file-image",
|
|
81
|
-
"mkv": "fas fa-file-video",
|
|
82
|
-
"flv": "fas fa-file-video",
|
|
83
|
-
"gif": "fas fa-file-video",
|
|
84
|
-
"gifv": "fas fa-file-video",
|
|
85
|
-
"avi": "fas fa-file-video",
|
|
86
|
-
"wmv": "fas fa-file-video",
|
|
87
|
-
"mp4": "fas fa-file-video",
|
|
88
|
-
"m4p": "fas fa-file-video",
|
|
89
|
-
"m4v": "fas fa-file-video",
|
|
90
|
-
"mpg": "fas fa-file-video",
|
|
91
|
-
"mp2": "fas fa-file-video",
|
|
92
|
-
"mpeg": "fas fa-file-video",
|
|
93
|
-
"mpe": "fas fa-file-video",
|
|
94
|
-
"mpv": "fas fa-file-video",
|
|
95
|
-
"m2v": "fas fa-file-video",
|
|
96
|
-
"3gp": "fas fa-file-video",
|
|
97
|
-
"3g2": "fas fa-file-video",
|
|
98
|
-
"mp3": "fas fa-file-audio",
|
|
99
|
-
};
|
|
100
|
-
AttachmentHelperService.ɵprov = ɵɵdefineInjectable({ factory: function AttachmentHelperService_Factory() { return new AttachmentHelperService(); }, token: AttachmentHelperService, providedIn: "root" });
|
|
101
|
-
AttachmentHelperService = __decorate([
|
|
102
|
-
Injectable({
|
|
103
|
-
providedIn: 'root'
|
|
104
|
-
})
|
|
105
|
-
], AttachmentHelperService);
|
|
106
|
-
|
|
107
|
-
let EqpAttachmentDialogService = class EqpAttachmentDialogService {
|
|
108
|
-
constructor() {
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Mostra uno sweet alert di tipo ERROR con il messaggio passato come parametro.
|
|
112
|
-
* @param message Messaggio d'errore da mostrare nello sweetalert
|
|
113
|
-
* @param title Titolo dello sweetalert (di default mostra 'Errore')
|
|
114
|
-
*/
|
|
115
|
-
static Error(message, title = null) {
|
|
116
|
-
let currentTitle = title != null ? title : 'Errore';
|
|
117
|
-
if (Array.isArray(message)) {
|
|
118
|
-
currentTitle = title != null ? title : 'Errore';
|
|
119
|
-
let htmlErrors = message.join("<br>");
|
|
120
|
-
Swal.fire({
|
|
121
|
-
title: currentTitle,
|
|
122
|
-
html: htmlErrors,
|
|
123
|
-
icon: 'error'
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
Swal.fire(currentTitle, message, 'error');
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Mostra uno sweetalert di tipo CONFIRM con il messaggio passato come parametro e se viene premuto
|
|
132
|
-
* CONFERMA lancia la funzione di callback passata come parametro
|
|
133
|
-
* @param message Messaggio da mostrare nello sweetalert
|
|
134
|
-
* @param title Titolo dello sweetalert (di default mostra 'Info')
|
|
135
|
-
*/
|
|
136
|
-
static Confirm(message, confirmCallback, isWarning = false, title = null, customWidth = null) {
|
|
137
|
-
let currentTitle = title != null ? title : 'Sei sicuro di voler procedere?';
|
|
138
|
-
if (Array.isArray(message)) {
|
|
139
|
-
let htmlErrors = message.join("<br>");
|
|
140
|
-
Swal.fire({
|
|
141
|
-
title: currentTitle,
|
|
142
|
-
html: htmlErrors,
|
|
143
|
-
width: customWidth ? customWidth : '32rem',
|
|
144
|
-
icon: !isWarning ? 'question' : 'warning',
|
|
145
|
-
showCancelButton: true,
|
|
146
|
-
allowOutsideClick: false,
|
|
147
|
-
allowEscapeKey: false
|
|
148
|
-
}).then((result) => {
|
|
149
|
-
if (result.value && confirmCallback) {
|
|
150
|
-
confirmCallback();
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
Swal.fire({
|
|
156
|
-
title: currentTitle,
|
|
157
|
-
text: message,
|
|
158
|
-
width: customWidth ? customWidth : '32rem',
|
|
159
|
-
icon: !isWarning ? 'question' : 'warning',
|
|
160
|
-
showCancelButton: true,
|
|
161
|
-
allowOutsideClick: false,
|
|
162
|
-
allowEscapeKey: false
|
|
163
|
-
}).then((result) => {
|
|
164
|
-
if (result.value && confirmCallback) {
|
|
165
|
-
confirmCallback();
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Mostra uno sweetalert di tipo INFO con il messaggio passato come parametro
|
|
172
|
-
* @param message Messaggio da mostrare nello sweetalert
|
|
173
|
-
* @param title Titolo dello sweetalert (di default mostra 'Info')
|
|
174
|
-
*/
|
|
175
|
-
static Info(message, title = null, isToast = null) {
|
|
176
|
-
let currentTitle = title != null ? title : "Informazione:";
|
|
177
|
-
Swal.fire(currentTitle, message, 'info');
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Mostra uno sweetalert di tipo WARNING con il messaggio passato come parametro
|
|
181
|
-
* @param message Messaggio da mostrare nello sweetalert
|
|
182
|
-
* @param title Titolo dello sweetalert (di default mostra 'Attenzione!')
|
|
183
|
-
*/
|
|
184
|
-
static Warning(message, title = null, isToast = null) {
|
|
185
|
-
let currentTitle = title != null ? title : "Attenzione!";
|
|
186
|
-
if (Array.isArray(message)) {
|
|
187
|
-
let htmlWarnings = message.join("<br>");
|
|
188
|
-
Swal.fire({
|
|
189
|
-
title: currentTitle,
|
|
190
|
-
html: htmlWarnings,
|
|
191
|
-
icon: 'warning'
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
Swal.fire(currentTitle, message, 'warning');
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
EqpAttachmentDialogService.ɵprov = ɵɵdefineInjectable({ factory: function EqpAttachmentDialogService_Factory() { return new EqpAttachmentDialogService(); }, token: EqpAttachmentDialogService, providedIn: "root" });
|
|
200
|
-
EqpAttachmentDialogService = __decorate([
|
|
201
|
-
Injectable({
|
|
202
|
-
providedIn: 'root'
|
|
203
|
-
})
|
|
204
|
-
], EqpAttachmentDialogService);
|
|
205
|
-
|
|
206
|
-
const toBase64 = file => new Promise((resolve, reject) => {
|
|
207
|
-
const reader = new FileReader();
|
|
208
|
-
reader.readAsDataURL(file);
|
|
209
|
-
reader.onload = () => resolve(reader.result.toString());
|
|
210
|
-
reader.onerror = error => reject(error);
|
|
211
|
-
});
|
|
212
|
-
const ɵ0 = toBase64;
|
|
213
|
-
let EqpAttachmentsComponent = class EqpAttachmentsComponent {
|
|
214
|
-
constructor(dialog, formBuilder, sanitizer, http, cd) {
|
|
215
|
-
this.dialog = dialog;
|
|
216
|
-
this.formBuilder = formBuilder;
|
|
217
|
-
this.sanitizer = sanitizer;
|
|
218
|
-
this.http = http;
|
|
219
|
-
this.cd = cd;
|
|
220
|
-
//#region @Input del componente
|
|
221
|
-
/**
|
|
222
|
-
* Se TRUE allora nasconde la colonna per le azioni sull'allegato (nel caso "multipleAttachment" è TRUE).
|
|
223
|
-
*/
|
|
224
|
-
this.disableAction = false;
|
|
225
|
-
/**
|
|
226
|
-
* Se TRUE mostra il titolo nell'header nel caso in cui "multipleAttachment" è TRUE ("Elenco allegati" di default).
|
|
227
|
-
*/
|
|
228
|
-
this.showHeader = true;
|
|
229
|
-
/**
|
|
230
|
-
* Titolo da visualizzare se il parametro "showHeader" è TRUE. Di devault viene visualizzato "Elenco allegati".
|
|
231
|
-
*/
|
|
232
|
-
this.headerTitle = "Elenco allegati";
|
|
233
|
-
/**
|
|
234
|
-
* Sorgente dati da visualizzare. Nel caso si vuole gestire un singolo allegato va passato in ogni caso come Array.
|
|
235
|
-
*/
|
|
236
|
-
this.attachmentsList = null;
|
|
237
|
-
/**
|
|
238
|
-
* Se TRUE non mostra la MatCard (nel caso in cui "multipleAttachment" è TRUE).
|
|
239
|
-
*/
|
|
240
|
-
this.showMatCard = true;
|
|
241
|
-
/**
|
|
242
|
-
* Se FALSE allora il componente mostra solo il pulsante di caricamento di un singolo file, una volta caricato il file invoca l'evento di output "localEditedAttachments".
|
|
243
|
-
* Se TRUE allora il componente mostra l'elenco di tutti gli allegati ricevuto nel parametro "attachmentsList".
|
|
244
|
-
*/
|
|
245
|
-
this.multipleAttachment = true;
|
|
246
|
-
/**
|
|
247
|
-
* Se assume il valore TRUE allora sarà possibile caricare più file per volta. Questa funzionalità è attiva
|
|
248
|
-
* SOLO se si gestiscono allegati multipli, quindi se l'input 'multipleAttachment' assume il valore TRUE, altrimenti è sempre disabilitata.
|
|
249
|
-
*/
|
|
250
|
-
this.loadMultipleFiles = false;
|
|
251
|
-
/**
|
|
252
|
-
* Configurazione delle colonne della eqp-table per la visualizzazione degli allegati (caso "multipleAttachment" è TRUE).
|
|
253
|
-
*/
|
|
254
|
-
this.attachmentsColumns = null;
|
|
255
|
-
/**
|
|
256
|
-
* Imposta il messaggio da visualizzare nel caso in cui la tabella degli allegati (nel caso in cui "multipleAttachment" è TRUE) è vuota.
|
|
257
|
-
*/
|
|
258
|
-
this.emptyTableMessage = "Nessun dato trovato";
|
|
259
|
-
/**
|
|
260
|
-
* Se TRUE allora permette di selezionare soltanto file di tipo immagine, avente uno dei mimetype
|
|
261
|
-
* specificati dentro AttachmentHelperService.
|
|
262
|
-
* Se FALSE permette di selezionare qualsiasi tipo di file
|
|
263
|
-
*/
|
|
264
|
-
this.allowOnlyImages = false;
|
|
265
|
-
/**
|
|
266
|
-
* Se TRUE disabilita il pulsante di Aggiunta allegato (a prescindere dal valore del parametro "multipleAttachment").
|
|
267
|
-
*/
|
|
268
|
-
this.isDisabled = false;
|
|
269
|
-
/**
|
|
270
|
-
* Mostra/nasconde la colonna per visualizzare l'anteprima dei file nella tabella (caso multipleAtatchments = true).
|
|
271
|
-
*/
|
|
272
|
-
this.showInlinePreview = false;
|
|
273
|
-
/**
|
|
274
|
-
* Endpoint da chiamare per recueprare l'IAttachmentDTO completo da vedere nell'anteprima. La chiamata sarà in POST e nel body
|
|
275
|
-
* conterrà l'IAttachmentDTO selezionato dall'utente.
|
|
276
|
-
* La chiamata viene eseguita solo per l'anteprima delle immagini essendo necessario il base64 completo dell'immagine a dimensione reale.
|
|
277
|
-
* Per documenti/link basta che sia popolata la proprietà FilePath di IAttachmentDTO.
|
|
278
|
-
*/
|
|
279
|
-
this.getAttachmentEndpoint = null;
|
|
280
|
-
/**
|
|
281
|
-
* Hostname dell'ambiente di produzione dell'applicativo. Necessario per visualizzare l'anteprima dei documenti
|
|
282
|
-
* tramite il viewer di google.
|
|
283
|
-
* NOTA: Per visualizzare l'anteprima è necessario che la prorietà FilePath dell'IAttachmentDTO sia popolata e che
|
|
284
|
-
* sia abilitato l'accesso alla cartella sul server tramite hostname.
|
|
285
|
-
*/
|
|
286
|
-
this.productionBaseUrl = null;
|
|
287
|
-
/**
|
|
288
|
-
* Opzioni per la compressione delle immagini caricate.
|
|
289
|
-
*/
|
|
290
|
-
this.compressionOptions = { maxSizeMB: 0.5, maxWidthOrHeight: 1920, useWebWorker: true };
|
|
291
|
-
/**
|
|
292
|
-
* Array di AttachmentType che si possono aggiungere
|
|
293
|
-
*/
|
|
294
|
-
this.allowedTypes = [AttachmentType.FILE, AttachmentType.LINK];
|
|
295
|
-
/**
|
|
296
|
-
* Booleano per impostare la eqp-table nella modalità multilingua
|
|
297
|
-
*/
|
|
298
|
-
this.isEqpTableMultiLanguage = false;
|
|
299
|
-
/**
|
|
300
|
-
* Input per definire le label da usare nel componente
|
|
301
|
-
*/
|
|
302
|
-
this.downloadTooltipPosition = TooltipPositionType.Below;
|
|
303
|
-
this.openLinkLabel = "Apri link";
|
|
304
|
-
this.addButtonLabel = "Aggiungi";
|
|
305
|
-
this.downloadLabel = "Download";
|
|
306
|
-
this.deleteLabel = "Elimina";
|
|
307
|
-
this.fileNameLabel = "Nome file";
|
|
308
|
-
this.previewLabel = "Anteprima";
|
|
309
|
-
this.uploadFileLabel = "Carica file";
|
|
310
|
-
this.confirmLabel = "Conferma";
|
|
311
|
-
this.abortLabel = "Annulla";
|
|
312
|
-
this.saveLabel = "Salva";
|
|
313
|
-
this.exitLabel = "Esci";
|
|
314
|
-
this.eqpTableSearchText = "Cerca";
|
|
315
|
-
this.deleteDialogTitle = null;
|
|
316
|
-
this.deleteDialogMessage = "Sei sicuro di voler cancellare quest'allegato?";
|
|
317
|
-
this.noImageSelectedErrorMessage = "Non è possibile selezionare un file che non sia un'immagine.";
|
|
318
|
-
this.wrongTypeSelectedErrorMessage = "Non è possibile caricare il file selezionato.";
|
|
319
|
-
this.videoPreviewErrorMessage = "Impossibile aprire l'anteprima di un file video.";
|
|
320
|
-
this.audioPreviewErrorMessage = "Impossibile aprire l'anteprima di un file audio.";
|
|
321
|
-
//#endregion
|
|
322
|
-
//#region @Output del componente
|
|
323
|
-
/**
|
|
324
|
-
* Restituisce la lista aggiornata degli allegati.
|
|
325
|
-
*/
|
|
326
|
-
this.localEditedAttachments = new EventEmitter();
|
|
327
|
-
/**
|
|
328
|
-
* Evento scatenato alla pressione del pulsante ESCI della modale di caricamento file.
|
|
329
|
-
*/
|
|
330
|
-
this.abortAddAttachment = new EventEmitter();
|
|
331
|
-
/**
|
|
332
|
-
* Evento di output che restituisce l'IAttachmentDTO selezionato per il download nel caso FileDataBase64, FileContentType o FileName non fossero specificati.
|
|
333
|
-
*/
|
|
334
|
-
this.downloadAttachment = new EventEmitter();
|
|
335
|
-
/**
|
|
336
|
-
* Evento di output che restituisce l'elemento eliminato prima che questo venga effettivamente rismosso dalla lista.
|
|
337
|
-
*/
|
|
338
|
-
this.onDeleteAttachment = new EventEmitter();
|
|
339
|
-
//#endregion
|
|
340
|
-
//#region Proprietà per gestione caricamento nuovo allegato
|
|
341
|
-
this.newAttachment = {};
|
|
342
|
-
this.newMultipleAttachments = [];
|
|
343
|
-
this.attachmentType = AttachmentType;
|
|
344
|
-
this.selectedFile = null;
|
|
345
|
-
this.selectedFiles = null;
|
|
346
|
-
this.showCropImage = false;
|
|
347
|
-
//#endregion
|
|
348
|
-
//#region Proprietà per gestione ridimensionamento file di tipo image
|
|
349
|
-
this.imageChangedEvent = '';
|
|
350
|
-
this.croppedImage = '';
|
|
351
|
-
this.transform = {};
|
|
352
|
-
//#endregion
|
|
353
|
-
this.AttachmentType = AttachmentType;
|
|
354
|
-
}
|
|
355
|
-
ngOnInit() {
|
|
356
|
-
//Se è stata richiesta la gestione delle sole immagini allora imposta il filtro per le estensioni possibili da caricare
|
|
357
|
-
if (!this.acceptedFileTypes)
|
|
358
|
-
if (this.allowOnlyImages == true)
|
|
359
|
-
this.acceptedFileTypes = "image/*";
|
|
360
|
-
else
|
|
361
|
-
this.acceptedFileTypes = "*";
|
|
362
|
-
// Se non sono stati specificati i tipi da gestire ma è stato passato null o un array vuoto imposto i tipi di default.
|
|
363
|
-
if (!this.allowedTypes || this.allowedTypes.length == 0)
|
|
364
|
-
this.allowedTypes = [AttachmentType.FILE, AttachmentType.LINK];
|
|
365
|
-
else if (this.allowedTypes.find(t => t != AttachmentType.FILE && t != AttachmentType.LINK)) {
|
|
366
|
-
EqpAttachmentDialogService.Warning("Almeno uno degli AttachmentType selezionati nel parametro \"allowedTypes\" non esiste.");
|
|
367
|
-
this.allowedTypes = [AttachmentType.FILE, AttachmentType.LINK];
|
|
368
|
-
}
|
|
369
|
-
//Se è stata richiesta la gestione multipla degli allegati allora configura l'eqp-table
|
|
370
|
-
if (this.multipleAttachment == true && (!this.attachmentsColumns || this.attachmentsColumns.length == 0)) {
|
|
371
|
-
this.configureColumns();
|
|
372
|
-
}
|
|
373
|
-
if (this.attachmentsList == null)
|
|
374
|
-
this.attachmentsList = new Array();
|
|
375
|
-
this.checkAttachmentImage();
|
|
376
|
-
}
|
|
377
|
-
reloadData() {
|
|
378
|
-
if (this.attachmentTable)
|
|
379
|
-
this.attachmentTable.reloadDatatable();
|
|
380
|
-
}
|
|
381
|
-
checkAttachmentImage() {
|
|
382
|
-
this.attachmentsList.forEach(a => {
|
|
383
|
-
a.IsImage = AttachmentHelperService.checkImageFromMimeType(a.FileContentType);
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
//#region Gestione elenco allegati
|
|
387
|
-
/**
|
|
388
|
-
* Configura le colonne per l'eqp-table nel caso in cui il parametro "multipleAttachments" è TRUE.
|
|
389
|
-
*/
|
|
390
|
-
configureColumns() {
|
|
391
|
-
this.attachmentsColumns = [];
|
|
392
|
-
if (this.disableAction != true) {
|
|
393
|
-
this.attachmentsColumns.push({
|
|
394
|
-
key: "action", display: "",
|
|
395
|
-
type: TypeColumn.MenuAction, buttonMenuIcon: "more_vert", styles: { flex: "0 0 6%" },
|
|
396
|
-
actions: [
|
|
397
|
-
{ name: this.deleteLabel, icon: "delete", fn: (element, index, col) => this.deleteAttachment(element) },
|
|
398
|
-
],
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
let downloadColumn = {
|
|
402
|
-
key: "attachment", display: "",
|
|
403
|
-
type: TypeColumn.SimpleAction, styles: { flex: "0 0 6%" },
|
|
404
|
-
actions: [
|
|
405
|
-
{
|
|
406
|
-
name: '', fontawesome: true,
|
|
407
|
-
icon: (element) => { return this.showInlinePreview ? (element.AttachmentType == AttachmentType.FILE ? "fas fa-cloud-download-alt" : "fas fa-external-link-alt") : this.getAttachmentIcon(element); },
|
|
408
|
-
fn: (element, col, elementIndex) => this.viewAttachment(element),
|
|
409
|
-
tooltip: { tooltipText: (element) => { return element.AttachmentType == AttachmentType.FILE ? this.downloadLabel : this.openLinkLabel; }, tooltipPosition: this.downloadTooltipPosition }
|
|
410
|
-
},
|
|
411
|
-
]
|
|
412
|
-
};
|
|
413
|
-
let inlinePreviewColumn = {
|
|
414
|
-
key: "InlinePreview", display: this.previewLabel,
|
|
415
|
-
type: TypeColumn.ExternalTemplate,
|
|
416
|
-
externalTemplate: this.inlinePreviewTemplate,
|
|
417
|
-
styles: { flex: "0 0 10%" }
|
|
418
|
-
};
|
|
419
|
-
let fileNameColumn = { key: "FileName", display: this.fileNameLabel };
|
|
420
|
-
if (this.showInlinePreview) {
|
|
421
|
-
this.attachmentsColumns.push(inlinePreviewColumn);
|
|
422
|
-
this.attachmentsColumns.push(fileNameColumn);
|
|
423
|
-
this.attachmentsColumns.push(downloadColumn);
|
|
424
|
-
}
|
|
425
|
-
else {
|
|
426
|
-
this.attachmentsColumns.push(downloadColumn);
|
|
427
|
-
this.attachmentsColumns.push(fileNameColumn);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Elimina un allegato eliminando anche il file presente nello storage di archiviazione utilizzato (AWS o cartella progetto)
|
|
432
|
-
* @param element IAttachmentDTO da cancellare
|
|
433
|
-
*/
|
|
434
|
-
deleteAttachment(element) {
|
|
435
|
-
EqpAttachmentDialogService.Confirm(this.deleteDialogMessage, () => {
|
|
436
|
-
this.removeAttachmentFromList(this.attachmentsList.indexOf(element));
|
|
437
|
-
}, true, this.deleteDialogTitle);
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* Rimuove l'allegato selezionato dalla lista "attachmentsList" e invoca l'evento di output che restituisce la lista aggiornata.
|
|
441
|
-
* @param attachmentIndex Indice dell'attachment da rimuovere
|
|
442
|
-
*/
|
|
443
|
-
removeAttachmentFromList(attachmentIndex) {
|
|
444
|
-
this.onDeleteAttachment.emit(this.attachmentsList[attachmentIndex]);
|
|
445
|
-
this.attachmentsList.splice(attachmentIndex, 1);
|
|
446
|
-
if (this.attachmentTable)
|
|
447
|
-
this.attachmentTable.reloadDatatable();
|
|
448
|
-
this.localEditedAttachments.emit(this.attachmentsList);
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Scarica l'allegato o apre il link
|
|
452
|
-
* @param element Allegato da mostrare
|
|
453
|
-
*/
|
|
454
|
-
viewAttachment(attachment) {
|
|
455
|
-
if (attachment.AttachmentType == AttachmentType.LINK) {
|
|
456
|
-
window.open(attachment.FilePath, '_blank');
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
if (attachment.FileDataBase64 && attachment.FileContentType && attachment.FileName) {
|
|
460
|
-
let source = `data:${attachment.FileContentType};base64,${attachment.FileDataBase64}`;
|
|
461
|
-
const link = document.createElement("a");
|
|
462
|
-
link.href = source;
|
|
463
|
-
link.download = `${attachment.FileName}`;
|
|
464
|
-
link.click();
|
|
465
|
-
}
|
|
466
|
-
else {
|
|
467
|
-
this.downloadAttachment.emit(attachment);
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* Ridefinisce l'icona da mostrare nella colonna dell'eqp-table per ogni file.
|
|
472
|
-
* L'icona varia in base all'estensione del file
|
|
473
|
-
* @param attachment
|
|
474
|
-
*/
|
|
475
|
-
getAttachmentIcon(attachment) {
|
|
476
|
-
if (attachment.AttachmentType == AttachmentType.LINK)
|
|
477
|
-
return "fas fa-link";
|
|
478
|
-
else
|
|
479
|
-
return AttachmentHelperService.getIconFromFileExtensione(attachment.FileExtension);
|
|
480
|
-
}
|
|
481
|
-
//#endregion
|
|
482
|
-
/**
|
|
483
|
-
* Apre la modale per la definizione dei parametri del nuovo file
|
|
484
|
-
*/
|
|
485
|
-
openModalAddAttachment(attachmentType) {
|
|
486
|
-
//Se è stato richiesto il caricamento di un LINK o è impostato il caricamento di FILE SINGOLO allora apre la modale per
|
|
487
|
-
//il caricamento singolo del file altrimenti apre quella per il caricamento multiplo
|
|
488
|
-
// if (attachmentType == AttachmentType.LINK || (attachmentType == AttachmentType.FILE && this.loadMultipleFiles != true)) {
|
|
489
|
-
this.newAttachment = {};
|
|
490
|
-
this.newAttachment.IsImage = false;
|
|
491
|
-
this.newAttachment.AttachmentType = attachmentType;
|
|
492
|
-
this.newMultipleAttachments = new Array();
|
|
493
|
-
if (attachmentType == AttachmentType.LINK)
|
|
494
|
-
this.newMultipleAttachments.push(this.newAttachment);
|
|
495
|
-
this.createAttachmentForm();
|
|
496
|
-
//Apre la modale
|
|
497
|
-
this.dialofRefAddAttachment = this.dialog.open(this.dialogAddAttachment, {
|
|
498
|
-
disableClose: true,
|
|
499
|
-
hasBackdrop: true,
|
|
500
|
-
width: '60%',
|
|
501
|
-
maxHeight: '80%'
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
createAttachmentForm() {
|
|
505
|
-
//Crea la form per la validazione dei campi
|
|
506
|
-
this.newAttachmentForm = this.formBuilder.group({
|
|
507
|
-
type: [this.newAttachment.AttachmentType, Validators.required],
|
|
508
|
-
name: [this.newAttachment.FileName],
|
|
509
|
-
path: [this.newAttachment.FilePath],
|
|
510
|
-
customHeight: [this.customHeight],
|
|
511
|
-
customWidth: [this.customWidth]
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
|
-
close(emitCloseEvent = true) {
|
|
515
|
-
this.newAttachment = {};
|
|
516
|
-
this.newMultipleAttachments = new Array();
|
|
517
|
-
this.abortFile();
|
|
518
|
-
if (this.newAttachmentForm)
|
|
519
|
-
this.newAttachmentForm.reset();
|
|
520
|
-
this.dialofRefAddAttachment.close();
|
|
521
|
-
if (emitCloseEvent == true && this.abortAddAttachment)
|
|
522
|
-
this.abortAddAttachment.emit();
|
|
523
|
-
}
|
|
524
|
-
/**
|
|
525
|
-
* In base al tipo di allegato controlla se disabilitare o meno il pulsante per salvare.
|
|
526
|
-
* Funzione usata nel [disable] del pulsante "Salva" del dialog per l'aggiunta di un allegato.
|
|
527
|
-
* @returns
|
|
528
|
-
*/
|
|
529
|
-
disableSave() {
|
|
530
|
-
if (this.loadMultipleFiles != true) {
|
|
531
|
-
if (this.newAttachment.AttachmentType == AttachmentType.FILE) {
|
|
532
|
-
return !this.newAttachment.FileDataBase64;
|
|
533
|
-
}
|
|
534
|
-
else {
|
|
535
|
-
return !this.newAttachment.FilePath;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
else {
|
|
539
|
-
return this.newMultipleAttachments.filter(p => (p.AttachmentType == AttachmentType.FILE && !p.FileDataBase64) || (p.AttachmentType == AttachmentType.LINK && !p.FilePath)).length > 0;
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
confirmAddAttachment() {
|
|
543
|
-
if (this.loadMultipleFiles != true) {
|
|
544
|
-
if (this.newAttachment.AttachmentType == AttachmentType.LINK && !this.newAttachment.FileName)
|
|
545
|
-
this.newAttachment.FileName = this.newAttachment.FilePath;
|
|
546
|
-
if (this.attachmentsList == null)
|
|
547
|
-
this.attachmentsList = new Array();
|
|
548
|
-
this.attachmentsList.push(this.newAttachment);
|
|
549
|
-
}
|
|
550
|
-
else {
|
|
551
|
-
if (this.newMultipleAttachments == null || this.newMultipleAttachments.length == 0)
|
|
552
|
-
return;
|
|
553
|
-
if (this.attachmentsList == null)
|
|
554
|
-
this.attachmentsList = new Array();
|
|
555
|
-
this.attachmentsList = this.attachmentsList.concat(this.newMultipleAttachments);
|
|
556
|
-
}
|
|
557
|
-
if (this.attachmentTable)
|
|
558
|
-
this.attachmentTable.reloadDatatable();
|
|
559
|
-
this.localEditedAttachments.emit(this.attachmentsList);
|
|
560
|
-
this.close(false);
|
|
561
|
-
}
|
|
562
|
-
/**
|
|
563
|
-
* Apre il dialog per l'anteprima dell'allegato selezionato.
|
|
564
|
-
* @param row
|
|
565
|
-
* @returns
|
|
566
|
-
*/
|
|
567
|
-
openPreviewDialog(row) {
|
|
568
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
569
|
-
this.selectedAttachment = JSON.parse(JSON.stringify(row));
|
|
570
|
-
if (this.selectedAttachment.AttachmentType == AttachmentType.FILE) {
|
|
571
|
-
if (this.selectedAttachment.FileContentType.startsWith("video")) {
|
|
572
|
-
EqpAttachmentDialogService.Warning(this.videoPreviewErrorMessage);
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
else if (this.selectedAttachment.FileContentType.startsWith("audio")) {
|
|
576
|
-
EqpAttachmentDialogService.Warning(this.audioPreviewErrorMessage);
|
|
577
|
-
return;
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
if (this.getAttachmentEndpoint && this.selectedAttachment.IsImage && !this.selectedAttachment.FileDataBase64) {
|
|
581
|
-
yield this.getAttachmentByID()
|
|
582
|
-
.then((res) => { this.selectedAttachment.FileDataBase64 = res.FileDataBase64; })
|
|
583
|
-
.catch((err) => { EqpAttachmentDialogService.Error(err); });
|
|
584
|
-
}
|
|
585
|
-
if (this.selectedAttachment.AttachmentType == AttachmentType.LINK) {
|
|
586
|
-
this.selectedAttachment.TrustedUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.selectedAttachment.FilePath);
|
|
587
|
-
}
|
|
588
|
-
else if (this.selectedAttachment.IsImage && !this.selectedAttachment.FileDataBase64 && !this.selectedAttachment.FileThumbnailBase64) {
|
|
589
|
-
EqpAttachmentDialogService.Info("Impossibile aprire l'anteprima dell'allegato, file mancante.");
|
|
590
|
-
return;
|
|
591
|
-
}
|
|
592
|
-
else if (!this.selectedAttachment.IsImage) {
|
|
593
|
-
if (this.selectedAttachment.FilePath && this.productionBaseUrl) {
|
|
594
|
-
this.selectedAttachment.TrustedUrl = this.sanitizer.bypassSecurityTrustResourceUrl("https://docs.google.com/gview?url=" +
|
|
595
|
-
this.productionBaseUrl +
|
|
596
|
-
"/" +
|
|
597
|
-
this.selectedAttachment.FilePath +
|
|
598
|
-
"&embedded=true");
|
|
599
|
-
}
|
|
600
|
-
else {
|
|
601
|
-
EqpAttachmentDialogService.Info("Impossibile aprire l'anteprima del documento!");
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
this.dialog.open(this.dialogPreview, {
|
|
606
|
-
disableClose: true,
|
|
607
|
-
hasBackdrop: true,
|
|
608
|
-
});
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
getAttachmentByID() {
|
|
612
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
613
|
-
return this.http.post(this.getAttachmentEndpoint, this.selectedAttachment).toPromise();
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
//#region Gestione caricamento file
|
|
617
|
-
/**
|
|
618
|
-
* Evento scatenato alla selezione del file (o dei file).
|
|
619
|
-
* 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
|
|
620
|
-
* mostrare le funzionalità del croppie (per ritagliare l'immagine) oppure no.
|
|
621
|
-
* Se il file caricato non è un immagine allora genera direttamente il base64 e lo associa all'allegato da salvare.
|
|
622
|
-
* Se invece il caricamento dei file è MULTIPLO e sono presenti più file allora esegue le stesse operazioni ignorando però il contrllo
|
|
623
|
-
* immagine per il croppie (in caso di caricamento multiplo le funzionalità del croppie sono disabilitate).
|
|
624
|
-
*/
|
|
625
|
-
onFileInputChange(event) {
|
|
626
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
627
|
-
this.showCropImage = false;
|
|
628
|
-
//Se è stato richiesto il caricamento SINGOLO oppure se il caricamento è MULTIPLO ma è stato selezionato un solo file
|
|
629
|
-
//allora verifica se il file è un immagine (per mostrare il CROPPIE)
|
|
630
|
-
if ([...event.target.files].length == 1 || this.loadMultipleFiles != true) {
|
|
631
|
-
this.selectedFile = event.target.files[0];
|
|
632
|
-
this.selectedFiles = event.target.files;
|
|
633
|
-
if (!this.selectedFile)
|
|
634
|
-
return;
|
|
635
|
-
//Memorizza i dati per l'allegato
|
|
636
|
-
this.newAttachment = yield this.createAttachmentFromUploadedFile(this.selectedFile, false);
|
|
637
|
-
this.newMultipleAttachments = new Array();
|
|
638
|
-
this.newMultipleAttachments.push(this.newAttachment);
|
|
639
|
-
//Se è stata richiesta la gestione delle sole immagini ma per errore è stato selezionato un file che non è un immagine
|
|
640
|
-
let checkOnlyImage = this.checkAllowOnlyImageFile(this.newAttachment);
|
|
641
|
-
if (checkOnlyImage == false)
|
|
642
|
-
return;
|
|
643
|
-
if (this.loadMultipleFiles == true && [...event.target.files].length == 1)
|
|
644
|
-
this.createAttachmentForm();
|
|
645
|
-
//Verifica se il file caricato è un'immagine oppure no. Se è un immagine, prima di caricarla mostra il croppie per il resize.
|
|
646
|
-
//Se non è un immagine allora genera il Base64
|
|
647
|
-
if (this.newAttachment.IsImage == true) {
|
|
648
|
-
this.getImageDimensions(event.target.files[0]);
|
|
649
|
-
//Mostra il croppie e disabilita la form finchè non termina la modifica dell'immagine
|
|
650
|
-
this.newAttachmentForm.disable();
|
|
651
|
-
this.newAttachmentForm.controls["customWidth"].enable();
|
|
652
|
-
this.newAttachmentForm.controls["customHeight"].enable();
|
|
653
|
-
this.showCropImage = true;
|
|
654
|
-
this.imageChangedEvent = event;
|
|
655
|
-
}
|
|
656
|
-
else {
|
|
657
|
-
this.showCropImage = false;
|
|
658
|
-
let base64Result = yield this.getBase64FromFile(this.selectedFile);
|
|
659
|
-
this.newAttachment.FileDataBase64 = base64Result.Base64File;
|
|
660
|
-
this.newAttachment.FileContentType = base64Result.ContentType;
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
else {
|
|
664
|
-
this.selectedFiles = event.target.files;
|
|
665
|
-
if (!this.selectedFiles || this.selectedFiles.length == 0)
|
|
666
|
-
return;
|
|
667
|
-
this.newMultipleAttachments = new Array();
|
|
668
|
-
for (let i = 0; i < this.selectedFiles.length; i++) {
|
|
669
|
-
let newAttachment = yield this.createAttachmentFromUploadedFile(this.selectedFiles[i], true);
|
|
670
|
-
//Se è stata richiesta la gestione delle sole immagini ma per errore è stato selezionato un file che non è un immagine
|
|
671
|
-
let checkOnlyImage = this.checkAllowOnlyImageFile(newAttachment);
|
|
672
|
-
if (checkOnlyImage == false)
|
|
673
|
-
return;
|
|
674
|
-
this.newMultipleAttachments.push(newAttachment);
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
/**
|
|
680
|
-
* A partire dal FILE ricevuto in input ricostruisce l'oggetto IAttachmentDTO e lo restituisce.
|
|
681
|
-
* Se il parametro getBase64 viene passato a TRUE allora, sempre a partire dal file,genera il base64 e
|
|
682
|
-
* ricava il ContentType da associare all'oggetto IAttachmentDTO da restituire
|
|
683
|
-
* @param currentFile Oggetto FILE da processare
|
|
684
|
-
* @param getBase64 Se TRUE allora calcola base64 e ContentType del file passato in input
|
|
685
|
-
* @returns Restituisce un oggetto di tipo IAttachmentDTO
|
|
686
|
-
*/
|
|
687
|
-
createAttachmentFromUploadedFile(currentFile, getBase64 = true) {
|
|
688
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
689
|
-
let newAttachment = {};
|
|
690
|
-
//Memorizza i dati per l'allegato
|
|
691
|
-
newAttachment.AttachmentType = AttachmentType.FILE;
|
|
692
|
-
newAttachment.FileContentType = currentFile.type;
|
|
693
|
-
newAttachment.FileName = currentFile.name;
|
|
694
|
-
newAttachment.FileExtension = currentFile.name.substr(currentFile.name.lastIndexOf('.') + 1);
|
|
695
|
-
newAttachment.IsImage = AttachmentHelperService.checkImageFromMimeType(currentFile.type);
|
|
696
|
-
if (getBase64 == true) {
|
|
697
|
-
let base64Result = yield this.getBase64FromFile(currentFile);
|
|
698
|
-
newAttachment.FileDataBase64 = base64Result.Base64File;
|
|
699
|
-
newAttachment.FileContentType = base64Result.ContentType;
|
|
700
|
-
}
|
|
701
|
-
return newAttachment;
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
/**
|
|
705
|
-
* A partire dal file passato in input restituisce un oggetto
|
|
706
|
-
* contenente il base64 del file e il suo contentType
|
|
707
|
-
* @param currentFile Oggetto File da cui estrapolare base64 e contentType
|
|
708
|
-
* @returns Restituisce un oggetto avente le proprietà Base64File e ContentType
|
|
709
|
-
*/
|
|
710
|
-
getBase64FromFile(currentFile) {
|
|
711
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
712
|
-
let base64File = yield toBase64(currentFile);
|
|
713
|
-
let contentType = null;
|
|
714
|
-
if (base64File) {
|
|
715
|
-
// Loris 20/01/2022: PROBLEMA - Quando eseguo l'upload di un file .sql non viene salvato/scaricato correttamente.
|
|
716
|
-
// Questo succede perchè non viene popolato il FileContentType. Per risolvere il problema
|
|
717
|
-
// faccio un controllo e se non esiste il FileContentType allora lo recupero dal base64 ottenuto.
|
|
718
|
-
contentType = base64File.split(",")[0].split(":")[1].split(";")[0];
|
|
719
|
-
// Un altro metodo per leggere il ccontent type del file è tramite una regular expression:
|
|
720
|
-
base64File = base64File.split(",")[1];
|
|
721
|
-
}
|
|
722
|
-
let result = {
|
|
723
|
-
Base64File: base64File,
|
|
724
|
-
ContentType: contentType
|
|
725
|
-
};
|
|
726
|
-
return result;
|
|
727
|
-
});
|
|
728
|
-
}
|
|
729
|
-
/**
|
|
730
|
-
* Controlla se il file che si sta caricando è supportato dal sistema.
|
|
731
|
-
* @returns
|
|
732
|
-
*/
|
|
733
|
-
checkAcceptedFiles() {
|
|
734
|
-
if ((this.loadMultipleFiles != true && this.selectedFile.type.startsWith("video"))
|
|
735
|
-
|| (this.loadMultipleFiles == true && [...this.selectedFiles].filter(p => p.type.startsWith("video")).length > 0))
|
|
736
|
-
return false;
|
|
737
|
-
if (this.acceptedFileTypes == "*")
|
|
738
|
-
return true;
|
|
739
|
-
//Verifica che i tipi del file (o dei file) caricati siano coerenti con quelli accettati dalla direttiva
|
|
740
|
-
let accepted = true;
|
|
741
|
-
if (this.loadMultipleFiles != true)
|
|
742
|
-
accepted = this.acceptedFileTypes.includes(this.selectedFile.type);
|
|
743
|
-
else {
|
|
744
|
-
let uploadedFileTypes = [...this.selectedFiles].map(p => p.type);
|
|
745
|
-
uploadedFileTypes.forEach(type => {
|
|
746
|
-
if (!this.acceptedFileTypes.includes(type))
|
|
747
|
-
accepted = false;
|
|
748
|
-
});
|
|
749
|
-
}
|
|
750
|
-
//Questo controllo permette di gestire le casistiche per cui vengono indicati come tipi validi, ad esempio, 'image/*'
|
|
751
|
-
if (!accepted && this.loadMultipleFiles != true) {
|
|
752
|
-
for (let t of this.acceptedFileTypes.split(",").filter(t => t.includes("*"))) {
|
|
753
|
-
accepted = this.selectedFile.type.startsWith(t.split("*")[0]);
|
|
754
|
-
if (accepted)
|
|
755
|
-
break;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
return accepted;
|
|
759
|
-
}
|
|
760
|
-
/**
|
|
761
|
-
* Se eqp-attachments è stata configurata per il caricamento delle sole immagini allora verifica che il file passato in
|
|
762
|
-
* input sia effettivamente un immagine o no.
|
|
763
|
-
* Se il controllo va a buon fine restituisce TRUE altrimenti mostra un messaggio d'errore e restituisce FALSE
|
|
764
|
-
*/
|
|
765
|
-
checkAllowOnlyImageFile(newAttachment) {
|
|
766
|
-
if (this.allowOnlyImages == true && newAttachment.IsImage != true) {
|
|
767
|
-
EqpAttachmentDialogService.Error(this.noImageSelectedErrorMessage);
|
|
768
|
-
this.abortFile();
|
|
769
|
-
return false;
|
|
770
|
-
}
|
|
771
|
-
else if (!this.checkAcceptedFiles()) {
|
|
772
|
-
EqpAttachmentDialogService.Error(this.wrongTypeSelectedErrorMessage);
|
|
773
|
-
this.abortFile();
|
|
774
|
-
return false;
|
|
775
|
-
}
|
|
776
|
-
return true;
|
|
777
|
-
}
|
|
778
|
-
getImageDimensions(img) {
|
|
779
|
-
const reader = new FileReader();
|
|
780
|
-
reader.onload = (e) => {
|
|
781
|
-
const image = new Image();
|
|
782
|
-
image.src = e.target.result;
|
|
783
|
-
image.onload = rs => {
|
|
784
|
-
this.originalHeight = rs.currentTarget['height'];
|
|
785
|
-
this.originalWidth = rs.currentTarget['width'];
|
|
786
|
-
if (this.originalWidth > 1280) {
|
|
787
|
-
this.customWidth = 1280;
|
|
788
|
-
this.customHeight = Math.round((1280 * this.originalHeight) / this.originalWidth);
|
|
789
|
-
}
|
|
790
|
-
else {
|
|
791
|
-
this.customHeight = rs.currentTarget['height'];
|
|
792
|
-
this.customWidth = rs.currentTarget['width'];
|
|
793
|
-
}
|
|
794
|
-
};
|
|
795
|
-
};
|
|
796
|
-
reader.readAsDataURL(img);
|
|
797
|
-
}
|
|
798
|
-
restoreOriginalDimensions() {
|
|
799
|
-
this.customWidth = this.originalWidth;
|
|
800
|
-
this.customHeight = this.originalHeight;
|
|
801
|
-
}
|
|
802
|
-
onDimensionsChange(dimension) {
|
|
803
|
-
if (dimension == "H") {
|
|
804
|
-
this.customWidth = Math.round((this.customHeight * this.originalWidth) / this.originalHeight);
|
|
805
|
-
}
|
|
806
|
-
else if (dimension == "W") {
|
|
807
|
-
this.customHeight = Math.round((this.customWidth * this.originalHeight) / this.originalWidth);
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
imageCropped(event) {
|
|
811
|
-
this.croppedImage = event.base64;
|
|
812
|
-
this.getCroppedAndUpload(this.croppedImage);
|
|
813
|
-
}
|
|
814
|
-
getCroppedAndUpload(file) {
|
|
815
|
-
var self = this;
|
|
816
|
-
var file = base64ToFile(file);
|
|
817
|
-
const options = this.compressionOptions;
|
|
818
|
-
/**
|
|
819
|
-
* Comprime l'immagine passando come parametri le options create nell'oggetto sopra, e il file dal reader principale
|
|
820
|
-
*/
|
|
821
|
-
imageCompression(file, options).then((fileCompressed => {
|
|
822
|
-
let fileReader = new FileReader();
|
|
823
|
-
//Faccio la push di ogni file all'interno dell'array di file dell'item da mandare al server
|
|
824
|
-
fileReader.onload = function () {
|
|
825
|
-
let resultReader = fileReader.result;
|
|
826
|
-
var marker = ';base64,';
|
|
827
|
-
self.newAttachment.FileDataBase64 = resultReader.substring(resultReader.indexOf(marker) + marker.length);
|
|
828
|
-
self.showCropImage = false;
|
|
829
|
-
self.newAttachmentForm.enable();
|
|
830
|
-
};
|
|
831
|
-
fileReader.readAsDataURL(fileCompressed);
|
|
832
|
-
}));
|
|
833
|
-
}
|
|
834
|
-
confirmCrop() {
|
|
835
|
-
this.imageCropper.crop();
|
|
836
|
-
}
|
|
837
|
-
/**
|
|
838
|
-
* Annulla la selezione del file, svuotando l'input e resettando tutte le proprietà dell'IAttachmentDTO
|
|
839
|
-
*/
|
|
840
|
-
abortFile() {
|
|
841
|
-
this.imageChangedEvent = '';
|
|
842
|
-
if (this.imageInput)
|
|
843
|
-
this.imageInput.nativeElement.value = '';
|
|
844
|
-
this.selectedFile = null;
|
|
845
|
-
this.selectedFiles = null;
|
|
846
|
-
this.showCropImage = false;
|
|
847
|
-
this.newAttachment.IsImage = false;
|
|
848
|
-
this.newAttachment.FileDataBase64 = null;
|
|
849
|
-
this.newAttachment.FileName = null;
|
|
850
|
-
this.newAttachment.FileExtension = null;
|
|
851
|
-
this.newAttachment.FileContentType = null;
|
|
852
|
-
this.newMultipleAttachments = new Array();
|
|
853
|
-
this.customHeight = null;
|
|
854
|
-
this.customWidth = null;
|
|
855
|
-
this.originalHeight = null;
|
|
856
|
-
this.originalWidth = null;
|
|
857
|
-
}
|
|
858
|
-
};
|
|
859
|
-
EqpAttachmentsComponent.ctorParameters = () => [
|
|
860
|
-
{ type: MatDialog },
|
|
861
|
-
{ type: FormBuilder },
|
|
862
|
-
{ type: DomSanitizer },
|
|
863
|
-
{ type: HttpClient },
|
|
864
|
-
{ type: ChangeDetectorRef }
|
|
865
|
-
];
|
|
866
|
-
__decorate([
|
|
867
|
-
Input("disableAction")
|
|
868
|
-
], EqpAttachmentsComponent.prototype, "disableAction", void 0);
|
|
869
|
-
__decorate([
|
|
870
|
-
Input("showHeader")
|
|
871
|
-
], EqpAttachmentsComponent.prototype, "showHeader", void 0);
|
|
872
|
-
__decorate([
|
|
873
|
-
Input("headerTitle")
|
|
874
|
-
], EqpAttachmentsComponent.prototype, "headerTitle", void 0);
|
|
875
|
-
__decorate([
|
|
876
|
-
Input("attachmentsList")
|
|
877
|
-
], EqpAttachmentsComponent.prototype, "attachmentsList", void 0);
|
|
878
|
-
__decorate([
|
|
879
|
-
Input("showMatCard")
|
|
880
|
-
], EqpAttachmentsComponent.prototype, "showMatCard", void 0);
|
|
881
|
-
__decorate([
|
|
882
|
-
Input("multipleAttachment")
|
|
883
|
-
], EqpAttachmentsComponent.prototype, "multipleAttachment", void 0);
|
|
884
|
-
__decorate([
|
|
885
|
-
Input("loadMultipleFiles")
|
|
886
|
-
], EqpAttachmentsComponent.prototype, "loadMultipleFiles", void 0);
|
|
887
|
-
__decorate([
|
|
888
|
-
Input("attachmentsColumns")
|
|
889
|
-
], EqpAttachmentsComponent.prototype, "attachmentsColumns", void 0);
|
|
890
|
-
__decorate([
|
|
891
|
-
Input("emptyTableMessage")
|
|
892
|
-
], EqpAttachmentsComponent.prototype, "emptyTableMessage", void 0);
|
|
893
|
-
__decorate([
|
|
894
|
-
Input("allowOnlyImages")
|
|
895
|
-
], EqpAttachmentsComponent.prototype, "allowOnlyImages", void 0);
|
|
896
|
-
__decorate([
|
|
897
|
-
Input("acceptedFileTypes")
|
|
898
|
-
], EqpAttachmentsComponent.prototype, "acceptedFileTypes", void 0);
|
|
899
|
-
__decorate([
|
|
900
|
-
Input("isDisabled")
|
|
901
|
-
], EqpAttachmentsComponent.prototype, "isDisabled", void 0);
|
|
902
|
-
__decorate([
|
|
903
|
-
Input("showInlinePreview")
|
|
904
|
-
], EqpAttachmentsComponent.prototype, "showInlinePreview", void 0);
|
|
905
|
-
__decorate([
|
|
906
|
-
Input("getAttachmentEndpoint")
|
|
907
|
-
], EqpAttachmentsComponent.prototype, "getAttachmentEndpoint", void 0);
|
|
908
|
-
__decorate([
|
|
909
|
-
Input("productionBaseUrl")
|
|
910
|
-
], EqpAttachmentsComponent.prototype, "productionBaseUrl", void 0);
|
|
911
|
-
__decorate([
|
|
912
|
-
Input("compressionOptions")
|
|
913
|
-
], EqpAttachmentsComponent.prototype, "compressionOptions", void 0);
|
|
914
|
-
__decorate([
|
|
915
|
-
Input("allowedTypes")
|
|
916
|
-
], EqpAttachmentsComponent.prototype, "allowedTypes", void 0);
|
|
917
|
-
__decorate([
|
|
918
|
-
Input("isEqpTableMultiLanguage")
|
|
919
|
-
], EqpAttachmentsComponent.prototype, "isEqpTableMultiLanguage", void 0);
|
|
920
|
-
__decorate([
|
|
921
|
-
Input("downloadTooltipPosition")
|
|
922
|
-
], EqpAttachmentsComponent.prototype, "downloadTooltipPosition", void 0);
|
|
923
|
-
__decorate([
|
|
924
|
-
Input("openLinkLabel")
|
|
925
|
-
], EqpAttachmentsComponent.prototype, "openLinkLabel", void 0);
|
|
926
|
-
__decorate([
|
|
927
|
-
Input("addButtonLabel")
|
|
928
|
-
], EqpAttachmentsComponent.prototype, "addButtonLabel", void 0);
|
|
929
|
-
__decorate([
|
|
930
|
-
Input("downloadLabel")
|
|
931
|
-
], EqpAttachmentsComponent.prototype, "downloadLabel", void 0);
|
|
932
|
-
__decorate([
|
|
933
|
-
Input("deleteLabel")
|
|
934
|
-
], EqpAttachmentsComponent.prototype, "deleteLabel", void 0);
|
|
935
|
-
__decorate([
|
|
936
|
-
Input("fileNameLabel")
|
|
937
|
-
], EqpAttachmentsComponent.prototype, "fileNameLabel", void 0);
|
|
938
|
-
__decorate([
|
|
939
|
-
Input("previewLabel")
|
|
940
|
-
], EqpAttachmentsComponent.prototype, "previewLabel", void 0);
|
|
941
|
-
__decorate([
|
|
942
|
-
Input("uploadFileLabel")
|
|
943
|
-
], EqpAttachmentsComponent.prototype, "uploadFileLabel", void 0);
|
|
944
|
-
__decorate([
|
|
945
|
-
Input("confirmLabel")
|
|
946
|
-
], EqpAttachmentsComponent.prototype, "confirmLabel", void 0);
|
|
947
|
-
__decorate([
|
|
948
|
-
Input("abortLabel")
|
|
949
|
-
], EqpAttachmentsComponent.prototype, "abortLabel", void 0);
|
|
950
|
-
__decorate([
|
|
951
|
-
Input("saveLabel")
|
|
952
|
-
], EqpAttachmentsComponent.prototype, "saveLabel", void 0);
|
|
953
|
-
__decorate([
|
|
954
|
-
Input("exitLabel")
|
|
955
|
-
], EqpAttachmentsComponent.prototype, "exitLabel", void 0);
|
|
956
|
-
__decorate([
|
|
957
|
-
Input("eqpTableSearchText")
|
|
958
|
-
], EqpAttachmentsComponent.prototype, "eqpTableSearchText", void 0);
|
|
959
|
-
__decorate([
|
|
960
|
-
Input("deleteDialogTitle")
|
|
961
|
-
], EqpAttachmentsComponent.prototype, "deleteDialogTitle", void 0);
|
|
962
|
-
__decorate([
|
|
963
|
-
Input("deleteDialogMessage")
|
|
964
|
-
], EqpAttachmentsComponent.prototype, "deleteDialogMessage", void 0);
|
|
965
|
-
__decorate([
|
|
966
|
-
Input("noImageSelectedErrorMessage")
|
|
967
|
-
], EqpAttachmentsComponent.prototype, "noImageSelectedErrorMessage", void 0);
|
|
968
|
-
__decorate([
|
|
969
|
-
Input("wrongTypeSelectedErrorMessage")
|
|
970
|
-
], EqpAttachmentsComponent.prototype, "wrongTypeSelectedErrorMessage", void 0);
|
|
971
|
-
__decorate([
|
|
972
|
-
Input("videoPreviewErrorMessage")
|
|
973
|
-
], EqpAttachmentsComponent.prototype, "videoPreviewErrorMessage", void 0);
|
|
974
|
-
__decorate([
|
|
975
|
-
Input("videoPreviewErrorMessage")
|
|
976
|
-
], EqpAttachmentsComponent.prototype, "audioPreviewErrorMessage", void 0);
|
|
977
|
-
__decorate([
|
|
978
|
-
Output()
|
|
979
|
-
], EqpAttachmentsComponent.prototype, "localEditedAttachments", void 0);
|
|
980
|
-
__decorate([
|
|
981
|
-
Output()
|
|
982
|
-
], EqpAttachmentsComponent.prototype, "abortAddAttachment", void 0);
|
|
983
|
-
__decorate([
|
|
984
|
-
Output("downloadAttachment")
|
|
985
|
-
], EqpAttachmentsComponent.prototype, "downloadAttachment", void 0);
|
|
986
|
-
__decorate([
|
|
987
|
-
Output("onDeleteAttachment")
|
|
988
|
-
], EqpAttachmentsComponent.prototype, "onDeleteAttachment", void 0);
|
|
989
|
-
__decorate([
|
|
990
|
-
ViewChild('dialogAddAttachment', { static: true })
|
|
991
|
-
], EqpAttachmentsComponent.prototype, "dialogAddAttachment", void 0);
|
|
992
|
-
__decorate([
|
|
993
|
-
ViewChild('dialogAddMultipleAttachment', { static: true })
|
|
994
|
-
], EqpAttachmentsComponent.prototype, "dialogAddMultipleAttachment", void 0);
|
|
995
|
-
__decorate([
|
|
996
|
-
ViewChild(ImageCropperComponent)
|
|
997
|
-
], EqpAttachmentsComponent.prototype, "imageCropper", void 0);
|
|
998
|
-
__decorate([
|
|
999
|
-
ViewChild('imageInput')
|
|
1000
|
-
], EqpAttachmentsComponent.prototype, "imageInput", void 0);
|
|
1001
|
-
__decorate([
|
|
1002
|
-
ViewChild('attachmentTable', { static: false })
|
|
1003
|
-
], EqpAttachmentsComponent.prototype, "attachmentTable", void 0);
|
|
1004
|
-
__decorate([
|
|
1005
|
-
ViewChild('inlinePreviewTemplate', { static: true })
|
|
1006
|
-
], EqpAttachmentsComponent.prototype, "inlinePreviewTemplate", void 0);
|
|
1007
|
-
__decorate([
|
|
1008
|
-
ViewChild('dialogPreview', { static: true })
|
|
1009
|
-
], EqpAttachmentsComponent.prototype, "dialogPreview", void 0);
|
|
1010
|
-
EqpAttachmentsComponent = __decorate([
|
|
1011
|
-
Component({
|
|
1012
|
-
selector: 'eqp-attachments',
|
|
1013
|
-
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>",
|
|
1014
|
-
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}"]
|
|
1015
|
-
})
|
|
1016
|
-
], EqpAttachmentsComponent);
|
|
1017
|
-
|
|
1018
|
-
let MaterialModule = class MaterialModule {
|
|
1019
|
-
};
|
|
1020
|
-
MaterialModule = __decorate([
|
|
1021
|
-
NgModule({
|
|
1022
|
-
imports: [
|
|
1023
|
-
MatCheckboxModule,
|
|
1024
|
-
MatButtonModule,
|
|
1025
|
-
MatInputModule,
|
|
1026
|
-
MatAutocompleteModule,
|
|
1027
|
-
MatDatepickerModule,
|
|
1028
|
-
MatFormFieldModule,
|
|
1029
|
-
MatRadioModule,
|
|
1030
|
-
MatSelectModule,
|
|
1031
|
-
MatSliderModule,
|
|
1032
|
-
MatSlideToggleModule,
|
|
1033
|
-
MatMenuModule,
|
|
1034
|
-
MatSidenavModule,
|
|
1035
|
-
MatToolbarModule,
|
|
1036
|
-
MatListModule,
|
|
1037
|
-
MatGridListModule,
|
|
1038
|
-
MatCardModule,
|
|
1039
|
-
MatStepperModule,
|
|
1040
|
-
MatTabsModule,
|
|
1041
|
-
MatExpansionModule,
|
|
1042
|
-
MatButtonToggleModule,
|
|
1043
|
-
MatChipsModule,
|
|
1044
|
-
MatIconModule,
|
|
1045
|
-
MatProgressSpinnerModule,
|
|
1046
|
-
MatProgressBarModule,
|
|
1047
|
-
MatDialogModule,
|
|
1048
|
-
MatTooltipModule,
|
|
1049
|
-
MatSnackBarModule,
|
|
1050
|
-
MatTableModule,
|
|
1051
|
-
MatSortModule,
|
|
1052
|
-
MatPaginatorModule,
|
|
1053
|
-
MatDatepickerModule,
|
|
1054
|
-
MatNativeDateModule
|
|
1055
|
-
],
|
|
1056
|
-
exports: [
|
|
1057
|
-
MatCheckboxModule,
|
|
1058
|
-
MatButtonModule,
|
|
1059
|
-
MatInputModule,
|
|
1060
|
-
MatAutocompleteModule,
|
|
1061
|
-
MatDatepickerModule,
|
|
1062
|
-
MatFormFieldModule,
|
|
1063
|
-
MatRadioModule,
|
|
1064
|
-
MatSelectModule,
|
|
1065
|
-
MatSliderModule,
|
|
1066
|
-
MatSlideToggleModule,
|
|
1067
|
-
MatMenuModule,
|
|
1068
|
-
MatSidenavModule,
|
|
1069
|
-
MatToolbarModule,
|
|
1070
|
-
MatListModule,
|
|
1071
|
-
MatGridListModule,
|
|
1072
|
-
MatCardModule,
|
|
1073
|
-
MatStepperModule,
|
|
1074
|
-
MatTabsModule,
|
|
1075
|
-
MatExpansionModule,
|
|
1076
|
-
MatButtonToggleModule,
|
|
1077
|
-
MatChipsModule,
|
|
1078
|
-
MatIconModule,
|
|
1079
|
-
MatProgressSpinnerModule,
|
|
1080
|
-
MatProgressBarModule,
|
|
1081
|
-
MatDialogModule,
|
|
1082
|
-
MatTooltipModule,
|
|
1083
|
-
MatSnackBarModule,
|
|
1084
|
-
MatTableModule,
|
|
1085
|
-
MatSortModule,
|
|
1086
|
-
MatPaginatorModule
|
|
1087
|
-
],
|
|
1088
|
-
})
|
|
1089
|
-
], MaterialModule);
|
|
1090
|
-
|
|
1091
|
-
let EqpAttachmentsModule = class EqpAttachmentsModule {
|
|
1092
|
-
};
|
|
1093
|
-
EqpAttachmentsModule = __decorate([
|
|
1094
|
-
NgModule({
|
|
1095
|
-
declarations: [EqpAttachmentsComponent],
|
|
1096
|
-
imports: [
|
|
1097
|
-
MaterialModule,
|
|
1098
|
-
FormsModule,
|
|
1099
|
-
CommonModule,
|
|
1100
|
-
ReactiveFormsModule,
|
|
1101
|
-
ImageCropperModule,
|
|
1102
|
-
EqpTableModule
|
|
1103
|
-
],
|
|
1104
|
-
exports: [EqpAttachmentsComponent]
|
|
1105
|
-
})
|
|
1106
|
-
], EqpAttachmentsModule);
|
|
1107
|
-
|
|
1108
|
-
/*
|
|
1109
|
-
* Public API Surface of eqp-attachments
|
|
1110
|
-
*/
|
|
1111
|
-
|
|
1112
|
-
/**
|
|
1113
|
-
* Generated bundle index. Do not edit.
|
|
1114
|
-
*/
|
|
1115
|
-
|
|
1116
|
-
export { AttachmentHelperService, AttachmentType, EqpAttachmentDialogService, EqpAttachmentsComponent, EqpAttachmentsModule, ɵ0, MaterialModule as ɵa };
|
|
1117
|
-
//# sourceMappingURL=eqproject-eqp-attachments.js.map
|