@sumaris-net/ngx-components 0.26.7 → 0.27.0
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 +142 -138
- 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/graphql/graphql.service.js +1 -2
- package/esm2015/src/app/core/services/config.service.js +1 -1
- package/esm2015/src/app/core/services/platform.service.js +67 -83
- package/esm2015/src/app/shared/services/startable-service.class.js +12 -5
- package/fesm2015/sumaris-net.ngx-components.js +74 -86
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +2 -2
- package/src/app/core/services/platform.service.d.ts +3 -15
- package/src/app/shared/services/startable-service.class.d.ts +2 -1
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -37,7 +37,7 @@ import { __awaiter, __decorate } from 'tslib';
|
|
|
37
37
|
import * as i1$6 from '@angular/forms';
|
|
38
38
|
import { NG_VALUE_ACCESSOR, FormGroupDirective, AbstractControl, FormGroup, FormArray, FormControl, ReactiveFormsModule, Validators, FormBuilder } from '@angular/forms';
|
|
39
39
|
import { timer, merge, fromEvent, Subscription, BehaviorSubject, Subject, isObservable, of, noop as noop$8, Observable, defer, from, combineLatest, EMPTY } from 'rxjs';
|
|
40
|
-
import { filter, first, map, takeUntil, startWith, debounceTime, takeWhile, switchMap, tap, distinctUntilChanged, mergeMap, catchError, throttleTime } from 'rxjs/operators';
|
|
40
|
+
import { filter, first, map, takeUntil, startWith, debounceTime, takeWhile, switchMap, tap, distinctUntilChanged, mergeMap, catchError, throttleTime, skip } from 'rxjs/operators';
|
|
41
41
|
import * as i1$1 from '@ngx-translate/core';
|
|
42
42
|
import { TranslateService, TranslateModule } from '@ngx-translate/core';
|
|
43
43
|
import * as i1$4 from '@ionic/angular';
|
|
@@ -7619,13 +7619,14 @@ AppFormField.propDecorators = {
|
|
|
7619
7619
|
};
|
|
7620
7620
|
|
|
7621
7621
|
class StartableService {
|
|
7622
|
-
constructor(
|
|
7622
|
+
constructor(prerequisiteService) {
|
|
7623
7623
|
this.onStart = new Subject();
|
|
7624
7624
|
this._debug = false;
|
|
7625
|
+
this._startByReadyFunction = true; // should start when calling ready() ?
|
|
7625
7626
|
this._data = null;
|
|
7626
7627
|
this._started = false;
|
|
7627
|
-
this._startPrerequisite =
|
|
7628
|
-
? () =>
|
|
7628
|
+
this._startPrerequisite = prerequisiteService
|
|
7629
|
+
? () => prerequisiteService.ready()
|
|
7629
7630
|
: () => Promise.resolve();
|
|
7630
7631
|
}
|
|
7631
7632
|
start() {
|
|
@@ -7680,7 +7681,12 @@ class StartableService {
|
|
|
7680
7681
|
ready() {
|
|
7681
7682
|
if (this._started)
|
|
7682
7683
|
return Promise.resolve(this._data);
|
|
7683
|
-
|
|
7684
|
+
if (this._startPromise)
|
|
7685
|
+
return this._startPromise;
|
|
7686
|
+
if (this._startByReadyFunction)
|
|
7687
|
+
return this.start();
|
|
7688
|
+
return waitFor(() => this._started)
|
|
7689
|
+
.then(() => this._data);
|
|
7684
7690
|
}
|
|
7685
7691
|
ngOnStop() {
|
|
7686
7692
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -12260,7 +12266,6 @@ class GraphqlService extends StartableService {
|
|
|
12260
12266
|
.append('Authorization', authorization);
|
|
12261
12267
|
//.append('X-App-Name', environment.name)
|
|
12262
12268
|
//.append('X-App-Version', environment.version)
|
|
12263
|
-
;
|
|
12264
12269
|
// Use the setContext method to set the HTTP headers.
|
|
12265
12270
|
operation.setContext(Object.assign(Object.assign({}, operation.getContext()), { headers }));
|
|
12266
12271
|
// Call the next link in the middleware chain.
|
|
@@ -14371,8 +14376,9 @@ ConfigService.ctorParameters = () => [
|
|
|
14371
14376
|
];
|
|
14372
14377
|
|
|
14373
14378
|
const moment$2 = momentImported;
|
|
14374
|
-
class PlatformService {
|
|
14379
|
+
class PlatformService extends StartableService {
|
|
14375
14380
|
constructor(platform, cdkPlatform, toastController, translate, dateAdapter, entitiesStorage, settings, networkService, accountService, configService, cache, storage, audioProvider, environment, statusBar, keyboard, splashScreen, browser, downloader) {
|
|
14381
|
+
super(platform);
|
|
14376
14382
|
this.platform = platform;
|
|
14377
14383
|
this.cdkPlatform = cdkPlatform;
|
|
14378
14384
|
this.toastController = toastController;
|
|
@@ -14392,15 +14398,13 @@ class PlatformService {
|
|
|
14392
14398
|
this.splashScreen = splashScreen;
|
|
14393
14399
|
this.browser = browser;
|
|
14394
14400
|
this.downloader = downloader;
|
|
14395
|
-
this._started = false;
|
|
14396
14401
|
this._downloadingJobs = new Map();
|
|
14397
14402
|
this._debug = !environment.production;
|
|
14398
14403
|
if (this._debug)
|
|
14399
14404
|
console.debug('[platform] Creating service');
|
|
14400
|
-
this.start()
|
|
14401
|
-
|
|
14402
|
-
|
|
14403
|
-
return this._started;
|
|
14405
|
+
this.start()
|
|
14406
|
+
// Manage error
|
|
14407
|
+
.catch(err => this.onStartupError(err));
|
|
14404
14408
|
}
|
|
14405
14409
|
get mobile() {
|
|
14406
14410
|
return isNotNil(this._mobile) ? this._mobile : this.platform.is('mobile');
|
|
@@ -14427,78 +14431,62 @@ class PlatformService {
|
|
|
14427
14431
|
height() {
|
|
14428
14432
|
return this.platform.height();
|
|
14429
14433
|
}
|
|
14430
|
-
|
|
14431
|
-
|
|
14432
|
-
|
|
14433
|
-
|
|
14434
|
-
|
|
14435
|
-
|
|
14436
|
-
|
|
14437
|
-
|
|
14438
|
-
|
|
14439
|
-
|
|
14440
|
-
|
|
14441
|
-
|
|
14442
|
-
|
|
14443
|
-
|
|
14444
|
-
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
|
|
14450
|
-
|
|
14451
|
-
|
|
14452
|
-
|
|
14453
|
-
|
|
14454
|
-
|
|
14455
|
-
|
|
14456
|
-
|
|
14457
|
-
|
|
14458
|
-
|
|
14459
|
-
|
|
14460
|
-
|
|
14461
|
-
|
|
14462
|
-
|
|
14463
|
-
|
|
14464
|
-
|
|
14465
|
-
|
|
14466
|
-
|
|
14467
|
-
|
|
14468
|
-
|
|
14469
|
-
|
|
14470
|
-
|
|
14471
|
-
|
|
14472
|
-
|
|
14473
|
-
|
|
14474
|
-
|
|
14475
|
-
|
|
14476
|
-
|
|
14477
|
-
|
|
14478
|
-
|
|
14479
|
-
|
|
14480
|
-
|
|
14481
|
-
|
|
14482
|
-
|
|
14483
|
-
|
|
14484
|
-
|
|
14485
|
-
|
|
14486
|
-
}
|
|
14487
|
-
/**
|
|
14488
|
-
* Wait platform is ready.<br/>
|
|
14489
|
-
* Important: this will NOT start the platform, has it should be started by the AppComponent
|
|
14490
|
-
*
|
|
14491
|
-
* @param opts
|
|
14492
|
-
*/
|
|
14493
|
-
ready(opts) {
|
|
14494
|
-
const period = opts && opts.checkPeriod || 300;
|
|
14495
|
-
if (this._started)
|
|
14496
|
-
return Promise.resolve();
|
|
14497
|
-
return timer(period, period)
|
|
14498
|
-
.pipe(
|
|
14499
|
-
// For DEBUG :
|
|
14500
|
-
//tap(() => this._debug && console.debug("Waiting platform ready...")),
|
|
14501
|
-
filter(() => this._started), first()).toPromise();
|
|
14434
|
+
ngOnStart() {
|
|
14435
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14436
|
+
const now = Date.now();
|
|
14437
|
+
this.accountService.tokenType = undefined;
|
|
14438
|
+
console.info('[platform] Starting platform...');
|
|
14439
|
+
try {
|
|
14440
|
+
this._mobile = this.platform.is('mobile');
|
|
14441
|
+
this._cordova = this.platform.is('cordova');
|
|
14442
|
+
this._android = this.platform.is('android');
|
|
14443
|
+
this.configureCordovaPlugins(this._mobile);
|
|
14444
|
+
this.touchUi = this._mobile || this.platform.is('tablet') || this.platform.is('phablet');
|
|
14445
|
+
// Force mobile in settings
|
|
14446
|
+
if (this._mobile) {
|
|
14447
|
+
this.settings.mobile = this._mobile;
|
|
14448
|
+
this.settings.touchUi = this.touchUi;
|
|
14449
|
+
}
|
|
14450
|
+
// Configure translation
|
|
14451
|
+
yield this.configureTranslate();
|
|
14452
|
+
// Configure storage
|
|
14453
|
+
const forage = yield this.storageReady();
|
|
14454
|
+
yield this.migrateStorage(forage);
|
|
14455
|
+
// Start root services
|
|
14456
|
+
yield Promise.all([
|
|
14457
|
+
this.entitiesStorage.ready(),
|
|
14458
|
+
this.cache.ready().then(() => this.configureCache()),
|
|
14459
|
+
this.settings.ready(),
|
|
14460
|
+
this.networkService.ready(),
|
|
14461
|
+
this.audioProvider.ready()
|
|
14462
|
+
]);
|
|
14463
|
+
console.info(`[platform] Starting platform [OK] {mobile: ${this._mobile}, touchUi: ${this.touchUi}, downloader: ${this.canDownload}} in ${Date.now() - now}ms`);
|
|
14464
|
+
// Update cache configuration when network changed
|
|
14465
|
+
this.networkService.onNetworkStatusChanges
|
|
14466
|
+
.pipe(skip(1)) // Skip the first event (behavior subject send event immediately)
|
|
14467
|
+
.subscribe(type => this.configureCache(type !== 'none'));
|
|
14468
|
+
// Update authentication type
|
|
14469
|
+
this.configService.config
|
|
14470
|
+
.pipe(map(config => config === null || config === void 0 ? void 0 : config.getProperty(CORE_CONFIG_OPTIONS.AUTH_TOKEN_TYPE)), filter(isNotNilOrBlank), distinctUntilChanged())
|
|
14471
|
+
.subscribe(tokenType => {
|
|
14472
|
+
console.info(`[platform] Using auth token type {${tokenType}}`);
|
|
14473
|
+
this.accountService.tokenType = tokenType;
|
|
14474
|
+
});
|
|
14475
|
+
// Hide the splashscreen (if mobile) - after 1s
|
|
14476
|
+
if (this.mobile) {
|
|
14477
|
+
setTimeout(() => {
|
|
14478
|
+
var _a;
|
|
14479
|
+
(_a = this.splashScreen) === null || _a === void 0 ? void 0 : _a.hide();
|
|
14480
|
+
// Play startup sound
|
|
14481
|
+
this.audioProvider.playStartupSound();
|
|
14482
|
+
}, 1000);
|
|
14483
|
+
}
|
|
14484
|
+
}
|
|
14485
|
+
catch (err) {
|
|
14486
|
+
// Manage startup error
|
|
14487
|
+
return this.onStartupError(err);
|
|
14488
|
+
}
|
|
14489
|
+
});
|
|
14502
14490
|
}
|
|
14503
14491
|
open(url, target, features, replace) {
|
|
14504
14492
|
console.info(`[platform] Opening link: ${url}`);
|
|
@@ -14609,9 +14597,9 @@ class PlatformService {
|
|
|
14609
14597
|
});
|
|
14610
14598
|
}
|
|
14611
14599
|
configureCache(online) {
|
|
14612
|
-
online =
|
|
14600
|
+
online = toBoolean(online, this.cache.isOnline());
|
|
14613
14601
|
const cacheTTL = online ? 3600 /* 1h */ : 3600 * 24 * 30; /* 1 month */
|
|
14614
|
-
console.info(`[platform] Configuring cache [OK] {online: ${online}
|
|
14602
|
+
console.info(`[platform] Configuring cache [OK] {online: ${online}, timeToLive: ${cacheTTL / 3600}h, offlineInvalidate: false}`);
|
|
14615
14603
|
this.cache.setDefaultTTL(cacheTTL);
|
|
14616
14604
|
this.cache.setOfflineInvalidate(false); // Do not invalidate cache when offline
|
|
14617
14605
|
}
|