@sumaris-net/ngx-components 0.25.1 → 0.25.5
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 +280 -93
- 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/graphql/graphql.service.js +10 -11
- package/esm2015/src/app/core/install/install-upgrade-card.component.js +147 -48
- package/esm2015/src/app/core/services/model/peer.model.js +15 -2
- package/esm2015/src/app/core/services/network.service.js +2 -2
- package/esm2015/src/app/core/services/platform.service.js +29 -10
- package/esm2015/src/app/shared/services/startable-service.class.js +4 -1
- package/fesm2015/sumaris-net.ngx-components.js +194 -64
- 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 +18 -8
- package/src/app/core/services/model/peer.model.d.ts +1 -0
- package/src/app/core/services/platform.service.d.ts +2 -0
- package/src/app/shared/services/startable-service.class.d.ts +1 -0
- package/src/assets/i18n/fr.json +3 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -7816,6 +7816,13 @@
|
|
|
7816
7816
|
enumerable: false,
|
|
7817
7817
|
configurable: true
|
|
7818
7818
|
});
|
|
7819
|
+
Object.defineProperty(StartableService.prototype, "starting", {
|
|
7820
|
+
get: function () {
|
|
7821
|
+
return !!this._startPromise;
|
|
7822
|
+
},
|
|
7823
|
+
enumerable: false,
|
|
7824
|
+
configurable: true
|
|
7825
|
+
});
|
|
7819
7826
|
StartableService.prototype.ready = function () {
|
|
7820
7827
|
if (this._started)
|
|
7821
7828
|
return Promise.resolve(this._data);
|
|
@@ -9205,6 +9212,24 @@
|
|
|
9205
9212
|
path: noTrailingSlash(url.pathname)
|
|
9206
9213
|
});
|
|
9207
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
|
+
};
|
|
9208
9233
|
Peer.prototype.asObject = function (options) {
|
|
9209
9234
|
return _super.prototype.asObject.call(this, options);
|
|
9210
9235
|
};
|
|
@@ -10939,7 +10964,7 @@
|
|
|
10939
10964
|
var _this = this;
|
|
10940
10965
|
this._listeners[name] = this._listeners[name] || [];
|
|
10941
10966
|
this._listeners[name].push(callback);
|
|
10942
|
-
// When
|
|
10967
|
+
// When unsubscribe, remove from the listener
|
|
10943
10968
|
return new rxjs.Subscription(function () {
|
|
10944
10969
|
var index = _this._listeners[name].indexOf(callback);
|
|
10945
10970
|
if (index !== -1) {
|
|
@@ -12705,7 +12730,7 @@
|
|
|
12705
12730
|
var GraphqlService = /** @class */ (function (_super) {
|
|
12706
12731
|
__extends(GraphqlService, _super);
|
|
12707
12732
|
function GraphqlService(platform, apollo, httpLink, network, storage, cryptoService, environment, typePolicies) {
|
|
12708
|
-
var _this = _super.call(this,
|
|
12733
|
+
var _this = _super.call(this, platform) || this;
|
|
12709
12734
|
_this.platform = platform;
|
|
12710
12735
|
_this.apollo = apollo;
|
|
12711
12736
|
_this.httpLink = httpLink;
|
|
@@ -12720,22 +12745,6 @@
|
|
|
12720
12745
|
_this.customErrors = {};
|
|
12721
12746
|
_this._debug = !environment.production;
|
|
12722
12747
|
_this._defaultFetchPolicy = environment.apolloFetchPolicy;
|
|
12723
|
-
// Restart if network restart
|
|
12724
|
-
_this.network.on('start', function () { return _this.restart(); });
|
|
12725
|
-
// Clear cache
|
|
12726
|
-
_this.network.on('resetCache', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
12727
|
-
return __generator(this, function (_a) {
|
|
12728
|
-
switch (_a.label) {
|
|
12729
|
-
case 0: return [4 /*yield*/, this.ready()];
|
|
12730
|
-
case 1:
|
|
12731
|
-
_a.sent();
|
|
12732
|
-
return [4 /*yield*/, this.clearCache()];
|
|
12733
|
-
case 2:
|
|
12734
|
-
_a.sent();
|
|
12735
|
-
return [2 /*return*/];
|
|
12736
|
-
}
|
|
12737
|
-
});
|
|
12738
|
-
}); });
|
|
12739
12748
|
// Listen network status
|
|
12740
12749
|
_this._networkStatusChanged$ = network.onNetworkStatusChanges
|
|
12741
12750
|
.pipe(operators.filter(isNotNil), operators.distinctUntilChanged());
|
|
@@ -13196,12 +13205,14 @@
|
|
|
13196
13205
|
return __generator(this, function (_a) {
|
|
13197
13206
|
switch (_a.label) {
|
|
13198
13207
|
case 0:
|
|
13199
|
-
client = (client || this.
|
|
13208
|
+
client = (client || this.client);
|
|
13200
13209
|
if (!client) return [3 /*break*/, 2];
|
|
13201
|
-
now = this._debug && Date.now();
|
|
13202
13210
|
console.info('[graphql] Clearing Apollo client\'s cache... ');
|
|
13211
|
+
now = this._debug && Date.now();
|
|
13212
|
+
// Clearing the cache
|
|
13203
13213
|
return [4 /*yield*/, client.cache.reset()];
|
|
13204
13214
|
case 1:
|
|
13215
|
+
// Clearing the cache
|
|
13205
13216
|
_a.sent();
|
|
13206
13217
|
if (this._debug)
|
|
13207
13218
|
console.debug("[graphql] Apollo client's cache cleared, in " + (Date.now() - now) + "ms");
|
|
@@ -13221,7 +13232,9 @@
|
|
|
13221
13232
|
var _this = this;
|
|
13222
13233
|
return __generator(this, function (_a) {
|
|
13223
13234
|
switch (_a.label) {
|
|
13224
|
-
case 0:
|
|
13235
|
+
case 0: return [4 /*yield*/, this.network.ready()];
|
|
13236
|
+
case 1:
|
|
13237
|
+
_a.sent();
|
|
13225
13238
|
console.info('[graphql] Starting graphql...');
|
|
13226
13239
|
mobile = this.platform.is('mobile') || this.platform.is('mobileweb');
|
|
13227
13240
|
enableTrackMutationQueries = !mobile;
|
|
@@ -13241,7 +13254,7 @@
|
|
|
13241
13254
|
}, webSocketImpl: AppWebSocket, uri: wsUri });
|
|
13242
13255
|
storage = new apollo3CachePersist.IonicStorageWrapper(this.storage);
|
|
13243
13256
|
client = this.apollo.client;
|
|
13244
|
-
if (!!client) return [3 /*break*/,
|
|
13257
|
+
if (!!client) return [3 /*break*/, 4];
|
|
13245
13258
|
console.debug('[apollo] Creating GraphQL client...');
|
|
13246
13259
|
wsLink = new ws.WebSocketLink(this.wsParams);
|
|
13247
13260
|
retryLink = new retry.RetryLink();
|
|
@@ -13267,7 +13280,7 @@
|
|
|
13267
13280
|
cache = new core.InMemoryCache({
|
|
13268
13281
|
typePolicies: this.typePolicies
|
|
13269
13282
|
});
|
|
13270
|
-
if (!this.environment.persistCache) return [3 /*break*/,
|
|
13283
|
+
if (!this.environment.persistCache) return [3 /*break*/, 3];
|
|
13271
13284
|
console.debug('[graphql] Starting persistence cache...');
|
|
13272
13285
|
return [4 /*yield*/, apollo3CachePersist.persistCache({
|
|
13273
13286
|
cache: cache,
|
|
@@ -13276,10 +13289,10 @@
|
|
|
13276
13289
|
debounce: 1000,
|
|
13277
13290
|
debug: true
|
|
13278
13291
|
})];
|
|
13279
|
-
case 1:
|
|
13280
|
-
_a.sent();
|
|
13281
|
-
_a.label = 2;
|
|
13282
13292
|
case 2:
|
|
13293
|
+
_a.sent();
|
|
13294
|
+
_a.label = 3;
|
|
13295
|
+
case 3:
|
|
13283
13296
|
mutationLinks = void 0;
|
|
13284
13297
|
// Add queue to store tracked queries, when offline
|
|
13285
13298
|
if (enableTrackMutationQueries) {
|
|
@@ -13339,25 +13352,29 @@
|
|
|
13339
13352
|
connectToDevTools: !this.environment.production
|
|
13340
13353
|
});
|
|
13341
13354
|
this.apollo.client = client;
|
|
13342
|
-
_a.label = 3;
|
|
13343
|
-
case 3:
|
|
13344
|
-
if (!(enableTrackMutationQueries && this.environment.persistCache)) return [3 /*break*/, 7];
|
|
13345
13355
|
_a.label = 4;
|
|
13346
13356
|
case 4:
|
|
13347
|
-
|
|
13357
|
+
if (!(enableTrackMutationQueries && this.environment.persistCache)) return [3 /*break*/, 8];
|
|
13358
|
+
_a.label = 5;
|
|
13359
|
+
case 5:
|
|
13360
|
+
_a.trys.push([5, 7, , 8]);
|
|
13348
13361
|
return [4 /*yield*/, restoreTrackedQueries({
|
|
13349
13362
|
apolloClient: client,
|
|
13350
13363
|
storage: storage,
|
|
13351
13364
|
debug: true
|
|
13352
13365
|
})];
|
|
13353
|
-
case 5:
|
|
13354
|
-
_a.sent();
|
|
13355
|
-
return [3 /*break*/, 7];
|
|
13356
13366
|
case 6:
|
|
13367
|
+
_a.sent();
|
|
13368
|
+
return [3 /*break*/, 8];
|
|
13369
|
+
case 7:
|
|
13357
13370
|
err_2 = _a.sent();
|
|
13358
13371
|
console.error('[graphql] Failed to restore tracked queries from storage: ' + (err_2 && err_2.message || err_2), err_2);
|
|
13359
|
-
return [3 /*break*/,
|
|
13360
|
-
case
|
|
13372
|
+
return [3 /*break*/, 8];
|
|
13373
|
+
case 8:
|
|
13374
|
+
// Listen for network restart
|
|
13375
|
+
this._subscription.add(this.network.on('start', function () { return _this.restart(); }));
|
|
13376
|
+
// Listen for clear cache request, from network
|
|
13377
|
+
this._subscription.add(this.network.on('resetCache', function () { return _this.clearCache(); }));
|
|
13361
13378
|
console.info('[graphql] Starting graphql [OK]');
|
|
13362
13379
|
return [2 /*return*/, client];
|
|
13363
13380
|
}
|
|
@@ -15661,6 +15678,7 @@
|
|
|
15661
15678
|
this.browser = browser;
|
|
15662
15679
|
this.downloader = downloader;
|
|
15663
15680
|
this._started = false;
|
|
15681
|
+
this._downloadingPromise = new Map();
|
|
15664
15682
|
this._debug = !environment.production;
|
|
15665
15683
|
if (this._debug)
|
|
15666
15684
|
console.debug('[platform] Creating service');
|
|
@@ -15695,7 +15713,7 @@
|
|
|
15695
15713
|
};
|
|
15696
15714
|
Object.defineProperty(PlatformService.prototype, "canDownload", {
|
|
15697
15715
|
get: function () {
|
|
15698
|
-
return !!this.downloader;
|
|
15716
|
+
return this._android && !!this.downloader;
|
|
15699
15717
|
},
|
|
15700
15718
|
enumerable: false,
|
|
15701
15719
|
configurable: true
|
|
@@ -15742,7 +15760,7 @@
|
|
|
15742
15760
|
.then(function () {
|
|
15743
15761
|
_this._started = true;
|
|
15744
15762
|
_this._startPromise = undefined;
|
|
15745
|
-
console.info("[platform] Starting platform [OK] {mobile: " + _this._mobile + ", touchUi: " + _this.touchUi + ",
|
|
15763
|
+
console.info("[platform] Starting platform [OK] {mobile: " + _this._mobile + ", touchUi: " + _this.touchUi + ", canDownload: " + _this.canDownload + "} in " + (Date.now() - now) + "ms");
|
|
15746
15764
|
// Update cache configuration when network changed
|
|
15747
15765
|
_this.networkService.onNetworkStatusChanges.subscribe(function (type) { return _this.configureCache(type !== 'none'); });
|
|
15748
15766
|
// Update authentication type
|
|
@@ -15790,34 +15808,53 @@
|
|
|
15790
15808
|
window.open(url, target, features, replace);
|
|
15791
15809
|
}
|
|
15792
15810
|
};
|
|
15811
|
+
PlatformService.prototype.getDownloadingPromise = function (uri) {
|
|
15812
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15813
|
+
return __generator(this, function (_a) {
|
|
15814
|
+
return [2 /*return*/, this._downloadingPromise.get(uri)];
|
|
15815
|
+
});
|
|
15816
|
+
});
|
|
15817
|
+
};
|
|
15793
15818
|
PlatformService.prototype.download = function (request) {
|
|
15794
15819
|
return __awaiter(this, void 0, void 0, function () {
|
|
15795
|
-
var location, err_1;
|
|
15820
|
+
var promise, location, err_1;
|
|
15796
15821
|
return __generator(this, function (_a) {
|
|
15797
15822
|
switch (_a.label) {
|
|
15798
15823
|
case 0:
|
|
15799
15824
|
if (!request || !request.uri)
|
|
15800
15825
|
throw new Error('Missing argument \'request\' or \'request.uri\'');
|
|
15801
|
-
if (!this.downloader) return [3 /*break*/,
|
|
15802
|
-
|
|
15826
|
+
if (!(this._android && this.downloader)) return [3 /*break*/, 6];
|
|
15827
|
+
promise = this._downloadingPromise.get(request.uri);
|
|
15828
|
+
if (promise)
|
|
15829
|
+
return [2 /*return*/, promise];
|
|
15830
|
+
request = Object.assign({ visibleInDownloadsUi: true, notificationVisibility: ngx$6.NotificationVisibility.VisibleNotifyCompleted, title: request.title || request.filename }, request);
|
|
15803
15831
|
_a.label = 1;
|
|
15804
15832
|
case 1:
|
|
15805
|
-
_a.trys.push([1, 3, ,
|
|
15806
|
-
|
|
15833
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
15834
|
+
console.debug('[platform] Downloading, using request: ' + JSON.stringify(request));
|
|
15835
|
+
// Start download
|
|
15836
|
+
promise = this.downloader.download(request);
|
|
15837
|
+
// Remember this request uri
|
|
15838
|
+
this._downloadingPromise.set(request.uri, promise);
|
|
15839
|
+
return [4 /*yield*/, promise];
|
|
15807
15840
|
case 2:
|
|
15808
15841
|
location = _a.sent();
|
|
15809
15842
|
console.info('[platform] File successfully downloaded at:' + location);
|
|
15810
15843
|
return [2 /*return*/, location];
|
|
15811
15844
|
case 3:
|
|
15812
15845
|
err_1 = _a.sent();
|
|
15813
|
-
console.error('[platform]
|
|
15846
|
+
console.error('[platform] Unable to download: ' + (err_1 && err_1.message || err_1));
|
|
15814
15847
|
throw err_1;
|
|
15815
|
-
case 4:
|
|
15816
|
-
|
|
15817
|
-
|
|
15848
|
+
case 4:
|
|
15849
|
+
// Forget the request
|
|
15850
|
+
this._downloadingPromise.delete(request.uri);
|
|
15851
|
+
return [7 /*endfinally*/];
|
|
15852
|
+
case 5: return [3 /*break*/, 7];
|
|
15853
|
+
case 6:
|
|
15854
|
+
console.warn('[platform] Cannot use Android downloader: using browser open()');
|
|
15818
15855
|
this.open(request.uri, '_system', 'location=no', true);
|
|
15819
15856
|
return [2 /*return*/, undefined];
|
|
15820
|
-
case
|
|
15857
|
+
case 7: return [2 /*return*/];
|
|
15821
15858
|
}
|
|
15822
15859
|
});
|
|
15823
15860
|
});
|
|
@@ -21279,9 +21316,12 @@
|
|
|
21279
21316
|
ANDROID_APK: 'application/vnd.android.package-archive'
|
|
21280
21317
|
});
|
|
21281
21318
|
var AppInstallUpgradeCard = /** @class */ (function () {
|
|
21282
|
-
function AppInstallUpgradeCard(modalCtrl, configService, cd, platform, network, environment) {
|
|
21319
|
+
function AppInstallUpgradeCard(modalCtrl, configService, toastController, alertController, translate, cd, platform, network, environment) {
|
|
21283
21320
|
this.modalCtrl = modalCtrl;
|
|
21284
21321
|
this.configService = configService;
|
|
21322
|
+
this.toastController = toastController;
|
|
21323
|
+
this.alertController = alertController;
|
|
21324
|
+
this.translate = translate;
|
|
21285
21325
|
this.cd = cd;
|
|
21286
21326
|
this.platform = platform;
|
|
21287
21327
|
this.network = network;
|
|
@@ -21319,18 +21359,8 @@
|
|
|
21319
21359
|
this.offline = this.network.offline;
|
|
21320
21360
|
// Listen pod config
|
|
21321
21361
|
this._subscription.add(this.configService.config
|
|
21322
|
-
.
|
|
21323
|
-
|
|
21324
|
-
var installLinks = _this.getAllInstallLinks(config);
|
|
21325
|
-
// Check for upgrade
|
|
21326
|
-
_this.updateLinks = _this.getCompatibleUpgradeLinks(installLinks, config);
|
|
21327
|
-
// Check for install links (if no upgrade need)
|
|
21328
|
-
_this.installLinks = !_this.updateLinks && _this.getCompatibleInstallLinks(installLinks);
|
|
21329
|
-
setTimeout(function () {
|
|
21330
|
-
_this.loading = false;
|
|
21331
|
-
_this.markForCheck();
|
|
21332
|
-
}, 2000); // Add a delay, for animation
|
|
21333
|
-
}));
|
|
21362
|
+
.pipe(operators.debounceTime(1000), operators.filter(function () { return _this.network.online; }))
|
|
21363
|
+
.subscribe(function (config) { return _this.checkNeedInstallOrUpdate(config); }));
|
|
21334
21364
|
// Listen network changes
|
|
21335
21365
|
this._subscription.add(this.network.onNetworkStatusChanges
|
|
21336
21366
|
.pipe(
|
|
@@ -21338,8 +21368,10 @@
|
|
|
21338
21368
|
//tap(() => this.waitingNetwork = false),
|
|
21339
21369
|
operators.map(function (connectionType) { return connectionType === 'none'; }), operators.distinctUntilChanged())
|
|
21340
21370
|
.subscribe(function (offline) {
|
|
21341
|
-
_this.offline
|
|
21342
|
-
|
|
21371
|
+
if (_this.offline !== offline) {
|
|
21372
|
+
_this.offline = offline;
|
|
21373
|
+
_this.markForCheck();
|
|
21374
|
+
}
|
|
21343
21375
|
}));
|
|
21344
21376
|
return [2 /*return*/];
|
|
21345
21377
|
}
|
|
@@ -21348,39 +21380,54 @@
|
|
|
21348
21380
|
};
|
|
21349
21381
|
AppInstallUpgradeCard.prototype.ngOnDestroy = function () {
|
|
21350
21382
|
this._subscription.unsubscribe();
|
|
21383
|
+
this._subscription = null;
|
|
21384
|
+
this.onUpdateOfflineModeClick.complete();
|
|
21385
|
+
this.installLinks = null;
|
|
21386
|
+
this.upgradeLinks = null;
|
|
21351
21387
|
};
|
|
21352
|
-
AppInstallUpgradeCard.prototype.
|
|
21388
|
+
AppInstallUpgradeCard.prototype.download = function (event, link) {
|
|
21353
21389
|
return __awaiter(this, void 0, void 0, function () {
|
|
21390
|
+
var job;
|
|
21354
21391
|
return __generator(this, function (_a) {
|
|
21355
21392
|
if (!link || !link.url) {
|
|
21356
|
-
console.
|
|
21393
|
+
console.error('[install-upgrade-card] Missing required argument \'link.url\'');
|
|
21357
21394
|
return [2 /*return*/]; // Skip
|
|
21358
21395
|
}
|
|
21359
|
-
|
|
21360
|
-
this.platform.download({
|
|
21396
|
+
job = this.platform.download({
|
|
21361
21397
|
uri: link.url,
|
|
21362
|
-
|
|
21398
|
+
title: link.title,
|
|
21399
|
+
filename: link.filename,
|
|
21363
21400
|
mimeType: link.mimeType
|
|
21364
|
-
}).then(function (location) {
|
|
21365
|
-
console.info('[install-upgrade] File downloaded at: ' + location);
|
|
21366
|
-
// TODO: display a info toast ?
|
|
21367
21401
|
});
|
|
21368
|
-
return [2 /*return
|
|
21402
|
+
return [2 /*return*/, this.listenDownloadPromise(link, job)];
|
|
21369
21403
|
});
|
|
21370
21404
|
});
|
|
21371
21405
|
};
|
|
21372
21406
|
AppInstallUpgradeCard.prototype.tryOnline = function () {
|
|
21373
|
-
|
|
21374
|
-
|
|
21375
|
-
|
|
21376
|
-
|
|
21377
|
-
|
|
21378
|
-
|
|
21379
|
-
|
|
21380
|
-
|
|
21381
|
-
|
|
21382
|
-
|
|
21383
|
-
|
|
21407
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
21408
|
+
return __generator(this, function (_a) {
|
|
21409
|
+
switch (_a.label) {
|
|
21410
|
+
case 0:
|
|
21411
|
+
this.waitingNetwork = true;
|
|
21412
|
+
this.markForCheck();
|
|
21413
|
+
_a.label = 1;
|
|
21414
|
+
case 1:
|
|
21415
|
+
_a.trys.push([1, , 3, 4]);
|
|
21416
|
+
return [4 /*yield*/, this.network.tryOnline({
|
|
21417
|
+
showLoadingToast: false,
|
|
21418
|
+
showOnlineToast: true,
|
|
21419
|
+
showOfflineToast: false
|
|
21420
|
+
})];
|
|
21421
|
+
case 2:
|
|
21422
|
+
_a.sent();
|
|
21423
|
+
return [3 /*break*/, 4];
|
|
21424
|
+
case 3:
|
|
21425
|
+
this.waitingNetwork = false;
|
|
21426
|
+
this.markForCheck();
|
|
21427
|
+
return [7 /*endfinally*/];
|
|
21428
|
+
case 4: return [2 /*return*/];
|
|
21429
|
+
}
|
|
21430
|
+
});
|
|
21384
21431
|
});
|
|
21385
21432
|
};
|
|
21386
21433
|
AppInstallUpgradeCard.prototype.getPlatformName = function (platform) {
|
|
@@ -21397,6 +21444,45 @@
|
|
|
21397
21444
|
return value;
|
|
21398
21445
|
};
|
|
21399
21446
|
/* -- private method -- */
|
|
21447
|
+
AppInstallUpgradeCard.prototype.checkNeedInstallOrUpdate = function (config) {
|
|
21448
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
21449
|
+
var links;
|
|
21450
|
+
var _this = this;
|
|
21451
|
+
return __generator(this, function (_a) {
|
|
21452
|
+
switch (_a.label) {
|
|
21453
|
+
case 0:
|
|
21454
|
+
console.info('[install] Check if need to install or upgrade...');
|
|
21455
|
+
_a.label = 1;
|
|
21456
|
+
case 1:
|
|
21457
|
+
_a.trys.push([1, , 3, 4]);
|
|
21458
|
+
links = this.getLinks(config);
|
|
21459
|
+
// Check for upgrade
|
|
21460
|
+
this.upgradeLinks = this.getCompatibleUpgradeLinks(links, config);
|
|
21461
|
+
// Check for install links (if no upgrade need)
|
|
21462
|
+
this.installLinks = !this.upgradeLinks && this.getCompatibleInstallLinks(links);
|
|
21463
|
+
return [4 /*yield*/, sleep(1000)];
|
|
21464
|
+
case 2:
|
|
21465
|
+
_a.sent(); // Add a delay, for animation
|
|
21466
|
+
return [3 /*break*/, 4];
|
|
21467
|
+
case 3:
|
|
21468
|
+
this.loading = false;
|
|
21469
|
+
this.markForCheck();
|
|
21470
|
+
return [7 /*endfinally*/];
|
|
21471
|
+
case 4:
|
|
21472
|
+
// Listening downloading files
|
|
21473
|
+
(this.upgradeLinks || []).forEach(function (link) {
|
|
21474
|
+
var promise = _this.platform.getDownloadingPromise(link.url);
|
|
21475
|
+
// Listening download promise, if exists
|
|
21476
|
+
if (promise) {
|
|
21477
|
+
console.info("[install-upgrade-card] Platform is already downloading this file '" + link.url + "': listening promise...");
|
|
21478
|
+
_this.listenDownloadPromise(link, promise);
|
|
21479
|
+
}
|
|
21480
|
+
});
|
|
21481
|
+
return [2 /*return*/];
|
|
21482
|
+
}
|
|
21483
|
+
});
|
|
21484
|
+
});
|
|
21485
|
+
};
|
|
21400
21486
|
AppInstallUpgradeCard.prototype.getCompatibleInstallLinks = function (installLinks) {
|
|
21401
21487
|
// Cordova already running: not need to install
|
|
21402
21488
|
if (this.platform.is('cordova'))
|
|
@@ -21426,7 +21512,7 @@
|
|
|
21426
21512
|
});
|
|
21427
21513
|
return isNotEmptyArray(upgradeLinks) ? upgradeLinks : undefined;
|
|
21428
21514
|
};
|
|
21429
|
-
AppInstallUpgradeCard.prototype.
|
|
21515
|
+
AppInstallUpgradeCard.prototype.getLinks = function (config) {
|
|
21430
21516
|
var result = [];
|
|
21431
21517
|
// Android
|
|
21432
21518
|
{
|
|
@@ -21434,16 +21520,20 @@
|
|
|
21434
21520
|
var url = config.getProperty(CORE_CONFIG_OPTIONS.ANDROID_INSTALL_URL);
|
|
21435
21521
|
if (isNilOrBlank(url))
|
|
21436
21522
|
url = this.environment.defaultAndroidInstallUrl || null;
|
|
21523
|
+
// Resolve relative URL
|
|
21524
|
+
var peer = this.network.peer;
|
|
21525
|
+
if (peer && (url.startsWith('./') || url.startsWith('/'))) {
|
|
21526
|
+
url = exports.Peer.path(peer, url);
|
|
21527
|
+
}
|
|
21437
21528
|
var minVersion = config.getProperty(CORE_CONFIG_OPTIONS.APP_MIN_VERSION);
|
|
21438
21529
|
// Compute App name
|
|
21439
21530
|
var name = isNotNilOrBlank(url) && config.label || this.environment.defaultAppName || 'SUMARiS';
|
|
21440
21531
|
if (url) {
|
|
21441
|
-
var
|
|
21442
|
-
var version = void 0;
|
|
21532
|
+
var title = void 0;
|
|
21443
21533
|
var mimeType = void 0;
|
|
21444
21534
|
// Get file name
|
|
21445
21535
|
var filename = this.getFilename(url);
|
|
21446
|
-
version = minVersion || 'latest';
|
|
21536
|
+
var version = minVersion || 'latest';
|
|
21447
21537
|
// OK, this is a downloadable APK file (e.g. NOT a link to a playstore)
|
|
21448
21538
|
if (filename === null || filename === void 0 ? void 0 : filename.endsWith('.apk')) {
|
|
21449
21539
|
// Define mime type
|
|
@@ -21452,18 +21542,18 @@
|
|
|
21452
21542
|
var versionMatches = /-v([1-9][0-9]*\.[0-9]+\.(:?(:?alpha|beta|rc)?[0-9]*))/i.exec(filename);
|
|
21453
21543
|
version = versionMatches && versionMatches[1] || version;
|
|
21454
21544
|
// Compute a new file name, with the version
|
|
21455
|
-
if (isNotNilOrBlank(name)) {
|
|
21456
|
-
|
|
21545
|
+
if (isNotNilOrBlank(name) && version !== 'latest') {
|
|
21546
|
+
filename = (name + "-v" + version + ".apk").toLowerCase();
|
|
21547
|
+
title = name + " v" + version;
|
|
21457
21548
|
}
|
|
21458
21549
|
else {
|
|
21459
|
-
downloadFilename = filename;
|
|
21460
21550
|
// Replace 'latest' with the app version, if present
|
|
21461
|
-
if (
|
|
21462
|
-
|
|
21551
|
+
if (filename.indexOf('latest')) {
|
|
21552
|
+
filename = filename.replace('latest', version);
|
|
21463
21553
|
}
|
|
21464
21554
|
}
|
|
21465
21555
|
}
|
|
21466
|
-
result.push({ name: name, url: url, platform: 'android', version: version,
|
|
21556
|
+
result.push({ name: name, url: url, platform: 'android', version: version, filename: filename, title: title, mimeType: mimeType });
|
|
21467
21557
|
}
|
|
21468
21558
|
}
|
|
21469
21559
|
// iOS - TODO
|
|
@@ -21487,12 +21577,106 @@
|
|
|
21487
21577
|
AppInstallUpgradeCard.prototype.markForCheck = function () {
|
|
21488
21578
|
this.cd.markForCheck();
|
|
21489
21579
|
};
|
|
21580
|
+
AppInstallUpgradeCard.prototype.showToast = function (opts) {
|
|
21581
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
21582
|
+
return __generator(this, function (_a) {
|
|
21583
|
+
switch (_a.label) {
|
|
21584
|
+
case 0: return [4 /*yield*/, Toasts.show(this.toastController, this.translate, opts)];
|
|
21585
|
+
case 1:
|
|
21586
|
+
_a.sent();
|
|
21587
|
+
return [2 /*return*/];
|
|
21588
|
+
}
|
|
21589
|
+
});
|
|
21590
|
+
});
|
|
21591
|
+
};
|
|
21592
|
+
AppInstallUpgradeCard.prototype.listenDownloadPromise = function (link, promise) {
|
|
21593
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
21594
|
+
var location, err_1;
|
|
21595
|
+
return __generator(this, function (_a) {
|
|
21596
|
+
switch (_a.label) {
|
|
21597
|
+
case 0:
|
|
21598
|
+
if (!link || !promise)
|
|
21599
|
+
return [2 /*return*/]; // Skip
|
|
21600
|
+
_a.label = 1;
|
|
21601
|
+
case 1:
|
|
21602
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
21603
|
+
// Mark link as loading
|
|
21604
|
+
if (!link.downloading) {
|
|
21605
|
+
link.downloading = true;
|
|
21606
|
+
this.markForCheck();
|
|
21607
|
+
}
|
|
21608
|
+
return [4 /*yield*/, promise];
|
|
21609
|
+
case 2:
|
|
21610
|
+
location = _a.sent();
|
|
21611
|
+
console.info('[install-upgrade-card] File downloaded at: ' + location);
|
|
21612
|
+
return [3 /*break*/, 5];
|
|
21613
|
+
case 3:
|
|
21614
|
+
err_1 = _a.sent();
|
|
21615
|
+
console.error('[install-upgrade] Download failed: ' + (err_1 && err_1.message || err_1));
|
|
21616
|
+
this.showDownloadFailedToast(err_1);
|
|
21617
|
+
return [3 /*break*/, 5];
|
|
21618
|
+
case 4:
|
|
21619
|
+
link.downloading = false;
|
|
21620
|
+
this.markForCheck();
|
|
21621
|
+
return [7 /*endfinally*/];
|
|
21622
|
+
case 5: return [2 /*return*/, this.showDownloadCompleteDialog()];
|
|
21623
|
+
}
|
|
21624
|
+
});
|
|
21625
|
+
});
|
|
21626
|
+
};
|
|
21627
|
+
AppInstallUpgradeCard.prototype.showDownloadFailedToast = function (err) {
|
|
21628
|
+
return this.showToast({
|
|
21629
|
+
message: 'ERROR.DOWNLOAD_FAILED',
|
|
21630
|
+
messageParams: { error: err },
|
|
21631
|
+
type: 'error',
|
|
21632
|
+
showCloseButton: true
|
|
21633
|
+
});
|
|
21634
|
+
};
|
|
21635
|
+
AppInstallUpgradeCard.prototype.showDownloadCompleteDialog = function () {
|
|
21636
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
21637
|
+
var translations, alert;
|
|
21638
|
+
return __generator(this, function (_a) {
|
|
21639
|
+
switch (_a.label) {
|
|
21640
|
+
case 0:
|
|
21641
|
+
if (!this._subscription)
|
|
21642
|
+
return [2 /*return*/]; // Skip if component has been destroyed
|
|
21643
|
+
return [4 /*yield*/, this.translate.get([
|
|
21644
|
+
'INFO.ALERT_HEADER',
|
|
21645
|
+
'INFO.DOWNLOAD_UPDATE_SUCCEED',
|
|
21646
|
+
'COMMON.BTN_CLOSE'
|
|
21647
|
+
]).toPromise()];
|
|
21648
|
+
case 1:
|
|
21649
|
+
translations = _a.sent();
|
|
21650
|
+
return [4 /*yield*/, this.alertController.create({
|
|
21651
|
+
header: translations['INFO.ALERT_HEADER'],
|
|
21652
|
+
message: translations['INFO.DOWNLOAD_UPDATE_SUCCEED'],
|
|
21653
|
+
buttons: [
|
|
21654
|
+
{
|
|
21655
|
+
text: translations['COMMON.BTN_CLOSE'],
|
|
21656
|
+
role: 'cancel',
|
|
21657
|
+
cssClass: 'secondary'
|
|
21658
|
+
}
|
|
21659
|
+
]
|
|
21660
|
+
})];
|
|
21661
|
+
case 2:
|
|
21662
|
+
alert = _a.sent();
|
|
21663
|
+
return [4 /*yield*/, alert.present()];
|
|
21664
|
+
case 3:
|
|
21665
|
+
_a.sent();
|
|
21666
|
+
return [4 /*yield*/, alert.onDidDismiss()];
|
|
21667
|
+
case 4:
|
|
21668
|
+
_a.sent();
|
|
21669
|
+
return [2 /*return*/];
|
|
21670
|
+
}
|
|
21671
|
+
});
|
|
21672
|
+
});
|
|
21673
|
+
};
|
|
21490
21674
|
return AppInstallUpgradeCard;
|
|
21491
21675
|
}());
|
|
21492
21676
|
AppInstallUpgradeCard.decorators = [
|
|
21493
21677
|
{ type: i0.Component, args: [{
|
|
21494
21678
|
selector: 'app-install-upgrade-card',
|
|
21495
|
-
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
|
|
21679
|
+
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",
|
|
21496
21680
|
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
21497
21681
|
animations: [slideUpDownAnimation],
|
|
21498
21682
|
styles: ["ion-text small{font-size:85%}"]
|
|
@@ -21501,6 +21685,9 @@
|
|
|
21501
21685
|
AppInstallUpgradeCard.ctorParameters = function () { return [
|
|
21502
21686
|
{ type: i1$5.ModalController },
|
|
21503
21687
|
{ type: ConfigService },
|
|
21688
|
+
{ type: i1$5.ToastController },
|
|
21689
|
+
{ type: i1$5.AlertController },
|
|
21690
|
+
{ type: i1$2.TranslateService },
|
|
21504
21691
|
{ type: i0.ChangeDetectorRef },
|
|
21505
21692
|
{ type: PlatformService },
|
|
21506
21693
|
{ type: NetworkService },
|