@sumaris-net/ngx-components 0.25.7 → 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 +51 -61
- 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 +12 -10
- package/esm2015/src/app/core/services/platform.service.js +38 -44
- package/fesm2015/sumaris-net.ngx-components.js +47 -51
- 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 +1 -1
- 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();
|
|
@@ -21393,7 +21380,7 @@
|
|
|
21393
21380
|
console.error('[install-upgrade-card] Missing required argument \'link.url\'');
|
|
21394
21381
|
return [2 /*return*/]; // Skip
|
|
21395
21382
|
}
|
|
21396
|
-
return [2 /*return*/, this.
|
|
21383
|
+
return [2 /*return*/, this.listenDownloadJob(link.url, this.platform.download({
|
|
21397
21384
|
uri: link.url,
|
|
21398
21385
|
title: link.title,
|
|
21399
21386
|
filename: link.filename,
|
|
@@ -21470,9 +21457,9 @@
|
|
|
21470
21457
|
case 4:
|
|
21471
21458
|
// Listening downloading promise, if exists
|
|
21472
21459
|
(this.upgradeLinks || []).forEach(function (link) {
|
|
21473
|
-
var
|
|
21474
|
-
if (
|
|
21475
|
-
_this.
|
|
21460
|
+
var job = _this.platform.getDownloadingJob(link.url);
|
|
21461
|
+
if (job)
|
|
21462
|
+
_this.listenDownloadJob(link.url, job);
|
|
21476
21463
|
});
|
|
21477
21464
|
return [2 /*return*/];
|
|
21478
21465
|
}
|
|
@@ -21585,13 +21572,13 @@
|
|
|
21585
21572
|
});
|
|
21586
21573
|
});
|
|
21587
21574
|
};
|
|
21588
|
-
AppInstallUpgradeCard.prototype.
|
|
21575
|
+
AppInstallUpgradeCard.prototype.listenDownloadJob = function (url, job) {
|
|
21589
21576
|
return __awaiter(this, void 0, void 0, function () {
|
|
21590
21577
|
var location, err_1;
|
|
21591
21578
|
return __generator(this, function (_a) {
|
|
21592
21579
|
switch (_a.label) {
|
|
21593
21580
|
case 0:
|
|
21594
|
-
if (!url || !
|
|
21581
|
+
if (!url || !job)
|
|
21595
21582
|
return [2 /*return*/]; // Skip
|
|
21596
21583
|
_a.label = 1;
|
|
21597
21584
|
case 1:
|
|
@@ -21602,10 +21589,13 @@
|
|
|
21602
21589
|
this.downloading = true;
|
|
21603
21590
|
this.markForCheck();
|
|
21604
21591
|
}
|
|
21605
|
-
return [4 /*yield*/,
|
|
21592
|
+
return [4 /*yield*/, job.toPromise()];
|
|
21606
21593
|
case 2:
|
|
21607
21594
|
location = _a.sent();
|
|
21608
|
-
|
|
21595
|
+
if (location) {
|
|
21596
|
+
console.info('[install-upgrade-card] File downloaded at: ' + location);
|
|
21597
|
+
return [2 /*return*/, this.showDownloadCompleteDialog()];
|
|
21598
|
+
}
|
|
21609
21599
|
return [3 /*break*/, 5];
|
|
21610
21600
|
case 3:
|
|
21611
21601
|
err_1 = _a.sent();
|
|
@@ -21615,7 +21605,7 @@
|
|
|
21615
21605
|
this.downloading = false;
|
|
21616
21606
|
this.markForCheck();
|
|
21617
21607
|
return [7 /*endfinally*/];
|
|
21618
|
-
case 5: return [2 /*return
|
|
21608
|
+
case 5: return [2 /*return*/];
|
|
21619
21609
|
}
|
|
21620
21610
|
});
|
|
21621
21611
|
});
|