@sumaris-net/ngx-components 1.9.5 → 1.9.8
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/bundles/sumaris-net.ngx-components.umd.js +42 -16
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/esm2015/src/app/core/services/account.service.js +38 -13
- package/esm2015/src/app/shared/services/startable-service.class.js +4 -1
- package/esm2015/src/environments/environment.class.js +1 -1
- package/esm2015/src/environments/environment.js +4 -3
- package/fesm2015/sumaris-net.ngx-components.js +36 -12
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/services/account.service.d.ts +9 -2
- package/src/app/shared/services/startable-service.class.d.ts +1 -0
- package/src/environments/environment.class.d.ts +2 -1
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -9414,6 +9414,9 @@
|
|
|
9414
9414
|
this._subscription = this._subscription || new rxjs.Subscription();
|
|
9415
9415
|
return this._subscription.add(sub);
|
|
9416
9416
|
};
|
|
9417
|
+
StartableService.prototype.unregisterSubscription = function (sub) {
|
|
9418
|
+
this._subscription.remove(sub);
|
|
9419
|
+
};
|
|
9417
9420
|
StartableService.prototype.ngOnStop = function () {
|
|
9418
9421
|
return __awaiter(this, void 0, void 0, function () {
|
|
9419
9422
|
return __generator(this, function (_a) {
|
|
@@ -10669,10 +10672,11 @@
|
|
|
10669
10672
|
},
|
|
10670
10673
|
account: {
|
|
10671
10674
|
enableListenChanges: true,
|
|
10672
|
-
|
|
10675
|
+
listenIntervalInSeconds: 30
|
|
10673
10676
|
},
|
|
10674
10677
|
entityEditor: {
|
|
10675
|
-
enableListenChanges:
|
|
10678
|
+
enableListenChanges: true,
|
|
10679
|
+
listenIntervalInSeconds: 30
|
|
10676
10680
|
}
|
|
10677
10681
|
});
|
|
10678
10682
|
|
|
@@ -15432,7 +15436,7 @@
|
|
|
15432
15436
|
};
|
|
15433
15437
|
var AccountService = /** @class */ (function (_super) {
|
|
15434
15438
|
__extends(AccountService, _super);
|
|
15435
|
-
function AccountService(cryptoService, network, graphql, settings, storage, file, environment) {
|
|
15439
|
+
function AccountService(cryptoService, network, graphql, settings, storage, file, translate, toastController, environment) {
|
|
15436
15440
|
var _this = _super.call(this, graphql, environment) || this;
|
|
15437
15441
|
_this.cryptoService = cryptoService;
|
|
15438
15442
|
_this.network = network;
|
|
@@ -15440,6 +15444,8 @@
|
|
|
15440
15444
|
_this.settings = settings;
|
|
15441
15445
|
_this.storage = storage;
|
|
15442
15446
|
_this.file = file;
|
|
15447
|
+
_this.translate = translate;
|
|
15448
|
+
_this.toastController = toastController;
|
|
15443
15449
|
_this.environment = environment;
|
|
15444
15450
|
_this.onLogin = new rxjs.Subject();
|
|
15445
15451
|
_this.onLogout = new rxjs.Subject();
|
|
@@ -15869,7 +15875,7 @@
|
|
|
15869
15875
|
};
|
|
15870
15876
|
AccountService.prototype.reload = function () {
|
|
15871
15877
|
return __awaiter(this, void 0, void 0, function () {
|
|
15872
|
-
var now;
|
|
15878
|
+
var now, wasLogin, error_6;
|
|
15873
15879
|
return __generator(this, function (_b) {
|
|
15874
15880
|
switch (_b.label) {
|
|
15875
15881
|
case 0:
|
|
@@ -15879,17 +15885,32 @@
|
|
|
15879
15885
|
throw new Error('Cannot check account in offline mode');
|
|
15880
15886
|
now = Date.now();
|
|
15881
15887
|
console.debug("[account] Reloading account...");
|
|
15882
|
-
|
|
15888
|
+
wasLogin = this.isLogin();
|
|
15889
|
+
_b.label = 1;
|
|
15883
15890
|
case 1:
|
|
15891
|
+
_b.trys.push([1, 4, , 8]);
|
|
15892
|
+
return [4 /*yield*/, this.loadData()];
|
|
15893
|
+
case 2:
|
|
15884
15894
|
_b.sent();
|
|
15885
15895
|
return [4 /*yield*/, this.saveLocally()];
|
|
15886
|
-
case
|
|
15896
|
+
case 3:
|
|
15887
15897
|
_b.sent();
|
|
15888
15898
|
console.debug("[account] Reloading account [OK] in " + (Date.now() - now) + "ms");
|
|
15889
15899
|
// Emit login event to subscribers
|
|
15890
15900
|
this.onLogin.next(this._data);
|
|
15891
15901
|
this.onChange.next(this._data);
|
|
15892
15902
|
return [2 /*return*/, this._data];
|
|
15903
|
+
case 4:
|
|
15904
|
+
error_6 = _b.sent();
|
|
15905
|
+
if (!(wasLogin && !this.isLogin())) return [3 /*break*/, 6];
|
|
15906
|
+
console.error("[account] Reloading account failed. Will force logout...", error_6);
|
|
15907
|
+
return [4 /*yield*/, this.logout()];
|
|
15908
|
+
case 5:
|
|
15909
|
+
_b.sent();
|
|
15910
|
+
return [3 /*break*/, 7];
|
|
15911
|
+
case 6: throw error_6;
|
|
15912
|
+
case 7: return [3 /*break*/, 8];
|
|
15913
|
+
case 8: return [2 /*return*/];
|
|
15893
15914
|
}
|
|
15894
15915
|
});
|
|
15895
15916
|
});
|
|
@@ -16188,7 +16209,7 @@
|
|
|
16188
16209
|
};
|
|
16189
16210
|
AccountService.prototype.loadData = function (opts) {
|
|
16190
16211
|
return __awaiter(this, void 0, void 0, function () {
|
|
16191
|
-
var account, settings,
|
|
16212
|
+
var account, settings, error_7;
|
|
16192
16213
|
return __generator(this, function (_b) {
|
|
16193
16214
|
switch (_b.label) {
|
|
16194
16215
|
case 0:
|
|
@@ -16225,11 +16246,11 @@
|
|
|
16225
16246
|
_b.label = 4;
|
|
16226
16247
|
case 4: return [2 /*return*/, this._data];
|
|
16227
16248
|
case 5:
|
|
16228
|
-
|
|
16249
|
+
error_7 = _b.sent();
|
|
16229
16250
|
this.resetData();
|
|
16230
|
-
if (
|
|
16231
|
-
throw
|
|
16232
|
-
console.error(
|
|
16251
|
+
if (error_7.code && error_7.message)
|
|
16252
|
+
throw error_7;
|
|
16253
|
+
console.error(error_7);
|
|
16233
16254
|
throw {
|
|
16234
16255
|
code: ErrorCodes$2.LOAD_ACCOUNT_ERROR,
|
|
16235
16256
|
message: 'ERROR.LOAD_ACCOUNT_ERROR'
|
|
@@ -16253,7 +16274,7 @@
|
|
|
16253
16274
|
};
|
|
16254
16275
|
AccountService.prototype.restoreLocally = function () {
|
|
16255
16276
|
return __awaiter(this, void 0, void 0, function () {
|
|
16256
|
-
var values, pubkey, token, seckey, canRemoteAuth,
|
|
16277
|
+
var values, pubkey, token, seckey, canRemoteAuth, error_8, jsonAccount, accountStr, account;
|
|
16257
16278
|
return __generator(this, function (_b) {
|
|
16258
16279
|
switch (_b.label) {
|
|
16259
16280
|
case 0: return [4 /*yield*/, Promise.all([
|
|
@@ -16291,7 +16312,7 @@
|
|
|
16291
16312
|
throw new Error('Authentication failed');
|
|
16292
16313
|
return [3 /*break*/, 5];
|
|
16293
16314
|
case 4:
|
|
16294
|
-
|
|
16315
|
+
error_8 = _b.sent();
|
|
16295
16316
|
// Offline feature are enable: continue in offline mode
|
|
16296
16317
|
if (this.settings.hasOfflineFeature()) {
|
|
16297
16318
|
console.warn('[account] Unable to authenticate on pod: forcing offline mode');
|
|
@@ -16300,7 +16321,7 @@
|
|
|
16300
16321
|
}
|
|
16301
16322
|
// No offline features enable (=offline mode not allowed)
|
|
16302
16323
|
else {
|
|
16303
|
-
console.error(
|
|
16324
|
+
console.error(error_8);
|
|
16304
16325
|
this.logout();
|
|
16305
16326
|
return [2 /*return*/];
|
|
16306
16327
|
}
|
|
@@ -16628,7 +16649,7 @@
|
|
|
16628
16649
|
if (this.network.offline)
|
|
16629
16650
|
throw new Error('Cannot watch account changes: network is offline.');
|
|
16630
16651
|
var variables = {
|
|
16631
|
-
interval: Math.max(0, (opts === null || opts === void 0 ? void 0 : opts.
|
|
16652
|
+
interval: Math.max(0, (opts === null || opts === void 0 ? void 0 : opts.intervalInSeconds) || ((_a = this.environment.account) === null || _a === void 0 ? void 0 : _a.listenIntervalInSeconds) || 0)
|
|
16632
16653
|
};
|
|
16633
16654
|
console.debug("[account] Watching remote changes, every " + variables.interval + "s");
|
|
16634
16655
|
return this.graphql.subscribe({
|
|
@@ -16663,9 +16684,12 @@
|
|
|
16663
16684
|
target.id = source.id || target.id;
|
|
16664
16685
|
target.updateDate = source.updateDate || target.updateDate;
|
|
16665
16686
|
};
|
|
16687
|
+
AccountService.prototype.showToast = function (opts) {
|
|
16688
|
+
return Toasts.show(this.toastController, this.translate, opts);
|
|
16689
|
+
};
|
|
16666
16690
|
return AccountService;
|
|
16667
16691
|
}(BaseGraphqlService));
|
|
16668
|
-
AccountService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function AccountService_Factory() { return new AccountService(i0__namespace.ɵɵinject(CryptoService), i0__namespace.ɵɵinject(NetworkService), i0__namespace.ɵɵinject(GraphqlService), i0__namespace.ɵɵinject(LocalSettingsService), i0__namespace.ɵɵinject(i3__namespace$1.Storage), i0__namespace.ɵɵinject(FileService), i0__namespace.ɵɵinject(ENVIRONMENT)); }, token: AccountService, providedIn: "root" });
|
|
16692
|
+
AccountService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function AccountService_Factory() { return new AccountService(i0__namespace.ɵɵinject(CryptoService), i0__namespace.ɵɵinject(NetworkService), i0__namespace.ɵɵinject(GraphqlService), i0__namespace.ɵɵinject(LocalSettingsService), i0__namespace.ɵɵinject(i3__namespace$1.Storage), i0__namespace.ɵɵinject(FileService), i0__namespace.ɵɵinject(i1__namespace$1.TranslateService, 8), i0__namespace.ɵɵinject(i1__namespace$4.ToastController, 8), i0__namespace.ɵɵinject(ENVIRONMENT)); }, token: AccountService, providedIn: "root" });
|
|
16669
16693
|
AccountService.decorators = [
|
|
16670
16694
|
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
16671
16695
|
];
|
|
@@ -16676,6 +16700,8 @@
|
|
|
16676
16700
|
{ type: LocalSettingsService },
|
|
16677
16701
|
{ type: i3$2.Storage },
|
|
16678
16702
|
{ type: FileService },
|
|
16703
|
+
{ type: i1$2.TranslateService, decorators: [{ type: i0.Optional }] },
|
|
16704
|
+
{ type: i1$5.ToastController, decorators: [{ type: i0.Optional }] },
|
|
16679
16705
|
{ type: undefined, decorators: [{ type: i0.Inject, args: [ENVIRONMENT,] }] }
|
|
16680
16706
|
]; };
|
|
16681
16707
|
var templateObject_1$4, templateObject_2$4, templateObject_3$3, templateObject_4$3, templateObject_5$2, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12;
|