diff --git a/.directory b/.directory index 9af614f0..8b3553f5 100644 --- a/.directory +++ b/.directory @@ -1,5 +1,5 @@ [Dolphin] -Timestamp=2024,2,15,9,41,31.242 +Timestamp=2024,8,7,10,25,9.632 Version=4 ViewMode=1 diff --git a/backups/src/routes/sponsorships/10_edit__sponsorship_obj.svelte b/backups/src/routes/sponsorships/10_edit__sponsorship_obj.svelte deleted file mode 100644 index bf133a19..00000000 --- a/backups/src/routes/sponsorships/10_edit__sponsorship_obj.svelte +++ /dev/null @@ -1,1185 +0,0 @@ - - - -
- -
- - {#await update_sponsorship_obj_promise} -
Saving...
- {:then} - {#if update_sponsorship_obj_promise} -
Finished saving
- {:else} - - {/if} - {/await} - - - - - -
- - - - - - - -
- -
- -
-

How to Attended

- -
- Face-to-Face or Virtual -

Is this a face-to-face/in person sponsorship, a virtual/online sponsorship, or both?

-
- - -
-
- -
- - Address - - - - - - - - - - - -
- -
- - - - {#if $ae_loc.lu_country_subdivision_list} - - {:else} - - {/if} - - - - {#if $ae_loc.lu_country_list} - - {:else} - - {/if} - -
- - - -
- Virtual/Online - - - - - - - -
- - - -
- -
- -
-

Recurring and When

- -
- Recurring -
- - -
-
- -
- - Recurring - -
- -
- - - - - - - -
- -
- - - -
- - {#if ( $ae_loc.administrator_access || $slct.sponsorship_obj && ($slct.sponsorship_obj.show_recurring_text || ($slct.sponsorship_obj.recurring_text && !$slct.sponsorship_obj.recurring_text.includes('*gen*'))) )} -

Please only use the text box for additional information if the options above do not cover your needs. This may affect how this sponsorship shows up in search results.

- - {/if} - {#if ( $ae_loc.administrator_access || $slct.sponsorship_obj && ($slct.sponsorship_obj.show_recurring_text || ($slct.sponsorship_obj.recurring_text && !$slct.sponsorship_obj.recurring_text.includes('*gen*'))) )} - - {:else} - - {/if} - - -
- -
- -
-

Contacts

- -
- Contact 1 - - - - - - - - - - - - - -
- -
- Contact 2 - - - - - - - - - -
-
- -
- -
- -

- Admin Options - -

- - - - - - - - - - - {#if $ae_loc.administrator_access} - - {/if} - - {#if $ae_loc.trusted_access} - - {/if} - - - -
- - -
- {#if $slct.sponsorship_id} - - {:else} - - {/if} - - {#if $slct.sponsorship_id} - {#if $ae_loc.administrator_access} - - {:else if $ae_loc.trusted_access} - - {:else} - - {/if} - {/if} -
- -
- -
- - - diff --git a/backups/src/routes/sponsorships/[slug]/hold +page.ts b/backups/src/routes/sponsorships/[slug]/hold +page.ts deleted file mode 100644 index e8c9e051..00000000 --- a/backups/src/routes/sponsorships/[slug]/hold +page.ts +++ /dev/null @@ -1,4 +0,0 @@ -// export function load({ params }) { -// console.log(`page data - params:`, params); -// return params -// } diff --git a/package-lock.json b/package-lock.json index 1154cdd5..9fb5e849 100644 --- a/package-lock.json +++ b/package-lock.json @@ -552,28 +552,28 @@ } }, "node_modules/@floating-ui/core": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.5.tgz", - "integrity": "sha512-8GrTWmoFhm5BsMZOTHeGD2/0FLKLQQHvO/ZmQga4tKempYRLz8aqJGqXVuQgisnMObq2YZ2SgkwctN1LOOxcqA==", + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.7.tgz", + "integrity": "sha512-yDzVT/Lm101nQ5TCVeK65LtdN7Tj4Qpr9RTXJ2vPFLqtLxwOrpoxAHAJI8J3yYWUc40J0BDBheaitK5SJmno2g==", "license": "MIT", "dependencies": { - "@floating-ui/utils": "^0.2.5" + "@floating-ui/utils": "^0.2.7" } }, "node_modules/@floating-ui/dom": { - "version": "1.6.8", - "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.6.8.tgz", - "integrity": "sha512-kx62rP19VZ767Q653wsP1XZCGIirkE09E0QUGNYTM/ttbbQHqcGPdSfWFxUyyNLc/W6aoJRBajOSXhP6GXjC0Q==", + "version": "1.6.10", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.6.10.tgz", + "integrity": "sha512-fskgCFv8J8OamCmyun8MfjB1Olfn+uZKjOKZ0vhYF3gRmEUXcGOjxWL8bBr7i4kIuPZ2KD2S3EUIOxnjC8kl2A==", "license": "MIT", "dependencies": { "@floating-ui/core": "^1.6.0", - "@floating-ui/utils": "^0.2.5" + "@floating-ui/utils": "^0.2.7" } }, "node_modules/@floating-ui/utils": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.5.tgz", - "integrity": "sha512-sTcG+QZ6fdEUObICavU+aB3Mp8HY4n14wYHdxK4fXjPmv3PXZZeY5RaguJmGyeH/CJQhX3fqKUtS4qc1LoHwhQ==", + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.7.tgz", + "integrity": "sha512-X8R8Oj771YRl/w+c1HqAC1szL8zWQRwFvgDwT129k9ACdBoud/+/rX9V0qiMl6LWUdP9voC2nDVZYPMQQsb6eA==", "license": "MIT" }, "node_modules/@humanwhocodes/config-array": { @@ -788,13 +788,13 @@ } }, "node_modules/@playwright/test": { - "version": "1.45.3", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.45.3.tgz", - "integrity": "sha512-UKF4XsBfy+u3MFWEH44hva1Q8Da28G6RFtR2+5saw+jgAFQV5yYnB1fu68Mz7fO+5GJF3wgwAIs0UelU8TxFrA==", + "version": "1.46.0", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.46.0.tgz", + "integrity": "sha512-/QYft5VArOrGRP5pgkrfKksqsKA6CEFyGQ/gjNe6q0y4tZ1aaPfq4gIjudr1s3D+pXyrPRdsy4opKDrjBabE5w==", "dev": true, "license": "Apache-2.0", "dependencies": { - "playwright": "1.45.3" + "playwright": "1.46.0" }, "bin": { "playwright": "cli.js" @@ -907,9 +907,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.19.2.tgz", - "integrity": "sha512-OHflWINKtoCFSpm/WmuQaWW4jeX+3Qt3XQDepkkiFTsoxFc5BpF3Z5aDxFZgBqRjO6ATP5+b1iilp4kGIZVWlA==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.20.0.tgz", + "integrity": "sha512-TSpWzflCc4VGAUJZlPpgAJE1+V60MePDQnBd7PPkpuEmOy8i87aL6tinFGKBFKuEDikYpig72QzdT3QPYIi+oA==", "cpu": [ "arm" ], @@ -921,9 +921,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.19.2.tgz", - "integrity": "sha512-k0OC/b14rNzMLDOE6QMBCjDRm3fQOHAL8Ldc9bxEWvMo4Ty9RY6rWmGetNTWhPo+/+FNd1lsQYRd0/1OSix36A==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.20.0.tgz", + "integrity": "sha512-u00Ro/nok7oGzVuh/FMYfNoGqxU5CPWz1mxV85S2w9LxHR8OoMQBuSk+3BKVIDYgkpeOET5yXkx90OYFc+ytpQ==", "cpu": [ "arm64" ], @@ -935,9 +935,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.19.2.tgz", - "integrity": "sha512-IIARRgWCNWMTeQH+kr/gFTHJccKzwEaI0YSvtqkEBPj7AshElFq89TyreKNFAGh5frLfDCbodnq+Ye3dqGKPBw==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.20.0.tgz", + "integrity": "sha512-uFVfvzvsdGtlSLuL0ZlvPJvl6ZmrH4CBwLGEFPe7hUmf7htGAN+aXo43R/V6LATyxlKVC/m6UsLb7jbG+LG39Q==", "cpu": [ "arm64" ], @@ -949,9 +949,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.19.2.tgz", - "integrity": "sha512-52udDMFDv54BTAdnw+KXNF45QCvcJOcYGl3vQkp4vARyrcdI/cXH8VXTEv/8QWfd6Fru8QQuw1b2uNersXOL0g==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.20.0.tgz", + "integrity": "sha512-xbrMDdlev53vNXexEa6l0LffojxhqDTBeL+VUxuuIXys4x6xyvbKq5XqTXBCEUA8ty8iEJblHvFaWRJTk/icAQ==", "cpu": [ "x64" ], @@ -963,9 +963,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.19.2.tgz", - "integrity": "sha512-r+SI2t8srMPYZeoa1w0o/AfoVt9akI1ihgazGYPQGRilVAkuzMGiTtexNZkrPkQsyFrvqq/ni8f3zOnHw4hUbA==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.20.0.tgz", + "integrity": "sha512-jMYvxZwGmoHFBTbr12Xc6wOdc2xA5tF5F2q6t7Rcfab68TT0n+r7dgawD4qhPEvasDsVpQi+MgDzj2faOLsZjA==", "cpu": [ "arm" ], @@ -977,9 +977,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.19.2.tgz", - "integrity": "sha512-+tYiL4QVjtI3KliKBGtUU7yhw0GMcJJuB9mLTCEauHEsqfk49gtUBXGtGP3h1LW8MbaTY6rSFIQV1XOBps1gBA==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.20.0.tgz", + "integrity": "sha512-1asSTl4HKuIHIB1GcdFHNNZhxAYEdqML/MW4QmPS4G0ivbEcBr1JKlFLKsIRqjSwOBkdItn3/ZDlyvZ/N6KPlw==", "cpu": [ "arm" ], @@ -991,9 +991,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.19.2.tgz", - "integrity": "sha512-OR5DcvZiYN75mXDNQQxlQPTv4D+uNCUsmSCSY2FolLf9W5I4DSoJyg7z9Ea3TjKfhPSGgMJiey1aWvlWuBzMtg==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.20.0.tgz", + "integrity": "sha512-COBb8Bkx56KldOYJfMf6wKeYJrtJ9vEgBRAOkfw6Ens0tnmzPqvlpjZiLgkhg6cA3DGzCmLmmd319pmHvKWWlQ==", "cpu": [ "arm64" ], @@ -1005,9 +1005,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.19.2.tgz", - "integrity": "sha512-Hw3jSfWdUSauEYFBSFIte6I8m6jOj+3vifLg8EU3lreWulAUpch4JBjDMtlKosrBzkr0kwKgL9iCfjA8L3geoA==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.20.0.tgz", + "integrity": "sha512-+it+mBSyMslVQa8wSPvBx53fYuZK/oLTu5RJoXogjk6x7Q7sz1GNRsXWjn6SwyJm8E/oMjNVwPhmNdIjwP135Q==", "cpu": [ "arm64" ], @@ -1019,9 +1019,9 @@ ] }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.19.2.tgz", - "integrity": "sha512-rhjvoPBhBwVnJRq/+hi2Q3EMiVF538/o9dBuj9TVLclo9DuONqt5xfWSaE6MYiFKpo/lFPJ/iSI72rYWw5Hc7w==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.20.0.tgz", + "integrity": "sha512-yAMvqhPfGKsAxHN8I4+jE0CpLWD8cv4z7CK7BMmhjDuz606Q2tFKkWRY8bHR9JQXYcoLfopo5TTqzxgPUjUMfw==", "cpu": [ "ppc64" ], @@ -1033,9 +1033,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.19.2.tgz", - "integrity": "sha512-EAz6vjPwHHs2qOCnpQkw4xs14XJq84I81sDRGPEjKPFVPBw7fwvtwhVjcZR6SLydCv8zNK8YGFblKWd/vRmP8g==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.20.0.tgz", + "integrity": "sha512-qmuxFpfmi/2SUkAw95TtNq/w/I7Gpjurx609OOOV7U4vhvUhBcftcmXwl3rqAek+ADBwSjIC4IVNLiszoj3dPA==", "cpu": [ "riscv64" ], @@ -1047,9 +1047,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.19.2.tgz", - "integrity": "sha512-IJSUX1xb8k/zN9j2I7B5Re6B0NNJDJ1+soezjNojhT8DEVeDNptq2jgycCOpRhyGj0+xBn7Cq+PK7Q+nd2hxLA==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.20.0.tgz", + "integrity": "sha512-I0BtGXddHSHjV1mqTNkgUZLnS3WtsqebAXv11D5BZE/gfw5KoyXSAXVqyJximQXNvNzUo4GKlCK/dIwXlz+jlg==", "cpu": [ "s390x" ], @@ -1061,9 +1061,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.19.2.tgz", - "integrity": "sha512-OgaToJ8jSxTpgGkZSkwKE+JQGihdcaqnyHEFOSAU45utQ+yLruE1dkonB2SDI8t375wOKgNn8pQvaWY9kPzxDQ==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.20.0.tgz", + "integrity": "sha512-y+eoL2I3iphUg9tN9GB6ku1FA8kOfmF4oUEWhztDJ4KXJy1agk/9+pejOuZkNFhRwHAOxMsBPLbXPd6mJiCwew==", "cpu": [ "x64" ], @@ -1075,9 +1075,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.19.2.tgz", - "integrity": "sha512-5V3mPpWkB066XZZBgSd1lwozBk7tmOkKtquyCJ6T4LN3mzKENXyBwWNQn8d0Ci81hvlBw5RoFgleVpL6aScLYg==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.20.0.tgz", + "integrity": "sha512-hM3nhW40kBNYUkZb/r9k2FKK+/MnKglX7UYd4ZUy5DJs8/sMsIbqWK2piZtVGE3kcXVNj3B2IrUYROJMMCikNg==", "cpu": [ "x64" ], @@ -1089,9 +1089,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.19.2.tgz", - "integrity": "sha512-ayVstadfLeeXI9zUPiKRVT8qF55hm7hKa+0N1V6Vj+OTNFfKSoUxyZvzVvgtBxqSb5URQ8sK6fhwxr9/MLmxdA==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.20.0.tgz", + "integrity": "sha512-psegMvP+Ik/Bg7QRJbv8w8PAytPA7Uo8fpFjXyCRHWm6Nt42L+JtoqH8eDQ5hRP7/XW2UiIriy1Z46jf0Oa1kA==", "cpu": [ "arm64" ], @@ -1103,9 +1103,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.19.2.tgz", - "integrity": "sha512-Mda7iG4fOLHNsPqjWSjANvNZYoW034yxgrndof0DwCy0D3FvTjeNo+HGE6oGWgvcLZNLlcp0hLEFcRs+UGsMLg==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.20.0.tgz", + "integrity": "sha512-GabekH3w4lgAJpVxkk7hUzUf2hICSQO0a/BLFA11/RMxQT92MabKAqyubzDZmMOC/hcJNlc+rrypzNzYl4Dx7A==", "cpu": [ "ia32" ], @@ -1117,9 +1117,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.19.2.tgz", - "integrity": "sha512-DPi0ubYhSow/00YqmG1jWm3qt1F8aXziHc/UNy8bo9cpCacqhuWu+iSq/fp2SyEQK7iYTZ60fBU9cat3MXTjIQ==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.20.0.tgz", + "integrity": "sha512-aJ1EJSuTdGnM6qbVC4B5DSmozPTqIag9fSzXRNNo+humQLG89XpPgdt16Ia56ORD7s+H8Pmyx44uczDQ0yDzpg==", "cpu": [ "x64" ], @@ -1786,9 +1786,9 @@ "license": "MIT" }, "node_modules/autoprefixer": { - "version": "10.4.19", - "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.19.tgz", - "integrity": "sha512-BaENR2+zBZ8xXhM4pUaKUxlVdxZ0EZhjvbopwnXmxRUfqDmwSpC2lAi/QXvx7NRdPCo1WKEcEF6mV64si1z4Ew==", + "version": "10.4.20", + "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.20.tgz", + "integrity": "sha512-XY25y5xSv/wEoqzDyXXME4AFfkZI0P23z6Fs3YgymDnKJkCGOnkL0iTxCa85UTqaSgfcqyf3UA6+c7wUvx/16g==", "dev": true, "funding": [ { @@ -1806,11 +1806,11 @@ ], "license": "MIT", "dependencies": { - "browserslist": "^4.23.0", - "caniuse-lite": "^1.0.30001599", + "browserslist": "^4.23.3", + "caniuse-lite": "^1.0.30001646", "fraction.js": "^4.3.7", "normalize-range": "^0.1.2", - "picocolors": "^1.0.0", + "picocolors": "^1.0.1", "postcss-value-parser": "^4.2.0" }, "bin": { @@ -1974,9 +1974,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001646", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001646.tgz", - "integrity": "sha512-dRg00gudiBDDTmUhClSdv3hqRfpbOnU28IpI1T6PBTLWa+kOj0681C8uML3PifYfREuBrVjDGhL3adYpBT6spw==", + "version": "1.0.30001650", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001650.tgz", + "integrity": "sha512-fgEc7hP/LB7iicdXHUI9VsBsMZmUmlVJeQP2qqQW+3lkqVhbmjEU8zp+h5stWeilX+G7uXuIUIIlWlDw9jdt8g==", "dev": true, "funding": [ { @@ -2385,9 +2385,9 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.4.tgz", - "integrity": "sha512-orzA81VqLyIGUEA77YkVA1D+N+nNfl2isJVjjmOyrlxuooZ19ynb+dOlaDTqd/idKRS9lDCSBmtzM+kyCsMnkA==", + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.5.tgz", + "integrity": "sha512-QR7/A7ZkMS8tZuoftC/jfqNkZLQO779SSW3YuZHP4eXpj3EffGLFcB/Xu9AAZQzLccTiCV+EmUo3ha4mQ9wnlA==", "dev": true, "license": "ISC" }, @@ -4146,13 +4146,13 @@ } }, "node_modules/playwright": { - "version": "1.45.3", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.45.3.tgz", - "integrity": "sha512-QhVaS+lpluxCaioejDZ95l4Y4jSFCsBvl2UZkpeXlzxmqS+aABr5c82YmfMHrL6x27nvrvykJAFpkzT2eWdJww==", + "version": "1.46.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.46.0.tgz", + "integrity": "sha512-XYJ5WvfefWONh1uPAUAi0H2xXV5S3vrtcnXe6uAOgdGi3aSpqOSXX08IAjXW34xitfuOJsvXU5anXZxPSEQiJw==", "dev": true, "license": "Apache-2.0", "dependencies": { - "playwright-core": "1.45.3" + "playwright-core": "1.46.0" }, "bin": { "playwright": "cli.js" @@ -4165,9 +4165,9 @@ } }, "node_modules/playwright-core": { - "version": "1.45.3", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.45.3.tgz", - "integrity": "sha512-+ym0jNbcjikaOwwSZycFbwkWgfruWvYlJfThKYAlImbxUgdWFO2oW70ojPm4OpE4t6TAo2FY/smM+hpVTtkhDA==", + "version": "1.46.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.46.0.tgz", + "integrity": "sha512-9Y/d5UIwuJk8t3+lhmMSAJyNP1BUC/DqP3cQJDQQL/oWqAiuPTLgy7Q5dzglmTLwcBRdetzgNM/gni7ckfTr6A==", "dev": true, "license": "Apache-2.0", "bin": { @@ -4178,9 +4178,9 @@ } }, "node_modules/postcss": { - "version": "8.4.40", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.40.tgz", - "integrity": "sha512-YF2kKIUzAofPMpfH6hOi2cGnv/HrUlfucspc7pDyvv7kGdqXrfj8SCl/t8owkEgKEuu8ZcRjSOxFxVLqwChZ2Q==", + "version": "8.4.41", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.41.tgz", + "integrity": "sha512-TesUflQ0WKZqAvg52PWL6kHgLKP6xB6heTOdoYM0Wt2UHyxNa4K25EZZMgKns3BH1RLVbZCREPpLY0rhnNoHVQ==", "dev": true, "funding": [ { @@ -4616,9 +4616,9 @@ } }, "node_modules/rollup": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.19.2.tgz", - "integrity": "sha512-6/jgnN1svF9PjNYJ4ya3l+cqutg49vOZ4rVgsDKxdl+5gpGPnByFXWGyfH9YGx9i3nfBwSu1Iyu6vGwFFA0BdQ==", + "version": "4.20.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.20.0.tgz", + "integrity": "sha512-6rbWBChcnSGzIlXeIdNIZTopKYad8ZG8ajhl78lGRLsI2rX8IkaotQhVas2Ma+GPxJav19wrSzvRvuiv0YKzWw==", "dev": true, "license": "MIT", "dependencies": { @@ -4632,22 +4632,22 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.19.2", - "@rollup/rollup-android-arm64": "4.19.2", - "@rollup/rollup-darwin-arm64": "4.19.2", - "@rollup/rollup-darwin-x64": "4.19.2", - "@rollup/rollup-linux-arm-gnueabihf": "4.19.2", - "@rollup/rollup-linux-arm-musleabihf": "4.19.2", - "@rollup/rollup-linux-arm64-gnu": "4.19.2", - "@rollup/rollup-linux-arm64-musl": "4.19.2", - "@rollup/rollup-linux-powerpc64le-gnu": "4.19.2", - "@rollup/rollup-linux-riscv64-gnu": "4.19.2", - "@rollup/rollup-linux-s390x-gnu": "4.19.2", - "@rollup/rollup-linux-x64-gnu": "4.19.2", - "@rollup/rollup-linux-x64-musl": "4.19.2", - "@rollup/rollup-win32-arm64-msvc": "4.19.2", - "@rollup/rollup-win32-ia32-msvc": "4.19.2", - "@rollup/rollup-win32-x64-msvc": "4.19.2", + "@rollup/rollup-android-arm-eabi": "4.20.0", + "@rollup/rollup-android-arm64": "4.20.0", + "@rollup/rollup-darwin-arm64": "4.20.0", + "@rollup/rollup-darwin-x64": "4.20.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.20.0", + "@rollup/rollup-linux-arm-musleabihf": "4.20.0", + "@rollup/rollup-linux-arm64-gnu": "4.20.0", + "@rollup/rollup-linux-arm64-musl": "4.20.0", + "@rollup/rollup-linux-powerpc64le-gnu": "4.20.0", + "@rollup/rollup-linux-riscv64-gnu": "4.20.0", + "@rollup/rollup-linux-s390x-gnu": "4.20.0", + "@rollup/rollup-linux-x64-gnu": "4.20.0", + "@rollup/rollup-linux-x64-musl": "4.20.0", + "@rollup/rollup-win32-arm64-msvc": "4.20.0", + "@rollup/rollup-win32-ia32-msvc": "4.20.0", + "@rollup/rollup-win32-x64-msvc": "4.20.0", "fsevents": "~2.3.2" } }, diff --git a/src/lib/ae_events__event.ts b/src/lib/ae_events__event.ts index 9501eb4b..d04d91b9 100644 --- a/src/lib/ae_events__event.ts +++ b/src/lib/ae_events__event.ts @@ -11,8 +11,8 @@ export async function handle_load_ae_obj_id__event( { api_cfg, event_id, - try_cache=false, - log_lvl=0 + try_cache = true, + log_lvl = 0 }: { api_cfg: any, event_id: string, @@ -36,7 +36,13 @@ export async function handle_load_ae_obj_id__event( }) .then(function (event_obj_get_result) { if (event_obj_get_result) { - handle_db_save_ae_obj_li__event({obj_type: 'event', obj_li: [event_obj_get_result]}); + if (try_cache) { + // This is expecting a list + handle_db_save_ae_obj_li__event({ + obj_type: 'event', + obj_li: [event_obj_get_result] + }); + } return event_obj_get_result; } else { console.log('No results returned.'); @@ -97,7 +103,9 @@ export async function handle_load_ae_obj_li__event( }) .then(function (event_obj_li_get_result) { if (event_obj_li_get_result) { - handle_db_save_ae_obj_li__event({obj_type: 'event', obj_li: event_obj_li_get_result}); + if (try_cache) { + handle_db_save_ae_obj_li__event({obj_type: 'event', obj_li: event_obj_li_get_result}); + } return event_obj_li_get_result; } else { return []; diff --git a/src/lib/ae_events__event_location.ts b/src/lib/ae_events__event_location.ts index cc0fc342..27ce1f3e 100644 --- a/src/lib/ae_events__event_location.ts +++ b/src/lib/ae_events__event_location.ts @@ -11,7 +11,7 @@ export async function handle_load_ae_obj_id__event_location( { api_cfg, event_location_id, - try_cache=false, + try_cache=true, log_lvl=0 }: { api_cfg: any, @@ -36,8 +36,13 @@ export async function handle_load_ae_obj_id__event_location( }) .then(function (event_location_obj_get_result) { if (event_location_obj_get_result) { - // This is expecting a list - handle_db_save_ae_obj_li__event_location({obj_type: 'event_location', obj_li: [event_location_obj_get_result]}); + if (try_cache) { + // This is expecting a list + handle_db_save_ae_obj_li__event_location({ + obj_type: 'event_location', + obj_li: [event_location_obj_get_result] + }); + } return event_location_obj_get_result; } else { console.log('No results returned.'); @@ -97,7 +102,12 @@ export async function handle_load_ae_obj_li__event_location( }) .then(function (event_location_obj_li_get_result) { if (event_location_obj_li_get_result) { - handle_db_save_ae_obj_li__event_location({obj_type: 'event_location', obj_li: event_location_obj_li_get_result}); + if (try_cache) { + handle_db_save_ae_obj_li__event_location({ + obj_type: 'event_location', + obj_li: event_location_obj_li_get_result + }); + } return event_location_obj_li_get_result; } else { return []; diff --git a/src/lib/ae_events__event_presenter.ts b/src/lib/ae_events__event_presenter.ts index 7d2ce19f..2c09d72f 100644 --- a/src/lib/ae_events__event_presenter.ts +++ b/src/lib/ae_events__event_presenter.ts @@ -67,7 +67,9 @@ export async function handle_load_ae_obj_li__event_presenter( log_lvl?: number } ) { - console.log(`*** handle_load_ae_obj_li__event_presenter() *** event_presentation_id=${event_presentation_id}`); + if (log_lvl) { + console.log(`*** handle_load_ae_obj_li__event_presenter() *** event_presentation_id=${event_presentation_id}`); + } let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden @@ -112,6 +114,59 @@ export async function handle_load_ae_obj_li__event_presenter( return ae_promises.load__event_presenter_obj_li; } + +// Updated 2024-08-07 +export async function handle_delete_ae_obj_id__event_presenter( + { + api_cfg, + event_presenter_id, + method='delete', // 'delete', 'disable', 'hide' + params={}, + log_lvl=0 + }: { + api_cfg: any, + event_presenter_id: string, + method?: string, + params?: key_val, + log_lvl?: number + } + ) { + if (log_lvl) { + console.log(`*** handle_delete_ae_obj_id__event_presenter() *** event_presenter_id=${event_presenter_id}`); + } + + ae_promises.delete__event_presenter_obj = await api.delete_ae_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_presenter', + obj_id: event_presenter_id, // NOTE: This is the FQDN, not normally the ID. + key: api_cfg.api_crud_super_key, + params: params, + method: method, + log_lvl: log_lvl + }) + .then(function (event_presenter_obj_delete_result) { + if (event_presenter_obj_delete_result) { + // handle_db_save_ae_obj_li__event_presenter({obj_type: 'event_presenter', obj_li: [event_presenter_obj_delete_result]}); + return event_presenter_obj_delete_result; + } else { + return null; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }) + .finally(function () { + db_events.presenters.delete(event_presenter_id); + }); + + if (log_lvl) { + console.log('ae_promises.delete__event_presenter_obj:', ae_promises.delete__event_presenter_obj); + } + + return ae_promises.delete__event_presenter_obj; +} + + // Updated 2024-06-24 export async function handle_create_ae_obj__event_presenter( { @@ -132,7 +187,9 @@ export async function handle_create_ae_obj__event_presenter( log_lvl?: number } ) { - console.log(`*** handle_create_ae_obj__event_presenter() *** event_id=${event_id} event_session_id=${event_session_id} event_presentation_id=${event_presentation_id}`); + if (log_lvl) { + console.log(`*** handle_create_ae_obj__event_presenter() *** event_id=${event_id} event_session_id=${event_session_id} event_presentation_id=${event_presentation_id}`); + } ae_promises.create__event_presenter = await api.create_ae_obj_crud({ api_cfg: api_cfg, @@ -188,7 +245,9 @@ export async function handle_update_ae_obj__event_presenter( log_lvl?: number } ) { - console.log(`*** handle_update_ae_obj__event_presenter() *** event_presenter_id=${event_presenter_id}`); + if (log_lvl) { + console.log(`*** handle_update_ae_obj__event_presenter() *** event_presenter_id=${event_presenter_id}`); + } ae_promises.update__event_presenter_obj = await api.update_ae_obj_id_crud({ api_cfg: api_cfg, @@ -251,7 +310,9 @@ export async function handle_search__event_presenter( log_lvl?: number } ) { - console.log(`*** handle_search__event_presenter() *** event_id=${event_id}`); + if (log_lvl) { + console.log(`*** handle_search__event_presenter() *** event_id=${event_id}`); + } let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden @@ -354,13 +415,17 @@ export async function handle_search__event_presenter( export function handle_db_save_ae_obj_li__event_presenter( { obj_type, - obj_li + obj_li, + log_lvl = 0 }: { obj_type: string, - obj_li: any + obj_li: any, + log_lvl?: number } ) { - console.log(`*** handle_db_save_ae_obj_li__event_presenter() ***`); + if (log_lvl) { + console.log(`*** handle_db_save_ae_obj_li__event_presenter() ***`); + } if (obj_li && obj_li.length) { obj_li.forEach(async function (obj: any) { @@ -464,6 +529,7 @@ export function handle_db_save_ae_obj_li__event_presenter( } +// Updated 2024-08-07 export async function handle_email_sign_in__event_presenter ( { api_cfg, @@ -476,7 +542,8 @@ export async function handle_email_sign_in__event_presenter ( event_presentation_id, event_presenter_id, session_name, - presentation_name + presentation_name, + log_lvl = 0 }: { api_cfg: any, to_email: string, @@ -488,10 +555,13 @@ export async function handle_email_sign_in__event_presenter ( event_presentation_id: string, event_presenter_id: string, session_name: string, - presentation_name: string + presentation_name: string, + log_lvl?: number } ) { - console.log(`*** handle_email_sign_in__event_presenter() *** to_email=${to_email} to_name=${to_name} person_id=${person_id} person_passcode=${person_passcode} presentation_id=${event_presentation_id} presenter_id=${event_presenter_id}`); + if (log_lvl) { + console.log(`*** handle_email_sign_in__event_presenter() *** to_email=${to_email} to_name=${to_name} person_id=${person_id} person_passcode=${person_passcode} presentation_id=${event_presentation_id} presenter_id=${event_presenter_id}`); + } let subject = `LCI Congress 2024 - Pres Mgmt Hub Sign In Link for ${session_name} (ID: ${event_session_id})`; @@ -522,4 +592,4 @@ export async function handle_email_sign_in__event_presenter ( subject: subject, body_html: body_html, }); -} \ No newline at end of file +} diff --git a/src/lib/ae_events__event_session.ts b/src/lib/ae_events__event_session.ts index 7b5af8fa..f3bc548c 100644 --- a/src/lib/ae_events__event_session.ts +++ b/src/lib/ae_events__event_session.ts @@ -11,8 +11,8 @@ export async function handle_load_ae_obj_id__event_session( { api_cfg, event_session_id, - try_cache=false, - log_lvl=0 + try_cache = true, + log_lvl = 0 }: { api_cfg: any, event_session_id: string, @@ -36,8 +36,13 @@ export async function handle_load_ae_obj_id__event_session( }) .then(function (event_session_obj_get_result) { if (event_session_obj_get_result) { - // This is expecting a list - handle_db_save_ae_obj_li__event_session({obj_type: 'event_session', obj_li: [event_session_obj_get_result]}); + if (try_cache) { + // This is expecting a list + handle_db_save_ae_obj_li__event_session({ + obj_type: 'event_session', + obj_li: [event_session_obj_get_result] + }); + } return event_session_obj_get_result; } else { console.log('No results returned.'); @@ -99,7 +104,12 @@ export async function handle_load_ae_obj_li__event_session( }) .then(function (event_session_obj_li_get_result) { if (event_session_obj_li_get_result) { - handle_db_save_ae_obj_li__event_session({obj_type: 'event_session', obj_li: event_session_obj_li_get_result}); + if (try_cache) { + handle_db_save_ae_obj_li__event_session({ + obj_type: 'event_session', + obj_li: event_session_obj_li_get_result + }); + } return event_session_obj_li_get_result; } else { return []; diff --git a/src/lib/ae_events_functions.ts b/src/lib/ae_events_functions.ts index 15ecb37c..9c034686 100644 --- a/src/lib/ae_events_functions.ts +++ b/src/lib/ae_events_functions.ts @@ -52,6 +52,7 @@ import { import { handle_load_ae_obj_id__event_presenter, handle_load_ae_obj_li__event_presenter, + handle_delete_ae_obj_id__event_presenter, handle_create_ae_obj__event_presenter, handle_update_ae_obj__event_presenter, handle_search__event_presenter, @@ -70,36 +71,44 @@ import { let export_obj = { handle_load_ae_obj_id__event: handle_load_ae_obj_id__event, handle_load_ae_obj_li__event: handle_load_ae_obj_li__event, + handle_db_save_ae_obj_li__event: handle_db_save_ae_obj_li__event, handle_load_ae_obj_id__event_file: handle_load_ae_obj_id__event_file, handle_load_ae_obj_li__event_file: handle_load_ae_obj_li__event_file, handle_delete_ae_obj_id__event_file: handle_delete_ae_obj_id__event_file, handle_update_ae_obj__event_file: handle_update_ae_obj__event_file, handle_search__event_file: handle_search__event_file, + handle_db_save_ae_obj_li__event_file: handle_db_save_ae_obj_li__event_file, handle_load_ae_obj_id__event_location: handle_load_ae_obj_id__event_location, handle_load_ae_obj_li__event_location: handle_load_ae_obj_li__event_location, handle_create_ae_obj__event_location: handle_create_ae_obj__event_location, + handle_db_save_ae_obj_li__event_location: handle_db_save_ae_obj_li__event_location, handle_load_ae_obj_id__event_session: handle_load_ae_obj_id__event_session, handle_load_ae_obj_li__event_session: handle_load_ae_obj_li__event_session, handle_search__event_session: handle_search__event_session, handle_email_sign_in__event_session: handle_email_sign_in__event_session, + handle_db_save_ae_obj_li__event_session: handle_db_save_ae_obj_li__event_session, handle_load_ae_obj_id__event_presentation: handle_load_ae_obj_id__event_presentation, handle_load_ae_obj_li__event_presentation: handle_load_ae_obj_li__event_presentation, handle_create_ae_obj__event_presentation: handle_create_ae_obj__event_presentation, + handle_db_save_ae_obj_li__event_presentation: handle_db_save_ae_obj_li__event_presentation, handle_load_ae_obj_id__event_presenter: handle_load_ae_obj_id__event_presenter, handle_load_ae_obj_li__event_presenter: handle_load_ae_obj_li__event_presenter, + handle_delete_ae_obj_id__event_presenter: handle_delete_ae_obj_id__event_presenter, handle_create_ae_obj__event_presenter: handle_create_ae_obj__event_presenter, handle_update_ae_obj__event_presenter: handle_update_ae_obj__event_presenter, handle_search__event_presenter: handle_search__event_presenter, + handle_db_save_ae_obj_li__event_presenter: handle_db_save_ae_obj_li__event_presenter, handle_email_sign_in__event_presenter: handle_email_sign_in__event_presenter, handle_load_ae_obj_id__badge: handle_load_ae_obj_id__badge, handle_load_ae_obj_li__badge: handle_load_ae_obj_li__badge, handle_search__event_badge: handle_search__event_badge, + handle_db_save_ae_obj_li__badge: handle_db_save_ae_obj_li__badge, handle_load_ae_obj_id__exhibit: handle_load_ae_obj_id__exhibit, handle_load_ae_obj_li__exhibit: handle_load_ae_obj_li__exhibit, @@ -108,6 +117,7 @@ let export_obj = { handle_create_ae_obj__exhibit_tracking: handle_create_ae_obj__exhibit_tracking, handle_update_ae_obj__exhibit_tracking: handle_update_ae_obj__exhibit_tracking, handle_download_export__event_exhibit_tracking: handle_download_export__event_exhibit_tracking, + handle_db_save_ae_obj_li__exhibitor: handle_db_save_ae_obj_li__exhibitor, create_event_file_obj_from_hosted_file_async: create_event_file_obj_from_hosted_file_async, }; diff --git a/src/lib/ae_stores.ts b/src/lib/ae_stores.ts index e1b61568..8494124f 100644 --- a/src/lib/ae_stores.ts +++ b/src/lib/ae_stores.ts @@ -47,8 +47,8 @@ export let ae_snip = string_snippets; // *** BEGIN *** Longer-term app data. This should be stored to local storage. export let ae_app_local_data_struct: key_val = { - 'ver': '2024-06-26_13', - 'ver_idb': '2024-06-26_1625', // Clear if date IndexedDB version + 'ver': '2024-08-07_1504', + 'ver_idb': '2024-08-07_1505', // Clear if date IndexedDB version 'name': 'Aether - App Hub (SvelteKit 2.x Svelte 4.x)', 'theme': 'light', 'iframe': false, diff --git a/src/lib/ae_utils.ts b/src/lib/ae_utils.ts index f914b905..3388b9de 100644 --- a/src/lib/ae_utils.ts +++ b/src/lib/ae_utils.ts @@ -410,7 +410,7 @@ export let shorten_string = function shorten_string( // console.log('*** shorten_filename() ***'); if (!string || typeof string != 'string') { - console.log('Invalid string value passed'); + // console.log('Invalid string value passed'); // return false; return ''; } diff --git a/src/lib/api.ts b/src/lib/api.ts index 61e35675..dd02da96 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -180,13 +180,14 @@ export let get_ae_obj_id_crud = async function get_ae_obj_id_crud( } +// The lookup "obj_type" should broken out into a separate function. - 2024-08-07 // Updated 2023-11-15 export let get_ae_obj_li_for_obj_id_crud = async function get_ae_obj_li_for_obj_id_crud( { api_cfg, obj_type, for_obj_type, - for_obj_id=null, // NOTE: Changed 2023-12-06 to no longer required + for_obj_id, // NOTE: Changed 2023-12-06 to no longer required use_alt_table=false, use_alt_base=false, inc={}, @@ -304,15 +305,15 @@ export let get_ae_obj_li_for_obj_id_crud = async function get_ae_obj_li_for_obj_ endpoint = `/crud/sponsorship/list`; // } else if (obj_type == 'user') { // endpoint = `/crud/user/list`; - } else if (obj_type == 'lu' && for_obj_type == 'country_subdivision') { - endpoint = `/crud/lu/country_subdivision/list`; - for_obj_type = null; - } else if (obj_type == 'lu' && for_obj_type == 'country') { - endpoint = `/crud/lu/country/list`; - for_obj_type = null; - } else if (obj_type == 'lu' && for_obj_type == 'time_zone') { - endpoint = `/crud/lu/time_zone/list`; - for_obj_type = null; + // } else if (obj_type == 'lu' && for_obj_type == 'country_subdivision') { + // endpoint = `/crud/lu/country_subdivision/list`; + // for_obj_type = null; + // } else if (obj_type == 'lu' && for_obj_type == 'country') { + // endpoint = `/crud/lu/country/list`; + // for_obj_type = null; + // } else if (obj_type == 'lu' && for_obj_type == 'time_zone') { + // endpoint = `/crud/lu/time_zone/list`; + // for_obj_type = null; } else { console.log(`Unknown object type: ${obj_type}`); return false; @@ -402,10 +403,147 @@ export let get_ae_obj_li_for_obj_id_crud = async function get_ae_obj_li_for_obj_ } -// Updated 2023-07-24 -export let create_ae_obj_crud = async function create_ae_obj_crud({api_cfg, obj_type, field_name=null, field_value=null, fields={}, key, jwt=null, headers={}, params={}, data={}, return_obj=false, obj_v_name='', return_meta=false, log_lvl=0}) { +// This new function has not been tested yet!!! +// Updated 2024-08-07 +export let get_ae_obj_li_for_lu = async function get_ae_obj_li_for_lu( + { + api_cfg, + // obj_type, + for_lu_type, + // for_obj_id=null, + // use_alt_table=false, + // use_alt_base=false, + // inc={}, + enabled='enabled', + hidden='not_hidden', + order_by_li=null, + limit=999999, + offset=0, + // key, + // jwt=null, + headers={}, + params_json=null, + // json_obj=null, + params={}, + return_meta=false, + log_lvl=1 + }: { + api_cfg: any, + // obj_type: string, + for_lu_type: string, + // for_lu_id?: string, + // use_alt_table?: boolean, + // use_alt_base?: boolean, + // inc?: key_val + enabled?: string, + hidden?: string, + order_by_li?: any, + limit?: number, + offset?: number, + // key: string, + // jwt?: string, + headers?: any, + params_json?: any, + // json_obj?: any, + params?: key_val, + return_meta?: boolean, + log_lvl?: number + } + ) { if (log_lvl) { - console.log('*** create_ae_obj_crud() ***'); + console.log(`*** get_ae_obj_li_for_lu() *** for_lu_type=${for_lu_type}`); + } + + let endpoint = ''; + if (for_lu_type == 'country_subdivision') { + endpoint = `/crud/lu/country_subdivision/list`; + } else if (for_lu_type == 'country') { + endpoint = `/crud/lu/country/list`; + } else if (for_lu_type == 'time_zone') { + endpoint = `/crud/lu/time_zone/list`; + } else { + console.log(`Unknown object type: ${for_lu_type}`); + return false; + } + if (log_lvl) { + console.log('Endpoint:', endpoint); + } + + if (order_by_li) { + headers['order_by_li'] = order_by_li; + } + + let allowed_enabled_list = ['all', 'enabled', 'not_enabled'] + if (allowed_enabled_list.includes(enabled) ) { + params['enabled'] = enabled; + } + + let allowed_hidden_list = ['all', 'hidden', 'not_hidden']; + if (allowed_hidden_list.includes(hidden) ) { + params['hidden'] = hidden; + } + + if (limit >= 0) { + params['limit'] = limit; + } + + if (offset >= 0) { + params['offset'] = offset; + } + + let object_li_get_promise = await api.get_object({ + api_cfg: api_cfg, + endpoint: endpoint, + headers: headers, + params: params, + return_meta: return_meta, + log_lvl: log_lvl + }); + + if (log_lvl > 1) { + console.log(object_li_get_promise); + } + + return object_li_get_promise; +} + + +// Updated 2023-07-24 +export let create_ae_obj_crud = async function create_ae_obj_crud( + { + api_cfg, + obj_type, + field_name = null, + field_value = null, + fields = {}, + key, + jwt = null, + headers = {}, + params = {}, + data = {}, + return_obj = false, + obj_v_name = '', + return_meta = false, + log_lvl = 0 + } : { + api_cfg: any, + obj_type: string, + field_name?: null|string, + field_value?: any, + fields?: key_val, + key: string, + jwt?: null|string, + headers?: key_val, + params?: key_val, + data?: key_val, + return_obj?: boolean, + obj_v_name?: string, + return_meta?: boolean, + log_lvl?: number + } + ) { + if (log_lvl) { + console.log(`*** create_ae_obj_crud() *** obj_type=${obj_type}`); } data['super_key'] = key; @@ -759,7 +897,33 @@ export let update_ae_obj_id_crud = async function update_ae_obj_id_crud( // Updated 2023-11-14 -export let delete_ae_obj_id_crud = async function delete_ae_obj_id_crud({api_cfg, obj_type, obj_id, key, jwt=null, headers={}, params={}, data={}, method='delete', return_meta=false, log_lvl=0}) { +export let delete_ae_obj_id_crud = async function delete_ae_obj_id_crud( + { + api_cfg, + obj_type, + obj_id, + key, + jwt=null, + headers={}, + params={}, + data={}, + method='delete', // 'delete', 'disable', 'hide' + return_meta=false, + log_lvl=0 + } : { + api_cfg: any, + obj_type: string, + obj_id: string, + key: string, + jwt?: string, + headers?: any, + params?: any, + data?: any, + method?: string, + return_meta?: boolean, + log_lvl?: number + } + ) { if (log_lvl) { console.log(`*** delete_ae_obj_id_crud() *** obj_type: ${obj_type} obj_id: ${obj_id}`); } @@ -864,15 +1028,25 @@ export let delete_ae_obj_id_crud = async function delete_ae_obj_id_crud({api_cfg /* BEGIN: Hosted File Related */ // Updated 2023-08-17 -export let download_hosted_file = async function download_hosted_file({ - api_cfg, - hosted_file_id, - return_file=true, - filename=null, - auto_download=false, - params={}, - log_lvl=0 - }) { +export let download_hosted_file = async function download_hosted_file( + { + api_cfg, + hosted_file_id, + return_file=true, + filename, + auto_download=false, + params={}, + log_lvl=0 + } : { + api_cfg: any, + hosted_file_id: string, + return_file?: boolean, + filename?: string, + auto_download?: boolean, + params?: key_val, + log_lvl?: number + } + ) { console.log('*** stores_hosted_api.js: download_hosted_file() ***'); let task_id = hosted_file_id; @@ -897,8 +1071,29 @@ export let download_hosted_file = async function download_hosted_file({ return hosted_file_download_get_promise; } + // Updated 2023-12-15 -export let delete_hosted_file = async function delete_hosted_file({api_cfg, hosted_file_id, link_to_type=null, link_to_id=null, rm_orphan=false, params={}, data={}, log_lvl=1}) { +export let delete_hosted_file = async function delete_hosted_file( + { + api_cfg, + hosted_file_id, + link_to_type, + link_to_id, + rm_orphan=false, + params={}, + data={}, + log_lvl=1 + } : { + api_cfg: any, + hosted_file_id: string, + link_to_type?: string, + link_to_id?: string, + rm_orphan?: boolean, + params?: key_val, + data?: key_val, + log_lvl?: number + } + ) { console.log('*** stores_hosted_api.js: delete_hosted_file() ***'); const endpoint = `/hosted_file/${hosted_file_id}`; @@ -923,14 +1118,23 @@ export let delete_hosted_file = async function delete_hosted_file({api_cfg, host // Updated 2023-06-29 export let get_data_store_obj_w_code = async function get_data_store_obj_w_code({ - api_cfg, - data_store_code, - data_type='text', - headers={}, - params={}, - timeout=25000, - log_lvl=0 - }) { + api_cfg, + data_store_code, + data_type='text', + headers={}, + params={}, + timeout=25000, + log_lvl=0 + } : { + api_cfg: any, + data_store_code: string, + data_type?: string, + headers?: key_val, + params?: key_val, + timeout?: number, + log_lvl?: number + } + ) { if (log_lvl) { console.log('*** get_data_store_obj_w_code() ***'); } @@ -974,7 +1178,47 @@ export let get_data_store_obj_w_code = async function get_data_store_obj_w_code( /* BEGIN: Utility: Email Related */ // Updated 2023-06-29 -export let send_email = async function send_email({api_cfg, from_email, from_name='', to_email, to_name='', cc_email=null, cc_name=null, bcc_email=null, bcc_name=null, subject, body_html, body_text=null, headers={}, params={}, data={}, return_obj=false, return_meta=false, log_lvl=0}) { +export let send_email = async function send_email( + { + api_cfg, + from_email, + from_name='', + to_email, + to_name='', + cc_email=null, + cc_name=null, + bcc_email=null, + bcc_name=null, + subject, + body_html, + body_text=null, + headers={}, + params={}, + data={}, + return_obj=false, + return_meta=false, + log_lvl=0 + } : { + api_cfg: any, + from_email: string, + from_name?: string, + to_email: string, + to_name?: string, + cc_email?: string, + cc_name?: string, + bcc_email?: string, + bcc_name?: string, + subject: string, + body_html: string, + body_text?: string, + headers?: key_val, + params?: key_val, + data?: key_val, + return_obj?: boolean, + return_meta?: boolean, + log_lvl?: number + } + ) { console.log('*** send_email() ***'); let endpoint = `/util/email/send`; @@ -1004,7 +1248,14 @@ export let send_email = async function send_email({api_cfg, from_email, from_nam params['return_obj'] = true; } - let send_email_post_promise = await api.post_object({api_cfg: api_cfg, endpoint: endpoint, headers: headers, params: params, data: data, return_meta: return_meta, log_lvl: log_lvl}); + let send_email_post_promise = await api.post_object({ + api_cfg: api_cfg, + endpoint: endpoint, + params: params, + data: data, + return_meta: return_meta, + log_lvl: log_lvl + }); if (log_lvl > 1) { console.log('Response Data:', send_email_post_promise); diff --git a/src/lib/api_2024-05-23.js b/src/lib/api_2024-05-23.js deleted file mode 100644 index 74d6350d..00000000 --- a/src/lib/api_2024-05-23.js +++ /dev/null @@ -1,1591 +0,0 @@ -import axios from 'axios'; -import { readable, writable } from 'svelte/store'; - -// console.log('*** Using api.js ***'); - - -export let delete_object = async function delete_object({api_cfg=null, endpoint='', params={}, data={}, return_meta=false, log_lvl=0}) { - console.log('*** delete_object() ***'); - - if (log_lvl) { - // console.log(api_cfg); - console.log(endpoint); - console.log(params); - if (log_lvl > 1) { - console.log('Data:', data); - console.log(typeof data); - } - // console.log(return_meta); - // console.log(as_list); - } - - // https://stackoverflow.com/questions/51069552/axios-delete-request-with-body-and-headers - - let axios_api = axios.create({ - baseURL: api_cfg['base_url'], - // timeout: 2000, - /* other custom settings */ - }); - axios_api.defaults.headers = api_cfg['headers']; - - //OLD: axios_api.delete(endpoint, { 'data': data }) - let response_data = await axios_api.delete(endpoint, { params: params, 'data': data }) - .then(function (response) { - console.log(response.data); - return response.data; - }) - .catch(function (error) { - if (error.response && error.response.status === 404) { - return null; // Returning null since there were no results - } - console.log(error); - return false; // Returning false since something may have gone wrong. Also more in line with what the API returns. - // return error; - }); - - if (log_lvl > 1) { - console.log(response_data); - } - return response_data; -} - - -export let temp_get_blob_percent_completed = 0; -// export let get_blob_percent_completed = readable(temp_get_blob_percent_completed); -export let get_blob_percent_completed = temp_get_blob_percent_completed; - -export let temp_get_object_percent_completed = 0; -// export let get_object_percent_completed = readable(temp_get_object_percent_completed); -export let get_object_percent_completed = temp_get_object_percent_completed; - -// Updated 2022-10-28 -export let get_object = async function get_object( - { - api_cfg=null, - endpoint='', - headers={}, - params={}, - data={}, - timeout=60000, - return_meta=false, - return_blob=false, - filename=null, - auto_download=false, - as_list=false, - // The task_id value should be a random string that is unique to the task. This is used to identify the task in the message event. - task_id='get_object_x', - log_lvl=0 - // }: { - // api_cfg: any, - // endpoint: string, - // headers?: any, - // params?: any, - // data?: any, - // timeout?: number, - // return_meta?: boolean, - // return_blob?: boolean, - // filename?: string, - // auto_download?: boolean, - // as_list?: boolean, - // log_lvl?: number - } - ) { - if (log_lvl) { - console.log(`*** get_object() *** Endpoint: ${endpoint} Task ID: ${task_id}`); - console.log('Params:', params); - if (log_lvl > 1) { - console.log('Data:', data); - console.log(`Base URL: ${api_cfg['base_url']}`); - console.log('API Config:', api_cfg); - } - if (log_lvl > 2) { - console.log(`Return Meta: ${return_meta}`); - console.log(`Return Blob: ${return_blob}`); - console.log(`Filename: ${filename}`); - console.log(`Auto Download: ${auto_download}`); - } - } - - if (!api_cfg) { - console.log('No API Config was provided. Returning false.'); - return false; - } - - let axios_api = axios.create({ - baseURL: api_cfg['base_url'], - timeout: timeout, // in milliseconds; 60000 = 60 seconds - /* other custom settings */ - }); - axios_api.defaults.headers = api_cfg['headers']; - if (log_lvl) { - console.log('axios_api.defaults.headers:', axios_api.defaults.headers); - console.log('Additional headers:', headers); - } - - // console.log('Clean the headers. No _underscores_!') - let headers_cleaned = {}; - for (const prop in headers) { - // No underscores allowed in the header parameters! - let prop_cleaned = prop.replaceAll('_', '-'); - - // The value must be a string for the header! - if (typeof headers[prop] != 'string') { - headers[prop] = JSON.stringify(headers[prop]); - } - - headers_cleaned[prop_cleaned] = headers[prop]; - - if (log_lvl) { - console.log(`${prop_cleaned}: ${headers_cleaned[prop_cleaned]}`); - } - } - headers = headers_cleaned; - if (log_lvl) { - console.log('All headers cleaned:', headers); - } - - if (log_lvl) { - console.log('URL params:'); - } - for (const prop in params) { - if (log_lvl) { - console.log(`URL param: ${prop}: ${params[prop]}`); - } - if (params[prop] === null ) { - params[prop] = 'null'; - } - } - - if (!return_blob) { - // let response_data_promise = await axios_api.get( - // endpoint, - // { - // params: params, - // 'paramsSerializer': params => parse_params(params), - // onDownloadProgress: (progressEvent) => { - // let percent_completed = Math.round( - // (progressEvent.loaded * 100) / progressEvent.total - // ); - // console.log('GET Data Timestamp:', progressEvent.timeStamp, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed); - - // temp_get_object_percent_completed = percent_completed; - // } - // } - // ) - let response_data_promise = await axios_api.get( - endpoint, - { - headers: headers, - params: params, - onDownloadProgress: (progressEvent) => { - let percent_completed = Math.round( - (progressEvent.loaded * 100) / progressEvent.total - ); - // console.log('GET Data Timestamp:', progressEvent.timeStamp, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed); - - temp_get_object_percent_completed = percent_completed; - } - } - ) - .then(function (response) { - if (log_lvl) { - console.log(`GET Response: status=${response.status} statusText=${response.statusText} baseURL=${response.config.baseURL} url=${response.config.url} method=${response.config.method} headers=${response.config.headers} params=${JSON.stringify(response.config.params)}`); - } - if (log_lvl > 1) { - console.log('GET Response:', response); - } - if (!Array.isArray(response.data['data']) && as_list) { - if (log_lvl) { - console.log('Data result is a dictionary/object, not an array/list. Forcing return as an array/list'); - } - let return_data = []; - return_data.push(response.data['data']); - return return_data; - } else if (response.data['data']) { - let return_data = response.data['data']; - if (log_lvl) { - if (Array.isArray(return_data)) { - console.log(`Data result is an array/list. Array length: ${return_data.length}`); - } else { - console.log(`Data result is a dictionary/object, not an array/list.`); - } - } - return return_data; - } else { - let return_data = response.data; - if (log_lvl) { - if (Array.isArray(return_data)) { - console.log(`Not a standard response from Aether's API. Data result is an array/list. Array length: ${return_data.length}`); - } else { - console.log(`Not a standard response from Aether's API. Data result is a dictionary/object, not an array/list.`); - } - } - return return_data; - } - }) - .catch(function (error) { - if (log_lvl) { - console.log(`Base URL: ${api_cfg['base_url']} | Endpoint: ${endpoint}`); - console.log('Error Message:', error.message); // Is this needed here or below in the in the else portion??? - - if (error.response) { - // The request was made and the server responded with a status code that falls out of the range of 2xx - console.log('Error Response Data', error.response.data); - console.log('Error Response Status', error.response.status); - console.log('Error Response Headers', error.response.headers); - } else if (error.request) { - // The request was made but no response was received `error.request` is an instance of XMLHttpRequest in the browser and an instance of http.ClientRequest in node.js - if (log_lvl > 1) { - console.log('Error Request', error.request); - } - } else { - // Something happened in setting up the request that triggered an Error - console.log('Error Message', error.message); - } - } - if (log_lvl > 2) { - console.log('Error:', error); - console.log(error.config); - } - - if (error.response && error.response.status === 404) { - if (log_lvl) { - console.log('The response was a 404 not found "error". Returning null.'); - } - if (log_lvl > 1) { - console.log(error.response); - } - if (log_lvl > 2) { - console.log(error); - } - return null; // Returning null since there were no results - } - if (error.code === 'ECONNABORTED') { - // Timeout Error (You can implement retry here where suitable) - console.log('Timeout Error: ', error.message); - } - if (log_lvl) { - console.log('The response was an error. Returning false.'); - } - - return false; // Returning false since something may have gone wrong. This includes timeouts. Also more in line with what the API returns. - // return error; - }); - - if (log_lvl > 1) { - // console.log(`Response Data: ${response_data_promise}`); - console.log(`Response Data:`, response_data_promise); - // console.log(response_data_promise); - } - if (response_data_promise) { - // The most common and expected response. - // console.log('Returning result. This is generally expected.'); - return response_data_promise; - } else if (response_data_promise === null) { - // Less common, but expected response if no results were returned. - console.log('Returning null. This is expected if no results were found.'); - return response_data_promise; - } else if (response_data_promise === false) { - // Not common, but expected response if the request to the API had an issue. - console.log('Returning false. There may have been an issue with this request.'); - return response_data_promise; - } else { - // This generally should not happen. It likely means the query was bad or an API issue. - console.log('Returning unknown. This should not happen in most cases.'); - Promise.reject(new Error('fail')).then(resolved, rejected); - } - } else { - // console.log('Expecting a Blob to be returned...'); - - let response_data_promise = await axios_api.get( - endpoint, - { - params: params, - // 'paramsSerializer': params => parse_params(params), - responseType: 'blob', - onDownloadProgress: (progressEvent) => { - let percent_completed = Math.round( - (progressEvent.loaded * 100) / progressEvent.total - ); - console.log('GET Blob Progress:', progressEvent.progress, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed); - - temp_get_blob_percent_completed = percent_completed; - - // WARNING: This needs to be tied to an object type and ID. This is a temporary solution. - try { - window.postMessage({ - type: 'api_download_blob', - endpoint: endpoint, - filename: filename, - size_total: progressEvent.total, - size_loaded: progressEvent.loaded, - percent_completed: percent_completed - }, - '*' - ); - } catch (error) { - console.log('Error posting message to window:', error); - } - } - } - ) - .then(function (response) { - if (log_lvl) { - console.log(`GET (blob) Response: status=${response.status} statusText=${response.statusText} baseURL=${response.config.baseURL} url=${response.config.url} method=${response.config.method} headers=${response.config.headers} params=${response.config.params}`); - } - if (log_lvl > 1) { - console.log('GET (blob) Response:', response); - } - - const { data, headers } = response; - - // Careful if this download filename needs to be changed to a different file extension. The browser/client may not know how to handle it. - if (filename) { - } else if (headers['content-disposition']) { - filename = headers['content-disposition'].replace(/\w+;filename=(.*)/, '$1'); - } else { - filename = 'unknown_file.ext'; - } - - // WARNING: This needs to be tied to an object type and ID. This is a temporary solution. - try { - window.postMessage({ - type: 'api_download_blob', endpoint: endpoint, filename: filename, size_total: 0, size_loaded: 0, percent_completed: 100 - }, - '*' - ); - } catch (error) { - console.log('Error posting message to window:', error); - } - - if (auto_download) { - if (log_lvl) { - console.log(`Auto Download: ${filename}`); - } - const url = window.URL.createObjectURL(new Blob([response.data])); - const link = document.createElement('a'); - link.href = url; - link.setAttribute('download', filename); - document.body.appendChild(link); - link.click(); - return true; - } else { - return response; - } - }); - - if (response_data_promise) { - // The most common and expected response. - // console.log('Returning result. This is generally expected.'); - // let test_blob = new Blob([response_data_promise.data]); - // console.log(test_blob); - // return test_blob; - // console.log(response_data_promise.blob()); - return response_data_promise; - } else { - // This generally should not happen. It likely means the query was bad or an API issue. - console.log('Returning (blob) unknown. This should not happen in most cases.'); - Promise.reject(new Error('fail')).then(resolved, rejected); - } - } -} - -export let patch_object = async function patch_object({api_cfg=null, endpoint='', params={}, data={}, return_meta=false, log_lvl=0}) { - console.log('*** patch_object() ***'); - - if (log_lvl) { - // console.log(api_cfg); - console.log(endpoint); - console.log(params); - if (log_lvl > 1) { - console.log(data); - } - // console.log(return_meta); - // console.log(as_list); - } - - let axios_api = axios.create({ - baseURL: api_cfg['base_url'], - /* other custom settings */ - }); - axios_api.defaults.headers = api_cfg['headers']; - - let response_data = await axios_api.patch(endpoint, data, { params: params }) - .then(function (response) { - console.log(response.data); - return response.data['data']; - //return response.data; - }) - .catch(function (error) { - if (error.response && error.response.status === 404) { - return null; // Returning null since there were no results - } - console.log(error); - return false; // Returning false since something may have gone wrong. Also more in line with what the API returns. - // return error; - }); - - if (log_lvl > 1) { - console.log(response_data); - } - return response_data; -} - - -export let temp_post_blob_percent_completed = 0; -export let post_blob_percent_completed = temp_post_blob_percent_completed; -export let temp_post_object_percent_completed = 0; -export let post_object_percent_completed = temp_post_object_percent_completed; - -// Updated 2023-11-10 -export let post_object = async function post_object( - { - api_cfg=null, - endpoint='', - params={}, - data={}, - form_data=null, - return_meta=false, - return_blob=false, - filename='', - auto_download=false, - // The task_id value should be a random string that is unique to the task. This is used to identify the task in the message event. - task_id='post_object_x', - log_lvl=0 - } - ) { - - if (log_lvl) { - console.log(`*** post_object() *** Endpoint: ${endpoint} Task ID: ${task_id}`); - console.log('Params:', params); - if (log_lvl > 1) { - console.log('Data:', data); - console.log(typeof data); - console.log(`Base URL: ${api_cfg['base_url']}`); - console.log('API Config:', api_cfg); - } - if (log_lvl > 2) { - console.log(`Return Meta: ${return_meta}`); - console.log(`Return Blob: ${return_blob}`); - console.log(`Filename: ${filename}`); - console.log(`Auto Download: ${auto_download}`); - } - // console.log(return_meta); - } - - let axios_api = axios.create({ - baseURL: api_cfg['base_url'], - /* other custom settings */ - }); - axios_api.defaults.headers = api_cfg['headers']; - console.log('Axios API', axios_api); - // console.log('Axios API POST', axios_api.post); - - // if (typeof data == 'FormData') { - if (form_data) { - axios_api.defaults.headers['content-type'] = 'multipart/form-data'; - data = form_data; - } else { - axios_api.defaults.headers['content-type'] = 'application/json'; - } - - - if (!return_blob) { - let response_data = await axios_api.post( - endpoint, - data, - { - params: params, - onUploadProgress: (progressEvent) => { - let percent_completed = Math.round( - (progressEvent.loaded * 100) / progressEvent.total - ); - console.log('POST Progress:', progressEvent.progress, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed); - - temp_post_object_percent_completed = percent_completed; - - try { - window.postMessage({ - type: 'api_post_json_form', - endpoint: endpoint, - size_total: progressEvent.total, - size_loaded: progressEvent.loaded, - percent_completed: percent_completed, - progress: progressEvent.progress, - rate: progressEvent.rate, - }, - '*' - ); - } catch (error) { - console.log('Error posting message to window:', error); - } - } - } - ) - .then(function (response) { - console.log('POST Response Data:', response.data); - if (response.data['data'].result === null) { - // This should mean that the request was successful, but a result of None/null was returned from Aether API. - // console.log('Returning null after POST'); - return null; - } else { - // This should mean that the request was successful, and a result with data was returned from Aether API. - // console.log('Returning data after POST'); - return response.data['data']; - } - //return response.data; - }) - .catch(function (error) { - if (error.response && error.response.status === 404) { - return null; // Returning null since there were no results - } - console.log(error); - return false; // Returning false since something may have gone wrong. Also more in line with what the API returns. - // return error; - }); - - if (log_lvl > 1) { - console.log('Response Data:', response_data); - } - axios_api.defaults.headers['content-type'] = 'application/json'; - return response_data; - - } else { - // console.log('Expecting a Blob to be returned...'); - - let response_data_promise = await axios_api.post( - endpoint, - data, - { - params: params, - responseType: 'blob', - onDownloadProgress: (progressEvent) => { - let percent_completed = Math.round( - (progressEvent.loaded * 100) / progressEvent.total - ); - console.log('POST Blob Timestamp:', progressEvent.timeStamp, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed); - - temp_get_blob_percent_completed = percent_completed; - } - } - ) - .then(function (response) { - if (log_lvl) { - console.log(response); - } - - const { data, headers } = response - console.log(headers); - - if (filename) { - } else if (headers['content-disposition']) { - filename = headers['content-disposition'].replace(/\w+;filename=(.*)/, '$1'); - } else { - filename = 'unknown_file.ext'; - } - - if (auto_download) { - const url = window.URL.createObjectURL(new Blob([response.data])); - const link = document.createElement('a'); - link.href = url; - // link.setAttribute('download', 'event_exhibit_tracking_export.xlsx'); //or any other extension - link.setAttribute('download', filename); //or any other extension - document.body.appendChild(link); - link.click(); - return true; - } else { - return response; - } - }); - - if (response_data_promise) { - // The most common and expected response. - // console.log('Returning result. This is generally expected.'); - // let test_blob = new Blob([response_data_promise.data]); - // console.log(test_blob); - // return test_blob; - // console.log(response_data_promise.blob()); - return response_data_promise; - } else { - // This generally should not happen. It likely means the query was bad or an API issue. - console.log('Returning unknown. This should not happen in most cases.'); - Promise.reject(new Error('fail')).then(resolved, rejected); - } - } -} - - -// Updated 2023-12-01 -export let get_ae_obj_id_crud = async function get_ae_obj_id_crud({ - api_cfg, - no_account_id=false, - obj_type, - obj_id, - use_alt_table=false, - use_alt_base=false, - inc={}, - enabled='enabled', - hidden='not_hidden', - limit=999999, - offset=0, - data={}, - // key, - jwt=null, - headers={}, - params={}, - timeout=25000, - return_meta=false, - log_lvl=0}) { - if (log_lvl) { - console.log('*** get_ae_obj_id_crud() ***'); - } - - // data = {}; - // data['super_key'] = key; - // data['jwt'] = jwt; - // NOTE: The key and or JWT should be in the header of the DELETE, GET, PATCH, POST - - let endpoint = ''; - if (obj_type == 'account') { - endpoint = `/crud/account/${obj_id}`; - } else if (obj_type == 'address') { - endpoint = `/crud/address/${obj_id}`; - } else if (obj_type == 'archive') { - endpoint = `/crud/archive/${obj_id}`; - } else if (obj_type == 'archive_content') { - endpoint = `/crud/archive/content/${obj_id}`; - } else if (obj_type == 'contact') { - endpoint = `/crud/contact/${obj_id}`; - } else if (obj_type == 'data_store') { - endpoint = `/crud/data_store/${obj_id}`; - } else if (obj_type == 'event') { - endpoint = `/crud/event/${obj_id}`; - } else if (obj_type == 'event_abstract') { - endpoint = `/crud/event/abstract/${obj_id}`; - } else if (obj_type == 'event_badge') { - endpoint = `/crud/event/badge/${obj_id}`; - } else if (obj_type == 'event_device') { - endpoint = `/crud/event/device/${obj_id}`; - } else if (obj_type == 'event_exhibit') { - endpoint = `/crud/event/exhibit/${obj_id}`; - } else if (obj_type == 'event_exhibit_tracking') { - endpoint = `/crud/event/exhibit/tracking/${obj_id}`; - } else if (obj_type == 'event_file') { - endpoint = `/crud/event/file/${obj_id}`; - } else if (obj_type == 'event_location') { - endpoint = `/crud/event/location/${obj_id}`; - } else if (obj_type == 'event_person') { - endpoint = `/crud/event/person/${obj_id}`; - } else if (obj_type == 'event_presentation') { - endpoint = `/crud/event/presentation/${obj_id}`; - } else if (obj_type == 'event_presenter') { - endpoint = `/crud/event/presenter/${obj_id}`; - } else if (obj_type == 'event_session') { - endpoint = `/crud/event/session/${obj_id}`; - } else if (obj_type == 'event_track') { - endpoint = `/crud/event/track/${obj_id}`; - } else if (obj_type == 'grant') { - endpoint = `/crud/grant/${obj_id}`; - } else if (obj_type == 'hosted_file') { - endpoint = `/crud/hosted_file/${obj_id}`; - } else if (obj_type == 'journal') { - endpoint = `/crud/journal/${obj_id}`; - } else if (obj_type == 'journal_entry') { - endpoint = `/crud/journal/entry/${obj_id}`; - } else if (obj_type == 'order') { - endpoint = `/crud/order/${obj_id}`; - } else if (obj_type == 'order_line') { - endpoint = `/crud/order/line/${obj_id}`; - } else if (obj_type == 'page') { - endpoint = `/crud/page/${obj_id}`; - } else if (obj_type == 'person') { - endpoint = `/crud/person/${obj_id}`; - } else if (obj_type == 'post') { - endpoint = `/crud/post/${obj_id}`; - } else if (obj_type == 'post_comment') { - endpoint = `/crud/post/comment/${obj_id}`; - } else if (obj_type == 'site') { - endpoint = `/crud/site/${obj_id}`; - } else if (obj_type == 'site_domain') { - endpoint = `/crud/site/domain/${obj_id}`; - } else if (obj_type == 'sponsorship_cfg') { - endpoint = `/crud/sponsorship/cfg/${obj_id}`; - } else if (obj_type == 'sponsorship') { - endpoint = `/crud/sponsorship/${obj_id}`; - // } else if (obj_type == 'user') { - // endpoint = `/crud/user/${obj_id}`; - } else { - console.log(`Unknown object type: ${obj_type}`); - return false; - } - if (log_lvl) { - console.log('Endpoint:', endpoint); - } - - params['use_alt_table'] = use_alt_table; - params['use_alt_base'] = use_alt_base; - - if (log_lvl) { - console.log('Params:', params); - } - - if (no_account_id) { - headers['x-no-account-id'] = 'Nothing to See Here'; - delete headers['x-account-id']; - delete api_cfg['headers']['x-account-id']; - // headers['x-account-id'] = null; - // headers['x-account-id'] = '_XY7DXtc9Mxx'; - // params['x_no_account_id_token'] = 'Nothing to See Here'; - - // Remove the x-account-id header - // if (headers['x-account-id']) { - // delete headers['x-account-id']; - // } - - // headers['x-account-id'] = null; - // headers['x-no-account-id-token'] = 'Nothing to See Here'; // get_object() will fix the underscores to dashes - } - - let object_obj_get_promise = await get_object({ - api_cfg: api_cfg, - endpoint: endpoint, - headers: headers, - params: params, - timeout: timeout, - log_lvl: log_lvl - }); - - if (log_lvl > 1) { - console.log(object_obj_get_promise); - } - - return object_obj_get_promise; -} - - -// Updated 2023-11-15 -export let get_ae_obj_li_for_obj_id_crud = async function get_ae_obj_li_for_obj_id_crud({ - api_cfg, - obj_type, - for_obj_type, - for_obj_id=null, // NOTE: Changed 2023-12-06 to no longer required - use_alt_table=false, - use_alt_base=false, - inc={}, - enabled='enabled', - hidden='not_hidden', - order_by_li=null, - limit=999999, - offset=0, - key, - jwt=null, - headers={}, - params_json=null, // NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the API endpoint. Example: { "fulltext_search": { "default_qry_str": "Search string for default", "address_default_qry_str": "Search string for address", "contact_1_default_qry_str": "Search string for contact_1" } } - // json_obj=null, // NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the search endpoint. - params={}, - return_meta=false, - log_lvl=0 - }) { - if (log_lvl) { - console.log('*** get_ae_obj_li_for_obj_id_crud() ***'); - } - - // data = {}; - // data['super_key'] = key; - // data['jwt'] = jwt; - // NOTE: The key and or JWT should be in the header of the DELETE, GET, PATCH, POST - - // const endpoint = `/crud/${obj_type}/list`; - - let endpoint = ''; - if (obj_type == 'account') { - endpoint = `/crud/account/list`; - } else if (obj_type == 'address') { - endpoint = `/crud/address/list`; - } else if (obj_type == 'archive') { - endpoint = `/crud/archive/list`; - } else if (obj_type == 'archive_content') { - endpoint = `/crud/archive/content/list`; - } else if (obj_type == 'contact') { - endpoint = `/crud/contact/list`; - } else if (obj_type == 'data_store') { - endpoint = `/crud/data_store/list`; - } else if (obj_type == 'event') { - endpoint = `/crud/event/list`; - } else if (obj_type == 'event_abstract') { - endpoint = `/crud/event/abstract/list`; - } else if (obj_type == 'event_badge') { - endpoint = `/crud/event/badge/list`; - } else if (obj_type == 'event_device') { - endpoint = `/crud/event/device/list`; - } else if (obj_type == 'event_exhibit') { - endpoint = `/crud/event/exhibit/list`; - } else if (obj_type == 'event_exhibit_tracking') { - endpoint = `/crud/event/exhibit/tracking/list`; - } else if (obj_type == 'event_file') { - endpoint = `/crud/event/file/list`; - } else if (obj_type == 'event_location') { - endpoint = `/crud/event/location/list`; - } else if (obj_type == 'event_person') { - endpoint = `/crud/event/person/list`; - } else if (obj_type == 'event_presentation') { - endpoint = `/crud/event/presentation/list`; - } else if (obj_type == 'event_presenter') { - endpoint = `/crud/event/presenter/list`; - } else if (obj_type == 'event_session') { - endpoint = `/crud/event/session/list`; - } else if (obj_type == 'event_track') { - endpoint = `/crud/event/track/list`; - } else if (obj_type == 'grant') { - endpoint = `/crud/grant/list`; - } else if (obj_type == 'hosted_file') { - endpoint = `/crud/hosted_file/list`; - } else if (obj_type == 'journal') { - endpoint = `/crud/journal/list`; - } else if (obj_type == 'journal_entry') { - endpoint = `/crud/journal/entry/list`; - } else if (obj_type == 'order') { - endpoint = `/crud/order/list`; - } else if (obj_type == 'order_line') { - endpoint = `/crud/order/line/list`; - } else if (obj_type == 'page') { - endpoint = `/crud/page/list`; - } else if (obj_type == 'person') { - endpoint = `/crud/person/list`; - } else if (obj_type == 'post') { - endpoint = `/crud/post/list`; - } else if (obj_type == 'post_comment') { - endpoint = `/crud/post/comment/list`; - } else if (obj_type == 'site') { - endpoint = `/crud/site/list`; - } else if (obj_type == 'sponsorship_cfg') { - endpoint = `/crud/sponsorship/cfg/list`; - } else if (obj_type == 'sponsorship') { - endpoint = `/crud/sponsorship/list`; - // } else if (obj_type == 'user') { - // endpoint = `/crud/user/list`; - } else if (obj_type == 'lu' && for_obj_type == 'country_subdivision') { - endpoint = `/crud/lu/country_subdivision/list`; - for_obj_type = null; - } else if (obj_type == 'lu' && for_obj_type == 'country') { - endpoint = `/crud/lu/country/list`; - for_obj_type = null; - } else if (obj_type == 'lu' && for_obj_type == 'time_zone') { - endpoint = `/crud/lu/time_zone/list`; - for_obj_type = null; - } else { - console.log(`Unknown object type: ${obj_type}`); - return false; - } - if (log_lvl) { - console.log('Endpoint:', endpoint); - } - - if (for_obj_type) { - params['for_obj_type'] = for_obj_type; - } - if (for_obj_id) { - params['for_obj_id'] = for_obj_id; - } - - params['use_alt_table'] = use_alt_table; - params['use_alt_base'] = use_alt_base; - - /* Need to deal with inc params here */ - - let allowed_enabled_list = ['all', 'enabled', 'not_enabled'] - if (allowed_enabled_list.includes(enabled) ) { - params['enabled'] = enabled; - } - - let allowed_hidden_list = ['all', 'hidden', 'not_hidden']; - if (allowed_hidden_list.includes(hidden) ) { - params['hidden'] = hidden; - } - - // NOTE: The order_by_li variable is in the "headers" because if is a the URL GET params do not handle multiple values very well. Maybe base64 encore in the future or something? Reminder that GET requests should not have a body (no JSON). - // NOTE: The order_by_li should be a key value pair of the property/DB field to sort and how to sort (ASC or DESC) - if (order_by_li) { - headers['order_by_li'] = order_by_li; - } - - if (limit >= 0) { - params['limit'] = limit; - } - - if (offset >= 0) { - params['offset'] = offset; - } - - if (params_json) { - // NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the search endpoint. - // Max characters for a GET request is 2083. This is a limitation of the browser (Microsoft IE and Edge). - console.log('JSON Object:', params_json); - console.log(JSON.stringify(params_json)); - // NOTE: "jp" stands for "JSON Params" - params['jp'] = encodeURIComponent(JSON.stringify(params_json)); - if (params['jp'].length > 2083) { - console.log(`The JSON object is too large to be used as a GET parameter. The overall max URL length is 2083 characters. Please use the POST endpoint instead. Length = ${params['jp'].length} [THIS DOES NOT EXIST YET]`); - return false; - } - } - - // if (json_obj) { - // // NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the search endpoint. - // // Max characters for a GET request is 2083. This is a limitation of the browser (Microsoft IE and Edge). - // console.log('JSON Object:', json_obj); - // params['json_str'] = encodeURIComponent(JSON.stringify(json_obj)); - // if (params['json_str'].length > 2083) { - // console.log(`The JSON object is too large to be used as a GET parameter. The overall max URL length is 2083 characters. Please use the POST endpoint instead. Length = ${params['json_str'].length} [THIS DOES NOT EXIST YET]`); - // return false; - // } - // } - - if (log_lvl) { - console.log('Params:', params); - } - - let object_li_get_promise = await api.get_object({ - api_cfg: api_cfg, - endpoint: endpoint, - headers: headers, - params: params, - return_meta: return_meta, - log_lvl: log_lvl - }); - - if (log_lvl > 1) { - console.log(object_li_get_promise); - } - - return object_li_get_promise; -} - - -// Updated 2023-07-24 -export let create_ae_obj_crud = async function create_ae_obj_crud({api_cfg, obj_type, field_name=null, field_value=null, fields={}, key, jwt=null, headers={}, params={}, data={}, return_obj=false, obj_v_name='', return_meta=false, log_lvl=0}) { - if (log_lvl) { - console.log('*** create_ae_obj_crud() ***'); - } - - data['super_key'] = key; - data['jwt'] = jwt; - // NOTE: The key and or JWT should be in the header of the DELETE, GET, PATCH, POST - - // This obj_v_name is the view name to use when returning data. Do not prefix it with v_. This is checked and done automatically by the API. - // This is not currently being exposed to other areas of the code. It is only used here. For now? - if (obj_v_name) { - obj_v_name = ''; - } - - let endpoint = ''; - if (obj_type == 'account') { - endpoint = `/crud/account`; - } else if (obj_type == 'address') { - endpoint = `/crud/address`; - } else if (obj_type == 'archive') { - endpoint = `/crud/archive`; - } else if (obj_type == 'archive_content') { - endpoint = `/crud/archive/content`; - } else if (obj_type == 'contact') { - endpoint = `/crud/contact`; - } else if (obj_type == 'data_store') { - endpoint = `/crud/data_store`; - } else if (obj_type == 'event') { - endpoint = `/crud/event`; - } else if (obj_type == 'event_abstract') { - endpoint = `/crud/event/abstract`; - } else if (obj_type == 'event_badge') { - endpoint = `/crud/event/badge`; - } else if (obj_type == 'event_device') { - endpoint = `/crud/event/device`; - } else if (obj_type == 'event_exhibit') { - endpoint = `/crud/event/exhibit`; - } else if (obj_type == 'event_exhibit_tracking') { - endpoint = `/crud/event/exhibit/tracking`; - } else if (obj_type == 'event_file') { - endpoint = `/crud/event/file`; - } else if (obj_type == 'event_location') { - endpoint = `/crud/event/location`; - } else if (obj_type == 'event_person') { - endpoint = `/crud/event/person`; - } else if (obj_type == 'event_presentation') { - endpoint = `/crud/event/presentation`; - } else if (obj_type == 'event_presenter') { - endpoint = `/crud/event/presenter`; - // obj_v_name = 'event_presenter_soft_links'; - } else if (obj_type == 'event_session') { - endpoint = `/crud/event/session`; - } else if (obj_type == 'event_track') { - endpoint = `/crud/event/track`; - } else if (obj_type == 'grant') { - endpoint = `/crud/grant`; - } else if (obj_type == 'hosted_file') { - endpoint = `/crud/hosted_file`; - } else if (obj_type == 'journal') { - endpoint = `/crud/journal`; - } else if (obj_type == 'journal_entry') { - endpoint = `/crud/journal/entry`; - } else if (obj_type == 'order') { - endpoint = `/crud/order`; - } else if (obj_type == 'order_line') { - endpoint = `/crud/order/line`; - } else if (obj_type == 'page') { - endpoint = `/crud/page`; - } else if (obj_type == 'person') { - endpoint = `/crud/person`; - } else if (obj_type == 'post') { - endpoint = `/crud/post`; - } else if (obj_type == 'post_comment') { - endpoint = `/crud/post/comment`; - } else if (obj_type == 'sponsorship_cfg') { - endpoint = `/crud/sponsorship/cfg`; - } else if (obj_type == 'sponsorship') { - endpoint = `/crud/sponsorship`; - } else if (obj_type == 'site') { - endpoint = `/crud/site`; - // } else if (obj_type == 'user') { - // endpoint = `/crud/user`; - } else { - console.log(`Unknown object type: ${obj_type}`); - return false; - } - if (log_lvl) { - console.log('Endpoint:', endpoint); - } - - if (return_obj) { - params['return_obj'] = true; - - // Pass along the view name to use for returning data. - if (obj_v_name) { - params['obj_v_name'] = obj_v_name; - } - } else { - params['return_obj'] = false; // NOTE: This is needed because the current default on the API is to return the object. - } - - if (field_name) { - data['data_list'] = {}; // Really an object/dict - data['data_list'][field_name] = field_value; - // data['data_list']['testing'] = 'asdf 1234'; - } else if (fields) { - data['data_list'] = fields; // Really an object/dict - } - - // NOTE: The data object may contain objects that need to be converted to JSON strings. This is done by adding "_json" to the end of the property name. This is done because the API does not support nested objects. This is a limitation of the API. - if (data['data_list']) { - if (log_lvl > 1) { - console.log('Data List:', data['data_list']); - } - for (const [key, value] of Object.entries(data['data_list'])) { - // console.log(key, value); - if (key.endsWith('_json')) { - if (log_lvl) { - console.log(`${key}: ${value}`); - } - data['data_list'][key] = JSON.stringify(value); - } - } - } - - if (log_lvl) { - console.log('Data:', data); - } - // params['xxxxx run_safety_check xxxxx'] = false; - params['by_alias'] = false; - - if (log_lvl) { - console.log('Params:', params); - } - - let object_obj_post_promise = await post_object({api_cfg: api_cfg, endpoint: endpoint, params: params, data: data, log_lvl: log_lvl}); - - if (log_lvl > 1) { - console.log(object_obj_post_promise); - } - - return object_obj_post_promise; -} - - -// Updated 2023-06-28 -export let update_ae_obj_id_crud = async function update_ae_obj_id_crud({api_cfg, obj_type, obj_id, field_name, field_value, fields={}, key, jwt=null, headers={}, params={}, data={}, return_obj=false, obj_v_name='', return_meta=false, log_lvl=0}) { - if (log_lvl) { - console.log('*** update_ae_obj_id_crud() ***'); - } - - data['super_key'] = key; - data['jwt'] = jwt; - // NOTE: The key and or JWT should be in the header of the DELETE, GET, PATCH, POST - - // This obj_v_name is the view name to use when returning data. Do not prefix it with v_. This is checked and done automatically by the API. - // This is not currently being exposed to other areas of the code. It is only used here. For now? - if (obj_v_name) { - obj_v_name = ''; - } - - let endpoint = ''; - if (obj_type == 'account') { - endpoint = `/crud/account/${obj_id}`; - } else if (obj_type == 'address') { - endpoint = `/crud/address/${obj_id}`; - } else if (obj_type == 'archive') { - endpoint = `/crud/archive/${obj_id}`; - } else if (obj_type == 'archive_content') { - endpoint = `/crud/archive/content/${obj_id}`; - } else if (obj_type == 'contact') { - endpoint = `/crud/contact/${obj_id}`; - } else if (obj_type == 'data_store') { - endpoint = `/crud/data_store/${obj_id}`; - } else if (obj_type == 'event') { - endpoint = `/crud/event/${obj_id}`; - } else if (obj_type == 'event_abstract') { - endpoint = `/crud/event/abstract/${obj_id}`; - } else if (obj_type == 'event_badge') { - endpoint = `/crud/event/badge/${obj_id}`; - } else if (obj_type == 'event_device') { - endpoint = `/crud/event/device/${obj_id}`; - } else if (obj_type == 'event_exhibit') { - endpoint = `/crud/event/exhibit/${obj_id}`; - } else if (obj_type == 'event_exhibit_tracking') { - endpoint = `/crud/event/exhibit/tracking/${obj_id}`; - } else if (obj_type == 'event_file') { - endpoint = `/crud/event/file/${obj_id}`; - } else if (obj_type == 'event_location') { - endpoint = `/crud/event/location/${obj_id}`; - } else if (obj_type == 'event_person') { - endpoint = `/crud/event/person/${obj_id}`; - } else if (obj_type == 'event_presentation') { - endpoint = `/crud/event/presentation/${obj_id}`; - } else if (obj_type == 'event_presenter') { - endpoint = `/crud/event/presenter/${obj_id}`; - // obj_v_name = 'event_presenter_soft_links'; - } else if (obj_type == 'event_session') { - endpoint = `/crud/event/session/${obj_id}`; - } else if (obj_type == 'event_track') { - endpoint = `/crud/event/track/${obj_id}`; - } else if (obj_type == 'grant') { - endpoint = `/crud/grant/${obj_id}`; - } else if (obj_type == 'hosted_file') { - endpoint = `/crud/hosted_file/${obj_id}`; - } else if (obj_type == 'journal') { - endpoint = `/crud/journal/${obj_id}`; - } else if (obj_type == 'journal_entry') { - endpoint = `/crud/journal/entry/${obj_id}`; - } else if (obj_type == 'order') { - endpoint = `/crud/order/${obj_id}`; - } else if (obj_type == 'order_line') { - endpoint = `/crud/order/line/${obj_id}`; - } else if (obj_type == 'page') { - endpoint = `/crud/page/${obj_id}`; - } else if (obj_type == 'person') { - endpoint = `/crud/person/${obj_id}`; - } else if (obj_type == 'post') { - endpoint = `/crud/post/${obj_id}`; - } else if (obj_type == 'post_comment') { - endpoint = `/crud/post/comment/${obj_id}`; - } else if (obj_type == 'site') { - endpoint = `/crud/site/${obj_id}`; - } else if (obj_type == 'sponsorship_cfg') { - endpoint = `/crud/sponsorship/cfg/${obj_id}`; - } else if (obj_type == 'sponsorship') { - endpoint = `/crud/sponsorship/${obj_id}`; - // } else if (obj_type == 'user') { - // endpoint = `/crud/user/${obj_id}`; - } else { - console.log(`Unknown object type: ${obj_type}`); - return false; - } - if (log_lvl) { - console.log('Endpoint:', endpoint); - } - - if (return_obj) { - params['return_obj'] = true; - - // Pass along the view name to use for returning data. - if (obj_v_name) { - params['obj_v_name'] = obj_v_name; - } - } else { - params['return_obj'] = false; // NOTE: This is needed because the current default on the API is to return the object. - } - - if (field_name) { - data['data_list'] = {}; // Really an object/dict - data['data_list'][field_name] = field_value; - // data['data_list']['testing'] = 'asdf 1234'; - } else if (fields) { - data['data_list'] = fields; // Really an object/dict - } - - // NOTE: The data object may contain objects that need to be converted to JSON strings. This is done by adding "_json" to the end of the property name. This is done because the API does not support nested objects. This is a limitation of the API. - if (data['data_list']) { - if (log_lvl > 1) { - console.log('Data List:', data['data_list']); - } - for (const [key, value] of Object.entries(data['data_list'])) { - // console.log(key, value); - if (key.endsWith('_json')) { - if (log_lvl) { - console.log(`${key}: ${value}`); - } - data['data_list'][key] = JSON.stringify(value); - } - } - } - - // If the data is an object then we need to loop through the object and convert any objects to JSON strings, but only if the property name ends with "_json". - // if (Array.isArray(data)) { - // // console.log('Data is an array'); - // for (let i = 0; i < data.length; i++) { - // // console.log(data[i]); - // if (typeof data[i] == 'object') { - // // console.log('Data is an object'); - // for (const [key, value] of Object.entries(data[i])) { - // // console.log(key, value); - // if (key.endsWith('_json')) { - // console.log(`${key}: ${value}`); - // data[i][key] = JSON.stringify(value); - // } - // } - - // } - // } - // } else if (typeof data == 'object') { - // // console.log('Data is an object'); - // for (const [key, value] of Object.entries(data)) { - // // console.log(key, value); - // if (key.endsWith('_json')) { - // console.log(`${key}: ${value}`); - // data[key] = JSON.stringify(value); - // } - // } - // } - - if (log_lvl) { - console.log('Data:', data); - } - // params['xxxxx run_safety_check xxxxx'] = false; - params['by_alias'] = false; - - if (log_lvl) { - console.log('Params:', params); - } - - let object_obj_patch_promise = await patch_object({api_cfg: api_cfg, endpoint: endpoint, params: params, data: data, log_lvl: log_lvl}); - - if (log_lvl > 1) { - console.log(object_obj_patch_promise); - } - - return object_obj_patch_promise; -} - - -// Updated 2023-11-14 -export let delete_ae_obj_id_crud = async function delete_ae_obj_id_crud({api_cfg, obj_type, obj_id, key, jwt=null, headers={}, params={}, data={}, method='delete', return_meta=false, log_lvl=0}) { - if (log_lvl) { - console.log(`*** delete_ae_obj_id_crud() *** obj_type: ${obj_type} obj_id: ${obj_id}`); - } - - data['super_key'] = key; - data['jwt'] = jwt; - // NOTE: The key and or JWT should be in the header of the DELETE, GET, PATCH, POST - - let endpoint = ''; - if (obj_type == 'account') { - endpoint = `/crud/account/${obj_id}`; - } else if (obj_type == 'address') { - endpoint = `/crud/address/${obj_id}`; - } else if (obj_type == 'archive') { - endpoint = `/crud/archive/${obj_id}`; - } else if (obj_type == 'archive_content') { - endpoint = `/crud/archive/content/${obj_id}`; - } else if (obj_type == 'contact') { - endpoint = `/crud/contact/${obj_id}`; - } else if (obj_type == 'data_store') { - endpoint = `/crud/data_store/${obj_id}`; - } else if (obj_type == 'event') { - endpoint = `/crud/event/${obj_id}`; - } else if (obj_type == 'event_abstract') { - endpoint = `/crud/event/abstract/${obj_id}`; - } else if (obj_type == 'event_badge') { - endpoint = `/crud/event/badge/${obj_id}`; - } else if (obj_type == 'event_device') { - endpoint = `/crud/event/device/${obj_id}`; - } else if (obj_type == 'event_exhibit') { - endpoint = `/crud/event/exhibit/${obj_id}`; - } else if (obj_type == 'event_exhibit_tracking') { - endpoint = `/crud/event/exhibit/tracking/${obj_id}`; - } else if (obj_type == 'event_file') { - endpoint = `/crud/event/file/${obj_id}`; - } else if (obj_type == 'event_location') { - endpoint = `/crud/event/location/${obj_id}`; - } else if (obj_type == 'event_person') { - endpoint = `/crud/event/person/${obj_id}`; - } else if (obj_type == 'event_presentation') { - endpoint = `/crud/event/presentation/${obj_id}`; - } else if (obj_type == 'event_presenter') { - endpoint = `/crud/event/presenter/${obj_id}`; - } else if (obj_type == 'event_session') { - endpoint = `/crud/event/session/${obj_id}`; - } else if (obj_type == 'event_track') { - endpoint = `/crud/event/track/${obj_id}`; - } else if (obj_type == 'grant') { - endpoint = `/crud/grant/${obj_id}`; - } else if (obj_type == 'hosted_file') { - endpoint = `/crud/hosted_file/${obj_id}`; - } else if (obj_type == 'journal') { - endpoint = `/crud/journal/${obj_id}`; - } else if (obj_type == 'journal_entry') { - endpoint = `/crud/journal/entry/${obj_id}`; - } else if (obj_type == 'order') { - endpoint = `/crud/order/${obj_id}`; - } else if (obj_type == 'order_line') { - endpoint = `/crud/order/line/${obj_id}`; - } else if (obj_type == 'page') { - endpoint = `/crud/page/${obj_id}`; - } else if (obj_type == 'person') { - endpoint = `/crud/person/${obj_id}`; - } else if (obj_type == 'post') { - endpoint = `/crud/post/${obj_id}`; - } else if (obj_type == 'post_comment') { - endpoint = `/crud/post/comment/${obj_id}`; - } else if (obj_type == 'site') { - endpoint = `/crud/site/${obj_id}`; - } else if (obj_type == 'sponsorship_cfg') { - endpoint = `/crud/sponsorship/cfg/${obj_id}`; - } else if (obj_type == 'sponsorship') { - endpoint = `/crud/sponsorship/${obj_id}`; - // } else if (obj_type == 'user') { - // endpoint = `/crud/user/${obj_id}`; - } else { - console.log(`Unknown object type: ${obj_type}`); - return false; - } - if (log_lvl) { - console.log('Endpoint:', endpoint); - } - - if (method) { // NOTE: method options: 'delete', 'disable', 'hide' - params['method'] = method; - } - - if (log_lvl) { - console.log('Params:', params); - } - - let object_obj_delete_promise = await delete_object({api_cfg: api_cfg, endpoint: endpoint, params: params, data: data, log_lvl: log_lvl}); - - if (log_lvl > 1) { - console.log(object_obj_delete_promise); - } - - return object_obj_delete_promise; -} - - -/* BEGIN: Hosted File Related */ - -// Updated 2023-08-17 -export let download_hosted_file = async function download_hosted_file({ - api_cfg, - hosted_file_id, - return_file=true, - filename=null, - auto_download=false, - params={}, - log_lvl=0 - }) { - console.log('*** stores_hosted_api.js: download_hosted_file() ***'); - - const endpoint = `/hosted_file/${hosted_file_id}/download`; - if (filename) { - params['filename'] = filename; - } - params['return_file'] = true; - - let hosted_file_download_get_promise = await api.get_object({api_cfg: api_cfg, endpoint: endpoint, params: params, return_blob: true, filename: filename, auto_download: auto_download, log_lvl: log_lvl}); - // console.log(hosted_file_download_get_promise); - return hosted_file_download_get_promise; -} - -// Updated 2023-12-15 -export let delete_hosted_file = async function delete_hosted_file({api_cfg, hosted_file_id, link_to_type=null, link_to_id=null, rm_orphan=false, params={}, data={}, log_lvl=1}) { - console.log('*** stores_hosted_api.js: delete_hosted_file() ***'); - - const endpoint = `/hosted_file/${hosted_file_id}`; - if (link_to_type) { - params['link_to_type'] = link_to_type; - } - if (link_to_id) { - params['link_to_id'] = link_to_id; - } - if (rm_orphan) { - params['rm_orphan'] = rm_orphan; - } - - let hosted_file_obj_delete_promise = await api.delete_object({api_cfg: api_cfg, endpoint: endpoint, params: params, data: data, log_lvl: log_lvl}); - // console.log(hosted_file_obj_delete_promise); - return hosted_file_obj_delete_promise; -} -/* END: Hosted File Related */ - - -/* BEGIN: Data Store Related */ - -// Updated 2023-06-29 -export let get_data_store_obj_w_code = async function get_data_store_obj_w_code({ - api_cfg, - data_store_code, - data_type='text', - headers={}, - params={}, - timeout=25000, - log_lvl=0 - }) { - if (log_lvl) { - console.log('*** get_data_store_obj_w_code() ***'); - } - - // let get_item_result = window.localStorage.getItem(code); - - const endpoint = `/data_store/code/${data_store_code}`; - let data_store_obj_get_promise = await api.get_object({api_cfg: api_cfg, endpoint: endpoint, headers: headers, params: params, timeout: timeout, log_lvl: log_lvl}); - - if (data_store_obj_get_promise === false) { - console.log('Data Store - RUN AGAIN WITH BACKUP'); - let original_api_base_url = api_cfg['base_url']; - - let temp_api = api_cfg; - temp_api['base_url'] = temp_api['base_url_bak'] - - data_store_obj_get_promise = await api.get_object({api_cfg: temp_api, endpoint: endpoint, headers: headers, params: params, timeout: timeout, log_lvl: log_lvl}); - temp_api['base_url'] = original_api_base_url; - } - - let data_store_obj = data_store_obj_get_promise; - - if (data_type == 'text') { - // console.log(data_store_obj.text); - // window.localStorage.setItem(data_store_code, data_store_obj.text); - // localStorage.setItem(data_store_code, data_store_obj.text); - } else if (data_type == 'json') { - // console.log(data_store_obj.json); - // window.localStorage.setItem(data_store_code, JSON.stringify(data_store_obj.json)); - // localStorage.setItem(data_store_code, JSON.stringify(data_store_obj.json)); - } - - if (log_lvl > 1) { - console.log('Response Data:', data_store_obj); - } - return data_store_obj; -} -/* END: Data Store Related */ - - -/* BEGIN: Utility: Email Related */ - -// Updated 2023-06-29 -export let send_email = async function send_email({api_cfg, from_email, from_name='', to_email, to_name='', cc_email=null, cc_name=null, bcc_email=null, bcc_name=null, subject, body_html, body_text=null, headers={}, params={}, data={}, return_obj=false, return_meta=false, log_lvl=0}) { - console.log('*** send_email() ***'); - - let endpoint = `/util/email/send`; - - data['from_email'] = from_email; // Required - data['from_name'] = from_name; - - data['to_email'] = to_email; // Required - data['to_name'] = to_name; - - data['cc_email'] = cc_email; - data['cc_name'] = cc_name; - - data['bcc_email'] = bcc_email; - data['bcc_name'] = bcc_name; - - data['subject'] = subject; - if (log_lvl) { - console.log('Data:', data); - } - - data['body_html'] = body_html; - - data['body_text'] = body_text; - - if (return_obj) { - params['return_obj'] = true; - } - - let send_email_post_promise = await api.post_object({api_cfg: api_cfg, endpoint: endpoint, headers: headers, params: params, data: data, return_meta: return_meta, log_lvl: log_lvl}); - - if (log_lvl > 1) { - console.log('Response Data:', send_email_post_promise); - } - if (return_obj) { - return send_email_post_promise; - } else { - return send_email_post_promise.event_abstract_id_random; - } -} - -/* END: Utility: Email Related */ - -function resolved(result) { - console.log('Resolved'); -} - -function rejected(result) { - console.error(result); -} - -const parse_params = (params) => { - const keys = Object.keys(params); - let options = ''; - - keys.forEach((key) => { - const isParamTypeObject = typeof params[key] === 'object'; - const isParamTypeArray = isParamTypeObject && (params[key].length >= 0); - - if (!isParamTypeObject) { - let encoded_value = encodeURIComponent(params[key]); - options += `${key}=${encoded_value}&`; - // options += `${key}=${params[key]}&`; - } - - if (isParamTypeObject && isParamTypeArray) { - params[key].forEach((element) => { - let encoded_value = encodeURIComponent(element); - options += `${key}=${encoded_value}&`; - // options += `${key}=${element}&`; - }); - } - }); - - return options ? options.slice(0, -1) : options; -}; - - -// export let test = async function test() { -// console.log('Exported test function from API.'); -// } - -let obj = {}; -obj.delete_object = delete_object; -obj.get_object = get_object; -obj.patch_object = patch_object; -obj.post_object = post_object; -obj.get_ae_obj_id_crud = get_ae_obj_id_crud; -obj.get_ae_obj_li_for_obj_id_crud = get_ae_obj_li_for_obj_id_crud; -obj.create_ae_obj_crud = create_ae_obj_crud; -obj.update_ae_obj_id_crud = update_ae_obj_id_crud; -obj.delete_ae_obj_id_crud = delete_ae_obj_id_crud; -obj.download_hosted_file = download_hosted_file; -obj.delete_hosted_file = delete_hosted_file; -obj.get_data_store_obj_w_code = get_data_store_obj_w_code; -obj.send_email = send_email; -// obj.test = test; -export let api = obj; -// module.exports = api; \ No newline at end of file diff --git a/src/lib/element_sql_qry.svelte b/src/lib/element_sql_qry.svelte index 605739cd..afc8ab0a 100644 --- a/src/lib/element_sql_qry.svelte +++ b/src/lib/element_sql_qry.svelte @@ -5,7 +5,7 @@ import { onMount } from 'svelte'; import type { key_val } from '$lib/ae_stores'; // import { api, Element_obj_tbl_row } from 'aether_npm_lib'; import Element_obj_tbl_row from '$lib/element_obj_tbl_row.svelte'; -import { post_object } from './api_2024-05-23.js'; +import { post_object } from '$lib/api_post_object'; // *** Import Aether core components // import Element_obj_tbl_row from './element_obj_tbl_row.svelte'; diff --git a/src/routes/core/+layout.ts b/src/routes/core/+layout.ts index e8f697d2..f2e97885 100644 --- a/src/routes/core/+layout.ts +++ b/src/routes/core/+layout.ts @@ -41,7 +41,7 @@ export async function load({ parent }) { // let load_event_obj = events_func.handle_load_ae_obj_id__event({ // api_cfg: ae_acct.api, // event_id: event_id, - // try_cache: false + // try_cache: true // }); // ae_acct.slct.event_obj = load_event_obj; diff --git a/src/routes/events_badges/+layout.ts b/src/routes/events_badges/+layout.ts index 99cdedf1..f9712f0e 100644 --- a/src/routes/events_badges/+layout.ts +++ b/src/routes/events_badges/+layout.ts @@ -25,7 +25,7 @@ export async function load({ parent }) { return false; } - let load_event_obj = events_func.handle_load_ae_obj_id__event({api_cfg: ae_acct.api, event_id: event_id, try_cache: false}); + let load_event_obj = events_func.handle_load_ae_obj_id__event({api_cfg: ae_acct.api, event_id: event_id, try_cache: true}); ae_acct.slct.event_obj = load_event_obj; diff --git a/src/routes/events_leads/+layout.ts b/src/routes/events_leads/+layout.ts index f66245c7..a518a155 100644 --- a/src/routes/events_leads/+layout.ts +++ b/src/routes/events_leads/+layout.ts @@ -23,7 +23,7 @@ export async function load({ parent }) { return false; } - let load_event_obj = events_func.handle_load_ae_obj_id__event({api_cfg: ae_acct.api, event_id: event_id, try_cache: false}); + let load_event_obj = events_func.handle_load_ae_obj_id__event({api_cfg: ae_acct.api, event_id: event_id, try_cache: true}); ae_acct.slct.event_obj = load_event_obj; diff --git a/src/routes/events_leads/+page.ts b/src/routes/events_leads/+page.ts index 564ea188..7a2873ae 100644 --- a/src/routes/events_leads/+page.ts +++ b/src/routes/events_leads/+page.ts @@ -26,7 +26,7 @@ export async function load({ params, parent, url }) { // route // Do not wait on these: - // let load_event_obj = events_func.handle_load_ae_obj_id__event({api_cfg: data.ae_api, event_id: event_id, try_cache: false}); + // let load_event_obj = events_func.handle_load_ae_obj_id__event({api_cfg: data.ae_api, event_id: event_id, try_cache: true}); // console.log(`load_event_obj = `, load_event_obj); // let load_event_exhibit_obj_li = events_func.handle_load_ae_obj_li__exhibit({api_cfg: data.ae_api, event_id: event_id, try_cache: false}); diff --git a/src/routes/events_leads/exhibit/[slug]/+page.svelte b/src/routes/events_leads/exhibit/[slug]/+page.svelte index 312f8d10..00a24f23 100644 --- a/src/routes/events_leads/exhibit/[slug]/+page.svelte +++ b/src/routes/events_leads/exhibit/[slug]/+page.svelte @@ -201,7 +201,7 @@ $: if ($events_trigger == 'load__event_exhibit_obj' && $events_slct.exhibit_id) $events_trigger = null; - // handle_load_ae_obj_id__event({event_exhibit_id: $events_slct.exhibit_id, try_cache: false}); + // handle_load_ae_obj_id__event({event_exhibit_id: $events_slct.exhibit_id, try_cache: true}); let load_event_exhibit_obj = events_func.handle_load_ae_obj_id__exhibit({api_cfg: ae_acct.api, exhibit_id: $events_slct.exhibit_id, try_cache: false}) .then(function (result) { diff --git a/src/routes/events_pres_mgmt/(launcher)/launcher/[slug]/+page.ts b/src/routes/events_pres_mgmt/(launcher)/launcher/[slug]/+page.ts index 1858b912..77992eb1 100644 --- a/src/routes/events_pres_mgmt/(launcher)/launcher/[slug]/+page.ts +++ b/src/routes/events_pres_mgmt/(launcher)/launcher/[slug]/+page.ts @@ -2,6 +2,7 @@ import { error } from '@sveltejs/kit'; console.log(`ae pres_mgmt launcher [slug] +page.ts: start`); +import { browser } from '$app/environment'; import { events_func } from '$lib/ae_events_functions'; export async function load({ params, parent }) { // route @@ -15,12 +16,12 @@ export async function load({ params, parent }) { // route let ae_acct = data[account_id]; console.log(`ae_acct = `, ae_acct); - if (!account_id) { - console.log(`ae pres_mgmt launcher [slug] +page.ts: The account_id was not found in the data!!!`); - error(404, { - message: 'Account ID not found' - }); - } + // if (!account_id) { + // console.log(`ae pres_mgmt launcher [slug] +page.ts: The account_id was not found in the data!!!`); + // error(404, { + // message: 'Account ID not found' + // }); + // } let event_id = params.slug; if (!event_id) { @@ -30,32 +31,40 @@ export async function load({ params, parent }) { // route }); } - ae_acct.slct.event_id = event_id; + // if (ae_acct.slct.event_id !== event_id) { + // ae_acct.slct.event_id = event_id; - let load_event_obj = events_func.handle_load_ae_obj_id__event({api_cfg: ae_acct.api, event_id: event_id, try_cache: false}); + // let load_event_obj = events_func.handle_load_ae_obj_id__event({ + // api_cfg: ae_acct.api, + // event_id: event_id, + // try_cache: false + // }); - ae_acct.slct.event_obj = await load_event_obj; + // ae_acct.slct.event_obj = await load_event_obj; + // } - let load_event_session_obj_li = events_func.handle_load_ae_obj_li__event_session({ - api_cfg: ae_acct.api, - for_obj_type: 'event', - for_obj_id: event_id, - params: {qry__enabled: 'enabled', qry__limit: 550}, - try_cache: false - }); - console.log(`load_event_session_obj_li = `, load_event_session_obj_li); + if (browser) { + let load_event_location_obj_li = events_func.handle_load_ae_obj_li__event_location({ + api_cfg: ae_acct.api, + event_id: event_id, + params: {qry__enabled: 'enabled', qry__limit: 550}, + try_cache: true + }); + console.log(`load_event_location_obj_li = `, load_event_location_obj_li); - ae_acct.slct.event_session_obj_li = load_event_session_obj_li; + ae_acct.slct.event_location_obj_li = load_event_location_obj_li; - let load_event_location_obj_li = events_func.handle_load_ae_obj_li__event_location({ - api_cfg: ae_acct.api, - event_id: event_id, - params: {qry__enabled: 'enabled', qry__limit: 550}, - try_cache: false - }); - console.log(`load_event_location_obj_li = `, load_event_location_obj_li); + let load_event_session_obj_li = events_func.handle_load_ae_obj_li__event_session({ + api_cfg: ae_acct.api, + for_obj_type: 'event', + for_obj_id: event_id, + params: {qry__enabled: 'enabled', qry__limit: 550}, + try_cache: true + }); + console.log(`load_event_session_obj_li = `, load_event_session_obj_li); - ae_acct.slct.event_location_obj_li = load_event_location_obj_li; + ae_acct.slct.event_session_obj_li = load_event_session_obj_li; + } // WARNING: Precaution against shared data between sites and sessions. data[account_id] = ae_acct; diff --git a/src/routes/events_pres_mgmt/(launcher)/launcher/[slug]/+page@(launcher).svelte b/src/routes/events_pres_mgmt/(launcher)/launcher/[slug]/+page@(launcher).svelte index 01e31599..40dfd0c3 100644 --- a/src/routes/events_pres_mgmt/(launcher)/launcher/[slug]/+page@(launcher).svelte +++ b/src/routes/events_pres_mgmt/(launcher)/launcher/[slug]/+page@(launcher).svelte @@ -25,7 +25,6 @@ import { kill_processes, open_local_file_v2, run_cmd, run_cmd_sync, run_osascrip import Event_launcher_menu from './launcher_menu.svelte'; import Event_launcher_session_view from './launcher_session_view.svelte'; - // Exports @@ -38,15 +37,28 @@ let ae_acct = data[$slct.account_id]; // $ae_loc.url_origin = data.url.origin; +// if (browser) { +// console.log(`Browser: ${browser}`); +// events_func.handle_db_save_ae_obj_li__event_location({ +// obj_type: 'event_location', +// obj_li: ae_acct.slct.event_location_obj_li +// }); + +// events_func.handle_db_save_ae_obj_li__event_session({ +// obj_type: 'event_session', +// obj_li: ae_acct.slct.event_session_obj_li +// }); +// } + $events_slct.event_id = ae_acct.slct.event_id; -$events_slct.event_obj = ae_acct.slct.event_obj; +// $events_slct.event_obj = ae_acct.slct.event_obj; $events_slct.event_location_obj_li = ae_acct.slct.event_location_obj_li; $events_slct.event_session_obj_li = ae_acct.slct.event_session_obj_li; // $events_trigger = 'event_location_li'; let lq__event_obj = liveQuery( - () => db_events.events.get($events_slct.event_id) + () => db_events.events.get(ae_acct.slct.event_id) ); @@ -118,7 +130,7 @@ onMount(() => { - Launcher: {ae_util.shorten_string({ string: $lq__event_obj?.name, max_length: 20, begin_length: 10, end_length: 4 })} + Launcher: {ae_util.shorten_string({ string: $lq__event_obj?.name ?? '', max_length: 20, begin_length: 10, end_length: 4 })} ({$lq__event_obj?.event_id ?? 'loading...'}) - Pres Mgmt - {$ae_loc?.title} diff --git a/src/routes/events_pres_mgmt/(launcher)/launcher/[slug]/launcher_session_view.svelte b/src/routes/events_pres_mgmt/(launcher)/launcher/[slug]/launcher_session_view.svelte index afd26bc3..9b16366a 100644 --- a/src/routes/events_pres_mgmt/(launcher)/launcher/[slug]/launcher_session_view.svelte +++ b/src/routes/events_pres_mgmt/(launcher)/launcher/[slug]/launcher_session_view.svelte @@ -19,7 +19,7 @@ export let slct_event_session_id: string; let load_event_session_obj = events_func.handle_load_ae_obj_id__event_session({ api_cfg: $ae_api, event_session_id: slct_event_session_id, - try_cache: false + try_cache: true }); // let lq__event_session_obj = liveQuery( diff --git a/src/routes/events_pres_mgmt/(launcher)/launcher/[slug]/menu_session_list.svelte b/src/routes/events_pres_mgmt/(launcher)/launcher/[slug]/menu_session_list.svelte index 1e73f880..8e3e97f6 100644 --- a/src/routes/events_pres_mgmt/(launcher)/launcher/[slug]/menu_session_list.svelte +++ b/src/routes/events_pres_mgmt/(launcher)/launcher/[slug]/menu_session_list.svelte @@ -57,7 +57,7 @@ let lq_kv__event_session_obj_li = liveQuery( let load_event_session_obj = events_func.handle_load_ae_obj_id__event_session({ api_cfg: $ae_api, event_session_id: slct_event_session_id, - try_cache: false + try_cache: true }); }} > diff --git a/src/routes/events_pres_mgmt/+layout.svelte b/src/routes/events_pres_mgmt/+layout.svelte index 1a7a886f..05c773f2 100644 --- a/src/routes/events_pres_mgmt/+layout.svelte +++ b/src/routes/events_pres_mgmt/+layout.svelte @@ -2,6 +2,8 @@ /** @type {import('./$types').LayoutData} */ export let data: any; +// Imports +import { browser } from '$app/environment'; import { goto } from '$app/navigation'; import { onMount } from 'svelte'; import type { Writable } from 'svelte/store'; @@ -27,8 +29,16 @@ console.log(`$slct.account_id = `, $slct.account_id); let ae_acct = data[$slct.account_id]; // console.log(`ae_acct = `, ae_acct); +// if (browser) { +// console.log(`Browser: ${browser}`); +// events_func.handle_db_save_ae_obj_li__event({ +// obj_type: 'event', +// obj_li: [ae_acct.slct.event_obj_li], +// }); +// } + $events_slct.event_id = ae_acct.slct.event_id; -$events_slct.event_obj = ae_acct.slct.event_obj; +// $events_slct.event_obj = ae_acct.slct.event_obj; $events_slct.event_obj_li = ae_acct.slct.event_obj_li; let ae_promises: key_val = {}; @@ -42,22 +52,22 @@ onMount(() => { // Updated 2024-06-25 -$: if ($events_trigger == 'load__event_session_obj_id' && $events_trig_kv['event_session_id']) { - console.log(`load__event_session_obj_id() $events_slct.event_session_id=${$events_slct.event_session_id}`); +// $: if ($events_trigger == 'load__event_session_obj_id' && $events_trig_kv['event_session_id']) { +// console.log(`load__event_session_obj_id() $events_slct.event_session_id=${$events_slct.event_session_id}`); - $events_trigger = null; +// $events_trigger = null; - if ($events_slct.event_session_id) { - $events_trig_kv['event_session_id'] = events_func.handle_load_ae_obj_id__event_session({ - api_cfg: $ae_api, - event_session_id: $events_slct.event_session_id, - log_lvl: 1 - }) - .then(function (load_results) { - console.log(`ae_event_session_get_promise:`, load_results); - }); - } -} +// if ($events_slct.event_session_id) { +// $events_trig_kv['event_session_id'] = events_func.handle_load_ae_obj_id__event_session({ +// api_cfg: $ae_api, +// event_session_id: $events_slct.event_session_id, +// log_lvl: 1 +// }) +// .then(function (load_results) { +// console.log(`ae_event_session_get_promise:`, load_results); +// }); +// } +// } @@ -113,7 +123,7 @@ $: if ($events_trigger == 'load__event_session_obj_id' && $events_trig_kv['event -{#if $ae_loc.ver != '2024-06-26_13' || $ae_loc.ver_idb != '2024-06-26_1625'} +{#if $ae_loc.ver != '2024-08-07_1504' || $ae_loc.ver_idb != '2024-08-07_1505'}
@@ -127,12 +137,12 @@ $: if ($events_trigger == 'load__event_session_obj_id' && $events_trig_kv['event on:click={() => { // This is not a very efficient way to do this, but it works for now. // Do this first even if the localStorage will be cleared. - if ($ae_loc.ver_idb != '2024-06-26_1625') { + if ($ae_loc.ver_idb != '2024-08-07_1505') { // Yep... this needs to be done differently. - $ae_loc.ver_idb = '2024-06-26_1625'; + $ae_loc.ver_idb = '2024-08-07_1505'; } - if ($ae_loc.ver != '2024-06-26_13') { + if ($ae_loc.ver != '2024-08-07_1504') { alert('You will need to sign in again.') // Clear the local and session storage. Clearing the localStorage will force it to be re-created. @@ -153,7 +163,7 @@ $: if ($events_trigger == 'load__event_session_obj_id' && $events_trig_kv['event Clear App Data & Settings - Reload -{#if $ae_loc.ver != '2024-06-26_13'} +{#if $ae_loc.ver != '2024-08-07_1504'}

You will need to sign in again after clearing the cache.

diff --git a/src/routes/events_pres_mgmt/+layout.ts b/src/routes/events_pres_mgmt/+layout.ts index 6e78c1f7..127c3787 100644 --- a/src/routes/events_pres_mgmt/+layout.ts +++ b/src/routes/events_pres_mgmt/+layout.ts @@ -1,6 +1,8 @@ /** @type {import('./$types').LayoutLoad} */ console.log(`ae_events_pres_mgmt +layout.ts start`); +// Imports +import { browser } from '$app/environment'; import { events_func } from '$lib/ae_events_functions'; @@ -21,30 +23,39 @@ export async function load({ parent }) { console.log(`ae_acct = `, ae_acct); } - // // Should we limit these to event.conference = true? - // let load_event_obj_li = events_func.handle_load_ae_obj_li__event({ - // api_cfg: ae_acct.api, - // account_id: account_id, - // params: {enabled: 'enabled', qry__limit: 25}, - // try_cache: false, - // log_lvl: 1 - // }); - // ae_acct.slct.event_obj_li = load_event_obj_li; - - - let event_id = ae_acct.slct.event_id; + let event_id = ae_acct.slct.event_id; // From root +layout.ts if (!event_id) { console.log(`ERROR: events_pres_mgmt +layout.ts: The event_id was not found in the data!!!`); return false; } - let load_event_obj = events_func.handle_load_ae_obj_id__event({ - api_cfg: ae_acct.api, - event_id: event_id, - try_cache: false - }); + if (browser) { + // Should we limit these to event.conference = true? + let load_event_obj_li = events_func.handle_load_ae_obj_li__event({ + api_cfg: ae_acct.api, + account_id: account_id, + params: {enabled: 'enabled', qry__limit: 25}, + try_cache: true, + log_lvl: log_lvl + }); + ae_acct.slct.event_obj_li = load_event_obj_li; + } - ae_acct.slct.event_obj = load_event_obj; + // let load_event_obj = events_func.handle_load_ae_obj_id__event({ + // api_cfg: ae_acct.api, + // event_id: event_id, + // try_cache: false + // }); + + // ae_acct.slct.event_obj = load_event_obj; + + // if (browser) { + // console.log(`Browser: ${browser}`); + // events_func.handle_db_save_ae_obj_li__event({ + // obj_type: 'event', + // obj_li: [load_event_obj_li], + // }); + // } let submenu = { main: {name: 'Main', href: '/events_pres_mgmt', access: false}, diff --git a/src/routes/events_pres_mgmt/+page.svelte b/src/routes/events_pres_mgmt/+page.svelte index 3956c4f1..d456946d 100644 --- a/src/routes/events_pres_mgmt/+page.svelte +++ b/src/routes/events_pres_mgmt/+page.svelte @@ -16,8 +16,8 @@ import { ae_util } from '$lib/ae_utils'; let ae_acct = data[$slct.account_id]; -$events_slct.event_obj = ae_acct.slct.event_obj; -$events_slct.event_obj_li = ae_acct.slct.event_obj_li; +// $events_slct.event_obj = ae_acct.slct.event_obj; +// $events_slct.event_obj_li = ae_acct.slct.event_obj_li; let lq__event_obj_li = liveQuery( @@ -42,7 +42,7 @@ let lq__event_obj_li = liveQuery( let lq__event_obj = liveQuery( async () => db_events.events .where('id') - .equals(await ae_acct.slct.event_id) + .equals(ae_acct.slct.event_id) .toArray() // .first() // .get($events_slct.event_id) @@ -60,7 +60,7 @@ onMount(() => { // console.log(`$ae_loc.href_url = `, $ae_loc.href_url); console.log(`lq__event_obj = `, $lq__event_obj); // $events_slct.event_obj = db_events.events.get($events_slct.event_id); - console.log(`$events_slct.event_obj = `, $events_slct.event_obj.name); + // console.log(`$events_slct.event_obj = `, $events_slct.event_obj?.name); }); @@ -106,7 +106,19 @@ onMount(() => { /> --> -{#if $lq__event_obj_li} +{#await ae_acct.slct.event_obj_li} +
+ + Loading... +
+{:then} +
+ + Loaded +
+ + +{#if ae_acct.slct.event_obj_li && $lq__event_obj_li}