@sumaris-net/ngx-components 1.13.2 → 1.14.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 +237 -48
- 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 +3 -0
- package/esm2015/src/app/core/services/account.service.js +1 -3
- package/esm2015/src/app/core/services/config/core.config.js +7 -1
- package/esm2015/src/app/core/services/network.service.js +53 -4
- package/esm2015/src/app/core/services/network.utils.js +1 -1
- package/esm2015/src/app/core/services/platform.service.js +92 -8
- package/esm2015/src/app/shared/http/http.utils.js +14 -2
- package/esm2015/src/app/shared/upload-file/upload-file.component.js +12 -7
- package/esm2015/src/app/shared/upload-file/upload-file.model.js +8 -1
- package/esm2015/src/app/shared/version/versions.js +5 -1
- package/esm2015/src/environments/environment.class.js +1 -1
- package/fesm2015/sumaris-net.ngx-components.js +178 -14
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/services/config/core.config.d.ts +1 -0
- package/src/app/core/services/network.service.d.ts +10 -1
- package/src/app/core/services/network.utils.d.ts +15 -0
- package/src/app/core/services/platform.service.d.ts +5 -0
- package/src/app/shared/http/http.utils.d.ts +1 -0
- package/src/app/shared/upload-file/upload-file.model.d.ts +5 -3
- package/src/app/shared/version/versions.d.ts +2 -0
- package/src/assets/i18n/en-US.json +2 -5
- package/src/assets/i18n/en.json +2 -5
- package/src/assets/i18n/fr.json +2 -1
- package/src/assets/manifest.json +5 -5
- package/src/environments/environment.class.d.ts +1 -0
- package/src/theme/_responsive.scss +7 -3
- package/sumaris-net.ngx-components.metadata.json +1 -1
- package/src/assets/manifest.sumaris.json +0 -17
|
@@ -11206,7 +11206,18 @@
|
|
|
11206
11206
|
switch (_a.label) {
|
|
11207
11207
|
case 0:
|
|
11208
11208
|
// Add headers
|
|
11209
|
-
opts = Object.assign({}, opts
|
|
11209
|
+
opts = Object.assign({}, opts
|
|
11210
|
+
//headers: new HttpHeaders(),
|
|
11211
|
+
//.append('X-App-Name', environment.name)
|
|
11212
|
+
//.append('X-App-Version', environment.version),
|
|
11213
|
+
);
|
|
11214
|
+
// Force no cache
|
|
11215
|
+
if (opts.nocache === true) {
|
|
11216
|
+
opts.headers = (opts.headers instanceof i2$1.HttpHeaders ? opts.headers : new i2$1.HttpHeaders(opts.headers));
|
|
11217
|
+
opts.headers
|
|
11218
|
+
.append('Cache-Control', 'no-cache')
|
|
11219
|
+
.append('Pragma', 'no-cache');
|
|
11220
|
+
}
|
|
11210
11221
|
_a.label = 1;
|
|
11211
11222
|
case 1:
|
|
11212
11223
|
_a.trys.push([1, 3, , 4]);
|
|
@@ -11264,6 +11275,7 @@
|
|
|
11264
11275
|
}());
|
|
11265
11276
|
VersionUtils.compare = compareVersionNumbers;
|
|
11266
11277
|
VersionUtils.isCompatible = isVersionCompatible;
|
|
11278
|
+
VersionUtils.isSame = isSameVersion;
|
|
11267
11279
|
/**
|
|
11268
11280
|
* Compare two software version numbers (e.g. 1.7.1)
|
|
11269
11281
|
* Returns:
|
|
@@ -11332,6 +11344,9 @@
|
|
|
11332
11344
|
//console.debug(`[http] Checking actual version {${actualVersion}} is compatible with min expected version {${minVersion}}`);
|
|
11333
11345
|
return compareVersionNumbers(minVersion, actualVersion) <= 0;
|
|
11334
11346
|
}
|
|
11347
|
+
function isSameVersion(v1, v2) {
|
|
11348
|
+
return compareVersionNumbers(v1, v2) === 0;
|
|
11349
|
+
}
|
|
11335
11350
|
|
|
11336
11351
|
var SelectPeerModal = /** @class */ (function () {
|
|
11337
11352
|
function SelectPeerModal(viewCtrl, cd, http, environment) {
|
|
@@ -12470,15 +12485,81 @@
|
|
|
12470
12485
|
});
|
|
12471
12486
|
};
|
|
12472
12487
|
NetworkService.prototype.getNodeInfo = function (peer) {
|
|
12488
|
+
var path = this.computePeerPath(peer, '/api/node/info');
|
|
12489
|
+
return this.get(path);
|
|
12490
|
+
};
|
|
12491
|
+
NetworkService.prototype.getAppManifest = function (peer, opts) {
|
|
12492
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12493
|
+
var path, err_3;
|
|
12494
|
+
return __generator(this, function (_b) {
|
|
12495
|
+
switch (_b.label) {
|
|
12496
|
+
case 0:
|
|
12497
|
+
_b.trys.push([0, 2, , 3]);
|
|
12498
|
+
path = this.computePeerPath(peer, 'manifest.json');
|
|
12499
|
+
if (opts === null || opts === void 0 ? void 0 : opts.nocache) {
|
|
12500
|
+
path += '?t=' + Date.now();
|
|
12501
|
+
}
|
|
12502
|
+
return [4 /*yield*/, this.get(path, opts)];
|
|
12503
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
12504
|
+
case 2:
|
|
12505
|
+
err_3 = _b.sent();
|
|
12506
|
+
if (this.environment.production)
|
|
12507
|
+
console.error('[network] Cannot load file \'manifest.json\'. Please make sure webserver config allow CORS access', err_3);
|
|
12508
|
+
else
|
|
12509
|
+
console.error('[network] Cannot load file \'manifest.json\'.', err_3);
|
|
12510
|
+
return [3 /*break*/, 3];
|
|
12511
|
+
case 3: return [2 /*return*/];
|
|
12512
|
+
}
|
|
12513
|
+
});
|
|
12514
|
+
});
|
|
12515
|
+
};
|
|
12516
|
+
NetworkService.prototype.getAppVersion = function (peer, opts) {
|
|
12517
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12518
|
+
var path, appVersion, err_4, manifest;
|
|
12519
|
+
return __generator(this, function (_b) {
|
|
12520
|
+
switch (_b.label) {
|
|
12521
|
+
case 0:
|
|
12522
|
+
_b.trys.push([0, 2, , 3]);
|
|
12523
|
+
path = this.computePeerPath(peer, 'version.appup');
|
|
12524
|
+
if (opts === null || opts === void 0 ? void 0 : opts.nocache) {
|
|
12525
|
+
path += '?t=' + Date.now();
|
|
12526
|
+
}
|
|
12527
|
+
return [4 /*yield*/, this.get(path, opts)];
|
|
12528
|
+
case 1:
|
|
12529
|
+
appVersion = _b.sent();
|
|
12530
|
+
if (isNotNilOrBlank(appVersion))
|
|
12531
|
+
return [2 /*return*/, appVersion];
|
|
12532
|
+
return [3 /*break*/, 3];
|
|
12533
|
+
case 2:
|
|
12534
|
+
err_4 = _b.sent();
|
|
12535
|
+
if (this.environment.production)
|
|
12536
|
+
console.error('[network] Cannot load file \'version.appup\'. Please make sure webserver config allow CORS access');
|
|
12537
|
+
else
|
|
12538
|
+
console.error('[network] Cannot load file \'version.appup\'.', err_4);
|
|
12539
|
+
return [3 /*break*/, 3];
|
|
12540
|
+
case 3: return [4 /*yield*/, this.getAppManifest(peer, opts)];
|
|
12541
|
+
case 4:
|
|
12542
|
+
manifest = _b.sent();
|
|
12543
|
+
return [2 /*return*/, manifest === null || manifest === void 0 ? void 0 : manifest.version];
|
|
12544
|
+
}
|
|
12545
|
+
});
|
|
12546
|
+
});
|
|
12547
|
+
};
|
|
12548
|
+
NetworkService.prototype.computePeerPath = function (peer, path) {
|
|
12473
12549
|
peer = peer || this.peer;
|
|
12474
12550
|
if (!peer)
|
|
12475
12551
|
return undefined;
|
|
12476
|
-
var peerUrl =
|
|
12552
|
+
var peerUrl = (peer instanceof exports.Peer) ? peer.url : peer;
|
|
12477
12553
|
// Remove trailing slash
|
|
12478
12554
|
if (peerUrl.endsWith('/')) {
|
|
12479
12555
|
peerUrl = peerUrl.substr(0, peerUrl.length - 1);
|
|
12480
12556
|
}
|
|
12481
|
-
|
|
12557
|
+
// Add first path
|
|
12558
|
+
if (!path.startsWith('/')) {
|
|
12559
|
+
path = '/' + path;
|
|
12560
|
+
}
|
|
12561
|
+
// Concat peer URL and path
|
|
12562
|
+
return peerUrl + path;
|
|
12482
12563
|
};
|
|
12483
12564
|
/**
|
|
12484
12565
|
* Allow to force offline mode
|
|
@@ -15860,8 +15941,6 @@
|
|
|
15860
15941
|
};
|
|
15861
15942
|
AccountService.prototype.canUserWriteDataForDepartment = function (recorderDepartment) {
|
|
15862
15943
|
if (ReferentialUtils.isEmpty(recorderDepartment)) {
|
|
15863
|
-
if (!this.isAdmin())
|
|
15864
|
-
console.warn('Unable to check if user has right: invalid recorderDepartment', recorderDepartment);
|
|
15865
15944
|
return this.isAdmin();
|
|
15866
15945
|
}
|
|
15867
15946
|
// Should be login, and status ENABLE
|
|
@@ -17167,6 +17246,12 @@
|
|
|
17167
17246
|
key: 'sumaris.android.install.url',
|
|
17168
17247
|
label: 'CONFIGURATION.OPTIONS.ANDROID_INSTALL_URL',
|
|
17169
17248
|
type: 'string'
|
|
17249
|
+
},
|
|
17250
|
+
DB_TIMEZONE: {
|
|
17251
|
+
key: 'sumaris.persistence.db.timezone',
|
|
17252
|
+
label: 'DB Timezone (readonly)',
|
|
17253
|
+
type: 'string',
|
|
17254
|
+
isTransient: true // ONly on server, cannot be set
|
|
17170
17255
|
}
|
|
17171
17256
|
});
|
|
17172
17257
|
|
|
@@ -17656,18 +17741,19 @@
|
|
|
17656
17741
|
return this.platform.height();
|
|
17657
17742
|
};
|
|
17658
17743
|
PlatformService.prototype.ngOnStart = function () {
|
|
17744
|
+
var _a, _b;
|
|
17659
17745
|
return __awaiter(this, void 0, void 0, function () {
|
|
17660
|
-
var now, storage, err_1;
|
|
17746
|
+
var now, storage, intervalMs, err_1;
|
|
17661
17747
|
var _this = this;
|
|
17662
|
-
return __generator(this, function (
|
|
17663
|
-
switch (
|
|
17748
|
+
return __generator(this, function (_d) {
|
|
17749
|
+
switch (_d.label) {
|
|
17664
17750
|
case 0:
|
|
17665
17751
|
now = Date.now();
|
|
17666
17752
|
this.accountService.tokenType = undefined;
|
|
17667
17753
|
console.info('[platform] Starting platform...');
|
|
17668
|
-
|
|
17754
|
+
_d.label = 1;
|
|
17669
17755
|
case 1:
|
|
17670
|
-
|
|
17756
|
+
_d.trys.push([1, 7, , 8]);
|
|
17671
17757
|
this._mobile = this.is('mobile');
|
|
17672
17758
|
this._cordova = this.is('cordova');
|
|
17673
17759
|
this._android = this.is('android');
|
|
@@ -17679,29 +17765,37 @@
|
|
|
17679
17765
|
return [4 /*yield*/, this.configureTranslate()];
|
|
17680
17766
|
case 2:
|
|
17681
17767
|
// Configure translation
|
|
17682
|
-
|
|
17768
|
+
_d.sent();
|
|
17683
17769
|
return [4 /*yield*/, this.storageReady()];
|
|
17684
17770
|
case 3:
|
|
17685
|
-
storage =
|
|
17771
|
+
storage = _d.sent();
|
|
17686
17772
|
return [4 /*yield*/, this.migrateStorage(storage)];
|
|
17687
17773
|
case 4:
|
|
17688
|
-
|
|
17774
|
+
_d.sent();
|
|
17689
17775
|
// Start root services
|
|
17690
17776
|
return [4 /*yield*/, Promise.all([
|
|
17691
17777
|
this.entitiesStorage.ready(),
|
|
17692
|
-
this.cache.ready()
|
|
17778
|
+
this.cache.ready(),
|
|
17693
17779
|
this.settings.ready(),
|
|
17694
17780
|
this.networkService.ready(),
|
|
17695
17781
|
this.audioProvider.ready()
|
|
17696
17782
|
])];
|
|
17697
17783
|
case 5:
|
|
17698
17784
|
// Start root services
|
|
17699
|
-
|
|
17700
|
-
|
|
17785
|
+
_d.sent();
|
|
17786
|
+
return [4 /*yield*/, Promise.all([
|
|
17787
|
+
this.configureCache(),
|
|
17788
|
+
this.checkAppVersion({ canReload: true })
|
|
17789
|
+
])];
|
|
17790
|
+
case 6:
|
|
17791
|
+
_d.sent();
|
|
17701
17792
|
// Update cache configuration when network changed
|
|
17702
17793
|
this.networkService.onNetworkStatusChanges
|
|
17703
|
-
.pipe(operators.skip(1)
|
|
17704
|
-
|
|
17794
|
+
.pipe(operators.skip(1), operators.map(function (type) { return type !== 'none'; }), operators.debounceTime(1000), operators.distinctUntilChanged(),
|
|
17795
|
+
// Configure the cache
|
|
17796
|
+
operators.tap(function (online) { return _this.configureCache(online); }))
|
|
17797
|
+
.subscribe();
|
|
17798
|
+
console.info("[platform] Starting platform [OK] {mobile: " + this._mobile + ", web: " + this.isWeb() + ", downloader: " + this.canDownload + ", fileOpener: " + this.canOpenFile + "} in " + (Date.now() - now) + "ms");
|
|
17705
17799
|
// Update authentication type
|
|
17706
17800
|
this.configService.config
|
|
17707
17801
|
.pipe(operators.map(function (config) { return config === null || config === void 0 ? void 0 : config.getProperty(CORE_CONFIG_OPTIONS.AUTH_TOKEN_TYPE); }), operators.filter(isNotNilOrBlank), operators.distinctUntilChanged())
|
|
@@ -17718,12 +17812,21 @@
|
|
|
17718
17812
|
_this.audioProvider.playStartupSound();
|
|
17719
17813
|
}, 1000);
|
|
17720
17814
|
}
|
|
17721
|
-
|
|
17722
|
-
|
|
17723
|
-
|
|
17815
|
+
// Check if new version, every 1 min
|
|
17816
|
+
if (this.isWeb()) {
|
|
17817
|
+
intervalMs = (((_a = this.environment) === null || _a === void 0 ? void 0 : _a.checkAppVersionIntervalInSeconds) || 0) * 1000;
|
|
17818
|
+
if (intervalMs > 0) {
|
|
17819
|
+
(_b = this.checkAppVersionTimer) === null || _b === void 0 ? void 0 : _b.unsubscribe();
|
|
17820
|
+
this.checkAppVersionTimer = rxjs.timer(intervalMs, intervalMs)
|
|
17821
|
+
.subscribe(function (_) { return _this.checkAppVersion({ silent: true, canReload: false /*do NOT auto reload, when app is started*/ }); });
|
|
17822
|
+
}
|
|
17823
|
+
}
|
|
17824
|
+
return [3 /*break*/, 8];
|
|
17825
|
+
case 7:
|
|
17826
|
+
err_1 = _d.sent();
|
|
17724
17827
|
// Manage startup error
|
|
17725
17828
|
return [2 /*return*/, this.onStartupError(err_1)];
|
|
17726
|
-
case
|
|
17829
|
+
case 8: return [2 /*return*/];
|
|
17727
17830
|
}
|
|
17728
17831
|
});
|
|
17729
17832
|
});
|
|
@@ -17844,16 +17947,88 @@
|
|
|
17844
17947
|
this.cache.setDefaultTTL(cacheTTL);
|
|
17845
17948
|
this.cache.setOfflineInvalidate(false); // Do not invalidate cache when offline
|
|
17846
17949
|
};
|
|
17950
|
+
PlatformService.prototype.checkAppVersion = function (opts) {
|
|
17951
|
+
var _a, _b, _c;
|
|
17952
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
17953
|
+
var silent, production, actualVersion, peer, remoteVersion, canAutoReload, reloadPath;
|
|
17954
|
+
return __generator(this, function (_d) {
|
|
17955
|
+
switch (_d.label) {
|
|
17956
|
+
case 0:
|
|
17957
|
+
if (this.networkService.offline || !this.isWeb())
|
|
17958
|
+
return [2 /*return*/]; // Skip
|
|
17959
|
+
silent = (opts === null || opts === void 0 ? void 0 : opts.silent) === true;
|
|
17960
|
+
production = this.environment.production;
|
|
17961
|
+
if (!silent)
|
|
17962
|
+
console.info('[platform] Checking remote app version...');
|
|
17963
|
+
actualVersion = this.environment.version;
|
|
17964
|
+
if (isNilOrBlank(actualVersion)) {
|
|
17965
|
+
console.warn('[platform] Missing required value for \'environment.version\'. Cannot check remote app version.');
|
|
17966
|
+
(_a = this.checkAppVersionTimer) === null || _a === void 0 ? void 0 : _a.unsubscribe(); // Stop timer if exists
|
|
17967
|
+
return [2 /*return*/]; // Skip
|
|
17968
|
+
}
|
|
17969
|
+
peer = undefined;
|
|
17970
|
+
return [4 /*yield*/, this.networkService.getAppVersion(peer)];
|
|
17971
|
+
case 1:
|
|
17972
|
+
remoteVersion = _d.sent();
|
|
17973
|
+
if (isNilOrBlank(remoteVersion)) {
|
|
17974
|
+
if (production && !silent)
|
|
17975
|
+
console.error('[platform] Cannot load remote app version. Skipping version check');
|
|
17976
|
+
(_b = this.checkAppVersionTimer) === null || _b === void 0 ? void 0 : _b.unsubscribe(); // Stop timer if exists
|
|
17977
|
+
return [2 /*return*/];
|
|
17978
|
+
}
|
|
17979
|
+
if (VersionUtils.isCompatible(remoteVersion, actualVersion)) {
|
|
17980
|
+
if (!silent)
|
|
17981
|
+
console.info('[platform] Checking remote app version [OK]');
|
|
17982
|
+
return [2 /*return*/];
|
|
17983
|
+
}
|
|
17984
|
+
canAutoReload = !opts || opts.canReload !== false;
|
|
17985
|
+
// Avoid infinite loop, if already reloaded
|
|
17986
|
+
if (location.href.indexOf('?version=' + remoteVersion) !== -1) {
|
|
17987
|
+
if (canAutoReload)
|
|
17988
|
+
console.error("[platform] Reloaded page failed, because version still mismatch! Please check version.appup file (expected app version: " + actualVersion + ")");
|
|
17989
|
+
(_c = this.checkAppVersionTimer) === null || _c === void 0 ? void 0 : _c.unsubscribe();
|
|
17990
|
+
return [2 /*return*/];
|
|
17991
|
+
}
|
|
17992
|
+
console.warn("[platform] More recent version detected (remote: " + remoteVersion + ", actual: " + actualVersion);
|
|
17993
|
+
reloadPath = location.href.replace(/[&?]{1}[a-z_-]=[0-9.]+/gi, '');
|
|
17994
|
+
reloadPath += (reloadPath.indexOf('?') === -1) ? '?' : '&'; // Add query param separator
|
|
17995
|
+
reloadPath += 'version=' + remoteVersion; // Add version (to avoid a reload infinite loop)
|
|
17996
|
+
console.info('[platform] Will reloading at ' + reloadPath);
|
|
17997
|
+
if (!canAutoReload) return [3 /*break*/, 2];
|
|
17998
|
+
location.href = reloadPath;
|
|
17999
|
+
return [3 /*break*/, 4];
|
|
18000
|
+
case 2: return [4 /*yield*/, this.showToast({
|
|
18001
|
+
message: 'CONFIRM.RELOAD_APP',
|
|
18002
|
+
messageParams: { version: remoteVersion, name: this.environment.name },
|
|
18003
|
+
type: 'info', duration: -1,
|
|
18004
|
+
buttons: [
|
|
18005
|
+
// Reload button
|
|
18006
|
+
{ text: this.translate.instant('COMMON.BTN_RELOAD'),
|
|
18007
|
+
side: 'end', handler: function () {
|
|
18008
|
+
location.href = reloadPath;
|
|
18009
|
+
return true;
|
|
18010
|
+
}
|
|
18011
|
+
}
|
|
18012
|
+
]
|
|
18013
|
+
})];
|
|
18014
|
+
case 3:
|
|
18015
|
+
_d.sent();
|
|
18016
|
+
_d.label = 4;
|
|
18017
|
+
case 4: return [2 /*return*/];
|
|
18018
|
+
}
|
|
18019
|
+
});
|
|
18020
|
+
});
|
|
18021
|
+
};
|
|
17847
18022
|
PlatformService.prototype.storageReady = function () {
|
|
17848
18023
|
return __awaiter(this, void 0, void 0, function () {
|
|
17849
18024
|
var forage, driver;
|
|
17850
|
-
return __generator(this, function (
|
|
17851
|
-
switch (
|
|
18025
|
+
return __generator(this, function (_d) {
|
|
18026
|
+
switch (_d.label) {
|
|
17852
18027
|
case 0:
|
|
17853
18028
|
console.info("[platform] Starting storage...");
|
|
17854
18029
|
return [4 /*yield*/, this.storage.ready()];
|
|
17855
18030
|
case 1:
|
|
17856
|
-
forage =
|
|
18031
|
+
forage = _d.sent();
|
|
17857
18032
|
driver = forage.driver();
|
|
17858
18033
|
if (isNil(driver)) {
|
|
17859
18034
|
console.error('[platform] NO DRIVER DEFINED IN STORAGE. Local storage cannot be used !');
|
|
@@ -17869,8 +18044,8 @@
|
|
|
17869
18044
|
PlatformService.prototype.migrateStorage = function (storage) {
|
|
17870
18045
|
return __awaiter(this, void 0, void 0, function () {
|
|
17871
18046
|
var canMigrate, oldForage, keys, now, toast_1, duration, err_2;
|
|
17872
|
-
return __generator(this, function (
|
|
17873
|
-
switch (
|
|
18047
|
+
return __generator(this, function (_d) {
|
|
18048
|
+
switch (_d.label) {
|
|
17874
18049
|
case 0:
|
|
17875
18050
|
canMigrate = storage &&
|
|
17876
18051
|
((storage.driver() === 'cordovaSQLiteDriver' && (storage.supports(storage.INDEXEDDB) || storage.supports(storage.WEBSQL))) ||
|
|
@@ -17884,26 +18059,26 @@
|
|
|
17884
18059
|
});
|
|
17885
18060
|
return [4 /*yield*/, oldForage.keys()];
|
|
17886
18061
|
case 1:
|
|
17887
|
-
keys =
|
|
18062
|
+
keys = _d.sent();
|
|
17888
18063
|
if (!isEmptyArray(keys)) return [3 /*break*/, 3];
|
|
17889
18064
|
// Drop the old instance (not need anymore)
|
|
17890
18065
|
console.debug("[platform] Old storage is empty: dropping unused instance {name: '" + storage.config().name + "', driver: '" + oldForage.driver() + "'}");
|
|
17891
18066
|
return [4 /*yield*/, oldForage.dropInstance()];
|
|
17892
18067
|
case 2:
|
|
17893
|
-
|
|
18068
|
+
_d.sent();
|
|
17894
18069
|
return [3 /*break*/, 12];
|
|
17895
18070
|
case 3:
|
|
17896
18071
|
now = Date.now();
|
|
17897
18072
|
console.info("[platform] Starting storage migration...");
|
|
17898
18073
|
return [4 /*yield*/, this.showToast({ message: 'INFO.DATA_MIGRATION_STARTED', type: 'info', duration: 30000 })];
|
|
17899
18074
|
case 4:
|
|
17900
|
-
toast_1 =
|
|
17901
|
-
|
|
18075
|
+
toast_1 = _d.sent();
|
|
18076
|
+
_d.label = 5;
|
|
17902
18077
|
case 5:
|
|
17903
|
-
|
|
18078
|
+
_d.trys.push([5, 9, , 12]);
|
|
17904
18079
|
return [4 /*yield*/, StorageUtils.copy(oldForage, storage, { keys: keys, deleteAfterCopy: false })];
|
|
17905
18080
|
case 6:
|
|
17906
|
-
|
|
18081
|
+
_d.sent();
|
|
17907
18082
|
duration = Date.now() - now;
|
|
17908
18083
|
setTimeout(function () { return toast_1.dismiss(); }, Math.max(2000 - duration, 0));
|
|
17909
18084
|
return [4 /*yield*/, this.showToast({ message: 'INFO.DATA_MIGRATION_SUCCEED',
|
|
@@ -17911,26 +18086,26 @@
|
|
|
17911
18086
|
showCloseButton: true
|
|
17912
18087
|
})];
|
|
17913
18088
|
case 7:
|
|
17914
|
-
|
|
18089
|
+
_d.sent();
|
|
17915
18090
|
console.info('[platform] Starting storage migration [OK]');
|
|
17916
18091
|
// Drop the old instance
|
|
17917
18092
|
console.info("[platform] Drop old storage {name: '" + storage.config().name + "', driver: '" + oldForage.driver() + "'}");
|
|
17918
18093
|
return [4 /*yield*/, oldForage.dropInstance()];
|
|
17919
18094
|
case 8:
|
|
17920
|
-
|
|
18095
|
+
_d.sent();
|
|
17921
18096
|
return [3 /*break*/, 12];
|
|
17922
18097
|
case 9:
|
|
17923
|
-
err_2 =
|
|
18098
|
+
err_2 = _d.sent();
|
|
17924
18099
|
console.error(err_2 && err_2.message || err_2, err_2);
|
|
17925
18100
|
return [4 /*yield*/, toast_1.dismiss()];
|
|
17926
18101
|
case 10:
|
|
17927
|
-
|
|
18102
|
+
_d.sent();
|
|
17928
18103
|
return [4 /*yield*/, this.showToast({ message: 'ERROR.DATA_MIGRATION_FAILED',
|
|
17929
18104
|
type: 'error',
|
|
17930
18105
|
showCloseButton: true
|
|
17931
18106
|
})];
|
|
17932
18107
|
case 11:
|
|
17933
|
-
|
|
18108
|
+
_d.sent();
|
|
17934
18109
|
return [3 /*break*/, 12];
|
|
17935
18110
|
case 12: return [2 /*return*/];
|
|
17936
18111
|
}
|
|
@@ -17946,8 +18121,8 @@
|
|
|
17946
18121
|
PlatformService.prototype.onStartupError = function (err) {
|
|
17947
18122
|
return __awaiter(this, void 0, void 0, function () {
|
|
17948
18123
|
var message, detailsMessage;
|
|
17949
|
-
return __generator(this, function (
|
|
17950
|
-
switch (
|
|
18124
|
+
return __generator(this, function (_d) {
|
|
18125
|
+
switch (_d.label) {
|
|
17951
18126
|
case 0:
|
|
17952
18127
|
console.error('[platform] Failed starting the platform! ', err);
|
|
17953
18128
|
message = err && err.message || err;
|
|
@@ -17959,14 +18134,14 @@
|
|
|
17959
18134
|
if (!this.translate) return [3 /*break*/, 2];
|
|
17960
18135
|
return [4 /*yield*/, this.translate.get(message).toPromise()];
|
|
17961
18136
|
case 1:
|
|
17962
|
-
message =
|
|
18137
|
+
message = _d.sent();
|
|
17963
18138
|
if (err && err.code) {
|
|
17964
18139
|
message += " {code: " + err.code + "}";
|
|
17965
18140
|
}
|
|
17966
18141
|
return [3 /*break*/, 3];
|
|
17967
18142
|
case 2:
|
|
17968
18143
|
message = "Fatal error: Please contact your administrator.\n\n{code: " + (err && err.code || 'null') + ", message: \"" + message + "\"}";
|
|
17969
|
-
|
|
18144
|
+
_d.label = 3;
|
|
17970
18145
|
case 3:
|
|
17971
18146
|
if (!this.toastController) return [3 /*break*/, 5];
|
|
17972
18147
|
if (detailsMessage) {
|
|
@@ -17979,7 +18154,7 @@
|
|
|
17979
18154
|
message: message
|
|
17980
18155
|
})];
|
|
17981
18156
|
case 4:
|
|
17982
|
-
|
|
18157
|
+
_d.sent();
|
|
17983
18158
|
return [3 /*break*/, 6];
|
|
17984
18159
|
case 5:
|
|
17985
18160
|
if (window) {
|
|
@@ -17993,7 +18168,7 @@
|
|
|
17993
18168
|
if (err && err.details)
|
|
17994
18169
|
console.error('cause', err.details);
|
|
17995
18170
|
}
|
|
17996
|
-
|
|
18171
|
+
_d.label = 6;
|
|
17997
18172
|
case 6: return [2 /*return*/];
|
|
17998
18173
|
}
|
|
17999
18174
|
});
|
|
@@ -18123,6 +18298,13 @@
|
|
|
18123
18298
|
}
|
|
18124
18299
|
return FileResponse;
|
|
18125
18300
|
}());
|
|
18301
|
+
function isProgressEvent(event) {
|
|
18302
|
+
return event.type === i2$1.HttpEventType.UploadProgress
|
|
18303
|
+
|| event.type === i2$1.HttpEventType.DownloadProgress;
|
|
18304
|
+
}
|
|
18305
|
+
function isResponseEvent(event) {
|
|
18306
|
+
return event.type === i2$1.HttpEventType.Response;
|
|
18307
|
+
}
|
|
18126
18308
|
|
|
18127
18309
|
var UploadFileComponent = /** @class */ (function () {
|
|
18128
18310
|
function UploadFileComponent(cd, translate) {
|
|
@@ -18289,7 +18471,7 @@
|
|
|
18289
18471
|
operators.switchMap(function (file) { return _this.uploadFn(file)
|
|
18290
18472
|
.pipe(operators.map(function (event) {
|
|
18291
18473
|
// Progress event
|
|
18292
|
-
if ((event
|
|
18474
|
+
if (isProgressEvent(event)) {
|
|
18293
18475
|
if (isNotNil(event.loaded) && event.loaded >= 0) {
|
|
18294
18476
|
file.progress = Math.min(1, event.loaded / (event.total || 1));
|
|
18295
18477
|
}
|
|
@@ -18297,15 +18479,20 @@
|
|
|
18297
18479
|
file.progress = -1; // Indeterminate progression
|
|
18298
18480
|
}
|
|
18299
18481
|
}
|
|
18482
|
+
// User event
|
|
18483
|
+
else if (event.type === i2$1.HttpEventType.User) {
|
|
18484
|
+
file.progress = -1; // Indeterminate progression
|
|
18485
|
+
}
|
|
18300
18486
|
// Response event
|
|
18301
|
-
else if (event
|
|
18487
|
+
else if (isResponseEvent(event)) {
|
|
18302
18488
|
file.progress = 1;
|
|
18303
18489
|
file.response = event;
|
|
18304
18490
|
console.debug("[upload-file] " + file.name + ": " + (event.statusText || 'OK'), file.response);
|
|
18305
18491
|
}
|
|
18306
|
-
// Other events
|
|
18492
|
+
// Other events: ignore
|
|
18307
18493
|
else {
|
|
18308
|
-
|
|
18494
|
+
// DEBUG
|
|
18495
|
+
console.debug('[upload-file] Ignoring a file event: ', event);
|
|
18309
18496
|
}
|
|
18310
18497
|
return file;
|
|
18311
18498
|
}), operators.catchError(function (err) {
|
|
@@ -31136,6 +31323,8 @@
|
|
|
31136
31323
|
exports.isNotNilString = isNotNilString;
|
|
31137
31324
|
exports.isNumber = isNumber;
|
|
31138
31325
|
exports.isNumberRange = isNumberRange;
|
|
31326
|
+
exports.isProgressEvent = isProgressEvent;
|
|
31327
|
+
exports.isResponseEvent = isResponseEvent;
|
|
31139
31328
|
exports.isTouchUi = isTouchUi;
|
|
31140
31329
|
exports.isWindow = isWindow;
|
|
31141
31330
|
exports.joinProperties = joinProperties;
|