@michalrakus/x-react-web-lib 0.25.0 → 1.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/XEnvVars.d.ts +3 -0
- package/XEnvVars.js +5 -0
- package/gulpfile.js +1 -0
- package/lib/administration/XBrowseMetaBrowse.js +1 -2
- package/lib/administration/XBrowseMetaForm.js +1 -3
- package/lib/administration/XUserBrowse.js +5 -5
- package/lib/administration/XUserForm.js +39 -29
- package/lib/components/SourceCodeLinkEntity.js +1 -2
- package/lib/components/XAutoComplete.js +1 -3
- package/lib/components/XAutoCompleteBase.js +6 -9
- package/lib/components/XBrowse.js +2 -4
- package/lib/components/XButton.js +1 -2
- package/lib/components/XButtonIconSmall.js +1 -2
- package/lib/components/XChangePasswordForm.js +2 -3
- package/lib/components/XCheckbox.d.ts +1 -0
- package/lib/components/XCheckbox.js +4 -4
- package/lib/components/XCheckboxDT.js +1 -2
- package/lib/components/XDataTable.js +3 -5
- package/lib/components/XDropdown.js +1 -3
- package/lib/components/XDropdownDT.js +2 -3
- package/lib/components/XDropdownDTFilter.js +2 -3
- package/lib/components/XDropdownFormDTFilter.js +2 -3
- package/lib/components/XEditColumnDialog.js +2 -3
- package/lib/components/XEnvVars.d.ts +12 -0
- package/lib/components/XEnvVars.js +20 -0
- package/lib/components/XExportRowsDialog.js +9 -8
- package/lib/components/XFieldSelector.js +2 -3
- package/lib/components/XFormBase.js +1 -3
- package/lib/components/XFormBaseT.js +1 -3
- package/lib/components/XFormComponent.js +1 -3
- package/lib/components/XFormDataTable2.js +8 -13
- package/lib/components/XFormFooter.js +1 -2
- package/lib/components/XFormNavigator3.js +6 -9
- package/lib/components/XHolders.js +2 -4
- package/lib/components/XInputDate.js +1 -2
- package/lib/components/XInputDateDT.js +1 -2
- package/lib/components/XInputDecimal.js +1 -2
- package/lib/components/XInputDecimalDT.js +1 -2
- package/lib/components/XInputText.js +1 -3
- package/lib/components/XInputTextDT.js +1 -2
- package/lib/components/XLazyDataTable.js +5 -7
- package/lib/components/XLoginDialog.js +1 -2
- package/lib/components/XLoginForm.js +3 -4
- package/lib/components/XResponseError.js +1 -3
- package/lib/components/XSearchButton.js +1 -3
- package/lib/components/XSearchButtonDT.js +2 -3
- package/lib/components/XSearchButtonOld.js +2 -3
- package/lib/components/XToOneAssocButton.js +1 -2
- package/lib/components/XToken.d.ts +4 -3
- package/lib/components/XUtils.d.ts +10 -3
- package/lib/components/XUtils.js +61 -13
- package/lib/serverApi/XUser.d.ts +1 -0
- package/package.json +14 -11
package/lib/components/XUtils.js
CHANGED
|
@@ -90,7 +90,7 @@ var XUtils = /** @class */ (function () {
|
|
|
90
90
|
function XUtils() {
|
|
91
91
|
}
|
|
92
92
|
XUtils.demo = function () {
|
|
93
|
-
return XUtils.
|
|
93
|
+
return XUtils.getXBackendUrl().indexOf('x-demo-server') !== -1;
|
|
94
94
|
};
|
|
95
95
|
XUtils.isMobile = function () {
|
|
96
96
|
// extra small displays (podla https://www.w3schools.com/howto/howto_css_media_query_breakpoints.asp)
|
|
@@ -306,7 +306,8 @@ var XUtils = /** @class */ (function () {
|
|
|
306
306
|
});
|
|
307
307
|
});
|
|
308
308
|
};
|
|
309
|
-
|
|
309
|
+
// nepouzivana stara Basic autentifikacia
|
|
310
|
+
XUtils.fetchBasicAuthBasic = function (path, headers, body, usePublicToken) {
|
|
310
311
|
return __awaiter(this, void 0, void 0, function () {
|
|
311
312
|
var xToken, response, responseBody;
|
|
312
313
|
return __generator(this, function (_a) {
|
|
@@ -325,7 +326,43 @@ var XUtils = /** @class */ (function () {
|
|
|
325
326
|
}
|
|
326
327
|
}
|
|
327
328
|
headers = __assign(__assign({}, headers), { 'Authorization': "Basic " + Buffer.from(xToken.username + ':' + xToken.password).toString('base64') });
|
|
328
|
-
return [4 /*yield*/, fetch(XUtils.
|
|
329
|
+
return [4 /*yield*/, fetch(XUtils.getXBackendUrl() + path, {
|
|
330
|
+
method: 'POST',
|
|
331
|
+
headers: headers,
|
|
332
|
+
body: body
|
|
333
|
+
})];
|
|
334
|
+
case 1:
|
|
335
|
+
response = _a.sent();
|
|
336
|
+
if (!!response.ok) return [3 /*break*/, 3];
|
|
337
|
+
return [4 /*yield*/, response.json()];
|
|
338
|
+
case 2:
|
|
339
|
+
responseBody = _a.sent();
|
|
340
|
+
throw new XResponseError_1.XResponseError(path, response.status, response.statusText, responseBody);
|
|
341
|
+
case 3: return [2 /*return*/, response];
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
XUtils.fetchBasic = function (path, headers, body, usePublicToken) {
|
|
347
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
348
|
+
var xToken, response, responseBody;
|
|
349
|
+
return __generator(this, function (_a) {
|
|
350
|
+
switch (_a.label) {
|
|
351
|
+
case 0:
|
|
352
|
+
if (typeof usePublicToken === 'object') {
|
|
353
|
+
xToken = usePublicToken;
|
|
354
|
+
}
|
|
355
|
+
else if (usePublicToken) {
|
|
356
|
+
xToken = XUtils.xTokenPublic; // public token vzdy
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
xToken = XUtils.getXToken();
|
|
360
|
+
if (xToken === null) {
|
|
361
|
+
xToken = XUtils.xTokenPublic; // ak nikto nie je prihlaseny, posleme public token
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
headers = __assign(__assign({}, headers), { 'Authorization': "Bearer " + xToken.accessToken });
|
|
365
|
+
return [4 /*yield*/, fetch(XUtils.getXBackendUrl() + path, {
|
|
329
366
|
method: 'POST',
|
|
330
367
|
headers: headers,
|
|
331
368
|
body: body
|
|
@@ -352,17 +389,28 @@ var XUtils = /** @class */ (function () {
|
|
|
352
389
|
return XUtils.xToken;
|
|
353
390
|
};
|
|
354
391
|
XUtils.getUsername = function () {
|
|
355
|
-
var _a;
|
|
356
|
-
return (_a = XUtils.getXToken()) === null || _a === void 0 ? void 0 : _a.username;
|
|
392
|
+
var _a, _b;
|
|
393
|
+
return (_b = (_a = XUtils.getXToken()) === null || _a === void 0 ? void 0 : _a.xUser) === null || _b === void 0 ? void 0 : _b.username;
|
|
357
394
|
};
|
|
358
|
-
XUtils.
|
|
359
|
-
if (XUtils.
|
|
360
|
-
throw "XUtils.
|
|
395
|
+
XUtils.getXBackendUrl = function () {
|
|
396
|
+
if (XUtils.xBackendUrl === undefined) {
|
|
397
|
+
throw "XUtils.xBackendUrl is undefined";
|
|
361
398
|
}
|
|
362
|
-
return XUtils.
|
|
363
|
-
};
|
|
364
|
-
XUtils.
|
|
365
|
-
XUtils.
|
|
399
|
+
return XUtils.xBackendUrl;
|
|
400
|
+
};
|
|
401
|
+
XUtils.setXBackendUrl = function (xBackendUrl) {
|
|
402
|
+
XUtils.xBackendUrl = xBackendUrl;
|
|
403
|
+
};
|
|
404
|
+
/**
|
|
405
|
+
* returns value of environment variable from configuration file .env
|
|
406
|
+
* @param envVar
|
|
407
|
+
*/
|
|
408
|
+
XUtils.getEnvVarValue = function (envVarEnum) {
|
|
409
|
+
var value = process.env[envVarEnum];
|
|
410
|
+
if (value === undefined) {
|
|
411
|
+
throw "Environment variable " + envVarEnum + " - value not found. Check configuration file .env*";
|
|
412
|
+
}
|
|
413
|
+
return value;
|
|
366
414
|
};
|
|
367
415
|
// funkcionalita ktoru by bolo dobre dat do servisov
|
|
368
416
|
XUtils.removeRow = function (entity, row) {
|
|
@@ -434,7 +482,7 @@ var XUtils = /** @class */ (function () {
|
|
|
434
482
|
return value;
|
|
435
483
|
};
|
|
436
484
|
XUtils.dropdownEmptyOptionValue = " ";
|
|
437
|
-
XUtils.
|
|
485
|
+
XUtils.xBackendUrl = undefined;
|
|
438
486
|
// nacachovany XToken - na rozlicnych miestach potrebujeme vediet uzivatela
|
|
439
487
|
XUtils.xToken = null;
|
|
440
488
|
// token pouzivany pre public stranky (napr. XLoginForm), meno/heslo natvrdo (lepsie ako nic)
|
package/lib/serverApi/XUser.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michalrakus/x-react-web-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf lib",
|
|
7
7
|
"compile": "tsc",
|
|
8
8
|
"generateApi": "gulp generateApi",
|
|
9
|
-
"build": "
|
|
10
|
-
"linkDemo": "
|
|
11
|
-
"linkDemoRouter": "
|
|
12
|
-
"linkKvm": "
|
|
13
|
-
"linkKvmNext": "
|
|
9
|
+
"build": "pnpm run clean && pnpm run compile && pnpm run generateApi",
|
|
10
|
+
"linkDemo": "pnpm link && pnpm link ../DemoReactWebApp/node_modules/react",
|
|
11
|
+
"linkDemoRouter": "pnpm link && pnpm link ../demo-router-web-app/node_modules/react",
|
|
12
|
+
"linkKvm": "pnpm link && pnpm link ../kvm-web-app/node_modules/react",
|
|
13
|
+
"linkKvmNext": "pnpm link && pnpm link ../kvm-next-web-app/node_modules/react",
|
|
14
14
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
15
|
-
"prepublishOnly": "
|
|
15
|
+
"prepublishOnly": "pnpm run build",
|
|
16
|
+
"buildAndPack": "pnpm run build && pnpm pack",
|
|
17
|
+
"bp": "pnpm run buildAndPack",
|
|
18
|
+
"preinstall": "npx only-allow pnpm"
|
|
16
19
|
},
|
|
17
20
|
"author": "Michal Rakus",
|
|
18
21
|
"license": "ISC",
|
|
@@ -30,9 +33,9 @@
|
|
|
30
33
|
"@types/react-transition-group": "^4.2.4",
|
|
31
34
|
"axios": "^0.19.0",
|
|
32
35
|
"classnames": "^2.2.6",
|
|
33
|
-
"primeflex": "3.0
|
|
34
|
-
"primeicons": "^
|
|
35
|
-
"primereact": "
|
|
36
|
+
"primeflex": "^3.3.0",
|
|
37
|
+
"primeicons": "^6.0.1",
|
|
38
|
+
"primereact": "6.0.2",
|
|
36
39
|
"lodash": "^4.17.21",
|
|
37
40
|
"react": "^17.0.1",
|
|
38
41
|
"react-dom": "^17.0.1",
|
|
@@ -40,7 +43,7 @@
|
|
|
40
43
|
"react-transition-group": "^4.4.1",
|
|
41
44
|
"gulp": "^4.0.2",
|
|
42
45
|
"rimraf": "^3.0.2",
|
|
43
|
-
"typescript": "^
|
|
46
|
+
"typescript": "^3.2.1",
|
|
44
47
|
"dateformat": "^4.4.1"
|
|
45
48
|
},
|
|
46
49
|
"files": [
|