@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
|
@@ -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) {
|
|
@@ -18544,7 +18538,7 @@ class AppInstallUpgradeCard {
|
|
|
18544
18538
|
console.error('[install-upgrade-card] Missing required argument \'link.url\'');
|
|
18545
18539
|
return; // Skip
|
|
18546
18540
|
}
|
|
18547
|
-
return this.
|
|
18541
|
+
return this.listenDownloadJob(link.url, this.platform.download({
|
|
18548
18542
|
uri: link.url,
|
|
18549
18543
|
title: link.title,
|
|
18550
18544
|
filename: link.filename,
|
|
@@ -18600,9 +18594,9 @@ class AppInstallUpgradeCard {
|
|
|
18600
18594
|
}
|
|
18601
18595
|
// Listening downloading promise, if exists
|
|
18602
18596
|
(this.upgradeLinks || []).forEach(link => {
|
|
18603
|
-
const
|
|
18604
|
-
if (
|
|
18605
|
-
this.
|
|
18597
|
+
const job = this.platform.getDownloadingJob(link.url);
|
|
18598
|
+
if (job)
|
|
18599
|
+
this.listenDownloadJob(link.url, job);
|
|
18606
18600
|
});
|
|
18607
18601
|
});
|
|
18608
18602
|
}
|
|
@@ -18704,9 +18698,9 @@ 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 (!url || !
|
|
18703
|
+
if (!url || !job)
|
|
18710
18704
|
return; // Skip
|
|
18711
18705
|
try {
|
|
18712
18706
|
// Mark as downloading
|
|
@@ -18715,8 +18709,11 @@ class AppInstallUpgradeCard {
|
|
|
18715
18709
|
this.downloading = true;
|
|
18716
18710
|
this.markForCheck();
|
|
18717
18711
|
}
|
|
18718
|
-
const location = yield
|
|
18719
|
-
|
|
18712
|
+
const location = yield job.toPromise();
|
|
18713
|
+
if (location) {
|
|
18714
|
+
console.info('[install-upgrade-card] File downloaded at: ' + location);
|
|
18715
|
+
return this.showDownloadCompleteDialog();
|
|
18716
|
+
}
|
|
18720
18717
|
}
|
|
18721
18718
|
// Failed: display a toast
|
|
18722
18719
|
catch (err) {
|
|
@@ -18727,7 +18724,6 @@ class AppInstallUpgradeCard {
|
|
|
18727
18724
|
this.downloading = false;
|
|
18728
18725
|
this.markForCheck();
|
|
18729
18726
|
}
|
|
18730
|
-
return this.showDownloadCompleteDialog();
|
|
18731
18727
|
});
|
|
18732
18728
|
}
|
|
18733
18729
|
showDownloadFailedToast(err) {
|