@eqproject/eqp-attachments 0.1.16 → 2.0.1

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.
Files changed (48) hide show
  1. package/README.md +0 -1
  2. package/esm2020/eqproject-eqp-attachments.mjs +5 -0
  3. package/esm2020/lib/eqp-attachments.component.mjs +830 -0
  4. package/esm2020/lib/eqp-attachments.module.mjs +39 -0
  5. package/esm2020/lib/helpers/attachment.helper.mjs +61 -0
  6. package/esm2020/lib/interfaces/IAttachment.mjs +6 -0
  7. package/esm2020/lib/interfaces/IOptions.mjs +2 -0
  8. package/esm2020/lib/modules/material.module.mjs +231 -0
  9. package/esm2020/lib/services/eqp-attachment-dialog.service.mjs +103 -0
  10. package/esm2020/public-api.mjs +10 -0
  11. package/fesm2015/eqproject-eqp-attachments.mjs +1275 -0
  12. package/fesm2015/eqproject-eqp-attachments.mjs.map +1 -0
  13. package/fesm2020/eqproject-eqp-attachments.mjs +1264 -0
  14. package/fesm2020/eqproject-eqp-attachments.mjs.map +1 -0
  15. package/{eqproject-eqp-attachments.d.ts → index.d.ts} +1 -1
  16. package/lib/eqp-attachments.component.d.ts +5 -11
  17. package/lib/eqp-attachments.module.d.ts +10 -0
  18. package/lib/helpers/attachment.helper.d.ts +3 -0
  19. package/lib/modules/material.module.d.ts +35 -0
  20. package/lib/services/eqp-attachment-dialog.service.d.ts +3 -0
  21. package/package.json +30 -18
  22. package/bundles/eqproject-eqp-attachments.umd.js +0 -1409
  23. package/bundles/eqproject-eqp-attachments.umd.js.map +0 -1
  24. package/bundles/eqproject-eqp-attachments.umd.min.js +0 -2
  25. package/bundles/eqproject-eqp-attachments.umd.min.js.map +0 -1
  26. package/eqproject-eqp-attachments.metadata.json +0 -1
  27. package/esm2015/eqproject-eqp-attachments.js +0 -6
  28. package/esm2015/lib/eqp-attachments.component.js +0 -857
  29. package/esm2015/lib/eqp-attachments.module.js +0 -26
  30. package/esm2015/lib/helpers/attachment.helper.js +0 -62
  31. package/esm2015/lib/interfaces/IAttachment.js +0 -6
  32. package/esm2015/lib/interfaces/IOptions.js +0 -1
  33. package/esm2015/lib/modules/material.module.js +0 -108
  34. package/esm2015/lib/services/eqp-attachment-dialog.service.js +0 -104
  35. package/esm2015/public-api.js +0 -9
  36. package/esm5/eqproject-eqp-attachments.js +0 -6
  37. package/esm5/lib/eqp-attachments.component.js +0 -916
  38. package/esm5/lib/eqp-attachments.module.js +0 -29
  39. package/esm5/lib/helpers/attachment.helper.js +0 -63
  40. package/esm5/lib/interfaces/IAttachment.js +0 -6
  41. package/esm5/lib/interfaces/IOptions.js +0 -1
  42. package/esm5/lib/modules/material.module.js +0 -111
  43. package/esm5/lib/services/eqp-attachment-dialog.service.js +0 -113
  44. package/esm5/public-api.js +0 -9
  45. package/fesm2015/eqproject-eqp-attachments.js +0 -1148
  46. package/fesm2015/eqproject-eqp-attachments.js.map +0 -1
  47. package/fesm5/eqproject-eqp-attachments.js +0 -1223
  48. package/fesm5/eqproject-eqp-attachments.js.map +0 -1
@@ -1,1409 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/forms'), require('ngx-image-cropper'), require('browser-image-compression'), require('@eqproject/eqp-table'), require('@angular/material/dialog'), require('sweetalert2'), require('@angular/platform-browser'), require('@angular/common/http'), require('@angular/common'), require('@angular/material/checkbox'), require('@angular/material/button'), require('@angular/material/input'), require('@angular/material/autocomplete'), require('@angular/material/datepicker'), require('@angular/material/form-field'), require('@angular/material/radio'), require('@angular/material/select'), require('@angular/material/slider'), require('@angular/material/slide-toggle'), require('@angular/material/menu'), require('@angular/material/sidenav'), require('@angular/material/toolbar'), require('@angular/material/list'), require('@angular/material/grid-list'), require('@angular/material/card'), require('@angular/material/stepper'), require('@angular/material/tabs'), require('@angular/material/expansion'), require('@angular/material/button-toggle'), require('@angular/material/chips'), require('@angular/material/icon'), require('@angular/material/progress-spinner'), require('@angular/material/progress-bar'), require('@angular/material/tooltip'), require('@angular/material/snack-bar'), require('@angular/material/table'), require('@angular/material/sort'), require('@angular/material/paginator'), require('@angular/material/core')) :
3
- typeof define === 'function' && define.amd ? define('@eqproject/eqp-attachments', ['exports', '@angular/core', '@angular/forms', 'ngx-image-cropper', 'browser-image-compression', '@eqproject/eqp-table', '@angular/material/dialog', 'sweetalert2', '@angular/platform-browser', '@angular/common/http', '@angular/common', '@angular/material/checkbox', '@angular/material/button', '@angular/material/input', '@angular/material/autocomplete', '@angular/material/datepicker', '@angular/material/form-field', '@angular/material/radio', '@angular/material/select', '@angular/material/slider', '@angular/material/slide-toggle', '@angular/material/menu', '@angular/material/sidenav', '@angular/material/toolbar', '@angular/material/list', '@angular/material/grid-list', '@angular/material/card', '@angular/material/stepper', '@angular/material/tabs', '@angular/material/expansion', '@angular/material/button-toggle', '@angular/material/chips', '@angular/material/icon', '@angular/material/progress-spinner', '@angular/material/progress-bar', '@angular/material/tooltip', '@angular/material/snack-bar', '@angular/material/table', '@angular/material/sort', '@angular/material/paginator', '@angular/material/core'], factory) :
4
- (global = global || self, factory((global.eqproject = global.eqproject || {}, global.eqproject['eqp-attachments'] = {}), global.ng.core, global.ng.forms, global.ngxImageCropper, global.imageCompression, global.eqpTable, global.ng.material.dialog, global.Swal, global.ng.platformBrowser, global.ng.common.http, global.ng.common, global.ng.material.checkbox, global.ng.material.button, global.ng.material.input, global.ng.material.autocomplete, global.ng.material.datepicker, global.ng.material.formField, global.ng.material.radio, global.ng.material.select, global.ng.material.slider, global.ng.material.slideToggle, global.ng.material.menu, global.ng.material.sidenav, global.ng.material.toolbar, global.ng.material.list, global.ng.material.gridList, global.ng.material.card, global.ng.material.stepper, global.ng.material.tabs, global.ng.material.expansion, global.ng.material.buttonToggle, global.ng.material.chips, global.ng.material.icon, global.ng.material.progressSpinner, global.ng.material.progressBar, global.ng.material.tooltip, global.ng.material.snackBar, global.ng.material.table, global.ng.material.sort, global.ng.material.paginator, global.ng.material.core));
5
- }(this, (function (exports, core, forms, ngxImageCropper, imageCompression, eqpTable, dialog, Swal, platformBrowser, http, common, checkbox, button, input, autocomplete, datepicker, formField, radio, select, slider, slideToggle, menu, sidenav, toolbar, list, gridList, card, stepper, tabs, expansion, buttonToggle, chips, icon, progressSpinner, progressBar, tooltip, snackBar, table, sort, paginator, core$1) { 'use strict';
6
-
7
- imageCompression = imageCompression && Object.prototype.hasOwnProperty.call(imageCompression, 'default') ? imageCompression['default'] : imageCompression;
8
- Swal = Swal && Object.prototype.hasOwnProperty.call(Swal, 'default') ? Swal['default'] : Swal;
9
-
10
- /*! *****************************************************************************
11
- Copyright (c) Microsoft Corporation.
12
-
13
- Permission to use, copy, modify, and/or distribute this software for any
14
- purpose with or without fee is hereby granted.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
17
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
19
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
20
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
21
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22
- PERFORMANCE OF THIS SOFTWARE.
23
- ***************************************************************************** */
24
- /* global Reflect, Promise */
25
-
26
- var extendStatics = function(d, b) {
27
- extendStatics = Object.setPrototypeOf ||
28
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
30
- return extendStatics(d, b);
31
- };
32
-
33
- function __extends(d, b) {
34
- extendStatics(d, b);
35
- function __() { this.constructor = d; }
36
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
37
- }
38
-
39
- var __assign = function() {
40
- __assign = Object.assign || function __assign(t) {
41
- for (var s, i = 1, n = arguments.length; i < n; i++) {
42
- s = arguments[i];
43
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
44
- }
45
- return t;
46
- };
47
- return __assign.apply(this, arguments);
48
- };
49
-
50
- function __rest(s, e) {
51
- var t = {};
52
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
53
- t[p] = s[p];
54
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
55
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
56
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
57
- t[p[i]] = s[p[i]];
58
- }
59
- return t;
60
- }
61
-
62
- function __decorate(decorators, target, key, desc) {
63
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
64
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
65
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
66
- return c > 3 && r && Object.defineProperty(target, key, r), r;
67
- }
68
-
69
- function __param(paramIndex, decorator) {
70
- return function (target, key) { decorator(target, key, paramIndex); }
71
- }
72
-
73
- function __metadata(metadataKey, metadataValue) {
74
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
75
- }
76
-
77
- function __awaiter(thisArg, _arguments, P, generator) {
78
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
79
- return new (P || (P = Promise))(function (resolve, reject) {
80
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
81
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
82
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
83
- step((generator = generator.apply(thisArg, _arguments || [])).next());
84
- });
85
- }
86
-
87
- function __generator(thisArg, body) {
88
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
89
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
90
- function verb(n) { return function (v) { return step([n, v]); }; }
91
- function step(op) {
92
- if (f) throw new TypeError("Generator is already executing.");
93
- while (_) try {
94
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
95
- if (y = 0, t) op = [op[0] & 2, t.value];
96
- switch (op[0]) {
97
- case 0: case 1: t = op; break;
98
- case 4: _.label++; return { value: op[1], done: false };
99
- case 5: _.label++; y = op[1]; op = [0]; continue;
100
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
101
- default:
102
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
103
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
104
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
105
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
106
- if (t[2]) _.ops.pop();
107
- _.trys.pop(); continue;
108
- }
109
- op = body.call(thisArg, _);
110
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
111
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
112
- }
113
- }
114
-
115
- function __createBinding(o, m, k, k2) {
116
- if (k2 === undefined) k2 = k;
117
- o[k2] = m[k];
118
- }
119
-
120
- function __exportStar(m, exports) {
121
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
122
- }
123
-
124
- function __values(o) {
125
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
126
- if (m) return m.call(o);
127
- if (o && typeof o.length === "number") return {
128
- next: function () {
129
- if (o && i >= o.length) o = void 0;
130
- return { value: o && o[i++], done: !o };
131
- }
132
- };
133
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
134
- }
135
-
136
- function __read(o, n) {
137
- var m = typeof Symbol === "function" && o[Symbol.iterator];
138
- if (!m) return o;
139
- var i = m.call(o), r, ar = [], e;
140
- try {
141
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
142
- }
143
- catch (error) { e = { error: error }; }
144
- finally {
145
- try {
146
- if (r && !r.done && (m = i["return"])) m.call(i);
147
- }
148
- finally { if (e) throw e.error; }
149
- }
150
- return ar;
151
- }
152
-
153
- function __spread() {
154
- for (var ar = [], i = 0; i < arguments.length; i++)
155
- ar = ar.concat(__read(arguments[i]));
156
- return ar;
157
- }
158
-
159
- function __spreadArrays() {
160
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
161
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
162
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
163
- r[k] = a[j];
164
- return r;
165
- };
166
-
167
- function __await(v) {
168
- return this instanceof __await ? (this.v = v, this) : new __await(v);
169
- }
170
-
171
- function __asyncGenerator(thisArg, _arguments, generator) {
172
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
173
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
174
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
175
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
176
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
177
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
178
- function fulfill(value) { resume("next", value); }
179
- function reject(value) { resume("throw", value); }
180
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
181
- }
182
-
183
- function __asyncDelegator(o) {
184
- var i, p;
185
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
186
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
187
- }
188
-
189
- function __asyncValues(o) {
190
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
191
- var m = o[Symbol.asyncIterator], i;
192
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
193
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
194
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
195
- }
196
-
197
- function __makeTemplateObject(cooked, raw) {
198
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
199
- return cooked;
200
- };
201
-
202
- function __importStar(mod) {
203
- if (mod && mod.__esModule) return mod;
204
- var result = {};
205
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
206
- result.default = mod;
207
- return result;
208
- }
209
-
210
- function __importDefault(mod) {
211
- return (mod && mod.__esModule) ? mod : { default: mod };
212
- }
213
-
214
- function __classPrivateFieldGet(receiver, privateMap) {
215
- if (!privateMap.has(receiver)) {
216
- throw new TypeError("attempted to get private field on non-instance");
217
- }
218
- return privateMap.get(receiver);
219
- }
220
-
221
- function __classPrivateFieldSet(receiver, privateMap, value) {
222
- if (!privateMap.has(receiver)) {
223
- throw new TypeError("attempted to set private field on non-instance");
224
- }
225
- privateMap.set(receiver, value);
226
- return value;
227
- }
228
-
229
- (function (AttachmentType) {
230
- AttachmentType[AttachmentType["FILE"] = 1] = "FILE";
231
- AttachmentType[AttachmentType["LINK"] = 2] = "LINK";
232
- })(exports.AttachmentType || (exports.AttachmentType = {}));
233
-
234
- var AttachmentHelperService = /** @class */ (function () {
235
- function AttachmentHelperService() {
236
- }
237
- /**
238
- * Restituisce TRUE se il mime type passato nel parametro corrisponde ad un mime type di un'immagine
239
- * @param mimeType Mime Type da verificare
240
- */
241
- AttachmentHelperService.checkImageFromMimeType = function (mimeType) {
242
- return this.imageMimeTypes.find(function (s) { return s == mimeType; }) != null;
243
- };
244
- /**
245
- * In base all'estensione passata come parametro, restituisce la FontAwesome corretta da utilizzare.
246
- * Se l'estensione non viene trovata nella costante riportata dentro common.model.ts restituisce un icona standard
247
- * @param extension Estensione del file per cui restituire l'icona corretta
248
- */
249
- AttachmentHelperService.getIconFromFileExtensione = function (extension) {
250
- var fileIcon = this.fileExtensionIcon[extension];
251
- return (fileIcon !== null && fileIcon !== void 0 ? fileIcon : "fas fa-file");
252
- };
253
- AttachmentHelperService.imageMimeTypes = ["image/bmp", "image/gif", "image/jpeg", "image/tiff", "image/png"];
254
- AttachmentHelperService.fileExtensionIcon = {
255
- "txt": "fas fa-file-text",
256
- "pdf": "fas fa-file-pdf",
257
- "doc": "fas fa-file-word",
258
- "docx": "fas fa-file-word",
259
- "xls": "fas fa-file-excel",
260
- "xlsx": "fas fa-file-excel",
261
- "jpg": "fas fa-file-image",
262
- "jpeg": "fas fa-file-image",
263
- "png": "fas fa-file-image",
264
- "bmp": "fas fa-file-image",
265
- "mkv": "fas fa-file-video",
266
- "flv": "fas fa-file-video",
267
- "gif": "fas fa-file-video",
268
- "gifv": "fas fa-file-video",
269
- "avi": "fas fa-file-video",
270
- "wmv": "fas fa-file-video",
271
- "mp4": "fas fa-file-video",
272
- "m4p": "fas fa-file-video",
273
- "m4v": "fas fa-file-video",
274
- "mpg": "fas fa-file-video",
275
- "mp2": "fas fa-file-video",
276
- "mpeg": "fas fa-file-video",
277
- "mpe": "fas fa-file-video",
278
- "mpv": "fas fa-file-video",
279
- "m2v": "fas fa-file-video",
280
- "3gp": "fas fa-file-video",
281
- "3g2": "fas fa-file-video",
282
- "mp3": "fas fa-file-audio",
283
- };
284
- AttachmentHelperService.ɵprov = core.ɵɵdefineInjectable({ factory: function AttachmentHelperService_Factory() { return new AttachmentHelperService(); }, token: AttachmentHelperService, providedIn: "root" });
285
- AttachmentHelperService = __decorate([
286
- core.Injectable({
287
- providedIn: 'root'
288
- })
289
- ], AttachmentHelperService);
290
- return AttachmentHelperService;
291
- }());
292
-
293
- var EqpAttachmentDialogService = /** @class */ (function () {
294
- function EqpAttachmentDialogService() {
295
- }
296
- /**
297
- * Mostra uno sweet alert di tipo ERROR con il messaggio passato come parametro.
298
- * @param message Messaggio d'errore da mostrare nello sweetalert
299
- * @param title Titolo dello sweetalert (di default mostra 'Errore')
300
- */
301
- EqpAttachmentDialogService.Error = function (message, title) {
302
- if (title === void 0) { title = null; }
303
- var currentTitle = title != null ? title : 'Errore';
304
- if (Array.isArray(message)) {
305
- currentTitle = title != null ? title : 'Errore';
306
- var htmlErrors = message.join("<br>");
307
- Swal.fire({
308
- title: currentTitle,
309
- html: htmlErrors,
310
- icon: 'error'
311
- });
312
- }
313
- else {
314
- Swal.fire(currentTitle, message, 'error');
315
- }
316
- };
317
- /**
318
- * Mostra uno sweetalert di tipo CONFIRM con il messaggio passato come parametro e se viene premuto
319
- * CONFERMA lancia la funzione di callback passata come parametro
320
- * @param message Messaggio da mostrare nello sweetalert
321
- * @param title Titolo dello sweetalert (di default mostra 'Info')
322
- */
323
- EqpAttachmentDialogService.Confirm = function (message, confirmCallback, isWarning, title, customWidth) {
324
- if (isWarning === void 0) { isWarning = false; }
325
- if (title === void 0) { title = null; }
326
- if (customWidth === void 0) { customWidth = null; }
327
- var currentTitle = title != null ? title : 'Sei sicuro di voler procedere?';
328
- if (Array.isArray(message)) {
329
- var htmlErrors = message.join("<br>");
330
- Swal.fire({
331
- title: currentTitle,
332
- html: htmlErrors,
333
- width: customWidth ? customWidth : '32rem',
334
- icon: !isWarning ? 'question' : 'warning',
335
- showCancelButton: true,
336
- allowOutsideClick: false,
337
- allowEscapeKey: false
338
- }).then(function (result) {
339
- if (result.value && confirmCallback) {
340
- confirmCallback();
341
- }
342
- });
343
- }
344
- else {
345
- Swal.fire({
346
- title: currentTitle,
347
- text: message,
348
- width: customWidth ? customWidth : '32rem',
349
- icon: !isWarning ? 'question' : 'warning',
350
- showCancelButton: true,
351
- allowOutsideClick: false,
352
- allowEscapeKey: false
353
- }).then(function (result) {
354
- if (result.value && confirmCallback) {
355
- confirmCallback();
356
- }
357
- });
358
- }
359
- };
360
- /**
361
- * Mostra uno sweetalert di tipo INFO con il messaggio passato come parametro
362
- * @param message Messaggio da mostrare nello sweetalert
363
- * @param title Titolo dello sweetalert (di default mostra 'Info')
364
- */
365
- EqpAttachmentDialogService.Info = function (message, title, isToast) {
366
- if (title === void 0) { title = null; }
367
- if (isToast === void 0) { isToast = null; }
368
- var currentTitle = title != null ? title : "Informazione:";
369
- Swal.fire(currentTitle, message, 'info');
370
- };
371
- /**
372
- * Mostra uno sweetalert di tipo WARNING con il messaggio passato come parametro
373
- * @param message Messaggio da mostrare nello sweetalert
374
- * @param title Titolo dello sweetalert (di default mostra 'Attenzione!')
375
- */
376
- EqpAttachmentDialogService.Warning = function (message, title, isToast) {
377
- if (title === void 0) { title = null; }
378
- if (isToast === void 0) { isToast = null; }
379
- var currentTitle = title != null ? title : "Attenzione!";
380
- if (Array.isArray(message)) {
381
- var htmlWarnings = message.join("<br>");
382
- Swal.fire({
383
- title: currentTitle,
384
- html: htmlWarnings,
385
- icon: 'warning'
386
- });
387
- }
388
- else {
389
- Swal.fire(currentTitle, message, 'warning');
390
- }
391
- };
392
- EqpAttachmentDialogService.ɵprov = core.ɵɵdefineInjectable({ factory: function EqpAttachmentDialogService_Factory() { return new EqpAttachmentDialogService(); }, token: EqpAttachmentDialogService, providedIn: "root" });
393
- EqpAttachmentDialogService = __decorate([
394
- core.Injectable({
395
- providedIn: 'root'
396
- })
397
- ], EqpAttachmentDialogService);
398
- return EqpAttachmentDialogService;
399
- }());
400
-
401
- var toBase64 = function (file) { return new Promise(function (resolve, reject) {
402
- var reader = new FileReader();
403
- reader.readAsDataURL(file);
404
- reader.onload = function () { return resolve(reader.result.toString()); };
405
- reader.onerror = function (error) { return reject(error); };
406
- }); };
407
- var ɵ0 = toBase64;
408
- var EqpAttachmentsComponent = /** @class */ (function () {
409
- function EqpAttachmentsComponent(dialog, formBuilder, sanitizer, http, cd) {
410
- this.dialog = dialog;
411
- this.formBuilder = formBuilder;
412
- this.sanitizer = sanitizer;
413
- this.http = http;
414
- this.cd = cd;
415
- //#region @Input del componente
416
- /**
417
- * Se TRUE allora nasconde la colonna per le azioni sull'allegato (nel caso "multipleAttachment" è TRUE).
418
- */
419
- this.disableAction = false;
420
- /**
421
- * Se TRUE mostra il titolo nell'header nel caso in cui "multipleAttachment" è TRUE ("Elenco allegati" di default).
422
- */
423
- this.showHeader = true;
424
- /**
425
- * Titolo da visualizzare se il parametro "showHeader" è TRUE. Di devault viene visualizzato "Elenco allegati".
426
- */
427
- this.headerTitle = "Elenco allegati";
428
- /**
429
- * Sorgente dati da visualizzare. Nel caso si vuole gestire un singolo allegato va passato in ogni caso come Array.
430
- */
431
- this.attachmentsList = null;
432
- /**
433
- * Se TRUE non mostra la MatCard (nel caso in cui "multipleAttachment" è TRUE).
434
- */
435
- this.showMatCard = true;
436
- /**
437
- * 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".
438
- * Se TRUE allora il componente mostra l'elenco di tutti gli allegati ricevuto nel parametro "attachmentsList".
439
- */
440
- this.multipleAttachment = true;
441
- /**
442
- * Se assume il valore TRUE allora sarà possibile caricare più file per volta. Questa funzionalità è attiva
443
- * SOLO se si gestiscono allegati multipli, quindi se l'input 'multipleAttachment' assume il valore TRUE, altrimenti è sempre disabilitata.
444
- */
445
- this.loadMultipleFiles = false;
446
- /**
447
- * Configurazione delle colonne della eqp-table per la visualizzazione degli allegati (caso "multipleAttachment" è TRUE).
448
- */
449
- this.attachmentsColumns = null;
450
- /**
451
- * Imposta il messaggio da visualizzare nel caso in cui la tabella degli allegati (nel caso in cui "multipleAttachment" è TRUE) è vuota.
452
- */
453
- this.emptyTableMessage = "Nessun dato trovato";
454
- /**
455
- * Se TRUE allora permette di selezionare soltanto file di tipo immagine, avente uno dei mimetype
456
- * specificati dentro AttachmentHelperService.
457
- * Se FALSE permette di selezionare qualsiasi tipo di file
458
- */
459
- this.allowOnlyImages = false;
460
- /**
461
- * Se TRUE disabilita il pulsante di Aggiunta allegato (a prescindere dal valore del parametro "multipleAttachment").
462
- */
463
- this.isDisabled = false;
464
- /**
465
- * Mostra/nasconde la colonna per visualizzare l'anteprima dei file nella tabella (caso multipleAtatchments = true).
466
- */
467
- this.showInlinePreview = false;
468
- /**
469
- * Endpoint da chiamare per recueprare l'IAttachmentDTO completo da vedere nell'anteprima. La chiamata sarà in POST e nel body
470
- * conterrà l'IAttachmentDTO selezionato dall'utente.
471
- * La chiamata viene eseguita solo per l'anteprima delle immagini essendo necessario il base64 completo dell'immagine a dimensione reale.
472
- * Per documenti/link basta che sia popolata la proprietà FilePath di IAttachmentDTO.
473
- */
474
- this.getAttachmentEndpoint = null;
475
- /**
476
- * Hostname dell'ambiente di produzione dell'applicativo. Necessario per visualizzare l'anteprima dei documenti
477
- * tramite il viewer di google.
478
- * NOTA: Per visualizzare l'anteprima è necessario che la prorietà FilePath dell'IAttachmentDTO sia popolata e che
479
- * sia abilitato l'accesso alla cartella sul server tramite hostname.
480
- */
481
- this.productionBaseUrl = null;
482
- /**
483
- * Opzioni per la compressione delle immagini caricate.
484
- */
485
- this.compressionOptions = { maxSizeMB: 0.5, maxWidthOrHeight: 1920, useWebWorker: true };
486
- /**
487
- * Array di AttachmentType che si possono aggiungere
488
- */
489
- this.allowedTypes = [exports.AttachmentType.FILE, exports.AttachmentType.LINK];
490
- /**
491
- * Permette di stabilire se la eqp-table contenente l'elenco degli allegati utilizza
492
- * il multilingua oppure no
493
- */
494
- this.isEqpTableMultiLanguage = false;
495
- /**
496
- * Permette di stabilire, in caso di gestione allegati multipli, se la tabella contenente l'elenco
497
- * degli allegati deve essere paginata oppure no
498
- */
499
- this.tablePaginatorVisible = true;
500
- /**
501
- * In caso di gestione allegati multipli, permette di stabilire la dimensione pagina di default
502
- * per la tabella contenente l'elenco degli allegati
503
- */
504
- this.tablePaginatorSize = null;
505
- /**
506
- * Input per definire le label da usare nel componente
507
- */
508
- this.downloadTooltipPosition = eqpTable.TooltipPositionType.Below;
509
- this.openLinkLabel = "Apri link";
510
- this.addButtonLabel = "Aggiungi";
511
- this.downloadLabel = "Download";
512
- this.deleteLabel = "Elimina";
513
- this.fileNameLabel = "Nome file";
514
- this.previewLabel = "Anteprima";
515
- this.uploadFileLabel = "Carica file";
516
- this.confirmLabel = "Conferma";
517
- this.abortLabel = "Annulla";
518
- this.saveLabel = "Salva";
519
- this.exitLabel = "Esci";
520
- this.eqpTableSearchText = "Cerca";
521
- this.deleteDialogTitle = null;
522
- this.deleteDialogMessage = "Sei sicuro di voler cancellare quest'allegato?";
523
- this.noImageSelectedErrorMessage = "Non è possibile selezionare un file che non sia un'immagine.";
524
- this.wrongTypeSelectedErrorMessage = "Non è possibile caricare il file selezionato.";
525
- this.videoPreviewErrorMessage = "Impossibile aprire l'anteprima di un file video.";
526
- this.audioPreviewErrorMessage = "Impossibile aprire l'anteprima di un file audio.";
527
- //#endregion
528
- //#region @Output del componente
529
- /**
530
- * Restituisce la lista aggiornata degli allegati.
531
- */
532
- this.localEditedAttachments = new core.EventEmitter();
533
- /**
534
- * Evento scatenato alla pressione del pulsante ESCI della modale di caricamento file.
535
- */
536
- this.abortAddAttachment = new core.EventEmitter();
537
- /**
538
- * Evento di output che restituisce l'IAttachmentDTO selezionato per il download nel caso FileDataBase64, FileContentType o FileName non fossero specificati.
539
- */
540
- this.downloadAttachment = new core.EventEmitter();
541
- /**
542
- * Evento di output che restituisce l'elemento eliminato prima che questo venga effettivamente rismosso dalla lista.
543
- */
544
- this.onDeleteAttachment = new core.EventEmitter();
545
- /**
546
- * Evento di output scatenato durante l'AfterViewInit del componente che restituisce l'istanza corrente del componente.
547
- * Questo evento avvisa quando il componente è stato renderizzato, utile per esempio quando si vogliono aggiungere delle colonne
548
- * alla visualizzazione con allegati multipli lasciando però quelle pre esistenti. Questo si può fare intervenendo sulla
549
- * proprietà "attachmentsColumns" di questo componente tramite l'istanza passata come paramentro oppure tramite ViewChild
550
- * dal componente che lo ospita.
551
- */
552
- this.onComponentLoaded = new core.EventEmitter();
553
- //#endregion
554
- //#region Proprietà per gestione caricamento nuovo allegato
555
- this.newAttachment = {};
556
- this.newMultipleAttachments = [];
557
- this.attachmentType = exports.AttachmentType;
558
- this.selectedFile = null;
559
- this.selectedFiles = null;
560
- this.showCropImage = false;
561
- //#endregion
562
- //#region Proprietà per gestione ridimensionamento file di tipo image
563
- this.imageChangedEvent = '';
564
- this.croppedImage = '';
565
- this.transform = {};
566
- //#endregion
567
- this.AttachmentType = exports.AttachmentType;
568
- }
569
- EqpAttachmentsComponent.prototype.ngOnInit = function () {
570
- //Se è stata richiesta la gestione delle sole immagini allora imposta il filtro per le estensioni possibili da caricare
571
- if (!this.acceptedFileTypes)
572
- if (this.allowOnlyImages == true)
573
- this.acceptedFileTypes = "image/*";
574
- else
575
- this.acceptedFileTypes = "*";
576
- // Se non sono stati specificati i tipi da gestire ma è stato passato null o un array vuoto imposto i tipi di default.
577
- if (!this.allowedTypes || this.allowedTypes.length == 0)
578
- this.allowedTypes = [exports.AttachmentType.FILE, exports.AttachmentType.LINK];
579
- else if (this.allowedTypes.find(function (t) { return t != exports.AttachmentType.FILE && t != exports.AttachmentType.LINK; })) {
580
- EqpAttachmentDialogService.Warning("Almeno uno degli AttachmentType selezionati nel parametro \"allowedTypes\" non esiste.");
581
- this.allowedTypes = [exports.AttachmentType.FILE, exports.AttachmentType.LINK];
582
- }
583
- //Se è stata richiesta la gestione multipla degli allegati allora configura l'eqp-table
584
- if (this.multipleAttachment == true && (!this.attachmentsColumns || this.attachmentsColumns.length == 0)) {
585
- this.configureColumns();
586
- }
587
- if (this.attachmentsList == null)
588
- this.attachmentsList = new Array();
589
- this.checkAttachmentImage();
590
- };
591
- EqpAttachmentsComponent.prototype.ngAfterViewInit = function () {
592
- this.onComponentLoaded.emit(this);
593
- };
594
- EqpAttachmentsComponent.prototype.reloadData = function () {
595
- if (this.attachmentTable)
596
- this.attachmentTable.reloadDatatable();
597
- };
598
- EqpAttachmentsComponent.prototype.checkAttachmentImage = function () {
599
- this.attachmentsList.forEach(function (a) {
600
- a.IsImage = AttachmentHelperService.checkImageFromMimeType(a.FileContentType);
601
- });
602
- };
603
- //#region Gestione elenco allegati
604
- /**
605
- * Configura le colonne per l'eqp-table nel caso in cui il parametro "multipleAttachments" è TRUE.
606
- */
607
- EqpAttachmentsComponent.prototype.configureColumns = function () {
608
- var _this = this;
609
- this.attachmentsColumns = [];
610
- if (this.disableAction != true) {
611
- this.attachmentsColumns.push({
612
- key: "action", display: "",
613
- type: eqpTable.TypeColumn.MenuAction, buttonMenuIcon: "more_vert", styles: { flex: "0 0 6%" },
614
- actions: [
615
- { name: this.deleteLabel, icon: "delete", fn: function (element, index, col) { return _this.deleteAttachment(element); } },
616
- ],
617
- });
618
- }
619
- var downloadColumn = {
620
- key: "attachment", display: "",
621
- type: eqpTable.TypeColumn.SimpleAction, styles: { flex: "0 0 6%" },
622
- actions: [
623
- {
624
- name: '', fontawesome: true,
625
- icon: function (element) { return _this.showInlinePreview ? (element.AttachmentType == exports.AttachmentType.FILE ? "fas fa-cloud-download-alt" : "fas fa-external-link-alt") : _this.getAttachmentIcon(element); },
626
- fn: function (element, col, elementIndex) { return _this.viewAttachment(element); },
627
- tooltip: { tooltipText: function (element) { return element.AttachmentType == exports.AttachmentType.FILE ? _this.downloadLabel : _this.openLinkLabel; }, tooltipPosition: this.downloadTooltipPosition }
628
- },
629
- ]
630
- };
631
- var inlinePreviewColumn = {
632
- key: "InlinePreview", display: this.previewLabel,
633
- type: eqpTable.TypeColumn.ExternalTemplate,
634
- externalTemplate: this.inlinePreviewTemplate,
635
- styles: { flex: "0 0 10%" }
636
- };
637
- var fileNameColumn = { key: "FileName", display: this.fileNameLabel };
638
- if (this.showInlinePreview) {
639
- this.attachmentsColumns.push(inlinePreviewColumn);
640
- this.attachmentsColumns.push(fileNameColumn);
641
- this.attachmentsColumns.push(downloadColumn);
642
- }
643
- else {
644
- this.attachmentsColumns.push(downloadColumn);
645
- this.attachmentsColumns.push(fileNameColumn);
646
- }
647
- };
648
- /**
649
- * Elimina un allegato eliminando anche il file presente nello storage di archiviazione utilizzato (AWS o cartella progetto)
650
- * @param element IAttachmentDTO da cancellare
651
- */
652
- EqpAttachmentsComponent.prototype.deleteAttachment = function (element) {
653
- var _this = this;
654
- EqpAttachmentDialogService.Confirm(this.deleteDialogMessage, function () {
655
- _this.removeAttachmentFromList(_this.attachmentsList.indexOf(element));
656
- }, true, this.deleteDialogTitle);
657
- };
658
- /**
659
- * Rimuove l'allegato selezionato dalla lista "attachmentsList" e invoca l'evento di output che restituisce la lista aggiornata.
660
- * @param attachmentIndex Indice dell'attachment da rimuovere
661
- */
662
- EqpAttachmentsComponent.prototype.removeAttachmentFromList = function (attachmentIndex) {
663
- this.onDeleteAttachment.emit(this.attachmentsList[attachmentIndex]);
664
- this.attachmentsList.splice(attachmentIndex, 1);
665
- if (this.attachmentTable)
666
- this.attachmentTable.reloadDatatable();
667
- this.localEditedAttachments.emit(this.attachmentsList);
668
- };
669
- /**
670
- * Scarica l'allegato o apre il link
671
- * @param element Allegato da mostrare
672
- */
673
- EqpAttachmentsComponent.prototype.viewAttachment = function (attachment) {
674
- if (attachment.AttachmentType == exports.AttachmentType.LINK) {
675
- window.open(attachment.FilePath, '_blank');
676
- return;
677
- }
678
- if (attachment.FileDataBase64 && attachment.FileContentType && attachment.FileName) {
679
- var source = "data:" + attachment.FileContentType + ";base64," + attachment.FileDataBase64;
680
- var link = document.createElement("a");
681
- link.href = source;
682
- link.download = "" + attachment.FileName;
683
- link.click();
684
- }
685
- else {
686
- this.downloadAttachment.emit(attachment);
687
- }
688
- };
689
- /**
690
- * Ridefinisce l'icona da mostrare nella colonna dell'eqp-table per ogni file.
691
- * L'icona varia in base all'estensione del file
692
- * @param attachment
693
- */
694
- EqpAttachmentsComponent.prototype.getAttachmentIcon = function (attachment) {
695
- if (attachment.AttachmentType == exports.AttachmentType.LINK)
696
- return "fas fa-link";
697
- else
698
- return AttachmentHelperService.getIconFromFileExtensione(attachment.FileExtension);
699
- };
700
- //#endregion
701
- /**
702
- * Apre la modale per la definizione dei parametri del nuovo file
703
- */
704
- EqpAttachmentsComponent.prototype.openModalAddAttachment = function (attachmentType) {
705
- //Se è stato richiesto il caricamento di un LINK o è impostato il caricamento di FILE SINGOLO allora apre la modale per
706
- //il caricamento singolo del file altrimenti apre quella per il caricamento multiplo
707
- // if (attachmentType == AttachmentType.LINK || (attachmentType == AttachmentType.FILE && this.loadMultipleFiles != true)) {
708
- this.newAttachment = {};
709
- this.newAttachment.IsImage = false;
710
- this.newAttachment.AttachmentType = attachmentType;
711
- this.newMultipleAttachments = new Array();
712
- if (attachmentType == exports.AttachmentType.LINK)
713
- this.newMultipleAttachments.push(this.newAttachment);
714
- this.createAttachmentForm();
715
- //Apre la modale
716
- this.dialofRefAddAttachment = this.dialog.open(this.dialogAddAttachment, {
717
- disableClose: true,
718
- hasBackdrop: true,
719
- width: '60%',
720
- maxHeight: '80%'
721
- });
722
- };
723
- EqpAttachmentsComponent.prototype.createAttachmentForm = function () {
724
- //Crea la form per la validazione dei campi
725
- this.newAttachmentForm = this.formBuilder.group({
726
- type: [this.newAttachment.AttachmentType, forms.Validators.required],
727
- name: [this.newAttachment.FileName],
728
- path: [this.newAttachment.FilePath],
729
- customHeight: [this.customHeight],
730
- customWidth: [this.customWidth]
731
- });
732
- };
733
- EqpAttachmentsComponent.prototype.close = function (emitCloseEvent) {
734
- if (emitCloseEvent === void 0) { emitCloseEvent = true; }
735
- this.newAttachment = {};
736
- this.newMultipleAttachments = new Array();
737
- this.abortFile();
738
- if (this.newAttachmentForm)
739
- this.newAttachmentForm.reset();
740
- this.dialofRefAddAttachment.close();
741
- if (emitCloseEvent == true && this.abortAddAttachment)
742
- this.abortAddAttachment.emit();
743
- };
744
- /**
745
- * In base al tipo di allegato controlla se disabilitare o meno il pulsante per salvare.
746
- * Funzione usata nel [disable] del pulsante "Salva" del dialog per l'aggiunta di un allegato.
747
- * @returns
748
- */
749
- EqpAttachmentsComponent.prototype.disableSave = function () {
750
- if (this.loadMultipleFiles != true) {
751
- if (this.newAttachment.AttachmentType == exports.AttachmentType.FILE) {
752
- return !this.newAttachment.FileDataBase64;
753
- }
754
- else {
755
- return !this.newAttachment.FilePath;
756
- }
757
- }
758
- else {
759
- return this.newMultipleAttachments.filter(function (p) { return (p.AttachmentType == exports.AttachmentType.FILE && !p.FileDataBase64) || (p.AttachmentType == exports.AttachmentType.LINK && !p.FilePath); }).length > 0;
760
- }
761
- };
762
- EqpAttachmentsComponent.prototype.confirmAddAttachment = function () {
763
- if (this.loadMultipleFiles != true) {
764
- if (this.newAttachment.AttachmentType == exports.AttachmentType.LINK && !this.newAttachment.FileName)
765
- this.newAttachment.FileName = this.newAttachment.FilePath;
766
- if (this.attachmentsList == null)
767
- this.attachmentsList = new Array();
768
- this.attachmentsList.push(this.newAttachment);
769
- }
770
- else {
771
- if (this.newMultipleAttachments == null || this.newMultipleAttachments.length == 0)
772
- return;
773
- if (this.attachmentsList == null)
774
- this.attachmentsList = new Array();
775
- this.attachmentsList = this.attachmentsList.concat(this.newMultipleAttachments);
776
- }
777
- if (this.attachmentTable)
778
- this.attachmentTable.reloadDatatable();
779
- this.localEditedAttachments.emit(this.attachmentsList);
780
- this.close(false);
781
- };
782
- /**
783
- * Apre il dialog per l'anteprima dell'allegato selezionato.
784
- * @param row
785
- * @returns
786
- */
787
- EqpAttachmentsComponent.prototype.openPreviewDialog = function (row) {
788
- return __awaiter(this, void 0, void 0, function () {
789
- var _this = this;
790
- return __generator(this, function (_a) {
791
- switch (_a.label) {
792
- case 0:
793
- this.selectedAttachment = JSON.parse(JSON.stringify(row));
794
- if (this.selectedAttachment.AttachmentType == exports.AttachmentType.FILE) {
795
- if (this.selectedAttachment.FileContentType.startsWith("video")) {
796
- EqpAttachmentDialogService.Warning(this.videoPreviewErrorMessage);
797
- return [2 /*return*/];
798
- }
799
- else if (this.selectedAttachment.FileContentType.startsWith("audio")) {
800
- EqpAttachmentDialogService.Warning(this.audioPreviewErrorMessage);
801
- return [2 /*return*/];
802
- }
803
- }
804
- if (!(this.getAttachmentEndpoint && this.selectedAttachment.IsImage && !this.selectedAttachment.FileDataBase64)) return [3 /*break*/, 2];
805
- return [4 /*yield*/, this.getAttachmentByID()
806
- .then(function (res) { _this.selectedAttachment.FileDataBase64 = res.FileDataBase64; })
807
- .catch(function (err) { EqpAttachmentDialogService.Error(err); })];
808
- case 1:
809
- _a.sent();
810
- _a.label = 2;
811
- case 2:
812
- if (this.selectedAttachment.AttachmentType == exports.AttachmentType.LINK) {
813
- this.selectedAttachment.TrustedUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.selectedAttachment.FilePath);
814
- }
815
- else if (this.selectedAttachment.IsImage && !this.selectedAttachment.FileDataBase64 && !this.selectedAttachment.FileThumbnailBase64) {
816
- EqpAttachmentDialogService.Info("Impossibile aprire l'anteprima dell'allegato, file mancante.");
817
- return [2 /*return*/];
818
- }
819
- else if (!this.selectedAttachment.IsImage) {
820
- if (this.selectedAttachment.FilePath && this.productionBaseUrl) {
821
- this.selectedAttachment.TrustedUrl = this.sanitizer.bypassSecurityTrustResourceUrl("https://docs.google.com/gview?url=" +
822
- this.productionBaseUrl +
823
- "/" +
824
- this.selectedAttachment.FilePath +
825
- "&embedded=true");
826
- }
827
- else {
828
- EqpAttachmentDialogService.Info("Impossibile aprire l'anteprima del documento!");
829
- return [2 /*return*/];
830
- }
831
- }
832
- this.dialog.open(this.dialogPreview, {
833
- disableClose: true,
834
- hasBackdrop: true,
835
- });
836
- return [2 /*return*/];
837
- }
838
- });
839
- });
840
- };
841
- EqpAttachmentsComponent.prototype.getAttachmentByID = function () {
842
- return __awaiter(this, void 0, void 0, function () {
843
- return __generator(this, function (_a) {
844
- return [2 /*return*/, this.http.post(this.getAttachmentEndpoint, this.selectedAttachment).toPromise()];
845
- });
846
- });
847
- };
848
- //#region Gestione caricamento file
849
- /**
850
- * Evento scatenato alla selezione del file (o dei file).
851
- * 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
852
- * mostrare le funzionalità del croppie (per ritagliare l'immagine) oppure no.
853
- * Se il file caricato non è un immagine allora genera direttamente il base64 e lo associa all'allegato da salvare.
854
- * Se invece il caricamento dei file è MULTIPLO e sono presenti più file allora esegue le stesse operazioni ignorando però il contrllo
855
- * immagine per il croppie (in caso di caricamento multiplo le funzionalità del croppie sono disabilitate).
856
- */
857
- EqpAttachmentsComponent.prototype.onFileInputChange = function (event) {
858
- return __awaiter(this, void 0, void 0, function () {
859
- var _a, checkOnlyImage, base64Result, i, newAttachment, checkOnlyImage;
860
- return __generator(this, function (_b) {
861
- switch (_b.label) {
862
- case 0:
863
- this.showCropImage = false;
864
- if (!(__spread(event.target.files).length == 1 || this.loadMultipleFiles != true)) return [3 /*break*/, 5];
865
- this.selectedFile = event.target.files[0];
866
- this.selectedFiles = event.target.files;
867
- if (!this.selectedFile)
868
- return [2 /*return*/];
869
- //Memorizza i dati per l'allegato
870
- _a = this;
871
- return [4 /*yield*/, this.createAttachmentFromUploadedFile(this.selectedFile, false)];
872
- case 1:
873
- //Memorizza i dati per l'allegato
874
- _a.newAttachment = _b.sent();
875
- this.newMultipleAttachments = new Array();
876
- this.newMultipleAttachments.push(this.newAttachment);
877
- checkOnlyImage = this.checkAllowOnlyImageFile(this.newAttachment);
878
- if (checkOnlyImage == false)
879
- return [2 /*return*/];
880
- if (this.loadMultipleFiles == true && __spread(event.target.files).length == 1)
881
- this.createAttachmentForm();
882
- if (!(this.newAttachment.IsImage == true)) return [3 /*break*/, 2];
883
- this.getImageDimensions(event.target.files[0]);
884
- //Mostra il croppie e disabilita la form finchè non termina la modifica dell'immagine
885
- this.newAttachmentForm.disable();
886
- this.newAttachmentForm.controls["customWidth"].enable();
887
- this.newAttachmentForm.controls["customHeight"].enable();
888
- this.showCropImage = true;
889
- this.imageChangedEvent = event;
890
- return [3 /*break*/, 4];
891
- case 2:
892
- this.showCropImage = false;
893
- return [4 /*yield*/, this.getBase64FromFile(this.selectedFile)];
894
- case 3:
895
- base64Result = _b.sent();
896
- this.newAttachment.FileDataBase64 = base64Result.Base64File;
897
- this.newAttachment.FileContentType = base64Result.ContentType;
898
- _b.label = 4;
899
- case 4: return [3 /*break*/, 9];
900
- case 5:
901
- this.selectedFiles = event.target.files;
902
- if (!this.selectedFiles || this.selectedFiles.length == 0)
903
- return [2 /*return*/];
904
- this.newMultipleAttachments = new Array();
905
- i = 0;
906
- _b.label = 6;
907
- case 6:
908
- if (!(i < this.selectedFiles.length)) return [3 /*break*/, 9];
909
- return [4 /*yield*/, this.createAttachmentFromUploadedFile(this.selectedFiles[i], true)];
910
- case 7:
911
- newAttachment = _b.sent();
912
- checkOnlyImage = this.checkAllowOnlyImageFile(newAttachment);
913
- if (checkOnlyImage == false)
914
- return [2 /*return*/];
915
- this.newMultipleAttachments.push(newAttachment);
916
- _b.label = 8;
917
- case 8:
918
- i++;
919
- return [3 /*break*/, 6];
920
- case 9: return [2 /*return*/];
921
- }
922
- });
923
- });
924
- };
925
- /**
926
- * A partire dal FILE ricevuto in input ricostruisce l'oggetto IAttachmentDTO e lo restituisce.
927
- * Se il parametro getBase64 viene passato a TRUE allora, sempre a partire dal file,genera il base64 e
928
- * ricava il ContentType da associare all'oggetto IAttachmentDTO da restituire
929
- * @param currentFile Oggetto FILE da processare
930
- * @param getBase64 Se TRUE allora calcola base64 e ContentType del file passato in input
931
- * @returns Restituisce un oggetto di tipo IAttachmentDTO
932
- */
933
- EqpAttachmentsComponent.prototype.createAttachmentFromUploadedFile = function (currentFile, getBase64) {
934
- if (getBase64 === void 0) { getBase64 = true; }
935
- return __awaiter(this, void 0, void 0, function () {
936
- var newAttachment, base64Result;
937
- return __generator(this, function (_a) {
938
- switch (_a.label) {
939
- case 0:
940
- newAttachment = {};
941
- //Memorizza i dati per l'allegato
942
- newAttachment.AttachmentType = exports.AttachmentType.FILE;
943
- newAttachment.FileContentType = currentFile.type;
944
- newAttachment.FileName = currentFile.name;
945
- newAttachment.FileExtension = currentFile.name.substr(currentFile.name.lastIndexOf('.') + 1);
946
- newAttachment.IsImage = AttachmentHelperService.checkImageFromMimeType(currentFile.type);
947
- if (!(getBase64 == true)) return [3 /*break*/, 2];
948
- return [4 /*yield*/, this.getBase64FromFile(currentFile)];
949
- case 1:
950
- base64Result = _a.sent();
951
- newAttachment.FileDataBase64 = base64Result.Base64File;
952
- newAttachment.FileContentType = base64Result.ContentType;
953
- _a.label = 2;
954
- case 2: return [2 /*return*/, newAttachment];
955
- }
956
- });
957
- });
958
- };
959
- /**
960
- * A partire dal file passato in input restituisce un oggetto
961
- * contenente il base64 del file e il suo contentType
962
- * @param currentFile Oggetto File da cui estrapolare base64 e contentType
963
- * @returns Restituisce un oggetto avente le proprietà Base64File e ContentType
964
- */
965
- EqpAttachmentsComponent.prototype.getBase64FromFile = function (currentFile) {
966
- return __awaiter(this, void 0, void 0, function () {
967
- var base64File, contentType, result;
968
- return __generator(this, function (_a) {
969
- switch (_a.label) {
970
- case 0: return [4 /*yield*/, toBase64(currentFile)];
971
- case 1:
972
- base64File = _a.sent();
973
- contentType = null;
974
- if (base64File) {
975
- // Loris 20/01/2022: PROBLEMA - Quando eseguo l'upload di un file .sql non viene salvato/scaricato correttamente.
976
- // Questo succede perchè non viene popolato il FileContentType. Per risolvere il problema
977
- // faccio un controllo e se non esiste il FileContentType allora lo recupero dal base64 ottenuto.
978
- contentType = base64File.split(",")[0].split(":")[1].split(";")[0];
979
- // Un altro metodo per leggere il ccontent type del file è tramite una regular expression:
980
- base64File = base64File.split(",")[1];
981
- }
982
- result = {
983
- Base64File: base64File,
984
- ContentType: contentType
985
- };
986
- return [2 /*return*/, result];
987
- }
988
- });
989
- });
990
- };
991
- /**
992
- * Controlla se il file che si sta caricando è supportato dal sistema.
993
- * @returns
994
- */
995
- EqpAttachmentsComponent.prototype.checkAcceptedFiles = function () {
996
- var e_1, _a;
997
- var _this = this;
998
- if ((this.loadMultipleFiles != true && this.selectedFile.type.startsWith("video"))
999
- || (this.loadMultipleFiles == true && __spread(this.selectedFiles).filter(function (p) { return p.type.startsWith("video"); }).length > 0))
1000
- return false;
1001
- if (this.acceptedFileTypes == "*")
1002
- return true;
1003
- //Verifica che i tipi del file (o dei file) caricati siano coerenti con quelli accettati dalla direttiva
1004
- var accepted = true;
1005
- if (this.loadMultipleFiles != true)
1006
- accepted = this.acceptedFileTypes.includes(this.selectedFile.type);
1007
- else {
1008
- var uploadedFileTypes = __spread(this.selectedFiles).map(function (p) { return p.type; });
1009
- uploadedFileTypes.forEach(function (type) {
1010
- if (!_this.acceptedFileTypes.includes(type))
1011
- accepted = false;
1012
- });
1013
- }
1014
- //Questo controllo permette di gestire le casistiche per cui vengono indicati come tipi validi, ad esempio, 'image/*'
1015
- if (!accepted && this.loadMultipleFiles != true) {
1016
- try {
1017
- for (var _b = __values(this.acceptedFileTypes.split(",").filter(function (t) { return t.includes("*"); })), _c = _b.next(); !_c.done; _c = _b.next()) {
1018
- var t = _c.value;
1019
- accepted = this.selectedFile.type.startsWith(t.split("*")[0]);
1020
- if (accepted)
1021
- break;
1022
- }
1023
- }
1024
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1025
- finally {
1026
- try {
1027
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1028
- }
1029
- finally { if (e_1) throw e_1.error; }
1030
- }
1031
- }
1032
- return accepted;
1033
- };
1034
- /**
1035
- * Se eqp-attachments è stata configurata per il caricamento delle sole immagini allora verifica che il file passato in
1036
- * input sia effettivamente un immagine o no.
1037
- * Se il controllo va a buon fine restituisce TRUE altrimenti mostra un messaggio d'errore e restituisce FALSE
1038
- */
1039
- EqpAttachmentsComponent.prototype.checkAllowOnlyImageFile = function (newAttachment) {
1040
- if (this.allowOnlyImages == true && newAttachment.IsImage != true) {
1041
- EqpAttachmentDialogService.Error(this.noImageSelectedErrorMessage);
1042
- this.abortFile();
1043
- return false;
1044
- }
1045
- else if (!this.checkAcceptedFiles()) {
1046
- EqpAttachmentDialogService.Error(this.wrongTypeSelectedErrorMessage);
1047
- this.abortFile();
1048
- return false;
1049
- }
1050
- return true;
1051
- };
1052
- EqpAttachmentsComponent.prototype.getImageDimensions = function (img) {
1053
- var _this = this;
1054
- var reader = new FileReader();
1055
- reader.onload = function (e) {
1056
- var image = new Image();
1057
- image.src = e.target.result;
1058
- image.onload = function (rs) {
1059
- _this.originalHeight = rs.currentTarget['height'];
1060
- _this.originalWidth = rs.currentTarget['width'];
1061
- if (_this.originalWidth > 1280) {
1062
- _this.customWidth = 1280;
1063
- _this.customHeight = Math.round((1280 * _this.originalHeight) / _this.originalWidth);
1064
- }
1065
- else {
1066
- _this.customHeight = rs.currentTarget['height'];
1067
- _this.customWidth = rs.currentTarget['width'];
1068
- }
1069
- };
1070
- };
1071
- reader.readAsDataURL(img);
1072
- };
1073
- EqpAttachmentsComponent.prototype.restoreOriginalDimensions = function () {
1074
- this.customWidth = this.originalWidth;
1075
- this.customHeight = this.originalHeight;
1076
- };
1077
- EqpAttachmentsComponent.prototype.onDimensionsChange = function (dimension) {
1078
- if (dimension == "H") {
1079
- this.customWidth = Math.round((this.customHeight * this.originalWidth) / this.originalHeight);
1080
- }
1081
- else if (dimension == "W") {
1082
- this.customHeight = Math.round((this.customWidth * this.originalHeight) / this.originalWidth);
1083
- }
1084
- };
1085
- EqpAttachmentsComponent.prototype.imageCropped = function (event) {
1086
- this.croppedImage = event.base64;
1087
- this.getCroppedAndUpload(this.croppedImage);
1088
- };
1089
- EqpAttachmentsComponent.prototype.getCroppedAndUpload = function (file) {
1090
- var self = this;
1091
- var file = ngxImageCropper.base64ToFile(file);
1092
- var options = this.compressionOptions;
1093
- /**
1094
- * Comprime l'immagine passando come parametri le options create nell'oggetto sopra, e il file dal reader principale
1095
- */
1096
- imageCompression(file, options).then((function (fileCompressed) {
1097
- var fileReader = new FileReader();
1098
- //Faccio la push di ogni file all'interno dell'array di file dell'item da mandare al server
1099
- fileReader.onload = function () {
1100
- var resultReader = fileReader.result;
1101
- var marker = ';base64,';
1102
- self.newAttachment.FileDataBase64 = resultReader.substring(resultReader.indexOf(marker) + marker.length);
1103
- self.showCropImage = false;
1104
- self.newAttachmentForm.enable();
1105
- };
1106
- fileReader.readAsDataURL(fileCompressed);
1107
- }));
1108
- };
1109
- EqpAttachmentsComponent.prototype.confirmCrop = function () {
1110
- this.imageCropper.crop();
1111
- };
1112
- /**
1113
- * Annulla la selezione del file, svuotando l'input e resettando tutte le proprietà dell'IAttachmentDTO
1114
- */
1115
- EqpAttachmentsComponent.prototype.abortFile = function () {
1116
- this.imageChangedEvent = '';
1117
- if (this.imageInput)
1118
- this.imageInput.nativeElement.value = '';
1119
- this.selectedFile = null;
1120
- this.selectedFiles = null;
1121
- this.showCropImage = false;
1122
- this.newAttachment.IsImage = false;
1123
- this.newAttachment.FileDataBase64 = null;
1124
- this.newAttachment.FileName = null;
1125
- this.newAttachment.FileExtension = null;
1126
- this.newAttachment.FileContentType = null;
1127
- this.newMultipleAttachments = new Array();
1128
- this.customHeight = null;
1129
- this.customWidth = null;
1130
- this.originalHeight = null;
1131
- this.originalWidth = null;
1132
- };
1133
- EqpAttachmentsComponent.ctorParameters = function () { return [
1134
- { type: dialog.MatDialog },
1135
- { type: forms.FormBuilder },
1136
- { type: platformBrowser.DomSanitizer },
1137
- { type: http.HttpClient },
1138
- { type: core.ChangeDetectorRef }
1139
- ]; };
1140
- __decorate([
1141
- core.Input("disableAction")
1142
- ], EqpAttachmentsComponent.prototype, "disableAction", void 0);
1143
- __decorate([
1144
- core.Input("showHeader")
1145
- ], EqpAttachmentsComponent.prototype, "showHeader", void 0);
1146
- __decorate([
1147
- core.Input("headerTitle")
1148
- ], EqpAttachmentsComponent.prototype, "headerTitle", void 0);
1149
- __decorate([
1150
- core.Input("attachmentsList")
1151
- ], EqpAttachmentsComponent.prototype, "attachmentsList", void 0);
1152
- __decorate([
1153
- core.Input("showMatCard")
1154
- ], EqpAttachmentsComponent.prototype, "showMatCard", void 0);
1155
- __decorate([
1156
- core.Input("multipleAttachment")
1157
- ], EqpAttachmentsComponent.prototype, "multipleAttachment", void 0);
1158
- __decorate([
1159
- core.Input("loadMultipleFiles")
1160
- ], EqpAttachmentsComponent.prototype, "loadMultipleFiles", void 0);
1161
- __decorate([
1162
- core.Input("attachmentsColumns")
1163
- ], EqpAttachmentsComponent.prototype, "attachmentsColumns", void 0);
1164
- __decorate([
1165
- core.Input("emptyTableMessage")
1166
- ], EqpAttachmentsComponent.prototype, "emptyTableMessage", void 0);
1167
- __decorate([
1168
- core.Input("allowOnlyImages")
1169
- ], EqpAttachmentsComponent.prototype, "allowOnlyImages", void 0);
1170
- __decorate([
1171
- core.Input("acceptedFileTypes")
1172
- ], EqpAttachmentsComponent.prototype, "acceptedFileTypes", void 0);
1173
- __decorate([
1174
- core.Input("isDisabled")
1175
- ], EqpAttachmentsComponent.prototype, "isDisabled", void 0);
1176
- __decorate([
1177
- core.Input("showInlinePreview")
1178
- ], EqpAttachmentsComponent.prototype, "showInlinePreview", void 0);
1179
- __decorate([
1180
- core.Input("getAttachmentEndpoint")
1181
- ], EqpAttachmentsComponent.prototype, "getAttachmentEndpoint", void 0);
1182
- __decorate([
1183
- core.Input("productionBaseUrl")
1184
- ], EqpAttachmentsComponent.prototype, "productionBaseUrl", void 0);
1185
- __decorate([
1186
- core.Input("compressionOptions")
1187
- ], EqpAttachmentsComponent.prototype, "compressionOptions", void 0);
1188
- __decorate([
1189
- core.Input("allowedTypes")
1190
- ], EqpAttachmentsComponent.prototype, "allowedTypes", void 0);
1191
- __decorate([
1192
- core.Input("isEqpTableMultiLanguage")
1193
- ], EqpAttachmentsComponent.prototype, "isEqpTableMultiLanguage", void 0);
1194
- __decorate([
1195
- core.Input("tablePaginatorVisible")
1196
- ], EqpAttachmentsComponent.prototype, "tablePaginatorVisible", void 0);
1197
- __decorate([
1198
- core.Input("tablePaginatorSize")
1199
- ], EqpAttachmentsComponent.prototype, "tablePaginatorSize", void 0);
1200
- __decorate([
1201
- core.Input("downloadTooltipPosition")
1202
- ], EqpAttachmentsComponent.prototype, "downloadTooltipPosition", void 0);
1203
- __decorate([
1204
- core.Input("openLinkLabel")
1205
- ], EqpAttachmentsComponent.prototype, "openLinkLabel", void 0);
1206
- __decorate([
1207
- core.Input("addButtonLabel")
1208
- ], EqpAttachmentsComponent.prototype, "addButtonLabel", void 0);
1209
- __decorate([
1210
- core.Input("downloadLabel")
1211
- ], EqpAttachmentsComponent.prototype, "downloadLabel", void 0);
1212
- __decorate([
1213
- core.Input("deleteLabel")
1214
- ], EqpAttachmentsComponent.prototype, "deleteLabel", void 0);
1215
- __decorate([
1216
- core.Input("fileNameLabel")
1217
- ], EqpAttachmentsComponent.prototype, "fileNameLabel", void 0);
1218
- __decorate([
1219
- core.Input("previewLabel")
1220
- ], EqpAttachmentsComponent.prototype, "previewLabel", void 0);
1221
- __decorate([
1222
- core.Input("uploadFileLabel")
1223
- ], EqpAttachmentsComponent.prototype, "uploadFileLabel", void 0);
1224
- __decorate([
1225
- core.Input("confirmLabel")
1226
- ], EqpAttachmentsComponent.prototype, "confirmLabel", void 0);
1227
- __decorate([
1228
- core.Input("abortLabel")
1229
- ], EqpAttachmentsComponent.prototype, "abortLabel", void 0);
1230
- __decorate([
1231
- core.Input("saveLabel")
1232
- ], EqpAttachmentsComponent.prototype, "saveLabel", void 0);
1233
- __decorate([
1234
- core.Input("exitLabel")
1235
- ], EqpAttachmentsComponent.prototype, "exitLabel", void 0);
1236
- __decorate([
1237
- core.Input("eqpTableSearchText")
1238
- ], EqpAttachmentsComponent.prototype, "eqpTableSearchText", void 0);
1239
- __decorate([
1240
- core.Input("deleteDialogTitle")
1241
- ], EqpAttachmentsComponent.prototype, "deleteDialogTitle", void 0);
1242
- __decorate([
1243
- core.Input("deleteDialogMessage")
1244
- ], EqpAttachmentsComponent.prototype, "deleteDialogMessage", void 0);
1245
- __decorate([
1246
- core.Input("noImageSelectedErrorMessage")
1247
- ], EqpAttachmentsComponent.prototype, "noImageSelectedErrorMessage", void 0);
1248
- __decorate([
1249
- core.Input("wrongTypeSelectedErrorMessage")
1250
- ], EqpAttachmentsComponent.prototype, "wrongTypeSelectedErrorMessage", void 0);
1251
- __decorate([
1252
- core.Input("videoPreviewErrorMessage")
1253
- ], EqpAttachmentsComponent.prototype, "videoPreviewErrorMessage", void 0);
1254
- __decorate([
1255
- core.Input("videoPreviewErrorMessage")
1256
- ], EqpAttachmentsComponent.prototype, "audioPreviewErrorMessage", void 0);
1257
- __decorate([
1258
- core.Output()
1259
- ], EqpAttachmentsComponent.prototype, "localEditedAttachments", void 0);
1260
- __decorate([
1261
- core.Output()
1262
- ], EqpAttachmentsComponent.prototype, "abortAddAttachment", void 0);
1263
- __decorate([
1264
- core.Output("downloadAttachment")
1265
- ], EqpAttachmentsComponent.prototype, "downloadAttachment", void 0);
1266
- __decorate([
1267
- core.Output("onDeleteAttachment")
1268
- ], EqpAttachmentsComponent.prototype, "onDeleteAttachment", void 0);
1269
- __decorate([
1270
- core.Output("onComponentLoaded")
1271
- ], EqpAttachmentsComponent.prototype, "onComponentLoaded", void 0);
1272
- __decorate([
1273
- core.ViewChild('dialogAddAttachment', { static: true })
1274
- ], EqpAttachmentsComponent.prototype, "dialogAddAttachment", void 0);
1275
- __decorate([
1276
- core.ViewChild('dialogAddMultipleAttachment', { static: true })
1277
- ], EqpAttachmentsComponent.prototype, "dialogAddMultipleAttachment", void 0);
1278
- __decorate([
1279
- core.ViewChild(ngxImageCropper.ImageCropperComponent)
1280
- ], EqpAttachmentsComponent.prototype, "imageCropper", void 0);
1281
- __decorate([
1282
- core.ViewChild('imageInput')
1283
- ], EqpAttachmentsComponent.prototype, "imageInput", void 0);
1284
- __decorate([
1285
- core.ViewChild('attachmentTable', { static: false })
1286
- ], EqpAttachmentsComponent.prototype, "attachmentTable", void 0);
1287
- __decorate([
1288
- core.ViewChild('inlinePreviewTemplate', { static: true })
1289
- ], EqpAttachmentsComponent.prototype, "inlinePreviewTemplate", void 0);
1290
- __decorate([
1291
- core.ViewChild('dialogPreview', { static: true })
1292
- ], EqpAttachmentsComponent.prototype, "dialogPreview", void 0);
1293
- EqpAttachmentsComponent = __decorate([
1294
- core.Component({
1295
- selector: 'eqp-attachments',
1296
- 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>",
1297
- 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}"]
1298
- })
1299
- ], EqpAttachmentsComponent);
1300
- return EqpAttachmentsComponent;
1301
- }());
1302
-
1303
- var MaterialModule = /** @class */ (function () {
1304
- function MaterialModule() {
1305
- }
1306
- MaterialModule = __decorate([
1307
- core.NgModule({
1308
- imports: [
1309
- checkbox.MatCheckboxModule,
1310
- button.MatButtonModule,
1311
- input.MatInputModule,
1312
- autocomplete.MatAutocompleteModule,
1313
- datepicker.MatDatepickerModule,
1314
- formField.MatFormFieldModule,
1315
- radio.MatRadioModule,
1316
- select.MatSelectModule,
1317
- slider.MatSliderModule,
1318
- slideToggle.MatSlideToggleModule,
1319
- menu.MatMenuModule,
1320
- sidenav.MatSidenavModule,
1321
- toolbar.MatToolbarModule,
1322
- list.MatListModule,
1323
- gridList.MatGridListModule,
1324
- card.MatCardModule,
1325
- stepper.MatStepperModule,
1326
- tabs.MatTabsModule,
1327
- expansion.MatExpansionModule,
1328
- buttonToggle.MatButtonToggleModule,
1329
- chips.MatChipsModule,
1330
- icon.MatIconModule,
1331
- progressSpinner.MatProgressSpinnerModule,
1332
- progressBar.MatProgressBarModule,
1333
- dialog.MatDialogModule,
1334
- tooltip.MatTooltipModule,
1335
- snackBar.MatSnackBarModule,
1336
- table.MatTableModule,
1337
- sort.MatSortModule,
1338
- paginator.MatPaginatorModule,
1339
- datepicker.MatDatepickerModule,
1340
- core$1.MatNativeDateModule
1341
- ],
1342
- exports: [
1343
- checkbox.MatCheckboxModule,
1344
- button.MatButtonModule,
1345
- input.MatInputModule,
1346
- autocomplete.MatAutocompleteModule,
1347
- datepicker.MatDatepickerModule,
1348
- formField.MatFormFieldModule,
1349
- radio.MatRadioModule,
1350
- select.MatSelectModule,
1351
- slider.MatSliderModule,
1352
- slideToggle.MatSlideToggleModule,
1353
- menu.MatMenuModule,
1354
- sidenav.MatSidenavModule,
1355
- toolbar.MatToolbarModule,
1356
- list.MatListModule,
1357
- gridList.MatGridListModule,
1358
- card.MatCardModule,
1359
- stepper.MatStepperModule,
1360
- tabs.MatTabsModule,
1361
- expansion.MatExpansionModule,
1362
- buttonToggle.MatButtonToggleModule,
1363
- chips.MatChipsModule,
1364
- icon.MatIconModule,
1365
- progressSpinner.MatProgressSpinnerModule,
1366
- progressBar.MatProgressBarModule,
1367
- dialog.MatDialogModule,
1368
- tooltip.MatTooltipModule,
1369
- snackBar.MatSnackBarModule,
1370
- table.MatTableModule,
1371
- sort.MatSortModule,
1372
- paginator.MatPaginatorModule
1373
- ],
1374
- })
1375
- ], MaterialModule);
1376
- return MaterialModule;
1377
- }());
1378
-
1379
- var EqpAttachmentsModule = /** @class */ (function () {
1380
- function EqpAttachmentsModule() {
1381
- }
1382
- EqpAttachmentsModule = __decorate([
1383
- core.NgModule({
1384
- declarations: [EqpAttachmentsComponent],
1385
- imports: [
1386
- MaterialModule,
1387
- forms.FormsModule,
1388
- common.CommonModule,
1389
- forms.ReactiveFormsModule,
1390
- ngxImageCropper.ImageCropperModule,
1391
- eqpTable.EqpTableModule
1392
- ],
1393
- exports: [EqpAttachmentsComponent]
1394
- })
1395
- ], EqpAttachmentsModule);
1396
- return EqpAttachmentsModule;
1397
- }());
1398
-
1399
- exports.AttachmentHelperService = AttachmentHelperService;
1400
- exports.EqpAttachmentDialogService = EqpAttachmentDialogService;
1401
- exports.EqpAttachmentsComponent = EqpAttachmentsComponent;
1402
- exports.EqpAttachmentsModule = EqpAttachmentsModule;
1403
- exports.ɵ0 = ɵ0;
1404
- exports.ɵa = MaterialModule;
1405
-
1406
- Object.defineProperty(exports, '__esModule', { value: true });
1407
-
1408
- })));
1409
- //# sourceMappingURL=eqproject-eqp-attachments.umd.js.map