@sumaris-net/ngx-components 0.25.4 → 0.25.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/sumaris-net.ngx-components.umd.js +75 -83
- 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/esm2015/src/app/core/install/install-upgrade-card.component.js +30 -26
- package/esm2015/src/app/core/services/platform.service.js +38 -44
- package/fesm2015/sumaris-net.ngx-components.js +64 -66
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/install/install-upgrade-card.component.d.ts +2 -2
- package/src/app/core/services/platform.service.d.ts +4 -3
- package/src/assets/i18n/en-US.json +4 -0
- package/src/assets/i18n/en.json +4 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -15678,7 +15678,7 @@
|
|
|
15678
15678
|
this.browser = browser;
|
|
15679
15679
|
this.downloader = downloader;
|
|
15680
15680
|
this._started = false;
|
|
15681
|
-
this.
|
|
15681
|
+
this._downloadingJobs = new Map();
|
|
15682
15682
|
this._debug = !environment.production;
|
|
15683
15683
|
if (this._debug)
|
|
15684
15684
|
console.debug('[platform] Creating service');
|
|
@@ -15808,56 +15808,43 @@
|
|
|
15808
15808
|
window.open(url, target, features, replace);
|
|
15809
15809
|
}
|
|
15810
15810
|
};
|
|
15811
|
-
PlatformService.prototype.
|
|
15812
|
-
return
|
|
15813
|
-
return __generator(this, function (_a) {
|
|
15814
|
-
return [2 /*return*/, this._downloadingPromise.get(uri)];
|
|
15815
|
-
});
|
|
15816
|
-
});
|
|
15811
|
+
PlatformService.prototype.getDownloadingJob = function (uri) {
|
|
15812
|
+
return this._downloadingJobs.get(uri);
|
|
15817
15813
|
};
|
|
15818
15814
|
PlatformService.prototype.download = function (request) {
|
|
15819
|
-
|
|
15820
|
-
|
|
15821
|
-
|
|
15822
|
-
|
|
15823
|
-
|
|
15824
|
-
|
|
15825
|
-
|
|
15826
|
-
|
|
15827
|
-
|
|
15828
|
-
|
|
15829
|
-
|
|
15830
|
-
|
|
15831
|
-
|
|
15832
|
-
|
|
15833
|
-
|
|
15834
|
-
|
|
15835
|
-
|
|
15836
|
-
|
|
15837
|
-
|
|
15838
|
-
|
|
15839
|
-
|
|
15840
|
-
|
|
15841
|
-
|
|
15842
|
-
|
|
15843
|
-
|
|
15844
|
-
|
|
15845
|
-
|
|
15846
|
-
|
|
15847
|
-
|
|
15848
|
-
|
|
15849
|
-
|
|
15850
|
-
|
|
15851
|
-
|
|
15852
|
-
case 5: return [3 /*break*/, 7];
|
|
15853
|
-
case 6:
|
|
15854
|
-
console.warn('[platform] Cannot use Android downloader: using browser open()');
|
|
15855
|
-
this.open(request.uri, '_system', 'location=no', true);
|
|
15856
|
-
return [2 /*return*/, undefined];
|
|
15857
|
-
case 7: return [2 /*return*/];
|
|
15858
|
-
}
|
|
15859
|
-
});
|
|
15860
|
-
});
|
|
15815
|
+
var _this = this;
|
|
15816
|
+
if (!request || !request.uri)
|
|
15817
|
+
throw new Error('Missing argument \'request\' or \'request.uri\'');
|
|
15818
|
+
if (this._android && this.downloader) {
|
|
15819
|
+
// Check if not already downloading file
|
|
15820
|
+
var location$ = this._downloadingJobs.get(request.uri);
|
|
15821
|
+
if (location$)
|
|
15822
|
+
return location$;
|
|
15823
|
+
request = Object.assign({ visibleInDownloadsUi: true, notificationVisibility: ngx$6.NotificationVisibility.VisibleNotifyCompleted, title: request.title || request.filename }, request);
|
|
15824
|
+
console.debug('[platform] Downloading, using request: ' + JSON.stringify(request));
|
|
15825
|
+
// Start download
|
|
15826
|
+
location$ = rxjs.from(this.downloader.download(request));
|
|
15827
|
+
// Remember this request uri
|
|
15828
|
+
this._downloadingJobs.set(request.uri, location$);
|
|
15829
|
+
return location$
|
|
15830
|
+
.pipe(operators.tap(function (location) {
|
|
15831
|
+
console.info('[platform] File successfully downloaded at:' + location);
|
|
15832
|
+
// Forget the request
|
|
15833
|
+
_this._downloadingJobs.delete(request.uri);
|
|
15834
|
+
}), operators.catchError(function (err) {
|
|
15835
|
+
console.error('[platform] Unable to download: ' + (err && err.message || err));
|
|
15836
|
+
// Forget the request
|
|
15837
|
+
_this._downloadingJobs.delete(request.uri);
|
|
15838
|
+
throw err;
|
|
15839
|
+
}));
|
|
15840
|
+
}
|
|
15841
|
+
// Fallback (if not Android and Cordova): opening the URI using the browser
|
|
15842
|
+
// TODO: find a way to download under iOS (see https://www.c-sharpcorner.com/article/how-to-download-a-file-using-file-transfer-plugin-in-ionic-3/)
|
|
15843
|
+
else {
|
|
15844
|
+
console.warn('[platform] Cannot use Android downloader: using browser open()');
|
|
15845
|
+
this.open(request.uri, '_system', 'location=no', true);
|
|
15846
|
+
return rxjs.of();
|
|
15847
|
+
}
|
|
15861
15848
|
};
|
|
15862
15849
|
/* -- protected methods -- */
|
|
15863
15850
|
PlatformService.prototype.configureCordovaPlugins = function (mobile) {
|
|
@@ -15953,7 +15940,7 @@
|
|
|
15953
15940
|
};
|
|
15954
15941
|
PlatformService.prototype.migrateStorage = function (forage) {
|
|
15955
15942
|
return __awaiter(this, void 0, void 0, function () {
|
|
15956
|
-
var canMigrate, oldForage, keys, now, toast_1, duration,
|
|
15943
|
+
var canMigrate, oldForage, keys, now, toast_1, duration, err_1;
|
|
15957
15944
|
return __generator(this, function (_a) {
|
|
15958
15945
|
switch (_a.label) {
|
|
15959
15946
|
case 0:
|
|
@@ -16006,8 +15993,8 @@
|
|
|
16006
15993
|
_a.sent();
|
|
16007
15994
|
return [3 /*break*/, 12];
|
|
16008
15995
|
case 9:
|
|
16009
|
-
|
|
16010
|
-
console.error(
|
|
15996
|
+
err_1 = _a.sent();
|
|
15997
|
+
console.error(err_1 && err_1.message || err_1, err_1);
|
|
16011
15998
|
return [4 /*yield*/, toast_1.dismiss()];
|
|
16012
15999
|
case 10:
|
|
16013
16000
|
_a.sent();
|
|
@@ -21329,6 +21316,7 @@
|
|
|
21329
21316
|
this._subscription = new rxjs.Subscription();
|
|
21330
21317
|
this._showUpdateOfflineFeature = false;
|
|
21331
21318
|
this.loading = true;
|
|
21319
|
+
this.downloading = false;
|
|
21332
21320
|
this.waitingNetwork = false;
|
|
21333
21321
|
this.showUpgradeWarning = true;
|
|
21334
21322
|
this.showOfflineWarning = true;
|
|
@@ -21359,7 +21347,7 @@
|
|
|
21359
21347
|
this.offline = this.network.offline;
|
|
21360
21348
|
// Listen pod config
|
|
21361
21349
|
this._subscription.add(this.configService.config
|
|
21362
|
-
.pipe(operators.debounceTime(1000))
|
|
21350
|
+
.pipe(operators.debounceTime(1000), operators.filter(function () { return _this.network.online; }))
|
|
21363
21351
|
.subscribe(function (config) { return _this.checkNeedInstallOrUpdate(config); }));
|
|
21364
21352
|
// Listen network changes
|
|
21365
21353
|
this._subscription.add(this.network.onNetworkStatusChanges
|
|
@@ -21387,19 +21375,17 @@
|
|
|
21387
21375
|
};
|
|
21388
21376
|
AppInstallUpgradeCard.prototype.download = function (event, link) {
|
|
21389
21377
|
return __awaiter(this, void 0, void 0, function () {
|
|
21390
|
-
var job;
|
|
21391
21378
|
return __generator(this, function (_a) {
|
|
21392
21379
|
if (!link || !link.url) {
|
|
21393
21380
|
console.error('[install-upgrade-card] Missing required argument \'link.url\'');
|
|
21394
21381
|
return [2 /*return*/]; // Skip
|
|
21395
21382
|
}
|
|
21396
|
-
|
|
21397
|
-
|
|
21398
|
-
|
|
21399
|
-
|
|
21400
|
-
|
|
21401
|
-
|
|
21402
|
-
return [2 /*return*/, this.listenDownloadPromise(link, job)];
|
|
21383
|
+
return [2 /*return*/, this.listenDownloadJob(link.url, this.platform.download({
|
|
21384
|
+
uri: link.url,
|
|
21385
|
+
title: link.title,
|
|
21386
|
+
filename: link.filename,
|
|
21387
|
+
mimeType: link.mimeType
|
|
21388
|
+
}))];
|
|
21403
21389
|
});
|
|
21404
21390
|
});
|
|
21405
21391
|
};
|
|
@@ -21447,6 +21433,7 @@
|
|
|
21447
21433
|
AppInstallUpgradeCard.prototype.checkNeedInstallOrUpdate = function (config) {
|
|
21448
21434
|
return __awaiter(this, void 0, void 0, function () {
|
|
21449
21435
|
var links;
|
|
21436
|
+
var _this = this;
|
|
21450
21437
|
return __generator(this, function (_a) {
|
|
21451
21438
|
switch (_a.label) {
|
|
21452
21439
|
case 0:
|
|
@@ -21459,7 +21446,7 @@
|
|
|
21459
21446
|
this.upgradeLinks = this.getCompatibleUpgradeLinks(links, config);
|
|
21460
21447
|
// Check for install links (if no upgrade need)
|
|
21461
21448
|
this.installLinks = !this.upgradeLinks && this.getCompatibleInstallLinks(links);
|
|
21462
|
-
return [4 /*yield*/, sleep(
|
|
21449
|
+
return [4 /*yield*/, sleep(1000)];
|
|
21463
21450
|
case 2:
|
|
21464
21451
|
_a.sent(); // Add a delay, for animation
|
|
21465
21452
|
return [3 /*break*/, 4];
|
|
@@ -21467,7 +21454,14 @@
|
|
|
21467
21454
|
this.loading = false;
|
|
21468
21455
|
this.markForCheck();
|
|
21469
21456
|
return [7 /*endfinally*/];
|
|
21470
|
-
case 4:
|
|
21457
|
+
case 4:
|
|
21458
|
+
// Listening downloading promise, if exists
|
|
21459
|
+
(this.upgradeLinks || []).forEach(function (link) {
|
|
21460
|
+
var job = _this.platform.getDownloadingJob(link.url);
|
|
21461
|
+
if (job)
|
|
21462
|
+
_this.listenDownloadJob(link.url, job);
|
|
21463
|
+
});
|
|
21464
|
+
return [2 /*return*/];
|
|
21471
21465
|
}
|
|
21472
21466
|
});
|
|
21473
21467
|
});
|
|
@@ -21498,12 +21492,6 @@
|
|
|
21498
21492
|
// Use min version as default version
|
|
21499
21493
|
upgradeLinks.forEach(function (link) {
|
|
21500
21494
|
link.version = link.version || appMinVersionFromPod;
|
|
21501
|
-
var promise = _this.platform.getDownloadingPromise(link.url);
|
|
21502
|
-
// Listening download promise, if exists
|
|
21503
|
-
if (promise) {
|
|
21504
|
-
console.info("[install-upgrade-card] Platform is already downloading this file '" + link.url + "': listening promise...");
|
|
21505
|
-
_this.listenDownloadPromise(link, promise);
|
|
21506
|
-
}
|
|
21507
21495
|
});
|
|
21508
21496
|
return isNotEmptyArray(upgradeLinks) ? upgradeLinks : undefined;
|
|
21509
21497
|
};
|
|
@@ -21584,36 +21572,40 @@
|
|
|
21584
21572
|
});
|
|
21585
21573
|
});
|
|
21586
21574
|
};
|
|
21587
|
-
AppInstallUpgradeCard.prototype.
|
|
21575
|
+
AppInstallUpgradeCard.prototype.listenDownloadJob = function (url, job) {
|
|
21588
21576
|
return __awaiter(this, void 0, void 0, function () {
|
|
21589
21577
|
var location, err_1;
|
|
21590
21578
|
return __generator(this, function (_a) {
|
|
21591
21579
|
switch (_a.label) {
|
|
21592
21580
|
case 0:
|
|
21593
|
-
if (!
|
|
21581
|
+
if (!url || !job)
|
|
21594
21582
|
return [2 /*return*/]; // Skip
|
|
21595
|
-
if (!link.downloading) {
|
|
21596
|
-
link.downloading = true;
|
|
21597
|
-
this.markForCheck();
|
|
21598
|
-
}
|
|
21599
21583
|
_a.label = 1;
|
|
21600
21584
|
case 1:
|
|
21601
21585
|
_a.trys.push([1, 3, 4, 5]);
|
|
21602
|
-
|
|
21586
|
+
// Mark as downloading
|
|
21587
|
+
if (!this.downloading) {
|
|
21588
|
+
console.info("[install-upgrade-card] Platform is downloading '" + url + "' ...");
|
|
21589
|
+
this.downloading = true;
|
|
21590
|
+
this.markForCheck();
|
|
21591
|
+
}
|
|
21592
|
+
return [4 /*yield*/, job.toPromise()];
|
|
21603
21593
|
case 2:
|
|
21604
21594
|
location = _a.sent();
|
|
21605
|
-
|
|
21595
|
+
if (location) {
|
|
21596
|
+
console.info('[install-upgrade-card] File downloaded at: ' + location);
|
|
21597
|
+
return [2 /*return*/, this.showDownloadCompleteDialog()];
|
|
21598
|
+
}
|
|
21606
21599
|
return [3 /*break*/, 5];
|
|
21607
21600
|
case 3:
|
|
21608
21601
|
err_1 = _a.sent();
|
|
21609
21602
|
console.error('[install-upgrade] Download failed: ' + (err_1 && err_1.message || err_1));
|
|
21610
|
-
this.showDownloadFailedToast(err_1);
|
|
21611
|
-
return [3 /*break*/, 5];
|
|
21603
|
+
return [2 /*return*/, this.showDownloadFailedToast(err_1)];
|
|
21612
21604
|
case 4:
|
|
21613
|
-
|
|
21605
|
+
this.downloading = false;
|
|
21614
21606
|
this.markForCheck();
|
|
21615
21607
|
return [7 /*endfinally*/];
|
|
21616
|
-
case 5: return [2 /*return
|
|
21608
|
+
case 5: return [2 /*return*/];
|
|
21617
21609
|
}
|
|
21618
21610
|
});
|
|
21619
21611
|
});
|
|
@@ -21636,14 +21628,14 @@
|
|
|
21636
21628
|
return [2 /*return*/]; // Skip if component has been destroyed
|
|
21637
21629
|
return [4 /*yield*/, this.translate.get([
|
|
21638
21630
|
'INFO.ALERT_HEADER',
|
|
21639
|
-
'INFO.
|
|
21631
|
+
'INFO.UPDATE_APP_DOWNLOADED',
|
|
21640
21632
|
'COMMON.BTN_CLOSE'
|
|
21641
21633
|
]).toPromise()];
|
|
21642
21634
|
case 1:
|
|
21643
21635
|
translations = _a.sent();
|
|
21644
21636
|
return [4 /*yield*/, this.alertController.create({
|
|
21645
21637
|
header: translations['INFO.ALERT_HEADER'],
|
|
21646
|
-
message: translations['INFO.
|
|
21638
|
+
message: translations['INFO.UPDATE_APP_DOWNLOADED'],
|
|
21647
21639
|
buttons: [
|
|
21648
21640
|
{
|
|
21649
21641
|
text: translations['COMMON.BTN_CLOSE'],
|