@sumaris-net/ngx-components 2.4.0-rc2 → 2.4.0-rc3
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/esm2020/src/app/core/services/storage/entities-storage.service.mjs +21 -19
- package/esm2020/src/app/shared/shared.module.mjs +3 -3
- package/fesm2015/sumaris-net.ngx-components.mjs +31 -19
- package/fesm2015/sumaris-net.ngx-components.mjs.map +1 -1
- package/fesm2020/sumaris-net.ngx-components.mjs +21 -19
- package/fesm2020/sumaris-net.ngx-components.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app/core/services/storage/entities-storage.service.d.ts +1 -1
|
@@ -12921,25 +12921,27 @@ class EntitiesStorage extends StartableService {
|
|
|
12921
12921
|
});
|
|
12922
12922
|
}
|
|
12923
12923
|
watchAll(entityName, variables, opts) {
|
|
12924
|
+
var _a;
|
|
12924
12925
|
// Make sure store is ready
|
|
12925
12926
|
if (!this.started) {
|
|
12926
12927
|
return defer(() => this.ready())
|
|
12927
12928
|
.pipe(switchMap(() => this.watchAll(entityName, variables, opts))); // Loop
|
|
12928
12929
|
}
|
|
12929
|
-
this.progressBarService.increase();
|
|
12930
|
+
(_a = this.progressBarService) === null || _a === void 0 ? void 0 : _a.increase();
|
|
12930
12931
|
const storeName = variables && variables.trash ? (EntitiesStorage.TRASH_PREFIX + entityName) : entityName;
|
|
12931
12932
|
const result = this.getEntityStore(storeName, { create: true })
|
|
12932
12933
|
.watchAll(variables, opts);
|
|
12933
|
-
result.pipe(first()).subscribe(() => this.progressBarService.decrease());
|
|
12934
|
+
result.pipe(first()).subscribe(() => { var _a; return (_a = this.progressBarService) === null || _a === void 0 ? void 0 : _a.decrease(); });
|
|
12934
12935
|
return result;
|
|
12935
12936
|
}
|
|
12936
12937
|
loadAll(entityName, variables, opts) {
|
|
12938
|
+
var _a, _b;
|
|
12937
12939
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12938
12940
|
// Make sure store is ready
|
|
12939
12941
|
if (!this.started)
|
|
12940
12942
|
yield this.ready();
|
|
12941
12943
|
try {
|
|
12942
|
-
this.progressBarService.increase();
|
|
12944
|
+
(_a = this.progressBarService) === null || _a === void 0 ? void 0 : _a.increase();
|
|
12943
12945
|
if (this._debug)
|
|
12944
12946
|
console.debug(`[entities-storage] Loading ${entityName}...`);
|
|
12945
12947
|
const entityStore = this.getEntityStore(entityName, { create: false });
|
|
@@ -12948,22 +12950,23 @@ class EntitiesStorage extends StartableService {
|
|
|
12948
12950
|
return entityStore.loadAll(variables, opts);
|
|
12949
12951
|
}
|
|
12950
12952
|
finally {
|
|
12951
|
-
this.progressBarService.decrease();
|
|
12953
|
+
(_b = this.progressBarService) === null || _b === void 0 ? void 0 : _b.decrease();
|
|
12952
12954
|
}
|
|
12953
12955
|
});
|
|
12954
12956
|
}
|
|
12955
12957
|
load(id, entityName, opts) {
|
|
12958
|
+
var _a, _b;
|
|
12956
12959
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12957
12960
|
yield this.ready();
|
|
12958
12961
|
try {
|
|
12959
|
-
this.progressBarService.increase();
|
|
12962
|
+
(_a = this.progressBarService) === null || _a === void 0 ? void 0 : _a.increase();
|
|
12960
12963
|
const entityStore = this.getEntityStore(entityName, { create: false });
|
|
12961
12964
|
if (!entityStore)
|
|
12962
12965
|
return undefined;
|
|
12963
12966
|
return yield entityStore.load(id, opts);
|
|
12964
12967
|
}
|
|
12965
12968
|
finally {
|
|
12966
|
-
this.progressBarService.decrease();
|
|
12969
|
+
(_b = this.progressBarService) === null || _b === void 0 ? void 0 : _b.decrease();
|
|
12967
12970
|
}
|
|
12968
12971
|
});
|
|
12969
12972
|
}
|
|
@@ -12996,13 +12999,14 @@ class EntitiesStorage extends StartableService {
|
|
|
12996
12999
|
});
|
|
12997
13000
|
}
|
|
12998
13001
|
save(entity, opts) {
|
|
13002
|
+
var _a, _b;
|
|
12999
13003
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13000
13004
|
if (!entity)
|
|
13001
13005
|
return; // skip
|
|
13002
13006
|
if (!this.started)
|
|
13003
13007
|
yield this.ready();
|
|
13004
13008
|
try {
|
|
13005
|
-
this.progressBarService.increase();
|
|
13009
|
+
(_a = this.progressBarService) === null || _a === void 0 ? void 0 : _a.increase();
|
|
13006
13010
|
this._dirty = true;
|
|
13007
13011
|
const storeName = opts && opts.entityName || this.detectEntityName(entity);
|
|
13008
13012
|
this.getEntityStore(storeName)
|
|
@@ -13012,24 +13016,25 @@ class EntitiesStorage extends StartableService {
|
|
|
13012
13016
|
return entity;
|
|
13013
13017
|
}
|
|
13014
13018
|
finally {
|
|
13015
|
-
this.progressBarService.decrease();
|
|
13019
|
+
(_b = this.progressBarService) === null || _b === void 0 ? void 0 : _b.decrease();
|
|
13016
13020
|
}
|
|
13017
13021
|
});
|
|
13018
13022
|
}
|
|
13019
13023
|
saveAll(entities, opts) {
|
|
13024
|
+
var _a, _b;
|
|
13020
13025
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13021
13026
|
if (isEmptyArray(entities) && (!opts || opts.reset !== true))
|
|
13022
13027
|
return entities; // Skip (nothing to save)
|
|
13023
13028
|
if (!this.started)
|
|
13024
13029
|
yield this.ready();
|
|
13025
13030
|
try {
|
|
13026
|
-
this.progressBarService.increase();
|
|
13031
|
+
(_a = this.progressBarService) === null || _a === void 0 ? void 0 : _a.increase();
|
|
13027
13032
|
this._dirty = true;
|
|
13028
13033
|
const entityName = opts && opts.entityName || this.detectEntityName(entities[0]);
|
|
13029
13034
|
return this.getEntityStore(entityName).saveAll(entities, opts);
|
|
13030
13035
|
}
|
|
13031
13036
|
finally {
|
|
13032
|
-
this.progressBarService.decrease();
|
|
13037
|
+
(_b = this.progressBarService) === null || _b === void 0 ? void 0 : _b.decrease();
|
|
13033
13038
|
}
|
|
13034
13039
|
});
|
|
13035
13040
|
}
|
|
@@ -13043,6 +13048,7 @@ class EntitiesStorage extends StartableService {
|
|
|
13043
13048
|
});
|
|
13044
13049
|
}
|
|
13045
13050
|
deleteById(id, opts) {
|
|
13051
|
+
var _a, _b;
|
|
13046
13052
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13047
13053
|
if (!this.started)
|
|
13048
13054
|
yield this.ready();
|
|
@@ -13050,7 +13056,7 @@ class EntitiesStorage extends StartableService {
|
|
|
13050
13056
|
throw new Error('Missing argument \'opts\' or \'entityName\'');
|
|
13051
13057
|
//if (id >= 0) throw new Error('Invalid id a local entity (not a negative number): ' + id);
|
|
13052
13058
|
try {
|
|
13053
|
-
this.progressBarService.increase();
|
|
13059
|
+
(_a = this.progressBarService) === null || _a === void 0 ? void 0 : _a.increase();
|
|
13054
13060
|
const entityStore = this.getEntityStore(opts.entityName, { create: false });
|
|
13055
13061
|
if (!entityStore)
|
|
13056
13062
|
return undefined;
|
|
@@ -13065,18 +13071,19 @@ class EntitiesStorage extends StartableService {
|
|
|
13065
13071
|
return deletedEntity;
|
|
13066
13072
|
}
|
|
13067
13073
|
finally {
|
|
13068
|
-
this.progressBarService.decrease();
|
|
13074
|
+
(_b = this.progressBarService) === null || _b === void 0 ? void 0 : _b.decrease();
|
|
13069
13075
|
}
|
|
13070
13076
|
});
|
|
13071
13077
|
}
|
|
13072
13078
|
deleteMany(ids, opts) {
|
|
13079
|
+
var _a, _b;
|
|
13073
13080
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13074
13081
|
if (!this.started)
|
|
13075
13082
|
yield this.ready();
|
|
13076
13083
|
if (!opts || isNilOrBlank(opts.entityName))
|
|
13077
13084
|
throw new Error('Missing argument \'opts\' or \'opts.entityName\'');
|
|
13078
13085
|
try {
|
|
13079
|
-
this.progressBarService.increase();
|
|
13086
|
+
(_a = this.progressBarService) === null || _a === void 0 ? void 0 : _a.increase();
|
|
13080
13087
|
const entityStore = this.getEntityStore(opts.entityName, { create: false });
|
|
13081
13088
|
if (!entityStore)
|
|
13082
13089
|
return undefined;
|
|
@@ -13092,7 +13099,7 @@ class EntitiesStorage extends StartableService {
|
|
|
13092
13099
|
return deletedEntities;
|
|
13093
13100
|
}
|
|
13094
13101
|
finally {
|
|
13095
|
-
this.progressBarService.decrease();
|
|
13102
|
+
(_b = this.progressBarService) === null || _b === void 0 ? void 0 : _b.decrease();
|
|
13096
13103
|
}
|
|
13097
13104
|
});
|
|
13098
13105
|
}
|
|
@@ -13226,6 +13233,7 @@ class EntitiesStorage extends StartableService {
|
|
|
13226
13233
|
});
|
|
13227
13234
|
}
|
|
13228
13235
|
storeLocally(opts = { skipIfPristine: true }) {
|
|
13236
|
+
var _a;
|
|
13229
13237
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13230
13238
|
if (opts.skipIfPristine && !this.dirty)
|
|
13231
13239
|
return; // skip
|
|
@@ -13238,7 +13246,7 @@ class EntitiesStorage extends StartableService {
|
|
|
13238
13246
|
}
|
|
13239
13247
|
this._saving = true;
|
|
13240
13248
|
this._dirty = false;
|
|
13241
|
-
this.progressBarService.increase();
|
|
13249
|
+
(_a = this.progressBarService) === null || _a === void 0 ? void 0 : _a.increase();
|
|
13242
13250
|
const entityNames = this._data && Object.keys(this._data) || [];
|
|
13243
13251
|
const now = Date.now();
|
|
13244
13252
|
if (this._debug)
|
|
@@ -13272,14 +13280,16 @@ class EntitiesStorage extends StartableService {
|
|
|
13272
13280
|
this.storage.set(ENTITIES_STORAGE_KEY_PREFIX, entityNames);
|
|
13273
13281
|
})
|
|
13274
13282
|
.then(() => {
|
|
13283
|
+
var _a;
|
|
13275
13284
|
if (this._debug)
|
|
13276
13285
|
console.debug(`[entities-storage] Persisting [OK] ${entityNames.length} stores saved in ${Date.now() - now}ms...`);
|
|
13277
13286
|
this._saving = false;
|
|
13278
|
-
this.progressBarService.decrease();
|
|
13287
|
+
(_a = this.progressBarService) === null || _a === void 0 ? void 0 : _a.decrease();
|
|
13279
13288
|
})
|
|
13280
13289
|
.catch(err => {
|
|
13290
|
+
var _a;
|
|
13281
13291
|
this._saving = false;
|
|
13282
|
-
this.progressBarService.decrease();
|
|
13292
|
+
(_a = this.progressBarService) === null || _a === void 0 ? void 0 : _a.decrease();
|
|
13283
13293
|
if (currentEntityName) {
|
|
13284
13294
|
console.error(`[entities-storage] Error while persisting ${currentEntityName}`, err);
|
|
13285
13295
|
}
|
|
@@ -13293,13 +13303,15 @@ class EntitiesStorage extends StartableService {
|
|
|
13293
13303
|
}
|
|
13294
13304
|
EntitiesStorage.TRASH_PREFIX = 'Trash#';
|
|
13295
13305
|
EntitiesStorage.REMOTE_PREFIX = 'Remote#';
|
|
13296
|
-
EntitiesStorage.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: EntitiesStorage, deps: [{ token: i2.Platform }, { token: APP_PROGRESS_BAR_SERVICE }, { token: APP_STORAGE }, { token: ENVIRONMENT }, { token: APP_LOCAL_STORAGE_TYPE_POLICIES, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
13306
|
+
EntitiesStorage.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: EntitiesStorage, deps: [{ token: i2.Platform }, { token: APP_PROGRESS_BAR_SERVICE, optional: true }, { token: APP_STORAGE }, { token: ENVIRONMENT }, { token: APP_LOCAL_STORAGE_TYPE_POLICIES, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
13297
13307
|
EntitiesStorage.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: EntitiesStorage, providedIn: 'root' });
|
|
13298
13308
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: EntitiesStorage, decorators: [{
|
|
13299
13309
|
type: Injectable,
|
|
13300
13310
|
args: [{ providedIn: 'root' }]
|
|
13301
13311
|
}], ctorParameters: function () {
|
|
13302
13312
|
return [{ type: i2.Platform }, { type: undefined, decorators: [{
|
|
13313
|
+
type: Optional
|
|
13314
|
+
}, {
|
|
13303
13315
|
type: Inject,
|
|
13304
13316
|
args: [APP_PROGRESS_BAR_SERVICE]
|
|
13305
13317
|
}] }, { type: undefined, decorators: [{
|
|
@@ -19332,7 +19344,7 @@ class SharedModule {
|
|
|
19332
19344
|
{ provide: ENVIRONMENT, useValue: environment },
|
|
19333
19345
|
// { provide: StorageService, useClass: StorageService, deps: [ENVIRONMENT]},
|
|
19334
19346
|
{ provide: APP_STORAGE, useExisting: StorageService },
|
|
19335
|
-
{ provide: APP_PROGRESS_BAR_SERVICE, useClass: ProgressBarService },
|
|
19347
|
+
// { provide: APP_PROGRESS_BAR_SERVICE, useClass: ProgressBarService },
|
|
19336
19348
|
StorageService,
|
|
19337
19349
|
AudioProvider,
|
|
19338
19350
|
FileService,
|