@sumaris-net/ngx-components 0.25.3 → 0.25.7
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 +96 -67
- 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 +71 -50
- package/esm2015/src/app/core/services/platform.service.js +6 -1
- package/fesm2015/sumaris-net.ngx-components.js +74 -48
- 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
|
@@ -13775,6 +13775,11 @@ class PlatformService {
|
|
|
13775
13775
|
window.open(url, target, features, replace);
|
|
13776
13776
|
}
|
|
13777
13777
|
}
|
|
13778
|
+
getDownloadingPromise(uri) {
|
|
13779
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13780
|
+
return this._downloadingPromise.get(uri);
|
|
13781
|
+
});
|
|
13782
|
+
}
|
|
13778
13783
|
download(request) {
|
|
13779
13784
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13780
13785
|
if (!request || !request.uri)
|
|
@@ -18510,7 +18515,7 @@ class AppInstallUpgradeCard {
|
|
|
18510
18515
|
this.offline = this.network.offline;
|
|
18511
18516
|
// Listen pod config
|
|
18512
18517
|
this._subscription.add(this.configService.config
|
|
18513
|
-
.pipe(debounceTime(1000))
|
|
18518
|
+
.pipe(debounceTime(1000), filter(() => this.network.online))
|
|
18514
18519
|
.subscribe(config => this.checkNeedInstallOrUpdate(config)));
|
|
18515
18520
|
// Listen network changes
|
|
18516
18521
|
this._subscription.add(this.network.onNetworkStatusChanges
|
|
@@ -18529,6 +18534,9 @@ class AppInstallUpgradeCard {
|
|
|
18529
18534
|
ngOnDestroy() {
|
|
18530
18535
|
this._subscription.unsubscribe();
|
|
18531
18536
|
this._subscription = null;
|
|
18537
|
+
this.onUpdateOfflineModeClick.complete();
|
|
18538
|
+
this.installLinks = null;
|
|
18539
|
+
this.upgradeLinks = null;
|
|
18532
18540
|
}
|
|
18533
18541
|
download(event, link) {
|
|
18534
18542
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -18536,35 +18544,12 @@ class AppInstallUpgradeCard {
|
|
|
18536
18544
|
console.error('[install-upgrade-card] Missing required argument \'link.url\'');
|
|
18537
18545
|
return; // Skip
|
|
18538
18546
|
}
|
|
18539
|
-
this.
|
|
18540
|
-
|
|
18541
|
-
|
|
18542
|
-
|
|
18543
|
-
|
|
18544
|
-
|
|
18545
|
-
filename: link.downloadFilename,
|
|
18546
|
-
mimeType: link.mimeType
|
|
18547
|
-
});
|
|
18548
|
-
console.info('[install-upgrade-card] File downloaded at: ' + location);
|
|
18549
|
-
}
|
|
18550
|
-
// Failed: display a toast
|
|
18551
|
-
catch (err) {
|
|
18552
|
-
console.error('[install-upgrade] Download failed: ' + (err && err.message || err));
|
|
18553
|
-
this.showToast({
|
|
18554
|
-
message: 'ERROR.DOWNLOAD_FAILED',
|
|
18555
|
-
messageParams: { error: err },
|
|
18556
|
-
type: 'error',
|
|
18557
|
-
showCloseButton: true
|
|
18558
|
-
});
|
|
18559
|
-
return; // Stop here
|
|
18560
|
-
}
|
|
18561
|
-
finally {
|
|
18562
|
-
this.downloading = false;
|
|
18563
|
-
this.markForCheck();
|
|
18564
|
-
}
|
|
18565
|
-
if (!this._subscription)
|
|
18566
|
-
return; // Skip if component destroyed
|
|
18567
|
-
yield this.showDownloadCompleteDialog();
|
|
18547
|
+
return this.listenDownloadPromise(link.url, this.platform.download({
|
|
18548
|
+
uri: link.url,
|
|
18549
|
+
title: link.title,
|
|
18550
|
+
filename: link.filename,
|
|
18551
|
+
mimeType: link.mimeType
|
|
18552
|
+
}));
|
|
18568
18553
|
});
|
|
18569
18554
|
}
|
|
18570
18555
|
tryOnline() {
|
|
@@ -18602,17 +18587,23 @@ class AppInstallUpgradeCard {
|
|
|
18602
18587
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18603
18588
|
console.info('[install] Check if need to install or upgrade...');
|
|
18604
18589
|
try {
|
|
18605
|
-
const
|
|
18590
|
+
const links = this.getLinks(config);
|
|
18606
18591
|
// Check for upgrade
|
|
18607
|
-
this.
|
|
18592
|
+
this.upgradeLinks = this.getCompatibleUpgradeLinks(links, config);
|
|
18608
18593
|
// Check for install links (if no upgrade need)
|
|
18609
|
-
this.installLinks = !this.
|
|
18610
|
-
yield sleep(
|
|
18594
|
+
this.installLinks = !this.upgradeLinks && this.getCompatibleInstallLinks(links);
|
|
18595
|
+
yield sleep(1000); // Add a delay, for animation
|
|
18611
18596
|
}
|
|
18612
18597
|
finally {
|
|
18613
18598
|
this.loading = false;
|
|
18614
18599
|
this.markForCheck();
|
|
18615
18600
|
}
|
|
18601
|
+
// Listening downloading promise, if exists
|
|
18602
|
+
(this.upgradeLinks || []).forEach(link => {
|
|
18603
|
+
const promise = this.platform.getDownloadingPromise(link.url);
|
|
18604
|
+
if (promise)
|
|
18605
|
+
this.listenDownloadPromise(link.url, promise);
|
|
18606
|
+
});
|
|
18616
18607
|
});
|
|
18617
18608
|
}
|
|
18618
18609
|
getCompatibleInstallLinks(installLinks) {
|
|
@@ -18643,7 +18634,7 @@ class AppInstallUpgradeCard {
|
|
|
18643
18634
|
});
|
|
18644
18635
|
return isNotEmptyArray(upgradeLinks) ? upgradeLinks : undefined;
|
|
18645
18636
|
}
|
|
18646
|
-
|
|
18637
|
+
getLinks(config) {
|
|
18647
18638
|
const result = [];
|
|
18648
18639
|
// Android
|
|
18649
18640
|
{
|
|
@@ -18660,12 +18651,11 @@ class AppInstallUpgradeCard {
|
|
|
18660
18651
|
// Compute App name
|
|
18661
18652
|
const name = isNotNilOrBlank(url) && config.label || this.environment.defaultAppName || 'SUMARiS';
|
|
18662
18653
|
if (url) {
|
|
18663
|
-
let
|
|
18664
|
-
let version;
|
|
18654
|
+
let title;
|
|
18665
18655
|
let mimeType;
|
|
18666
18656
|
// Get file name
|
|
18667
|
-
|
|
18668
|
-
version = minVersion || 'latest';
|
|
18657
|
+
let filename = this.getFilename(url);
|
|
18658
|
+
let version = minVersion || 'latest';
|
|
18669
18659
|
// OK, this is a downloadable APK file (e.g. NOT a link to a playstore)
|
|
18670
18660
|
if (filename === null || filename === void 0 ? void 0 : filename.endsWith('.apk')) {
|
|
18671
18661
|
// Define mime type
|
|
@@ -18674,18 +18664,18 @@ class AppInstallUpgradeCard {
|
|
|
18674
18664
|
const versionMatches = /-v([1-9][0-9]*\.[0-9]+\.(:?(:?alpha|beta|rc)?[0-9]*))/i.exec(filename);
|
|
18675
18665
|
version = versionMatches && versionMatches[1] || version;
|
|
18676
18666
|
// Compute a new file name, with the version
|
|
18677
|
-
if (isNotNilOrBlank(name)) {
|
|
18678
|
-
|
|
18667
|
+
if (isNotNilOrBlank(name) && version !== 'latest') {
|
|
18668
|
+
filename = `${name}-v${version}.apk`.toLowerCase();
|
|
18669
|
+
title = `${name} v${version}`;
|
|
18679
18670
|
}
|
|
18680
18671
|
else {
|
|
18681
|
-
downloadFilename = filename;
|
|
18682
18672
|
// Replace 'latest' with the app version, if present
|
|
18683
|
-
if (
|
|
18684
|
-
|
|
18673
|
+
if (filename.indexOf('latest')) {
|
|
18674
|
+
filename = filename.replace('latest', version);
|
|
18685
18675
|
}
|
|
18686
18676
|
}
|
|
18687
18677
|
}
|
|
18688
|
-
result.push({ name, url, platform: 'android', version,
|
|
18678
|
+
result.push({ name, url, platform: 'android', version, filename, title, mimeType });
|
|
18689
18679
|
}
|
|
18690
18680
|
}
|
|
18691
18681
|
// iOS - TODO
|
|
@@ -18714,16 +18704,52 @@ class AppInstallUpgradeCard {
|
|
|
18714
18704
|
yield Toasts.show(this.toastController, this.translate, opts);
|
|
18715
18705
|
});
|
|
18716
18706
|
}
|
|
18707
|
+
listenDownloadPromise(url, promise) {
|
|
18708
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18709
|
+
if (!url || !promise)
|
|
18710
|
+
return; // Skip
|
|
18711
|
+
try {
|
|
18712
|
+
// Mark as downloading
|
|
18713
|
+
if (!this.downloading) {
|
|
18714
|
+
console.info(`[install-upgrade-card] Platform is downloading \'${url}\' ...`);
|
|
18715
|
+
this.downloading = true;
|
|
18716
|
+
this.markForCheck();
|
|
18717
|
+
}
|
|
18718
|
+
const location = yield promise;
|
|
18719
|
+
console.info('[install-upgrade-card] File downloaded at: ' + location);
|
|
18720
|
+
}
|
|
18721
|
+
// Failed: display a toast
|
|
18722
|
+
catch (err) {
|
|
18723
|
+
console.error('[install-upgrade] Download failed: ' + (err && err.message || err));
|
|
18724
|
+
return this.showDownloadFailedToast(err);
|
|
18725
|
+
}
|
|
18726
|
+
finally {
|
|
18727
|
+
this.downloading = false;
|
|
18728
|
+
this.markForCheck();
|
|
18729
|
+
}
|
|
18730
|
+
return this.showDownloadCompleteDialog();
|
|
18731
|
+
});
|
|
18732
|
+
}
|
|
18733
|
+
showDownloadFailedToast(err) {
|
|
18734
|
+
return this.showToast({
|
|
18735
|
+
message: 'ERROR.DOWNLOAD_FAILED',
|
|
18736
|
+
messageParams: { error: err },
|
|
18737
|
+
type: 'error',
|
|
18738
|
+
showCloseButton: true
|
|
18739
|
+
});
|
|
18740
|
+
}
|
|
18717
18741
|
showDownloadCompleteDialog() {
|
|
18718
18742
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18743
|
+
if (!this._subscription)
|
|
18744
|
+
return; // Skip if component has been destroyed
|
|
18719
18745
|
const translations = yield this.translate.get([
|
|
18720
18746
|
'INFO.ALERT_HEADER',
|
|
18721
|
-
'INFO.
|
|
18747
|
+
'INFO.UPDATE_APP_DOWNLOADED',
|
|
18722
18748
|
'COMMON.BTN_CLOSE'
|
|
18723
18749
|
]).toPromise();
|
|
18724
18750
|
const alert = yield this.alertController.create({
|
|
18725
18751
|
header: translations['INFO.ALERT_HEADER'],
|
|
18726
|
-
message: translations['INFO.
|
|
18752
|
+
message: translations['INFO.UPDATE_APP_DOWNLOADED'],
|
|
18727
18753
|
buttons: [
|
|
18728
18754
|
{
|
|
18729
18755
|
text: translations['COMMON.BTN_CLOSE'],
|
|
@@ -18740,7 +18766,7 @@ class AppInstallUpgradeCard {
|
|
|
18740
18766
|
AppInstallUpgradeCard.decorators = [
|
|
18741
18767
|
{ type: Component, args: [{
|
|
18742
18768
|
selector: 'app-install-upgrade-card',
|
|
18743
|
-
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 &&
|
|
18769
|
+
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",
|
|
18744
18770
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
18745
18771
|
animations: [slideUpDownAnimation],
|
|
18746
18772
|
styles: ["ion-text small{font-size:85%}"]
|