@koalarx/ui 13.2.2 → 13.2.5
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/core/esm2020/lib/services/api-requester/koala.api-requester.base.mjs +27 -6
- package/core/esm2020/lib/services/api-requester/koala.api-requester.cache.mjs +20 -0
- package/core/fesm2015/koalarx-ui-core.mjs +43 -4
- package/core/fesm2015/koalarx-ui-core.mjs.map +1 -1
- package/core/fesm2020/koalarx-ui-core.mjs +42 -4
- package/core/fesm2020/koalarx-ui-core.mjs.map +1 -1
- package/core/lib/services/api-requester/koala.api-requester.base.d.ts +11 -8
- package/core/lib/services/api-requester/koala.api-requester.cache.d.ts +10 -0
- package/list/esm2020/lib/koala.list-config.interface.mjs +1 -1
- package/list/esm2020/lib/list-builder/list.builder.mjs +9 -1
- package/list/esm2020/lib/list.abstract.mjs +2 -5
- package/list/esm2020/lib/list.component.mjs +2 -1
- package/list/fesm2015/koalarx-ui-list.mjs +12 -5
- package/list/fesm2015/koalarx-ui-list.mjs.map +1 -1
- package/list/fesm2020/koalarx-ui-list.mjs +10 -4
- package/list/fesm2020/koalarx-ui-list.mjs.map +1 -1
- package/list/lib/koala.list-config.interface.d.ts +1 -0
- package/list/lib/list-builder/list.builder.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1243,21 +1243,41 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
1243
1243
|
args: [{ providedIn: "root" }]
|
|
1244
1244
|
}], ctorParameters: function () { return [{ type: i1$2.HttpClient }, { type: KoalaOAuth2Service }]; } });
|
|
1245
1245
|
|
|
1246
|
+
class KoalaApiRequesterCache {
|
|
1247
|
+
static setInCache(cache) {
|
|
1248
|
+
const index = koala(this.cache).array().getIndex('name', cache.name);
|
|
1249
|
+
if (index >= 0) {
|
|
1250
|
+
this.cache[index] = cache;
|
|
1251
|
+
}
|
|
1252
|
+
else {
|
|
1253
|
+
this.cache.push(cache);
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
static getCache(name) {
|
|
1257
|
+
return this.cache.find(item => item.name === name)?.data;
|
|
1258
|
+
}
|
|
1259
|
+
static hasCache(name) {
|
|
1260
|
+
return !!this.getCache(name);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
KoalaApiRequesterCache.cache = [];
|
|
1264
|
+
|
|
1246
1265
|
class KoalaApiRequesterBase {
|
|
1247
|
-
constructor(koalaService, endpoint, environmentNameToEndpointApi = 'endpointApi', isMockup = false) {
|
|
1266
|
+
constructor(koalaService, endpoint, enableCache = false, environmentNameToEndpointApi = 'endpointApi', isMockup = false) {
|
|
1248
1267
|
this.koalaService = koalaService;
|
|
1249
1268
|
this.endpoint = endpoint;
|
|
1269
|
+
this.enableCache = enableCache;
|
|
1250
1270
|
koalaService.apiUrl = KoalaEnvironment.environment?.[environmentNameToEndpointApi];
|
|
1251
1271
|
koalaService.isMockup = isMockup;
|
|
1252
1272
|
}
|
|
1253
1273
|
getAll(filter) {
|
|
1254
|
-
return this.
|
|
1274
|
+
return this.request('get', this.endpoint, this.getParams(filter));
|
|
1255
1275
|
}
|
|
1256
1276
|
getById(id) {
|
|
1257
|
-
return this.
|
|
1277
|
+
return this.request('get', this.endpoint + '/' + id);
|
|
1258
1278
|
}
|
|
1259
1279
|
getBySomething(something) {
|
|
1260
|
-
return this.
|
|
1280
|
+
return this.request('get', this.endpoint + '/' + something);
|
|
1261
1281
|
}
|
|
1262
1282
|
save(data, id) {
|
|
1263
1283
|
return this.koalaService.request((id ? 'put' : 'post'), `${this.endpoint}${(id ? `/${id}` : '')}`, data);
|
|
@@ -1301,6 +1321,24 @@ class KoalaApiRequesterBase {
|
|
|
1301
1321
|
}
|
|
1302
1322
|
return filter ?? null;
|
|
1303
1323
|
}
|
|
1324
|
+
request(method, url, data = {}) {
|
|
1325
|
+
this.startCache(url);
|
|
1326
|
+
return this.koalaService
|
|
1327
|
+
.request(method, url, data)
|
|
1328
|
+
.pipe(map(response => {
|
|
1329
|
+
if (this.enableCache)
|
|
1330
|
+
KoalaApiRequesterCache.setInCache({ name: url, data: response });
|
|
1331
|
+
return response;
|
|
1332
|
+
}));
|
|
1333
|
+
}
|
|
1334
|
+
startCache(endpoint) {
|
|
1335
|
+
if (this.enableCache && KoalaApiRequesterCache.hasCache(endpoint)) {
|
|
1336
|
+
return new Observable(observe => {
|
|
1337
|
+
observe.next(KoalaApiRequesterCache.getCache(endpoint));
|
|
1338
|
+
observe.complete();
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1304
1342
|
}
|
|
1305
1343
|
|
|
1306
1344
|
class KoalaRequestService {
|