@esfaenza/httpservice 11.2.36 → 11.2.39
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/esfaenza-httpservice.umd.js +37 -12
- package/bundles/esfaenza-httpservice.umd.js.map +1 -1
- package/bundles/esfaenza-httpservice.umd.min.js +1 -1
- package/bundles/esfaenza-httpservice.umd.min.js.map +1 -1
- package/esfaenza-httpservice.metadata.json +1 -1
- package/esm2015/lib/httpservice.service.js +24 -13
- package/fesm2015/esfaenza-httpservice.js +23 -12
- package/fesm2015/esfaenza-httpservice.js.map +1 -1
- package/lib/httpservice.service.d.ts +5 -3
- package/package.json +1 -1
|
@@ -497,6 +497,8 @@
|
|
|
497
497
|
this.PersistTimedCacheASAP = false;
|
|
498
498
|
/** Indica che la cache senza limiti di tempo dev'essere persistita il prima possibile */
|
|
499
499
|
this.PersistUntimedCacheASAP = false;
|
|
500
|
+
/** Lista delle ultime 3 chiamate completate con successo in ordine di completamento (in posizione 0 c'è l'ultima completata eccetera...) */
|
|
501
|
+
this.LastThreeCompletedCalls = [];
|
|
500
502
|
this.ExtensionsImpl = this.EXTENSION_CLASS || new HttpServiceExtensions();
|
|
501
503
|
this.me = this.ExtensionsImpl.retrieveIdentity();
|
|
502
504
|
this.localStorageHttpCacheKey = ((_a = this.APP_NAME) !== null && _a !== void 0 ? _a : "APP").replace(/\s/g, '_') + "_HttpCache";
|
|
@@ -724,12 +726,12 @@
|
|
|
724
726
|
* @param {Function} afterGetFile Callback da chiamare dopo aver gestito la risposta del **getFileCallback**, in caso **handleError** fosse **false** verrà richiamato anche in caso di errore
|
|
725
727
|
* @param {boolean} handleError Indica se di default gli errori devono essere gestiti dalla libreria o se devono essere ignorati
|
|
726
728
|
*/
|
|
727
|
-
HTTPService.prototype.postGetFile = function (url, bodyData, filename, getFileCallback, afterGetFile, handleError) {
|
|
729
|
+
HTTPService.prototype.postGetFile = function (url, bodyData, filename, getFileCallback, afterGetFile, handleError, pars) {
|
|
728
730
|
var _this = this;
|
|
729
731
|
if (afterGetFile === void 0) { afterGetFile = null; }
|
|
730
732
|
if (handleError === void 0) { handleError = true; }
|
|
731
733
|
var myGuid = this.defaultStartCall(url);
|
|
732
|
-
this.http.post(url, bodyData, { headers: this.getHeaders(), observe: 'response', responseType: "blob" }).pipe(operators.catchError(function (err, caught) {
|
|
734
|
+
this.http.post(url, bodyData, { params: pars, headers: this.getHeaders(), observe: 'response', responseType: "blob" }).pipe(operators.catchError(function (err, caught) {
|
|
733
735
|
if (afterGetFile && !handleError)
|
|
734
736
|
afterGetFile();
|
|
735
737
|
return _this.registerErrorAndReturnEmptyObservable(err, myGuid, handleError);
|
|
@@ -841,7 +843,7 @@
|
|
|
841
843
|
HTTPService.prototype.defaultStartCall = function (url) {
|
|
842
844
|
var myGuid = this.getGUID();
|
|
843
845
|
this.checkCacheInvalidation(url);
|
|
844
|
-
this.callStatus[myGuid] = true;
|
|
846
|
+
this.callStatus[myGuid] = { url: url, success: true };
|
|
845
847
|
this.log(this.loc("Starting call") + " " + myGuid + " " + this.loc("at URL") + ": " + url);
|
|
846
848
|
return myGuid;
|
|
847
849
|
};
|
|
@@ -888,12 +890,16 @@
|
|
|
888
890
|
return __generator(this, function (_e) {
|
|
889
891
|
switch (_e.label) {
|
|
890
892
|
case 0:
|
|
891
|
-
this.log(this.loc("Finalizing call") + " " + guid + " " + this.loc("with status") + ": " + (this.callStatus[guid] ? this.loc('Success') : this.loc('Failure')));
|
|
892
|
-
//Alla prima chiamata buona, significa che almeno il login ce l'ho. Posso mettermi in modalità redirectInProgress false
|
|
893
|
-
//e riiniziare a valutare errori di javashit
|
|
894
|
-
if (this.callStatus[guid] && this.ExtensionsImpl.readRedirectionStatus())
|
|
893
|
+
this.log(this.loc("Finalizing call") + " " + guid + " " + this.loc("with status") + ": " + (this.callStatus[guid].success ? this.loc('Success') : this.loc('Failure')));
|
|
894
|
+
// Alla prima chiamata buona, significa che almeno il login ce l'ho. Posso mettermi in modalità redirectInProgress false
|
|
895
|
+
// e riiniziare a valutare errori di javashit
|
|
896
|
+
if (this.callStatus[guid].success && this.ExtensionsImpl.readRedirectionStatus())
|
|
895
897
|
this.ExtensionsImpl.writeRedirectionStatus(false);
|
|
896
|
-
//
|
|
898
|
+
// Aggiungo la chiamata alla lista delle ultime 3 completate
|
|
899
|
+
this.LastThreeCompletedCalls.unshift(this.callStatus[guid].url);
|
|
900
|
+
if (this.LastThreeCompletedCalls.length > 3)
|
|
901
|
+
this.LastThreeCompletedCalls.pop();
|
|
902
|
+
// In ogni caso questa posso rimuoverla
|
|
897
903
|
delete this.callStatus[guid];
|
|
898
904
|
// Se vengo da una chiamata che ha aggiornato la cache a timer o globale marco il fatto che quella cache dev'essere aggiornata
|
|
899
905
|
if (cacheInfos && cacheInfos.cache) {
|
|
@@ -988,7 +994,8 @@
|
|
|
988
994
|
return __generator(this, function (_e) {
|
|
989
995
|
switch (_e.label) {
|
|
990
996
|
case 0:
|
|
991
|
-
this.callStatus[guid]
|
|
997
|
+
if (this.callStatus[guid])
|
|
998
|
+
this.callStatus[guid].success = false;
|
|
992
999
|
//Mi assicuro che tutti gli errori durante il redirect al login vengano ignorati
|
|
993
1000
|
if (this.ExtensionsImpl.readRedirectingToLogin()) {
|
|
994
1001
|
this.log(this.loc("Redirecting to Login, ignoring HTTP error on call") + " " + guid);
|
|
@@ -1194,14 +1201,32 @@
|
|
|
1194
1201
|
*/
|
|
1195
1202
|
HTTPService.prototype.resetHttpUntimedCacheStorage = function () {
|
|
1196
1203
|
var _a;
|
|
1197
|
-
|
|
1198
|
-
|
|
1204
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1205
|
+
return __generator(this, function (_e) {
|
|
1206
|
+
switch (_e.label) {
|
|
1207
|
+
case 0: return [4 /*yield*/, this.localStorage.setItem(this.localStorageHttpCacheKey, {}).toPromise()];
|
|
1208
|
+
case 1:
|
|
1209
|
+
_e.sent();
|
|
1210
|
+
localStorage.setItem(this.localStorageHttpCacheExpireKey, JSON.stringify(dayjs().add((_a = this.CLIENT_CACHE_DURATION_S) !== null && _a !== void 0 ? _a : 3600, "second")));
|
|
1211
|
+
return [2 /*return*/];
|
|
1212
|
+
}
|
|
1213
|
+
});
|
|
1214
|
+
});
|
|
1199
1215
|
};
|
|
1200
1216
|
/**
|
|
1201
1217
|
* Ripulisce la cache delle chiamate con un tempo di expire definito
|
|
1202
1218
|
*/
|
|
1203
1219
|
HTTPService.prototype.resetHttpTimedCacheStorage = function () {
|
|
1204
|
-
|
|
1220
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1221
|
+
return __generator(this, function (_e) {
|
|
1222
|
+
switch (_e.label) {
|
|
1223
|
+
case 0: return [4 /*yield*/, this.localStorage.setItem(this.localStorageHttpTimedCacheKey, {}).toPromise()];
|
|
1224
|
+
case 1:
|
|
1225
|
+
_e.sent();
|
|
1226
|
+
return [2 /*return*/];
|
|
1227
|
+
}
|
|
1228
|
+
});
|
|
1229
|
+
});
|
|
1205
1230
|
};
|
|
1206
1231
|
/**
|
|
1207
1232
|
* Genera una chiave per la cache delle chiamate in base ad URL e Parametri HTTP
|