@sumaris-net/ngx-components 0.28.2 → 1.0.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/bundles/sumaris-net.ngx-components.umd.js +369 -337
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +2 -2
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/doc/changelog.md +4 -0
- package/esm2015/src/app/core/account/account.js +4 -5
- package/esm2015/src/app/core/auth/form/form-auth.js +3 -4
- package/esm2015/src/app/core/form/form.class.js +24 -12
- package/esm2015/src/app/core/form/list.form.js +2 -3
- package/esm2015/src/app/core/form/properties.form.js +2 -3
- package/esm2015/src/app/core/graphql/graphql.service.js +5 -8
- package/esm2015/src/app/core/services/account.service.js +177 -188
- package/esm2015/src/app/core/services/base-entity-service.class.js +9 -7
- package/esm2015/src/app/core/services/base-graphql-service.class.js +7 -2
- package/esm2015/src/app/core/services/config.service.js +9 -54
- package/esm2015/src/app/core/services/model/account.model.js +1 -1
- package/esm2015/src/app/core/services/model/settings.model.js +29 -2
- package/esm2015/src/app/core/services/network.service.js +5 -7
- package/esm2015/src/app/core/services/storage/entities-storage.service.js +3 -6
- package/esm2015/src/app/core/settings/settings.page.js +3 -4
- package/esm2015/src/app/shared/services/startable-service.class.js +13 -2
- package/esm2015/src/app/shared/services/translate-context.service.js +38 -13
- package/fesm2015/sumaris-net.ngx-components.js +308 -296
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/account/account.d.ts +0 -1
- package/src/app/core/auth/form/form-auth.d.ts +0 -1
- package/src/app/core/form/form.class.d.ts +10 -2
- package/src/app/core/form/list.form.d.ts +0 -1
- package/src/app/core/form/properties.form.d.ts +0 -1
- package/src/app/core/graphql/graphql.service.d.ts +0 -1
- package/src/app/core/services/account.service.d.ts +8 -21
- package/src/app/core/services/base-entity-service.class.d.ts +1 -0
- package/src/app/core/services/base-graphql-service.class.d.ts +3 -2
- package/src/app/core/services/config.service.d.ts +2 -9
- package/src/app/core/services/model/settings.model.d.ts +2 -0
- package/src/app/core/services/network.service.d.ts +2 -2
- package/src/app/core/services/storage/entities-storage.service.d.ts +0 -1
- package/src/app/core/settings/settings.page.d.ts +0 -1
- package/src/app/shared/services/startable-service.class.d.ts +3 -1
- package/src/app/shared/services/translate-context.service.d.ts +10 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -2854,23 +2854,42 @@
|
|
|
2854
2854
|
TranslateContextService.prototype.get = function (key, context, interpolateParams) {
|
|
2855
2855
|
var _this = this;
|
|
2856
2856
|
// No context: do a normal translate
|
|
2857
|
-
if (!isNil(context))
|
|
2857
|
+
if (!key || !isNil(context))
|
|
2858
2858
|
return this.translate.get(key, interpolateParams);
|
|
2859
2859
|
// Compute a contextual i18n key, using the context as suffix
|
|
2860
|
-
var
|
|
2860
|
+
var contextualKeys = this.contextualKeys(key, context);
|
|
2861
2861
|
// Return the contextual translation, or default of not exists
|
|
2862
|
-
return this.translate.get(
|
|
2863
|
-
.pipe(operators.
|
|
2862
|
+
return this.translate.get(contextualKeys, interpolateParams)
|
|
2863
|
+
.pipe(operators.map(function (translations) { return _this.findFirstValid(contextualKeys, translations); }));
|
|
2864
2864
|
};
|
|
2865
2865
|
TranslateContextService.prototype.instant = function (key, context, interpolateParams) {
|
|
2866
2866
|
// No context: do a normal translate
|
|
2867
|
-
if (isNilOrBlank(context))
|
|
2867
|
+
if (!key || isNilOrBlank(context))
|
|
2868
2868
|
return this.translate.instant(key, interpolateParams);
|
|
2869
2869
|
// Compute a contextual i18n key, using the context as suffix
|
|
2870
|
-
var
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2870
|
+
var contextualKeys = this.contextualKeys(key, context);
|
|
2871
|
+
var translations = this.translate.instant(contextualKeys, interpolateParams);
|
|
2872
|
+
return this.findFirstValid(contextualKeys, translations);
|
|
2873
|
+
};
|
|
2874
|
+
/**
|
|
2875
|
+
* Compute contextual i18n keys, using the context as suffix.<br>
|
|
2876
|
+
* Suffix can be simple name (like 'aaa' - will return ['<key>.aaa']) or complexe (like 'aaa.bbb' - will return ['<key>.aaa.bbb', '<key>.aaa']
|
|
2877
|
+
*
|
|
2878
|
+
* @param key
|
|
2879
|
+
* @param context
|
|
2880
|
+
* @private
|
|
2881
|
+
*/
|
|
2882
|
+
TranslateContextService.prototype.contextualKeys = function (key, context) {
|
|
2883
|
+
var _this = this;
|
|
2884
|
+
return context.split('.')
|
|
2885
|
+
.filter(isNotNilOrBlank)
|
|
2886
|
+
.reduce(function (res, item) {
|
|
2887
|
+
var inheritedContext = res.length > 0 ? (res[res.length - 1] + '.') : '';
|
|
2888
|
+
return res.concat(inheritedContext + item);
|
|
2889
|
+
}, [])
|
|
2890
|
+
.reverse() // Start with children, ends with parent key
|
|
2891
|
+
.map(function (contextItem) { return _this.contextualKey(key, contextItem); })
|
|
2892
|
+
.concat(key);
|
|
2874
2893
|
};
|
|
2875
2894
|
/**
|
|
2876
2895
|
* Compute a contextual i18n key, using the context as suffix
|
|
@@ -2890,6 +2909,25 @@
|
|
|
2890
2909
|
? "" + context + key
|
|
2891
2910
|
: parts.slice(0, parts.length - 1).concat(context + parts[parts.length - 1]).join('.');
|
|
2892
2911
|
};
|
|
2912
|
+
TranslateContextService.prototype.findFirstValid = function (keys, translations) {
|
|
2913
|
+
var e_1, _a;
|
|
2914
|
+
try {
|
|
2915
|
+
// For eac contextual key: try to find translation, then use the first valid
|
|
2916
|
+
for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
|
|
2917
|
+
var key = keys_1_1.value;
|
|
2918
|
+
if (translations[key] !== key)
|
|
2919
|
+
return translations[key];
|
|
2920
|
+
}
|
|
2921
|
+
}
|
|
2922
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2923
|
+
finally {
|
|
2924
|
+
try {
|
|
2925
|
+
if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
|
|
2926
|
+
}
|
|
2927
|
+
finally { if (e_1) throw e_1.error; }
|
|
2928
|
+
}
|
|
2929
|
+
return translations[keys[keys.length - 1]]; // Return the last keys translation
|
|
2930
|
+
};
|
|
2893
2931
|
return TranslateContextService;
|
|
2894
2932
|
}());
|
|
2895
2933
|
TranslateContextService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function TranslateContextService_Factory() { return new TranslateContextService(i0__namespace.ɵɵinject(i1__namespace$1.TranslateService)); }, token: TranslateContextService, providedIn: "root" });
|
|
@@ -8662,6 +8700,9 @@
|
|
|
8662
8700
|
this._startByReadyFunction = true; // should start when calling ready() ?
|
|
8663
8701
|
this._data = null;
|
|
8664
8702
|
this._started = false;
|
|
8703
|
+
this._startPromise = null;
|
|
8704
|
+
this._startPrerequisite = null;
|
|
8705
|
+
this._subscription = null;
|
|
8665
8706
|
this._startPrerequisite = prerequisiteService
|
|
8666
8707
|
? function () { return prerequisiteService.ready(); }
|
|
8667
8708
|
: function () { return Promise.resolve(); };
|
|
@@ -8696,6 +8737,10 @@
|
|
|
8696
8737
|
switch (_a.label) {
|
|
8697
8738
|
case 0:
|
|
8698
8739
|
_a.trys.push([0, 2, , 3]);
|
|
8740
|
+
if (this._subscription) {
|
|
8741
|
+
this._subscription.unsubscribe();
|
|
8742
|
+
this._subscription = null;
|
|
8743
|
+
}
|
|
8699
8744
|
return [4 /*yield*/, this.ngOnStop()];
|
|
8700
8745
|
case 1:
|
|
8701
8746
|
_a.sent();
|
|
@@ -8758,6 +8803,10 @@
|
|
|
8758
8803
|
return waitFor(function () { return _this._started; })
|
|
8759
8804
|
.then(function () { return _this._data; });
|
|
8760
8805
|
};
|
|
8806
|
+
StartableService.prototype.registerSubscription = function (sub) {
|
|
8807
|
+
this._subscription = this._subscription || new rxjs.Subscription();
|
|
8808
|
+
return this._subscription.add(sub);
|
|
8809
|
+
};
|
|
8761
8810
|
StartableService.prototype.ngOnStop = function () {
|
|
8762
8811
|
return __awaiter(this, void 0, void 0, function () {
|
|
8763
8812
|
return __generator(this, function (_a) {
|
|
@@ -11311,7 +11360,6 @@
|
|
|
11311
11360
|
_this.onPeerChanges = _this.onStart.pipe(operators.map(function (peer) { return peer && peer.url; }), operators.filter(isNotNilOrBlank), operators.distinctUntilChanged());
|
|
11312
11361
|
_this.onNetworkStatusChanges = new rxjs.BehaviorSubject(null);
|
|
11313
11362
|
_this.onResetNetworkCache = new i0.EventEmitter(true);
|
|
11314
|
-
_this._subscription = new rxjs.Subscription();
|
|
11315
11363
|
_this._listeners = {};
|
|
11316
11364
|
_this._mobile = _this.platform.is('mobile');
|
|
11317
11365
|
if (_this._mobile) {
|
|
@@ -11524,7 +11572,8 @@
|
|
|
11524
11572
|
/**
|
|
11525
11573
|
* Check if the peer is alive
|
|
11526
11574
|
*
|
|
11527
|
-
* @param
|
|
11575
|
+
* @param peer
|
|
11576
|
+
* @param opts
|
|
11528
11577
|
*/
|
|
11529
11578
|
NetworkService.prototype.checkPeerAlive = function (peer, opts) {
|
|
11530
11579
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -11720,8 +11769,8 @@
|
|
|
11720
11769
|
this.startRefreshTimer();
|
|
11721
11770
|
// Listen for device network changes
|
|
11722
11771
|
if (this.network) {
|
|
11723
|
-
this.
|
|
11724
|
-
this.
|
|
11772
|
+
this.registerSubscription(this.network.onDisconnect().subscribe(function () { return _this.onDeviceConnectionChanged('none'); }));
|
|
11773
|
+
this.registerSubscription(this.network.onConnect().subscribe(function () { return _this.onDeviceConnectionChanged(_this.network.type); }));
|
|
11725
11774
|
}
|
|
11726
11775
|
return [2 /*return*/];
|
|
11727
11776
|
}
|
|
@@ -11736,8 +11785,6 @@
|
|
|
11736
11785
|
if (this._timerRefreshCondition() === false) {
|
|
11737
11786
|
this.stopRefreshTimer();
|
|
11738
11787
|
}
|
|
11739
|
-
this._subscription.unsubscribe();
|
|
11740
|
-
this._subscription = new rxjs.Subscription();
|
|
11741
11788
|
return [2 /*return*/];
|
|
11742
11789
|
});
|
|
11743
11790
|
});
|
|
@@ -12537,7 +12584,6 @@
|
|
|
12537
12584
|
_this.progressBarService = progressBarService;
|
|
12538
12585
|
_this.storage = storage;
|
|
12539
12586
|
_this.environment = environment;
|
|
12540
|
-
_this._subscription = new rxjs.Subscription();
|
|
12541
12587
|
_this._$save = new i0.EventEmitter(true);
|
|
12542
12588
|
_this._dirty = false;
|
|
12543
12589
|
_this._saving = false;
|
|
@@ -12986,7 +13032,7 @@
|
|
|
12986
13032
|
// Restore sequences
|
|
12987
13033
|
_a.sent();
|
|
12988
13034
|
// Start a save timer
|
|
12989
|
-
this.
|
|
13035
|
+
this.registerSubscription(rxjs.merge(this._$save, rxjs.timer(this._saveTimerPeriod, this._saveTimerPeriod))
|
|
12990
13036
|
.pipe(
|
|
12991
13037
|
// Avoid to many call (e.g. when $save AND timer are triggered
|
|
12992
13038
|
operators.throttleTime(this._saveTimerPeriod))
|
|
@@ -13002,8 +13048,6 @@
|
|
|
13002
13048
|
return __generator(this, function (_a) {
|
|
13003
13049
|
switch (_a.label) {
|
|
13004
13050
|
case 0:
|
|
13005
|
-
this._subscription.unsubscribe();
|
|
13006
|
-
this._subscription = new rxjs.Subscription();
|
|
13007
13051
|
if (!this.dirty) return [3 /*break*/, 2];
|
|
13008
13052
|
return [4 /*yield*/, this.storeLocally()];
|
|
13009
13053
|
case 1:
|
|
@@ -13221,8 +13265,36 @@
|
|
|
13221
13265
|
}
|
|
13222
13266
|
this.nonce = source.nonce;
|
|
13223
13267
|
};
|
|
13268
|
+
UserSettings.prototype.merge = function (source, includesProperties) {
|
|
13269
|
+
var _this = this;
|
|
13270
|
+
if (!source)
|
|
13271
|
+
return; // Skip
|
|
13272
|
+
// Reset content
|
|
13273
|
+
this.content = {};
|
|
13274
|
+
var hasChanges = false;
|
|
13275
|
+
// For each property of source object
|
|
13276
|
+
Object.keys(source)
|
|
13277
|
+
.forEach(function (key) {
|
|
13278
|
+
// If property exists in UserSettings class: store it directly
|
|
13279
|
+
if (UserSettings_1.SETTINGS_PROPERTIES.includes(key)) {
|
|
13280
|
+
if (!equals(_this[key], source[key])) {
|
|
13281
|
+
_this[key] = source[key];
|
|
13282
|
+
hasChanges = true;
|
|
13283
|
+
}
|
|
13284
|
+
}
|
|
13285
|
+
// Else, store property into the 'content' map
|
|
13286
|
+
else if (includesProperties && includesProperties.includes(key)) {
|
|
13287
|
+
if (!equals(_this.content[key], source[key])) {
|
|
13288
|
+
_this.content[key] = Object.assign({}, source[key]);
|
|
13289
|
+
hasChanges = true;
|
|
13290
|
+
}
|
|
13291
|
+
}
|
|
13292
|
+
});
|
|
13293
|
+
return hasChanges;
|
|
13294
|
+
};
|
|
13224
13295
|
return UserSettings;
|
|
13225
13296
|
}(Entity));
|
|
13297
|
+
exports.UserSettings.SETTINGS_PROPERTIES = ['locale', 'latLongFormat'];
|
|
13226
13298
|
exports.UserSettings = UserSettings_1 = __decorate([
|
|
13227
13299
|
EntityClass({ typename: 'UserSettingsVO' })
|
|
13228
13300
|
], exports.UserSettings);
|
|
@@ -13673,7 +13745,6 @@
|
|
|
13673
13745
|
_this.cryptoService = cryptoService;
|
|
13674
13746
|
_this.environment = environment;
|
|
13675
13747
|
_this.typePolicies = typePolicies;
|
|
13676
|
-
_this._subscription = new rxjs.Subscription();
|
|
13677
13748
|
_this.connectionParams = {};
|
|
13678
13749
|
_this.onNetworkError = new rxjs.Subject();
|
|
13679
13750
|
_this.customErrors = {};
|
|
@@ -14237,7 +14308,7 @@
|
|
|
14237
14308
|
debug: true
|
|
14238
14309
|
});
|
|
14239
14310
|
queueLink_1 = new QueueLink__default["default"]();
|
|
14240
|
-
this.
|
|
14311
|
+
this.registerSubscription(this._networkStatusChanged$
|
|
14241
14312
|
.subscribe(function (type) {
|
|
14242
14313
|
// Network is offline: start buffering into queue
|
|
14243
14314
|
if (type === 'none') {
|
|
@@ -14305,9 +14376,9 @@
|
|
|
14305
14376
|
return [3 /*break*/, 8];
|
|
14306
14377
|
case 8:
|
|
14307
14378
|
// Listen for network restart
|
|
14308
|
-
this.
|
|
14379
|
+
this.registerSubscription(this.network.on('start', function () { return _this.restart(); }));
|
|
14309
14380
|
// Listen for clear cache request, from network
|
|
14310
|
-
this.
|
|
14381
|
+
this.registerSubscription(this.network.on('resetCache', function () { return _this.clearCache(); }));
|
|
14311
14382
|
console.info('[graphql] Starting graphql [OK]');
|
|
14312
14383
|
return [2 /*return*/, client];
|
|
14313
14384
|
}
|
|
@@ -14320,8 +14391,6 @@
|
|
|
14320
14391
|
switch (_a.label) {
|
|
14321
14392
|
case 0:
|
|
14322
14393
|
console.info('[graphql] Stopping graphql service...');
|
|
14323
|
-
this._subscription.unsubscribe();
|
|
14324
|
-
this._subscription = new rxjs.Subscription();
|
|
14325
14394
|
return [4 /*yield*/, this.resetClient()];
|
|
14326
14395
|
case 1:
|
|
14327
14396
|
_a.sent();
|
|
@@ -14457,18 +14526,21 @@
|
|
|
14457
14526
|
return BaseGraphqlServiceOptions;
|
|
14458
14527
|
}());
|
|
14459
14528
|
// eslint-disable-next-line @angular-eslint/directive-class-suffix
|
|
14460
|
-
var BaseGraphqlService = /** @class */ (function () {
|
|
14529
|
+
var BaseGraphqlService = /** @class */ (function (_super) {
|
|
14530
|
+
__extends(BaseGraphqlService, _super);
|
|
14461
14531
|
function BaseGraphqlService(graphql, options) {
|
|
14462
|
-
this
|
|
14463
|
-
|
|
14532
|
+
var _this = _super.call(this, graphql) || this;
|
|
14533
|
+
_this.graphql = graphql;
|
|
14534
|
+
_this._mutableWatchQueries = [];
|
|
14464
14535
|
// Max updated queries, for this entity.
|
|
14465
14536
|
// - Can be override by subclasses (in constructor)
|
|
14466
14537
|
// - Use value -1 for no max size
|
|
14467
14538
|
// - Default value to 3, because it usually enough (e.g. OperationService and LandingService need at least 2)
|
|
14468
|
-
|
|
14539
|
+
_this._mutableWatchQueriesMaxCount = 3;
|
|
14469
14540
|
// for DEV only
|
|
14470
|
-
|
|
14471
|
-
|
|
14541
|
+
_this._debug = toBoolean(options && !options.production, !environment.production);
|
|
14542
|
+
_this._logPrefix = "[base-graphql-service] ";
|
|
14543
|
+
return _this;
|
|
14472
14544
|
}
|
|
14473
14545
|
BaseGraphqlService.prototype.mutableWatchQuery = function (opts) {
|
|
14474
14546
|
opts.fetchPolicy = opts.fetchPolicy || this.graphql.defaultFetchPolicy;
|
|
@@ -14666,8 +14738,11 @@
|
|
|
14666
14738
|
return { query: query, variables: variables };
|
|
14667
14739
|
});
|
|
14668
14740
|
};
|
|
14741
|
+
BaseGraphqlService.prototype.ngOnStart = function () {
|
|
14742
|
+
return Promise.resolve(null);
|
|
14743
|
+
};
|
|
14669
14744
|
return BaseGraphqlService;
|
|
14670
|
-
}());
|
|
14745
|
+
}(StartableService));
|
|
14671
14746
|
BaseGraphqlService.decorators = [
|
|
14672
14747
|
{ type: i0.Directive }
|
|
14673
14748
|
];
|
|
@@ -14720,18 +14795,16 @@
|
|
|
14720
14795
|
_this.onChange = new rxjs.Subject();
|
|
14721
14796
|
_this.onAuthTokenChange = new rxjs.Subject();
|
|
14722
14797
|
_this.onAuthBasicChange = new rxjs.Subject();
|
|
14723
|
-
_this.
|
|
14798
|
+
_this._cache = {
|
|
14724
14799
|
loaded: false,
|
|
14725
14800
|
keypair: null,
|
|
14726
14801
|
authToken: null,
|
|
14727
14802
|
authBasic: null,
|
|
14728
14803
|
pubkey: null,
|
|
14729
14804
|
mainProfile: null,
|
|
14730
|
-
account: null,
|
|
14731
14805
|
person: null,
|
|
14732
14806
|
department: null
|
|
14733
14807
|
};
|
|
14734
|
-
_this._started = false;
|
|
14735
14808
|
_this._$additionalFields = new rxjs.BehaviorSubject([]);
|
|
14736
14809
|
_this._tokenType$ = new rxjs.BehaviorSubject(undefined);
|
|
14737
14810
|
_this._debug = !environment.production;
|
|
@@ -14741,33 +14814,22 @@
|
|
|
14741
14814
|
// Send auth token to the graphql layer, when changed
|
|
14742
14815
|
_this.onAuthTokenChange.subscribe(function (token) { return _this.graphql.setAuthToken(token); });
|
|
14743
14816
|
_this.onAuthBasicChange.subscribe(function (basic) { return _this.graphql.setAuthBasic(basic); });
|
|
14744
|
-
// Listen graphql start (or restart)
|
|
14745
|
-
_this.graphql.onStart.subscribe(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
14746
|
-
return __generator(this, function (_b) {
|
|
14747
|
-
if (!this._started) {
|
|
14748
|
-
this.ready();
|
|
14749
|
-
}
|
|
14750
|
-
if (this._started && this.isLogin()) {
|
|
14751
|
-
console.debug('[account] Restarting, to retry to authenticate...');
|
|
14752
|
-
this.restart();
|
|
14753
|
-
}
|
|
14754
|
-
return [2 /*return*/];
|
|
14755
|
-
});
|
|
14756
|
-
}); });
|
|
14757
14817
|
// Force network to wait account service, after getting connection to the peer
|
|
14758
14818
|
_this.network.on('beforeTryOnlineFinish', function (online) { return __awaiter(_this, void 0, void 0, function () {
|
|
14759
14819
|
return __generator(this, function (_b) {
|
|
14760
14820
|
switch (_b.label) {
|
|
14761
14821
|
case 0:
|
|
14762
|
-
if (!(online && (!this.
|
|
14763
|
-
console.debug('[account] Force networkService.tryOnline() to wait, that account service is restarted...');
|
|
14764
|
-
//await this.stop();
|
|
14822
|
+
if (!(online && (!this.started || this.isLogin()))) return [3 /*break*/, 3];
|
|
14823
|
+
console.debug('[account] Force networkService.tryOnline() to wait, that graphql and account service is restarted...');
|
|
14765
14824
|
return [4 /*yield*/, sleep(500)];
|
|
14766
14825
|
case 1:
|
|
14767
|
-
|
|
14826
|
+
_b.sent(); // wait graphql service to be restarted
|
|
14827
|
+
if (!!this.started) return [3 /*break*/, 3];
|
|
14828
|
+
return [4 /*yield*/, this.ready()];
|
|
14829
|
+
case 2:
|
|
14768
14830
|
_b.sent();
|
|
14769
|
-
|
|
14770
|
-
case
|
|
14831
|
+
_b.label = 3;
|
|
14832
|
+
case 3: return [2 /*return*/];
|
|
14771
14833
|
}
|
|
14772
14834
|
});
|
|
14773
14835
|
}); });
|
|
@@ -14775,27 +14837,27 @@
|
|
|
14775
14837
|
}
|
|
14776
14838
|
Object.defineProperty(AccountService.prototype, "account", {
|
|
14777
14839
|
get: function () {
|
|
14778
|
-
return this.
|
|
14840
|
+
return this._cache.loaded ? this._data : undefined;
|
|
14779
14841
|
},
|
|
14780
14842
|
enumerable: false,
|
|
14781
14843
|
configurable: true
|
|
14782
14844
|
});
|
|
14783
14845
|
Object.defineProperty(AccountService.prototype, "person", {
|
|
14784
14846
|
get: function () {
|
|
14785
|
-
if (this.
|
|
14786
|
-
this.
|
|
14847
|
+
if (this._cache.loaded && !this._cache.person) {
|
|
14848
|
+
this._cache.person = this._cache.loaded ? this._data.asPerson() : undefined;
|
|
14787
14849
|
}
|
|
14788
|
-
return this.
|
|
14850
|
+
return this._cache.person;
|
|
14789
14851
|
},
|
|
14790
14852
|
enumerable: false,
|
|
14791
14853
|
configurable: true
|
|
14792
14854
|
});
|
|
14793
14855
|
Object.defineProperty(AccountService.prototype, "department", {
|
|
14794
14856
|
get: function () {
|
|
14795
|
-
if (this.
|
|
14796
|
-
this.
|
|
14857
|
+
if (this._cache.loaded && !this._cache.department) {
|
|
14858
|
+
this._cache.department = this._cache.loaded ? this._data.asPerson().department : undefined;
|
|
14797
14859
|
}
|
|
14798
|
-
return this.
|
|
14860
|
+
return this._cache.department;
|
|
14799
14861
|
},
|
|
14800
14862
|
enumerable: false,
|
|
14801
14863
|
configurable: true
|
|
@@ -14809,109 +14871,91 @@
|
|
|
14809
14871
|
console.info('[account] Using authentication token type: ' + value);
|
|
14810
14872
|
this._tokenType$.next(value);
|
|
14811
14873
|
// Reset values
|
|
14812
|
-
this.
|
|
14874
|
+
this._cache.authToken = undefined;
|
|
14813
14875
|
this.onAuthTokenChange.next(undefined);
|
|
14814
|
-
this.
|
|
14876
|
+
this._cache.authBasic = undefined;
|
|
14815
14877
|
this.onAuthBasicChange.next(undefined);
|
|
14816
14878
|
}
|
|
14817
14879
|
},
|
|
14818
14880
|
enumerable: false,
|
|
14819
14881
|
configurable: true
|
|
14820
14882
|
});
|
|
14821
|
-
AccountService.prototype.
|
|
14822
|
-
var _this = this;
|
|
14823
|
-
if (this._startPromise)
|
|
14824
|
-
return this._startPromise;
|
|
14825
|
-
if (this._started)
|
|
14826
|
-
return Promise.resolve(this.account);
|
|
14827
|
-
// Restoring local settings
|
|
14828
|
-
this._startPromise = Promise.all([
|
|
14829
|
-
this.settings.ready(),
|
|
14830
|
-
// Wait token type to be set
|
|
14831
|
-
firstNotNilPromise(this._tokenType$)
|
|
14832
|
-
])
|
|
14833
|
-
.then(function () { return _this.restoreLocally(); })
|
|
14834
|
-
.then(function () {
|
|
14835
|
-
_this._started = true;
|
|
14836
|
-
_this._startPromise = undefined;
|
|
14837
|
-
return _this.account;
|
|
14838
|
-
});
|
|
14839
|
-
return this._startPromise;
|
|
14840
|
-
};
|
|
14841
|
-
Object.defineProperty(AccountService.prototype, "started", {
|
|
14842
|
-
get: function () {
|
|
14843
|
-
return this._started;
|
|
14844
|
-
},
|
|
14845
|
-
enumerable: false,
|
|
14846
|
-
configurable: true
|
|
14847
|
-
});
|
|
14848
|
-
AccountService.prototype.stop = function () {
|
|
14883
|
+
AccountService.prototype.ngOnStart = function () {
|
|
14849
14884
|
return __awaiter(this, void 0, void 0, function () {
|
|
14850
|
-
var
|
|
14885
|
+
var _this = this;
|
|
14851
14886
|
return __generator(this, function (_b) {
|
|
14852
|
-
|
|
14853
|
-
|
|
14854
|
-
|
|
14855
|
-
|
|
14856
|
-
|
|
14857
|
-
|
|
14858
|
-
|
|
14859
|
-
|
|
14860
|
-
|
|
14861
|
-
this.
|
|
14862
|
-
|
|
14863
|
-
|
|
14864
|
-
|
|
14865
|
-
|
|
14866
|
-
|
|
14887
|
+
switch (_b.label) {
|
|
14888
|
+
case 0: return [4 /*yield*/, Promise.all([
|
|
14889
|
+
this.settings.ready(),
|
|
14890
|
+
// Wait token type to be set
|
|
14891
|
+
firstNotNilPromise(this._tokenType$)
|
|
14892
|
+
])];
|
|
14893
|
+
case 1:
|
|
14894
|
+
_b.sent();
|
|
14895
|
+
// Listen graphql start (or restart)
|
|
14896
|
+
this.registerSubscription(this.graphql.onStart.subscribe(function () {
|
|
14897
|
+
if (_this.started && _this.isLogin()) {
|
|
14898
|
+
console.debug('[account] Restarting, to retry to authenticate...');
|
|
14899
|
+
_this.restart();
|
|
14900
|
+
}
|
|
14901
|
+
}));
|
|
14902
|
+
return [4 /*yield*/, this.restoreLocally()];
|
|
14903
|
+
case 2:
|
|
14904
|
+
_b.sent();
|
|
14905
|
+
return [4 /*yield*/, this.listenSettings()];
|
|
14906
|
+
case 3:
|
|
14907
|
+
_b.sent();
|
|
14908
|
+
return [2 /*return*/, this._data];
|
|
14867
14909
|
}
|
|
14868
|
-
return [2 /*return*/];
|
|
14869
14910
|
});
|
|
14870
14911
|
});
|
|
14871
14912
|
};
|
|
14872
|
-
AccountService.prototype.
|
|
14913
|
+
AccountService.prototype.ngOnStop = function () {
|
|
14873
14914
|
return __awaiter(this, void 0, void 0, function () {
|
|
14915
|
+
var hadAuthToken, hadAuthBasic, hadAuth;
|
|
14874
14916
|
return __generator(this, function (_b) {
|
|
14875
|
-
|
|
14876
|
-
|
|
14877
|
-
|
|
14878
|
-
|
|
14879
|
-
|
|
14917
|
+
hadAuthToken = this._cache.authToken && true;
|
|
14918
|
+
hadAuthBasic = this._cache.authBasic && true;
|
|
14919
|
+
hadAuth = hadAuthToken || hadAuthBasic;
|
|
14920
|
+
this.resetData();
|
|
14921
|
+
if (hadAuth) {
|
|
14922
|
+
this.onLogout.next();
|
|
14923
|
+
this.onChange.next(undefined);
|
|
14924
|
+
if (hadAuthToken)
|
|
14925
|
+
this.onAuthTokenChange.next(undefined);
|
|
14926
|
+
if (hadAuthBasic)
|
|
14927
|
+
this.onAuthBasicChange.next(undefined);
|
|
14880
14928
|
}
|
|
14929
|
+
return [2 /*return*/];
|
|
14881
14930
|
});
|
|
14882
14931
|
});
|
|
14883
14932
|
};
|
|
14884
|
-
AccountService.prototype.ready = function () {
|
|
14885
|
-
if (this._started)
|
|
14886
|
-
return Promise.resolve(this.account);
|
|
14887
|
-
return this.start();
|
|
14888
|
-
};
|
|
14889
14933
|
AccountService.prototype.isLogin = function () {
|
|
14890
|
-
return !!(this.
|
|
14934
|
+
return !!(this._cache.pubkey && this._cache.loaded);
|
|
14891
14935
|
};
|
|
14892
14936
|
AccountService.prototype.isAuth = function () {
|
|
14893
|
-
return !!(this.
|
|
14937
|
+
return !!(this._cache.pubkey && this._cache.keypair && this._cache.keypair.secretKey);
|
|
14894
14938
|
};
|
|
14895
14939
|
AccountService.prototype.hasMinProfile = function (userProfile) {
|
|
14896
14940
|
// should be login, and status ENABLE or TEMPORARY
|
|
14897
|
-
if (!this._data
|
|
14898
|
-
(this._data.
|
|
14941
|
+
if (!this._data || !this._data.pubkey ||
|
|
14942
|
+
(this._data.statusId !== StatusIds.ENABLE && this._data.statusId !== StatusIds.TEMPORARY)) {
|
|
14899
14943
|
return false;
|
|
14900
14944
|
}
|
|
14901
|
-
return PersonUtils.hasUpperOrEqualsProfile(this._data.
|
|
14945
|
+
return PersonUtils.hasUpperOrEqualsProfile(this._data.profiles, userProfile);
|
|
14902
14946
|
};
|
|
14903
14947
|
AccountService.prototype.hasExactProfile = function (label) {
|
|
14904
14948
|
// should be login, and status ENABLE or TEMPORARY
|
|
14905
|
-
if (!this._data
|
|
14906
|
-
(this._data.
|
|
14949
|
+
if (!this._data || !this._data.pubkey ||
|
|
14950
|
+
(this._data.statusId !== StatusIds.ENABLE && this._data.statusId !== StatusIds.TEMPORARY))
|
|
14907
14951
|
return false;
|
|
14908
|
-
return this._data.
|
|
14952
|
+
return this._data.profiles.some(function (profile) { return profile === label; });
|
|
14909
14953
|
};
|
|
14910
14954
|
AccountService.prototype.hasProfileAndIsEnable = function (userProfile) {
|
|
14911
14955
|
// should be login, and status ENABLE
|
|
14912
|
-
if (!this._data
|
|
14956
|
+
if (!this._data || !this._data.pubkey || this._data.statusId !== StatusIds.ENABLE)
|
|
14913
14957
|
return false;
|
|
14914
|
-
return PersonUtils.hasUpperOrEqualsProfile(this._data.
|
|
14958
|
+
return PersonUtils.hasUpperOrEqualsProfile(this._data.profiles, userProfile);
|
|
14915
14959
|
};
|
|
14916
14960
|
AccountService.prototype.isAdmin = function () {
|
|
14917
14961
|
return this.hasProfileAndIsEnable('ADMIN');
|
|
@@ -14931,11 +14975,11 @@
|
|
|
14931
14975
|
};
|
|
14932
14976
|
AccountService.prototype.isOnlyGuest = function () {
|
|
14933
14977
|
// Should be login, and status ENABLE or TEMPORARY
|
|
14934
|
-
if (!this._data
|
|
14935
|
-
(this._data.
|
|
14978
|
+
if (!this._data || !this._data.pubkey ||
|
|
14979
|
+
(this._data.statusId !== StatusIds.ENABLE && this._data.statusId !== StatusIds.TEMPORARY))
|
|
14936
14980
|
return false;
|
|
14937
14981
|
// Profile less then user
|
|
14938
|
-
return !PersonUtils.hasUpperOrEqualsProfile(this._data.
|
|
14982
|
+
return !PersonUtils.hasUpperOrEqualsProfile(this._data.profiles, 'USER');
|
|
14939
14983
|
};
|
|
14940
14984
|
AccountService.prototype.canUserWriteDataForDepartment = function (recorderDepartment) {
|
|
14941
14985
|
if (ReferentialUtils.isEmpty(recorderDepartment)) {
|
|
@@ -14944,17 +14988,17 @@
|
|
|
14944
14988
|
return this.isAdmin();
|
|
14945
14989
|
}
|
|
14946
14990
|
// Should be login, and status ENABLE
|
|
14947
|
-
if (!this._data
|
|
14991
|
+
if (!this._data || !this._data.pubkey || this._data.statusId !== StatusIds.ENABLE)
|
|
14948
14992
|
return false;
|
|
14949
|
-
if (!this._data.
|
|
14993
|
+
if (!this._data.department || !this._data.department.id) {
|
|
14950
14994
|
console.warn('User account has no department ! Unable to check write right against recorderDepartment');
|
|
14951
14995
|
return false;
|
|
14952
14996
|
}
|
|
14953
14997
|
// Same recorder department: OK, user can write
|
|
14954
|
-
if (this._data.
|
|
14998
|
+
if (this._data.department.id === recorderDepartment.id)
|
|
14955
14999
|
return true;
|
|
14956
15000
|
// Else, check if supervisor (or more)
|
|
14957
|
-
return PersonUtils.hasUpperOrEqualsProfile(this._data.
|
|
15001
|
+
return PersonUtils.hasUpperOrEqualsProfile(this._data.profiles, 'SUPERVISOR');
|
|
14958
15002
|
};
|
|
14959
15003
|
AccountService.prototype.register = function (data) {
|
|
14960
15004
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -14969,7 +15013,7 @@
|
|
|
14969
15013
|
throw new Error('Missing required username or password');
|
|
14970
15014
|
if (this._debug)
|
|
14971
15015
|
console.debug('[account] Register new user account...', data.account);
|
|
14972
|
-
this.
|
|
15016
|
+
this._cache.loaded = false;
|
|
14973
15017
|
now = Date.now();
|
|
14974
15018
|
_b.label = 1;
|
|
14975
15019
|
case 1:
|
|
@@ -14983,29 +15027,29 @@
|
|
|
14983
15027
|
data.account.settings.locale = this.settings.locale;
|
|
14984
15028
|
data.account.settings.latLongFormat = this.settings.latLongFormat;
|
|
14985
15029
|
data.account.department.id = data.account.department.id || this.environment.defaultDepartmentId;
|
|
14986
|
-
this.
|
|
15030
|
+
this._cache.keypair = keypair;
|
|
14987
15031
|
return [4 /*yield*/, this.saveRemotely(data.account, keypair)];
|
|
14988
15032
|
case 3:
|
|
14989
15033
|
account = _b.sent();
|
|
14990
15034
|
// Default values
|
|
14991
15035
|
account.avatar = account.avatar || (this.environment.baseUrl + DEFAULT_AVATAR_IMAGE);
|
|
14992
|
-
this.
|
|
14993
|
-
this._data
|
|
14994
|
-
this.
|
|
15036
|
+
this._cache.mainProfile = PersonUtils.getMainProfile(account.profiles);
|
|
15037
|
+
this._data = account;
|
|
15038
|
+
this._cache.pubkey = account.pubkey;
|
|
14995
15039
|
// Try to auth on pod
|
|
14996
15040
|
return [4 /*yield*/, this.authenticate(data)];
|
|
14997
15041
|
case 4:
|
|
14998
15042
|
// Try to auth on pod
|
|
14999
15043
|
_b.sent();
|
|
15000
|
-
this.
|
|
15044
|
+
this._cache.loaded = true;
|
|
15001
15045
|
return [4 /*yield*/, this.saveLocally()];
|
|
15002
15046
|
case 5:
|
|
15003
15047
|
_b.sent();
|
|
15004
15048
|
console.debug("[account] Account successfully registered in " + (Date.now() - now) + "ms");
|
|
15005
15049
|
// Emit events
|
|
15006
|
-
this.onLogin.next(this._data
|
|
15007
|
-
this.onChange.next(this._data
|
|
15008
|
-
return [2 /*return*/, this._data
|
|
15050
|
+
this.onLogin.next(this._data);
|
|
15051
|
+
this.onChange.next(this._data);
|
|
15052
|
+
return [2 /*return*/, this._data];
|
|
15009
15053
|
case 6:
|
|
15010
15054
|
error_1 = _b.sent();
|
|
15011
15055
|
console.error(error_1 && error_1.message || error_1);
|
|
@@ -15027,22 +15071,22 @@
|
|
|
15027
15071
|
// Basic auth
|
|
15028
15072
|
if (tokenType === 'basic' || tokenType === 'basic-and-token') {
|
|
15029
15073
|
// Generate the authBasic, if used
|
|
15030
|
-
if (!this.
|
|
15074
|
+
if (!this._cache.authBasic) {
|
|
15031
15075
|
// Skip if token already provided
|
|
15032
|
-
if (!(this.
|
|
15076
|
+
if (!(this._cache.authToken && tokenType === 'basic-and-token')) {
|
|
15033
15077
|
if (!data || !data.username || !data.password)
|
|
15034
15078
|
throw new Error('Missing username and password');
|
|
15035
|
-
this.
|
|
15079
|
+
this._cache.authBasic = this.cryptoService.encodeBase64(data.username + ":" + data.password);
|
|
15036
15080
|
}
|
|
15037
15081
|
}
|
|
15038
|
-
this.onAuthBasicChange.next(this.
|
|
15082
|
+
this.onAuthBasicChange.next(this._cache.authBasic);
|
|
15039
15083
|
}
|
|
15040
15084
|
if (!(tokenType === 'token' || tokenType === 'basic-and-token')) return [3 /*break*/, 5];
|
|
15041
15085
|
_c.label = 2;
|
|
15042
15086
|
case 2:
|
|
15043
15087
|
_c.trys.push([2, 4, , 5]);
|
|
15044
|
-
_b = this.
|
|
15045
|
-
return [4 /*yield*/, this.authenticateAndGetToken(this.
|
|
15088
|
+
_b = this._cache;
|
|
15089
|
+
return [4 /*yield*/, this.authenticateAndGetToken(this._cache.authToken)];
|
|
15046
15090
|
case 3:
|
|
15047
15091
|
_b.authToken = _c.sent();
|
|
15048
15092
|
return [3 /*break*/, 5];
|
|
@@ -15055,7 +15099,7 @@
|
|
|
15055
15099
|
case 5:
|
|
15056
15100
|
// Forget authBasic, to switch to authToken
|
|
15057
15101
|
if (tokenType === 'basic-and-token') {
|
|
15058
|
-
this.
|
|
15102
|
+
this._cache.authBasic = undefined;
|
|
15059
15103
|
this.onAuthBasicChange.next(undefined);
|
|
15060
15104
|
}
|
|
15061
15105
|
return [2 /*return*/];
|
|
@@ -15086,18 +15130,18 @@
|
|
|
15086
15130
|
throw { code: ErrorCodes$2.UNKNOWN_ERROR, message: 'ERROR.SCRYPT_ERROR' };
|
|
15087
15131
|
case 4:
|
|
15088
15132
|
// Store pubkey+keypair
|
|
15089
|
-
this.
|
|
15090
|
-
this.
|
|
15133
|
+
this._cache.pubkey = Base58.encode(keypair.publicKey);
|
|
15134
|
+
this._cache.keypair = keypair;
|
|
15091
15135
|
return [4 /*yield*/, this.storage.get(TOKEN_STORAGE_KEY)];
|
|
15092
15136
|
case 5:
|
|
15093
15137
|
previousToken = _b.sent();
|
|
15094
|
-
previousToken = previousToken && previousToken.startsWith(this.
|
|
15138
|
+
previousToken = previousToken && previousToken.startsWith(this._cache.pubkey) && previousToken || null;
|
|
15095
15139
|
offline = this.settings.hasOfflineFeature() && (this.network.offline || data.offline === true);
|
|
15096
15140
|
if (!offline) return [3 /*break*/, 6];
|
|
15097
|
-
this.
|
|
15141
|
+
this._cache.authToken = previousToken;
|
|
15098
15142
|
// Make sure network if set as offline
|
|
15099
15143
|
this.network.setForceOffline(true, { showToast: false });
|
|
15100
|
-
console.info("[account] Login [OK] {pubkey: " + this.
|
|
15144
|
+
console.info("[account] Login [OK] {pubkey: " + this._cache.pubkey.substr(0, 8) + "}, {offline: true}");
|
|
15101
15145
|
return [3 /*break*/, 9];
|
|
15102
15146
|
case 6:
|
|
15103
15147
|
_b.trys.push([6, 8, , 9]);
|
|
@@ -15157,9 +15201,9 @@
|
|
|
15157
15201
|
throw error_5;
|
|
15158
15202
|
case 21:
|
|
15159
15203
|
// Emit event to observers
|
|
15160
|
-
this.onLogin.next(this._data
|
|
15161
|
-
this.onChange.next(this._data
|
|
15162
|
-
return [2 /*return*/, this._data
|
|
15204
|
+
this.onLogin.next(this._data);
|
|
15205
|
+
this.onChange.next(this._data);
|
|
15206
|
+
return [2 /*return*/, this._data];
|
|
15163
15207
|
}
|
|
15164
15208
|
});
|
|
15165
15209
|
});
|
|
@@ -15169,7 +15213,7 @@
|
|
|
15169
15213
|
return __generator(this, function (_b) {
|
|
15170
15214
|
switch (_b.label) {
|
|
15171
15215
|
case 0:
|
|
15172
|
-
if (!this.
|
|
15216
|
+
if (!this._cache.pubkey)
|
|
15173
15217
|
throw new Error('User not logged');
|
|
15174
15218
|
if (this.network.offline)
|
|
15175
15219
|
throw new Error('Cannot check account in offline mode');
|
|
@@ -15181,9 +15225,9 @@
|
|
|
15181
15225
|
_b.sent();
|
|
15182
15226
|
console.debug('[account] Successfully reload account');
|
|
15183
15227
|
// Emit login event to subscribers
|
|
15184
|
-
this.onLogin.next(this._data
|
|
15185
|
-
this.onChange.next(this._data
|
|
15186
|
-
return [2 /*return*/, this._data
|
|
15228
|
+
this.onLogin.next(this._data);
|
|
15229
|
+
this.onChange.next(this._data);
|
|
15230
|
+
return [2 /*return*/, this._data];
|
|
15187
15231
|
}
|
|
15188
15232
|
});
|
|
15189
15233
|
});
|
|
@@ -15198,27 +15242,27 @@
|
|
|
15198
15242
|
return __generator(this, function (_b) {
|
|
15199
15243
|
switch (_b.label) {
|
|
15200
15244
|
case 0:
|
|
15201
|
-
if (!this.
|
|
15245
|
+
if (!this._cache.pubkey)
|
|
15202
15246
|
return [2 /*return*/, Promise.reject('User not logged')];
|
|
15203
|
-
if (this.
|
|
15247
|
+
if (this._cache.pubkey !== account.pubkey)
|
|
15204
15248
|
return [2 /*return*/, Promise.reject('Not user account')];
|
|
15205
|
-
return [4 /*yield*/, this.saveRemotely(account, this.
|
|
15249
|
+
return [4 /*yield*/, this.saveRemotely(account, this._cache.keypair)];
|
|
15206
15250
|
case 1:
|
|
15207
15251
|
account = _b.sent();
|
|
15208
15252
|
// Set defaults
|
|
15209
15253
|
account.avatar = account.avatar || (this.environment.baseUrl + DEFAULT_AVATAR_IMAGE);
|
|
15210
|
-
this.
|
|
15211
|
-
this._data
|
|
15212
|
-
this.
|
|
15254
|
+
this._cache.mainProfile = PersonUtils.getMainProfile(account.profiles);
|
|
15255
|
+
this._data = account;
|
|
15256
|
+
this._cache.loaded = true;
|
|
15213
15257
|
// Save locally (in storage)
|
|
15214
15258
|
return [4 /*yield*/, this.saveLocally()];
|
|
15215
15259
|
case 2:
|
|
15216
15260
|
// Save locally (in storage)
|
|
15217
15261
|
_b.sent();
|
|
15218
15262
|
// Send event
|
|
15219
|
-
this.onLogin.next(this._data
|
|
15220
|
-
this.onChange.next(this._data
|
|
15221
|
-
return [2 /*return*/, this._data
|
|
15263
|
+
this.onLogin.next(this._data);
|
|
15264
|
+
this.onChange.next(this._data);
|
|
15265
|
+
return [2 /*return*/, this._data];
|
|
15222
15266
|
}
|
|
15223
15267
|
});
|
|
15224
15268
|
});
|
|
@@ -15229,9 +15273,9 @@
|
|
|
15229
15273
|
return __generator(this, function (_b) {
|
|
15230
15274
|
switch (_b.label) {
|
|
15231
15275
|
case 0:
|
|
15232
|
-
hadAuthToken = this.
|
|
15233
|
-
hadAuthBasic = this.
|
|
15234
|
-
pubkey = this.
|
|
15276
|
+
hadAuthToken = this._cache.authToken && true;
|
|
15277
|
+
hadAuthBasic = this._cache.authBasic && true;
|
|
15278
|
+
pubkey = this._cache && this._cache.pubkey;
|
|
15235
15279
|
this.resetData();
|
|
15236
15280
|
if (!!this.settings.hasOfflineFeature()) return [3 /*break*/, 2];
|
|
15237
15281
|
// Remove all data from the local storage
|
|
@@ -15303,9 +15347,9 @@
|
|
|
15303
15347
|
case 1:
|
|
15304
15348
|
json = _b.sent();
|
|
15305
15349
|
json = json && (typeof json === 'string') && JSON.parse(json) || json;
|
|
15306
|
-
json = json && this.
|
|
15307
|
-
if (!(!json && this.
|
|
15308
|
-
return [4 /*yield*/, this.storage.get(ACCOUNT_STORAGE_KEY + '#' + this.
|
|
15350
|
+
json = json && this._cache.pubkey && (json.pubkey === this._cache.pubkey) && json || null;
|
|
15351
|
+
if (!(!json && this._cache.pubkey)) return [3 /*break*/, 3];
|
|
15352
|
+
return [4 /*yield*/, this.storage.get(ACCOUNT_STORAGE_KEY + '#' + this._cache.pubkey)];
|
|
15309
15353
|
case 2:
|
|
15310
15354
|
json = _b.sent();
|
|
15311
15355
|
json = json && (typeof json === 'string') && JSON.parse(json) || json;
|
|
@@ -15437,7 +15481,7 @@
|
|
|
15437
15481
|
};
|
|
15438
15482
|
AccountService.prototype.listenChanges = function () {
|
|
15439
15483
|
var _this = this;
|
|
15440
|
-
if (!this.
|
|
15484
|
+
if (!this._cache.pubkey)
|
|
15441
15485
|
return rxjs.Subscription.EMPTY;
|
|
15442
15486
|
var self = this;
|
|
15443
15487
|
console.debug('[account] [WS] Listening account changes');
|
|
@@ -15460,7 +15504,7 @@
|
|
|
15460
15504
|
case 0:
|
|
15461
15505
|
if (!data)
|
|
15462
15506
|
return [2 /*return*/];
|
|
15463
|
-
existingUpdateDate = toDateISOString((_a = self._data
|
|
15507
|
+
existingUpdateDate = toDateISOString((_a = self._data) === null || _a === void 0 ? void 0 : _a.updateDate);
|
|
15464
15508
|
if (!(existingUpdateDate !== data.updateDate)) return [3 /*break*/, 2];
|
|
15465
15509
|
console.debug("[account] [WS] Detected update on {" + data.updateDate + "}");
|
|
15466
15510
|
return [4 /*yield*/, self.refresh()];
|
|
@@ -15504,27 +15548,6 @@
|
|
|
15504
15548
|
subscription.add(function () { return console.debug('[account] [WS] Stop listening account changes'); });
|
|
15505
15549
|
return subscription;
|
|
15506
15550
|
};
|
|
15507
|
-
/**
|
|
15508
|
-
* @deprecated
|
|
15509
|
-
*/
|
|
15510
|
-
AccountService.prototype.getPageSettings = function (pageId, propertyName) {
|
|
15511
|
-
return this.settings.getPageSettings(pageId, propertyName);
|
|
15512
|
-
};
|
|
15513
|
-
/**
|
|
15514
|
-
* @deprecated
|
|
15515
|
-
*/
|
|
15516
|
-
AccountService.prototype.savePageSetting = function (pageId, value, propertyName) {
|
|
15517
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
15518
|
-
return __generator(this, function (_b) {
|
|
15519
|
-
switch (_b.label) {
|
|
15520
|
-
case 0: return [4 /*yield*/, this.settings.savePageSetting(pageId, value, propertyName)];
|
|
15521
|
-
case 1:
|
|
15522
|
-
_b.sent();
|
|
15523
|
-
return [2 /*return*/];
|
|
15524
|
-
}
|
|
15525
|
-
});
|
|
15526
|
-
});
|
|
15527
|
-
};
|
|
15528
15551
|
Object.defineProperty(AccountService.prototype, "additionalFields", {
|
|
15529
15552
|
get: function () {
|
|
15530
15553
|
return this._$additionalFields.getValue();
|
|
@@ -15553,28 +15576,28 @@
|
|
|
15553
15576
|
};
|
|
15554
15577
|
/* -- protected method -- */
|
|
15555
15578
|
AccountService.prototype.resetData = function () {
|
|
15556
|
-
this.
|
|
15557
|
-
this.
|
|
15558
|
-
this.
|
|
15559
|
-
this.
|
|
15560
|
-
this.
|
|
15561
|
-
this.
|
|
15562
|
-
this.
|
|
15563
|
-
this.
|
|
15564
|
-
this._data
|
|
15579
|
+
this._cache.loaded = false;
|
|
15580
|
+
this._cache.keypair = null;
|
|
15581
|
+
this._cache.authToken = null;
|
|
15582
|
+
this._cache.authBasic = null;
|
|
15583
|
+
this._cache.pubkey = null;
|
|
15584
|
+
this._cache.mainProfile = null;
|
|
15585
|
+
this._cache.person = null;
|
|
15586
|
+
this._cache.department = null;
|
|
15587
|
+
this._data = new exports.Account();
|
|
15565
15588
|
};
|
|
15566
15589
|
AccountService.prototype.loadData = function (opts) {
|
|
15567
15590
|
return __awaiter(this, void 0, void 0, function () {
|
|
15568
|
-
var account, error_6;
|
|
15591
|
+
var account, accountSettingsContentKeys, settings, error_6;
|
|
15569
15592
|
return __generator(this, function (_b) {
|
|
15570
15593
|
switch (_b.label) {
|
|
15571
15594
|
case 0:
|
|
15572
|
-
if (!this.
|
|
15595
|
+
if (!this._cache.pubkey)
|
|
15573
15596
|
throw new Error('User not logged');
|
|
15574
|
-
this.
|
|
15597
|
+
this._cache.loaded = false;
|
|
15575
15598
|
_b.label = 1;
|
|
15576
15599
|
case 1:
|
|
15577
|
-
_b.trys.push([1,
|
|
15600
|
+
_b.trys.push([1, 5, , 6]);
|
|
15578
15601
|
return [4 /*yield*/, this.load(opts)];
|
|
15579
15602
|
case 2:
|
|
15580
15603
|
account = (_b.sent()) || new exports.Account();
|
|
@@ -15583,18 +15606,27 @@
|
|
|
15583
15606
|
account.settings = account.settings || new exports.UserSettings();
|
|
15584
15607
|
account.settings.locale = account.settings.locale || this.settings.locale;
|
|
15585
15608
|
account.settings.latLongFormat = account.settings.latLongFormat || this.settings.latLongFormat || 'DDMM';
|
|
15609
|
+
account.settings.content = account.settings.content || {};
|
|
15586
15610
|
// Read main profile
|
|
15587
|
-
this.
|
|
15611
|
+
this._cache.mainProfile = PersonUtils.getMainProfile(account.profiles);
|
|
15588
15612
|
// Update, instead of replace it
|
|
15589
|
-
if (this._data
|
|
15590
|
-
this._data.
|
|
15613
|
+
if (this._data) {
|
|
15614
|
+
this._data.fromObject(account);
|
|
15591
15615
|
}
|
|
15592
15616
|
else {
|
|
15593
|
-
this._data
|
|
15617
|
+
this._data = account;
|
|
15594
15618
|
}
|
|
15595
|
-
this.
|
|
15596
|
-
|
|
15619
|
+
this._cache.loaded = true;
|
|
15620
|
+
accountSettingsContentKeys = Object.keys(account.settings.content);
|
|
15621
|
+
if (!isNotEmptyArray(accountSettingsContentKeys)) return [3 /*break*/, 4];
|
|
15622
|
+
settings = Object.assign(Object.assign(Object.assign({}, this.settings.settings), account.settings.content), account.settings);
|
|
15623
|
+
delete settings.content; // Remove content attribute
|
|
15624
|
+
return [4 /*yield*/, this.settings.apply(settings)];
|
|
15597
15625
|
case 3:
|
|
15626
|
+
_b.sent();
|
|
15627
|
+
_b.label = 4;
|
|
15628
|
+
case 4: return [2 /*return*/, this._data];
|
|
15629
|
+
case 5:
|
|
15598
15630
|
error_6 = _b.sent();
|
|
15599
15631
|
this.resetData();
|
|
15600
15632
|
if (error_6.code && error_6.message)
|
|
@@ -15604,11 +15636,23 @@
|
|
|
15604
15636
|
code: ErrorCodes$2.LOAD_ACCOUNT_ERROR,
|
|
15605
15637
|
message: 'ERROR.LOAD_ACCOUNT_ERROR'
|
|
15606
15638
|
};
|
|
15607
|
-
case
|
|
15639
|
+
case 6: return [2 /*return*/];
|
|
15608
15640
|
}
|
|
15609
15641
|
});
|
|
15610
15642
|
});
|
|
15611
15643
|
};
|
|
15644
|
+
AccountService.prototype.listenSettings = function () {
|
|
15645
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15646
|
+
var _this = this;
|
|
15647
|
+
return __generator(this, function (_b) {
|
|
15648
|
+
// When settings changed: save it remotely
|
|
15649
|
+
this.registerSubscription(this.settings.onChange
|
|
15650
|
+
.pipe(operators.debounceTime(1000), operators.filter(function () { return _this.isLogin() && _this.network.online; }))
|
|
15651
|
+
.subscribe(function (settings) { return _this.saveLocalSettingsRemotely(settings); }));
|
|
15652
|
+
return [2 /*return*/];
|
|
15653
|
+
});
|
|
15654
|
+
});
|
|
15655
|
+
};
|
|
15612
15656
|
AccountService.prototype.restoreLocally = function () {
|
|
15613
15657
|
return __awaiter(this, void 0, void 0, function () {
|
|
15614
15658
|
var values, pubkey, token, seckey, canRemoteAuth, error_7, jsonAccount, accountStr, account;
|
|
@@ -15632,9 +15676,9 @@
|
|
|
15632
15676
|
return [2 /*return*/];
|
|
15633
15677
|
if (this._debug)
|
|
15634
15678
|
console.debug("[account] Account restoration...");
|
|
15635
|
-
this.
|
|
15636
|
-
this.
|
|
15637
|
-
this.
|
|
15679
|
+
this._cache.authToken = token;
|
|
15680
|
+
this._cache.pubkey = pubkey;
|
|
15681
|
+
this._cache.keypair = seckey && {
|
|
15638
15682
|
publicKey: Base58.decode(pubkey),
|
|
15639
15683
|
secretKey: Base58.decode(seckey)
|
|
15640
15684
|
} || null;
|
|
@@ -15645,7 +15689,7 @@
|
|
|
15645
15689
|
return [4 /*yield*/, this.authenticate()];
|
|
15646
15690
|
case 3:
|
|
15647
15691
|
_b.sent();
|
|
15648
|
-
if (!this.
|
|
15692
|
+
if (!this._cache.authToken && !this._cache.authBasic)
|
|
15649
15693
|
throw new Error('Authentication failed');
|
|
15650
15694
|
return [3 /*break*/, 5];
|
|
15651
15695
|
case 4:
|
|
@@ -15678,14 +15722,14 @@
|
|
|
15678
15722
|
return [2 /*return*/];
|
|
15679
15723
|
account = exports.Account.fromObject(jsonAccount);
|
|
15680
15724
|
// Update data
|
|
15681
|
-
this._data
|
|
15682
|
-
this.
|
|
15683
|
-
this.
|
|
15725
|
+
this._data = account;
|
|
15726
|
+
this._cache.mainProfile = PersonUtils.getMainProfile(account.profiles);
|
|
15727
|
+
this._cache.loaded = true;
|
|
15684
15728
|
// Emit event
|
|
15685
|
-
this.onLogin.next(this._data
|
|
15686
|
-
this.onChange.next(this._data
|
|
15729
|
+
this.onLogin.next(this._data);
|
|
15730
|
+
this.onChange.next(this._data);
|
|
15687
15731
|
if (this._debug)
|
|
15688
|
-
console.debug("[account] Account restoration [OK] {pubkey: " + pubkey.substr(0, 8) + "}, {profile: " + this.
|
|
15732
|
+
console.debug("[account] Account restoration [OK] {pubkey: " + pubkey.substr(0, 8) + "}, {profile: " + this._cache.mainProfile + "}");
|
|
15689
15733
|
return [2 /*return*/, account];
|
|
15690
15734
|
}
|
|
15691
15735
|
});
|
|
@@ -15701,12 +15745,12 @@
|
|
|
15701
15745
|
return __generator(this, function (_b) {
|
|
15702
15746
|
switch (_b.label) {
|
|
15703
15747
|
case 0:
|
|
15704
|
-
if (!this.
|
|
15748
|
+
if (!this._cache.pubkey)
|
|
15705
15749
|
throw new Error('User not logged');
|
|
15706
15750
|
if (this._debug)
|
|
15707
|
-
console.debug("[account] Saving account {" + this.
|
|
15708
|
-
json = this._data.
|
|
15709
|
-
seckey = this.
|
|
15751
|
+
console.debug("[account] Saving account {" + this._cache.pubkey.substring(0, 6) + "} in local storage...");
|
|
15752
|
+
json = this._data.asObject({ keepTypename: true });
|
|
15753
|
+
seckey = this._cache.keypair && this._cache.keypair.secretKey && Base58.encode(this._cache.keypair.secretKey) || null;
|
|
15710
15754
|
hasAvatarUrl = json.avatar && !json.avatar.endsWith(DEFAULT_AVATAR_IMAGE) &&
|
|
15711
15755
|
(json.avatar.startsWith('http://') || (json.avatar.startsWith('https://')));
|
|
15712
15756
|
if (!(hasAvatarUrl && this.network.online)) return [3 /*break*/, 2];
|
|
@@ -15729,9 +15773,9 @@
|
|
|
15729
15773
|
case 2:
|
|
15730
15774
|
_b.trys.push([2, 4, , 5]);
|
|
15731
15775
|
return [4 /*yield*/, Promise.all([
|
|
15732
|
-
this.storage.set(PUBKEY_STORAGE_KEY, this.
|
|
15733
|
-
this.storage.set(TOKEN_STORAGE_KEY, this.
|
|
15734
|
-
this.storage.set(ACCOUNT_STORAGE_KEY + "#" + this.
|
|
15776
|
+
this.storage.set(PUBKEY_STORAGE_KEY, this._cache.pubkey),
|
|
15777
|
+
this.storage.set(TOKEN_STORAGE_KEY, this._cache.authToken),
|
|
15778
|
+
this.storage.set(ACCOUNT_STORAGE_KEY + "#" + this._cache.pubkey, json),
|
|
15735
15779
|
// Secret key (optional)
|
|
15736
15780
|
seckey && this.storage.set(SECKEY_STORAGE_KEY, seckey) || this.storage.remove(SECKEY_STORAGE_KEY),
|
|
15737
15781
|
// Remove old storage key
|
|
@@ -15751,6 +15795,30 @@
|
|
|
15751
15795
|
});
|
|
15752
15796
|
});
|
|
15753
15797
|
};
|
|
15798
|
+
AccountService.prototype.saveLocalSettingsRemotely = function (source) {
|
|
15799
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15800
|
+
var account, settings, hasChanges;
|
|
15801
|
+
return __generator(this, function (_b) {
|
|
15802
|
+
switch (_b.label) {
|
|
15803
|
+
case 0:
|
|
15804
|
+
if (!source || !this.isLogin())
|
|
15805
|
+
return [2 /*return*/]; // Skip
|
|
15806
|
+
account = this.account;
|
|
15807
|
+
settings = exports.UserSettings.fromObject(account.settings) || new exports.UserSettings();
|
|
15808
|
+
hasChanges = settings.merge(source, ['locale', 'latLongFormat', 'properties']);
|
|
15809
|
+
if (!hasChanges) return [3 /*break*/, 2];
|
|
15810
|
+
if (this._debug)
|
|
15811
|
+
console.debug('[account] Save local settings remotely', settings);
|
|
15812
|
+
account.settings = settings;
|
|
15813
|
+
return [4 /*yield*/, this.saveRemotely(account)];
|
|
15814
|
+
case 1:
|
|
15815
|
+
_b.sent();
|
|
15816
|
+
_b.label = 2;
|
|
15817
|
+
case 2: return [2 /*return*/];
|
|
15818
|
+
}
|
|
15819
|
+
});
|
|
15820
|
+
});
|
|
15821
|
+
};
|
|
15754
15822
|
/**
|
|
15755
15823
|
* Create or update an user account
|
|
15756
15824
|
*
|
|
@@ -15808,7 +15876,7 @@
|
|
|
15808
15876
|
return __generator(this, function (_b) {
|
|
15809
15877
|
switch (_b.label) {
|
|
15810
15878
|
case 0:
|
|
15811
|
-
if (!this.
|
|
15879
|
+
if (!this._cache.pubkey)
|
|
15812
15880
|
throw new Error('User not logged');
|
|
15813
15881
|
if (!counter)
|
|
15814
15882
|
console.info('[account] Authentication on pod...');
|
|
@@ -15835,7 +15903,7 @@
|
|
|
15835
15903
|
if (data_1 && data_1.authenticate) {
|
|
15836
15904
|
// Store the token
|
|
15837
15905
|
this.onAuthTokenChange.next(token);
|
|
15838
|
-
console.info("[account] Authentication on pod [OK] {pubkey: '" + this.
|
|
15906
|
+
console.info("[account] Authentication on pod [OK] {pubkey: '" + this._cache.pubkey.substr(0, 8) + "'}");
|
|
15839
15907
|
return [2 /*return*/, token]; // return the token
|
|
15840
15908
|
}
|
|
15841
15909
|
_b.label = 2;
|
|
@@ -15861,10 +15929,10 @@
|
|
|
15861
15929
|
if (!signatureOK) {
|
|
15862
15930
|
console.warn('FIXME: Bad peer signature on auth challenge !', data.authChallenge);
|
|
15863
15931
|
}
|
|
15864
|
-
return [4 /*yield*/, this.cryptoService.sign(data.authChallenge.challenge, this.
|
|
15932
|
+
return [4 /*yield*/, this.cryptoService.sign(data.authChallenge.challenge, this._cache.keypair)];
|
|
15865
15933
|
case 5:
|
|
15866
15934
|
signature = _b.sent();
|
|
15867
|
-
newToken = this.
|
|
15935
|
+
newToken = this._cache.pubkey + ":" + data.authChallenge.challenge + "|" + signature;
|
|
15868
15936
|
return [4 /*yield*/, this.authenticateAndGetToken(newToken, (counter || 1) + 1 /* increment */)];
|
|
15869
15937
|
case 6:
|
|
15870
15938
|
// iterate with the new token
|
|
@@ -16169,94 +16237,42 @@
|
|
|
16169
16237
|
_this.toastController = toastController;
|
|
16170
16238
|
_this.translate = translate;
|
|
16171
16239
|
_this.environment = environment;
|
|
16172
|
-
_this._started = false;
|
|
16173
|
-
_this._subscription = new rxjs.Subscription();
|
|
16174
16240
|
_this.$data = new rxjs.BehaviorSubject(null);
|
|
16175
16241
|
_this._debug = !environment.production;
|
|
16176
16242
|
if (_this._debug)
|
|
16177
16243
|
console.debug('[config] Creating service');
|
|
16178
16244
|
_this._optionDefs = Object.values(Object.assign(Object.assign({}, CORE_CONFIG_OPTIONS), defaultOptionsMap));
|
|
16179
|
-
// Restart if graphql service restart
|
|
16180
|
-
_this.graphql.onStart.subscribe(function () { return _this.restart(); });
|
|
16181
|
-
// Start
|
|
16182
|
-
if (_this.graphql.started) {
|
|
16183
|
-
_this.start();
|
|
16184
|
-
}
|
|
16185
16245
|
return _this;
|
|
16186
16246
|
}
|
|
16187
|
-
Object.defineProperty(ConfigService.prototype, "started", {
|
|
16188
|
-
get: function () {
|
|
16189
|
-
return this._started;
|
|
16190
|
-
},
|
|
16191
|
-
enumerable: false,
|
|
16192
|
-
configurable: true
|
|
16193
|
-
});
|
|
16194
16247
|
Object.defineProperty(ConfigService.prototype, "config", {
|
|
16195
16248
|
get: function () {
|
|
16196
16249
|
// If first call: start loading
|
|
16197
|
-
if (!this.
|
|
16250
|
+
if (!this.started)
|
|
16198
16251
|
this.start();
|
|
16199
16252
|
return this.$data.pipe(operators.filter(isNotNil));
|
|
16200
16253
|
},
|
|
16201
16254
|
enumerable: false,
|
|
16202
16255
|
configurable: true
|
|
16203
16256
|
});
|
|
16204
|
-
ConfigService.prototype.
|
|
16205
|
-
var _this = this;
|
|
16206
|
-
if (this._startPromise)
|
|
16207
|
-
return this._startPromise;
|
|
16208
|
-
if (this._started)
|
|
16209
|
-
return;
|
|
16210
|
-
console.info('[config] Starting configuration...');
|
|
16211
|
-
this._startPromise = this.graphql.ready()
|
|
16212
|
-
.then(function () { return _this.loadOrRestoreLocally(); })
|
|
16213
|
-
.then(function (data) {
|
|
16214
|
-
_this._started = true;
|
|
16215
|
-
_this._startPromise = undefined;
|
|
16216
|
-
_this.$data.next(data);
|
|
16217
|
-
return data;
|
|
16218
|
-
})
|
|
16219
|
-
.catch(function (err) {
|
|
16220
|
-
console.error(err && err.message || err, err);
|
|
16221
|
-
_this._started = false;
|
|
16222
|
-
_this._startPromise = undefined;
|
|
16223
|
-
return null;
|
|
16224
|
-
});
|
|
16225
|
-
return this._startPromise;
|
|
16226
|
-
};
|
|
16227
|
-
ConfigService.prototype.stop = function () {
|
|
16228
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
16229
|
-
return __generator(this, function (_a) {
|
|
16230
|
-
this._subscription.unsubscribe();
|
|
16231
|
-
this._subscription = new rxjs.Subscription();
|
|
16232
|
-
this._started = false;
|
|
16233
|
-
this._startPromise = undefined;
|
|
16234
|
-
return [2 /*return*/];
|
|
16235
|
-
});
|
|
16236
|
-
});
|
|
16237
|
-
};
|
|
16238
|
-
ConfigService.prototype.restart = function () {
|
|
16257
|
+
ConfigService.prototype.ngOnStart = function () {
|
|
16239
16258
|
return __awaiter(this, void 0, void 0, function () {
|
|
16259
|
+
var data;
|
|
16260
|
+
var _this = this;
|
|
16240
16261
|
return __generator(this, function (_a) {
|
|
16241
16262
|
switch (_a.label) {
|
|
16242
16263
|
case 0:
|
|
16243
|
-
|
|
16244
|
-
return [4 /*yield*/, this.
|
|
16264
|
+
console.info('[config] Starting configuration...');
|
|
16265
|
+
return [4 /*yield*/, this.loadOrRestoreLocally()];
|
|
16245
16266
|
case 1:
|
|
16246
|
-
_a.sent();
|
|
16247
|
-
|
|
16248
|
-
|
|
16267
|
+
data = _a.sent();
|
|
16268
|
+
this.$data.next(data);
|
|
16269
|
+
// Restart if graphql service restart
|
|
16270
|
+
this.registerSubscription(this.graphql.onStart.subscribe(function () { return _this.restart(); }));
|
|
16271
|
+
return [2 /*return*/, data];
|
|
16249
16272
|
}
|
|
16250
16273
|
});
|
|
16251
16274
|
});
|
|
16252
16275
|
};
|
|
16253
|
-
ConfigService.prototype.ready = function () {
|
|
16254
|
-
if (this._started)
|
|
16255
|
-
return Promise.resolve(this.$data.value);
|
|
16256
|
-
if (this._startPromise)
|
|
16257
|
-
return this._startPromise;
|
|
16258
|
-
return this.start();
|
|
16259
|
-
};
|
|
16260
16276
|
ConfigService.prototype.loadDefault = function (opts) {
|
|
16261
16277
|
return __awaiter(this, void 0, void 0, function () {
|
|
16262
16278
|
var now, query, variables, res, data;
|
|
@@ -19139,7 +19155,7 @@
|
|
|
19139
19155
|
this.error = null;
|
|
19140
19156
|
this._enable = false;
|
|
19141
19157
|
this._$ready = new rxjs.BehaviorSubject(false);
|
|
19142
|
-
this.
|
|
19158
|
+
this._$loading = new rxjs.BehaviorSubject(true);
|
|
19143
19159
|
this.i18nFieldPrefix = null;
|
|
19144
19160
|
this._subscription = new rxjs.Subscription();
|
|
19145
19161
|
this.debug = false;
|
|
@@ -19155,9 +19171,25 @@
|
|
|
19155
19171
|
});
|
|
19156
19172
|
this.autocompleteFields = this.autocompleteHelper.fields;
|
|
19157
19173
|
}
|
|
19158
|
-
Object.defineProperty(AppForm.prototype, "
|
|
19174
|
+
Object.defineProperty(AppForm.prototype, "_loading", {
|
|
19175
|
+
/**
|
|
19176
|
+
* @deprecated
|
|
19177
|
+
*/
|
|
19178
|
+
get: function () {
|
|
19179
|
+
return this._$loading.value;
|
|
19180
|
+
},
|
|
19181
|
+
/**
|
|
19182
|
+
* @deprecated
|
|
19183
|
+
*/
|
|
19184
|
+
set: function (value) {
|
|
19185
|
+
this._$loading.next(value);
|
|
19186
|
+
},
|
|
19187
|
+
enumerable: false,
|
|
19188
|
+
configurable: true
|
|
19189
|
+
});
|
|
19190
|
+
Object.defineProperty(AppForm.prototype, "loading", {
|
|
19159
19191
|
get: function () {
|
|
19160
|
-
return this._$
|
|
19192
|
+
return this._$loading.value;
|
|
19161
19193
|
},
|
|
19162
19194
|
enumerable: false,
|
|
19163
19195
|
configurable: true
|
|
@@ -19295,11 +19327,11 @@
|
|
|
19295
19327
|
if (this.debug)
|
|
19296
19328
|
console.debug('[form] Updating form (using entity)', data);
|
|
19297
19329
|
// Convert object to json, then apply it to form (e.g. convert 'undefined' into 'null')
|
|
19298
|
-
AppFormUtils.copyEntity2Form(data, this.form,
|
|
19299
|
-
if (
|
|
19300
|
-
this.markAsLoaded(
|
|
19301
|
-
if (!opts || opts.emitEvent !== true)
|
|
19330
|
+
AppFormUtils.copyEntity2Form(data, this.form, opts);
|
|
19331
|
+
if (!opts || opts.emitEvent !== false) {
|
|
19332
|
+
this.markAsLoaded({ emitEvent: false });
|
|
19302
19333
|
this.markForCheck();
|
|
19334
|
+
}
|
|
19303
19335
|
};
|
|
19304
19336
|
AppForm.prototype.reset = function (data, opts) {
|
|
19305
19337
|
if (data) {
|
|
@@ -19348,15 +19380,15 @@
|
|
|
19348
19380
|
this.markForCheck();
|
|
19349
19381
|
};
|
|
19350
19382
|
AppForm.prototype.markAsLoading = function (opts) {
|
|
19351
|
-
if (
|
|
19352
|
-
this.
|
|
19383
|
+
if (this._$loading.value !== true) {
|
|
19384
|
+
this._$loading.next(true);
|
|
19353
19385
|
if (!opts || opts.emitEvent !== false)
|
|
19354
19386
|
this.markForCheck();
|
|
19355
19387
|
}
|
|
19356
19388
|
};
|
|
19357
19389
|
AppForm.prototype.markAsLoaded = function (opts) {
|
|
19358
|
-
if (this.
|
|
19359
|
-
this.
|
|
19390
|
+
if (this._$loading.value !== false) {
|
|
19391
|
+
this._$loading.next(false);
|
|
19360
19392
|
if (!opts || opts.emitEvent !== false)
|
|
19361
19393
|
this.markForCheck();
|
|
19362
19394
|
}
|
|
@@ -19457,7 +19489,6 @@
|
|
|
19457
19489
|
_this.network = network;
|
|
19458
19490
|
_this.cd = cd;
|
|
19459
19491
|
_this.environment = environment;
|
|
19460
|
-
_this.loading = false;
|
|
19461
19492
|
_this.canWorkOffline = false;
|
|
19462
19493
|
_this.showPwd = false;
|
|
19463
19494
|
_this.onCancel = new i0.EventEmitter();
|
|
@@ -19508,13 +19539,13 @@
|
|
|
19508
19539
|
}
|
|
19509
19540
|
if (this.form.invalid || this.loading)
|
|
19510
19541
|
return;
|
|
19511
|
-
this.
|
|
19542
|
+
this.markAsLoading();
|
|
19512
19543
|
var data = this.form.value;
|
|
19513
19544
|
this.showPwd = false; // Hide password
|
|
19514
19545
|
this.error = null; // Reset error
|
|
19515
19546
|
this.registerSubscription(this.onSubmit
|
|
19516
19547
|
.pipe(operators.debounceTime(500))
|
|
19517
|
-
.subscribe(function (res) { return _this.
|
|
19548
|
+
.subscribe(function (res) { return _this.markAsLoaded(); }));
|
|
19518
19549
|
setTimeout(function () { return _this.onSubmit.emit({
|
|
19519
19550
|
username: data.username,
|
|
19520
19551
|
password: data.password,
|
|
@@ -20269,7 +20300,6 @@
|
|
|
20269
20300
|
_this.translate = translate;
|
|
20270
20301
|
_this.settings = settings;
|
|
20271
20302
|
_this.cd = cd;
|
|
20272
|
-
_this.loading = true;
|
|
20273
20303
|
_this.email = {
|
|
20274
20304
|
confirmed: false,
|
|
20275
20305
|
notConfirmed: false,
|
|
@@ -20299,7 +20329,7 @@
|
|
|
20299
20329
|
_this.onLogin(_this.accountService.account);
|
|
20300
20330
|
}
|
|
20301
20331
|
else {
|
|
20302
|
-
_this.
|
|
20332
|
+
_this.markAsLoaded();
|
|
20303
20333
|
}
|
|
20304
20334
|
}));
|
|
20305
20335
|
return _this;
|
|
@@ -20317,7 +20347,7 @@
|
|
|
20317
20347
|
this.enable();
|
|
20318
20348
|
this.markAsPristine();
|
|
20319
20349
|
this.startListenChanges();
|
|
20320
|
-
this.
|
|
20350
|
+
this.markAsLoaded();
|
|
20321
20351
|
};
|
|
20322
20352
|
AccountPage.prototype.onLogout = function () {
|
|
20323
20353
|
this.isLogin = false;
|
|
@@ -20335,7 +20365,7 @@
|
|
|
20335
20365
|
return __awaiter(this, void 0, void 0, function () {
|
|
20336
20366
|
return __generator(this, function (_a) {
|
|
20337
20367
|
this.disable();
|
|
20338
|
-
this.
|
|
20368
|
+
this.markAsLoading();
|
|
20339
20369
|
return [2 /*return*/, this.accountService.refresh()];
|
|
20340
20370
|
});
|
|
20341
20371
|
});
|
|
@@ -20869,7 +20899,6 @@
|
|
|
20869
20899
|
_this.cd = cd;
|
|
20870
20900
|
_this.network = network;
|
|
20871
20901
|
_this.locales = locales;
|
|
20872
|
-
_this.loading = true;
|
|
20873
20902
|
_this.saving = false;
|
|
20874
20903
|
_this.usageModes = ['FIELD', 'DESK'];
|
|
20875
20904
|
_this.propertyDefinitionsByKey = {};
|
|
@@ -20959,7 +20988,7 @@
|
|
|
20959
20988
|
return __generator(this, function (_a) {
|
|
20960
20989
|
switch (_a.label) {
|
|
20961
20990
|
case 0:
|
|
20962
|
-
this.
|
|
20991
|
+
this.markAsLoading();
|
|
20963
20992
|
console.debug('[settings] Loading settings...');
|
|
20964
20993
|
data = this.settings.settings;
|
|
20965
20994
|
// Set defaults
|
|
@@ -20995,7 +21024,7 @@
|
|
|
20995
21024
|
this.enable({ emitEvent: false });
|
|
20996
21025
|
// Apply inheritance
|
|
20997
21026
|
this.setAccountInheritance(data.accountInheritance, { emitEvent: false });
|
|
20998
|
-
this.
|
|
21027
|
+
this.markAsLoaded();
|
|
20999
21028
|
this.error = null;
|
|
21000
21029
|
this.markForCheck();
|
|
21001
21030
|
};
|
|
@@ -21234,7 +21263,6 @@
|
|
|
21234
21263
|
_this.settings = settings;
|
|
21235
21264
|
_this.cd = cd;
|
|
21236
21265
|
_this.formGroupDir = formGroupDir;
|
|
21237
|
-
_this.loading = true;
|
|
21238
21266
|
_this.definitionsMapByKey = {};
|
|
21239
21267
|
_this.definitionsByIndex = {};
|
|
21240
21268
|
return _this;
|
|
@@ -21313,7 +21341,7 @@
|
|
|
21313
21341
|
this.helper.resize(values.length);
|
|
21314
21342
|
this.helper.formArray.patchValue(values, { emitEvent: false });
|
|
21315
21343
|
this.markAsPristine();
|
|
21316
|
-
this.
|
|
21344
|
+
this.markAsLoaded();
|
|
21317
21345
|
};
|
|
21318
21346
|
/* -- protected methods -- */
|
|
21319
21347
|
AppPropertiesForm.prototype.getPropertyFormGroup = function (data) {
|
|
@@ -21359,7 +21387,6 @@
|
|
|
21359
21387
|
_this.settings = settings;
|
|
21360
21388
|
_this.cd = cd;
|
|
21361
21389
|
_this.formGroupDir = formGroupDir;
|
|
21362
|
-
_this.loading = true;
|
|
21363
21390
|
_this.selection = new collections.SelectionModel(true, []);
|
|
21364
21391
|
_this.displayWithFn = referentialToString;
|
|
21365
21392
|
_this.onNewItem = new i0.EventEmitter();
|
|
@@ -21485,7 +21512,7 @@
|
|
|
21485
21512
|
}
|
|
21486
21513
|
this.selection.clear();
|
|
21487
21514
|
this.markAsPristine();
|
|
21488
|
-
this.
|
|
21515
|
+
this.markAsLoaded();
|
|
21489
21516
|
};
|
|
21490
21517
|
/** Whether the number of selected elements matches the total number of rows. */
|
|
21491
21518
|
AppListForm.prototype.isAllSelected = function () {
|
|
@@ -22783,12 +22810,6 @@
|
|
|
22783
22810
|
_this.defaultSortBy = options.defaultSortBy || 'id';
|
|
22784
22811
|
_this.defaultSortDirection = options.defaultSortDirection || 'asc';
|
|
22785
22812
|
_this.watchQueriesUpdatePolicy = options.watchQueriesUpdatePolicy || 'update-cache';
|
|
22786
|
-
platform.ready().then(function () {
|
|
22787
|
-
// No limit for updatable watch queries, if desktop
|
|
22788
|
-
if (!platform.mobile) {
|
|
22789
|
-
_this._mutableWatchQueriesMaxCount = -1;
|
|
22790
|
-
}
|
|
22791
|
-
});
|
|
22792
22813
|
var obj = new dataType();
|
|
22793
22814
|
_this._typename = obj.__typename || 'UnknownVO';
|
|
22794
22815
|
_this._logTypeName = removeEnd(_this._typename, 'VO');
|
|
@@ -23244,6 +23265,17 @@
|
|
|
23244
23265
|
return EntityFilterUtils.fromObject(source, this.filterType);
|
|
23245
23266
|
};
|
|
23246
23267
|
/* -- protected functions -- */
|
|
23268
|
+
BaseEntityService.prototype.ngOnStart = function () {
|
|
23269
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
23270
|
+
return __generator(this, function (_b) {
|
|
23271
|
+
// No limit for updatable watch queries, if desktop
|
|
23272
|
+
if (!this.platform.mobile) {
|
|
23273
|
+
this._mutableWatchQueriesMaxCount = -1;
|
|
23274
|
+
}
|
|
23275
|
+
return [2 /*return*/];
|
|
23276
|
+
});
|
|
23277
|
+
});
|
|
23278
|
+
};
|
|
23247
23279
|
BaseEntityService.prototype.fillDefaultProperties = function (source) {
|
|
23248
23280
|
// Can be override by subclasses
|
|
23249
23281
|
};
|