@sumaris-net/ngx-components 0.25.3 → 0.25.4
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 +91 -64
- 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/esm2015/src/app/core/install/install-upgrade-card.component.js +65 -46
- package/esm2015/src/app/core/services/platform.service.js +6 -1
- package/fesm2015/sumaris-net.ngx-components.js +69 -45
- 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 +8 -5
- package/src/app/core/services/platform.service.d.ts +1 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -15808,6 +15808,13 @@
|
|
|
15808
15808
|
window.open(url, target, features, replace);
|
|
15809
15809
|
}
|
|
15810
15810
|
};
|
|
15811
|
+
PlatformService.prototype.getDownloadingPromise = function (uri) {
|
|
15812
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15813
|
+
return __generator(this, function (_a) {
|
|
15814
|
+
return [2 /*return*/, this._downloadingPromise.get(uri)];
|
|
15815
|
+
});
|
|
15816
|
+
});
|
|
15817
|
+
};
|
|
15811
15818
|
PlatformService.prototype.download = function (request) {
|
|
15812
15819
|
return __awaiter(this, void 0, void 0, function () {
|
|
15813
15820
|
var promise, location, err_1;
|
|
@@ -21322,7 +21329,6 @@
|
|
|
21322
21329
|
this._subscription = new rxjs.Subscription();
|
|
21323
21330
|
this._showUpdateOfflineFeature = false;
|
|
21324
21331
|
this.loading = true;
|
|
21325
|
-
this.downloading = false;
|
|
21326
21332
|
this.waitingNetwork = false;
|
|
21327
21333
|
this.showUpgradeWarning = true;
|
|
21328
21334
|
this.showOfflineWarning = true;
|
|
@@ -21375,54 +21381,25 @@
|
|
|
21375
21381
|
AppInstallUpgradeCard.prototype.ngOnDestroy = function () {
|
|
21376
21382
|
this._subscription.unsubscribe();
|
|
21377
21383
|
this._subscription = null;
|
|
21384
|
+
this.onUpdateOfflineModeClick.complete();
|
|
21385
|
+
this.installLinks = null;
|
|
21386
|
+
this.upgradeLinks = null;
|
|
21378
21387
|
};
|
|
21379
21388
|
AppInstallUpgradeCard.prototype.download = function (event, link) {
|
|
21380
21389
|
return __awaiter(this, void 0, void 0, function () {
|
|
21381
|
-
var
|
|
21390
|
+
var job;
|
|
21382
21391
|
return __generator(this, function (_a) {
|
|
21383
|
-
|
|
21384
|
-
|
|
21385
|
-
|
|
21386
|
-
console.error('[install-upgrade-card] Missing required argument \'link.url\'');
|
|
21387
|
-
return [2 /*return*/]; // Skip
|
|
21388
|
-
}
|
|
21389
|
-
this.downloading = true;
|
|
21390
|
-
_a.label = 1;
|
|
21391
|
-
case 1:
|
|
21392
|
-
_a.trys.push([1, 3, 4, 5]);
|
|
21393
|
-
console.info('[install-upgrade-card] User click to download file: ' + link.url);
|
|
21394
|
-
return [4 /*yield*/, this.platform.download({
|
|
21395
|
-
uri: link.url,
|
|
21396
|
-
title: link.name,
|
|
21397
|
-
filename: link.downloadFilename,
|
|
21398
|
-
mimeType: link.mimeType
|
|
21399
|
-
})];
|
|
21400
|
-
case 2:
|
|
21401
|
-
location = _a.sent();
|
|
21402
|
-
console.info('[install-upgrade-card] File downloaded at: ' + location);
|
|
21403
|
-
return [3 /*break*/, 5];
|
|
21404
|
-
case 3:
|
|
21405
|
-
err_1 = _a.sent();
|
|
21406
|
-
console.error('[install-upgrade] Download failed: ' + (err_1 && err_1.message || err_1));
|
|
21407
|
-
this.showToast({
|
|
21408
|
-
message: 'ERROR.DOWNLOAD_FAILED',
|
|
21409
|
-
messageParams: { error: err_1 },
|
|
21410
|
-
type: 'error',
|
|
21411
|
-
showCloseButton: true
|
|
21412
|
-
});
|
|
21413
|
-
return [2 /*return*/]; // Stop here
|
|
21414
|
-
case 4:
|
|
21415
|
-
this.downloading = false;
|
|
21416
|
-
this.markForCheck();
|
|
21417
|
-
return [7 /*endfinally*/];
|
|
21418
|
-
case 5:
|
|
21419
|
-
if (!this._subscription)
|
|
21420
|
-
return [2 /*return*/]; // Skip if component destroyed
|
|
21421
|
-
return [4 /*yield*/, this.showDownloadCompleteDialog()];
|
|
21422
|
-
case 6:
|
|
21423
|
-
_a.sent();
|
|
21424
|
-
return [2 /*return*/];
|
|
21392
|
+
if (!link || !link.url) {
|
|
21393
|
+
console.error('[install-upgrade-card] Missing required argument \'link.url\'');
|
|
21394
|
+
return [2 /*return*/]; // Skip
|
|
21425
21395
|
}
|
|
21396
|
+
job = this.platform.download({
|
|
21397
|
+
uri: link.url,
|
|
21398
|
+
title: link.title,
|
|
21399
|
+
filename: link.filename,
|
|
21400
|
+
mimeType: link.mimeType
|
|
21401
|
+
});
|
|
21402
|
+
return [2 /*return*/, this.listenDownloadPromise(link, job)];
|
|
21426
21403
|
});
|
|
21427
21404
|
});
|
|
21428
21405
|
};
|
|
@@ -21469,7 +21446,7 @@
|
|
|
21469
21446
|
/* -- private method -- */
|
|
21470
21447
|
AppInstallUpgradeCard.prototype.checkNeedInstallOrUpdate = function (config) {
|
|
21471
21448
|
return __awaiter(this, void 0, void 0, function () {
|
|
21472
|
-
var
|
|
21449
|
+
var links;
|
|
21473
21450
|
return __generator(this, function (_a) {
|
|
21474
21451
|
switch (_a.label) {
|
|
21475
21452
|
case 0:
|
|
@@ -21477,11 +21454,11 @@
|
|
|
21477
21454
|
_a.label = 1;
|
|
21478
21455
|
case 1:
|
|
21479
21456
|
_a.trys.push([1, , 3, 4]);
|
|
21480
|
-
|
|
21457
|
+
links = this.getLinks(config);
|
|
21481
21458
|
// Check for upgrade
|
|
21482
|
-
this.
|
|
21459
|
+
this.upgradeLinks = this.getCompatibleUpgradeLinks(links, config);
|
|
21483
21460
|
// Check for install links (if no upgrade need)
|
|
21484
|
-
this.installLinks = !this.
|
|
21461
|
+
this.installLinks = !this.upgradeLinks && this.getCompatibleInstallLinks(links);
|
|
21485
21462
|
return [4 /*yield*/, sleep(500)];
|
|
21486
21463
|
case 2:
|
|
21487
21464
|
_a.sent(); // Add a delay, for animation
|
|
@@ -21521,10 +21498,16 @@
|
|
|
21521
21498
|
// Use min version as default version
|
|
21522
21499
|
upgradeLinks.forEach(function (link) {
|
|
21523
21500
|
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
|
+
}
|
|
21524
21507
|
});
|
|
21525
21508
|
return isNotEmptyArray(upgradeLinks) ? upgradeLinks : undefined;
|
|
21526
21509
|
};
|
|
21527
|
-
AppInstallUpgradeCard.prototype.
|
|
21510
|
+
AppInstallUpgradeCard.prototype.getLinks = function (config) {
|
|
21528
21511
|
var result = [];
|
|
21529
21512
|
// Android
|
|
21530
21513
|
{
|
|
@@ -21541,12 +21524,11 @@
|
|
|
21541
21524
|
// Compute App name
|
|
21542
21525
|
var name = isNotNilOrBlank(url) && config.label || this.environment.defaultAppName || 'SUMARiS';
|
|
21543
21526
|
if (url) {
|
|
21544
|
-
var
|
|
21545
|
-
var version = void 0;
|
|
21527
|
+
var title = void 0;
|
|
21546
21528
|
var mimeType = void 0;
|
|
21547
21529
|
// Get file name
|
|
21548
21530
|
var filename = this.getFilename(url);
|
|
21549
|
-
version = minVersion || 'latest';
|
|
21531
|
+
var version = minVersion || 'latest';
|
|
21550
21532
|
// OK, this is a downloadable APK file (e.g. NOT a link to a playstore)
|
|
21551
21533
|
if (filename === null || filename === void 0 ? void 0 : filename.endsWith('.apk')) {
|
|
21552
21534
|
// Define mime type
|
|
@@ -21555,18 +21537,18 @@
|
|
|
21555
21537
|
var versionMatches = /-v([1-9][0-9]*\.[0-9]+\.(:?(:?alpha|beta|rc)?[0-9]*))/i.exec(filename);
|
|
21556
21538
|
version = versionMatches && versionMatches[1] || version;
|
|
21557
21539
|
// Compute a new file name, with the version
|
|
21558
|
-
if (isNotNilOrBlank(name)) {
|
|
21559
|
-
|
|
21540
|
+
if (isNotNilOrBlank(name) && version !== 'latest') {
|
|
21541
|
+
filename = (name + "-v" + version + ".apk").toLowerCase();
|
|
21542
|
+
title = name + " v" + version;
|
|
21560
21543
|
}
|
|
21561
21544
|
else {
|
|
21562
|
-
downloadFilename = filename;
|
|
21563
21545
|
// Replace 'latest' with the app version, if present
|
|
21564
|
-
if (
|
|
21565
|
-
|
|
21546
|
+
if (filename.indexOf('latest')) {
|
|
21547
|
+
filename = filename.replace('latest', version);
|
|
21566
21548
|
}
|
|
21567
21549
|
}
|
|
21568
21550
|
}
|
|
21569
|
-
result.push({ name: name, url: url, platform: 'android', version: version,
|
|
21551
|
+
result.push({ name: name, url: url, platform: 'android', version: version, filename: filename, title: title, mimeType: mimeType });
|
|
21570
21552
|
}
|
|
21571
21553
|
}
|
|
21572
21554
|
// iOS - TODO
|
|
@@ -21602,16 +21584,61 @@
|
|
|
21602
21584
|
});
|
|
21603
21585
|
});
|
|
21604
21586
|
};
|
|
21587
|
+
AppInstallUpgradeCard.prototype.listenDownloadPromise = function (link, promise) {
|
|
21588
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
21589
|
+
var location, err_1;
|
|
21590
|
+
return __generator(this, function (_a) {
|
|
21591
|
+
switch (_a.label) {
|
|
21592
|
+
case 0:
|
|
21593
|
+
if (!link || !promise)
|
|
21594
|
+
return [2 /*return*/]; // Skip
|
|
21595
|
+
if (!link.downloading) {
|
|
21596
|
+
link.downloading = true;
|
|
21597
|
+
this.markForCheck();
|
|
21598
|
+
}
|
|
21599
|
+
_a.label = 1;
|
|
21600
|
+
case 1:
|
|
21601
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
21602
|
+
return [4 /*yield*/, promise];
|
|
21603
|
+
case 2:
|
|
21604
|
+
location = _a.sent();
|
|
21605
|
+
console.info('[install-upgrade-card] File downloaded at: ' + location);
|
|
21606
|
+
return [3 /*break*/, 5];
|
|
21607
|
+
case 3:
|
|
21608
|
+
err_1 = _a.sent();
|
|
21609
|
+
console.error('[install-upgrade] Download failed: ' + (err_1 && err_1.message || err_1));
|
|
21610
|
+
this.showDownloadFailedToast(err_1);
|
|
21611
|
+
return [3 /*break*/, 5];
|
|
21612
|
+
case 4:
|
|
21613
|
+
link.downloading = false;
|
|
21614
|
+
this.markForCheck();
|
|
21615
|
+
return [7 /*endfinally*/];
|
|
21616
|
+
case 5: return [2 /*return*/, this.showDownloadCompleteDialog()];
|
|
21617
|
+
}
|
|
21618
|
+
});
|
|
21619
|
+
});
|
|
21620
|
+
};
|
|
21621
|
+
AppInstallUpgradeCard.prototype.showDownloadFailedToast = function (err) {
|
|
21622
|
+
return this.showToast({
|
|
21623
|
+
message: 'ERROR.DOWNLOAD_FAILED',
|
|
21624
|
+
messageParams: { error: err },
|
|
21625
|
+
type: 'error',
|
|
21626
|
+
showCloseButton: true
|
|
21627
|
+
});
|
|
21628
|
+
};
|
|
21605
21629
|
AppInstallUpgradeCard.prototype.showDownloadCompleteDialog = function () {
|
|
21606
21630
|
return __awaiter(this, void 0, void 0, function () {
|
|
21607
21631
|
var translations, alert;
|
|
21608
21632
|
return __generator(this, function (_a) {
|
|
21609
21633
|
switch (_a.label) {
|
|
21610
|
-
case 0:
|
|
21611
|
-
|
|
21612
|
-
|
|
21613
|
-
|
|
21614
|
-
|
|
21634
|
+
case 0:
|
|
21635
|
+
if (!this._subscription)
|
|
21636
|
+
return [2 /*return*/]; // Skip if component has been destroyed
|
|
21637
|
+
return [4 /*yield*/, this.translate.get([
|
|
21638
|
+
'INFO.ALERT_HEADER',
|
|
21639
|
+
'INFO.DOWNLOAD_UPDATE_SUCCEED',
|
|
21640
|
+
'COMMON.BTN_CLOSE'
|
|
21641
|
+
]).toPromise()];
|
|
21615
21642
|
case 1:
|
|
21616
21643
|
translations = _a.sent();
|
|
21617
21644
|
return [4 /*yield*/, this.alertController.create({
|
|
@@ -21643,7 +21670,7 @@
|
|
|
21643
21670
|
AppInstallUpgradeCard.decorators = [
|
|
21644
21671
|
{ type: i0.Component, args: [{
|
|
21645
21672
|
selector: 'app-install-upgrade-card',
|
|
21646
|
-
template: "\n\n<!-- Offline mode card-->\n<ion-card *ngIf=\"showOfflineWarning && (!loading && offline || waitingNetwork)\"\n color=\"accent\"\n class=\"main ion-no-margin\"\n @slideUpDownAnimation>\n <ion-card-content class=\"ion-no-padding\">\n <ion-grid>\n <ion-row>\n <ion-col>\n <ion-text class=\"ion-text-wrap\" *ngIf=\"!waitingNetwork; else waitingNetworkText\">\n <h4>\n <b *ngIf=\"isLogin; else notLogin\" [innerHTML]=\"'NETWORK.INFO.OFFLINE_OR_UNAUTHORIZED'| translate\"></b>\n <ng-template #notLogin>\n <b [innerHTML]=\"'NETWORK.INFO.OFFLINE'| translate\"></b>\n </ng-template>\n </h4>\n <h3>\n <small [innerHTML]=\"'NETWORK.INFO.OFFLINE_HELP'|translate\"></small>\n </h3>\n </ion-text>\n <ng-template #waitingNetworkText>\n <ion-text class=\"ion-text-wrap\" [innerHTML]=\"'NETWORK.INFO.RETRY_TO_CONNECT'| translate\"></ion-text>\n </ng-template>\n </ion-col>\n <ion-col size=\"auto\">\n\n <!-- Retry button -->\n <ion-button *ngIf=\"!waitingNetwork; else waitingSpinner\" color=\"tertiary\" class=\"ion-float-end\"\n (click)=\"tryOnline()\">\n <span translate>NETWORK.BTN_CHECK_ALIVE</span>\n </ion-button>\n\n </ion-col>\n </ion-row>\n </ion-grid>\n\n </ion-card-content>\n</ion-card>\n\n<!-- Upgrade links -->\n<ion-card *ngIf=\"showUpgradeWarning && !loading && !offline &&
|
|
21673
|
+
template: "\n\n<!-- Offline mode card-->\n<ion-card *ngIf=\"showOfflineWarning && (!loading && offline || waitingNetwork)\"\n color=\"accent\"\n class=\"main ion-no-margin\"\n @slideUpDownAnimation>\n <ion-card-content class=\"ion-no-padding\">\n <ion-grid>\n <ion-row>\n <ion-col>\n <ion-text class=\"ion-text-wrap\" *ngIf=\"!waitingNetwork; else waitingNetworkText\">\n <h4>\n <b *ngIf=\"isLogin; else notLogin\" [innerHTML]=\"'NETWORK.INFO.OFFLINE_OR_UNAUTHORIZED'| translate\"></b>\n <ng-template #notLogin>\n <b [innerHTML]=\"'NETWORK.INFO.OFFLINE'| translate\"></b>\n </ng-template>\n </h4>\n <h3>\n <small [innerHTML]=\"'NETWORK.INFO.OFFLINE_HELP'|translate\"></small>\n </h3>\n </ion-text>\n <ng-template #waitingNetworkText>\n <ion-text class=\"ion-text-wrap\" [innerHTML]=\"'NETWORK.INFO.RETRY_TO_CONNECT'| translate\"></ion-text>\n </ng-template>\n </ion-col>\n <ion-col size=\"auto\">\n\n <!-- Retry button -->\n <ion-button *ngIf=\"!waitingNetwork; else waitingSpinner\" color=\"tertiary\" class=\"ion-float-end\"\n (click)=\"tryOnline()\">\n <span translate>NETWORK.BTN_CHECK_ALIVE</span>\n </ion-button>\n\n </ion-col>\n </ion-row>\n </ion-grid>\n\n </ion-card-content>\n</ion-card>\n\n<!-- Upgrade links -->\n<ion-card *ngIf=\"showUpgradeWarning && !loading && !offline && upgradeLinks\"\n color=\"accent\"\n class=\"ion-no-margin\"\n @slideUpDownAnimation>\n <ion-card-content class=\"ion-no-padding\">\n <ion-grid>\n <ion-row *ngFor=\"let link of upgradeLinks; last as last\">\n <ion-col>\n <ion-text class=\"ion-text-wrap\">\n <h3>\n <span *ngIf=\"link.version\" [innerHTML]=\"'INFO.UPDATE_APP_TO_VERSION'| translate: link\"></span>\n <span *ngIf=\"!link.version\" [innerHTML]=\"'INFO.UPDATE_APP'| translate: link\"></span>\n </h3>\n <h4>\n <small *ngIf=\"last\" [innerHTML]=\"'INFO.UPDATE_APP_HELP'|translate\"></small>\n </h4>\n </ion-text>\n </ion-col>\n\n <ion-col size=\"auto\">\n <ng-container *ngTemplateOutlet=\"downloadButton; context: { $implicit: link }\"></ng-container>\n </ion-col>\n </ion-row>\n\n </ion-grid>\n\n </ion-card-content>\n</ion-card>\n\n<!-- Install links -->\n<ion-card *ngIf=\"showInstallButton && !loading && !offline && installLinks\"\n color=\"secondary\"\n class=\"ion-no-margin\"\n @slideUpDownAnimation>\n <ion-card-content class=\"ion-no-padding\">\n <ion-grid>\n <ion-row *ngFor=\"let link of installLinks; last as last\">\n <ion-col>\n <ion-text class=\"ion-text-wrap\">\n <h3 [innerHTML]=\"'INFO.DOWNLOAD_APP_TITLE'| translate: {name: link.name, platform: getPlatformName(link.platform) }\"></h3>\n <h4><small *ngIf=\"last\" [innerHTML]=\"'INFO.DOWNLOAD_APP_HELP'|translate\"></small></h4>\n </ion-text>\n </ion-col>\n <ion-col size=\"auto\">\n <ng-container *ngTemplateOutlet=\"downloadButton; context: { $implicit: link }\"></ng-container>\n </ion-col>\n </ion-row>\n\n </ion-grid>\n\n </ion-card-content>\n</ion-card>\n\n<!-- Update offline feature card-->\n<ion-card *ngIf=\"showUpdateOfflineFeature && !loading && !offline\"\n color=\"accent\"\n class=\"main ion-no-margin\"\n @slideUpDownAnimation>\n <ion-card-content class=\"ion-no-padding\">\n <ion-grid>\n <ion-row>\n <ion-col>\n <ion-text class=\"ion-text-wrap\">\n <h4>\n <b [innerHTML]=\"'NETWORK.INFO.UPDATE_OFFLINE_MODE'| translate\"></b>\n </h4>\n <h3>\n <small [innerHTML]=\"'NETWORK.INFO.UPDATE_OFFLINE_MODE_HELP'|translate\"></small>\n </h3>\n </ion-text>\n </ion-col>\n <ion-col size=\"auto\">\n\n <!-- Retry button -->\n <ion-button color=\"tertiary\" class=\"ion-float-end\"\n (click)=\"onUpdateOfflineModeClick.emit($event)\">\n <span translate>NETWORK.BTN_UPDATE</span>\n </ion-button>\n </ion-col>\n </ion-row>\n </ion-grid>\n\n </ion-card-content>\n</ion-card>\n\n<!-- Display a download button, depending on the link URL, and the device platform -->\n<ng-template #downloadButton let-link>\n\n <ng-container *ngIf=\"link.downloadFilename; else redirectButton\">\n\n <ng-container *ngIf=\"platform.canDownload; else webDownloadButton\">\n <!-- Download using platform -->\n <ion-button (click)=\"download($event, asLink(link))\"\n [disabled]=\"link.downloading\"\n color=\"tertiary\" class=\"ion-float-end\">\n <ion-icon slot=\"start\" *ngIf=\"!link.downloading\" name=\"download\"></ion-icon>\n <ion-spinner slot=\"start\" class=\"ion-no-padding\" *ngIf=\"link.downloading\"></ion-spinner>\n <ion-label translate>COMMON.BTN_DOWNLOAD</ion-label>\n </ion-button>\n </ng-container>\n\n <!-- Web download button -->\n <ng-template #webDownloadButton>\n <ion-button [download]=\"link.downloadFilename\"\n [href]=\"link.url\"\n color=\"tertiary\" class=\"ion-float-end\" >\n <ion-label translate>COMMON.BTN_DOWNLOAD</ion-label>\n </ion-button>\n </ng-template>\n </ng-container>\n\n <!-- Web redirect button -->\n <ng-template #redirectButton>\n <ion-button [href]=\"link.url\" rel=\"external\" color=\"tertiary\" class=\"ion-float-end\" target=\"_blank\">\n <ion-label translate>COMMON.BTN_SHOW_MORE</ion-label>\n </ion-button>\n </ng-template>\n</ng-template>\n\n\n<!-- Waiting spinner -->\n<ng-template #waitingSpinner>\n <ion-spinner color=\"light\"></ion-spinner>\n</ng-template>\n",
|
|
21647
21674
|
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
21648
21675
|
animations: [slideUpDownAnimation],
|
|
21649
21676
|
styles: ["ion-text small{font-size:85%}"]
|