@progressive-development/pd-spa-helper 0.1.171 → 0.1.173

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.
Files changed (54) hide show
  1. package/dist/src/PdSpaHelper.d.ts +8 -6
  2. package/dist/src/PdSpaHelper.js +30 -1
  3. package/dist/src/PdSpaHelper.js.map +1 -1
  4. package/dist/src/model/spa-model.d.ts +7 -0
  5. package/dist/src/model/spa-model.js +2 -0
  6. package/dist/src/model/spa-model.js.map +1 -0
  7. package/dist/src/service-provider/firebase/auth.d.ts +1 -0
  8. package/dist/src/service-provider/firebase/auth.js +6 -0
  9. package/dist/src/service-provider/firebase/auth.js.map +1 -1
  10. package/dist/src/service-provider/firebase/firestorage-client.js +19 -9
  11. package/dist/src/service-provider/firebase/firestorage-client.js.map +1 -1
  12. package/dist/src/service-provider/mock/auth.d.ts +1 -0
  13. package/dist/src/service-provider/mock/auth.js +4 -0
  14. package/dist/src/service-provider/mock/auth.js.map +1 -1
  15. package/dist/src/service-provider/service-provider-impl.d.ts +1 -0
  16. package/dist/src/service-provider/service-provider-impl.js +12 -2
  17. package/dist/src/service-provider/service-provider-impl.js.map +1 -1
  18. package/dist/src/service-provider/service-provider-model.d.ts +3 -1
  19. package/dist/src/service-provider/service-provider-model.js.map +1 -1
  20. package/dist/src/store/indexDB.d.ts +1 -1
  21. package/dist/src/store/indexDB.js +4 -2
  22. package/dist/src/store/indexDB.js.map +1 -1
  23. package/dist/src/store/mini-rx.store.js +11 -2
  24. package/dist/src/store/mini-rx.store.js.map +1 -1
  25. package/dist/src/store/spa-app-actions.d.ts +32 -0
  26. package/dist/src/store/spa-app-actions.js +7 -0
  27. package/dist/src/store/spa-app-actions.js.map +1 -0
  28. package/dist/src/store/spa-app-effects.d.ts +6 -0
  29. package/dist/src/store/spa-app-effects.js +23 -0
  30. package/dist/src/store/spa-app-effects.js.map +1 -0
  31. package/dist/src/store/spa-app-reducer.d.ts +9 -0
  32. package/dist/src/store/spa-app-reducer.js +28 -0
  33. package/dist/src/store/spa-app-reducer.js.map +1 -0
  34. package/dist/src/store/spa-app-selector.d.ts +6 -0
  35. package/dist/src/store/spa-app-selector.js +9 -0
  36. package/dist/src/store/spa-app-selector.js.map +1 -0
  37. package/dist/src/tmpown/pd-loading-state.d.ts +2 -6
  38. package/dist/src/tmpown/pd-loading-state.js.map +1 -1
  39. package/dist/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +1 -1
  41. package/src/PdSpaHelper.ts +43 -9
  42. package/src/model/spa-model.ts +8 -0
  43. package/src/service-provider/firebase/auth.ts +6 -0
  44. package/src/service-provider/firebase/firestorage-client.ts +13 -6
  45. package/src/service-provider/mock/auth.ts +6 -0
  46. package/src/service-provider/service-provider-impl.ts +13 -2
  47. package/src/service-provider/service-provider-model.ts +4 -2
  48. package/src/store/indexDB.ts +5 -4
  49. package/src/store/mini-rx.store.ts +13 -2
  50. package/src/store/spa-app-actions.ts +11 -0
  51. package/src/store/spa-app-effects.ts +33 -0
  52. package/src/store/spa-app-reducer.ts +64 -0
  53. package/src/store/spa-app-selector.ts +23 -0
  54. package/src/tmpown/pd-loading-state.ts +3 -6
@@ -1,4 +1,6 @@
1
1
  // use version import to initialize modul
2
+ import { pdStore } from "./mini-rx.store";
3
+ import { initIndexDBSucess } from "./spa-app-actions.js";
2
4
  const { indexedDB } = window;
3
5
  let db;
4
6
  /*
@@ -143,7 +145,7 @@ const removeDatabase = (dbName) => new Promise((resolve, reject) => {
143
145
  * @param config - config for index db
144
146
  * @param successCallback - callback function after db is successfully initialized
145
147
  */
146
- export const initDB = (config, successCallback) => {
148
+ export const initDB = (config) => {
147
149
  if (!indexedDB) {
148
150
  window.alert("Your browser doesn't support a stable version of IndexedDB.");
149
151
  }
@@ -156,7 +158,7 @@ export const initDB = (config, successCallback) => {
156
158
  request.onsuccess = () => {
157
159
  db = request.result;
158
160
  console.log(`db init success: ${db}`);
159
- successCallback();
161
+ pdStore().dispatch(initIndexDBSucess());
160
162
  };
161
163
  request.onupgradeneeded = (event) => {
162
164
  console.log('Upgrade needed', event);
@@ -1 +1 @@
1
- {"version":3,"file":"indexDB.js","sourceRoot":"","sources":["../../../src/store/indexDB.ts"],"names":[],"mappings":"AAAA,yCAAyC;AAEzC,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC;AAC3B,IAAI,EAAM,CAAC;AAEX;;;;;;;;;;;;EAYE;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,CAAI,KAAa,EAAE,EAAK,EAAE,gBAAyB,EAAE,EAAE,CACxE,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IAC9B,MAAM,OAAO,GAAG,EAAE;SACf,WAAW,CAAC,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;SACjC,WAAW,CAAC,KAAK,CAAC;SAClB,GAAG,CAAC,EAAE,CAAC,CAAC;IACX,OAAO,CAAC,SAAS,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAClD,OAAO,CAAC,OAAO,GAAG,CAAC,KAAU,EAAE,EAAE;QAC/B,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,gBAAgB,EAAE;YACrD,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC;SAC7B;QACD,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC/C,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,MAAM,GAAG,CAAI,KAAa,EAAE,EAAK,EAAE,EAAE,CAChD,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IAC9B,MAAM,OAAO,GAAG,EAAE;SACf,WAAW,CAAC,CAAC,KAAK,CAAC,EAAE,WAAW,CAA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,MAAM,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;YACtC,eAAe,EAAE,CAAC;QACpB,CAAC,CAAC;QAEF,OAAO,CAAC,eAAe,GAAG,CAAC,KAAU,EAAE,EAAE;YACvC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;YACrC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;YACzB,QAAQ,KAAK,CAAC,UAAU,EAAE;gBACxB,kCAAkC;gBAClC,KAAK,CAAC;oBACJ,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;wBACtB,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,cAAc,CAAC,CAAC;oBACjD,CAAC,CAAC,CAAC;oBACH,MAAM;gBACR,4EAA4E;gBAC5E,eAAe;gBACf;oBACE,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;aAC1C;QACH,CAAC,CAAC;KACH;AACH,CAAC,CAAC","sourcesContent":["// use version import to initialize modul\n\nconst {indexedDB} = window;\nlet db:any;\n\n/*\nEine kurze Verzögerung eingebaut.\n\nFehler im Chrome (einmal, sonst nicht) => Vorher logout durch USerSync (user nicht da).\nUpgrade needed IDBVersionChangeEvent {isTrusted: true, oldVersion: 0, newVersion: 2, dataLoss: \"none\", dataLossMessage: \"\",}\nindexDB2.js:190 Error during background initialize DOMException: Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running.\n at http://localhost:8000/src/js/indexDB2.js:32:24\n at new Promise (<anonymous>)\n at add (http://localhost:8000/src/js/indexDB2.js:31:46)\n at addBackground (http://localhost:8000/src/js/indexDB2.js:203:38)\n at http://localhost:8000/src/js/indexDB2.js:143:26\n\n*/\n\nexport const add = <T>(table: string, el: T, ignoreDuplicates: boolean) =>\n new Promise((resolve, reject) => {\n const request = db\n .transaction([table], 'readwrite')\n .objectStore(table)\n .add(el);\n request.onsuccess = () => resolve(request.result);\n request.onerror = (event: any) => {\n if (event.target.error.code === 0 && ignoreDuplicates) {\n return resolve('duplicate');\n }\n console.warn('Unable to add data!', event, el);\n return reject(event.target.error);\n };\n });\n\nexport const update = <T>(table: string, el: T) =>\n new Promise((resolve, reject) => {\n const request = db\n .transaction([table], 'readwrite')\n .objectStore(table)\n .put(el);\n request.onsuccess = () => resolve(request.result);\n request.onerror = (event: any) => {\n console.warn('Unable to put data!', event, el);\n return reject(event.target.error);\n };\n }); \n\nexport const updateAll = <T>(table: string, elArray: T[]) =>\n new Promise((resolve, reject) => {\n const promises: unknown[] = [];\n elArray.forEach(el => {\n promises.push(update<T>(table, el));\n });\n\n return Promise.all(promises)\n .then(resArr => resolve(resArr))\n .catch(e => reject(e));\n });\n\n\nexport const addAll = <T>(table: string, elArray: T[], ignoreDuplicates: boolean) =>\n new Promise((resolve, reject) => {\n const promises: unknown[] = [];\n elArray.forEach(el => {\n promises.push(<T>add(table, el, ignoreDuplicates));\n });\n\n return Promise.all(promises)\n .then(resArr => resolve(resArr))\n .catch(e => reject(e));\n });\n\n\nconst deleteEl = (table: string, id: string) =>\n new Promise((resolve, reject) => {\n const request = db\n .transaction([table], 'readwrite')\n .objectStore(table)\n .delete(id);\n\n request.onsuccess = () => resolve(request.result);\n request.onerror = (e: any) => reject(e);\n }); \n\n\nexport const deleteAllEl = (table: string, elIdArray: string[]) =>\n new Promise((resolve, reject) => {\n const promises: unknown[] = [];\n elIdArray.forEach(elId => {\n promises.push(deleteEl(table, elId));\n });\n\n return Promise.all(promises)\n .then(resArr => resolve(resArr))\n .catch(e => reject(e));\n }); \n\n\nexport const get = <T>(table: string, id: string): Promise<T> =>\n new Promise((resolve, reject) => {\n const request = db.transaction([table]).objectStore(table).get(id);\n request.onsuccess = () => resolve(request.result);\n request.onerror = (e: any) => reject(e);\n });\n\nexport const getAll = <T>(table: string, index?: string): Promise<T[]> =>\n new Promise((resolve, reject) => {\n const request = index\n ? db\n .transaction([table], 'readonly')\n .objectStore(table)\n .index(index)\n .openCursor()\n : db.transaction([table], 'readonly').objectStore(table).openCursor();\n // CHECK: getAll => https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore \n const res: T[] = [];\n request.onsuccess = function (event: any) {\n const cursor = event.target.result;\n if (cursor) {\n // cursor.value contains the current record being iterated through\n // this is where you'd do something with the result\n res.push(cursor.value);\n cursor.continue();\n } else {\n // no more results\n resolve(res);\n }\n };\n request.onerror = (e: any) => reject(e);\n });\n\nexport const getAllIds = (table: string) => \n new Promise((resolve, reject) => {\n const request = db.transaction([table], 'readonly').objectStore(table).openCursor();\n // CHECK: getAll => https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore \n const res: unknown[] = [];\n request.onsuccess = function (event: any) {\n const cursor = event.target.result;\n if (cursor) {\n // cursor.value contains the current record being iterated through\n // this is where you'd do something with the result\n res.push(cursor.value.id);\n cursor.continue();\n } else {\n // no more results\n resolve(res);\n }\n };\n request.onerror = (e: any) => reject(e);\n });\n\n\nconst deleteAll = (table: string) =>\n new Promise((resolve, reject) => {\n const request = db\n .transaction([table], 'readwrite')\n .objectStore(table)\n .clear();\n\n request.onsuccess = () => resolve(request.result);\n request.onerror = (e: any) => reject(e);\n });\n\n\nconst removeDatabase = (dbName:string) =>\n new Promise((resolve, reject) => {\n db.close();\n const request = indexedDB.deleteDatabase(dbName);\n request.onsuccess = () => resolve(request.result);\n request.onerror = (e: any) => reject(e);\n});\n\n\n/**\n * Init indexDB for application.\n * \n * @param config - config for index db \n * @param successCallback - callback function after db is successfully initialized \n */\nexport const initDB = (\n config: {\n dbName:string,\n dbVersion:number,\n collections: {\n name: string,\n collectionConf: { \n keyPath?: string\n }\n }[]\n }, \n successCallback: Function\n) => {\n if (!indexedDB) {\n window.alert(\"Your browser doesn't support a stable version of IndexedDB.\");\n } else {\n const {dbName, dbVersion, collections} = config;\n const request = indexedDB.open(dbName, dbVersion);\n request.onerror = event => {\n console.log('error during db init:', event);\n };\n\n request.onsuccess = () => {\n db = request.result;\n console.log(`db init success: ${db}`);\n successCallback();\n };\n\n request.onupgradeneeded = (event: any) => {\n console.log('Upgrade needed', event);\n db = event.target.result;\n switch (event.oldVersion) {\n // first call from client, init db\n case 0: \n collections.forEach(c => {\n db.createObjectStore(c.name, c.collectionConf);\n });\n break;\n // depending on our needs, add specific versions here to migrate existing db\n // case X: ....\n default:\n console.log('No update needed for db');\n }\n };\n }\n};\n"]}
1
+ {"version":3,"file":"indexDB.js","sourceRoot":"","sources":["../../../src/store/indexDB.ts"],"names":[],"mappings":"AAAA,yCAAyC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC;AAC3B,IAAI,EAAM,CAAC;AAEX;;;;;;;;;;;;EAYE;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,CAAI,KAAa,EAAE,EAAK,EAAE,gBAAyB,EAAE,EAAE,CACxE,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IAC9B,MAAM,OAAO,GAAG,EAAE;SACf,WAAW,CAAC,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;SACjC,WAAW,CAAC,KAAK,CAAC;SAClB,GAAG,CAAC,EAAE,CAAC,CAAC;IACX,OAAO,CAAC,SAAS,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAClD,OAAO,CAAC,OAAO,GAAG,CAAC,KAAU,EAAE,EAAE;QAC/B,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,gBAAgB,EAAE;YACrD,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC;SAC7B;QACD,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC/C,OAAO,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,GAAG,MAAM,CAAC;QAChD,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAClD,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,EAAE;YACxB,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;QAC9C,CAAC,CAAC;QAEF,OAAO,CAAC,SAAS,GAAG,GAAG,EAAE;YACvB,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;YACtC,OAAO,EAAE,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,CAAC;QAC1C,CAAC,CAAC;QAEF,OAAO,CAAC,eAAe,GAAG,CAAC,KAAU,EAAE,EAAE;YACvC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;YACrC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;YACzB,QAAQ,KAAK,CAAC,UAAU,EAAE;gBACxB,kCAAkC;gBAClC,KAAK,CAAC;oBACJ,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;wBACtB,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,cAAc,CAAC,CAAC;oBACjD,CAAC,CAAC,CAAC;oBACH,MAAM;gBACR,4EAA4E;gBAC5E,eAAe;gBACf;oBACE,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;aAC1C;QACH,CAAC,CAAC;KACH;AACH,CAAC,CAAC","sourcesContent":["// use version import to initialize modul\n\nimport { pdStore } from \"./mini-rx.store\";\nimport { initIndexDBSucess } from \"./spa-app-actions.js\";\n\nconst {indexedDB} = window;\nlet db:any;\n\n/*\nEine kurze Verzögerung eingebaut.\n\nFehler im Chrome (einmal, sonst nicht) => Vorher logout durch USerSync (user nicht da).\nUpgrade needed IDBVersionChangeEvent {isTrusted: true, oldVersion: 0, newVersion: 2, dataLoss: \"none\", dataLossMessage: \"\",}\nindexDB2.js:190 Error during background initialize DOMException: Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running.\n at http://localhost:8000/src/js/indexDB2.js:32:24\n at new Promise (<anonymous>)\n at add (http://localhost:8000/src/js/indexDB2.js:31:46)\n at addBackground (http://localhost:8000/src/js/indexDB2.js:203:38)\n at http://localhost:8000/src/js/indexDB2.js:143:26\n\n*/\n\nexport const add = <T>(table: string, el: T, ignoreDuplicates: boolean) =>\n new Promise((resolve, reject) => {\n const request = db\n .transaction([table], 'readwrite')\n .objectStore(table)\n .add(el);\n request.onsuccess = () => resolve(request.result);\n request.onerror = (event: any) => {\n if (event.target.error.code === 0 && ignoreDuplicates) {\n return resolve('duplicate');\n }\n console.warn('Unable to add data!', event, el);\n return reject(event.target.error);\n };\n });\n\nexport const update = <T>(table: string, el: T) =>\n new Promise((resolve, reject) => {\n const request = db\n .transaction([table], 'readwrite')\n .objectStore(table)\n .put(el);\n request.onsuccess = () => resolve(request.result);\n request.onerror = (event: any) => {\n console.warn('Unable to put data!', event, el);\n return reject(event.target.error);\n };\n }); \n\nexport const updateAll = <T>(table: string, elArray: T[]) =>\n new Promise((resolve, reject) => {\n const promises: unknown[] = [];\n elArray.forEach(el => {\n promises.push(update<T>(table, el));\n });\n\n return Promise.all(promises)\n .then(resArr => resolve(resArr))\n .catch(e => reject(e));\n });\n\n\nexport const addAll = <T>(table: string, elArray: T[], ignoreDuplicates: boolean) =>\n new Promise((resolve, reject) => {\n const promises: unknown[] = [];\n elArray.forEach(el => {\n promises.push(<T>add(table, el, ignoreDuplicates));\n });\n\n return Promise.all(promises)\n .then(resArr => resolve(resArr))\n .catch(e => reject(e));\n });\n\n\nconst deleteEl = (table: string, id: string) =>\n new Promise((resolve, reject) => {\n const request = db\n .transaction([table], 'readwrite')\n .objectStore(table)\n .delete(id);\n\n request.onsuccess = () => resolve(request.result);\n request.onerror = (e: any) => reject(e);\n }); \n\n\nexport const deleteAllEl = (table: string, elIdArray: string[]) =>\n new Promise((resolve, reject) => {\n const promises: unknown[] = [];\n elIdArray.forEach(elId => {\n promises.push(deleteEl(table, elId));\n });\n\n return Promise.all(promises)\n .then(resArr => resolve(resArr))\n .catch(e => reject(e));\n }); \n\n\nexport const get = <T>(table: string, id: string): Promise<T> =>\n new Promise((resolve, reject) => {\n const request = db.transaction([table]).objectStore(table).get(id);\n request.onsuccess = () => resolve(request.result);\n request.onerror = (e: any) => reject(e);\n });\n\nexport const getAll = <T>(table: string, index?: string): Promise<T[]> =>\n new Promise((resolve, reject) => {\n const request = index\n ? db\n .transaction([table], 'readonly')\n .objectStore(table)\n .index(index)\n .openCursor()\n : db.transaction([table], 'readonly').objectStore(table).openCursor();\n // CHECK: getAll => https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore \n const res: T[] = [];\n request.onsuccess = function (event: any) {\n const cursor = event.target.result;\n if (cursor) {\n // cursor.value contains the current record being iterated through\n // this is where you'd do something with the result\n res.push(cursor.value);\n cursor.continue();\n } else {\n // no more results\n resolve(res);\n }\n };\n request.onerror = (e: any) => reject(e);\n });\n\nexport const getAllIds = (table: string) => \n new Promise((resolve, reject) => {\n const request = db.transaction([table], 'readonly').objectStore(table).openCursor();\n // CHECK: getAll => https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore \n const res: unknown[] = [];\n request.onsuccess = function (event: any) {\n const cursor = event.target.result;\n if (cursor) {\n // cursor.value contains the current record being iterated through\n // this is where you'd do something with the result\n res.push(cursor.value.id);\n cursor.continue();\n } else {\n // no more results\n resolve(res);\n }\n };\n request.onerror = (e: any) => reject(e);\n });\n\n\nconst deleteAll = (table: string) =>\n new Promise((resolve, reject) => {\n const request = db\n .transaction([table], 'readwrite')\n .objectStore(table)\n .clear();\n\n request.onsuccess = () => resolve(request.result);\n request.onerror = (e: any) => reject(e);\n });\n\n\nconst removeDatabase = (dbName:string) =>\n new Promise((resolve, reject) => {\n db.close();\n const request = indexedDB.deleteDatabase(dbName);\n request.onsuccess = () => resolve(request.result);\n request.onerror = (e: any) => reject(e);\n});\n\n\n/**\n * Init indexDB for application.\n * \n * @param config - config for index db \n * @param successCallback - callback function after db is successfully initialized \n */\nexport const initDB = (\n config: {\n dbName:string,\n dbVersion:number,\n collections: {\n name: string,\n collectionConf: { \n keyPath?: string\n }\n }[]\n }) => {\n if (!indexedDB) {\n window.alert(\"Your browser doesn't support a stable version of IndexedDB.\");\n } else {\n const {dbName, dbVersion, collections} = config;\n const request = indexedDB.open(dbName, dbVersion);\n request.onerror = event => {\n console.log('error during db init:', event);\n };\n\n request.onsuccess = () => {\n db = request.result;\n console.log(`db init success: ${db}`);\n pdStore().dispatch(initIndexDBSucess());\n };\n\n request.onupgradeneeded = (event: any) => {\n console.log('Upgrade needed', event);\n db = event.target.result;\n switch (event.oldVersion) {\n // first call from client, init db\n case 0: \n collections.forEach(c => {\n db.createObjectStore(c.name, c.collectionConf);\n });\n break;\n // depending on our needs, add specific versions here to migrate existing db\n // case X: ....\n default:\n console.log('No update needed for db');\n }\n };\n }\n};\n"]}
@@ -1,11 +1,18 @@
1
1
  import { configureStore, LoggerExtension, ReduxDevtoolsExtension, ImmutableStateExtension } from 'mini-rx-store';
2
+ import { spaAppReducer } from '../store/spa-app-reducer.js';
3
+ import { appRouteEffect } from '../store/spa-app-effects.js';
2
4
  let store;
3
5
  export const initializeStore = (param) => {
4
6
  console.log("Initialize Store:", param);
5
7
  // create store
6
8
  if (!store) {
7
9
  store = configureStore({
8
- reducers: param.reducer,
10
+ reducers: param.reducer ? {
11
+ spaApp: spaAppReducer,
12
+ ...param.reducer
13
+ } : {
14
+ spaApp: spaAppReducer
15
+ },
9
16
  extensions: [
10
17
  new LoggerExtension(),
11
18
  new ReduxDevtoolsExtension({
@@ -14,7 +21,9 @@ export const initializeStore = (param) => {
14
21
  new ImmutableStateExtension()
15
22
  ],
16
23
  });
17
- // register effects
24
+ // register default effects
25
+ store.effect(appRouteEffect);
26
+ // register configured effects
18
27
  param.effects.forEach(effect => store.effect(effect));
19
28
  }
20
29
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mini-rx.store.js","sourceRoot":"","sources":["../../../src/store/mini-rx.store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAS,eAAe,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAKxH,IAAI,KAAY,CAAC;AAEjB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAkB,EAAE,EAAE;IAEpD,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;IAExC,eAAe;IACf,IAAI,CAAC,KAAK,EAAE;QACV,KAAK,GAAG,cAAc,CAAC;YACrB,QAAQ,EAAE,KAAK,CAAC,OAAO;YACvB,UAAU,EAAE;gBACV,IAAI,eAAe,EAAE;gBACrB,IAAI,sBAAsB,CAAC;oBACzB,IAAI,EAAE,KAAK,CAAC,OAAO;iBACpB,CAAC;gBACF,IAAI,uBAAuB,EAAE;aAC9B;SACF,CAAC,CAAC;QAEH,mBAAmB;QACnB,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;KACvD;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,GAAS,EAAE,CAAC,KAAK,CAAC","sourcesContent":["import { configureStore, Store, LoggerExtension, ReduxDevtoolsExtension, ImmutableStateExtension } from 'mini-rx-store';\n\nimport { StoreConfig } from '../service-provider/service-provider-model.js';\n\n\nlet store: Store;\n\nexport const initializeStore = (param: StoreConfig) => {\n\n console.log(\"Initialize Store:\", param);\n\n // create store\n if (!store) {\n store = configureStore({ \n reducers: param.reducer,\n extensions: [\n new LoggerExtension(),\n new ReduxDevtoolsExtension({\n name: param.appName\n }),\n new ImmutableStateExtension()\n ],\n });\n\n // register effects\n param.effects.forEach(effect => store.effect(effect));\n }\n}\n\nexport const pdStore = ():Store => store;\n"]}
1
+ {"version":3,"file":"mini-rx.store.js","sourceRoot":"","sources":["../../../src/store/mini-rx.store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAS,eAAe,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAIxH,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D,IAAI,KAAY,CAAC;AAEjB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAkB,EAAE,EAAE;IAEpD,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;IAExC,eAAe;IACf,IAAI,CAAC,KAAK,EAAE;QACV,KAAK,GAAG,cAAc,CAAC;YACrB,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;gBACxB,MAAM,EAAE,aAAa;gBACrB,GAAG,KAAK,CAAC,OAAO;aACjB,CAAC,CAAC,CAAC;gBACF,MAAM,EAAE,aAAa;aACtB;YACD,UAAU,EAAE;gBACV,IAAI,eAAe,EAAE;gBACrB,IAAI,sBAAsB,CAAC;oBACzB,IAAI,EAAE,KAAK,CAAC,OAAO;iBACpB,CAAC;gBACF,IAAI,uBAAuB,EAAE;aAC9B;SACF,CAAC,CAAC;QAEH,2BAA2B;QAC3B,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QAE7B,8BAA8B;QAC9B,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;KACvD;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,GAAS,EAAE,CAAC,KAAK,CAAC","sourcesContent":["import { configureStore, Store, LoggerExtension, ReduxDevtoolsExtension, ImmutableStateExtension } from 'mini-rx-store';\n\nimport { StoreConfig } from '../service-provider/service-provider-model.js';\n\nimport { spaAppReducer } from '../store/spa-app-reducer.js';\nimport { appRouteEffect } from '../store/spa-app-effects.js';\n\n\nlet store: Store;\n\nexport const initializeStore = (param: StoreConfig) => {\n\n console.log(\"Initialize Store:\", param);\n\n // create store\n if (!store) {\n store = configureStore({ \n reducers: param.reducer ? {\n spaApp: spaAppReducer,\n ...param.reducer\n } : {\n spaApp: spaAppReducer \n },\n extensions: [\n new LoggerExtension(),\n new ReduxDevtoolsExtension({\n name: param.appName\n }),\n new ImmutableStateExtension()\n ],\n });\n\n // register default effects\n store.effect(appRouteEffect);\n\n // register configured effects\n param.effects.forEach(effect => store.effect(effect));\n }\n}\n\nexport const pdStore = ():Store => store;\n"]}
@@ -0,0 +1,32 @@
1
+ import { LoadingState } from '../model/spa-model.js';
2
+ export declare const initIndexDBSucess: (() => {
3
+ type: "SPA_INIT_INDEX_DB_SUCCESS";
4
+ }) & {
5
+ type: "SPA_INIT_INDEX_DB_SUCCESS";
6
+ };
7
+ export declare const loginSucess: (() => {
8
+ type: "SPA_LOGIN_SUCCESS";
9
+ }) & {
10
+ type: "SPA_LOGIN_SUCCESS";
11
+ };
12
+ export declare const routeAction: ((payload: string) => {
13
+ payload: string;
14
+ } & {
15
+ type: "SPA_APP_ROUTE";
16
+ }) & {
17
+ type: "SPA_APP_ROUTE";
18
+ };
19
+ export declare const updateInternetOffline: ((payload: boolean) => {
20
+ payload: boolean;
21
+ } & {
22
+ type: "SPA_APP_UPDATE_INTERNET_OFFLINE";
23
+ }) & {
24
+ type: "SPA_APP_UPDATE_INTERNET_OFFLINE";
25
+ };
26
+ export declare const loadingStateChange: ((payload: LoadingState) => {
27
+ payload: LoadingState;
28
+ } & {
29
+ type: "SPA_APP_LOADING_STATE_CHANGE";
30
+ }) & {
31
+ type: "SPA_APP_LOADING_STATE_CHANGE";
32
+ };
@@ -0,0 +1,7 @@
1
+ import { action, payload } from 'ts-action';
2
+ export const initIndexDBSucess = action('SPA_INIT_INDEX_DB_SUCCESS');
3
+ export const loginSucess = action('SPA_LOGIN_SUCCESS');
4
+ export const routeAction = action('SPA_APP_ROUTE', payload());
5
+ export const updateInternetOffline = action('SPA_APP_UPDATE_INTERNET_OFFLINE', payload());
6
+ export const loadingStateChange = action('SPA_APP_LOADING_STATE_CHANGE', payload());
7
+ //# sourceMappingURL=spa-app-actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spa-app-actions.js","sourceRoot":"","sources":["../../../src/store/spa-app-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAEvD,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,eAAe,EAAE,OAAO,EAAU,CAAC,CAAC;AAEtE,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,iCAAiC,EAAE,OAAO,EAAW,CAAC,CAAC;AAEnG,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,8BAA8B,EAAE,OAAO,EAAgB,CAAC,CAAC","sourcesContent":["import { action, payload } from 'ts-action';\nimport { LoadingState } from '../model/spa-model.js';\n\nexport const initIndexDBSucess = action('SPA_INIT_INDEX_DB_SUCCESS');\nexport const loginSucess = action('SPA_LOGIN_SUCCESS');\n\nexport const routeAction = action('SPA_APP_ROUTE', payload<string>());\n\nexport const updateInternetOffline = action('SPA_APP_UPDATE_INTERNET_OFFLINE', payload<boolean>());\n\nexport const loadingStateChange = action('SPA_APP_LOADING_STATE_CHANGE', payload<LoadingState>());"]}
@@ -0,0 +1,6 @@
1
+ export declare const setRouteElement: (param: HTMLElement) => void;
2
+ export declare const appRouteEffect: import("rxjs").Observable<{
3
+ payload: string;
4
+ } & {
5
+ type: "SPA_APP_ROUTE";
6
+ }> & import("mini-rx-store/lib/models.js").HasEffectMetadata;
@@ -0,0 +1,23 @@
1
+ import { actions$, createEffect } from 'mini-rx-store';
2
+ import { tap } from 'rxjs/operators';
3
+ import { ofType } from 'ts-action-operators';
4
+ import { routeAction } from './spa-app-actions.js';
5
+ let routeElement;
6
+ export const setRouteElement = (param) => {
7
+ routeElement = param;
8
+ };
9
+ export const appRouteEffect = createEffect(actions$.pipe(ofType(routeAction), tap((action) => {
10
+ if (!routeElement) {
11
+ console.error("No route element set for appRouteEffect");
12
+ }
13
+ else {
14
+ routeElement.dispatchEvent(new CustomEvent('route-event', {
15
+ detail: { route: action.payload },
16
+ bubbles: true,
17
+ composed: true
18
+ }));
19
+ }
20
+ })), {
21
+ dispatch: false
22
+ });
23
+ //# sourceMappingURL=spa-app-effects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spa-app-effects.js","sourceRoot":"","sources":["../../../src/store/spa-app-effects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,IAAI,YAAyB,CAAC;AAE9B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAkB,EAAE,EAAE;IACpD,YAAY,GAAG,KAAK,CAAC;AACvB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CACxC,QAAQ,CAAC,IAAI,CACX,MAAM,CAAC,WAAW,CAAC,EACnB,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;IACb,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;KAC1D;SAAM;QACL,YAAY,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,aAAa,EAAE;YACxD,MAAM,EAAE,EAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAC;YAC/B,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC,CAAC;KACL;AACH,CAAC,CAAC,CACH,EAAE;IACD,QAAQ,EAAE,KAAK;CAChB,CACF,CAAC","sourcesContent":["import { actions$, createEffect } from 'mini-rx-store';\n\nimport { tap } from 'rxjs/operators';\n\nimport { ofType } from 'ts-action-operators';\n\nimport { routeAction } from './spa-app-actions.js';\n\n\nlet routeElement: HTMLElement;\n\nexport const setRouteElement = (param: HTMLElement) => {\n routeElement = param;\n}\n\nexport const appRouteEffect = createEffect(\n actions$.pipe(\n ofType(routeAction),\n tap((action) => {\n if (!routeElement) {\n console.error(\"No route element set for appRouteEffect\");\n } else { \n routeElement.dispatchEvent(new CustomEvent('route-event', {\n detail: {route: action.payload},\n bubbles: true,\n composed: true\n })); \n }\n })\n ), {\n dispatch: false\n }\n);\n"]}
@@ -0,0 +1,9 @@
1
+ import { LoadingState } from '../model/spa-model.js';
2
+ export interface SpaAppState {
3
+ offline?: boolean;
4
+ loadingState?: LoadingState;
5
+ lastRoutes?: any[];
6
+ initIndexDB?: boolean;
7
+ userLogin?: boolean;
8
+ }
9
+ export declare const spaAppReducer: import("ts-action").Reducer<SpaAppState>;
@@ -0,0 +1,28 @@
1
+ import { on, reducer } from 'ts-action';
2
+ import { initIndexDBSucess, loadingStateChange, loginSucess, routeAction, updateInternetOffline } from './spa-app-actions.js';
3
+ const initialState = {};
4
+ export const spaAppReducer = reducer(initialState, on(updateInternetOffline, (state, { payload }) => ({
5
+ ...state,
6
+ offline: payload
7
+ })), on(loadingStateChange, (state, { payload }) => ({
8
+ ...state,
9
+ loadingState: payload ? {
10
+ isLoading: payload.isLoading,
11
+ smallBackground: payload.smallBackground,
12
+ modal: payload.modal,
13
+ txt: payload.loadingTxt,
14
+ } : undefined
15
+ })), on(routeAction, (state, { payload }) => ({
16
+ ...state,
17
+ lastRoutes: [
18
+ ...(state.lastRoutes || []),
19
+ payload
20
+ ]
21
+ })), on(initIndexDBSucess, (state) => ({
22
+ ...state,
23
+ initIndexDB: true,
24
+ })), on(loginSucess, (state) => ({
25
+ ...state,
26
+ userLogin: true,
27
+ })));
28
+ //# sourceMappingURL=spa-app-reducer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spa-app-reducer.js","sourceRoot":"","sources":["../../../src/store/spa-app-reducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAW9H,MAAM,YAAY,GAAgB,EAEjC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAClC,YAAY,EAEZ,EAAE,CAAE,qBAAqB,EAAE,CAAC,KAAK,EAAE,EAAC,OAAO,EAAC,EAAE,EAAE,CAAE,CAChD;IACE,GAAG,KAAK;IACR,OAAO,EAAE,OAAO;CACjB,CACF,CAAC,EAEF,EAAE,CAAC,kBAAkB,EAAE,CAAC,KAAK,EAAE,EAAC,OAAO,EAAC,EAAE,EAAE,CAAC,CAC3C;IACE,GAAG,KAAK;IACR,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC;QACtB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,GAAG,EAAE,OAAO,CAAC,UAAU;KACxB,CAAC,CAAC,CAAC,SAAS;CACd,CACF,CAAC,EAEF,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAC,OAAO,EAAC,EAAE,EAAE,CAAC,CACpC;IACE,GAAG,KAAK;IACR,UAAU,EAAE;QACV,GAAG,CAAC,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC;QAC3B,OAAO;KACR;CACF,CACF,CAAC,EAEF,EAAE,CAAC,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAC/B;IACE,GAAG,KAAK;IACR,WAAW,EAAE,IAAI;CAClB,CACF,CAAC,EAEF,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CACzB;IACE,GAAG,KAAK;IACR,SAAS,EAAE,IAAI;CAChB,CACF,CAAC,CAEH,CAAC","sourcesContent":["import { on, reducer } from 'ts-action';\n\nimport { initIndexDBSucess, loadingStateChange, loginSucess, routeAction, updateInternetOffline } from './spa-app-actions.js';\nimport { LoadingState } from '../model/spa-model.js';\n\nexport interface SpaAppState {\n offline?: boolean,\n loadingState?: LoadingState;\n lastRoutes?: any[];\n initIndexDB?: boolean;\n userLogin?: boolean;\n}\n\nconst initialState: SpaAppState = { \n \n};\n\nexport const spaAppReducer = reducer(\n initialState,\n\n on (updateInternetOffline, (state, {payload}) => (\n {\n ...state,\n offline: payload\n }\n )), \n \n on(loadingStateChange, (state, {payload}) => (\n {\n ...state,\n loadingState: payload ? {\n isLoading: payload.isLoading,\n smallBackground: payload.smallBackground,\n modal: payload.modal,\n txt: payload.loadingTxt,\n } : undefined\n }\n )),\n\n on(routeAction, (state, {payload}) => (\n {\n ...state,\n lastRoutes: [\n ...(state.lastRoutes || []),\n payload\n ]\n }\n )),\n\n on(initIndexDBSucess, (state) => (\n {\n ...state,\n initIndexDB: true,\n }\n )),\n\n on(loginSucess, (state) => (\n {\n ...state,\n userLogin: true,\n }\n )),\n\n);"]}
@@ -0,0 +1,6 @@
1
+ export declare const getLoadingSelector: import("mini-rx-store/lib/selector.js").Selector<object, import("../model/spa-model.js").LoadingState | undefined>;
2
+ export declare const getOfflineSelector: import("mini-rx-store/lib/selector.js").Selector<object, boolean>;
3
+ export declare const getInitStatusSelector: import("mini-rx-store/lib/selector.js").Selector<object, {
4
+ login: boolean | undefined;
5
+ indexedDB: boolean | undefined;
6
+ }>;
@@ -0,0 +1,9 @@
1
+ import { createFeatureStateSelector, createSelector } from "mini-rx-store";
2
+ const getSpaAppFeatureState = createFeatureStateSelector('spaApp');
3
+ export const getLoadingSelector = createSelector(getSpaAppFeatureState, state => state.loadingState);
4
+ export const getOfflineSelector = createSelector(getSpaAppFeatureState, state => state.offline === true);
5
+ export const getInitStatusSelector = createSelector(getSpaAppFeatureState, state => ({
6
+ login: state.userLogin,
7
+ indexedDB: state.initIndexDB
8
+ }));
9
+ //# sourceMappingURL=spa-app-selector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spa-app-selector.js","sourceRoot":"","sources":["../../../src/store/spa-app-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAI3E,MAAM,qBAAqB,GAAG,0BAA0B,CAAc,QAAQ,CAAC,CAAC;AAEhF,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAC9C,qBAAqB,EACrB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAC5B,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAC9C,qBAAqB,EACrB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,IAAI,CAChC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CACjD,qBAAqB,EACrB,KAAK,CAAC,EAAE,CAAC,CAAC;IACR,KAAK,EAAE,KAAK,CAAC,SAAS;IACtB,SAAS,EAAE,KAAK,CAAC,WAAW;CAC7B,CAAC,CACH,CAAC","sourcesContent":["import { createFeatureStateSelector, createSelector } from \"mini-rx-store\";\n\nimport { SpaAppState } from \"./spa-app-reducer.js\";\n\nconst getSpaAppFeatureState = createFeatureStateSelector<SpaAppState>('spaApp');\n\nexport const getLoadingSelector = createSelector(\n getSpaAppFeatureState,\n state => state.loadingState\n);\n\nexport const getOfflineSelector = createSelector(\n getSpaAppFeatureState,\n state => state.offline === true\n);\n\nexport const getInitStatusSelector = createSelector(\n getSpaAppFeatureState,\n state => ({\n login: state.userLogin,\n indexedDB: state.initIndexDB\n })\n);"]}
@@ -1,11 +1,7 @@
1
1
  import { LitElement, CSSResultGroup } from 'lit';
2
+ import { LoadingState } from '../model/spa-model.js';
2
3
  export declare class PdLoadingState extends LitElement {
3
- loadingState: {
4
- isLoading: boolean;
5
- modal?: boolean;
6
- smallBackground?: boolean;
7
- loadingTxt?: string;
8
- };
4
+ loadingState: LoadingState;
9
5
  static styles: CSSResultGroup;
10
6
  render(): import("lit").TemplateResult<1>;
11
7
  _renderContent(): import("lit").TemplateResult<1>;
@@ -1 +1 @@
1
- {"version":3,"file":"pd-loading-state.js","sourceRoot":"","sources":["../../../src/tmpown/pd-loading-state.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAIhD,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QAGL,iBAAY,GAKR;YACF,SAAS,EAAE,KAAK;SACjB,CAAC;IAkHJ,CAAC;IAtBC,MAAM;QACJ,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;;YAE7B,IAAI,CAAC,cAAc,EAAE;;OAE1B,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;IAC9B,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAA;oBACK,QAAQ,CAAC;YACnB,OAAO,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe;YAC3C,kBAAkB,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,eAAe,KAAK,IAAI;YAClG,oBAAoB,EAAE,IAAI,CAAC,YAAY,CAAC,eAAe,KAAK,IAAI;SACjE,CAAC;sBACY,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,QAAQ;aAC3E,IAAI,CAAC,YAAY,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;YACvE,GAAG,CAAC,6BAA6B,EAAE,EAAC,EAAE,EAAE,6BAA6B,EAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,oCAAoC,EAAE,EAAC,EAAE,EAAE,8BAA8B,EAAC,CAAC,CAAC;;KAE/J,CAAA;IACH,CAAC;;AA7GM,qBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqFF;CACgB,CAAC;AAjGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAC,CAAC;oDAQxB;AAVS,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CA4H1B;SA5HY,cAAc","sourcesContent":["import { LitElement, html, css, CSSResultGroup } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { msg } from '@lit/localize';\nimport { classMap } from 'lit/directives/class-map.js';\n\n\n@customElement('pd-loading-state')\nexport class PdLoadingState extends LitElement {\n\n @property({ type: Object}) \n loadingState: {\n isLoading: boolean,\n modal?: boolean,\n smallBackground?: boolean,\n loadingTxt?: string\n } = {\n isLoading: false\n };\n\n\n static styles = [ \n css`\n :host {\n display: block;\n }\n\n /* The Modal (background) */\n .modal { \n position: fixed; /* Stay in place */ \n left: 0;\n top: 0;\n z-index: 500; /* Sit on top */\n\n display: flex;\n align-items: center;\n justify-content: center;\n \n width: 100%; /* Full width */\n height: 100%; /* Full height */ \n overflow: auto; /* Enable scroll if needed */\n /* RGBA Wert muss hier verwendet werden #AFC1D2 to rgba for opacity */\n background-color: var(--pd-popup-modal-bg-rgba, rgba(175, 193, 210, 0.8)); \n }\n\n /* Modal Content */\n .no-modal-content { \n position: fixed; /* Stay in place */ \n left: 50%; \n top: 50%; \n transform: translate(-50%, -50%); \n }\n\n .content {\n padding: 1em;\n text-align: center;\n background-color: var(--pd-loading-state-bg-col, #edf7fd);\n border: 2px solid var(--pd-loading-state-bg-col, var(--pd-default-col, #067394));\n z-index: 101; /* Sit on top */\n }\n\n .background-content {\n\n position: fixed; /* Stay in place */ \n right: 0em; \n bottom: 0em; \n\n padding: 1em; \n z-index: 101; /* Sit on top */\n\n display: flex;\n gap: 0.5em;\n align-items: center;\n\n background-color: white;\n }\n\n .loader { \n border: 16px solid var(--pd-heating-service-loader, #0A3A48);\n border-top: 16px solid var(--pd-heating-service-loader-run, #067394);\n border-radius: 50%;\n width: 30px;\n height: 30px;\n animation: spin 2s linear infinite;\n \n margin-left: auto;\n margin-right: auto;\n }\n\n .background-loader { \n border: 10px solid var(--pd-heating-service-loader, #0A3A48);\n border-top: 10px solid var(--pd-heating-service-loader-run, #067394);\n border-radius: 50%;\n width: 10px;\n height: 10px;\n animation: spin 2s linear infinite;\n }\n\n @keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n\n `\n ] as CSSResultGroup; \n\n render() { \n return this.loadingState.modal ? html`\n <div id=\"modalId\" class=\"modal\">\n ${this._renderContent()}\n </div>\n ` : this._renderContent();\n }\n\n _renderContent() {\n return html`\n <div class=\"${classMap({\n content: !this.loadingState.smallBackground,\n \"no-modal-content\": this.loadingState.modal !== true && this.loadingState.smallBackground !== true,\n \"background-content\": this.loadingState.smallBackground === true,\n })}\">\n <div class=\"${this.loadingState.smallBackground ? \"background-loader\" : \"loader\"}\"></div>\n <p>${this.loadingState.loadingTxt || (this.loadingState.smallBackground ? \n msg(\"Daten werden synchronisiert\", {id: \"spaH.loadingstate.syncState\"}) : msg(\"Bitte warten, Daten werden geladen\", {id: \"spaH.loadingstate.pleaseWait\"}))}</p>\n </div>\n `\n }\n\n}"]}
1
+ {"version":3,"file":"pd-loading-state.js","sourceRoot":"","sources":["../../../src/tmpown/pd-loading-state.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAMhD,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QAGL,iBAAY,GAAiB;YAC3B,SAAS,EAAE,KAAK;SACjB,CAAC;IAkHJ,CAAC;IAtBC,MAAM;QACJ,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;;YAE7B,IAAI,CAAC,cAAc,EAAE;;OAE1B,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;IAC9B,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAA;oBACK,QAAQ,CAAC;YACnB,OAAO,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe;YAC3C,kBAAkB,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,YAAY,CAAC,eAAe,KAAK,IAAI;YAClG,oBAAoB,EAAE,IAAI,CAAC,YAAY,CAAC,eAAe,KAAK,IAAI;SACjE,CAAC;sBACY,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,QAAQ;aAC3E,IAAI,CAAC,YAAY,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;YACvE,GAAG,CAAC,6BAA6B,EAAE,EAAC,EAAE,EAAE,6BAA6B,EAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,oCAAoC,EAAE,EAAC,EAAE,EAAE,8BAA8B,EAAC,CAAC,CAAC;;KAE/J,CAAA;IACH,CAAC;;AA7GM,qBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqFF;CACgB,CAAC;AA5FpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAC,CAAC;oDAGxB;AALS,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAuH1B;SAvHY,cAAc","sourcesContent":["import { LitElement, html, css, CSSResultGroup } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { msg } from '@lit/localize';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport {LoadingState} from '../model/spa-model.js';\n\n\n@customElement('pd-loading-state')\nexport class PdLoadingState extends LitElement {\n\n @property({ type: Object}) \n loadingState: LoadingState = {\n isLoading: false\n };\n\n\n static styles = [ \n css`\n :host {\n display: block;\n }\n\n /* The Modal (background) */\n .modal { \n position: fixed; /* Stay in place */ \n left: 0;\n top: 0;\n z-index: 500; /* Sit on top */\n\n display: flex;\n align-items: center;\n justify-content: center;\n \n width: 100%; /* Full width */\n height: 100%; /* Full height */ \n overflow: auto; /* Enable scroll if needed */\n /* RGBA Wert muss hier verwendet werden #AFC1D2 to rgba for opacity */\n background-color: var(--pd-popup-modal-bg-rgba, rgba(175, 193, 210, 0.8)); \n }\n\n /* Modal Content */\n .no-modal-content { \n position: fixed; /* Stay in place */ \n left: 50%; \n top: 50%; \n transform: translate(-50%, -50%); \n }\n\n .content {\n padding: 1em;\n text-align: center;\n background-color: var(--pd-loading-state-bg-col, #edf7fd);\n border: 2px solid var(--pd-loading-state-bg-col, var(--pd-default-col, #067394));\n z-index: 101; /* Sit on top */\n }\n\n .background-content {\n\n position: fixed; /* Stay in place */ \n right: 0em; \n bottom: 0em; \n\n padding: 1em; \n z-index: 101; /* Sit on top */\n\n display: flex;\n gap: 0.5em;\n align-items: center;\n\n background-color: white;\n }\n\n .loader { \n border: 16px solid var(--pd-heating-service-loader, #0A3A48);\n border-top: 16px solid var(--pd-heating-service-loader-run, #067394);\n border-radius: 50%;\n width: 30px;\n height: 30px;\n animation: spin 2s linear infinite;\n \n margin-left: auto;\n margin-right: auto;\n }\n\n .background-loader { \n border: 10px solid var(--pd-heating-service-loader, #0A3A48);\n border-top: 10px solid var(--pd-heating-service-loader-run, #067394);\n border-radius: 50%;\n width: 10px;\n height: 10px;\n animation: spin 2s linear infinite;\n }\n\n @keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n\n `\n ] as CSSResultGroup; \n\n render() { \n return this.loadingState.modal ? html`\n <div id=\"modalId\" class=\"modal\">\n ${this._renderContent()}\n </div>\n ` : this._renderContent();\n }\n\n _renderContent() {\n return html`\n <div class=\"${classMap({\n content: !this.loadingState.smallBackground,\n \"no-modal-content\": this.loadingState.modal !== true && this.loadingState.smallBackground !== true,\n \"background-content\": this.loadingState.smallBackground === true,\n })}\">\n <div class=\"${this.loadingState.smallBackground ? \"background-loader\" : \"loader\"}\"></div>\n <p>${this.loadingState.loadingTxt || (this.loadingState.smallBackground ? \n msg(\"Daten werden synchronisiert\", {id: \"spaH.loadingstate.syncState\"}) : msg(\"Bitte warten, Daten werden geladen\", {id: \"spaH.loadingstate.pleaseWait\"}))}</p>\n </div>\n `\n }\n\n}"]}