@esfaenza/extensions 11.2.12 → 11.2.16
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-extensions.umd.js +501 -43
- package/bundles/esfaenza-extensions.umd.js.map +1 -1
- package/bundles/esfaenza-extensions.umd.min.js +16 -1
- package/bundles/esfaenza-extensions.umd.min.js.map +1 -1
- package/esfaenza-extensions.d.ts +2 -0
- package/esfaenza-extensions.metadata.json +1 -1
- package/esm2015/esfaenza-extensions.js +3 -1
- package/esm2015/lib/models/ExtensionsModuleConfig.js +1 -1
- package/esm2015/lib/models/providers/base/BaseStorageProvider.js +11 -0
- package/esm2015/lib/models/providers/implementation/DefaultStorageProvider.js +76 -0
- package/esm2015/lib/models/session/base/BaseSessionRetriever.js +6 -0
- package/esm2015/lib/models/session/implementation/DefaultSessionRetriever.js +26 -0
- package/esm2015/lib/modules/extensions.full.module.js +11 -2
- package/esm2015/lib/services/extensions.storage.service.js +55 -39
- package/esm2015/public-api.js +3 -1
- package/fesm2015/esfaenza-extensions.js +173 -40
- package/fesm2015/esfaenza-extensions.js.map +1 -1
- package/lib/models/ExtensionsModuleConfig.d.ts +11 -0
- package/lib/models/providers/base/BaseStorageProvider.d.ts +61 -0
- package/lib/models/providers/implementation/DefaultStorageProvider.d.ts +19 -0
- package/lib/models/session/base/BaseSessionRetriever.d.ts +11 -0
- package/lib/models/session/implementation/DefaultSessionRetriever.d.ts +18 -0
- package/lib/modules/extensions.full.module.d.ts +2 -0
- package/lib/services/extensions.storage.service.d.ts +26 -16
- package/package.json +1 -1
- package/public-api.d.ts +2 -0
|
@@ -2,6 +2,8 @@ import { InjectionToken, NgModule, Injectable, Optional, Inject } from '@angular
|
|
|
2
2
|
import { ToastrService } from 'ngx-toastr';
|
|
3
3
|
import swal from 'sweetalert2';
|
|
4
4
|
import { Deserialize } from 'cerialize';
|
|
5
|
+
import { tap } from 'rxjs/operators';
|
|
6
|
+
import { of } from 'rxjs';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Token che identifica il locale da utilizzare per questa libreria, sono supportati i locali 'it-IT' ed 'en-US'
|
|
@@ -1728,9 +1730,26 @@ UtilityService.decorators = [
|
|
|
1728
1730
|
{ type: Injectable }
|
|
1729
1731
|
];
|
|
1730
1732
|
|
|
1733
|
+
/**
|
|
1734
|
+
* Classe che gestisce la scrittura delle informazioni nello store locale.
|
|
1735
|
+
* Questo store locale potrebbe essere il localStorage (implementazione di default data dal **DefaultStorageProvider**),
|
|
1736
|
+
* oppure un'implementazione custom facente capo a un DB esterno.
|
|
1737
|
+
*
|
|
1738
|
+
* In questo ultimo caso però sarà necessario implementarsi un proprio **BaseSessionRetriever**
|
|
1739
|
+
* che generi una chiave univoca di sessione su cui tutte le operazioni di questa classe saranno eseguite
|
|
1740
|
+
*/
|
|
1741
|
+
class BaseStorageProvider {
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
/**
|
|
1745
|
+
* Classe astratta che si occupa di recuperare l'Id sessione univoco per applicazione ed utente collegato
|
|
1746
|
+
*/
|
|
1747
|
+
class BaseSessionRetriever {
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1731
1750
|
// Angular
|
|
1732
1751
|
/**
|
|
1733
|
-
* Service che fornisce funzionalità di base per storicizzazione e recupero oggetti
|
|
1752
|
+
* Service che fornisce funzionalità di base per storicizzazione e recupero oggetti dallo Storage Locale
|
|
1734
1753
|
*/
|
|
1735
1754
|
class StorageService {
|
|
1736
1755
|
/**
|
|
@@ -1738,8 +1757,10 @@ class StorageService {
|
|
|
1738
1757
|
*
|
|
1739
1758
|
* @ignore
|
|
1740
1759
|
*/
|
|
1741
|
-
constructor(APPSEARCH_PREFIX) {
|
|
1760
|
+
constructor(APPSEARCH_PREFIX, _session, _storage) {
|
|
1742
1761
|
this.APPSEARCH_PREFIX = APPSEARCH_PREFIX;
|
|
1762
|
+
this._session = _session;
|
|
1763
|
+
this._storage = _storage;
|
|
1743
1764
|
}
|
|
1744
1765
|
/**
|
|
1745
1766
|
* Inserisce un oggetto che funga da contenitore di oggetti nel local storage, ripulendone gli oggetti (supponendo che sia una view di ricerca) e marcandolo come
|
|
@@ -1748,65 +1769,173 @@ class StorageService {
|
|
|
1748
1769
|
* @param {string} storeName Chiave del localStorage in cui storicizzare l'oggetto **itemsContainer**
|
|
1749
1770
|
* @param {{ items: any[] }} itemsContainer Oggetto da storicizzare
|
|
1750
1771
|
*/
|
|
1751
|
-
setItem(storeName,
|
|
1752
|
-
var
|
|
1753
|
-
//
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1772
|
+
setItem(storeName, item) {
|
|
1773
|
+
var finalItem;
|
|
1774
|
+
//Se sto salvando un oggetto con "items" e "page" vuol dire che è un appsearch, la ripulisco
|
|
1775
|
+
if (item.items && item.page) {
|
|
1776
|
+
finalItem = JSON.parse(JSON.stringify(item));
|
|
1777
|
+
finalItem.items = [];
|
|
1778
|
+
finalItem.savedstate = true;
|
|
1779
|
+
finalItem.savedprefix = this.APPSEARCH_PREFIX || 'Hot';
|
|
1759
1780
|
}
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
delete localStorage[key];
|
|
1766
|
-
}
|
|
1767
|
-
try {
|
|
1768
|
-
localStorage.setItem(storeName, JSON.stringify(item));
|
|
1769
|
-
}
|
|
1770
|
-
catch (e) {
|
|
1771
|
-
console.error("Spazio del local Storage insufficiente per salvare i risultati di ricerca con solo filtri. Non salvo nulla");
|
|
1781
|
+
else
|
|
1782
|
+
finalItem = item;
|
|
1783
|
+
return this._storage.setItem(this._session.getSessionKey(), storeName, finalItem).pipe(tap(res => {
|
|
1784
|
+
if (res == false) {
|
|
1785
|
+
console.error("Impossibile effettuare il salvataggio dell'oggetto all'interno dello Storage Locale per la chiave " + storeName);
|
|
1772
1786
|
}
|
|
1773
|
-
}
|
|
1787
|
+
}));
|
|
1774
1788
|
}
|
|
1775
1789
|
/**
|
|
1776
|
-
*
|
|
1790
|
+
* Recupera un oggetto dallo Storage Locale
|
|
1791
|
+
*
|
|
1792
|
+
* @param {string} storeName Chiave del localStorage da cui recuperare l'oggetto
|
|
1777
1793
|
*
|
|
1778
|
-
* @
|
|
1779
|
-
* @param {any} item Oggetto da storicizzare
|
|
1794
|
+
* @returns {any} Oggetto recuperato e deserializzato
|
|
1780
1795
|
*/
|
|
1781
|
-
|
|
1782
|
-
|
|
1796
|
+
getItem(storeName) {
|
|
1797
|
+
return this._storage.getItem(this._session.getSessionKey(), storeName).pipe(tap(res => {
|
|
1798
|
+
if (res == null)
|
|
1799
|
+
console.warn("Impossibile ottenere l'oggetto salvato con chiave " + storeName);
|
|
1800
|
+
}));
|
|
1783
1801
|
}
|
|
1784
1802
|
/**
|
|
1785
|
-
*
|
|
1803
|
+
* Ripulisce lo Storage Locale
|
|
1786
1804
|
*
|
|
1787
|
-
* @param {string} storeName Chiave del localStorage da
|
|
1788
|
-
*
|
|
1789
|
-
* @returns {any} Oggetto recuperato e deserializzato
|
|
1805
|
+
* @param {string} storeName Chiave del localStorage da ripulire
|
|
1790
1806
|
*/
|
|
1791
|
-
|
|
1792
|
-
return
|
|
1807
|
+
removeItem(storeName) {
|
|
1808
|
+
return this._storage.removeItem(this._session.getSessionKey(), storeName).pipe(tap(res => {
|
|
1809
|
+
if (res == false)
|
|
1810
|
+
console.warn("Impossibile rimuovere l'oggetto salvato con chiave " + storeName);
|
|
1811
|
+
}));
|
|
1793
1812
|
}
|
|
1794
1813
|
/**
|
|
1795
|
-
* Ripulisce
|
|
1814
|
+
* Ripulisce lo Storage Locale di ogni cosa salvata
|
|
1796
1815
|
*
|
|
1797
1816
|
* @param {string} storeName Chiave del localStorage da ripulire
|
|
1798
1817
|
*/
|
|
1799
|
-
clear(
|
|
1800
|
-
|
|
1818
|
+
clear() {
|
|
1819
|
+
return this._storage.clear(this._session.getSessionKey()).pipe(tap(res => {
|
|
1820
|
+
if (res == false)
|
|
1821
|
+
console.warn("Impossibile ripulire lo Storage Locale");
|
|
1822
|
+
}));
|
|
1823
|
+
}
|
|
1824
|
+
/**
|
|
1825
|
+
* Restituisce tutte le chiavi-valore associate alla sessione corrente
|
|
1826
|
+
*
|
|
1827
|
+
* @returns {Observable<{ [index: string]: string; }>} Risultato della query
|
|
1828
|
+
*/
|
|
1829
|
+
getAll() {
|
|
1830
|
+
return this._storage.getAll(this._session.getSessionKey());
|
|
1801
1831
|
}
|
|
1802
1832
|
}
|
|
1803
1833
|
StorageService.decorators = [
|
|
1804
1834
|
{ type: Injectable }
|
|
1805
1835
|
];
|
|
1806
1836
|
StorageService.ctorParameters = () => [
|
|
1807
|
-
{ type: String, decorators: [{ type: Optional }, { type: Inject, args: [APPSEARCH_PREFIX,] }] }
|
|
1837
|
+
{ type: String, decorators: [{ type: Optional }, { type: Inject, args: [APPSEARCH_PREFIX,] }] },
|
|
1838
|
+
{ type: BaseSessionRetriever },
|
|
1839
|
+
{ type: BaseStorageProvider }
|
|
1808
1840
|
];
|
|
1809
1841
|
|
|
1842
|
+
/**
|
|
1843
|
+
* Implementazione di default per la classe **BaseSessionRetriever**
|
|
1844
|
+
*/
|
|
1845
|
+
class DefaultSessionRetriever extends BaseSessionRetriever {
|
|
1846
|
+
/**
|
|
1847
|
+
* Costruttore
|
|
1848
|
+
*
|
|
1849
|
+
* @ignore
|
|
1850
|
+
*/
|
|
1851
|
+
constructor() { super(); }
|
|
1852
|
+
/**
|
|
1853
|
+
* Ottiene un ID sessione
|
|
1854
|
+
*
|
|
1855
|
+
* @returns {string} ID sessione
|
|
1856
|
+
*/
|
|
1857
|
+
getSessionKey() {
|
|
1858
|
+
return "DUMMY_SESSION";
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
DefaultSessionRetriever.decorators = [
|
|
1862
|
+
{ type: Injectable }
|
|
1863
|
+
];
|
|
1864
|
+
DefaultSessionRetriever.ctorParameters = () => [];
|
|
1865
|
+
|
|
1866
|
+
/** Implementazione di default per la classe **BaseStorageProvider** */
|
|
1867
|
+
class DefaultStorageProvider extends BaseStorageProvider {
|
|
1868
|
+
/** @ignore Costruttore */
|
|
1869
|
+
constructor() { super(); }
|
|
1870
|
+
/** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
|
|
1871
|
+
setItem(identity, key, value) {
|
|
1872
|
+
try {
|
|
1873
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
1874
|
+
return of(true);
|
|
1875
|
+
}
|
|
1876
|
+
catch (_a) {
|
|
1877
|
+
// Potrebbe arrivarmi un prefisso di salvataggio nella modalità di default. Questo serve per ripulire le stesse cose con quel prefisso e sperare di liberare spazio
|
|
1878
|
+
if (value.savedprefix) {
|
|
1879
|
+
console.warn("Spazio del local Storage insufficiente, prova a ripulirlo e risalvare");
|
|
1880
|
+
//Pulisco tutte le view con nome che parta per "Hot"
|
|
1881
|
+
for (let key in localStorage) {
|
|
1882
|
+
if (localStorage.hasOwnProperty(key) && key.startsWith(value.savedprefix))
|
|
1883
|
+
delete localStorage[key];
|
|
1884
|
+
}
|
|
1885
|
+
try {
|
|
1886
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
1887
|
+
}
|
|
1888
|
+
catch (e) {
|
|
1889
|
+
console.error("Spazio del local Storage insufficiente per salvare i risultati di ricerca con solo filtri. Non salvo nulla");
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
return of(false);
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
/** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
|
|
1896
|
+
getItem(identity, key) {
|
|
1897
|
+
try {
|
|
1898
|
+
var ret = JSON.parse(localStorage.getItem(key));
|
|
1899
|
+
return of(ret);
|
|
1900
|
+
}
|
|
1901
|
+
catch (_a) {
|
|
1902
|
+
return of(null);
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
/** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
|
|
1906
|
+
removeItem(identity, key) {
|
|
1907
|
+
try {
|
|
1908
|
+
localStorage.removeItem(key);
|
|
1909
|
+
return of(true);
|
|
1910
|
+
}
|
|
1911
|
+
catch (_a) {
|
|
1912
|
+
return of(false);
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
/** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
|
|
1916
|
+
clear(identity) {
|
|
1917
|
+
try {
|
|
1918
|
+
localStorage.clear();
|
|
1919
|
+
return of(true);
|
|
1920
|
+
}
|
|
1921
|
+
catch (_a) {
|
|
1922
|
+
return of(false);
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
/** @ignore Implementazione di Default con localStorage. Identity viene ignorata perché essendo già nel localStorage è già per sito */
|
|
1926
|
+
getAll(identity) {
|
|
1927
|
+
var ret = {};
|
|
1928
|
+
for (let key in localStorage) {
|
|
1929
|
+
ret[key] = localStorage[key];
|
|
1930
|
+
}
|
|
1931
|
+
return of(ret);
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
DefaultStorageProvider.decorators = [
|
|
1935
|
+
{ type: Injectable }
|
|
1936
|
+
];
|
|
1937
|
+
DefaultStorageProvider.ctorParameters = () => [];
|
|
1938
|
+
|
|
1810
1939
|
// Angular
|
|
1811
1940
|
/**
|
|
1812
1941
|
* Modulo di estensione che registra autonomamente **TUTTI** i servizi di estensione:
|
|
@@ -1817,6 +1946,8 @@ StorageService.ctorParameters = () => [
|
|
|
1817
1946
|
* MessageService,
|
|
1818
1947
|
* UtilityService,
|
|
1819
1948
|
* StorageService,
|
|
1949
|
+
*
|
|
1950
|
+
* con eventuali provider che utilizzano
|
|
1820
1951
|
*/
|
|
1821
1952
|
class FullExtensionsModule {
|
|
1822
1953
|
static forRoot(config) {
|
|
@@ -1833,7 +1964,9 @@ class FullExtensionsModule {
|
|
|
1833
1964
|
{ provide: EXT_LOCALE, useValue: (config === null || config === void 0 ? void 0 : config.locale) || 'it-IT' },
|
|
1834
1965
|
{ provide: EXT_FANCY_ALERTS, useValue: (config === null || config === void 0 ? void 0 : config.fancy_alerts) || true },
|
|
1835
1966
|
{ provide: APPSEARCH_PREFIX, useValue: (config === null || config === void 0 ? void 0 : config.appsearch_prefix) || 'Hot' },
|
|
1836
|
-
{ provide: EXT_ALLOW_UTC, useValue: (config === null || config === void 0 ? void 0 : config.allow_utc) == null ? false : config === null || config === void 0 ? void 0 : config.allow_utc }
|
|
1967
|
+
{ provide: EXT_ALLOW_UTC, useValue: (config === null || config === void 0 ? void 0 : config.allow_utc) == null ? false : config === null || config === void 0 ? void 0 : config.allow_utc },
|
|
1968
|
+
{ provide: BaseSessionRetriever, useClass: (config === null || config === void 0 ? void 0 : config.sessionRetriever) || DefaultSessionRetriever },
|
|
1969
|
+
{ provide: BaseStorageProvider, useClass: (config === null || config === void 0 ? void 0 : config.storageProvider) || DefaultStorageProvider },
|
|
1837
1970
|
]
|
|
1838
1971
|
};
|
|
1839
1972
|
}
|
|
@@ -1868,5 +2001,5 @@ class GenericItem {
|
|
|
1868
2001
|
* Generated bundle index. Do not edit.
|
|
1869
2002
|
*/
|
|
1870
2003
|
|
|
1871
|
-
export { APPSEARCH_PREFIX, CallResult, ClipboardService, CsvHeaders, DateService, EXT_ALLOW_UTC, EXT_FANCY_ALERTS, EXT_LOCALE, Export, ExportAs, ExportDictionary, ExportList, ExportService, ExtensionsModule, FullExtensionsModule, GenericItem, HashingService, MessageService, StorageService, UtilityService };
|
|
2004
|
+
export { APPSEARCH_PREFIX, BaseSessionRetriever, BaseStorageProvider, CallResult, ClipboardService, CsvHeaders, DateService, EXT_ALLOW_UTC, EXT_FANCY_ALERTS, EXT_LOCALE, Export, ExportAs, ExportDictionary, ExportList, ExportService, ExtensionsModule, FullExtensionsModule, GenericItem, HashingService, MessageService, StorageService, UtilityService, DefaultSessionRetriever as ɵa, DefaultStorageProvider as ɵb };
|
|
1872
2005
|
//# sourceMappingURL=esfaenza-extensions.js.map
|