@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
|
@@ -36,7 +36,7 @@ import { MatAutocomplete, MatAutocompleteTrigger, MatAutocompleteModule, MAT_AUT
|
|
|
36
36
|
import { __awaiter, __decorate } from 'tslib';
|
|
37
37
|
import * as i1$6 from '@angular/forms';
|
|
38
38
|
import { NG_VALUE_ACCESSOR, FormGroupDirective, ReactiveFormsModule, AbstractControl, Validators, FormBuilder, FormControl, FormGroup, FormArray } from '@angular/forms';
|
|
39
|
-
import { timer, merge, fromEvent, Subscription, BehaviorSubject, Subject, isObservable, of, noop as noop$8, Observable, defer, combineLatest, EMPTY } from 'rxjs';
|
|
39
|
+
import { timer, merge, fromEvent, Subscription, BehaviorSubject, Subject, isObservable, of, noop as noop$8, Observable, defer, from, combineLatest, EMPTY } from 'rxjs';
|
|
40
40
|
import { filter, first, map, takeUntil, startWith, debounceTime, takeWhile, switchMap, tap, distinctUntilChanged, mergeMap, catchError, throttleTime } from 'rxjs/operators';
|
|
41
41
|
import * as i1$1 from '@ngx-translate/core';
|
|
42
42
|
import { TranslateService, TranslateModule } from '@ngx-translate/core';
|
|
@@ -13659,7 +13659,7 @@ class PlatformService {
|
|
|
13659
13659
|
this.browser = browser;
|
|
13660
13660
|
this.downloader = downloader;
|
|
13661
13661
|
this._started = false;
|
|
13662
|
-
this.
|
|
13662
|
+
this._downloadingJobs = new Map();
|
|
13663
13663
|
this._debug = !environment.production;
|
|
13664
13664
|
if (this._debug)
|
|
13665
13665
|
console.debug('[platform] Creating service');
|
|
@@ -13775,48 +13775,42 @@ class PlatformService {
|
|
|
13775
13775
|
window.open(url, target, features, replace);
|
|
13776
13776
|
}
|
|
13777
13777
|
}
|
|
13778
|
-
|
|
13779
|
-
return
|
|
13780
|
-
return this._downloadingPromise.get(uri);
|
|
13781
|
-
});
|
|
13778
|
+
getDownloadingJob(uri) {
|
|
13779
|
+
return this._downloadingJobs.get(uri);
|
|
13782
13780
|
}
|
|
13783
13781
|
download(request) {
|
|
13784
|
-
|
|
13785
|
-
|
|
13786
|
-
|
|
13787
|
-
if
|
|
13788
|
-
|
|
13789
|
-
|
|
13790
|
-
|
|
13791
|
-
|
|
13792
|
-
|
|
13793
|
-
|
|
13794
|
-
|
|
13795
|
-
|
|
13796
|
-
|
|
13797
|
-
|
|
13798
|
-
|
|
13799
|
-
|
|
13800
|
-
|
|
13801
|
-
|
|
13802
|
-
|
|
13803
|
-
|
|
13804
|
-
|
|
13805
|
-
|
|
13806
|
-
|
|
13807
|
-
|
|
13808
|
-
|
|
13809
|
-
|
|
13810
|
-
|
|
13811
|
-
|
|
13812
|
-
|
|
13813
|
-
|
|
13814
|
-
|
|
13815
|
-
|
|
13816
|
-
this.open(request.uri, '_system', 'location=no', true);
|
|
13817
|
-
return undefined;
|
|
13818
|
-
}
|
|
13819
|
-
});
|
|
13782
|
+
if (!request || !request.uri)
|
|
13783
|
+
throw new Error('Missing argument \'request\' or \'request.uri\'');
|
|
13784
|
+
if (this._android && this.downloader) {
|
|
13785
|
+
// Check if not already downloading file
|
|
13786
|
+
let location$ = this._downloadingJobs.get(request.uri);
|
|
13787
|
+
if (location$)
|
|
13788
|
+
return location$;
|
|
13789
|
+
request = Object.assign({ visibleInDownloadsUi: true, notificationVisibility: NotificationVisibility.VisibleNotifyCompleted, title: request.title || request.filename }, request);
|
|
13790
|
+
console.debug('[platform] Downloading, using request: ' + JSON.stringify(request));
|
|
13791
|
+
// Start download
|
|
13792
|
+
location$ = from(this.downloader.download(request));
|
|
13793
|
+
// Remember this request uri
|
|
13794
|
+
this._downloadingJobs.set(request.uri, location$);
|
|
13795
|
+
return location$
|
|
13796
|
+
.pipe(tap(location => {
|
|
13797
|
+
console.info('[platform] File successfully downloaded at:' + location);
|
|
13798
|
+
// Forget the request
|
|
13799
|
+
this._downloadingJobs.delete(request.uri);
|
|
13800
|
+
}), catchError(err => {
|
|
13801
|
+
console.error('[platform] Unable to download: ' + (err && err.message || err));
|
|
13802
|
+
// Forget the request
|
|
13803
|
+
this._downloadingJobs.delete(request.uri);
|
|
13804
|
+
throw err;
|
|
13805
|
+
}));
|
|
13806
|
+
}
|
|
13807
|
+
// Fallback (if not Android and Cordova): opening the URI using the browser
|
|
13808
|
+
// 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/)
|
|
13809
|
+
else {
|
|
13810
|
+
console.warn('[platform] Cannot use Android downloader: using browser open()');
|
|
13811
|
+
this.open(request.uri, '_system', 'location=no', true);
|
|
13812
|
+
return of();
|
|
13813
|
+
}
|
|
13820
13814
|
}
|
|
13821
13815
|
/* -- protected methods -- */
|
|
13822
13816
|
configureCordovaPlugins(mobile) {
|
|
@@ -18493,6 +18487,7 @@ class AppInstallUpgradeCard {
|
|
|
18493
18487
|
this._subscription = new Subscription();
|
|
18494
18488
|
this._showUpdateOfflineFeature = false;
|
|
18495
18489
|
this.loading = true;
|
|
18490
|
+
this.downloading = false;
|
|
18496
18491
|
this.waitingNetwork = false;
|
|
18497
18492
|
this.showUpgradeWarning = true;
|
|
18498
18493
|
this.showOfflineWarning = true;
|
|
@@ -18514,7 +18509,7 @@ class AppInstallUpgradeCard {
|
|
|
18514
18509
|
this.offline = this.network.offline;
|
|
18515
18510
|
// Listen pod config
|
|
18516
18511
|
this._subscription.add(this.configService.config
|
|
18517
|
-
.pipe(debounceTime(1000))
|
|
18512
|
+
.pipe(debounceTime(1000), filter(() => this.network.online))
|
|
18518
18513
|
.subscribe(config => this.checkNeedInstallOrUpdate(config)));
|
|
18519
18514
|
// Listen network changes
|
|
18520
18515
|
this._subscription.add(this.network.onNetworkStatusChanges
|
|
@@ -18543,13 +18538,12 @@ class AppInstallUpgradeCard {
|
|
|
18543
18538
|
console.error('[install-upgrade-card] Missing required argument \'link.url\'');
|
|
18544
18539
|
return; // Skip
|
|
18545
18540
|
}
|
|
18546
|
-
|
|
18541
|
+
return this.listenDownloadJob(link.url, this.platform.download({
|
|
18547
18542
|
uri: link.url,
|
|
18548
18543
|
title: link.title,
|
|
18549
18544
|
filename: link.filename,
|
|
18550
18545
|
mimeType: link.mimeType
|
|
18551
|
-
});
|
|
18552
|
-
return this.listenDownloadPromise(link, job);
|
|
18546
|
+
}));
|
|
18553
18547
|
});
|
|
18554
18548
|
}
|
|
18555
18549
|
tryOnline() {
|
|
@@ -18592,12 +18586,18 @@ class AppInstallUpgradeCard {
|
|
|
18592
18586
|
this.upgradeLinks = this.getCompatibleUpgradeLinks(links, config);
|
|
18593
18587
|
// Check for install links (if no upgrade need)
|
|
18594
18588
|
this.installLinks = !this.upgradeLinks && this.getCompatibleInstallLinks(links);
|
|
18595
|
-
yield sleep(
|
|
18589
|
+
yield sleep(1000); // Add a delay, for animation
|
|
18596
18590
|
}
|
|
18597
18591
|
finally {
|
|
18598
18592
|
this.loading = false;
|
|
18599
18593
|
this.markForCheck();
|
|
18600
18594
|
}
|
|
18595
|
+
// Listening downloading promise, if exists
|
|
18596
|
+
(this.upgradeLinks || []).forEach(link => {
|
|
18597
|
+
const job = this.platform.getDownloadingJob(link.url);
|
|
18598
|
+
if (job)
|
|
18599
|
+
this.listenDownloadJob(link.url, job);
|
|
18600
|
+
});
|
|
18601
18601
|
});
|
|
18602
18602
|
}
|
|
18603
18603
|
getCompatibleInstallLinks(installLinks) {
|
|
@@ -18625,12 +18625,6 @@ class AppInstallUpgradeCard {
|
|
|
18625
18625
|
// Use min version as default version
|
|
18626
18626
|
upgradeLinks.forEach(link => {
|
|
18627
18627
|
link.version = link.version || appMinVersionFromPod;
|
|
18628
|
-
const promise = this.platform.getDownloadingPromise(link.url);
|
|
18629
|
-
// Listening download promise, if exists
|
|
18630
|
-
if (promise) {
|
|
18631
|
-
console.info(`[install-upgrade-card] Platform is already downloading this file \'${link.url}\': listening promise...`);
|
|
18632
|
-
this.listenDownloadPromise(link, promise);
|
|
18633
|
-
}
|
|
18634
18628
|
});
|
|
18635
18629
|
return isNotEmptyArray(upgradeLinks) ? upgradeLinks : undefined;
|
|
18636
18630
|
}
|
|
@@ -18704,28 +18698,32 @@ class AppInstallUpgradeCard {
|
|
|
18704
18698
|
yield Toasts.show(this.toastController, this.translate, opts);
|
|
18705
18699
|
});
|
|
18706
18700
|
}
|
|
18707
|
-
|
|
18701
|
+
listenDownloadJob(url, job) {
|
|
18708
18702
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18709
|
-
if (!
|
|
18703
|
+
if (!url || !job)
|
|
18710
18704
|
return; // Skip
|
|
18711
|
-
if (!link.downloading) {
|
|
18712
|
-
link.downloading = true;
|
|
18713
|
-
this.markForCheck();
|
|
18714
|
-
}
|
|
18715
18705
|
try {
|
|
18716
|
-
|
|
18717
|
-
|
|
18706
|
+
// Mark as downloading
|
|
18707
|
+
if (!this.downloading) {
|
|
18708
|
+
console.info(`[install-upgrade-card] Platform is downloading \'${url}\' ...`);
|
|
18709
|
+
this.downloading = true;
|
|
18710
|
+
this.markForCheck();
|
|
18711
|
+
}
|
|
18712
|
+
const location = yield job.toPromise();
|
|
18713
|
+
if (location) {
|
|
18714
|
+
console.info('[install-upgrade-card] File downloaded at: ' + location);
|
|
18715
|
+
return this.showDownloadCompleteDialog();
|
|
18716
|
+
}
|
|
18718
18717
|
}
|
|
18719
18718
|
// Failed: display a toast
|
|
18720
18719
|
catch (err) {
|
|
18721
18720
|
console.error('[install-upgrade] Download failed: ' + (err && err.message || err));
|
|
18722
|
-
this.showDownloadFailedToast(err);
|
|
18721
|
+
return this.showDownloadFailedToast(err);
|
|
18723
18722
|
}
|
|
18724
18723
|
finally {
|
|
18725
|
-
|
|
18724
|
+
this.downloading = false;
|
|
18726
18725
|
this.markForCheck();
|
|
18727
18726
|
}
|
|
18728
|
-
return this.showDownloadCompleteDialog();
|
|
18729
18727
|
});
|
|
18730
18728
|
}
|
|
18731
18729
|
showDownloadFailedToast(err) {
|
|
@@ -18742,12 +18740,12 @@ class AppInstallUpgradeCard {
|
|
|
18742
18740
|
return; // Skip if component has been destroyed
|
|
18743
18741
|
const translations = yield this.translate.get([
|
|
18744
18742
|
'INFO.ALERT_HEADER',
|
|
18745
|
-
'INFO.
|
|
18743
|
+
'INFO.UPDATE_APP_DOWNLOADED',
|
|
18746
18744
|
'COMMON.BTN_CLOSE'
|
|
18747
18745
|
]).toPromise();
|
|
18748
18746
|
const alert = yield this.alertController.create({
|
|
18749
18747
|
header: translations['INFO.ALERT_HEADER'],
|
|
18750
|
-
message: translations['INFO.
|
|
18748
|
+
message: translations['INFO.UPDATE_APP_DOWNLOADED'],
|
|
18751
18749
|
buttons: [
|
|
18752
18750
|
{
|
|
18753
18751
|
text: translations['COMMON.BTN_CLOSE'],
|