@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.
Files changed (53) hide show
  1. package/XEnvVars.d.ts +3 -0
  2. package/XEnvVars.js +5 -0
  3. package/gulpfile.js +1 -0
  4. package/lib/administration/XBrowseMetaBrowse.js +1 -2
  5. package/lib/administration/XBrowseMetaForm.js +1 -3
  6. package/lib/administration/XUserBrowse.js +5 -5
  7. package/lib/administration/XUserForm.js +39 -29
  8. package/lib/components/SourceCodeLinkEntity.js +1 -2
  9. package/lib/components/XAutoComplete.js +1 -3
  10. package/lib/components/XAutoCompleteBase.js +6 -9
  11. package/lib/components/XBrowse.js +2 -4
  12. package/lib/components/XButton.js +1 -2
  13. package/lib/components/XButtonIconSmall.js +1 -2
  14. package/lib/components/XChangePasswordForm.js +2 -3
  15. package/lib/components/XCheckbox.d.ts +1 -0
  16. package/lib/components/XCheckbox.js +4 -4
  17. package/lib/components/XCheckboxDT.js +1 -2
  18. package/lib/components/XDataTable.js +3 -5
  19. package/lib/components/XDropdown.js +1 -3
  20. package/lib/components/XDropdownDT.js +2 -3
  21. package/lib/components/XDropdownDTFilter.js +2 -3
  22. package/lib/components/XDropdownFormDTFilter.js +2 -3
  23. package/lib/components/XEditColumnDialog.js +2 -3
  24. package/lib/components/XEnvVars.d.ts +12 -0
  25. package/lib/components/XEnvVars.js +20 -0
  26. package/lib/components/XExportRowsDialog.js +9 -8
  27. package/lib/components/XFieldSelector.js +2 -3
  28. package/lib/components/XFormBase.js +1 -3
  29. package/lib/components/XFormBaseT.js +1 -3
  30. package/lib/components/XFormComponent.js +1 -3
  31. package/lib/components/XFormDataTable2.js +8 -13
  32. package/lib/components/XFormFooter.js +1 -2
  33. package/lib/components/XFormNavigator3.js +6 -9
  34. package/lib/components/XHolders.js +2 -4
  35. package/lib/components/XInputDate.js +1 -2
  36. package/lib/components/XInputDateDT.js +1 -2
  37. package/lib/components/XInputDecimal.js +1 -2
  38. package/lib/components/XInputDecimalDT.js +1 -2
  39. package/lib/components/XInputText.js +1 -3
  40. package/lib/components/XInputTextDT.js +1 -2
  41. package/lib/components/XLazyDataTable.js +5 -7
  42. package/lib/components/XLoginDialog.js +1 -2
  43. package/lib/components/XLoginForm.js +3 -4
  44. package/lib/components/XResponseError.js +1 -3
  45. package/lib/components/XSearchButton.js +1 -3
  46. package/lib/components/XSearchButtonDT.js +2 -3
  47. package/lib/components/XSearchButtonOld.js +2 -3
  48. package/lib/components/XToOneAssocButton.js +1 -2
  49. package/lib/components/XToken.d.ts +4 -3
  50. package/lib/components/XUtils.d.ts +10 -3
  51. package/lib/components/XUtils.js +61 -13
  52. package/lib/serverApi/XUser.d.ts +1 -0
  53. package/package.json +14 -11
@@ -90,7 +90,7 @@ var XUtils = /** @class */ (function () {
90
90
  function XUtils() {
91
91
  }
92
92
  XUtils.demo = function () {
93
- return XUtils.getXServerUrl().indexOf('x-demo-server') !== -1;
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
- XUtils.fetchBasic = function (path, headers, body, usePublicToken) {
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.getXServerUrl() + path, {
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.getXServerUrl = function () {
359
- if (XUtils.xServerUrl === null) {
360
- throw "XUtils.xServerUrl is null";
395
+ XUtils.getXBackendUrl = function () {
396
+ if (XUtils.xBackendUrl === undefined) {
397
+ throw "XUtils.xBackendUrl is undefined";
361
398
  }
362
- return XUtils.xServerUrl;
363
- };
364
- XUtils.setXServerUrl = function (xServerUrl) {
365
- XUtils.xServerUrl = xServerUrl;
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.xServerUrl = null;
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)
@@ -3,4 +3,5 @@ export interface XUser {
3
3
  username: string;
4
4
  password: string;
5
5
  name: string;
6
+ enabled: boolean;
6
7
  }
package/package.json CHANGED
@@ -1,18 +1,21 @@
1
1
  {
2
2
  "name": "@michalrakus/x-react-web-lib",
3
- "version": "0.25.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": "npm run clean && npm run compile && npm run generateApi",
10
- "linkDemo": "npm link && npm link ../DemoReactWebApp/node_modules/react",
11
- "linkDemoRouter": "npm link && npm link ../demo-router-web-app/node_modules/react",
12
- "linkKvm": "npm link && npm link ../kvm-web-app/node_modules/react",
13
- "linkKvmNext": "npm link && npm link ../kvm-next-web-app/node_modules/react",
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": "npm run build"
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.1",
34
- "primeicons": "^4.1.0",
35
- "primereact": "latest",
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": "^4.2.4",
46
+ "typescript": "^3.2.1",
44
47
  "dateformat": "^4.4.1"
45
48
  },
46
49
  "files": [