@zeedhi/common 1.65.1 → 1.67.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/zd-common.esm.js +45 -2
- package/dist/zd-common.umd.js +45 -1
- package/package.json +2 -2
- package/types/components/zd-frame/frame.d.ts +1 -0
- package/types/components/zd-frame/interfaces.d.ts +1 -0
- package/types/services/index.d.ts +1 -0
- package/types/services/zd-json-cache/json-cache-service.d.ts +12 -0
package/dist/zd-common.esm.js
CHANGED
|
@@ -2948,6 +2948,37 @@ class LoadingService {
|
|
|
2948
2948
|
}
|
|
2949
2949
|
}
|
|
2950
2950
|
|
|
2951
|
+
class JsonCacheService {
|
|
2952
|
+
static saveJSONCache(jsonCollection) {
|
|
2953
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2954
|
+
const jsonCollectionInCache = jsonCollection.map((jsonItem) => __awaiter(this, void 0, void 0, function* () {
|
|
2955
|
+
const { path } = jsonItem;
|
|
2956
|
+
const metadata = yield Metadata.get(path, true);
|
|
2957
|
+
localStorage.setItem(path, JSON.stringify(metadata));
|
|
2958
|
+
}));
|
|
2959
|
+
yield Promise.all(jsonCollectionInCache);
|
|
2960
|
+
});
|
|
2961
|
+
}
|
|
2962
|
+
static getJSONCache(path) {
|
|
2963
|
+
const getMetadaFromCache = localStorage.getItem(path);
|
|
2964
|
+
let metadataValueReturn = false;
|
|
2965
|
+
if (typeof getMetadaFromCache === 'string') {
|
|
2966
|
+
metadataValueReturn = JSON.parse(getMetadaFromCache);
|
|
2967
|
+
}
|
|
2968
|
+
return metadataValueReturn;
|
|
2969
|
+
}
|
|
2970
|
+
static clearJSONCache(jsonCollection) {
|
|
2971
|
+
jsonCollection.map((jsonItem) => __awaiter(this, void 0, void 0, function* () {
|
|
2972
|
+
const { path } = jsonItem;
|
|
2973
|
+
localStorage.removeItem(path);
|
|
2974
|
+
}));
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
/**
|
|
2978
|
+
* jsons collection
|
|
2979
|
+
*/
|
|
2980
|
+
JsonCacheService.jsonCollection = [];
|
|
2981
|
+
|
|
2951
2982
|
/**
|
|
2952
2983
|
* Base class for Dashboard component.
|
|
2953
2984
|
*/
|
|
@@ -4525,6 +4556,7 @@ class Frame extends ComponentRender {
|
|
|
4525
4556
|
this.overrideNamedProps = {};
|
|
4526
4557
|
this.path = '';
|
|
4527
4558
|
this.cache = false;
|
|
4559
|
+
this.JSONCache = false;
|
|
4528
4560
|
this.cacheDuration = 2 * 60 * 60 * 1000;
|
|
4529
4561
|
this.height = 'auto';
|
|
4530
4562
|
this.maxHeight = 'none';
|
|
@@ -4536,6 +4568,7 @@ class Frame extends ComponentRender {
|
|
|
4536
4568
|
this.override = props.override || this.override;
|
|
4537
4569
|
this.overrideNamedProps = props.overrideNamedProps || this.overrideNamedProps;
|
|
4538
4570
|
this.cache = props.cache || this.cache;
|
|
4571
|
+
this.JSONCache = this.getInitValue('JSONCache', props.JSONCache, this.JSONCache);
|
|
4539
4572
|
this.cacheDuration = this.getInitValue('cacheDuration', props.cacheDuration, this.cacheDuration);
|
|
4540
4573
|
this.height = this.getInitValue('height', props.height, this.height);
|
|
4541
4574
|
this.minHeight = this.getInitValue('minHeight', props.minHeight, this.minHeight);
|
|
@@ -4547,8 +4580,18 @@ class Frame extends ComponentRender {
|
|
|
4547
4580
|
}
|
|
4548
4581
|
getMetadata() {
|
|
4549
4582
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4583
|
+
let page;
|
|
4550
4584
|
try {
|
|
4551
|
-
|
|
4585
|
+
if (this.JSONCache) {
|
|
4586
|
+
page = JsonCacheService.getJSONCache(this.path);
|
|
4587
|
+
if (page === false) {
|
|
4588
|
+
yield JsonCacheService.saveJSONCache([{ path: this.path }]);
|
|
4589
|
+
page = yield this.requestPage();
|
|
4590
|
+
}
|
|
4591
|
+
}
|
|
4592
|
+
else {
|
|
4593
|
+
page = yield this.requestPage();
|
|
4594
|
+
}
|
|
4552
4595
|
if (typeof page !== 'object')
|
|
4553
4596
|
throw new Error();
|
|
4554
4597
|
this.metadata = merge(page, this.override);
|
|
@@ -13299,4 +13342,4 @@ const AutoNumeric = require('@zeedhi/autonumeric/dist/autoNumeric');
|
|
|
13299
13342
|
const packageContent = require('../package.json');
|
|
13300
13343
|
VersionService.addPackageVersion(packageContent.name, packageContent.version);
|
|
13301
13344
|
|
|
13302
|
-
export { Alert, AlertService, ApexChart, AutoNumeric, Badge, Breadcrumbs, Button, ButtonGroup, CSVReport, Card, Carousel, Checkbox, CheckboxMultiple, ChildNotFoundError, Chip, CodeEditor, Col, CollapseCard, Column, ColumnNotFoundError, Component, ComponentRender, Container, Currency, Dashboard, Date$1 as Date, DateRange, Dialog, DialogService, Divider, Dropdown, FileInput, Footer, Form, Frame, FramePage, Grid, GridColumn, GridColumnEditable, GridEditable, Header, Icon, Icons, Image, Increment, Input, Iterable, IterableColumnsButton, IterableColumnsButtonController, IterableComponentRender, IterablePageComponent, IterablePageInfo, IterablePageSize, IterablePagination, List, ListGroup, ListItem, Loading, LoadingService, Login, LoginButton, MasterDetail, Menu, MenuButton, MenuGroup, MenuLink, MenuSeparator, Modal, ModalCloseButton, ModalService, Month, Number$1 as Number, PDFReport, Password, Progress, Radio, RangeSlider, Report, Row, Search, Select, SelectMultiple, SelectTree, SelectTreeMultiple, SelectableList, SpeedDial, Steppers, SvgMap, Switch, Tab, Table, Tabs, Tag, Text, TextInput, Textarea, Time, Toggleable, Tooltip, Tree, TreeDataStructure, TreeGrid, TreeGridEditable, WatchURL, XLS2Report, XLS3Report, XLSReport, initTheme };
|
|
13345
|
+
export { Alert, AlertService, ApexChart, AutoNumeric, Badge, Breadcrumbs, Button, ButtonGroup, CSVReport, Card, Carousel, Checkbox, CheckboxMultiple, ChildNotFoundError, Chip, CodeEditor, Col, CollapseCard, Column, ColumnNotFoundError, Component, ComponentRender, Container, Currency, Dashboard, Date$1 as Date, DateRange, Dialog, DialogService, Divider, Dropdown, FileInput, Footer, Form, Frame, FramePage, Grid, GridColumn, GridColumnEditable, GridEditable, Header, Icon, Icons, Image, Increment, Input, Iterable, IterableColumnsButton, IterableColumnsButtonController, IterableComponentRender, IterablePageComponent, IterablePageInfo, IterablePageSize, IterablePagination, JsonCacheService, List, ListGroup, ListItem, Loading, LoadingService, Login, LoginButton, MasterDetail, Menu, MenuButton, MenuGroup, MenuLink, MenuSeparator, Modal, ModalCloseButton, ModalService, Month, Number$1 as Number, PDFReport, Password, Progress, Radio, RangeSlider, Report, Row, Search, Select, SelectMultiple, SelectTree, SelectTreeMultiple, SelectableList, SpeedDial, Steppers, SvgMap, Switch, Tab, Table, Tabs, Tag, Text, TextInput, Textarea, Time, Toggleable, Tooltip, Tree, TreeDataStructure, TreeGrid, TreeGridEditable, WatchURL, XLS2Report, XLS3Report, XLSReport, initTheme };
|
package/dist/zd-common.umd.js
CHANGED
|
@@ -2955,6 +2955,37 @@
|
|
|
2955
2955
|
}
|
|
2956
2956
|
}
|
|
2957
2957
|
|
|
2958
|
+
class JsonCacheService {
|
|
2959
|
+
static saveJSONCache(jsonCollection) {
|
|
2960
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2961
|
+
const jsonCollectionInCache = jsonCollection.map((jsonItem) => __awaiter(this, void 0, void 0, function* () {
|
|
2962
|
+
const { path } = jsonItem;
|
|
2963
|
+
const metadata = yield core.Metadata.get(path, true);
|
|
2964
|
+
localStorage.setItem(path, JSON.stringify(metadata));
|
|
2965
|
+
}));
|
|
2966
|
+
yield Promise.all(jsonCollectionInCache);
|
|
2967
|
+
});
|
|
2968
|
+
}
|
|
2969
|
+
static getJSONCache(path) {
|
|
2970
|
+
const getMetadaFromCache = localStorage.getItem(path);
|
|
2971
|
+
let metadataValueReturn = false;
|
|
2972
|
+
if (typeof getMetadaFromCache === 'string') {
|
|
2973
|
+
metadataValueReturn = JSON.parse(getMetadaFromCache);
|
|
2974
|
+
}
|
|
2975
|
+
return metadataValueReturn;
|
|
2976
|
+
}
|
|
2977
|
+
static clearJSONCache(jsonCollection) {
|
|
2978
|
+
jsonCollection.map((jsonItem) => __awaiter(this, void 0, void 0, function* () {
|
|
2979
|
+
const { path } = jsonItem;
|
|
2980
|
+
localStorage.removeItem(path);
|
|
2981
|
+
}));
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
/**
|
|
2985
|
+
* jsons collection
|
|
2986
|
+
*/
|
|
2987
|
+
JsonCacheService.jsonCollection = [];
|
|
2988
|
+
|
|
2958
2989
|
/**
|
|
2959
2990
|
* Base class for Dashboard component.
|
|
2960
2991
|
*/
|
|
@@ -4532,6 +4563,7 @@
|
|
|
4532
4563
|
this.overrideNamedProps = {};
|
|
4533
4564
|
this.path = '';
|
|
4534
4565
|
this.cache = false;
|
|
4566
|
+
this.JSONCache = false;
|
|
4535
4567
|
this.cacheDuration = 2 * 60 * 60 * 1000;
|
|
4536
4568
|
this.height = 'auto';
|
|
4537
4569
|
this.maxHeight = 'none';
|
|
@@ -4543,6 +4575,7 @@
|
|
|
4543
4575
|
this.override = props.override || this.override;
|
|
4544
4576
|
this.overrideNamedProps = props.overrideNamedProps || this.overrideNamedProps;
|
|
4545
4577
|
this.cache = props.cache || this.cache;
|
|
4578
|
+
this.JSONCache = this.getInitValue('JSONCache', props.JSONCache, this.JSONCache);
|
|
4546
4579
|
this.cacheDuration = this.getInitValue('cacheDuration', props.cacheDuration, this.cacheDuration);
|
|
4547
4580
|
this.height = this.getInitValue('height', props.height, this.height);
|
|
4548
4581
|
this.minHeight = this.getInitValue('minHeight', props.minHeight, this.minHeight);
|
|
@@ -4554,8 +4587,18 @@
|
|
|
4554
4587
|
}
|
|
4555
4588
|
getMetadata() {
|
|
4556
4589
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4590
|
+
let page;
|
|
4557
4591
|
try {
|
|
4558
|
-
|
|
4592
|
+
if (this.JSONCache) {
|
|
4593
|
+
page = JsonCacheService.getJSONCache(this.path);
|
|
4594
|
+
if (page === false) {
|
|
4595
|
+
yield JsonCacheService.saveJSONCache([{ path: this.path }]);
|
|
4596
|
+
page = yield this.requestPage();
|
|
4597
|
+
}
|
|
4598
|
+
}
|
|
4599
|
+
else {
|
|
4600
|
+
page = yield this.requestPage();
|
|
4601
|
+
}
|
|
4559
4602
|
if (typeof page !== 'object')
|
|
4560
4603
|
throw new Error();
|
|
4561
4604
|
this.metadata = merge__default["default"](page, this.override);
|
|
@@ -13360,6 +13403,7 @@
|
|
|
13360
13403
|
exports.IterablePageInfo = IterablePageInfo;
|
|
13361
13404
|
exports.IterablePageSize = IterablePageSize;
|
|
13362
13405
|
exports.IterablePagination = IterablePagination;
|
|
13406
|
+
exports.JsonCacheService = JsonCacheService;
|
|
13363
13407
|
exports.List = List;
|
|
13364
13408
|
exports.ListGroup = ListGroup;
|
|
13365
13409
|
exports.ListItem = ListItem;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.67.0",
|
|
4
4
|
"description": "Zeedhi Common",
|
|
5
5
|
"author": "Zeedhi <zeedhi@teknisa.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"lodash.times": "^4.3.2",
|
|
40
40
|
"mockdate": "^3.0.2"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "e073bdc1515fa3ab9da439f984a2a8f8fd572c9e"
|
|
43
43
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface IJSONObject {
|
|
2
|
+
path: string;
|
|
3
|
+
}
|
|
4
|
+
export declare class JsonCacheService {
|
|
5
|
+
/**
|
|
6
|
+
* jsons collection
|
|
7
|
+
*/
|
|
8
|
+
static jsonCollection: IJSONObject[];
|
|
9
|
+
static saveJSONCache(jsonCollection: IJSONObject[]): Promise<void>;
|
|
10
|
+
static getJSONCache(path: string): any;
|
|
11
|
+
static clearJSONCache(jsonCollection: IJSONObject[]): void;
|
|
12
|
+
}
|