@sd-angular/core 1.3.55 → 1.3.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/sd-angular-core-common.umd.js +131 -0
- package/bundles/sd-angular-core-common.umd.js.map +1 -1
- package/bundles/sd-angular-core-common.umd.min.js +1 -1
- package/bundles/sd-angular-core-common.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-export.umd.js +186 -152
- package/bundles/sd-angular-core-export.umd.js.map +1 -1
- package/bundles/sd-angular-core-export.umd.min.js +1 -1
- package/bundles/sd-angular-core-export.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-pdf.umd.js +3 -22
- package/bundles/sd-angular-core-pdf.umd.js.map +1 -1
- package/bundles/sd-angular-core-pdf.umd.min.js +2 -2
- package/bundles/sd-angular-core-pdf.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-zip.umd.js +3 -21
- package/bundles/sd-angular-core-zip.umd.js.map +1 -1
- package/bundles/sd-angular-core-zip.umd.min.js +2 -2
- package/bundles/sd-angular-core-zip.umd.min.js.map +1 -1
- package/common/src/lib/typings/utility.extension.d.ts +19 -0
- package/common/src/public-api.d.ts +1 -0
- package/esm2015/common/src/lib/typings/utility.extension.js +122 -0
- package/esm2015/common/src/public-api.js +2 -1
- package/esm2015/export/src/lib/export.model.js +1 -6
- package/esm2015/export/src/lib/export.service.js +83 -67
- package/esm2015/pdf/src/lib/pdf.service.js +4 -22
- package/esm2015/zip/src/lib/zip.service.js +4 -21
- package/export/sd-angular-core-export.metadata.json +1 -1
- package/export/src/lib/export.model.d.ts +0 -5
- package/export/src/lib/export.service.d.ts +1 -11
- package/fesm2015/sd-angular-core-common.js +122 -1
- package/fesm2015/sd-angular-core-common.js.map +1 -1
- package/fesm2015/sd-angular-core-export.js +81 -69
- package/fesm2015/sd-angular-core-export.js.map +1 -1
- package/fesm2015/sd-angular-core-pdf.js +3 -21
- package/fesm2015/sd-angular-core-pdf.js.map +1 -1
- package/fesm2015/sd-angular-core-zip.js +3 -20
- package/fesm2015/sd-angular-core-zip.js.map +1 -1
- package/package.json +1 -1
- package/{sd-angular-core-1.3.55.tgz → sd-angular-core-1.3.57.tgz} +0 -0
- package/zip/sd-angular-core-zip.metadata.json +1 -1
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@sd-angular/core/api'), require('uuid'), require('object-hash'), require('export-to-csv'), require('exceljs'), require('@sd-angular/core/notify'), require('@sd-angular/core/
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@sd-angular/core/export', ['exports', '@angular/core', '@sd-angular/core/api', 'uuid', 'object-hash', 'export-to-csv', 'exceljs', '@sd-angular/core/notify', '@sd-angular/core/
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['sd-angular'] = global['sd-angular'] || {}, global['sd-angular'].core = global['sd-angular'].core || {}, global['sd-angular'].core.export = {}), global.ng.core, global['sd-angular'].core.api, global.uuid, global['object-hash'], global.exportToCsv, global.exceljs, global['sd-angular'].core.notify, global['sd-angular'].core.
|
|
5
|
-
}(this, (function (exports, i0, i1, uuid, hash, exportToCsv, exceljs,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@sd-angular/core/api'), require('uuid'), require('object-hash'), require('export-to-csv'), require('exceljs'), require('@sd-angular/core/notify'), require('@sd-angular/core/common')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@sd-angular/core/export', ['exports', '@angular/core', '@sd-angular/core/api', 'uuid', 'object-hash', 'export-to-csv', 'exceljs', '@sd-angular/core/notify', '@sd-angular/core/common'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['sd-angular'] = global['sd-angular'] || {}, global['sd-angular'].core = global['sd-angular'].core || {}, global['sd-angular'].core.export = {}), global.ng.core, global['sd-angular'].core.api, global.uuid, global['object-hash'], global.exportToCsv, global.exceljs, global['sd-angular'].core.notify, global['sd-angular'].core.common));
|
|
5
|
+
}(this, (function (exports, i0, i1, uuid, hash, exportToCsv, exceljs, i2, i3) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
9
|
var hash__default = /*#__PURE__*/_interopDefaultLegacy(hash);
|
|
10
10
|
|
|
11
11
|
var API = {
|
|
12
|
-
generateTemplate: '/excel/generateTemplate',
|
|
13
12
|
uploadTemplate: '/excel/uploadTemplate',
|
|
14
13
|
generateUploadTemplate: '/excel/generateUploadTemplate',
|
|
15
|
-
export: '/excel/export',
|
|
16
|
-
downloadByTemplate: '/excel/downloadByTemplate',
|
|
17
14
|
filesInFolder: '/excel/filesInFolder',
|
|
18
15
|
removeFile: '/excel/remove',
|
|
19
|
-
sdExport: '/excel/sd-export',
|
|
20
16
|
sdExportByTemplate: '/excel/sd-export-by-template',
|
|
21
17
|
sdMergePDF: '/excel/sd-merge-pdf',
|
|
22
|
-
sdGenerateTemplate: '/excel/sd-generate-template',
|
|
23
18
|
};
|
|
24
19
|
|
|
25
20
|
/*! *****************************************************************************
|
|
@@ -340,12 +335,11 @@
|
|
|
340
335
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
341
336
|
}
|
|
342
337
|
|
|
343
|
-
var _fieldStyle, _titleStyle, _requiredStyle, _descriptionStyle, _cellStyle, _directory
|
|
338
|
+
var _fieldStyle, _titleColor, _titleFgColor, _titleStyle, _requiredStyle, _descriptionStyle, _cellStyle, _directory;
|
|
344
339
|
var SdExportService = /** @class */ (function () {
|
|
345
|
-
function SdExportService(apiService,
|
|
340
|
+
function SdExportService(apiService, notifyService, firebaseConfiguration) {
|
|
346
341
|
var _this = this;
|
|
347
342
|
this.apiService = apiService;
|
|
348
|
-
this.utilityService = utilityService;
|
|
349
343
|
this.notifyService = notifyService;
|
|
350
344
|
this.firebaseConfiguration = firebaseConfiguration;
|
|
351
345
|
_fieldStyle.set(this, {
|
|
@@ -372,6 +366,8 @@
|
|
|
372
366
|
}
|
|
373
367
|
}
|
|
374
368
|
});
|
|
369
|
+
_titleColor.set(this, 'FFFFFF');
|
|
370
|
+
_titleFgColor.set(this, '143180');
|
|
375
371
|
_titleStyle.set(this, {
|
|
376
372
|
border: {
|
|
377
373
|
bottom: { style: 'thin' },
|
|
@@ -386,13 +382,13 @@
|
|
|
386
382
|
font: {
|
|
387
383
|
bold: true,
|
|
388
384
|
size: 11,
|
|
389
|
-
color: { argb:
|
|
385
|
+
color: { argb: __classPrivateFieldGet(this, _titleColor) },
|
|
390
386
|
},
|
|
391
387
|
fill: {
|
|
392
388
|
type: 'pattern',
|
|
393
389
|
pattern: 'solid',
|
|
394
390
|
fgColor: {
|
|
395
|
-
argb:
|
|
391
|
+
argb: __classPrivateFieldGet(this, _titleFgColor),
|
|
396
392
|
}
|
|
397
393
|
}
|
|
398
394
|
});
|
|
@@ -461,67 +457,133 @@
|
|
|
461
457
|
group: group
|
|
462
458
|
});
|
|
463
459
|
return "dir1=" + _this.folder + "&dir2=G-" + hashedFolder + "&dir3=" + (key || '');
|
|
464
|
-
}
|
|
465
|
-
// generateTemplate = async (template: SdExportTemplate) => {
|
|
466
|
-
// const { sdGenerateTemplate } = API;
|
|
467
|
-
// const url = `${this.functionUrl}${sdGenerateTemplate}`;
|
|
468
|
-
// const buffer = await this.apiService.post(url, template, null, {
|
|
469
|
-
// responseType: 'arraybuffer'
|
|
470
|
-
// });
|
|
471
|
-
// const blob = new Blob([buffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,' });
|
|
472
|
-
// this.#blobToSaveAs(blob, template.fileName || 'Template');
|
|
473
|
-
// }
|
|
474
|
-
);
|
|
475
|
-
// generateTemplate = async (template: SdExportTemplate) => {
|
|
476
|
-
// const { sdGenerateTemplate } = API;
|
|
477
|
-
// const url = `${this.functionUrl}${sdGenerateTemplate}`;
|
|
478
|
-
// const buffer = await this.apiService.post(url, template, null, {
|
|
479
|
-
// responseType: 'arraybuffer'
|
|
480
|
-
// });
|
|
481
|
-
// const blob = new Blob([buffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,' });
|
|
482
|
-
// this.#blobToSaveAs(blob, template.fileName || 'Template');
|
|
483
|
-
// }
|
|
460
|
+
});
|
|
484
461
|
this.generateTemplate = function (template) { return __awaiter(_this, void 0, void 0, function () {
|
|
485
|
-
var
|
|
486
|
-
|
|
487
|
-
|
|
462
|
+
var fileName, columns, sheets, _g, _h, _j, idx, column, hasDescription, workbook, firstSheet, _loop_1, sheets_1, sheets_1_1, sheet, file;
|
|
463
|
+
var e_1, _k, e_2, _l;
|
|
464
|
+
var _this = this;
|
|
465
|
+
return __generator(this, function (_m) {
|
|
466
|
+
switch (_m.label) {
|
|
488
467
|
case 0:
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
468
|
+
fileName = template.fileName, columns = template.columns, sheets = template.sheets;
|
|
469
|
+
if (!Array.isArray(columns)) {
|
|
470
|
+
throw new Error('Excel template columns must be an array');
|
|
471
|
+
}
|
|
472
|
+
try {
|
|
473
|
+
for (_g = __values(columns.entries()), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
474
|
+
_j = __read(_h.value, 2), idx = _j[0], column = _j[1];
|
|
475
|
+
if (!column.field) {
|
|
476
|
+
throw new Error("Column " + (idx + 1) + ": Field is required");
|
|
477
|
+
}
|
|
478
|
+
if (!column.title) {
|
|
479
|
+
throw new Error("Column " + (idx + 1) + ": Title is required");
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
484
|
+
finally {
|
|
485
|
+
try {
|
|
486
|
+
if (_h && !_h.done && (_k = _g.return)) _k.call(_g);
|
|
487
|
+
}
|
|
488
|
+
finally { if (e_1) throw e_1.error; }
|
|
489
|
+
}
|
|
490
|
+
hasDescription = columns.some(function (column) { return column.description; });
|
|
491
|
+
workbook = new exceljs.Workbook();
|
|
492
|
+
firstSheet = workbook.addWorksheet('template');
|
|
493
|
+
columns.forEach(function (column, index) {
|
|
494
|
+
var _a, _b, _c, _d, _e, _f;
|
|
495
|
+
var required = column.required, fill = column.fill, fontColor = column.fontColor;
|
|
496
|
+
var cellField = firstSheet.getCell(1, index + 1);
|
|
497
|
+
var cellTitle = firstSheet.getCell(2, index + 1);
|
|
498
|
+
var cellDescription = firstSheet.getCell(3, index + 1);
|
|
499
|
+
var width = 120;
|
|
500
|
+
if (column.width && column.width.endsWith('px')) {
|
|
501
|
+
width = +column.width.replace('px', '');
|
|
502
|
+
}
|
|
503
|
+
firstSheet.getColumn(index + 1).width = width / 7 || 20;
|
|
504
|
+
cellField.style = __classPrivateFieldGet(_this, _fieldStyle);
|
|
505
|
+
if (required) {
|
|
506
|
+
cellField.style = __classPrivateFieldGet(_this, _requiredStyle);
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
cellField.style = __classPrivateFieldGet(_this, _fieldStyle);
|
|
510
|
+
}
|
|
511
|
+
cellTitle.style = Object.assign(Object.assign({}, __classPrivateFieldGet(_this, _titleStyle)), { font: Object.assign(Object.assign({}, (_a = __classPrivateFieldGet(_this, _titleStyle)) === null || _a === void 0 ? void 0 : _a.font), { color: Object.assign(Object.assign({}, (_c = (_b = __classPrivateFieldGet(_this, _titleStyle)) === null || _b === void 0 ? void 0 : _b.font) === null || _c === void 0 ? void 0 : _c.color), { argb: fontColor || ((_f = (_e = (_d = __classPrivateFieldGet(_this, _titleStyle)) === null || _d === void 0 ? void 0 : _d.font) === null || _e === void 0 ? void 0 : _e.color) === null || _f === void 0 ? void 0 : _f.argb) }) }), fill: {
|
|
512
|
+
type: 'pattern',
|
|
513
|
+
pattern: 'solid',
|
|
514
|
+
fgColor: {
|
|
515
|
+
argb: fill || __classPrivateFieldGet(_this, _titleFgColor)
|
|
516
|
+
}
|
|
517
|
+
} });
|
|
518
|
+
cellField.value = column.field;
|
|
519
|
+
cellTitle.value = column.title;
|
|
520
|
+
if (hasDescription) {
|
|
521
|
+
cellDescription.style = __classPrivateFieldGet(_this, _descriptionStyle);
|
|
522
|
+
cellDescription.value = column.description || '';
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
if (sheets === null || sheets === void 0 ? void 0 : sheets.length) {
|
|
526
|
+
_loop_1 = function (sheet) {
|
|
527
|
+
if (sheet.name && Array.isArray(sheet.items) && Array.isArray(sheet.fields)) {
|
|
528
|
+
var newSheet_1 = workbook.addWorksheet(sheet.name);
|
|
529
|
+
sheet.fields.forEach(function (field, index) {
|
|
530
|
+
newSheet_1.getColumn(index + 1).width = 30;
|
|
531
|
+
newSheet_1.getCell(1, index + 1).style = __classPrivateFieldGet(_this, _titleStyle);
|
|
532
|
+
newSheet_1.getCell(1, index + 1).value = field;
|
|
533
|
+
});
|
|
534
|
+
sheet.items.forEach(function (item, idx1) {
|
|
535
|
+
sheet.fields.forEach(function (field, idx2) {
|
|
536
|
+
newSheet_1.getCell(2 + idx1, 1 + idx2).value = item[field];
|
|
537
|
+
newSheet_1.getCell(2 + idx1, 1 + idx2).style = __classPrivateFieldGet(_this, _cellStyle);
|
|
538
|
+
});
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
try {
|
|
543
|
+
for (sheets_1 = __values(sheets), sheets_1_1 = sheets_1.next(); !sheets_1_1.done; sheets_1_1 = sheets_1.next()) {
|
|
544
|
+
sheet = sheets_1_1.value;
|
|
545
|
+
_loop_1(sheet);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
549
|
+
finally {
|
|
550
|
+
try {
|
|
551
|
+
if (sheets_1_1 && !sheets_1_1.done && (_l = sheets_1.return)) _l.call(sheets_1);
|
|
552
|
+
}
|
|
553
|
+
finally { if (e_2) throw e_2.error; }
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return [4 /*yield*/, workbook.xlsx.writeBuffer()];
|
|
494
557
|
case 1:
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
__classPrivateFieldGet(this, _blobToSaveAs).call(this, blob, template.fileName || 'Template');
|
|
558
|
+
file = _m.sent();
|
|
559
|
+
SdUtility.downloadBlob(new Blob([file], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }), fileName);
|
|
498
560
|
return [2 /*return*/];
|
|
499
561
|
}
|
|
500
562
|
});
|
|
501
563
|
}); };
|
|
502
564
|
this.uploadTemplate = function (args) { return __awaiter(_this, void 0, void 0, function () {
|
|
503
|
-
var key, group, validator, uploadTemplate, url, file,
|
|
565
|
+
var key, group, validator, uploadTemplate, url, file, _g, filePath, fileName;
|
|
504
566
|
var _this = this;
|
|
505
|
-
return __generator(this, function (
|
|
506
|
-
switch (
|
|
567
|
+
return __generator(this, function (_h) {
|
|
568
|
+
switch (_h.label) {
|
|
507
569
|
case 0:
|
|
508
570
|
key = args.key, group = args.group, validator = args.validator;
|
|
509
571
|
uploadTemplate = API.uploadTemplate;
|
|
510
572
|
url = "" + this.functionUrl + uploadTemplate + "?" + __classPrivateFieldGet(this, _directory).call(this, key, group);
|
|
511
|
-
return [4 /*yield*/,
|
|
573
|
+
return [4 /*yield*/, SdUtility.upload({
|
|
512
574
|
extensions: ['xlsx'],
|
|
513
575
|
maxSizeInMb: 0.1,
|
|
514
576
|
validator: validator
|
|
515
577
|
})];
|
|
516
578
|
case 1:
|
|
517
|
-
file =
|
|
579
|
+
file = _h.sent();
|
|
518
580
|
if (!file) return [3 /*break*/, 3];
|
|
519
581
|
return [4 /*yield*/, this.apiService.upload(url, file).catch(function (err) {
|
|
520
582
|
_this.notifyService.notify.warning(err === null || err === void 0 ? void 0 : err.message);
|
|
521
583
|
throw err;
|
|
522
584
|
})];
|
|
523
585
|
case 2:
|
|
524
|
-
|
|
586
|
+
_g = _h.sent(), filePath = _g.filePath, fileName = _g.fileName;
|
|
525
587
|
return [2 /*return*/, {
|
|
526
588
|
filePath: filePath,
|
|
527
589
|
fileName: fileName,
|
|
@@ -531,46 +593,46 @@
|
|
|
531
593
|
});
|
|
532
594
|
}); };
|
|
533
595
|
this.generateUploadTemplate = function (args) { return __awaiter(_this, void 0, void 0, function () {
|
|
534
|
-
var key, template, group, generateUploadTemplate, url,
|
|
535
|
-
return __generator(this, function (
|
|
536
|
-
switch (
|
|
596
|
+
var key, template, group, generateUploadTemplate, url, _g, filePath, fileName;
|
|
597
|
+
return __generator(this, function (_h) {
|
|
598
|
+
switch (_h.label) {
|
|
537
599
|
case 0:
|
|
538
600
|
key = args.key, template = args.template, group = args.group;
|
|
539
601
|
generateUploadTemplate = API.generateUploadTemplate;
|
|
540
602
|
url = "" + this.functionUrl + generateUploadTemplate + "?" + __classPrivateFieldGet(this, _directory).call(this, key, group);
|
|
541
603
|
return [4 /*yield*/, this.apiService.post(url, template)];
|
|
542
604
|
case 1:
|
|
543
|
-
|
|
605
|
+
_g = _h.sent(), filePath = _g.filePath, fileName = _g.fileName;
|
|
544
606
|
return [2 /*return*/, { filePath: filePath, fileName: fileName }];
|
|
545
607
|
}
|
|
546
608
|
});
|
|
547
609
|
}); };
|
|
548
610
|
this.removeFile = function (args) { return __awaiter(_this, void 0, void 0, function () {
|
|
549
611
|
var key, group, fileName, removeFile, url;
|
|
550
|
-
return __generator(this, function (
|
|
551
|
-
switch (
|
|
612
|
+
return __generator(this, function (_g) {
|
|
613
|
+
switch (_g.label) {
|
|
552
614
|
case 0:
|
|
553
615
|
key = args.key, group = args.group, fileName = args.fileName;
|
|
554
616
|
removeFile = API.removeFile;
|
|
555
617
|
url = "" + this.functionUrl + removeFile + "?" + __classPrivateFieldGet(this, _directory).call(this, key, group) + "&name=" + fileName;
|
|
556
618
|
return [4 /*yield*/, this.apiService.post(url)];
|
|
557
619
|
case 1:
|
|
558
|
-
|
|
620
|
+
_g.sent();
|
|
559
621
|
return [2 /*return*/];
|
|
560
622
|
}
|
|
561
623
|
});
|
|
562
624
|
}); };
|
|
563
625
|
this.filesInFolder = function (args) { return __awaiter(_this, void 0, void 0, function () {
|
|
564
626
|
var _a, key, group, filesInFolder, url, res;
|
|
565
|
-
return __generator(this, function (
|
|
566
|
-
switch (
|
|
627
|
+
return __generator(this, function (_g) {
|
|
628
|
+
switch (_g.label) {
|
|
567
629
|
case 0:
|
|
568
630
|
key = args.key, group = args.group;
|
|
569
631
|
filesInFolder = API.filesInFolder;
|
|
570
632
|
url = "" + this.functionUrl + filesInFolder + "?" + __classPrivateFieldGet(this, _directory).call(this, key, group);
|
|
571
633
|
return [4 /*yield*/, this.apiService.get(url)];
|
|
572
634
|
case 1:
|
|
573
|
-
res =
|
|
635
|
+
res = _g.sent();
|
|
574
636
|
return [2 /*return*/, ((_a = res.files) === null || _a === void 0 ? void 0 : _a.map(function (e) { return ({
|
|
575
637
|
filePath: e.publicUrl,
|
|
576
638
|
fileName: e.name
|
|
@@ -588,8 +650,8 @@
|
|
|
588
650
|
};
|
|
589
651
|
this.exportByTemplate = function (args) { return __awaiter(_this, void 0, void 0, function () {
|
|
590
652
|
var filePath, columns, items, fileName, sdExportByTemplate, url, buffer, blob;
|
|
591
|
-
return __generator(this, function (
|
|
592
|
-
switch (
|
|
653
|
+
return __generator(this, function (_g) {
|
|
654
|
+
switch (_g.label) {
|
|
593
655
|
case 0:
|
|
594
656
|
filePath = args.filePath, columns = args.columns, items = args.items, fileName = args.fileName;
|
|
595
657
|
sdExportByTemplate = API.sdExportByTemplate;
|
|
@@ -603,17 +665,17 @@
|
|
|
603
665
|
responseType: 'arraybuffer'
|
|
604
666
|
})];
|
|
605
667
|
case 1:
|
|
606
|
-
buffer =
|
|
668
|
+
buffer = _g.sent();
|
|
607
669
|
blob = new Blob([buffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,' });
|
|
608
|
-
|
|
670
|
+
SdUtility.downloadBlob(blob, fileName);
|
|
609
671
|
return [2 /*return*/];
|
|
610
672
|
}
|
|
611
673
|
});
|
|
612
674
|
}); };
|
|
613
675
|
this.exportCSV = function (option) { return __awaiter(_this, void 0, void 0, function () {
|
|
614
676
|
var columns, items, fileName, headerCSV, columns_1, columns_1_1, column, csvExporter;
|
|
615
|
-
var
|
|
616
|
-
return __generator(this, function (
|
|
677
|
+
var e_3, _g;
|
|
678
|
+
return __generator(this, function (_h) {
|
|
617
679
|
columns = option.columns, items = option.items, fileName = option.fileName;
|
|
618
680
|
headerCSV = {};
|
|
619
681
|
try {
|
|
@@ -622,12 +684,12 @@
|
|
|
622
684
|
headerCSV[column.field] = column.title;
|
|
623
685
|
}
|
|
624
686
|
}
|
|
625
|
-
catch (
|
|
687
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
626
688
|
finally {
|
|
627
689
|
try {
|
|
628
|
-
if (columns_1_1 && !columns_1_1.done && (
|
|
690
|
+
if (columns_1_1 && !columns_1_1.done && (_g = columns_1.return)) _g.call(columns_1);
|
|
629
691
|
}
|
|
630
|
-
finally { if (
|
|
692
|
+
finally { if (e_3) throw e_3.error; }
|
|
631
693
|
}
|
|
632
694
|
csvExporter = new exportToCsv.ExportToCsv({
|
|
633
695
|
filename: (fileName || 'CSV') + "_" + Date.toFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss'),
|
|
@@ -644,17 +706,17 @@
|
|
|
644
706
|
});
|
|
645
707
|
}); };
|
|
646
708
|
this.export = function (option) { return __awaiter(_this, void 0, void 0, function () {
|
|
647
|
-
var columns, items, fileName, sheets, hasDescription,
|
|
648
|
-
var
|
|
709
|
+
var columns, items, fileName, sheets, hasDescription, _g, _h, _j, idx, column, workbook, firstSheet, _loop_2, sheets_2, sheets_2_1, sheet, fromRow, file;
|
|
710
|
+
var e_4, _k, e_5, _l;
|
|
649
711
|
var _this = this;
|
|
650
|
-
return __generator(this, function (
|
|
651
|
-
switch (
|
|
712
|
+
return __generator(this, function (_m) {
|
|
713
|
+
switch (_m.label) {
|
|
652
714
|
case 0:
|
|
653
715
|
columns = option.columns, items = option.items, fileName = option.fileName, sheets = option.sheets;
|
|
654
716
|
hasDescription = false;
|
|
655
717
|
try {
|
|
656
|
-
for (
|
|
657
|
-
|
|
718
|
+
for (_g = __values(columns.entries()), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
719
|
+
_j = __read(_h.value, 2), idx = _j[0], column = _j[1];
|
|
658
720
|
if (!column.field) {
|
|
659
721
|
throw new Error("Column " + (idx + 1) + ": Field is required");
|
|
660
722
|
}
|
|
@@ -666,12 +728,12 @@
|
|
|
666
728
|
}
|
|
667
729
|
}
|
|
668
730
|
}
|
|
669
|
-
catch (
|
|
731
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
670
732
|
finally {
|
|
671
733
|
try {
|
|
672
|
-
if (
|
|
734
|
+
if (_h && !_h.done && (_k = _g.return)) _k.call(_g);
|
|
673
735
|
}
|
|
674
|
-
finally { if (
|
|
736
|
+
finally { if (e_4) throw e_4.error; }
|
|
675
737
|
}
|
|
676
738
|
workbook = new exceljs.Workbook();
|
|
677
739
|
firstSheet = workbook.addWorksheet('data');
|
|
@@ -696,34 +758,34 @@
|
|
|
696
758
|
}
|
|
697
759
|
});
|
|
698
760
|
if (sheets === null || sheets === void 0 ? void 0 : sheets.length) {
|
|
699
|
-
|
|
761
|
+
_loop_2 = function (sheet) {
|
|
700
762
|
if (sheet.name && Array.isArray(sheet.items) && Array.isArray(sheet.fields)) {
|
|
701
|
-
var
|
|
763
|
+
var newSheet_2 = workbook.addWorksheet(sheet.name);
|
|
702
764
|
sheet.fields.forEach(function (field, index) {
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
765
|
+
newSheet_2.getColumn(index + 1).width = 30;
|
|
766
|
+
newSheet_2.getCell(1, index + 1).style = __classPrivateFieldGet(_this, _titleStyle);
|
|
767
|
+
newSheet_2.getCell(1, index + 1).value = field;
|
|
706
768
|
});
|
|
707
769
|
sheet.items.forEach(function (item, idx1) {
|
|
708
770
|
sheet.fields.forEach(function (field, idx2) {
|
|
709
|
-
|
|
710
|
-
|
|
771
|
+
newSheet_2.getCell(2 + idx1, 1 + idx2).value = item[field];
|
|
772
|
+
newSheet_2.getCell(2 + idx1, 1 + idx2).style = __classPrivateFieldGet(_this, _cellStyle);
|
|
711
773
|
});
|
|
712
774
|
});
|
|
713
775
|
}
|
|
714
776
|
};
|
|
715
777
|
try {
|
|
716
|
-
for (
|
|
717
|
-
sheet =
|
|
718
|
-
|
|
778
|
+
for (sheets_2 = __values(sheets), sheets_2_1 = sheets_2.next(); !sheets_2_1.done; sheets_2_1 = sheets_2.next()) {
|
|
779
|
+
sheet = sheets_2_1.value;
|
|
780
|
+
_loop_2(sheet);
|
|
719
781
|
}
|
|
720
782
|
}
|
|
721
|
-
catch (
|
|
783
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
722
784
|
finally {
|
|
723
785
|
try {
|
|
724
|
-
if (
|
|
786
|
+
if (sheets_2_1 && !sheets_2_1.done && (_l = sheets_2.return)) _l.call(sheets_2);
|
|
725
787
|
}
|
|
726
|
-
finally { if (
|
|
788
|
+
finally { if (e_5) throw e_5.error; }
|
|
727
789
|
}
|
|
728
790
|
}
|
|
729
791
|
fromRow = hasDescription ? 4 : 3;
|
|
@@ -735,17 +797,17 @@
|
|
|
735
797
|
});
|
|
736
798
|
return [4 /*yield*/, workbook.xlsx.writeBuffer()];
|
|
737
799
|
case 1:
|
|
738
|
-
file =
|
|
739
|
-
|
|
800
|
+
file = _m.sent();
|
|
801
|
+
SdUtility.downloadBlob(new Blob([file], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }), fileName);
|
|
740
802
|
return [2 /*return*/];
|
|
741
803
|
}
|
|
742
804
|
});
|
|
743
805
|
}); };
|
|
744
806
|
this.exportCustom = function (option) { return __awaiter(_this, void 0, void 0, function () {
|
|
745
|
-
var fileName, sheets, workbook,
|
|
746
|
-
var
|
|
747
|
-
return __generator(this, function (
|
|
748
|
-
switch (
|
|
807
|
+
var fileName, sheets, workbook, _g, _h, _j, idx, sheet, name, columns, cells, worksheet, _k, _l, column, cells_1, cells_1_1, cell, row, column, value, style, file;
|
|
808
|
+
var e_6, _m, e_7, _o, e_8, _p;
|
|
809
|
+
return __generator(this, function (_q) {
|
|
810
|
+
switch (_q.label) {
|
|
749
811
|
case 0:
|
|
750
812
|
fileName = option.fileName, sheets = option.sheets;
|
|
751
813
|
if (!(sheets === null || sheets === void 0 ? void 0 : sheets.length)) {
|
|
@@ -754,60 +816,60 @@
|
|
|
754
816
|
}
|
|
755
817
|
workbook = new exceljs.Workbook();
|
|
756
818
|
try {
|
|
757
|
-
for (
|
|
758
|
-
|
|
819
|
+
for (_g = __values(sheets.entries()), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
820
|
+
_j = __read(_h.value, 2), idx = _j[0], sheet = _j[1];
|
|
759
821
|
name = sheet.name, columns = sheet.columns, cells = sheet.cells;
|
|
760
822
|
worksheet = workbook.addWorksheet(name || "Sheet " + (idx + 1));
|
|
761
823
|
try {
|
|
762
|
-
for (
|
|
763
|
-
column =
|
|
824
|
+
for (_k = (e_7 = void 0, __values((columns || []))), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
825
|
+
column = _l.value;
|
|
764
826
|
worksheet.getColumn(column.index).style = column.style;
|
|
765
827
|
worksheet.getColumn(column.index).width = column.width;
|
|
766
828
|
}
|
|
767
829
|
}
|
|
768
|
-
catch (
|
|
830
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
769
831
|
finally {
|
|
770
832
|
try {
|
|
771
|
-
if (
|
|
833
|
+
if (_l && !_l.done && (_o = _k.return)) _o.call(_k);
|
|
772
834
|
}
|
|
773
|
-
finally { if (
|
|
835
|
+
finally { if (e_7) throw e_7.error; }
|
|
774
836
|
}
|
|
775
837
|
try {
|
|
776
|
-
for (cells_1 = (
|
|
838
|
+
for (cells_1 = (e_8 = void 0, __values(cells)), cells_1_1 = cells_1.next(); !cells_1_1.done; cells_1_1 = cells_1.next()) {
|
|
777
839
|
cell = cells_1_1.value;
|
|
778
840
|
row = cell.row, column = cell.column, value = cell.value, style = cell.style;
|
|
779
841
|
worksheet.getCell(row, column).style = style || worksheet.getColumn(column).style;
|
|
780
842
|
worksheet.getCell(row, column).value = value;
|
|
781
843
|
}
|
|
782
844
|
}
|
|
783
|
-
catch (
|
|
845
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
784
846
|
finally {
|
|
785
847
|
try {
|
|
786
|
-
if (cells_1_1 && !cells_1_1.done && (
|
|
848
|
+
if (cells_1_1 && !cells_1_1.done && (_p = cells_1.return)) _p.call(cells_1);
|
|
787
849
|
}
|
|
788
|
-
finally { if (
|
|
850
|
+
finally { if (e_8) throw e_8.error; }
|
|
789
851
|
}
|
|
790
852
|
}
|
|
791
853
|
}
|
|
792
|
-
catch (
|
|
854
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
793
855
|
finally {
|
|
794
856
|
try {
|
|
795
|
-
if (
|
|
857
|
+
if (_h && !_h.done && (_m = _g.return)) _m.call(_g);
|
|
796
858
|
}
|
|
797
|
-
finally { if (
|
|
859
|
+
finally { if (e_6) throw e_6.error; }
|
|
798
860
|
}
|
|
799
861
|
return [4 /*yield*/, workbook.xlsx.writeBuffer()];
|
|
800
862
|
case 1:
|
|
801
|
-
file =
|
|
802
|
-
|
|
863
|
+
file = _q.sent();
|
|
864
|
+
SdUtility.downloadBlob(new Blob([file], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }), fileName);
|
|
803
865
|
return [2 /*return*/];
|
|
804
866
|
}
|
|
805
867
|
});
|
|
806
868
|
}); };
|
|
807
869
|
this.mergePDF = function (urls) { return __awaiter(_this, void 0, void 0, function () {
|
|
808
|
-
var sdMergePDF, url, buffer
|
|
809
|
-
return __generator(this, function (
|
|
810
|
-
switch (
|
|
870
|
+
var sdMergePDF, url, buffer;
|
|
871
|
+
return __generator(this, function (_g) {
|
|
872
|
+
switch (_g.label) {
|
|
811
873
|
case 0:
|
|
812
874
|
sdMergePDF = API.sdMergePDF;
|
|
813
875
|
url = "" + this.functionUrl + sdMergePDF;
|
|
@@ -817,39 +879,12 @@
|
|
|
817
879
|
responseType: 'arraybuffer'
|
|
818
880
|
})];
|
|
819
881
|
case 1:
|
|
820
|
-
buffer =
|
|
821
|
-
|
|
822
|
-
__classPrivateFieldGet(this, _blobToSaveAs).call(this, blob, "" + uuid.v4());
|
|
882
|
+
buffer = _g.sent();
|
|
883
|
+
SdUtility.downloadBlob(new Blob([buffer], { type: 'application/pdf' }));
|
|
823
884
|
return [2 /*return*/];
|
|
824
885
|
}
|
|
825
886
|
});
|
|
826
887
|
}); };
|
|
827
|
-
this.loadExportedItems = function (items) { return __awaiter(_this, void 0, void 0, function () {
|
|
828
|
-
return __generator(this, function (_b) {
|
|
829
|
-
return [2 /*return*/];
|
|
830
|
-
});
|
|
831
|
-
}); };
|
|
832
|
-
_blobToSaveAs.set(this, function (blob, fileName) {
|
|
833
|
-
if (fileName === void 0) { fileName = 'Export'; }
|
|
834
|
-
try {
|
|
835
|
-
var url = window.URL.createObjectURL(blob);
|
|
836
|
-
var link = document.createElement('a');
|
|
837
|
-
fileName = fileName.replace(/.xlsx/i, '');
|
|
838
|
-
fileName = fileName.replace(/.pdf/i, '');
|
|
839
|
-
if (link.download !== undefined) { // feature detection
|
|
840
|
-
link.setAttribute('href', url);
|
|
841
|
-
link.setAttribute('download', fileName + "_" + new Date().toFormat('yyyy_MM_dd_HH_mm'));
|
|
842
|
-
link.style.visibility = 'hidden';
|
|
843
|
-
document.body.appendChild(link);
|
|
844
|
-
link.click();
|
|
845
|
-
window.URL.revokeObjectURL(url);
|
|
846
|
-
link.remove();
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
catch (e) {
|
|
850
|
-
console.error('BlobToSaveAs error', e);
|
|
851
|
-
}
|
|
852
|
-
});
|
|
853
888
|
}
|
|
854
889
|
Object.defineProperty(SdExportService.prototype, "functionUrl", {
|
|
855
890
|
get: function () {
|
|
@@ -861,7 +896,7 @@
|
|
|
861
896
|
});
|
|
862
897
|
Object.defineProperty(SdExportService.prototype, "folder", {
|
|
863
898
|
get: function () {
|
|
864
|
-
var
|
|
899
|
+
var _g = this.firebaseConfiguration, project = _g.project, env = _g.env;
|
|
865
900
|
return project + "-" + env;
|
|
866
901
|
},
|
|
867
902
|
enumerable: false,
|
|
@@ -883,8 +918,8 @@
|
|
|
883
918
|
});
|
|
884
919
|
return SdExportService;
|
|
885
920
|
}());
|
|
886
|
-
_fieldStyle = new WeakMap(),
|
|
887
|
-
SdExportService.ɵprov = i0.ɵɵdefineInjectable({ factory: function SdExportService_Factory() { return new SdExportService(i0.ɵɵinject(i1.SdApiService), i0.ɵɵinject(i2.
|
|
921
|
+
_fieldStyle = new WeakMap(), _titleColor = new WeakMap(), _titleFgColor = new WeakMap(), _titleStyle = new WeakMap(), _requiredStyle = new WeakMap(), _descriptionStyle = new WeakMap(), _cellStyle = new WeakMap(), _directory = new WeakMap();
|
|
922
|
+
SdExportService.ɵprov = i0.ɵɵdefineInjectable({ factory: function SdExportService_Factory() { return new SdExportService(i0.ɵɵinject(i1.SdApiService), i0.ɵɵinject(i2.SdNotifyService), i0.ɵɵinject(i3.FIREBASE_CONFIG, 8)); }, token: SdExportService, providedIn: "root" });
|
|
888
923
|
SdExportService.decorators = [
|
|
889
924
|
{ type: i0.Injectable, args: [{
|
|
890
925
|
providedIn: 'root'
|
|
@@ -892,9 +927,8 @@
|
|
|
892
927
|
];
|
|
893
928
|
SdExportService.ctorParameters = function () { return [
|
|
894
929
|
{ type: i1.SdApiService },
|
|
895
|
-
{ type: i2.
|
|
896
|
-
{ type: i3.
|
|
897
|
-
{ type: undefined, decorators: [{ type: i0.Inject, args: [i4.FIREBASE_CONFIG,] }, { type: i0.Optional }] }
|
|
930
|
+
{ type: i2.SdNotifyService },
|
|
931
|
+
{ type: undefined, decorators: [{ type: i0.Inject, args: [i3.FIREBASE_CONFIG,] }, { type: i0.Optional }] }
|
|
898
932
|
]; };
|
|
899
933
|
|
|
900
934
|
/*
|