@olenbetong/appframe-core 1.3.7 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/af.common.js +204 -304
- package/dist/esm/af.common.legacy.js +206 -307
- package/dist/esm/af.common.legacy.min.js +3 -3
- package/dist/esm/af.common.legacy.min.js.map +4 -4
- package/dist/esm/af.common.min.js +5 -5
- package/dist/esm/af.common.min.js.map +4 -4
- package/dist/iife/af.common.js +204 -304
- package/dist/iife/af.common.legacy.js +206 -307
- package/dist/iife/af.common.legacy.min.js +3 -3
- package/dist/iife/af.common.legacy.min.js.map +4 -4
- package/dist/iife/af.common.min.js +5 -5
- package/dist/iife/af.common.min.js.map +4 -4
- package/es/UserSession.d.ts +5 -1
- package/es/UserSession.js +5 -1
- package/es/index.d.ts +31 -3
- package/es/index.js +3 -4
- package/package.json +2 -2
- package/src/UserSession.ts +5 -1
- package/src/index.ts +36 -3
- package/es/exportDataObject.d.ts +0 -73
- package/es/exportDataObject.js +0 -61
- package/es/formDataToObject.d.ts +0 -26
- package/es/formDataToObject.js +0 -73
- package/src/exportDataObject.ts +0 -110
- package/src/formDataToObject.ts +0 -80
- package/src/global.d.ts +0 -56
|
@@ -57,224 +57,6 @@ function mitt_default(n) {
|
|
|
57
57
|
} };
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
// src/downloadBlob.ts
|
|
61
|
-
function downloadBlob(blob, fileName) {
|
|
62
|
-
return new Promise(function(resolve, reject) {
|
|
63
|
-
try {
|
|
64
|
-
const url = URL.createObjectURL(blob);
|
|
65
|
-
const parent = document.body;
|
|
66
|
-
const anchor = document.createElement("a");
|
|
67
|
-
anchor.setAttribute("download", fileName);
|
|
68
|
-
anchor.href = url;
|
|
69
|
-
parent.append(anchor);
|
|
70
|
-
anchor.click();
|
|
71
|
-
parent.removeChild(anchor);
|
|
72
|
-
setTimeout(function() {
|
|
73
|
-
URL.revokeObjectURL(url);
|
|
74
|
-
resolve();
|
|
75
|
-
}, 250);
|
|
76
|
-
} catch (ex) {
|
|
77
|
-
reject(ex);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// src/downloadRequest.ts
|
|
83
|
-
async function downloadRequest(request, { fileName, signal, onProgress }) {
|
|
84
|
-
var _a;
|
|
85
|
-
function reportProgress(progress) {
|
|
86
|
-
if (typeof onProgress === "function") {
|
|
87
|
-
onProgress(__spreadValues({}, progress));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
let bytesReceived = 0;
|
|
91
|
-
reportProgress({ status: "requested" });
|
|
92
|
-
try {
|
|
93
|
-
let response = await fetch(request);
|
|
94
|
-
if (!response.ok || !response.body) {
|
|
95
|
-
if ((_a = response.headers.get("content-type")) == null ? void 0 : _a.includes("application/json")) {
|
|
96
|
-
let data = await response.json();
|
|
97
|
-
if (data.error) {
|
|
98
|
-
throw new Error(data.error);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
throw new Error(`${response.status} ${response.statusText}`);
|
|
102
|
-
}
|
|
103
|
-
try {
|
|
104
|
-
const reader = response.body.getReader();
|
|
105
|
-
const stream = new ReadableStream({
|
|
106
|
-
start: function(controller) {
|
|
107
|
-
function pump() {
|
|
108
|
-
return reader.read().then(function(read) {
|
|
109
|
-
if (read.done) {
|
|
110
|
-
controller.close();
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
bytesReceived += read.value.length;
|
|
114
|
-
reportProgress({ bytesReceived, status: "downloading" });
|
|
115
|
-
controller.enqueue(read.value);
|
|
116
|
-
return pump();
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
return pump();
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
response = new Response(stream);
|
|
123
|
-
} catch (error) {
|
|
124
|
-
console.warn("Failed to replace response stream to log download progress.");
|
|
125
|
-
}
|
|
126
|
-
const blob = await response.blob();
|
|
127
|
-
reportProgress({ bytesReceived, status: "downloaded" });
|
|
128
|
-
await downloadBlob(blob, fileName);
|
|
129
|
-
reportProgress({ bytesReceived, status: "completed" });
|
|
130
|
-
} catch (err) {
|
|
131
|
-
if (signal == null ? void 0 : signal.aborted) {
|
|
132
|
-
reportProgress({ status: "cancelled" });
|
|
133
|
-
} else {
|
|
134
|
-
reportProgress({ error: err.message, status: "error" });
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// src/exportDataObject.ts
|
|
140
|
-
function exportOptionsFromDataObject(dataObject, specifiedOptions) {
|
|
141
|
-
return __spreadValues({
|
|
142
|
-
columns: dataObject.getFields().map((field) => ({ name: field.name })),
|
|
143
|
-
distinctRows: dataObject.getParameter("distinctRows"),
|
|
144
|
-
filterObject: dataObject.getParameter("filterObject"),
|
|
145
|
-
filterString: dataObject.getParameter("filterString"),
|
|
146
|
-
maxRecords: dataObject.getParameter("maxRecords"),
|
|
147
|
-
sortOrder: dataObject.getParameter("sortOrder"),
|
|
148
|
-
whereClause: dataObject.getParameter("whereClause"),
|
|
149
|
-
whereObject: dataObject.getParameter("whereObject")
|
|
150
|
-
}, specifiedOptions);
|
|
151
|
-
}
|
|
152
|
-
var defaultOptions = {
|
|
153
|
-
columns: [],
|
|
154
|
-
distinctRows: false,
|
|
155
|
-
filterObject: null,
|
|
156
|
-
filterString: "",
|
|
157
|
-
maxRecords: -1,
|
|
158
|
-
sortOrder: [],
|
|
159
|
-
whereClause: "",
|
|
160
|
-
whereObject: null
|
|
161
|
-
};
|
|
162
|
-
function getDataObjectReportRequest(params) {
|
|
163
|
-
var _a;
|
|
164
|
-
const { articleId, dataObject, format, options } = params;
|
|
165
|
-
const reportOptions = options ? Object.assign({}, defaultOptions, options) : defaultOptions;
|
|
166
|
-
const body = "data=" + encodeURIComponent(JSON.stringify(reportOptions));
|
|
167
|
-
const requestUrl = `/api/data-object/export/${articleId}/${dataObject}/${format}`;
|
|
168
|
-
const controller = (_a = params.controller) != null ? _a : new AbortController();
|
|
169
|
-
return {
|
|
170
|
-
controller,
|
|
171
|
-
request: new Request(requestUrl, {
|
|
172
|
-
body,
|
|
173
|
-
credentials: "same-origin",
|
|
174
|
-
headers: {
|
|
175
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
176
|
-
},
|
|
177
|
-
method: "POST",
|
|
178
|
-
signal: controller.signal
|
|
179
|
-
})
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
function openDataObjectReport(params) {
|
|
183
|
-
const { dataObject, fileName, format } = params;
|
|
184
|
-
const { request } = getDataObjectReportRequest(params);
|
|
185
|
-
return downloadRequest(request, {
|
|
186
|
-
fileName: `${fileName || dataObject}.${format}`
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// src/has.ts
|
|
191
|
-
function has(obj, key2) {
|
|
192
|
-
return Object.prototype.hasOwnProperty.call(obj, key2);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// src/parseFunc.ts
|
|
196
|
-
var funcRegex = /^function(?:\s+([a-zA-Z$_][a-zA-Z0-9$_]*))?\s*\(((?:(?:\s*[a-zA-Z$_][a-zA-Z0-9$_]*)(?:\s*,\s*[a-zA-Z$_][a-zA-Z0-9$_]*)*)?)\s*\)\s*\{((?:.|\n|\r)*)\}$/;
|
|
197
|
-
function parseFunc(func) {
|
|
198
|
-
var match = func.toString().match(funcRegex);
|
|
199
|
-
if (match === null) {
|
|
200
|
-
throw new TypeError("Unable to parse function!");
|
|
201
|
-
}
|
|
202
|
-
return { name: match[1], args: match[2].split(","), body: match[3] };
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// src/Namespace.ts
|
|
206
|
-
function Namespace() {
|
|
207
|
-
}
|
|
208
|
-
Namespace.prototype = /* @__PURE__ */ Object.create(null);
|
|
209
|
-
var Namespace_default = Namespace;
|
|
210
|
-
|
|
211
|
-
// src/requireNamespace.ts
|
|
212
|
-
function requireNamespace(root, namespace) {
|
|
213
|
-
if (typeof root === "object") {
|
|
214
|
-
if (typeof namespace === "string") {
|
|
215
|
-
let path = namespace.split(".");
|
|
216
|
-
return requireNamespace(root, path);
|
|
217
|
-
} else if (Array.isArray(namespace)) {
|
|
218
|
-
let current = root;
|
|
219
|
-
for (let i = 0; i < namespace.length; i++) {
|
|
220
|
-
current = current[namespace[i]] = current[namespace[i]] || new Namespace_default();
|
|
221
|
-
}
|
|
222
|
-
return current;
|
|
223
|
-
} else {
|
|
224
|
-
throw new TypeError("Invalid type of parameter 'namespace'");
|
|
225
|
-
}
|
|
226
|
-
} else {
|
|
227
|
-
throw new TypeError("Invalid type of parameter 'root'");
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// src/warn.ts
|
|
232
|
-
function warn(message, fallbackToAlert) {
|
|
233
|
-
console.warn(message);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// src/expose.ts
|
|
237
|
-
function expose(name, value) {
|
|
238
|
-
if (arguments.length !== 2) {
|
|
239
|
-
throw new Error("Incorrect number of arguments passed to the expose function!");
|
|
240
|
-
}
|
|
241
|
-
if (Array.isArray(value)) {
|
|
242
|
-
for (let func of value) {
|
|
243
|
-
const { name: funcName } = parseFunc(func);
|
|
244
|
-
if (funcName) {
|
|
245
|
-
expose(name, func);
|
|
246
|
-
} else {
|
|
247
|
-
throw new Error(
|
|
248
|
-
"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
} else {
|
|
253
|
-
let keyName;
|
|
254
|
-
let namespace;
|
|
255
|
-
if (typeof value === "function") {
|
|
256
|
-
keyName = parseFunc(value).name;
|
|
257
|
-
}
|
|
258
|
-
if (typeof name === "string") {
|
|
259
|
-
let pathParts = name.split(".");
|
|
260
|
-
if (!keyName) {
|
|
261
|
-
keyName = pathParts[pathParts.length - 1];
|
|
262
|
-
pathParts = pathParts.slice(0, pathParts.length - 1);
|
|
263
|
-
}
|
|
264
|
-
namespace = requireNamespace(window, pathParts);
|
|
265
|
-
} else if (keyName && (typeof name === "object" || typeof name === "function")) {
|
|
266
|
-
namespace = name;
|
|
267
|
-
} else {
|
|
268
|
-
throw new TypeError("Invalid typeof parameter 'name', or unable to parse pValue!");
|
|
269
|
-
}
|
|
270
|
-
if (has(namespace, keyName)) {
|
|
271
|
-
warn([name, keyName].join(".") + " is already defined!");
|
|
272
|
-
} else {
|
|
273
|
-
namespace[keyName] = value;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
60
|
// src/getLocalizedString.ts
|
|
279
61
|
async function getLocalizedStringAsync(string) {
|
|
280
62
|
try {
|
|
@@ -397,49 +179,6 @@ function getLocalizedString(string) {
|
|
|
397
179
|
return localized;
|
|
398
180
|
}
|
|
399
181
|
|
|
400
|
-
// src/localStorage.ts
|
|
401
|
-
function getLocalKey(key2) {
|
|
402
|
-
var _a;
|
|
403
|
-
return [((_a = af == null ? void 0 : af.article) == null ? void 0 : _a.id) || "", "common", key2].join(".");
|
|
404
|
-
}
|
|
405
|
-
var LocalStorage = class {
|
|
406
|
-
isPersisted() {
|
|
407
|
-
return true;
|
|
408
|
-
}
|
|
409
|
-
getLocalStorageKey(key2, global) {
|
|
410
|
-
return global ? ["common", key2].join(".") : getLocalKey(key2);
|
|
411
|
-
}
|
|
412
|
-
get(key2, defaultValue, global) {
|
|
413
|
-
const lsKey = this.getLocalStorageKey(key2, global);
|
|
414
|
-
const value = localStorage.getItem(lsKey);
|
|
415
|
-
return value !== null ? JSON.parse(value) : defaultValue;
|
|
416
|
-
}
|
|
417
|
-
set(key2, value, global) {
|
|
418
|
-
localStorage.setItem(
|
|
419
|
-
this.getLocalStorageKey(key2, global),
|
|
420
|
-
JSON.stringify(value)
|
|
421
|
-
);
|
|
422
|
-
}
|
|
423
|
-
remove(key2, global) {
|
|
424
|
-
const lsKey = this.getLocalStorageKey(key2, global);
|
|
425
|
-
if (localStorage.getItem(lsKey) !== null) {
|
|
426
|
-
localStorage.removeItem(lsKey);
|
|
427
|
-
return true;
|
|
428
|
-
} else {
|
|
429
|
-
return false;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
clear() {
|
|
433
|
-
const baseKey = getLocalKey("");
|
|
434
|
-
for (let key2 in localStorage) {
|
|
435
|
-
if (key2.slice(0, baseKey.length) === baseKey) {
|
|
436
|
-
localStorage.removeItem(key2);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
var localStorage_default = new LocalStorage();
|
|
442
|
-
|
|
443
182
|
// src/SessionHandler.ts
|
|
444
183
|
var _SessionHandler = class {
|
|
445
184
|
constructor() {
|
|
@@ -589,62 +328,228 @@ var UserSession = class extends SessionHandler {
|
|
|
589
328
|
constructor(userData) {
|
|
590
329
|
super();
|
|
591
330
|
this.decimalSeparator = ".";
|
|
331
|
+
this.domain = "OB";
|
|
592
332
|
this.groupSeparator = null;
|
|
593
333
|
this.shortDateFormat = "dd.MM.yyyy";
|
|
594
|
-
this.login =
|
|
334
|
+
this.login = "";
|
|
595
335
|
this.isDeveloper = false;
|
|
336
|
+
this.culture = "en-GB";
|
|
337
|
+
this.uiculture = "en-GB";
|
|
338
|
+
this.expired = () => null;
|
|
596
339
|
this.formats = {};
|
|
597
340
|
Object.assign(this, userData);
|
|
598
341
|
}
|
|
599
342
|
};
|
|
600
343
|
|
|
601
|
-
// src/
|
|
602
|
-
function
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
344
|
+
// src/downloadBlob.ts
|
|
345
|
+
function downloadBlob(blob, fileName) {
|
|
346
|
+
return new Promise(function(resolve, reject) {
|
|
347
|
+
try {
|
|
348
|
+
const url = URL.createObjectURL(blob);
|
|
349
|
+
const parent = document.body;
|
|
350
|
+
const anchor = document.createElement("a");
|
|
351
|
+
anchor.setAttribute("download", fileName);
|
|
352
|
+
anchor.href = url;
|
|
353
|
+
parent.append(anchor);
|
|
354
|
+
anchor.click();
|
|
355
|
+
parent.removeChild(anchor);
|
|
356
|
+
setTimeout(function() {
|
|
357
|
+
URL.revokeObjectURL(url);
|
|
358
|
+
resolve();
|
|
359
|
+
}, 250);
|
|
360
|
+
} catch (ex) {
|
|
361
|
+
reject(ex);
|
|
362
|
+
}
|
|
363
|
+
});
|
|
617
364
|
}
|
|
618
|
-
|
|
365
|
+
|
|
366
|
+
// src/downloadRequest.ts
|
|
367
|
+
async function downloadRequest(request, { fileName, signal, onProgress }) {
|
|
619
368
|
var _a;
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
369
|
+
function reportProgress(progress) {
|
|
370
|
+
if (typeof onProgress === "function") {
|
|
371
|
+
onProgress(__spreadValues({}, progress));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
let bytesReceived = 0;
|
|
375
|
+
reportProgress({ status: "requested" });
|
|
376
|
+
try {
|
|
377
|
+
let response = await fetch(request);
|
|
378
|
+
if (!response.ok || !response.body) {
|
|
379
|
+
if ((_a = response.headers.get("content-type")) == null ? void 0 : _a.includes("application/json")) {
|
|
380
|
+
let data = await response.json();
|
|
381
|
+
if (data.error) {
|
|
382
|
+
throw new Error(data.error);
|
|
383
|
+
}
|
|
631
384
|
}
|
|
385
|
+
throw new Error(`${response.status} ${response.statusText}`);
|
|
386
|
+
}
|
|
387
|
+
try {
|
|
388
|
+
const reader = response.body.getReader();
|
|
389
|
+
const stream = new ReadableStream({
|
|
390
|
+
start: function(controller) {
|
|
391
|
+
function pump() {
|
|
392
|
+
return reader.read().then(function(read) {
|
|
393
|
+
if (read.done) {
|
|
394
|
+
controller.close();
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
bytesReceived += read.value.length;
|
|
398
|
+
reportProgress({ bytesReceived, status: "downloading" });
|
|
399
|
+
controller.enqueue(read.value);
|
|
400
|
+
return pump();
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
return pump();
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
response = new Response(stream);
|
|
407
|
+
} catch (error) {
|
|
408
|
+
console.warn("Failed to replace response stream to log download progress.");
|
|
409
|
+
}
|
|
410
|
+
const blob = await response.blob();
|
|
411
|
+
reportProgress({ bytesReceived, status: "downloaded" });
|
|
412
|
+
await downloadBlob(blob, fileName);
|
|
413
|
+
reportProgress({ bytesReceived, status: "completed" });
|
|
414
|
+
} catch (err) {
|
|
415
|
+
if (signal == null ? void 0 : signal.aborted) {
|
|
416
|
+
reportProgress({ status: "cancelled" });
|
|
632
417
|
} else {
|
|
633
|
-
|
|
418
|
+
reportProgress({ error: err.message, status: "error" });
|
|
634
419
|
}
|
|
635
420
|
}
|
|
636
|
-
return result;
|
|
637
421
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
return
|
|
422
|
+
|
|
423
|
+
// src/has.ts
|
|
424
|
+
function has(obj, key2) {
|
|
425
|
+
return Object.prototype.hasOwnProperty.call(obj, key2);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// src/parseFunc.ts
|
|
429
|
+
var funcRegex = /^function(?:\s+([a-zA-Z$_][a-zA-Z0-9$_]*))?\s*\(((?:(?:\s*[a-zA-Z$_][a-zA-Z0-9$_]*)(?:\s*,\s*[a-zA-Z$_][a-zA-Z0-9$_]*)*)?)\s*\)\s*\{((?:.|\n|\r)*)\}$/;
|
|
430
|
+
function parseFunc(func) {
|
|
431
|
+
var match = func.toString().match(funcRegex);
|
|
432
|
+
if (match === null) {
|
|
433
|
+
throw new TypeError("Unable to parse function!");
|
|
434
|
+
}
|
|
435
|
+
return { name: match[1], args: match[2].split(","), body: match[3] };
|
|
642
436
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
return formDataToObject(form, types);
|
|
437
|
+
|
|
438
|
+
// src/Namespace.ts
|
|
439
|
+
function Namespace() {
|
|
647
440
|
}
|
|
441
|
+
Namespace.prototype = /* @__PURE__ */ Object.create(null);
|
|
442
|
+
var Namespace_default = Namespace;
|
|
443
|
+
|
|
444
|
+
// src/requireNamespace.ts
|
|
445
|
+
function requireNamespace(root, namespace) {
|
|
446
|
+
if (typeof root === "object") {
|
|
447
|
+
if (typeof namespace === "string") {
|
|
448
|
+
let path = namespace.split(".");
|
|
449
|
+
return requireNamespace(root, path);
|
|
450
|
+
} else if (Array.isArray(namespace)) {
|
|
451
|
+
let current = root;
|
|
452
|
+
for (let i = 0; i < namespace.length; i++) {
|
|
453
|
+
current = current[namespace[i]] = current[namespace[i]] || new Namespace_default();
|
|
454
|
+
}
|
|
455
|
+
return current;
|
|
456
|
+
} else {
|
|
457
|
+
throw new TypeError("Invalid type of parameter 'namespace'");
|
|
458
|
+
}
|
|
459
|
+
} else {
|
|
460
|
+
throw new TypeError("Invalid type of parameter 'root'");
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// src/warn.ts
|
|
465
|
+
function warn(message, fallbackToAlert) {
|
|
466
|
+
console.warn(message);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// src/expose.ts
|
|
470
|
+
function expose(name, value) {
|
|
471
|
+
if (arguments.length !== 2) {
|
|
472
|
+
throw new Error("Incorrect number of arguments passed to the expose function!");
|
|
473
|
+
}
|
|
474
|
+
if (Array.isArray(value)) {
|
|
475
|
+
for (let func of value) {
|
|
476
|
+
const { name: funcName } = parseFunc(func);
|
|
477
|
+
if (funcName) {
|
|
478
|
+
expose(name, func);
|
|
479
|
+
} else {
|
|
480
|
+
throw new Error(
|
|
481
|
+
"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
} else {
|
|
486
|
+
let keyName;
|
|
487
|
+
let namespace;
|
|
488
|
+
if (typeof value === "function") {
|
|
489
|
+
keyName = parseFunc(value).name;
|
|
490
|
+
}
|
|
491
|
+
if (typeof name === "string") {
|
|
492
|
+
let pathParts = name.split(".");
|
|
493
|
+
if (!keyName) {
|
|
494
|
+
keyName = pathParts[pathParts.length - 1];
|
|
495
|
+
pathParts = pathParts.slice(0, pathParts.length - 1);
|
|
496
|
+
}
|
|
497
|
+
namespace = requireNamespace(window, pathParts);
|
|
498
|
+
} else if (keyName && (typeof name === "object" || typeof name === "function")) {
|
|
499
|
+
namespace = name;
|
|
500
|
+
} else {
|
|
501
|
+
throw new TypeError("Invalid typeof parameter 'name', or unable to parse pValue!");
|
|
502
|
+
}
|
|
503
|
+
if (has(namespace, keyName)) {
|
|
504
|
+
warn([name, keyName].join(".") + " is already defined!");
|
|
505
|
+
} else {
|
|
506
|
+
namespace[keyName] = value;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// src/localStorage.ts
|
|
512
|
+
function getLocalKey(key2) {
|
|
513
|
+
var _a;
|
|
514
|
+
return [((_a = af == null ? void 0 : af.article) == null ? void 0 : _a.id) || "", "common", key2].join(".");
|
|
515
|
+
}
|
|
516
|
+
var LocalStorage = class {
|
|
517
|
+
isPersisted() {
|
|
518
|
+
return true;
|
|
519
|
+
}
|
|
520
|
+
getLocalStorageKey(key2, global) {
|
|
521
|
+
return global ? ["common", key2].join(".") : getLocalKey(key2);
|
|
522
|
+
}
|
|
523
|
+
get(key2, defaultValue, global) {
|
|
524
|
+
const lsKey = this.getLocalStorageKey(key2, global);
|
|
525
|
+
const value = localStorage.getItem(lsKey);
|
|
526
|
+
return value !== null ? JSON.parse(value) : defaultValue;
|
|
527
|
+
}
|
|
528
|
+
set(key2, value, global) {
|
|
529
|
+
localStorage.setItem(
|
|
530
|
+
this.getLocalStorageKey(key2, global),
|
|
531
|
+
JSON.stringify(value)
|
|
532
|
+
);
|
|
533
|
+
}
|
|
534
|
+
remove(key2, global) {
|
|
535
|
+
const lsKey = this.getLocalStorageKey(key2, global);
|
|
536
|
+
if (localStorage.getItem(lsKey) !== null) {
|
|
537
|
+
localStorage.removeItem(lsKey);
|
|
538
|
+
return true;
|
|
539
|
+
} else {
|
|
540
|
+
return false;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
clear() {
|
|
544
|
+
const baseKey = getLocalKey("");
|
|
545
|
+
for (let key2 in localStorage) {
|
|
546
|
+
if (key2.slice(0, baseKey.length) === baseKey) {
|
|
547
|
+
localStorage.removeItem(key2);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
var localStorage_default = new LocalStorage();
|
|
648
553
|
|
|
649
554
|
// src/settings.ts
|
|
650
555
|
function getKey(article) {
|
|
@@ -675,24 +580,18 @@ function saveSettings(setting, value, article) {
|
|
|
675
580
|
}
|
|
676
581
|
|
|
677
582
|
// src/index.ts
|
|
678
|
-
var version = "
|
|
583
|
+
var version = "2.0.0";
|
|
679
584
|
export {
|
|
680
585
|
SessionHandler,
|
|
681
586
|
UserSession,
|
|
682
587
|
downloadBlob,
|
|
683
588
|
downloadRequest,
|
|
684
|
-
exportOptionsFromDataObject,
|
|
685
589
|
expose,
|
|
686
|
-
formDataToDataObjectRecord,
|
|
687
|
-
formDataToObject,
|
|
688
|
-
formDataToProcedureParameters,
|
|
689
|
-
getDataObjectReportRequest,
|
|
690
590
|
getLocalizedString,
|
|
691
591
|
getSettings,
|
|
692
592
|
has,
|
|
693
593
|
localStorage_default as localStorage,
|
|
694
594
|
mitt_default as mitt,
|
|
695
|
-
openDataObjectReport,
|
|
696
595
|
saveSettings,
|
|
697
596
|
version
|
|
698
597
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var D=Object.defineProperty;var N=Object.getOwnPropertySymbols;var C=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var j=(t,e,n)=>e in t?D(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,T=(t,e)=>{for(var n in e||(e={}))C.call(e,n)&&j(t,n,e[n]);if(N)for(var n of N(e))P.call(e,n)&&j(t,n,e[n]);return t};window.addEventListener("error",t=>{var e,n,r,o,a,s,i;try{let u={error:(r=(n=(e=t.error)==null?void 0:e.message)!=null?n:t.message)!=null?r:null,file:t.filename,line:(o=t.lineno)!=null?o:0,column:(a=t.colno)!=null?a:0,stack:(i=(s=t.error)==null?void 0:s.stack)!=null?i:null};fetch("/data/Logger/LogError",{body:JSON.stringify(u),headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8","X-Requested-With":"XMLHttpRequest"},method:"POST"})}catch(u){}});function x(t){return{all:t=t||new Map,on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(o){o(n)}),(r=t.get("*"))&&r.slice().map(function(o){o(e,n)})}}}async function M(t){try{let e=await fetch("/api/user/localize",{body:JSON.stringify({string:t}),headers:{Accept:"application/json; */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},method:"POST"});if(e.ok)return await e.json()}catch(e){}return t}function O(t,e){var n;if(((n=af==null?void 0:af.article)==null?void 0:n.i18n)!==void 0){if(!Object.prototype.hasOwnProperty.call(af.article.i18n,t)){af.article.i18n[t]=t;let r=M(t).then(o=>(af.article.i18n[t]=o,o));if(e)return r}return af.article.i18n[t]}else return t}var h="__UNLOCALIZED_STRINGS__",m=window[h]||new Set;window[h]||(window[h]=m);function k(){document.readyState!=="loading"&&(R(),document.removeEventListener("readystatechange",k))}document.readyState!=="loading"?R():document.addEventListener("readystatechange",k);function U(){let{af:t}=window;return t&&t.userSession&&t.userSession.isDeveloper}function R(){if(U()){if(typeof window.__doNothingWithStrings=="function"){let t=window.__doNothingWithStrings();for(let e of Object.keys(t))m.add(e)}window[h]||(window[h]=m),window.__getUnlocalizedStrings||(window.__getUnlocalizedStrings=function(t){let e=[];for(let n of m)if(n){let r=n.replace(/'/g,"\\'");if(t){let o=O(n).replaceAll(/'/g,"\\'");e.push(`'${r}': '${o}',`)}else e.push(`s['${r}'] = @Html(@context.AddLocalizableString("${n.replaceAll('"','\\"')}"));`)}return t?`// Localization hack, since it AddLocalizableString doesn't work properly when custom routes is used
|
|
2
2
|
if (af.userSession.uiculture === 'nb-NO') {
|
|
3
3
|
const strings = {
|
|
4
4
|
${e.join(`
|
|
@@ -16,7 +16,7 @@ ${e.join(`
|
|
|
16
16
|
`)}
|
|
17
17
|
return s;
|
|
18
18
|
}
|
|
19
|
-
<\/script>`})}}function y(t){let e=
|
|
19
|
+
<\/script>`})}}function y(t){let e=O(t);return e===t&&!m.has(t)&&m.add(t),e}var w=class{constructor(){this.eventHandler=x();this.showingDialog=!1;this.dialog=null}expired(e){if(af.userSession=af.userSession||{login:null},typeof e!="function")throw new TypeError("Parameter pCallback passed to the expired function must be a function!");let n=()=>{this.detachEvent("onAuthenticated",n),e()};if(this.attachEvent("onAuthenticated",n),this.showingDialog!==!0){this.showingDialog=!0;let r=document.createElement("div");r.className="session-expired-container",r.innerHTML=`
|
|
20
20
|
<div class="session-expired-log-in" style="margin-top: 20px;">
|
|
21
21
|
<div class="row">
|
|
22
22
|
<div class="sessionExpired">
|
|
@@ -44,5 +44,5 @@ return s;
|
|
|
44
44
|
</div>
|
|
45
45
|
</div>
|
|
46
46
|
</div>
|
|
47
|
-
`;let o=af.userSession.login?
|
|
47
|
+
`;let o=af.userSession.login?w.messages.relog:w.messages.login,a=r.querySelector(".message"),s=r.querySelector(".alert-warning"),i=r.querySelector("input[type=text]"),u=r.querySelector(".sign-in"),l=r.querySelector("input[type=password]");if(a!==null&&i!==null&&s!==null&&i!==null&&u!==null&&l!==null){a.innerText=y(o),i.value=af.userSession.login||"",i.disabled=!!af.userSession.login,i.readOnly=!!af.userSession.login,document.body.appendChild(r);let f=async()=>{l.disabled=!0;let c=new Request("/login",{body:JSON.stringify({username:i.value,password:l.value,remember:!1}),headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8","X-Requested-With":"XMLHttpRequest"},method:"POST"});try{let d=await(await fetch(c)).json();if(d.success)document.body.removeChild(r),this.showingDialog=!1,this.eventHandler.emit("onAuthenticated"),s.parentNode&&(s.parentNode.style.display="none");else throw new Error(d.error)}catch(p){if(p&&typeof p=="object"){let d=p;l.disabled=!1,l.classList.toggle("invalid",!0),l.value="",l.focus(),s.innerText=d.message?d.message:String(d),s.parentNode&&(s.parentNode.style.display="initial")}}};u.addEventListener("click",f),l.addEventListener("keyup",c=>{c.key==="Enter"&&f()}),l.addEventListener("change",c=>{c.key==="Enter"&&f()}),i.addEventListener("keyup",c=>{c.key==="Enter"&&f()}),i.addEventListener("change",c=>{c.key==="Enter"&&f()}),l.focus()}}}attachEvent(e,n){return this.eventHandler.on(e,n)}detachEvent(e,n){return this.eventHandler.off(e,n)}},g=w;g.messages={login:"Log in",relog:"Session expired - log in"};var S=class extends g{constructor(n){super();this.decimalSeparator=".";this.domain="OB";this.groupSeparator=null;this.shortDateFormat="dd.MM.yyyy";this.login="";this.isDeveloper=!1;this.culture="en-GB";this.uiculture="en-GB";this.expired=()=>null;this.formats={},Object.assign(this,n)}};function E(t,e){return new Promise(function(n,r){try{let o=URL.createObjectURL(t),a=document.body,s=document.createElement("a");s.setAttribute("download",e),s.href=o,a.append(s),s.click(),a.removeChild(s),setTimeout(function(){URL.revokeObjectURL(o),n()},250)}catch(o){r(o)}})}async function re(t,{fileName:e,signal:n,onProgress:r}){var s;function o(i){typeof r=="function"&&r(T({},i))}let a=0;o({status:"requested"});try{let i=await fetch(t);if(!i.ok||!i.body){if((s=i.headers.get("content-type"))!=null&&s.includes("application/json")){let l=await i.json();if(l.error)throw new Error(l.error)}throw new Error(`${i.status} ${i.statusText}`)}try{let l=i.body.getReader(),f=new ReadableStream({start:function(c){function p(){return l.read().then(function(d){if(d.done){c.close();return}return a+=d.value.length,o({bytesReceived:a,status:"downloading"}),c.enqueue(d.value),p()})}return p()}});i=new Response(f)}catch(l){console.warn("Failed to replace response stream to log download progress.")}let u=await i.blob();o({bytesReceived:a,status:"downloaded"}),await E(u,e),o({bytesReceived:a,status:"completed"})}catch(i){n!=null&&n.aborted?o({status:"cancelled"}):o({error:i.message,status:"error"})}}function z(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var K=/^function(?:\s+([a-zA-Z$_][a-zA-Z0-9$_]*))?\s*\(((?:(?:\s*[a-zA-Z$_][a-zA-Z0-9$_]*)(?:\s*,\s*[a-zA-Z$_][a-zA-Z0-9$_]*)*)?)\s*\)\s*\{((?:.|\n|\r)*)\}$/;function b(t){var e=t.toString().match(K);if(e===null)throw new TypeError("Unable to parse function!");return{name:e[1],args:e[2].split(","),body:e[3]}}function I(){}I.prototype=Object.create(null);var H=I;function v(t,e){if(typeof t=="object")if(typeof e=="string"){let n=e.split(".");return v(t,n)}else if(Array.isArray(e)){let n=t;for(let r=0;r<e.length;r++)n=n[e[r]]=n[e[r]]||new H;return n}else throw new TypeError("Invalid type of parameter 'namespace'");else throw new TypeError("Invalid type of parameter 'root'")}function L(t,e){console.warn(t)}function _(t,e){if(arguments.length!==2)throw new Error("Incorrect number of arguments passed to the expose function!");if(Array.isArray(e))for(let n of e){let{name:r}=b(n);if(r)_(t,n);else throw new Error("Unable to detect name of function! Name it, or only supply one function and include name in first parameter.")}else{let n,r;if(typeof e=="function"&&(n=b(e).name),typeof t=="string"){let o=t.split(".");n||(n=o[o.length-1],o=o.slice(0,o.length-1)),r=v(window,o)}else if(n&&(typeof t=="object"||typeof t=="function"))r=t;else throw new TypeError("Invalid typeof parameter 'name', or unable to parse pValue!");z(r,n)?L([t,n].join(".")+" is already defined!"):r[n]=e}}function q(t){var e;return[((e=af==null?void 0:af.article)==null?void 0:e.id)||"","common",t].join(".")}var A=class{isPersisted(){return!0}getLocalStorageKey(e,n){return n?["common",e].join("."):q(e)}get(e,n,r){let o=this.getLocalStorageKey(e,r),a=localStorage.getItem(o);return a!==null?JSON.parse(a):n}set(e,n,r){localStorage.setItem(this.getLocalStorageKey(e,r),JSON.stringify(n))}remove(e,n){let r=this.getLocalStorageKey(e,n);return localStorage.getItem(r)!==null?(localStorage.removeItem(r),!0):!1}clear(){let e=q("");for(let n in localStorage)n.slice(0,e.length)===e&&localStorage.removeItem(n)}},W=new A;function $(t){return`${t||af.article.id}.${af.userSession.login}`}function we(t,e){if(!(af!=null&&af.userSession))return null;let n=$(e),r=JSON.parse(localStorage.getItem(n)||"{}");return t?r[t]||null:r}function Se(t,e,n){if(!(af!=null&&af.userSession))return;let r=$(n),o=JSON.parse(localStorage.getItem(r)||"{}");typeof e<"u"?o[t]=e:o=t,localStorage.setItem(r,JSON.stringify(o))}var Ee="2.0.0";export{g as SessionHandler,S as UserSession,E as downloadBlob,re as downloadRequest,_ as expose,y as getLocalizedString,we as getSettings,z as has,W as localStorage,x as mitt,Se as saveSettings,Ee as version};
|
|
48
48
|
//# sourceMappingURL=af.common.legacy.min.js.map
|