@sumaris-net/ngx-components 0.25.2 → 0.25.3
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 +128 -47
- 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 +40 -11
- package/esm2015/src/app/core/services/model/peer.model.js +15 -2
- package/esm2015/src/app/core/services/platform.service.js +18 -6
- package/fesm2015/sumaris-net.ngx-components.js +67 -14
- 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 +4 -2
- package/src/app/core/services/model/peer.model.d.ts +1 -0
- package/src/app/core/services/platform.service.d.ts +1 -0
- package/src/assets/i18n/fr.json +3 -2
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -9212,6 +9212,24 @@
|
|
|
9212
9212
|
path: noTrailingSlash(url.pathname)
|
|
9213
9213
|
});
|
|
9214
9214
|
};
|
|
9215
|
+
Peer.path = function (peer) {
|
|
9216
|
+
var _a;
|
|
9217
|
+
var paths = [];
|
|
9218
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
9219
|
+
paths[_i - 1] = arguments[_i];
|
|
9220
|
+
}
|
|
9221
|
+
if (!peer)
|
|
9222
|
+
throw new Error('Missing required argument \'peer\'!');
|
|
9223
|
+
// Remove starting slashes
|
|
9224
|
+
paths = (paths || []).map(function (path) {
|
|
9225
|
+
if (path.startsWith('./'))
|
|
9226
|
+
return path.substring(2);
|
|
9227
|
+
if (path.startsWith('/'))
|
|
9228
|
+
return path.substring(1);
|
|
9229
|
+
return path;
|
|
9230
|
+
}).filter(isNotNilOrBlank);
|
|
9231
|
+
return (_a = [noTrailingSlash(Peer_1.fromObject(peer).url)]).concat.apply(_a, __spread(paths)).join('/');
|
|
9232
|
+
};
|
|
9215
9233
|
Peer.prototype.asObject = function (options) {
|
|
9216
9234
|
return _super.prototype.asObject.call(this, options);
|
|
9217
9235
|
};
|
|
@@ -15660,6 +15678,7 @@
|
|
|
15660
15678
|
this.browser = browser;
|
|
15661
15679
|
this.downloader = downloader;
|
|
15662
15680
|
this._started = false;
|
|
15681
|
+
this._downloadingPromise = new Map();
|
|
15663
15682
|
this._debug = !environment.production;
|
|
15664
15683
|
if (this._debug)
|
|
15665
15684
|
console.debug('[platform] Creating service');
|
|
@@ -15791,19 +15810,26 @@
|
|
|
15791
15810
|
};
|
|
15792
15811
|
PlatformService.prototype.download = function (request) {
|
|
15793
15812
|
return __awaiter(this, void 0, void 0, function () {
|
|
15794
|
-
var location, err_1;
|
|
15813
|
+
var promise, location, err_1;
|
|
15795
15814
|
return __generator(this, function (_a) {
|
|
15796
15815
|
switch (_a.label) {
|
|
15797
15816
|
case 0:
|
|
15798
15817
|
if (!request || !request.uri)
|
|
15799
15818
|
throw new Error('Missing argument \'request\' or \'request.uri\'');
|
|
15800
|
-
if (!(this._android && this.downloader)) return [3 /*break*/,
|
|
15801
|
-
|
|
15819
|
+
if (!(this._android && this.downloader)) return [3 /*break*/, 6];
|
|
15820
|
+
promise = this._downloadingPromise.get(request.uri);
|
|
15821
|
+
if (promise)
|
|
15822
|
+
return [2 /*return*/, promise];
|
|
15823
|
+
request = Object.assign({ visibleInDownloadsUi: true, notificationVisibility: ngx$6.NotificationVisibility.VisibleNotifyCompleted, title: request.title || request.filename }, request);
|
|
15802
15824
|
_a.label = 1;
|
|
15803
15825
|
case 1:
|
|
15804
|
-
_a.trys.push([1, 3, ,
|
|
15826
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
15805
15827
|
console.debug('[platform] Downloading, using request: ' + JSON.stringify(request));
|
|
15806
|
-
|
|
15828
|
+
// Start download
|
|
15829
|
+
promise = this.downloader.download(request);
|
|
15830
|
+
// Remember this request uri
|
|
15831
|
+
this._downloadingPromise.set(request.uri, promise);
|
|
15832
|
+
return [4 /*yield*/, promise];
|
|
15807
15833
|
case 2:
|
|
15808
15834
|
location = _a.sent();
|
|
15809
15835
|
console.info('[platform] File successfully downloaded at:' + location);
|
|
@@ -15812,12 +15838,16 @@
|
|
|
15812
15838
|
err_1 = _a.sent();
|
|
15813
15839
|
console.error('[platform] Unable to download: ' + (err_1 && err_1.message || err_1));
|
|
15814
15840
|
throw err_1;
|
|
15815
|
-
case 4:
|
|
15816
|
-
|
|
15817
|
-
|
|
15841
|
+
case 4:
|
|
15842
|
+
// Forget the request
|
|
15843
|
+
this._downloadingPromise.delete(request.uri);
|
|
15844
|
+
return [7 /*endfinally*/];
|
|
15845
|
+
case 5: return [3 /*break*/, 7];
|
|
15846
|
+
case 6:
|
|
15847
|
+
console.warn('[platform] Cannot use Android downloader: using browser open()');
|
|
15818
15848
|
this.open(request.uri, '_system', 'location=no', true);
|
|
15819
15849
|
return [2 /*return*/, undefined];
|
|
15820
|
-
case
|
|
15850
|
+
case 7: return [2 /*return*/];
|
|
15821
15851
|
}
|
|
15822
15852
|
});
|
|
15823
15853
|
});
|
|
@@ -21279,10 +21309,11 @@
|
|
|
21279
21309
|
ANDROID_APK: 'application/vnd.android.package-archive'
|
|
21280
21310
|
});
|
|
21281
21311
|
var AppInstallUpgradeCard = /** @class */ (function () {
|
|
21282
|
-
function AppInstallUpgradeCard(modalCtrl, configService, toastController, translate, cd, platform, network, environment) {
|
|
21312
|
+
function AppInstallUpgradeCard(modalCtrl, configService, toastController, alertController, translate, cd, platform, network, environment) {
|
|
21283
21313
|
this.modalCtrl = modalCtrl;
|
|
21284
21314
|
this.configService = configService;
|
|
21285
21315
|
this.toastController = toastController;
|
|
21316
|
+
this.alertController = alertController;
|
|
21286
21317
|
this.translate = translate;
|
|
21287
21318
|
this.cd = cd;
|
|
21288
21319
|
this.platform = platform;
|
|
@@ -21343,47 +21374,55 @@
|
|
|
21343
21374
|
};
|
|
21344
21375
|
AppInstallUpgradeCard.prototype.ngOnDestroy = function () {
|
|
21345
21376
|
this._subscription.unsubscribe();
|
|
21377
|
+
this._subscription = null;
|
|
21346
21378
|
};
|
|
21347
21379
|
AppInstallUpgradeCard.prototype.download = function (event, link) {
|
|
21348
21380
|
return __awaiter(this, void 0, void 0, function () {
|
|
21349
|
-
var location;
|
|
21381
|
+
var location, err_1;
|
|
21350
21382
|
return __generator(this, function (_a) {
|
|
21351
|
-
|
|
21352
|
-
|
|
21353
|
-
|
|
21354
|
-
|
|
21355
|
-
|
|
21356
|
-
|
|
21357
|
-
|
|
21358
|
-
|
|
21359
|
-
|
|
21360
|
-
|
|
21361
|
-
|
|
21362
|
-
|
|
21363
|
-
|
|
21364
|
-
|
|
21365
|
-
|
|
21366
|
-
|
|
21367
|
-
|
|
21368
|
-
|
|
21369
|
-
|
|
21370
|
-
|
|
21371
|
-
|
|
21372
|
-
|
|
21373
|
-
|
|
21374
|
-
|
|
21375
|
-
|
|
21376
|
-
|
|
21377
|
-
|
|
21378
|
-
|
|
21379
|
-
|
|
21383
|
+
switch (_a.label) {
|
|
21384
|
+
case 0:
|
|
21385
|
+
if (!link || !link.url) {
|
|
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*/];
|
|
21380
21425
|
}
|
|
21381
|
-
this.showToast({
|
|
21382
|
-
message: 'INFO.DOWNLOAD_UPDATE_SUCCEED',
|
|
21383
|
-
type: 'info',
|
|
21384
|
-
showCloseButton: true
|
|
21385
|
-
});
|
|
21386
|
-
return [2 /*return*/];
|
|
21387
21426
|
});
|
|
21388
21427
|
});
|
|
21389
21428
|
};
|
|
@@ -21493,6 +21532,11 @@
|
|
|
21493
21532
|
var url = config.getProperty(CORE_CONFIG_OPTIONS.ANDROID_INSTALL_URL);
|
|
21494
21533
|
if (isNilOrBlank(url))
|
|
21495
21534
|
url = this.environment.defaultAndroidInstallUrl || null;
|
|
21535
|
+
// Resolve relative URL
|
|
21536
|
+
var peer = this.network.peer;
|
|
21537
|
+
if (peer && (url.startsWith('./') || url.startsWith('/'))) {
|
|
21538
|
+
url = exports.Peer.path(peer, url);
|
|
21539
|
+
}
|
|
21496
21540
|
var minVersion = config.getProperty(CORE_CONFIG_OPTIONS.APP_MIN_VERSION);
|
|
21497
21541
|
// Compute App name
|
|
21498
21542
|
var name = isNotNilOrBlank(url) && config.label || this.environment.defaultAppName || 'SUMARiS';
|
|
@@ -21558,12 +21602,48 @@
|
|
|
21558
21602
|
});
|
|
21559
21603
|
});
|
|
21560
21604
|
};
|
|
21605
|
+
AppInstallUpgradeCard.prototype.showDownloadCompleteDialog = function () {
|
|
21606
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
21607
|
+
var translations, alert;
|
|
21608
|
+
return __generator(this, function (_a) {
|
|
21609
|
+
switch (_a.label) {
|
|
21610
|
+
case 0: return [4 /*yield*/, this.translate.get([
|
|
21611
|
+
'INFO.ALERT_HEADER',
|
|
21612
|
+
'INFO.DOWNLOAD_UPDATE_SUCCEED',
|
|
21613
|
+
'COMMON.BTN_CLOSE'
|
|
21614
|
+
]).toPromise()];
|
|
21615
|
+
case 1:
|
|
21616
|
+
translations = _a.sent();
|
|
21617
|
+
return [4 /*yield*/, this.alertController.create({
|
|
21618
|
+
header: translations['INFO.ALERT_HEADER'],
|
|
21619
|
+
message: translations['INFO.DOWNLOAD_UPDATE_SUCCEED'],
|
|
21620
|
+
buttons: [
|
|
21621
|
+
{
|
|
21622
|
+
text: translations['COMMON.BTN_CLOSE'],
|
|
21623
|
+
role: 'cancel',
|
|
21624
|
+
cssClass: 'secondary'
|
|
21625
|
+
}
|
|
21626
|
+
]
|
|
21627
|
+
})];
|
|
21628
|
+
case 2:
|
|
21629
|
+
alert = _a.sent();
|
|
21630
|
+
return [4 /*yield*/, alert.present()];
|
|
21631
|
+
case 3:
|
|
21632
|
+
_a.sent();
|
|
21633
|
+
return [4 /*yield*/, alert.onDidDismiss()];
|
|
21634
|
+
case 4:
|
|
21635
|
+
_a.sent();
|
|
21636
|
+
return [2 /*return*/];
|
|
21637
|
+
}
|
|
21638
|
+
});
|
|
21639
|
+
});
|
|
21640
|
+
};
|
|
21561
21641
|
return AppInstallUpgradeCard;
|
|
21562
21642
|
}());
|
|
21563
21643
|
AppInstallUpgradeCard.decorators = [
|
|
21564
21644
|
{ type: i0.Component, args: [{
|
|
21565
21645
|
selector: 'app-install-upgrade-card',
|
|
21566
|
-
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
|
|
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 && updateLinks\"\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 updateLinks; 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 *ngIf=\"!downloading; else waitingSpinner\"\n (click)=\"download($event, asLink(link))\"\n [disabled]=\"downloading\"\n color=\"tertiary\" class=\"ion-float-end\">\n <ion-icon slot=\"start\" *ngIf=\"!downloading\" name=\"download\"></ion-icon>\n <ion-spinner slot=\"start\" class=\"ion-no-padding\" *ngIf=\"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",
|
|
21567
21647
|
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
21568
21648
|
animations: [slideUpDownAnimation],
|
|
21569
21649
|
styles: ["ion-text small{font-size:85%}"]
|
|
@@ -21573,6 +21653,7 @@
|
|
|
21573
21653
|
{ type: i1$5.ModalController },
|
|
21574
21654
|
{ type: ConfigService },
|
|
21575
21655
|
{ type: i1$5.ToastController },
|
|
21656
|
+
{ type: i1$5.AlertController },
|
|
21576
21657
|
{ type: i1$2.TranslateService },
|
|
21577
21658
|
{ type: i0.ChangeDetectorRef },
|
|
21578
21659
|
{ type: PlatformService },
|