@sumaris-net/ngx-components 1.15.8 → 1.15.11
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 +37 -20
- 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/doc/changelog.md +6 -0
- package/esm2015/src/app/core/form/entity-editor.class.js +27 -15
- package/esm2015/src/app/core/services/base-entity-service.class.js +2 -1
- package/esm2015/src/app/core/services/base-graphql-service.class.js +7 -3
- package/esm2015/src/app/core/services/config.service.js +3 -3
- package/esm2015/src/app/core/services/network.service.js +3 -3
- package/fesm2015/sumaris-net.ngx-components.js +36 -20
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/services/base-entity-service.class.d.ts +2 -1
- package/src/assets/i18n/en-US.json +3 -0
- package/src/assets/i18n/en.json +3 -0
- package/src/assets/i18n/fr.json +3 -2
|
@@ -10928,7 +10928,7 @@ class NetworkService extends StartableService {
|
|
|
10928
10928
|
this.onNetworkStatusChanges = new BehaviorSubject(null);
|
|
10929
10929
|
this.onResetNetworkCache = new EventEmitter(true);
|
|
10930
10930
|
this._listeners = {};
|
|
10931
|
-
this._mobile = this.
|
|
10931
|
+
this._mobile = this.settings.mobile;
|
|
10932
10932
|
if (this._mobile) {
|
|
10933
10933
|
this._timerRefreshPeriod = NetworkRefreshTimerPeriod.MOBILE;
|
|
10934
10934
|
this._timerRefreshCondition = () => this.online; // Check only when online, and stop when offline
|
|
@@ -11253,7 +11253,7 @@ class NetworkService extends StartableService {
|
|
|
11253
11253
|
/* -- protected functions -- */
|
|
11254
11254
|
ngOnStart() {
|
|
11255
11255
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11256
|
-
console.info('[network] Starting network...'
|
|
11256
|
+
console.info('[network] Starting network...');
|
|
11257
11257
|
// Restoring local settings
|
|
11258
11258
|
let peer = this._startingPeer || (yield this.restoreLocally());
|
|
11259
11259
|
// Make sure to hide the splashscreen, before open the modal
|
|
@@ -13777,7 +13777,9 @@ class BaseGraphqlService extends StartableService {
|
|
|
13777
13777
|
return this._mutableWatchQueries.filter(q => q.id.startsWith(opts.queryName + '|'));
|
|
13778
13778
|
}
|
|
13779
13779
|
if (opts.queryNames) {
|
|
13780
|
-
return opts.queryNames.
|
|
13780
|
+
return opts.queryNames.map(queryName => this._mutableWatchQueries.filter(q => q.id.startsWith(queryName + '|')))
|
|
13781
|
+
// flatMap
|
|
13782
|
+
.reduce((res, array) => res.concat(...array), []);
|
|
13781
13783
|
}
|
|
13782
13784
|
// Search by query
|
|
13783
13785
|
if (opts.query) {
|
|
@@ -13786,7 +13788,9 @@ class BaseGraphqlService extends StartableService {
|
|
|
13786
13788
|
if (opts.queries) {
|
|
13787
13789
|
return opts.queries
|
|
13788
13790
|
.filter(isNotNil)
|
|
13789
|
-
.
|
|
13791
|
+
.map(query => this._mutableWatchQueries.filter(q => q.query === query))
|
|
13792
|
+
// flatMap
|
|
13793
|
+
.reduce((res, array) => res.concat(...array), []);
|
|
13790
13794
|
}
|
|
13791
13795
|
throw Error('Invalid options: only one property must be set');
|
|
13792
13796
|
}
|
|
@@ -15376,12 +15380,12 @@ class ConfigService extends BaseGraphqlService {
|
|
|
15376
15380
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15377
15381
|
const now = Date.now();
|
|
15378
15382
|
console.debug('[config] Clear server cache...');
|
|
15379
|
-
const variables =
|
|
15383
|
+
const variables = opts && opts.cacheName && { name: opts.cacheName } || undefined;
|
|
15380
15384
|
const res = yield this.graphql.query({
|
|
15381
15385
|
query: ClearCache,
|
|
15382
15386
|
variables,
|
|
15383
15387
|
error: { code: ErrorCodes$2.LOAD_CONFIG_ERROR, message: 'ERROR.LOAD_CONFIG_ERROR' },
|
|
15384
|
-
fetchPolicy: '
|
|
15388
|
+
fetchPolicy: 'no-cache'
|
|
15385
15389
|
});
|
|
15386
15390
|
const data = res && res.clearCache || undefined;
|
|
15387
15391
|
console.info(`[config] Clear server cache in ${Date.now() - now}ms:`, data);
|
|
@@ -21320,6 +21324,7 @@ class BaseEntityService extends BaseGraphqlService {
|
|
|
21320
21324
|
console.debug(this._logPrefix + `[WS] Listening for changes on ${this._logTypeName} {${id}}...`);
|
|
21321
21325
|
return this.graphql.subscribe({
|
|
21322
21326
|
query: opts && opts.query || this.subscriptions.listenChanges,
|
|
21327
|
+
fetchPolicy: opts && opts.fetchPolicy || 'no-cache',
|
|
21323
21328
|
variables,
|
|
21324
21329
|
error: {
|
|
21325
21330
|
code: ErrorCodes$2.SUBSCRIBE_DATA_ERROR,
|
|
@@ -24106,23 +24111,31 @@ class AppEntityEditor extends AppTabEditor {
|
|
|
24106
24111
|
}
|
|
24107
24112
|
startListenRemoteChanges() {
|
|
24108
24113
|
// Skip if disable, or already listening
|
|
24109
|
-
if (this._listenChangesSubscription || !this._enableListenChanges
|
|
24114
|
+
if (this._listenChangesSubscription || !this._enableListenChanges)
|
|
24115
|
+
return;
|
|
24116
|
+
// Skip if new or local data
|
|
24117
|
+
if (this.isNewData || EntityUtils.isLocal(this.data))
|
|
24110
24118
|
return;
|
|
24111
24119
|
// Listen for changes on server
|
|
24112
|
-
this._listenChangesSubscription = this.listenChanges(this.data.id, {
|
|
24120
|
+
this._listenChangesSubscription = this.listenChanges(this.data.id, {
|
|
24121
|
+
interval: this._listenIntervalInSeconds
|
|
24122
|
+
})
|
|
24113
24123
|
.pipe(filter(isNotNil))
|
|
24114
24124
|
.subscribe((data) => {
|
|
24115
|
-
|
|
24116
|
-
|
|
24117
|
-
|
|
24118
|
-
|
|
24119
|
-
|
|
24120
|
-
|
|
24121
|
-
|
|
24122
|
-
|
|
24123
|
-
|
|
24124
|
-
|
|
24125
|
-
|
|
24125
|
+
const isNewer = isMoment(data.updateDate) && data.updateDate.isAfter(this.data.updateDate);
|
|
24126
|
+
if (!isNewer)
|
|
24127
|
+
return; // Skip
|
|
24128
|
+
// Editor has no changes: reload
|
|
24129
|
+
if (!this.dirty) {
|
|
24130
|
+
if (this.debug)
|
|
24131
|
+
console.debug(`[data-editor] Changes detected on server, at {${data.updateDate}}: reloading page...`);
|
|
24132
|
+
this.reload();
|
|
24133
|
+
}
|
|
24134
|
+
// Cannot reload: alert the user
|
|
24135
|
+
else {
|
|
24136
|
+
if (this.debug)
|
|
24137
|
+
console.debug(`[data-editor] Changes detected on server, at {${data.updateDate}}, but page is dirty: skip reloading.`);
|
|
24138
|
+
this.showToast({ message: 'ERROR.DATA_UPDATE_DATE_CHANGED', type: 'warning', showCloseButton: true });
|
|
24126
24139
|
}
|
|
24127
24140
|
});
|
|
24128
24141
|
this._listenChangesSubscription.add(() => this._listenChangesSubscription = null);
|
|
@@ -24532,7 +24545,10 @@ class AppEntityEditor extends AppTabEditor {
|
|
|
24532
24545
|
return parentUrl;
|
|
24533
24546
|
}
|
|
24534
24547
|
listenChanges(id, opts) {
|
|
24535
|
-
return this.dataService.listenChanges(this.data.id,
|
|
24548
|
+
return this.dataService.listenChanges(this.data.id, Object.assign({
|
|
24549
|
+
// Make sure to skip cache, because NOT the full graph will be fetched by subscription
|
|
24550
|
+
// When a changes occur, we call reload() to force refetching the full graph
|
|
24551
|
+
fetchPolicy: 'no-cache' }, opts));
|
|
24536
24552
|
}
|
|
24537
24553
|
markForCheck() {
|
|
24538
24554
|
this.cd.markForCheck();
|