@progressive-development/pd-spa-helper 0.2.7 → 0.2.9
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/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/service-provider/firebase/firestorage-client.d.ts +1 -0
- package/dist/src/service-provider/firebase/firestorage-client.js +22 -1
- package/dist/src/service-provider/firebase/firestorage-client.js.map +1 -1
- package/dist/src/service-provider/mock/storage-client.d.ts +2 -1
- package/dist/src/service-provider/mock/storage-client.js +7 -2
- package/dist/src/service-provider/mock/storage-client.js.map +1 -1
- package/dist/src/service-provider/service-provider-impl.d.ts +1 -0
- package/dist/src/service-provider/service-provider-impl.js +11 -2
- package/dist/src/service-provider/service-provider-impl.js.map +1 -1
- package/dist/src/service-provider/service-provider-model.d.ts +2 -0
- package/dist/src/service-provider/service-provider-model.js.map +1 -1
- package/dist/src/store/spa-app-selector.js +1 -1
- package/dist/src/store/spa-app-selector.js.map +1 -1
- package/dist/src/stories/pd-loading-state.stories.d.ts +1 -0
- package/dist/src/stories/pd-loading-state.stories.js +27 -0
- package/dist/src/stories/pd-loading-state.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/service-provider/firebase/firestorage-client.ts +26 -1
- package/src/service-provider/mock/storage-client.ts +8 -2
- package/src/service-provider/service-provider-impl.ts +16 -3
- package/src/service-provider/service-provider-model.ts +2 -0
- package/src/store/spa-app-selector.ts +1 -1
- package/src/stories/pd-loading-state.stories.ts +28 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { DefaultWizardStep } from './defaultpage/default-wizard-step.js';
|
|
|
11
11
|
export { DefaultStepAddress } from './defaultpage/default-step-address.js';
|
|
12
12
|
export { DefaultStepSummary, OrderStep } from './defaultpage/default-step-summary.js';
|
|
13
13
|
export { getDB, } from './service-provider/firebase/firestore-client.js';
|
|
14
|
-
export { loginImpl, logoutImpl, isAuthenticatedImpl, callFunctionImpl, uploadFile, getStorageFileList } from './service-provider/service-provider-impl.js';
|
|
14
|
+
export { loginImpl, logoutImpl, isAuthenticatedImpl, callFunctionImpl, uploadFile, downloadFile, getStorageFileList } from './service-provider/service-provider-impl.js';
|
|
15
15
|
export { pdStore } from './store/mini-rx.store.js';
|
|
16
16
|
export { setRouteElement } from './store/spa-app-effects.js';
|
|
17
17
|
export * as pdAction from './store/spa-app-actions.js';
|
package/dist/src/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export { DefaultWizardStep } from './defaultpage/default-wizard-step.js';
|
|
|
11
11
|
export { DefaultStepAddress } from './defaultpage/default-step-address.js';
|
|
12
12
|
export { DefaultStepSummary } from './defaultpage/default-step-summary.js';
|
|
13
13
|
export { getDB, } from './service-provider/firebase/firestore-client.js';
|
|
14
|
-
export { loginImpl, logoutImpl, isAuthenticatedImpl, callFunctionImpl, uploadFile, getStorageFileList } from './service-provider/service-provider-impl.js';
|
|
14
|
+
export { loginImpl, logoutImpl, isAuthenticatedImpl, callFunctionImpl, uploadFile, downloadFile, getStorageFileList } from './service-provider/service-provider-impl.js';
|
|
15
15
|
export { pdStore } from './store/mini-rx.store.js';
|
|
16
16
|
export { setRouteElement } from './store/spa-app-effects.js';
|
|
17
17
|
export * as pdAction from './store/spa-app-actions.js';
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,SAAS,GACV,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,UAAU,MAAM,8CAA8C,CAAC;AAC3E,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAC,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAElF,OAAO,EAAC,eAAe,E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ACR;QACD,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,CAAC;AACN,CAAC,CAAA","sourcesContent":["export { \n PdSpaHelper, \n startInit, \n} from './PdSpaHelper.js';\n\nexport * as pdSpaModel from './service-provider/service-provider-model.js';\nexport * as pdSpaModel2 from './model/spa-model.js';\n\nexport {isBlank, isEmpty, activateOfflineWatcher} from './helper/helper-utils.js';\n\nexport {DefaultViewPage} from './defaultpage/default-view-page.js';\n\nexport {DefaultConfirmPopup, PopupType, ABORT_EVENT_NAME, STORE_EVENT_NAME} from './defaultpage/default-confirm-popup.js';\n\nexport {DefaultDialogPopup} from './defaultpage/default-dialog-popup.js';\n\nexport {DefaultPopup} from './defaultpage/default-popup.js';\n\nexport {DefaultWizard} from './defaultpage/default-wizard.js';\n\nexport {DefaultWizardStep} from './defaultpage/default-wizard-step.js';\n\nexport {DefaultStepAddress} from './defaultpage/default-step-address.js';\n\nexport {DefaultStepSummary, OrderStep} from './defaultpage/default-step-summary.js';\n\nexport {\n getDB,\n} from './service-provider/firebase/firestore-client.js'\n\nexport {\n loginImpl,\n logoutImpl,\n isAuthenticatedImpl,\n callFunctionImpl,\n uploadFile,\n getStorageFileList\n} from './service-provider/service-provider-impl.js'\n\nexport { pdStore } from './store/mini-rx.store.js';\nexport { setRouteElement } from './store/spa-app-effects.js';\n\nexport * as pdAction from './store/spa-app-actions.js';\nexport * as pdSelector from './store/spa-app-selector.js';\n\nexport * as pdDB from './store/indexDB.js'\n\nexport { templates as beTemplaes} from './generated/locale-wrapper/be-wrapper.js'\nexport { templates as deTemplaes} from './generated/locale-wrapper/de-wrapper.js'\nexport { templates as enTemplaes} from './generated/locale-wrapper/en-wrapper.js'\n\nexport const dispatchToastEvent = (element:any, txt:string, isSuccess:boolean, isError:boolean) => {\n element.dispatchEvent(new CustomEvent(\"toast-event\",{\n detail: {\n txt,\n isSuccess,\n isError\n },\n bubbles: true,\n composed: true\n }));\n}\n"]}
|
|
1
|
+
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AE,SAAS,IAAI,UAAU,EAAC,MAAM,0CAA0C,CAAA;AACjF,OAAO,EAAE,SAAS,IAAI,UAAU,EAAC,MAAM,0CAA0C,CAAA;AAEjF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAW,EAAE,GAAU,EAAE,SAAiB,EAAE,OAAe,EAAE,EAAE;IAChG,OAAO,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,aAAa,EAAC;QAClD,MAAM,EAAE;YACN,GAAG;YACH,SAAS;YACT,OAAO;SACR;QACD,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC,CAAC;AACN,CAAC,CAAA","sourcesContent":["export { \n PdSpaHelper, \n startInit, \n} from './PdSpaHelper.js';\n\nexport * as pdSpaModel from './service-provider/service-provider-model.js';\nexport * as pdSpaModel2 from './model/spa-model.js';\n\nexport {isBlank, isEmpty, activateOfflineWatcher} from './helper/helper-utils.js';\n\nexport {DefaultViewPage} from './defaultpage/default-view-page.js';\n\nexport {DefaultConfirmPopup, PopupType, ABORT_EVENT_NAME, STORE_EVENT_NAME} from './defaultpage/default-confirm-popup.js';\n\nexport {DefaultDialogPopup} from './defaultpage/default-dialog-popup.js';\n\nexport {DefaultPopup} from './defaultpage/default-popup.js';\n\nexport {DefaultWizard} from './defaultpage/default-wizard.js';\n\nexport {DefaultWizardStep} from './defaultpage/default-wizard-step.js';\n\nexport {DefaultStepAddress} from './defaultpage/default-step-address.js';\n\nexport {DefaultStepSummary, OrderStep} from './defaultpage/default-step-summary.js';\n\nexport {\n getDB,\n} from './service-provider/firebase/firestore-client.js'\n\nexport {\n loginImpl,\n logoutImpl,\n isAuthenticatedImpl,\n callFunctionImpl,\n uploadFile,\n downloadFile,\n getStorageFileList\n} from './service-provider/service-provider-impl.js'\n\nexport { pdStore } from './store/mini-rx.store.js';\nexport { setRouteElement } from './store/spa-app-effects.js';\n\nexport * as pdAction from './store/spa-app-actions.js';\nexport * as pdSelector from './store/spa-app-selector.js';\n\nexport * as pdDB from './store/indexDB.js'\n\nexport { templates as beTemplaes} from './generated/locale-wrapper/be-wrapper.js'\nexport { templates as deTemplaes} from './generated/locale-wrapper/de-wrapper.js'\nexport { templates as enTemplaes} from './generated/locale-wrapper/en-wrapper.js'\n\nexport const dispatchToastEvent = (element:any, txt:string, isSuccess:boolean, isError:boolean) => {\n element.dispatchEvent(new CustomEvent(\"toast-event\",{\n detail: {\n txt,\n isSuccess,\n isError\n },\n bubbles: true,\n composed: true\n }));\n}\n"]}
|
|
@@ -9,3 +9,4 @@ import { FileStorageConfig, StorageDocument, UploadFile } from '../service-provi
|
|
|
9
9
|
export declare const initFirestorage: (app: FirebaseApp, defaultStorage?: string, storageConfig?: FileStorageConfig) => void;
|
|
10
10
|
export declare const uploadFirestorageFile: (file: UploadFile) => Promise<UploadResult>;
|
|
11
11
|
export declare const getFirestorageFileList: (storageName: string, refKey: string, subFolder?: string, includeMetaData?: boolean) => Promise<StorageDocument[]>;
|
|
12
|
+
export declare const downloadFileFirestorage: (file: StorageDocument) => Promise<string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getMetadata, getStorage, listAll, ref, uploadString } from "firebase/storage";
|
|
1
|
+
import { getDownloadURL, getMetadata, getStorage, listAll, ref, uploadString } from "firebase/storage";
|
|
2
2
|
import { getUser } from '../service-provider-impl.js';
|
|
3
3
|
const DEFAULT_STORAGE = "default_storage";
|
|
4
4
|
const storageMap = new Map();
|
|
@@ -97,6 +97,7 @@ export const getFirestorageFileList = (storageName, refKey, subFolder, includeMe
|
|
|
97
97
|
itemRefs.push({
|
|
98
98
|
fileName: itemRef.name,
|
|
99
99
|
filePath: itemRef.fullPath,
|
|
100
|
+
storageName, refKey
|
|
100
101
|
});
|
|
101
102
|
// MetaData for each item with own promise
|
|
102
103
|
if (includeMetaData) {
|
|
@@ -126,6 +127,26 @@ export const getFirestorageFileList = (storageName, refKey, subFolder, includeMe
|
|
|
126
127
|
throw error;
|
|
127
128
|
});
|
|
128
129
|
};
|
|
130
|
+
export const downloadFileFirestorage = (file) => {
|
|
131
|
+
if (!storageMap || storageMap.size === 0) {
|
|
132
|
+
throw new Error("No storage is configured");
|
|
133
|
+
}
|
|
134
|
+
// get storage
|
|
135
|
+
const storageConf = storageMap.get(file.storageName);
|
|
136
|
+
if (!storageConf) {
|
|
137
|
+
throw new Error(`Invalid storage name: ${file.storageName}`);
|
|
138
|
+
}
|
|
139
|
+
if (!storageConf.references || storageConf.references.length === 0) {
|
|
140
|
+
throw new Error(`No references configured for storage: ${file.storageName}`);
|
|
141
|
+
}
|
|
142
|
+
// get refrence
|
|
143
|
+
const storageRef = storageConf.references.filter(refIt => refIt.key === file.refKey)[0];
|
|
144
|
+
if (!storageRef) {
|
|
145
|
+
throw new Error(`No reference available for storage: ${file.storageName} and ref: ${file.refKey}`);
|
|
146
|
+
}
|
|
147
|
+
const usedRef = ref(storageRef.storageRef, file.filePath);
|
|
148
|
+
return getDownloadURL(usedRef);
|
|
149
|
+
};
|
|
129
150
|
/* Firestorage Error List: https://firebase.google.com/docs/storage/web/handle-errors */
|
|
130
151
|
/*
|
|
131
152
|
storage/unknown An unknown error occurred.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firestorage-client.js","sourceRoot":"","sources":["../../../../src/service-provider/firebase/firestorage-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAiE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGtJ,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAE1C,MAAM,UAAU,GAMX,IAAI,GAAG,EAAE,CAAC;AAEf;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAgB,EAAE,cAAuB,EAAE,aAAiC,EAAE,EAAE;IAC9G,IAAI;QAEF,sBAAsB;QACtB,IAAI,cAAc,EAAE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etadata, StorageReference, UploadResult, getMetadata, getStorage, listAll, ref, uploadString } from \"firebase/storage\";\n\nimport { FileStorageConfig, StorageDocument, UploadFile } from '../service-provider-model.js';\nimport { getUser } from '../service-provider-impl.js';\n\nconst DEFAULT_STORAGE = \"default_storage\";\n\nconst storageMap:Map<string, { \n storage: FirebaseStorage,\n references?: {\n key: string,\n storageRef: StorageReference\n }[],\n}> = new Map();\n\n/**\n * During start/load application, initialize functions.\n *\n * @param {*} app - initialized app.\n */\nexport const initFirestorage = (app: FirebaseApp, defaultStorage?: string, storageConfig?: FileStorageConfig) => {\n try {\n\n // add default storage\n if (defaultStorage) {\n storageMap.set(DEFAULT_STORAGE, {\n storage: getStorage(app)\n });\n } \n \n // add specific storages\n storageConfig?.storage.forEach(storeConfig => {\n\n const storage = getStorage(app, storeConfig.name);\n const storageRootRef = ref(storage);\n\n storageMap.set(storeConfig.name, {\n storage,\n references: [\n {\n key: \"ROOT\",\n storageRef: storageRootRef\n },\n ...storeConfig.references.map(refConfigString => ({\n key: refConfigString,\n storageRef: ref(storageRootRef, refConfigString)\n }))\n ]\n });\n }); \n\n } catch (error) {\n console.error(error);\n }\n};\n\nexport const uploadFirestorageFile = (file: UploadFile):Promise<UploadResult> => { \n\n if (!storageMap || storageMap.size === 0) {\n throw new Error(\"No storage is configured\");\n } \n\n // get storage\n const {storageName, referenceKey, subFolderName, fileName} = file;\n const storageConf = storageMap.get(storageName || DEFAULT_STORAGE);\n if (!storageConf ) {\n throw new Error(`Invalid storage name: ${storageName || DEFAULT_STORAGE}`);\n } \n if (!storageConf.references || storageConf.references.length === 0) {\n throw new Error(`No references configured for storage: ${storageName || DEFAULT_STORAGE}`);\n }\n\n // get reference to path\n const uploadRefConf = referenceKey ? (storageConf.references.filter(filterRef => filterRef.key === referenceKey)[0]) : storageConf.references[0];\n if (!uploadRefConf || !uploadRefConf.storageRef) {\n throw new Error(`No valid reference for key: ${referenceKey}`);\n }\n\n // create file reference and upload\n const fileRef = ref(uploadRefConf.storageRef, subFolderName ? `${subFolderName}/${fileName}` : fileName);\n\n // default usefull metadata: contentType, size, timeCreated, updated\n\n // additional custom metadata\n const metadata = {\n customMetadata: {\n 'creator': (getUser() as any)?.displayName,\n 'comment': file.description,\n 'name': file.descriptionName,\n }\n };\n \n return uploadString(fileRef, file.base64DataURL, 'data_url', metadata);\n};\n\nexport const getFirestorageFileList = (\n storageName: string, \n refKey: string, \n subFolder?: string,\n includeMetaData?: boolean\n):Promise<StorageDocument[]> => { \n\n if (!storageMap || storageMap.size === 0) {\n throw new Error(\"No storage is configured\");\n }\n\n // get storage \n const storageConf = storageMap.get(storageName);\n if (!storageConf ) {\n throw new Error(`Invalid storage name: ${storageName}`);\n } \n if (!storageConf.references || storageConf.references.length === 0) {\n throw new Error(`No references configured for storage: ${storageName || DEFAULT_STORAGE}`);\n }\n\n // get refrence\n const storageRef = storageConf.references.filter(refIt => refIt.key === refKey)[0];\n if (!storageRef) {\n throw new Error(`No reference available for storage: ${storageName || DEFAULT_STORAGE} and ref: ${refKey}`);\n }\n\n const usedRef = subFolder ? ref(storageRef.storageRef, subFolder) : storageRef.storageRef; \n const itemRefs: StorageDocument[] = [];\n return listAll(usedRef)\n .then((res) => {\n \n const metaPromises:Promise<FullMetadata>[] = [];\n res.items.forEach((itemRef) => { \n // All the items under listRef .\n itemRefs.push({\n fileName: itemRef.name,\n filePath: itemRef.fullPath,\n });\n\n // MetaData for each item with own promise\n if (includeMetaData) {\n metaPromises.push(getMetadata(itemRef)); \n }\n });\n\n if (includeMetaData) {\n return Promise.all(metaPromises)\n .then(metaResults => itemRefs.map((item: StorageDocument, index: number) => (\n {\n ...item,\n creation: new Date(metaResults[index]?.timeCreated),\n documentType: metaResults[index]?.contentType, \n creator: metaResults[index]?.customMetadata?.creator,\n descriptionName: metaResults[index]?.customMetadata?.name,\n description: metaResults[index]?.customMetadata?.comment,\n size: metaResults[index]?.size,\n metaData: metaResults[index]\n }\n )));\n }\n return itemRefs;\n }).catch((error) => {\n // TODO: add error handling\n console.log(\"Error during file list\", error);\n throw error;\n });\n\n};\n\n\n/* Firestorage Error List: https://firebase.google.com/docs/storage/web/handle-errors */\n/* \nstorage/unknown\tAn unknown error occurred.\nstorage/object-not-found\tNo object exists at the desired reference.\nstorage/bucket-not-found\tNo bucket is configured for Cloud Storage\nstorage/project-not-found\tNo project is configured for Cloud Storage\nstorage/quota-exceeded\tQuota on your Cloud Storage bucket has been exceeded. If you're on the no-cost tier, upgrade to a paid plan. If you're on a paid plan, reach out to Firebase support.\nstorage/unauthenticated\tUser is unauthenticated, please authenticate and try again.\nstorage/unauthorized\tUser is not authorized to perform the desired action, check your security rules to ensure they are correct.\nstorage/retry-limit-exceeded\tThe maximum time limit on an operation (upload, download, delete, etc.) has been excceded. Try uploading again.\nstorage/invalid-checksum\tFile on the client does not match the checksum of the file received by the server. Try uploading again.\nstorage/canceled\tUser canceled the operation.\nstorage/invalid-event-name\tInvalid event name provided. Must be one of [`running`, `progress`, `pause`]\nstorage/invalid-url\tInvalid URL provided to refFromURL(). Must be of the form: gs://bucket/object or https://firebasestorage.googleapis.com/v0/b/bucket/o/object?token=<TOKEN>\nstorage/invalid-argument\tThe argument passed to put() must be `File`, `Blob`, or `UInt8` Array. The argument passed to putString() must be a raw, `Base64`, or `Base64URL` string.\nstorage/no-default-bucket\tNo bucket has been set in your config's storageBucket property.\nstorage/cannot-slice-blob\tCommonly occurs when the local file has changed (deleted, saved again, etc.). Try uploading again after verifying that the file hasn't changed.\nstorage/server-file-wrong-size\n*/"]}
|
|
1
|
+
{"version":3,"file":"firestorage-client.js","sourceRoot":"","sources":["../../../../src/service-provider/firebase/firestorage-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAiE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGtK,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,MAAM,eAAe,GAAG,iBAAi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import { FirebaseStorage, FullMetadata, StorageReference, UploadResult, getDownloadURL, getMetadata, getStorage, listAll, ref, uploadString } from \"firebase/storage\";\n\nimport { FileStorageConfig, StorageDocument, UploadFile } from '../service-provider-model.js';\nimport { getUser } from '../service-provider-impl.js';\n\nconst DEFAULT_STORAGE = \"default_storage\";\n\nconst storageMap:Map<string, { \n storage: FirebaseStorage,\n references?: {\n key: string,\n storageRef: StorageReference\n }[],\n}> = new Map();\n\n/**\n * During start/load application, initialize functions.\n *\n * @param {*} app - initialized app.\n */\nexport const initFirestorage = (app: FirebaseApp, defaultStorage?: string, storageConfig?: FileStorageConfig) => {\n try {\n\n // add default storage\n if (defaultStorage) {\n storageMap.set(DEFAULT_STORAGE, {\n storage: getStorage(app)\n });\n } \n \n // add specific storages\n storageConfig?.storage.forEach(storeConfig => {\n\n const storage = getStorage(app, storeConfig.name);\n const storageRootRef = ref(storage);\n\n storageMap.set(storeConfig.name, {\n storage,\n references: [\n {\n key: \"ROOT\",\n storageRef: storageRootRef\n },\n ...storeConfig.references.map(refConfigString => ({\n key: refConfigString,\n storageRef: ref(storageRootRef, refConfigString)\n }))\n ]\n });\n }); \n\n } catch (error) {\n console.error(error);\n }\n};\n\nexport const uploadFirestorageFile = (file: UploadFile):Promise<UploadResult> => { \n\n if (!storageMap || storageMap.size === 0) {\n throw new Error(\"No storage is configured\");\n } \n\n // get storage\n const {storageName, referenceKey, subFolderName, fileName} = file;\n const storageConf = storageMap.get(storageName || DEFAULT_STORAGE);\n if (!storageConf ) {\n throw new Error(`Invalid storage name: ${storageName || DEFAULT_STORAGE}`);\n } \n if (!storageConf.references || storageConf.references.length === 0) {\n throw new Error(`No references configured for storage: ${storageName || DEFAULT_STORAGE}`);\n }\n\n // get reference to path\n const uploadRefConf = referenceKey ? (storageConf.references.filter(filterRef => filterRef.key === referenceKey)[0]) : storageConf.references[0];\n if (!uploadRefConf || !uploadRefConf.storageRef) {\n throw new Error(`No valid reference for key: ${referenceKey}`);\n }\n\n // create file reference and upload\n const fileRef = ref(uploadRefConf.storageRef, subFolderName ? `${subFolderName}/${fileName}` : fileName);\n\n // default usefull metadata: contentType, size, timeCreated, updated\n\n // additional custom metadata\n const metadata = {\n customMetadata: {\n 'creator': (getUser() as any)?.displayName,\n 'comment': file.description,\n 'name': file.descriptionName,\n }\n };\n \n return uploadString(fileRef, file.base64DataURL, 'data_url', metadata);\n};\n\nexport const getFirestorageFileList = (\n storageName: string, \n refKey: string, \n subFolder?: string,\n includeMetaData?: boolean\n):Promise<StorageDocument[]> => { \n\n if (!storageMap || storageMap.size === 0) {\n throw new Error(\"No storage is configured\");\n }\n\n // get storage \n const storageConf = storageMap.get(storageName);\n if (!storageConf ) {\n throw new Error(`Invalid storage name: ${storageName}`);\n } \n if (!storageConf.references || storageConf.references.length === 0) {\n throw new Error(`No references configured for storage: ${storageName || DEFAULT_STORAGE}`);\n }\n\n // get refrence\n const storageRef = storageConf.references.filter(refIt => refIt.key === refKey)[0];\n if (!storageRef) {\n throw new Error(`No reference available for storage: ${storageName || DEFAULT_STORAGE} and ref: ${refKey}`);\n }\n\n const usedRef = subFolder ? ref(storageRef.storageRef, subFolder) : storageRef.storageRef; \n const itemRefs: StorageDocument[] = [];\n return listAll(usedRef)\n .then((res) => {\n \n const metaPromises:Promise<FullMetadata>[] = [];\n res.items.forEach((itemRef) => { \n // All the items under listRef .\n itemRefs.push({\n fileName: itemRef.name,\n filePath: itemRef.fullPath,\n storageName, refKey\n });\n\n // MetaData for each item with own promise\n if (includeMetaData) {\n metaPromises.push(getMetadata(itemRef)); \n }\n });\n\n if (includeMetaData) {\n return Promise.all(metaPromises)\n .then(metaResults => itemRefs.map((item: StorageDocument, index: number) => (\n {\n ...item,\n creation: new Date(metaResults[index]?.timeCreated),\n documentType: metaResults[index]?.contentType, \n creator: metaResults[index]?.customMetadata?.creator,\n descriptionName: metaResults[index]?.customMetadata?.name,\n description: metaResults[index]?.customMetadata?.comment,\n size: metaResults[index]?.size,\n metaData: metaResults[index]\n }\n )));\n }\n return itemRefs;\n }).catch((error) => {\n // TODO: add error handling\n console.log(\"Error during file list\", error);\n throw error;\n });\n\n};\n\nexport const downloadFileFirestorage = (file: StorageDocument) => {\n\n if (!storageMap || storageMap.size === 0) {\n throw new Error(\"No storage is configured\");\n }\n\n // get storage \n const storageConf = storageMap.get(file.storageName);\n if (!storageConf ) {\n throw new Error(`Invalid storage name: ${file.storageName}`);\n } \n if (!storageConf.references || storageConf.references.length === 0) {\n throw new Error(`No references configured for storage: ${file.storageName}`);\n }\n\n // get refrence\n const storageRef = storageConf.references.filter(refIt => refIt.key === file.refKey)[0];\n if (!storageRef) {\n throw new Error(`No reference available for storage: ${file.storageName} and ref: ${file.refKey}`);\n }\n const usedRef = ref(storageRef.storageRef, file.filePath);\n return getDownloadURL(usedRef);\n}\n\n\n/* Firestorage Error List: https://firebase.google.com/docs/storage/web/handle-errors */\n/* \nstorage/unknown\tAn unknown error occurred.\nstorage/object-not-found\tNo object exists at the desired reference.\nstorage/bucket-not-found\tNo bucket is configured for Cloud Storage\nstorage/project-not-found\tNo project is configured for Cloud Storage\nstorage/quota-exceeded\tQuota on your Cloud Storage bucket has been exceeded. If you're on the no-cost tier, upgrade to a paid plan. If you're on a paid plan, reach out to Firebase support.\nstorage/unauthenticated\tUser is unauthenticated, please authenticate and try again.\nstorage/unauthorized\tUser is not authorized to perform the desired action, check your security rules to ensure they are correct.\nstorage/retry-limit-exceeded\tThe maximum time limit on an operation (upload, download, delete, etc.) has been excceded. Try uploading again.\nstorage/invalid-checksum\tFile on the client does not match the checksum of the file received by the server. Try uploading again.\nstorage/canceled\tUser canceled the operation.\nstorage/invalid-event-name\tInvalid event name provided. Must be one of [`running`, `progress`, `pause`]\nstorage/invalid-url\tInvalid URL provided to refFromURL(). Must be of the form: gs://bucket/object or https://firebasestorage.googleapis.com/v0/b/bucket/o/object?token=<TOKEN>\nstorage/invalid-argument\tThe argument passed to put() must be `File`, `Blob`, or `UInt8` Array. The argument passed to putString() must be a raw, `Base64`, or `Base64URL` string.\nstorage/no-default-bucket\tNo bucket has been set in your config's storageBucket property.\nstorage/cannot-slice-blob\tCommonly occurs when the local file has changed (deleted, saved again, etc.). Try uploading again after verifying that the file hasn't changed.\nstorage/server-file-wrong-size\n*/"]}
|
|
@@ -6,4 +6,5 @@ import { FileStorageConfig, StorageDocument, UploadFile } from '../service-provi
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const initStorageMock: (defaultStorage?: string, storageConfig?: FileStorageConfig) => void;
|
|
8
8
|
export declare const uploadStorageFileMock: (file: UploadFile) => Promise<any>;
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const downloadFileMock: (file: StorageDocument) => Promise<string>;
|
|
10
|
+
export declare const getMockFileList: (storageName: string, refKey: string, subFolder?: string, includeMetadata?: boolean) => Promise<StorageDocument[]>;
|
|
@@ -88,12 +88,17 @@ export const uploadStorageFileMock = (file) => {
|
|
|
88
88
|
const fileRef = `${uploadRefConf.storageRef}/${subFolderName ? `${subFolderName}/${fileName}` : fileName}`;
|
|
89
89
|
return storageConf.storage.uploadFile(fileRef, file);
|
|
90
90
|
};
|
|
91
|
-
export const
|
|
92
|
-
|
|
91
|
+
export const downloadFileMock = (file) => {
|
|
92
|
+
alert("Not implemented for mock");
|
|
93
|
+
return Promise.resolve("");
|
|
94
|
+
};
|
|
95
|
+
export const getMockFileList = (storageName, refKey, subFolder, includeMetadata) => {
|
|
96
|
+
console.log("Searching for Documents in ", storageName, refKey, subFolder, includeMetadata);
|
|
93
97
|
return Promise.resolve([{
|
|
94
98
|
fileName: "workReport.png",
|
|
95
99
|
filePath: "workReports/1234234f2fswf/workReport.png",
|
|
96
100
|
documentType: "ToDo",
|
|
101
|
+
storageName, refKey
|
|
97
102
|
}]);
|
|
98
103
|
};
|
|
99
104
|
//# sourceMappingURL=storage-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-client.js","sourceRoot":"","sources":["../../../../src/service-provider/mock/storage-client.ts"],"names":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;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAqB,EAAE,EAAE;IACxD,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAClC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC7B,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,WAAmB,EACnB,MAAc,EACd,SAAkB,EAClB,eAAyB,EACE,EAAE;IAC7B,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;IAC5F,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;YACtB,QAAQ,EAAE,gBAAgB;YAC1B,QAAQ,EAAE,0CAA0C;YACpD,YAAY,EAAE,MAAM;YACpB,WAAW,EAAE,MAAM;SACpB,CAAC,CAAC,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { FileStorageConfig, StorageDocument, UploadFile } from '../service-provider-model.js';\n\n\nconst DEFAULT_STORAGE = \"default_storage\";\n\n\n// Download file in mock implementation\nconst downloadFile = (buffer: ArrayBuffer) => {\n const data: Blob = new Blob([buffer], {\n type: 'image/png'\n });\n const url= window.URL.createObjectURL(data);\n window.open(url);\n}\n\nconst base64ToArrayBuffer = (base64:string) => {\n const test = base64.replace(\"data:image/png;base64,\", \"\");\n const binaryString = atob(test);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i+=1) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n return bytes.buffer;\n}\n\n\n\n\nclass MockStorage {\n\n private _name: string;\n\n constructor(storageName: string) {\n this._name = storageName;\n }\n\n // eslint-disable-next-line class-methods-use-this\n uploadFile(filePath: string, file: UploadFile): Promise<any> {\n \n downloadFile(base64ToArrayBuffer(file.base64DataURL));\n\n return Promise.resolve({\n fullPath: filePath\n });\n }\n\n}\n\nconst storageMap:Map<string, { \n storage: MockStorage,\n references?: {\n key: string,\n storageRef: string\n }[],\n}> = new Map();\n\n/**\n * During start/load application, initialize functions.\n *\n * @param {*} app - initialized app.\n */\nexport const initStorageMock = (defaultStorage?: string, storageConfig?: FileStorageConfig) => {\n console.log(\"Init mock Storage\");\n try {\n\n // add default storage\n if (defaultStorage) {\n storageMap.set(DEFAULT_STORAGE, {\n storage: new MockStorage(DEFAULT_STORAGE)\n });\n } \n \n // add specific storages\n storageConfig?.storage.forEach(storeConfig => {\n\n const storage = new MockStorage(storeConfig.name);\n const storageRootRef = \"/\";\n\n storageMap.set(storeConfig.name, {\n storage,\n references: [\n {\n key: \"ROOT\",\n storageRef: storageRootRef\n },\n ...storeConfig.references.map(refConfigString => ({\n key: refConfigString,\n storageRef: `${storageRootRef}/${refConfigString}`\n }))\n ]\n });\n }); \n\n } catch (error) {\n console.error(error);\n }\n};\n\n\nexport const uploadStorageFileMock = (file: UploadFile):Promise<any> => { \n\n if (!storageMap || storageMap.size === 0) {\n throw new Error(\"No storage is configured\");\n } \n\n // get storage\n const {storageName, referenceKey, subFolderName, fileName} = file;\n const storageConf = storageMap.get(storageName || DEFAULT_STORAGE);\n if (!storageConf ) {\n throw new Error(`Invalid storage name: ${storageName || DEFAULT_STORAGE}`);\n } \n if (!storageConf.references || storageConf.references.length === 0) {\n throw new Error(`No references configured for storage: ${storageName || DEFAULT_STORAGE}`);\n }\n\n // get reference to path\n const uploadRefConf = referenceKey ? (storageConf.references.filter(filterRef => filterRef.key === referenceKey)[0]) : storageConf.references[0];\n if (!uploadRefConf || !uploadRefConf.storageRef) {\n throw new Error(`No valid reference for key: ${referenceKey}`);\n }\n\n // create file reference and upload\n const fileRef = `${uploadRefConf.storageRef}/${subFolderName ? `${subFolderName}/${fileName}` : fileName}`; \n return storageConf.storage.uploadFile(fileRef, file);\n};\n\nexport const downloadFileMock = (file: StorageDocument) => {\n alert(\"Not implemented for mock\");\n return Promise.resolve(\"\");\n}\n\nexport const getMockFileList = (\n storageName: string, \n refKey: string,\n subFolder?: string,\n includeMetadata?: boolean\n):Promise<StorageDocument[]> => {\n console.log(\"Searching for Documents in \", storageName, refKey, subFolder, includeMetadata);\n return Promise.resolve([{\n fileName: \"workReport.png\",\n filePath: \"workReports/1234234f2fswf/workReport.png\",\n documentType: \"ToDo\",\n storageName, refKey\n }]);\n};\n\n\n\n\n"]}
|
|
@@ -11,3 +11,4 @@ export declare const logoutImpl: () => Promise<boolean>;
|
|
|
11
11
|
export declare const getUser: () => unknown;
|
|
12
12
|
export declare const uploadFile: (file: UploadFile) => Promise<unknown>;
|
|
13
13
|
export declare const getStorageFileList: (storageName: string, keyRef: string, subFolder?: string, includeMetadata?: boolean) => Promise<StorageDocument[]>;
|
|
14
|
+
export declare const downloadFile: (file: StorageDocument) => Promise<unknown>;
|
|
@@ -4,8 +4,8 @@ import { authStateChangedMock, getAuthUserMock, isAuthenticatedMock, loginMock,
|
|
|
4
4
|
import { callFunction, initFunctions } from "./firebase/functions-client.js";
|
|
5
5
|
import { initFirestore } from "./firebase/firestore-client.js";
|
|
6
6
|
import { callFunctionMock, initMockResponse } from "./mock/function-client.js";
|
|
7
|
-
import { getFirestorageFileList, initFirestorage, uploadFirestorageFile } from "./firebase/firestorage-client.js";
|
|
8
|
-
import { getMockFileList, initStorageMock, uploadStorageFileMock } from "./mock/storage-client.js";
|
|
7
|
+
import { downloadFileFirestorage, getFirestorageFileList, initFirestorage, uploadFirestorageFile } from "./firebase/firestorage-client.js";
|
|
8
|
+
import { downloadFileMock, getMockFileList, initStorageMock, uploadStorageFileMock } from "./mock/storage-client.js";
|
|
9
9
|
let provider;
|
|
10
10
|
let controller;
|
|
11
11
|
const throwUndefinedProviderError = () => {
|
|
@@ -145,4 +145,13 @@ export const getStorageFileList = (storageName, keyRef, subFolder, includeMetada
|
|
|
145
145
|
}
|
|
146
146
|
return throwUndefinedProviderError();
|
|
147
147
|
};
|
|
148
|
+
export const downloadFile = (file) => {
|
|
149
|
+
if (provider === "firebase") {
|
|
150
|
+
return downloadFileFirestorage(file);
|
|
151
|
+
}
|
|
152
|
+
if (provider === "mock") {
|
|
153
|
+
return downloadFileMock(file);
|
|
154
|
+
}
|
|
155
|
+
return throwUndefinedProviderError();
|
|
156
|
+
};
|
|
148
157
|
//# sourceMappingURL=service-provider-impl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-provider-impl.js","sourceRoot":"","sources":["../../../src/service-provider/service-provider-impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,aAAa,EAAE,MAAM,cAAc,CAAC;AAE3E,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC7G,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,mBAAmB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEnH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE/E,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEnG,IAAI,QAAkD,CAAC;AACvD,IAAI,UAAiC,CAAC;AAEtC,MAAM,2BAA2B,GAAG,GAAG,EAAE;IACvC,MAAM,IAAI,KAAK,CAAC,4FAA4F,CAAC,CAAC;AAChH,CAAC,CAAA;AAED;;2BAE2B;AAE3B,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,aAA4C,EAAE,EAAE;IACjF,QAAQ,GAAG,aAAa,CAAC;AAC3B,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,eAAsC,EAAE,EAAE;IACvE,U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B,EACnB,MAAc,EACd,SAAkB,EAClB,eAAwB,EACI,EAAE;IAC9B,IAAI,QAAQ,KAAK,UAAU,EAAE;QAC3B,OAAO,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;KAChF;IACD,IAAI,QAAQ,KAAK,MAAM,EAAE;QACvB,OAAO,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;KACzE;IACD,OAAO,2BAA2B,EAAE,CAAC;AACvC,CAAC,CAAA","sourcesContent":["import { FirebaseApp, FirebaseOptions, initializeApp } from \"firebase/app\";\n\nimport { authStateChanged, getAuthUser, initAuth, isAuthenticated, login, logout } from \"./firebase/auth.js\";\nimport { authStateChangedMock, getAuthUserMock, isAuthenticatedMock, loginMock, logoutMock } from \"./mock/auth.js\";\nimport { AppConfiguration, FileStorageConfig, FunctionDefinition, FunctionResult, FunctionsConfig, ServiceProviderConfiguration, StorageDocument, UploadFile } from \"./service-provider-model.js\";\nimport { callFunction, initFunctions } from \"./firebase/functions-client.js\";\nimport { initFirestore } from \"./firebase/firestore-client.js\";\nimport { callFunctionMock, initMockResponse } from \"./mock/function-client.js\";\nimport { ServiceCallController } from \"../service-call-controller2.js\";\nimport { getFirestorageFileList, initFirestorage, uploadFirestorageFile } from \"./firebase/firestorage-client.js\";\nimport { getMockFileList, initStorageMock, uploadStorageFileMock } from \"./mock/storage-client.js\";\n\nlet provider: ServiceProviderConfiguration | undefined;\nlet controller: ServiceCallController;\n\nconst throwUndefinedProviderError = () => {\n throw new Error(\"Undefined service provider, please check configuration. 'firebase' or 'mock' allowed here.\");\n}\n\n/* #####################\n * Init Implementation\n * ##################### */\n\nexport const setServiceProvider = (providerParam?: ServiceProviderConfiguration) => {\n provider = providerParam;\n}\n\nexport const initController = (controllerParam: ServiceCallController) => {\n controller = controllerParam\n}\n\nconst initFirebaseApplicationServices = (\n firebaseApp: FirebaseApp, \n functionsConfig: FunctionsConfig, \n firebaseConfig: FirebaseOptions,\n storageConfig?: FileStorageConfig, \n) => {\n // do something with the app, init db, firestore and functions \n initAuth(firebaseApp);\n initFunctions(firebaseApp, functionsConfig);\n initFirestore(firebaseApp); \n initFirestorage(firebaseApp, firebaseConfig.storageBucket, storageConfig);\n\n console.log(\"Firebase App with functions, firestore and firestorage initialized\"); \n}\n\nexport const initAppImpl = (config: AppConfiguration) => {\n\n if (provider === \"firebase\" && config.firebaseConfig) {\n const app:FirebaseApp = initializeApp(config.firebaseConfig);\n if (config.functionsConfig) { // TODO: invalid if only storage config exists\n // init application services (functions, store) \n initFirebaseApplicationServices(app, config.functionsConfig, config.firebaseConfig, config.storageConfig);\n }\n } else if (provider === \"mock\") {\n initMockResponse(config.mock);\n initStorageMock(\"default\", config.storageConfig);\n } else {\n throwUndefinedProviderError();\n }\n}\n\n/* #####################\n * Functions Implementation\n * ##################### */\nexport const callFunctionImpl = async (def: FunctionDefinition, functionInput: any): Promise<FunctionResult> => {\n \n const callController = (promise: Promise<any>) => {\n if (controller) {\n controller.callDataPromise = {func: def, promise};\n }\n }\n \n if (provider === \"firebase\") {\n const promise = callFunction(def, functionInput)\n callController(promise);\n return promise;\n } \n if (provider === \"mock\") {\n const promise = callFunctionMock(def, functionInput)\n callController(promise);\n return promise;\n }\n\n return throwUndefinedProviderError(); \n}\n\n\n\n/* #####################\n * Auth Implementation\n * ##################### */\n\n\nexport const authStateChangedImpl = (\n callback: Function\n) => {\n if (provider === \"firebase\") {\n authStateChanged(callback);\n } else if (provider === \"mock\") {\n authStateChangedMock(callback);\n } else {\n throwUndefinedProviderError();\n }\n}\n\nexport const isAuthenticatedImpl = () => {\n if (provider === \"firebase\") {\n return isAuthenticated();\n } \n if (provider === \"mock\") {\n return isAuthenticatedMock();\n } \n return throwUndefinedProviderError(); \n}\n\nexport const loginImpl = (user: string, sec: string) => {\n\n if (!user) { \n const returnError = new Error(\"empty user\");\n return Promise.reject(returnError);\n }\n if (!sec) {\n const returnError = new Error(\"empty password\");\n return Promise.reject(returnError);\n }\n\n if (provider === \"firebase\") {\n return login(user, sec);\n } \n if (provider === \"mock\") {\n return loginMock(user, sec);\n } \n return throwUndefinedProviderError(); \n}\n\nexport const logoutImpl = () => {\n if (provider === \"firebase\") {\n return logout();\n } \n if (provider === \"mock\") {\n return logoutMock();\n } \n return throwUndefinedProviderError(); \n};\n\n// Refactor: Return defined USer Object\nexport const getUser = () => {\n if (provider === \"firebase\") {\n return getAuthUser();\n } \n if (provider === \"mock\") {\n return getAuthUserMock();\n } \n return throwUndefinedProviderError(); \n}\n\n/* #####################\n * Storage Implementation\n * ##################### */\nexport const uploadFile = (file: UploadFile): Promise<unknown> => { \n if (provider === \"firebase\") {\n return uploadFirestorageFile(file); \n } \n if (provider === \"mock\") {\n return uploadStorageFileMock(file)\n }\n return throwUndefinedProviderError(); \n}\n\nexport const getStorageFileList = (\n storageName: string, \n keyRef: string, \n subFolder?: string, \n includeMetadata?:boolean\n): Promise<StorageDocument[]> => { \n if (provider === \"firebase\") {\n return getFirestorageFileList(storageName, keyRef, subFolder, includeMetadata);\n }\n if (provider === \"mock\") {\n return getMockFileList(storageName, keyRef, subFolder, includeMetadata);\n }\n return throwUndefinedProviderError(); \n}"]}
|
|
1
|
+
{"version":3,"file":"service-provider-impl.js","sourceRoot":"","sources":["../../../src/service-provider/service-provider-impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,aAAa,EAAE,MAAM,cAAc,CAAC;AAE3E,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC7G,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,mBAAmB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAKnH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAg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AAC;AACvC,CAAC,CAAA","sourcesContent":["import { FirebaseApp, FirebaseOptions, initializeApp } from \"firebase/app\";\n\nimport { authStateChanged, getAuthUser, initAuth, isAuthenticated, login, logout } from \"./firebase/auth.js\";\nimport { authStateChangedMock, getAuthUserMock, isAuthenticatedMock, loginMock, logoutMock } from \"./mock/auth.js\";\nimport { \n AppConfiguration, FileStorageConfig, FunctionDefinition, FunctionResult, \n FunctionsConfig, ServiceProviderConfiguration, StorageDocument, UploadFile \n} from \"./service-provider-model.js\";\nimport { callFunction, initFunctions } from \"./firebase/functions-client.js\";\nimport { initFirestore } from \"./firebase/firestore-client.js\";\nimport { callFunctionMock, initMockResponse } from \"./mock/function-client.js\";\nimport { ServiceCallController } from \"../service-call-controller2.js\";\nimport { downloadFileFirestorage, getFirestorageFileList, initFirestorage, uploadFirestorageFile } from \"./firebase/firestorage-client.js\";\nimport { downloadFileMock, getMockFileList, initStorageMock, uploadStorageFileMock } from \"./mock/storage-client.js\";\n\nlet provider: ServiceProviderConfiguration | undefined;\nlet controller: ServiceCallController;\n\nconst throwUndefinedProviderError = () => {\n throw new Error(\"Undefined service provider, please check configuration. 'firebase' or 'mock' allowed here.\");\n}\n\n/* #####################\n * Init Implementation\n * ##################### */\n\nexport const setServiceProvider = (providerParam?: ServiceProviderConfiguration) => {\n provider = providerParam;\n}\n\nexport const initController = (controllerParam: ServiceCallController) => {\n controller = controllerParam\n}\n\nconst initFirebaseApplicationServices = (\n firebaseApp: FirebaseApp, \n functionsConfig: FunctionsConfig, \n firebaseConfig: FirebaseOptions,\n storageConfig?: FileStorageConfig, \n) => {\n // do something with the app, init db, firestore and functions \n initAuth(firebaseApp);\n initFunctions(firebaseApp, functionsConfig);\n initFirestore(firebaseApp); \n initFirestorage(firebaseApp, firebaseConfig.storageBucket, storageConfig);\n\n console.log(\"Firebase App with functions, firestore and firestorage initialized\"); \n}\n\nexport const initAppImpl = (config: AppConfiguration) => {\n\n if (provider === \"firebase\" && config.firebaseConfig) {\n const app:FirebaseApp = initializeApp(config.firebaseConfig);\n if (config.functionsConfig) { // TODO: invalid if only storage config exists\n // init application services (functions, store) \n initFirebaseApplicationServices(app, config.functionsConfig, config.firebaseConfig, config.storageConfig);\n }\n } else if (provider === \"mock\") {\n initMockResponse(config.mock);\n initStorageMock(\"default\", config.storageConfig);\n } else {\n throwUndefinedProviderError();\n }\n}\n\n/* #####################\n * Functions Implementation\n * ##################### */\nexport const callFunctionImpl = async (def: FunctionDefinition, functionInput: any): Promise<FunctionResult> => {\n \n const callController = (promise: Promise<any>) => {\n if (controller) {\n controller.callDataPromise = {func: def, promise};\n }\n }\n \n if (provider === \"firebase\") {\n const promise = callFunction(def, functionInput)\n callController(promise);\n return promise;\n } \n if (provider === \"mock\") {\n const promise = callFunctionMock(def, functionInput)\n callController(promise);\n return promise;\n }\n\n return throwUndefinedProviderError(); \n}\n\n\n\n/* #####################\n * Auth Implementation\n * ##################### */\n\n\nexport const authStateChangedImpl = (\n callback: Function\n) => {\n if (provider === \"firebase\") {\n authStateChanged(callback);\n } else if (provider === \"mock\") {\n authStateChangedMock(callback);\n } else {\n throwUndefinedProviderError();\n }\n}\n\nexport const isAuthenticatedImpl = () => {\n if (provider === \"firebase\") {\n return isAuthenticated();\n } \n if (provider === \"mock\") {\n return isAuthenticatedMock();\n } \n return throwUndefinedProviderError(); \n}\n\nexport const loginImpl = (user: string, sec: string) => {\n\n if (!user) { \n const returnError = new Error(\"empty user\");\n return Promise.reject(returnError);\n }\n if (!sec) {\n const returnError = new Error(\"empty password\");\n return Promise.reject(returnError);\n }\n\n if (provider === \"firebase\") {\n return login(user, sec);\n } \n if (provider === \"mock\") {\n return loginMock(user, sec);\n } \n return throwUndefinedProviderError(); \n}\n\nexport const logoutImpl = () => {\n if (provider === \"firebase\") {\n return logout();\n } \n if (provider === \"mock\") {\n return logoutMock();\n } \n return throwUndefinedProviderError(); \n};\n\n// Refactor: Return defined USer Object\nexport const getUser = () => {\n if (provider === \"firebase\") {\n return getAuthUser();\n } \n if (provider === \"mock\") {\n return getAuthUserMock();\n } \n return throwUndefinedProviderError(); \n}\n\n/* #####################\n * Storage Implementation\n * ##################### */\nexport const uploadFile = (file: UploadFile): Promise<unknown> => { \n if (provider === \"firebase\") {\n return uploadFirestorageFile(file); \n } \n if (provider === \"mock\") {\n return uploadStorageFileMock(file)\n }\n return throwUndefinedProviderError(); \n}\n\nexport const getStorageFileList = (\n storageName: string, \n keyRef: string, \n subFolder?: string, \n includeMetadata?:boolean\n): Promise<StorageDocument[]> => { \n if (provider === \"firebase\") {\n return getFirestorageFileList(storageName, keyRef, subFolder, includeMetadata);\n }\n if (provider === \"mock\") {\n return getMockFileList(storageName, keyRef, subFolder, includeMetadata);\n }\n return throwUndefinedProviderError(); \n}\n\nexport const downloadFile = (file: StorageDocument): Promise<unknown> => { \n if (provider === \"firebase\") {\n return downloadFileFirestorage(file);\n } \n if (provider === \"mock\") {\n return downloadFileMock(file)\n }\n return throwUndefinedProviderError(); \n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-provider-model.js","sourceRoot":"","sources":["../../../src/service-provider/service-provider-model.ts"],"names":[],"mappings":"","sourcesContent":["import { FirebaseOptions } from \"firebase/app\";\nimport { TemplateResult } from \"lit\";\n\n\n/**\n * Implemeted service provider\n */\nexport type ServiceProviderFirebase = \"firebase\";\nexport type ServiceProviderMock = \"mock\";\nexport type ServiceProviderConfiguration = ServiceProviderFirebase | ServiceProviderMock;\n\n\nexport interface FunctionResult {\n resultData: unknown,\n statusCode: number,\n}\n\n/**\n * Function model.\n */\n\nexport interface FunctionDefinition {\n name: string,\n successCodes: Array<Number>, \n // Fade window during function call (true) or show only background infos (false).\n fadeWindow: boolean,\n successTxt: string | TemplateResult,\n pendingTxt: string | TemplateResult,\n param?: any,\n redirect?: string,\n logoutOnFail?: boolean,\n}\n\nexport interface FunctionParam {\n func: FunctionDefinition,\n inputData: any,\n}\n\nexport interface FunctionsConfig {\n region: string, // 'europe-west3'\n functions: Array<FunctionDefinition>,\n postLoginFunc?: FunctionDefinition,\n}\n\n\n/**\n * App data models.\n */\n\nexport interface MenuElement {\n key: string,\n name: string,\n sec?: string,\n route?: string,\n action?: Function,\n topItem?: boolean,\n ref?: any,\n icon?: string,\n}\n\nexport interface NavigationPage {\n name: string,\n mainClass?: string,\n pattern: Array<string>, \n auth: boolean,\n menu?: Array<MenuElement>,\n topMenu?: Array<MenuElement>,\n withTeaser?: boolean,\n withFooter?: boolean\n hideMenu?: boolean\n hideTopMenu?: boolean\n topMenuItems?: Array<MenuElement>,\n}\n\nexport interface NavigationConfig {\n pages: Array<NavigationPage>,\n includeLogin: boolean\n}\n\nexport interface LinkObj {\n name: string,\n key: string,\n link?: string,\n action?: Function\n}\n\nexport interface Footer {\n version: string,\n links: Array<LinkObj>\n}\n\n\nexport interface StoreConfig {\n appName: string,\n reducer: any,\n effects: Array<any>\n}\n\nexport interface FileStorage {\n name: string,\n references: string[] \n}\n\nexport interface FileStorageConfig {\n storage: FileStorage[],\n}\n\nexport interface AppConfiguration { \n serviceProvider?: ServiceProviderConfiguration,\n mock?: {\n mockResponse?: Map<string, Function>,\n mockWaitTime?: number,\n }\n navigationConfigParam: NavigationConfig;\n storeConfigParam?: StoreConfig;\n firebaseConfig?: FirebaseOptions;\n storageConfig?: FileStorageConfig;\n functionsConfig?: FunctionsConfig;\n}\n\nexport interface UploadFile { \n fileName: string, \n base64DataURL:string,\n descriptionName:string,\n description:string,\n storageName: string\n referenceKey: string\n subFolderName?: string,\n}\n\nexport interface StorageMetadata {\n\n}\n\nexport interface StorageDocument {\n fileName: string, \n filePath: string,\n documentType?: string, \n description?:string, \n descriptionName?: string,\n creation?:Date,\n creator?:string,\n size?: number,\n metaData?: StorageMetadata\n}"]}
|
|
1
|
+
{"version":3,"file":"service-provider-model.js","sourceRoot":"","sources":["../../../src/service-provider/service-provider-model.ts"],"names":[],"mappings":"","sourcesContent":["import { FirebaseOptions } from \"firebase/app\";\nimport { TemplateResult } from \"lit\";\n\n\n/**\n * Implemeted service provider\n */\nexport type ServiceProviderFirebase = \"firebase\";\nexport type ServiceProviderMock = \"mock\";\nexport type ServiceProviderConfiguration = ServiceProviderFirebase | ServiceProviderMock;\n\n\nexport interface FunctionResult {\n resultData: unknown,\n statusCode: number,\n}\n\n/**\n * Function model.\n */\n\nexport interface FunctionDefinition {\n name: string,\n successCodes: Array<Number>, \n // Fade window during function call (true) or show only background infos (false).\n fadeWindow: boolean,\n successTxt: string | TemplateResult,\n pendingTxt: string | TemplateResult,\n param?: any,\n redirect?: string,\n logoutOnFail?: boolean,\n}\n\nexport interface FunctionParam {\n func: FunctionDefinition,\n inputData: any,\n}\n\nexport interface FunctionsConfig {\n region: string, // 'europe-west3'\n functions: Array<FunctionDefinition>,\n postLoginFunc?: FunctionDefinition,\n}\n\n\n/**\n * App data models.\n */\n\nexport interface MenuElement {\n key: string,\n name: string,\n sec?: string,\n route?: string,\n action?: Function,\n topItem?: boolean,\n ref?: any,\n icon?: string,\n}\n\nexport interface NavigationPage {\n name: string,\n mainClass?: string,\n pattern: Array<string>, \n auth: boolean,\n menu?: Array<MenuElement>,\n topMenu?: Array<MenuElement>,\n withTeaser?: boolean,\n withFooter?: boolean\n hideMenu?: boolean\n hideTopMenu?: boolean\n topMenuItems?: Array<MenuElement>,\n}\n\nexport interface NavigationConfig {\n pages: Array<NavigationPage>,\n includeLogin: boolean\n}\n\nexport interface LinkObj {\n name: string,\n key: string,\n link?: string,\n action?: Function\n}\n\nexport interface Footer {\n version: string,\n links: Array<LinkObj>\n}\n\n\nexport interface StoreConfig {\n appName: string,\n reducer: any,\n effects: Array<any>\n}\n\nexport interface FileStorage {\n name: string,\n references: string[] \n}\n\nexport interface FileStorageConfig {\n storage: FileStorage[],\n}\n\nexport interface AppConfiguration { \n serviceProvider?: ServiceProviderConfiguration,\n mock?: {\n mockResponse?: Map<string, Function>,\n mockWaitTime?: number,\n }\n navigationConfigParam: NavigationConfig;\n storeConfigParam?: StoreConfig;\n firebaseConfig?: FirebaseOptions;\n storageConfig?: FileStorageConfig;\n functionsConfig?: FunctionsConfig;\n}\n\nexport interface UploadFile { \n fileName: string, \n base64DataURL:string,\n descriptionName:string,\n description:string,\n storageName: string\n referenceKey: string\n subFolderName?: string,\n}\n\nexport interface StorageMetadata {\n\n}\n\nexport interface StorageDocument {\n storageName: string, \n refKey: string, \n fileName: string, \n filePath: string,\n documentType?: string, \n description?:string, \n descriptionName?: string,\n creation?:Date,\n creator?:string,\n size?: number,\n metaData?: StorageMetadata\n}"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createFeatureStateSelector, createSelector } from "mini-rx-store";
|
|
2
2
|
const getSpaAppFeatureState = createFeatureStateSelector('spaApp');
|
|
3
3
|
export const getLoadingSelector = createSelector(getSpaAppFeatureState, state => {
|
|
4
|
-
// filter add only the oldest for each typ
|
|
4
|
+
// filter add only the oldest for each typ (avoid overlapping loading boxes with different size)
|
|
5
5
|
const orderByCreation = [...state.loadingState].sort((a, b) => { var _a, _b; return (((_a = a.creation) === null || _a === void 0 ? void 0 : _a.getMilliseconds()) || 0) - (((_b = b.creation) === null || _b === void 0 ? void 0 : _b.getMilliseconds()) || 0); });
|
|
6
6
|
// filter modal
|
|
7
7
|
const loadings = [];
|
|
@@ -1 +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;IACN,
|
|
1
|
+
{"version":3,"file":"spa-app-selector.js","sourceRoot":"","sources":["../../../src/store/spa-app-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,cAAc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,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 => {\n // filter add only the oldest for each typ (avoid overlapping loading boxes with different size)\n const orderByCreation = [...state.loadingState].sort(\n (a, b) => (a.creation?.getMilliseconds() || 0) - (b.creation?.getMilliseconds() || 0)\n );\n\n // filter modal\n const loadings = [];\n const mainLoading = orderByCreation.filter(a => !a.smallBackground);\n if (mainLoading.length > 0) {\n loadings.push(mainLoading[0]);\n }\n const smallLoading = orderByCreation.filter(a => a.smallBackground);\n if (smallLoading.length > 0) {\n loadings.push(smallLoading[0]);\n }\n\n return loadings;\n }\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);"]}
|
|
@@ -123,4 +123,31 @@ export const ModalStateWithSubTasks = {
|
|
|
123
123
|
}
|
|
124
124
|
},
|
|
125
125
|
};
|
|
126
|
+
export const BackgroundWithSubTasks = {
|
|
127
|
+
args: {
|
|
128
|
+
loadingState: {
|
|
129
|
+
isLoading: true,
|
|
130
|
+
modal: false,
|
|
131
|
+
smallBackground: true,
|
|
132
|
+
loadingTxt: "Sammelaufgabe wird erledigt",
|
|
133
|
+
subTask: [
|
|
134
|
+
{
|
|
135
|
+
actionKey: "",
|
|
136
|
+
completed: true,
|
|
137
|
+
loadingTxt: "SubTask 1"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
actionKey: "",
|
|
141
|
+
completed: false,
|
|
142
|
+
loadingTxt: "SubTask 2"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
actionKey: "",
|
|
146
|
+
completed: false,
|
|
147
|
+
loadingTxt: "SubTask 3"
|
|
148
|
+
},
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
};
|
|
126
153
|
//# sourceMappingURL=pd-loading-state.stories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pd-loading-state.stories.js","sourceRoot":"","sources":["../../../src/stories/pd-loading-state.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAG3B,OAAO,+BAA+B,CAAC;AAGvC,8GAA8G;AAC9G,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,4BAA4B;IACnC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAA;;uBAED,IAAI,CAAC,YAAY;;;MAGlC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAA;;uBAEN;QACf,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,IAAI;QACX,SAAS,EAAE,EAAE;KACd;;OAEA,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;GAoBT;IACD,QAAQ,EAAE;QACR,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QACrC,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;QAC9B,IAAI,EAAE;YACJ,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC3B,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC;SACtC;KACF;CACa,CAAC;AAEjB,eAAe,IAAI,CAAC;AAIpB,uGAAuG;AACvG,MAAM,CAAC,MAAM,YAAY,GAAU;IACjC,IAAI,EAAE;QACJ,YAAY,EAAE;YACZ,SAAS,EAAE,IAAI;SAChB;KACF;CACF,CAAC;AAEF,MAAM,CAA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ryObj } from '@storybook/web-components';\n\nimport '../tmpown/pd-loading-state.js';\n\n\n// More on how to set up stories at: https://storybook.js.org/docs/web-components/writing-stories/introduction\nconst meta = {\n title: 'PD Components/LoadingState', \n render: (args) => html`\n <pd-loading-state\n .loadingState=\"${args.loadingState}\"\n ></pd-loading-state> \n\n ${args.doubleState ? html`\n <pd-loading-state\n .loadingState=\"${{\n isLoading: true,\n modal: true,\n actionKey: \"\"\n }}\"\n ></pd-loading-state> \n ` : ''} \n\n <p>\n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n </p>\n <p>\n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n </p>\n `,\n argTypes: {\n backgroundColor: { control: 'color' },\n onClick: { action: 'onClick' },\n size: {\n control: { type: 'select' },\n options: ['small', 'medium', 'large'],\n },\n },\n} satisfies Meta;\n\nexport default meta;\ntype Story = StoryObj;\n\n\n// More on writing stories with args: https://storybook.js.org/docs/web-components/writing-stories/args\nexport const NoModalState: Story = {\n args: {\n loadingState: {\n isLoading: true\n }\n },\n};\n\nexport const ModalState: Story = {\n args: {\n loadingState: {\n isLoading: true,\n modal: true\n }\n },\n};\n\nexport const CustomTxtState: Story = {\n args: {\n loadingState: {\n isLoading: true,\n loadingTxt: \"Hier steht was anderes...\"\n }\n },\n};\n\nexport const BackgroundState: Story = {\n args: {\n loadingState: {\n isLoading: true,\n smallBackground: true,\n }\n },\n};\n\nexport const ModalBackgroundState: Story = {\n args: {\n loadingState: {\n isLoading: true,\n smallBackground: true,\n modal: true,\n }\n },\n};\n\nexport const ModalWithBackgroundState: Story = {\n args: {\n loadingState: {\n isLoading: true,\n smallBackground: true, \n },\n doubleState: true\n },\n};\n\nexport const ModalStateWithSubTasks: Story = {\n args: {\n loadingState: {\n isLoading: true,\n modal: true,\n loadingTxt: \"Sammelaufgabe wird erledigt\",\n subTask: [\n {\n actionKey: \"\",\n completed: true,\n loadingTxt: \"SubTask 1\"\n },\n {\n actionKey: \"\",\n completed: false,\n loadingTxt: \"SubTask 2\"\n },\n {\n actionKey: \"\",\n completed: false,\n loadingTxt: \"SubTask 3\"\n },\n ]\n }\n },\n};\n\n"]}
|
|
1
|
+
{"version":3,"file":"pd-loading-state.stories.js","sourceRoot":"","sources":["../../../src/stories/pd-loading-state.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAG3B,OAAO,+BAA+B,CAAC;AAGvC,8GAA8G;AAC9G,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,4BAA4B;IACnC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAA;;uBAED,IAAI,CAAC,YAAY;;;MAGlC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAA;;uBAEN;QACf,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,IAAI;QACX,SAAS,EAAE,EAAE;KACd;;OAEA,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;GAoBT;IACD,QAAQ,EAAE;QACR,eAAe,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;QACrC,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;QAC9B,IAAI,EAAE;YACJ,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC3B,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC;SACtC;KACF;CACa,CAAC;AAEjB,eAAe,IAAI,CAAC;AAIpB,uGAAuG;AACvG,MAAM,CAAC,MAAM,YAAY,GAAU;IACjC,IAAI,EAAE;QACJ,YAAY,EAAE;YACZ,SAAS,EAAE,IAAI;SAChB;KACF;CACF,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AC,MAAM,sBAAsB,GAAU;IAC3C,IAAI,EAAE;QACJ,YAAY,EAAE;YACZ,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,KAAK;YACZ,eAAe,EAAE,IAAI;YACrB,UAAU,EAAE,6BAA6B;YACzC,OAAO,EAAE;gBACP;oBACE,SAAS,EAAE,EAAE;oBACb,SAAS,EAAE,IAAI;oBACf,UAAU,EAAE,WAAW;iBACxB;gBACD;oBACE,SAAS,EAAE,EAAE;oBACb,SAAS,EAAE,KAAK;oBAChB,UAAU,EAAE,WAAW;iBACxB;gBACD;oBACE,SAAS,EAAE,EAAE;oBACb,SAAS,EAAE,KAAK;oBAChB,UAAU,EAAE,WAAW;iBACxB;aACF;SACF;KACF;CACF,CAAC","sourcesContent":["import { html } from 'lit';\nimport type { Meta, StoryObj } from '@storybook/web-components';\n\nimport '../tmpown/pd-loading-state.js';\n\n\n// More on how to set up stories at: https://storybook.js.org/docs/web-components/writing-stories/introduction\nconst meta = {\n title: 'PD Components/LoadingState', \n render: (args) => html`\n <pd-loading-state\n .loadingState=\"${args.loadingState}\"\n ></pd-loading-state> \n\n ${args.doubleState ? html`\n <pd-loading-state\n .loadingState=\"${{\n isLoading: true,\n modal: true,\n actionKey: \"\"\n }}\"\n ></pd-loading-state> \n ` : ''} \n\n <p>\n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n </p>\n <p>\n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n Hier steht noch sonst was an text. \n </p>\n `,\n argTypes: {\n backgroundColor: { control: 'color' },\n onClick: { action: 'onClick' },\n size: {\n control: { type: 'select' },\n options: ['small', 'medium', 'large'],\n },\n },\n} satisfies Meta;\n\nexport default meta;\ntype Story = StoryObj;\n\n\n// More on writing stories with args: https://storybook.js.org/docs/web-components/writing-stories/args\nexport const NoModalState: Story = {\n args: {\n loadingState: {\n isLoading: true\n }\n },\n};\n\nexport const ModalState: Story = {\n args: {\n loadingState: {\n isLoading: true,\n modal: true\n }\n },\n};\n\nexport const CustomTxtState: Story = {\n args: {\n loadingState: {\n isLoading: true,\n loadingTxt: \"Hier steht was anderes...\"\n }\n },\n};\n\nexport const BackgroundState: Story = {\n args: {\n loadingState: {\n isLoading: true,\n smallBackground: true,\n }\n },\n};\n\nexport const ModalBackgroundState: Story = {\n args: {\n loadingState: {\n isLoading: true,\n smallBackground: true,\n modal: true,\n }\n },\n};\n\nexport const ModalWithBackgroundState: Story = {\n args: {\n loadingState: {\n isLoading: true,\n smallBackground: true, \n },\n doubleState: true\n },\n};\n\nexport const ModalStateWithSubTasks: Story = {\n args: {\n loadingState: {\n isLoading: true,\n modal: true,\n loadingTxt: \"Sammelaufgabe wird erledigt\",\n subTask: [\n {\n actionKey: \"\",\n completed: true,\n loadingTxt: \"SubTask 1\"\n },\n {\n actionKey: \"\",\n completed: false,\n loadingTxt: \"SubTask 2\"\n },\n {\n actionKey: \"\",\n completed: false,\n loadingTxt: \"SubTask 3\"\n },\n ]\n }\n },\n};\n\nexport const BackgroundWithSubTasks: Story = {\n args: {\n loadingState: {\n isLoading: true,\n modal: false,\n smallBackground: true,\n loadingTxt: \"Sammelaufgabe wird erledigt\",\n subTask: [\n {\n actionKey: \"\",\n completed: true,\n loadingTxt: \"SubTask 1\"\n },\n {\n actionKey: \"\",\n completed: false,\n loadingTxt: \"SubTask 2\"\n },\n {\n actionKey: \"\",\n completed: false,\n loadingTxt: \"SubTask 3\"\n },\n ]\n }\n },\n};\n\n"]}
|