@esfaenza/extensions 19.2.31 → 20.3.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.
- package/fesm2022/esfaenza-extensions.mjs +126 -27
- package/fesm2022/esfaenza-extensions.mjs.map +1 -1
- package/lib/services/extensions.base.d.ts +1 -1
- package/lib/services/extensions.clipboard.service.d.ts +3 -2
- package/lib/services/extensions.embedding.service.d.ts +2 -1
- package/lib/services/extensions.exports.service.d.ts +8 -0
- package/lib/services/extensions.messages.service.d.ts +4 -2
- package/package.json +6 -7
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, Optional, Inject, Injectable, Pipe, NgModule, Injector } from '@angular/core';
|
|
2
|
+
import { InjectionToken, Optional, Inject, Injectable, Pipe, NgModule, Injector, PLATFORM_ID } from '@angular/core';
|
|
3
3
|
import * as i1 from '@esfaenza/localizations';
|
|
4
4
|
import { LocalizationModule } from '@esfaenza/localizations';
|
|
5
5
|
import { first, filter, take, map } from 'rxjs/operators';
|
|
6
6
|
import { ReplaySubject, of, Subject, filter as filter$1 } from 'rxjs';
|
|
7
|
+
import * as i3 from '@angular/common';
|
|
8
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
7
9
|
import { ToastrService } from 'ngx-toastr';
|
|
8
10
|
import swal from 'sweetalert2';
|
|
9
11
|
import * as i2 from '@angular/router';
|
|
10
|
-
import * as i3 from '@angular/common';
|
|
11
12
|
import * as XLSX from 'xlsx';
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -673,12 +674,20 @@ class MessageService {
|
|
|
673
674
|
Embedded = false;
|
|
674
675
|
MainWindow = null;
|
|
675
676
|
MessageObserver = null;
|
|
677
|
+
isBrowser = true;
|
|
676
678
|
/** Costruttore @ignore */
|
|
677
|
-
constructor(injector, locProvider, hash) {
|
|
679
|
+
constructor(injector, locProvider, hash, platformId) {
|
|
678
680
|
this.injector = injector;
|
|
679
681
|
this.locProvider = locProvider;
|
|
680
682
|
this.hash = hash;
|
|
681
|
-
this.
|
|
683
|
+
this.isBrowser = isPlatformBrowser(platformId);
|
|
684
|
+
if (this.isBrowser)
|
|
685
|
+
this.init();
|
|
686
|
+
}
|
|
687
|
+
browserCheck() {
|
|
688
|
+
if (!this.isBrowser)
|
|
689
|
+
console.error("@esfaenza/extensions MessageService is only able to display browser messages at this time. Since you are not running in a browser, all functions witll do nothing");
|
|
690
|
+
return this.isBrowser;
|
|
682
691
|
}
|
|
683
692
|
configureEmbeddability(mainWindow, messageObserver) {
|
|
684
693
|
this.Embedded = true;
|
|
@@ -786,6 +795,8 @@ class MessageService {
|
|
|
786
795
|
* @param {"toastr" | "swal" | null} secondaryNotificationType Qualora sia una notifica secondaria, ne indica il tipo
|
|
787
796
|
*/
|
|
788
797
|
simpleSuccess(text, secondaryNotificationType = null, secondaryNotificationTimeout = null) {
|
|
798
|
+
if (!this.browserCheck())
|
|
799
|
+
return;
|
|
789
800
|
if (this.Embedded) {
|
|
790
801
|
this.MainWindow.postMessage({ type: "alert", level: 'success', msg: text }, "*");
|
|
791
802
|
return;
|
|
@@ -806,6 +817,8 @@ class MessageService {
|
|
|
806
817
|
* @param {"toastr" | "swal" | null} secondaryNotificationType Qualora sia una notifica secondaria, ne indica il tipo
|
|
807
818
|
*/
|
|
808
819
|
simpleInfo(text, secondaryNotificationType = null, secondaryNotificationTimeout = null) {
|
|
820
|
+
if (!this.browserCheck())
|
|
821
|
+
return;
|
|
809
822
|
if (this.Embedded) {
|
|
810
823
|
this.MainWindow.postMessage({ type: "alert", level: 'info', msg: text }, "*");
|
|
811
824
|
return;
|
|
@@ -826,6 +839,8 @@ class MessageService {
|
|
|
826
839
|
* @param {"toastr" | "swal" | null} secondaryNotificationType Qualora sia una notifica secondaria, ne indica il tipo
|
|
827
840
|
*/
|
|
828
841
|
simpleError(text, secondaryNotificationType = null, secondaryNotificationTimeout = null) {
|
|
842
|
+
if (!this.browserCheck())
|
|
843
|
+
return;
|
|
829
844
|
if (this.Embedded) {
|
|
830
845
|
this.MainWindow.postMessage({ type: "alert", level: 'error', msg: text }, "*");
|
|
831
846
|
return;
|
|
@@ -846,6 +861,8 @@ class MessageService {
|
|
|
846
861
|
* @param {"toastr" | "swal" | null} secondaryNotificationType Qualora sia una notifica secondaria, ne indica il tipo
|
|
847
862
|
*/
|
|
848
863
|
simpleWarning(text, secondaryNotificationType = null, secondaryNotificationTimeout = null) {
|
|
864
|
+
if (!this.browserCheck())
|
|
865
|
+
return;
|
|
849
866
|
if (this.Embedded) {
|
|
850
867
|
this.MainWindow.postMessage({ type: "alert", level: 'warning', msg: text }, "*");
|
|
851
868
|
return;
|
|
@@ -860,6 +877,8 @@ class MessageService {
|
|
|
860
877
|
* Ripulisce tutti i messaggi presenti in un dato momento sullo schermo
|
|
861
878
|
*/
|
|
862
879
|
clearMessages() {
|
|
880
|
+
if (!this.browserCheck())
|
|
881
|
+
return;
|
|
863
882
|
this.toastr.clear();
|
|
864
883
|
swal.close();
|
|
865
884
|
}
|
|
@@ -872,6 +891,8 @@ class MessageService {
|
|
|
872
891
|
* @returns {Promise} Restituisce una Promise col risultato scelto dall'utente (conferma o no)
|
|
873
892
|
*/
|
|
874
893
|
promiseWarningWithChoice(title, text) {
|
|
894
|
+
if (!this.browserCheck())
|
|
895
|
+
return;
|
|
875
896
|
return this.warningSwalWithCancel.fire(title, text);
|
|
876
897
|
}
|
|
877
898
|
/**
|
|
@@ -888,9 +909,13 @@ class MessageService {
|
|
|
888
909
|
}
|
|
889
910
|
GuidRepsonseFunctionsMap = {};
|
|
890
911
|
simpleWarningWithChoice(title, text, onsuccess, onerror, confirmtext = "", aborttext = '') {
|
|
912
|
+
if (!this.browserCheck())
|
|
913
|
+
return;
|
|
891
914
|
this.withChoiceBase("warning", title, text, onsuccess, onerror, confirmtext, aborttext);
|
|
892
915
|
}
|
|
893
916
|
simpleSuccessWithChoice(title, text, onsuccess, onerror, confirmtext = "", aborttext = '') {
|
|
917
|
+
if (!this.browserCheck())
|
|
918
|
+
return;
|
|
894
919
|
this.withChoiceBase("success", title, text, onsuccess, onerror, confirmtext, aborttext);
|
|
895
920
|
}
|
|
896
921
|
withChoiceBase(level, title, text, onsuccess, onerror, confirmtext = "", aborttext = '') {
|
|
@@ -969,6 +994,8 @@ class MessageService {
|
|
|
969
994
|
* @param {string} text Contenuto del messaggio
|
|
970
995
|
*/
|
|
971
996
|
observableSimpleWarningWithChoice(title, text) {
|
|
997
|
+
if (!this.browserCheck())
|
|
998
|
+
return of(false);
|
|
972
999
|
return of(this.warningSwalWithCancel.fire(title, text)).pipe(map(t => !!t.value));
|
|
973
1000
|
}
|
|
974
1001
|
/**
|
|
@@ -980,6 +1007,8 @@ class MessageService {
|
|
|
980
1007
|
* @param {Function} onnavigate Callback da chimare su navigazione in corso
|
|
981
1008
|
*/
|
|
982
1009
|
expiredSessionMessage(title, text, onnavigate = null) {
|
|
1010
|
+
if (!this.browserCheck())
|
|
1011
|
+
return;
|
|
983
1012
|
this.expiredSessionSwal.fire(title, text).then((result) => {
|
|
984
1013
|
if (result.value && onnavigate)
|
|
985
1014
|
onnavigate();
|
|
@@ -995,6 +1024,8 @@ class MessageService {
|
|
|
995
1024
|
* @param {Function} postFailure Callback da chimare in caso di fallimento
|
|
996
1025
|
*/
|
|
997
1026
|
manageCallResultResponse(response, successMsg, errorMsg, postSuccess = null, postFailure = null) {
|
|
1027
|
+
if (!this.browserCheck())
|
|
1028
|
+
return;
|
|
998
1029
|
let anyReponse = response;
|
|
999
1030
|
if (response.success || anyReponse.Success) {
|
|
1000
1031
|
if (response.haswarning || anyReponse.HasWarning)
|
|
@@ -1024,6 +1055,8 @@ class MessageService {
|
|
|
1024
1055
|
* @param {Function} postFailure Callback da chimare in caso di fallimento
|
|
1025
1056
|
*/
|
|
1026
1057
|
manageStringResponse(response, successMsg, errorMsg, postSuccess = null, postFailure = null) {
|
|
1058
|
+
if (!this.browserCheck())
|
|
1059
|
+
return;
|
|
1027
1060
|
if (!response) {
|
|
1028
1061
|
if (successMsg)
|
|
1029
1062
|
this.simpleSuccess(successMsg);
|
|
@@ -1047,6 +1080,8 @@ class MessageService {
|
|
|
1047
1080
|
* @param {Function} postFailure Callback da chimare in caso di fallimento
|
|
1048
1081
|
*/
|
|
1049
1082
|
manageStringResponseBool(response, successMsg, errorMsg, postSuccess = null, postFailure = null) {
|
|
1083
|
+
if (!this.browserCheck())
|
|
1084
|
+
return;
|
|
1050
1085
|
if (response) {
|
|
1051
1086
|
if (successMsg)
|
|
1052
1087
|
this.simpleSuccess(successMsg);
|
|
@@ -1060,7 +1095,7 @@ class MessageService {
|
|
|
1060
1095
|
postFailure();
|
|
1061
1096
|
}
|
|
1062
1097
|
}
|
|
1063
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: MessageService, deps: [{ token: Injector }, { token: i1.BaseLocalization, optional: true }, { token: HashingService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1098
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: MessageService, deps: [{ token: Injector }, { token: i1.BaseLocalization, optional: true }, { token: HashingService }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1064
1099
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: MessageService, providedIn: "root" });
|
|
1065
1100
|
}
|
|
1066
1101
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: MessageService, decorators: [{
|
|
@@ -1071,7 +1106,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
|
|
|
1071
1106
|
args: [Injector]
|
|
1072
1107
|
}] }, { type: i1.BaseLocalization, decorators: [{
|
|
1073
1108
|
type: Optional
|
|
1074
|
-
}] }, { type: HashingService }
|
|
1109
|
+
}] }, { type: HashingService }, { type: Object, decorators: [{
|
|
1110
|
+
type: Inject,
|
|
1111
|
+
args: [PLATFORM_ID]
|
|
1112
|
+
}] }] });
|
|
1075
1113
|
|
|
1076
1114
|
// Angular
|
|
1077
1115
|
/* Classe che contiene tutte le informazioni sull'embedding in un unico contenitore per semplicità */
|
|
@@ -1088,10 +1126,14 @@ class AppEmbeddingExtensions {
|
|
|
1088
1126
|
_reloadAllowed = true;
|
|
1089
1127
|
EmbeddedModule;
|
|
1090
1128
|
pushedHistories = [];
|
|
1091
|
-
|
|
1129
|
+
isBrowser = true;
|
|
1130
|
+
constructor(msgService, router, location, platformId) {
|
|
1092
1131
|
this.msgService = msgService;
|
|
1093
1132
|
this.router = router;
|
|
1094
1133
|
this.location = location;
|
|
1134
|
+
this.isBrowser = isPlatformBrowser(platformId);
|
|
1135
|
+
if (!this.isBrowser)
|
|
1136
|
+
return;
|
|
1095
1137
|
this.MainWindow = window;
|
|
1096
1138
|
while (this.MainWindow.parent != this.MainWindow) {
|
|
1097
1139
|
this.MainWindow = this.MainWindow.parent;
|
|
@@ -1122,6 +1164,8 @@ class AppEmbeddingExtensions {
|
|
|
1122
1164
|
});
|
|
1123
1165
|
}
|
|
1124
1166
|
waitForMyConfigAndForceEmbeddedModule() {
|
|
1167
|
+
if (!this.isBrowser)
|
|
1168
|
+
return;
|
|
1125
1169
|
// Aspetto di ricevere il myconfig e setto con lui l'embeddedmodule. Questo viene eseguito solo se this.location.path() per qualche motivo non contiene il module
|
|
1126
1170
|
let interval = setInterval(() => {
|
|
1127
1171
|
if (myconfig?.AppData?.ModuleId) {
|
|
@@ -1141,6 +1185,8 @@ class AppEmbeddingExtensions {
|
|
|
1141
1185
|
return `${JSON.parse(JSON.stringify(event?.data))}`;
|
|
1142
1186
|
}
|
|
1143
1187
|
configureEmbeddability() {
|
|
1188
|
+
if (!this.isBrowser)
|
|
1189
|
+
return;
|
|
1144
1190
|
if (this.Embedded)
|
|
1145
1191
|
this.MainWindow.postMessage({ type: "whois" }, "*");
|
|
1146
1192
|
else
|
|
@@ -1297,6 +1343,8 @@ class AppEmbeddingExtensions {
|
|
|
1297
1343
|
document.body.style.setProperty("overflow-y", "auto", "important");
|
|
1298
1344
|
}
|
|
1299
1345
|
onNavigateBack() {
|
|
1346
|
+
if (!this.isBrowser)
|
|
1347
|
+
return;
|
|
1300
1348
|
if (history?.state?._pushed) {
|
|
1301
1349
|
this._reloadAllowed = false;
|
|
1302
1350
|
this.pushedHistories.pop();
|
|
@@ -1304,6 +1352,8 @@ class AppEmbeddingExtensions {
|
|
|
1304
1352
|
}
|
|
1305
1353
|
}
|
|
1306
1354
|
replaceState(basePath, url) {
|
|
1355
|
+
if (!this.isBrowser)
|
|
1356
|
+
return;
|
|
1307
1357
|
// Esempio basePath: pages
|
|
1308
1358
|
// Esempio url: parties/leads_search
|
|
1309
1359
|
// Normalizzazione senza slash prima o dopo
|
|
@@ -1313,6 +1363,8 @@ class AppEmbeddingExtensions {
|
|
|
1313
1363
|
this.MainWindow.postMessage({ type: "replace-state", url: `pages/embed/${this.EmbeddedModule}/${url}` }, "*");
|
|
1314
1364
|
}
|
|
1315
1365
|
refreshBoundariesOnMenuCollapse() {
|
|
1366
|
+
if (!this.isBrowser)
|
|
1367
|
+
return;
|
|
1316
1368
|
const wrapper = document.body.getElementsByClassName("main-wrapper")[0];
|
|
1317
1369
|
let wrapperStyles = window.getComputedStyle(wrapper);
|
|
1318
1370
|
const wrapperPaddingLeft = parseInt(wrapperStyles.getPropertyValue("padding-left"));
|
|
@@ -1326,17 +1378,20 @@ class AppEmbeddingExtensions {
|
|
|
1326
1378
|
if (left)
|
|
1327
1379
|
left.style.setProperty("width", leftSpace + "px");
|
|
1328
1380
|
}
|
|
1329
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AppEmbeddingExtensions, deps: [{ token: MessageService }, { token: i2.Router }, { token: i3.Location }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1381
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AppEmbeddingExtensions, deps: [{ token: MessageService }, { token: i2.Router }, { token: i3.Location }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1330
1382
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AppEmbeddingExtensions, providedIn: "root" });
|
|
1331
1383
|
}
|
|
1332
1384
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AppEmbeddingExtensions, decorators: [{
|
|
1333
1385
|
type: Injectable,
|
|
1334
1386
|
args: [{ providedIn: "root" }]
|
|
1335
|
-
}], ctorParameters: () => [{ type: MessageService }, { type: i2.Router }, { type: i3.Location }
|
|
1387
|
+
}], ctorParameters: () => [{ type: MessageService }, { type: i2.Router }, { type: i3.Location }, { type: Object, decorators: [{
|
|
1388
|
+
type: Inject,
|
|
1389
|
+
args: [PLATFORM_ID]
|
|
1390
|
+
}] }] });
|
|
1336
1391
|
|
|
1337
1392
|
// Angular
|
|
1338
1393
|
/**
|
|
1339
|
-
*
|
|
1394
|
+
* WIP: per razionalizzare il fill della routesmap (vedi CRM app.extensions.ts)
|
|
1340
1395
|
*/
|
|
1341
1396
|
class BaseExtensionsService {
|
|
1342
1397
|
emb;
|
|
@@ -1427,14 +1482,14 @@ class UtilityService {
|
|
|
1427
1482
|
* Deseleziona il testo eventualmente selezionato
|
|
1428
1483
|
*/
|
|
1429
1484
|
clearTextSelection() {
|
|
1430
|
-
if (window
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
else if (window.getSelection().removeAllRanges) // Firefox
|
|
1434
|
-
window.getSelection().removeAllRanges();
|
|
1485
|
+
if (!window) {
|
|
1486
|
+
console.error("This function access the javascript window object which is not defined. Are you executing this outside of browser context?");
|
|
1487
|
+
return;
|
|
1435
1488
|
}
|
|
1436
|
-
|
|
1437
|
-
|
|
1489
|
+
if (window.getSelection().empty) // Chrome
|
|
1490
|
+
window.getSelection().empty();
|
|
1491
|
+
else if (window.getSelection().removeAllRanges) // Firefox
|
|
1492
|
+
window.getSelection().removeAllRanges();
|
|
1438
1493
|
}
|
|
1439
1494
|
/**
|
|
1440
1495
|
* Partendo da una lista, dato il nome della proprietà chiave e il valore della chiave selezionata,
|
|
@@ -1481,6 +1536,10 @@ class UtilityService {
|
|
|
1481
1536
|
* @param {string} filename Nome del file suggerito in fase di salvataggio
|
|
1482
1537
|
*/
|
|
1483
1538
|
fileDownload(url, fileName) {
|
|
1539
|
+
if (!document) {
|
|
1540
|
+
console.error("This function access the javascript document object which is not defined. Are you executing this outside of browser context?");
|
|
1541
|
+
return;
|
|
1542
|
+
}
|
|
1484
1543
|
var a = document.createElement("a");
|
|
1485
1544
|
document.body.appendChild(a);
|
|
1486
1545
|
a.className = "ta-display-none";
|
|
@@ -1540,6 +1599,10 @@ class UtilityService {
|
|
|
1540
1599
|
* @param {string} filename Nome del file suggerito in fase di salvataggio
|
|
1541
1600
|
*/
|
|
1542
1601
|
saveByteArray(byte, filename) {
|
|
1602
|
+
if (!document) {
|
|
1603
|
+
console.error("This function access the javascript document object which is not defined. Are you executing this outside of browser context?");
|
|
1604
|
+
return;
|
|
1605
|
+
}
|
|
1543
1606
|
var blob = new Blob([byte]);
|
|
1544
1607
|
var link = document.createElement("a");
|
|
1545
1608
|
document.body.appendChild(link);
|
|
@@ -2175,6 +2238,12 @@ class ExportService {
|
|
|
2175
2238
|
* Effettua l'esportazione in file CSV
|
|
2176
2239
|
*/
|
|
2177
2240
|
exportCSV(fn, headers, data) {
|
|
2241
|
+
var buffer = this.exportCSVBuffer(fn, headers, data);
|
|
2242
|
+
var blob = new Blob([new TextDecoder().decode(buffer)], { type: 'text/csv' });
|
|
2243
|
+
var objectUrl = URL.createObjectURL(blob);
|
|
2244
|
+
this.utiExts.fileDownload(objectUrl, fn.endsWith('.xlsx') ? fn.replace('.xlsx', '.csv') : fn.endsWith('.csv') ? fn : fn + ".csv");
|
|
2245
|
+
}
|
|
2246
|
+
exportCSVBuffer(fn, headers, data) {
|
|
2178
2247
|
let csvData = '', row = '', sep = ';';
|
|
2179
2248
|
for (let i = 0; i < headers.length; i++) {
|
|
2180
2249
|
let h = headers[i];
|
|
@@ -2190,13 +2259,18 @@ class ExportService {
|
|
|
2190
2259
|
}
|
|
2191
2260
|
csvData += row + '\r\n';
|
|
2192
2261
|
}
|
|
2193
|
-
var BOM =
|
|
2194
|
-
var
|
|
2195
|
-
|
|
2196
|
-
this.utiExts.fileDownload(objectUrl, fn.endsWith('.xlsx') ? fn.replace('.xlsx', '.csv') : fn.endsWith('.csv') ? fn : fn + ".csv");
|
|
2262
|
+
var BOM = [0xEF, 0xBB, 0xBF];
|
|
2263
|
+
var buffer = new Uint8Array([...BOM, ...new TextEncoder().encode(csvData)]);
|
|
2264
|
+
return buffer;
|
|
2197
2265
|
}
|
|
2198
2266
|
/** Effettua l'esportazione del file Excel basandosi sul modulo **ExcelJS**, sugli header **headers** e sui dati **data** */
|
|
2199
2267
|
async exportExcel(fn, headers, data) {
|
|
2268
|
+
let buffer = this.exportExcelBuffer(fn, headers, data);
|
|
2269
|
+
let blob = new Blob([buffer], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;" });
|
|
2270
|
+
let objectUrl = URL.createObjectURL(blob);
|
|
2271
|
+
this.utiExts.fileDownload(objectUrl, fn.endsWith('.csv') ? fn.replace('.csv', '.xlsx') : fn.endsWith('.xlsx') ? fn : fn + ".xlsx");
|
|
2272
|
+
}
|
|
2273
|
+
exportExcelBuffer(fn, headers, data) {
|
|
2200
2274
|
var toExport = [];
|
|
2201
2275
|
headers = headers.sort((a, b) => a.order - b.order);
|
|
2202
2276
|
for (let d = 0; d < data.length; d++) {
|
|
@@ -2204,8 +2278,10 @@ class ExportService {
|
|
|
2204
2278
|
for (let h = 0; h < headers.length; h++) {
|
|
2205
2279
|
let head = headers[h];
|
|
2206
2280
|
let val = data[d][head.key];
|
|
2281
|
+
if (head.type == "date" && val && !this.dates.getDateConvertion(val))
|
|
2282
|
+
console.error("[@esfaenza/extensions - export] Valore data che non è una data per qualche motivo: " + val);
|
|
2207
2283
|
toExportItem[head.label] =
|
|
2208
|
-
head.type == "date" ? this.dates.getDateConvertion(val)
|
|
2284
|
+
head.type == "date" ? (val ? this.dates.getDateConvertion(val)?.toDate() : "") :
|
|
2209
2285
|
head.type == "number" ? (isNaN(parseFloat(val.replace(',', '.'))) ? "" : parseFloat(val.replace(',', '.'))) :
|
|
2210
2286
|
val;
|
|
2211
2287
|
}
|
|
@@ -2218,9 +2294,7 @@ class ExportService {
|
|
|
2218
2294
|
const wb = XLSX.utils.book_new();
|
|
2219
2295
|
XLSX.utils.book_append_sheet(wb, ws, 'Data');
|
|
2220
2296
|
let buffer = XLSX.write(wb, { bookType: 'xlsx', type: 'array', cellDates: true });
|
|
2221
|
-
|
|
2222
|
-
let objectUrl = URL.createObjectURL(blob);
|
|
2223
|
-
this.utiExts.fileDownload(objectUrl, fn.endsWith('.csv') ? fn.replace('.csv', '.xlsx') : fn.endsWith('.xlsx') ? fn : fn + ".xlsx");
|
|
2297
|
+
return buffer;
|
|
2224
2298
|
}
|
|
2225
2299
|
/**
|
|
2226
2300
|
* Metodo che effettivamente genera gli header e i dati per l'esportazione con **ngx-csv**
|
|
@@ -2234,6 +2308,17 @@ class ExportService {
|
|
|
2234
2308
|
(format == "CSV" ? this.exportCSV : this.exportExcel).bind(this)(fileName, headers, createdItems);
|
|
2235
2309
|
return headers;
|
|
2236
2310
|
}
|
|
2311
|
+
/**
|
|
2312
|
+
* Metodo che effettivamente genera gli header e i dati per l'esportazione con **ngx-csv**
|
|
2313
|
+
*
|
|
2314
|
+
* @param {any[]} items Oggetti da esportare
|
|
2315
|
+
*/
|
|
2316
|
+
exportBuffer(items, format, fileName, type, columnsFilter, genericHeaders) {
|
|
2317
|
+
// Deepclone con assegnatura del tipo
|
|
2318
|
+
var createdItems = items.map(t => this.utiExts.deepClone(t, type));
|
|
2319
|
+
let headers = genericHeaders ? this.setupForGenericExport(createdItems, genericHeaders) : this.setupForExport(createdItems, columnsFilter);
|
|
2320
|
+
return (format == "CSV" ? this.exportCSVBuffer : this.exportExcelBuffer).bind(this)(fileName, headers, createdItems);
|
|
2321
|
+
}
|
|
2237
2322
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ExportService, deps: [{ token: DateService }, { token: UtilityService }, { token: i1.LocalizationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2238
2323
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ExportService, providedIn: "root" });
|
|
2239
2324
|
}
|
|
@@ -2290,14 +2375,16 @@ class ClipboardService {
|
|
|
2290
2375
|
'it-IT': "Annulla"
|
|
2291
2376
|
},
|
|
2292
2377
|
};
|
|
2378
|
+
isBrowser = true;
|
|
2293
2379
|
/**
|
|
2294
2380
|
* Costruttore
|
|
2295
2381
|
*
|
|
2296
2382
|
* @ignore
|
|
2297
2383
|
*/
|
|
2298
|
-
constructor(msgService, locProvider) {
|
|
2384
|
+
constructor(msgService, locProvider, platformId) {
|
|
2299
2385
|
this.msgService = msgService;
|
|
2300
2386
|
this.locProvider = locProvider;
|
|
2387
|
+
this.isBrowser = isPlatformBrowser(platformId);
|
|
2301
2388
|
}
|
|
2302
2389
|
/**
|
|
2303
2390
|
* Prende il valore della clipboard.
|
|
@@ -2307,6 +2394,11 @@ class ClipboardService {
|
|
|
2307
2394
|
* @param {Function} valueFoundCallback Callback che questa funzione chiamerà una volta ottenuto i valori richiesti dalla clipboard
|
|
2308
2395
|
*/
|
|
2309
2396
|
async getClipboard(style, valueFoundCallback) {
|
|
2397
|
+
if (!this.isBrowser) {
|
|
2398
|
+
console.log("@esfaenza/extensions ClipboardService requires browser environment to function. Every call will return the default for the expected value");
|
|
2399
|
+
valueFoundCallback([]);
|
|
2400
|
+
return;
|
|
2401
|
+
}
|
|
2310
2402
|
let LOCALE = this.locProvider ? await this.locProvider.Locale.pipe(first()).toPromise() : 'it-IT';
|
|
2311
2403
|
if (navigator.userAgent.indexOf("Firefox") != -1) {
|
|
2312
2404
|
swal.fire({
|
|
@@ -2400,6 +2492,10 @@ class ClipboardService {
|
|
|
2400
2492
|
* @param {string} text Testo da inserire nella clipboard
|
|
2401
2493
|
*/
|
|
2402
2494
|
async copyTextToClipboard(text) {
|
|
2495
|
+
if (!this.isBrowser) {
|
|
2496
|
+
console.log("@esfaenza/extensions ClipboardService requires browser environment to function. Every call will return the default for the expected value");
|
|
2497
|
+
return;
|
|
2498
|
+
}
|
|
2403
2499
|
let LOCALE = this.locProvider ? await this.locProvider.Locale.pipe(first()).toPromise() : 'it-IT';
|
|
2404
2500
|
var textArea = document.createElement("textarea");
|
|
2405
2501
|
//
|
|
@@ -2446,7 +2542,7 @@ class ClipboardService {
|
|
|
2446
2542
|
}
|
|
2447
2543
|
document.body.removeChild(textArea);
|
|
2448
2544
|
}
|
|
2449
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ClipboardService, deps: [{ token: MessageService }, { token: i1.BaseLocalization, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2545
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ClipboardService, deps: [{ token: MessageService }, { token: i1.BaseLocalization, optional: true }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2450
2546
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ClipboardService, providedIn: "root" });
|
|
2451
2547
|
}
|
|
2452
2548
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ClipboardService, decorators: [{
|
|
@@ -2454,6 +2550,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
|
|
|
2454
2550
|
args: [{ providedIn: "root" }]
|
|
2455
2551
|
}], ctorParameters: () => [{ type: MessageService }, { type: i1.BaseLocalization, decorators: [{
|
|
2456
2552
|
type: Optional
|
|
2553
|
+
}] }, { type: Object, decorators: [{
|
|
2554
|
+
type: Inject,
|
|
2555
|
+
args: [PLATFORM_ID]
|
|
2457
2556
|
}] }] });
|
|
2458
2557
|
|
|
2459
2558
|
/**
|