@dbg-riskit/angular-file 12.3.0 → 13.0.3

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 (54) hide show
  1. package/dbg-riskit-angular-file.d.ts +1 -0
  2. package/docs/README.md +1 -11
  3. package/{esm2015/dbg-riskit-angular-file.js → esm2020/dbg-riskit-angular-file.mjs} +0 -0
  4. package/esm2020/lib/abstract.file.download.directive.mjs +139 -0
  5. package/esm2020/lib/abstract.file.upload.component.mjs +84 -0
  6. package/esm2020/lib/binary.file.upload.component.mjs +25 -0
  7. package/esm2020/lib/binary.file.upload.service.mjs +41 -0
  8. package/esm2020/lib/csv.file.download.directive.mjs +83 -0
  9. package/esm2020/lib/csv.file.upload.component.mjs +47 -0
  10. package/esm2020/lib/csv.file.upload.service.mjs +108 -0
  11. package/esm2020/lib/download.menu.component.mjs +34 -0
  12. package/esm2020/lib/file.download.directive.mjs +53 -0
  13. package/esm2020/lib/file.module.mjs +78 -0
  14. package/esm2020/lib/file.size.pipe.mjs +34 -0
  15. package/{esm2015/lib/file.types.js → esm2020/lib/file.types.mjs} +0 -0
  16. package/esm2020/lib/text.file.upload.component.mjs +26 -0
  17. package/esm2020/lib/text.file.upload.service.mjs +41 -0
  18. package/{esm2015/public_api.js → esm2020/public_api.mjs} +0 -0
  19. package/fesm2015/dbg-riskit-angular-file.mjs +727 -0
  20. package/fesm2015/dbg-riskit-angular-file.mjs.map +1 -0
  21. package/fesm2020/dbg-riskit-angular-file.mjs +727 -0
  22. package/fesm2020/dbg-riskit-angular-file.mjs.map +1 -0
  23. package/lib/abstract.file.download.directive.d.ts +3 -0
  24. package/lib/abstract.file.upload.component.d.ts +3 -0
  25. package/lib/binary.file.upload.component.d.ts +3 -0
  26. package/lib/binary.file.upload.service.d.ts +3 -0
  27. package/lib/csv.file.download.directive.d.ts +3 -0
  28. package/lib/csv.file.upload.component.d.ts +3 -0
  29. package/lib/csv.file.upload.service.d.ts +3 -0
  30. package/lib/download.menu.component.d.ts +3 -0
  31. package/lib/file.download.directive.d.ts +3 -0
  32. package/lib/file.module.d.ts +14 -0
  33. package/lib/file.size.pipe.d.ts +3 -0
  34. package/lib/text.file.upload.component.d.ts +3 -0
  35. package/lib/text.file.upload.service.d.ts +3 -0
  36. package/package.json +27 -15
  37. package/bundles/dbg-riskit-angular-file.umd.js +0 -1129
  38. package/bundles/dbg-riskit-angular-file.umd.js.map +0 -1
  39. package/dbg-riskit-angular-file.metadata.json +0 -1
  40. package/esm2015/lib/abstract.file.download.directive.js +0 -141
  41. package/esm2015/lib/abstract.file.upload.component.js +0 -73
  42. package/esm2015/lib/binary.file.upload.component.js +0 -29
  43. package/esm2015/lib/binary.file.upload.service.js +0 -38
  44. package/esm2015/lib/csv.file.download.directive.js +0 -79
  45. package/esm2015/lib/csv.file.upload.component.js +0 -51
  46. package/esm2015/lib/csv.file.upload.service.js +0 -105
  47. package/esm2015/lib/download.menu.component.js +0 -28
  48. package/esm2015/lib/file.download.directive.js +0 -51
  49. package/esm2015/lib/file.module.js +0 -50
  50. package/esm2015/lib/file.size.pipe.js +0 -46
  51. package/esm2015/lib/text.file.upload.component.js +0 -30
  52. package/esm2015/lib/text.file.upload.service.js +0 -38
  53. package/fesm2015/dbg-riskit-angular-file.js +0 -704
  54. package/fesm2015/dbg-riskit-angular-file.js.map +0 -1
@@ -1,1129 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@dbg-riskit/angular-view'), require('@dbg-riskit/common'), require('file-saver'), require('rxjs'), require('rxjs/operators'), require('@angular/common'), require('@dbg-riskit/angular-logging')) :
3
- typeof define === 'function' && define.amd ? define('@dbg-riskit/angular-file', ['exports', '@angular/core', '@dbg-riskit/angular-view', '@dbg-riskit/common', 'file-saver', 'rxjs', 'rxjs/operators', '@angular/common', '@dbg-riskit/angular-logging'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["dbg-riskit"] = global["dbg-riskit"] || {}, global["dbg-riskit"]["angular-file"] = {}), global.ng.core, global["dbg-riskit"]["angular-view"], global["dbg-riskit"].common, global.saveAs, global.rxjs, global.rxjs.operators, global.ng.common, global["dbg-riskit"]["angular-logging"]));
5
- })(this, (function (exports, core, angularView, common$1, fileSaver, rxjs, operators, common, angularLogging) { 'use strict';
6
-
7
- /*! *****************************************************************************
8
- Copyright (c) Microsoft Corporation.
9
-
10
- Permission to use, copy, modify, and/or distribute this software for any
11
- purpose with or without fee is hereby granted.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
- PERFORMANCE OF THIS SOFTWARE.
20
- ***************************************************************************** */
21
- /* global Reflect, Promise */
22
- var extendStatics = function (d, b) {
23
- extendStatics = Object.setPrototypeOf ||
24
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25
- function (d, b) { for (var p in b)
26
- if (Object.prototype.hasOwnProperty.call(b, p))
27
- d[p] = b[p]; };
28
- return extendStatics(d, b);
29
- };
30
- function __extends(d, b) {
31
- if (typeof b !== "function" && b !== null)
32
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
33
- extendStatics(d, b);
34
- function __() { this.constructor = d; }
35
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36
- }
37
- var __assign = function () {
38
- __assign = Object.assign || function __assign(t) {
39
- for (var s, i = 1, n = arguments.length; i < n; i++) {
40
- s = arguments[i];
41
- for (var p in s)
42
- if (Object.prototype.hasOwnProperty.call(s, p))
43
- t[p] = s[p];
44
- }
45
- return t;
46
- };
47
- return __assign.apply(this, arguments);
48
- };
49
- function __rest(s, e) {
50
- var t = {};
51
- for (var p in s)
52
- 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
- function __decorate(decorators, target, key, desc) {
62
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
63
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
64
- r = Reflect.decorate(decorators, target, key, desc);
65
- else
66
- for (var i = decorators.length - 1; i >= 0; i--)
67
- if (d = decorators[i])
68
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
69
- return c > 3 && r && Object.defineProperty(target, key, r), r;
70
- }
71
- function __param(paramIndex, decorator) {
72
- return function (target, key) { decorator(target, key, paramIndex); };
73
- }
74
- function __metadata(metadataKey, metadataValue) {
75
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
76
- return Reflect.metadata(metadataKey, metadataValue);
77
- }
78
- function __awaiter(thisArg, _arguments, P, generator) {
79
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
80
- return new (P || (P = Promise))(function (resolve, reject) {
81
- function fulfilled(value) { try {
82
- step(generator.next(value));
83
- }
84
- catch (e) {
85
- reject(e);
86
- } }
87
- function rejected(value) { try {
88
- step(generator["throw"](value));
89
- }
90
- catch (e) {
91
- reject(e);
92
- } }
93
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
94
- step((generator = generator.apply(thisArg, _arguments || [])).next());
95
- });
96
- }
97
- function __generator(thisArg, body) {
98
- var _ = { label: 0, sent: function () { if (t[0] & 1)
99
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
100
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
101
- function verb(n) { return function (v) { return step([n, v]); }; }
102
- function step(op) {
103
- if (f)
104
- throw new TypeError("Generator is already executing.");
105
- while (_)
106
- try {
107
- 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)
108
- return t;
109
- if (y = 0, t)
110
- op = [op[0] & 2, t.value];
111
- switch (op[0]) {
112
- case 0:
113
- case 1:
114
- t = op;
115
- break;
116
- case 4:
117
- _.label++;
118
- return { value: op[1], done: false };
119
- case 5:
120
- _.label++;
121
- y = op[1];
122
- op = [0];
123
- continue;
124
- case 7:
125
- op = _.ops.pop();
126
- _.trys.pop();
127
- continue;
128
- default:
129
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
130
- _ = 0;
131
- continue;
132
- }
133
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
134
- _.label = op[1];
135
- break;
136
- }
137
- if (op[0] === 6 && _.label < t[1]) {
138
- _.label = t[1];
139
- t = op;
140
- break;
141
- }
142
- if (t && _.label < t[2]) {
143
- _.label = t[2];
144
- _.ops.push(op);
145
- break;
146
- }
147
- if (t[2])
148
- _.ops.pop();
149
- _.trys.pop();
150
- continue;
151
- }
152
- op = body.call(thisArg, _);
153
- }
154
- catch (e) {
155
- op = [6, e];
156
- y = 0;
157
- }
158
- finally {
159
- f = t = 0;
160
- }
161
- if (op[0] & 5)
162
- throw op[1];
163
- return { value: op[0] ? op[1] : void 0, done: true };
164
- }
165
- }
166
- var __createBinding = Object.create ? (function (o, m, k, k2) {
167
- if (k2 === undefined)
168
- k2 = k;
169
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
170
- }) : (function (o, m, k, k2) {
171
- if (k2 === undefined)
172
- k2 = k;
173
- o[k2] = m[k];
174
- });
175
- function __exportStar(m, o) {
176
- for (var p in m)
177
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
178
- __createBinding(o, m, p);
179
- }
180
- function __values(o) {
181
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
182
- if (m)
183
- return m.call(o);
184
- if (o && typeof o.length === "number")
185
- return {
186
- next: function () {
187
- if (o && i >= o.length)
188
- o = void 0;
189
- return { value: o && o[i++], done: !o };
190
- }
191
- };
192
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
193
- }
194
- function __read(o, n) {
195
- var m = typeof Symbol === "function" && o[Symbol.iterator];
196
- if (!m)
197
- return o;
198
- var i = m.call(o), r, ar = [], e;
199
- try {
200
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
201
- ar.push(r.value);
202
- }
203
- catch (error) {
204
- e = { error: error };
205
- }
206
- finally {
207
- try {
208
- if (r && !r.done && (m = i["return"]))
209
- m.call(i);
210
- }
211
- finally {
212
- if (e)
213
- throw e.error;
214
- }
215
- }
216
- return ar;
217
- }
218
- /** @deprecated */
219
- function __spread() {
220
- for (var ar = [], i = 0; i < arguments.length; i++)
221
- ar = ar.concat(__read(arguments[i]));
222
- return ar;
223
- }
224
- /** @deprecated */
225
- function __spreadArrays() {
226
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
227
- s += arguments[i].length;
228
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
229
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
230
- r[k] = a[j];
231
- return r;
232
- }
233
- function __spreadArray(to, from, pack) {
234
- if (pack || arguments.length === 2)
235
- for (var i = 0, l = from.length, ar; i < l; i++) {
236
- if (ar || !(i in from)) {
237
- if (!ar)
238
- ar = Array.prototype.slice.call(from, 0, i);
239
- ar[i] = from[i];
240
- }
241
- }
242
- return to.concat(ar || Array.prototype.slice.call(from));
243
- }
244
- function __await(v) {
245
- return this instanceof __await ? (this.v = v, this) : new __await(v);
246
- }
247
- function __asyncGenerator(thisArg, _arguments, generator) {
248
- if (!Symbol.asyncIterator)
249
- throw new TypeError("Symbol.asyncIterator is not defined.");
250
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
251
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
252
- function verb(n) { if (g[n])
253
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
254
- function resume(n, v) { try {
255
- step(g[n](v));
256
- }
257
- catch (e) {
258
- settle(q[0][3], e);
259
- } }
260
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
261
- function fulfill(value) { resume("next", value); }
262
- function reject(value) { resume("throw", value); }
263
- function settle(f, v) { if (f(v), q.shift(), q.length)
264
- resume(q[0][0], q[0][1]); }
265
- }
266
- function __asyncDelegator(o) {
267
- var i, p;
268
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
269
- 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; }
270
- }
271
- function __asyncValues(o) {
272
- if (!Symbol.asyncIterator)
273
- throw new TypeError("Symbol.asyncIterator is not defined.");
274
- var m = o[Symbol.asyncIterator], i;
275
- 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);
276
- 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); }); }; }
277
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
278
- }
279
- function __makeTemplateObject(cooked, raw) {
280
- if (Object.defineProperty) {
281
- Object.defineProperty(cooked, "raw", { value: raw });
282
- }
283
- else {
284
- cooked.raw = raw;
285
- }
286
- return cooked;
287
- }
288
- ;
289
- var __setModuleDefault = Object.create ? (function (o, v) {
290
- Object.defineProperty(o, "default", { enumerable: true, value: v });
291
- }) : function (o, v) {
292
- o["default"] = v;
293
- };
294
- function __importStar(mod) {
295
- if (mod && mod.__esModule)
296
- return mod;
297
- var result = {};
298
- if (mod != null)
299
- for (var k in mod)
300
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
301
- __createBinding(result, mod, k);
302
- __setModuleDefault(result, mod);
303
- return result;
304
- }
305
- function __importDefault(mod) {
306
- return (mod && mod.__esModule) ? mod : { default: mod };
307
- }
308
- function __classPrivateFieldGet(receiver, state, kind, f) {
309
- if (kind === "a" && !f)
310
- throw new TypeError("Private accessor was defined without a getter");
311
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
312
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
313
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
314
- }
315
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
316
- if (kind === "m")
317
- throw new TypeError("Private method is not writable");
318
- if (kind === "a" && !f)
319
- throw new TypeError("Private accessor was defined without a setter");
320
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
321
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
322
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
323
- }
324
-
325
- // Copyright 2017 The Kubernetes Authors.
326
- var FileSizePipe = /** @class */ (function () {
327
- function FileSizePipe(decimalPipe) {
328
- this.decimalPipe = decimalPipe;
329
- this.base = 1024;
330
- this.powerSuffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
331
- }
332
- FileSizePipe.prototype.transform = function (value) {
333
- if (value == null) {
334
- return '';
335
- }
336
- if (typeof value === 'string') {
337
- value = parseFloat(value);
338
- }
339
- var divider = 1;
340
- var power = 0;
341
- while (value / divider > this.base && power < this.powerSuffixes.length - 1) {
342
- divider *= this.base;
343
- power += 1;
344
- }
345
- var formatted = this.decimalPipe.transform(value / divider, '1.2-2') || '';
346
- var suffix = this.powerSuffixes[power];
347
- return suffix ? "" + formatted + suffix : formatted;
348
- };
349
- return FileSizePipe;
350
- }());
351
- FileSizePipe.decorators = [
352
- { type: core.Pipe, args: [{ name: 'riskFileSize' },] }
353
- ];
354
- FileSizePipe.ctorParameters = function () { return [
355
- { type: common.DecimalPipe }
356
- ]; };
357
-
358
- var AbstractFileDownloadDirective = /** @class */ (function (_super) {
359
- __extends(AbstractFileDownloadDirective, _super);
360
- function AbstractFileDownloadDirective(elementRef, dialogService, fileSizePipe, logger) {
361
- var _this = _super.call(this) || this;
362
- _this.elementRef = elementRef;
363
- _this.dialogService = dialogService;
364
- _this.fileSizePipe = fileSizePipe;
365
- _this.logger = logger;
366
- return _this;
367
- }
368
- AbstractFileDownloadDirective.prototype.isDisabled = function () {
369
- if (this.elementRef.nativeElement.disabled === true) {
370
- return true;
371
- }
372
- if (this.disabled == null) {
373
- return false;
374
- }
375
- switch (typeof this.disabled) {
376
- case 'boolean':
377
- return this.disabled;
378
- case 'string':
379
- return this.disabled.toLowerCase() === 'disabled' || this.disabled.toLowerCase() === 'true';
380
- }
381
- return false;
382
- };
383
- AbstractFileDownloadDirective.prototype.download = function () {
384
- var _this = this;
385
- if (this.isDisabled()) {
386
- return;
387
- }
388
- if (this.data == null) {
389
- this.logger.error(new Error('No data provided for download!'));
390
- return;
391
- }
392
- this.getDataObservable(this.data).pipe(operators.takeUntil(this.destroyed), operators.take(1), operators.map(function (data) { return _this.mapToFile(data); })).subscribe(function (file) { return _this.store(file); });
393
- };
394
- AbstractFileDownloadDirective.prototype.store = function (file) {
395
- setTimeout(function () {
396
- fileSaver.saveAs(file.content, file.filename || 'data.txt');
397
- });
398
- };
399
- AbstractFileDownloadDirective.prototype.getDataObservable = function (data) {
400
- if (!(data instanceof rxjs.Observable)) {
401
- return rxjs.of(data);
402
- }
403
- return this.downloadWithProgress(data);
404
- };
405
- AbstractFileDownloadDirective.prototype.downloadWithProgress = function (observableWithProgress) {
406
- var _this = this;
407
- var canceled = new rxjs.Subject();
408
- var dialog;
409
- return observableWithProgress.pipe(operators.takeUntil(canceled), operators.takeUntil(this.destroyed), operators.tap(function (event) {
410
- dialog = _this.updateProgress(event, dialog, canceled);
411
- }), operators.filter(function (event) { return !common$1.isEventObject(event)
412
- || event.type === common$1.ObservableEventType.Result; }), operators.map(function (event) {
413
- if (common$1.isEventObject(event)) {
414
- var resultEvent = event;
415
- return resultEvent.result;
416
- }
417
- return event;
418
- }), operators.catchError(function (err) { return _this.processError(err); }), operators.finalize(function () {
419
- if (dialog != null) {
420
- dialog.close();
421
- }
422
- }));
423
- };
424
- AbstractFileDownloadDirective.prototype.updateProgress = function (event, dialog, canceledSubject) {
425
- if (common$1.isEventObject(event) && event.type === common$1.ObservableEventType.Progress) {
426
- var progressEvent = event;
427
- if (dialog == null) {
428
- dialog = this.dialogService.showProgressLoaderDialog({
429
- title: 'Downloading file...',
430
- cancel: function () {
431
- canceledSubject.next();
432
- canceledSubject.complete();
433
- },
434
- valueFormatter: this.fileSizePipe
435
- });
436
- }
437
- dialog.value = progressEvent.current;
438
- dialog.total = progressEvent.total;
439
- }
440
- return dialog;
441
- };
442
- AbstractFileDownloadDirective.prototype.processError = function (err) {
443
- var title = 'Failed to download file:';
444
- var message;
445
- if ('errorType' in err) {
446
- var errorMessage = err;
447
- switch (errorMessage.status) {
448
- case 401:
449
- case 403:
450
- message = 'You are not authorized to download this file.';
451
- break;
452
- case 404:
453
- message = 'File not found.';
454
- break;
455
- default:
456
- message = errorMessage.message;
457
- }
458
- }
459
- else {
460
- if ('message' in err) {
461
- message = err.message;
462
- }
463
- else {
464
- message = 'Failed to download file.';
465
- title = undefined;
466
- }
467
- }
468
- this.dialogService.showMessageDialog({
469
- dialogType: 'error',
470
- icon: 'cloud_off',
471
- title: title,
472
- message: message
473
- });
474
- return rxjs.EMPTY;
475
- };
476
- /**
477
- * Blob constructor for testing purposes.
478
- */
479
- AbstractFileDownloadDirective.prototype.createBlob = function (data, contentType) {
480
- return new Blob(data, contentType);
481
- };
482
- return AbstractFileDownloadDirective;
483
- }(angularView.BaseComponent));
484
- AbstractFileDownloadDirective.decorators = [
485
- { type: core.Directive }
486
- ];
487
- AbstractFileDownloadDirective.ctorParameters = function () { return [
488
- { type: core.ElementRef },
489
- { type: angularView.DialogService },
490
- { type: FileSizePipe },
491
- { type: common$1.Logger }
492
- ]; };
493
- AbstractFileDownloadDirective.propDecorators = {
494
- disabled: [{ type: core.Input }]
495
- };
496
-
497
- var AbstractFileUploadComponent = /** @class */ (function (_super) {
498
- __extends(AbstractFileUploadComponent, _super);
499
- function AbstractFileUploadComponent(renderer) {
500
- var _this = _super.call(this) || this;
501
- _this.renderer = renderer;
502
- _this.error = new core.EventEmitter(true);
503
- _this.multiple = true;
504
- _this.filesLoaded = new core.EventEmitter(true);
505
- _this.fileInputHidden = false;
506
- _this.raised = true;
507
- _this.color = 'primary';
508
- _this.disabled = false;
509
- return _this;
510
- }
511
- AbstractFileUploadComponent.prototype.move = function (event) {
512
- if (this.fileInput && event.target !== this.fileInput.nativeElement) {
513
- this.renderer.setStyle(this.wrapper.nativeElement, 'left', event.offsetX + "px");
514
- }
515
- };
516
- AbstractFileUploadComponent.prototype.handleFiles = function (fileList) {
517
- var _this = this;
518
- // Check for the various File API support.
519
- if ('FileReader' in window) {
520
- this.readFiles(fileList).pipe(operators.takeUntil(this.destroyed), operators.first()).subscribe(function (files) {
521
- _this.filesLoaded.emit(files);
522
- _this.resetInputField();
523
- }, function (error) {
524
- _this.error.emit({
525
- message: common$1.toString(error),
526
- errorType: common$1.ErrorType.ERROR,
527
- status: 0
528
- });
529
- _this.resetInputField();
530
- });
531
- }
532
- else {
533
- this.error.emit({
534
- message: 'FileReader is not supported in your browser! A newer browser (IE 11+, Chrome 50+, '
535
- + 'FireFox 50+, Safari 9+) is required to use this application.',
536
- errorType: common$1.ErrorType.ERROR,
537
- status: 0
538
- });
539
- }
540
- };
541
- // Hide and show the input field to reset the selection
542
- AbstractFileUploadComponent.prototype.resetInputField = function () {
543
- var _this = this;
544
- this.fileInputHidden = true;
545
- setTimeout(function () {
546
- _this.fileInputHidden = false;
547
- });
548
- };
549
- return AbstractFileUploadComponent;
550
- }(angularView.BaseComponent));
551
- AbstractFileUploadComponent.decorators = [
552
- { type: core.Directive }
553
- ];
554
- AbstractFileUploadComponent.ctorParameters = function () { return [
555
- { type: core.Renderer2 }
556
- ]; };
557
- AbstractFileUploadComponent.propDecorators = {
558
- error: [{ type: core.Output }],
559
- label: [{ type: core.Input }],
560
- accept: [{ type: core.Input }],
561
- multiple: [{ type: core.Input }],
562
- filesLoaded: [{ type: core.Output }],
563
- fileInput: [{ type: core.ViewChild, args: ['fileInput',] }],
564
- wrapper: [{ type: core.ViewChild, args: ['wrapper',] }],
565
- raised: [{ type: core.Input }],
566
- color: [{ type: core.Input }],
567
- icon: [{ type: core.Input }],
568
- disabled: [{ type: core.Input }]
569
- };
570
-
571
- var BinaryFileUploadService = /** @class */ (function () {
572
- function BinaryFileUploadService() {
573
- }
574
- BinaryFileUploadService.prototype.readFiles = function (files) {
575
- var e_1, _a;
576
- var fileOservables = [];
577
- var _loop_1 = function (file) {
578
- fileOservables.push(new rxjs.Observable(function (observer) {
579
- setTimeout(function () {
580
- try {
581
- var reader = new FileReader();
582
- // Handle errors load
583
- reader.onload = function (event) {
584
- observer.next({
585
- bodyBase64: common$1.base64encode((event.target.result)),
586
- file: file
587
- });
588
- observer.complete();
589
- };
590
- reader.onerror = function (event) {
591
- observer.error(event.target.error);
592
- };
593
- // Read file into memory as UTF-8
594
- reader.readAsArrayBuffer(file);
595
- }
596
- catch (err) {
597
- observer.error(err);
598
- }
599
- });
600
- }));
601
- };
602
- try {
603
- for (var _b = __values(Array.from(files)), _c = _b.next(); !_c.done; _c = _b.next()) {
604
- var file = _c.value;
605
- _loop_1(file);
606
- }
607
- }
608
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
609
- finally {
610
- try {
611
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
612
- }
613
- finally { if (e_1) throw e_1.error; }
614
- }
615
- return rxjs.forkJoin(fileOservables);
616
- };
617
- return BinaryFileUploadService;
618
- }());
619
- BinaryFileUploadService.decorators = [
620
- { type: core.Injectable }
621
- ];
622
-
623
- var BinaryFileUploadComponent = /** @class */ (function (_super) {
624
- __extends(BinaryFileUploadComponent, _super);
625
- function BinaryFileUploadComponent(fileUploadService, renderer) {
626
- var _this = _super.call(this, renderer) || this;
627
- _this.fileUploadService = fileUploadService;
628
- return _this;
629
- }
630
- BinaryFileUploadComponent.prototype.readFiles = function (fileList) {
631
- return this.fileUploadService.readFiles(fileList);
632
- };
633
- return BinaryFileUploadComponent;
634
- }(AbstractFileUploadComponent));
635
- BinaryFileUploadComponent.decorators = [
636
- { type: core.Component, args: [{
637
- selector: 'risk-binary-file-upload',
638
- template: "<a *ngIf=\"raised; else notRaised\"\n mat-raised-button\n [disabled]=\"disabled\"\n [color]=\"color\"\n (mousemove)=\"move($event)\">\n <mat-icon *ngIf=\"icon\">{{icon}}</mat-icon>\n {{label}}\n <div #wrapper\n class=\"risk-file-upload-input-wrapper\">\n <input *ngIf=\"!fileInputHidden\" type=\"file\"\n id=\"fileInput\"\n #fileInput\n [multiple]=\"multiple\"\n [disabled]=\"disabled\"\n title=\"\"\n (change)=\"handleFiles($event.target.files)\"\n [accept]=\"accept\">\n </div>\n</a>\n<ng-template #notRaised>\n <a mat-button\n [disabled]=\"disabled\"\n [color]=\"color\"\n (mousemove)=\"move($event)\">\n <mat-icon *ngIf=\"icon\">{{icon}}</mat-icon>\n {{label}}\n <div #wrapper\n class=\"risk-file-upload-input-wrapper\">\n <input *ngIf=\"!fileInputHidden\" type=\"file\"\n id=\"fileInput\"\n #fileInput\n [multiple]=\"multiple\"\n [disabled]=\"disabled\"\n title=\"\"\n (change)=\"handleFiles($event.target.files)\"\n [accept]=\"accept\">\n </div>\n </a>\n</ng-template>\n",
639
- host: {
640
- '[class.risk-binary-file-upload]': 'true'
641
- },
642
- changeDetection: core.ChangeDetectionStrategy.OnPush,
643
- preserveWhitespaces: false,
644
- styles: [":host{display:block;padding:0;margin:0}:host>*{vertical-align:bottom}\n", ":host{display:inline-block}a{overflow:hidden}a .risk-file-upload-input-wrapper{width:30px;height:36px;margin-left:-15px;top:0;left:0;position:absolute;overflow:hidden;cursor:pointer;z-index:1}a .risk-file-upload-input-wrapper input{position:absolute;display:block;cursor:pointer;height:36px;font-size:36px;top:0;right:0;outline:0 none;opacity:0}\n"]
645
- },] }
646
- ];
647
- BinaryFileUploadComponent.ctorParameters = function () { return [
648
- { type: BinaryFileUploadService },
649
- { type: core.Renderer2 }
650
- ]; };
651
-
652
- var CSVFileDownloadDirective = /** @class */ (function (_super) {
653
- __extends(CSVFileDownloadDirective, _super);
654
- function CSVFileDownloadDirective(dateFormatter, elementRef, dialogService, fileSizePipe, logger) {
655
- var _this = _super.call(this, elementRef, dialogService, fileSizePipe, logger) || this;
656
- _this.dateFormatter = dateFormatter;
657
- _this.filename = 'data.csv';
658
- _this.crlfLineEnding = false;
659
- return _this;
660
- }
661
- CSVFileDownloadDirective.prototype.mapToFile = function (data) {
662
- var e_1, _a;
663
- var csvFile = '';
664
- if (this.columns) {
665
- csvFile += this.createHeader();
666
- try {
667
- for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
668
- var row = data_1_1.value;
669
- csvFile += this.processRow(row);
670
- }
671
- }
672
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
673
- finally {
674
- try {
675
- if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);
676
- }
677
- finally { if (e_1) throw e_1.error; }
678
- }
679
- }
680
- return {
681
- filename: this.filename,
682
- content: this.createBlob([csvFile], { type: common$1.CONTENT_TYPE.TEXT_CSV })
683
- };
684
- };
685
- CSVFileDownloadDirective.prototype.processRow = function (row) {
686
- var _this = this;
687
- return this.columns.map(function (column) {
688
- var value = column.get(row);
689
- var innerValue = common$1.toString(value);
690
- if (value instanceof Date) {
691
- innerValue = _this.dateFormatter.transform(value) || '';
692
- }
693
- var result = innerValue.replace(/"/g, '""');
694
- if (result.search(/([",\n])/g) >= 0) {
695
- result = "\"" + result + "\"";
696
- }
697
- return result;
698
- }).join(',') + this.getLineEnding();
699
- };
700
- CSVFileDownloadDirective.prototype.createHeader = function () {
701
- return this.columns.map(function (column) {
702
- var innerValue = common$1.toString(column.header);
703
- var result = innerValue.replace(/"/g, '""');
704
- if (result.search(/([",\n])/g) >= 0) {
705
- result = "\"" + result + "\"";
706
- }
707
- return result;
708
- }).join(',') + this.getLineEnding();
709
- };
710
- CSVFileDownloadDirective.prototype.getLineEnding = function () {
711
- if (this.crlfLineEnding) {
712
- return '\r\n';
713
- }
714
- return '\n';
715
- };
716
- return CSVFileDownloadDirective;
717
- }(AbstractFileDownloadDirective));
718
- CSVFileDownloadDirective.decorators = [
719
- { type: core.Directive, args: [{
720
- selector: '[risk-csv-download]',
721
- host: {
722
- '[class.risk-csv-download]': 'true',
723
- '(click)': 'download()'
724
- }
725
- },] }
726
- ];
727
- CSVFileDownloadDirective.ctorParameters = function () { return [
728
- { type: angularView.DateFormatter },
729
- { type: core.ElementRef },
730
- { type: angularView.DialogService },
731
- { type: FileSizePipe },
732
- { type: common$1.Logger }
733
- ]; };
734
- CSVFileDownloadDirective.propDecorators = {
735
- columns: [{ type: core.Input, args: ['risk-csv-download-columns',] }],
736
- data: [{ type: core.Input, args: ['risk-csv-download',] }],
737
- filename: [{ type: core.Input, args: ['risk-csv-download-filename',] }],
738
- crlfLineEnding: [{ type: core.Input, args: ['risk-csv-download-crlf',] }]
739
- };
740
-
741
- // Create a regular expression to parse the CSV values.
742
- var CSV_FILE_PATTERN = new RegExp((
743
- // Delimiters.
744
- '([,;]|\\r?\\n|\\r|^)' +
745
- // Quoted fields.
746
- '(?:"([^"]*(?:""[^"]*)*)"|' +
747
- // Standard fields.
748
- '([^",;\\r\\n]*))'), 'gi');
749
- var CSVFileUploadService = /** @class */ (function () {
750
- function CSVFileUploadService() {
751
- }
752
- CSVFileUploadService.prototype.readFiles = function (files, nameMapper) {
753
- var e_1, _a;
754
- if (nameMapper === void 0) { nameMapper = function (name) { return name; }; }
755
- var fileOservables = [];
756
- var _loop_1 = function (file) {
757
- fileOservables.push(new rxjs.Observable(function (observer) {
758
- setTimeout(function () {
759
- try {
760
- var reader = new FileReader();
761
- // Handle errors load
762
- reader.onload = function (event) {
763
- observer.next(CSVFileUploadService.getCSVFile(common$1.toString(event.target.result), file, nameMapper));
764
- observer.complete();
765
- };
766
- reader.onerror = function (event) {
767
- observer.error(event.target.error);
768
- };
769
- // Read file into memory as UTF-8
770
- reader.readAsText(file);
771
- }
772
- catch (err) {
773
- observer.error(err);
774
- }
775
- });
776
- }));
777
- };
778
- try {
779
- for (var _b = __values(Array.from(files)), _c = _b.next(); !_c.done; _c = _b.next()) {
780
- var file = _c.value;
781
- _loop_1(file);
782
- }
783
- }
784
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
785
- finally {
786
- try {
787
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
788
- }
789
- finally { if (e_1) throw e_1.error; }
790
- }
791
- return rxjs.forkJoin(fileOservables);
792
- };
793
- CSVFileUploadService.getCSVFile = function (content, file, nameMapper) {
794
- // Create an array to hold our data. Give the array
795
- // a default empty first row.
796
- var arrData = [[]];
797
- // Create an array to hold our individual pattern
798
- // matching groups.
799
- // Keep looping over the regular expression matches
800
- // until we can no longer find a match.
801
- while (true) {
802
- var arrMatches = CSV_FILE_PATTERN.exec(content);
803
- if (arrMatches == null) {
804
- break;
805
- }
806
- // Get the delimiter that was found.
807
- var strMatchedDelimiter = arrMatches[1];
808
- // Check to see if the given delimiter has a length
809
- // (is not the start of string) and if it matches
810
- // field delimiter. If id does not, then we know
811
- // that this delimiter is a row delimiter.
812
- if (strMatchedDelimiter.length && strMatchedDelimiter !== ',' && strMatchedDelimiter !== ';') {
813
- // Since we have reached a new row of data,
814
- // add an empty row to our data array.
815
- arrData.push([]);
816
- }
817
- var strMatchedValue = void 0;
818
- // Now that we have our delimiter out of the way,
819
- // let's check to see which kind of value we
820
- // captured (quoted or unquoted).
821
- if (arrMatches[2]) {
822
- // We found a quoted value. When we capture
823
- // this value, unescape any double quotes.
824
- strMatchedValue = arrMatches[2].replace(new RegExp('""', 'g'), '"');
825
- }
826
- else {
827
- // We found a non-quoted value.
828
- strMatchedValue = arrMatches[3];
829
- }
830
- // Now that we have our value string, let's add
831
- // it to the data array.
832
- arrData[arrData.length - 1].push(strMatchedValue);
833
- }
834
- // Filter out empty rows
835
- arrData = arrData.filter(function (dataRow) {
836
- return dataRow.some(function (item) { return item != null && item.trim() !== ''; });
837
- });
838
- // Return the parsed data.
839
- return {
840
- header: arrData[0],
841
- body: arrData.slice(1).map(function (dataRow) {
842
- var row = {};
843
- for (var i = 0; i < arrData[0].length; i++) {
844
- row[nameMapper(arrData[0][i])] = dataRow[i];
845
- }
846
- return row;
847
- }),
848
- file: {
849
- name: file.name,
850
- size: file.size,
851
- type: file.type
852
- }
853
- };
854
- };
855
- return CSVFileUploadService;
856
- }());
857
- CSVFileUploadService.decorators = [
858
- { type: core.Injectable }
859
- ];
860
-
861
- var CSVFileUploadComponent = /** @class */ (function (_super) {
862
- __extends(CSVFileUploadComponent, _super);
863
- function CSVFileUploadComponent(fileUploadService, renderer) {
864
- var _this = _super.call(this, renderer) || this;
865
- _this.fileUploadService = fileUploadService;
866
- return _this;
867
- }
868
- CSVFileUploadComponent.prototype.readFiles = function (fileList) {
869
- var _this = this;
870
- return this.fileUploadService.readFiles(fileList, this.nameMapper).pipe(operators.switchMap(function (files) {
871
- var validationErrors = [];
872
- if (!_this.validator || files.every(function (file) {
873
- var result = _this.validator(file);
874
- if (!result.result && result.messages != null) {
875
- result.messages.forEach(function (message) {
876
- validationErrors.push(message);
877
- });
878
- }
879
- return result.result;
880
- })) {
881
- return rxjs.of(files);
882
- }
883
- else {
884
- return rxjs.throwError("<li>" + validationErrors.join('</li><li>') + "</li>");
885
- }
886
- }));
887
- };
888
- return CSVFileUploadComponent;
889
- }(AbstractFileUploadComponent));
890
- CSVFileUploadComponent.decorators = [
891
- { type: core.Component, args: [{
892
- selector: 'risk-csv-file-upload',
893
- template: "<a *ngIf=\"raised; else notRaised\"\n mat-raised-button\n [disabled]=\"disabled\"\n [color]=\"color\"\n (mousemove)=\"move($event)\">\n <mat-icon *ngIf=\"icon\">{{icon}}</mat-icon>\n {{label}}\n <div #wrapper\n class=\"risk-file-upload-input-wrapper\">\n <input *ngIf=\"!fileInputHidden\" type=\"file\"\n id=\"fileInput\"\n #fileInput\n [multiple]=\"multiple\"\n [disabled]=\"disabled\"\n title=\"\"\n (change)=\"handleFiles($event.target.files)\"\n [accept]=\"accept\">\n </div>\n</a>\n<ng-template #notRaised>\n <a mat-button\n [disabled]=\"disabled\"\n [color]=\"color\"\n (mousemove)=\"move($event)\">\n <mat-icon *ngIf=\"icon\">{{icon}}</mat-icon>\n {{label}}\n <div #wrapper\n class=\"risk-file-upload-input-wrapper\">\n <input *ngIf=\"!fileInputHidden\" type=\"file\"\n id=\"fileInput\"\n #fileInput\n [multiple]=\"multiple\"\n [disabled]=\"disabled\"\n title=\"\"\n (change)=\"handleFiles($event.target.files)\"\n [accept]=\"accept\">\n </div>\n </a>\n</ng-template>\n",
894
- host: {
895
- '[class.risk-csv-file-upload]': 'true'
896
- },
897
- changeDetection: core.ChangeDetectionStrategy.OnPush,
898
- preserveWhitespaces: false,
899
- styles: [":host{display:block;padding:0;margin:0}:host>*{vertical-align:bottom}\n", ":host{display:inline-block}a{overflow:hidden}a .risk-file-upload-input-wrapper{width:30px;height:36px;margin-left:-15px;top:0;left:0;position:absolute;overflow:hidden;cursor:pointer;z-index:1}a .risk-file-upload-input-wrapper input{position:absolute;display:block;cursor:pointer;height:36px;font-size:36px;top:0;right:0;outline:0 none;opacity:0}\n"]
900
- },] }
901
- ];
902
- CSVFileUploadComponent.ctorParameters = function () { return [
903
- { type: CSVFileUploadService },
904
- { type: core.Renderer2 }
905
- ]; };
906
- CSVFileUploadComponent.propDecorators = {
907
- validator: [{ type: core.Input }],
908
- nameMapper: [{ type: core.Input }]
909
- };
910
-
911
- var TextFileUploadService = /** @class */ (function () {
912
- function TextFileUploadService() {
913
- }
914
- TextFileUploadService.prototype.readFiles = function (files) {
915
- var e_1, _a;
916
- var fileOservables = [];
917
- var _loop_1 = function (file) {
918
- fileOservables.push(new rxjs.Observable(function (observer) {
919
- setTimeout(function () {
920
- try {
921
- var reader = new FileReader();
922
- // Handle errors load
923
- reader.onload = function (event) {
924
- observer.next({
925
- body: common$1.toString(event.target.result),
926
- file: file
927
- });
928
- observer.complete();
929
- };
930
- reader.onerror = function (event) {
931
- observer.error(event.target.error);
932
- };
933
- // Read file into memory as UTF-8
934
- reader.readAsText(file);
935
- }
936
- catch (err) {
937
- observer.error(err);
938
- }
939
- });
940
- }));
941
- };
942
- try {
943
- for (var _b = __values(Array.from(files)), _c = _b.next(); !_c.done; _c = _b.next()) {
944
- var file = _c.value;
945
- _loop_1(file);
946
- }
947
- }
948
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
949
- finally {
950
- try {
951
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
952
- }
953
- finally { if (e_1) throw e_1.error; }
954
- }
955
- return rxjs.forkJoin(fileOservables);
956
- };
957
- return TextFileUploadService;
958
- }());
959
- TextFileUploadService.decorators = [
960
- { type: core.Injectable }
961
- ];
962
-
963
- var TextFileUploadComponent = /** @class */ (function (_super) {
964
- __extends(TextFileUploadComponent, _super);
965
- function TextFileUploadComponent(fileUploadService, renderer) {
966
- var _this = _super.call(this, renderer) || this;
967
- _this.fileUploadService = fileUploadService;
968
- return _this;
969
- }
970
- TextFileUploadComponent.prototype.readFiles = function (fileList) {
971
- return this.fileUploadService
972
- .readFiles(fileList);
973
- };
974
- return TextFileUploadComponent;
975
- }(AbstractFileUploadComponent));
976
- TextFileUploadComponent.decorators = [
977
- { type: core.Component, args: [{
978
- selector: 'risk-text-file-upload',
979
- template: "<a *ngIf=\"raised; else notRaised\"\n mat-raised-button\n [disabled]=\"disabled\"\n [color]=\"color\"\n (mousemove)=\"move($event)\">\n <mat-icon *ngIf=\"icon\">{{icon}}</mat-icon>\n {{label}}\n <div #wrapper\n class=\"risk-file-upload-input-wrapper\">\n <input *ngIf=\"!fileInputHidden\" type=\"file\"\n id=\"fileInput\"\n #fileInput\n [multiple]=\"multiple\"\n [disabled]=\"disabled\"\n title=\"\"\n (change)=\"handleFiles($event.target.files)\"\n [accept]=\"accept\">\n </div>\n</a>\n<ng-template #notRaised>\n <a mat-button\n [disabled]=\"disabled\"\n [color]=\"color\"\n (mousemove)=\"move($event)\">\n <mat-icon *ngIf=\"icon\">{{icon}}</mat-icon>\n {{label}}\n <div #wrapper\n class=\"risk-file-upload-input-wrapper\">\n <input *ngIf=\"!fileInputHidden\" type=\"file\"\n id=\"fileInput\"\n #fileInput\n [multiple]=\"multiple\"\n [disabled]=\"disabled\"\n title=\"\"\n (change)=\"handleFiles($event.target.files)\"\n [accept]=\"accept\">\n </div>\n </a>\n</ng-template>\n",
980
- host: {
981
- '[class.risk-text-file-upload]': 'true'
982
- },
983
- changeDetection: core.ChangeDetectionStrategy.OnPush,
984
- preserveWhitespaces: false,
985
- styles: [":host{display:block;padding:0;margin:0}:host>*{vertical-align:bottom}\n", ":host{display:inline-block}a{overflow:hidden}a .risk-file-upload-input-wrapper{width:30px;height:36px;margin-left:-15px;top:0;left:0;position:absolute;overflow:hidden;cursor:pointer;z-index:1}a .risk-file-upload-input-wrapper input{position:absolute;display:block;cursor:pointer;height:36px;font-size:36px;top:0;right:0;outline:0 none;opacity:0}\n"]
986
- },] }
987
- ];
988
- TextFileUploadComponent.ctorParameters = function () { return [
989
- { type: TextFileUploadService },
990
- { type: core.Renderer2 }
991
- ]; };
992
-
993
- var CSVDownloadMenuComponent = /** @class */ (function () {
994
- function CSVDownloadMenuComponent() {
995
- this.menuLabel = 'Download';
996
- this.disabled = false;
997
- }
998
- return CSVDownloadMenuComponent;
999
- }());
1000
- CSVDownloadMenuComponent.decorators = [
1001
- { type: core.Component, args: [{
1002
- selector: 'risk-download-menu',
1003
- template: "<mat-menu #downloadMenu=\"matMenu\"\n [overlapTrigger]=\"false\">\n <a mat-menu-item\n [risk-csv-download]=\"data\"\n [risk-csv-download-columns]=\"columns\"\n [risk-csv-download-filename]=\"filename\"\n [risk-csv-download-crlf]=\"true\">\n As CSV file (Windows)\n </a>\n <a mat-menu-item\n [risk-csv-download]=\"data\"\n [risk-csv-download-columns]=\"columns\"\n [risk-csv-download-filename]=\"filename\">\n As CSV file (Unix)\n </a>\n</mat-menu>\n\n<button mat-button\n #menu=\"matMenuTrigger\"\n [disabled]=\"disabled\"\n [matMenuTriggerFor]=\"downloadMenu\"\n [class.risk-menu-open]=\"menu.menuOpen\"\n [matTooltip]=\"menuTooltip\">\n <mat-icon>file_download</mat-icon>\n {{ menuLabel }}\n</button>\n",
1004
- host: {
1005
- '[class.risk-download-menu]': 'true'
1006
- },
1007
- changeDetection: core.ChangeDetectionStrategy.OnPush,
1008
- preserveWhitespaces: false,
1009
- styles: [":host{display:block;padding:0;margin:0}:host>*{vertical-align:bottom}\n", ":host{display:inline-block}\n"]
1010
- },] }
1011
- ];
1012
- CSVDownloadMenuComponent.propDecorators = {
1013
- menuLabel: [{ type: core.Input }],
1014
- menuTooltip: [{ type: core.Input }],
1015
- columns: [{ type: core.Input }],
1016
- data: [{ type: core.Input }],
1017
- disabled: [{ type: core.Input }],
1018
- filename: [{ type: core.Input }]
1019
- };
1020
-
1021
- var FileDownloadDirective = /** @class */ (function (_super) {
1022
- __extends(FileDownloadDirective, _super);
1023
- function FileDownloadDirective(elementRef, dialogService, fileSizePipe, logger) {
1024
- return _super.call(this, elementRef, dialogService, fileSizePipe, logger) || this;
1025
- }
1026
- FileDownloadDirective.prototype.mapToFile = function (data) {
1027
- var filename = this.filename || 'data.txt';
1028
- if (data instanceof Blob) {
1029
- return {
1030
- content: data,
1031
- filename: filename
1032
- };
1033
- }
1034
- if (typeof data === 'object' && 'content' in data && data.content instanceof Blob) {
1035
- return {
1036
- content: data.content,
1037
- filename: data.filename || filename
1038
- };
1039
- }
1040
- var stringData = typeof data === 'string' ? data : JSON.stringify(data);
1041
- return {
1042
- content: this.createBlob([stringData], { type: this.contentType }),
1043
- filename: filename
1044
- };
1045
- };
1046
- return FileDownloadDirective;
1047
- }(AbstractFileDownloadDirective));
1048
- FileDownloadDirective.decorators = [
1049
- { type: core.Directive, args: [{
1050
- selector: '[risk-download]',
1051
- host: {
1052
- '[class.risk-download]': 'true',
1053
- '(click)': 'download()'
1054
- }
1055
- },] }
1056
- ];
1057
- FileDownloadDirective.ctorParameters = function () { return [
1058
- { type: core.ElementRef },
1059
- { type: angularView.DialogService },
1060
- { type: FileSizePipe },
1061
- { type: common$1.Logger }
1062
- ]; };
1063
- FileDownloadDirective.propDecorators = {
1064
- data: [{ type: core.Input, args: ['risk-download',] }],
1065
- contentType: [{ type: core.Input, args: ['risk-download-content-type',] }],
1066
- filename: [{ type: core.Input, args: ['risk-download-filename',] }]
1067
- };
1068
-
1069
- var FileModule = /** @class */ (function () {
1070
- function FileModule() {
1071
- }
1072
- return FileModule;
1073
- }());
1074
- FileModule.decorators = [
1075
- { type: core.NgModule, args: [{
1076
- imports: [
1077
- common.CommonModule,
1078
- angularView.CommonViewModule,
1079
- angularLogging.LoggingModule
1080
- ],
1081
- declarations: [
1082
- BinaryFileUploadComponent,
1083
- CSVFileUploadComponent,
1084
- TextFileUploadComponent,
1085
- CSVFileDownloadDirective,
1086
- CSVDownloadMenuComponent,
1087
- FileDownloadDirective,
1088
- FileSizePipe
1089
- ],
1090
- exports: [
1091
- BinaryFileUploadComponent,
1092
- CSVFileUploadComponent,
1093
- TextFileUploadComponent,
1094
- CSVFileDownloadDirective,
1095
- CSVDownloadMenuComponent,
1096
- FileDownloadDirective,
1097
- FileSizePipe
1098
- ],
1099
- providers: [
1100
- BinaryFileUploadService,
1101
- CSVFileUploadService,
1102
- TextFileUploadService,
1103
- FileSizePipe
1104
- ]
1105
- },] }
1106
- ];
1107
-
1108
- /**
1109
- * Generated bundle index. Do not edit.
1110
- */
1111
-
1112
- exports.AbstractFileDownloadDirective = AbstractFileDownloadDirective;
1113
- exports.AbstractFileUploadComponent = AbstractFileUploadComponent;
1114
- exports.BinaryFileUploadComponent = BinaryFileUploadComponent;
1115
- exports.BinaryFileUploadService = BinaryFileUploadService;
1116
- exports.CSVDownloadMenuComponent = CSVDownloadMenuComponent;
1117
- exports.CSVFileDownloadDirective = CSVFileDownloadDirective;
1118
- exports.CSVFileUploadComponent = CSVFileUploadComponent;
1119
- exports.CSVFileUploadService = CSVFileUploadService;
1120
- exports.FileDownloadDirective = FileDownloadDirective;
1121
- exports.FileModule = FileModule;
1122
- exports.FileSizePipe = FileSizePipe;
1123
- exports.TextFileUploadComponent = TextFileUploadComponent;
1124
- exports.TextFileUploadService = TextFileUploadService;
1125
-
1126
- Object.defineProperty(exports, '__esModule', { value: true });
1127
-
1128
- }));
1129
- //# sourceMappingURL=dbg-riskit-angular-file.umd.js.map