@michalrakus/x-react-web-lib 1.32.8 → 1.32.10
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.
|
@@ -50,6 +50,7 @@ export interface XLazyDataTableProps {
|
|
|
50
50
|
entity: string;
|
|
51
51
|
stateKey?: string;
|
|
52
52
|
label?: string;
|
|
53
|
+
labelStyle?: React.CSSProperties;
|
|
53
54
|
dataKey?: string;
|
|
54
55
|
rowExpansionTemplate?: (row: any, options: DataTableRowExpansionTemplate) => React.ReactNode;
|
|
55
56
|
showExpandedRow?: (row: any, multilineSwitchValue: XMultilineRenderType) => boolean;
|
|
@@ -544,6 +544,9 @@ var XLazyDataTable = function (props) {
|
|
|
544
544
|
setFiltersAfterFiltering(filters);
|
|
545
545
|
setFtsInputValueAfterFiltering(ftsInputValue ? __assign({}, ftsInputValue) : undefined);
|
|
546
546
|
setOptionalCustomFilterAfterFiltering(optionalCustomFilter);
|
|
547
|
+
// async check for new version - the purpose is to get new version of app to the browser (if available) in short time (10 minutes)
|
|
548
|
+
// (if there is no new version, the check will run async (as the last operation) and nothing will happen)
|
|
549
|
+
XUtils_1.XUtils.reloadIfNewVersion();
|
|
547
550
|
return [2 /*return*/];
|
|
548
551
|
}
|
|
549
552
|
});
|
|
@@ -1352,7 +1355,7 @@ var XLazyDataTable = function (props) {
|
|
|
1352
1355
|
// x-lazy-datatable-label-right-compensation - vyvazuje label, aby item-y v strede isli aspon priblizne do stredu
|
|
1353
1356
|
return (react_1.default.createElement("div", null,
|
|
1354
1357
|
react_1.default.createElement("div", { className: "flex justify-content-center align-items-center" },
|
|
1355
|
-
props.label ? react_1.default.createElement("div", { className: "x-lazy-datatable-label" }, props.label) : null,
|
|
1358
|
+
props.label ? react_1.default.createElement("div", { className: "x-lazy-datatable-label", style: props.labelStyle }, props.label) : null,
|
|
1356
1359
|
ftsInputValue ? react_1.default.createElement(XFtsInput_1.XFtsInput, { value: ftsInputValue, onChange: function (value) { return setFtsInputValue(value); } }) : null,
|
|
1357
1360
|
props.showFilterButtons ? react_1.default.createElement(XButton_1.XButton, { key: "filter", icon: isMobile ? "pi pi-search" : undefined, label: !isMobile ? (0, XLocale_1.xLocaleOption)('filter') : undefined, onClick: onClickFilter }) : null,
|
|
1358
1361
|
props.showFilterButtons ? react_1.default.createElement(XButton_1.XButton, { key: "resetTable", icon: isMobile ? "pi pi-ban" : undefined, label: !isMobile ? (0, XLocale_1.xLocaleOption)('resetTable') : undefined, onClick: onClickResetTable }) : null,
|
|
@@ -49,6 +49,8 @@ export declare class XUtils {
|
|
|
49
49
|
static csvEncodingOptions: CsvEncoding[];
|
|
50
50
|
static remSize: number | null;
|
|
51
51
|
static FIELD_LABEL_WIDTH: string;
|
|
52
|
+
static lastVersionCheckTimestamp: number | null;
|
|
53
|
+
static VERSION_CHECK_PERIOD: number;
|
|
52
54
|
static demo(): boolean;
|
|
53
55
|
static isMobile(): boolean;
|
|
54
56
|
static mobileCssSuffix(): string;
|
|
@@ -108,4 +110,9 @@ export declare class XUtils {
|
|
|
108
110
|
static saveValueIntoStorage(key: string, value: any): void;
|
|
109
111
|
static getValueFromStorage(key: string, initValue: any): any;
|
|
110
112
|
static removeValueFromStorage(key: string): void;
|
|
113
|
+
static clearStorage(): void;
|
|
114
|
+
static reloadIfNewVersion(): void;
|
|
115
|
+
static reloadIfNewVersionNow(): Promise<void>;
|
|
116
|
+
static isNewVersion(): Promise<boolean>;
|
|
117
|
+
static reload(): void;
|
|
111
118
|
}
|
package/lib/components/XUtils.js
CHANGED
|
@@ -749,6 +749,102 @@ var XUtils = /** @class */ (function () {
|
|
|
749
749
|
XUtils.removeValueFromStorage = function (key) {
|
|
750
750
|
sessionStorage.removeItem(key);
|
|
751
751
|
};
|
|
752
|
+
XUtils.clearStorage = function () {
|
|
753
|
+
sessionStorage.clear();
|
|
754
|
+
};
|
|
755
|
+
// hleper method used for items of XLazyDataTable (shortcut ldt)
|
|
756
|
+
// static getValueFromStorageLdt(entity: string, stateKeySuffix: XStateKeySuffix, initValue: any): any {
|
|
757
|
+
// return XUtils.getValueFromStorage(`xldt-state-${entity}-${stateKeySuffix}`, initValue);
|
|
758
|
+
// }
|
|
759
|
+
XUtils.reloadIfNewVersion = function () {
|
|
760
|
+
// to save requests, we check for new version only if 10 minutes (or another time period) are passed from the last check
|
|
761
|
+
// we could use method setInterval (timer) and run check exactly 10 minutes but the disadvantage is that then there will be
|
|
762
|
+
// some processing during idle time and that can exhaust battery on mobile phone (mobile phone will not go to sleeping mode) - is it true?
|
|
763
|
+
var currentTimestamp = Date.now(); // Current time
|
|
764
|
+
if (XUtils.lastVersionCheckTimestamp === null || currentTimestamp - XUtils.lastVersionCheckTimestamp > XUtils.VERSION_CHECK_PERIOD) {
|
|
765
|
+
XUtils.reloadIfNewVersionNow();
|
|
766
|
+
XUtils.lastVersionCheckTimestamp = currentTimestamp;
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
XUtils.reloadIfNewVersionNow = function () {
|
|
770
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
771
|
+
return __generator(this, function (_a) {
|
|
772
|
+
switch (_a.label) {
|
|
773
|
+
case 0: return [4 /*yield*/, XUtils.isNewVersion()];
|
|
774
|
+
case 1:
|
|
775
|
+
if (_a.sent()) {
|
|
776
|
+
alert("New version was released. Application will be restarted.");
|
|
777
|
+
XUtils.reload();
|
|
778
|
+
}
|
|
779
|
+
return [2 /*return*/];
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
});
|
|
783
|
+
};
|
|
784
|
+
XUtils.isNewVersion = function () {
|
|
785
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
786
|
+
var response, text, r, remoteMainScript, localMainScript, scripts, scripts_1, scripts_1_1, script, rl, err_1;
|
|
787
|
+
var e_7, _a;
|
|
788
|
+
return __generator(this, function (_b) {
|
|
789
|
+
switch (_b.label) {
|
|
790
|
+
case 0:
|
|
791
|
+
_b.trys.push([0, 3, , 4]);
|
|
792
|
+
return [4 /*yield*/, fetch("index.html", { method: 'GET', cache: "no-store" })];
|
|
793
|
+
case 1:
|
|
794
|
+
response = _b.sent();
|
|
795
|
+
return [4 /*yield*/, response.text()];
|
|
796
|
+
case 2:
|
|
797
|
+
text = _b.sent();
|
|
798
|
+
r = /^.*<script.*\/(main.*\.js).*$/gim.exec(text);
|
|
799
|
+
if (!r || r.length < 2) {
|
|
800
|
+
return [2 /*return*/, false];
|
|
801
|
+
}
|
|
802
|
+
remoteMainScript = r.length > 1 ? r[1] : null;
|
|
803
|
+
if (remoteMainScript === null) {
|
|
804
|
+
return [2 /*return*/, false];
|
|
805
|
+
}
|
|
806
|
+
localMainScript = null;
|
|
807
|
+
scripts = document.body.getElementsByTagName('script');
|
|
808
|
+
try {
|
|
809
|
+
for (scripts_1 = __values(scripts), scripts_1_1 = scripts_1.next(); !scripts_1_1.done; scripts_1_1 = scripts_1.next()) {
|
|
810
|
+
script = scripts_1_1.value;
|
|
811
|
+
rl = /^.*\/(main.*\.js).*$/gim.exec(script.src);
|
|
812
|
+
if (!rl || rl.length < 2) {
|
|
813
|
+
continue;
|
|
814
|
+
}
|
|
815
|
+
localMainScript = rl[1];
|
|
816
|
+
break;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
820
|
+
finally {
|
|
821
|
+
try {
|
|
822
|
+
if (scripts_1_1 && !scripts_1_1.done && (_a = scripts_1.return)) _a.call(scripts_1);
|
|
823
|
+
}
|
|
824
|
+
finally { if (e_7) throw e_7.error; }
|
|
825
|
+
}
|
|
826
|
+
if (localMainScript === null) {
|
|
827
|
+
return [2 /*return*/, false];
|
|
828
|
+
}
|
|
829
|
+
return [2 /*return*/, remoteMainScript !== localMainScript];
|
|
830
|
+
case 3:
|
|
831
|
+
err_1 = _b.sent();
|
|
832
|
+
console.log(err_1);
|
|
833
|
+
return [2 /*return*/, false];
|
|
834
|
+
case 4: return [2 /*return*/];
|
|
835
|
+
}
|
|
836
|
+
});
|
|
837
|
+
});
|
|
838
|
+
};
|
|
839
|
+
XUtils.reload = function () {
|
|
840
|
+
// data in session may not correspond with new structures in new version
|
|
841
|
+
// e.g. if we add new column to XLazyDataTable, filter operator/value for this column new column is missing in data from session and application will crash
|
|
842
|
+
// simple solution is to clear session
|
|
843
|
+
XUtils.clearStorage();
|
|
844
|
+
// page reload (like pressing F5 or Enter on url bar)
|
|
845
|
+
// warning - if user has typed some data in form, the data will be lost
|
|
846
|
+
window.location.reload();
|
|
847
|
+
};
|
|
752
848
|
XUtils.dropdownEmptyOptionValue = " ";
|
|
753
849
|
XUtils.xBackendUrl = undefined;
|
|
754
850
|
// nacachovany XToken - na rozlicnych miestach potrebujeme vediet uzivatela
|
|
@@ -766,6 +862,8 @@ var XUtils = /** @class */ (function () {
|
|
|
766
862
|
XUtils.remSize = null;
|
|
767
863
|
// konstanty (zatial takto jednoducho)
|
|
768
864
|
XUtils.FIELD_LABEL_WIDTH = '10.5rem';
|
|
865
|
+
XUtils.lastVersionCheckTimestamp = null;
|
|
866
|
+
XUtils.VERSION_CHECK_PERIOD = 10 * 60 * 1000; // 10 minutes in milliseconds
|
|
769
867
|
return XUtils;
|
|
770
868
|
}());
|
|
771
869
|
exports.XUtils = XUtils;
|