Compare commits
1 Commits
ae_app_sve
...
ae_app_sve
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c212eeb45e |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,4 @@
|
||||
.DS_Store
|
||||
.directory
|
||||
node_modules
|
||||
/build
|
||||
/.svelte-kit
|
||||
|
||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -116,6 +116,5 @@
|
||||
"transition",
|
||||
"width",
|
||||
"zIndex"
|
||||
],
|
||||
"explorer.fileNesting.enabled": false
|
||||
]
|
||||
}
|
||||
63
README.md
63
README.md
@@ -1,17 +1,15 @@
|
||||
# One Sky IT's Aether App - SvelteKit v2
|
||||
|
||||
This uses SvelteKit version 2.x with Svelte version 5.x, TailwindCSS 4.1, and Skelton.
|
||||
This uses SvelteKit version 2, TailwindCSS, and Skelton.
|
||||
|
||||
|
||||
# Current Modules
|
||||
|
||||
## AE Events - Speakers (/events_speakers)
|
||||
### Components
|
||||
* +page.svelte - The main page for the Events - Speakers module
|
||||
* 10_edit_modal__event_presenter_obj.svelte - The modal for editing a presenter
|
||||
* 10_list__event_presenter_obj.svelte - The list of presenters/speakers
|
||||
* 10_view_modal__event_presenter_obj.svelte - The modal for viewing a presenter
|
||||
### Path [slug]
|
||||
#### [slug]
|
||||
* +page.svelte - The main page for the presenter ID [slug]
|
||||
|
||||
## AE Sponsorships (/sponsorships)
|
||||
@@ -19,7 +17,7 @@ This uses SvelteKit version 2.x with Svelte version 5.x, TailwindCSS 4.1, and Sk
|
||||
* 10_edit_modal__sponsorship_obj.svelte - The modal for editing a sponsorship
|
||||
* 10_list__sponsorship_obj.svelte - The list of sponsorships
|
||||
* 10_view_modal__sponsorship_obj.svelte - The modal for viewing a sponsorship
|
||||
### Path [slug]
|
||||
#### [slug]
|
||||
* +page.svelte - The main page for the sponsorship ID [slug]
|
||||
|
||||
|
||||
@@ -35,7 +33,6 @@ This uses SvelteKit version 2.x with Svelte version 5.x, TailwindCSS 4.1, and Sk
|
||||
|
||||
# How to build and deploy SvelteKit:
|
||||
Copy the contents of the "build" directory to ./npm_deploy/build/
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
@@ -47,32 +44,23 @@ rsync -vhrz --exclude 'node_modules' ~/OSIT_dev/ae_app_svelte_tailwind_skeleton/
|
||||
rsync -vhrz ~/OSIT_dev/ae_env_node_app/npm_deploy/build/ scott@linode.oneskyit.com:/srv/env/prod_aether_sveltekit/npm_deploy/build/ --delete
|
||||
```
|
||||
|
||||
If this includes package updates (not development) we need to copy the new package.json. Manually copy the new package.json file to ./npm_deploy/. This also needs to be copied to the server. Copy the package.json even though not really used.
|
||||
If this includes package updates we need to copy the new package.json. Manually copy the new package.json file to ./npm_deploy/. This also needs to be copied to the server.
|
||||
```bash
|
||||
# copy/paste, rsync, or cp
|
||||
```
|
||||
|
||||
Run the --omit dev to clear out the node_modules directory. Copy the root node_modules directory to ./npm_deploy/build/node_modules/ after running te omit dev command.
|
||||
```bash
|
||||
npm ci --omit dev
|
||||
|
||||
# copy/paste, rsync, or cp
|
||||
rsync -vhrz ~/OSIT_dev/ae_app_svelte_tailwind_skeleton/node_modules ~/OSIT_dev/ae_env_node_app/npm_deploy/build/ --delete
|
||||
|
||||
# copy package.json as well
|
||||
|
||||
npm install
|
||||
```
|
||||
|
||||
Everything should be ready to run on the development server and production server.
|
||||
|
||||
|
||||
# Rebuild the node_modules directory and manually install extra Svelte packages
|
||||
|
||||
Run the npm update to fix the node_modules directory and package.json
|
||||
```bash
|
||||
npm list
|
||||
npm outdated
|
||||
npm update
|
||||
npm outdated
|
||||
npm list
|
||||
```
|
||||
|
||||
Other installs?:
|
||||
@@ -82,45 +70,14 @@ npm install --save-dev svelte-highlight
|
||||
npm install --save-dev typescript-svelte-plugin
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Set up and run
|
||||
|
||||
## Packages and dependencies
|
||||
|
||||
```bash
|
||||
npm install --save-dev svelte-highlight typescript-svelte-plugin
|
||||
npm install flowbite flowbite-svelte tailwind-merge @popperjs/core
|
||||
```
|
||||
|
||||
I am slowly switching from Font-Awesome to Lucide
|
||||
|
||||
## Tiptap Editor
|
||||
* Eventually use Edra? https://edra.tsuzat.com/
|
||||
* Best Rich Text Editor, made for Svelte Developers with Tiptap
|
||||
* ShadEditor is "evolving" to be Edra.
|
||||
* ShadCN is still stuck on Tailwind 3. Waiting to upgrade to Tailwind 4.x. Tailwind 4.x was released in late January 2025. ShadCN is still being worked on as of late March 2025.
|
||||
* [https://github.com/huntabyte/shadcn-svelte/issues/1643](https://github.com/huntabyte/shadcn-svelte/issues/1643)
|
||||
|
||||
Need to install ShadCN and Lucide for the Tiptap editor.
|
||||
```bash
|
||||
npm install shadcn-svelte
|
||||
npm install lucide-svelte
|
||||
npm install mode-watcher
|
||||
```
|
||||
|
||||
Now we initialize the ShadCN and ShadEditor packages. Follow the command line instructions.
|
||||
```bash
|
||||
npx shadcn-svelte@next init
|
||||
npx shadcn-svelte@next add dropdown-menu button tooltip input popover separator
|
||||
npx shadeditor init
|
||||
```
|
||||
|
||||
More packages related to the Tiptap editor???
|
||||
```bash
|
||||
npm install @tiptap/extension-link @tiptap/extension-bullet-list @tiptap/extension-history @tiptap/extension-typography @tiptap/extension-underline
|
||||
```
|
||||
|
||||
## Build
|
||||
|
||||
## Environment file
|
||||
@@ -140,11 +97,9 @@ This is modified to allow for a staging environment and production environment b
|
||||
This is modified to allow for a staging environment and production environment built.
|
||||
|
||||
### Example Important Values when running in dev:
|
||||
Note: Environment values need to be updated when our home IP address changes. Be sure to check the Aether Container Environment and Aether Node App (SvelteKit) Environment files for the correct IP address. The Node Docker environment needs to be updated here and in the .env file that Docker will read. This needs to be improved later...
|
||||
Note our home IP address that changes.
|
||||
```bash
|
||||
DOCKER_AE_API_DEV_SERVER_EXTRA_HOST=dev-api.oneskyit.com:108.48.200.147
|
||||
|
||||
DOCKER_AE_API_SERVER_EXTRA_HOST=dev-api.oneskyit.com:108.48.200.147
|
||||
DOCKER_AE_API_SERVER_EXTRA_HOST=dev-api.oneskyit.com:108.28.68.107
|
||||
|
||||
PUBLIC_AE_API_SERVER=api.oneskyit.com
|
||||
PUBLIC_AE_API_BAK_SERVER=bak-api.oneskyit.com
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
# One Sky IT's Aether App - UI and UX Guidelines and Rules
|
||||
|
||||
|
||||
## General
|
||||
### Events
|
||||
#### layout header
|
||||
#### layout footer
|
||||
|
||||
### Journals
|
||||
#### buttons
|
||||
##### alert
|
||||
|
||||
##### info
|
||||
|
||||
##### priority, flag
|
||||
|
||||
##### warning, hide
|
||||
```css
|
||||
variant-soft-warning hover:variant-filled-warning
|
||||
```
|
||||
##### error, delete, disable
|
||||
```css
|
||||
variant-soft-error hover:variant-filled-error
|
||||
```
|
||||
#### new root layout header
|
||||
#### submenu
|
||||
```css
|
||||
flex flex-row items-center justify-center gap-1
|
||||
```
|
||||
#### new layout footer
|
||||
|
||||
|
||||
## Svelte 5 and SvelteKit v2 (framework and routing)
|
||||
|
||||
|
||||
## Tailwind 3.x CSS (styles)
|
||||
Waiting to upgrade to 4.x when ShadCN is ready. ShadCN is still being worked on as of late March 2025.
|
||||
* https://ui.shadcn.com/docs/tailwind-v4
|
||||
|
||||
|
||||
## CodeMirror 6.x (text and code editor)
|
||||
* https://codemirror.net
|
||||
|
||||
## ShadCN (Tailwind Components)
|
||||
* https://ui.shadcn.com/docs
|
||||
* https://github.com/shadcn-ui/ui
|
||||
|
||||
|
||||
## Skeleton (Design System, Tailwind Components, Functional Components)
|
||||
Waiting to upgrade to Skeleton v3. Mostly because of the Tailwind 4.x upgrade needed for ShadCN.
|
||||
* https://www.skeleton.dev/docs/get-started/migrate-from-v2
|
||||
|
||||
## Flowbite (Tailwind Components)
|
||||
|
||||
|
||||
## Lucide Icons (SVG Icons)
|
||||
* https://lucide.dev/icons/
|
||||
|
||||
|
||||
## Markdown
|
||||
Using marked for Markdown parsing.
|
||||
* https://marked.js.org/
|
||||
|
||||
|
||||
## Edra (TipTap based Rich Text Editor)
|
||||
* https://edra.tsuzat.com/
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"$schema": "https://next.shadcn-svelte.com/schema.json",
|
||||
"style": "default",
|
||||
"tailwind": {
|
||||
"config": "tailwind.config.ts",
|
||||
"css": "src/app.css",
|
||||
"baseColor": "gray"
|
||||
},
|
||||
"aliases": {
|
||||
"components": "$lib/components",
|
||||
"utils": "$lib/utils",
|
||||
"ui": "$lib/components/ui",
|
||||
"hooks": "$lib/hooks"
|
||||
},
|
||||
"typescript": true,
|
||||
"registry": "https://next.shadcn-svelte.com/registry"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"$lib/*": ["./src/lib/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
103
osit_ae_theme_1.ts
Normal file
103
osit_ae_theme_1.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
import type { CustomThemeConfig } from '@skeletonlabs/tw-plugin';
|
||||
|
||||
export const myCustomTheme: CustomThemeConfig = {
|
||||
name: 'my-custom-theme',
|
||||
properties: {
|
||||
// =~= Theme Properties =~=
|
||||
"--theme-font-family-base": `Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'`,
|
||||
"--theme-font-family-heading": `Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'`,
|
||||
"--theme-font-color-base": "0 0 0",
|
||||
"--theme-font-color-dark": "255 255 255",
|
||||
"--theme-rounded-base": "16px",
|
||||
"--theme-rounded-container": "8px",
|
||||
"--theme-border-base": "1px",
|
||||
// =~= Theme On-X Colors =~=
|
||||
"--on-primary": "0 0 0",
|
||||
"--on-secondary": "0 0 0",
|
||||
"--on-tertiary": "0 0 0",
|
||||
"--on-success": "0 0 0",
|
||||
"--on-warning": "0 0 0",
|
||||
"--on-error": "0 0 0",
|
||||
"--on-surface": "0 0 0",
|
||||
// =~= Theme Colors =~=
|
||||
// primary | #99c1f1
|
||||
"--color-primary-50": "240 246 253", // #f0f6fd
|
||||
"--color-primary-100": "235 243 252", // #ebf3fc
|
||||
"--color-primary-200": "230 240 252", // #e6f0fc
|
||||
"--color-primary-300": "214 230 249", // #d6e6f9
|
||||
"--color-primary-400": "184 212 245", // #b8d4f5
|
||||
"--color-primary-500": "153 193 241", // #99c1f1
|
||||
"--color-primary-600": "138 174 217", // #8aaed9
|
||||
"--color-primary-700": "115 145 181", // #7391b5
|
||||
"--color-primary-800": "92 116 145", // #5c7491
|
||||
"--color-primary-900": "75 95 118", // #4b5f76
|
||||
// secondary | #8ff0a4
|
||||
"--color-secondary-50": "238 253 241", // #eefdf1
|
||||
"--color-secondary-100": "233 252 237", // #e9fced
|
||||
"--color-secondary-200": "227 251 232", // #e3fbe8
|
||||
"--color-secondary-300": "210 249 219", // #d2f9db
|
||||
"--color-secondary-400": "177 245 191", // #b1f5bf
|
||||
"--color-secondary-500": "143 240 164", // #8ff0a4
|
||||
"--color-secondary-600": "129 216 148", // #81d894
|
||||
"--color-secondary-700": "107 180 123", // #6bb47b
|
||||
"--color-secondary-800": "86 144 98", // #569062
|
||||
"--color-secondary-900": "70 118 80", // #467650
|
||||
// tertiary | #f8e45c
|
||||
"--color-tertiary-50": "254 251 231", // #fefbe7
|
||||
"--color-tertiary-100": "254 250 222", // #fefade
|
||||
"--color-tertiary-200": "253 248 214", // #fdf8d6
|
||||
"--color-tertiary-300": "252 244 190", // #fcf4be
|
||||
"--color-tertiary-400": "250 236 141", // #faec8d
|
||||
"--color-tertiary-500": "248 228 92", // #f8e45c
|
||||
"--color-tertiary-600": "223 205 83", // #dfcd53
|
||||
"--color-tertiary-700": "186 171 69", // #baab45
|
||||
"--color-tertiary-800": "149 137 55", // #958937
|
||||
"--color-tertiary-900": "122 112 45", // #7a702d
|
||||
// success | #33d17a
|
||||
"--color-success-50": "224 248 235", // #e0f8eb
|
||||
"--color-success-100": "214 246 228", // #d6f6e4
|
||||
"--color-success-200": "204 244 222", // #ccf4de
|
||||
"--color-success-300": "173 237 202", // #adedca
|
||||
"--color-success-400": "112 223 162", // #70dfa2
|
||||
"--color-success-500": "51 209 122", // #33d17a
|
||||
"--color-success-600": "46 188 110", // #2ebc6e
|
||||
"--color-success-700": "38 157 92", // #269d5c
|
||||
"--color-success-800": "31 125 73", // #1f7d49
|
||||
"--color-success-900": "25 102 60", // #19663c
|
||||
// warning | #ffa348
|
||||
"--color-warning-50": "255 241 228", // #fff1e4
|
||||
"--color-warning-100": "255 237 218", // #ffedda
|
||||
"--color-warning-200": "255 232 209", // #ffe8d1
|
||||
"--color-warning-300": "255 218 182", // #ffdab6
|
||||
"--color-warning-400": "255 191 127", // #ffbf7f
|
||||
"--color-warning-500": "255 163 72", // #ffa348
|
||||
"--color-warning-600": "230 147 65", // #e69341
|
||||
"--color-warning-700": "191 122 54", // #bf7a36
|
||||
"--color-warning-800": "153 98 43", // #99622b
|
||||
"--color-warning-900": "125 80 35", // #7d5023
|
||||
// error | #f66151
|
||||
"--color-error-50": "254 231 229", // #fee7e5
|
||||
"--color-error-100": "253 223 220", // #fddfdc
|
||||
"--color-error-200": "253 216 212", // #fdd8d4
|
||||
"--color-error-300": "251 192 185", // #fbc0b9
|
||||
"--color-error-400": "249 144 133", // #f99085
|
||||
"--color-error-500": "246 97 81", // #f66151
|
||||
"--color-error-600": "221 87 73", // #dd5749
|
||||
"--color-error-700": "185 73 61", // #b9493d
|
||||
"--color-error-800": "148 58 49", // #943a31
|
||||
"--color-error-900": "121 48 40", // #793028
|
||||
// surface | #deddda
|
||||
"--color-surface-50": "250 250 249", // #fafaf9
|
||||
"--color-surface-100": "248 248 248", // #f8f8f8
|
||||
"--color-surface-200": "247 247 246", // #f7f7f6
|
||||
"--color-surface-300": "242 241 240", // #f2f1f0
|
||||
"--color-surface-400": "232 231 229", // #e8e7e5
|
||||
"--color-surface-500": "222 221 218", // #deddda
|
||||
"--color-surface-600": "200 199 196", // #c8c7c4
|
||||
"--color-surface-700": "167 166 164", // #a7a6a4
|
||||
"--color-surface-800": "133 133 131", // #858583
|
||||
"--color-surface-900": "109 108 107", // #6d6c6b
|
||||
|
||||
}
|
||||
}
|
||||
103
osit_ae_theme_2.ts
Normal file
103
osit_ae_theme_2.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
import type { CustomThemeConfig } from '@skeletonlabs/tw-plugin';
|
||||
|
||||
export const myCustomTheme: CustomThemeConfig = {
|
||||
name: 'my-custom-theme',
|
||||
properties: {
|
||||
// =~= Theme Properties =~=
|
||||
"--theme-font-family-base": `Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'`,
|
||||
"--theme-font-family-heading": `Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'`,
|
||||
"--theme-font-color-base": "0 0 0",
|
||||
"--theme-font-color-dark": "255 255 255",
|
||||
"--theme-rounded-base": "16px",
|
||||
"--theme-rounded-container": "8px",
|
||||
"--theme-border-base": "1px",
|
||||
// =~= Theme On-X Colors =~=
|
||||
"--on-primary": "0 0 0",
|
||||
"--on-secondary": "0 0 0",
|
||||
"--on-tertiary": "0 0 0",
|
||||
"--on-success": "0 0 0",
|
||||
"--on-warning": "0 0 0",
|
||||
"--on-error": "0 0 0",
|
||||
"--on-surface": "0 0 0",
|
||||
// =~= Theme Colors =~=
|
||||
// primary | #62a0ea
|
||||
"--color-primary-50": "231 241 252", // #e7f1fc
|
||||
"--color-primary-100": "224 236 251", // #e0ecfb
|
||||
"--color-primary-200": "216 231 250", // #d8e7fa
|
||||
"--color-primary-300": "192 217 247", // #c0d9f7
|
||||
"--color-primary-400": "145 189 240", // #91bdf0
|
||||
"--color-primary-500": "98 160 234", // #62a0ea
|
||||
"--color-primary-600": "88 144 211", // #5890d3
|
||||
"--color-primary-700": "74 120 176", // #4a78b0
|
||||
"--color-primary-800": "59 96 140", // #3b608c
|
||||
"--color-primary-900": "48 78 115", // #304e73
|
||||
// secondary | #99c1f1
|
||||
"--color-secondary-50": "240 246 253", // #f0f6fd
|
||||
"--color-secondary-100": "235 243 252", // #ebf3fc
|
||||
"--color-secondary-200": "230 240 252", // #e6f0fc
|
||||
"--color-secondary-300": "214 230 249", // #d6e6f9
|
||||
"--color-secondary-400": "184 212 245", // #b8d4f5
|
||||
"--color-secondary-500": "153 193 241", // #99c1f1
|
||||
"--color-secondary-600": "138 174 217", // #8aaed9
|
||||
"--color-secondary-700": "115 145 181", // #7391b5
|
||||
"--color-secondary-800": "92 116 145", // #5c7491
|
||||
"--color-secondary-900": "75 95 118", // #4b5f76
|
||||
// tertiary | #f8e45c
|
||||
"--color-tertiary-50": "254 251 231", // #fefbe7
|
||||
"--color-tertiary-100": "254 250 222", // #fefade
|
||||
"--color-tertiary-200": "253 248 214", // #fdf8d6
|
||||
"--color-tertiary-300": "252 244 190", // #fcf4be
|
||||
"--color-tertiary-400": "250 236 141", // #faec8d
|
||||
"--color-tertiary-500": "248 228 92", // #f8e45c
|
||||
"--color-tertiary-600": "223 205 83", // #dfcd53
|
||||
"--color-tertiary-700": "186 171 69", // #baab45
|
||||
"--color-tertiary-800": "149 137 55", // #958937
|
||||
"--color-tertiary-900": "122 112 45", // #7a702d
|
||||
// success | #33d17a
|
||||
"--color-success-50": "224 248 235", // #e0f8eb
|
||||
"--color-success-100": "214 246 228", // #d6f6e4
|
||||
"--color-success-200": "204 244 222", // #ccf4de
|
||||
"--color-success-300": "173 237 202", // #adedca
|
||||
"--color-success-400": "112 223 162", // #70dfa2
|
||||
"--color-success-500": "51 209 122", // #33d17a
|
||||
"--color-success-600": "46 188 110", // #2ebc6e
|
||||
"--color-success-700": "38 157 92", // #269d5c
|
||||
"--color-success-800": "31 125 73", // #1f7d49
|
||||
"--color-success-900": "25 102 60", // #19663c
|
||||
// warning | #ffa348
|
||||
"--color-warning-50": "255 241 228", // #fff1e4
|
||||
"--color-warning-100": "255 237 218", // #ffedda
|
||||
"--color-warning-200": "255 232 209", // #ffe8d1
|
||||
"--color-warning-300": "255 218 182", // #ffdab6
|
||||
"--color-warning-400": "255 191 127", // #ffbf7f
|
||||
"--color-warning-500": "255 163 72", // #ffa348
|
||||
"--color-warning-600": "230 147 65", // #e69341
|
||||
"--color-warning-700": "191 122 54", // #bf7a36
|
||||
"--color-warning-800": "153 98 43", // #99622b
|
||||
"--color-warning-900": "125 80 35", // #7d5023
|
||||
// error | #f66151
|
||||
"--color-error-50": "254 231 229", // #fee7e5
|
||||
"--color-error-100": "253 223 220", // #fddfdc
|
||||
"--color-error-200": "253 216 212", // #fdd8d4
|
||||
"--color-error-300": "251 192 185", // #fbc0b9
|
||||
"--color-error-400": "249 144 133", // #f99085
|
||||
"--color-error-500": "246 97 81", // #f66151
|
||||
"--color-error-600": "221 87 73", // #dd5749
|
||||
"--color-error-700": "185 73 61", // #b9493d
|
||||
"--color-error-800": "148 58 49", // #943a31
|
||||
"--color-error-900": "121 48 40", // #793028
|
||||
// surface | #deddda
|
||||
"--color-surface-50": "250 250 249", // #fafaf9
|
||||
"--color-surface-100": "248 248 248", // #f8f8f8
|
||||
"--color-surface-200": "247 247 246", // #f7f7f6
|
||||
"--color-surface-300": "242 241 240", // #f2f1f0
|
||||
"--color-surface-400": "232 231 229", // #e8e7e5
|
||||
"--color-surface-500": "222 221 218", // #deddda
|
||||
"--color-surface-600": "200 199 196", // #c8c7c4
|
||||
"--color-surface-700": "167 166 164", // #a7a6a4
|
||||
"--color-surface-800": "133 133 131", // #858583
|
||||
"--color-surface-900": "109 108 107", // #6d6c6b
|
||||
|
||||
}
|
||||
}
|
||||
103
osit_ae_theme_3.ts
Normal file
103
osit_ae_theme_3.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
import type { CustomThemeConfig } from '@skeletonlabs/tw-plugin';
|
||||
|
||||
export const myCustomTheme: CustomThemeConfig = {
|
||||
name: 'my-custom-theme',
|
||||
properties: {
|
||||
// =~= Theme Properties =~=
|
||||
"--theme-font-family-base": `Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'`,
|
||||
"--theme-font-family-heading": `Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'`,
|
||||
"--theme-font-color-base": "0 0 0",
|
||||
"--theme-font-color-dark": "255 255 255",
|
||||
"--theme-rounded-base": "16px",
|
||||
"--theme-rounded-container": "8px",
|
||||
"--theme-border-base": "1px",
|
||||
// =~= Theme On-X Colors =~=
|
||||
"--on-primary": "0 0 0",
|
||||
"--on-secondary": "0 0 0",
|
||||
"--on-tertiary": "0 0 0",
|
||||
"--on-success": "0 0 0",
|
||||
"--on-warning": "0 0 0",
|
||||
"--on-error": "0 0 0",
|
||||
"--on-surface": "0 0 0",
|
||||
// =~= Theme Colors =~=
|
||||
// primary | #3584e4
|
||||
"--color-primary-50": "225 237 251", // #e1edfb
|
||||
"--color-primary-100": "215 230 250", // #d7e6fa
|
||||
"--color-primary-200": "205 224 248", // #cde0f8
|
||||
"--color-primary-300": "174 206 244", // #aecef4
|
||||
"--color-primary-400": "114 169 236", // #72a9ec
|
||||
"--color-primary-500": "53 132 228", // #3584e4
|
||||
"--color-primary-600": "48 119 205", // #3077cd
|
||||
"--color-primary-700": "40 99 171", // #2863ab
|
||||
"--color-primary-800": "32 79 137", // #204f89
|
||||
"--color-primary-900": "26 65 112", // #1a4170
|
||||
// secondary | #99c1f1
|
||||
"--color-secondary-50": "240 246 253", // #f0f6fd
|
||||
"--color-secondary-100": "235 243 252", // #ebf3fc
|
||||
"--color-secondary-200": "230 240 252", // #e6f0fc
|
||||
"--color-secondary-300": "214 230 249", // #d6e6f9
|
||||
"--color-secondary-400": "184 212 245", // #b8d4f5
|
||||
"--color-secondary-500": "153 193 241", // #99c1f1
|
||||
"--color-secondary-600": "138 174 217", // #8aaed9
|
||||
"--color-secondary-700": "115 145 181", // #7391b5
|
||||
"--color-secondary-800": "92 116 145", // #5c7491
|
||||
"--color-secondary-900": "75 95 118", // #4b5f76
|
||||
// tertiary | #f8e45c
|
||||
"--color-tertiary-50": "254 251 231", // #fefbe7
|
||||
"--color-tertiary-100": "254 250 222", // #fefade
|
||||
"--color-tertiary-200": "253 248 214", // #fdf8d6
|
||||
"--color-tertiary-300": "252 244 190", // #fcf4be
|
||||
"--color-tertiary-400": "250 236 141", // #faec8d
|
||||
"--color-tertiary-500": "248 228 92", // #f8e45c
|
||||
"--color-tertiary-600": "223 205 83", // #dfcd53
|
||||
"--color-tertiary-700": "186 171 69", // #baab45
|
||||
"--color-tertiary-800": "149 137 55", // #958937
|
||||
"--color-tertiary-900": "122 112 45", // #7a702d
|
||||
// success | #33d17a
|
||||
"--color-success-50": "224 248 235", // #e0f8eb
|
||||
"--color-success-100": "214 246 228", // #d6f6e4
|
||||
"--color-success-200": "204 244 222", // #ccf4de
|
||||
"--color-success-300": "173 237 202", // #adedca
|
||||
"--color-success-400": "112 223 162", // #70dfa2
|
||||
"--color-success-500": "51 209 122", // #33d17a
|
||||
"--color-success-600": "46 188 110", // #2ebc6e
|
||||
"--color-success-700": "38 157 92", // #269d5c
|
||||
"--color-success-800": "31 125 73", // #1f7d49
|
||||
"--color-success-900": "25 102 60", // #19663c
|
||||
// warning | #ffa348
|
||||
"--color-warning-50": "255 241 228", // #fff1e4
|
||||
"--color-warning-100": "255 237 218", // #ffedda
|
||||
"--color-warning-200": "255 232 209", // #ffe8d1
|
||||
"--color-warning-300": "255 218 182", // #ffdab6
|
||||
"--color-warning-400": "255 191 127", // #ffbf7f
|
||||
"--color-warning-500": "255 163 72", // #ffa348
|
||||
"--color-warning-600": "230 147 65", // #e69341
|
||||
"--color-warning-700": "191 122 54", // #bf7a36
|
||||
"--color-warning-800": "153 98 43", // #99622b
|
||||
"--color-warning-900": "125 80 35", // #7d5023
|
||||
// error | #f66151
|
||||
"--color-error-50": "254 231 229", // #fee7e5
|
||||
"--color-error-100": "253 223 220", // #fddfdc
|
||||
"--color-error-200": "253 216 212", // #fdd8d4
|
||||
"--color-error-300": "251 192 185", // #fbc0b9
|
||||
"--color-error-400": "249 144 133", // #f99085
|
||||
"--color-error-500": "246 97 81", // #f66151
|
||||
"--color-error-600": "221 87 73", // #dd5749
|
||||
"--color-error-700": "185 73 61", // #b9493d
|
||||
"--color-error-800": "148 58 49", // #943a31
|
||||
"--color-error-900": "121 48 40", // #793028
|
||||
// surface | #deddda
|
||||
"--color-surface-50": "250 250 249", // #fafaf9
|
||||
"--color-surface-100": "248 248 248", // #f8f8f8
|
||||
"--color-surface-200": "247 247 246", // #f7f7f6
|
||||
"--color-surface-300": "242 241 240", // #f2f1f0
|
||||
"--color-surface-400": "232 231 229", // #e8e7e5
|
||||
"--color-surface-500": "222 221 218", // #deddda
|
||||
"--color-surface-600": "200 199 196", // #c8c7c4
|
||||
"--color-surface-700": "167 166 164", // #a7a6a4
|
||||
"--color-surface-800": "133 133 131", // #858583
|
||||
"--color-surface-900": "109 108 107", // #6d6c6b
|
||||
|
||||
}
|
||||
}
|
||||
7572
package-lock.json
generated
7572
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
110
package.json
110
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ae-app-svelte5",
|
||||
"version": "0.2.711",
|
||||
"name": "ae-app-svelte4-tailwind-skeleton",
|
||||
"version": "0.1.5",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
@@ -18,99 +18,51 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.28.1",
|
||||
"@skeletonlabs/skeleton": "^3.1.3",
|
||||
"@skeletonlabs/skeleton-svelte": "^1.2.3",
|
||||
"@sveltejs/adapter-auto": "^6.0.0",
|
||||
"@skeletonlabs/skeleton": "^3.0.0-next.5",
|
||||
"@skeletonlabs/skeleton-svelte": "^1.0.0-next.10",
|
||||
"@skeletonlabs/tw-plugin": "^0.4.0",
|
||||
"@sveltejs/adapter-auto": "^3.0.0",
|
||||
"@sveltejs/adapter-node": "^5.0.0",
|
||||
"@sveltejs/adapter-static": "^3.0.1",
|
||||
"@sveltejs/kit": "^2.5.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^5.0.0",
|
||||
"@sveltejs/kit": "^2.0.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^4.0.0-next",
|
||||
"@tailwindcss/forms": "^0.5.7",
|
||||
"@tailwindcss/typography": "^0.5.10",
|
||||
"@tiptap/core": "^2.10.3",
|
||||
"@tiptap/extension-bubble-menu": "^2.10.3",
|
||||
"@tiptap/extension-code-block-lowlight": "^2.10.3",
|
||||
"@tiptap/extension-color": "^2.10.3",
|
||||
"@tiptap/extension-highlight": "^2.10.3",
|
||||
"@tiptap/extension-image": "^2.10.3",
|
||||
"@tiptap/extension-link": "^2.10.3",
|
||||
"@tiptap/extension-subscript": "^2.10.3",
|
||||
"@tiptap/extension-superscript": "^2.10.3",
|
||||
"@tiptap/extension-table": "^2.10.3",
|
||||
"@tiptap/extension-table-cell": "^2.10.3",
|
||||
"@tiptap/extension-table-header": "^2.10.3",
|
||||
"@tiptap/extension-table-row": "^2.10.3",
|
||||
"@tiptap/extension-task-item": "^2.10.3",
|
||||
"@tiptap/extension-task-list": "^2.10.3",
|
||||
"@tiptap/extension-text": "^2.10.3",
|
||||
"@tiptap/extension-text-align": "^2.10.3",
|
||||
"@tiptap/extension-text-style": "^2.10.3",
|
||||
"@tiptap/extension-typography": "^2.10.3",
|
||||
"@tiptap/extension-underline": "^2.10.3",
|
||||
"@tiptap/pm": "^2.10.3",
|
||||
"@tiptap/starter-kit": "^2.10.3",
|
||||
"@types/eslint": "^9.0.0",
|
||||
"@types/node": "^24.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
||||
"@typescript-eslint/parser": "^8.0.0",
|
||||
"bits-ui": "^2.0.0",
|
||||
"clsx": "^2.1.1",
|
||||
"@types/node": "^22.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.9.0",
|
||||
"@typescript-eslint/parser": "^8.9.0",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"eslint": "^9.0.0",
|
||||
"eslint-config-prettier": "^10.0.0",
|
||||
"eslint-plugin-svelte": "^3.0.0",
|
||||
"flowbite": "^3.0.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-svelte": "^2.36.0-next",
|
||||
"flowbite": "^2.5.2",
|
||||
"flowbite-svelte": "^0.46.23",
|
||||
"flowbite-svelte-icons": "^1.6.2",
|
||||
"highlight.js": "^11.10.0",
|
||||
"lowlight": "^3.2.0",
|
||||
"mode-watcher": "^1.0.0",
|
||||
"postcss": "^8.4.41",
|
||||
"prettier": "^3.1.1",
|
||||
"prettier-plugin-svelte": "^3.1.2",
|
||||
"sass-embedded": "^1.81.0",
|
||||
"svelte": "^5.0.0",
|
||||
"svelte-awesome-color-picker": "^4.0.0",
|
||||
"svelte": "^5.0.0-next",
|
||||
"svelte-check": "^4.0.0",
|
||||
"svelte-highlight": "^7.8.3",
|
||||
"svelte-idle": "^3.0.1",
|
||||
"svelte-tiptap": "^2.1.0",
|
||||
"tailwind-merge": "^3.0.0",
|
||||
"tailwind-variants": "^2.1.0",
|
||||
"tailwindcss": "^4.1.10",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"svelte-highlight": "^7.7.0",
|
||||
"tailwindcss": "^3.4.10",
|
||||
"tslib": "^2.4.1",
|
||||
"typescript": "^5.0.0",
|
||||
"typescript-svelte-plugin": "^0.3.47",
|
||||
"vite": "^6.0.0",
|
||||
"vitest": "^3.0.0"
|
||||
"typescript-svelte-plugin": "^0.3.41",
|
||||
"vite": "^5.4.0",
|
||||
"vite-plugin-tailwind-purgecss": "^0.3.3",
|
||||
"vitest": "^2.1.0"
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@codemirror/commands": "^6.8.1",
|
||||
"@codemirror/gutter": "^0.19.9",
|
||||
"@codemirror/lang-css": "^6.3.1",
|
||||
"@codemirror/lang-html": "^6.4.9",
|
||||
"@codemirror/lang-javascript": "^6.2.3",
|
||||
"@codemirror/lang-json": "^6.0.1",
|
||||
"@codemirror/lang-markdown": "^6.3.2",
|
||||
"@codemirror/language": "^6.11.0",
|
||||
"@codemirror/language-data": "^6.5.1",
|
||||
"@codemirror/theme-one-dark": "^6.1.2",
|
||||
"@codemirror/view": "^6.36.8",
|
||||
"@floating-ui/dom": "^1.6.0",
|
||||
"@lucide/svelte": "^0.539.0",
|
||||
"@popperjs/core": "^2.11.0",
|
||||
"@tailwindcss/vite": "^4.1.10",
|
||||
"@tiptap/extension-bullet-list": "^2.10.2",
|
||||
"@tiptap/extension-document": "^2.10.2",
|
||||
"@tiptap/extension-history": "^2.10.2",
|
||||
"@tiptap/extension-paragraph": "^2.10.2",
|
||||
"axios": "^1.7.0",
|
||||
"codemirror": "^6.0.1",
|
||||
"@floating-ui/dom": "^1.6.3",
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"axios": "^1.6.7",
|
||||
"dayjs": "^1.11.10",
|
||||
"dexie": "^4.0.0",
|
||||
"flowbite-svelte": "^1.7.0",
|
||||
"dexie": "^4.0.1-beta.14",
|
||||
"html5-qrcode": "^2.3.8",
|
||||
"lucide-svelte": "^0.539.0",
|
||||
"marked": "^16.0.0",
|
||||
"shadcn-svelte": "^1.0.0",
|
||||
"svelte-persisted-store": "^0.12.0"
|
||||
"svelte-persisted-store": "^0.11.0",
|
||||
"tailwind-merge": "^2.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
6
postcss.config.cjs
Normal file
6
postcss.config.cjs
Normal file
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
@@ -1,205 +0,0 @@
|
||||
[data-theme='AE_c_IDAA_light'] {
|
||||
--text-scaling: 1.067;
|
||||
--base-font-color: var(--color-surface-950);
|
||||
|
||||
--base-font-family: system-ui, sans-serif;
|
||||
--base-font-size: inherit;
|
||||
--base-line-height: inherit;
|
||||
--base-font-weight: normal;
|
||||
--base-font-style: normal;
|
||||
--base-letter-spacing: 0em;
|
||||
--heading-font-color: inherit;
|
||||
|
||||
--heading-font-family: inherit;
|
||||
--heading-font-weight: bold;
|
||||
--heading-font-style: normal;
|
||||
--heading-letter-spacing: inherit;
|
||||
--anchor-font-color: var(--color-primary-600);
|
||||
|
||||
--anchor-font-family: inherit;
|
||||
--anchor-font-size: inherit;
|
||||
--anchor-line-height: inherit;
|
||||
--anchor-font-weight: inherit;
|
||||
--anchor-font-style: inherit;
|
||||
--anchor-letter-spacing: inherit;
|
||||
--anchor-text-decoration: none;
|
||||
--anchor-text-decoration-hover: underline;
|
||||
--anchor-text-decoration-active: none;
|
||||
--anchor-text-decoration-focus: none;
|
||||
--spacing: 0.25rem;
|
||||
--radius-base: 0.375rem;
|
||||
--radius-container: 0.75rem;
|
||||
--default-border-width: 1px;
|
||||
--default-divide-width: 1px;
|
||||
--default-ring-width: 1px;
|
||||
--body-background-color: var(--color-surface-50);
|
||||
|
||||
--color-primary-50: oklch(85.73% 0.07 251.8deg);
|
||||
--color-primary-100: oklch(78.5% 0.09 252.03deg);
|
||||
--color-primary-200: oklch(71.06% 0.1 253.6deg);
|
||||
--color-primary-300: oklch(63.76% 0.12 253.85deg);
|
||||
--color-primary-400: oklch(56.32% 0.14 255.25deg);
|
||||
--color-primary-500: oklch(49.23% 0.15 256.36deg);
|
||||
--color-primary-600: oklch(43.11% 0.14 258.86deg);
|
||||
--color-primary-700: oklch(36.85% 0.14 261.54deg);
|
||||
--color-primary-800: oklch(30.41% 0.13 263.99deg);
|
||||
--color-primary-900: oklch(23.91% 0.12 265.91deg);
|
||||
--color-primary-950: oklch(16.96% 0.12 264.05deg);
|
||||
|
||||
--color-primary-contrast-light: var(--color-primary-50);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--color-primary-contrast-500: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-600: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-700: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-800: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-900: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-950: var(--color-primary-contrast-light);
|
||||
--color-secondary-50: oklch(96.26% 0.06 196.24deg);
|
||||
--color-secondary-100: oklch(89.14% 0.07 220.79deg);
|
||||
--color-secondary-200: oklch(82.13% 0.08 234.87deg);
|
||||
--color-secondary-300: oklch(75.03% 0.11 245.33deg);
|
||||
--color-secondary-400: oklch(68.15% 0.14 250.72deg);
|
||||
--color-secondary-500: oklch(61.37% 0.16 255.34deg);
|
||||
--color-secondary-600: oklch(55.1% 0.16 256.81deg);
|
||||
--color-secondary-700: oklch(48.64% 0.15 258.4deg);
|
||||
--color-secondary-800: oklch(41.84% 0.15 260.39deg);
|
||||
--color-secondary-900: oklch(35.05% 0.14 262.03deg);
|
||||
--color-secondary-950: oklch(28.12% 0.14 262.47deg);
|
||||
|
||||
--color-secondary-contrast-light: var(--color-secondary-50);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--color-secondary-contrast-600: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-700: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-800: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-900: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-950: var(--color-secondary-contrast-light);
|
||||
--color-tertiary-50: oklch(100% 0 none);
|
||||
--color-tertiary-100: oklch(96.07% 0.01 251.15deg);
|
||||
--color-tertiary-200: oklch(91.88% 0.03 252.69deg);
|
||||
--color-tertiary-300: oklch(87.99% 0.05 253.24deg);
|
||||
--color-tertiary-400: oklch(83.81% 0.06 253.57deg);
|
||||
--color-tertiary-500: oklch(79.93% 0.08 253.32deg);
|
||||
--color-tertiary-600: oklch(72.53% 0.08 251.75deg);
|
||||
--color-tertiary-700: oklch(64.93% 0.08 249.75deg);
|
||||
--color-tertiary-800: oklch(57.14% 0.09 247.99deg);
|
||||
--color-tertiary-900: oklch(49.18% 0.09 246.55deg);
|
||||
--color-tertiary-950: oklch(41.1% 0.09 246.54deg);
|
||||
|
||||
--color-tertiary-contrast-light: var(--color-tertiary-50);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--color-tertiary-contrast-800: var(--color-tertiary-contrast-light);
|
||||
--color-tertiary-contrast-900: var(--color-tertiary-contrast-light);
|
||||
--color-tertiary-contrast-950: var(--color-tertiary-contrast-light);
|
||||
--color-success-50: oklch(95.82% 0.06 184.52deg);
|
||||
--color-success-100: oklch(91.55% 0.08 172.29deg);
|
||||
--color-success-200: oklch(87.44% 0.11 165.22deg);
|
||||
--color-success-300: oklch(83.26% 0.13 161.2deg);
|
||||
--color-success-400: oklch(79.56% 0.16 157.13deg);
|
||||
--color-success-500: oklch(76.12% 0.18 153.61deg);
|
||||
--color-success-600: oklch(69.31% 0.17 151.81deg);
|
||||
--color-success-700: oklch(62.07% 0.16 149.95deg);
|
||||
--color-success-800: oklch(54.9% 0.15 147.65deg);
|
||||
--color-success-900: oklch(47.26% 0.14 145.54deg);
|
||||
--color-success-950: oklch(39.64% 0.13 143.79deg);
|
||||
|
||||
--color-success-contrast-light: var(--color-success-50);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--color-success-contrast-800: var(--color-success-contrast-light);
|
||||
--color-success-contrast-900: var(--color-success-contrast-light);
|
||||
--color-success-contrast-950: var(--color-success-contrast-light);
|
||||
--color-warning-50: oklch(98.26% 0.1 108.02deg);
|
||||
--color-warning-100: oklch(95.84% 0.12 104.66deg);
|
||||
--color-warning-200: oklch(93.48% 0.13 102.21deg);
|
||||
--color-warning-300: oklch(91.49% 0.15 100.17deg);
|
||||
--color-warning-400: oklch(89.28% 0.16 98.19deg);
|
||||
--color-warning-500: oklch(87.14% 0.17 96.01deg);
|
||||
--color-warning-600: oklch(79.88% 0.16 96.31deg);
|
||||
--color-warning-700: oklch(72.35% 0.14 95.62deg);
|
||||
--color-warning-800: oklch(64.73% 0.13 95.92deg);
|
||||
--color-warning-900: oklch(56.77% 0.11 94.87deg);
|
||||
--color-warning-950: oklch(48.63% 0.1 95.22deg);
|
||||
|
||||
--color-warning-contrast-light: var(--color-warning-50);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--color-warning-contrast-800: var(--color-warning-contrast-light);
|
||||
--color-warning-contrast-900: var(--color-warning-contrast-light);
|
||||
--color-warning-contrast-950: var(--color-warning-contrast-light);
|
||||
--color-error-50: oklch(81.88% 0.1 38.14deg);
|
||||
--color-error-100: oklch(75.88% 0.13 31.15deg);
|
||||
--color-error-200: oklch(70.29% 0.16 27.32deg);
|
||||
--color-error-300: oklch(65.15% 0.19 25.65deg);
|
||||
--color-error-400: oklch(60.98% 0.21 25.56deg);
|
||||
--color-error-500: oklch(57.86% 0.22 26.62deg);
|
||||
--color-error-600: oklch(52.52% 0.2 26.86deg);
|
||||
--color-error-700: oklch(46.81% 0.18 27.02deg);
|
||||
--color-error-800: oklch(41.15% 0.16 27.63deg);
|
||||
--color-error-900: oklch(35.01% 0.14 27.9deg);
|
||||
--color-error-950: oklch(28.69% 0.12 29.23deg);
|
||||
|
||||
--color-error-contrast-light: var(--color-error-50);
|
||||
|
||||
|
||||
|
||||
|
||||
--color-error-contrast-400: var(--color-error-contrast-light);
|
||||
--color-error-contrast-500: var(--color-error-contrast-light);
|
||||
--color-error-contrast-600: var(--color-error-contrast-light);
|
||||
--color-error-contrast-700: var(--color-error-contrast-light);
|
||||
--color-error-contrast-800: var(--color-error-contrast-light);
|
||||
--color-error-contrast-900: var(--color-error-contrast-light);
|
||||
--color-error-contrast-950: var(--color-error-contrast-light);
|
||||
--color-surface-50: oklch(100% 0 none);
|
||||
--color-surface-100: oklch(93.98% 0 105.57deg);
|
||||
--color-surface-200: oklch(87.66% 0 67.88deg);
|
||||
--color-surface-300: oklch(81.35% 0 106.1deg);
|
||||
--color-surface-400: oklch(74.79% 0 84.45deg);
|
||||
--color-surface-500: oklch(68.29% 0 91.36deg);
|
||||
--color-surface-600: oklch(60.99% 0 91.38deg);
|
||||
--color-surface-700: oklch(53.5% 0 84.49deg);
|
||||
--color-surface-800: oklch(46.03% 0 91.43deg);
|
||||
--color-surface-900: oklch(37.94% 0 84.52deg);
|
||||
--color-surface-950: oklch(29.34% 0 84.54deg);
|
||||
|
||||
--color-surface-contrast-light: var(--color-surface-50);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--color-surface-contrast-700: var(--color-surface-contrast-light);
|
||||
--color-surface-contrast-800: var(--color-surface-contrast-light);
|
||||
--color-surface-contrast-900: var(--color-surface-contrast-light);
|
||||
--color-surface-contrast-950: var(--color-surface-contrast-light);
|
||||
}
|
||||
205
src/ae-c-lci.css
205
src/ae-c-lci.css
@@ -1,205 +0,0 @@
|
||||
[data-theme='AE_c_LCI'] {
|
||||
--text-scaling: 1.067;
|
||||
--base-font-color: var(--color-surface-950);
|
||||
--base-font-color-dark: var(--color-surface-50);
|
||||
--base-font-family: system-ui, sans-serif;
|
||||
--base-font-size: inherit;
|
||||
--base-line-height: inherit;
|
||||
--base-font-weight: normal;
|
||||
--base-font-style: normal;
|
||||
--base-letter-spacing: 0em;
|
||||
--heading-font-color: inherit;
|
||||
--heading-font-color-dark: inherit;
|
||||
--heading-font-family: inherit;
|
||||
--heading-font-weight: bold;
|
||||
--heading-font-style: normal;
|
||||
--heading-letter-spacing: inherit;
|
||||
--anchor-font-color: var(--color-primary-500);
|
||||
--anchor-font-color-dark: var(--color-primary-500);
|
||||
--anchor-font-family: inherit;
|
||||
--anchor-font-size: inherit;
|
||||
--anchor-line-height: inherit;
|
||||
--anchor-font-weight: inherit;
|
||||
--anchor-font-style: inherit;
|
||||
--anchor-letter-spacing: inherit;
|
||||
--anchor-text-decoration: none;
|
||||
--anchor-text-decoration-hover: underline;
|
||||
--anchor-text-decoration-active: none;
|
||||
--anchor-text-decoration-focus: none;
|
||||
--spacing: 0.25rem;
|
||||
--radius-base: 0.375rem;
|
||||
--radius-container: 0.75rem;
|
||||
--default-border-width: 1px;
|
||||
--default-divide-width: 1px;
|
||||
--default-ring-width: 1px;
|
||||
--body-background-color: var(--color-surface-50);
|
||||
--body-background-color-dark: var(--color-surface-950);
|
||||
--color-primary-50: oklch(85.1% 0.07 265.19deg);
|
||||
--color-primary-100: oklch(77.89% 0.08 264.31deg);
|
||||
--color-primary-200: oklch(70.32% 0.08 264.44deg);
|
||||
--color-primary-300: oklch(62.86% 0.09 263.87deg);
|
||||
--color-primary-400: oklch(54.96% 0.1 263.8deg);
|
||||
--color-primary-500: oklch(47.12% 0.11 262.88deg);
|
||||
--color-primary-600: oklch(40.9% 0.1 264.73deg);
|
||||
--color-primary-700: oklch(34.53% 0.1 267.34deg);
|
||||
--color-primary-800: oklch(28.16% 0.09 268.81deg);
|
||||
--color-primary-900: oklch(21.29% 0.09 271.12deg);
|
||||
--color-primary-950: oklch(12.88% 0.09 264.05deg);
|
||||
--color-primary-contrast-dark: var(--color-primary-950);
|
||||
--color-primary-contrast-light: var(--color-primary-50);
|
||||
--color-primary-contrast-50: var(--color-primary-contrast-dark);
|
||||
--color-primary-contrast-100: var(--color-primary-contrast-dark);
|
||||
--color-primary-contrast-200: var(--color-primary-contrast-dark);
|
||||
--color-primary-contrast-300: var(--color-primary-contrast-dark);
|
||||
--color-primary-contrast-400: var(--color-primary-contrast-dark);
|
||||
--color-primary-contrast-500: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-600: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-700: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-800: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-900: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-950: var(--color-primary-contrast-light);
|
||||
--color-secondary-50: oklch(96.14% 0.06 196.21deg);
|
||||
--color-secondary-100: oklch(89.81% 0.07 212.45deg);
|
||||
--color-secondary-200: oklch(83.71% 0.08 223.06deg);
|
||||
--color-secondary-300: oklch(77.42% 0.1 231.73deg);
|
||||
--color-secondary-400: oklch(71.44% 0.12 237.59deg);
|
||||
--color-secondary-500: oklch(65.39% 0.14 243.22deg);
|
||||
--color-secondary-600: oklch(58.93% 0.13 245.07deg);
|
||||
--color-secondary-700: oklch(52.09% 0.12 248.03deg);
|
||||
--color-secondary-800: oklch(45.27% 0.12 250.54deg);
|
||||
--color-secondary-900: oklch(38.01% 0.11 254.24deg);
|
||||
--color-secondary-950: oklch(30.67% 0.11 256.73deg);
|
||||
--color-secondary-contrast-dark: var(--color-secondary-950);
|
||||
--color-secondary-contrast-light: var(--color-secondary-50);
|
||||
--color-secondary-contrast-50: var(--color-secondary-contrast-dark);
|
||||
--color-secondary-contrast-100: var(--color-secondary-contrast-dark);
|
||||
--color-secondary-contrast-200: var(--color-secondary-contrast-dark);
|
||||
--color-secondary-contrast-300: var(--color-secondary-contrast-dark);
|
||||
--color-secondary-contrast-400: var(--color-secondary-contrast-dark);
|
||||
--color-secondary-contrast-500: var(--color-secondary-contrast-dark);
|
||||
--color-secondary-contrast-600: var(--color-secondary-contrast-dark);
|
||||
--color-secondary-contrast-700: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-800: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-900: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-950: var(--color-secondary-contrast-light);
|
||||
--color-tertiary-50: oklch(87.75% 0.12 326.52deg);
|
||||
--color-tertiary-100: oklch(80.92% 0.13 323.93deg);
|
||||
--color-tertiary-200: oklch(73.87% 0.14 321.55deg);
|
||||
--color-tertiary-300: oklch(66.9% 0.15 319.41deg);
|
||||
--color-tertiary-400: oklch(59.72% 0.16 317.25deg);
|
||||
--color-tertiary-500: oklch(52.73% 0.17 315.13deg);
|
||||
--color-tertiary-600: oklch(46.6% 0.16 314.18deg);
|
||||
--color-tertiary-700: oklch(40.43% 0.14 312.8deg);
|
||||
--color-tertiary-800: oklch(33.85% 0.13 309.88deg);
|
||||
--color-tertiary-900: oklch(27.23% 0.12 306.83deg);
|
||||
--color-tertiary-950: oklch(19.83% 0.1 302.7deg);
|
||||
--color-tertiary-contrast-dark: var(--color-tertiary-950);
|
||||
--color-tertiary-contrast-light: var(--color-tertiary-50);
|
||||
--color-tertiary-contrast-50: var(--color-tertiary-contrast-dark);
|
||||
--color-tertiary-contrast-100: var(--color-tertiary-contrast-dark);
|
||||
--color-tertiary-contrast-200: var(--color-tertiary-contrast-dark);
|
||||
--color-tertiary-contrast-300: var(--color-tertiary-contrast-dark);
|
||||
--color-tertiary-contrast-400: var(--color-tertiary-contrast-light);
|
||||
--color-tertiary-contrast-500: var(--color-tertiary-contrast-light);
|
||||
--color-tertiary-contrast-600: var(--color-tertiary-contrast-light);
|
||||
--color-tertiary-contrast-700: var(--color-tertiary-contrast-light);
|
||||
--color-tertiary-contrast-800: var(--color-tertiary-contrast-light);
|
||||
--color-tertiary-contrast-900: var(--color-tertiary-contrast-light);
|
||||
--color-tertiary-contrast-950: var(--color-tertiary-contrast-light);
|
||||
--color-success-50: oklch(95.23% 0.07 195.99deg);
|
||||
--color-success-100: oklch(90.22% 0.09 189.46deg);
|
||||
--color-success-200: oklch(85.11% 0.1 186.03deg);
|
||||
--color-success-300: oklch(80.35% 0.12 181.75deg);
|
||||
--color-success-400: oklch(75.55% 0.12 178.92deg);
|
||||
--color-success-500: oklch(71.19% 0.13 174.73deg);
|
||||
--color-success-600: oklch(64.29% 0.12 173.65deg);
|
||||
--color-success-700: oklch(57.46% 0.11 171.75deg);
|
||||
--color-success-800: oklch(50.18% 0.1 170.68deg);
|
||||
--color-success-900: oklch(42.87% 0.09 167.65deg);
|
||||
--color-success-950: oklch(34.91% 0.07 164.42deg);
|
||||
--color-success-contrast-dark: var(--color-success-950);
|
||||
--color-success-contrast-light: var(--color-success-50);
|
||||
--color-success-contrast-50: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-100: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-200: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-300: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-400: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-500: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-600: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-700: var(--color-success-contrast-light);
|
||||
--color-success-contrast-800: var(--color-success-contrast-light);
|
||||
--color-success-contrast-900: var(--color-success-contrast-light);
|
||||
--color-success-contrast-950: var(--color-success-contrast-light);
|
||||
--color-warning-50: oklch(95.67% 0.05 84.56deg);
|
||||
--color-warning-100: oklch(92.83% 0.06 82.16deg);
|
||||
--color-warning-200: oklch(90.12% 0.08 80.33deg);
|
||||
--color-warning-300: oklch(87.59% 0.1 80.01deg);
|
||||
--color-warning-400: oklch(85.03% 0.12 78.35deg);
|
||||
--color-warning-500: oklch(82.46% 0.14 76.71deg);
|
||||
--color-warning-600: oklch(76.34% 0.13 72.25deg);
|
||||
--color-warning-700: oklch(70.34% 0.13 68.09deg);
|
||||
--color-warning-800: oklch(63.99% 0.13 63.18deg);
|
||||
--color-warning-900: oklch(57.91% 0.13 57.97deg);
|
||||
--color-warning-950: oklch(51.69% 0.13 51.44deg);
|
||||
--color-warning-contrast-dark: var(--color-warning-950);
|
||||
--color-warning-contrast-light: var(--color-warning-50);
|
||||
--color-warning-contrast-50: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-100: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-200: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-300: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-400: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-500: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-600: var(--color-warning-contrast-light);
|
||||
--color-warning-contrast-700: var(--color-warning-contrast-light);
|
||||
--color-warning-contrast-800: var(--color-warning-contrast-light);
|
||||
--color-warning-contrast-900: var(--color-warning-contrast-light);
|
||||
--color-warning-contrast-950: var(--color-warning-contrast-light);
|
||||
--color-error-50: oklch(84.29% 0.09 46.91deg);
|
||||
--color-error-100: oklch(78.63% 0.12 39.19deg);
|
||||
--color-error-200: oklch(72.92% 0.14 34.35deg);
|
||||
--color-error-300: oklch(67.88% 0.17 31.48deg);
|
||||
--color-error-400: oklch(63.09% 0.19 30.02deg);
|
||||
--color-error-500: oklch(59.32% 0.21 29.47deg);
|
||||
--color-error-600: oklch(53.56% 0.19 29.25deg);
|
||||
--color-error-700: oklch(47.75% 0.17 29.2deg);
|
||||
--color-error-800: oklch(41.51% 0.15 28.7deg);
|
||||
--color-error-900: oklch(35.35% 0.14 28.7deg);
|
||||
--color-error-950: oklch(28.69% 0.12 29.23deg);
|
||||
--color-error-contrast-dark: var(--color-error-950);
|
||||
--color-error-contrast-light: var(--color-error-50);
|
||||
--color-error-contrast-50: var(--color-error-contrast-dark);
|
||||
--color-error-contrast-100: var(--color-error-contrast-dark);
|
||||
--color-error-contrast-200: var(--color-error-contrast-dark);
|
||||
--color-error-contrast-300: var(--color-error-contrast-dark);
|
||||
--color-error-contrast-400: var(--color-error-contrast-dark);
|
||||
--color-error-contrast-500: var(--color-error-contrast-light);
|
||||
--color-error-contrast-600: var(--color-error-contrast-light);
|
||||
--color-error-contrast-700: var(--color-error-contrast-light);
|
||||
--color-error-contrast-800: var(--color-error-contrast-light);
|
||||
--color-error-contrast-900: var(--color-error-contrast-light);
|
||||
--color-error-contrast-950: var(--color-error-contrast-light);
|
||||
--color-surface-50: oklch(100% 0 none);
|
||||
--color-surface-100: oklch(97.02% 0 none);
|
||||
--color-surface-200: oklch(94.01% 0 none);
|
||||
--color-surface-300: oklch(91.12% 0 196.34deg);
|
||||
--color-surface-400: oklch(88.07% 0 196.37deg);
|
||||
--color-surface-500: oklch(84.99% 0 196.4deg);
|
||||
--color-surface-600: oklch(77.78% 0 196.47deg);
|
||||
--color-surface-700: oklch(70.09% 0 196.54deg);
|
||||
--color-surface-800: oklch(62.51% 0 196.61deg);
|
||||
--color-surface-900: oklch(54.34% 0 196.68deg);
|
||||
--color-surface-950: oklch(46.22% 0 196.73deg);
|
||||
--color-surface-contrast-dark: var(--color-surface-950);
|
||||
--color-surface-contrast-light: var(--color-surface-50);
|
||||
--color-surface-contrast-50: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-100: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-200: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-300: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-400: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-500: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-600: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-700: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-800: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-900: var(--color-surface-contrast-light);
|
||||
--color-surface-contrast-950: var(--color-surface-contrast-light);
|
||||
}
|
||||
@@ -1,205 +0,0 @@
|
||||
[data-theme='AE_OSIT_default'] {
|
||||
--text-scaling: 1.067;
|
||||
--base-font-color: var(--color-surface-950);
|
||||
--base-font-color-dark: var(--color-surface-50);
|
||||
--base-font-family: system-ui, sans-serif;
|
||||
--base-font-size: inherit;
|
||||
--base-line-height: inherit;
|
||||
--base-font-weight: normal;
|
||||
--base-font-style: normal;
|
||||
--base-letter-spacing: 0em;
|
||||
--heading-font-color: inherit;
|
||||
--heading-font-color-dark: inherit;
|
||||
--heading-font-family: inherit;
|
||||
--heading-font-weight: bold;
|
||||
--heading-font-style: normal;
|
||||
--heading-letter-spacing: inherit;
|
||||
--anchor-font-color: var(--color-primary-600);
|
||||
--anchor-font-color-dark: var(--color-primary-400);
|
||||
--anchor-font-family: inherit;
|
||||
--anchor-font-size: inherit;
|
||||
--anchor-line-height: inherit;
|
||||
--anchor-font-weight: inherit;
|
||||
--anchor-font-style: inherit;
|
||||
--anchor-letter-spacing: inherit;
|
||||
--anchor-text-decoration: none;
|
||||
--anchor-text-decoration-hover: underline;
|
||||
--anchor-text-decoration-active: none;
|
||||
--anchor-text-decoration-focus: none;
|
||||
--spacing: 0.25rem;
|
||||
--radius-base: 0.375rem;
|
||||
--radius-container: 0.75rem;
|
||||
--default-border-width: 1px;
|
||||
--default-divide-width: 1px;
|
||||
--default-ring-width: 1px;
|
||||
--body-background-color: var(--color-surface-50);
|
||||
--body-background-color-dark: var(--color-surface-950);
|
||||
--color-primary-50: oklch(85.73% 0.07 251.8deg);
|
||||
--color-primary-100: oklch(78.5% 0.09 252.03deg);
|
||||
--color-primary-200: oklch(71.06% 0.1 253.6deg);
|
||||
--color-primary-300: oklch(63.76% 0.12 253.85deg);
|
||||
--color-primary-400: oklch(56.32% 0.14 255.25deg);
|
||||
--color-primary-500: oklch(49.23% 0.15 256.36deg);
|
||||
--color-primary-600: oklch(43.11% 0.14 258.86deg);
|
||||
--color-primary-700: oklch(36.85% 0.14 261.54deg);
|
||||
--color-primary-800: oklch(30.41% 0.13 263.99deg);
|
||||
--color-primary-900: oklch(23.91% 0.12 265.91deg);
|
||||
--color-primary-950: oklch(16.96% 0.12 264.05deg);
|
||||
--color-primary-contrast-dark: var(--color-primary-950);
|
||||
--color-primary-contrast-light: var(--color-primary-50);
|
||||
--color-primary-contrast-50: var(--color-primary-contrast-dark);
|
||||
--color-primary-contrast-100: var(--color-primary-contrast-dark);
|
||||
--color-primary-contrast-200: var(--color-primary-contrast-dark);
|
||||
--color-primary-contrast-300: var(--color-primary-contrast-dark);
|
||||
--color-primary-contrast-400: var(--color-primary-contrast-dark);
|
||||
--color-primary-contrast-500: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-600: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-700: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-800: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-900: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-950: var(--color-primary-contrast-light);
|
||||
--color-secondary-50: oklch(96.26% 0.06 196.24deg);
|
||||
--color-secondary-100: oklch(89.14% 0.07 220.79deg);
|
||||
--color-secondary-200: oklch(82.13% 0.08 234.87deg);
|
||||
--color-secondary-300: oklch(75.03% 0.11 245.33deg);
|
||||
--color-secondary-400: oklch(68.15% 0.14 250.72deg);
|
||||
--color-secondary-500: oklch(61.37% 0.16 255.34deg);
|
||||
--color-secondary-600: oklch(55.1% 0.16 256.81deg);
|
||||
--color-secondary-700: oklch(48.64% 0.15 258.4deg);
|
||||
--color-secondary-800: oklch(41.84% 0.15 260.39deg);
|
||||
--color-secondary-900: oklch(35.05% 0.14 262.03deg);
|
||||
--color-secondary-950: oklch(28.12% 0.14 262.47deg);
|
||||
--color-secondary-contrast-dark: var(--color-secondary-950);
|
||||
--color-secondary-contrast-light: var(--color-secondary-50);
|
||||
--color-secondary-contrast-50: var(--color-secondary-contrast-dark);
|
||||
--color-secondary-contrast-100: var(--color-secondary-contrast-dark);
|
||||
--color-secondary-contrast-200: var(--color-secondary-contrast-dark);
|
||||
--color-secondary-contrast-300: var(--color-secondary-contrast-dark);
|
||||
--color-secondary-contrast-400: var(--color-secondary-contrast-dark);
|
||||
--color-secondary-contrast-500: var(--color-secondary-contrast-dark);
|
||||
--color-secondary-contrast-600: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-700: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-800: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-900: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-950: var(--color-secondary-contrast-light);
|
||||
--color-tertiary-50: oklch(100% 0 none);
|
||||
--color-tertiary-100: oklch(96.07% 0.01 251.15deg);
|
||||
--color-tertiary-200: oklch(91.88% 0.03 252.69deg);
|
||||
--color-tertiary-300: oklch(87.99% 0.05 253.24deg);
|
||||
--color-tertiary-400: oklch(83.81% 0.06 253.57deg);
|
||||
--color-tertiary-500: oklch(79.93% 0.08 253.32deg);
|
||||
--color-tertiary-600: oklch(72.53% 0.08 251.75deg);
|
||||
--color-tertiary-700: oklch(64.93% 0.08 249.75deg);
|
||||
--color-tertiary-800: oklch(57.14% 0.09 247.99deg);
|
||||
--color-tertiary-900: oklch(49.18% 0.09 246.55deg);
|
||||
--color-tertiary-950: oklch(41.1% 0.09 246.54deg);
|
||||
--color-tertiary-contrast-dark: var(--color-tertiary-950);
|
||||
--color-tertiary-contrast-light: var(--color-tertiary-50);
|
||||
--color-tertiary-contrast-50: var(--color-tertiary-contrast-dark);
|
||||
--color-tertiary-contrast-100: var(--color-tertiary-contrast-dark);
|
||||
--color-tertiary-contrast-200: var(--color-tertiary-contrast-dark);
|
||||
--color-tertiary-contrast-300: var(--color-tertiary-contrast-dark);
|
||||
--color-tertiary-contrast-400: var(--color-tertiary-contrast-dark);
|
||||
--color-tertiary-contrast-500: var(--color-tertiary-contrast-dark);
|
||||
--color-tertiary-contrast-600: var(--color-tertiary-contrast-dark);
|
||||
--color-tertiary-contrast-700: var(--color-tertiary-contrast-dark);
|
||||
--color-tertiary-contrast-800: var(--color-tertiary-contrast-light);
|
||||
--color-tertiary-contrast-900: var(--color-tertiary-contrast-light);
|
||||
--color-tertiary-contrast-950: var(--color-tertiary-contrast-light);
|
||||
--color-success-50: oklch(95.82% 0.06 184.52deg);
|
||||
--color-success-100: oklch(91.55% 0.08 172.29deg);
|
||||
--color-success-200: oklch(87.44% 0.11 165.22deg);
|
||||
--color-success-300: oklch(83.26% 0.13 161.2deg);
|
||||
--color-success-400: oklch(79.56% 0.16 157.13deg);
|
||||
--color-success-500: oklch(76.12% 0.18 153.61deg);
|
||||
--color-success-600: oklch(69.31% 0.17 151.81deg);
|
||||
--color-success-700: oklch(62.07% 0.16 149.95deg);
|
||||
--color-success-800: oklch(54.9% 0.15 147.65deg);
|
||||
--color-success-900: oklch(47.26% 0.14 145.54deg);
|
||||
--color-success-950: oklch(39.64% 0.13 143.79deg);
|
||||
--color-success-contrast-dark: var(--color-success-950);
|
||||
--color-success-contrast-light: var(--color-success-50);
|
||||
--color-success-contrast-50: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-100: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-200: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-300: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-400: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-500: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-600: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-700: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-800: var(--color-success-contrast-light);
|
||||
--color-success-contrast-900: var(--color-success-contrast-light);
|
||||
--color-success-contrast-950: var(--color-success-contrast-light);
|
||||
--color-warning-50: oklch(98.26% 0.1 108.02deg);
|
||||
--color-warning-100: oklch(95.84% 0.12 104.66deg);
|
||||
--color-warning-200: oklch(93.48% 0.13 102.21deg);
|
||||
--color-warning-300: oklch(91.49% 0.15 100.17deg);
|
||||
--color-warning-400: oklch(89.28% 0.16 98.19deg);
|
||||
--color-warning-500: oklch(87.14% 0.17 96.01deg);
|
||||
--color-warning-600: oklch(79.88% 0.16 96.31deg);
|
||||
--color-warning-700: oklch(72.35% 0.14 95.62deg);
|
||||
--color-warning-800: oklch(64.73% 0.13 95.92deg);
|
||||
--color-warning-900: oklch(56.77% 0.11 94.87deg);
|
||||
--color-warning-950: oklch(48.63% 0.1 95.22deg);
|
||||
--color-warning-contrast-dark: var(--color-warning-950);
|
||||
--color-warning-contrast-light: var(--color-warning-50);
|
||||
--color-warning-contrast-50: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-100: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-200: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-300: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-400: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-500: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-600: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-700: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-800: var(--color-warning-contrast-light);
|
||||
--color-warning-contrast-900: var(--color-warning-contrast-light);
|
||||
--color-warning-contrast-950: var(--color-warning-contrast-light);
|
||||
--color-error-50: oklch(81.88% 0.1 38.14deg);
|
||||
--color-error-100: oklch(75.88% 0.13 31.15deg);
|
||||
--color-error-200: oklch(70.29% 0.16 27.32deg);
|
||||
--color-error-300: oklch(65.15% 0.19 25.65deg);
|
||||
--color-error-400: oklch(60.98% 0.21 25.56deg);
|
||||
--color-error-500: oklch(57.86% 0.22 26.62deg);
|
||||
--color-error-600: oklch(52.52% 0.2 26.86deg);
|
||||
--color-error-700: oklch(46.81% 0.18 27.02deg);
|
||||
--color-error-800: oklch(41.15% 0.16 27.63deg);
|
||||
--color-error-900: oklch(35.01% 0.14 27.9deg);
|
||||
--color-error-950: oklch(28.69% 0.12 29.23deg);
|
||||
--color-error-contrast-dark: var(--color-error-950);
|
||||
--color-error-contrast-light: var(--color-error-50);
|
||||
--color-error-contrast-50: var(--color-error-contrast-dark);
|
||||
--color-error-contrast-100: var(--color-error-contrast-dark);
|
||||
--color-error-contrast-200: var(--color-error-contrast-dark);
|
||||
--color-error-contrast-300: var(--color-error-contrast-dark);
|
||||
--color-error-contrast-400: var(--color-error-contrast-light);
|
||||
--color-error-contrast-500: var(--color-error-contrast-light);
|
||||
--color-error-contrast-600: var(--color-error-contrast-light);
|
||||
--color-error-contrast-700: var(--color-error-contrast-light);
|
||||
--color-error-contrast-800: var(--color-error-contrast-light);
|
||||
--color-error-contrast-900: var(--color-error-contrast-light);
|
||||
--color-error-contrast-950: var(--color-error-contrast-light);
|
||||
--color-surface-50: oklch(100% 0 none);
|
||||
--color-surface-100: oklch(93.98% 0 105.57deg);
|
||||
--color-surface-200: oklch(87.66% 0 67.88deg);
|
||||
--color-surface-300: oklch(81.35% 0 106.1deg);
|
||||
--color-surface-400: oklch(74.79% 0 84.45deg);
|
||||
--color-surface-500: oklch(68.29% 0 91.36deg);
|
||||
--color-surface-600: oklch(60.99% 0 91.38deg);
|
||||
--color-surface-700: oklch(53.5% 0 84.49deg);
|
||||
--color-surface-800: oklch(46.03% 0 91.43deg);
|
||||
--color-surface-900: oklch(37.94% 0 84.52deg);
|
||||
--color-surface-950: oklch(29.34% 0 84.54deg);
|
||||
--color-surface-contrast-dark: var(--color-surface-950);
|
||||
--color-surface-contrast-light: var(--color-surface-50);
|
||||
--color-surface-contrast-50: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-100: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-200: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-300: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-400: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-500: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-600: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-700: var(--color-surface-contrast-light);
|
||||
--color-surface-contrast-800: var(--color-surface-contrast-light);
|
||||
--color-surface-contrast-900: var(--color-surface-contrast-light);
|
||||
--color-surface-contrast-950: var(--color-surface-contrast-light);
|
||||
}
|
||||
@@ -1,205 +0,0 @@
|
||||
[data-theme='aeclci'] {
|
||||
--text-scaling: 1.067;
|
||||
--base-font-color: var(--color-surface-950);
|
||||
--base-font-color-dark: var(--color-surface-50);
|
||||
--base-font-family: system-ui, sans-serif;
|
||||
--base-font-size: inherit;
|
||||
--base-line-height: inherit;
|
||||
--base-font-weight: normal;
|
||||
--base-font-style: normal;
|
||||
--base-letter-spacing: 0em;
|
||||
--heading-font-color: inherit;
|
||||
--heading-font-color-dark: inherit;
|
||||
--heading-font-family: inherit;
|
||||
--heading-font-weight: bold;
|
||||
--heading-font-style: normal;
|
||||
--heading-letter-spacing: inherit;
|
||||
--anchor-font-color: var(--color-primary-500);
|
||||
--anchor-font-color-dark: var(--color-primary-500);
|
||||
--anchor-font-family: inherit;
|
||||
--anchor-font-size: inherit;
|
||||
--anchor-line-height: inherit;
|
||||
--anchor-font-weight: inherit;
|
||||
--anchor-font-style: inherit;
|
||||
--anchor-letter-spacing: inherit;
|
||||
--anchor-text-decoration: none;
|
||||
--anchor-text-decoration-hover: underline;
|
||||
--anchor-text-decoration-active: none;
|
||||
--anchor-text-decoration-focus: none;
|
||||
--spacing: 0.25rem;
|
||||
--radius-base: 0.375rem;
|
||||
--radius-container: 0.75rem;
|
||||
--default-border-width: 1px;
|
||||
--default-divide-width: 1px;
|
||||
--default-ring-width: 1px;
|
||||
--body-background-color: var(--color-surface-50);
|
||||
--body-background-color-dark: var(--color-surface-950);
|
||||
--color-primary-50: oklch(85.1% 0.07 265.19deg);
|
||||
--color-primary-100: oklch(77.89% 0.08 264.31deg);
|
||||
--color-primary-200: oklch(70.32% 0.08 264.44deg);
|
||||
--color-primary-300: oklch(62.86% 0.09 263.87deg);
|
||||
--color-primary-400: oklch(54.96% 0.1 263.8deg);
|
||||
--color-primary-500: oklch(47.12% 0.11 262.88deg);
|
||||
--color-primary-600: oklch(40.9% 0.1 264.73deg);
|
||||
--color-primary-700: oklch(34.53% 0.1 267.34deg);
|
||||
--color-primary-800: oklch(28.16% 0.09 268.81deg);
|
||||
--color-primary-900: oklch(21.29% 0.09 271.12deg);
|
||||
--color-primary-950: oklch(12.88% 0.09 264.05deg);
|
||||
--color-primary-contrast-dark: var(--color-primary-950);
|
||||
--color-primary-contrast-light: var(--color-primary-50);
|
||||
--color-primary-contrast-50: var(--color-primary-contrast-dark);
|
||||
--color-primary-contrast-100: var(--color-primary-contrast-dark);
|
||||
--color-primary-contrast-200: var(--color-primary-contrast-dark);
|
||||
--color-primary-contrast-300: var(--color-primary-contrast-dark);
|
||||
--color-primary-contrast-400: var(--color-primary-contrast-dark);
|
||||
--color-primary-contrast-500: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-600: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-700: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-800: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-900: var(--color-primary-contrast-light);
|
||||
--color-primary-contrast-950: var(--color-primary-contrast-light);
|
||||
--color-secondary-50: oklch(73.24% 0.12 278.78deg);
|
||||
--color-secondary-100: oklch(65.76% 0.12 276.12deg);
|
||||
--color-secondary-200: oklch(58.15% 0.12 273.33deg);
|
||||
--color-secondary-300: oklch(50.59% 0.12 270.28deg);
|
||||
--color-secondary-400: oklch(42.65% 0.12 267.23deg);
|
||||
--color-secondary-500: oklch(34.53% 0.12 264.22deg);
|
||||
--color-secondary-600: oklch(30.3% 0.11 264.59deg);
|
||||
--color-secondary-700: oklch(25.96% 0.09 265.69deg);
|
||||
--color-secondary-800: oklch(21.25% 0.08 267.5deg);
|
||||
--color-secondary-900: oklch(16.42% 0.06 269.55deg);
|
||||
--color-secondary-950: oklch(8.85% 0.06 264.05deg);
|
||||
--color-secondary-contrast-dark: var(--color-secondary-950);
|
||||
--color-secondary-contrast-light: var(--color-secondary-50);
|
||||
--color-secondary-contrast-50: var(--color-secondary-contrast-dark);
|
||||
--color-secondary-contrast-100: var(--color-secondary-contrast-dark);
|
||||
--color-secondary-contrast-200: var(--color-secondary-contrast-dark);
|
||||
--color-secondary-contrast-300: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-400: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-500: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-600: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-700: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-800: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-900: var(--color-secondary-contrast-light);
|
||||
--color-secondary-contrast-950: var(--color-secondary-contrast-light);
|
||||
--color-tertiary-50: oklch(87.75% 0.12 326.52deg);
|
||||
--color-tertiary-100: oklch(80.92% 0.13 323.93deg);
|
||||
--color-tertiary-200: oklch(73.87% 0.14 321.55deg);
|
||||
--color-tertiary-300: oklch(66.9% 0.15 319.41deg);
|
||||
--color-tertiary-400: oklch(59.72% 0.16 317.25deg);
|
||||
--color-tertiary-500: oklch(52.73% 0.17 315.13deg);
|
||||
--color-tertiary-600: oklch(46.6% 0.16 314.18deg);
|
||||
--color-tertiary-700: oklch(40.43% 0.14 312.8deg);
|
||||
--color-tertiary-800: oklch(33.85% 0.13 309.88deg);
|
||||
--color-tertiary-900: oklch(27.23% 0.12 306.83deg);
|
||||
--color-tertiary-950: oklch(19.83% 0.1 302.7deg);
|
||||
--color-tertiary-contrast-dark: var(--color-tertiary-950);
|
||||
--color-tertiary-contrast-light: var(--color-tertiary-50);
|
||||
--color-tertiary-contrast-50: var(--color-tertiary-contrast-dark);
|
||||
--color-tertiary-contrast-100: var(--color-tertiary-contrast-dark);
|
||||
--color-tertiary-contrast-200: var(--color-tertiary-contrast-dark);
|
||||
--color-tertiary-contrast-300: var(--color-tertiary-contrast-dark);
|
||||
--color-tertiary-contrast-400: var(--color-tertiary-contrast-light);
|
||||
--color-tertiary-contrast-500: var(--color-tertiary-contrast-light);
|
||||
--color-tertiary-contrast-600: var(--color-tertiary-contrast-light);
|
||||
--color-tertiary-contrast-700: var(--color-tertiary-contrast-light);
|
||||
--color-tertiary-contrast-800: var(--color-tertiary-contrast-light);
|
||||
--color-tertiary-contrast-900: var(--color-tertiary-contrast-light);
|
||||
--color-tertiary-contrast-950: var(--color-tertiary-contrast-light);
|
||||
--color-success-50: oklch(95.23% 0.07 195.99deg);
|
||||
--color-success-100: oklch(90.22% 0.09 189.46deg);
|
||||
--color-success-200: oklch(85.11% 0.1 186.03deg);
|
||||
--color-success-300: oklch(80.35% 0.12 181.75deg);
|
||||
--color-success-400: oklch(75.55% 0.12 178.92deg);
|
||||
--color-success-500: oklch(71.19% 0.13 174.73deg);
|
||||
--color-success-600: oklch(64.29% 0.12 173.65deg);
|
||||
--color-success-700: oklch(57.46% 0.11 171.75deg);
|
||||
--color-success-800: oklch(50.18% 0.1 170.68deg);
|
||||
--color-success-900: oklch(42.87% 0.09 167.65deg);
|
||||
--color-success-950: oklch(34.91% 0.07 164.42deg);
|
||||
--color-success-contrast-dark: var(--color-success-950);
|
||||
--color-success-contrast-light: var(--color-success-50);
|
||||
--color-success-contrast-50: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-100: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-200: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-300: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-400: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-500: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-600: var(--color-success-contrast-dark);
|
||||
--color-success-contrast-700: var(--color-success-contrast-light);
|
||||
--color-success-contrast-800: var(--color-success-contrast-light);
|
||||
--color-success-contrast-900: var(--color-success-contrast-light);
|
||||
--color-success-contrast-950: var(--color-success-contrast-light);
|
||||
--color-warning-50: oklch(95.67% 0.05 84.56deg);
|
||||
--color-warning-100: oklch(92.83% 0.06 82.16deg);
|
||||
--color-warning-200: oklch(90.12% 0.08 80.33deg);
|
||||
--color-warning-300: oklch(87.59% 0.1 80.01deg);
|
||||
--color-warning-400: oklch(85.03% 0.12 78.35deg);
|
||||
--color-warning-500: oklch(82.46% 0.14 76.71deg);
|
||||
--color-warning-600: oklch(76.34% 0.13 72.25deg);
|
||||
--color-warning-700: oklch(70.34% 0.13 68.09deg);
|
||||
--color-warning-800: oklch(63.99% 0.13 63.18deg);
|
||||
--color-warning-900: oklch(57.91% 0.13 57.97deg);
|
||||
--color-warning-950: oklch(51.69% 0.13 51.44deg);
|
||||
--color-warning-contrast-dark: var(--color-warning-950);
|
||||
--color-warning-contrast-light: var(--color-warning-50);
|
||||
--color-warning-contrast-50: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-100: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-200: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-300: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-400: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-500: var(--color-warning-contrast-dark);
|
||||
--color-warning-contrast-600: var(--color-warning-contrast-light);
|
||||
--color-warning-contrast-700: var(--color-warning-contrast-light);
|
||||
--color-warning-contrast-800: var(--color-warning-contrast-light);
|
||||
--color-warning-contrast-900: var(--color-warning-contrast-light);
|
||||
--color-warning-contrast-950: var(--color-warning-contrast-light);
|
||||
--color-error-50: oklch(84.29% 0.09 46.91deg);
|
||||
--color-error-100: oklch(78.63% 0.12 39.19deg);
|
||||
--color-error-200: oklch(72.92% 0.14 34.35deg);
|
||||
--color-error-300: oklch(67.88% 0.17 31.48deg);
|
||||
--color-error-400: oklch(63.09% 0.19 30.02deg);
|
||||
--color-error-500: oklch(59.32% 0.21 29.47deg);
|
||||
--color-error-600: oklch(53.56% 0.19 29.25deg);
|
||||
--color-error-700: oklch(47.75% 0.17 29.2deg);
|
||||
--color-error-800: oklch(41.51% 0.15 28.7deg);
|
||||
--color-error-900: oklch(35.35% 0.14 28.7deg);
|
||||
--color-error-950: oklch(28.69% 0.12 29.23deg);
|
||||
--color-error-contrast-dark: var(--color-error-950);
|
||||
--color-error-contrast-light: var(--color-error-50);
|
||||
--color-error-contrast-50: var(--color-error-contrast-dark);
|
||||
--color-error-contrast-100: var(--color-error-contrast-dark);
|
||||
--color-error-contrast-200: var(--color-error-contrast-dark);
|
||||
--color-error-contrast-300: var(--color-error-contrast-dark);
|
||||
--color-error-contrast-400: var(--color-error-contrast-dark);
|
||||
--color-error-contrast-500: var(--color-error-contrast-light);
|
||||
--color-error-contrast-600: var(--color-error-contrast-light);
|
||||
--color-error-contrast-700: var(--color-error-contrast-light);
|
||||
--color-error-contrast-800: var(--color-error-contrast-light);
|
||||
--color-error-contrast-900: var(--color-error-contrast-light);
|
||||
--color-error-contrast-950: var(--color-error-contrast-light);
|
||||
--color-surface-50: oklch(100% 0 none);
|
||||
--color-surface-100: oklch(97.02% 0 none);
|
||||
--color-surface-200: oklch(94.01% 0 none);
|
||||
--color-surface-300: oklch(91.12% 0 196.34deg);
|
||||
--color-surface-400: oklch(88.07% 0 196.37deg);
|
||||
--color-surface-500: oklch(84.99% 0 196.4deg);
|
||||
--color-surface-600: oklch(77.78% 0 196.47deg);
|
||||
--color-surface-700: oklch(70.09% 0 196.54deg);
|
||||
--color-surface-800: oklch(62.51% 0 196.61deg);
|
||||
--color-surface-900: oklch(54.34% 0 196.68deg);
|
||||
--color-surface-950: oklch(46.22% 0 196.73deg);
|
||||
--color-surface-contrast-dark: var(--color-surface-950);
|
||||
--color-surface-contrast-light: var(--color-surface-50);
|
||||
--color-surface-contrast-50: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-100: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-200: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-300: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-400: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-500: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-600: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-700: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-800: var(--color-surface-contrast-dark);
|
||||
--color-surface-contrast-900: var(--color-surface-contrast-light);
|
||||
--color-surface-contrast-950: var(--color-surface-contrast-light);
|
||||
}
|
||||
964
src/app.css
964
src/app.css
@@ -1,964 +0,0 @@
|
||||
@import 'tailwindcss';
|
||||
|
||||
@import "@skeletonlabs/skeleton";
|
||||
@import "@skeletonlabs/skeleton/optional/presets";
|
||||
|
||||
/* Register Preset Themes */
|
||||
/* @import '@skeletonlabs/skeleton/themes/{theme-name}'; */
|
||||
@import '@skeletonlabs/skeleton/themes/cerberus';
|
||||
@import '@skeletonlabs/skeleton/themes/concord';
|
||||
@import '@skeletonlabs/skeleton/themes/crimson';
|
||||
@import '@skeletonlabs/skeleton/themes/hamlindigo';
|
||||
@import '@skeletonlabs/skeleton/themes/modern';
|
||||
@import '@skeletonlabs/skeleton/themes/nouveau';
|
||||
@import '@skeletonlabs/skeleton/themes/rocket';
|
||||
@import '@skeletonlabs/skeleton/themes/terminus';
|
||||
@import '@skeletonlabs/skeleton/themes/vintage';
|
||||
@import '@skeletonlabs/skeleton/themes/wintry';
|
||||
/* @import '@skeletonlabs/skeleton/themes/ae_c_osit'; */
|
||||
/* @import '@skeletonlabs/skeleton/themes/ae_c_lci'; */
|
||||
@import './ae-osit-default.css';
|
||||
@import './ae-c-lci.css';
|
||||
@import './ae-c-idaa-light.css';
|
||||
|
||||
@source '../node_modules/@skeletonlabs/skeleton-svelte/dist';
|
||||
|
||||
|
||||
/* Add your theme import for your theme: "osit-custom-theme" here */
|
||||
/* @plugin '@tailwindcss/forms'; */
|
||||
/* @plugin '@tailwindcss/typography'; */
|
||||
|
||||
|
||||
/* @import "tailwindcss/theme.css" layer(theme); */
|
||||
/* @import "tailwindcss/preflight"; */
|
||||
@import "tailwindcss/utilities.css" layer(utilities);
|
||||
/*@tailwind utilities;*/
|
||||
|
||||
|
||||
/* Register a Custom Themes */
|
||||
/* Make sure to resolve the relative path. */
|
||||
/* Note the .css extension is optional. */
|
||||
/* @import '../{my-theme-name}'; */
|
||||
|
||||
/* @import '@fontsource/open-sans'; */
|
||||
|
||||
/* https://www.skeleton.dev/docs/guides/cookbook/light-switch */
|
||||
/* @custom-variant dark (&:where([data-mode="dark"], [data-mode="dark"] *)); */
|
||||
|
||||
|
||||
@layer base {
|
||||
:root {
|
||||
--background: 0 0% 100%;
|
||||
--foreground: 224 71.4% 4.1%;
|
||||
--muted: 220 14.3% 95.9%;
|
||||
--muted-foreground: 220 8.9% 46.1%;
|
||||
--popover: 0 0% 100%;
|
||||
--popover-foreground: 224 71.4% 4.1%;
|
||||
--card: 0 0% 100%;
|
||||
--card-foreground: 224 71.4% 4.1%;
|
||||
--border: 220 13% 91%;
|
||||
--input: 220 13% 91%;
|
||||
--primary: 220.9 39.3% 11%;
|
||||
--primary-foreground: 210 20% 98%;
|
||||
--secondary: 220 14.3% 95.9%;
|
||||
--secondary-foreground: 220.9 39.3% 11%;
|
||||
--accent: 220 14.3% 95.9%;
|
||||
--accent-foreground: 220.9 39.3% 11%;
|
||||
--destructive: 0 72.2% 50.6%;
|
||||
--destructive-foreground: 210 20% 98%;
|
||||
--ring: 224 71.4% 4.1%;
|
||||
--radius: 0.5rem;
|
||||
--sidebar-background: 0 0% 98%;
|
||||
--sidebar-foreground: 240 5.3% 26.1%;
|
||||
--sidebar-primary: 240 5.9% 10%;
|
||||
--sidebar-primary-foreground: 0 0% 98%;
|
||||
--sidebar-accent: 240 4.8% 95.9%;
|
||||
--sidebar-accent-foreground: 240 5.9% 10%;
|
||||
--sidebar-border: 220 13% 91%;
|
||||
--sidebar-ring: 217.2 91.2% 59.8%;
|
||||
}
|
||||
|
||||
/* .dark {
|
||||
--background: 224 71.4% 4.1%;
|
||||
--foreground: 210 20% 98%;
|
||||
--muted: 215 27.9% 16.9%;
|
||||
--muted-foreground: 217.9 10.6% 64.9%;
|
||||
--popover: 224 71.4% 4.1%;
|
||||
--popover-foreground: 210 20% 98%;
|
||||
--card: 224 71.4% 4.1%;
|
||||
--card-foreground: 210 20% 98%;
|
||||
--border: 215 27.9% 16.9%;
|
||||
--input: 215 27.9% 16.9%;
|
||||
--primary: 210 20% 98%;
|
||||
--primary-foreground: 220.9 39.3% 11%;
|
||||
--secondary: 215 27.9% 16.9%;
|
||||
--secondary-foreground: 210 20% 98%;
|
||||
--accent: 215 27.9% 16.9%;
|
||||
--accent-foreground: 210 20% 98%;
|
||||
--destructive: 0 62.8% 30.6%;
|
||||
--destructive-foreground: 210 20% 98%;
|
||||
--ring: 216 12.2% 83.9%;
|
||||
--sidebar-background: 240 5.9% 10%;
|
||||
--sidebar-foreground: 240 4.8% 95.9%;
|
||||
--sidebar-primary: 224.3 76.3% 48%;
|
||||
--sidebar-primary-foreground: 0 0% 100%;
|
||||
--sidebar-accent: 240 3.7% 15.9%;
|
||||
--sidebar-accent-foreground: 240 4.8% 95.9%;
|
||||
--sidebar-border: 240 3.7% 15.9%;
|
||||
--sidebar-ring: 217.2 91.2% 59.8%;
|
||||
} */
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* {
|
||||
border-color: hsl(var(--border));
|
||||
}
|
||||
body {
|
||||
background-color: hsl(var(--background));
|
||||
color: hsl(var(--foreground));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* There are no more Tailwind layers. */
|
||||
|
||||
html,
|
||||
body {
|
||||
@apply h-full overflow-hidden;
|
||||
|
||||
/* font-family: 'Liberation Sans', sans-serif; */
|
||||
/* font-family: 'Noto Sans', sans-serif; */
|
||||
}
|
||||
|
||||
html.super_access #appShell {
|
||||
background-color: hsla(0, 100%, 50%, 0.5);
|
||||
}
|
||||
|
||||
html.manager_access #appShell {
|
||||
background-color: hsla(0, 50%, 75%, 0.5);
|
||||
}
|
||||
html.administrator_access #appShell {
|
||||
background-color: hsla(40, 50%, 85%, 0.25);
|
||||
}
|
||||
html.trusted_access #appShell {
|
||||
background-color: hsla(20, 50%, 85%, 0.25);
|
||||
}
|
||||
|
||||
/* default theme */
|
||||
/* @font-face {
|
||||
font-family: 'Liberation Sans', sans-serif;
|
||||
font-family: 'Noto Sans', sans-serif;
|
||||
src: url('/fonts/liberation/LiberationSans-Regular.ttf');
|
||||
src: url('/fonts/noto/NotoSans-Regular.ttf');
|
||||
font-display: swap;
|
||||
} */
|
||||
|
||||
/* modern theme */
|
||||
@font-face {
|
||||
font-family: 'Quicksand';
|
||||
src: url('/fonts/Quicksand.ttf');
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
/* :root [data-theme='modern'] { */
|
||||
/* --theme-rounded-base: 20px;
|
||||
--theme-rounded-container: 4px; */
|
||||
|
||||
/* --theme-font-family-base: 'Liberation Sans', sans-serif; */
|
||||
/* --theme-font-family-heading: 'Liberation Sans', sans-serif; */
|
||||
/* } */
|
||||
|
||||
/* Using Skeleton Tailwind Presets */
|
||||
/* Built in colors (also with "contrast" option):
|
||||
* - primary
|
||||
* - secondary
|
||||
* - tertiary
|
||||
* - success
|
||||
* - warning
|
||||
* - error
|
||||
* - surface
|
||||
*/
|
||||
|
||||
/* Built in presets:
|
||||
* - Filled - a filled preset of the primary brand color.
|
||||
* - Tonal - a tonal preset of the primary brand color.
|
||||
* - Outlined - an outlined preset of the primary brand color.
|
||||
*/
|
||||
|
||||
/* Additional customized presets:
|
||||
* - Glass - a custom preset using background transparency and backdrop blur.
|
||||
* - Elevated - mixes a filled preset with a shadow.
|
||||
* - Ghost - has no style by default, but shows a tonal preset on hover.
|
||||
* - Ghost Icon - has no style by default, but shows a branded tonal preset on hover.
|
||||
* - Gradient - a custom preset generated using Tailwind gradient primitives.
|
||||
*/
|
||||
|
||||
/* Generic button types needed:
|
||||
* - primary
|
||||
* - secondary
|
||||
* - tertiary
|
||||
* - success
|
||||
* - warning
|
||||
* - error
|
||||
* - neutral
|
||||
* - surface
|
||||
* - info
|
||||
* - danger
|
||||
* - normal
|
||||
* - outline
|
||||
* - text
|
||||
*/
|
||||
|
||||
/* Aether specific button types needed:
|
||||
* - open or view
|
||||
* - close or hide
|
||||
* - help
|
||||
* - save
|
||||
* - delete
|
||||
* - cancel
|
||||
* - confirm
|
||||
* - reset
|
||||
* - submit
|
||||
* - next or previous
|
||||
* - back
|
||||
* - edit
|
||||
* - create
|
||||
* - add
|
||||
* - remove
|
||||
* - copy
|
||||
* - paste
|
||||
* - download
|
||||
* - upload
|
||||
* - print
|
||||
* - share
|
||||
* - search
|
||||
* - filter
|
||||
* - sort
|
||||
* - select
|
||||
* - clear
|
||||
* - toggle or switch
|
||||
* - expand or collapse
|
||||
* - configure or settings
|
||||
* - refresh or reload
|
||||
* - sync or synchronize
|
||||
* - play or pause
|
||||
* - stop
|
||||
* - like or dislike
|
||||
* - favorite or unfavorite
|
||||
* - follow or unfollow
|
||||
* - subscribe or unsubscribe
|
||||
* - vote or unvote
|
||||
* - rate or review
|
||||
* - report or flag
|
||||
* - block or unblock
|
||||
* - accept or decline
|
||||
* - agree or disagree
|
||||
* - confirm or cancel
|
||||
* - approve or reject
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* Create a custom preset in your global stylesheet */
|
||||
/* .preset-gradient {
|
||||
background-image: linear-gradient(-45deg, var(--color-primary-300), var(--color-primary-700));
|
||||
color: var(--color-primary-contrast-500);
|
||||
} */
|
||||
/* .preset-glass-primary {
|
||||
background: color-mix(in oklab, var(--color-primary-500) 40%, transparent);
|
||||
box-shadow: 0 0px 30px color-mix(in oklab, var(--color-primary-500) 50%, transparent) inset;
|
||||
backdrop-filter: blur(16px);
|
||||
} */
|
||||
|
||||
/*
|
||||
* - tonal buttons - use these for most buttons
|
||||
* - filled buttons - use these for buttons that need to stand out
|
||||
* - outlined buttons - use these for buttons that need to be less prominent (sort of like TW v3 ghost)
|
||||
*/
|
||||
|
||||
/* Buttons default to the tonal presets */
|
||||
/* Buttons based on Skeleton Tailwind preset classes */
|
||||
.ae_btn_neutral {
|
||||
@apply preset-tonal hover:preset-outlined border transition-all;
|
||||
}
|
||||
.ae_btn_primary {
|
||||
@apply preset-tonal-primary border border-primary-500 transition-all;
|
||||
}
|
||||
.ae_btn_secondary {
|
||||
@apply preset-tonal-secondary border border-secondary-500 transition-all;
|
||||
/* hover:preset-filled-secondary-500 */
|
||||
}
|
||||
.ae_btn_tertiary {
|
||||
@apply preset-tonal-tertiary border border-tertiary-500 transition-all;
|
||||
}
|
||||
.ae_btn_success {
|
||||
@apply preset-tonal-success border border-success-500 transition-all;
|
||||
}
|
||||
.ae_btn_warning {
|
||||
@apply preset-tonal-warning border border-warning-500 text-warning-950-50 transition-all;
|
||||
}
|
||||
.ae_btn_error {
|
||||
@apply preset-tonal-error border border-error-500 transition-all;
|
||||
}
|
||||
.ae_btn_surface {
|
||||
@apply preset-tonal-surface border border-surface-500 transition-all;
|
||||
}
|
||||
/* Buttons customized for Aether using Skeleton Tailwind preset classes */
|
||||
.ae_btn_info {
|
||||
@apply border text-cyan-950 dark:text-cyan-50 bg-cyan-50 dark:bg-cyan-950 border-cyan-100 dark:border-cyan-900 hover:bg-cyan-200 hover:dark:bg-cyan-800 transition-all;
|
||||
}
|
||||
|
||||
/* Buttons are for filled and outlined presets */
|
||||
.ae_btn_secondary_filled {
|
||||
@apply preset-filled-secondary-200-800 border border-secondary-500 transition-all;
|
||||
/* hover:preset-filled-secondary-500 */
|
||||
}
|
||||
.ae_btn_secondary_outlined {
|
||||
@apply preset-outlined-secondary-200-800 hover:preset-filled-secondary-400-600 text-secondary-950-50 transition-all;
|
||||
}
|
||||
.ae_btn_success_filled {
|
||||
@apply preset-filled-success-200-800 border border-success-500 transition-all;
|
||||
}
|
||||
.ae_btn_success_outlined {
|
||||
@apply preset-outlined-success-200-800 hover:preset-filled-success-400-600 text-success-950-50 transition-all;
|
||||
}
|
||||
.ae_btn_warning_filled {
|
||||
@apply preset-filled-warning-200-800 border border-warning-500 transition-all;
|
||||
}
|
||||
.ae_btn_warning_outlined {
|
||||
@apply preset-outlined-warning-200-800 hover:preset-filled-warning-400-600 text-warning-950-50 transition-all;
|
||||
}
|
||||
.ae_btn_surface_filled {
|
||||
@apply preset-filled-surface-200-800 border border-surface-500 transition-all;
|
||||
}
|
||||
.ae_btn_surface_outlined {
|
||||
@apply preset-outlined-surface-200-800 hover:preset-filled-surface-400-600 text-surface-950-50 transition-all;
|
||||
}
|
||||
.ae_btn_error_outlined {
|
||||
@apply preset-outlined-error-200-800 hover:preset-filled-error-400-600 text-error-950-50 transition-all;
|
||||
}
|
||||
.ae_btn_info_filled {
|
||||
@apply border text-cyan-950 dark:text-cyan-50 bg-cyan-200 dark:bg-cyan-800 border-cyan-200 dark:border-cyan-800 transition-all;
|
||||
}
|
||||
.ae_btn_info_outlined {
|
||||
@apply border text-cyan-950 dark:text-cyan-50 bg-cyan-50 dark:bg-cyan-950 border-cyan-200 dark:border-cyan-800 transition-all;
|
||||
}
|
||||
|
||||
|
||||
/* Containers customized for Aether using Skeleton Tailwind preset classes */
|
||||
.ae_container_system_menu {
|
||||
@apply container;
|
||||
}
|
||||
.ae_container_system_options {
|
||||
@apply container;
|
||||
}
|
||||
.ae_container_system_help {
|
||||
@apply container;
|
||||
}
|
||||
|
||||
.ae_container_module {
|
||||
@apply container;
|
||||
/* @apply container mx-auto max-w-7xl px-4 sm:px-6 lg:px-8; */
|
||||
}
|
||||
/* .ae_container_module_main {
|
||||
@apply container;
|
||||
} */
|
||||
.ae_module_header {
|
||||
/* LCI request 3a5997 */
|
||||
/* bg-gray-300 */
|
||||
@apply preset-tonal-surface rounded-md flex flex-row gap-0.25 items-center justify-between w-full p-1 px-2;
|
||||
}
|
||||
|
||||
[data-theme='AE_c_LCI'] .ae_module_header {
|
||||
/* LCI request 3a5997 */
|
||||
/* bg-gray-300 */
|
||||
@apply preset-tonal-primary;
|
||||
}
|
||||
[data-theme='AE_c_LCI'] .ae_obj__event_presenter {
|
||||
@apply preset-filled-success-500;
|
||||
/* --color-success-500; */
|
||||
}
|
||||
|
||||
.ae_container_module_content {
|
||||
@apply container;
|
||||
}
|
||||
.ae_container_module_menu {
|
||||
@apply w-full flex flex-col items-center justify-center gap-1 p-1
|
||||
border rounded-md border-gray-200 dark:border-gray-800 hover:bg-gray-100 dark:hover:bg-gray-900 transition-all duration-700 hover:duration-300;
|
||||
}
|
||||
.ae_container_module_options {
|
||||
@apply
|
||||
text-cyan-950 dark:text-cyan-50
|
||||
bg-cyan-50 dark:bg-cyan-950 hover:bg-cyan-100 dark:hover:bg-cyan-900
|
||||
border border-cyan-200 dark:border-cyan-800 hover:border-cyan-400 dark:hover:border-cyan-600
|
||||
rounded-md
|
||||
flex flex-row flex-wrap items-center justify-around
|
||||
w-full max-w-full
|
||||
p-2
|
||||
transition-all;
|
||||
}
|
||||
.ae_container_module_help {
|
||||
@apply
|
||||
text-yellow-950 dark:text-yellow-50
|
||||
bg-yellow-50 dark:bg-yellow-950 hover:bg-yellow-100 dark:hover:bg-yellow-900
|
||||
border border-yellow-200 dark:border-yellow-800 hover:border-yellow-400 dark:hover:border-yellow-600
|
||||
rounded-md
|
||||
w-lg max-w-full
|
||||
p-2
|
||||
transition-all;
|
||||
/* bg-yellow-100 border border-yellow-400 p-2 rounded-md max-w-xl */
|
||||
}
|
||||
|
||||
.ae_container_actions {
|
||||
@apply container preset-tonal-success border border-success-500 rounded-md flex flex-row items-center my-2 p-2;
|
||||
}
|
||||
.ae_container_results {
|
||||
@apply container;
|
||||
}
|
||||
.ae_container_content {
|
||||
@apply container;
|
||||
}
|
||||
.ae_container_content_header {
|
||||
@apply container;
|
||||
}
|
||||
.ae_container_content_content {
|
||||
@apply container;
|
||||
}
|
||||
.ae_container_content_footer {
|
||||
@apply container;
|
||||
}
|
||||
|
||||
.ae_container_alert {
|
||||
@apply container;
|
||||
}
|
||||
.ae_container_help {
|
||||
@apply
|
||||
text-yellow-950 dark:text-yellow-50
|
||||
bg-yellow-50 dark:bg-yellow-950 hover:bg-yellow-100 dark:hover:bg-yellow-900
|
||||
border border-yellow-200 dark:border-yellow-800 hover:border-yellow-400 dark:hover:border-yellow-600
|
||||
rounded-md
|
||||
max-w-full
|
||||
p-2
|
||||
transition-all;
|
||||
/* bg-yellow-100 border border-yellow-400 p-2 rounded-md max-w-xl */
|
||||
}
|
||||
.ae_container_info {
|
||||
@apply
|
||||
text-cyan-950 dark:text-cyan-50
|
||||
bg-cyan-50 dark:bg-cyan-950 hover:bg-cyan-100 dark:hover:bg-cyan-900
|
||||
border border-cyan-200 dark:border-cyan-800 hover:border-cyan-400 dark:hover:border-cyan-600
|
||||
rounded-md
|
||||
max-w-full
|
||||
p-2
|
||||
transition-all;
|
||||
}
|
||||
.ae_container_msg {
|
||||
@apply container;
|
||||
}
|
||||
.ae_container_warning {
|
||||
@apply container;
|
||||
}
|
||||
.ae_container_tag {
|
||||
@apply container;
|
||||
}
|
||||
|
||||
.ae_container_modal {
|
||||
@apply container mx-auto max-w-7xl px-4 sm:px-6 lg:px-8;
|
||||
}
|
||||
.ae_container_modal_header {
|
||||
@apply container;
|
||||
}
|
||||
.ae_container_modal_content {
|
||||
@apply container;
|
||||
}
|
||||
.ae_container_modal_footer {
|
||||
@apply container;
|
||||
}
|
||||
|
||||
|
||||
/* Standard Aether object properties:
|
||||
* - id
|
||||
* - name
|
||||
* - enable
|
||||
* - hide
|
||||
* - priority
|
||||
* - sort
|
||||
* - group
|
||||
* - notes
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
.card-footer {
|
||||
border-top: 1px solid hsla(0, 0%, 0%, 0.5);
|
||||
margin-top: 1em;
|
||||
padding-top: 1em;
|
||||
|
||||
opacity: .5;
|
||||
}
|
||||
|
||||
|
||||
/* Tailwind: This "fixes" Tailwind's default group button styles that do not seem to allow hiding buttons. */
|
||||
.btn-group a.hidden, .btn-group button.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
.ae_d_none {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
/* Allow content to scroll horizontal if too wide */
|
||||
.ae_h_scrollfix {
|
||||
max-width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
/* These helps with the Skeleton Tailwind modal utility. */
|
||||
.ae_modal_scrollfix {
|
||||
/* Allow modal content to scroll if it's too long */
|
||||
overflow-y: auto;
|
||||
max-height: 96vh;
|
||||
/* max-height: 99%; */
|
||||
|
||||
}
|
||||
|
||||
.ae_debug {
|
||||
/* A darker pink outline */
|
||||
outline: thin dashed;
|
||||
outline-color: hsla(0, 100%, 50%, 0.15);
|
||||
/* A light pink background color */
|
||||
background-color: hsla(0, 100%, 50%, 0.15);
|
||||
}
|
||||
.ae_debug:hover {
|
||||
/* A darker pink outline */
|
||||
outline-color: hsla(0, 100%, 50%, 0.50);
|
||||
/* A light pink background color */
|
||||
background-color: hsla(0, 100%, 50%, 0.40);
|
||||
}
|
||||
|
||||
|
||||
/* Deal with being in an iframe */
|
||||
#appShell #shell-header.iframe {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#appShell #shell-footer.iframe {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.iframe .module_header, .iframe .module_footer{
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Remove the background from the body in all cases */
|
||||
/* body[data-theme] { */
|
||||
/* background: none; */
|
||||
/* background-image: none; */
|
||||
/* } */
|
||||
|
||||
/* Remove the background from the body if using iframes */
|
||||
/* body[data-theme]:has(#page.iframe) { */
|
||||
/* background: none; */
|
||||
/* background-image: none; */
|
||||
/* background-image: url('https://static.oneskyit.com/c/CHOW/images/CHOW_2024_yellow_background.png'); */
|
||||
/* background-size: cover; */
|
||||
/* } */
|
||||
|
||||
main {
|
||||
/* background: none;
|
||||
background-color: hsla(0, 0%, 100%, 0.92); */
|
||||
}
|
||||
|
||||
main>section {
|
||||
background: none;
|
||||
background-color: hsla(0, 0%, 100%, 0.92);
|
||||
padding: .5em;
|
||||
}
|
||||
|
||||
/* @media (min-width: 640px) {
|
||||
main>div, main>section {
|
||||
padding: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
} */
|
||||
|
||||
/* @media (min-width: 768px) {
|
||||
main>div, main>section {
|
||||
padding: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
} */
|
||||
|
||||
.ae_sponsorships {
|
||||
/* background: none; */
|
||||
/* background-color: hsla(0, 0%, 100%, 0.92); */
|
||||
/* background-image: url('https://static.oneskyit.com/c/CHOW/images/CHOW_2024_yellow_background.png'); */
|
||||
/* background-size: cover; */
|
||||
}
|
||||
|
||||
pre.pre_wrap {
|
||||
white-space: pre-wrap;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
|
||||
border: none;
|
||||
|
||||
max-width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
|
||||
input.required {
|
||||
/* border-right: solid medium var(--color-warning-500); */
|
||||
/* color: var(--color-warning-500); */
|
||||
}
|
||||
|
||||
input:required {
|
||||
/* background-color: var(--alert-color-lightest); */
|
||||
/* border: solid 2px red; */
|
||||
/* outline: dashed thin var(--alert-color-lighter); */
|
||||
|
||||
/* border-right: solid medium var(--alert-color-mid); */
|
||||
/* border-right: solid medium var(--warning-color-mid); */
|
||||
/* border-right: solid medium var(--error-color-mid); */
|
||||
}
|
||||
/* input:required:hover {
|
||||
background-color: var(--alert-color-lighter);
|
||||
border-right: solid thick var(--alert-color-darker);
|
||||
} */
|
||||
|
||||
/* input:required::before {
|
||||
display: block;
|
||||
|
||||
content: '*';
|
||||
color: var(--warning-color-darker);
|
||||
|
||||
top: 5px;
|
||||
left: 5px;
|
||||
} */
|
||||
|
||||
.input_required::after {
|
||||
content: '*';
|
||||
color: rgb(var(--color-error-500) / 0.9);
|
||||
|
||||
position: relative;
|
||||
/* top: 0em; */
|
||||
left: .25em;
|
||||
}
|
||||
|
||||
/* Make the group a flex row by default */
|
||||
/* div.btn-group { */
|
||||
/* display: flex; */
|
||||
/* gap: 0; */
|
||||
/* flex-direction: row; */
|
||||
/* justify-content: space-around; */
|
||||
/* align-items: center; */
|
||||
/* margin: 0;
|
||||
padding: 0; */
|
||||
|
||||
/* } */
|
||||
/* Make all button elements except for the the first button element not rounded on the left. */
|
||||
/* Make all button elements except for the fhe last button element not rounded on the right. */
|
||||
/* These helps with the Skeleton (Tailwind?) button group element. */
|
||||
.btn-group button {
|
||||
border-radius: 0;
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* .md:btn-group button,
|
||||
.lg:btn-group button {
|
||||
border-radius: 0;
|
||||
border: none;
|
||||
} */
|
||||
|
||||
/* div.btn-group button:first-child {
|
||||
border-top-left-radius: .25rem;
|
||||
border-bottom-left-radius: .25rem;
|
||||
}
|
||||
div.btn-group button:last-child {
|
||||
border-top-right-radius: .25rem;
|
||||
border-bottom-right-radius: .25rem;
|
||||
} */
|
||||
|
||||
.ae_obj_prop .label {
|
||||
|
||||
}
|
||||
|
||||
.ae_obj_prop .value {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
.ae_md_hide {
|
||||
/* outline: medium dashed green; */
|
||||
/* display: none; */
|
||||
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.ae_md_hide {
|
||||
/* outline: medium dashed red; */
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@media (min-width: 768px) {
|
||||
.ae_lg_hide {
|
||||
/* outline: medium dashed blue; */
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Use the div.ae_quick_modal_container to block background clicks when using the section.ae_quick_popover. */
|
||||
div.ae_quick_modal_container {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 100;
|
||||
background-color: hsla(0, 0%, 0%, .5);
|
||||
}
|
||||
|
||||
/* The section.ae_quick_popover should be above the rest of the content and centered on the page. */
|
||||
section.ae_quick_popover {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 100;
|
||||
background-color: hsla(0, 0%, 100%, .95);
|
||||
padding: 1rem;
|
||||
border-radius: .5rem;
|
||||
box-shadow: 0 0 1rem hsla(0, 0%, 0%, .5);
|
||||
|
||||
min-height: 98%;
|
||||
min-width: 98%;
|
||||
}
|
||||
|
||||
section.ae_quick_popover_small {
|
||||
position: fixed;
|
||||
top: 1em;
|
||||
left: 50%;
|
||||
transform: translate(-50%, 0%);
|
||||
z-index: 100;
|
||||
background-color: hsla(0, 0%, 100%, .95);
|
||||
padding: 1rem;
|
||||
border-radius: .5rem;
|
||||
box-shadow: 0 0 1rem hsla(0, 0%, 0%, .5);
|
||||
|
||||
min-height: 24rem;
|
||||
max-height: 95%;
|
||||
min-width: 50%;
|
||||
max-width: 95%;
|
||||
}
|
||||
|
||||
|
||||
.fade_50 {
|
||||
opacity: 0.5;
|
||||
}
|
||||
.fade_50:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
|
||||
.auth_view_only {
|
||||
display: none;
|
||||
}
|
||||
.ae_root--auth_access .auth_view_only {
|
||||
display: initial;
|
||||
}
|
||||
|
||||
|
||||
|
||||
img.qr_code {
|
||||
/* outline: solid thin hsla(30, 100%, 50%, .1); */
|
||||
/* width: 1.50in; */
|
||||
}
|
||||
|
||||
img.qr_code:hover {
|
||||
/* outline: solid thin green; */
|
||||
/* width: 2.50in; */
|
||||
}
|
||||
|
||||
img.qr_code:focus {
|
||||
/* outline: solid thin red; */
|
||||
/* width: 2.50in; */
|
||||
}
|
||||
|
||||
|
||||
.dim {
|
||||
opacity: 0.5;
|
||||
color: hsla(0, 0%, 50%, .95);
|
||||
}
|
||||
.dim_warning {
|
||||
opacity: 0.5;
|
||||
/* color: hsla(0, 100%, 50%, .95); */
|
||||
/* background should be hash marks */
|
||||
background-image: repeating-linear-gradient(-45deg, hsla(0, 100%, 50%, .25), hsla(0, 100%, 50%, .25) 10px, transparent 10px, transparent 20px);
|
||||
}
|
||||
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.sk_header.hide_sm {
|
||||
display: none;
|
||||
}
|
||||
.sk_header.show_sm {
|
||||
display: initial;
|
||||
}
|
||||
.sk_header.show_md {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.sk_header.hide_md {
|
||||
display: none;
|
||||
}
|
||||
.sk_header.show_md {
|
||||
display: initial;
|
||||
}
|
||||
.sk_header.show_sm {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* We need to reset many of the styles for the reset_css class. */
|
||||
.reset_css p {
|
||||
margin: .75em 0;
|
||||
}
|
||||
.reset_css ol {
|
||||
list-style-type: decimal;
|
||||
}
|
||||
.reset_css ul {
|
||||
list-style-type: disc;
|
||||
}
|
||||
.reset_css li {
|
||||
margin-left: 1.5em;
|
||||
}
|
||||
/* Reset anchor tags to the default color and underline. */
|
||||
.reset_css a {
|
||||
color: hsla(210, 100%, 50%, 1);
|
||||
text-decoration: underline;
|
||||
}
|
||||
.reset_css a:hover {
|
||||
color: hsla(210, 100%, 50%, .75);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
||||
/* .ae_btn.btn-danger,
|
||||
.ae_btn.btn-info,
|
||||
.ae_btn.btn-warning {
|
||||
border-radius: 60px;
|
||||
} */
|
||||
|
||||
/* .ae_margin_xs {
|
||||
margin: 0.25em;
|
||||
}
|
||||
.ae_margin_sm {
|
||||
margin: 0.5em;
|
||||
}
|
||||
.ae_margin_md {
|
||||
margin: 0.75em;
|
||||
}
|
||||
.ae_margin_lg {
|
||||
margin: 1em;
|
||||
}
|
||||
.ae_margin_lg {
|
||||
margin: 1.25em;
|
||||
} */
|
||||
|
||||
/* BEGIN: Overrides and fixes specific to Novi and IDAA */
|
||||
.iframe .novi_btn {
|
||||
border-radius: 60px;
|
||||
/* border-color: hsla(0, 0%, 50%, .5); */
|
||||
/* border-color: hsla(0, 0%, 0%, .15); */
|
||||
|
||||
|
||||
}
|
||||
|
||||
.iframe .dark .novi_label {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.iframe .dark .novi_black {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.iframe .dark .novi_white {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.iframe .dark .novi_bg_black {
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
.iframe .dark .novi_bg_white {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.iframe .dark .novi_bg_gray {
|
||||
background-color: hsla(0, 0%, 50%, 1);
|
||||
}
|
||||
|
||||
.iframe .dark .novi_bg_light_gray {
|
||||
background-color: hsla(0, 0%, 95%, 1);
|
||||
}
|
||||
.iframe .dark .novi_bg_dark_gray {
|
||||
background-color: hsla(0, 0%, 20%, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
.iframe .novi_bg_light {
|
||||
background-color: hsla(0, 0%, 0%, .15);
|
||||
color: hsla(0, 0%, 20%, 1);
|
||||
}
|
||||
.iframe .novi_bg_dark {
|
||||
background-color: hsla(0, 0%, 0%, .25);
|
||||
color: hsla(0, 0%, 95%, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
.iframe .novi_margin_sm {
|
||||
/* margin: 0.5em; */
|
||||
}
|
||||
|
||||
.iframe .novi_text_wrap {
|
||||
/* white-space: normal; */
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
/* END: Overrides and fixes specific to Novi and IDAA */
|
||||
|
||||
.iframe button.ae_normal,
|
||||
.iframe .btn.ae_normal {
|
||||
/* font: normal 1em sans-serif; */
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.iframe button.ae_smaller,
|
||||
.iframe .btn.ae_smaller,
|
||||
.iframe button.novi_smaller,
|
||||
.iframe .btn.novi_smaller
|
||||
{
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.iframe button.ae_smallest,
|
||||
.iframe .btn.ae_smallest,
|
||||
.iframe button.novi_smallest,
|
||||
.iframe .btn.novi_smallest
|
||||
{
|
||||
font-size: 0.65rem;
|
||||
}
|
||||
17
src/app.html
17
src/app.html
@@ -1,12 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="light" data-theme="">
|
||||
<html lang="en" class="light">
|
||||
<head>
|
||||
<meta charset="utf-8" >
|
||||
<meta charset="utf-8" />
|
||||
|
||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" >
|
||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||
<link rel="manifest" href="%sveltekit.assets%/manifest.json">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" >
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
@@ -14,14 +14,11 @@
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Serif:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet">
|
||||
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossorigin="anonymous" referrerpolicy="no-referrer" >
|
||||
|
||||
<!-- <link href="app.css" rel="stylesheet"> -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover" class="h-full w-full overflow-auto">
|
||||
|
||||
<div style="display: contents" class="">%sveltekit.body%</div>
|
||||
<body data-sveltekit-preload-data="hover" data-theme="my-custom-theme">
|
||||
<div style="display: contents" class="h-full w-full overflow-hidden">%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,82 +1,7 @@
|
||||
@import "tailwindcss/preflight";
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
@layer base {
|
||||
:root {
|
||||
--background: 0 0% 100%;
|
||||
--foreground: 224 71.4% 4.1%;
|
||||
--muted: 220 14.3% 95.9%;
|
||||
--muted-foreground: 220 8.9% 46.1%;
|
||||
--popover: 0 0% 100%;
|
||||
--popover-foreground: 224 71.4% 4.1%;
|
||||
--card: 0 0% 100%;
|
||||
--card-foreground: 224 71.4% 4.1%;
|
||||
--border: 220 13% 91%;
|
||||
--input: 220 13% 91%;
|
||||
--primary: 220.9 39.3% 11%;
|
||||
--primary-foreground: 210 20% 98%;
|
||||
--secondary: 220 14.3% 95.9%;
|
||||
--secondary-foreground: 220.9 39.3% 11%;
|
||||
--accent: 220 14.3% 95.9%;
|
||||
--accent-foreground: 220.9 39.3% 11%;
|
||||
--destructive: 0 72.2% 50.6%;
|
||||
--destructive-foreground: 210 20% 98%;
|
||||
--ring: 224 71.4% 4.1%;
|
||||
--radius: 0.5rem;
|
||||
--sidebar-background: 0 0% 98%;
|
||||
--sidebar-foreground: 240 5.3% 26.1%;
|
||||
--sidebar-primary: 240 5.9% 10%;
|
||||
--sidebar-primary-foreground: 0 0% 98%;
|
||||
--sidebar-accent: 240 4.8% 95.9%;
|
||||
--sidebar-accent-foreground: 240 5.9% 10%;
|
||||
--sidebar-border: 220 13% 91%;
|
||||
--sidebar-ring: 217.2 91.2% 59.8%;
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: 224 71.4% 4.1%;
|
||||
--foreground: 210 20% 98%;
|
||||
--muted: 215 27.9% 16.9%;
|
||||
--muted-foreground: 217.9 10.6% 64.9%;
|
||||
--popover: 224 71.4% 4.1%;
|
||||
--popover-foreground: 210 20% 98%;
|
||||
--card: 224 71.4% 4.1%;
|
||||
--card-foreground: 210 20% 98%;
|
||||
--border: 215 27.9% 16.9%;
|
||||
--input: 215 27.9% 16.9%;
|
||||
--primary: 210 20% 98%;
|
||||
--primary-foreground: 220.9 39.3% 11%;
|
||||
--secondary: 215 27.9% 16.9%;
|
||||
--secondary-foreground: 210 20% 98%;
|
||||
--accent: 215 27.9% 16.9%;
|
||||
--accent-foreground: 210 20% 98%;
|
||||
--destructive: 0 62.8% 30.6%;
|
||||
--destructive-foreground: 210 20% 98%;
|
||||
--ring: 216 12.2% 83.9%;
|
||||
--sidebar-background: 240 5.9% 10%;
|
||||
--sidebar-foreground: 240 4.8% 95.9%;
|
||||
--sidebar-primary: 224.3 76.3% 48%;
|
||||
--sidebar-primary-foreground: 0 0% 100%;
|
||||
--sidebar-accent: 240 3.7% 15.9%;
|
||||
--sidebar-accent-foreground: 240 4.8% 95.9%;
|
||||
--sidebar-border: 240 3.7% 15.9%;
|
||||
--sidebar-ring: 217.2 91.2% 59.8%;
|
||||
}
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* {
|
||||
border-color: hsl(var(--border));
|
||||
}
|
||||
body {
|
||||
background-color: hsl(var(--background));
|
||||
color: hsl(var(--foreground));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@tailwind variants;
|
||||
/* There are no more Tailwind layers. */
|
||||
|
||||
html,
|
||||
@@ -87,20 +12,6 @@ body {
|
||||
/* font-family: 'Noto Sans', sans-serif; */
|
||||
}
|
||||
|
||||
html.super_access #appShell {
|
||||
background-color: hsla(0, 100%, 50%, 0.5);
|
||||
}
|
||||
|
||||
html.manager_access #appShell {
|
||||
background-color: hsla(0, 50%, 75%, 0.5);
|
||||
}
|
||||
html.administrator_access #appShell {
|
||||
background-color: hsla(40, 50%, 85%, 0.25);
|
||||
}
|
||||
html.trusted_access #appShell {
|
||||
background-color: hsla(20, 50%, 85%, 0.25);
|
||||
}
|
||||
|
||||
/* default theme */
|
||||
/* @font-face {
|
||||
font-family: 'Liberation Sans', sans-serif;
|
||||
@@ -134,7 +45,7 @@ html.trusted_access #appShell {
|
||||
}
|
||||
|
||||
|
||||
/* Tailwind: This "fixes" Tailwind's default group button styles that do not seem to allow hiding buttons. */
|
||||
/* Tailwind: This "fixes" Tailwind's default group button styles that do not seem to allow hidding buttons. */
|
||||
.btn-group a.hidden, .btn-group button.hidden {
|
||||
display: none;
|
||||
}
|
||||
@@ -458,89 +369,3 @@ img.qr_code:focus {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* We need to reset many of the styles for the reset_css class. */
|
||||
.reset_css p {
|
||||
margin: .75em 0;
|
||||
}
|
||||
.reset_css ol {
|
||||
list-style-type: decimal;
|
||||
}
|
||||
.reset_css ul {
|
||||
list-style-type: disc;
|
||||
}
|
||||
.reset_css li {
|
||||
margin-left: 1.5em;
|
||||
}
|
||||
/* Reset anchor tags to the default color and underline. */
|
||||
.reset_css a {
|
||||
color: hsla(210, 100%, 50%, 1);
|
||||
text-decoration: underline;
|
||||
}
|
||||
.reset_css a:hover {
|
||||
color: hsla(210, 100%, 50%, .75);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
||||
/* .ae_btn.btn-danger,
|
||||
.ae_btn.btn-info,
|
||||
.ae_btn.btn-warning {
|
||||
border-radius: 60px;
|
||||
} */
|
||||
|
||||
/* .ae_margin_xs {
|
||||
margin: 0.25em;
|
||||
}
|
||||
.ae_margin_sm {
|
||||
margin: 0.5em;
|
||||
}
|
||||
.ae_margin_md {
|
||||
margin: 0.75em;
|
||||
}
|
||||
.ae_margin_lg {
|
||||
margin: 1em;
|
||||
}
|
||||
.ae_margin_lg {
|
||||
margin: 1.25em;
|
||||
} */
|
||||
|
||||
/* BEGIN: Overrides and fixes specific to Novi and IDAA */
|
||||
.iframe .novi_btn {
|
||||
border-radius: 60px;
|
||||
border-color: hsla(0, 0%, 50%, .5);
|
||||
}
|
||||
|
||||
.iframe .novi_margin_sm {
|
||||
/* margin: 0.5em; */
|
||||
}
|
||||
|
||||
.iframe .novi_text_wrap {
|
||||
/* white-space: normal; */
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
/* END: Overrides and fixes specific to Novi and IDAA */
|
||||
|
||||
.iframe button.ae_normal,
|
||||
.iframe .btn.ae_normal {
|
||||
/* font: normal 1em sans-serif; */
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.iframe button.ae_smaller,
|
||||
.iframe .btn.ae_smaller,
|
||||
.iframe button.novi_smaller,
|
||||
.iframe .btn.novi_smaller
|
||||
{
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.iframe button.ae_smallest,
|
||||
.iframe .btn.ae_smallest,
|
||||
.iframe button.novi_smallest,
|
||||
.iframe .btn.novi_smallest
|
||||
{
|
||||
font-size: 0.65rem;
|
||||
}
|
||||
@@ -1,133 +1,63 @@
|
||||
// import axios from 'axios';
|
||||
import axios from 'axios';
|
||||
|
||||
// Updated 2024-05-23
|
||||
export let delete_object = async function delete_object(
|
||||
{
|
||||
api_cfg = null,
|
||||
endpoint = '',
|
||||
params = {},
|
||||
data = {},
|
||||
return_meta = false,
|
||||
log_lvl = 0,
|
||||
retry_count = 5 // Number of retry attempts
|
||||
api_cfg=null,
|
||||
endpoint='',
|
||||
params={},
|
||||
data={},
|
||||
return_meta=false,
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
endpoint: string,
|
||||
params?: any,
|
||||
data?: any,
|
||||
return_meta?: boolean,
|
||||
log_lvl?: number,
|
||||
retry_count?: number
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** delete_object() *** Endpoint: ${endpoint}`);
|
||||
console.log('Params:', params);
|
||||
if (log_lvl > 1) {
|
||||
console.log('Data:', data);
|
||||
}
|
||||
}
|
||||
|
||||
if (!api_cfg) {
|
||||
console.error('No API Config was provided. Returning false.');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Construct the URL with query parameters
|
||||
const url = new URL(endpoint, api_cfg['base_url']);
|
||||
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));
|
||||
|
||||
// Clean the headers
|
||||
let headers_cleaned: Record<string, string> = {};
|
||||
for (const prop in api_cfg['headers']) {
|
||||
let prop_cleaned = prop.replaceAll('_', '-');
|
||||
headers_cleaned[prop_cleaned] = api_cfg['headers'][prop];
|
||||
}
|
||||
console.log('*** delete_object() ***');
|
||||
|
||||
if (log_lvl) {
|
||||
// console.log(api_cfg);
|
||||
console.log(endpoint);
|
||||
console.log(params);
|
||||
if (log_lvl > 1) {
|
||||
console.log('Cleaned Headers:', headers_cleaned);
|
||||
console.log('Data:', data);
|
||||
console.log(typeof data);
|
||||
}
|
||||
|
||||
const fetchOptions: RequestInit = {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
...headers_cleaned,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
};
|
||||
|
||||
if (log_lvl > 1) {
|
||||
console.log('Fetch Options:', fetchOptions);
|
||||
}
|
||||
|
||||
for (let attempt = 1; attempt <= retry_count; attempt++) {
|
||||
try {
|
||||
const response = await fetch(url.toString(), fetchOptions);
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`Response: status=${response.status} attempt=${attempt}`);
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
if (response.status === 404) {
|
||||
console.warn('404 Not Found. Returning null.');
|
||||
return null; // Returning null since there were no results
|
||||
}
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
const json = await response.json();
|
||||
|
||||
if (log_lvl > 1) {
|
||||
console.log('Response JSON:', json);
|
||||
}
|
||||
|
||||
// Return the response data or metadata
|
||||
return return_meta ? json : json.data;
|
||||
} catch (error) {
|
||||
console.error(`API DELETE error on attempt ${attempt}:`, error);
|
||||
|
||||
// If this is the last attempt, return false
|
||||
if (attempt === retry_count) {
|
||||
console.error('Max retry attempts reached. Returning false.');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Log retry information
|
||||
if (log_lvl) {
|
||||
console.log(`Retrying... (${attempt}/${retry_count})`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -162,13 +162,10 @@ export async function get_ae_obj_id_crud(
|
||||
params: params,
|
||||
timeout: timeout,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('API GET CRUD object ID request failed.', error);
|
||||
});
|
||||
});
|
||||
|
||||
if (log_lvl > 1) {
|
||||
console.log('GET Object result =', object_obj_get_promise);
|
||||
console.log(object_obj_get_promise);
|
||||
}
|
||||
|
||||
return object_obj_get_promise;
|
||||
|
||||
@@ -9,30 +9,30 @@ export async function get_ae_obj_li_for_obj_id_crud(
|
||||
obj_type,
|
||||
for_obj_type,
|
||||
for_obj_id, // 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,
|
||||
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
|
||||
// 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=1
|
||||
}: {
|
||||
api_cfg: any,
|
||||
obj_type: string,
|
||||
for_obj_type: null|string,
|
||||
for_obj_type: string,
|
||||
for_obj_id?: string,
|
||||
use_alt_table?: boolean,
|
||||
use_alt_base?: boolean,
|
||||
// inc?: key_val
|
||||
inc?: key_val
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
order_by_li?: any,
|
||||
@@ -49,7 +49,7 @@ export async function get_ae_obj_li_for_obj_id_crud(
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** get_ae_obj_li_for_obj_id_crud() *** [${obj_type}]`);
|
||||
console.log('*** get_ae_obj_li_for_obj_id_crud() ***');
|
||||
}
|
||||
|
||||
// data = {};
|
||||
@@ -126,15 +126,15 @@ export async function get_ae_obj_li_for_obj_id_crud(
|
||||
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;
|
||||
|
||||
@@ -24,8 +24,8 @@ export async function get_ae_obj_li_for_obj_id_crud_v2(
|
||||
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
|
||||
return_meta = false,
|
||||
log_lvl = 1
|
||||
}: {
|
||||
api_cfg: any,
|
||||
obj_type: string,
|
||||
@@ -46,7 +46,7 @@ export async function get_ae_obj_li_for_obj_id_crud_v2(
|
||||
params_json?: any,
|
||||
// json_obj?: any,
|
||||
params?: key_val,
|
||||
// return_meta?: boolean,
|
||||
return_meta?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
@@ -128,15 +128,15 @@ export async function get_ae_obj_li_for_obj_id_crud_v2(
|
||||
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;
|
||||
@@ -146,13 +146,6 @@ export async function get_ae_obj_li_for_obj_id_crud_v2(
|
||||
console.log('Endpoint:', endpoint);
|
||||
}
|
||||
|
||||
// We need to remove a few parameters from the params object that are not allowed.
|
||||
delete params['qry__enabled'];
|
||||
delete params['qry__hidden'];
|
||||
delete params['qry__limit'];
|
||||
delete params['qry__offset'];
|
||||
|
||||
|
||||
if (for_obj_type) {
|
||||
params['for_obj_type'] = for_obj_type;
|
||||
}
|
||||
@@ -170,9 +163,7 @@ export async function get_ae_obj_li_for_obj_id_crud_v2(
|
||||
params['exp_alt'] = 'alt'; // Use alternate export table or view name
|
||||
}
|
||||
|
||||
|
||||
// Need to deal with inc params here???
|
||||
|
||||
/* Need to deal with inc params here */
|
||||
|
||||
let allowed_enabled_list = ['all', 'enabled', 'not_enabled']
|
||||
if (allowed_enabled_list.includes(enabled) ) {
|
||||
@@ -187,8 +178,7 @@ export async function get_ae_obj_li_for_obj_id_crud_v2(
|
||||
// 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;
|
||||
headers['order_by_li'] = JSON.stringify(order_by_li);
|
||||
headers['order_by_li'] = order_by_li;
|
||||
}
|
||||
|
||||
if (limit >= 0) {
|
||||
@@ -234,7 +224,7 @@ export async function get_ae_obj_li_for_obj_id_crud_v2(
|
||||
endpoint: endpoint,
|
||||
headers: headers,
|
||||
params: params,
|
||||
// return_meta: return_meta,
|
||||
return_meta: return_meta,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
|
||||
@@ -1,50 +1,58 @@
|
||||
import axios from 'axios';
|
||||
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
|
||||
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 2024-05-23
|
||||
export let get_object = async function get_object(
|
||||
{
|
||||
api_cfg = null,
|
||||
endpoint = '',
|
||||
headers = {},
|
||||
params = {},
|
||||
data = {},
|
||||
timeout = 60000,
|
||||
// return_meta = false,
|
||||
return_blob = false,
|
||||
filename = '',
|
||||
auto_download = false,
|
||||
as_list = false, // Is this still really needed?
|
||||
// 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 = crypto.randomUUID(),
|
||||
log_lvl = 0,
|
||||
retry_count = 5 // Number of retry attempts
|
||||
}: {
|
||||
api_cfg: any,
|
||||
endpoint: string,
|
||||
headers?: any,
|
||||
params?: any,
|
||||
data?: any,
|
||||
timeout?: number,
|
||||
// return_meta?: boolean,
|
||||
return_blob?: boolean,
|
||||
filename?: null | string,
|
||||
auto_download?: boolean,
|
||||
as_list?: boolean,
|
||||
task_id?: string,
|
||||
log_lvl?: number,
|
||||
retry_count?: number
|
||||
}
|
||||
) {
|
||||
{
|
||||
api_cfg=null,
|
||||
endpoint='',
|
||||
headers={},
|
||||
params={},
|
||||
data={},
|
||||
timeout=60000,
|
||||
return_meta=false,
|
||||
return_blob=false,
|
||||
filename='',
|
||||
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=crypto.randomUUID(),
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
endpoint: string,
|
||||
headers?: any,
|
||||
params?: any,
|
||||
data?: any,
|
||||
timeout?: number,
|
||||
return_meta?: boolean,
|
||||
return_blob?: boolean,
|
||||
filename?: null|string,
|
||||
auto_download?: boolean,
|
||||
as_list?: boolean,
|
||||
task_id?: string,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** get_object() *** Endpoint: ${endpoint} AE Task ID: ${task_id}`);
|
||||
console.log('Params:', params);
|
||||
if (log_lvl > 1) {
|
||||
console.log('Data:', data);
|
||||
console.log(`Base URL: ${api_cfg['base_url']}; Timeout: ${timeout}`);
|
||||
console.log('API Config:', api_cfg);
|
||||
}
|
||||
if (log_lvl > 2) {
|
||||
console.log(`Return Meta: ${return_meta}; Return Blob: ${return_blob}; Filename: ${filename}; Auto Download: ${auto_download}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,161 +61,436 @@ export let get_object = async function get_object(
|
||||
return false;
|
||||
}
|
||||
|
||||
const url = new URL(endpoint, api_cfg['base_url']);
|
||||
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));
|
||||
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
||||
|
||||
// Remove a header parameter if it is set to null
|
||||
if (api_cfg['headers'].hasOwnProperty('x-no-account-id') && api_cfg['headers']['x-no-account-id'] === null) {
|
||||
delete api_cfg['headers']['x-no-account-id'];
|
||||
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);
|
||||
}
|
||||
|
||||
// Clean the headers
|
||||
// console.log('Clean the headers. No _underscores_!')
|
||||
let headers_cleaned: key_val = {};
|
||||
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 > 1) {
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`${prop_cleaned}: ${headers_cleaned[prop_cleaned]}`);
|
||||
}
|
||||
}
|
||||
headers = headers_cleaned;
|
||||
if (log_lvl > 1) {
|
||||
if (log_lvl) {
|
||||
console.log('All headers cleaned:', headers);
|
||||
}
|
||||
|
||||
const fetchOptions: RequestInit = {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
...api_cfg['headers'],
|
||||
...headers
|
||||
},
|
||||
signal: controller.signal
|
||||
};
|
||||
|
||||
if (log_lvl > 1) {
|
||||
console.log('Fetch options:', fetchOptions);
|
||||
if (log_lvl) {
|
||||
console.log('URL params:');
|
||||
}
|
||||
|
||||
let fetch_method: any = fetch;
|
||||
if (api_cfg.fetch) {
|
||||
for (const prop in params) {
|
||||
if (log_lvl > 1) {
|
||||
console.log('Using custom fetch function from api_cfg!!!');
|
||||
console.log(`URL param: ${prop}: ${params[prop]}`);
|
||||
}
|
||||
if (params[prop] === null ) {
|
||||
params[prop] = 'null';
|
||||
}
|
||||
fetch_method = api_cfg.fetch;
|
||||
}
|
||||
|
||||
for (let attempt = 1; attempt <= retry_count; attempt++) {
|
||||
try {
|
||||
const response = await fetch_method(url.toString(), fetchOptions)
|
||||
.catch(function (error) {
|
||||
console.log('API GET Object *fetch* request was aborted or failed in an unexpected way.', error);
|
||||
});
|
||||
clearTimeout(timeoutId);
|
||||
// Handle the case where there is no Blob expected to be returned. Mainly JSON and text data.
|
||||
if (!return_blob) {
|
||||
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
|
||||
);
|
||||
if (log_lvl > 1) {
|
||||
console.log('GET Data Progress:', progressEvent.progress, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed);
|
||||
}
|
||||
|
||||
if (!response) {
|
||||
if (log_lvl > 1) {
|
||||
console.log('API GET Object: Something went wrong with *fetch* request. Returning false? Throwing an error!');
|
||||
temp_get_object_percent_completed = percent_completed;
|
||||
|
||||
// WARNING: This needs to be tied to an object type and ID. This is a temporary solution.
|
||||
try {
|
||||
// Check if window is defined. This is to prevent errors in SvelteKit.
|
||||
if (typeof window !== 'undefined') {
|
||||
window.postMessage({
|
||||
type: 'api_download_data',
|
||||
status: 'downloading',
|
||||
task_id: task_id,
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error(`HTTP fetch request was aborted or failed in an unexpected way! URL = ${url.toString()}`); // This will allow it to retry
|
||||
// return false; // This will stop the retries
|
||||
)
|
||||
.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);
|
||||
}
|
||||
|
||||
// Post file download message
|
||||
try {
|
||||
if (typeof window !== 'undefined') {
|
||||
window.postMessage({
|
||||
type: 'api_download_data',
|
||||
status: 'complete',
|
||||
task_id: task_id,
|
||||
endpoint: endpoint,
|
||||
filename: filename,
|
||||
size_total: 0,
|
||||
size_loaded: 0,
|
||||
percent_completed: 100,
|
||||
},
|
||||
'*'
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Error posting message to window:', error);
|
||||
}
|
||||
|
||||
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) {
|
||||
// Handle the common and expected 404 "error" first
|
||||
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);
|
||||
}
|
||||
|
||||
// Post file download message
|
||||
try {
|
||||
if (typeof window !== 'undefined') {
|
||||
window.postMessage({
|
||||
type: 'api_download_data',
|
||||
status: 'complete',
|
||||
task_id: task_id,
|
||||
endpoint: endpoint,
|
||||
filename: filename,
|
||||
size_total: 0,
|
||||
size_loaded: 0,
|
||||
percent_completed: 0,
|
||||
},
|
||||
'*'
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Error posting message to window:', error);
|
||||
}
|
||||
return null; // Returning null since there were no results
|
||||
}
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`Response: status=${response.status} statusText=${response.statusText} url=${response.url} attempt=${attempt}`);
|
||||
}
|
||||
if (log_lvl > 1) {
|
||||
console.log('Response:', response);
|
||||
}
|
||||
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 (!response.ok) {
|
||||
if (response.status === 404) {
|
||||
if (log_lvl) {
|
||||
console.log('The response was a 404 not found "error". Returning null.');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
console.log('The response was not ok. Throwing an error!');
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
if (!return_blob) {
|
||||
const json = await response.json();
|
||||
if (log_lvl > 1) {
|
||||
console.log('Response JSON:', json);
|
||||
}
|
||||
if (!Array.isArray(json.data) && as_list) {
|
||||
return [json.data];
|
||||
}
|
||||
return json.data || json;
|
||||
} else {
|
||||
const reader = response.body?.getReader();
|
||||
const contentLength = +response.headers.get('Content-Length')!;
|
||||
let receivedLength = 0;
|
||||
const chunks = [];
|
||||
|
||||
while (true) {
|
||||
const { done, value } = await reader!.read();
|
||||
if (done) break;
|
||||
chunks.push(value);
|
||||
receivedLength += value.length;
|
||||
|
||||
const percent_completed = Math.round((receivedLength * 100) / contentLength);
|
||||
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('GET Blob Progress:', percent_completed, 'Total:', contentLength, 'Loaded:', receivedLength, 'Percent Completed', percent_completed);
|
||||
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);
|
||||
}
|
||||
|
||||
temp_get_blob_percent_completed = percent_completed;
|
||||
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.');
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof window !== 'undefined') {
|
||||
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.
|
||||
if (log_lvl) {
|
||||
console.log('Returning null. This is expected if no results were found. (404)');
|
||||
}
|
||||
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 (JSON/text) unknown. This should not happen in most cases.');
|
||||
Promise.reject(new Error('fail')).then(resolved, rejected);
|
||||
}
|
||||
|
||||
// Handle the case where a Blob is expected to be returned.
|
||||
} else {
|
||||
|
||||
// console.log('Expecting a Blob to be returned...');
|
||||
|
||||
let response_data_promise = await axios_api.get(
|
||||
endpoint,
|
||||
{
|
||||
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 {
|
||||
if (typeof window !== 'undefined') {
|
||||
window.postMessage({
|
||||
type: 'api_download_blob',
|
||||
status: 'downloading',
|
||||
task_id: task_id,
|
||||
endpoint: endpoint,
|
||||
filename: filename,
|
||||
size_total: contentLength,
|
||||
size_loaded: receivedLength,
|
||||
percent_completed: percent_completed
|
||||
}, '*');
|
||||
size_total: progressEvent.total,
|
||||
size_loaded: progressEvent.loaded,
|
||||
percent_completed: percent_completed,
|
||||
},
|
||||
'*'
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Error posting message to window:', error);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error posting message:', e);
|
||||
}
|
||||
}
|
||||
)
|
||||
.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 blob = new Blob(chunks);
|
||||
if (auto_download) {
|
||||
const downloadUrl = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = downloadUrl;
|
||||
link.setAttribute('download', filename || 'download');
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
return true;
|
||||
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 {
|
||||
if (typeof window !== 'undefined') {
|
||||
window.postMessage({
|
||||
type: 'api_download_blob',
|
||||
status: 'complete',
|
||||
task_id: task_id,
|
||||
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;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
// Handle the common and expected 404 "error" first
|
||||
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);
|
||||
}
|
||||
|
||||
// Post file download message
|
||||
try {
|
||||
if (typeof window !== 'undefined') {
|
||||
window.postMessage({
|
||||
type: 'api_download_blob',
|
||||
status: 'complete',
|
||||
task_id: task_id,
|
||||
endpoint: endpoint,
|
||||
filename: filename,
|
||||
size_total: 0,
|
||||
size_loaded: 0,
|
||||
percent_completed: 0,
|
||||
},
|
||||
'*'
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Error posting message to window:', error);
|
||||
}
|
||||
return null; // Returning null since there were no results
|
||||
}
|
||||
|
||||
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 {
|
||||
return blob;
|
||||
// Something happened in setting up the request that triggered an Error
|
||||
console.log('Error Message', error.message);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(`API GET object request *fetch* error on attempt ${attempt}:`, error);
|
||||
|
||||
if (attempt === retry_count) {
|
||||
console.log('Max retry attempts reached. Returning false.');
|
||||
return false;
|
||||
if (error.code === 'ECONNABORTED') {
|
||||
// Timeout Error (You can implement retry here where suitable)
|
||||
console.log('Timeout Error: ', error.message);
|
||||
}
|
||||
|
||||
// Log retry information
|
||||
if (log_lvl) {
|
||||
console.log(`Retrying... (${attempt}/${retry_count})`);
|
||||
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 (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 if (response_data_promise === null) {
|
||||
// Less common, but expected response if no results were returned.
|
||||
if (log_lvl) {
|
||||
console.log('Returning null. This is expected if no results were found. (404)');
|
||||
}
|
||||
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 (blob) unknown. This should not happen in most cases.');
|
||||
Promise.reject(new Error('fail')).then(resolved, rejected);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function resolved(result: any) {
|
||||
console.log('Resolved');
|
||||
}
|
||||
|
||||
function rejected(result: any) {
|
||||
console.error(result);
|
||||
}
|
||||
@@ -1,496 +0,0 @@
|
||||
import axios from 'axios';
|
||||
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
|
||||
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 2024-05-23
|
||||
export let get_object = async function get_object(
|
||||
{
|
||||
api_cfg=null,
|
||||
endpoint='',
|
||||
headers={},
|
||||
params={},
|
||||
data={},
|
||||
timeout=60000,
|
||||
return_meta=false,
|
||||
return_blob=false,
|
||||
filename='',
|
||||
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=crypto.randomUUID(),
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
endpoint: string,
|
||||
headers?: any,
|
||||
params?: any,
|
||||
data?: any,
|
||||
timeout?: number,
|
||||
return_meta?: boolean,
|
||||
return_blob?: boolean,
|
||||
filename?: null|string,
|
||||
auto_download?: boolean,
|
||||
as_list?: boolean,
|
||||
task_id?: string,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** get_object() *** Endpoint: ${endpoint} AE Task ID: ${task_id}`);
|
||||
console.log('Params:', params);
|
||||
if (log_lvl > 1) {
|
||||
console.log('Data:', data);
|
||||
console.log(`Base URL: ${api_cfg['base_url']}; Timeout: ${timeout}`);
|
||||
console.log('API Config:', api_cfg);
|
||||
}
|
||||
if (log_lvl > 2) {
|
||||
console.log(`Return Meta: ${return_meta}; Return Blob: ${return_blob}; Filename: ${filename}; 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: key_val = {};
|
||||
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 > 1) {
|
||||
console.log(`URL param: ${prop}: ${params[prop]}`);
|
||||
}
|
||||
if (params[prop] === null ) {
|
||||
params[prop] = 'null';
|
||||
}
|
||||
}
|
||||
|
||||
// Handle the case where there is no Blob expected to be returned. Mainly JSON and text data.
|
||||
if (!return_blob) {
|
||||
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
|
||||
);
|
||||
if (log_lvl > 1) {
|
||||
console.log('GET Data Progress:', progressEvent.progress, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed);
|
||||
}
|
||||
|
||||
temp_get_object_percent_completed = percent_completed;
|
||||
|
||||
// WARNING: This needs to be tied to an object type and ID. This is a temporary solution.
|
||||
try {
|
||||
// Check if window is defined. This is to prevent errors in SvelteKit.
|
||||
if (typeof window !== 'undefined') {
|
||||
window.postMessage({
|
||||
type: 'api_download_data',
|
||||
status: 'downloading',
|
||||
task_id: task_id,
|
||||
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 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);
|
||||
}
|
||||
|
||||
// Post file download message
|
||||
try {
|
||||
if (typeof window !== 'undefined') {
|
||||
window.postMessage({
|
||||
type: 'api_download_data',
|
||||
status: 'complete',
|
||||
task_id: task_id,
|
||||
endpoint: endpoint,
|
||||
filename: filename,
|
||||
size_total: 0,
|
||||
size_loaded: 0,
|
||||
percent_completed: 100,
|
||||
},
|
||||
'*'
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Error posting message to window:', error);
|
||||
}
|
||||
|
||||
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) {
|
||||
// Handle the common and expected 404 "error" first
|
||||
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);
|
||||
}
|
||||
|
||||
// Post file download message
|
||||
try {
|
||||
if (typeof window !== 'undefined') {
|
||||
window.postMessage({
|
||||
type: 'api_download_data',
|
||||
status: 'complete',
|
||||
task_id: task_id,
|
||||
endpoint: endpoint,
|
||||
filename: filename,
|
||||
size_total: 0,
|
||||
size_loaded: 0,
|
||||
percent_completed: 0,
|
||||
},
|
||||
'*'
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Error posting message to window:', error);
|
||||
}
|
||||
return null; // Returning null since there were no results
|
||||
}
|
||||
|
||||
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.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.
|
||||
if (log_lvl) {
|
||||
console.log('Returning null. This is expected if no results were found. (404)');
|
||||
}
|
||||
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 (JSON/text) unknown. This should not happen in most cases.');
|
||||
Promise.reject(new Error('fail')).then(resolved, rejected);
|
||||
}
|
||||
|
||||
// Handle the case where a Blob is expected to be returned.
|
||||
} else {
|
||||
|
||||
// console.log('Expecting a Blob to be returned...');
|
||||
|
||||
let response_data_promise = await axios_api.get(
|
||||
endpoint,
|
||||
{
|
||||
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 {
|
||||
if (typeof window !== 'undefined') {
|
||||
window.postMessage({
|
||||
type: 'api_download_blob',
|
||||
status: 'downloading',
|
||||
task_id: task_id,
|
||||
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 {
|
||||
if (typeof window !== 'undefined') {
|
||||
window.postMessage({
|
||||
type: 'api_download_blob',
|
||||
status: 'complete',
|
||||
task_id: task_id,
|
||||
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;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
// Handle the common and expected 404 "error" first
|
||||
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);
|
||||
}
|
||||
|
||||
// Post file download message
|
||||
try {
|
||||
if (typeof window !== 'undefined') {
|
||||
window.postMessage({
|
||||
type: 'api_download_blob',
|
||||
status: 'complete',
|
||||
task_id: task_id,
|
||||
endpoint: endpoint,
|
||||
filename: filename,
|
||||
size_total: 0,
|
||||
size_loaded: 0,
|
||||
percent_completed: 0,
|
||||
},
|
||||
'*'
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Error posting message to window:', error);
|
||||
}
|
||||
return null; // Returning null since there were no results
|
||||
}
|
||||
|
||||
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 (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 (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 if (response_data_promise === null) {
|
||||
// Less common, but expected response if no results were returned.
|
||||
if (log_lvl) {
|
||||
console.log('Returning null. This is expected if no results were found. (404)');
|
||||
}
|
||||
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 (blob) unknown. This should not happen in most cases.');
|
||||
Promise.reject(new Error('fail')).then(resolved, rejected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function resolved(result: any) {
|
||||
console.log('Resolved');
|
||||
}
|
||||
|
||||
function rejected(result: any) {
|
||||
console.error(result);
|
||||
}
|
||||
@@ -1,149 +1,60 @@
|
||||
// import axios from 'axios';
|
||||
import axios from 'axios';
|
||||
|
||||
// Updated 2024-05-23
|
||||
export let patch_object = async function patch_object(
|
||||
{
|
||||
api_cfg = null,
|
||||
endpoint = '',
|
||||
params = {},
|
||||
data = {},
|
||||
return_meta = false,
|
||||
log_lvl = 0,
|
||||
retry_count = 5 // Number of retry attempts
|
||||
api_cfg=null,
|
||||
endpoint='',
|
||||
params={},
|
||||
data={},
|
||||
return_meta=false,
|
||||
log_lvl = 3
|
||||
}: {
|
||||
api_cfg: any,
|
||||
endpoint: string,
|
||||
params?: any,
|
||||
data?: any,
|
||||
return_meta?: boolean,
|
||||
log_lvl?: number,
|
||||
retry_count?: number
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** patch_object() *** Endpoint: ${endpoint}`);
|
||||
console.log('Params:', params);
|
||||
if (log_lvl > 1) {
|
||||
console.log('Data:', data);
|
||||
}
|
||||
}
|
||||
|
||||
if (!api_cfg) {
|
||||
console.error('No API Config was provided. Returning false.');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Construct the URL with query parameters
|
||||
const url = new URL(endpoint, api_cfg['base_url']);
|
||||
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));
|
||||
|
||||
// Clean the headers
|
||||
let headers_cleaned: Record<string, string> = {};
|
||||
for (const prop in api_cfg['headers']) {
|
||||
let prop_cleaned = prop.replaceAll('_', '-');
|
||||
headers_cleaned[prop_cleaned] = api_cfg['headers'][prop];
|
||||
}
|
||||
console.log('*** patch_object() XXXX ***');
|
||||
|
||||
if (log_lvl) {
|
||||
// console.log(api_cfg);
|
||||
console.log(endpoint);
|
||||
console.log(params);
|
||||
if (log_lvl > 1) {
|
||||
console.log('Cleaned Headers:', headers_cleaned);
|
||||
console.log(data);
|
||||
}
|
||||
|
||||
const fetchOptions: RequestInit = {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
...headers_cleaned,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
};
|
||||
|
||||
if (log_lvl > 1) {
|
||||
console.log('Fetch Options:', fetchOptions);
|
||||
}
|
||||
|
||||
for (let attempt = 1; attempt <= retry_count; attempt++) {
|
||||
try {
|
||||
const response = await fetch(url.toString(), fetchOptions);
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`Response: status=${response.status} attempt=${attempt}`);
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
if (response.status === 404) {
|
||||
console.warn('404 Not Found. Returning null.');
|
||||
return null; // Returning null since there were no results
|
||||
}
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
const json = await response.json();
|
||||
|
||||
if (log_lvl > 1) {
|
||||
console.log('Response JSON:', json);
|
||||
}
|
||||
|
||||
// Return the response data or metadata
|
||||
return return_meta ? json : json.data;
|
||||
} catch (error) {
|
||||
console.error(`API PATCH error on attempt ${attempt}:`, error);
|
||||
|
||||
// If this is the last attempt, return false
|
||||
if (attempt === retry_count) {
|
||||
console.error('Max retry attempts reached. Returning false.');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Log retry information
|
||||
if (log_lvl) {
|
||||
console.log(`Retrying... (${attempt}/${retry_count})`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// let axios_api = axios.create({
|
||||
// baseURL: api_cfg['base_url'],
|
||||
// /* other custom settings */
|
||||
// });
|
||||
// axios_api.defaults.headers = api_cfg['headers'];
|
||||
|
||||
// for (let attempt = 1; attempt <= retry_count; attempt++) {
|
||||
// try {
|
||||
// const response = await axios_api.patch(endpoint, data, { params: params });
|
||||
// if (log_lvl) {
|
||||
// console.log(`Response: status=${response.status} attempt=${attempt}`);
|
||||
// }
|
||||
// if (log_lvl > 1) {
|
||||
// console.log('Response Data:', response.data);
|
||||
// }
|
||||
|
||||
// // Return the response data
|
||||
// return response.data['data'];
|
||||
// } catch (error) {
|
||||
// if (log_lvl) {
|
||||
// console.error(`Error on attempt ${attempt}:`, error);
|
||||
// }
|
||||
|
||||
// // Handle specific errors (e.g., 404)
|
||||
// if (error.response && error.response.status === 404) {
|
||||
// console.warn('404 Not Found. Returning null.');
|
||||
// return null; // Returning null since there were no results
|
||||
// }
|
||||
|
||||
// // If this is the last attempt, return false
|
||||
// if (attempt === retry_count) {
|
||||
// console.error('Max retry attempts reached. Returning false.');
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// // Log retry information
|
||||
// if (log_lvl) {
|
||||
// console.log(`Retrying... (${attempt}/${retry_count})`);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return response_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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// import axios from 'axios';
|
||||
import axios from 'axios';
|
||||
|
||||
export let temp_post_blob_percent_completed = 0;
|
||||
export let post_blob_percent_completed = temp_post_blob_percent_completed;
|
||||
@@ -8,19 +8,18 @@ export let post_object_percent_completed = temp_post_object_percent_completed;
|
||||
// Updated 2024-05-23
|
||||
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,
|
||||
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 = crypto.randomUUID(),
|
||||
log_lvl = 0,
|
||||
retry_count = 5
|
||||
task_id=crypto.randomUUID(),
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
endpoint: string,
|
||||
@@ -32,10 +31,9 @@ export let post_object = async function post_object(
|
||||
filename?: string,
|
||||
auto_download?: boolean,
|
||||
task_id?: string,
|
||||
log_lvl?: number,
|
||||
retry_count?: number
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
) {
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`*** post_object() *** Endpoint: ${endpoint} Task ID: ${task_id}`);
|
||||
@@ -52,304 +50,175 @@ export let post_object = async function post_object(
|
||||
console.log(`Filename: ${filename}`);
|
||||
console.log(`Auto Download: ${auto_download}`);
|
||||
}
|
||||
// console.log(return_meta);
|
||||
}
|
||||
|
||||
// console.log('HERE!! API POST 0');
|
||||
|
||||
if (!api_cfg) {
|
||||
console.error('No API Config was provided. Returning false.');
|
||||
return false;
|
||||
}
|
||||
|
||||
// console.log('HERE!! API POST 1');
|
||||
|
||||
// Construct the URL with query parameters
|
||||
const url = new URL(endpoint, api_cfg['base_url']);
|
||||
if (params) {
|
||||
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));
|
||||
}
|
||||
|
||||
// console.log('HERE!! API POST 2');
|
||||
|
||||
// Clean the headers
|
||||
let headers_cleaned: Record<string, string> = {};
|
||||
for (const prop in api_cfg['headers']) {
|
||||
let prop_cleaned = prop.replaceAll('_', '-');
|
||||
headers_cleaned[prop_cleaned] = api_cfg['headers'][prop];
|
||||
}
|
||||
|
||||
// console.log('HERE!! API POST 3');
|
||||
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) {
|
||||
// headers_cleaned['Content-Type'] = 'multipart/form-data';
|
||||
delete headers_cleaned['Content-Type'];
|
||||
delete headers_cleaned['content-type']; // Just in case
|
||||
delete headers_cleaned['Content-type']; // Just in case
|
||||
console.log('Form Data:', form_data);
|
||||
axios_api.defaults.headers['content-type'] = 'multipart/form-data';
|
||||
data = form_data;
|
||||
} else {
|
||||
headers_cleaned['Content-Type'] = 'application/json';
|
||||
axios_api.defaults.headers['content-type'] = 'application/json';
|
||||
}
|
||||
|
||||
if (log_lvl > 1) {
|
||||
console.log('Cleaned Headers:', headers_cleaned);
|
||||
}
|
||||
|
||||
// console.log('HERE!! API POST 4');
|
||||
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);
|
||||
|
||||
for (let attempt = 1; attempt <= retry_count; attempt++) {
|
||||
try {
|
||||
const controller = new AbortController();
|
||||
const fetchOptions: RequestInit = {
|
||||
method: 'POST',
|
||||
headers: headers_cleaned,
|
||||
body: form_data ? form_data : JSON.stringify(data),
|
||||
signal: controller.signal
|
||||
};
|
||||
temp_post_object_percent_completed = percent_completed;
|
||||
|
||||
if (log_lvl > 1) {
|
||||
console.log('Fetch Options:', fetchOptions);
|
||||
try {
|
||||
window.postMessage({
|
||||
type: 'api_post_json_form',
|
||||
status: 'uploading',
|
||||
task_id: task_id,
|
||||
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);
|
||||
try {
|
||||
window.postMessage({
|
||||
type: 'api_post_json_form',
|
||||
status: 'complete',
|
||||
task_id: task_id,
|
||||
endpoint: endpoint,
|
||||
size_total: 0,
|
||||
size_loaded: 0,
|
||||
percent_completed: 100,
|
||||
progress: 100,
|
||||
rate: 0,
|
||||
},
|
||||
'*'
|
||||
);
|
||||
} catch (error) {
|
||||
console.log('Error posting message to window:', error);
|
||||
}
|
||||
|
||||
const response = await fetch(url.toString(), fetchOptions);
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`Response: status=${response.status} attempt=${attempt}`);
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
if (response.status === 404) {
|
||||
console.warn('404 Not Found. Returning null.');
|
||||
return null; // Returning null since there were no results
|
||||
}
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
if (!return_blob) {
|
||||
const json = await response.json();
|
||||
|
||||
if (log_lvl > 1) {
|
||||
console.log('Response JSON:', json);
|
||||
}
|
||||
|
||||
// Post a message to the window indicating the upload is complete
|
||||
try {
|
||||
window.postMessage({
|
||||
type: 'api_post_json_form',
|
||||
status: 'complete',
|
||||
task_id: task_id,
|
||||
endpoint: endpoint,
|
||||
size_total: 0,
|
||||
size_loaded: 0,
|
||||
percent_completed: 100,
|
||||
progress: 100,
|
||||
rate: 0
|
||||
}, '*');
|
||||
} catch (error) {
|
||||
console.error('Error posting message to window:', error);
|
||||
}
|
||||
|
||||
// Return the response data or metadata
|
||||
return return_meta ? json : json.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 {
|
||||
const blob = await response.blob();
|
||||
// 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 (auto_download) {
|
||||
const downloadUrl = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = downloadUrl;
|
||||
link.setAttribute('download', filename || 'download');
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
return true;
|
||||
} else {
|
||||
return blob;
|
||||
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 Progress:', progressEvent.progress, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed);
|
||||
|
||||
temp_post_blob_percent_completed = percent_completed;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`API POST error on attempt ${attempt}:`, error);
|
||||
|
||||
// If this is the last attempt, return false
|
||||
if (attempt === retry_count) {
|
||||
console.error('Max retry attempts reached. Returning false.');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Log retry information
|
||||
)
|
||||
.then(function (response) {
|
||||
if (log_lvl) {
|
||||
console.log(`Retrying... (${attempt}/${retry_count})`);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 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',
|
||||
// status: 'uploading',
|
||||
// task_id: task_id,
|
||||
// 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);
|
||||
// try {
|
||||
// window.postMessage({
|
||||
// type: 'api_post_json_form',
|
||||
// status: 'complete',
|
||||
// task_id: task_id,
|
||||
// endpoint: endpoint,
|
||||
// size_total: 0,
|
||||
// size_loaded: 0,
|
||||
// percent_completed: 100,
|
||||
// progress: 100,
|
||||
// rate: 0,
|
||||
// },
|
||||
// '*'
|
||||
// );
|
||||
// } catch (error) {
|
||||
// console.log('Error posting message to window:', error);
|
||||
// }
|
||||
|
||||
// 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 Progress:', progressEvent.progress, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed);
|
||||
|
||||
// temp_post_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);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
// function resolved(result: any) {
|
||||
// console.log('Resolved');
|
||||
// }
|
||||
function resolved(result: any) {
|
||||
console.log('Resolved');
|
||||
}
|
||||
|
||||
// function rejected(result: any) {
|
||||
// console.error(result);
|
||||
// }
|
||||
function rejected(result: any) {
|
||||
console.error(result);
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
||||
import { db_archives } from "$lib/ae_archives/db_archives";
|
||||
import { db_archives } from "$lib/db_archives";
|
||||
|
||||
import { load_ae_obj_li__archive_content } from "$lib/ae_archives/ae_archives__archive_content";
|
||||
import { load_ae_obj_li__archive_content } from "$lib/ae_archives__archive_content";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
@@ -15,62 +14,37 @@ export async function load_ae_obj_id__archive(
|
||||
api_cfg,
|
||||
archive_id,
|
||||
inc_content_li = false,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
archive_id: string,
|
||||
inc_content_li?: boolean,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__archive() *** archive_id=${archive_id}`);
|
||||
}
|
||||
console.log(`*** load_ae_obj_id__archive() *** archive_id=${archive_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
ae_promises.load__archive_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'archive',
|
||||
obj_id: archive_id,
|
||||
use_alt_table: true,
|
||||
use_alt_base: false,
|
||||
obj_id: archive_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (archive_obj_get_result) {
|
||||
.then(function (archive_obj_get_result) {
|
||||
if (archive_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__archive_props({
|
||||
obj_li: [archive_obj_get_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_archives,
|
||||
table_name: 'archive',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__archive({
|
||||
obj_type: 'archive',
|
||||
obj_li: [archive_obj_get_result]
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// // This is expecting a list
|
||||
// db_save_ae_obj_li__archive({
|
||||
// obj_type: 'archive',
|
||||
// obj_li: [archive_obj_get_result]
|
||||
// });
|
||||
}
|
||||
return archive_obj_get_result;
|
||||
} else {
|
||||
@@ -95,9 +69,7 @@ export async function load_ae_obj_id__archive(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'archive',
|
||||
for_obj_id: archive_id,
|
||||
enabled: 'all',
|
||||
limit: 99,
|
||||
params: params,
|
||||
params: {qry__enabled: 'all', qry__limit: 25},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -118,17 +90,13 @@ export async function load_ae_obj_id__archive(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-11-20
|
||||
// Updated 2024-09-25
|
||||
export async function load_ae_obj_li__archive(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type = 'account',
|
||||
for_obj_id,
|
||||
inc_content_li = false,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
@@ -138,65 +106,30 @@ export async function load_ae_obj_li__archive(
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
inc_content_li?: boolean,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__archive() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
}
|
||||
console.log(`*** load_ae_obj_li__archive() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
// ae_promises.load__archive_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
// api_cfg: api_cfg,
|
||||
// obj_type: 'archive',
|
||||
// for_obj_type: for_obj_type,
|
||||
// for_obj_id: for_obj_id,
|
||||
// use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
// use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
// enabled: enabled,
|
||||
// hidden: hidden,
|
||||
// order_by_li: order_by_li,
|
||||
// limit: limit,
|
||||
// offset: offset,
|
||||
// params_json: params_json,
|
||||
// params: params,
|
||||
// log_lvl: log_lvl
|
||||
// })
|
||||
// .then(function (archive_obj_li_get_result) {
|
||||
// if (archive_obj_li_get_result) {
|
||||
// if (try_cache) {
|
||||
// db_save_ae_obj_li__archive({
|
||||
// obj_type: 'archive',
|
||||
// obj_li: archive_obj_li_get_result
|
||||
// });
|
||||
// }
|
||||
// return archive_obj_li_get_result;
|
||||
// } else {
|
||||
// return [];
|
||||
// }
|
||||
// })
|
||||
// .catch(function (error) {
|
||||
// console.log('No results returned or failed.', error);
|
||||
// });
|
||||
|
||||
ae_promises.load__archive_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
ae_promises.load__archive_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'archive',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: false,
|
||||
use_alt_mdl: false,
|
||||
use_alt_exp: false,
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
@@ -206,41 +139,21 @@ export async function load_ae_obj_li__archive(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (archive_obj_li_get_result) {
|
||||
.then(function (archive_obj_li_get_result) {
|
||||
if (archive_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__archive_props({
|
||||
obj_li: archive_obj_li_get_result,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_archives,
|
||||
table_name: 'archive',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
db_save_ae_obj_li__archive({
|
||||
obj_type: 'archive',
|
||||
obj_li: archive_obj_li_get_result
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__archive({
|
||||
// obj_type: 'archive',
|
||||
// obj_li: archive_obj_li_get_result
|
||||
// });
|
||||
}
|
||||
return archive_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
@@ -260,7 +173,7 @@ export async function load_ae_obj_li__archive(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'archive',
|
||||
for_obj_id: archive_id,
|
||||
params: params,
|
||||
params: {qry__enabled: enabled, qry__limit: limit},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -275,10 +188,6 @@ export async function load_ae_obj_li__archive(
|
||||
if (log_lvl) {
|
||||
console.log(`load_archive_content_obj_li = `, load_archive_content_obj_li);
|
||||
}
|
||||
|
||||
if (load_archive_content_obj_li) {
|
||||
ae_promises.load__archive_obj_li[i].archive_content_obj_li = load_archive_content_obj_li;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,32 +195,23 @@ export async function load_ae_obj_li__archive(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-23
|
||||
// Updated 2024-09-25
|
||||
export async function create_ae_obj__archive(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** create_ae_obj__archive() *** account_id=${account_id}`);
|
||||
}
|
||||
|
||||
if (!account_id) {
|
||||
console.log(`ERROR: Archives - Archive - account_id required to create`);
|
||||
return false;
|
||||
}
|
||||
console.log(`*** create_ae_obj__archive() *** account_id=${account_id}`);
|
||||
|
||||
ae_promises.create__archive = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
@@ -325,38 +225,13 @@ export async function create_ae_obj__archive(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (archive_obj_create_result) {
|
||||
.then(function (archive_obj_create_result) {
|
||||
if (archive_obj_create_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__archive_props({
|
||||
obj_li: [archive_obj_create_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_archives,
|
||||
table_name: 'archive',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
db_save_ae_obj_li__archive(
|
||||
{
|
||||
obj_type: 'archive',
|
||||
obj_li: [archive_obj_create_result]
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__archive(
|
||||
// {
|
||||
// obj_type: 'archive',
|
||||
// obj_li: [archive_obj_create_result]
|
||||
// });
|
||||
}
|
||||
return archive_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
@@ -364,6 +239,8 @@ export async function create_ae_obj__archive(
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
@@ -373,58 +250,7 @@ export async function create_ae_obj__archive(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-11-08
|
||||
export async function delete_ae_obj_id__archive(
|
||||
{
|
||||
api_cfg,
|
||||
archive_id,
|
||||
method = 'delete', // 'delete', 'disable', 'hide'
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
archive_id: string,
|
||||
method?: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** delete_ae_obj_id__archive() *** archive_id=${archive_id}`);
|
||||
}
|
||||
|
||||
ae_promises.delete__archive_obj = await api.delete_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'archive',
|
||||
obj_id: archive_id,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
method: method,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
if (try_cache) {
|
||||
if (log_lvl) {
|
||||
console.log(`Attempting to remove IDB entry for archive_id=${archive_id}`);
|
||||
}
|
||||
db_archives.content.delete(archive_id); // Delete from the DB no matter what.
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.delete__archive_obj:', ae_promises.delete__archive_obj);
|
||||
}
|
||||
|
||||
return ae_promises.delete__archive_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-23
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__archive(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -445,9 +271,7 @@ export async function update_ae_obj__archive(
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__archive() *** archive_id=${archive_id}`, data_kv);
|
||||
}
|
||||
|
||||
// Perform the API update
|
||||
const result = await api.update_ae_obj_id_crud({
|
||||
ae_promises.update__archive_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'archive',
|
||||
obj_id: archive_id,
|
||||
@@ -456,45 +280,29 @@ export async function update_ae_obj__archive(
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (archive_obj_update_result) {
|
||||
if (archive_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__archive({
|
||||
obj_type: 'archive', obj_li: [archive_obj_update_result]
|
||||
});
|
||||
}
|
||||
return archive_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
// Handle the result
|
||||
if (result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__archive_props({
|
||||
obj_li: [result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_archives,
|
||||
table_name: 'archive',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// await db_save_ae_obj_li__archive({
|
||||
// obj_type: 'archive',
|
||||
// obj_li: [result],
|
||||
// log_lvl: log_lvl,
|
||||
// });
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
console.error('Failed to update archive.');
|
||||
return null;
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__archive_obj:', ae_promises.update__archive_obj);
|
||||
}
|
||||
return ae_promises.update__archive_obj;
|
||||
}
|
||||
|
||||
|
||||
@@ -597,12 +405,10 @@ export async function qry__archive(
|
||||
})
|
||||
.then(function (archive_obj_li_get_result) {
|
||||
if (archive_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__archive({
|
||||
obj_type: 'archive',
|
||||
obj_li: archive_obj_li_get_result
|
||||
});
|
||||
}
|
||||
db_save_ae_obj_li__archive({
|
||||
obj_type: 'archive',
|
||||
obj_li: archive_obj_li_get_result
|
||||
});
|
||||
return archive_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
@@ -829,128 +635,3 @@ export function db_save_ae_obj_li__archive(
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'archive_id',
|
||||
// 'archive_id_random',
|
||||
|
||||
'code',
|
||||
|
||||
'account_id',
|
||||
// 'account_id_random',
|
||||
|
||||
'name',
|
||||
'description',
|
||||
|
||||
'original_datetime',
|
||||
'original_timezone',
|
||||
'original_location',
|
||||
|
||||
'original_url',
|
||||
'original_url_text',
|
||||
|
||||
'sort_by',
|
||||
'sort_by_desc',
|
||||
|
||||
'cfg_json',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
// 'tmp_sort_a',
|
||||
// 'tmp_sort_b',
|
||||
|
||||
// From SQL view
|
||||
// 'archive_content_count',
|
||||
|
||||
// A key value list of the contents
|
||||
// 'archive_content_kv',
|
||||
// 'archive_content_li',
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
export async function process_ae_obj__archive_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__archive_props() ***`, obj_li);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj archive:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.archive_id_random,
|
||||
archive_id: obj.archive_id_random,
|
||||
// archive_id_random: obj.archive_id_random,
|
||||
|
||||
code: obj.code,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
// account_id_random: obj.account_id_random,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
original_datetime: obj.original_datetime,
|
||||
original_timezone: obj.original_timezone,
|
||||
original_location: obj.original_location,
|
||||
|
||||
original_url: obj.original_url,
|
||||
original_url_text: obj.original_url_text,
|
||||
|
||||
sort_by: obj.sort_by,
|
||||
sort_by_desc: obj.sort_by_desc,
|
||||
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
// archive_content_count: obj.archive_content_count,
|
||||
|
||||
// A key value list of the contents
|
||||
// archive_content_kv: obj.archive_content_kv,
|
||||
// archive_content_li: obj.archive_content_li,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
@@ -1,15 +1,11 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
||||
import { db_archives } from "$lib/ae_archives/db_archives";
|
||||
import { db_archives } from "$lib/db_archives";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// TESTING NOTE: I changed these to all use async and await. Not sure if this helps or hurts things. Mainly this is related to the Dexie DB changes. 2024-11-08
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function load_ae_obj_id__archive_content(
|
||||
{
|
||||
@@ -24,9 +20,7 @@ export async function load_ae_obj_id__archive_content(
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__archive_content() *** archive_content_id=${archive_content_id}`);
|
||||
}
|
||||
console.log(`*** load_ae_obj_id__archive_content() *** archive_content_id=${archive_content_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
@@ -39,38 +33,15 @@ export async function load_ae_obj_id__archive_content(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (archive_content_obj_get_result) {
|
||||
.then(function (archive_content_obj_get_result) {
|
||||
if (archive_content_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__archive_content_props({
|
||||
obj_li: [archive_content_obj_get_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_archives,
|
||||
table_name: 'content',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__archive_content({
|
||||
obj_type: 'archive_content',
|
||||
obj_li: [archive_content_obj_get_result]
|
||||
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// // This is expecting a list
|
||||
// await db_save_ae_obj_li__archive_content({
|
||||
// obj_type: 'archive_content',
|
||||
// obj_li: [archive_content_obj_get_result]
|
||||
|
||||
// });
|
||||
}
|
||||
return archive_content_obj_get_result;
|
||||
} else {
|
||||
@@ -86,17 +57,13 @@ export async function load_ae_obj_id__archive_content(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-11-20
|
||||
// Updated 2024-09-25
|
||||
export async function load_ae_obj_li__archive_content(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type = 'archive',
|
||||
for_obj_id,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'original_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
@@ -104,37 +71,30 @@ export async function load_ae_obj_li__archive_content(
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__archive_content() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
}
|
||||
console.log(`*** load_ae_obj_li__archive_content() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
|
||||
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
// let limit: number = (params.qry__limit ?? 99); // 99
|
||||
// let offset: number = (params.qry__offset ?? 0); // 0
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console('params_json:', params_json);
|
||||
|
||||
ae_promises.load__archive_content_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
ae_promises.load__archive_content_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'archive_content',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: false,
|
||||
use_alt_mdl: false,
|
||||
use_alt_exp: false,
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
@@ -144,35 +104,12 @@ export async function load_ae_obj_li__archive_content(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (archive_content_obj_li_get_result) {
|
||||
.then(function (archive_content_obj_li_get_result) {
|
||||
if (archive_content_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__archive_content_props({
|
||||
obj_li: archive_content_obj_li_get_result,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_archives,
|
||||
table_name: 'content',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
db_save_ae_obj_li__archive_content({
|
||||
obj_type: 'archive_content', obj_li: archive_content_obj_li_get_result
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// await db_save_ae_obj_li__archive_content({
|
||||
// obj_type: 'archive_content', obj_li: archive_content_obj_li_get_result
|
||||
// });
|
||||
}
|
||||
return archive_content_obj_li_get_result;
|
||||
} else {
|
||||
@@ -191,32 +128,23 @@ export async function load_ae_obj_li__archive_content(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-23
|
||||
// Updated 2024-09-25
|
||||
export async function create_ae_obj__archive_content(
|
||||
{
|
||||
api_cfg,
|
||||
archive_id,
|
||||
data_kv,
|
||||
params={},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
archive_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** create_ae_obj__archive_content() *** archive_id=${archive_id}`);
|
||||
}
|
||||
|
||||
if (!archive_id) {
|
||||
console.log(`ERROR: Archives - Content - archive_id required to create`);
|
||||
return false;
|
||||
}
|
||||
console.log(`*** create_ae_obj__archive_content() *** archive_id=${archive_id}`);
|
||||
|
||||
ae_promises.create__archive_content = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
@@ -230,38 +158,13 @@ export async function create_ae_obj__archive_content(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (archive_content_obj_create_result) {
|
||||
.then(function (archive_content_obj_create_result) {
|
||||
if (archive_content_obj_create_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__archive_content_props({
|
||||
obj_li: [archive_content_obj_create_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_archives,
|
||||
table_name: 'content',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
db_save_ae_obj_li__archive_content(
|
||||
{
|
||||
obj_type: 'archive_content',
|
||||
obj_li: [archive_content_obj_create_result]
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// await db_save_ae_obj_li__archive_content(
|
||||
// {
|
||||
// obj_type: 'archive_content',
|
||||
// obj_li: [archive_content_obj_create_result]
|
||||
// });
|
||||
}
|
||||
return archive_content_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
@@ -269,6 +172,8 @@ export async function create_ae_obj__archive_content(
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
@@ -278,58 +183,7 @@ export async function create_ae_obj__archive_content(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-11-08
|
||||
export async function delete_ae_obj_id__archive_content(
|
||||
{
|
||||
api_cfg,
|
||||
archive_content_id,
|
||||
method = 'delete', // 'delete', 'disable', 'hide'
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
archive_content_id: string,
|
||||
method?: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** delete_ae_obj_id__archive_content() *** archive_content_id=${archive_content_id}`);
|
||||
}
|
||||
|
||||
ae_promises.delete__archive_content_obj = await api.delete_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'archive_content',
|
||||
obj_id: archive_content_id,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
method: method,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
if (try_cache) {
|
||||
if (log_lvl) {
|
||||
console.log(`Attempting to remove IDB entry for archive_content_id=${archive_content_id}`);
|
||||
}
|
||||
db_archives.content.delete(archive_content_id); // Delete from the DB no matter what.
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.delete__archive_content_obj:', ae_promises.delete__archive_content_obj);
|
||||
}
|
||||
|
||||
return ae_promises.delete__archive_content_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-23
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__archive_content(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -350,9 +204,7 @@ export async function update_ae_obj__archive_content(
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__archive_content() *** archive_content_id=${archive_content_id}`, data_kv);
|
||||
}
|
||||
|
||||
// Perform the API update
|
||||
const result = await api.update_ae_obj_id_crud({
|
||||
ae_promises.update__archive_content_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'archive_content',
|
||||
obj_id: archive_content_id,
|
||||
@@ -360,52 +212,36 @@ export async function update_ae_obj__archive_content(
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (archive_content_obj_update_result) {
|
||||
if (archive_content_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__archive_content({
|
||||
obj_type: 'archive_content', obj_li: [archive_content_obj_update_result]
|
||||
});
|
||||
}
|
||||
return archive_content_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
// Handle the result
|
||||
if (result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__archive_content_props({
|
||||
obj_li: [result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_archives,
|
||||
table_name: 'content',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// await db_save_ae_obj_li__archive_content({
|
||||
// obj_type: 'archive_content',
|
||||
// obj_li: [result],
|
||||
// log_lvl: log_lvl,
|
||||
// });
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
console.error('Failed to update archive content.');
|
||||
return null;
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__archive_content_obj:', ae_promises.update__archive_content_obj);
|
||||
}
|
||||
return ae_promises.update__archive_content_obj;
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the archive_content_obj_li and save each one to the DB.
|
||||
// Updated 2024-09-25
|
||||
export async function db_save_ae_obj_li__archive_content(
|
||||
export function db_save_ae_obj_li__archive_content(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
@@ -444,7 +280,7 @@ export async function db_save_ae_obj_li__archive_content(
|
||||
url: obj.url,
|
||||
url_text: obj.url_text,
|
||||
|
||||
hosted_file_id: obj.hosted_file_id_random,
|
||||
hosted_file_id: obj.hosted_file_id,
|
||||
|
||||
file_path: obj.file_path,
|
||||
|
||||
@@ -470,15 +306,9 @@ export async function db_save_ae_obj_li__archive_content(
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.original_datetime}_${obj.group}_${obj.priority}_${obj.sort}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.original_datetime}_${obj.priority}_${obj.sort}`,
|
||||
|
||||
// From SQL view
|
||||
archive_code: obj.archive_code,
|
||||
archive_name: obj.archive_name,
|
||||
|
||||
hash_sha256: obj.hosted_file_hash_sha256
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.archive_content_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
@@ -493,153 +323,3 @@ export async function db_save_ae_obj_li__archive_content(
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'archive_content_id',
|
||||
// 'archive_content_id_random',
|
||||
|
||||
'archive_id',
|
||||
// 'archive_id_random',
|
||||
|
||||
'archive_content_type',
|
||||
|
||||
'name',
|
||||
'description',
|
||||
|
||||
'content_html',
|
||||
'content_json',
|
||||
|
||||
'url',
|
||||
'url_text',
|
||||
|
||||
'hosted_file_id',
|
||||
'hosted_file_id_random',
|
||||
|
||||
'file_path',
|
||||
|
||||
'filename',
|
||||
'file_extension',
|
||||
|
||||
'original_datetime',
|
||||
'original_timezone',
|
||||
'original_location',
|
||||
'original_url',
|
||||
'original_url_text',
|
||||
|
||||
'enable_for_public',
|
||||
|
||||
'cfg_json',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
// 'tmp_sort_a',
|
||||
// 'tmp_sort_b',
|
||||
|
||||
// From SQL view
|
||||
'archive_code',
|
||||
'archive_name',
|
||||
|
||||
'hash_sha256'
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
export async function process_ae_obj__archive_content_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__archive_content_props() ***`, obj_li);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj archive_content:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.archive_content_id_random,
|
||||
archive_content_id: obj.archive_content_id_random,
|
||||
// archive_content_id_random: obj.archive_content_id_random,
|
||||
|
||||
archive_id: obj.archive_id_random,
|
||||
// archive_id_random: obj.archive_id_random,
|
||||
|
||||
archive_content_type: obj.archive_content_type,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
content_html: obj.content_html,
|
||||
content_json: obj.content_json,
|
||||
|
||||
url: obj.url,
|
||||
url_text: obj.url_text,
|
||||
|
||||
hosted_file_id: obj.hosted_file_id_random,
|
||||
hosted_file_id_random: obj.hosted_file_id_random,
|
||||
|
||||
file_path: obj.file_path,
|
||||
|
||||
filename: obj.filename,
|
||||
file_extension: obj.file_extension,
|
||||
|
||||
original_datetime: obj.original_datetime,
|
||||
original_timezone: obj.original_timezone,
|
||||
original_location: obj.original_location,
|
||||
original_url: obj.original_url,
|
||||
original_url_text: obj.original_url_text,
|
||||
|
||||
enable_for_public: obj.enable_for_public,
|
||||
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.original_datetime ?? ''}`,
|
||||
tmp_sort_2: `${obj.group ?? ''}_${obj.original_datetime ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}`,
|
||||
tmp_sort_3: `${obj.original_datetime ?? ''}_${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}`,
|
||||
// tmp_sort_a: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
// tmp_sort_b: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
archive_code: obj.archive_code,
|
||||
archive_name: obj.archive_name,
|
||||
|
||||
hash_sha256: obj.hosted_file_hash_sha256
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
@@ -4,36 +4,32 @@ import {
|
||||
load_ae_obj_id__archive,
|
||||
load_ae_obj_li__archive,
|
||||
create_ae_obj__archive,
|
||||
delete_ae_obj_id__archive,
|
||||
update_ae_obj__archive,
|
||||
// qry__archive,
|
||||
db_save_ae_obj_li__archive,
|
||||
} from "$lib/ae_archives/ae_archives__archive";
|
||||
} from "$lib/ae_archives__archive";
|
||||
|
||||
|
||||
import {
|
||||
load_ae_obj_id__archive_content,
|
||||
load_ae_obj_li__archive_content,
|
||||
create_ae_obj__archive_content,
|
||||
delete_ae_obj_id__archive_content,
|
||||
update_ae_obj__archive_content,
|
||||
// qry__archive_content,
|
||||
db_save_ae_obj_li__archive_content,
|
||||
} from "$lib/ae_archives/ae_archives__archive_content";
|
||||
} from "$lib/ae_archives__archive_content";
|
||||
|
||||
|
||||
let export_obj = {
|
||||
load_ae_obj_id__archive: load_ae_obj_id__archive,
|
||||
load_ae_obj_li__archive: load_ae_obj_li__archive,
|
||||
create_ae_obj__archive: create_ae_obj__archive,
|
||||
delete_ae_obj_id__archive: delete_ae_obj_id__archive,
|
||||
update_ae_obj__archive: update_ae_obj__archive,
|
||||
db_save_ae_obj_li__archive: db_save_ae_obj_li__archive,
|
||||
|
||||
load_ae_obj_id__archive_content: load_ae_obj_id__archive_content,
|
||||
load_ae_obj_li__archive_content: load_ae_obj_li__archive_content,
|
||||
create_ae_obj__archive_content: create_ae_obj__archive_content,
|
||||
delete_ae_obj_id__archive_content: delete_ae_obj_id__archive_content,
|
||||
update_ae_obj__archive_content: update_ae_obj__archive_content,
|
||||
db_save_ae_obj_li__archive_content: db_save_ae_obj_li__archive_content,
|
||||
};
|
||||
|
||||
@@ -1,377 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { preventDefault } from 'svelte/legacy';
|
||||
|
||||
// Imports
|
||||
// Import components and elements
|
||||
// import Element_input_files_tbl from '$lib/element_input_files_tbl.svelte';
|
||||
|
||||
// Import storage, functions, and libraries
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
|
||||
import { api } from '$lib/api';
|
||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
|
||||
|
||||
// Exports
|
||||
|
||||
|
||||
// export let input_name = 'file_list';
|
||||
// export let multiple: boolean = true;
|
||||
// export let required: boolean = true;
|
||||
|
||||
|
||||
// export let input_class_li: string[] = ['file_drop_area'];
|
||||
|
||||
|
||||
interface Props {
|
||||
log_lvl?: number;
|
||||
// Expecting these for link_to_type: 'event', 'event_location', 'archive_content', etc
|
||||
link_to_type: string;
|
||||
link_to_id: string;
|
||||
// export let accept: string = 'audio/*, image/*, video/*, .bak, .cfg, .css, .csv, .doc, .docx, .gz, .htm, .html, .ini, .iso, .j2, .json, .key, .keynote, .md, .pdf, .ppt, .pptx, .rar, .rtf, .sql, .svelte, ttf, .txt, .xls, .xlsx, .xz, .zip, .bin, .dmg, .exe, .js, .msi, .php, .py, .sh';
|
||||
class_li_default?: string;
|
||||
class_li?: string;
|
||||
// export let table_class_li: string[] = ['table', 'table-sm', 'table-striped', 'table-hover' , 'text-sm'];
|
||||
clip_complete?: boolean;
|
||||
// export let upload_complete: boolean = false;
|
||||
submit_status?: null|string;
|
||||
// hosted_file_id_li?: string[];
|
||||
// hosted_file_obj_li?: any[];
|
||||
hosted_file_obj_kv?: key_val;
|
||||
video_clip_file_kv?: key_val;
|
||||
}
|
||||
|
||||
let {
|
||||
log_lvl = $bindable(0),
|
||||
link_to_type = $bindable(),
|
||||
link_to_id = $bindable(),
|
||||
class_li_default = 'flex flex-col gap-1 items-center justify-center w-full max-w-2xl mx-auto my-1',
|
||||
class_li = $bindable(''),
|
||||
clip_complete = $bindable(false),
|
||||
submit_status = $bindable(null),
|
||||
// hosted_file_id_li = [],
|
||||
// hosted_file_obj_li = [],
|
||||
hosted_file_obj_kv = $bindable({}),
|
||||
video_clip_file_kv = $bindable({})
|
||||
}: Props = $props();
|
||||
|
||||
|
||||
// Local Variables
|
||||
let task_id = link_to_id;
|
||||
// let input_file_list: any = null;
|
||||
let ae_promises: key_val = $state({});
|
||||
// let ae_promises_clipping: key_val = {};
|
||||
// let ae_triggers: key_val = {};
|
||||
|
||||
// let input_element_id = 'ae_comp__hosted_files_upload__input';
|
||||
|
||||
// let form_kv: key_val = {
|
||||
// start_time: null,
|
||||
// end_time: null,
|
||||
// reencode: null,
|
||||
// video_file: null,
|
||||
// };
|
||||
// let download_clip_src: string;
|
||||
// let download_clip_filename: string;
|
||||
|
||||
$ae_sess.files.obj = {
|
||||
obj: null,
|
||||
};
|
||||
|
||||
|
||||
// *** Functions and Logic
|
||||
function handle_clip_video(event) {
|
||||
console.log('*** handle_clip_video() ***');
|
||||
|
||||
submit_status = 'clipping';
|
||||
clip_complete = false;
|
||||
|
||||
let hosted_file_id = event.target.hosted_file_id.value;
|
||||
|
||||
$ae_sess.files.processed_file_kv[hosted_file_id] = {};
|
||||
$ae_sess.files.processed_file_kv[hosted_file_id].submit_status = 'clipping';
|
||||
$ae_sess.files.processed_file_kv[hosted_file_id].clip_complete = false;
|
||||
|
||||
// $ae_sess.files.disable_submit__hosted_file_obj = true;
|
||||
$ae_loc.files.processed_file_kv[hosted_file_id] = {};
|
||||
$ae_loc.files.processed_file_kv[hosted_file_id].submit_status = 'clipping';
|
||||
$ae_loc.files.processed_file_kv[hosted_file_id].start_time = event.target.start_time.value;
|
||||
$ae_loc.files.processed_file_kv[hosted_file_id].end_time = event.target.end_time.value;
|
||||
$ae_loc.files.processed_file_kv[hosted_file_id].reencode = event.target.reencode.value;
|
||||
$ae_loc.files.processed_file_kv[hosted_file_id].scale_down = event.target.scale_down.value;
|
||||
$ae_loc.files.processed_file_kv[hosted_file_id].new_filename = event.target.new_filename.value;
|
||||
$ae_loc.files.processed_file_kv[hosted_file_id].clip_complete = false;
|
||||
|
||||
let endpoint = `/hosted_file/${hosted_file_id}/clip_video`;
|
||||
|
||||
let params = {
|
||||
link_to_type: link_to_type,
|
||||
link_to_id: link_to_id,
|
||||
filename_no_ext: event.target.new_filename.value.replace('.mp4', ''),
|
||||
from_type: 'mp4', // Video file type being converted
|
||||
to_type: 'mp4', // Video file type to convert to
|
||||
start_time: event.target.start_time.value,
|
||||
end_time: event.target.end_time.value,
|
||||
reencode: event.target.reencode.value,
|
||||
scale_down: event.target.scale_down.value,
|
||||
};
|
||||
|
||||
ae_promises[hosted_file_id] = {};
|
||||
// .convert__hosted_file_obj
|
||||
ae_promises[hosted_file_id] = api.get_object({
|
||||
api_cfg: $ae_api,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
timeout: 300000, // 5 minutes
|
||||
// return_blob: true,
|
||||
// filename: event.target.new_filename.value,
|
||||
// auto_download: false,
|
||||
task_id: task_id,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (result) {
|
||||
console.log(result);
|
||||
|
||||
video_clip_file_kv[result.hosted_file_id_random] = {};
|
||||
video_clip_file_kv[result.hosted_file_id_random] = result;
|
||||
|
||||
// $ae_loc.files.video_clip_file_kv[result.hosted_file_id_random] = {};
|
||||
// $ae_loc.files.video_clip_file_kv[result.hosted_file_id_random] = result;
|
||||
|
||||
$ae_sess.files.processed_file_kv[hosted_file_id].submit_status = 'clipped';
|
||||
$ae_sess.files.processed_file_kv[hosted_file_id].clip_complete = true;
|
||||
|
||||
$ae_loc.files.processed_file_kv[hosted_file_id].submit_status = 'clipped';
|
||||
$ae_loc.files.processed_file_kv[hosted_file_id].clip_complete = true;
|
||||
|
||||
submit_status = 'clipped';
|
||||
clip_complete = true;
|
||||
|
||||
// let file_blob = new Blob([result.data]);
|
||||
// // console.log(file_blob);
|
||||
// let file_obj_url = window.URL.createObjectURL(file_blob); // The img src
|
||||
// // const url = window.URL.createObjectURL(new Blob([result.data]));
|
||||
// download_clip_src = file_obj_url;
|
||||
// // download_filename = file_obj_url;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<section
|
||||
class="{class_li_default} {class_li}"
|
||||
>
|
||||
|
||||
<!-- <h3 class="h3">{hosted_file_obj_li.length}× files uploaded</h3>
|
||||
{#each hosted_file_obj_li as hosted_file_obj, i} -->
|
||||
|
||||
<h3
|
||||
class="h3"
|
||||
>
|
||||
{Object.entries(hosted_file_obj_kv).length}× files uploaded
|
||||
</h3>
|
||||
|
||||
{#each Object.entries(hosted_file_obj_kv) as [hosted_file_id, hosted_file_obj]}
|
||||
<div class="border border-gray-300 rounded-lg p-2 m-2">
|
||||
<!-- {#if $ae_sess.files[hosted_file_id].upload_complete}
|
||||
<a href="/hosted_file/{hosted_file_id}/download?x_no_account_id_token=direct-download" download={$ae_sess.files[hosted_file_id].new_filename} class="ae_btn btn_lg btn_primary"><span class="fas fa-download"></span> Ready to Download</a>
|
||||
{/if} -->
|
||||
|
||||
<div class="flex flex-row flex-wrap gap-1 justify-center items-center w-full">
|
||||
<!-- Remove from uploaded file kv list -->
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
// This (uploaded_file_kv) is referenced by other AE components. Currently it is only used with the manage hosted file list and clip video components.
|
||||
console.log(`Removed hosted file ID: ${hosted_file_id}`, $ae_loc.files.uploaded_file_kv);
|
||||
// delete $ae_sess.files.uploaded_file_kv[hosted_file_id];
|
||||
delete $ae_loc.files.uploaded_file_kv[hosted_file_id];
|
||||
$ae_loc.files.uploaded_file_kv = {...$ae_loc.files.uploaded_file_kv};
|
||||
delete hosted_file_obj_kv[hosted_file_id];
|
||||
hosted_file_obj_kv = {...hosted_file_obj_kv};
|
||||
// delete $ae_loc.files.uploaded_file_kv[hosted_file_obj.hosted_file_id];
|
||||
console.log(`Removed hosted file ID: ${hosted_file_obj.hosted_file_id}`, $ae_loc.files.uploaded_file_kv);
|
||||
}}
|
||||
class="btn btn-sm preset-tonal-warning hover:preset-filled-warning-500"
|
||||
title={`Remove this file from list of videos:\n${hosted_file_obj.filename}\n[API] SHA256: ${hosted_file_obj?.hash_sha256?.slice(0, 10)}... Hosted ID: ${hosted_file_obj.hosted_file_id_random}`}
|
||||
>
|
||||
<span class="fas fa-minus-circle m-1"></span>
|
||||
<span class="">Remove</span>
|
||||
</button>
|
||||
|
||||
<!-- Download the file -->
|
||||
<button
|
||||
type="button"
|
||||
disabled={!$ae_loc.trusted_access}
|
||||
onclick={() => {
|
||||
ae_promises[hosted_file_id] = api.download_hosted_file({
|
||||
api_cfg: $ae_api,
|
||||
hosted_file_id: hosted_file_id,
|
||||
return_file: true,
|
||||
filename: hosted_file_obj.filename,
|
||||
auto_download: true,
|
||||
log_lvl: 0
|
||||
});
|
||||
|
||||
// window.postMessage({ type: 'download_event_file', hosted_file_id: idaa_archive_content_obj.hosted_file_id, filename: idaa_archive_content_obj.filename, auto_download: true }, '*');
|
||||
}}
|
||||
class:hidden={!$ae_loc.edit_mode}
|
||||
class="novi_btn btn btn-sm lg:btn-md preset-tonal-primary hover:preset-filled-primary-500 min-w-72 lg:min-w-96"
|
||||
title={`Download this file:\n${hosted_file_obj.filename}\n[API] SHA256: ${hosted_file_obj?.hash_sha256?.slice(0, 10)}... Hosted ID: ${hosted_file_obj.hosted_file_id_random}`}
|
||||
>
|
||||
{#await ae_promises[hosted_file_id]}
|
||||
<span class="fas fa-spinner fa-spin mx-1"></span>
|
||||
{#if submit_status == 'clipping'}
|
||||
<span class="">Clipping</span>
|
||||
{:else}
|
||||
<span class="">
|
||||
Downloading
|
||||
{#if $ae_sess.api_download_kv[hosted_file_id]}
|
||||
{$ae_sess.api_download_kv[hosted_file_id].percent_completed}%
|
||||
{/if}
|
||||
:
|
||||
</span>
|
||||
{/if}
|
||||
{:then}
|
||||
<span class="fas fa-{ae_util.file_extension_icon(hosted_file_obj?.file_extension)}"></span>
|
||||
{/await}
|
||||
|
||||
<span class="grow">
|
||||
{ae_util.shorten_filename({filename: hosted_file_obj?.filename, max_length: 30})}
|
||||
</span>
|
||||
</button>
|
||||
<span>{ae_util.shorten_filename({filename: hosted_file_obj?.filename, max_length: 30})}</span>
|
||||
<span>
|
||||
<span class="text-sm font-bold">
|
||||
File ID:
|
||||
</span>
|
||||
{hosted_file_obj.hosted_file_id_random}</span>
|
||||
<span>
|
||||
<span class="text-sm font-bold">
|
||||
Type:
|
||||
</span>
|
||||
{hosted_file_obj.extension}</span>
|
||||
<!-- <span>{hosted_file_obj.filename}</span> -->
|
||||
</div>
|
||||
|
||||
<form
|
||||
onsubmit={preventDefault(handle_clip_video)}
|
||||
class="{class_li_default} {class_li}"
|
||||
>
|
||||
<!-- {$ae_sess?.files[hosted_file_obj?.hosted_file_id_random ?? 'obj'].submit_status ?? 'not set'} -->
|
||||
|
||||
<input type="hidden" name="hosted_file_id" value="{hosted_file_obj.hosted_file_id_random}" />
|
||||
|
||||
<div class="flex flex-row gap-1 justify-center items-center w-full">
|
||||
<span class="text-xs font-bold w-32">New Filename:</span>
|
||||
<input type="text" class="input w-full text-sm" name="new_filename" value={hosted_file_obj.filename} />
|
||||
</div>
|
||||
|
||||
<div class="max-w-(--breakpoint-sm) flex flex-row gap-1 justify-center items-center w-full">
|
||||
<label class="label w-48"
|
||||
title="The start time of the clip. This is the time in the video where the clip will start. You may need to subtract a few seconds to get the exact start time."
|
||||
>
|
||||
<span class="text-xs font-bold">Start time (HH:MM:SS)</span>
|
||||
<input type="text" name="start_time"
|
||||
value={($ae_loc.files.processed_file_kv && $ae_loc.files.processed_file_kv[hosted_file_id] && $ae_loc.files.processed_file_kv[hosted_file_id].start_time) ? $ae_loc.files.processed_file_kv[hosted_file_id].start_time : '00:00:00'}
|
||||
placeholder="HH:MM:SS (00:01:30)" class="input w-32" />
|
||||
</label>
|
||||
|
||||
<label class="label w-48"
|
||||
title="The end time of the clip. This is the time in the video where the clip will end. You may need to add a few seconds to get the exact end time."
|
||||
>
|
||||
<span class="text-xs font-bold">End time (HH:MM:SS)</span>
|
||||
<input type="text" name="end_time"
|
||||
value={($ae_loc.files.processed_file_kv && $ae_loc.files.processed_file_kv[hosted_file_id] && $ae_loc.files.processed_file_kv[hosted_file_id].end_time) ? $ae_loc.files.processed_file_kv[hosted_file_id].end_time : '00:45:59'}
|
||||
placeholder="HH:MM:SS (01:05:25)" class="input w-32" />
|
||||
</label>
|
||||
|
||||
<span class="flex flex-col gap-1 items-center justify-center"
|
||||
title="Re-encode the video file? This does cause some minor quality loss. Re-encoding is useful if the audio or video seems to be chopped off at the beginning or end of the clip. It can also help with partially corrupted files."
|
||||
>
|
||||
<span class="text-xs font-bold">
|
||||
Re-encode?
|
||||
</span>
|
||||
<label class="inline-block">
|
||||
<input type="radio" name="reencode" value="true" class="radio" checked />
|
||||
True
|
||||
</label>
|
||||
<label class="inline-block">
|
||||
<input type="radio" name="reencode" value="false" class="radio" />
|
||||
False
|
||||
</label>
|
||||
</span>
|
||||
|
||||
<span class="flex flex-col gap-1 items-center justify-center"
|
||||
title="Scale the video file down to 1920x1080? This does cause some minor quality loss. Re-encoding is useful if the audio or video seems to be chopped off at the beginning or end of the clip. It can also help with partially corrupted files."
|
||||
>
|
||||
<span class="text-xs font-bold">
|
||||
Scale down?
|
||||
</span>
|
||||
<label class="inline-block">
|
||||
<input type="radio" name="scale_down" value="true" class="radio" checked />
|
||||
True
|
||||
</label>
|
||||
<label class="inline-block">
|
||||
<input type="radio" name="scale_down" value="false" class="radio" />
|
||||
False
|
||||
</label>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="btn btn-lg btn-primary preset-tonal-primary border border-primary-500"
|
||||
disabled={submit_status == 'clipping'}
|
||||
>
|
||||
<!-- {#await ae_promises[hosted_file_id]} -->
|
||||
{#if $ae_loc.files.processed_file_kv[hosted_file_id] && $ae_loc.files.processed_file_kv[hosted_file_id].submit_status == 'clipping'}
|
||||
<span class="fas fa-spinner fa-spin m-1"></span>
|
||||
<span class="highlight">Clipping...</span>
|
||||
{:else}
|
||||
<!-- {#if ae_promises[hosted_file_id]} -->
|
||||
{#if $ae_loc.files.processed_file_kv[hosted_file_id] && $ae_loc.files.processed_file_kv[hosted_file_id].submit_status == 'clipped'}
|
||||
<span class="fas fa-check m-1"></span>
|
||||
Clipped
|
||||
{:else}
|
||||
<span class="fas fa-cut m-1"></span>
|
||||
Clip Video
|
||||
{/if}
|
||||
{/if}
|
||||
<!-- <span class="fas fa-cut m-1"></span>
|
||||
Clip Video -->
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
{#await ae_promises[hosted_file_id]}
|
||||
<span class="fas fa-spinner fa-spin m-1"></span>
|
||||
<span class="highlight">Processing... This may take a few minutes.</span>
|
||||
{:then}
|
||||
{#if ae_promises[hosted_file_id]}
|
||||
<span class="fas fa-download"></span> Ready to download below!
|
||||
{:else}
|
||||
<!-- <p>Fill out the form and select the video file to clip.</p> -->
|
||||
{/if}
|
||||
{/await}
|
||||
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
<!-- <hr />
|
||||
|
||||
{#await ae_promises.upload__hosted_file_obj}
|
||||
<span class="fas fa-spinner fa-spin m-1"></span>
|
||||
<p class="highlight">Converting... This may take a few minutes.</p>
|
||||
{:then}
|
||||
{#if ae_promises.upload__hosted_file_obj}
|
||||
<a href={download_clip_src} download={download_clip_filename} class="ae_btn btn_lg btn_primary"><span class="fas fa-download"></span> Ready to Download</a>
|
||||
{:else}
|
||||
<p>Fill out the form and select the video file to clip.</p>
|
||||
{/if}
|
||||
{/await} -->
|
||||
|
||||
</section>
|
||||
@@ -1,88 +0,0 @@
|
||||
<script lang="ts">
|
||||
|
||||
// Imports
|
||||
// Import components and elements
|
||||
|
||||
// Import storage, functions, and libraries
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
|
||||
import { api } from '$lib/api';
|
||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
|
||||
|
||||
// Exports
|
||||
|
||||
// export let hosted_file_id_li: string[] = [];
|
||||
// export let hosted_file_obj_li: any[] = [];
|
||||
|
||||
interface Props {
|
||||
log_lvl?: number;
|
||||
// export let hosted_file_obj_kv: key_val = {};
|
||||
video_clip_file_kv?: key_val;
|
||||
class_li_default?: string;
|
||||
class_li?: string;
|
||||
link_to_type: string;
|
||||
link_to_id: string;
|
||||
}
|
||||
|
||||
let {
|
||||
log_lvl = 0,
|
||||
video_clip_file_kv = $bindable({}),
|
||||
class_li_default = 'flex flex-row flex-wrap gap-2 items-center justify-center w-full max-w-2xl p-2 mx-auto my-1 border border-gray-300 rounded-lg',
|
||||
class_li = '',
|
||||
link_to_type,
|
||||
link_to_id
|
||||
}: Props = $props();
|
||||
|
||||
let ae_promises: key_val = $state({});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<h3 class="h3">{Object.entries($ae_loc.files).length}× files clipped</h3>
|
||||
<div class="{class_li_default} {class_li} ">
|
||||
|
||||
{#each Object.entries(video_clip_file_kv) as [hosted_file_id, hosted_file_obj]}
|
||||
<button
|
||||
type="button"
|
||||
disabled={!$ae_loc.trusted_access}
|
||||
onclick={() => {
|
||||
ae_promises[hosted_file_id] = api.download_hosted_file({
|
||||
api_cfg: $ae_api,
|
||||
hosted_file_id: hosted_file_id,
|
||||
return_file: true,
|
||||
filename: hosted_file_obj.filename,
|
||||
auto_download: true,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
// window.postMessage({ type: 'download_event_file', hosted_file_id: idaa_archive_content_obj.hosted_file_id, filename: idaa_archive_content_obj.filename, auto_download: true }, '*');
|
||||
}}
|
||||
class="novi_btn btn btn-sm lg:btn-md preset-tonal-primary hover:preset-filled-primary-500 min-w-72 lg:min-w-96"
|
||||
title={`Download this file:\n${hosted_file_obj.filename}\n[API] SHA256: ${hosted_file_obj?.hash_sha256?.slice(0, 10)}... Hosted ID: ${hosted_file_obj.hosted_file_id_random}`}
|
||||
>
|
||||
|
||||
{#await ae_promises[hosted_file_id]}
|
||||
<span class="fas fa-spinner fa-spin mx-1"></span>
|
||||
<span class="">
|
||||
Downloading
|
||||
{#if $ae_sess.api_download_kv[hosted_file_id]}
|
||||
{$ae_sess.api_download_kv[hosted_file_id].percent_completed}%
|
||||
{/if}
|
||||
:
|
||||
</span>
|
||||
{:then}
|
||||
<span class="fas fa-{ae_util.file_extension_icon(hosted_file_obj?.file_extension)}"></span>
|
||||
{/await}
|
||||
|
||||
<span class="grow">
|
||||
{ae_util.shorten_filename({filename: hosted_file_obj?.filename, max_length: 30})}
|
||||
</span>
|
||||
|
||||
<span class="shrink">
|
||||
{ae_util.format_bytes(hosted_file_obj?.size)}
|
||||
</span>
|
||||
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
@@ -1,382 +0,0 @@
|
||||
<script lang="ts">
|
||||
export let log_lvl: number = 0;
|
||||
|
||||
// Imports
|
||||
// Import components and elements
|
||||
import Element_input_files_tbl from '$lib/element_input_files_tbl.svelte';
|
||||
|
||||
// Import storage, functions, and libraries
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
|
||||
import { api } from '$lib/api';
|
||||
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
|
||||
|
||||
// Exports
|
||||
// Expecting these for link_to_type: 'event', 'event_location', 'archive_content', etc
|
||||
export let link_to_type: string;
|
||||
export let link_to_id: string;
|
||||
|
||||
export let input_name = 'file_list';
|
||||
export let multiple: boolean = true;
|
||||
export let required: boolean = true;
|
||||
export let accept: string = 'audio/*, image/*, video/*, .bak, .cfg, .css, .csv, .doc, .docx, .gz, .htm, .html, .ini, .iso, .j2, .json, .key, .keynote, .md, .pdf, .ppt, .pptx, .rar, .rtf, .sql, .svelte, ttf, .txt, .xls, .xlsx, .xz, .zip, .bin, .dmg, .exe, .js, .msi, .php, .py, .sh';
|
||||
|
||||
export let class_li_default: string = 'flex flex-col gap-1 items-center justify-center w-full max-w-2xl mx-auto my-1';
|
||||
export let class_li: string = '';
|
||||
export let input_class_li: string[] = ['file_drop_area'];
|
||||
export let table_class_li: string[] = ['table', 'table-sm', 'table-striped', '' , 'text-sm'];
|
||||
|
||||
export let upload_complete: boolean = false;
|
||||
export let submit_status: null|string = null;
|
||||
|
||||
export let hosted_file_id_li: string[] = [];
|
||||
export let hosted_file_obj_li: any[] = [];
|
||||
|
||||
|
||||
// Local Variables
|
||||
let task_id = link_to_id;
|
||||
let input_file_list: any = null;
|
||||
let ae_promises: key_val = {}; // Promise<any>;
|
||||
let ae_triggers: key_val = {};
|
||||
|
||||
let input_element_id = 'ae_comp__hosted_files_upload__input';
|
||||
|
||||
let form_kv: key_val = {
|
||||
start_time: null,
|
||||
end_time: null,
|
||||
reencode: null,
|
||||
video_file: null,
|
||||
};
|
||||
let download_clip_src: string;
|
||||
let download_clip_filename: string;
|
||||
|
||||
// *** Functions and Logic
|
||||
async function handle_submit_form_files(event) {
|
||||
console.log('*** handle_submit_form() ***');
|
||||
|
||||
$ae_sess.files.disable_submit__hosted_file_obj = true;
|
||||
$ae_sess.files.submit_status = 'saving';
|
||||
submit_status = 'saving';
|
||||
upload_complete = false;
|
||||
|
||||
hosted_file_id_li = [];
|
||||
hosted_file_obj_li = [];
|
||||
|
||||
let hosted_file_results;
|
||||
|
||||
form_kv = {
|
||||
start_time: event.target.start_time.value,
|
||||
end_time: event.target.end_time.value,
|
||||
reencode: event.target.reencode.value,
|
||||
video_file: event.target.file_list.files[0],
|
||||
};
|
||||
|
||||
|
||||
// const form_data = new FormData();
|
||||
|
||||
// form_data.append('start_time', event.target.start_time.value);
|
||||
// form_data.append('end_time', event.target.end_time.value);
|
||||
|
||||
// if (event.target.reencode.value == '1' || event.target.reencode.value == 'true') {
|
||||
// form_data.append('reencode', 'true');
|
||||
// } else {
|
||||
// form_data.append('reencode', 'false');
|
||||
// }
|
||||
// form_data.append('reencode', event.target.reencode.value);
|
||||
|
||||
// form_data.append(`video_file`, event.target.video_file.files[0]);
|
||||
|
||||
// let download_filename = `clipped_file_test.mp4`;
|
||||
|
||||
// let params = null;
|
||||
|
||||
// let endpoint = '/hosted_file/clip_video';
|
||||
|
||||
// console.log(form_data);
|
||||
|
||||
// params = null;
|
||||
|
||||
|
||||
if (event.target[input_element_id].files.length > 0) {
|
||||
task_id = link_to_id; // Ideally this should be the file hash, but we may be uploading multiple files at once. This should be done with a loop instead?
|
||||
|
||||
// Loop through each file and upload them individually in event.target[input_element_id].files
|
||||
// The task_id should be the file hash.
|
||||
// processed_file_list[i] has the file hash_sha256, hash_sha256_match, warnings, uploaded, uploaded_bytes, filename, and file_size_bytes.
|
||||
for (let i = 0; i < event.target[input_element_id].files.length; i++) {
|
||||
let tmp_file = event.target[input_element_id].files[i];
|
||||
|
||||
task_id = $ae_sess.files.processed_file_list[i].hash_sha256;
|
||||
|
||||
hosted_file_results = await handle_input_upload_files([tmp_file], form_kv, task_id);
|
||||
|
||||
if (hosted_file_results) {
|
||||
console.log(`hosted_file_results:`, hosted_file_results);
|
||||
} else {
|
||||
console.log(`hosted_file_results:`, hosted_file_results);
|
||||
}
|
||||
}
|
||||
// hosted_file_results = await handle_input_upload_files(event.target[input_element_id].files, task_id);
|
||||
$ae_sess.files.processed_file_list = [];
|
||||
$ae_sess = $ae_sess;
|
||||
event.target.reset();
|
||||
// await tick();
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`hosted_file_id_li: ${hosted_file_id_li}`, hosted_file_id_li);
|
||||
} else if (log_lvl > 1) {
|
||||
console.log('hosted_file_results:', hosted_file_results);
|
||||
}
|
||||
}
|
||||
|
||||
$ae_sess.files.disable_submit__hosted_file_obj = false;
|
||||
$ae_sess.files.submit_status = 'saved';
|
||||
submit_status = 'saved';
|
||||
upload_complete = true;
|
||||
}
|
||||
|
||||
|
||||
async function handle_input_upload_files(input_upload_files, form_kv, task_id) {
|
||||
console.log('*** handle_input_upload_files() ***');
|
||||
console.log(input_upload_files);
|
||||
console.log(form_kv);
|
||||
|
||||
const form_data = new FormData();
|
||||
|
||||
// form_data.append('account_id', $ae_loc.account_id);
|
||||
// form_data.append('link_to_type', link_to_type);
|
||||
// form_data.append('link_to_id', link_to_id);
|
||||
|
||||
form_data.append('start_time', form_kv.start_time);
|
||||
form_data.append('end_time', form_kv.end_time);
|
||||
|
||||
if (form_kv.reencode == '1' || form_kv.reencode == 'true') {
|
||||
form_data.append('reencode', 'true');
|
||||
} else {
|
||||
form_data.append('reencode', 'false');
|
||||
}
|
||||
|
||||
// There should really only be one file uploaded at a time for now.
|
||||
for (let i = 0; i < input_upload_files.length; i++) {
|
||||
form_data.append(`video_file`, input_upload_files[i]);
|
||||
}
|
||||
|
||||
// hash_sha256, uploaded, uploaded_bytes
|
||||
// $ae_sess.files.processed_file_list[i] = {
|
||||
// ...$ae_sess.files.processed_file_list[i],
|
||||
// uploaded: $ae_sess.api_upload_kv[link_to_id].percent_completed,
|
||||
// uploaded_bytes: $ae_sess.api_upload_kv[link_to_id].uploaded_bytes,
|
||||
// };
|
||||
|
||||
let params = null;
|
||||
|
||||
let endpoint = '/hosted_file/clip_video';
|
||||
|
||||
console.log(form_data);
|
||||
|
||||
params = null;
|
||||
|
||||
// Uncomment and the post_promise is not seen by the "await" below
|
||||
// post_promise = await api.post_object({api_cfg: $cfg.api, endpoint: endpoint, params: params, data:form_data});
|
||||
// Uncomment so that the post_promise is not seen by the "await" below
|
||||
ae_promises.upload__hosted_file_obj = api.post_object({
|
||||
api_cfg: $ae_api,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
form_data: form_data,
|
||||
return_blob: true,
|
||||
filename: 'clipped_video_test.mp4',
|
||||
auto_download: false,
|
||||
task_id: task_id,
|
||||
log_lvl: log_lvl,
|
||||
// retry_count: 1,
|
||||
})
|
||||
.then(async function (result) {
|
||||
console.log(result);
|
||||
|
||||
let file_blob = new Blob([result.data]);
|
||||
// console.log(file_blob);
|
||||
let file_obj_url = window.URL.createObjectURL(file_blob); // The img src
|
||||
// const url = window.URL.createObjectURL(new Blob([result.data]));
|
||||
download_clip_src = file_obj_url;
|
||||
// download_filename = file_obj_url;
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
// // WARNING!!!! ONLY ONE FILE IS EXPECTED TO BE UPLOADED AT A TIME!!!
|
||||
// // NOTE: The /hosted_file/upload_files endpoint will always return a list of successful files uploaded. In this case we are only uploading one file and expecting a list of one item.
|
||||
// let x = 0;
|
||||
// console.log(result[x]);
|
||||
// let hosted_file_obj = result[x];
|
||||
|
||||
// let hosted_file_id = hosted_file_obj.hosted_file_id_random;
|
||||
|
||||
// hosted_file_id_li.push(hosted_file_id);
|
||||
// hosted_file_obj_li.push(hosted_file_obj);
|
||||
|
||||
// let hosted_file_data: key_val = {};
|
||||
// hosted_file_data['hosted_file_id_random'] = hosted_file_id;
|
||||
// hosted_file_data['for_type'] = link_to_type;
|
||||
// hosted_file_data['for_id_random'] = link_to_id;
|
||||
// hosted_file_data['filename'] = hosted_file_obj.filename;
|
||||
// hosted_file_data['extension'] = hosted_file_obj.extension;
|
||||
// hosted_file_data['enable'] = true;
|
||||
// console.log(hosted_file_data);
|
||||
|
||||
// return hosted_file_data;
|
||||
|
||||
// $ae_sess.files.new_upload_list[i].uploaded_bytes = 10; // fake 10 bytes at least...
|
||||
|
||||
// let event_file_id = await events_func.create_hosted_file_obj_from_hosted_file_async({
|
||||
// api_cfg: $ae_api,
|
||||
// hosted_file_id: hosted_file_id,
|
||||
// data: event_file_data,
|
||||
// log_lvl: log_lvl
|
||||
// })
|
||||
// .then(function (create_result) {
|
||||
// console.log(create_result); // NOTE: This should be the event_file_id string
|
||||
// // let event_file_id = create_result;
|
||||
// return create_result;
|
||||
// });
|
||||
|
||||
// return event_file_id;
|
||||
})
|
||||
// .then(function (hosted_file_data) {
|
||||
// return hosted_file_data;
|
||||
// })
|
||||
.catch(function (error) {
|
||||
console.log('Something went wrong.');
|
||||
console.log(error);
|
||||
return false;
|
||||
})
|
||||
.finally( function () {
|
||||
// $slct_trigger = 'load__hosted_file_obj_li';
|
||||
});
|
||||
|
||||
console.log(ae_promises.upload__hosted_file_obj);
|
||||
let hosted_file_result = ae_promises.upload__hosted_file_obj;
|
||||
|
||||
return hosted_file_result;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<div>
|
||||
<!-- class:hidden={!$ae_loc.trusted_access} -->
|
||||
<form
|
||||
on:submit|preventDefault={handle_submit_form_files}
|
||||
class="{class_li_default} {class_li}"
|
||||
>
|
||||
|
||||
<label class="label">Start time (HH:MM:SS) <input type="text" name="start_time" value="00:00:00" placeholder="HH:MM:SS (00:01:30)" class="input w-32" /></label>
|
||||
<label class="label">End time (HH:MM:SS) <input type="text" name="end_time" value="00:01:15" placeholder="HH:MM:SS (01:05:25)" class="input w-32" /></label>
|
||||
|
||||
<label class="label">Re-encode (true or false) <input type="text" name="reencode" value="false" placeholder="true" class="input w-32" /></label>
|
||||
|
||||
{#await ae_promises.upload__hosted_file_obj}
|
||||
<div class="text-lg flex flex-row gap-1 items-center justify-center">
|
||||
<span class="fas fa-spinner fa-spin m-1"></span>
|
||||
<span class="">
|
||||
Uploading
|
||||
{#if $ae_sess.api_upload_kv[task_id]}
|
||||
{$ae_sess.api_upload_kv[task_id].percent_completed}%
|
||||
{/if}
|
||||
</span>
|
||||
</div>
|
||||
{/await}
|
||||
|
||||
<label
|
||||
for="ae_comp__hosted_files_upload__input"
|
||||
class="svelte_input_file_label text-center"
|
||||
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
|
||||
>
|
||||
<slot name="label">
|
||||
<div>
|
||||
<span class="fas fa-upload"></span>
|
||||
<!-- Select files to upload -->
|
||||
<!-- <span class="fas fa-file-archive"></span> -->
|
||||
<strong class="bg-blue-300 p-1">Upload files</strong>
|
||||
<!-- (drag and drop) -->
|
||||
</div>
|
||||
<span class="text-sm text-gray-600 dark:text-gray-400 italic">
|
||||
<strong>Video files only</strong><br>
|
||||
(mp4 or mkv)
|
||||
</span>
|
||||
</slot>
|
||||
</label>
|
||||
|
||||
<input
|
||||
id={input_element_id}
|
||||
type="file"
|
||||
bind:files={input_file_list}
|
||||
{multiple}
|
||||
{required}
|
||||
{accept}
|
||||
name={input_name}
|
||||
class="svelte_input_file_element file-dropzone-input block w-full text-lg text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 dark:text-gray-400 focus:outline-hidden dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 {input_class_li.join(' ')}"
|
||||
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
|
||||
/>
|
||||
|
||||
<Element_input_files_tbl
|
||||
bind:input_file_list={input_file_list}
|
||||
|
||||
bind:file_list_status={$ae_sess.files.status__file_list}
|
||||
bind:processed_file_list={$ae_sess.files.processed_file_list}
|
||||
table_class_li={table_class_li}
|
||||
/>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="btn btn-lg btn-primary preset-tonal-primary border border-primary-500 hover:preset-tonal-success border border-success-500 w-54"
|
||||
disabled={$ae_sess.files.disable_submit__hosted_file_obj || $ae_sess.files.status__file_list != 'ready'}
|
||||
>
|
||||
{#await ae_promises.upload__hosted_file_obj}
|
||||
<span class="fas fa-spinner fa-spin m-1"></span>
|
||||
<span class="">
|
||||
Uploading
|
||||
{#if $ae_sess.api_upload_kv[task_id]}
|
||||
{$ae_sess.api_upload_kv[task_id].percent_completed}%
|
||||
{/if}
|
||||
</span>
|
||||
{:then}
|
||||
<span class="fas fa-upload m-1"></span>
|
||||
<span class="text-sm">
|
||||
Upload?
|
||||
</span>
|
||||
<!-- <span class="fas fa-save m-1"></span> -->
|
||||
<span class="grow font-bold">
|
||||
{#if $ae_sess.files.processed_file_list?.length > 0}
|
||||
<!-- {#each $ae_sess.files.processed_file_list as file_obj, index}
|
||||
<span class="text-xs">
|
||||
{file_obj.filename}
|
||||
</span>
|
||||
{/each} -->
|
||||
{$ae_sess.files.processed_file_list.length == 1 ? `${$ae_sess.files.processed_file_list.length} file` : `${$ae_sess.files.processed_file_list.length} files`}
|
||||
{:else}
|
||||
<span class="text-xs">
|
||||
No files selected
|
||||
</span>
|
||||
{/if}
|
||||
<!-- Files -->
|
||||
</span>
|
||||
{/await}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
{#await ae_promises.upload__hosted_file_obj}
|
||||
<span class="fas fa-spinner fa-spin m-1"></span>
|
||||
<p class="highlight">Converting... This may take a few minutes.</p>
|
||||
{:then}
|
||||
{#if ae_promises.upload__hosted_file_obj}
|
||||
<a href={download_clip_src} download={download_clip_filename} class="ae_btn btn_lg btn_primary"><span class="fas fa-download"></span> Ready to Download</a>
|
||||
{:else}
|
||||
<p>Fill out the form and select the video file to clip.</p>
|
||||
{/if}
|
||||
{/await}
|
||||
|
||||
</div>
|
||||
@@ -1,152 +0,0 @@
|
||||
<script lang="ts">
|
||||
// *** Import Svelte specific
|
||||
|
||||
// Eventually this should use Lucide icons instead of FontAwesome
|
||||
// import {
|
||||
// ArrowDown01, ArrowDown10, ArrowDownUp,
|
||||
// BookHeart, BriefcaseBusiness,
|
||||
// CalendarClock, CalendarOff, Clock, CodeXml, Copy,
|
||||
// Eye, EyeOff,
|
||||
// Flag, FlagOff, FileX, Fingerprint,
|
||||
// Globe, Group,
|
||||
// Hash, History,
|
||||
// LockKeyhole, LockKeyholeOpen,
|
||||
// MessageSquareWarning, Menu, Minus,
|
||||
// NotebookPen, NotebookText, NotepadTextDashed,
|
||||
// Pencil, PenLine, Plus,
|
||||
// RemoveFormatting,
|
||||
// Search, Settings,
|
||||
// Shapes, Share2, ShieldCheck, ShieldMinus, Siren, Skull,
|
||||
// SquareLibrary,
|
||||
// Tags, Trash2, TypeOutline,
|
||||
// X
|
||||
// } from '@lucide/svelte';
|
||||
|
||||
// *** Import Aether specific variables and functions
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||
import { api } from '$lib/api';
|
||||
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
|
||||
|
||||
interface Props {
|
||||
log_lvl?: number;
|
||||
hosted_file_id: null|string;
|
||||
hosted_file_obj: null|key_val;
|
||||
filename?: null|string;
|
||||
max_length?: number;
|
||||
auto_download?: boolean;
|
||||
linked_to_type?: null|string;
|
||||
linked_to_id?: null|string;
|
||||
download_complete?: null|boolean;
|
||||
download_percent?: number;
|
||||
download_status_msg?: string;
|
||||
classes?: string;
|
||||
}
|
||||
|
||||
let {
|
||||
log_lvl = 0,
|
||||
hosted_file_id,
|
||||
hosted_file_obj,
|
||||
filename = $bindable(null),
|
||||
max_length = $bindable(30),
|
||||
auto_download = true,
|
||||
linked_to_type = $bindable(null),
|
||||
linked_to_id = $bindable(null),
|
||||
download_complete = $bindable(),
|
||||
download_percent = $bindable(),
|
||||
download_status_msg = $bindable('Not started'),
|
||||
classes = 'btn btn-sm lg:btn-md preset-tonal-tertiary border border-tertiary-500 hover:preset-filled-tertiary-500 min-w-48'
|
||||
}: Props = $props();
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`ae_comp__hosted_files_download_button.svelte hosted_file_id=${hosted_file_id}`, hosted_file_obj);
|
||||
}
|
||||
|
||||
let ae_promises: key_val = $state({});
|
||||
|
||||
|
||||
$effect(() => {
|
||||
if ($ae_sess?.api_download_kv[hosted_file_obj?.hosted_file_id_random]?.percent_completed) {
|
||||
download_percent = $ae_sess.api_download_kv[hosted_file_obj?.hosted_file_id_random].percent_completed;
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
{#if hosted_file_id && hosted_file_obj}
|
||||
<button
|
||||
type="button"
|
||||
disabled={!$ae_loc.trusted_access}
|
||||
class="{classes ?? 'btn'}"
|
||||
onclick={() => {
|
||||
download_complete = false;
|
||||
download_status_msg = 'Downloading...';
|
||||
ae_promises[hosted_file_obj.hosted_file_id_random] = api.download_hosted_file({
|
||||
api_cfg: $ae_api,
|
||||
hosted_file_id: hosted_file_obj.hosted_file_id_random,
|
||||
return_file: true,
|
||||
filename: filename ?? hosted_file_obj.filename,
|
||||
auto_download: auto_download,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then((result) => {
|
||||
if (result === null) {
|
||||
console.log('File not found (404)');
|
||||
download_complete = null;
|
||||
download_status_msg = 'File not found';
|
||||
} else if (result === false) {
|
||||
console.log('Possible error with API server (check network and server status)');
|
||||
download_complete = false;
|
||||
download_status_msg = 'Failed to download';
|
||||
} else {
|
||||
// console.log('File found and downloaded');
|
||||
download_complete = true;
|
||||
download_status_msg = 'File downloaded';
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}}
|
||||
|
||||
title={`Download this file:\n${filename ?? hosted_file_obj?.filename}\n[API] SHA256: ${hosted_file_obj?.hash_sha256?.slice(0, 10)}...\nHosted ID: ${hosted_file_obj?.hosted_file_id_random}\n Linked to: ${linked_to_type} ID: ${linked_to_id}`}
|
||||
>
|
||||
{#await ae_promises[hosted_file_obj.hosted_file_id_random]}
|
||||
<span class="fas fa-spinner fa-spin mx-1"></span>
|
||||
<span class="">
|
||||
Downloading
|
||||
{#if $ae_sess.api_download_kv[hosted_file_obj.hosted_file_id_random]}
|
||||
{$ae_sess.api_download_kv[hosted_file_obj.hosted_file_id_random].percent_completed}%
|
||||
{/if}
|
||||
:
|
||||
</span>
|
||||
{:then}
|
||||
<span class="fas fa-{ae_util.file_extension_icon(hosted_file_obj?.extension)}"></span>
|
||||
|
||||
{/await}
|
||||
|
||||
{#if download_complete === null}
|
||||
<span class="text-red-800 dark:text-red-200">File not found</span>
|
||||
{:else if download_complete === false}
|
||||
<span class="text-red-800 dark:text-red-200">Failed to download!</span>
|
||||
{/if}
|
||||
|
||||
<span class="grow">
|
||||
{ae_util.shorten_filename({filename: filename ?? hosted_file_obj?.filename, max_length: max_length})}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
{:else}
|
||||
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
class="{classes ?? 'btn'}"
|
||||
title="No file selected"
|
||||
>
|
||||
<span class="fas fa-{ae_util.file_extension_icon(hosted_file_obj?.extension)}"></span>
|
||||
<span class="grow">
|
||||
No file info
|
||||
</span>
|
||||
</button>
|
||||
|
||||
{/if}
|
||||
@@ -1,320 +0,0 @@
|
||||
<script lang="ts">
|
||||
export let log_lvl: number = 0;
|
||||
|
||||
// Imports
|
||||
// Import components and elements
|
||||
import Element_input_files_tbl from '$lib/element_input_files_tbl.svelte';
|
||||
|
||||
// Import storage, functions, and libraries
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
|
||||
import { api } from '$lib/api';
|
||||
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
|
||||
|
||||
// Exports
|
||||
// Expecting these for link_to_type: 'event', 'event_location', 'archive_content', etc
|
||||
export let link_to_type: string;
|
||||
export let link_to_id: string;
|
||||
|
||||
export let input_name = 'file_list';
|
||||
export let multiple: boolean = true;
|
||||
export let required: boolean = true;
|
||||
export let accept: string = 'audio/*, image/*, video/*, .bak, .cfg, .css, .csv, .doc, .docx, .gz, .htm, .html, .ini, .iso, .j2, .json, .key, .keynote, .md, .pdf, .ppt, .pptx, .rar, .rtf, .sql, .svelte, ttf, .txt, .xls, .xlsx, .xz, .zip, .bin, .dmg, .exe, .js, .msi, .php, .py, .sh';
|
||||
|
||||
export let class_li_default: string = 'flex flex-col gap-1 items-center justify-center w-full max-w-2xl mx-auto my-1';
|
||||
export let class_li: string = '';
|
||||
export let input_class_li: string[] = ['file_drop_area'];
|
||||
export let table_class_li: string[] = ['table', 'table-sm', 'table-striped', '' , 'text-sm'];
|
||||
|
||||
export let upload_complete: boolean = false;
|
||||
export let submit_status: null|string = null;
|
||||
|
||||
export let hosted_file_id_li: string[] = [];
|
||||
export let hosted_file_obj_li: any[] = [];
|
||||
export let hosted_file_obj_kv: key_val = {};
|
||||
|
||||
|
||||
// Local Variables
|
||||
let task_id = link_to_id;
|
||||
let input_file_list: any = null;
|
||||
let ae_promises: key_val = {}; // Promise<any>;
|
||||
let ae_triggers: key_val = {};
|
||||
|
||||
let input_element_id = 'ae_comp__hosted_files_upload__input';
|
||||
|
||||
// *** Functions and Logic
|
||||
async function handle_submit_form_files(event: SubmitEvent) {
|
||||
console.log('*** handle_submit_form() ***');
|
||||
|
||||
if (!event) {
|
||||
return;
|
||||
}
|
||||
|
||||
$ae_sess.files.disable_submit__hosted_file_obj = true;
|
||||
$ae_sess.files.submit_status = 'saving';
|
||||
submit_status = 'saving';
|
||||
upload_complete = false;
|
||||
|
||||
hosted_file_id_li = [];
|
||||
hosted_file_obj_li = [];
|
||||
hosted_file_obj_kv = {};
|
||||
|
||||
let hosted_file_results;
|
||||
|
||||
const target = event.target as HTMLFormElement;
|
||||
if (target && target[input_element_id] && (target[input_element_id] as HTMLInputElement)?.files && (target[input_element_id] as HTMLInputElement).files.length > 0) {
|
||||
task_id = link_to_id; // Ideally this should be the file hash, but we may be uploading multiple files at once. This should be done with a loop instead?
|
||||
|
||||
// Loop through each file and upload them individually in event.target[input_element_id].files
|
||||
// The task_id should be the file hash.
|
||||
// processed_file_list[i] has the file hash_sha256, hash_sha256_match, warnings, uploaded, uploaded_bytes, filename, and file_size_bytes.
|
||||
for (let i = 0; i < event.target[input_element_id].files.length; i++) {
|
||||
let tmp_file = event.target[input_element_id].files[i];
|
||||
|
||||
task_id = $ae_sess.files.processed_file_list[i].hash_sha256;
|
||||
|
||||
// hosted_file_results = await handle_input_upload_files([tmp_file], task_id);
|
||||
hosted_file_results = await handle_input_upload_files({
|
||||
input_upload_files: [tmp_file],
|
||||
task_id: task_id
|
||||
});
|
||||
|
||||
if (hosted_file_results) {
|
||||
console.log(`hosted_file_results:`, hosted_file_results);
|
||||
} else {
|
||||
console.log(`hosted_file_results:`, hosted_file_results);
|
||||
}
|
||||
}
|
||||
// hosted_file_results = await handle_input_upload_files(event.target[input_element_id].files, task_id);
|
||||
$ae_sess.files.processed_file_list = [];
|
||||
$ae_sess = $ae_sess; // Is this needed? 2025-03-17
|
||||
event.target.reset();
|
||||
// await tick();
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`hosted_file_id_li: ${hosted_file_id_li}`, hosted_file_id_li);
|
||||
} else if (log_lvl > 1) {
|
||||
console.log('hosted_file_results:', hosted_file_results);
|
||||
}
|
||||
}
|
||||
|
||||
$ae_sess.files.disable_submit__hosted_file_obj = false;
|
||||
$ae_sess.files.submit_status = 'saved';
|
||||
submit_status = 'saved';
|
||||
upload_complete = true;
|
||||
}
|
||||
|
||||
|
||||
async function handle_input_upload_files(
|
||||
{
|
||||
input_upload_files,
|
||||
task_id
|
||||
} : {
|
||||
input_upload_files: any[],
|
||||
task_id: string
|
||||
}
|
||||
) {
|
||||
console.log('*** handle_input_upload_files() ***');
|
||||
|
||||
const form_data = new FormData();
|
||||
|
||||
form_data.append('account_id', $ae_loc.account_id);
|
||||
form_data.append('link_to_type', link_to_type);
|
||||
form_data.append('link_to_id', link_to_id);
|
||||
|
||||
for (let i = 0; i < input_upload_files.length; i++) {
|
||||
form_data.append(`file_list`, input_upload_files[i]);
|
||||
}
|
||||
|
||||
// hash_sha256, uploaded, uploaded_bytes
|
||||
// $ae_sess.files.processed_file_list[i] = {
|
||||
// ...$ae_sess.files.processed_file_list[i],
|
||||
// uploaded: $ae_sess.api_upload_kv[link_to_id].percent_completed,
|
||||
// uploaded_bytes: $ae_sess.api_upload_kv[link_to_id].uploaded_bytes,
|
||||
// };
|
||||
|
||||
let params = null;
|
||||
|
||||
let endpoint = '/hosted_file/upload_files';
|
||||
|
||||
console.log(form_data);
|
||||
|
||||
params = null;
|
||||
|
||||
// Uncomment and the post_promise is not seen by the "await" below
|
||||
// post_promise = await api.post_object({api_cfg: $cfg.api, endpoint: endpoint, params: params, data:form_data});
|
||||
// Uncomment so that the post_promise is not seen by the "await" below
|
||||
ae_promises.upload__hosted_file_obj = api.post_object({
|
||||
api_cfg: $ae_api,
|
||||
endpoint: endpoint,
|
||||
// params: params,
|
||||
form_data: form_data,
|
||||
task_id: task_id,
|
||||
log_lvl: log_lvl,
|
||||
// retry_count: 1,
|
||||
})
|
||||
.then(async function (result) {
|
||||
// WARNING!!!! ONLY ONE FILE IS EXPECTED TO BE UPLOADED AT A TIME!!!
|
||||
// NOTE: The /hosted_file/upload_files endpoint will always return a list of successful files uploaded. In this case we are only uploading one file and expecting a list of one item.
|
||||
let x = 0;
|
||||
console.log(result[x]);
|
||||
let hosted_file_obj = result[x];
|
||||
|
||||
let hosted_file_id = hosted_file_obj.hosted_file_id_random;
|
||||
|
||||
hosted_file_id_li.push(hosted_file_id);
|
||||
hosted_file_obj_li.push(hosted_file_obj);
|
||||
|
||||
let hosted_file_data: key_val = {};
|
||||
hosted_file_data['id'] = hosted_file_id;
|
||||
hosted_file_data['hosted_file_id'] = hosted_file_id;
|
||||
hosted_file_data['hosted_file_id_random'] = hosted_file_id;
|
||||
hosted_file_data['for_type'] = link_to_type;
|
||||
hosted_file_data['for_id'] = link_to_id;
|
||||
hosted_file_data['for_id_random'] = link_to_id;
|
||||
hosted_file_data['hash_sha256'] = hosted_file_obj.hash_sha256;
|
||||
hosted_file_data['filename'] = hosted_file_obj.filename;
|
||||
hosted_file_data['extension'] = hosted_file_obj.extension;
|
||||
hosted_file_data['content_type'] = hosted_file_obj.content_type;
|
||||
hosted_file_data['size'] = hosted_file_obj.size;
|
||||
hosted_file_data['enable'] = true;
|
||||
hosted_file_data['created_on'] = hosted_file_obj.created_on;
|
||||
hosted_file_data['updated_on'] = hosted_file_obj.updated_on;
|
||||
console.log(hosted_file_data);
|
||||
|
||||
hosted_file_obj_kv[hosted_file_id] = hosted_file_data;
|
||||
|
||||
return hosted_file_data;
|
||||
|
||||
// $ae_sess.files.new_upload_list[i].uploaded_bytes = 10; // fake 10 bytes at least...
|
||||
|
||||
// let event_file_id = await events_func.create_hosted_file_obj_from_hosted_file_async({
|
||||
// api_cfg: $ae_api,
|
||||
// hosted_file_id: hosted_file_id,
|
||||
// data: event_file_data,
|
||||
// log_lvl: log_lvl
|
||||
// })
|
||||
// .then(function (create_result) {
|
||||
// console.log(create_result); // NOTE: This should be the event_file_id string
|
||||
// // let event_file_id = create_result;
|
||||
// return create_result;
|
||||
// });
|
||||
|
||||
// return event_file_id;
|
||||
})
|
||||
.then(function (hosted_file_data) {
|
||||
return hosted_file_data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('Something went wrong.');
|
||||
console.log(error);
|
||||
return false;
|
||||
})
|
||||
.finally( function () {
|
||||
$slct_trigger = 'load__hosted_file_obj_li';
|
||||
});
|
||||
|
||||
console.log(ae_promises.upload__hosted_file_obj);
|
||||
let hosted_file_result = ae_promises.upload__hosted_file_obj;
|
||||
|
||||
return hosted_file_result;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<!-- class:hidden={!$ae_loc.trusted_access} -->
|
||||
<form
|
||||
on:submit|preventDefault={handle_submit_form_files}
|
||||
class="{class_li_default} {class_li}"
|
||||
>
|
||||
|
||||
{#await ae_promises.upload__hosted_file_obj}
|
||||
<div class="text-lg flex flex-row gap-1 items-center justify-center">
|
||||
<span class="fas fa-spinner fa-spin m-1"></span>
|
||||
<span class="">
|
||||
Uploading
|
||||
{#if $ae_sess.api_upload_kv[task_id]}
|
||||
{$ae_sess.api_upload_kv[task_id].percent_completed}%
|
||||
{/if}
|
||||
</span>
|
||||
</div>
|
||||
{/await}
|
||||
|
||||
<label
|
||||
for="ae_comp__hosted_files_upload__input"
|
||||
class="svelte_input_file_label text-center"
|
||||
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
|
||||
>
|
||||
<slot name="label">
|
||||
<div>
|
||||
<span class="fas fa-upload"></span>
|
||||
<!-- Select files to upload -->
|
||||
<!-- <span class="fas fa-file-archive"></span> -->
|
||||
<strong class="bg-blue-300 p-1">Upload files</strong>
|
||||
<!-- (drag and drop) -->
|
||||
</div>
|
||||
<span class="text-sm text-gray-600 dark:text-gray-400 italic">
|
||||
<strong>Presentation related files only</strong><br>
|
||||
(PowerPoint, Keynote, PDF, mp4, Word Doc, Excel, txt, etc)
|
||||
</span>
|
||||
</slot>
|
||||
</label>
|
||||
|
||||
<input
|
||||
id={input_element_id}
|
||||
type="file"
|
||||
bind:files={input_file_list}
|
||||
{multiple}
|
||||
{required}
|
||||
{accept}
|
||||
name={input_name}
|
||||
class="svelte_input_file_element file-dropzone-input block w-full text-lg text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 dark:text-gray-400 focus:outline-hidden dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 {input_class_li.join(' ')}"
|
||||
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
|
||||
/>
|
||||
|
||||
<Element_input_files_tbl
|
||||
bind:input_file_list={input_file_list}
|
||||
|
||||
bind:file_list_status={$ae_sess.files.status__file_list}
|
||||
bind:processed_file_list={$ae_sess.files.processed_file_list}
|
||||
table_class_li={table_class_li}
|
||||
/>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="btn btn-lg btn-primary preset-tonal-primary border border-primary-500 hover:preset-tonal-success border border-success-500 w-54"
|
||||
disabled={$ae_sess.files.disable_submit__hosted_file_obj || $ae_sess.files.status__file_list != 'ready'}
|
||||
>
|
||||
{#await ae_promises.upload__hosted_file_obj}
|
||||
<span class="fas fa-spinner fa-spin m-1"></span>
|
||||
<span class="">
|
||||
Uploading
|
||||
{#if $ae_sess.api_upload_kv[task_id]}
|
||||
{$ae_sess.api_upload_kv[task_id].percent_completed}%
|
||||
{/if}
|
||||
</span>
|
||||
{:then}
|
||||
<span class="fas fa-upload m-1"></span>
|
||||
<span class="text-sm">
|
||||
Upload?
|
||||
</span>
|
||||
<!-- <span class="fas fa-save m-1"></span> -->
|
||||
<span class="grow font-bold">
|
||||
{#if $ae_sess.files.processed_file_list?.length > 0}
|
||||
<!-- {#each $ae_sess.files.processed_file_list as file_obj, index}
|
||||
<span class="text-xs">
|
||||
{file_obj.filename}
|
||||
</span>
|
||||
{/each} -->
|
||||
{$ae_sess.files.processed_file_list.length == 1 ? `${$ae_sess.files.processed_file_list.length} file` : `${$ae_sess.files.processed_file_list.length} files`}
|
||||
{:else}
|
||||
<span class="text-xs">
|
||||
No files selected
|
||||
</span>
|
||||
{/if}
|
||||
<!-- Files -->
|
||||
</span>
|
||||
{/await}
|
||||
</button>
|
||||
</form>
|
||||
@@ -1,361 +0,0 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-10-23
|
||||
export async function load_ae_obj_id__activity_log(
|
||||
{
|
||||
api_cfg,
|
||||
activity_log_id,
|
||||
// inc_other_li = false,
|
||||
try_cache = false,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
activity_log_id: string,
|
||||
// inc_other_li?: boolean,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** load_ae_obj_id__activity_log() *** activity_log_id=${activity_log_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
ae_promises.load__activity_log_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'activity_log',
|
||||
obj_id: activity_log_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (activity_log_obj_get_result) {
|
||||
if (activity_log_obj_get_result) {
|
||||
// if (try_cache) {
|
||||
// // This is expecting a list
|
||||
// db_save_ae_obj_li__activity_log({
|
||||
// obj_type: 'activity_log',
|
||||
// obj_li: [activity_log_obj_get_result]
|
||||
// });
|
||||
// }
|
||||
return activity_log_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__activity_log_obj:', ae_promises.load__activity_log_obj);
|
||||
}
|
||||
|
||||
return ae_promises.load__activity_log_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-10-23
|
||||
export async function load_ae_obj_li__activity_log(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type = 'account',
|
||||
for_obj_id,
|
||||
// inc_other_li = false,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params = {},
|
||||
try_cache = false,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
// inc_other_li?: boolean,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** load_ae_obj_li__activity_log() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
ae_promises.load__activity_log_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'activity_log',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (activity_log_obj_li_get_result) {
|
||||
if (activity_log_obj_li_get_result) {
|
||||
// if (try_cache) {
|
||||
// db_save_ae_obj_li__activity_log({
|
||||
// obj_type: 'activity_log',
|
||||
// obj_li: activity_log_obj_li_get_result
|
||||
// });
|
||||
// }
|
||||
return activity_log_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__activity_log_obj_li:', ae_promises.load__activity_log_obj_li);
|
||||
}
|
||||
|
||||
return ae_promises.load__activity_log_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-10-23
|
||||
export async function create_ae_obj__activity_log(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** create_ae_obj__activity_log() *** account_id=${account_id}`);
|
||||
|
||||
ae_promises.create__activity_log = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'activity_log',
|
||||
fields: {
|
||||
account_id_random: account_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (activity_log_obj_create_result) {
|
||||
if (activity_log_obj_create_result) {
|
||||
// db_save_ae_obj_li__activity_log(
|
||||
// {
|
||||
// obj_type: 'activity_log',
|
||||
// obj_li: [activity_log_obj_create_result]
|
||||
// });
|
||||
return activity_log_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__activity_log:', ae_promises.create__activity_log);
|
||||
}
|
||||
return ae_promises.create__activity_log;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-10-23
|
||||
export async function update_ae_obj__activity_log(
|
||||
{
|
||||
api_cfg,
|
||||
activity_log_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = false,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
activity_log_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__activity_log() *** activity_log_id=${activity_log_id}`, data_kv);
|
||||
}
|
||||
ae_promises.update__activity_log_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'activity_log',
|
||||
obj_id: activity_log_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (activity_log_obj_update_result) {
|
||||
if (activity_log_obj_update_result) {
|
||||
// if (try_cache) {
|
||||
// db_save_ae_obj_li__activity_log({
|
||||
// obj_type: 'activity_log', obj_li: [activity_log_obj_update_result]
|
||||
// });
|
||||
// }
|
||||
return activity_log_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__activity_log_obj:', ae_promises.update__activity_log_obj);
|
||||
}
|
||||
return ae_promises.update__activity_log_obj;
|
||||
}
|
||||
|
||||
|
||||
// This new function is using CRUD v2. This should allow for more flexibility in the queries.
|
||||
// Updated 2024-10-23
|
||||
export async function qry__activity_log(
|
||||
{
|
||||
api_cfg,
|
||||
activity_log_id,
|
||||
qry_str,
|
||||
qry_files,
|
||||
qry_start_datetime, // Example greater than: '2024-10-24'
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 50,
|
||||
offset = 0,
|
||||
params = {},
|
||||
try_cache = false,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
activity_log_id: any,
|
||||
qry_str?: string,
|
||||
qry_files?: null|boolean,
|
||||
qry_start_datetime?: null|string, // Greater than this datetime
|
||||
enabled?: string, // all, disabled, enabled
|
||||
hidden?: string, // all, hidden, not_hidden
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
params?: any,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** qry__activity_log() *** activity_log_id=${activity_log_id} qry_str=${qry_str}`);
|
||||
|
||||
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
// let limit: number = (params.qry__limit ?? 25); // 99
|
||||
// let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// if (qry_str && qry_str.length > 2) {
|
||||
// params_json['ft_qry'] = {};
|
||||
// params_json['ft_qry']['default_qry_str'] = qry_str;
|
||||
// }
|
||||
|
||||
params_json['qry'] = [];
|
||||
|
||||
if (qry_files === true) {
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "file_count_all",
|
||||
operator: ">",
|
||||
value: 0
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
} else if (qry_files === false) {
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "file_count_all",
|
||||
operator: "IS",
|
||||
value: null
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
}
|
||||
|
||||
if (qry_start_datetime) {
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "start_datetime",
|
||||
operator: ">",
|
||||
value: qry_start_datetime
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
}
|
||||
|
||||
let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
|
||||
|
||||
ae_promises.load__activity_log_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'activity_log',
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: activity_log_id,
|
||||
use_alt_tbl: true, // NOTE: We want to use the alt table for activity_log searching
|
||||
use_alt_mdl: false,
|
||||
use_alt_exp: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (activity_log_obj_li_get_result) {
|
||||
if (activity_log_obj_li_get_result) {
|
||||
// db_save_ae_obj_li__activity_log({
|
||||
// obj_type: 'activity_log',
|
||||
// obj_li: activity_log_obj_li_get_result
|
||||
// });
|
||||
return activity_log_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__activity_log_obj_li:', ae_promises.load__activity_log_obj_li);
|
||||
}
|
||||
return ae_promises.load__activity_log_obj_li;
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
|
||||
|
||||
// Updated 2025-01-28
|
||||
export function add_url_params(
|
||||
{
|
||||
base_url = '',
|
||||
endpoint,
|
||||
params,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
base_url?: string,
|
||||
endpoint: string,
|
||||
params: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** add_url_params() *** base_url=${base_url} endpoint=${endpoint}`, params);
|
||||
}
|
||||
|
||||
const url_obj = new URL(endpoint, base_url);
|
||||
|
||||
Object.keys(params).forEach(key => url_obj.searchParams.append(key, params[key]));
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('New URL:', url_obj.toString());
|
||||
}
|
||||
|
||||
return url_obj.toString();
|
||||
// return 'test';
|
||||
}
|
||||
|
||||
|
||||
// This is used to clean the header property names. Not underscores allowed in the header names.
|
||||
// Updated 2025-01-28
|
||||
export function clean_headers(
|
||||
{
|
||||
headers,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
headers: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** clean_headers() ***`, headers);
|
||||
}
|
||||
|
||||
let headers_cleaned: key_val = {};
|
||||
for (const prop in headers) {
|
||||
let prop_cleaned = prop.replaceAll('_', '-');
|
||||
if (typeof headers[prop] != 'string') {
|
||||
headers[prop] = JSON.stringify(headers[prop]);
|
||||
}
|
||||
headers_cleaned[prop_cleaned] = headers[prop];
|
||||
if (log_lvl > 1) {
|
||||
console.log(`${prop_cleaned}: ${headers_cleaned[prop_cleaned]}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Object.keys(headers).forEach(key => {
|
||||
// if (headers[key]) {
|
||||
// headers_cleaned[key] = headers[key];
|
||||
// }
|
||||
// });
|
||||
|
||||
return headers_cleaned;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
|
||||
// Updated 2024-10-02
|
||||
export async function check_hosted_file_obj_w_hash(
|
||||
{
|
||||
api_cfg,
|
||||
hosted_file_hash,
|
||||
check_for_local = true, // Forces a check on the host server for the file.
|
||||
params = {},
|
||||
return_meta = false,
|
||||
log_lvl = 0
|
||||
} : {
|
||||
api_cfg: any,
|
||||
hosted_file_hash: string,
|
||||
check_for_local?: boolean,
|
||||
params?: key_val,
|
||||
return_meta?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log('*** stores_event_api.js: check_hosted_file_obj_w_hash() ***');
|
||||
|
||||
const endpoint = `/hosted_file/hash/${hosted_file_hash}`;
|
||||
if (check_for_local) {
|
||||
params['check_for_local'] = true;
|
||||
}
|
||||
let check_hosted_file_obj_w_hash_get_promise = await api.get_object({
|
||||
api_cfg: api_cfg,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
return_meta: return_meta,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
return check_hosted_file_obj_w_hash_get_promise;
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_core } from "$lib/ae_core/db_core";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-10-14
|
||||
export async function load_ae_obj_li__country(
|
||||
{
|
||||
api_cfg,
|
||||
// account_id,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 299,
|
||||
offset = 0,
|
||||
order_by_li = {'sort': 'DESC', 'english_short_name': 'ASC', 'alpha_2_code': 'ASC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
// account_id: string,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
order_by_li?: key_val
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__country() ***`);
|
||||
}
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
ae_promises.load__country_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'lu',
|
||||
for_obj_type: 'country',
|
||||
// for_obj_id: account_id,
|
||||
use_alt_tbl: false,
|
||||
use_alt_mdl: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (country_li_get_result) {
|
||||
if (country_li_get_result) {
|
||||
// handle_db_save_ae_obj_li__country({obj_type: 'country', obj_li: country_li_get_result});
|
||||
return country_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
console.log('ae_promises.load__country_li:', ae_promises.load__country_li);
|
||||
return ae_promises.load__country_li;
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_core } from "$lib/ae_core/db_core";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-10-14
|
||||
export async function load_ae_obj_li__country_subdivision(
|
||||
{
|
||||
api_cfg,
|
||||
// account_id,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 399,
|
||||
offset = 0,
|
||||
order_by_li = {'sort': 'DESC', 'name': 'ASC', 'code': 'ASC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
// account_id: string,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
order_by_li?: key_val
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__country_subdivision() ***`);
|
||||
}
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
ae_promises.load__country_subdivision_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'lu',
|
||||
for_obj_type: 'country_subdivision',
|
||||
// for_obj_id: account_id,
|
||||
use_alt_tbl: false,
|
||||
use_alt_mdl: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (country_subdivision_li_get_result) {
|
||||
if (country_subdivision_li_get_result) {
|
||||
// handle_db_save_ae_obj_li__country_subdivision({obj_type: 'country_subdivision', obj_li: country_subdivision_li_get_result});
|
||||
return country_subdivision_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
console.log('ae_promises.load__country_subdivision_li:', ae_promises.load__country_subdivision_li);
|
||||
return ae_promises.load__country_subdivision_li;
|
||||
}
|
||||
@@ -1,443 +0,0 @@
|
||||
import { marked } from 'marked';
|
||||
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
||||
|
||||
// Define generic CRUD args
|
||||
export interface GenericCrudArgs {
|
||||
api_cfg: any;
|
||||
obj_type: string;
|
||||
obj_id?: string;
|
||||
for_obj_type?: string;
|
||||
for_obj_id?: string;
|
||||
|
||||
db_instance?: any; // Optional DB instance for caching
|
||||
db_field_li?: string[]; // Optional list of fields to save in DB
|
||||
|
||||
// Flags to include related core object models
|
||||
inc_account_li?: boolean;
|
||||
inc_address_li?: boolean;
|
||||
inc_contact_li?: boolean;
|
||||
inc_person_li?: boolean;
|
||||
inc_site_li?: boolean;
|
||||
inc_site_domain_li?: boolean;
|
||||
inc_user_li?: boolean;
|
||||
|
||||
|
||||
// Flags to include related other object models
|
||||
inc_archive_li?: boolean;
|
||||
inc_archive_entry_li?: boolean;
|
||||
inc_event_li?: boolean;
|
||||
inc_event_session_li?: boolean;
|
||||
inc_post_li?: boolean;
|
||||
inc_post_comment_li?: boolean;
|
||||
inc_journal_li?: boolean;
|
||||
inc_journal_entry_li?: boolean;
|
||||
|
||||
inc_obj_type_li?: string[]; // Optional list of object types to include
|
||||
|
||||
data_kv?: key_val;
|
||||
enabled?: 'enabled' | 'disabled' | 'all';
|
||||
hidden?: 'not_hidden' | 'hidden' | 'all';
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
order_by_li?: key_val;
|
||||
params?: key_val;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}
|
||||
|
||||
// Generic function: Load single object by ID
|
||||
export async function load_ae_obj_id(
|
||||
args: GenericCrudArgs
|
||||
): Promise<any> {
|
||||
const { api_cfg, obj_type, obj_id, db_instance, db_field_li, inc_obj_type_li, try_cache = true, log_lvl = 0 } = args;
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id() *** obj_type=${obj_type} obj_id=${obj_id}`);
|
||||
}
|
||||
|
||||
let result = await api.get_ae_obj_id_crud({
|
||||
api_cfg,
|
||||
obj_type,
|
||||
obj_id,
|
||||
params: {},
|
||||
log_lvl
|
||||
});
|
||||
|
||||
let idb_db_instance = null; // You must inject the correct DB instance per module
|
||||
let idb_tbl_name = obj_type;
|
||||
let properties_to_save: string[] = [];
|
||||
if (obj_type === 'journal') {
|
||||
idb_db_instance = 'ae_journals_db';
|
||||
// idb_tbl_name = 'journal';
|
||||
|
||||
result.id = result.journal_id_random; // Ensure we use the correct ID field
|
||||
result.journal_id = result.journal_id_random;
|
||||
result.account_id = result.account_id_random;
|
||||
result.person_id = result.person_id_random;
|
||||
|
||||
// WARNING: This works to populate most of the IDB table fields but it is not ideal. It is sort of a safety net.
|
||||
properties_to_save = Object.keys(db_instance.table('journal').schema.idxByName);
|
||||
}
|
||||
if (obj_type === 'journal_entry') {
|
||||
idb_db_instance = 'ae_journals_db';
|
||||
// idb_tbl_name = 'entry';
|
||||
|
||||
result.id = result.journal_entry_id_random; // Ensure we use the correct ID field
|
||||
result.journal_entry_id = result.journal_entry_id_random; // Ensure we use the correct ID field
|
||||
result.journal_id = result.journal_id_random;
|
||||
|
||||
// WARNING: This works to populate most of the IDB table fields but it is not ideal. It is sort of a safety net.
|
||||
properties_to_save = Object.keys(db_instance.table('journal_entry').schema.idxByName);
|
||||
|
||||
}
|
||||
properties_to_save = [
|
||||
...db_field_li
|
||||
];
|
||||
|
||||
// if (log_lvl) {
|
||||
// console.log('IDB DB Instance:', db_instance);
|
||||
// console.log(db_instance.journal_entry.core.schema);
|
||||
// console.log(db_instance.table('journal_entry'));
|
||||
// console.log(db_instance.table('journal_entry').schema.idxByName);
|
||||
// // Show only the keys of the indexes
|
||||
// console.log(Object.keys(db_instance.table('journal_entry').schema.idxByName));
|
||||
// }
|
||||
|
||||
if (try_cache && result) {
|
||||
// Process and save to DB
|
||||
const processed = await process_ae_obj__props({ obj_li: [result], log_lvl });
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_instance, // You must inject the correct DB instance per module
|
||||
table_name: idb_tbl_name,
|
||||
obj_li: processed,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
if (inc_obj_type_li) {
|
||||
// Load related objects if specified
|
||||
for (const inc_obj_type of inc_obj_type_li) {
|
||||
if (log_lvl) {
|
||||
console.log(`Loading related objects of type: ${inc_obj_type}`);
|
||||
}
|
||||
const related_objects = await load_ae_obj_li({
|
||||
api_cfg,
|
||||
obj_type: inc_obj_type,
|
||||
for_obj_type: obj_type,
|
||||
for_obj_id: obj_id,
|
||||
enabled: 'enabled',
|
||||
hidden: 'not_hidden',
|
||||
limit: 99,
|
||||
try_cache,
|
||||
log_lvl
|
||||
});
|
||||
result[`${inc_obj_type}_li`] = related_objects;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Generic function: Load list of objects
|
||||
export async function load_ae_obj_li(
|
||||
args: GenericCrudArgs
|
||||
): Promise<any> {
|
||||
const {
|
||||
api_cfg,
|
||||
obj_type,
|
||||
for_obj_type = '',
|
||||
for_obj_id,
|
||||
db_instance,
|
||||
db_field_li,
|
||||
inc_obj_type_li,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
order_by_li = {},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
} = args;
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li() *** obj_type=${obj_type} for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
}
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
let result = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg,
|
||||
obj_type,
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
enabled,
|
||||
hidden,
|
||||
order_by_li,
|
||||
limit,
|
||||
offset,
|
||||
params_json: {},
|
||||
params,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
// Loop through results a
|
||||
let idb_db_instance = null; // You must inject the correct DB instance per module
|
||||
let idb_tbl_name = obj_type;
|
||||
let properties_to_save: string[] = [];
|
||||
if (obj_type === 'journal') {
|
||||
idb_db_instance = 'ae_journals_db';
|
||||
// idb_tbl_name = 'journal';
|
||||
|
||||
result.id = result.journal_id_random; // Ensure we use the correct ID field
|
||||
result.journal_id = result.journal_id_random;
|
||||
result.account_id = result.account_id_random;
|
||||
result.person_id = result.person_id_random;
|
||||
|
||||
// WARNING: This works to populate most of the IDB table fields but it is not ideal. It is sort of a safety net.
|
||||
properties_to_save = Object.keys(db_instance.table('journal').schema.idxByName);
|
||||
}
|
||||
if (obj_type === 'journal_entry') {
|
||||
idb_db_instance = 'ae_journals_db';
|
||||
// idb_tbl_name = 'entry';
|
||||
|
||||
result.id = result.journal_entry_id_random; // Ensure we use the correct ID field
|
||||
result.journal_entry_id = result.journal_entry_id_random; // Ensure we use the correct ID field
|
||||
result.journal_id = result.journal_id_random;
|
||||
|
||||
// WARNING: This works to populate most of the IDB table fields but it is not ideal. It is sort of a safety net.
|
||||
properties_to_save = Object.keys(db_instance.table('journal_entry').schema.idxByName);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (try_cache && result) {
|
||||
// Process and save to DB
|
||||
const processed = await process_ae_obj__props({ obj_li: result, log_lvl });
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_instance,
|
||||
table_name: idb_tbl_name,
|
||||
obj_li: processed,
|
||||
properties_to_save: [],
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Generic function: Create object
|
||||
export async function create_ae_obj(
|
||||
args: GenericCrudArgs
|
||||
): Promise<any> {
|
||||
const { api_cfg, obj_type, data_kv, try_cache = true, log_lvl = 0 } = args;
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`*** create_ae_obj() *** obj_type=${obj_type}`, data_kv);
|
||||
}
|
||||
|
||||
let result = await api.create_ae_obj_crud({
|
||||
api_cfg,
|
||||
obj_type,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: {},
|
||||
return_obj: true,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (try_cache && result) {
|
||||
const processed = await process_ae_obj__props({ obj_li: [result], log_lvl });
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: null,
|
||||
table_name: obj_type,
|
||||
obj_li: processed,
|
||||
properties_to_save: [],
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Generic function: Update object
|
||||
export async function update_ae_obj(
|
||||
args: GenericCrudArgs
|
||||
): Promise<any> {
|
||||
const { api_cfg, obj_type, obj_id, data_kv, try_cache = true, log_lvl = 0 } = args;
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj() *** obj_type=${obj_type} obj_id=${obj_id}`, data_kv);
|
||||
}
|
||||
|
||||
let result = await api.update_ae_obj_id_crud({
|
||||
api_cfg,
|
||||
obj_type,
|
||||
obj_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: {},
|
||||
return_obj: true,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (try_cache && result) {
|
||||
const processed = await process_ae_obj__props({ obj_li: [result], log_lvl });
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: null,
|
||||
table_name: obj_type,
|
||||
obj_li: processed,
|
||||
properties_to_save: [],
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Generic function: Delete object
|
||||
export async function delete_ae_obj_id(
|
||||
args: GenericCrudArgs
|
||||
): Promise<any> {
|
||||
const { api_cfg, obj_type, obj_id, method = 'delete', try_cache = true, log_lvl = 0 } = args;
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`*** delete_ae_obj_id() *** obj_type=${obj_type} obj_id=${obj_id}`);
|
||||
}
|
||||
|
||||
let result = await api.delete_ae_obj_id_crud({
|
||||
api_cfg,
|
||||
obj_type,
|
||||
obj_id,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: {},
|
||||
method,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (try_cache) {
|
||||
// Remove from DB regardless of success/failure
|
||||
try {
|
||||
// db_<module>.<obj_type>.delete(obj_id); // You must inject the correct DB here
|
||||
} catch (err) {
|
||||
console.error(`Failed to delete ${obj_id}:`, err);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Generic processor with dynamic field detection
|
||||
export async function process_ae_obj__props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__props() ***`, obj_li);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed = obj_li.map(obj => {
|
||||
// Extract fields with fallbacks and detect existence
|
||||
const group = obj.group || '';
|
||||
const priority = obj.priority !== undefined ? obj.priority : 0;
|
||||
const sort = obj.sort !== undefined ? obj.sort : 0;
|
||||
const created_on = obj.created_on || '';
|
||||
const updated_on = obj.updated_on || '';
|
||||
const name = obj.name || '';
|
||||
|
||||
// const description = obj.description || '';
|
||||
// // Handle special case with description that has markdown
|
||||
// // Remove the most common zerowidth characters from the start of the file
|
||||
// const description_cleaned: string = obj.description.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,"");
|
||||
// const description_md_html: null|string = marked.parse(description_cleaned ?? '') ?? null;
|
||||
// // Add processed description
|
||||
// obj.description_md_html = description_md_html;
|
||||
|
||||
// Handle special case with content that has markdown
|
||||
// Remove the most common zerowidth characters from the start of the file
|
||||
const has_content = obj.content !== undefined && obj.content !== null;
|
||||
if (has_content) {
|
||||
const content_cleaned: string = obj.content.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,"");
|
||||
const content_md_html: null|string = marked.parse(content_cleaned ?? '') ?? null;
|
||||
// Add processed content
|
||||
obj.content_md_html = content_md_html;
|
||||
}
|
||||
|
||||
// Check which fields actually exist for this object
|
||||
const has_group = obj.group !== undefined && obj.group !== null;
|
||||
const has_priority = obj.priority !== undefined && obj.priority !== null;
|
||||
const has_sort = obj.sort !== undefined && obj.sort !== null;
|
||||
const has_created = obj.created_on !== undefined && obj.created_on !== null;
|
||||
const has_updated = obj.updated_on !== undefined && obj.updated_on !== null;
|
||||
const has_name = obj.name !== undefined && obj.name !== null;
|
||||
|
||||
// Generate standardized tmp_sort fields with proper zero-padding
|
||||
const sort_str = sort?.toString().padStart(3, '0') ?? '000';
|
||||
|
||||
// Build dynamic sorting combinations based on what exists
|
||||
let tmp_sort_1 = '';
|
||||
let tmp_sort_2 = '';
|
||||
let tmp_sort_3 = '';
|
||||
|
||||
// Build based on existing fields
|
||||
if (has_group && has_priority && has_sort) {
|
||||
tmp_sort_1 = `${group}_${priority}_${sort_str}`;
|
||||
tmp_sort_2 = `${group}_${priority}_${sort_str}_${name || ''}`;
|
||||
tmp_sort_3 = `${priority}_${sort_str}_${group}`;
|
||||
} else if (has_priority && has_sort) {
|
||||
tmp_sort_1 = `${priority}_${sort_str}`;
|
||||
tmp_sort_2 = `${priority}_${sort_str}_${name || ''}`;
|
||||
tmp_sort_3 = `${priority}_${sort_str}`;
|
||||
} else if (has_sort) {
|
||||
tmp_sort_1 = `${sort_str}`;
|
||||
tmp_sort_2 = `${sort_str}_${name || ''}`;
|
||||
tmp_sort_3 = `${sort_str}`;
|
||||
} else {
|
||||
// Fallback for minimal data
|
||||
tmp_sort_1 = `${created_on || ''}`;
|
||||
tmp_sort_2 = `${created_on || ''}_${name || ''}`;
|
||||
tmp_sort_3 = `${updated_on || ''}`;
|
||||
}
|
||||
|
||||
// Add time-based sorting for better ordering
|
||||
if (has_created && has_updated) {
|
||||
tmp_sort_1 += `_${created_on}_${updated_on}`;
|
||||
tmp_sort_2 += `_${created_on}_${updated_on}`;
|
||||
tmp_sort_3 += `_${updated_on}`;
|
||||
} else if (has_created) {
|
||||
tmp_sort_1 += `_${created_on}`;
|
||||
tmp_sort_2 += `_${created_on}`;
|
||||
tmp_sort_3 += `_${created_on}`;
|
||||
}
|
||||
|
||||
// Return processed object with standardized fields
|
||||
return {
|
||||
...obj,
|
||||
tmp_sort_1,
|
||||
tmp_sort_2,
|
||||
tmp_sort_3
|
||||
};
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`Processed objects:`, processed);
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
@@ -1,357 +0,0 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_core } from "$lib/ae_core/db_core";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-06-14
|
||||
export async function load_ae_obj_id__hosted_file(
|
||||
{
|
||||
api_cfg,
|
||||
hosted_file_id,
|
||||
try_cache = false,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
hosted_file_id: string,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__hosted_file() *** hosted_file_id=${hosted_file_id}`);
|
||||
}
|
||||
|
||||
let params = {};
|
||||
|
||||
ae_promises.load__hosted_file_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'hosted_file',
|
||||
obj_id: hosted_file_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (hosted_file_obj_get_result) {
|
||||
if (hosted_file_obj_get_result) {
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__hosted_file({obj_type: 'hosted_file', obj_li: [hosted_file_obj_get_result]});
|
||||
return hosted_file_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
return ae_promises.load__hosted_file_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-07-03
|
||||
export async function load_ae_obj_li__hosted_file(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__hosted_file() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
}
|
||||
|
||||
// Check if for_obj_type is in the list of valid Aether object types:
|
||||
let valid_for_obj_types = ['account', 'archive', 'archive_content', 'event', 'event_session', 'event_presentation', 'event_presenter', 'event_location', 'journal', 'journal_entry', 'post', 'post_comment'];
|
||||
if (!valid_for_obj_types.includes(for_obj_type)) {
|
||||
console.log(`Invalid for_obj_type: ${for_obj_type}`);
|
||||
return [];
|
||||
}
|
||||
|
||||
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
// let hidden: string = (params.qry__hidden ?? 'all'); // all, hidden, not_hidden
|
||||
// let limit: number = (params.qry__limit ?? 99); // 99
|
||||
// let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
ae_promises.load__hosted_file_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'hosted_file',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: false,
|
||||
use_alt_mdl: false,
|
||||
use_alt_exp: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (hosted_file_obj_li_get_result) {
|
||||
if (hosted_file_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__hosted_file({
|
||||
obj_type: 'hosted_file',
|
||||
obj_li: hosted_file_obj_li_get_result,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
return hosted_file_obj_li_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__hosted_file_obj_li:', ae_promises.load__hosted_file_obj_li);
|
||||
}
|
||||
return ae_promises.load__hosted_file_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-11-07
|
||||
export async function delete_ae_obj_id__hosted_file(
|
||||
{
|
||||
api_cfg,
|
||||
hosted_file_id,
|
||||
link_to_type, // Ideally this should be required...
|
||||
link_to_id, // Ideally this should be required...
|
||||
rm_orphan = false,
|
||||
fake_delete = false, // Fake the delete result to "true"
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
hosted_file_id: string,
|
||||
link_to_type: string,
|
||||
link_to_id: string,
|
||||
rm_orphan?: boolean,
|
||||
fake_delete?: boolean,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** delete_ae_obj_id__hosted_file() *** hosted_file_id=${hosted_file_id}`);
|
||||
}
|
||||
|
||||
const endpoint = `/hosted_file/${hosted_file_id}`;
|
||||
|
||||
params['link_to_type'] = link_to_type;
|
||||
params['link_to_id'] = link_to_id;
|
||||
params['rm_orphan'] = rm_orphan; // This is what actually allows the hosted file to be deleted from the server.
|
||||
if (log_lvl) {
|
||||
console.log(`delete_ae_obj_id__hosted_file() params=`, params);
|
||||
}
|
||||
|
||||
if (fake_delete) {
|
||||
console.log(`*** FAKE DELETE!!! ***`);
|
||||
ae_promises.delete__hosted_file_obj = true;
|
||||
return ae_promises.delete__hosted_file_obj;
|
||||
}
|
||||
|
||||
ae_promises.delete__hosted_file_obj = await api.delete_object({
|
||||
api_cfg: api_cfg,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
// return_meta: return_meta,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (hosted_file_obj_li_get_result) {
|
||||
if (hosted_file_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
if (log_lvl) {
|
||||
console.log(`Attempting to remove IDB entry for hosted_file_id=${hosted_file_id}`);
|
||||
}
|
||||
db_core.file.delete(hosted_file_id); // Delete from the DB no matter what.
|
||||
}
|
||||
return hosted_file_obj_li_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.delete__hosted_file_obj:', ae_promises.delete__hosted_file_obj);
|
||||
}
|
||||
|
||||
return ae_promises.delete__hosted_file_obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This function will loop through the hosted_file_obj_li and save each one to the DB.
|
||||
// Updated 2025-01-07
|
||||
export function db_save_ae_obj_li__hosted_file(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__hosted_file() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_core.file.put({
|
||||
id: obj.hosted_file_id_random,
|
||||
id_random: obj.hosted_file_id_random,
|
||||
hosted_file_id: obj.hosted_file_id_random,
|
||||
hosted_file_id_random: obj.hosted_file_id_random,
|
||||
|
||||
hash_sha256: obj.hash_sha256, // Renamed with alias in FastAPI model
|
||||
|
||||
for_type: obj.for_type,
|
||||
for_id: obj.for_id_id_random,
|
||||
for_id_random: obj.for_id_random,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
|
||||
filename: obj.filename,
|
||||
extension: obj.extension,
|
||||
content_type: obj.content_type,
|
||||
size: obj.size,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
// priority: obj.priority,
|
||||
// sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
filename_no_ext: obj.filename_no_ext,
|
||||
filename_w_ext: obj.filename_w_ext,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.hosted_file_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.hosted_file_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_core.file.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.hosted_file_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-01-07
|
||||
export function db_update_ae_obj_id__hosted_file(
|
||||
{
|
||||
obj_type,
|
||||
obj_id,
|
||||
data_kv,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_id: string,
|
||||
data_kv: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_update_ae_obj_id__hosted_file() ***`);
|
||||
}
|
||||
|
||||
if (obj_id) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj_id);
|
||||
|
||||
try {
|
||||
// db_core.file.update(obj_id, data_kv);
|
||||
db_core.file.update(obj_id,
|
||||
{
|
||||
// for_type: data_kv.for_type,
|
||||
// for_id: data_kv.for_id_id_random,
|
||||
// for_id_random: data_kv.for_id_random,
|
||||
|
||||
filename: data_kv.filename,
|
||||
extension: data_kv.extension,
|
||||
content_type: data_kv.content_type,
|
||||
size: data_kv.size,
|
||||
|
||||
// enable: data_kv.enable,
|
||||
// hide: data_kv.hide,
|
||||
// priority: data_kv.priority,
|
||||
// sort: data_kv.sort,
|
||||
// group: data_kv.group,
|
||||
// notes: data_kv.notes,
|
||||
// created_on: data_kv.created_on,
|
||||
// updated_on: data_kv.updated_on,
|
||||
|
||||
filename_no_ext: data_kv.filename_no_ext,
|
||||
filename_w_ext: data_kv.filename_w_ext,
|
||||
// hosted_file_content_type: data_kv.hosted_file_content_type,
|
||||
// file_size: data_kv.file_size,
|
||||
// hosted_file_size: data_kv.hosted_file_size,
|
||||
}
|
||||
);
|
||||
|
||||
console.log(`Update obj with ID: ${obj_id}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to update ${obj_id}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_core.file.put(obj);
|
||||
// console.log(`Put obj with ID: ${data_kv.hosted_file_id_random}`);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
|
||||
// This function will save an array of objects to a Dexie database table.
|
||||
// It will first attempt to update existing records using bulkUpdate.
|
||||
// If that fails, it will fall back to bulkPut.
|
||||
// The function takes a database instance, table name, array of objects, and properties to save.
|
||||
// It also accepts a log level for debugging purposes.
|
||||
// Updated 2025-05-09
|
||||
export async function db_save_ae_obj_li__ae_obj({
|
||||
db_instance,
|
||||
table_name,
|
||||
obj_li,
|
||||
properties_to_save,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
db_instance: any; // The Dexie database instance
|
||||
table_name: string; // The name of the table in the database
|
||||
obj_li: any[];
|
||||
properties_to_save: string[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
// log_lvl = 1;
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__ae_obj() *** table_name=${table_name}`, obj_li);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) {
|
||||
console.log('No objects to save.');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
const db_table = db_instance[table_name];
|
||||
if (!db_table) {
|
||||
console.error(`Table not found in ${db_instance}: ${table_name}`);
|
||||
return [];
|
||||
}
|
||||
|
||||
const bulkUpdateData = [];
|
||||
const bulkPutData = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
const obj_record: Record<string, any> = {};
|
||||
|
||||
// Extract only the specified properties to save
|
||||
for (const prop of properties_to_save) {
|
||||
obj_record[prop] = obj[prop];
|
||||
}
|
||||
|
||||
// Ensure the `id` field is included
|
||||
obj_record.id = obj_record.id || obj.id || obj[`${table_name}_id`] || obj[`${table_name}_id_random`];
|
||||
|
||||
if (!obj_record.id) {
|
||||
console.error(`Object is missing an ID:`, obj);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Prepare data for bulkUpdate or bulkPut
|
||||
bulkUpdateData.push({
|
||||
key: obj_record.id,
|
||||
changes: obj_record,
|
||||
});
|
||||
bulkPutData.push(obj_record);
|
||||
}
|
||||
|
||||
// Attempt bulkUpdate first
|
||||
try {
|
||||
const updatedKeys = await db_table.bulkUpdate(bulkUpdateData);
|
||||
if (log_lvl) {
|
||||
console.log(`Bulk update completed. Updated keys:`, updatedKeys);
|
||||
}
|
||||
} catch (error) {
|
||||
// This is fairly common and normal if the object is new
|
||||
if (log_lvl) {
|
||||
console.log(`Bulk update failed. Falling back to bulkPut. This is normal.`, error);
|
||||
}
|
||||
}
|
||||
|
||||
// Use bulkPut for any records that couldn't be updated
|
||||
try {
|
||||
const putKeys = await db_table.bulkPut(bulkPutData);
|
||||
if (log_lvl) {
|
||||
console.log(`Bulk put completed. Put keys:`, putKeys);
|
||||
}
|
||||
return putKeys;
|
||||
} catch (error) {
|
||||
// This should not happen if the object is new
|
||||
console.error(`Bulk put failed. Something likely went wrong!`, error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -1,794 +0,0 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
||||
import { db_core } from "$lib/ae_core/db_core";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2025-06-10
|
||||
export async function load_ae_obj_id__person(
|
||||
{
|
||||
api_cfg,
|
||||
person_id,
|
||||
params = {},
|
||||
try_cache = false,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
person_id: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__person() *** person_id=${person_id}`);
|
||||
}
|
||||
|
||||
ae_promises.load__person_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
obj_id: person_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (person_obj_get_result) {
|
||||
if (person_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__person_props({
|
||||
obj_li: [person_obj_get_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_core,
|
||||
table_name: 'person',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// // This is expecting a list
|
||||
// db_save_ae_obj_li__person({
|
||||
// obj_type: 'person',
|
||||
// obj_li: [person_obj_get_result],
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return person_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__person_obj:', ae_promises.load__person_obj);
|
||||
}
|
||||
|
||||
return ae_promises.load__person_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-10
|
||||
export async function load_ae_obj_li__person(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type = 'account',
|
||||
for_obj_id,
|
||||
qry_email = null,
|
||||
qry_user_id = null,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
order_by_li = {'family_name': 'ASC', 'given_name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
// params_json = {},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
qry_email?: string|null,
|
||||
qry_user_id?: string|null,
|
||||
enabled?: string, // all, disabled, enabled
|
||||
hidden?: string, // all, hidden, not_hidden
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
order_by_li?: key_val,
|
||||
// params_json?: null|key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__person() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id} enabled=${enabled} hidden=${hidden} limit=${limit} offset=${offset}`);
|
||||
}
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
if (qry_user_id) {
|
||||
// params_json['and_qry'] = {};
|
||||
// params_json['and_qry']['user_id_random'] = qry_user_id;
|
||||
|
||||
params_json['qry'] = []
|
||||
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "user_id_random",
|
||||
operator: "=",
|
||||
value: qry_user_id
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
}
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('params_json:', params_json);
|
||||
}
|
||||
|
||||
ae_promises.load__person_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: false,
|
||||
use_alt_mdl: false,
|
||||
use_alt_exp: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (person_obj_li_get_result) {
|
||||
if (person_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__person_props({
|
||||
obj_li: person_obj_li_get_result,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_core,
|
||||
table_name: 'person',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__person({
|
||||
// obj_type: 'person',
|
||||
// obj_li: person_obj_li_get_result,
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return person_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
console.log('ae_promises.load__person_obj_li:', ae_promises.load__person_obj_li);
|
||||
return ae_promises.load__person_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-10
|
||||
export async function create_ae_obj__person(
|
||||
{
|
||||
api_cfg,
|
||||
user_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
user_id?: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** create_ae_obj__person() *** user_id=${user_id}`);
|
||||
}
|
||||
|
||||
ae_promises.create__person = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
fields: {
|
||||
user_id_random: user_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (person_obj_create_result) {
|
||||
if (person_obj_create_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__person_props({
|
||||
obj_li: [person_obj_create_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_core,
|
||||
table_name: 'person',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__person(
|
||||
// {
|
||||
// obj_type: 'person',
|
||||
// obj_li: [person_obj_create_result],
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return person_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__person:', ae_promises.create__person);
|
||||
}
|
||||
return ae_promises.create__person;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-10
|
||||
export async function delete_ae_obj_id__person(
|
||||
{
|
||||
api_cfg,
|
||||
person_id,
|
||||
method = 'delete', // 'delete', 'disable', 'hide'
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
person_id: string,
|
||||
method?: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** delete_ae_obj_id__person() *** person_id=${person_id}`);
|
||||
}
|
||||
|
||||
ae_promises.delete__person_obj = await api.delete_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
obj_id: person_id,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
method: method,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(async function () {
|
||||
if (try_cache) {
|
||||
if (log_lvl) {
|
||||
console.log(`Attempting to remove IDB entry for person_id=${person_id}`);
|
||||
}
|
||||
await db_core.person.delete(person_id);
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.delete__person_obj:', ae_promises.delete__person_obj);
|
||||
}
|
||||
|
||||
return ae_promises.delete__person_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-10
|
||||
export async function update_ae_obj__person(
|
||||
{
|
||||
api_cfg,
|
||||
person_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
person_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__person() *** person_id=${person_id}`, data_kv);
|
||||
}
|
||||
|
||||
// log_lvl = 1;
|
||||
|
||||
// Perform the API update
|
||||
const result = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
obj_id: person_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
// Handle the result
|
||||
if (result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__person_props({
|
||||
obj_li: [result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_core,
|
||||
table_name: 'person',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// await db_save_ae_obj_li__person({
|
||||
// obj_type: 'person',
|
||||
// obj_li: [result],
|
||||
// log_lvl: log_lvl,
|
||||
// });
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
console.error('Failed to update person.');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-10
|
||||
export function db_save_ae_obj_li__person(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__person() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
let obj_record = {
|
||||
id: obj.person_id_random,
|
||||
// id_random: obj.person_id_random,
|
||||
person_id: obj.person_id_random,
|
||||
person_id_random: obj.person_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
external_sys_id: obj.external_sys_id,
|
||||
code: obj.code,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
account_id_random: obj.account_id_random,
|
||||
|
||||
person_profile_id: obj.person_profile_id_random,
|
||||
person_profile_id_random: obj.person_profile_id_random, // The new table person_profile will be used soon...
|
||||
|
||||
user_id: obj.user_id_random,
|
||||
user_id_random: obj.user_id_random,
|
||||
|
||||
pronouns: obj.pronouns,
|
||||
informal_name: obj.informal_name,
|
||||
title_names: obj.title_names,
|
||||
given_name: obj.given_name,
|
||||
middle_name: obj.middle_name,
|
||||
family_name: obj.family_name,
|
||||
designations: obj.designations,
|
||||
|
||||
professional_title: obj.professional_title,
|
||||
|
||||
full_name: obj.full_name,
|
||||
full_name_override: obj.full_name_override, // was display_name and display_name_override
|
||||
|
||||
affiliations: obj.affiliations,
|
||||
|
||||
primary_email: obj.primary_email,
|
||||
|
||||
biography: obj.biography,
|
||||
|
||||
agree: obj.agree,
|
||||
comments: obj.comments,
|
||||
|
||||
allow_auth_key: obj.allow_auth_key, // For sign in without password
|
||||
// auth_key: obj.auth_key,
|
||||
passcode: obj.passcode,
|
||||
|
||||
data_json: obj.data_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// From SQL view
|
||||
username: obj.username,
|
||||
user_name: obj.user_name,
|
||||
user_email: obj.user_email,
|
||||
user_allow_auth_key: obj.user_allow_auth_key, // For sign in without password
|
||||
user_super: obj.user_super,
|
||||
user_manager: obj.user_manager,
|
||||
user_administrator: obj.user_administrator,
|
||||
user_public: obj.user_public,
|
||||
};
|
||||
|
||||
let id_random = null;
|
||||
|
||||
try {
|
||||
id_random = await db_core.person.update(obj_record.id, obj_record);
|
||||
} catch (error) {
|
||||
console.log(`Error: Failed to update ${obj_record.id}: ${error}`);
|
||||
}
|
||||
if (!id_random) {
|
||||
if (log_lvl) {
|
||||
console.log(`Failed to update record with ID: ${obj_record.id}. Trying put...`);
|
||||
}
|
||||
try {
|
||||
id_random = await db_core.person.put(obj_record);
|
||||
} catch (error) {
|
||||
console.log(`Error: Failed to put ${obj.person_id_random}: ${error}`);
|
||||
}
|
||||
} else {
|
||||
if (log_lvl) {
|
||||
console.log(`Updated record with ID: ${obj_record.id}`);
|
||||
}
|
||||
}
|
||||
if (!id_random) {
|
||||
console.log(`Failed to save record with ID: ${obj_record.id}`);
|
||||
} else {
|
||||
if (log_lvl) {
|
||||
console.log(`Saved record with ID: ${obj_record.id}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-10
|
||||
let properties_to_save = [
|
||||
|
||||
'id',
|
||||
'person_id',
|
||||
'person_id_random',
|
||||
|
||||
'external_id',
|
||||
'external_sys_id',
|
||||
'code',
|
||||
|
||||
'account_id',
|
||||
'account_id_random',
|
||||
|
||||
'person_profile_id',
|
||||
'person_profile_id_random', // The new table person_profile will be used soon...
|
||||
|
||||
'user_id',
|
||||
'user_id_random',
|
||||
|
||||
'pronouns',
|
||||
'informal_name',
|
||||
'title_names',
|
||||
'given_name',
|
||||
'middle_name',
|
||||
'family_name',
|
||||
'designations',
|
||||
|
||||
'professional_title',
|
||||
|
||||
'full_name',
|
||||
'full_name_override', // was display_name and display_name_override
|
||||
|
||||
'affiliations',
|
||||
'primary_email',
|
||||
'biography',
|
||||
'agree',
|
||||
'comments',
|
||||
|
||||
'allow_auth_key', // For sign in without password
|
||||
// 'auth_key', // Should this be saved locally?
|
||||
'passcode',
|
||||
|
||||
// 'passcode_timeout',
|
||||
// 'passcode_read', // For LLM (AI) generated summary...???
|
||||
// 'passcode_read_expire',
|
||||
// 'passcode_write',
|
||||
// 'passcode_write_expire',
|
||||
// 'private_passcode',
|
||||
|
||||
// 'alert',
|
||||
// 'alert_msg',
|
||||
|
||||
'data_json',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
'tmp_sort_3',
|
||||
|
||||
// From SQL view
|
||||
'username',
|
||||
// 'user_username', // Same as username
|
||||
'user_name',
|
||||
'user_email',
|
||||
'user_allow_auth_key', // For sign in without password
|
||||
'user_super',
|
||||
'user_manager',
|
||||
'user_administrator',
|
||||
'user_public',
|
||||
|
||||
'organization_id',
|
||||
'organization_id_random',
|
||||
'organization_name',
|
||||
|
||||
'contact_id',
|
||||
'contact_id_random',
|
||||
'contact_name',
|
||||
'contact_email',
|
||||
'contact_cc_email',
|
||||
'contact_phone_mobile',
|
||||
'contact_phone_home',
|
||||
'contact_phone_office',
|
||||
'contact_phone_land',
|
||||
'contact_phone_fax',
|
||||
'contact_phone_other',
|
||||
|
||||
'address_id',
|
||||
'address_id_random',
|
||||
'address_city',
|
||||
'address_country_alpha_2_code', // contact_address_country_alpha_2_code
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-06-10
|
||||
export async function process_ae_obj__person_props(
|
||||
{
|
||||
// obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
// obj_type: string;
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__person_props() ***`, obj_li);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) {
|
||||
console.log('No objects to process.');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
// const processed_obj = { ...obj };
|
||||
|
||||
// Process the properties as needed
|
||||
// None needed to process for person at this time...
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.person_id_random,
|
||||
person_id: obj.person_id_random,
|
||||
person_id_random: obj.person_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
external_sys_id: obj.external_sys_id,
|
||||
code: obj.code,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
account_id_random: obj.account_id_random,
|
||||
|
||||
person_profile_id: obj.person_profile_id_random,
|
||||
person_profile_id_random: obj.person_profile_id_random, // The new table person_profile will be used soon...
|
||||
|
||||
user_id: obj.user_id_random,
|
||||
user_id_random: obj.user_id_random,
|
||||
|
||||
pronouns: obj.pronouns,
|
||||
informal_name: obj.informal_name,
|
||||
title_names: obj.title_names,
|
||||
given_name: obj.given_name,
|
||||
middle_name: obj.middle_name,
|
||||
family_name: obj.family_name,
|
||||
designations: obj.designations,
|
||||
|
||||
professional_title: obj.professional_title,
|
||||
|
||||
full_name: obj.full_name,
|
||||
full_name_override: obj.full_name_override, // was display_name and display_name_override
|
||||
|
||||
affiliations: obj.affiliations,
|
||||
|
||||
primary_email: obj.primary_email,
|
||||
|
||||
biography: obj.biography,
|
||||
|
||||
agree: obj.agree,
|
||||
comments: obj.comments,
|
||||
|
||||
allow_auth_key: obj.allow_auth_key, // For sign in without password
|
||||
// auth_key: obj.auth_key,
|
||||
passcode: obj.passcode,
|
||||
// passcode_timeout: obj.passcode_timeout,
|
||||
|
||||
// This only allows for basic access to the data.
|
||||
// passcode_read: obj.passcode_read, // For LLM (AI) generated summary...???
|
||||
// passcode_read_expire: obj.passcode_read_expire,
|
||||
// passcode_write: obj.passcode_write,
|
||||
// passcode_write_expire: obj.passcode_write_expire,
|
||||
|
||||
// private_passcode: obj.private_passcode,
|
||||
|
||||
// alert: obj.alert,
|
||||
// alert_msg: obj.alert_msg,
|
||||
|
||||
data_json: obj.data_json ?? {},
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group ?? '0'}_${obj.priority ? 1 : 0}_${obj.sort ?? '0'}_${obj.updated_on}_${obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group ?? '0'}_${obj.priority ? 1 : 0}_${obj.sort ?? '0'}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_3: `${obj.group ?? '0'}_${obj.priority ? 1 : 0}_${obj.sort ?? '0'}_${obj.name}_${obj.updated_on ?? obj.created_on}`,
|
||||
// tmp_sort_1: `${obj.original_datetime}_${obj.group}_${obj.priority}_${obj.sort}`,
|
||||
// tmp_sort_2: `${obj.group}_${obj.original_datetime}_${obj.priority}_${obj.sort}`,
|
||||
|
||||
// From SQL view
|
||||
username: obj.username, // Same as user_username
|
||||
user_name: obj.user_name,
|
||||
user_email: obj.user_email,
|
||||
user_allow_auth_key: obj.user_allow_auth_key, // For sign in without password
|
||||
user_super: obj.user_super,
|
||||
user_manager: obj.user_manager,
|
||||
user_administrator: obj.user_administrator,
|
||||
user_public: obj.user_public,
|
||||
|
||||
organization_id: obj.organization_id_random,
|
||||
organization_id_random: obj.organization_id_random,
|
||||
organization_name: obj.organization_name,
|
||||
|
||||
contact_id: obj.contact_id_random,
|
||||
contact_id_random: obj.contact_id_random,
|
||||
contact_name: obj.contact_name,
|
||||
contact_email: obj.contact_email,
|
||||
contact_cc_email: obj.contact_cc_email,
|
||||
contact_phone_mobile: obj.contact_phone_mobile,
|
||||
contact_phone_home: obj.contact_phone_home,
|
||||
contact_phone_office: obj.contact_phone_office,
|
||||
contact_phone_land: obj.contact_phone_land,
|
||||
contact_phone_fax: obj.contact_phone_fax,
|
||||
contact_phone_other: obj.contact_phone_other,
|
||||
|
||||
address_id: obj.contact_address_id_random,
|
||||
address_id_random: obj.contact_address_id_random,
|
||||
address_city: obj.contact_address_city,
|
||||
address_country_alpha_2_code: obj.contact_address_country_alpha_2_code, // contact_address_country_alpha_2_code
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_core } from "$lib/ae_core/db_core";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-10-14
|
||||
export async function load_ae_obj_li__time_zone(
|
||||
{
|
||||
api_cfg,
|
||||
// account_id,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
// order_by_li = {'priority': 'DESC', 'group': 'ASC', 'sort': 'DESC', 'name': 'ASC'},
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
// account_id: string,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__time_zone() ***`);
|
||||
}
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
ae_promises.load__time_zone_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'lu',
|
||||
for_obj_type: 'time_zone',
|
||||
// for_obj_id: account_id,
|
||||
use_alt_tbl: true, // NOTE: Using this with the time zones to use the view named "v_lu_time_zone_cust"
|
||||
use_alt_mdl: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (time_zone_li_get_result) {
|
||||
if (time_zone_li_get_result) {
|
||||
// handle_db_save_ae_obj_li__time_zone({obj_type: 'time_zone', obj_li: time_zone_li_get_result});
|
||||
return time_zone_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
console.log('ae_promises.load__time_zone_li:', ae_promises.load__time_zone_li);
|
||||
return ae_promises.load__time_zone_li;
|
||||
}
|
||||
@@ -1,339 +0,0 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_core } from "$lib/ae_core/db_core";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2025-04-04
|
||||
export async function auth_ae_obj__username_password(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
null_account_id = false,
|
||||
username,
|
||||
password,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
null_account_id?: boolean,
|
||||
username: string,
|
||||
password: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** auth_ae_obj__username_password() *** account_id=${account_id} username=${username} password=${password}`);
|
||||
}
|
||||
|
||||
let endpoint = '/user/authenticate';
|
||||
|
||||
if (null_account_id) {
|
||||
params['null_account_id'] = true;
|
||||
}
|
||||
params['username'] = username; // Required
|
||||
params['password'] = password; // Required
|
||||
if (log_lvl > 1) {
|
||||
console.log(`auth_ae_obj__username_password() - params:`, params);
|
||||
}
|
||||
|
||||
ae_promises.auth__username_password = await api.get_object({
|
||||
api_cfg: api_cfg,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
// data: {},
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (user_obj_get_result) {
|
||||
if (user_obj_get_result) {
|
||||
// if (try_cache) {
|
||||
// // This is expecting a list
|
||||
// db_save_ae_obj_li__user({
|
||||
// obj_type: 'user',
|
||||
// obj_li: [user_obj_get_result],
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
// }
|
||||
return user_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.auth__username_password:', ae_promises.auth__username_password);
|
||||
}
|
||||
return ae_promises.auth__username_password;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-04-04
|
||||
export async function auth_ae_obj__user_id_user_auth_key(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
user_id,
|
||||
user_auth_key,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
user_id: string,
|
||||
user_auth_key: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** auth_ae_obj__user_id_user_auth_key() *** account_id=${account_id} user_id=${user_id}`);
|
||||
}
|
||||
|
||||
let endpoint = '/user/authenticate';
|
||||
|
||||
params['user_id'] = user_id; // Required
|
||||
params['auth_key'] = user_auth_key; // Required
|
||||
if (log_lvl > 1) {
|
||||
console.log(`auth_ae_obj__user_id_user_auth_key() - params:`, params);
|
||||
}
|
||||
|
||||
ae_promises.auth__user_id_user_key = await api.get_object({
|
||||
api_cfg: api_cfg,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (user_obj_get_result) {
|
||||
if (user_obj_get_result) {
|
||||
return user_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.auth__user_id_user_key:', ae_promises.auth__user_id_user_key);
|
||||
}
|
||||
return ae_promises.auth__user_id_user_key;
|
||||
}
|
||||
|
||||
|
||||
// Send an email to the user with a new one time use authentication key. The new key must be generated and returned first.
|
||||
// Updated 2025-04-08
|
||||
export async function send_email_auth_ae_obj__user_id(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
user_id,
|
||||
base_url,
|
||||
key_param_name = 'user_key', // API defaults to 'auth_key'
|
||||
params = {},
|
||||
// try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
user_id: string,
|
||||
base_url?: string,
|
||||
key_param_name?: string,
|
||||
params?: key_val,
|
||||
// try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** send_email_auth_ae_obj__user_id() *** account_id=${account_id} user_id=${user_id}`);
|
||||
}
|
||||
if (log_lvl > 1) {
|
||||
console.log(api_cfg);
|
||||
}
|
||||
|
||||
let email_auth_key_endpoint = `user/${user_id}/email_auth_key_url`;
|
||||
params = {
|
||||
'root_url': base_url,
|
||||
'key_param_name': key_param_name
|
||||
}
|
||||
ae_promises.auth_key__send_email = await api.get_object({
|
||||
api_cfg: api_cfg,
|
||||
endpoint: email_auth_key_endpoint,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
return ae_promises.auth_key__send_email;
|
||||
|
||||
// let endpoint = `/user/${user_id}/new_auth_key`;
|
||||
|
||||
// // params['user_id'] = user_id; // Required
|
||||
// if (log_lvl > 1) {
|
||||
// console.log(`send_email_auth_ae_obj__user_id() - params:`, params);
|
||||
// }
|
||||
|
||||
// ae_promises.auth_key__gen_auth_key = await api.get_object({
|
||||
// api_cfg: api_cfg,
|
||||
// endpoint: endpoint,
|
||||
// params: params,
|
||||
// log_lvl: log_lvl
|
||||
// })
|
||||
// .then(async function (email_send_result) {
|
||||
// if (email_send_result) {
|
||||
// let email_auth_key_endpoint = `user/${user_id}/email_auth_key_url`;
|
||||
// params = {
|
||||
// 'root_url': 'https://test.oneskyit.com'
|
||||
// }
|
||||
// ae_promises.auth_key__send_email = await api.get_object({
|
||||
// api_cfg: api_cfg,
|
||||
// endpoint: email_auth_key_endpoint,
|
||||
// params: params,
|
||||
// log_lvl: log_lvl
|
||||
// })
|
||||
|
||||
// return email_send_result;
|
||||
// } else {
|
||||
// console.log('No results returned.');
|
||||
// return null;
|
||||
// }
|
||||
// })
|
||||
// .catch(function (error) {
|
||||
// console.log('No results returned or failed.', error);
|
||||
// });
|
||||
|
||||
// if (log_lvl) {
|
||||
// console.log('ae_promises.send_email_auth__user_id:', ae_promises.send_email_auth__user_id);
|
||||
// }
|
||||
// return ae_promises.send_email_auth__user_id;
|
||||
}
|
||||
|
||||
// Look up user based on email address provided
|
||||
// Updated 2025-04-08
|
||||
export async function qry_ae_obj_li__user_email(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
null_account_id = false,
|
||||
email,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
null_account_id?: boolean,
|
||||
email: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** qry_ae_obj_li__user_email() *** account_id=${account_id} email=${email}`);
|
||||
}
|
||||
|
||||
let endpoint = '/user/lookup_email';
|
||||
|
||||
params['email'] = email; // Required
|
||||
params['null_account_id'] = null_account_id || false;
|
||||
if (log_lvl > 1) {
|
||||
console.log(`qry_ae_obj_li__user_email() - params:`, params);
|
||||
}
|
||||
|
||||
ae_promises.qry__user_email = await api.get_object({
|
||||
api_cfg: api_cfg,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (user_obj_get_result) {
|
||||
if (user_obj_get_result) {
|
||||
return user_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.qry__user_email:', ae_promises.qry__user_email);
|
||||
}
|
||||
return ae_promises.qry__user_email;
|
||||
}
|
||||
|
||||
|
||||
// Change user password
|
||||
// endpoint: PATCH /user/{user_id}/change_password
|
||||
// params:
|
||||
// data_kv: password (the new password)
|
||||
// Updated 2025-04-11
|
||||
export async function auth_ae_obj__user_id_change_password(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
user_id,
|
||||
password,
|
||||
params = {},
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
user_id: string,
|
||||
password: string,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** auth_ae_obj__user_id_change_password() *** account_id=${account_id} user_id=${user_id}`);
|
||||
}
|
||||
|
||||
let endpoint = `/user/${user_id}/change_password`;
|
||||
|
||||
params['user_id'] = user_id; // Required
|
||||
if (log_lvl > 1) {
|
||||
console.log(`auth_ae_obj__user_id_change_password() - params:`, params);
|
||||
}
|
||||
|
||||
ae_promises.change_password__user_id = await api.patch_object({
|
||||
api_cfg: api_cfg,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
data: { password: password },
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (change_password_result) {
|
||||
if (change_password_result) {
|
||||
return change_password_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.change_password__user_id:', ae_promises.change_password__user_id);
|
||||
}
|
||||
return ae_promises.change_password__user_id;
|
||||
}
|
||||
319
src/lib/ae_core__person.ts
Normal file
319
src/lib/ae_core__person.ts
Normal file
@@ -0,0 +1,319 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_core } from "$lib/db_core";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-07-17
|
||||
export async function handle_load_ae_obj_id__person(
|
||||
{
|
||||
api_cfg,
|
||||
person_id,
|
||||
try_cache=false,
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
person_id: string,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_id__person() *** person_id=${person_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
ae_promises.load__person_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
obj_id: person_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (person_obj_get_result) {
|
||||
if (person_obj_get_result) {
|
||||
// This is expecting a list
|
||||
handle_db_save_ae_obj_li__person({obj_type: 'person', obj_li: [person_obj_get_result]});
|
||||
return person_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
return ae_promises.load__person_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-07-17
|
||||
export async function handle_load_ae_obj_li__person(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
params={},
|
||||
try_cache=true,
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_li__person() *** account_id=${account_id}`);
|
||||
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
ae_promises.load__person_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: account_id,
|
||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: {'given_name': 'ASC', 'family_name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (person_obj_li_get_result) {
|
||||
if (person_obj_li_get_result) {
|
||||
handle_db_save_ae_obj_li__person({obj_type: 'person', obj_li: person_obj_li_get_result});
|
||||
return person_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
console.log('ae_promises.load__person_obj_li:', ae_promises.load__person_obj_li);
|
||||
return ae_promises.load__person_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-24
|
||||
export async function handle_create_ae_obj__person(
|
||||
{
|
||||
api_cfg,
|
||||
user_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
user_id?: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_create_ae_obj__person() *** user_id=${user_id}`);
|
||||
|
||||
ae_promises.create__person = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
fields: {
|
||||
user_id_random: user_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (person_obj_create_result) {
|
||||
if (person_obj_create_result) {
|
||||
handle_db_save_ae_obj_li__person(
|
||||
{
|
||||
obj_type: 'person', obj_li: [person_obj_create_result]
|
||||
});
|
||||
return person_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__person:', ae_promises.create__person);
|
||||
}
|
||||
return ae_promises.create__person;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-07-17
|
||||
export async function handle_update_ae_obj__person(
|
||||
{
|
||||
api_cfg,
|
||||
person_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
person_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_update_ae_obj__person() *** person_id=${person_id}`);
|
||||
|
||||
ae_promises.update__person_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'person',
|
||||
obj_id: person_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (person_obj_update_result) {
|
||||
if (person_obj_update_result) {
|
||||
handle_db_save_ae_obj_li__person({obj_type: 'person', obj_li: [person_obj_update_result]});
|
||||
return person_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__person_obj:', ae_promises.update__person_obj);
|
||||
}
|
||||
return ae_promises.update__person_obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Updated 2024-06-10
|
||||
export function handle_db_save_ae_obj_li__person(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl=0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** handle_db_save_ae_obj_li__person() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_core.person.put({
|
||||
id: obj.person_id_random,
|
||||
// id_random: obj.person_id_random,
|
||||
person_id: obj.person_id_random,
|
||||
person_id_random: obj.person_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
external_sys_id: obj.external_sys_id,
|
||||
code: obj.code,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
account_id_random: obj.account_id_random,
|
||||
|
||||
person_profile_id: obj.person_profile_id_random,
|
||||
person_profile_id_random: obj.person_profile_id_random, // The new table person_profile will be used soon...
|
||||
|
||||
user_id: obj.user_id_random,
|
||||
user_id_random: obj.user_id_random,
|
||||
|
||||
pronouns: obj.pronouns,
|
||||
informal_name: obj.informal_name,
|
||||
title_names: obj.title_names,
|
||||
given_name: obj.given_name,
|
||||
middle_name: obj.middle_name,
|
||||
family_name: obj.family_name,
|
||||
designations: obj.designations,
|
||||
|
||||
professional_title: obj.professional_title,
|
||||
|
||||
full_name: obj.full_name,
|
||||
|
||||
affiliations: obj.affiliations,
|
||||
|
||||
primary_email: obj.primary_email,
|
||||
|
||||
biography: obj.biography,
|
||||
|
||||
agree: obj.agree,
|
||||
comments: obj.comments,
|
||||
|
||||
allow_auth_key: obj.allow_auth_key, // For sign in without password
|
||||
// auth_key: obj.auth_key,
|
||||
passcode: obj.passcode,
|
||||
|
||||
data_json: obj.data_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// From SQL view
|
||||
username: obj.username,
|
||||
user_name: obj.user_name,
|
||||
user_email: obj.user_email,
|
||||
user_allow_auth_key: obj.user_allow_auth_key, // For sign in without password
|
||||
user_super: obj.user_super,
|
||||
user_manager: obj.user_manager,
|
||||
user_administrator: obj.user_administrator,
|
||||
user_public: obj.user_public,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.person_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.person_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_core.person.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.person_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_core } from "$lib/ae_core/db_core";
|
||||
import { db_core } from "$lib/db_core";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
@@ -2,78 +2,58 @@ import { browser } from '$app/environment';
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import {
|
||||
load_ae_obj_id__activity_log,
|
||||
load_ae_obj_li__activity_log,
|
||||
create_ae_obj__activity_log,
|
||||
update_ae_obj__activity_log,
|
||||
// db_save_ae_obj_li__activity_log
|
||||
} from "$lib/ae_core/core__activity_log";
|
||||
|
||||
import {
|
||||
load_ae_obj_id__person,
|
||||
load_ae_obj_li__person,
|
||||
create_ae_obj__person,
|
||||
delete_ae_obj_id__person,
|
||||
update_ae_obj__person,
|
||||
// db_save_ae_obj_li__person
|
||||
} from "$lib/ae_core/core__person";
|
||||
|
||||
import {
|
||||
auth_ae_obj__username_password,
|
||||
auth_ae_obj__user_id_user_auth_key,
|
||||
send_email_auth_ae_obj__user_id,
|
||||
qry_ae_obj_li__user_email,
|
||||
auth_ae_obj__user_id_change_password,
|
||||
// handle_load_ae_obj_id__user,
|
||||
// handle_load_ae_obj_li__user,
|
||||
// handle_create_ae_obj__user,
|
||||
// handle_update_ae_obj__user,
|
||||
// handle_db_save_ae_obj_li__user
|
||||
} from "$lib/ae_core/core__user";
|
||||
handle_load_ae_obj_id__person,
|
||||
handle_load_ae_obj_li__person,
|
||||
handle_create_ae_obj__person,
|
||||
handle_update_ae_obj__person,
|
||||
// handle_db_save_ae_obj_li__person
|
||||
} from "$lib/ae_core__person";
|
||||
|
||||
import {
|
||||
generate_qr_code,
|
||||
} from "$lib/ae_core/core__qr_code";
|
||||
|
||||
import {
|
||||
check_hosted_file_obj_w_hash
|
||||
} from "$lib/ae_core/core__check_hosted_file_obj_w_hash";
|
||||
|
||||
import {
|
||||
load_ae_obj_li__time_zone
|
||||
} from "$lib/ae_core/core__time_zones";
|
||||
|
||||
import {
|
||||
load_ae_obj_li__country
|
||||
} from "$lib/ae_core/core__countries";
|
||||
|
||||
import {
|
||||
load_ae_obj_li__country_subdivision
|
||||
} from "$lib/ae_core/core__country_subdivisions";
|
||||
|
||||
import {
|
||||
load_ae_obj_id__hosted_file,
|
||||
load_ae_obj_li__hosted_file,
|
||||
delete_ae_obj_id__hosted_file,
|
||||
db_save_ae_obj_li__hosted_file,
|
||||
db_update_ae_obj_id__hosted_file
|
||||
} from "$lib/ae_core/core__hosted_files";
|
||||
|
||||
// This has more generic general purpose functions that can eventually replace the custom ones per object type.
|
||||
import {
|
||||
db_save_ae_obj_li__ae_obj,
|
||||
} from "$lib/ae_core/core__idb_dexie";
|
||||
|
||||
import {
|
||||
add_url_params,
|
||||
clean_headers,
|
||||
} from "$lib/ae_core/core__api_helpers";
|
||||
} from "$lib/ae_core__qr_code";
|
||||
|
||||
|
||||
let ae_promises: key_val = {}; // Promise<any>;
|
||||
|
||||
|
||||
// Updated 2024-10-02
|
||||
async function check_hosted_file_obj_w_hash(
|
||||
{
|
||||
api_cfg,
|
||||
hosted_file_hash,
|
||||
check_for_local = true, // Forces a check on the host server for the file.
|
||||
params = {},
|
||||
return_meta = false,
|
||||
log_lvl = 0
|
||||
} : {
|
||||
api_cfg: any,
|
||||
hosted_file_hash: string,
|
||||
check_for_local?: boolean,
|
||||
params?: key_val,
|
||||
return_meta?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log('*** stores_event_api.js: check_hosted_file_obj_w_hash() ***');
|
||||
|
||||
const endpoint = `/hosted_file/hash/${hosted_file_hash}`;
|
||||
if (check_for_local) {
|
||||
params['check_for_local'] = true;
|
||||
}
|
||||
let check_hosted_file_obj_w_hash_get_promise = await api.get_object({
|
||||
api_cfg: api_cfg,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
return_meta: return_meta,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
return check_hosted_file_obj_w_hash_get_promise;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-03-29
|
||||
async function handle_load_ae_obj_id__site_domain(
|
||||
{
|
||||
@@ -90,9 +70,7 @@ async function handle_load_ae_obj_id__site_domain(
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** handle_load_ae_obj_id__site_domain() *** api.base_url=${api_cfg.base_url}, fqdn=${fqdn}, timeout=${timeout}`);
|
||||
}
|
||||
console.log(`*** handle_load_ae_obj_id__site_domain() *** fqdn=${fqdn}`);
|
||||
|
||||
let no_account_id = false;
|
||||
if (!api_cfg.account_id) {
|
||||
@@ -103,7 +81,7 @@ async function handle_load_ae_obj_id__site_domain(
|
||||
|
||||
let params = {};
|
||||
|
||||
// ae_sess.hub.site_domain_id_qry_status = 'loading';
|
||||
// ae_loc.hub.site_domain_id_qry_status = 'loading';
|
||||
ae_promises.load__site_domain_obj = api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
no_account_id: no_account_id,
|
||||
@@ -429,43 +407,12 @@ async function handle_download_export__obj_type(
|
||||
|
||||
let export_obj = {
|
||||
check_hosted_file_obj_w_hash: check_hosted_file_obj_w_hash,
|
||||
|
||||
load_ae_obj_li__time_zone: load_ae_obj_li__time_zone,
|
||||
|
||||
load_ae_obj_li__country: load_ae_obj_li__country,
|
||||
load_ae_obj_li__country_subdivision: load_ae_obj_li__country_subdivision,
|
||||
|
||||
load_ae_obj_id__hosted_file: load_ae_obj_id__hosted_file,
|
||||
load_ae_obj_li__hosted_file: load_ae_obj_li__hosted_file,
|
||||
delete_ae_obj_id__hosted_file: delete_ae_obj_id__hosted_file,
|
||||
db_save_ae_obj_li__hosted_file: db_save_ae_obj_li__hosted_file,
|
||||
db_update_ae_obj_id__hosted_file: db_update_ae_obj_id__hosted_file,
|
||||
|
||||
db_save_ae_obj_li__ae_obj: db_save_ae_obj_li__ae_obj,
|
||||
|
||||
add_url_params: add_url_params,
|
||||
clean_headers: clean_headers,
|
||||
|
||||
handle_load_ae_obj_id__site_domain: handle_load_ae_obj_id__site_domain,
|
||||
handle_load_ae_obj_code__data_store: handle_load_ae_obj_code__data_store,
|
||||
|
||||
load_ae_obj_id__activity_log: load_ae_obj_id__activity_log,
|
||||
load_ae_obj_li__activity_log: load_ae_obj_li__activity_log,
|
||||
create_ae_obj__activity_log: create_ae_obj__activity_log,
|
||||
update_ae_obj__activity_log: update_ae_obj__activity_log,
|
||||
|
||||
load_ae_obj_id__person: load_ae_obj_id__person,
|
||||
load_ae_obj_li__person: load_ae_obj_li__person,
|
||||
create_ae_obj__person: create_ae_obj__person,
|
||||
delete_ae_obj_id__person: delete_ae_obj_id__person,
|
||||
update_ae_obj__person: update_ae_obj__person,
|
||||
|
||||
auth_ae_obj__username_password: auth_ae_obj__username_password,
|
||||
auth_ae_obj__user_id_user_auth_key: auth_ae_obj__user_id_user_auth_key,
|
||||
send_email_auth_ae_obj__user_id: send_email_auth_ae_obj__user_id,
|
||||
qry_ae_obj_li__user_email: qry_ae_obj_li__user_email,
|
||||
auth_ae_obj__user_id_change_password: auth_ae_obj__user_id_change_password,
|
||||
|
||||
handle_load_ae_obj_id__person: handle_load_ae_obj_id__person,
|
||||
handle_load_ae_obj_li__person: handle_load_ae_obj_li__person,
|
||||
handle_create_ae_obj__person: handle_create_ae_obj__person,
|
||||
handle_update_ae_obj__person: handle_update_ae_obj__person,
|
||||
handle_update_ae_obj_id_crud: handle_update_ae_obj_id_crud,
|
||||
handle_download_export__obj_type: handle_download_export__obj_type,
|
||||
generate_qr_code: generate_qr_code
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,850 +0,0 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
||||
import { db_events } from "$lib/ae_events/db_events";
|
||||
|
||||
import { load_ae_obj_id__event_location } from './ae_events__event_location';
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export async function load_ae_obj_id__event_device(
|
||||
{
|
||||
api_cfg,
|
||||
event_device_id,
|
||||
inc_location_id = false,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_device_id: string,
|
||||
inc_location_id?: boolean,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__event_device() *** event_device_id=${event_device_id}`);
|
||||
}
|
||||
|
||||
let params = {};
|
||||
|
||||
ae_promises.load__event_device_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_device',
|
||||
obj_id: event_device_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_device_obj_get_result) {
|
||||
if (event_device_obj_get_result) {
|
||||
if (try_cache) {
|
||||
let processed_obj_li = await process_ae_obj__event_device_props({
|
||||
obj_li: [event_device_obj_get_result],
|
||||
log_lvl
|
||||
});
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'devices',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// // This is expecting a list
|
||||
// db_save_ae_obj_li__event_device({
|
||||
// obj_type: 'event_device',
|
||||
// obj_li: [event_device_obj_get_result]
|
||||
// });
|
||||
}
|
||||
return event_device_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_device_obj:', ae_promises.load__event_device_obj);
|
||||
}
|
||||
|
||||
if (inc_location_id) {
|
||||
// Load the location linked to this device
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the location id for the device now`);
|
||||
}
|
||||
let load_event_location_obj_id = load_ae_obj_id__event_location({
|
||||
api_cfg: api_cfg,
|
||||
event_location_id: ae_promises.load__event_device_obj.event_location_id,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_location_obj_id = `, load_event_location_obj_id);
|
||||
}
|
||||
ae_promises.load__event_device_obj.event_location_obj = load_event_location_obj_id;
|
||||
}
|
||||
|
||||
return ae_promises.load__event_device_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export async function load_ae_obj_li__event_device(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
inc_location_id = false,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 49,
|
||||
offset = 0,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'code': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
inc_location_id?: boolean,
|
||||
enabled?: string, // all, disabled, enabled
|
||||
hidden?: string, // all, hidden, not_hidden
|
||||
limit?: number, // 99
|
||||
offset?: number, // 0
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__event_device() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
}
|
||||
|
||||
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
// let hidden: string = (params.qry__hidden ?? 'all'); // all, hidden, not_hidden
|
||||
// let limit: number = (params.qry__limit ?? 99); // 99
|
||||
// let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
ae_promises.load__event_device_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_device',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: true,
|
||||
use_alt_mdl: false,
|
||||
use_alt_exp: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_device_obj_li_get_result) {
|
||||
if (event_device_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_device_props({
|
||||
obj_li: event_device_obj_li_get_result,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'devices',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_device({
|
||||
// obj_type: 'event_device',
|
||||
// obj_li: event_device_obj_li_get_result
|
||||
// });
|
||||
}
|
||||
return event_device_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_device_obj_li:', ae_promises.load__event_device_obj_li);
|
||||
}
|
||||
|
||||
if (inc_location_id) {
|
||||
// Load the location for the devices
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the location list for each device now`);
|
||||
}
|
||||
for (let i = 0; i < ae_promises.load__event_device_obj_li.length; i++) {
|
||||
let event_device_obj = ae_promises.load__event_device_obj_li[i];
|
||||
|
||||
let load_event_location_obj_li = load_ae_obj_id__event_location({
|
||||
api_cfg: api_cfg,
|
||||
event_location_id: event_device_obj.event_location_id,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then((event_location_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_location_obj_li = `, event_location_obj_li);
|
||||
}
|
||||
return event_location_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_location_obj_li = `, load_event_location_obj_li);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_device_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export async function create_ae_obj__event_device(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** create_ae_obj__event_device() *** event_id=${event_id}`);
|
||||
}
|
||||
|
||||
ae_promises.create__event_device = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_device',
|
||||
fields: {
|
||||
event_id_random: event_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_device_obj_create_result) {
|
||||
if (event_device_obj_create_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_device_props({
|
||||
obj_li: [event_device_obj_create_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'devices',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_device(
|
||||
// {
|
||||
// obj_type: 'event_device',
|
||||
// obj_li: [event_device_obj_create_result]
|
||||
// });
|
||||
}
|
||||
return event_device_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__event_device:', ae_promises.create__event_device);
|
||||
}
|
||||
return ae_promises.create__event_device;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export async function delete_ae_obj_id__event_device(
|
||||
{
|
||||
api_cfg,
|
||||
event_device_id,
|
||||
method = 'delete', // 'delete', 'disable', 'hide'
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_device_id: string,
|
||||
method?: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** delete_ae_obj_id__event_device() *** event_device_id=${event_device_id}`);
|
||||
}
|
||||
|
||||
ae_promises.delete__event_device_obj = await api.delete_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_device',
|
||||
obj_id: event_device_id,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
method: method,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
if (try_cache) {
|
||||
if (log_lvl) {
|
||||
console.log(`Attempting to remove IDB entry for event_device_id=${event_device_id}`);
|
||||
}
|
||||
db_events.devices.delete(event_device_id);
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.delete__event_device_obj:', ae_promises.delete__event_device_obj);
|
||||
}
|
||||
|
||||
return ae_promises.delete__event_device_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-10-16
|
||||
export async function update_ae_obj__event_device(
|
||||
{
|
||||
api_cfg,
|
||||
event_device_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_device_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__event_device() *** event_device_id=${event_device_id}`, data_kv);
|
||||
}
|
||||
ae_promises.update__event_device_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_device',
|
||||
obj_id: event_device_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_device_obj_update_result) {
|
||||
if (event_device_obj_update_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_device_props({
|
||||
obj_li: [event_device_obj_update_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'devices',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_device({
|
||||
// obj_type: 'event_device', obj_li: [event_device_obj_update_result]
|
||||
// });
|
||||
}
|
||||
return event_device_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__event_device_obj:', ae_promises.update__event_device_obj);
|
||||
}
|
||||
return ae_promises.update__event_device_obj;
|
||||
}
|
||||
|
||||
|
||||
// Not yet used or tested fully!
|
||||
// Updated 2025-05-23
|
||||
export async function search__event_device(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
fulltext_search_qry_str,
|
||||
ft_presenter_search_qry_str,
|
||||
like_search_qry_str = null,
|
||||
like_presentation_search_qry_str = null,
|
||||
like_presenter_search_qry_str = null,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: any,
|
||||
fulltext_search_qry_str?: null|string,
|
||||
ft_presenter_search_qry_str?: null|string,
|
||||
like_search_qry_str?: null|string,
|
||||
like_presentation_search_qry_str?: null|string,
|
||||
like_presenter_search_qry_str?: null|string,
|
||||
params?: any,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** search__event_device() *** 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
|
||||
let limit: number = (params.qry__limit ?? 25); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
if (!fulltext_search_qry_str && !like_search_qry_str) {
|
||||
console.log('No search string provided!!!');
|
||||
return false; // Returning false instead of [] because no search was performed.
|
||||
}
|
||||
|
||||
if (fulltext_search_qry_str || ft_presenter_search_qry_str) {
|
||||
params_json['ft_qry'] = {};
|
||||
if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
|
||||
params_json['ft_qry']['default_qry_str'] = fulltext_search_qry_str;
|
||||
}
|
||||
|
||||
if (ft_presenter_search_qry_str && ft_presenter_search_qry_str.length > 2) {
|
||||
params_json['ft_qry']['event_presenter_li_qry_str'] = ft_presenter_search_qry_str;
|
||||
}
|
||||
}
|
||||
|
||||
// Use the AND (AND LIKE) query
|
||||
// if (like_search_qry_str || like_presenter_search_qry_str) {
|
||||
// params_json['and_like'] = {};
|
||||
// if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
// params_json['and_like']['default_qry_str'] = like_search_qry_str;
|
||||
// }
|
||||
// if (like_presenter_search_qry_str && like_presenter_search_qry_str.length > 2) {
|
||||
// params_json['and_like']['event_presenter_li_qry_str'] = like_presenter_search_qry_str;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Use the AND (OR LIKE) query
|
||||
if (like_search_qry_str || like_presentation_search_qry_str || like_presenter_search_qry_str) {
|
||||
params_json['or_like'] = {};
|
||||
if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
params_json['or_like']['default_qry_str'] = like_search_qry_str;
|
||||
}
|
||||
if (like_presentation_search_qry_str && like_presentation_search_qry_str.length > 2) {
|
||||
params_json['or_like']['event_presentation_li_qry_str'] = like_presentation_search_qry_str;
|
||||
}
|
||||
if (like_presenter_search_qry_str && like_presenter_search_qry_str.length > 2) {
|
||||
params_json['or_like']['event_presenter_li_qry_str'] = like_presenter_search_qry_str;
|
||||
}
|
||||
}
|
||||
|
||||
params_json['and_qry'] = {};
|
||||
|
||||
// if (device_type_code) {
|
||||
// params_json['and_qry']['device_type_code'] = device_type_code;
|
||||
// }
|
||||
|
||||
let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
|
||||
|
||||
// ae_promises.load__event_device_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
ae_promises.load__event_device_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_device',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_tbl: true, // NOTE: We want to use the alt table for device searching
|
||||
// use_alt_mdl: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_device_obj_li_get_result) {
|
||||
if (event_device_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event_device({obj_type: 'event_device', obj_li: event_device_obj_li_get_result});
|
||||
}
|
||||
return event_device_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_device_obj_li:', ae_promises.load__event_device_obj_li);
|
||||
}
|
||||
return ae_promises.load__event_device_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the event_device_obj_li and save each one to the DB.
|
||||
// Updated 2024-10-16
|
||||
export function db_save_ae_obj_li__event_device(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__event_device() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_events.devices.put({
|
||||
id: obj.event_device_id_random,
|
||||
event_device_id: obj.event_device_id_random,
|
||||
// event_device_id_random: obj.event_device_id_random,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
// event_id_random: obj.event_id_random,
|
||||
event_location_id: obj.event_location_id_random,
|
||||
// event_location_id_random: obj.event_location_id_random,
|
||||
|
||||
code: obj.code,
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
local_file_cache_path: obj.local_file_cache_path,
|
||||
host_file_temp_path: obj.host_file_temp_path,
|
||||
recording_path: obj.recording_path,
|
||||
|
||||
record_audio: obj.record_audio,
|
||||
record_video: obj.record_video,
|
||||
|
||||
trigger_open_file_id: obj.trigger_open_file_id,
|
||||
trigger_open_session_id: obj.trigger_open_session_id,
|
||||
trigger_recording_start: obj.trigger_recording_start,
|
||||
trigger_recording_stop: obj.trigger_recording_stop,
|
||||
trigger_reset: obj.trigger_reset,
|
||||
trigger_show_admin: obj.trigger_show_admin,
|
||||
trigger_show_hidden: obj.trigger_show_hidden,
|
||||
|
||||
alert: obj.alert,
|
||||
alert_msg: obj.alert_msg,
|
||||
alert_on: obj.alert_on,
|
||||
status: obj.status,
|
||||
status_msg: obj.status_msg,
|
||||
status_on: obj.status_on,
|
||||
record_status: obj.record_status,
|
||||
record_status_msg: obj.record_status_msg,
|
||||
record_status_on: obj.record_status_on,
|
||||
// These are timestamps that are in UTC but missing the 'Z' at the end
|
||||
heartbeat: obj.heartbeat ? obj.heartbeat+'Z' : null,
|
||||
|
||||
info_hostname: obj.info_hostname,
|
||||
info_ip_list: obj.info_ip_list,
|
||||
|
||||
meta_json: obj.meta_json,
|
||||
other_json: obj.other_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// From SQL view
|
||||
event_name: obj.event_name,
|
||||
event_location_code: obj.event_location_code,
|
||||
event_location_name: obj.event_location_name,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.event_device_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.event_device_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_events.devices.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.event_device_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_device_id',
|
||||
'event_device_id_random',
|
||||
|
||||
'event_id',
|
||||
'event_id_random',
|
||||
'event_location_id',
|
||||
'event_location_id_random',
|
||||
|
||||
'code',
|
||||
'name',
|
||||
'description',
|
||||
|
||||
'passcode',
|
||||
|
||||
'local_file_cache_path',
|
||||
'host_file_temp_path',
|
||||
'recording_path',
|
||||
|
||||
'record_audio',
|
||||
'record_video',
|
||||
|
||||
'trigger_open_file_id',
|
||||
'trigger_open_session_id',
|
||||
'trigger_recording_start',
|
||||
'trigger_recording_stop',
|
||||
'trigger_reset',
|
||||
'trigger_show_admin',
|
||||
'trigger_show_hidden',
|
||||
|
||||
'alert',
|
||||
'alert_msg',
|
||||
'alert_on',
|
||||
'status',
|
||||
'status_msg',
|
||||
'status_on',
|
||||
'record_status',
|
||||
'record_status_msg',
|
||||
'record_status_on',
|
||||
'heartbeat',
|
||||
|
||||
'info_hostname',
|
||||
'info_ip_list',
|
||||
|
||||
'meta_json',
|
||||
'other_json',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
// 'tmp_sort_a',
|
||||
// 'tmp_sort_b',
|
||||
|
||||
// From SQL view
|
||||
'event_name',
|
||||
'event_location_code',
|
||||
'event_location_name',
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export async function process_ae_obj__event_device_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_location_props() ***`, obj_li);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj event_device:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.event_device_id_random,
|
||||
event_device_id: obj.event_device_id_random,
|
||||
event_device_id_random: obj.event_device_id_random,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
event_location_id: obj.event_location_id_random,
|
||||
event_location_id_random: obj.event_location_id_random,
|
||||
|
||||
code: obj.code,
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
local_file_cache_path: obj.local_file_cache_path,
|
||||
host_file_temp_path: obj.host_file_temp_path,
|
||||
recording_path: obj.recording_path,
|
||||
|
||||
record_audio: obj.record_audio,
|
||||
record_video: obj.record_video,
|
||||
|
||||
trigger_open_file_id: obj.trigger_open_file_id,
|
||||
trigger_open_session_id: obj.trigger_open_session_id,
|
||||
trigger_recording_start: obj.trigger_recording_start,
|
||||
trigger_recording_stop: obj.trigger_recording_stop,
|
||||
trigger_reset: obj.trigger_reset,
|
||||
trigger_show_admin: obj.trigger_show_admin,
|
||||
trigger_show_hidden: obj.trigger_show_hidden,
|
||||
|
||||
alert: obj.alert,
|
||||
alert_msg: obj.alert_msg,
|
||||
alert_on: obj.alert_on,
|
||||
status: obj.status,
|
||||
status_msg: obj.status_msg,
|
||||
status_on: obj.status_on,
|
||||
record_status: obj.record_status,
|
||||
record_status_msg: obj.record_status_msg,
|
||||
record_status_on: obj.record_status_on,
|
||||
// These are timestamps that are in UTC but missing the 'Z' at the end
|
||||
heartbeat: obj.heartbeat ? obj.heartbeat+'Z' : null,
|
||||
|
||||
info_hostname: obj.info_hostname,
|
||||
info_ip_list: obj.info_ip_list,
|
||||
|
||||
meta_json: obj.meta_json,
|
||||
other_json: obj.other_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
event_name: obj.event_name,
|
||||
event_location_code: obj.event_location_code,
|
||||
event_location_name: obj.event_location_name,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
613
src/lib/ae_events__event.ts
Normal file
613
src/lib/ae_events__event.ts
Normal file
@@ -0,0 +1,613 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_events } from "$lib/db_events";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function load_ae_obj_id__event(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
inc_file_li = false,
|
||||
inc_location_li = false,
|
||||
inc_presentation_li = false,
|
||||
inc_presenter_li = false,
|
||||
inc_session_li = false,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
inc_file_li?: boolean,
|
||||
inc_location_li?: boolean,
|
||||
inc_presentation_li?: boolean,
|
||||
inc_presenter_li?: boolean,
|
||||
inc_session_li?: boolean,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** load_ae_obj_id__event() *** event_id=${event_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
// $events_sess.badges.status_load__event_obj = 'loading';
|
||||
ae_promises.load__event_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event',
|
||||
obj_id: event_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_get_result) {
|
||||
if (event_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// This is expecting a list
|
||||
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.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
return ae_promises.load__event_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-27
|
||||
export async function load_ae_obj_li__event(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type = 'account',
|
||||
for_obj_id,
|
||||
qry_conference = true,
|
||||
qry_str = null,
|
||||
inc_file_li = false,
|
||||
inc_location_li = false,
|
||||
inc_presentation_li = false,
|
||||
inc_presenter_li = false,
|
||||
inc_session_li = false,
|
||||
order_by_li = {'start_datetime': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params_json = null,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
qry_conference?: null|boolean,
|
||||
qry_str?: null|string,
|
||||
inc_file_li?: boolean,
|
||||
inc_location_li?: boolean,
|
||||
inc_presentation_li?: boolean,
|
||||
inc_presenter_li?: boolean,
|
||||
inc_session_li?: boolean,
|
||||
order_by_li?: key_val,
|
||||
params_json?: null|key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** load_ae_obj_li__event() *** for_obj_id=${for_obj_id}`);
|
||||
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
// There is probably a better way to handle this. I don't want to just start a new object if it is not passed. However, the qry_conference and qry_str are sort of a special case. -2024-10-01
|
||||
if (!params_json) {
|
||||
params_json = {};
|
||||
}
|
||||
|
||||
if (qry_conference) {
|
||||
if (!params_json['and_qry']) {
|
||||
params_json['and_qry'] = {};
|
||||
}
|
||||
|
||||
params_json['and_qry']['conference'] = qry_conference;
|
||||
} else if (qry_conference === false) {
|
||||
if (!params_json['and_qry']) {
|
||||
params_json['and_qry'] = {};
|
||||
}
|
||||
|
||||
console.log('qry_conference is false!');
|
||||
params_json['and_qry']['conference'] = qry_conference;
|
||||
}
|
||||
|
||||
if (qry_str) {
|
||||
if (!params_json['ft_qry']) {
|
||||
params_json['ft_qry'] = {};
|
||||
}
|
||||
|
||||
params_json['ft_qry'] = {};
|
||||
params_json['ft_qry']['default_qry_str'] = qry_str;
|
||||
params_json['ft_qry']['location_address_json_ext'] = qry_str;
|
||||
params_json['ft_qry']['contact_li_json_ext'] = qry_str;
|
||||
}
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
// ae_promises.load__event_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
// api_cfg: api_cfg,
|
||||
// obj_type: 'event',
|
||||
// for_obj_type: for_obj_type,
|
||||
// for_obj_id: for_obj_id,
|
||||
// use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
// use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
// enabled: enabled,
|
||||
// hidden: hidden,
|
||||
// order_by_li: order_by_li,
|
||||
// limit: limit,
|
||||
// offset: offset,
|
||||
// params_json: params_json,
|
||||
// params: params,
|
||||
// log_lvl: log_lvl
|
||||
// })
|
||||
ae_promises.load__event_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
// use_alt_mdl: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_li_get_result) {
|
||||
if (event_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event({obj_type: 'event', obj_li: event_obj_li_get_result});
|
||||
}
|
||||
return event_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_obj_li:', ae_promises.load__event_obj_li);
|
||||
}
|
||||
return ae_promises.load__event_obj_li;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// The qry_ae_obj_li__event() is essentially a wrapper for the load_ae_obj_li__event() function. This should process the query strings and related before calling the load_ae_obj_li__event() function.
|
||||
// Updated 2024-10-01
|
||||
export async function qry_ae_obj_li__event(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type = 'account',
|
||||
for_obj_id,
|
||||
qry_conference = true,
|
||||
qry_physical = null,
|
||||
qry_virtual = null,
|
||||
qry_type = null,
|
||||
qry_str = null,
|
||||
inc_file_li = false,
|
||||
inc_location_li = false,
|
||||
inc_presentation_li = false,
|
||||
inc_presenter_li = false,
|
||||
inc_session_li = false,
|
||||
order_by_li = {'start_datetime': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
qry_conference?: null|boolean,
|
||||
qry_physical?: null|boolean,
|
||||
qry_virtual?: null|boolean,
|
||||
qry_type?: null|string,
|
||||
qry_str?: null|string,
|
||||
inc_file_li?: boolean,
|
||||
inc_location_li?: boolean,
|
||||
inc_presentation_li?: boolean,
|
||||
inc_presenter_li?: boolean,
|
||||
inc_session_li?: boolean,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** qry_ae_obj_li__event() *** for_obj_id=${for_obj_id}`);
|
||||
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
// Build the params_json object. This needs to be documented better! -2024-10-01
|
||||
let params_json: key_val = {};
|
||||
|
||||
params_json['and_qry'] = {};
|
||||
|
||||
// This is handled in the actual load_ae_obj_li__event() function. For now...?
|
||||
// if (qry_conference) {
|
||||
// params_json['and_qry']['conference'] = qry_conference;
|
||||
// } else if (qry_conference === false) {
|
||||
// console.log('qry_conference is false!');
|
||||
// params_json['and_qry']['conference'] = qry_conference;
|
||||
// }
|
||||
|
||||
if (qry_physical && qry_virtual) {
|
||||
// Ignore both if both are set to true.
|
||||
} else if (qry_physical || qry_virtual) {
|
||||
if (qry_physical) {
|
||||
params_json['and_qry']['physical'] = qry_physical;
|
||||
}
|
||||
if (qry_virtual) {
|
||||
params_json['and_qry']['virtual'] = qry_virtual;
|
||||
}
|
||||
}
|
||||
|
||||
if (qry_type) {
|
||||
params_json['and_qry']['type'] = qry_type;
|
||||
}
|
||||
|
||||
if (qry_str) {
|
||||
params_json['ft_qry'] = {};
|
||||
params_json['ft_qry']['default_qry_str'] = qry_str;
|
||||
params_json['ft_qry']['location_address_json_ext'] = qry_str;
|
||||
params_json['ft_qry']['contact_li_json_ext'] = qry_str;
|
||||
}
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('params_json:', params_json);
|
||||
}
|
||||
|
||||
ae_promises.qry__event_obj_li = await load_ae_obj_li__event({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
qry_conference: qry_conference,
|
||||
qry_str: qry_str,
|
||||
inc_file_li: inc_file_li,
|
||||
inc_location_li: inc_location_li,
|
||||
inc_presentation_li: inc_presentation_li,
|
||||
inc_presenter_li: inc_presenter_li,
|
||||
inc_session_li: inc_session_li,
|
||||
order_by_li: order_by_li,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
return ae_promises.qry__event_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function create_ae_obj__event(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** create_ae_obj__event() *** account_id=${account_id}`);
|
||||
|
||||
ae_promises.create__event = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event',
|
||||
fields: {
|
||||
account_id_random: account_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_create_result) {
|
||||
if (event_obj_create_result) {
|
||||
db_save_ae_obj_li__event(
|
||||
{
|
||||
obj_type: 'event',
|
||||
obj_li: [event_obj_create_result]
|
||||
});
|
||||
return event_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__event:', ae_promises.create__event);
|
||||
}
|
||||
return ae_promises.create__event;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__event(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__event() *** event_id=${event_id}`, data_kv);
|
||||
}
|
||||
// ae_promises.update__event_obj = 'test';
|
||||
ae_promises.update__event_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event',
|
||||
obj_id: event_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_obj_update_result) {
|
||||
if (event_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event({
|
||||
obj_type: 'event', obj_li: [event_obj_update_result]
|
||||
});
|
||||
}
|
||||
return event_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__event_obj:', ae_promises.update__event_obj);
|
||||
}
|
||||
return ae_promises.update__event_obj;
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the event_obj_li and save each one to the DB.
|
||||
export function db_save_ae_obj_li__event(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__event() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_events.events.put({
|
||||
id: obj.event_id_random,
|
||||
// id_random: obj.event_id_random,
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
|
||||
code: obj.event_code,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
account_id_random: obj.account_id_random,
|
||||
|
||||
conference: obj.conference,
|
||||
type: obj.type,
|
||||
name: obj.name,
|
||||
summary: obj.summary,
|
||||
description: obj.description,
|
||||
|
||||
start_datetime: obj.start_datetime,
|
||||
end_datetime: obj.end_datetime,
|
||||
timezone: obj.timezone,
|
||||
location_address_json: obj.location_address_json,
|
||||
|
||||
mod_abstracts_json: obj.mod_abstracts_json,
|
||||
mod_badges_json: obj.mod_badges_json,
|
||||
mod_exhibits_json: obj.mod_exhibits_json,
|
||||
mod_pres_mgmt_json: obj.mod_pres_mgmt_json,
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// IDAA Recovery Meetings
|
||||
contact_li_json: obj.contact_li_json,
|
||||
external_person_id: obj.external_person_id,
|
||||
|
||||
physical: obj.physical,
|
||||
virtual: obj.virtual,
|
||||
|
||||
weekday_sunday: obj.weekday_sunday,
|
||||
weekday_monday: obj.weekday_monday,
|
||||
weekday_tuesday: obj.weekday_tuesday,
|
||||
weekday_wednesday: obj.weekday_wednesday,
|
||||
weekday_thursday: obj.weekday_thursday,
|
||||
weekday_friday: obj.weekday_friday,
|
||||
weekday_saturday: obj.weekday_saturday,
|
||||
|
||||
recurring_start_time: obj.recurring_start_time,
|
||||
|
||||
// From SQL view
|
||||
file_count: obj.file_count,
|
||||
file_count_all: obj.file_count_all,
|
||||
internal_use_count: obj.internal_use_count,
|
||||
event_file_id_li_json: obj.event_file_id_li_json,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.event_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.event_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_events.events.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.event_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This function will process the event config, specifically for presentation management.
|
||||
export function sync_config__event_pres_mgmt(
|
||||
{
|
||||
pres_mgmt_cfg_remote, // This is the remote config that will be compared.
|
||||
pres_mgmt_cfg_local, // This is the local config that will be updated.
|
||||
log_lvl = 0
|
||||
}: {
|
||||
pres_mgmt_cfg_remote: key_val,
|
||||
pres_mgmt_cfg_local: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** sync_config__event_pres_mgmt() *** pres_mgmt_cfg_remote:`, pres_mgmt_cfg_remote);
|
||||
}
|
||||
|
||||
// Deal with things that can not be overridden first:
|
||||
// Labels:
|
||||
pres_mgmt_cfg_local.label__presenter_external_id = pres_mgmt_cfg_remote?.label__presenter_external_id ?? 'External ID';
|
||||
|
||||
pres_mgmt_cfg_local.label__session_poc_type = pres_mgmt_cfg_remote?.label__session_poc_type ?? 'poc';
|
||||
pres_mgmt_cfg_local.label__session_poc_name = pres_mgmt_cfg_remote?.label__session_poc_name_short ?? 'POC';
|
||||
pres_mgmt_cfg_local.label__session_poc_name = pres_mgmt_cfg_remote?.label__session_poc_name ?? 'Point of Contact';
|
||||
|
||||
// Hide content:
|
||||
|
||||
pres_mgmt_cfg_local.hide__session_poc = pres_mgmt_cfg_remote?.hide__session_poc ?? false;
|
||||
|
||||
// pres_mgmt_cfg_local.hide__report_kv = pres_mgmt_cfg_remote?.hide__report_kv ?? null;
|
||||
|
||||
// pres_mgmt_cfg_local.limit__navigation = pres_mgmt_cfg_remote?.limit__navigation ?? false;
|
||||
// pres_mgmt_cfg_local.limit__options = pres_mgmt_cfg_remote?.limit__options ?? false;
|
||||
|
||||
// Required fields or options (agreements):
|
||||
pres_mgmt_cfg_local.require__presenter_agree = pres_mgmt_cfg_remote?.require__presenter_agree ?? false; // In use
|
||||
pres_mgmt_cfg_local.require__session_agree = pres_mgmt_cfg_remote?.require__session_agree ?? false; // New and in progress
|
||||
|
||||
// Show content:
|
||||
// pres_mgmt_cfg_local.show__navigation = pres_mgmt_cfg_remote?.show__navigation ?? false;
|
||||
|
||||
pres_mgmt_cfg_local.file_purpose_option_kv = pres_mgmt_cfg_remote?.file_purpose_option_kv ?? null;
|
||||
|
||||
// Deal with things that can be overridden:
|
||||
|
||||
// Locking the config is targeted at the trusted staff level and below. It is more or less ignored at the global manager and super levels. It may be enforced at the staff admin level?
|
||||
// pres_mgmt_cfg_local.lock_config = pres_mgmt_cfg_remote?.lock_config ? true : false; // This disables the sync local config button and options.
|
||||
if (pres_mgmt_cfg_local.lock_config) {
|
||||
console.log(`The config should be locked! Forcing the sync!`);
|
||||
// This is to forcibly sync the local config with the remote config.
|
||||
pres_mgmt_cfg_local.sync_local_config = true;
|
||||
} else {
|
||||
// Do not override the preference for syncing the local config with the remote config.
|
||||
console.log(`The config is not locked. Currently set to sync? ${pres_mgmt_cfg_local.sync_local_config}`);
|
||||
|
||||
// Check if the sync_local_config is undefined versus just false.
|
||||
// if (pres_mgmt_cfg_local?.sync_local_config) {
|
||||
// pres_mgmt_cfg_local.sync_local_config = true;
|
||||
// } else {
|
||||
// pres_mgmt_cfg_local.sync_local_config = pres_mgmt_cfg_remote?.sync_local_config ?? false;
|
||||
// }
|
||||
}
|
||||
|
||||
if (pres_mgmt_cfg_local?.sync_local_config) {
|
||||
if (log_lvl) {
|
||||
console.log(`Syncing the local config with the remote config!!!`);
|
||||
}
|
||||
// Hide content:
|
||||
pres_mgmt_cfg_local.hide__location_code = pres_mgmt_cfg_remote?.hide__location_code ?? false;
|
||||
|
||||
pres_mgmt_cfg_local.hide__presentation_code = pres_mgmt_cfg_remote?.hide__presentation_code ?? false;
|
||||
|
||||
pres_mgmt_cfg_local.hide__presenter_code = pres_mgmt_cfg_remote?.hide__presenter_code ?? false;
|
||||
pres_mgmt_cfg_local.hide__presenter_biography = pres_mgmt_cfg_remote?.hide__presenter_biography ?? false;
|
||||
|
||||
pres_mgmt_cfg_local.hide__session_code = pres_mgmt_cfg_remote?.hide__session_code ?? false;
|
||||
pres_mgmt_cfg_local.hide__session_description = pres_mgmt_cfg_remote?.hide__session_description ?? false;
|
||||
pres_mgmt_cfg_local.hide__session_location = pres_mgmt_cfg_remote?.hide__session_location ?? false;
|
||||
pres_mgmt_cfg_local.hide__session_msg = pres_mgmt_cfg_remote?.hide__session_msg ?? false;
|
||||
|
||||
// pres_mgmt_cfg_local.hide__session_li_poc_field = pres_mgmt_cfg_remote?.hide__session_li_poc_field ?? false; // This should still allow the POC name to be shown.
|
||||
pres_mgmt_cfg_local.hide__session_poc_profile = pres_mgmt_cfg_remote?.hide__session_poc_profile ?? false; // This should still allow the POC name to be shown.
|
||||
pres_mgmt_cfg_local.hide__session_poc_biography = pres_mgmt_cfg_remote?.hide__session_poc_biography ?? false; // New and in progress
|
||||
pres_mgmt_cfg_local.hide__session_poc_profile_pic = pres_mgmt_cfg_remote?.hide__session_poc_profile_pic ?? false; // New and in progress
|
||||
|
||||
pres_mgmt_cfg_local.show__copy_access_link = pres_mgmt_cfg_remote?.show__copy_access_link ?? false;
|
||||
pres_mgmt_cfg_local.show__email_access_link = pres_mgmt_cfg_remote?.show__email_access_link ?? false;
|
||||
pres_mgmt_cfg_local.show__launcher_link = pres_mgmt_cfg_remote?.show__launcher_link ?? false;
|
||||
pres_mgmt_cfg_local.show__launcher_link_legacy = pres_mgmt_cfg_remote?.show__launcher_link_legacy ?? false;
|
||||
}
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`pres_mgmt_cfg_local:`, pres_mgmt_cfg_local);
|
||||
}
|
||||
return pres_mgmt_cfg_local;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_events } from "$lib/ae_events/db_events";
|
||||
import { db_events } from "$lib/db_events";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
@@ -135,60 +135,6 @@ export async function handle_load_ae_obj_li__badge(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-11-08
|
||||
export async function delete_ae_obj_id__event_badge(
|
||||
{
|
||||
api_cfg,
|
||||
event_badge_id,
|
||||
method = 'delete', // 'delete', 'disable', 'hide'
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_badge_id: string,
|
||||
method?: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** delete_ae_obj_id__event_badge() *** event_badge_id=${event_badge_id}`);
|
||||
}
|
||||
|
||||
ae_promises.delete__event_badge_obj = await api.delete_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_badge',
|
||||
obj_id: event_badge_id,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
method: method,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_badge_obj_delete_result) {
|
||||
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
if (try_cache) {
|
||||
if (log_lvl) {
|
||||
console.log(`Attempting to remove IDB entry for event_badge_id=${event_badge_id}`);
|
||||
}
|
||||
db_events.badges.delete(event_badge_id);
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.delete__event_badge_obj:', ae_promises.delete__event_badge_obj);
|
||||
}
|
||||
|
||||
return ae_promises.delete__event_badge_obj;
|
||||
}
|
||||
|
||||
|
||||
export async function handle_search__event_badge(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -1,13 +1,12 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
||||
import { db_events } from "$lib/ae_events/db_events";
|
||||
import { db_events } from "$lib/db_events";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2025-07-21
|
||||
// Updated 2024-06-14
|
||||
export async function load_ae_obj_id__event_file(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -21,9 +20,7 @@ export async function load_ae_obj_id__event_file(
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__event_file() *** event_file_id=${event_file_id}`);
|
||||
}
|
||||
console.log(`*** load_ae_obj_id__event_file() *** event_file_id=${event_file_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
@@ -36,35 +33,10 @@ export async function load_ae_obj_id__event_file(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_file_obj_get_result) {
|
||||
.then(function (event_file_obj_get_result) {
|
||||
if (event_file_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_file_props({
|
||||
obj_li: [event_file_obj_get_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'files',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// This is expecting a list
|
||||
// db_save_ae_obj_li__event_file({obj_type: 'event_file', obj_li: [event_file_obj_get_result]});
|
||||
}
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__event_file({obj_type: 'event_file', obj_li: [event_file_obj_get_result]});
|
||||
return event_file_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
@@ -79,17 +51,12 @@ export async function load_ae_obj_id__event_file(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-07-21
|
||||
// Updated 2024-07-03
|
||||
export async function load_ae_obj_li__event_file(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
@@ -97,75 +64,49 @@ export async function load_ae_obj_li__event_file(
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
enabled?: string, // all, disabled, enabled
|
||||
hidden?: string, // all, hidden, not_hidden
|
||||
limit?: number, // 99
|
||||
offset?: number, // 0
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__event_file() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
}
|
||||
console.log(`*** load_ae_obj_li__event_file() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
|
||||
// Check if for_obj_type is in the list of valid Aether object types:
|
||||
let valid_for_obj_types = ['event', 'event_session', 'event_presentation', 'event_presenter', 'event_location', 'event_badge', 'event_device'];
|
||||
let valid_for_obj_types = ['event', 'event_session', 'event_presentation', 'event_presenter', 'event_location'];
|
||||
if (!valid_for_obj_types.includes(for_obj_type)) {
|
||||
console.log(`Invalid for_obj_type: ${for_obj_type}`);
|
||||
return [];
|
||||
}
|
||||
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'all'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
ae_promises.load__event_file_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
ae_promises.load__event_file_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_file',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_mdl: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
use_alt_exp: false,
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_file_obj_li_get_result) {
|
||||
.then(function (event_file_obj_li_get_result) {
|
||||
if (event_file_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_file_props({
|
||||
obj_li: event_file_obj_li_get_result,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'files',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_file({obj_type: 'event_file', obj_li: event_file_obj_li_get_result});
|
||||
db_save_ae_obj_li__event_file({obj_type: 'event_file', obj_li: event_file_obj_li_get_result});
|
||||
}
|
||||
return event_file_obj_li_get_result;
|
||||
} else {
|
||||
@@ -184,8 +125,42 @@ export async function load_ae_obj_li__event_file(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-07-21
|
||||
// This may need to be reviewed again???
|
||||
// Updated 2024-06-17
|
||||
export async function delete_ae_obj_id__event_file(
|
||||
{
|
||||
api_cfg,
|
||||
event_file_id,
|
||||
params = {},
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_file_id: string,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** delete_ae_obj_id__event_file() *** event_file_id=${event_file_id}`);
|
||||
|
||||
const endpoint = `/event/file/${event_file_id}/v2`;
|
||||
|
||||
params['delete_hosted_file'] = true; // This does not actually delete the hosted file from the server.
|
||||
params['rm_orphan'] = true; // This is what actually allows the hosted file to be deleted from the server.
|
||||
|
||||
ae_promises.delete__event_file_obj = await api.delete_object({
|
||||
api_cfg: api_cfg,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
// return_meta: return_meta,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
db_events.files.delete(event_file_id);
|
||||
|
||||
return ae_promises.delete__event_file_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-14
|
||||
export async function create_event_file_obj_from_hosted_file_async(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -208,14 +183,7 @@ export async function create_event_file_obj_from_hosted_file_async(
|
||||
}
|
||||
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** create_event_file_obj_from_hosted_file_async() *** hosted_file_id=${hosted_file_id}`);
|
||||
}
|
||||
|
||||
if (!hosted_file_id) {
|
||||
console.log(`ERROR: Events Launcher - Event File - hosted_file_id required to create`);
|
||||
return false;
|
||||
}
|
||||
console.log('*** ae_events_functions.js: create_event_file_obj_from_hosted_file() ***');
|
||||
|
||||
let endpoint = `/event/file/from_hosted_file/${hosted_file_id}`;
|
||||
if (return_obj) {
|
||||
@@ -254,70 +222,19 @@ export async function create_event_file_obj_from_hosted_file_async(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-07-21
|
||||
export async function delete_ae_obj_id__event_file(
|
||||
{
|
||||
api_cfg,
|
||||
event_file_id,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_file_id: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** delete_ae_obj_id__event_file() *** event_file_id=${event_file_id}`);
|
||||
}
|
||||
|
||||
const endpoint = `/event/file/${event_file_id}/v2`;
|
||||
|
||||
params['delete_hosted_file'] = true; // This does not actually delete the hosted file from the server.
|
||||
params['rm_orphan'] = true; // This is what actually allows the hosted file to be deleted from the server.
|
||||
|
||||
ae_promises.delete__event_file_obj = await api.delete_object({
|
||||
api_cfg: api_cfg,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
// return_meta: return_meta,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.finally(function () {
|
||||
if (try_cache) {
|
||||
if (log_lvl) {
|
||||
console.log(`Attempting to remove IDB entry for event_file_id=${event_file_id}`);
|
||||
}
|
||||
db_events.files.delete(event_file_id); // Delete from the DB no matter what.
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.delete__event_file_obj:', ae_promises.delete__event_file_obj);
|
||||
}
|
||||
|
||||
return ae_promises.delete__event_file_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-07-21
|
||||
// Updated 2024-06-13
|
||||
export async function update_ae_obj__event_file(
|
||||
{
|
||||
api_cfg,
|
||||
event_file_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
log_lvl = 1
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_file_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
@@ -325,8 +242,7 @@ export async function update_ae_obj__event_file(
|
||||
console.log(`*** update_ae_obj__event_file() *** event_file_id=${event_file_id}`);
|
||||
}
|
||||
|
||||
// Perform the API update
|
||||
const result = await api.update_ae_obj_id_crud({
|
||||
ae_promises.update__event_file_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_file',
|
||||
obj_id: event_file_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
@@ -336,175 +252,35 @@ export async function update_ae_obj__event_file(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
// Handle the result
|
||||
if (result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_file_props({
|
||||
obj_li: [result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'files',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// await db_save_ae_obj_li__event_file({
|
||||
// obj_type: 'event_file',
|
||||
// obj_li: [result],
|
||||
// log_lvl: log_lvl,
|
||||
// });
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
console.error('Failed to update event file.');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This new function is using CRUD v2. This should allow for more flexibility in the queries.
|
||||
// Updated 2025-07-21
|
||||
export async function qry__event_file(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
qry_created_on = null, // Example greater than: '2024-10-24'
|
||||
qry_min_file_size = null,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 50,
|
||||
offset = 0,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'created_on': 'DESC', 'updated_on': 'DESC', 'filename': 'ASC', 'extension': 'ASC', 'hosted_file_size': 'ASC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: any,
|
||||
qry_created_on?: null|string,
|
||||
qry_min_file_size?: null|number,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
order_by_li?: key_val,
|
||||
params?: any,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** qry__event_file() *** event_id=${event_id}`);
|
||||
}
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
params_json['qry'] = [];
|
||||
|
||||
if (qry_created_on) {
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "created_on",
|
||||
operator: ">",
|
||||
value: qry_created_on
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
}
|
||||
|
||||
if (qry_min_file_size) {
|
||||
console.log('qry_min_file_size:', qry_min_file_size);
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "hosted_file_size",
|
||||
operator: ">",
|
||||
value: qry_min_file_size
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
}
|
||||
|
||||
ae_promises.load__event_file_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_file',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_tbl: true, // NOTE: We want to use the alt table for file searching?
|
||||
use_alt_mdl: false,
|
||||
use_alt_exp: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_file_obj_li_get_result) {
|
||||
if (event_file_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
process_ae_obj__event_file_props({
|
||||
obj_li: event_file_obj_li_get_result,
|
||||
log_lvl: log_lvl,
|
||||
})
|
||||
.then(async function (processed_obj_li) {
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'files',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_file({obj_type: 'event_file', obj_li: event_file_obj_li_get_result});
|
||||
return event_file_obj_li_get_result;
|
||||
.then(function (event_file_obj_update_result) {
|
||||
if (event_file_obj_update_result) {
|
||||
// db_save_ae_obj_li__event_file({obj_type: 'event_file', obj_li: [event_file_obj_update_result]});
|
||||
// Very important: The results returned from the API does not include fields from the DB views. It is the actual table fields only.
|
||||
db_update_ae_obj_id__event_file({obj_type: 'event_file', obj_id: event_file_id, data_kv: event_file_obj_update_result});
|
||||
return event_file_obj_update_result;
|
||||
} else {
|
||||
return [];
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_file_obj_li:', ae_promises.load__event_file_obj_li);
|
||||
console.log('ae_promises.update__event_file_obj:', ae_promises.update__event_file_obj);
|
||||
}
|
||||
return ae_promises.load__event_file_obj_li;
|
||||
return ae_promises.update__event_file_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-07-21
|
||||
// Updated 2024-07-12
|
||||
export async function search__event_file(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
created_on = null,
|
||||
min_file_size = null,
|
||||
fulltext_search_qry_str,
|
||||
ft_file_search_qry_str,
|
||||
like_search_qry_str = null,
|
||||
@@ -518,7 +294,6 @@ export async function search__event_file(
|
||||
api_cfg: any,
|
||||
event_id: any,
|
||||
created_on?: null|string,
|
||||
min_file_size?: null|number,
|
||||
fulltext_search_qry_str?: null|string,
|
||||
ft_file_search_qry_str?: null|string,
|
||||
like_search_qry_str?: null|string,
|
||||
@@ -588,10 +363,6 @@ export async function search__event_file(
|
||||
// params_json['and_qry']['created_on'] = created_on;
|
||||
// }
|
||||
|
||||
if (min_file_size) {
|
||||
params_json['and_qry'] = {'hosted_file_size': {'>': min_file_size}};
|
||||
}
|
||||
|
||||
ae_promises.load__event_file_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_file',
|
||||
@@ -608,34 +379,9 @@ export async function search__event_file(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_file_obj_li_get_result) {
|
||||
.then(function (event_file_obj_li_get_result) {
|
||||
if (event_file_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_file_props({
|
||||
obj_li: event_file_obj_li_get_result,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'files',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_file({obj_type: 'event_file', obj_li: event_file_obj_li_get_result});
|
||||
}
|
||||
db_save_ae_obj_li__event_file({obj_type: 'event_file', obj_li: event_file_obj_li_get_result});
|
||||
return event_file_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
@@ -692,15 +438,10 @@ export function db_save_ae_obj_li__event_file(
|
||||
for_id: obj.for_id_id_random,
|
||||
for_id_random: obj.for_id_random,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
event_session_id: obj.event_session_id_random,
|
||||
event_session_id_random: obj.event_session_id_random,
|
||||
event_presentation_id: obj.event_presentation_id_random,
|
||||
event_presentation_id_random: obj.event_presentation_id_random,
|
||||
event_presenter_id: obj.event_presenter_id_random,
|
||||
event_presenter_id_random: obj.event_presenter_id_random,
|
||||
event_location_id: obj.event_location_id_random,
|
||||
event_location_id_random: obj.event_location_id_random,
|
||||
|
||||
filename: obj.filename,
|
||||
@@ -841,178 +582,3 @@ export function db_update_ae_obj_id__event_file(
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
// 'id_random',
|
||||
'event_file_id',
|
||||
'event_file_id_random',
|
||||
|
||||
'hosted_file_id',
|
||||
'hosted_file_id_random',
|
||||
'hash_sha256',
|
||||
|
||||
'for_type',
|
||||
'for_id',
|
||||
'for_id_random',
|
||||
|
||||
'event_id',
|
||||
// 'event_id_random',
|
||||
'event_session_id',
|
||||
// 'event_session_id_random',
|
||||
'event_presentation_id',
|
||||
// 'event_presentation_id_random',
|
||||
'event_presenter_id',
|
||||
// 'event_presenter_id_random',
|
||||
'event_location_id',
|
||||
// 'event_location_id_random',
|
||||
|
||||
'filename',
|
||||
'extension',
|
||||
|
||||
'open_in_os',
|
||||
|
||||
'lu_file_purpose_id',
|
||||
'lu_event_file_purpose_name',
|
||||
'file_purpose',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
// 'tmp_sort_a',
|
||||
// 'tmp_sort_b',
|
||||
|
||||
'filename_no_ext',
|
||||
'filename_w_ext',
|
||||
'hosted_file_content_type',
|
||||
'file_size',
|
||||
'hosted_file_size',
|
||||
|
||||
'event_location_code',
|
||||
'event_location_name',
|
||||
'event_session_code',
|
||||
'event_session_type_code',
|
||||
'event_session_name',
|
||||
'event_session_start_datetime',
|
||||
'event_session_end_datetime',
|
||||
'event_presentation_code',
|
||||
'event_presentation_type_code',
|
||||
'event_presentation_name',
|
||||
'event_presentation_start_datetime',
|
||||
'event_presentation_end_datetime',
|
||||
'event_presenter_given_name',
|
||||
'event_presenter_family_name',
|
||||
'event_presenter_full_name',
|
||||
'event_presenter_email',
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export async function process_ae_obj__event_file_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_file_props() ***`, obj_li);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj event_file:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.event_file_id_random,
|
||||
// id_random: obj.event_file_id_random,
|
||||
event_file_id: obj.event_file_id_random,
|
||||
event_file_id_random: obj.event_file_id_random,
|
||||
|
||||
hosted_file_id: obj.hosted_file_id_random,
|
||||
hosted_file_id_random: obj.hosted_file_id_random,
|
||||
hash_sha256: obj.hash_sha256,
|
||||
|
||||
for_type: obj.for_type,
|
||||
for_id: obj.for_id_random,
|
||||
for_id_random: obj.for_id_random,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
// event_id_random: obj.event_id_random,
|
||||
event_session_id: obj.event_session_id_random,
|
||||
// event_session_id_random: obj.event_session_id_random,
|
||||
event_presentation_id: obj.event_presentation_id_random,
|
||||
// event_presentation_id_random: obj.event_presentation_id_random,
|
||||
event_presenter_id: obj.event_presenter_id_random,
|
||||
// event_presenter_id_random: obj.event_presenter_id_random,
|
||||
event_location_id: obj.event_location_id_random,
|
||||
// event_location_id_random: obj.event_location_id_random,
|
||||
|
||||
filename: obj.filename,
|
||||
extension: obj.extension,
|
||||
|
||||
open_in_os: obj.open_in_os,
|
||||
|
||||
lu_file_purpose_id: obj.lu_file_purpose_id, // Not id_random in this case?
|
||||
lu_event_file_purpose_name: obj.lu_event_file_purpose_name,
|
||||
file_purpose: obj.file_purpose,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
filename_no_ext: obj.filename_no_ext,
|
||||
filename_w_ext: obj.filename_w_ext,
|
||||
hosted_file_content_type: obj.hosted_file_content_type,
|
||||
file_size: obj.file_size,
|
||||
hosted_file_size: obj.hosted_file_size,
|
||||
|
||||
event_location_code: obj.event_location_code,
|
||||
event_location_name: obj.event_location_name,
|
||||
event_session_code: obj.event_session_code,
|
||||
event_session_type_code: obj.event_session_type_code,
|
||||
event_session_name: obj.event_session_name,
|
||||
event_session_start_datetime: obj.event_session_start_datetime,
|
||||
event_session_end_datetime: obj.event_session_end_datetime,
|
||||
event_presentation_code: obj.event_presentation_code,
|
||||
event_presentation_type_code: obj.event_presentation_type_code,
|
||||
event_presentation_name: obj.event_presentation_name,
|
||||
event_presentation_start_datetime: obj.event_presentation_start_datetime,
|
||||
event_presentation_end_datetime: obj.event_presentation_end_datetime,
|
||||
event_presenter_given_name: obj.event_presenter_given_name,
|
||||
event_presenter_family_name: obj.event_presenter_family_name,
|
||||
event_presenter_full_name: obj.event_presenter_full_name,
|
||||
event_presenter_email: obj.event_presenter_email,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
@@ -1,17 +1,15 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
||||
import { db_events } from "$lib/ae_events/db_events";
|
||||
import { db_events } from "$lib/db_events";
|
||||
|
||||
import { load_ae_obj_li__event_device } from "$lib/ae_events/ae_events__event_device";
|
||||
import { load_ae_obj_li__event_file } from "$lib/ae_events/ae_events__event_file";
|
||||
import { load_ae_obj_li__event_file } from "$lib/ae_events__event_file";
|
||||
import { load_ae_obj_li__event_session } from './ae_events__event_session';
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
// Updated 2024-06-10
|
||||
export async function load_ae_obj_id__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -29,12 +27,11 @@ export async function load_ae_obj_id__event_location(
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__event_location() *** event_location_id=${event_location_id}`);
|
||||
}
|
||||
console.log(`*** load_ae_obj_id__event_location() *** event_location_id=${event_location_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
// $events_sess.badges.status_load__event_location_obj = 'loading';
|
||||
ae_promises.load__event_location_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
@@ -44,33 +41,14 @@ export async function load_ae_obj_id__event_location(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_location_obj_get_result) {
|
||||
.then(function (event_location_obj_get_result) {
|
||||
if (event_location_obj_get_result) {
|
||||
if (try_cache) {
|
||||
let processed_obj_li = await process_ae_obj__event_location_props({
|
||||
obj_li: [event_location_obj_get_result],
|
||||
log_lvl
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__event_location({
|
||||
obj_type: 'event_location',
|
||||
obj_li: [event_location_obj_get_result]
|
||||
});
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'locations',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// // This is expecting a list
|
||||
// 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 {
|
||||
@@ -86,11 +64,6 @@ export async function load_ae_obj_id__event_location(
|
||||
console.log('ae_promises.load__event_location_obj:', ae_promises.load__event_location_obj);
|
||||
}
|
||||
|
||||
if (ae_promises?.load__event_location_obj === null) {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
|
||||
if (inc_file_li) {
|
||||
// Load the files for the location
|
||||
if (log_lvl) {
|
||||
@@ -100,8 +73,7 @@ export async function load_ae_obj_id__event_location(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
enabled: 'all',
|
||||
limit: 15,
|
||||
params: {qry__enabled: 'all', qry__limit: 15},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -127,10 +99,24 @@ export async function load_ae_obj_id__event_location(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
enabled: 'all',
|
||||
limit: 15,
|
||||
params: {qry__enabled: 'all', qry__limit: 15},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then((event_session_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_session_obj_li = `, event_session_obj_li);
|
||||
}
|
||||
// if (try_cache) {
|
||||
// console.log(`ae_promises.load__event_session_obj = `, ae_promises.load__event_session_obj);
|
||||
// ae_promises.load__event_session_obj.event_session_li = event_session_obj_li;
|
||||
// // Re-save the session object with the new session list
|
||||
// db_save_ae_obj_li__event_session({
|
||||
// obj_type: 'event_session',
|
||||
// obj_li: [ae_promises.load__event_session_obj]
|
||||
// });
|
||||
// }
|
||||
return event_session_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
@@ -143,19 +129,14 @@ export async function load_ae_obj_id__event_location(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
// Updated 2024-09-24
|
||||
export async function load_ae_obj_li__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
inc_device_li = false,
|
||||
inc_file_li = false,
|
||||
inc_session_li = false,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 29,
|
||||
offset = 0,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'code': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
@@ -164,35 +145,32 @@ export async function load_ae_obj_li__event_location(
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
inc_device_li?: boolean,
|
||||
inc_file_li?: boolean,
|
||||
inc_session_li?: boolean,
|
||||
enabled?: string, // all, disabled, enabled
|
||||
hidden?: string, // all, hidden, not_hidden
|
||||
limit?: number, // 99
|
||||
offset?: number, // 0
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__event_location() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
}
|
||||
console.log(`*** load_ae_obj_li__event_location() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'all'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
// ae_promises.load__event_location_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
ae_promises.load__event_location_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
ae_promises.load__event_location_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
// use_alt_mdl: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
@@ -202,36 +180,13 @@ export async function load_ae_obj_li__event_location(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_location_obj_li_get_result) {
|
||||
.then(function (event_location_obj_li_get_result) {
|
||||
if (event_location_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_location_props({
|
||||
obj_li: event_location_obj_li_get_result,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'locations',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
db_save_ae_obj_li__event_location({
|
||||
obj_type: 'event_location',
|
||||
obj_li: event_location_obj_li_get_result
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// 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 {
|
||||
@@ -246,36 +201,6 @@ export async function load_ae_obj_li__event_location(
|
||||
console.log('ae_promises.load__event_location_obj_li:', ae_promises.load__event_location_obj_li);
|
||||
}
|
||||
|
||||
if (inc_device_li) {
|
||||
// Load the devices for the locations
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the device list for each location now`);
|
||||
}
|
||||
for (let i = 0; i < ae_promises.load__event_location_obj_li.length; i++) {
|
||||
let event_location_obj = ae_promises.load__event_location_obj_li[i];
|
||||
let event_location_id = event_location_obj.event_location_id_random;
|
||||
|
||||
let load_event_device_obj_li = load_ae_obj_li__event_device({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
params: {qry__enabled: enabled, qry__limit: limit},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then((event_device_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_device_obj_li = `, event_device_obj_li);
|
||||
}
|
||||
return event_device_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_device_obj_li = `, load_event_device_obj_li);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inc_file_li) {
|
||||
// Load the files for the locations
|
||||
if (log_lvl) {
|
||||
@@ -289,8 +214,7 @@ export async function load_ae_obj_li__event_location(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
enabled: enabled,
|
||||
limit: limit,
|
||||
params: {qry__enabled: enabled, qry__limit: limit},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -320,8 +244,7 @@ export async function load_ae_obj_li__event_location(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
enabled: enabled,
|
||||
limit: limit,
|
||||
params: {qry__enabled: enabled, qry__limit: limit},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -342,27 +265,23 @@ export async function load_ae_obj_li__event_location(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
// Updated 2024-06-25
|
||||
export async function create_ae_obj__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** create_ae_obj__event_location() *** event_id=${event_id}`);
|
||||
}
|
||||
console.log(`*** create_ae_obj__event_location() *** event_id=${event_id}`);
|
||||
|
||||
ae_promises.create__event_location = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
@@ -376,38 +295,13 @@ export async function create_ae_obj__event_location(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_location_obj_create_result) {
|
||||
.then(function (event_location_obj_create_result) {
|
||||
if (event_location_obj_create_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_location_props({
|
||||
obj_li: [event_location_obj_create_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'locations',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
db_save_ae_obj_li__event_location(
|
||||
{
|
||||
obj_type: 'event_location',
|
||||
obj_li: [event_location_obj_create_result]
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_location(
|
||||
// {
|
||||
// obj_type: 'event_location',
|
||||
// obj_li: [event_location_obj_create_result]
|
||||
// });
|
||||
}
|
||||
return event_location_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
@@ -426,58 +320,7 @@ export async function create_ae_obj__event_location(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export async function delete_ae_obj_id__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
event_location_id,
|
||||
method = 'delete', // 'delete', 'disable', 'hide'
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_location_id: string,
|
||||
method?: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** delete_ae_obj_id__event_location() *** event_location_id=${event_location_id}`);
|
||||
}
|
||||
|
||||
ae_promises.delete__event_location_obj = await api.delete_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
obj_id: event_location_id,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
method: method,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
if (try_cache) {
|
||||
if (log_lvl) {
|
||||
console.log(`Attempting to remove IDB entry for event_location_id=${event_location_id}`);
|
||||
}
|
||||
db_events.locations.delete(event_location_id);
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.delete__event_location_obj:', ae_promises.delete__event_location_obj);
|
||||
}
|
||||
|
||||
return ae_promises.delete__event_location_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -508,35 +351,12 @@ export async function update_ae_obj__event_location(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_location_obj_update_result) {
|
||||
.then(function (event_location_obj_update_result) {
|
||||
if (event_location_obj_update_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_location_props({
|
||||
obj_li: [event_location_obj_update_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'locations',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
db_save_ae_obj_li__event_location({
|
||||
obj_type: 'event_location', obj_li: [event_location_obj_update_result]
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_location({
|
||||
// obj_type: 'event_location', obj_li: [event_location_obj_update_result]
|
||||
// });
|
||||
}
|
||||
return event_location_obj_update_result;
|
||||
} else {
|
||||
@@ -556,7 +376,6 @@ export async function update_ae_obj__event_location(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export async function search__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -582,9 +401,7 @@ export async function search__event_location(
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** search__event_location() *** event_id=${event_id}`);
|
||||
}
|
||||
console.log(`*** search__event_location() *** 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
|
||||
@@ -642,14 +459,13 @@ export async function search__event_location(
|
||||
|
||||
let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
|
||||
|
||||
// ae_promises.load__event_location_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
ae_promises.load__event_location_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
ae_promises.load__event_location_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_tbl: true, // NOTE: We want to use the alt table for location searching
|
||||
// use_alt_mdl: false,
|
||||
use_alt_table: true, // NOTE: We want to use the alt table for location searching
|
||||
use_alt_base: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
@@ -661,9 +477,7 @@ export async function search__event_location(
|
||||
})
|
||||
.then(function (event_location_obj_li_get_result) {
|
||||
if (event_location_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event_location({obj_type: 'event_location', obj_li: event_location_obj_li_get_result});
|
||||
}
|
||||
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 [];
|
||||
@@ -768,130 +582,3 @@ export function db_save_ae_obj_li__event_location(
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_location_id',
|
||||
'event_location_id_random',
|
||||
|
||||
'external_id',
|
||||
'code',
|
||||
|
||||
'type_code',
|
||||
|
||||
'event_id',
|
||||
'event_id_random',
|
||||
|
||||
'name',
|
||||
'description',
|
||||
|
||||
'passcode',
|
||||
|
||||
'hide_event_launcher',
|
||||
|
||||
'alert',
|
||||
'alert_msg',
|
||||
|
||||
'data_json',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
// 'tmp_sort_a',
|
||||
// 'tmp_sort_b',
|
||||
|
||||
// From SQL view
|
||||
'file_count',
|
||||
'file_count_all',
|
||||
'internal_use_count',
|
||||
'event_file_id_li_json',
|
||||
|
||||
'event_name',
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export async function process_ae_obj__event_location_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_location_props() ***`, obj_li);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj event_location:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.event_location_id_random,
|
||||
event_location_id: obj.event_location_id_random,
|
||||
event_location_id_random: obj.event_location_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
code: obj.code,
|
||||
|
||||
type_code: obj.type_code,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
hide_event_launcher: obj.hide_event_launcher,
|
||||
|
||||
alert: obj.alert,
|
||||
alert_msg: obj.alert_msg,
|
||||
|
||||
data_json: obj.data_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
file_count: obj.file_count,
|
||||
file_count_all: obj.file_count_all,
|
||||
internal_use_count: obj.internal_use_count,
|
||||
event_file_id_li_json: obj.event_file_id_li_json,
|
||||
|
||||
event_name: obj.event_name,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
@@ -1,26 +1,20 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
||||
import { db_events } from "$lib/ae_events/db_events";
|
||||
|
||||
import { load_ae_obj_li__event_file } from "$lib/ae_events/ae_events__event_file";
|
||||
import { load_ae_obj_li__event_presenter } from "$lib/ae_events/ae_events__event_presenter";
|
||||
import { db_events } from "$lib/db_events";
|
||||
import { load_ae_obj_li__event_file } from "$lib/ae_events__event_file";
|
||||
import { load_ae_obj_li__event_presenter } from "$lib/ae_events__event_presenter";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2025-05-22
|
||||
// Updated 2024-10-08
|
||||
export async function load_ae_obj_id__event_presentation(
|
||||
{
|
||||
api_cfg,
|
||||
event_presentation_id,
|
||||
inc_file_li = false,
|
||||
inc_presenter_li = false,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 49,
|
||||
offset = 0,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
@@ -28,17 +22,11 @@ export async function load_ae_obj_id__event_presentation(
|
||||
event_presentation_id: string,
|
||||
inc_file_li?: boolean,
|
||||
inc_presenter_li?: boolean,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__event_presentation() *** event_presentation_id=${event_presentation_id}`);
|
||||
}
|
||||
console.log(`*** load_ae_obj_id__event_presentation() *** event_presentation_id=${event_presentation_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
@@ -51,38 +39,15 @@ export async function load_ae_obj_id__event_presentation(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_presentation_obj_get_result) {
|
||||
.then(function (event_presentation_obj_get_result) {
|
||||
if (event_presentation_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_presentation_props({
|
||||
obj_li: [event_presentation_obj_get_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'presentations',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__event_presentation({
|
||||
obj_type: 'event_presentation',
|
||||
obj_li: [event_presentation_obj_get_result]
|
||||
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// // This is expecting a list
|
||||
// db_save_ae_obj_li__event_presentation({
|
||||
// obj_type: 'event_presentation',
|
||||
// obj_li: [event_presentation_obj_get_result]
|
||||
|
||||
// });
|
||||
}
|
||||
return event_presentation_obj_get_result;
|
||||
} else {
|
||||
@@ -94,15 +59,6 @@ export async function load_ae_obj_id__event_presentation(
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_presentation_obj:', ae_promises.load__event_presentation_obj);
|
||||
}
|
||||
|
||||
if (ae_promises?.load__event_presentation_obj === null) {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
|
||||
if (inc_file_li) {
|
||||
// Load the files for the presentation
|
||||
if (log_lvl) {
|
||||
@@ -112,8 +68,7 @@ export async function load_ae_obj_id__event_presentation(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_presentation',
|
||||
for_obj_id: event_presentation_id,
|
||||
enabled: 'all',
|
||||
limit: 25,
|
||||
params: {qry__enabled: 'all', qry__limit: 25},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -140,12 +95,7 @@ export async function load_ae_obj_id__event_presentation(
|
||||
for_obj_type: 'event_presentation',
|
||||
for_obj_id: event_presentation_id,
|
||||
inc_file_li: inc_file_li,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
// order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
// params: params,
|
||||
params: {qry__enabled: 'all', qry__limit: 25},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -166,7 +116,7 @@ export async function load_ae_obj_id__event_presentation(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-22
|
||||
// Updated 2024-10-08
|
||||
export async function load_ae_obj_li__event_presentation(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -174,10 +124,6 @@ export async function load_ae_obj_li__event_presentation(
|
||||
for_obj_id,
|
||||
inc_file_li = false,
|
||||
inc_presenter_li = false,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 49,
|
||||
offset = 0,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
@@ -188,37 +134,30 @@ export async function load_ae_obj_li__event_presentation(
|
||||
for_obj_id: string,
|
||||
inc_file_li?: boolean,
|
||||
inc_presenter_li?: boolean,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__event_presentation() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
}
|
||||
console.log(`*** load_ae_obj_li__event_presentation() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
|
||||
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
// let limit: number = (params.qry__limit ?? 99); // 99
|
||||
// let offset: number = (params.qry__offset ?? 0); // 0
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console('params_json:', params_json);
|
||||
|
||||
// ae_promises.load__event_presentation_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
ae_promises.load__event_presentation_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
ae_promises.load__event_presentation_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_presentation',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
// use_alt_mdl: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
@@ -228,35 +167,12 @@ export async function load_ae_obj_li__event_presentation(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_presentation_obj_li_get_result) {
|
||||
.then(function (event_presentation_obj_li_get_result) {
|
||||
if (event_presentation_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_presentation_props({
|
||||
obj_li: event_presentation_obj_li_get_result,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'presentations',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
db_save_ae_obj_li__event_presentation({
|
||||
obj_type: 'event_presentation', obj_li: event_presentation_obj_li_get_result
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_presentation({
|
||||
// obj_type: 'event_presentation', obj_li: event_presentation_obj_li_get_result
|
||||
// });
|
||||
}
|
||||
return event_presentation_obj_li_get_result;
|
||||
} else {
|
||||
@@ -284,8 +200,7 @@ export async function load_ae_obj_li__event_presentation(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_presentation',
|
||||
for_obj_id: event_presentation_id,
|
||||
enabled: enabled,
|
||||
limit: limit,
|
||||
params: {qry__enabled: 'all', qry__limit: 25},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -316,13 +231,7 @@ export async function load_ae_obj_li__event_presentation(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_presentation',
|
||||
for_obj_id: event_presentation_id,
|
||||
inc_file_li: inc_file_li,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
// order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
// params: {},
|
||||
params: {qry__enabled: 'all', qry__limit: 25},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -344,7 +253,7 @@ export async function load_ae_obj_li__event_presentation(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-22
|
||||
// Updated 2024-06-24
|
||||
export async function create_ae_obj__event_presentation(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -352,7 +261,6 @@ export async function create_ae_obj__event_presentation(
|
||||
event_session_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
@@ -360,13 +268,10 @@ export async function create_ae_obj__event_presentation(
|
||||
event_session_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** create_ae_obj__event_presentation() *** event_id=${event_id} event_session_id=${event_session_id}`);
|
||||
}
|
||||
console.log(`*** create_ae_obj__event_presentation() *** event_id=${event_id} event_session_id=${event_session_id}`);
|
||||
|
||||
ae_promises.create__event_presentation = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
@@ -381,38 +286,13 @@ export async function create_ae_obj__event_presentation(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_presentation_obj_create_result) {
|
||||
.then(function (event_presentation_obj_create_result) {
|
||||
if (event_presentation_obj_create_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_presentation_props({
|
||||
obj_li: [event_presentation_obj_create_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'presentations',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
db_save_ae_obj_li__event_presentation(
|
||||
{
|
||||
obj_type: 'event_presentation',
|
||||
obj_li: [event_presentation_obj_create_result]
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_presentation(
|
||||
// {
|
||||
// obj_type: 'event_presentation',
|
||||
// obj_li: [event_presentation_obj_create_result]
|
||||
// });
|
||||
}
|
||||
return event_presentation_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
@@ -431,58 +311,7 @@ export async function create_ae_obj__event_presentation(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-22
|
||||
export async function delete_ae_obj_id__event_presentation(
|
||||
{
|
||||
api_cfg,
|
||||
event_presentation_id,
|
||||
method = 'delete', // 'delete', 'disable', 'hide'
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_presentation_id: string,
|
||||
method?: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** delete_ae_obj_id__event_presentation() *** event_presentation_id=${event_presentation_id}`);
|
||||
}
|
||||
|
||||
ae_promises.delete__event_presentation_obj = await api.delete_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_presentation',
|
||||
obj_id: event_presentation_id,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
method: method,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
if (try_cache) {
|
||||
if (log_lvl) {
|
||||
console.log(`Attempting to remove IDB entry for event_presentation_id=${event_presentation_id}`);
|
||||
}
|
||||
db_events.presentations.delete(event_presentation_id);
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.delete__event_presentation_obj:', ae_promises.delete__event_presentation_obj);
|
||||
}
|
||||
|
||||
return ae_promises.delete__event_presentation_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-22
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__event_presentation(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -513,37 +342,12 @@ export async function update_ae_obj__event_presentation(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_presentation_obj_update_result) {
|
||||
.then(function (event_presentation_obj_update_result) {
|
||||
if (event_presentation_obj_update_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_presentation_props({
|
||||
obj_li: [event_presentation_obj_update_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'presentations',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
db_save_ae_obj_li__event_presentation({
|
||||
obj_type: 'event_presentation', obj_li: [event_presentation_obj_update_result]
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_presentation({
|
||||
// obj_type: 'event_presentation',
|
||||
// obj_li: [event_presentation_obj_update_result],
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return event_presentation_obj_update_result;
|
||||
} else {
|
||||
@@ -650,144 +454,3 @@ export function db_save_ae_obj_li__event_presentation(
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-22
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_presentation_id',
|
||||
'event_presentation_id_random',
|
||||
|
||||
'external_id',
|
||||
'code',
|
||||
|
||||
'for_type',
|
||||
'for_id',
|
||||
'for_id_random',
|
||||
|
||||
'type_code',
|
||||
|
||||
'event_id',
|
||||
'event_id_random',
|
||||
'event_session_id',
|
||||
'event_session_id_random',
|
||||
'event_abstract_id',
|
||||
'event_abstract_id_random',
|
||||
|
||||
'abstract_code',
|
||||
|
||||
'name',
|
||||
'description',
|
||||
|
||||
'start_datetime',
|
||||
'end_datetime',
|
||||
|
||||
'passcode',
|
||||
|
||||
'hide_event_launcher',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
// 'tmp_sort_a',
|
||||
// 'tmp_sort_b',
|
||||
|
||||
// From SQL view
|
||||
'event_session_code',
|
||||
'event_session_name',
|
||||
|
||||
// Add more fields here if your DB save logic uses them
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-05-22
|
||||
export async function process_ae_obj__event_presentation_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_presentation_props() ***`, obj_li);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) {
|
||||
console.log('No objects to process.');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) {
|
||||
console.log(`Processing ae_obj event_presentation:`, obj);
|
||||
}
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.event_presentation_id_random,
|
||||
event_presentation_id: obj.event_presentation_id_random,
|
||||
event_presentation_id_random: obj.event_presentation_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
code: obj.code,
|
||||
|
||||
for_type: obj.for_type,
|
||||
for_id: obj.for_id_random,
|
||||
for_id_random: obj.for_id_random,
|
||||
|
||||
type_code: obj.type_code,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
event_session_id: obj.event_session_id_random,
|
||||
event_session_id_random: obj.event_session_id_random,
|
||||
event_abstract_id: obj.event_abstract_id_random,
|
||||
event_abstract_id_random: obj.event_abstract_id_random,
|
||||
|
||||
abstract_code: obj.abstract_code,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
start_datetime: obj.start_datetime,
|
||||
end_datetime: obj.end_datetime,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
hide_event_launcher: obj.hide_event_launcher,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
event_session_code: obj.event_session_code,
|
||||
event_session_name: obj.event_session_name,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
||||
import { db_events } from "$lib/ae_events/db_events";
|
||||
|
||||
import { load_ae_obj_li__event_file } from "$lib/ae_events/ae_events__event_file";
|
||||
import { db_events } from "$lib/db_events";
|
||||
import { load_ae_obj_li__event_file } from "$lib/ae_events__event_file";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
@@ -15,27 +13,17 @@ export async function load_ae_obj_id__event_presenter(
|
||||
api_cfg,
|
||||
event_presenter_id,
|
||||
inc_file_li = false,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 19,
|
||||
offset = 0,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_presenter_id: string,
|
||||
inc_file_li?: boolean,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__event_presenter() *** event_presenter_id=${event_presenter_id}`);
|
||||
}
|
||||
console.log(`*** load_ae_obj_id__event_presenter() *** event_presenter_id=${event_presenter_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
@@ -48,37 +36,14 @@ export async function load_ae_obj_id__event_presenter(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_presenter_obj_get_result) {
|
||||
.then(function (event_presenter_obj_get_result) {
|
||||
if (event_presenter_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_presenter_props({
|
||||
obj_li: [event_presenter_obj_get_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'presenters',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__event_presenter({
|
||||
obj_type: 'event_presenter',
|
||||
obj_li: [event_presenter_obj_get_result]
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// // This is expecting a list
|
||||
// db_save_ae_obj_li__event_presenter({
|
||||
// obj_type: 'event_presenter',
|
||||
// obj_li: [event_presenter_obj_get_result]
|
||||
// });
|
||||
}
|
||||
return event_presenter_obj_get_result;
|
||||
} else {
|
||||
@@ -99,8 +64,7 @@ export async function load_ae_obj_id__event_presenter(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_presenter',
|
||||
for_obj_id: event_presenter_id,
|
||||
enabled: enabled,
|
||||
limit: limit,
|
||||
params: {qry__enabled: 'all', qry__limit: 25},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -128,10 +92,6 @@ export async function load_ae_obj_li__event_presenter(
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
inc_file_li = false,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 19,
|
||||
offset = 0,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'given_name': 'ASC', 'family_name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
@@ -141,10 +101,6 @@ export async function load_ae_obj_li__event_presenter(
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
inc_file_li?: boolean,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
@@ -155,23 +111,22 @@ export async function load_ae_obj_li__event_presenter(
|
||||
console.log(`*** load_ae_obj_li__event_presenter() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
}
|
||||
|
||||
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
// let limit: number = (params.qry__limit ?? 99); // 99
|
||||
// let offset: number = (params.qry__offset ?? 0); // 0
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
// ae_promises.load__event_presenter_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
ae_promises.load__event_presenter_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
ae_promises.load__event_presenter_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_presenter',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
// use_alt_mdl: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
@@ -181,36 +136,13 @@ export async function load_ae_obj_li__event_presenter(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_presenter_obj_li_get_result) {
|
||||
.then(function (event_presenter_obj_li_get_result) {
|
||||
if (event_presenter_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_presenter_props({
|
||||
obj_li: event_presenter_obj_li_get_result,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'presenters',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
db_save_ae_obj_li__event_presenter({
|
||||
obj_type: 'event_presenter',
|
||||
obj_li: event_presenter_obj_li_get_result
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_presenter({
|
||||
// obj_type: 'event_presenter',
|
||||
// obj_li: event_presenter_obj_li_get_result
|
||||
// });
|
||||
}
|
||||
return event_presenter_obj_li_get_result;
|
||||
} else {
|
||||
@@ -238,8 +170,7 @@ export async function load_ae_obj_li__event_presenter(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_presenter',
|
||||
for_obj_id: event_presenter_id,
|
||||
enabled: enabled,
|
||||
limit: limit,
|
||||
params: {qry__enabled: 'all', qry__limit: 25},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -261,7 +192,59 @@ export async function load_ae_obj_li__event_presenter(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
// Updated 2024-08-07
|
||||
export async function 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(`*** 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) {
|
||||
// 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 create_ae_obj__event_presenter(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -270,7 +253,6 @@ export async function create_ae_obj__event_presenter(
|
||||
event_presentation_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
@@ -279,7 +261,6 @@ export async function create_ae_obj__event_presenter(
|
||||
event_presentation_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
@@ -301,37 +282,12 @@ export async function create_ae_obj__event_presenter(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_presenter_obj_create_result) {
|
||||
.then(function (event_presenter_obj_create_result) {
|
||||
if (event_presenter_obj_create_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_presenter_props({
|
||||
obj_li: [event_presenter_obj_create_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'presenters',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
db_save_ae_obj_li__event_presenter(
|
||||
{
|
||||
obj_type: 'event_presenter', obj_li: [event_presenter_obj_create_result]
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_presenter(
|
||||
// {
|
||||
// obj_type: 'event_presenter', obj_li: [event_presenter_obj_create_result]
|
||||
// });
|
||||
}
|
||||
return event_presenter_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
@@ -350,58 +306,7 @@ export async function create_ae_obj__event_presenter(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export async function delete_ae_obj_id__event_presenter(
|
||||
{
|
||||
api_cfg,
|
||||
event_presenter_id,
|
||||
method = 'delete', // 'delete', 'disable', 'hide'
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_presenter_id: string,
|
||||
method?: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** 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,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
method: method,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
if (try_cache) {
|
||||
if (log_lvl) {
|
||||
console.log(`Attempting to remove IDB entry for event_presenter_id=${event_presenter_id}`);
|
||||
}
|
||||
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 2025-05-23
|
||||
// Updated 2024-09-13
|
||||
export async function update_ae_obj__event_presenter(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -433,36 +338,13 @@ export async function update_ae_obj__event_presenter(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_presenter_obj_update_result) {
|
||||
.then(function (event_presenter_obj_update_result) {
|
||||
if (event_presenter_obj_update_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__event_presenter_props({
|
||||
obj_li: [event_presenter_obj_update_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'presenters',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
db_save_ae_obj_li__event_presenter({
|
||||
obj_type: 'event_presenter',
|
||||
obj_li: [event_presenter_obj_update_result]
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_presenter({
|
||||
// obj_type: 'event_presenter',
|
||||
// obj_li: [event_presenter_obj_update_result]
|
||||
// });
|
||||
}
|
||||
return event_presenter_obj_update_result;
|
||||
} else {
|
||||
@@ -482,7 +364,7 @@ export async function update_ae_obj__event_presenter(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
// Updated 2024-07-11
|
||||
export async function search__event_presenter(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -568,13 +450,7 @@ export async function search__event_presenter(
|
||||
|
||||
params_json['and_qry'] = {};
|
||||
|
||||
if (agree === true || agree === false) {
|
||||
params_json['and_qry']['agree'] = agree;
|
||||
// if (!agree) {
|
||||
// params_json['or_qry']['agree'] = null;
|
||||
// }
|
||||
}
|
||||
if (agree === null) {
|
||||
if (agree) {
|
||||
params_json['and_qry']['agree'] = agree;
|
||||
}
|
||||
|
||||
@@ -582,14 +458,13 @@ export async function search__event_presenter(
|
||||
params_json['and_qry']['biography_check'] = biography;
|
||||
}
|
||||
|
||||
// ae_promises.load__event_presenter_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
ae_promises.load__event_presenter_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
ae_promises.load__event_presenter_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_presenter',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_tbl: true, // NOTE: We want to use the alt table for session searching
|
||||
// use_alt_mdl: false,
|
||||
use_alt_table: true, // NOTE: We want to use the alt table for session searching
|
||||
use_alt_base: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
@@ -607,7 +482,7 @@ export async function search__event_presenter(
|
||||
obj_li: event_presenter_obj_li_get_result
|
||||
});
|
||||
}
|
||||
// db_save_ae_obj_li__event_presenter({obj_type: 'event_presenter', obj_li: event_presenter_obj_li_get_result});
|
||||
db_save_ae_obj_li__event_presenter({obj_type: 'event_presenter', obj_li: event_presenter_obj_li_get_result});
|
||||
return event_presenter_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
@@ -755,7 +630,6 @@ export async function email_sign_in__event_presenter (
|
||||
base_url,
|
||||
person_id,
|
||||
person_passcode,
|
||||
event_id,
|
||||
event_session_id,
|
||||
event_presentation_id,
|
||||
event_presenter_id,
|
||||
@@ -769,7 +643,6 @@ export async function email_sign_in__event_presenter (
|
||||
base_url: string,
|
||||
person_id: string,
|
||||
person_passcode: string,
|
||||
event_id: string,
|
||||
event_session_id: string,
|
||||
event_presentation_id: string,
|
||||
event_presenter_id: string,
|
||||
@@ -782,238 +655,33 @@ export async function email_sign_in__event_presenter (
|
||||
console.log(`*** 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 2025 - Pres Mgmt Hub Sign In Link for ${session_name} (ID: ${event_session_id})`;
|
||||
let subject = `LCI Congress 2024 - Pres Mgmt Hub Sign In Link for ${session_name} (ID: ${event_session_id})`;
|
||||
|
||||
let sign_in_url = encodeURI(`${base_url}/events/${event_id}/session/${event_session_id}?person_id=${person_id}&person_pass=${person_passcode}&presentation_id=${event_presentation_id}&presenter_id=${event_presenter_id}`)
|
||||
let sign_in_url = encodeURI(`${base_url}/events_pres_mgmt/session/${event_session_id}?person_id=${person_id}&person_pass=${person_passcode}&presentation_id=${event_presentation_id}&presenter_id=${event_presenter_id}`)
|
||||
|
||||
let body_html = `
|
||||
<div>${to_name},
|
||||
<p>Your link to sign into the presentation management hub for LCI Congress 2025 is below. If you did not request this, please delete and ignore this email. If you need to make any changes or updates to your submission, you may use this link again later.</p>
|
||||
<p>Your link to sign into the presentation management hub for LCI Congress 2024 is below. If you did not request this, please delete and ignore this email. If you need to make any changes or updates to your submission, you may use this link again later.</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<strong>27th Annual Lean Construction Congress (2025)</strong>:<br>
|
||||
<strong>26th Annual Lean Construction Congress (2024)</strong>:<br>
|
||||
<p>
|
||||
Session Name: ${session_name}<br>
|
||||
Session ID: ${event_session_id}<br>
|
||||
Presentation Name: ${presentation_name}<br>
|
||||
Presentation ID: ${event_presentation_id}
|
||||
</p>
|
||||
<p>Use this link to view or update your LCI 2025 presentation information.<br>
|
||||
<p>Use this link to view or update your LCI 2024 presentation information.<br>
|
||||
Copy and paste link: <a href="${sign_in_url}">${sign_in_url}</a></p>
|
||||
</div>`;
|
||||
|
||||
api.send_email({
|
||||
api_cfg: api_cfg,
|
||||
from_email: 'noreply+presmgmt@oneskyit.com',
|
||||
from_name: 'LCI 2025 Pres Mgmt Hub',
|
||||
from_name: 'LCI 2024 Pres Mgmt Hub',
|
||||
to_email: to_email,
|
||||
subject: subject,
|
||||
body_html: body_html,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_presenter_id',
|
||||
'event_presenter_id_random',
|
||||
|
||||
'external_id',
|
||||
'code',
|
||||
|
||||
// 'for_type',
|
||||
// 'for_id',
|
||||
// 'for_id_random',
|
||||
|
||||
'event_id',
|
||||
'event_id_random',
|
||||
'event_session_id',
|
||||
'event_session_id_random',
|
||||
'event_presentation_id',
|
||||
'event_presentation_id_random',
|
||||
'event_person_id',
|
||||
'event_person_id_random',
|
||||
'person_id',
|
||||
'person_id_random',
|
||||
'person_profile_id',
|
||||
'person_profile_id_random',
|
||||
|
||||
'pronouns',
|
||||
'informal_name',
|
||||
'title_names',
|
||||
'given_name',
|
||||
'middle_name',
|
||||
'family_name',
|
||||
'designations',
|
||||
|
||||
'professional_title',
|
||||
|
||||
'full_name',
|
||||
|
||||
'affiliations',
|
||||
|
||||
'email',
|
||||
|
||||
'biography',
|
||||
|
||||
'agree',
|
||||
'comments',
|
||||
|
||||
'passcode',
|
||||
|
||||
'hide_event_launcher',
|
||||
|
||||
'data_json',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
// 'tmp_sort_a',
|
||||
// 'tmp_sort_b',
|
||||
|
||||
// From SQL view
|
||||
'file_count',
|
||||
|
||||
'event_session_code',
|
||||
'event_session_name',
|
||||
'event_session_start_datetime',
|
||||
'event_presentation_code',
|
||||
'event_presentation_name',
|
||||
'event_presentation_start_datetime',
|
||||
|
||||
'person_external_id',
|
||||
'person_external_sys_id',
|
||||
'person_given_name',
|
||||
'person_family_name',
|
||||
'person_full_name',
|
||||
'person_professional_title',
|
||||
'person_affiliations',
|
||||
'person_primary_email',
|
||||
'person_passcode',
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-05-23
|
||||
export async function process_ae_obj__event_presenter_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__event_presenter_props() ***`, obj_li);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj event_presenter:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.event_presenter_id_random,
|
||||
event_presenter_id: obj.event_presenter_id_random,
|
||||
event_presenter_id_random: obj.event_presenter_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
code: obj.code,
|
||||
|
||||
// for_type: obj.for_type,
|
||||
// for_id: obj.for_id,
|
||||
// for_id_random: obj.for_id_random,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
event_session_id: obj.event_session_id_random,
|
||||
event_session_id_random: obj.event_session_id_random,
|
||||
event_presentation_id: obj.event_presentation_id_random,
|
||||
event_presentation_id_random: obj.event_presentation_id_random,
|
||||
event_person_id: obj.event_person_id_random,
|
||||
event_person_id_random: obj.event_person_id_random,
|
||||
person_id: obj.person_id_random,
|
||||
person_id_random: obj.person_id_random,
|
||||
person_profile_id: obj.person_profile_id_random,
|
||||
person_profile_id_random: obj.person_profile_id_random,
|
||||
|
||||
pronouns: obj.pronouns,
|
||||
informal_name: obj.informal_name,
|
||||
title_names: obj.title_names,
|
||||
given_name: obj.given_name,
|
||||
middle_name: obj.middle_name,
|
||||
family_name: obj.family_name,
|
||||
designations: obj.designations,
|
||||
|
||||
professional_title: obj.professional_title,
|
||||
|
||||
full_name: obj.full_name,
|
||||
|
||||
affiliations: obj.affiliations,
|
||||
|
||||
email: obj.email,
|
||||
|
||||
biography: obj.biography,
|
||||
|
||||
agree: obj.agree,
|
||||
comments: obj.comments,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
hide_event_launcher: obj.hide_event_launcher,
|
||||
|
||||
data_json: obj.data_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
file_count: obj.file_count,
|
||||
|
||||
event_session_code: obj.event_session_code,
|
||||
event_session_name: obj.event_session_name,
|
||||
event_session_start_datetime: obj.event_session_start_datetime,
|
||||
event_presentation_code: obj.event_presentation_code,
|
||||
event_presentation_name: obj.event_presentation_name,
|
||||
event_presentation_start_datetime: obj.event_presentation_start_datetime,
|
||||
|
||||
person_external_id: obj.person_external_id,
|
||||
person_external_sys_id: obj.person_external_sys_id,
|
||||
person_given_name: obj.person_given_name,
|
||||
person_family_name: obj.person_family_name,
|
||||
person_full_name: obj.person_full_name,
|
||||
person_professional_title: obj.person_professional_title,
|
||||
person_affiliations: obj.person_affiliations,
|
||||
person_primary_email: obj.person_primary_email,
|
||||
person_passcode: obj.person_passcode,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
821
src/lib/ae_events__event_session.ts
Normal file
821
src/lib/ae_events__event_session.ts
Normal file
@@ -0,0 +1,821 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_events } from "$lib/db_events";
|
||||
|
||||
import { load_ae_obj_li__event_file } from "$lib/ae_events__event_file";
|
||||
import { load_ae_obj_li__event_presentation } from "$lib/ae_events__event_presentation";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-08-09
|
||||
export async function load_ae_obj_id__event_session(
|
||||
{
|
||||
api_cfg,
|
||||
event_session_id,
|
||||
inc_file_li = false,
|
||||
inc_presentation_li = false,
|
||||
inc_presenter_li = false,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_session_id: string,
|
||||
inc_file_li?: boolean,
|
||||
inc_presentation_li?: boolean,
|
||||
inc_presenter_li?: boolean,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** load_ae_obj_id__event_session() *** event_session_id=${event_session_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
// $events_sess.badges.status_load__event_session_obj = 'loading';
|
||||
ae_promises.load__event_session_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_session',
|
||||
obj_id: event_session_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_session_obj_get_result) {
|
||||
if (event_session_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// This is expecting a list
|
||||
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.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_session_obj:', ae_promises?.load__event_session_obj);
|
||||
}
|
||||
|
||||
if (ae_promises?.load__event_session_obj === null) {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
|
||||
if (inc_file_li) {
|
||||
// Load the files for the session
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the file list for the session now`);
|
||||
}
|
||||
let load_event_file_obj_li = load_ae_obj_li__event_file({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_session',
|
||||
for_obj_id: event_session_id,
|
||||
params: {qry__enabled: 'all', qry__limit: 15},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then((event_file_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_file_obj_li = `, event_file_obj_li);
|
||||
}
|
||||
return event_file_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_file_obj_li = `, load_event_file_obj_li);
|
||||
}
|
||||
ae_promises.load__event_session_obj.event_file_li = load_event_file_obj_li;
|
||||
}
|
||||
|
||||
if (inc_presentation_li) {
|
||||
// Load the presentations for the session
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the presentation list for the session now`);
|
||||
}
|
||||
let load_event_presentation_obj_li = load_ae_obj_li__event_presentation({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_session',
|
||||
for_obj_id: event_session_id,
|
||||
inc_file_li: inc_file_li,
|
||||
inc_presenter_li: inc_presenter_li,
|
||||
params: {qry__enabled: 'all', qry__limit: 25},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then((event_presentation_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_presentation_obj_li = `, event_presentation_obj_li);
|
||||
}
|
||||
// if (try_cache) {
|
||||
// console.log(`ae_promises.load__event_session_obj = `, ae_promises.load__event_session_obj);
|
||||
// ae_promises.load__event_session_obj.event_presentation_li = event_presentation_obj_li;
|
||||
// // Re-save the session object with the new presentation list
|
||||
// db_save_ae_obj_li__event_session({
|
||||
// obj_type: 'event_session',
|
||||
// obj_li: [ae_promises.load__event_session_obj]
|
||||
// });
|
||||
// }
|
||||
return event_presentation_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`event_presentation_obj_li = `, load_event_presentation_obj_li);
|
||||
}
|
||||
ae_promises.load__event_session_obj.event_presentation_li = load_event_presentation_obj_li;
|
||||
}
|
||||
|
||||
return ae_promises.load__event_session_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-08-09
|
||||
export async function load_ae_obj_li__event_session(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
inc_file_li = false,
|
||||
inc_presentation_li = false,
|
||||
inc_presenter_li = false,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
inc_file_li?: boolean,
|
||||
inc_presentation_li?: boolean,
|
||||
inc_presenter_li?: boolean,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** load_ae_obj_li__event_session() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
ae_promises.load__event_session_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_session',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_session_obj_li_get_result) {
|
||||
if (event_session_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
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 [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_session_obj_li:', ae_promises.load__event_session_obj_li);
|
||||
}
|
||||
|
||||
if (inc_file_li) {
|
||||
// Load the files for the sessions
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the file list for each session now`);
|
||||
}
|
||||
for (let i = 0; i < ae_promises.load__event_session_obj_li.length; i++) {
|
||||
let event_session_obj = ae_promises.load__event_session_obj_li[i];
|
||||
let event_session_id = event_session_obj.event_session_id_random;
|
||||
|
||||
let load_event_file_obj_li = load_ae_obj_li__event_file({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_session',
|
||||
for_obj_id: event_session_id,
|
||||
params: {qry__enabled: enabled, qry__limit: limit},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then((event_file_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_file_obj_li = `, event_file_obj_li);
|
||||
}
|
||||
return event_file_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_file_obj_li = `, load_event_file_obj_li);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inc_presentation_li) {
|
||||
// Load the presentations for the sessions
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the presentation list for each session now`);
|
||||
}
|
||||
for (let i = 0; i < ae_promises.load__event_session_obj_li.length; i++) {
|
||||
let event_session_obj = ae_promises.load__event_session_obj_li[i];
|
||||
let event_session_id = event_session_obj.event_session_id_random;
|
||||
|
||||
let load_event_presentation_obj_li = load_ae_obj_li__event_presentation({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_session',
|
||||
for_obj_id: event_session_id,
|
||||
inc_file_li: inc_file_li,
|
||||
inc_presenter_li: inc_presenter_li,
|
||||
params: {qry__enabled: enabled, qry__limit: limit},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then((event_presentation_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_presentation_obj_li = `, event_presentation_obj_li);
|
||||
}
|
||||
// if (try_cache) {
|
||||
// console.log(`event_session_obj = `, event_session_obj);
|
||||
// event_session_obj.event_presentation_li = event_presentation_obj_li;
|
||||
// // Re-save the session object with the new presentation list
|
||||
// db_save_ae_obj_li__event_session({
|
||||
// obj_type: 'event_session',
|
||||
// obj_li: event_session_obj
|
||||
// });
|
||||
// }
|
||||
|
||||
return event_presentation_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_presentation_obj_li = `, load_event_presentation_obj_li);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_session_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function create_ae_obj__event_session(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** create_ae_obj__event_session() *** event_id=${event_id}`);
|
||||
|
||||
ae_promises.create__event_session = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_session',
|
||||
fields: {
|
||||
event_id_random: event_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_session_obj_create_result) {
|
||||
if (event_session_obj_create_result) {
|
||||
db_save_ae_obj_li__event_session(
|
||||
{
|
||||
obj_type: 'event_session',
|
||||
obj_li: [event_session_obj_create_result]
|
||||
});
|
||||
return event_session_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__event_session:', ae_promises.create__event_session);
|
||||
}
|
||||
return ae_promises.create__event_session;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-13
|
||||
export async function update_ae_obj__event_session(
|
||||
{
|
||||
api_cfg,
|
||||
event_session_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_session_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__event_session() *** event_session_id=${event_session_id}`, data_kv);
|
||||
}
|
||||
// ae_promises.update__event_session_obj = 'test';
|
||||
ae_promises.update__event_session_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_session',
|
||||
obj_id: event_session_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_session_obj_update_result) {
|
||||
if (event_session_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event_session({
|
||||
obj_type: 'event_session', obj_li: [event_session_obj_update_result]
|
||||
});
|
||||
}
|
||||
return event_session_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__event_session_obj:', ae_promises.update__event_session_obj);
|
||||
}
|
||||
return ae_promises.update__event_session_obj;
|
||||
}
|
||||
|
||||
|
||||
// This new function is using CRUD v2. This should allow for more flexibility in the queries.
|
||||
// Updated 2024-08-14
|
||||
export async function qry__event_session(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
qry_str,
|
||||
qry_files,
|
||||
qry_start_datetime, // Example greater than: '2024-10-24'
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 50,
|
||||
offset = 0,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: any,
|
||||
qry_str?: string,
|
||||
qry_files?: null|boolean,
|
||||
qry_start_datetime?: null|string, // Greater than this datetime
|
||||
enabled?: string, // all, disabled, enabled
|
||||
hidden?: string, // all, hidden, not_hidden
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
params?: any,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** qry__event_session() *** event_id=${event_id} qry_str=${qry_str}`);
|
||||
|
||||
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
// let limit: number = (params.qry__limit ?? 25); // 99
|
||||
// let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// if (qry_str && qry_str.length > 2) {
|
||||
// params_json['ft_qry'] = {};
|
||||
// params_json['ft_qry']['default_qry_str'] = qry_str;
|
||||
// }
|
||||
|
||||
params_json['qry'] = [];
|
||||
|
||||
if (qry_files === true) {
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "file_count_all",
|
||||
operator: ">",
|
||||
value: 0
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
} else if (qry_files === false) {
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "file_count_all",
|
||||
operator: "IS",
|
||||
value: null
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
}
|
||||
|
||||
if (qry_start_datetime) {
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "start_datetime",
|
||||
operator: ">",
|
||||
value: qry_start_datetime
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
}
|
||||
|
||||
let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
|
||||
|
||||
ae_promises.load__event_session_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_session',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_tbl: true, // NOTE: We want to use the alt table for session searching
|
||||
use_alt_mdl: false,
|
||||
use_alt_exp: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_session_obj_li_get_result) {
|
||||
if (event_session_obj_li_get_result) {
|
||||
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 [];
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_session_obj_li:', ae_promises.load__event_session_obj_li);
|
||||
}
|
||||
return ae_promises.load__event_session_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-13
|
||||
export async function search__event_session(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
poc_agree = null,
|
||||
fulltext_search_qry_str,
|
||||
ft_presenter_search_qry_str,
|
||||
like_search_qry_str = null,
|
||||
like_presentation_search_qry_str = null,
|
||||
like_presenter_search_qry_str = null,
|
||||
file_count = false, // If true then only show those that have a file count
|
||||
location_name = null,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: any,
|
||||
poc_agree?: null|boolean,
|
||||
fulltext_search_qry_str?: null|string,
|
||||
ft_presenter_search_qry_str?: null|string,
|
||||
like_search_qry_str?: null|string,
|
||||
like_presentation_search_qry_str?: null|string,
|
||||
like_presenter_search_qry_str?: null|string,
|
||||
file_count?: boolean,
|
||||
location_name?: null|string,
|
||||
params?: any,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** search__event_session() *** 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
|
||||
let limit: number = (params.qry__limit ?? 25); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// if (!fulltext_search_qry_str && !like_search_qry_str) {
|
||||
// console.log('No search string provided!!!');
|
||||
// return false; // Returning false instead of [] because no search was performed.
|
||||
// }
|
||||
|
||||
if (fulltext_search_qry_str || ft_presenter_search_qry_str) {
|
||||
params_json['ft_qry'] = {};
|
||||
if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
|
||||
params_json['ft_qry']['default_qry_str'] = fulltext_search_qry_str;
|
||||
}
|
||||
|
||||
if (ft_presenter_search_qry_str && ft_presenter_search_qry_str.length > 2) {
|
||||
params_json['ft_qry']['event_presenter_li_qry_str'] = ft_presenter_search_qry_str;
|
||||
}
|
||||
}
|
||||
|
||||
// Use the AND (AND LIKE) query
|
||||
// if (like_search_qry_str || like_presenter_search_qry_str) {
|
||||
// params_json['and_like'] = {};
|
||||
// if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
// params_json['and_like']['default_qry_str'] = like_search_qry_str;
|
||||
// }
|
||||
// if (like_presenter_search_qry_str && like_presenter_search_qry_str.length > 2) {
|
||||
// params_json['and_like']['event_presenter_li_qry_str'] = like_presenter_search_qry_str;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Use the AND (OR LIKE) query
|
||||
if (like_search_qry_str || like_presentation_search_qry_str || like_presenter_search_qry_str) {
|
||||
params_json['or_like'] = {};
|
||||
if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
params_json['or_like']['default_qry_str'] = like_search_qry_str;
|
||||
}
|
||||
if (like_presentation_search_qry_str && like_presentation_search_qry_str.length > 2) {
|
||||
params_json['or_like']['event_presentation_li_qry_str'] = like_presentation_search_qry_str;
|
||||
}
|
||||
if (like_presenter_search_qry_str && like_presenter_search_qry_str.length > 2) {
|
||||
params_json['or_like']['event_presenter_li_qry_str'] = like_presenter_search_qry_str;
|
||||
}
|
||||
}
|
||||
|
||||
params_json['and_qry'] = {};
|
||||
|
||||
if (poc_agree) {
|
||||
params_json['and_qry']['poc_agree'] = poc_agree;
|
||||
}
|
||||
|
||||
if (file_count) {
|
||||
params_json['and_qry']['file_count'] = file_count;
|
||||
}
|
||||
|
||||
// This should be using a like with surrounded by %'s
|
||||
if (location_name) {
|
||||
params_json['and_qry']['event_location_name'] = location_name;
|
||||
}
|
||||
|
||||
let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
|
||||
|
||||
ae_promises.load__event_session_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_session',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_table: true, // NOTE: We want to use the alt table for session searching
|
||||
use_alt_base: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_session_obj_li_get_result) {
|
||||
if (event_session_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
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 [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_session_obj_li:', ae_promises.load__event_session_obj_li);
|
||||
}
|
||||
return ae_promises.load__event_session_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the event_session_obj_li and save each one to the DB.
|
||||
export function db_save_ae_obj_li__event_session(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__event_session() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_events.sessions.put({
|
||||
id: obj.event_session_id_random,
|
||||
event_session_id: obj.event_session_id_random,
|
||||
event_session_id_random: obj.event_session_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
code: obj.code,
|
||||
|
||||
for_type: obj.for_type,
|
||||
for_id: obj.for_id_id_random,
|
||||
for_id_random: obj.for_id_random,
|
||||
|
||||
type_code: obj.type_code,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
event_location_id: obj.event_location_id_random,
|
||||
event_location_id_random: obj.event_location_id_random,
|
||||
|
||||
poc_person_id: obj.poc_person_id_random,
|
||||
poc_person_id_random: obj.poc_person_id_random,
|
||||
poc_agree: obj.poc_agree,
|
||||
poc_kv_json: obj.poc_kv_json ?? {},
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
start_datetime: obj.start_datetime,
|
||||
end_datetime: obj.end_datetime,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
hide_event_launcher: obj.hide_event_launcher,
|
||||
|
||||
alert: obj.alert,
|
||||
alert_msg: obj.alert_msg,
|
||||
|
||||
data_json: obj.data_json,
|
||||
|
||||
ux_mode: obj.ux_mode,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// From SQL view
|
||||
file_count: obj.file_count,
|
||||
file_count_all: obj.file_count_all,
|
||||
internal_use_count: obj.internal_use_count,
|
||||
event_file_id_li_json: obj.event_file_id_li_json,
|
||||
|
||||
poc_person_given_name: obj.poc_person_given_name,
|
||||
poc_person_family_name: obj.poc_person_family_name,
|
||||
poc_person_full_name: obj.poc_person_full_name,
|
||||
poc_person_primary_email: obj.poc_person_primary_email,
|
||||
poc_person_passcode: obj.poc_person_passcode,
|
||||
|
||||
event_name: obj.event_name,
|
||||
|
||||
event_location_code: obj.event_location_code,
|
||||
event_location_name: obj.event_location_name,
|
||||
|
||||
// A key value list of the presentations
|
||||
event_presentation_kv: obj.event_presentation_kv,
|
||||
event_presentation_li: obj.event_presentation_li,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.event_session_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.event_session_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_events.sessions.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.event_session_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This is intended for the Point of Contact (POC) for the session.
|
||||
// Updated 2024-07-01
|
||||
export async function email_sign_in__event_session (
|
||||
{
|
||||
api_cfg,
|
||||
to_email,
|
||||
to_name,
|
||||
base_url,
|
||||
person_id,
|
||||
person_passcode,
|
||||
event_session_id,
|
||||
session_name,
|
||||
}: {
|
||||
api_cfg: any,
|
||||
to_email: string,
|
||||
to_name: string,
|
||||
base_url: string,
|
||||
person_id: string,
|
||||
person_passcode: string,
|
||||
event_session_id: string,
|
||||
session_name: string,
|
||||
}
|
||||
) {
|
||||
console.log(`*** email_sign_in__event_session() *** to_email=${to_email} to_name=${to_name} person_id=${person_id} person_passcode=${person_passcode} session_id=${event_session_id}`);
|
||||
|
||||
let subject = `LCI Congress 2024 - Pres Mgmt Hub Sign In Link for ${session_name} (ID: ${event_session_id})`;
|
||||
|
||||
let sign_in_url = encodeURI(`${base_url}/events_pres_mgmt/session/${event_session_id}?person_id=${person_id}&person_pass=${person_passcode}&session_id=${event_session_id}`)
|
||||
|
||||
let body_html = `
|
||||
<div>${to_name},
|
||||
<p>Your link to sign into the presentation management hub as a session Champion for LCI Congress 2024 is below. If you did not request this, please delete and ignore this email. If you need to make any changes or updates to your submission, you may use this link again later.</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<strong>26th Annual Lean Construction Congress (2024)</strong>:<br>
|
||||
<p>
|
||||
Session Name: ${session_name}<br>
|
||||
Session ID: ${event_session_id}
|
||||
</p>
|
||||
<p>Use this link to view or update your LCI 2024 session information.<br>
|
||||
Copy and paste link: <a href="${sign_in_url}">${sign_in_url}</a></p>
|
||||
</div>`;
|
||||
|
||||
api.send_email({
|
||||
api_cfg: api_cfg,
|
||||
from_email: 'noreply+presmgmt@oneskyit.com',
|
||||
from_name: 'LCI 2024 Pres Mgmt Hub',
|
||||
to_email: to_email,
|
||||
subject: subject,
|
||||
body_html: body_html,
|
||||
});
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_events } from "$lib/ae_events/db_events";
|
||||
import { db_events } from "$lib/db_events";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
// This file is used to export all the functions that are used for Aether Events related functions.
|
||||
|
||||
// Import all the functions from this library:
|
||||
import * as event from "$lib/ae_events/ae_events__event";
|
||||
import * as event_device from "$lib/ae_events/ae_events__event_device";
|
||||
import * as events from "$lib/ae_events__event";
|
||||
|
||||
import * as event_file from "$lib/ae_events/ae_events__event_file";
|
||||
import {
|
||||
load_ae_obj_id__event_file,
|
||||
load_ae_obj_li__event_file,
|
||||
delete_ae_obj_id__event_file,
|
||||
create_event_file_obj_from_hosted_file_async,
|
||||
update_ae_obj__event_file,
|
||||
search__event_file,
|
||||
db_save_ae_obj_li__event_file,
|
||||
} from "$lib/ae_events__event_file";
|
||||
|
||||
import {
|
||||
handle_load_ae_obj_id__exhibit,
|
||||
@@ -15,82 +22,104 @@ import {
|
||||
handle_update_ae_obj__exhibit_tracking,
|
||||
handle_download_export__event_exhibit_tracking,
|
||||
handle_db_save_ae_obj_li__exhibitor,
|
||||
} from "$lib/ae_events/ae_events__exhibit";
|
||||
} from "$lib/ae_events__exhibit";
|
||||
|
||||
import * as event_location from "$lib/ae_events/ae_events__event_location";
|
||||
import {
|
||||
load_ae_obj_id__event_location,
|
||||
load_ae_obj_li__event_location,
|
||||
create_ae_obj__event_location,
|
||||
update_ae_obj__event_location,
|
||||
db_save_ae_obj_li__event_location,
|
||||
} from "$lib/ae_events__event_location";
|
||||
|
||||
import * as event_session from "$lib/ae_events/ae_events__event_session";
|
||||
import {
|
||||
load_ae_obj_id__event_session,
|
||||
load_ae_obj_li__event_session,
|
||||
create_ae_obj__event_session,
|
||||
update_ae_obj__event_session,
|
||||
qry__event_session,
|
||||
search__event_session,
|
||||
db_save_ae_obj_li__event_session,
|
||||
email_sign_in__event_session,
|
||||
} from "$lib/ae_events__event_session";
|
||||
|
||||
import * as event_presentation from "$lib/ae_events/ae_events__event_presentation";
|
||||
import {
|
||||
load_ae_obj_id__event_presentation,
|
||||
load_ae_obj_li__event_presentation,
|
||||
create_ae_obj__event_presentation,
|
||||
update_ae_obj__event_presentation,
|
||||
db_save_ae_obj_li__event_presentation,
|
||||
} from "$lib/ae_events__event_presentation";
|
||||
|
||||
import * as event_presenter from "$lib/ae_events/ae_events__event_presenter";
|
||||
import {
|
||||
load_ae_obj_id__event_presenter,
|
||||
load_ae_obj_li__event_presenter,
|
||||
delete_ae_obj_id__event_presenter,
|
||||
create_ae_obj__event_presenter,
|
||||
update_ae_obj__event_presenter,
|
||||
search__event_presenter,
|
||||
db_save_ae_obj_li__event_presenter,
|
||||
email_sign_in__event_presenter,
|
||||
} from "$lib/ae_events__event_presenter";
|
||||
|
||||
import * as event_badge from "$lib/ae_events/ae_events__event_badge";
|
||||
import {
|
||||
handle_load_ae_obj_id__badge,
|
||||
handle_load_ae_obj_li__badge,
|
||||
handle_search__event_badge,
|
||||
handle_db_save_ae_obj_li__badge,
|
||||
} from "$lib/ae_events__event_badge";
|
||||
|
||||
|
||||
let export_obj = {
|
||||
load_ae_obj_id__event: event.load_ae_obj_id__event,
|
||||
load_ae_obj_li__event: event.load_ae_obj_li__event,
|
||||
qry_ae_obj_li__event: event.qry_ae_obj_li__event,
|
||||
create_ae_obj__event: event.create_ae_obj__event,
|
||||
delete_ae_obj_id__event: event.delete_ae_obj_id__event,
|
||||
update_ae_obj__event: event.update_ae_obj__event,
|
||||
// db_save_ae_obj_li__event: event.db_save_ae_obj_li__event,
|
||||
sync_config__event_pres_mgmt: event.sync_config__event_pres_mgmt,
|
||||
load_ae_obj_id__event: events.load_ae_obj_id__event,
|
||||
load_ae_obj_li__event: events.load_ae_obj_li__event,
|
||||
qry_ae_obj_li__event: events.qry_ae_obj_li__event,
|
||||
create_ae_obj__event: events.create_ae_obj__event,
|
||||
update_ae_obj__event: events.update_ae_obj__event,
|
||||
db_save_ae_obj_li__event: events.db_save_ae_obj_li__event,
|
||||
sync_config__event_pres_mgmt: events.sync_config__event_pres_mgmt,
|
||||
|
||||
load_ae_obj_id__event_device: event_device.load_ae_obj_id__event_device,
|
||||
load_ae_obj_li__event_device: event_device.load_ae_obj_li__event_device,
|
||||
create_ae_obj__event_device: event_device.create_ae_obj__event_device,
|
||||
delete_ae_obj_id__event_device: event_device.delete_ae_obj_id__event_device,
|
||||
update_ae_obj__event_device: event_device.update_ae_obj__event_device,
|
||||
// db_save_ae_obj_li__event_device: event_device.db_save_ae_obj_li__event_device,
|
||||
load_ae_obj_id__event_file: load_ae_obj_id__event_file,
|
||||
load_ae_obj_li__event_file: load_ae_obj_li__event_file,
|
||||
delete_ae_obj_id__event_file: delete_ae_obj_id__event_file,
|
||||
update_ae_obj__event_file: update_ae_obj__event_file,
|
||||
search__event_file: search__event_file,
|
||||
db_save_ae_obj_li__event_file: db_save_ae_obj_li__event_file,
|
||||
|
||||
load_ae_obj_id__event_file: event_file.load_ae_obj_id__event_file,
|
||||
load_ae_obj_li__event_file: event_file.load_ae_obj_li__event_file,
|
||||
create_event_file_obj_from_hosted_file_async: event_file.create_event_file_obj_from_hosted_file_async,
|
||||
delete_ae_obj_id__event_file: event_file.delete_ae_obj_id__event_file,
|
||||
update_ae_obj__event_file: event_file.update_ae_obj__event_file,
|
||||
qry__event_file: event_file.qry__event_file,
|
||||
search__event_file: event_file.search__event_file,
|
||||
// db_save_ae_obj_li__event_file: event_file.db_save_ae_obj_li__event_file,
|
||||
load_ae_obj_id__event_location: load_ae_obj_id__event_location,
|
||||
load_ae_obj_li__event_location: load_ae_obj_li__event_location,
|
||||
create_ae_obj__event_location: create_ae_obj__event_location,
|
||||
update_ae_obj__event_location: update_ae_obj__event_location,
|
||||
db_save_ae_obj_li__event_location: db_save_ae_obj_li__event_location,
|
||||
|
||||
load_ae_obj_id__event_location: event_location.load_ae_obj_id__event_location,
|
||||
load_ae_obj_li__event_location: event_location.load_ae_obj_li__event_location,
|
||||
create_ae_obj__event_location: event_location.create_ae_obj__event_location,
|
||||
delete_ae_obj_id__event_location: event_location.delete_ae_obj_id__event_location,
|
||||
update_ae_obj__event_location: event_location.update_ae_obj__event_location,
|
||||
// db_save_ae_obj_li__event_location: event_location.db_save_ae_obj_li__event_location,
|
||||
load_ae_obj_id__event_session: load_ae_obj_id__event_session,
|
||||
load_ae_obj_li__event_session: load_ae_obj_li__event_session,
|
||||
create_ae_obj__event_session: create_ae_obj__event_session,
|
||||
update_ae_obj__event_session: update_ae_obj__event_session,
|
||||
qry__event_session: qry__event_session,
|
||||
search__event_session: search__event_session,
|
||||
email_sign_in__event_session: email_sign_in__event_session,
|
||||
db_save_ae_obj_li__event_session: db_save_ae_obj_li__event_session,
|
||||
|
||||
load_ae_obj_id__event_session: event_session.load_ae_obj_id__event_session,
|
||||
load_ae_obj_li__event_session: event_session.load_ae_obj_li__event_session,
|
||||
create_ae_obj__event_session: event_session.create_ae_obj__event_session,
|
||||
delete_ae_obj_id__event_session: event_session.delete_ae_obj_id__event_session,
|
||||
update_ae_obj__event_session: event_session.update_ae_obj__event_session,
|
||||
qry__event_session: event_session.qry__event_session,
|
||||
search__event_session: event_session.search__event_session,
|
||||
email_sign_in__event_session: event_session.email_sign_in__event_session,
|
||||
// db_save_ae_obj_li__event_session: event_session.db_save_ae_obj_li__event_session,
|
||||
load_ae_obj_id__event_presentation: load_ae_obj_id__event_presentation,
|
||||
load_ae_obj_li__event_presentation: load_ae_obj_li__event_presentation,
|
||||
create_ae_obj__event_presentation: create_ae_obj__event_presentation,
|
||||
update_ae_obj__event_presentation: update_ae_obj__event_presentation,
|
||||
db_save_ae_obj_li__event_presentation: db_save_ae_obj_li__event_presentation,
|
||||
|
||||
load_ae_obj_id__event_presentation: event_presentation.load_ae_obj_id__event_presentation,
|
||||
load_ae_obj_li__event_presentation: event_presentation.load_ae_obj_li__event_presentation,
|
||||
create_ae_obj__event_presentation: event_presentation.create_ae_obj__event_presentation,
|
||||
delete_ae_obj_id__event_presentation: event_presentation.delete_ae_obj_id__event_presentation,
|
||||
update_ae_obj__event_presentation: event_presentation.update_ae_obj__event_presentation,
|
||||
// db_save_ae_obj_li__event_presentation: event_presentation.db_save_ae_obj_li__event_presentation,
|
||||
load_ae_obj_id__event_presenter: load_ae_obj_id__event_presenter,
|
||||
load_ae_obj_li__event_presenter: load_ae_obj_li__event_presenter,
|
||||
delete_ae_obj_id__event_presenter: delete_ae_obj_id__event_presenter,
|
||||
create_ae_obj__event_presenter: create_ae_obj__event_presenter,
|
||||
update_ae_obj__event_presenter: update_ae_obj__event_presenter,
|
||||
search__event_presenter: search__event_presenter,
|
||||
db_save_ae_obj_li__event_presenter: db_save_ae_obj_li__event_presenter,
|
||||
email_sign_in__event_presenter: email_sign_in__event_presenter,
|
||||
|
||||
load_ae_obj_id__event_presenter: event_presenter.load_ae_obj_id__event_presenter,
|
||||
load_ae_obj_li__event_presenter: event_presenter.load_ae_obj_li__event_presenter,
|
||||
create_ae_obj__event_presenter: event_presenter.create_ae_obj__event_presenter,
|
||||
delete_ae_obj_id__event_presenter: event_presenter.delete_ae_obj_id__event_presenter,
|
||||
update_ae_obj__event_presenter: event_presenter.update_ae_obj__event_presenter,
|
||||
search__event_presenter: event_presenter.search__event_presenter,
|
||||
// db_save_ae_obj_li__event_presenter: event_presenter.db_save_ae_obj_li__event_presenter,
|
||||
email_sign_in__event_presenter: event_presenter.email_sign_in__event_presenter,
|
||||
|
||||
handle_load_ae_obj_id__badge: event_badge.handle_load_ae_obj_id__badge,
|
||||
handle_load_ae_obj_li__badge: event_badge.handle_load_ae_obj_li__badge,
|
||||
handle_search__event_badge: event_badge.handle_search__event_badge,
|
||||
// handle_db_save_ae_obj_li__badge: event_badge.handle_db_save_ae_obj_li__badge,
|
||||
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,
|
||||
@@ -99,6 +128,8 @@ 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,
|
||||
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,
|
||||
};
|
||||
export let events_func = export_obj;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { persisted } from 'svelte-persisted-store';
|
||||
import { localStorageStore } from '@skeletonlabs/skeleton';
|
||||
import { writable } from 'svelte/store';
|
||||
import type { Writable } from 'svelte/store';
|
||||
|
||||
@@ -86,10 +86,11 @@ let events_local_data_struct: key_val = {
|
||||
|
||||
'show_element__cfg': true,
|
||||
'show_element__cfg_detail': false,
|
||||
// 'theme_mode': 'dark',
|
||||
// 'theme_name': 'wintry',
|
||||
'show_element__access_type': true,
|
||||
'theme_mode': 'dark',
|
||||
'theme_name': 'wintry',
|
||||
|
||||
'classes__form': 'border border-surface-200 p-4 space-y-4 rounded-container',
|
||||
'classes__form': 'border border-surface-200 p-4 space-y-4 rounded-container-token',
|
||||
},
|
||||
|
||||
// Event Files - uploads for sessions, presenters, etc
|
||||
@@ -102,15 +103,10 @@ let events_local_data_struct: key_val = {
|
||||
app_mode: 'default', // 'default', 'native', 'onsite'
|
||||
ws_connect: false,
|
||||
|
||||
qry_limit__files: 25,
|
||||
qry_limit__sessions: 50,
|
||||
qry_limit__presentations: 25,
|
||||
qry_limit__presenters: 75,
|
||||
qry_limit__sessions: 50,
|
||||
|
||||
hide_drawer__debug: true,
|
||||
hide__ws_form: true,
|
||||
hide__ws_messages: true,
|
||||
hide__ws_commands: true,
|
||||
qry_limit__files: 75,
|
||||
|
||||
show_content__disabled_files: false,
|
||||
show_content__hidden_files: false,
|
||||
@@ -144,12 +140,7 @@ let events_local_data_struct: key_val = {
|
||||
'host_file_config_path': 'device_configs/ae_native_app_config.default.json',
|
||||
},
|
||||
|
||||
idle_timer: 5*60*1000, // How many seconds until idle
|
||||
idle_cycle: 2*1000, // How frequently the idle status is checked
|
||||
idle_loop_period: 1*60*1000, // How frequently the loop runs for the screen saver and similar
|
||||
|
||||
screen_saver_img_kv: {},
|
||||
// screen_saver_img_li: [],
|
||||
screen_saver_img_list: [],
|
||||
modal__title: '-- Not Set --',
|
||||
modal__open: null,
|
||||
modal__open_filename: null,
|
||||
@@ -157,7 +148,6 @@ let events_local_data_struct: key_val = {
|
||||
|
||||
controller: 'local',
|
||||
controller_group_code: 'launcher-00',
|
||||
controller_client_id: null,
|
||||
// controller_cmd: null,
|
||||
// controller_trigger_send: null,
|
||||
},
|
||||
@@ -207,7 +197,7 @@ let events_local_data_struct: key_val = {
|
||||
// Presentation Management
|
||||
pres_mgmt: {
|
||||
sync_local_config: false,
|
||||
lock_config: true,
|
||||
lock_config: false,
|
||||
|
||||
datetime_format: 'datetime_12_long',
|
||||
time_format: 'time_12_short',
|
||||
@@ -217,19 +207,15 @@ let events_local_data_struct: key_val = {
|
||||
qry_hidden: 'not_hidden', // all, hidden, not_hidden
|
||||
qry_limit__files: 75,
|
||||
qry_limit__presentations: 25,
|
||||
qry_limit__presenters: 250,
|
||||
qry_limit__presenters: 75,
|
||||
qry_limit__sessions: 100,
|
||||
qry_max: 500, // This is the max number the limit is allowed to be set to.
|
||||
qry__files_offset_seconds: null,
|
||||
|
||||
qry_and__file_count: true, // Essentially it should be greater than 0
|
||||
|
||||
save_search_text: true,
|
||||
saved_search__session: null,
|
||||
|
||||
require__presenter_agree: false,
|
||||
require__session_agree: false,
|
||||
|
||||
// show_content__agree_text: false,
|
||||
show_content__event_view: null,
|
||||
show__launcher_link: false,
|
||||
@@ -251,8 +237,6 @@ let events_local_data_struct: key_val = {
|
||||
show_content__session_qr: false,
|
||||
hide__session_msg: true,
|
||||
hide__session_poc: true,
|
||||
hide__session_poc_biography: true,
|
||||
hide__presenter_biography: true,
|
||||
|
||||
show_content__disabled_files: false,
|
||||
show_content__hidden_files: false,
|
||||
@@ -270,21 +254,13 @@ let events_local_data_struct: key_val = {
|
||||
show_menu__session_search: null,
|
||||
show_menu__event_reports: null,
|
||||
|
||||
show_report: null,
|
||||
// show_report__presenters_agree: false,
|
||||
// show_report__recent_files: false,
|
||||
show_report__presenters_agree: false,
|
||||
show_report__recent_files: false,
|
||||
|
||||
// time_format: 'time_12_short', // 'time_short', 'time_12_short'
|
||||
|
||||
disable_submit__opt_out: true,
|
||||
submit_status__opt_out: null,
|
||||
|
||||
device_kv: {
|
||||
// 'LNDF-67-89-92': {'collapse': true},
|
||||
},
|
||||
location_kv: {
|
||||
// 'LNDF-67-89-92': {'collapse': true},
|
||||
},
|
||||
},
|
||||
|
||||
// Speakers Management (Collection)
|
||||
@@ -299,7 +275,7 @@ let events_local_data_struct: key_val = {
|
||||
// export let ae_loc = writable(events_local_data_struct);
|
||||
|
||||
// This works and uses *local* storage:
|
||||
export let events_loc: Writable<key_val> = persisted('ae_events_loc', events_local_data_struct);
|
||||
export let events_loc: Writable<key_val> = localStorageStore('ae_events_loc', events_local_data_struct);
|
||||
// console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
|
||||
|
||||
|
||||
@@ -368,7 +344,6 @@ let events_session_data_struct: key_val = {
|
||||
event_file_open: {}, // This is from the older Launcher.
|
||||
native: {
|
||||
},
|
||||
modal__open: false,
|
||||
},
|
||||
|
||||
// Lead Retrievals (Exhibit)
|
||||
@@ -457,28 +432,22 @@ let events_session_data_struct: key_val = {
|
||||
|
||||
show_content__presentation_description: false, // Note that this is per presentation. The event_presentation_id_random should match.
|
||||
|
||||
show_report: null,
|
||||
// show_report__presenters_agree: false,
|
||||
// show_report__recent_files: false,
|
||||
show_report__presenters_agree: false,
|
||||
show_report__recent_files: false,
|
||||
|
||||
show_field_edit__filename: false, // For file rename
|
||||
|
||||
new_upload_list: null,
|
||||
files_uploading_count: null,
|
||||
|
||||
qry_limit__files: 75,
|
||||
qry_limit__sessions: 75,
|
||||
qry_limit__presentations: 25,
|
||||
qry_limit__presenters: 250,
|
||||
qry_limit__sessions: 100,
|
||||
qry_limit__presenters: 75,
|
||||
qry_limit__files: 75,
|
||||
|
||||
show_fields__presentation: true,
|
||||
show_fields__session: true,
|
||||
|
||||
|
||||
show_modal__presenter_agree: false,
|
||||
show__session_poc_profile: false,
|
||||
show_modal__session_poc_agree: false,
|
||||
|
||||
status_rpt: {
|
||||
recent_files: null,
|
||||
presenters_agree: null,
|
||||
@@ -574,7 +543,7 @@ let events_slct_obj_template: key_val = {
|
||||
export let events_slct = writable(events_slct_obj_template);
|
||||
|
||||
// This works and uses *local* storage:
|
||||
// export let events_slct: Writable<key_val> = persisted('ae_events_slct', events_slct_obj_template);
|
||||
// export let events_slct: Writable<key_val> = localStorageStore('ae_events_slct', events_slct_obj_template);
|
||||
|
||||
|
||||
/* *** BEGIN *** Initialize events_trigger */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { persisted } from 'svelte-persisted-store';
|
||||
import { localStorageStore } from '@skeletonlabs/skeleton';
|
||||
import { writable } from 'svelte/store';
|
||||
import type { Writable } from 'svelte/store';
|
||||
|
||||
@@ -23,17 +23,8 @@ let idaa_local_data_struct: key_val = {
|
||||
novi_uuid: null,
|
||||
novi_email: null,
|
||||
novi_full_name: null,
|
||||
novi_admin_li: [
|
||||
"2b078deb-b4e7-4203-99da-9f7cd62159a5"
|
||||
],
|
||||
novi_trusted_li: [
|
||||
"c9ea07b5-06b0-4a43-a2d0-8d06558c8a82",
|
||||
"58db22ee-4b0a-49a7-9f34-53d2ba85a84b",
|
||||
],
|
||||
|
||||
novi_archives_base_url: "https://www.idaa.org/idaa-archives",
|
||||
novi_bb_base_url: "https://www.idaa.org/idaa-bulletin-board",
|
||||
novi_meetings_base_url: "https://www.idaa.org/idaa-meetings",
|
||||
novi_admin_li: [],
|
||||
novi_trusted_li: [],
|
||||
|
||||
'ds': {},
|
||||
|
||||
@@ -51,46 +42,20 @@ let idaa_local_data_struct: key_val = {
|
||||
hidden: 'not_hidden', // all, hidden, not_hidden
|
||||
limit: 150,
|
||||
offset: 0,
|
||||
|
||||
edit_kv: {}, // Used to track which archive objects are being edited
|
||||
edit__archive_obj: null,
|
||||
edit__archive_content_obj: null,
|
||||
|
||||
// qry__order_by: 'updated_on', // For the IDB index query
|
||||
// qry__order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'name': 'ASC'}, // For the SQL query
|
||||
},
|
||||
|
||||
bb: {
|
||||
enabled: 'enabled', // all, disabled, enabled
|
||||
hidden: 'not_hidden', // all, hidden, not_hidden
|
||||
limit: 50,
|
||||
limit: 150,
|
||||
offset: 0,
|
||||
|
||||
edit_kv: {}, // Used to track which post objects are being edited
|
||||
edit__post_obj: null,
|
||||
edit__post_comment_obj: null,
|
||||
|
||||
show_list__post_obj_li: true,
|
||||
|
||||
qry__enabled: 'enabled', // all, disabled, enabled
|
||||
qry__hidden: 'not_hidden', // all, hidden, not_hidden
|
||||
qry__limit: 25,
|
||||
qry__offset: 0,
|
||||
qry__order_by: 'updated_on', // For the IDB index query
|
||||
qry__order_by_li: {'updated_on': 'DESC', 'created_on': 'DESC'}, // For the SQL query
|
||||
|
||||
|
||||
},
|
||||
|
||||
recovery_meetings: {
|
||||
edit_kv: {}, // Used to track which event objects are being edited
|
||||
edit__event_obj: null,
|
||||
|
||||
qry__enabled: 'enabled', // all, disabled, enabled
|
||||
qry__hidden: 'not_hidden', // all, hidden, not_hidden
|
||||
qry__limit: 150,
|
||||
qry__order_by: 'updated_on', // For the IDB index query; name, updated_on/created_on
|
||||
qry__order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'name': 'ASC'}, // For the SQL query
|
||||
qry__offset: 0,
|
||||
|
||||
qry__fulltext_str: null,
|
||||
@@ -105,7 +70,7 @@ let idaa_local_data_struct: key_val = {
|
||||
// export let ae_loc = writable(idaa_local_data_struct);
|
||||
|
||||
// This works and uses *local* storage:
|
||||
export let idaa_loc: Writable<key_val> = persisted('ae_idaa_loc', idaa_local_data_struct);
|
||||
export let idaa_loc: Writable<key_val> = localStorageStore('ae_idaa_loc', idaa_local_data_struct);
|
||||
// console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
|
||||
|
||||
|
||||
@@ -119,40 +84,18 @@ let idaa_session_data_struct: key_val = {
|
||||
|
||||
archives: {
|
||||
qry__status: null,
|
||||
show__modal_edit__archive_id: null,
|
||||
show__modal_view__archive_id: null,
|
||||
show__modal_edit__archive_content_id: null,
|
||||
show__modal_view__archive_content_id: null,
|
||||
obj_changed: false, // Used to track if the archive object has been changed in the edit view
|
||||
},
|
||||
|
||||
bb: {
|
||||
qry__status: null,
|
||||
|
||||
edit__post_obj: null,
|
||||
|
||||
show__inline_edit__post_obj: null,
|
||||
show__modal_edit__post_id: null,
|
||||
show__modal_view__post_id: null,
|
||||
obj_changed: false, // Used to track if the post object has been changed in the edit view
|
||||
// edit_kv: {}, // Used to track which post objects are being edited
|
||||
},
|
||||
|
||||
recovery_meetings: {
|
||||
qry__status: null,
|
||||
qry__fulltext_str: null,
|
||||
|
||||
edit__event_obj: null,
|
||||
|
||||
status_qry__last_request_str: null,
|
||||
// qry__fulltext_str: null,
|
||||
|
||||
show__modal_edit: false,
|
||||
show__modal_view: false,
|
||||
show__modal_edit__event_id: null,
|
||||
show__modal_view__event_id: null,
|
||||
obj_changed: false, // Used to track if the event object has been changed in the edit view
|
||||
|
||||
attend_platform: null, // 'Zoom', 'Google Meet', 'Microsoft Teams', etc.
|
||||
},
|
||||
|
||||
};
|
||||
@@ -160,7 +103,7 @@ let idaa_session_data_struct: key_val = {
|
||||
export let idaa_sess = writable(idaa_session_data_struct);
|
||||
|
||||
|
||||
/* *** BEGIN *** Initialize idaa_slct and idaa_trig */
|
||||
/* *** BEGIN *** Initialize idaa_slct and idaa_trigger */
|
||||
/* The slct and slct_trigger variable should not be stored in local storage. Only use session storage because browser tabs can be open to different idaa, badges, exhibits, etc. */
|
||||
|
||||
// Intended for temporary session storage.
|
||||
@@ -193,30 +136,11 @@ let idaa_slct_obj_template: key_val = {
|
||||
export let idaa_slct = writable(idaa_slct_obj_template);
|
||||
|
||||
// This works and uses *local* storage:
|
||||
// export let idaa_slct: Writable<key_val> = persisted('ae_idaa_slct', idaa_slct_obj_template);
|
||||
// export let idaa_slct: Writable<key_val> = localStorageStore('ae_idaa_slct', idaa_slct_obj_template);
|
||||
|
||||
|
||||
/* *** BEGIN *** Initialize idaa_trig */
|
||||
/* *** BEGIN *** Initialize idaa_trigger */
|
||||
// Intended for temporary session storage.
|
||||
// Updated 2024-11-19
|
||||
let idaa_trig_template: key_val = {
|
||||
archive_id: false,
|
||||
archive_content_li: false,
|
||||
event_id: false,
|
||||
post_id: false,
|
||||
};
|
||||
export let idaa_trig: any = writable(idaa_trig_template);
|
||||
// console.log(`AE IDAA Stores - IDAA Trigger:`, idaa_trig);
|
||||
|
||||
|
||||
/* *** BEGIN *** Initialize idaa_prom */
|
||||
// Intended for temporary session storage.
|
||||
// Updated 2024-11-19
|
||||
let idaa_prom_template: key_val = {
|
||||
archive_id: false,
|
||||
archive_content_li: false,
|
||||
event_id: false,
|
||||
post_id: false,
|
||||
};
|
||||
export let idaa_prom: any = writable(idaa_prom_template);
|
||||
// console.log(`AE IDAA Stores - IDAA Trigger:`, idaa_prom);
|
||||
// Updated 2024-03-06
|
||||
export let idaa_trigger: any = writable(null);
|
||||
// console.log(`AE IDAA Stores - IDAA Trigger:`, idaa_trigger);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,22 +0,0 @@
|
||||
// This file is used to export all the functions that are used for Aether Journals related functions.
|
||||
|
||||
import * as journal from "$lib/ae_journals/ae_journals__journal";
|
||||
import * as journal_entry from "$lib/ae_journals/ae_journals__journal_entry";
|
||||
|
||||
|
||||
let export_obj = {
|
||||
load_ae_obj_id__journal: journal.load_ae_obj_id__journal,
|
||||
load_ae_obj_li__journal: journal.load_ae_obj_li__journal,
|
||||
create_ae_obj__journal: journal.create_ae_obj__journal,
|
||||
delete_ae_obj_id__journal: journal.delete_ae_obj_id__journal,
|
||||
update_ae_obj__journal: journal.update_ae_obj__journal,
|
||||
// db_save_ae_obj_li__journal: journal.db_save_ae_obj_li__journal,
|
||||
load_ae_obj_id__journal_entry: journal_entry.load_ae_obj_id__journal_entry,
|
||||
load_ae_obj_li__journal_entry: journal_entry.load_ae_obj_li__journal_entry,
|
||||
create_ae_obj__journal_entry: journal_entry.create_ae_obj__journal_entry,
|
||||
delete_ae_obj_id__journal_entry: journal_entry.delete_ae_obj_id__journal_entry,
|
||||
update_ae_obj__journal_entry: journal_entry.update_ae_obj__journal_entry,
|
||||
qry__journal_entry: journal_entry.qry__journal_entry,
|
||||
// db_save_ae_obj_li__journal_entry: journal_entry.db_save_ae_obj_li__journal_entry,
|
||||
};
|
||||
export let journals_func = export_obj;
|
||||
@@ -1,150 +0,0 @@
|
||||
import { persisted } from 'svelte-persisted-store';
|
||||
|
||||
import { writable } from 'svelte/store';
|
||||
import type { Writable } from 'svelte/store';
|
||||
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
|
||||
|
||||
/* *** BEGIN *** Initialize journals_local_data_struct */
|
||||
// This is for longer term or sticky app data. This should be stored to *local* storage.
|
||||
// Updated 2025-03-20
|
||||
let journals_local_data_struct: key_val = {
|
||||
ver: '2024-08-20_19',
|
||||
// Shared
|
||||
name: 'Aether - Journals (SvelteKit 2.x Svelte 4.x)',
|
||||
title: `OSIT's Æ Journals`, // Æ
|
||||
|
||||
mode__edit: false,
|
||||
mode__debug: false,
|
||||
|
||||
qry__enabled: 'enabled', // all, disabled, enabled
|
||||
qry__hidden: 'not_hidden', // all, hidden, not_hidden
|
||||
qry__limit: 20,
|
||||
qry__order_by_li: {
|
||||
// 'created_on': 'desc',
|
||||
// 'updated_on': 'desc',
|
||||
},
|
||||
qry__offset: 0,
|
||||
qry__journal_id: null,
|
||||
|
||||
journal: {
|
||||
edit: false,
|
||||
edit_kv: {},
|
||||
|
||||
type_code_li: [
|
||||
{ code: 'diary', name: 'Diary' },
|
||||
{ code: 'log', name: 'Log' },
|
||||
{ code: 'journal', name: 'Journal' },
|
||||
{ code: 'notebook', name: 'Notebook' },
|
||||
{ code: 'personal', name: 'Personal' },
|
||||
{ code: 'professional', name: 'Professional' },
|
||||
{ code: 'tracking', name: 'Tracking' },
|
||||
{ code: 'other', name: 'Other' },
|
||||
{ code: 'test', name: 'Test' },
|
||||
// { code: 'notepad', name: 'Notepad' },
|
||||
],
|
||||
},
|
||||
entry: {
|
||||
edit: false,
|
||||
edit_kv: {},
|
||||
},
|
||||
|
||||
};
|
||||
// console.log(`AE Stores - App Journals Local Storage Data:`, journals_local_data_struct);
|
||||
|
||||
// This works and uses *local* storage:
|
||||
export let journals_loc: Writable<key_val> = persisted('ae_journals_loc', journals_local_data_struct);
|
||||
// console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
|
||||
|
||||
|
||||
/* *** BEGIN *** Initialize journals_session_data_struct */
|
||||
// Temporary app data. This is lost if the page is refreshed or using different tabs/windows. This should be stored to *session* storage.
|
||||
// Updated 2025-03-20
|
||||
let journals_session_data_struct: key_val = {
|
||||
ver: '2024-08-20_19',
|
||||
log_lvl: 1,
|
||||
|
||||
// Shared Triggers
|
||||
trigger: null,
|
||||
trigger__journal_id: null,
|
||||
// trigger__journal_li: null,
|
||||
|
||||
show__modal_edit__journal_obj: false,
|
||||
show__modal_new__journal_obj: false,
|
||||
show__modal_view__journal_id: null,
|
||||
show_list__journal_entry_li_group: true,
|
||||
show__modal_view__journal_entry_id: null,
|
||||
show__modal_edit__journal_entry_id: null,
|
||||
|
||||
show__modal_edit__journal_obj: false,
|
||||
|
||||
show__content__journal_entry_history: false,
|
||||
|
||||
journal: {
|
||||
edit: false,
|
||||
edit_kv: {},
|
||||
|
||||
new_journal_name: '',
|
||||
new_journal_type_code: '',
|
||||
|
||||
tmp_obj: {},
|
||||
},
|
||||
entry: {
|
||||
decrypt_kv: {}, // Essentially flag that the entry (content and history) can be decrypted.
|
||||
edit: false,
|
||||
edit_kv: {},
|
||||
|
||||
tmp_obj: {},
|
||||
},
|
||||
|
||||
journal_kv: {
|
||||
// journal_id: {},
|
||||
},
|
||||
};
|
||||
// console.log(`AE Stores - App Journals Session Storage Data:`, journals_session_data_struct);
|
||||
export let journals_sess = writable(journals_session_data_struct);
|
||||
|
||||
|
||||
|
||||
/* *** BEGIN *** Initialize journals_slct and journals_trig */
|
||||
/* The slct and slct_trigger variable should not be stored in local storage. Only use session storage because browser tabs can be open to different journals, badges, exhibits, etc. */
|
||||
|
||||
// Intended for temporary session storage.
|
||||
// Updated 2024-08-20
|
||||
let journals_slct_obj_template: key_val = {
|
||||
// Top level
|
||||
'journal_id': null,
|
||||
'journal_obj': {},
|
||||
'journal_obj_li': [],
|
||||
|
||||
'tmp_journal_obj': {}, // Temporary object for new journal
|
||||
'tmp_journal_entry_obj': {}, // Temporary object for new journal entry
|
||||
|
||||
'lq__journal_obj': {}, // Testing passing a LiveQuery object around...
|
||||
};
|
||||
// console.log(`AE Stores - Selected Journals Objects:`, journals_slct_obj_template);
|
||||
|
||||
// This works, and uses *session* (not local) storage:
|
||||
export let journals_slct = writable(journals_slct_obj_template);
|
||||
|
||||
|
||||
/* *** BEGIN *** Initialize journals_trig */
|
||||
// Intended for temporary session storage.
|
||||
// Updated 2025-03-16
|
||||
let journals_trig_template: key_val = {
|
||||
journal_id: false,
|
||||
journal_entry_li: false,
|
||||
};
|
||||
export let journals_trig: any = writable(journals_trig_template);
|
||||
// console.log(`AE Journals Stores - Journals Trigger:`, journals_trig);
|
||||
|
||||
|
||||
/* *** BEGIN *** Initialize journals_prom */
|
||||
// Intended for temporary session storage.
|
||||
// Updated 2025-03-16
|
||||
let journals_prom_template: key_val = {
|
||||
journal_id: false,
|
||||
journal_entry_li: false,};
|
||||
export let journals_prom: any = writable(journals_prom_template);
|
||||
// console.log(`AE Journals Stores - Journals Trigger:`, journals_prom);
|
||||
@@ -1,543 +0,0 @@
|
||||
import Dexie, { type Table } from 'dexie';
|
||||
|
||||
import type { key_val } from '../ae_stores';
|
||||
|
||||
// li = list
|
||||
// kv = key value list
|
||||
// json = JSON string
|
||||
// ux = user experience (mode)
|
||||
// LLM = Large Language Model (AI)
|
||||
// Updated 2025-03-15
|
||||
|
||||
|
||||
export interface Journal {
|
||||
id: string; // actually "id_random"
|
||||
journal_id: string;
|
||||
|
||||
// Essentially this is a change log of journals
|
||||
snapshot_id?: string; // This is the original journal ID. If deleted, then delete all children journals.
|
||||
previous_id?: null|string; // This is the old or parent journal ID
|
||||
next_id?: null|string; // This is the new or child journal ID
|
||||
|
||||
external_id?: null|string;
|
||||
import_id?: null|string;
|
||||
code?: null|string;
|
||||
|
||||
for_type?: null|string;
|
||||
for_id?: null|string;
|
||||
|
||||
// template?: null|boolean; // Is this a template journal? If true, it can be used to create new journals.
|
||||
|
||||
type_code?: null|string;
|
||||
|
||||
account_id?: null|string; // Owner account of the journal
|
||||
person_id?: null|string; // Owner person of the journal
|
||||
// event_id?: null|string; // Assign to an event???
|
||||
// location_id?: null|string; // Assign to a location???
|
||||
|
||||
name: string; // or the title
|
||||
short_name?: null|string; // Short name for the journal, if any. Used for display purposes.
|
||||
summary?: null|string; // LLM (AI) generated summary...???
|
||||
outline?: null|string; // LLM (AI) generated outline...???
|
||||
|
||||
description?: null|string;
|
||||
description_md_html?: null|string; // Markdown converted to HTML based on description. Uses marked or similar library for conversion.
|
||||
description_md_html_alt?: null|string; // Markdown converted to HTML based on description. Uses marked or similar library for conversion.
|
||||
description_html?: null|string;
|
||||
description_json?: null|string;
|
||||
|
||||
start_datetime?: null|Date;
|
||||
end_datetime?: null|Date;
|
||||
timezone?: null|string;
|
||||
|
||||
alert?: null|boolean; // LLM (AI) generated summary...???
|
||||
alert_msg?: null|string; // LLM (AI) generated summary...???
|
||||
|
||||
sort_by?: null|string; // This is the sort by field
|
||||
sort_by_desc?: null|string; // This is the sort by field description
|
||||
|
||||
cfg_json?: null|key_val; // This is the configuration JSON for the journal
|
||||
|
||||
data_json?: null|key_val; // We always need to store something extra...
|
||||
|
||||
ux_mode?: null|string; // 'mobile' or 'desktop'
|
||||
|
||||
// This only allows for basic access to the data.
|
||||
passcode_read?: null|string; // For LLM (AI) generated summary...???
|
||||
passcode_read_expire?: null|Date;
|
||||
passcode_write?: null|string;
|
||||
passcode_write_expire?: null|Date
|
||||
|
||||
passcode?: null|string; // For Journal Entry encryption password
|
||||
passcode_timeout?: null|number; // Timeout in seconds
|
||||
|
||||
private_passcode?: null|string; // Combine with the Journal passcode for Journal Entry encryption password
|
||||
|
||||
auth_key?: null|string; // For Journal authorization without sign in
|
||||
|
||||
enable: null|boolean;
|
||||
hide?: null|boolean;
|
||||
archive?: null|boolean; // Archive the journal
|
||||
archive_on?: null|Date;
|
||||
priority?: null|boolean
|
||||
sort?: null|number;
|
||||
group?: null|string;
|
||||
notes?: null|string;
|
||||
created_on: Date;
|
||||
updated_on?: null|Date;
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1?: null|string;
|
||||
tmp_sort_2?: null|string;
|
||||
tmp_sort_3?: null|string;
|
||||
|
||||
combined_passcode?: null|string; // For Journal Entry encryption password
|
||||
|
||||
// Additional fields for convenience (database views)
|
||||
file_count?: null|number; // Only files directly under a journal
|
||||
journal_file_id_li_json?: null|string;
|
||||
|
||||
// One person
|
||||
person__given_name?: null|string;
|
||||
person__family_name?: null|string;
|
||||
person__full_name?: null|string;
|
||||
person__primary_email?: null|string;
|
||||
person__passcode?: null|string;
|
||||
|
||||
// JSON formatted key value pairs for multiple people: {id: name, email, etc.}
|
||||
person__kv_json?: null|string;
|
||||
|
||||
journal_name?: null|string;
|
||||
|
||||
journal_location_code?: null|string;
|
||||
journal_location_name?: null|string;
|
||||
|
||||
journal_entry_count?: null|number;
|
||||
|
||||
// A key value list of the entries
|
||||
journal_entry_kv?: null|key_val;
|
||||
journal_entry_li?: null|[];
|
||||
// A key value list of the files
|
||||
journal_file_kv?: null|key_val;
|
||||
journal_file_li?: null|[];
|
||||
|
||||
// journal_collection_id?: null|string; // For a collection of journals?
|
||||
|
||||
// Future standard fields!!!
|
||||
obj_id?: null|string;
|
||||
obj_ext_uid?: null|string; // Probably not needed for journals
|
||||
obj_ext_id?: null|string; // Probably not needed for journals
|
||||
obj_import_id?: null|string; // Probably not needed for journals
|
||||
obj_code?: null|string;
|
||||
obj_account_id?: null|string;
|
||||
obj_passcode?: null|string;
|
||||
obj_type?: null|string; // Should always be 'journal' in this case
|
||||
obj_type_ver_id?: null|string; // The ID from the table for the object type
|
||||
obj_name?: null|string;
|
||||
obj_summary?: null|string; // LLM (AI) generated summary...???
|
||||
obj_outline?: null|string; // LLM (AI) generated outline...???
|
||||
obj_description?: null|string; // Probably not needed for journals
|
||||
obj_enable?: null|boolean;
|
||||
obj_enable_on?: null|Date;
|
||||
obj_archive_on?: null|Date;
|
||||
obj_hide?: null|boolean;
|
||||
obj_priority?: null|number;
|
||||
obj_sort?: null|number;
|
||||
obj_group?: null|string;
|
||||
obj_cfg_json?: null|string;
|
||||
obj_notes?: null|string;
|
||||
obj_created_on?: Date;
|
||||
obj_updated_on?: null|Date;
|
||||
}
|
||||
|
||||
export const journal_field_li = [
|
||||
'id',
|
||||
'journal_id',
|
||||
'snapshot_id',
|
||||
'previous_id',
|
||||
'next_id',
|
||||
'external_id',
|
||||
'import_id',
|
||||
'code',
|
||||
'for_type',
|
||||
'for_id',
|
||||
'type_code',
|
||||
'account_id',
|
||||
'person_id',
|
||||
'name',
|
||||
'short_name',
|
||||
'summary',
|
||||
'outline',
|
||||
'description',
|
||||
'description_md_html',
|
||||
'description_md_html_alt',
|
||||
'description_html',
|
||||
'description_json',
|
||||
'start_datetime',
|
||||
'end_datetime',
|
||||
'timezone',
|
||||
'alert',
|
||||
'alert_msg',
|
||||
'sort_by',
|
||||
'sort_by_desc',
|
||||
'cfg_json',
|
||||
'data_json',
|
||||
'ux_mode',
|
||||
'passcode_read',
|
||||
'passcode_read_expire',
|
||||
'passcode_write',
|
||||
'passcode_write_expire',
|
||||
'passcode_timeout',
|
||||
'private_passcode',
|
||||
'auth_key',
|
||||
'enable',
|
||||
'hide',
|
||||
'archive', // Archive the journal
|
||||
'archive_on', // Archive date
|
||||
'priority', // Priority flag
|
||||
'sort', // Sort order
|
||||
'group', // Group name
|
||||
'notes', // Notes about the journal
|
||||
'created_on', // Creation date
|
||||
'updated_on', // Last updated date
|
||||
|
||||
'tmp_sort_1', // Temporary sort field 1
|
||||
'tmp_sort_2', // Temporary sort field 2
|
||||
'tmp_sort_3', // Temporary sort field 3
|
||||
|
||||
'combined_passcode', // For Journal Entry encryption password
|
||||
'file_count', // Only files directly under a journal
|
||||
'journal_file_id_li_json', // JSON string of file IDs
|
||||
'person__given_name', // Person's given name
|
||||
'person__family_name', // Person's family name
|
||||
'person__full_name', // Person's full name
|
||||
'person__primary_email', // Person's primary email
|
||||
'person__passcode', // Person's passcode
|
||||
'person__kv_json', // JSON formatted key value pairs for multiple people
|
||||
'journal_name', // Journal name
|
||||
'journal_location_code', // Journal location code
|
||||
'journal_location_name', // Journal location name
|
||||
'journal_entry_count', // Count of journal entries
|
||||
'journal_entry_kv', // Key value list of the entries
|
||||
'journal_entry_li', // List of journal entries
|
||||
'journal_file_kv', // Key value list of the files
|
||||
'journal_file_li', // List of journal files
|
||||
|
||||
'obj_id', // Object ID
|
||||
'obj_ext_uid', // External UID
|
||||
'obj_ext_id', // External ID
|
||||
'obj_import_id', // Import ID
|
||||
'obj_code', // Object code
|
||||
'obj_account_id', // Object account ID
|
||||
'obj_passcode', // Object passcode
|
||||
'obj_type', // Object type
|
||||
'obj_type_ver_id', // Object type version ID
|
||||
'obj_name', // Object name
|
||||
'obj_summary', // Object summary
|
||||
'obj_outline', // Object outline
|
||||
'obj_description', // Object description
|
||||
'obj_enable', // Object enable flag
|
||||
'obj_enable_on', // Object enable date
|
||||
'obj_archive_on', // Object archive date
|
||||
'obj_hide', // Object hide flag
|
||||
'obj_priority', // Object priority
|
||||
'obj_sort', // Object sort order
|
||||
'obj_group', // Object group name
|
||||
'obj_cfg_json', // Object configuration JSON
|
||||
'obj_notes', // Object notes
|
||||
'obj_created_on', // Object creation date
|
||||
'obj_updated_on' // Object last updated date
|
||||
];
|
||||
|
||||
// Updated 2025-04-02
|
||||
export interface Journal_Entry {
|
||||
id: string; // actually "id_random"
|
||||
journal_entry_id: string;
|
||||
|
||||
journal_id: string; // This is the parent journal ID. If deleted, then delete all children journal entries.
|
||||
|
||||
// Essentially this is a change log of journal entries
|
||||
snapshot_id?: string; // This is the original journal ID. If deleted, then delete all children journal entries.
|
||||
previous_id?: null|string; // This is the old or parent journal ID
|
||||
next_id?: null|string; // This is the new or child journal ID
|
||||
|
||||
external_id?: null|string;
|
||||
import_id?: null|string;
|
||||
code?: null|string;
|
||||
|
||||
for_type?: null|string;
|
||||
for_id?: null|string;
|
||||
|
||||
template?: null|boolean; // Is this a template journal entry? If true, it can be used to create new journal entries.
|
||||
|
||||
activity_code?: null|string;
|
||||
category_code?: null|string;
|
||||
topic_code?: null|string;
|
||||
type_code?: null|string;
|
||||
tags?: null|string; // Comma separated tags
|
||||
|
||||
journal_entry_type?: null|string; // This is the type of journal entry
|
||||
|
||||
account_id?: null|string; // Owner account of the journal
|
||||
person_id?: null|string; // Owner person of the journal
|
||||
// event_id?: null|string; // Assign to an event???
|
||||
// location_id?: null|string; // Assign to a location???
|
||||
|
||||
public?: null|boolean;
|
||||
private?: null|boolean;
|
||||
personal?: null|boolean;
|
||||
professional?: null|boolean;
|
||||
|
||||
name: string; // or the title
|
||||
short_name?: null|string; // Short name for the journal entry, if any. Used for display purposes. Most likely for the templates list.
|
||||
summary?: null|string; // LLM (AI) generated summary...???
|
||||
outline?: null|string; // LLM (AI) generated outline...???
|
||||
// description?: null|string; // This is the description of the journal entry
|
||||
|
||||
content?: null|string;
|
||||
content_md_html?: null|string; // Markdown converted to HTML based on content. Uses marked or similar library for conversion.
|
||||
content_md_html_alt?: null|string; // Markdown converted to HTML based on content. Uses marked or similar library for conversion.
|
||||
content_html?: null|string;
|
||||
content_json?: null|string;
|
||||
content_encrypted?: null|string; // This is the encrypted content of the journal entry
|
||||
|
||||
history?: null|string; // This is the history of the journal entry; a log
|
||||
history_encrypted?: null|string; // This is the encrypted history of the journal entry
|
||||
|
||||
passcode_hash?: null|string; // This is the passcode hash for the journal entry to look up the passcode
|
||||
|
||||
start_datetime?: null|Date;
|
||||
end_datetime?: null|Date;
|
||||
timezone?: null|string;
|
||||
seconds?: null|number; // Duration in seconds
|
||||
|
||||
location?: null|string; // Location of the journal entry
|
||||
latitude?: null|number; // Latitude of the journal entry
|
||||
longitude?: null|number; // Longitude of the journal entry
|
||||
|
||||
billable?: null|boolean; // Is this billable?
|
||||
bill_to?: null|string; // Who to bill for this journal entry
|
||||
bill_rate?: null|number; // Rate to bill for this journal entry
|
||||
billable_minutes?: null|number; // Billable minutes for this journal entry
|
||||
|
||||
alert?: null|boolean; // LLM (AI) generated summary...???
|
||||
alert_msg?: null|string; // LLM (AI) generated summary...???
|
||||
|
||||
parent_id?: null|string; // This is the parent journal entry ID. If deleted, then delete all children journal entries.
|
||||
related_entry_id_li?: null|key_val; // List of related journal entry IDs
|
||||
|
||||
// cfg_json?: null|key_val; // This is the configuration JSON for the journal entry
|
||||
data_json?: null|key_val; // We always need to store something extra...
|
||||
|
||||
// This only allows for basic access to the content.
|
||||
passcode_read?: null|string; // For LLM (AI) generated summary...???
|
||||
passcode_read_expire?: null|Date;
|
||||
passcode_write?: null|string;
|
||||
passcode_write_expire?: null|Date
|
||||
|
||||
enable: null|boolean;
|
||||
hide?: null|boolean;
|
||||
priority?: null|boolean
|
||||
sort?: null|number;
|
||||
group?: null|string;
|
||||
notes?: null|string;
|
||||
created_on: Date;
|
||||
updated_on?: null|Date;
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1?: null|string;
|
||||
tmp_sort_2?: null|string;
|
||||
tmp_sort_3?: null|string;
|
||||
|
||||
// Additional fields for convenience (database views)
|
||||
file_count?: null|number; // Only files directly under a journal
|
||||
journal_file_id_li_json?: null|string;
|
||||
|
||||
journal_code?: null|string; // This is the code for the journal entry
|
||||
journal_name?: null|string; // This is the name for the journal entry
|
||||
|
||||
// One person
|
||||
person__given_name?: null|string;
|
||||
person__family_name?: null|string;
|
||||
person__full_name?: null|string;
|
||||
person__primary_email?: null|string;
|
||||
person__passcode?: null|string;
|
||||
|
||||
// JSON formatted key value pairs for multiple people: {id: name, email, etc.}
|
||||
person__kv_json?: null|string;
|
||||
|
||||
// A key value list of the files
|
||||
journal_file_kv?: null|key_val;
|
||||
journal_file_li?: null|[];
|
||||
|
||||
// journal_collection_id?: null|string; // For a collection of journal entries?
|
||||
|
||||
// Future standard fields!!!
|
||||
obj_id?: null|string;
|
||||
obj_ext_uid?: null|string; // Probably not needed for journal entries
|
||||
obj_ext_id?: null|string; // Probably not needed for journal entries
|
||||
obj_import_id?: null|string; // Probably not needed for journal entries
|
||||
obj_code?: null|string;
|
||||
obj_account_id?: null|string;
|
||||
obj_passcode?: null|string;
|
||||
obj_type?: null|string; // Should always be 'journal' in this case
|
||||
obj_type_ver_id?: null|string; // The ID from the table for the object type
|
||||
obj_name?: null|string;
|
||||
obj_summary?: null|string; // LLM (AI) generated summary...???
|
||||
obj_outline?: null|string; // LLM (AI) generated outline...???
|
||||
obj_description?: null|string; // Probably not needed for journal entries
|
||||
obj_enable?: null|boolean;
|
||||
obj_enable_on?: null|Date;
|
||||
obj_archive_on?: null|Date;
|
||||
obj_hide?: null|boolean;
|
||||
obj_priority?: null|number;
|
||||
obj_sort?: null|number;
|
||||
obj_group?: null|string;
|
||||
obj_cfg_json?: null|string;
|
||||
obj_notes?: null|string;
|
||||
obj_created_on?: Date;
|
||||
obj_updated_on?: null|Date;
|
||||
}
|
||||
|
||||
export const journal_entry_field_li = [
|
||||
'id',
|
||||
'journal_entry_id',
|
||||
'journal_id',
|
||||
'code',
|
||||
'for_type',
|
||||
'for_id',
|
||||
'template',
|
||||
'activity_code',
|
||||
'category_code',
|
||||
'topic_code',
|
||||
'type_code',
|
||||
'tags',
|
||||
'journal_entry_type',
|
||||
'account_id',
|
||||
'person_id',
|
||||
'public',
|
||||
'private',
|
||||
'personal',
|
||||
'professional',
|
||||
'name',
|
||||
'short_name',
|
||||
'summary',
|
||||
'outline',
|
||||
'content',
|
||||
'content_md_html',
|
||||
'content_md_html_alt',
|
||||
'content_html',
|
||||
'content_json',
|
||||
'content_encrypted',
|
||||
'history',
|
||||
'history_encrypted',
|
||||
'passcode_hash',
|
||||
'start_datetime',
|
||||
'end_datetime',
|
||||
'timezone',
|
||||
'seconds',
|
||||
'location',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'billable',
|
||||
'bill_to',
|
||||
'bill_rate',
|
||||
'billable_minutes',
|
||||
'alert',
|
||||
'alert_msg',
|
||||
'parent_id',
|
||||
'related_entry_id_li',
|
||||
'data_json',
|
||||
'passcode_read',
|
||||
'passcode_read_expire',
|
||||
'passcode_write',
|
||||
'passcode_write_expire',
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
'tmp_sort_3',
|
||||
|
||||
'file_count',
|
||||
'journal_file_id_li_json',
|
||||
'journal_code',
|
||||
'journal_name',
|
||||
'person__given_name',
|
||||
'person__family_name',
|
||||
'person__full_name',
|
||||
'person__primary_email',
|
||||
'person__passcode',
|
||||
'person__kv_json',
|
||||
'journal_file_kv',
|
||||
'journal_file_li',
|
||||
|
||||
'obj_id',
|
||||
'obj_ext_uid',
|
||||
'obj_ext_id',
|
||||
'obj_import_id',
|
||||
'obj_code',
|
||||
'obj_account_id',
|
||||
'obj_passcode',
|
||||
'obj_type',
|
||||
'obj_type_ver_id',
|
||||
'obj_name',
|
||||
'obj_summary',
|
||||
'obj_outline',
|
||||
'obj_description',
|
||||
'obj_enable',
|
||||
'obj_enable_on',
|
||||
'obj_archive_on',
|
||||
'obj_hide',
|
||||
'obj_priority',
|
||||
'obj_sort',
|
||||
'obj_group',
|
||||
'obj_cfg_json',
|
||||
'obj_notes',
|
||||
'obj_created_on',
|
||||
'obj_updated_on'
|
||||
];
|
||||
|
||||
|
||||
// Updated 2024-06-10
|
||||
export class MySubClassedDexie extends Dexie {
|
||||
// We just tell the typing system this is the case
|
||||
journal!: Table<Journal>;
|
||||
journal_entry!: Table<Journal_Entry>;
|
||||
|
||||
constructor() {
|
||||
super('ae_journals_db');
|
||||
this.version(4).stores({
|
||||
journal: `
|
||||
id, journal_id,
|
||||
code,
|
||||
account_id,
|
||||
person_id,
|
||||
conference, type,
|
||||
name,
|
||||
start_datetime, end_datetime,
|
||||
timezone,
|
||||
tmp_sort_1, tmp_sort_2, tmp_sort_3,
|
||||
enable, hide, priority, sort, group, created_on, updated_on`,
|
||||
journal_entry: `
|
||||
id, journal_entry_id,
|
||||
journal_id,
|
||||
code,
|
||||
account_id,
|
||||
template,
|
||||
name,
|
||||
start_datetime, end_datetime,
|
||||
timezone,
|
||||
tmp_sort_1, tmp_sort_2, tmp_sort_3,
|
||||
enable, hide, priority, sort, group, created_on, updated_on`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const db_journals = new MySubClassedDexie();
|
||||
646
src/lib/ae_notes__note.ts
Normal file
646
src/lib/ae_notes__note.ts
Normal file
@@ -0,0 +1,646 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_notes } from "$lib/db_notes";
|
||||
|
||||
// import { load_ae_obj_li__note_other } from "$lib/ae_notes__note_other";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function load_ae_obj_id__note(
|
||||
{
|
||||
api_cfg,
|
||||
note_id,
|
||||
// inc_other_li = false,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
note_id: string,
|
||||
// inc_other_li?: boolean,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** load_ae_obj_id__note() *** note_id=${note_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
ae_promises.load__note_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'note',
|
||||
obj_id: note_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (note_obj_get_result) {
|
||||
if (note_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__note({
|
||||
obj_type: 'note',
|
||||
obj_li: [note_obj_get_result]
|
||||
});
|
||||
}
|
||||
return note_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__note_obj:', ae_promises.load__note_obj);
|
||||
}
|
||||
|
||||
// if (inc_other_li) {
|
||||
// // Load the others for the note
|
||||
// if (log_lvl) {
|
||||
// console.log(`Need to load the other list for the note now`);
|
||||
// }
|
||||
// let load_note_other_obj_li = load_ae_obj_li__note_other({
|
||||
// api_cfg: api_cfg,
|
||||
// for_obj_type: 'note',
|
||||
// for_obj_id: note_id,
|
||||
// inc_other_li: inc_other_li,
|
||||
// params: {qry__enabled: 'all', qry__limit: 25},
|
||||
// try_cache: try_cache,
|
||||
// log_lvl: log_lvl
|
||||
// })
|
||||
// .then((note_other_obj_li) => {
|
||||
// if (log_lvl) {
|
||||
// console.log(`note_other_obj_li = `, note_other_obj_li);
|
||||
// }
|
||||
// return note_other_obj_li;
|
||||
// });
|
||||
|
||||
// if (log_lvl) {
|
||||
// console.log(`note_other_obj_li = `, load_note_other_obj_li);
|
||||
// }
|
||||
// ae_promises.load__note_obj.note_other_li = load_note_other_obj_li;
|
||||
// }
|
||||
|
||||
return ae_promises.load__note_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function load_ae_obj_li__note(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type = 'account',
|
||||
for_obj_id,
|
||||
// inc_other_li = false,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
// inc_other_li?: boolean,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** load_ae_obj_li__note() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
ae_promises.load__note_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'note',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (note_obj_li_get_result) {
|
||||
if (note_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__note({
|
||||
obj_type: 'note',
|
||||
obj_li: note_obj_li_get_result
|
||||
});
|
||||
}
|
||||
return note_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__note_obj_li:', ae_promises.load__note_obj_li);
|
||||
}
|
||||
|
||||
// if (inc_other_li) {
|
||||
// // Load the others for the notes
|
||||
// if (log_lvl) {
|
||||
// console.log(`Need to load the other list for each note now`);
|
||||
// }
|
||||
// for (let i = 0; i < ae_promises.load__note_obj_li.length; i++) {
|
||||
// let note_obj = ae_promises.load__note_obj_li[i];
|
||||
// let note_id = note_obj.note_id_random;
|
||||
|
||||
// let load_note_other_obj_li = load_ae_obj_li__note_other({
|
||||
// api_cfg: api_cfg,
|
||||
// for_obj_type: 'note',
|
||||
// for_obj_id: note_id,
|
||||
// params: {qry__enabled: enabled, qry__limit: limit},
|
||||
// try_cache: try_cache,
|
||||
// log_lvl: log_lvl
|
||||
// })
|
||||
// .then((note_other_obj_li) => {
|
||||
// if (log_lvl) {
|
||||
// console.log(`note_other_obj_li = `, note_other_obj_li);
|
||||
// }
|
||||
|
||||
// return note_other_obj_li;
|
||||
// });
|
||||
|
||||
// if (log_lvl) {
|
||||
// console.log(`load_note_other_obj_li = `, load_note_other_obj_li);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
return ae_promises.load__note_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function create_ae_obj__note(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** create_ae_obj__note() *** account_id=${account_id}`);
|
||||
|
||||
ae_promises.create__note = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'note',
|
||||
fields: {
|
||||
account_id_random: account_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (note_obj_create_result) {
|
||||
if (note_obj_create_result) {
|
||||
db_save_ae_obj_li__note(
|
||||
{
|
||||
obj_type: 'note',
|
||||
obj_li: [note_obj_create_result]
|
||||
});
|
||||
return note_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__note:', ae_promises.create__note);
|
||||
}
|
||||
return ae_promises.create__note;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__note(
|
||||
{
|
||||
api_cfg,
|
||||
note_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
note_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__note() *** note_id=${note_id}`, data_kv);
|
||||
}
|
||||
ae_promises.update__note_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'note',
|
||||
obj_id: note_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (note_obj_update_result) {
|
||||
if (note_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__note({
|
||||
obj_type: 'note', obj_li: [note_obj_update_result]
|
||||
});
|
||||
}
|
||||
return note_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__note_obj:', ae_promises.update__note_obj);
|
||||
}
|
||||
return ae_promises.update__note_obj;
|
||||
}
|
||||
|
||||
|
||||
// This new function is using CRUD v2. This should allow for more flexibility in the queries.
|
||||
// Updated 2024-09-25
|
||||
export async function qry__note(
|
||||
{
|
||||
api_cfg,
|
||||
note_id,
|
||||
qry_str,
|
||||
qry_files,
|
||||
qry_start_datetime, // Example greater than: '2024-10-24'
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 50,
|
||||
offset = 0,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
note_id: any,
|
||||
qry_str?: string,
|
||||
qry_files?: null|boolean,
|
||||
qry_start_datetime?: null|string, // Greater than this datetime
|
||||
enabled?: string, // all, disabled, enabled
|
||||
hidden?: string, // all, hidden, not_hidden
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
params?: any,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** qry__note() *** note_id=${note_id} qry_str=${qry_str}`);
|
||||
|
||||
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
// let limit: number = (params.qry__limit ?? 25); // 99
|
||||
// let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// if (qry_str && qry_str.length > 2) {
|
||||
// params_json['ft_qry'] = {};
|
||||
// params_json['ft_qry']['default_qry_str'] = qry_str;
|
||||
// }
|
||||
|
||||
params_json['qry'] = [];
|
||||
|
||||
if (qry_files === true) {
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "file_count_all",
|
||||
operator: ">",
|
||||
value: 0
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
} else if (qry_files === false) {
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "file_count_all",
|
||||
operator: "IS",
|
||||
value: null
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
}
|
||||
|
||||
if (qry_start_datetime) {
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "start_datetime",
|
||||
operator: ">",
|
||||
value: qry_start_datetime
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
}
|
||||
|
||||
let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
|
||||
|
||||
ae_promises.load__note_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'note',
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: note_id,
|
||||
use_alt_tbl: true, // NOTE: We want to use the alt table for note searching
|
||||
use_alt_mdl: false,
|
||||
use_alt_exp: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (note_obj_li_get_result) {
|
||||
if (note_obj_li_get_result) {
|
||||
db_save_ae_obj_li__note({
|
||||
obj_type: 'note',
|
||||
obj_li: note_obj_li_get_result
|
||||
});
|
||||
return note_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__note_obj_li:', ae_promises.load__note_obj_li);
|
||||
}
|
||||
return ae_promises.load__note_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
// export async function search__note(
|
||||
// {
|
||||
// api_cfg,
|
||||
// account_id,
|
||||
// poc_agree = null,
|
||||
// fulltext_search_qry_str,
|
||||
// ft_other_search_qry_str,
|
||||
// like_search_qry_str = null,
|
||||
// file_count = false, // If true then only show those that have a file count
|
||||
// person_name = null,
|
||||
// params = {},
|
||||
// try_cache = true,
|
||||
// log_lvl = 0
|
||||
// }: {
|
||||
// api_cfg: any,
|
||||
// account_id: any,
|
||||
// poc_agree?: null|boolean,
|
||||
// fulltext_search_qry_str?: null|string,
|
||||
// ft_other_search_qry_str?: null|string,
|
||||
// like_search_qry_str?: null|string,
|
||||
// file_count?: boolean,
|
||||
// person_name?: null|string,
|
||||
// params?: any,
|
||||
// try_cache?: boolean,
|
||||
// log_lvl?: number
|
||||
// }
|
||||
// ) {
|
||||
// console.log(`*** search__note() *** account_id=${account_id}`);
|
||||
|
||||
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
// let limit: number = (params.qry__limit ?? 25); // 99
|
||||
// let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
// let params_json: key_val = {};
|
||||
|
||||
// // if (!fulltext_search_qry_str && !like_search_qry_str) {
|
||||
// // console.log('No search string provided!!!');
|
||||
// // return false; // Returning false instead of [] because no search was performed.
|
||||
// // }
|
||||
|
||||
// if (fulltext_search_qry_str || ft_other_search_qry_str) {
|
||||
// params_json['ft_qry'] = {};
|
||||
// if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
|
||||
// params_json['ft_qry']['default_qry_str'] = fulltext_search_qry_str;
|
||||
// }
|
||||
|
||||
// if (ft_other_search_qry_str && ft_other_search_qry_str.length > 2) {
|
||||
// params_json['ft_qry']['note_other_li_qry_str'] = ft_other_search_qry_str;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Use the AND (AND LIKE) query
|
||||
// // if (like_search_qry_str || like_other_search_qry_str) {
|
||||
// // params_json['and_like'] = {};
|
||||
// // if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
// // params_json['and_like']['default_qry_str'] = like_search_qry_str;
|
||||
// // }
|
||||
// // if (like_other_search_qry_str && like_other_search_qry_str.length > 2) {
|
||||
// // params_json['and_like']['note_other_li_qry_str'] = like_other_search_qry_str;
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // Use the AND (OR LIKE) query
|
||||
// if (like_search_qry_str || like_other_search_qry_str || like_other_search_qry_str) {
|
||||
// params_json['or_like'] = {};
|
||||
// if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
// params_json['or_like']['default_qry_str'] = like_search_qry_str;
|
||||
// }
|
||||
// if (like_other_search_qry_str && like_other_search_qry_str.length > 2) {
|
||||
// params_json['or_like']['note_other_li_qry_str'] = like_other_search_qry_str;
|
||||
// }
|
||||
// if (like_other_search_qry_str && like_other_search_qry_str.length > 2) {
|
||||
// params_json['or_like']['note_other_li_qry_str'] = like_other_search_qry_str;
|
||||
// }
|
||||
// }
|
||||
|
||||
// params_json['and_qry'] = {};
|
||||
|
||||
// if (poc_agree) {
|
||||
// params_json['and_qry']['poc_agree'] = poc_agree;
|
||||
// }
|
||||
|
||||
// if (file_count) {
|
||||
// params_json['and_qry']['file_count'] = file_count;
|
||||
// }
|
||||
|
||||
// // This should be using a like with surrounded by %'s
|
||||
// if (person_name) {
|
||||
// params_json['and_qry']['note_full_name'] = person_name;
|
||||
// }
|
||||
|
||||
// let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
|
||||
|
||||
// ae_promises.load__note_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
// api_cfg: api_cfg,
|
||||
// obj_type: 'note',
|
||||
// for_obj_type: 'account',
|
||||
// for_obj_id: account_id,
|
||||
// use_alt_table: true, // NOTE: We want to use the alt table for note searching
|
||||
// use_alt_base: false,
|
||||
// enabled: enabled,
|
||||
// hidden: hidden,
|
||||
// order_by_li: order_by_li,
|
||||
// limit: limit,
|
||||
// offset: offset,
|
||||
// params_json: params_json,
|
||||
// params: params,
|
||||
// log_lvl: log_lvl
|
||||
// })
|
||||
// .then(function (note_obj_li_get_result) {
|
||||
// if (note_obj_li_get_result) {
|
||||
// if (try_cache) {
|
||||
// db_save_ae_obj_li__note({
|
||||
// obj_type: 'note',
|
||||
// obj_li: note_obj_li_get_result
|
||||
// });
|
||||
// }
|
||||
// return note_obj_li_get_result;
|
||||
// } else {
|
||||
// return [];
|
||||
// }
|
||||
// })
|
||||
// .catch(function (error) {
|
||||
// console.log('No results returned or failed.', error);
|
||||
// })
|
||||
// .finally(function () {
|
||||
// });
|
||||
|
||||
// if (log_lvl) {
|
||||
// console.log('ae_promises.load__note_obj_li:', ae_promises.load__note_obj_li);
|
||||
// }
|
||||
// return ae_promises.load__note_obj_li;
|
||||
// }
|
||||
|
||||
|
||||
// This function will loop through the note_obj_li and save each one to the DB.
|
||||
// Updated 2024-09-25
|
||||
export function db_save_ae_obj_li__note(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__note() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_notes.note.put({
|
||||
id: obj.note_id_random,
|
||||
note_id: obj.note_id_random,
|
||||
|
||||
code: obj.code,
|
||||
|
||||
for_type: obj.for_type,
|
||||
for_id: obj.for_id,
|
||||
|
||||
type_code: obj.type_code,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
person_id: obj.person_id_random,
|
||||
|
||||
name: obj.name,
|
||||
summary: obj.summary,
|
||||
outline: obj.outline,
|
||||
|
||||
// note: obj.note,
|
||||
note_html: obj.note_html,
|
||||
note_json: obj.note_json,
|
||||
|
||||
start_datetime: obj.start_datetime,
|
||||
end_datetime: obj.end_datetime,
|
||||
timezone: obj.timezone,
|
||||
|
||||
alert: obj.alert,
|
||||
alert_msg: obj.alert_msg,
|
||||
|
||||
data_json: obj.data_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// From SQL view
|
||||
// note_other_count: obj.note_other_count,
|
||||
|
||||
// A key value list of the others
|
||||
// note_other_kv: obj.note_other_kv,
|
||||
// note_other_li: obj.note_other_li,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.note_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.note_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_notes.note.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.note_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
20
src/lib/ae_notes_functions.ts
Normal file
20
src/lib/ae_notes_functions.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
// This file is used to export all the functions that are used for Aether Events related functions.
|
||||
|
||||
import {
|
||||
load_ae_obj_id__note,
|
||||
load_ae_obj_li__note,
|
||||
create_ae_obj__note,
|
||||
update_ae_obj__note,
|
||||
// qry__note,
|
||||
db_save_ae_obj_li__note,
|
||||
} from "$lib/ae_notes__note";
|
||||
|
||||
|
||||
let export_obj = {
|
||||
load_ae_obj_id__note: load_ae_obj_id__note,
|
||||
load_ae_obj_li__note: load_ae_obj_li__note,
|
||||
create_ae_obj__note: create_ae_obj__note,
|
||||
update_ae_obj__note: update_ae_obj__note,
|
||||
db_save_ae_obj_li__note: db_save_ae_obj_li__note,
|
||||
};
|
||||
export let notes_func = export_obj;
|
||||
70
src/lib/ae_notes_stores.ts
Normal file
70
src/lib/ae_notes_stores.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import { localStorageStore } from '@skeletonlabs/skeleton';
|
||||
import { writable } from 'svelte/store';
|
||||
import type { Writable } from 'svelte/store';
|
||||
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
|
||||
|
||||
/* *** BEGIN *** Initialize notes_local_data_struct */
|
||||
// This is for longer term or sticky app data. This should be stored to *local* storage.
|
||||
// Updated 2024-08-20
|
||||
let notes_local_data_struct: key_val = {
|
||||
ver: '2024-08-20_19',
|
||||
// Shared
|
||||
name: 'Aether - Notes (SvelteKit 2.x Svelte 4.x)',
|
||||
title: `OSIT's Æ Notes`, // Æ
|
||||
|
||||
mode__edit: false,
|
||||
mode__debug: false,
|
||||
|
||||
};
|
||||
// console.log(`AE Stores - App Notes Local Storage Data:`, notes_local_data_struct);
|
||||
|
||||
// This works and uses *local* storage:
|
||||
export let notes_loc: Writable<key_val> = localStorageStore('ae_notes_loc', notes_local_data_struct);
|
||||
// console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
|
||||
|
||||
|
||||
|
||||
/* *** BEGIN *** Initialize notes_session_data_struct */
|
||||
// Temporary app data. This is lost if the page is refreshed or using different tabs/windows. This should be stored to *session* storage.
|
||||
// Updated 2024-08-20
|
||||
let notes_session_data_struct: key_val = {
|
||||
ver: '2024-08-20_19',
|
||||
log_lvl: 1,
|
||||
|
||||
// Shared Triggers
|
||||
trigger: null,
|
||||
trigger__note_id: null,
|
||||
// trigger__note_li: null,
|
||||
};
|
||||
// console.log(`AE Stores - App Notes Session Storage Data:`, notes_session_data_struct);
|
||||
export let notes_sess = writable(notes_session_data_struct);
|
||||
|
||||
|
||||
|
||||
/* *** BEGIN *** Initialize notes_slct and notes_trigger */
|
||||
/* The slct and slct_trigger variable should not be stored in local storage. Only use session storage because browser tabs can be open to different notes, badges, exhibits, etc. */
|
||||
|
||||
// Intended for temporary session storage.
|
||||
// Updated 2024-08-20
|
||||
let notes_slct_obj_template: key_val = {
|
||||
// Top level
|
||||
'note_id': null,
|
||||
'note_obj': {},
|
||||
'note_obj_li': [],
|
||||
|
||||
'lq__note_obj': {}, // Testing passing a LiveQuery object around...
|
||||
};
|
||||
// console.log(`AE Stores - Selected Notes Objects:`, notes_slct_obj_template);
|
||||
|
||||
// This works, and uses *session* (not local) storage:
|
||||
export let notes_slct = writable(notes_slct_obj_template);
|
||||
|
||||
|
||||
|
||||
/* *** BEGIN *** Initialize notes_trigger */
|
||||
// Intended for temporary session storage.
|
||||
// Updated 2024-08-20
|
||||
export let notes_trigger: any = writable(null);
|
||||
// console.log(`AE Notes Stores - Notes Trigger:`, notes_trigger);
|
||||
@@ -1,593 +0,0 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
||||
|
||||
import { db_posts } from "$lib/ae_posts/db_posts";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2025-06-23
|
||||
export async function load_ae_obj_id__post_comment(
|
||||
{
|
||||
api_cfg,
|
||||
post_comment_id,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
post_comment_id: string,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__post_comment() *** post_comment_id=${post_comment_id}`);
|
||||
}
|
||||
|
||||
ae_promises.load__post_comment_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post_comment',
|
||||
obj_id: post_comment_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (post_comment_obj_get_result) {
|
||||
if (post_comment_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__post_comment_props({
|
||||
obj_li: [post_comment_obj_get_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_posts,
|
||||
table_name: 'comment',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// // This is expecting a list
|
||||
// db_save_ae_obj_li__post_comment({
|
||||
// obj_type: 'post_comment',
|
||||
// obj_li: [post_comment_obj_get_result],
|
||||
// log_lvl: log_lvl
|
||||
|
||||
// });
|
||||
}
|
||||
return post_comment_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
return ae_promises.load__post_comment_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-23
|
||||
export async function load_ae_obj_li__post_comment(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type = 'post',
|
||||
for_obj_id,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'title': 'ASC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__post_comment() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
}
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('params_json:', params_json);
|
||||
}
|
||||
|
||||
ae_promises.load__post_comment_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post_comment',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: false,
|
||||
use_alt_mdl: false,
|
||||
use_alt_exp: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (post_comment_obj_li_get_result) {
|
||||
if (post_comment_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__post_comment_props({
|
||||
obj_li: post_comment_obj_li_get_result,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_posts,
|
||||
table_name: 'comment',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__post_comment({
|
||||
// obj_type: 'post_comment',
|
||||
// obj_li: post_comment_obj_li_get_result,
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return post_comment_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__post_comment_obj_li:', ae_promises.load__post_comment_obj_li);
|
||||
}
|
||||
|
||||
return ae_promises.load__post_comment_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-23
|
||||
export async function create_ae_obj__post_comment(
|
||||
{
|
||||
api_cfg,
|
||||
post_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
post_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** create_ae_obj__post_comment() *** post_id=${post_id}`);
|
||||
}
|
||||
|
||||
if (!post_id) {
|
||||
console.log(`ERROR: Posts - Comment - post_id required to create`);
|
||||
return false;
|
||||
}
|
||||
|
||||
ae_promises.create__post_comment = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post_comment',
|
||||
fields: {
|
||||
post_id_random: post_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (post_comment_obj_create_result) {
|
||||
if (post_comment_obj_create_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__post_comment_props({
|
||||
obj_li: [post_comment_obj_create_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_posts,
|
||||
table_name: 'comment',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__post_comment(
|
||||
// {
|
||||
// obj_type: 'post_comment',
|
||||
// obj_li: [post_comment_obj_create_result],
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return post_comment_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__post_comment:', ae_promises.create__post_comment);
|
||||
}
|
||||
return ae_promises.create__post_comment;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-11-08
|
||||
export async function delete_ae_obj_id__post_comment(
|
||||
{
|
||||
api_cfg,
|
||||
post_comment_id,
|
||||
method = 'delete', // 'delete', 'disable', 'hide'
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
post_comment_id: string,
|
||||
method?: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** delete_ae_obj_id__post_comment() *** post_comment_id=${post_comment_id}`);
|
||||
}
|
||||
|
||||
ae_promises.delete__post_comment_obj = await api.delete_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post_comment',
|
||||
obj_id: post_comment_id,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
method: method,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
if (try_cache) {
|
||||
if (log_lvl) {
|
||||
console.log(`Attempting to remove IDB entry for post_comment_id=${post_comment_id}`);
|
||||
}
|
||||
db_posts.comment.delete(post_comment_id); // Delete from the DB no matter what.
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.delete__post_comment_obj:', ae_promises.delete__post_comment_obj);
|
||||
}
|
||||
|
||||
return ae_promises.delete__post_comment_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-23
|
||||
export async function update_ae_obj__post_comment(
|
||||
{
|
||||
api_cfg,
|
||||
post_comment_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
post_comment_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__post_comment() *** post_comment_id=${post_comment_id}`, data_kv);
|
||||
}
|
||||
|
||||
// Perform the API update
|
||||
const result = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post_comment',
|
||||
obj_id: post_comment_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
|
||||
// Handle the result
|
||||
if (result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__post_comment_props({
|
||||
obj_li: [result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_posts,
|
||||
table_name: 'comment',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// await db_save_ae_obj_li__post_comment({
|
||||
// obj_type: 'post_comment',
|
||||
// obj_li: [result],
|
||||
// log_lvl: log_lvl,
|
||||
// });
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
console.error('Failed to update post comment.');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the post_comment_obj_li and save each one to the DB.
|
||||
// Updated 2024-09-25
|
||||
export function db_save_ae_obj_li__post_comment(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__post_comment() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_posts.comment.put({
|
||||
id: obj.post_comment_id_random,
|
||||
post_comment_id: obj.post_comment_id_random,
|
||||
|
||||
post_id: obj.post_id_random,
|
||||
|
||||
external_person_id: obj.external_person_id,
|
||||
|
||||
name: obj.name,
|
||||
title: obj.title, // Switching to name instead of title
|
||||
// summary: obj.summary,
|
||||
content: obj.content,
|
||||
|
||||
anonymous: obj.anonymous,
|
||||
full_name: obj.full_name,
|
||||
email: obj.email,
|
||||
notify: obj.notify,
|
||||
|
||||
linked_li_json: obj.linked_li_json,
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
tmp_sort_1: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(2, '0') ?? ''}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log(`Put obj with ID: ${obj.post_comment_id_random} or ${id_random}`);
|
||||
}
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.post_comment_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'post_comment_id',
|
||||
// 'post_comment_id_random',
|
||||
|
||||
'post_id',
|
||||
// 'post_id_random',
|
||||
|
||||
'external_person_id',
|
||||
|
||||
'name',
|
||||
'title',
|
||||
'content',
|
||||
|
||||
'anonymous',
|
||||
'full_name',
|
||||
'email',
|
||||
'notify',
|
||||
|
||||
'linked_li_json',
|
||||
'cfg_json',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
// 'tmp_sort_a',
|
||||
// 'tmp_sort_b',
|
||||
|
||||
// From SQL view
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
export async function process_ae_obj__post_comment_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__post_comment_props() ***`, obj_li);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj post_comment:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.post_comment_id_random,
|
||||
post_comment_id: obj.post_comment_id_random,
|
||||
post_comment_id_random: obj.post_comment_id_random,
|
||||
|
||||
post_id: obj.post_id_random,
|
||||
post_id_random: obj.post_id_random,
|
||||
|
||||
external_person_id: obj.external_person_id,
|
||||
|
||||
name: obj.name,
|
||||
title: obj.title,
|
||||
content: obj.content,
|
||||
|
||||
anonymous: obj.anonymous,
|
||||
full_name: obj.full_name,
|
||||
email: obj.email,
|
||||
notify: obj.notify,
|
||||
|
||||
linked_li_json: obj.linked_li_json,
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
@@ -1,86 +1,50 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
||||
import { db_posts } from "$lib/db_posts";
|
||||
|
||||
import { db_posts } from "$lib/ae_posts/db_posts";
|
||||
|
||||
import { load_ae_obj_li__post_comment } from "$lib/ae_posts/ae_posts__post_comment";
|
||||
import { load_ae_obj_li__post_comment } from "$lib/ae_posts__post_comment";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2025-06-23
|
||||
// Updated 2024-09-25
|
||||
export async function load_ae_obj_id__post(
|
||||
{
|
||||
api_cfg,
|
||||
post_id,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
inc_comment_li = false,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
post_id: string,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
inc_comment_li?: boolean,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__post() *** post_id=${post_id}`);
|
||||
}
|
||||
console.log(`*** load_ae_obj_id__post() *** post_id=${post_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
ae_promises.load__post_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post',
|
||||
obj_id: post_id,
|
||||
use_alt_table: true,
|
||||
use_alt_base: false,
|
||||
obj_id: post_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (post_obj_get_result) {
|
||||
.then(function (post_obj_get_result) {
|
||||
if (post_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__post_props({
|
||||
obj_li: [post_obj_get_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_posts,
|
||||
table_name: 'post',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__post({
|
||||
obj_type: 'post',
|
||||
obj_li: [post_obj_get_result]
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// // This is expecting a list
|
||||
// db_save_ae_obj_li__post({
|
||||
// obj_type: 'post',
|
||||
// obj_li: [post_obj_get_result],
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return post_obj_get_result;
|
||||
} else {
|
||||
@@ -95,10 +59,6 @@ export async function load_ae_obj_id__post(
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__post_obj:', ae_promises.load__post_obj);
|
||||
}
|
||||
if (!ae_promises.load__post_obj) {
|
||||
console.log(`ERROR: Posts - Post - The post with ID ${post_id} was not found.`);
|
||||
return ae_promises.load__post_obj; // Return null if the post was not found
|
||||
}
|
||||
|
||||
if (inc_comment_li) {
|
||||
// Load the comments for the post
|
||||
@@ -109,11 +69,7 @@ export async function load_ae_obj_id__post(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'post',
|
||||
for_obj_id: post_id,
|
||||
enabled: enabled, // all, disabled, enabled
|
||||
hidden: hidden, // all, hidden, not_hidden
|
||||
limit: limit, // Limit for the comments
|
||||
offset: offset,
|
||||
params: params,
|
||||
params: {qry__enabled: 'all', qry__limit: 25},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -134,94 +90,46 @@ export async function load_ae_obj_id__post(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-23
|
||||
// Updated 2024-09-25
|
||||
export async function load_ae_obj_li__post(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type = 'account',
|
||||
for_obj_id,
|
||||
qry_archive_on = null,
|
||||
inc_comment_li = false,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'title': 'ASC'},
|
||||
params = {},
|
||||
params_json = null,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
qry_archive_on?: boolean|null|string,
|
||||
inc_comment_li?: boolean,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
order_by_li?: key_val,
|
||||
params_json?: null|key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__post() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
}
|
||||
console.log(`*** load_ae_obj_li__post() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
|
||||
// There is probably a better way to handle this. I don't want to just start a new object if it is not passed. However, the qry_conference and qry_str are sort of a special case. -2024-10-01
|
||||
if (!params_json) {
|
||||
params_json = {};
|
||||
}
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
params_json['qry'] = [];
|
||||
let params_json: key_val = {};
|
||||
|
||||
if (qry_archive_on) {
|
||||
// let qry_param =
|
||||
// {
|
||||
// type: "AND",
|
||||
// field: "archive_on",
|
||||
// operator: ">",
|
||||
// value: qry_archive_on
|
||||
// };
|
||||
// params_json['qry'].push(qry_param);
|
||||
}
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
|
||||
// if (qry_archive_on) {
|
||||
// if (!params_json['and_qry']) {
|
||||
// params_json['and_qry'] = {};
|
||||
// }
|
||||
|
||||
// params_json['and_qry']['archive_on'] = qry_archive_on;
|
||||
// } else if (qry_archive_on === false) {
|
||||
// if (!params_json['and_qry']) {
|
||||
// params_json['and_qry'] = {};
|
||||
// }
|
||||
|
||||
// if (log_lvl) {
|
||||
// console.log('qry_archive_on is false!');
|
||||
// }
|
||||
// params_json['and_qry']['conference'] = qry_archive_on;
|
||||
// }
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('params_json:', params_json);
|
||||
}
|
||||
|
||||
|
||||
|
||||
ae_promises.load__post_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
ae_promises.load__post_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: false,
|
||||
use_alt_mdl: false,
|
||||
use_alt_exp: false,
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
@@ -231,37 +139,13 @@ export async function load_ae_obj_li__post(
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (post_obj_li_get_result) {
|
||||
.then(function (post_obj_li_get_result) {
|
||||
if (post_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__post_props({
|
||||
obj_li: post_obj_li_get_result,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_posts,
|
||||
table_name: 'post',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
db_save_ae_obj_li__post({
|
||||
obj_type: 'post',
|
||||
obj_li: post_obj_li_get_result
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__post({
|
||||
// obj_type: 'post',
|
||||
// obj_li: post_obj_li_get_result,
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return post_obj_li_get_result;
|
||||
} else {
|
||||
@@ -289,11 +173,7 @@ export async function load_ae_obj_li__post(
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'post',
|
||||
for_obj_id: post_id,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params: params,
|
||||
params: {qry__enabled: enabled, qry__limit: limit},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
@@ -315,32 +195,23 @@ export async function load_ae_obj_li__post(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-23
|
||||
// Updated 2024-09-25
|
||||
export async function create_ae_obj__post(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** create_ae_obj__post() *** account_id=${account_id}`);
|
||||
}
|
||||
|
||||
if (!account_id) {
|
||||
console.log(`ERROR: Posts - Post - account_id required to create`);
|
||||
return false;
|
||||
}
|
||||
console.log(`*** create_ae_obj__post() *** account_id=${account_id}`);
|
||||
|
||||
ae_promises.create__post = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
@@ -354,39 +225,13 @@ export async function create_ae_obj__post(
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (post_obj_create_result) {
|
||||
.then(function (post_obj_create_result) {
|
||||
if (post_obj_create_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__post_props({
|
||||
obj_li: [post_obj_create_result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_posts,
|
||||
table_name: 'post',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
db_save_ae_obj_li__post(
|
||||
{
|
||||
obj_type: 'post',
|
||||
obj_li: [post_obj_create_result]
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__post(
|
||||
// {
|
||||
// obj_type: 'post',
|
||||
// obj_li: [post_obj_create_result],
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
}
|
||||
return post_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
@@ -405,58 +250,7 @@ export async function create_ae_obj__post(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-11-08
|
||||
export async function delete_ae_obj_id__post(
|
||||
{
|
||||
api_cfg,
|
||||
post_id,
|
||||
method = 'delete', // 'delete', 'disable', 'hide'
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
post_id: string,
|
||||
method?: string,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** delete_ae_obj_id__post() *** post_id=${post_id}`);
|
||||
}
|
||||
|
||||
ae_promises.delete__post_obj = await api.delete_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post',
|
||||
obj_id: post_id,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
method: method,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
if (try_cache) {
|
||||
if (log_lvl) {
|
||||
console.log(`Attempting to remove IDB entry for post_id=${post_id}`);
|
||||
}
|
||||
db_posts.post.delete(post_id); // Delete from the DB no matter what.
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.delete__post_obj:', ae_promises.delete__post_obj);
|
||||
}
|
||||
|
||||
return ae_promises.delete__post_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-23
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__post(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -477,9 +271,7 @@ export async function update_ae_obj__post(
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__post() *** post_id=${post_id}`, data_kv);
|
||||
}
|
||||
|
||||
// Perform the API update
|
||||
const result = await api.update_ae_obj_id_crud({
|
||||
ae_promises.update__post_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post',
|
||||
obj_id: post_id,
|
||||
@@ -487,46 +279,30 @@ export async function update_ae_obj__post(
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (post_obj_update_result) {
|
||||
if (post_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__post({
|
||||
obj_type: 'post', obj_li: [post_obj_update_result]
|
||||
});
|
||||
}
|
||||
return post_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
// Handle the result
|
||||
if (result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
let processed_obj_li = await process_ae_obj__post_props({
|
||||
obj_li: [result],
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_posts,
|
||||
table_name: 'post',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// await db_save_ae_obj_li__post({
|
||||
// obj_type: 'post',
|
||||
// obj_li: [result],
|
||||
// log_lvl: log_lvl,
|
||||
// });
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
console.error('Failed to update post.');
|
||||
return null;
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__post_obj:', ae_promises.update__post_obj);
|
||||
}
|
||||
return ae_promises.update__post_obj;
|
||||
}
|
||||
|
||||
|
||||
@@ -631,8 +407,7 @@ export async function qry__post(
|
||||
if (post_obj_li_get_result) {
|
||||
db_save_ae_obj_li__post({
|
||||
obj_type: 'post',
|
||||
obj_li: post_obj_li_get_result,
|
||||
log_lvl: log_lvl
|
||||
obj_li: post_obj_li_get_result
|
||||
});
|
||||
return post_obj_li_get_result;
|
||||
} else {
|
||||
@@ -814,28 +589,22 @@ export function db_save_ae_obj_li__post(
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
|
||||
external_person_id: obj.external_person_id,
|
||||
|
||||
topic_id: obj.topic_id,
|
||||
topic: obj.topic,
|
||||
topic_name: obj.topic_name,
|
||||
|
||||
name: obj.title,
|
||||
title: obj.title, // Switching to name instead of title
|
||||
// summary: obj.summary,
|
||||
title: obj.title,
|
||||
content: obj.content,
|
||||
|
||||
anonymous: obj.anonymous,
|
||||
full_name: obj.full_name,
|
||||
email: obj.email,
|
||||
notify: obj.notify,
|
||||
|
||||
enable_comments: obj.enable_comments,
|
||||
|
||||
archive: obj.archive,
|
||||
archive_on: obj.archive_on,
|
||||
|
||||
linked_li_json: obj.linked_li_json,
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
@@ -847,163 +616,23 @@ export function db_save_ae_obj_li__post(
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
tmp_sort_1: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
post_comment_count: obj.post_comment_count,
|
||||
// post_comment_count: obj.post_comment_count,
|
||||
|
||||
// A key value list of the comments
|
||||
// post_comment_kv: obj.post_comment_kv,
|
||||
// post_comment_li: obj.post_comment_li,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log(`Put obj with ID: ${obj.post_id_random} or ${id_random}`);
|
||||
}
|
||||
// console.log(`Put obj with ID: ${obj.post_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.post_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
return false;
|
||||
}
|
||||
|
||||
// const id_random = await db_posts.post.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.post_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'post_id',
|
||||
// 'post_id_random',
|
||||
|
||||
'account_id',
|
||||
// 'account_id_random',
|
||||
|
||||
'external_person_id',
|
||||
|
||||
'topic_id',
|
||||
'topic',
|
||||
'topic_name',
|
||||
|
||||
'name',
|
||||
'title',
|
||||
'content',
|
||||
|
||||
'anonymous',
|
||||
'full_name',
|
||||
'email',
|
||||
'notify',
|
||||
|
||||
'enable_comments',
|
||||
|
||||
'archive',
|
||||
'archive_on',
|
||||
|
||||
'linked_li_json',
|
||||
'cfg_json',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
'sort',
|
||||
'group',
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
// 'tmp_sort_a',
|
||||
// 'tmp_sort_b',
|
||||
|
||||
// From SQL view
|
||||
'post_comment_count',
|
||||
|
||||
// A key value list of the comments
|
||||
// 'post_comment_kv',
|
||||
// 'post_comment_li',
|
||||
];
|
||||
|
||||
|
||||
// Updated 2025-06-04
|
||||
export async function process_ae_obj__post_props({
|
||||
obj_li,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
obj_li: any[];
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** process_ae_obj__post_props() ***`, obj_li);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const processed_obj_li = [];
|
||||
|
||||
for (const obj of obj_li) {
|
||||
if (log_lvl) console.log(`Processing ae_obj post:`, obj);
|
||||
|
||||
let processed_obj = {
|
||||
id: obj.post_id_random,
|
||||
post_id: obj.post_id_random,
|
||||
// post_id_random: obj.post_id_random,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
// account_id_random: obj.account_id_random,
|
||||
|
||||
external_person_id: obj.external_person_id,
|
||||
|
||||
topic_id: obj.topic_id,
|
||||
topic: obj.topic,
|
||||
topic_name: obj.topic_name,
|
||||
|
||||
name: obj.title,
|
||||
title: obj.title,
|
||||
content: obj.content,
|
||||
|
||||
anonymous: obj.anonymous,
|
||||
full_name: obj.full_name,
|
||||
email: obj.email,
|
||||
notify: obj.notify,
|
||||
|
||||
enable_comments: obj.enable_comments,
|
||||
|
||||
archive: obj.archive,
|
||||
archive_on: obj.archive_on,
|
||||
|
||||
linked_li_json: obj.linked_li_json,
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
post_comment_count: obj.post_comment_count,
|
||||
|
||||
// A key value list of the contents
|
||||
// post_comment_kv: obj.post_comment_kv,
|
||||
// post_comment_li: obj.post_comment_li,
|
||||
};
|
||||
|
||||
processed_obj_li.push(processed_obj);
|
||||
}
|
||||
|
||||
return processed_obj_li;
|
||||
}
|
||||
306
src/lib/ae_posts__post_comment.ts
Normal file
306
src/lib/ae_posts__post_comment.ts
Normal file
@@ -0,0 +1,306 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_posts } from "$lib/db_posts";
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function load_ae_obj_id__post_comment(
|
||||
{
|
||||
api_cfg,
|
||||
post_comment_id,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
post_comment_id: string,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** load_ae_obj_id__post_comment() *** post_comment_id=${post_comment_id}`);
|
||||
|
||||
let params = {};
|
||||
|
||||
ae_promises.load__post_comment_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post_comment',
|
||||
obj_id: post_comment_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (post_comment_obj_get_result) {
|
||||
if (post_comment_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__post_comment({
|
||||
obj_type: 'post_comment',
|
||||
obj_li: [post_comment_obj_get_result]
|
||||
|
||||
});
|
||||
}
|
||||
return post_comment_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
return ae_promises.load__post_comment_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function load_ae_obj_li__post_comment(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type = 'post',
|
||||
for_obj_id,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'title': 'ASC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** load_ae_obj_li__post_comment() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console('params_json:', params_json);
|
||||
|
||||
ae_promises.load__post_comment_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post_comment',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (post_comment_obj_li_get_result) {
|
||||
if (post_comment_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__post_comment({
|
||||
obj_type: 'post_comment', obj_li: post_comment_obj_li_get_result
|
||||
});
|
||||
}
|
||||
return post_comment_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__post_comment_obj_li:', ae_promises.load__post_comment_obj_li);
|
||||
}
|
||||
|
||||
return ae_promises.load__post_comment_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function create_ae_obj__post_comment(
|
||||
{
|
||||
api_cfg,
|
||||
post_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
post_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** create_ae_obj__post_comment() *** post_id=${post_id}`);
|
||||
|
||||
ae_promises.create__post_comment = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post_comment',
|
||||
fields: {
|
||||
post_id_random: post_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (post_comment_obj_create_result) {
|
||||
if (post_comment_obj_create_result) {
|
||||
db_save_ae_obj_li__post_comment(
|
||||
{
|
||||
obj_type: 'post_comment',
|
||||
obj_li: [post_comment_obj_create_result]
|
||||
});
|
||||
return post_comment_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__post_comment:', ae_promises.create__post_comment);
|
||||
}
|
||||
return ae_promises.create__post_comment;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__post_comment(
|
||||
{
|
||||
api_cfg,
|
||||
post_comment_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
post_comment_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__post_comment() *** post_comment_id=${post_comment_id}`, data_kv);
|
||||
}
|
||||
ae_promises.update__post_comment_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'post_comment',
|
||||
obj_id: post_comment_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (post_comment_obj_update_result) {
|
||||
if (post_comment_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__post_comment({
|
||||
obj_type: 'post_comment', obj_li: [post_comment_obj_update_result]
|
||||
});
|
||||
}
|
||||
return post_comment_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__post_comment_obj:', ae_promises.update__post_comment_obj);
|
||||
}
|
||||
return ae_promises.update__post_comment_obj;
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the post_comment_obj_li and save each one to the DB.
|
||||
// Updated 2024-09-25
|
||||
export function db_save_ae_obj_li__post_comment(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl=0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__post_comment() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_posts.comment.put({
|
||||
id: obj.post_comment_id_random,
|
||||
post_comment_id: obj.post_comment_id_random,
|
||||
|
||||
post_id: obj.post_id_random,
|
||||
|
||||
// name: obj.name,
|
||||
// summary: obj.summary,
|
||||
title: obj.title,
|
||||
content: obj.content,
|
||||
|
||||
anonymous: obj.anonymous,
|
||||
full_name: obj.full_name,
|
||||
email: obj.email,
|
||||
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// From SQL view
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.post_comment_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.post_comment_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_posts.comment.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.post_comment_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -4,36 +4,32 @@ import {
|
||||
load_ae_obj_id__post,
|
||||
load_ae_obj_li__post,
|
||||
create_ae_obj__post,
|
||||
delete_ae_obj_id__post,
|
||||
update_ae_obj__post,
|
||||
// qry__post,
|
||||
db_save_ae_obj_li__post,
|
||||
} from "$lib/ae_posts/ae_posts__post";
|
||||
} from "$lib/ae_posts__post";
|
||||
|
||||
|
||||
import {
|
||||
load_ae_obj_id__post_comment,
|
||||
load_ae_obj_li__post_comment,
|
||||
create_ae_obj__post_comment,
|
||||
delete_ae_obj_id__post_comment,
|
||||
update_ae_obj__post_comment,
|
||||
// qry__post_comment,
|
||||
db_save_ae_obj_li__post_comment,
|
||||
} from "$lib/ae_posts/ae_posts__post_comment";
|
||||
} from "$lib/ae_posts__post_comment";
|
||||
|
||||
|
||||
let export_obj = {
|
||||
load_ae_obj_id__post: load_ae_obj_id__post,
|
||||
load_ae_obj_li__post: load_ae_obj_li__post,
|
||||
create_ae_obj__post: create_ae_obj__post,
|
||||
delete_ae_obj_id__post: delete_ae_obj_id__post,
|
||||
update_ae_obj__post: update_ae_obj__post,
|
||||
db_save_ae_obj_li__post: db_save_ae_obj_li__post,
|
||||
|
||||
load_ae_obj_id__post_comment: load_ae_obj_id__post_comment,
|
||||
load_ae_obj_li__post_comment: load_ae_obj_li__post_comment,
|
||||
create_ae_obj__post_comment: create_ae_obj__post_comment,
|
||||
delete_ae_obj_id__post_comment: delete_ae_obj_id__post_comment,
|
||||
update_ae_obj__post_comment: update_ae_obj__post_comment,
|
||||
db_save_ae_obj_li__post_comment: db_save_ae_obj_li__post_comment,
|
||||
};
|
||||
@@ -1,350 +0,0 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_sponsorships } from "$lib/ae_sponsorships/db_sponsorships";
|
||||
|
||||
// import { liveQuery } from "dexie";
|
||||
// import { db_core } from "$lib/db_core";
|
||||
|
||||
let ae_promises: key_val = {}; // Promise<any>;
|
||||
|
||||
|
||||
// Updated 2024-03-29
|
||||
async function load_ae_obj_id__sponsorship_cfg(
|
||||
{
|
||||
api_cfg,
|
||||
sponsorship_cfg_id,
|
||||
try_cache = false,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
sponsorship_cfg_id: string,
|
||||
try_cache: boolean,
|
||||
log_lvl: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__sponsorship_cfg() *** sponsorship_cfg_id=${sponsorship_cfg_id}`);
|
||||
}
|
||||
|
||||
let params = {};
|
||||
|
||||
ae_promises.load__sponsorship_cfg_obj = api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'sponsorship_cfg',
|
||||
obj_id: sponsorship_cfg_id,
|
||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (sponsorship_cfg_obj_get_result) {
|
||||
if (sponsorship_cfg_obj_get_result) {
|
||||
if (log_lvl) {
|
||||
console.log(`*spons_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}`);
|
||||
} else if (log_lvl > 1) {
|
||||
console.log(`*spons_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}:`, sponsorship_cfg_obj_get_result);
|
||||
}
|
||||
if (try_cache) {
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__sponsorship_cfg({
|
||||
obj_type: 'sponsorship_cfg',
|
||||
obj_li: [sponsorship_cfg_obj_get_result]
|
||||
});
|
||||
}
|
||||
return sponsorship_cfg_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__sponsorship_cfg_obj:', ae_promises.load__sponsorship_cfg_obj);
|
||||
}
|
||||
|
||||
return ae_promises.load__sponsorship_cfg_obj;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-03-29
|
||||
async function load_ae_obj_id__sponsorship(
|
||||
{
|
||||
api_cfg,
|
||||
sponsorship_id,
|
||||
try_cache = false,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
sponsorship_id: string,
|
||||
try_cache: boolean,
|
||||
log_lvl: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__sponsorship() *** sponsorship_id=${sponsorship_id}`);
|
||||
}
|
||||
|
||||
let params = {};
|
||||
|
||||
ae_promises.load__sponsorship_obj = api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'sponsorship',
|
||||
obj_id: sponsorship_id,
|
||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (sponsorship_obj_get_result) {
|
||||
if (sponsorship_obj_get_result) {
|
||||
if (log_lvl) {
|
||||
console.log(`*spons_func* Got a result for sponsorship_id ${sponsorship_id}`);
|
||||
} else if (log_lvl > 1) {
|
||||
console.log(`*spons_func* Got a result for sponsorship_id ${sponsorship_id}:`, sponsorship_obj_get_result);
|
||||
}
|
||||
if (try_cache) {
|
||||
// This is expecting a list
|
||||
db_save_ae_obj_li__sponsorship({
|
||||
obj_type: 'sponsorship',
|
||||
obj_li: [sponsorship_obj_get_result]
|
||||
});
|
||||
}
|
||||
return sponsorship_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__sponsorship_obj:', ae_promises.load__sponsorship_obj);
|
||||
}
|
||||
|
||||
return ae_promises.load__sponsorship_obj;
|
||||
}
|
||||
|
||||
// Updated 2025-01-15
|
||||
async function load_ae_obj_li__sponsorship(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type = 'account',
|
||||
for_obj_id,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
inc_content_li?: boolean,
|
||||
enabled?: string,
|
||||
hidden?: string,
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__sponsorship() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
}
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
ae_promises.load__sponsorship_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'sponsorship',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: false,
|
||||
use_alt_mdl: false,
|
||||
use_alt_exp: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (sponsorship_obj_li_get_result) {
|
||||
if (sponsorship_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__sponsorship({
|
||||
obj_type: 'sponsorship',
|
||||
obj_li: sponsorship_obj_li_get_result
|
||||
});
|
||||
}
|
||||
return sponsorship_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__sponsorship_obj_li:', ae_promises.load__sponsorship_obj_li);
|
||||
}
|
||||
|
||||
return ae_promises.load__sponsorship_obj_li;
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function handle_download_export__sponsorship(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
file_type='CSV', // 'CSV' or 'Excel'
|
||||
return_file=true,
|
||||
filename='no_filename.csv',
|
||||
auto_download=false,
|
||||
params={}, // key value object is expected
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
file_type?: string,
|
||||
return_file?: boolean,
|
||||
filename?: string,
|
||||
auto_download?: boolean,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log('*** stores_event_api.js: get_sponsorship_export() ***');
|
||||
|
||||
const endpoint = `/v2/crud/sponsorship/list`;
|
||||
params['for_obj_type'] = 'account';
|
||||
params['for_obj_id'] = account_id;
|
||||
|
||||
if (file_type == 'CSV' || file_type == 'Excel') {
|
||||
params['file_type'] = file_type;
|
||||
}
|
||||
params['return_file'] = true;
|
||||
|
||||
ae_promises.download__sponsorship_export_file = await api.get_object({
|
||||
api_cfg: api_cfg,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
return_blob: return_file,
|
||||
filename: filename,
|
||||
auto_download: auto_download,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
console.log('ae_promises.download__sponsorship_export_file:', ae_promises.download__sponsorship_export_file);
|
||||
return ae_promises.download__sponsorship_export_file;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-01-15
|
||||
export function db_save_ae_obj_li__sponsorship(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__sponsorship() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_sponsorships.sponsorship.put({
|
||||
id: obj.sponsorship_id_random,
|
||||
sponsorship_id: obj.sponsorship_id_random,
|
||||
|
||||
account_id: obj.account_id_random,
|
||||
|
||||
external_person_id: obj.external_person_id,
|
||||
|
||||
topic_id: obj.topic_id,
|
||||
topic: obj.topic,
|
||||
topic_name: obj.topic_name,
|
||||
|
||||
name: obj.title,
|
||||
title: obj.title, // Switching to name instead of title
|
||||
// summary: obj.summary,
|
||||
content: obj.content,
|
||||
|
||||
anonymous: obj.anonymous,
|
||||
full_name: obj.full_name,
|
||||
email: obj.email,
|
||||
notify: obj.notify,
|
||||
|
||||
enable_comments: obj.enable_comments,
|
||||
|
||||
archive: obj.archive,
|
||||
archive_on: obj.archive_on,
|
||||
|
||||
linked_li_json: obj.linked_li_json,
|
||||
cfg_json: obj.cfg_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
|
||||
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
|
||||
|
||||
// From SQL view
|
||||
sponsorship_comment_count: obj.sponsorship_comment_count,
|
||||
|
||||
// A key value list of the comments
|
||||
// sponsorship_comment_kv: obj.sponsorship_comment_kv,
|
||||
// sponsorship_comment_li: obj.sponsorship_comment_li,
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log(`Put obj with ID: ${obj.sponsorship_id_random} or ${id_random}`);
|
||||
}
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.sponsorship_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
let export_obj = {
|
||||
load_ae_obj_id__sponsorship_cfg: load_ae_obj_id__sponsorship_cfg,
|
||||
load_ae_obj_id__sponsorship: load_ae_obj_id__sponsorship,
|
||||
load_ae_obj_li__sponsorship: load_ae_obj_li__sponsorship,
|
||||
handle_download_export__sponsorship: handle_download_export__sponsorship,
|
||||
db_save_ae_obj_li__sponsorship: db_save_ae_obj_li__sponsorship
|
||||
};
|
||||
export let spons_func = export_obj;
|
||||
@@ -1,135 +0,0 @@
|
||||
import Dexie, { type Table } from 'dexie';
|
||||
|
||||
import type { key_val } from '../ae_stores';
|
||||
|
||||
// li = list
|
||||
// kv = key value list
|
||||
|
||||
// Updated 2025-01-15
|
||||
export interface Sponsorship {
|
||||
id: string;
|
||||
// id_random: string;
|
||||
sponsorship_id: string;
|
||||
// sponsorship_id_random: string;
|
||||
|
||||
account_id: string;
|
||||
// account_id_random: string;
|
||||
|
||||
organization_id?: null|string;
|
||||
person_id?: null|string;
|
||||
|
||||
poc_person_id?: null|string;
|
||||
poc_json?: null|string;
|
||||
|
||||
name: null|string;
|
||||
name_override: null|string;
|
||||
|
||||
description?: null|string;
|
||||
|
||||
email?: null|string;
|
||||
website_url?: null|string;
|
||||
|
||||
// html_text?: null|string;
|
||||
// thumbnail_url?: null|string;
|
||||
// picture_url?: null|string;
|
||||
// video_url?: null|string;
|
||||
// audio_url?: null|string;
|
||||
// image_url?: null|string;
|
||||
// document_url?: null|string;
|
||||
// logo_url?: null|string;
|
||||
|
||||
logo_li_json?: null|string;
|
||||
media_li_json?: null|string;
|
||||
social_li_json?: null|string;
|
||||
address_li_json?: null|string;
|
||||
contact_li_json?: null|string;
|
||||
guest_li_json?: null|string;
|
||||
|
||||
level_num?: null|number;
|
||||
level_str?: null|string;
|
||||
|
||||
amount?: null|number; // In dollars
|
||||
|
||||
questions_li_json?: null|string;
|
||||
|
||||
agree?: null|boolean; // Catchall agree or consent
|
||||
|
||||
comments?: null|string; // From the sponsor
|
||||
staff_notes?: null|string; // Internal use; from staff
|
||||
|
||||
enable: null|boolean;
|
||||
hide?: null|boolean;
|
||||
priority?: null|boolean
|
||||
sort?: null|number;
|
||||
group?: null|string;
|
||||
notes?: null|string;
|
||||
created_on: Date;
|
||||
updated_on?: null|Date;
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
tmp_sort_1?: null|string;
|
||||
tmp_sort_2?: null|string;
|
||||
|
||||
// Additional fields for convenience (database views)
|
||||
}
|
||||
|
||||
|
||||
// Updated 2025-01-15
|
||||
export interface Sponsorship_Cfg {
|
||||
id: string;
|
||||
// id_random: string;
|
||||
sponsorship_cfg_id: string;
|
||||
// sponsorship_cfg_id_random: string;
|
||||
|
||||
account_id: string;
|
||||
// account_id_random: string;
|
||||
|
||||
for_type?: null|string;
|
||||
for_id?: null|number;
|
||||
|
||||
level_li_json?: null|string;
|
||||
option_li_json?: null|string;
|
||||
schedule_li_json?: null|string;
|
||||
|
||||
cfg_json?: null|key_val;
|
||||
|
||||
enable: null|boolean;
|
||||
hide?: null|boolean;
|
||||
priority?: null|boolean
|
||||
sort?: null|number;
|
||||
group?: null|string;
|
||||
notes?: null|string;
|
||||
created_on: Date;
|
||||
updated_on?: null|Date;
|
||||
|
||||
// Additional fields for convenience (database views)
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export class MySubClassedDexie extends Dexie {
|
||||
// We just tell the typing system this is the case
|
||||
sponsorship!: Table<Sponsorship>;
|
||||
cfg!: Table<Sponsorship_Cfg>;
|
||||
|
||||
constructor() {
|
||||
super('ae_sponsorships_db');
|
||||
this.version(1).stores({
|
||||
sponsorship: `
|
||||
id, sponsorship_id,
|
||||
account_id,
|
||||
poc_person_id,
|
||||
name, name_override,
|
||||
level_num, level_str, amount,
|
||||
agree,
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on, [updated_on+created_on], [created_on+updated_on]`,
|
||||
|
||||
cfg: `
|
||||
id, sponsorship_cfg_id,
|
||||
account_id,
|
||||
for_type, for_id`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const db_sponsorships = new MySubClassedDexie();
|
||||
120
src/lib/ae_sponsorships_functions.ts
Normal file
120
src/lib/ae_sponsorships_functions.ts
Normal file
@@ -0,0 +1,120 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
import type { log } from 'console';
|
||||
|
||||
// import { liveQuery } from "dexie";
|
||||
// import { db_core } from "$lib/db_core";
|
||||
|
||||
// let example_li = liveQuery(
|
||||
// () => db_core.sponsorships.toArray()
|
||||
// );
|
||||
|
||||
let ae_promises: key_val = {}; // Promise<any>;
|
||||
|
||||
|
||||
// Updated 2024-03-29
|
||||
async function handle_load_ae_obj_id__sponsorship_cfg(
|
||||
{
|
||||
api_cfg,
|
||||
sponsorship_cfg_id,
|
||||
try_cache=false,
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
sponsorship_cfg_id: string,
|
||||
try_cache: boolean,
|
||||
log_lvl: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_id__sponsorship_cfg() *** sponsorship_cfg_id=${sponsorship_cfg_id}`);
|
||||
|
||||
if (!api_cfg.account_id) {
|
||||
console.log(`*ae_func* No account_id found in API config!'`);
|
||||
return false;
|
||||
}
|
||||
|
||||
let params = {};
|
||||
|
||||
// ae_loc.hub.sponsorships.qry_status = 'loading';
|
||||
ae_promises.load__sponsorship_cfg_obj = api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'sponsorship_cfg',
|
||||
obj_id: sponsorship_cfg_id,
|
||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (sponsorship_cfg_obj_get_result) {
|
||||
if (sponsorship_cfg_obj_get_result) {
|
||||
if (log_lvl) {
|
||||
console.log(`*ae_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}`);
|
||||
} else if (log_lvl > 1) {
|
||||
console.log(`*ae_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}:`, sponsorship_cfg_obj_get_result);
|
||||
}
|
||||
return sponsorship_cfg_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
return ae_promises.load__sponsorship_cfg_obj;
|
||||
}
|
||||
|
||||
|
||||
async function handle_download_export__sponsorship(
|
||||
{
|
||||
api_cfg,
|
||||
account_id,
|
||||
file_type='CSV', // 'CSV' or 'Excel'
|
||||
return_file=true,
|
||||
filename='no_filename.csv',
|
||||
auto_download=false,
|
||||
params={}, // key value object is expected
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
account_id: string,
|
||||
file_type?: string,
|
||||
return_file?: boolean,
|
||||
filename?: string,
|
||||
auto_download?: boolean,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log('*** stores_event_api.js: get_sponsorship_export() ***');
|
||||
|
||||
const endpoint = `/v2/crud/sponsorship/list`;
|
||||
params['for_obj_type'] = 'account';
|
||||
params['for_obj_id'] = account_id;
|
||||
|
||||
if (file_type == 'CSV' || file_type == 'Excel') {
|
||||
params['file_type'] = file_type;
|
||||
}
|
||||
params['return_file'] = true;
|
||||
|
||||
ae_promises.download__sponsorship_export_file = await api.get_object({
|
||||
api_cfg: api_cfg,
|
||||
endpoint: endpoint,
|
||||
params: params,
|
||||
return_blob: return_file,
|
||||
filename: filename,
|
||||
auto_download: auto_download,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
console.log('ae_promises.download__sponsorship_export_file:', ae_promises.download__sponsorship_export_file);
|
||||
return ae_promises.download__sponsorship_export_file;
|
||||
}
|
||||
|
||||
|
||||
let export_obj = {
|
||||
handle_load_ae_obj_id__sponsorship_cfg: handle_load_ae_obj_id__sponsorship_cfg,
|
||||
handle_download_export__sponsorship: handle_download_export__sponsorship,
|
||||
};
|
||||
export let spons_func = export_obj;
|
||||
@@ -1,5 +1,4 @@
|
||||
import { persisted } from 'svelte-persisted-store';
|
||||
|
||||
import { localStorageStore } from '@skeletonlabs/skeleton';
|
||||
import { readable, writable } from 'svelte/store';
|
||||
import type { Readable, Writable } from 'svelte/store';
|
||||
|
||||
@@ -48,47 +47,29 @@ export let ae_snip = string_snippets;
|
||||
// };
|
||||
|
||||
// Set the version for the app data. Changing this should force a notification and ask the user to clear and reload the page.
|
||||
let ver = '2025-05-01_1445'; // KEEP: 2025-05-01_1445
|
||||
let ver_idb = '2025-05-01_1445'; // Not currently used
|
||||
let ver = '2024-08-21_1736';
|
||||
let ver_idb = '2024-08-21_1735';
|
||||
|
||||
// *** BEGIN *** Longer-term app data. This should be stored to local storage.
|
||||
const ae_app_local_data_defaults: key_val = {
|
||||
last_page_reload: null,
|
||||
// last_idb_reload: null,
|
||||
// last_cache_refresh: null, // Date.now()
|
||||
last_cache_refresh: Date.now(),
|
||||
cache_expired: false,
|
||||
ver: ver, // ver, // '2025-04-18_1100',
|
||||
ver_idb: ver_idb, // '2025-04-18_1100',
|
||||
|
||||
export let ae_app_local_data_struct: key_val = {
|
||||
'ver': '2024-08-16_1821',
|
||||
'ver_idb': '2024-08-16_1826', // Clear if date IndexedDB version
|
||||
name: 'Aether - App Hub (SvelteKit 2.x Svelte 4.x)',
|
||||
|
||||
theme: 'light',
|
||||
theme_mode: 'light',
|
||||
theme_name: 'nouveau', // wintry
|
||||
iframe: false,
|
||||
|
||||
// disable_sys_header: false,
|
||||
// disable_sys_nav: false,
|
||||
// disable_sys_footer: false,
|
||||
|
||||
browser_type: null, // Safari needs help with scrolling correctly in iframes.
|
||||
|
||||
title: `OSIT's Æ`, // - Dev SvelteKit`, // Æ
|
||||
|
||||
// debug_menu: false, // Flag show debug menu.
|
||||
debug_mode: false, // Flag to know if we should be in debug mode and show show debug options.
|
||||
edit_mode: false, // Flag to know if we should be in edit mode and show edit options.
|
||||
// sys_menu: true, // Flag show system menu.
|
||||
sync_local_config: true, // Flag to know if we should sync local config with the remote API server.
|
||||
debug: false, // A simple flag to know if we should show debug information.
|
||||
edit_mode: false, // A simple flag to know if we should show edit mode options.
|
||||
sync_local_config: true, // A simple flag to know if we should sync local config with the remote API server.
|
||||
|
||||
'account_id': ae_account_id, // OSIT Demo _XY7DXtc9MY
|
||||
'account_code': 'not_set',
|
||||
'account_name': 'Account Name Not Set',
|
||||
'allow_access': true, // Set to key site key was used, otherwise set to true.
|
||||
'allow_access': false, // Set to key if access is allowed.
|
||||
'site_domain': null, // https://example.com, https://dev.example.com, etc.
|
||||
'site_access_key': null, // This is the general site access key
|
||||
'site_domain_access_key': null, // This is specific to a (sub)domain.
|
||||
'site_access_key': null,
|
||||
'site_domain_access_key': null,
|
||||
'site_cfg_json': {
|
||||
slct__event_id: null,
|
||||
slct__event_badge_template_id: null,
|
||||
@@ -99,8 +80,8 @@ const ae_app_local_data_defaults: key_val = {
|
||||
// The site access codes can be pulled from the site records for an account.
|
||||
'site_access_code_kv': {
|
||||
// 'manager': '10240',
|
||||
'administrator': null,
|
||||
'trusted': null,
|
||||
'administrator': '11500',
|
||||
'trusted': '19111',
|
||||
'public': 'public1980',
|
||||
'authenticated': 'auth1980'
|
||||
},
|
||||
@@ -109,56 +90,14 @@ const ae_app_local_data_defaults: key_val = {
|
||||
// 'trusted_passcode': '19111',
|
||||
// 'authenticated_passcode': 'auth2024',
|
||||
|
||||
access_type: 'anonymous',
|
||||
administrator_access: false,
|
||||
trusted_access: false,
|
||||
public_access: false,
|
||||
authenticated_access: false,
|
||||
anonymous_access: true,
|
||||
'access_type': 'anonymous',
|
||||
'administrator_access': false,
|
||||
'trusted_access': false,
|
||||
'public_access': false,
|
||||
'authenticated_access': false,
|
||||
'anonymous_access': true,
|
||||
|
||||
user_email: null, // Currently used with Sponsorships only?
|
||||
user_access_type: null, // Used to revert back to the user's access type after quick access (temporarily escalate permissions) turned off.
|
||||
|
||||
// Added 2025-04-04
|
||||
person_id: null, // The current person_id of the logged-in user (if any)
|
||||
person: {
|
||||
id: null, // The current person_id of the logged-in user
|
||||
// profile_id: null, // The current person_profile_id of the logged-in user
|
||||
// pronouns: null,
|
||||
// informal_name: null,
|
||||
// given_name: null,
|
||||
// family_name: null,
|
||||
// professional_title: null,
|
||||
full_name: null, // convenience
|
||||
full_name_override: null, // was called display_name
|
||||
|
||||
// affiliations: null,
|
||||
primary_email: null, // The primary email of the logged-in person/user
|
||||
user_id: null, // The user ID of the logged-in user
|
||||
|
||||
qry_limit__people: 150,
|
||||
|
||||
show_content__person_page_help: false,
|
||||
},
|
||||
|
||||
// Added 2025-04-04
|
||||
user_id: null, // The current user_id of the logged-in user (if any)
|
||||
user: {
|
||||
id: null, // The current user_id of the logged-in user
|
||||
username: null,
|
||||
name: null,
|
||||
email: null, // The email of the logged-in user
|
||||
allow_auth_key: null, // For sign in without password
|
||||
super: false, // Is the user a super user
|
||||
manager: false, // Is the user a global manager (can manage accounts and users)
|
||||
administrator: false, // Is the user an account administrator
|
||||
verified: false, // Is the user verified
|
||||
public: false, // Is the user a public user (can view public content)
|
||||
person_id: null, // The person ID of the logged-in user
|
||||
access_type: null, // The access type of the logged-in user
|
||||
|
||||
qry_limit__users: 100,
|
||||
},
|
||||
'user_email': null, // Currently used with Sponsorships only?
|
||||
|
||||
'qry__enabled': 'enabled', // all, disabled, enabled
|
||||
'qry__hidden': 'not_hidden', // all, hidden, not_hidden
|
||||
@@ -172,52 +111,6 @@ const ae_app_local_data_defaults: key_val = {
|
||||
show_element__sql_qry_results: false,
|
||||
},
|
||||
|
||||
sys_menu: {
|
||||
hide: false,
|
||||
expand: false,
|
||||
hide_access_type: false,
|
||||
expand_access_type: false,
|
||||
hide_edit_mode: false,
|
||||
expand_edit_mode: false,
|
||||
hide_user: false,
|
||||
expand_user: false,
|
||||
hide_theme: false,
|
||||
expand_theme: false,
|
||||
hide_app_cfg: false,
|
||||
expand_app_cfg: false,
|
||||
},
|
||||
debug_menu: {
|
||||
hide: false,
|
||||
expand: false,
|
||||
// hide_quick_info: true
|
||||
},
|
||||
|
||||
app_cfg: {
|
||||
show_element__header: false,
|
||||
show_element__footer: false,
|
||||
show_element__menu: false,
|
||||
show_element__menu_btn: true,
|
||||
|
||||
show_element__access_type: true,
|
||||
show_element__passcode_input: true,
|
||||
show_element__cfg: true,
|
||||
show_element__cfg_detail: false,
|
||||
show_element__sign_in_out: true, // Show the sign-in/out button in the UI
|
||||
show_opt__debug: true,
|
||||
show_opt__permissions: true,
|
||||
show_opt__reset: true,
|
||||
show_opt__sync: true,
|
||||
show_opt__theme: true,
|
||||
show_opt__utilities: true,
|
||||
},
|
||||
|
||||
files: {
|
||||
processed_file_kv: {},
|
||||
uploaded_file_kv: {},
|
||||
video_clip_file_kv: {},
|
||||
add_to_use_files_method: 'upload', // upload, select
|
||||
},
|
||||
|
||||
'ds': {},
|
||||
'hub': {
|
||||
'show_element__cfg': true,
|
||||
@@ -226,7 +119,7 @@ const ae_app_local_data_defaults: key_val = {
|
||||
'theme_mode': 'light',
|
||||
'theme_name': 'wintry', // wintry
|
||||
|
||||
'classes__form': 'border border-surface-200 p-4 space-y-4 rounded-container',
|
||||
'classes__form': 'border border-surface-200 p-4 space-y-4 rounded-container-token',
|
||||
|
||||
'qr': {},
|
||||
},
|
||||
@@ -284,105 +177,41 @@ const ae_app_local_data_defaults: key_val = {
|
||||
submit_status: null, // 'saving', 'created', 'updated'
|
||||
},
|
||||
|
||||
// testing: {},
|
||||
'testing': {},
|
||||
},
|
||||
|
||||
// testing: true,
|
||||
// ver_testing: true,
|
||||
'person': {
|
||||
show_content__person_page_help: false,
|
||||
},
|
||||
|
||||
test: true,
|
||||
}
|
||||
|
||||
// let ae_app_local_data_struct: key_val = {
|
||||
// ...ae_app_local_data_defaults,
|
||||
// };
|
||||
// // {
|
||||
// // // ...ae_app_local_data_defaults,
|
||||
// // };
|
||||
// // console.log(`AE Stores - App Local Storage Data:`, ae_app_local_data_struct);
|
||||
// if (!ae_app_local_data_defaults?.ver_testing) {
|
||||
// console.log(`TEST: AE Stores - ver_testing missing:`, ae_app_local_data_defaults);
|
||||
// // ae_app_local_data_struct = {
|
||||
// // ...ae_app_local_data_defaults,
|
||||
// // ...ae_app_local_data_struct,
|
||||
// // };
|
||||
// } else {
|
||||
// console.log(`TEST: AE Stores - ver_testing found`);
|
||||
// }
|
||||
// if (ae_app_local_data_struct?.ver !== ae_app_local_data_defaults?.ver) {
|
||||
// console.log(`TEST: AE Stores - ver not match:`, ae_app_local_data_struct);
|
||||
|
||||
// ae_app_local_data_struct = {
|
||||
// ...ae_app_local_data_defaults,
|
||||
// };
|
||||
// } else {
|
||||
// console.log(`TEST: AE Stores - ver match: ${ae_app_local_data_struct.ver} === ${ae_app_local_data_defaults.ver}`);
|
||||
// }
|
||||
// if (!ae_app_local_data_struct?.app_cfg) {
|
||||
// console.log(`TEST: AE Stores - app_cfg missing:`, ae_app_local_data_struct);
|
||||
|
||||
// ae_app_local_data_struct = {
|
||||
// ...ae_app_local_data_defaults,
|
||||
// ...ae_app_local_data_struct,
|
||||
// };
|
||||
// }
|
||||
// console.log(`AE Stores - App Local Storage Data:`, ae_app_local_data_struct);
|
||||
|
||||
// This works, but does not uses local storage:
|
||||
// export let ae_loc = writable(ae_app_local_data_struct);
|
||||
|
||||
// This works and uses local storage:
|
||||
export let ae_loc: Writable<key_val> = persisted('ae_loc', ae_app_local_data_defaults);
|
||||
export let ae_loc: Writable<key_val> = localStorageStore('ae_loc', ae_app_local_data_struct);
|
||||
// console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
|
||||
|
||||
|
||||
// *** BEGIN *** Temporary app data. This should be stored to session storage.
|
||||
let ae_app_session_data_defaults: key_val = {
|
||||
// ver: '2025-04-18_1335', // ver, // '2025-04-18_1100',
|
||||
ver: ver,
|
||||
ver_idb: ver_idb,
|
||||
export let ae_app_session_data_struct: key_val = {
|
||||
'ver': '2024-02-27_13',
|
||||
// ver_idb: ver_idb,
|
||||
log_lvl: 0,
|
||||
|
||||
disable_sys_header: false,
|
||||
disable_sys_nav: false,
|
||||
disable_sys_footer: false,
|
||||
|
||||
sys_menu: {
|
||||
},
|
||||
|
||||
debug_menu: {
|
||||
hide_quick_info: true
|
||||
},
|
||||
|
||||
app_cfg: {
|
||||
show_element__passcode_input: true,
|
||||
},
|
||||
|
||||
// 'name': 'Aether App Template',
|
||||
// 'theme': 'light',
|
||||
// 'account_id': ae_account_id,
|
||||
'ds': {
|
||||
'submit_status': null,
|
||||
},
|
||||
'ds_loaded': {
|
||||
},
|
||||
|
||||
'files': {
|
||||
disable_submit__hosted_file_obj: false,
|
||||
processed_file_kv: {},
|
||||
uploaded_file_kv: {},
|
||||
video_clip_file_kv: {},
|
||||
processed_file_list: [],
|
||||
// uploaded_file_list: [],
|
||||
video_clip_file_list: [],
|
||||
submit_status: null, // 'saving', 'created', 'updated', 'saved'
|
||||
clip_complete: null,
|
||||
},
|
||||
|
||||
'hub': {
|
||||
'show_xyz': null,
|
||||
'account_id_qry_status': null,
|
||||
'event_badge_id_status_qry__search': null,
|
||||
'event_presenter_id_qry_status': null,
|
||||
'site_domain_id_qry_status': null,
|
||||
'sponsorship_id_qry_status': null,
|
||||
'sponsorship_cfg_id_qry_status': null,
|
||||
|
||||
'qr': {},
|
||||
},
|
||||
'mod': {
|
||||
'archives': {},
|
||||
@@ -414,8 +243,6 @@ let ae_app_session_data_defaults: key_val = {
|
||||
qry_limit__people: 100,
|
||||
},
|
||||
|
||||
show__modal_change_password: false,
|
||||
|
||||
|
||||
'download': {},
|
||||
// For API download and upload progress status per file.
|
||||
@@ -425,8 +252,8 @@ let ae_app_session_data_defaults: key_val = {
|
||||
|
||||
test: true,
|
||||
};
|
||||
// console.log(`AE Stores - App Session Storage Data:`, ae_app_session_data_defaults);
|
||||
export let ae_sess = writable(ae_app_session_data_defaults);
|
||||
// console.log(`AE Stores - App Session Storage Data:`, ae_app_session_data_struct);
|
||||
export let ae_sess = writable(ae_app_session_data_struct);
|
||||
|
||||
|
||||
// *** BEGIN *** Temporary API data. This should be stored to session storage.
|
||||
@@ -444,7 +271,7 @@ export let ae_api_data_struct: key_val = {
|
||||
|
||||
let ae_api_headers: key_val = {};
|
||||
ae_api_headers['Access-Control-Allow-Origin'] = '*';
|
||||
ae_api_headers['Content-Yype'] = 'application/json';
|
||||
ae_api_headers['content-type'] = 'application/json';
|
||||
ae_api_headers['x-aether-api-key'] = ae_api_data_struct.api_secret_key;
|
||||
ae_api_headers['x-aether-api-token'] = 'fake-temp-token';
|
||||
ae_api_headers['x-aether-api-expire-on'] = '';
|
||||
@@ -508,7 +335,7 @@ let slct_obj_template: key_val = {
|
||||
export let slct = writable(slct_obj_template);
|
||||
|
||||
// This works and uses *local* storage:
|
||||
// export let slct: Writable<key_val> = persisted('ae_slct', slct_obj_template);
|
||||
// export let slct: Writable<key_val> = localStorageStore('ae_slct', slct_obj_template);
|
||||
|
||||
|
||||
/* *** BEGIN *** Initialize slct_trigger */
|
||||
|
||||
@@ -11,21 +11,21 @@ string_snippets['html__not_set'] = `
|
||||
|
||||
string_snippets['classes__core_menu'] = 'flex flex-col items-center space-y-1 border border-blue-200 rounded-md py-1 px-2 hover:bg-blue-100';
|
||||
|
||||
string_snippets['classes__core_menu__button'] = 'btn btn-sm mx-1 preset-tonal-tertiary text-info-300 hover:text-info-800';
|
||||
string_snippets['classes__core_menu__button_highlight'] = 'btn btn-sm mx-1 preset-filled-tertiary-500 text-info-300 hover:text-info-800';
|
||||
string_snippets['classes__core_menu__button_warning'] = 'btn btn-sm mx-1 preset-tonal-warning text-info-300 hover:text-info-800';
|
||||
string_snippets['classes__core_menu__button'] = 'btn btn-sm mx-1 variant-soft-tertiary text-info-300 hover:text-info-800';
|
||||
string_snippets['classes__core_menu__button_highlight'] = 'btn btn-sm mx-1 variant-filled-tertiary text-info-300 hover:text-info-800';
|
||||
string_snippets['classes__core_menu__button_warning'] = 'btn btn-sm mx-1 variant-soft-warning text-info-300 hover:text-info-800';
|
||||
|
||||
// string_snippets['classes__events_pres_mgmt_menu'] = 'flex flex-col items-center space-y-1 border border-blue-200 rounded-md py-1 px-2 hover:bg-blue-100 transition-all duration-700 hover:duration-300';
|
||||
string_snippets['classes__events_pres_mgmt_menu'] = 'w-full flex flex-col items-center gap-1 border border-gray-200 rounded-md p-1 hover:bg-gray-100 transition-all duration-700 hover:duration-300';
|
||||
|
||||
string_snippets['classes__events_pres_mgmt_menu__button'] = 'btn btn-sm mx-1 preset-tonal-secondary hover:preset-filled-secondary-500';
|
||||
string_snippets['classes__events_pres_mgmt_menu__button_special'] = 'btn btn-sm mx-1 hover:preset-filled-primary-500';
|
||||
string_snippets['classes__events_pres_mgmt_menu__button'] = 'btn btn-sm mx-1 variant-glass-secondary hover:variant-filled-secondary';
|
||||
string_snippets['classes__events_pres_mgmt_menu__button_special'] = 'btn btn-sm mx-1 hover:variant-filled-primary';
|
||||
|
||||
// string_snippets['classes__events_pres_mgmt_menu__button'] = 'btn btn-sm mx-1 variant-soft-tertiary text-info-300 hover:text-info-800 hover:variant-filled-tertiary';
|
||||
// string_snippets['classes__events_pres_mgmt_menu__button_special'] = 'btn btn-sm mx-1 variant-ghost-tertiary text-info-300 hover:text-info-800 hover:variant-filled-tertiary';
|
||||
string_snippets['classes__events_pres_mgmt_menu__button_highlight'] = 'btn btn-sm mx-1 preset-filled-tertiary-500 text-info-300 hover:text-info-800';
|
||||
string_snippets['classes__events_pres_mgmt_menu__button_warning'] = 'btn btn-sm mx-1 preset-tonal-warning text-info-300 hover:text-info-800';
|
||||
string_snippets['classes__events_pres_mgmt_menu__button_warning_special'] = 'btn btn-sm mx-1 preset-tonal-warning';
|
||||
string_snippets['classes__events_pres_mgmt_menu__button_highlight'] = 'btn btn-sm mx-1 variant-filled-tertiary text-info-300 hover:text-info-800';
|
||||
string_snippets['classes__events_pres_mgmt_menu__button_warning'] = 'btn btn-sm mx-1 variant-soft-warning text-info-300 hover:text-info-800';
|
||||
string_snippets['classes__events_pres_mgmt_menu__button_warning_special'] = 'btn btn-sm mx-1 variant-glass-warning';
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
// Import external files first. Eventually this will be broken up in to smaller files.
|
||||
import { clean_filename, format_bytes, guess_file_name, guess_file_extension, get_file_hash } from './ae_utils__files';
|
||||
import { get_obj_li_w_match_prop} from './ae_utils__get_obj_li_w_match_prop';
|
||||
import { file_extension_icon } from './ae_utils__file_extension_icon';
|
||||
import { process_permission_checks } from './ae_utils__perm_checks';
|
||||
import { iso_datetime_formatter } from './ae_utils__datetime_format';
|
||||
import { is_datetime_recent } from './ae_utils__is_datetime_recent';
|
||||
import { extract_prefixed_form_data } from './ae_utils__extract_prefixed_form_data';
|
||||
import { to_title_case } from './ae_utils__to_title_case';
|
||||
import { process_data_string } from './ae_utils__process_data_string';
|
||||
import { set_obj_prop_display_name } from './ae_utils__set_obj_prop_display_name';
|
||||
import { return_obj_type_path } from './ae_utils__return_obj_type_path';
|
||||
import { combine_iv_and_base64, encrypt_content, encrypt_wrapper, decrypt_content, decrypt_wrapper } from './ae_utils__crypto';
|
||||
import { format_bytes, guess_file_name, guess_file_extension, get_file_hash } from './ae_utils__files';
|
||||
|
||||
|
||||
export type key_str = {
|
||||
type key_str = {
|
||||
[key: string]: string;
|
||||
};
|
||||
|
||||
export type key_val = {
|
||||
type key_val = {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
@@ -28,14 +19,213 @@ function number_w_commas(x) {
|
||||
}
|
||||
|
||||
|
||||
/* This utility function looks for any form data with the prefixed name passed and returns a new object.
|
||||
* This function is used heavily! Be very careful making changes!!!
|
||||
* If rm_empty_id then it will remove/ignore fields matching. This helps with the API and new records/objects
|
||||
* If rm_empty then it will remove/ignore fields matching. Sometimes this is needed.
|
||||
* If trim_values then it will trim string values.
|
||||
* If bool_tf_str then it will convert string values of true/false (case insensitive) to boolean values.
|
||||
* Updated 2023-12-22
|
||||
*/
|
||||
export let extract_prefixed_form_data = function extract_prefixed_form_data({prefix=null, form_data={}, rm_empty_id=true, rm_empty=false, trim_values=false, bool_tf_str=false, log_lvl=0}) {
|
||||
if (log_lvl) {
|
||||
console.log('*** extract_prefixed_form_data() ***');
|
||||
if (prefix) {
|
||||
console.log(`Looking for prefixed fields: ${prefix}; Removing emptry ID fields: ${rm_empty_id}; Removing empty fields: ${rm_empty}; Trim string values: ${trim_values}; Convert true/false string values to boolean: ${bool_tf_str}`);
|
||||
} else {
|
||||
console.log(`No prefix set. Looking at all fields. Removing emptry ID fields: ${rm_empty_id}; Removing empty fields: ${rm_empty}; Trim string values: ${trim_values}; Convert true/false string values to boolean: ${bool_tf_str}`);
|
||||
}
|
||||
}
|
||||
if (log_lvl > 1) {
|
||||
console.log('Form Data:');
|
||||
console.log(form_data);
|
||||
}
|
||||
|
||||
// const data_obj: any = {}; // future TS
|
||||
let data_obj = {};
|
||||
for (let field of form_data) {
|
||||
let [obj_prop_name, obj_prop_value] = field;
|
||||
if (log_lvl > 1) {
|
||||
console.log(`${obj_prop_name}: ${obj_prop_value} type=${typeof obj_prop_value}`);
|
||||
}
|
||||
|
||||
// Trim string values if needed
|
||||
if (trim_values && typeof obj_prop_value === 'string') {
|
||||
if (log_lvl && obj_prop_value.trim() != obj_prop_value) {
|
||||
console.log('Trimming string value!');
|
||||
obj_prop_value = obj_prop_value.trim();
|
||||
}
|
||||
}
|
||||
|
||||
// Convert string to boolean if needed
|
||||
if (bool_tf_str && typeof obj_prop_value === 'string') {
|
||||
// console.log('Flag set for converting true/false string values to boolean!');
|
||||
|
||||
if (obj_prop_value.toLowerCase() === 'true') {
|
||||
if (log_lvl) {
|
||||
console.log('Converting string to boolean value: true');
|
||||
}
|
||||
obj_prop_value = true;
|
||||
} else if (obj_prop_value.toLowerCase() === 'false') {
|
||||
if (log_lvl) {
|
||||
console.log('Converting string to boolean value: false');
|
||||
}
|
||||
obj_prop_value = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (prefix && obj_prop_name.startsWith(prefix)) { // Prefix set
|
||||
// if (obj_prop_name.startsWith(prefix)) {
|
||||
obj_prop_name = obj_prop_name.replace(prefix, '');
|
||||
if (log_lvl) {
|
||||
console.log(`Checking: (${prefix})${obj_prop_name} value=${obj_prop_value}`);
|
||||
}
|
||||
if (rm_empty_id && obj_prop_name.endsWith('id_random') && !obj_prop_value) {
|
||||
if (log_lvl) {
|
||||
console.log(`Match but empty *_id_random. Ignoring/removing: ${obj_prop_name}`);
|
||||
}
|
||||
} else if (rm_empty && !obj_prop_value) {
|
||||
if (log_lvl) {
|
||||
console.log(`Match but empty. Ignoring/removing: ${obj_prop_name}`);
|
||||
}
|
||||
} else {
|
||||
if (log_lvl) {
|
||||
console.log(`Match: ${prefix})${obj_prop_name} value=${obj_prop_value}`);
|
||||
}
|
||||
data_obj[obj_prop_name] = obj_prop_value;
|
||||
}
|
||||
} else if (prefix && !obj_prop_name.startsWith(prefix)) { // Prefix set
|
||||
if (log_lvl > 1) {
|
||||
console.log('Did not start with prefix. Ignoring');
|
||||
}
|
||||
} else { // No prefix set
|
||||
if (log_lvl) {
|
||||
console.log(`Checking: ${obj_prop_name} value=${obj_prop_value}`);
|
||||
}
|
||||
if (rm_empty_id && obj_prop_name.endsWith('id_random') && !obj_prop_value) {
|
||||
if (log_lvl > 1) {
|
||||
console.log(`Match but empty *_id_random. Ignoring/removing: ${obj_prop_name}`);
|
||||
}
|
||||
} else if (rm_empty && !obj_prop_value) {
|
||||
if (log_lvl > 1) {
|
||||
console.log(`Match but empty. Ignoring/removing: ${obj_prop_name}`);
|
||||
}
|
||||
} else {
|
||||
if (log_lvl > 1) {
|
||||
console.log(`Match: ${obj_prop_name} value=${obj_prop_value}`);
|
||||
}
|
||||
data_obj[obj_prop_name] = obj_prop_value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (log_lvl > 1) {
|
||||
console.log(data_obj);
|
||||
}
|
||||
return data_obj;
|
||||
}
|
||||
|
||||
|
||||
/* This utility function processes specific data string.
|
||||
* MECARD
|
||||
* OBJ = OBJ:ot:example,oi:asdf1234
|
||||
* ot = Aether object type; oi = Aether object ID random
|
||||
* KV = KV:"key":"value"
|
||||
* JS = {"id":123,"name":"example name"}
|
||||
* http or https?
|
||||
* Common short keys used:
|
||||
* bdg: Badge ID Random
|
||||
* reg: Registration ID Random
|
||||
* exid: External ID
|
||||
* gn: Given First Name
|
||||
* fn: Family Last Name
|
||||
* em: Email Address
|
||||
*/
|
||||
// Updated 2022-02-11
|
||||
export let process_data_string = function process_data_string(data_string: string) {
|
||||
console.log('*** process_data_string() ***');
|
||||
// console.log(data_string);
|
||||
|
||||
if (!data_string || data_string.length < 1) {
|
||||
console.log('No data string found.');
|
||||
return false;
|
||||
}
|
||||
|
||||
let obj: key_val = {};
|
||||
|
||||
let colon_index = data_string.indexOf(':')
|
||||
if (colon_index) {
|
||||
let data_string_type = data_string.slice(0, colon_index);
|
||||
console.log(data_string_type);
|
||||
|
||||
obj['qr_type'] = data_string_type;
|
||||
|
||||
if (data_string_type == 'MECARD') {
|
||||
let mecard_str = data_string.slice(colon_index+1);
|
||||
console.log(mecard_str);
|
||||
|
||||
obj['str'] = mecard_str;
|
||||
} else if (data_string_type == 'OBJ') {
|
||||
let key_value_str = data_string.slice(colon_index+1);
|
||||
console.log(key_value_str);
|
||||
let key_value_array = key_value_str.split(',');
|
||||
// console.log(key_value_array);
|
||||
|
||||
let ot_colon_index = key_value_array[0].indexOf(':')
|
||||
let obj_type = key_value_array[0].slice(ot_colon_index+1);
|
||||
// console.log(obj_type);
|
||||
|
||||
let oi_colon_index = key_value_array[1].indexOf(':')
|
||||
let obj_id = key_value_array[1].slice(oi_colon_index+1);
|
||||
// console.log(obj_id);
|
||||
|
||||
obj['type'] = obj_type;
|
||||
obj['id'] = obj_id;
|
||||
} else if (data_string_type == 'JSON') {
|
||||
let partial_json_str = data_string.slice(colon_index+1);
|
||||
console.log(partial_json_str);
|
||||
let json_str = `{${partial_json_str}}`;
|
||||
console.log(json_str);
|
||||
|
||||
obj['json'] = JSON.parse(json_str);
|
||||
} else if (data_string_type == 'STR') {
|
||||
let str = data_string.slice(colon_index+1);
|
||||
console.log(str);
|
||||
|
||||
obj['str'] = str;
|
||||
} else if (data_string_type == 'http' || data_string_type == 'https') {
|
||||
console.log(`http or https: ${data_string}`);
|
||||
|
||||
obj['type'] = 'url';
|
||||
obj['url'] = data_string;
|
||||
} else {
|
||||
console.log('The unknown data string type was found. Returning the string part.')
|
||||
let unknown_str = data_string.slice(colon_index+1);
|
||||
console.log(unknown_str);
|
||||
|
||||
obj['str'] = unknown_str;
|
||||
}
|
||||
} else {
|
||||
console.log('The data string type was not found. Returning the entire string.')
|
||||
console.log(data_string);
|
||||
|
||||
obj['qr_type'] = 'UNKNOWN';
|
||||
obj['str'] = data_string;
|
||||
// return false;
|
||||
}
|
||||
|
||||
console.log(obj);
|
||||
return obj; // Returns an object
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This function will update the URL and send a message to the parent window (iframe).
|
||||
// The name should be something like "example_id".
|
||||
// Svelte specific:
|
||||
// WARNING: Avoid using `history.pushState(...)` and `history.replaceState(...)` as these will conflict with SvelteKit's router. Use the `pushState` and `replaceState` imports from `$app/navigation` instead.
|
||||
// Updated 2024-03-02
|
||||
// import { pushState, replaceState } from '$app/navigation';
|
||||
|
||||
|
||||
import { pushState, replaceState } from '$app/navigation';
|
||||
|
||||
function handle_url_and_message(name: string, value: null|string) {
|
||||
console.log(`*** handle_url_and_message() *** name=${name} value=${value}`);
|
||||
@@ -128,9 +318,9 @@ function create_video_element({account_id, base_url, hosted_file_id, filename=nu
|
||||
// }
|
||||
|
||||
|
||||
// This function will take a long string (sentences or paragraphs) of text and return an estimated number of words.
|
||||
// This function will take a long string (sentences or paraghraphs) of text and return an estimated number of words.
|
||||
function count_words(text: string) {
|
||||
if (!text || text.length < 1) {
|
||||
if (!text && text.length < 1) {
|
||||
return false;
|
||||
}
|
||||
let count = text.trim().split(/\s+/).length;
|
||||
@@ -139,15 +329,62 @@ function count_words(text: string) {
|
||||
}
|
||||
|
||||
|
||||
/* Adapted from: To Title Case © 2018 David Gouch | https://github.com/gouch/to-title-case */
|
||||
|
||||
// eslint-disable-next-line no-extend-native
|
||||
function to_title_case (text_string) {
|
||||
// console.log('*** to_title_case() ***');
|
||||
|
||||
let smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|v.?|vs.?|via)$/i
|
||||
let alphanumericPattern = /([A-Za-z0-9\u00C0-\u00FF])/
|
||||
let wordSeparators = /([ :–—-])/
|
||||
|
||||
return text_string.split(wordSeparators)
|
||||
.map(function (current, index, array) {
|
||||
if (
|
||||
/* Check for small words */
|
||||
current.search(smallWords) > -1 &&
|
||||
/* Skip first and last word */
|
||||
index !== 0 &&
|
||||
index !== array.length - 1 &&
|
||||
/* Ignore title end and subtitle start */
|
||||
array[index - 3] !== ':' &&
|
||||
array[index + 1] !== ':' &&
|
||||
/* Ignore small words that start a hyphenated phrase */
|
||||
(array[index + 1] !== '-' ||
|
||||
(array[index - 1] === '-' && array[index + 1] === '-'))
|
||||
) {
|
||||
return current.toLowerCase()
|
||||
}
|
||||
|
||||
/* Ignore intentional capitalization */
|
||||
if (current.substr(1).search(/[A-Z]|\../) > -1) {
|
||||
return current
|
||||
}
|
||||
|
||||
/* Ignore URLs */
|
||||
if (array[index + 1] === ':' && array[index + 2] !== '') {
|
||||
return current
|
||||
}
|
||||
|
||||
/* Capitalize the first letter */
|
||||
return current.replace(alphanumericPattern, function (match) {
|
||||
return match.toUpperCase()
|
||||
})
|
||||
})
|
||||
.join('')
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-19
|
||||
// This function behaves weirdly. It needs to be reviewed and updated.
|
||||
export let shorten_string = function shorten_string(
|
||||
{
|
||||
string,
|
||||
max_length = 45,
|
||||
begin_length = 15,
|
||||
end_length = 5,
|
||||
wildcard_length = 3
|
||||
max_length=45,
|
||||
begin_length=15,
|
||||
end_length=5,
|
||||
wildcard_length=3
|
||||
}: {
|
||||
string: undefined|string,
|
||||
max_length?: number,
|
||||
@@ -203,9 +440,9 @@ export let shorten_string = function shorten_string(
|
||||
function shorten_filename(
|
||||
{
|
||||
filename,
|
||||
max_length = 20,
|
||||
slice_end_at = 15,
|
||||
max_end_length = 5
|
||||
max_length=20,
|
||||
slice_end_at=15,
|
||||
max_end_length=5
|
||||
}: {
|
||||
filename: string,
|
||||
max_length?: number,
|
||||
@@ -240,17 +477,244 @@ function shorten_filename(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-6-19
|
||||
function file_extension_icon(
|
||||
extension: string
|
||||
) {
|
||||
// console.log('*** file_extension_icon() ***');
|
||||
|
||||
let file_icons: key_str = {
|
||||
'file': 'file',
|
||||
'3gp': 'file-video',
|
||||
'7z': 'file-archive',
|
||||
'aac': 'file-audio',
|
||||
'ac3': 'file-audio',
|
||||
'aif': 'file-audio',
|
||||
'aiff': 'file-audio',
|
||||
'avi': 'file-video',
|
||||
'bmp': 'file-image',
|
||||
'csv': 'file-csv',
|
||||
'doc': 'file-word',
|
||||
'docx': 'file-word',
|
||||
'eps': 'file-image',
|
||||
'flac': 'file-audio',
|
||||
'gif': 'file-image',
|
||||
'htm': 'file-code',
|
||||
'html': 'file-code',
|
||||
'jpeg': 'file-image',
|
||||
'jpg': 'file-image',
|
||||
'key': 'file-powerpoint',
|
||||
'mkv': 'file-video',
|
||||
'mov': 'file-video',
|
||||
'mp3': 'file-audio',
|
||||
'mp4': 'file-video',
|
||||
'odp': 'file-powerpoint',
|
||||
'pdf': 'file-pdf',
|
||||
'png': 'file-image',
|
||||
'ppt': 'file-powerpoint',
|
||||
'pptx': 'file-powerpoint',
|
||||
'txt': 'file-alt',
|
||||
'wav': 'file-audio',
|
||||
'webp': 'file-image',
|
||||
'xls': 'file-excel',
|
||||
'xlsx': 'file-excel',
|
||||
'zip': 'file-archive'
|
||||
};
|
||||
|
||||
if (file_icons[extension]) {
|
||||
return file_icons[extension];
|
||||
} else {
|
||||
// return null;
|
||||
return file_icons['file'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updated 2023-08-18
|
||||
function set_obj_prop_display_name({prop_name, obj_type=null, prefix_w_obj_type=true, prefix_all_w_obj_type=false, replace_underscores=true, title_case=true, override=null}) {
|
||||
console.log('*** set_obj_prop_display_name() ***');
|
||||
|
||||
if (override) {
|
||||
return override;
|
||||
}
|
||||
|
||||
let known_obj_type_li = ['account', 'address', 'contact', 'event_badge', 'event_exhibit', 'event_file', 'event_location', 'event_person', 'event_presentation', 'event_presenter', 'event_registration', 'event_session', 'event', 'hosted_file', 'order_line', 'order', 'person', 'user'];
|
||||
|
||||
|
||||
let known_obj_type_li_dict = [
|
||||
{name: 'account', display: 'Account'},
|
||||
{name: 'address', display: 'Address'},
|
||||
{name: 'contact', display: 'Contact'},
|
||||
{name: 'event_badge', display: 'Event Badge'},
|
||||
{name: 'event_exhibit', display: 'Event Exhibit'},
|
||||
{name: 'event_file', display: 'Event File'},
|
||||
{name: 'event_location', display: 'Event Location'},
|
||||
{name: 'event_person', display: 'Event Person'},
|
||||
{name: 'event_presentation', display: 'Event Presentation'},
|
||||
{name: 'event_presenter', display: 'Event Presenter'},
|
||||
{name: 'event_registration', display: 'Event Registration'},
|
||||
{name: 'event_session', display: 'Event Session'},
|
||||
{name: 'event', display: 'Event'},
|
||||
{name: 'hosted_file', display: 'Hosted File'},
|
||||
{name: 'order_line', display: 'Order Line'},
|
||||
{name: 'order', display: 'Order'},
|
||||
{name: 'person', display: 'Person'},
|
||||
{name: 'user', display: 'User'},
|
||||
];
|
||||
|
||||
let prop_display_name = prop_name;
|
||||
|
||||
if (!prefix_w_obj_type) {
|
||||
if (obj_type) {
|
||||
prop_display_name = prop_name.replace(obj_type, '');
|
||||
} else {
|
||||
for (let i = 0; i < known_obj_type_li_dict.length; i++) {
|
||||
// console.log(known_obj_type_li_dict[i]);
|
||||
|
||||
if (prop_name.startsWith(known_obj_type_li_dict[i].name)) {
|
||||
// console.log(`Found ${known_obj_type_li_dict[i].name}`);
|
||||
prop_display_name = prop_name.replace(known_obj_type_li_dict[i].name, '');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// for (let i = 0; i < known_obj_type_li.length; i++) {
|
||||
// // console.log(known_obj_type_li[i]);
|
||||
|
||||
// if (prop_name.startsWith(known_obj_type_li[i])) {
|
||||
// console.log(`Found ${known_obj_type_li[i]}`);
|
||||
// prop_display_name = prop_name.replace(known_obj_type_li[i], '');
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
if (!prefix_all_w_obj_type) {
|
||||
for (let i = 0; i < known_obj_type_li.length; i++) {
|
||||
// console.log(known_obj_type_li[i]);
|
||||
|
||||
let found_obj_type = null;
|
||||
|
||||
if (prop_name.startsWith(known_obj_type_li_dict[i].name)) {
|
||||
// if (prop_name.startsWith(known_obj_type_li[i])) {
|
||||
// console.log(`Found ${known_obj_type_li_dict[i].name}`);
|
||||
found_obj_type = known_obj_type_li_dict[i].name;
|
||||
if (found_obj_type == obj_type) {
|
||||
prop_display_name = prop_name.replace(known_obj_type_li_dict[i].name, '');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if (obj_type) {
|
||||
// prop_display_name = prop_name.replace(obj_type, '');
|
||||
// } else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(prop_display_name);
|
||||
|
||||
if (prop_display_name.search('ID')) {
|
||||
|
||||
}
|
||||
prop_display_name = prop_display_name.replace('id_random', 'ID');
|
||||
|
||||
if (replace_underscores) {
|
||||
prop_display_name = prop_display_name.replaceAll('_', ' ');
|
||||
}
|
||||
|
||||
if (title_case) {
|
||||
prop_display_name = to_title_case(prop_display_name);
|
||||
}
|
||||
|
||||
// console.log(prop_display_name);
|
||||
|
||||
return prop_display_name;
|
||||
}
|
||||
|
||||
|
||||
function return_obj_type_path({obj_type=null, obj_type_prop_name=null}) {
|
||||
console.log('*** set_obj_prop_display_name() ***');
|
||||
|
||||
let obj_type_path = null;
|
||||
|
||||
let known_obj_type_li = ['account', 'address', 'archive', 'archive_content', 'contact', 'event_badge', 'event_exhibit', 'event_file', 'event_location', 'event_person', 'event_presentation', 'event_presenter', 'event_registration', 'event_session', 'event', 'hosted_file', 'order_line', 'order', 'person', 'post', 'post_comment', 'user'];
|
||||
|
||||
let known_obj_type_li_dict = [
|
||||
{name: 'account', display: 'Account', path: 'account'},
|
||||
{name: 'archive', display: 'Archive', path: 'archive'},
|
||||
{name: 'address', display: 'Address', path: 'address'},
|
||||
{name: 'archive', display: 'Archive', path: 'archive'},
|
||||
{name: 'archive_content', display: 'Archive Content', path: 'archive/content'},
|
||||
{name: 'contact', display: 'Contact', path: 'contact'},
|
||||
{name: 'data_store', display: 'Data Store', path: 'data_store'},
|
||||
{name: 'event_abstract', display: 'Event Abstract', path: 'event/abstract'},
|
||||
{name: 'event_badge', display: 'Event Badge', path: 'event/badge'},
|
||||
{name: 'event_device', display: 'Event Device', path: 'event/device'},
|
||||
{name: 'event_exhibit', display: 'Event Exhibit', path: 'event/exhibit'},
|
||||
{name: 'event_file', display: 'Event File', path: 'event/file'},
|
||||
{name: 'event_location', display: 'Event Location', path: 'event/location'},
|
||||
{name: 'event_person', display: 'Event Person', path: 'event/person'},
|
||||
{name: 'event_presentation', display: 'Event Presentation', path: 'event/'},
|
||||
{name: 'event_presenter', display: 'Event Presenter', path: 'event/presenter'},
|
||||
{name: 'event_registration', display: 'Event Registration', path: 'event/registration'},
|
||||
{name: 'event_session', display: 'Event Session', path: 'event/session'},
|
||||
{name: 'event', display: 'Event', path: 'event'},
|
||||
{name: 'hosted_file', display: 'Hosted File', path: 'hosted_file'},
|
||||
{name: 'journal', display: 'Journal', path: 'journal'},
|
||||
{name: 'journal_entry', display: 'Journal Entry', path: 'journal/entry'},
|
||||
{name: 'order_line', display: 'Order Line', path: 'order/line'},
|
||||
{name: 'order', display: 'Order', path: 'order'},
|
||||
{name: 'person', display: 'Person', path: 'person'},
|
||||
{name: 'post', display: 'Archive', path: 'post'},
|
||||
{name: 'post_comment', display: 'Archive Content', path: 'post/comment'},
|
||||
{name: 'user', display: 'User', path: 'user'},
|
||||
];
|
||||
|
||||
if (obj_type) {
|
||||
// Need to loop through known for safety?
|
||||
obj_type_path = obj_type_prop_name.replaceAll('_', '/');
|
||||
|
||||
} else if (obj_type_prop_name) {
|
||||
let found_obj_type_name = null;
|
||||
let found_obj_type_path = null;
|
||||
|
||||
for (let i = 0; i < known_obj_type_li_dict.length; i++) {
|
||||
// console.log(known_obj_type_li_dict[i]);
|
||||
|
||||
// let guessed_obj_type = prop_name.startsWith(known_obj_type_li_dict[i]
|
||||
|
||||
|
||||
if (obj_type_prop_name.startsWith(known_obj_type_li_dict[i].name)) {
|
||||
console.log(`Found ${known_obj_type_li_dict[i].name}`);
|
||||
found_obj_type_name = known_obj_type_li_dict[i].name;
|
||||
found_obj_type_path = known_obj_type_li_dict[i].path;
|
||||
// obj_type_path = obj_type_prop_name.replaceAll('_', '/');
|
||||
obj_type_path = found_obj_type_path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log('Missing required parameters');
|
||||
return false;
|
||||
}
|
||||
|
||||
return obj_type_path;
|
||||
}
|
||||
|
||||
|
||||
export let ae_util = {
|
||||
is_datetime_recent: is_datetime_recent,
|
||||
process_permission_checks: process_permission_checks,
|
||||
iso_datetime_formatter: iso_datetime_formatter,
|
||||
clean_filename: clean_filename,
|
||||
format_bytes: format_bytes,
|
||||
number_w_commas: number_w_commas,
|
||||
guess_file_name: guess_file_name,
|
||||
guess_file_extension: guess_file_extension,
|
||||
get_file_hash: get_file_hash,
|
||||
get_obj_li_w_match_prop: get_obj_li_w_match_prop,
|
||||
extract_prefixed_form_data: extract_prefixed_form_data,
|
||||
process_data_string: process_data_string,
|
||||
handle_url_and_message: handle_url_and_message,
|
||||
@@ -264,9 +728,4 @@ export let ae_util = {
|
||||
file_extension_icon: file_extension_icon,
|
||||
set_obj_prop_display_name: set_obj_prop_display_name,
|
||||
return_obj_type_path: return_obj_type_path,
|
||||
combine_iv_and_base64: combine_iv_and_base64,
|
||||
encrypt_content: encrypt_content,
|
||||
encrypt_wrapper: encrypt_wrapper,
|
||||
decrypt_content: decrypt_content,
|
||||
decrypt_wrapper: decrypt_wrapper,
|
||||
};
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
let log_lvl = 0; // 0 = no logging, 1 = some logging, 2 = all logging
|
||||
|
||||
// Updated 2025-05-08
|
||||
async function generate_iv() {
|
||||
const data = new Uint8Array(16);
|
||||
crypto.getRandomValues(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
// Updated 2025-05-08
|
||||
export let encrypt_content = async function encrypt_content(
|
||||
content: string,
|
||||
keyData: string
|
||||
) {
|
||||
const iv = await generate_iv();
|
||||
const keyBytes = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(keyData));
|
||||
const key = await crypto.subtle.importKey('raw', keyBytes, { name: 'AES-CBC' }, false, ['encrypt']);
|
||||
const encodedContent = await crypto.subtle.encrypt({ name: 'AES-CBC', iv }, key, new TextEncoder().encode(content));
|
||||
const base64 = btoa(String.fromCharCode(...new Uint8Array(encodedContent)));
|
||||
if (log_lvl) {
|
||||
console.log(`IV: ${iv}; Encrypted:`, base64);
|
||||
}
|
||||
return { base64, iv };
|
||||
}
|
||||
|
||||
// Updated 2025-05-08
|
||||
export let combine_iv_and_base64 = function combine_iv_and_base64(
|
||||
base64: string,
|
||||
iv: Uint8Array
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`IV: ${iv}; Encrypted:`, base64);
|
||||
}
|
||||
|
||||
// Combine the IV and encrypted content
|
||||
const combined = Array.from(iv).map(byte => byte.toString(16).padStart(2, '0')).join('') + ':' + base64;
|
||||
if (log_lvl) {
|
||||
console.log('Combined IV and Base64:', combined);
|
||||
}
|
||||
// const ivBase64 = btoa(String.fromCharCode(...iv));
|
||||
// const combined = `${ivBase64}:${base64}`;
|
||||
// console.log('Combined IV and Base64 v2:', combined);
|
||||
return combined;
|
||||
}
|
||||
|
||||
// Updated 2025-05-08
|
||||
export let encrypt_wrapper = async function encrypt_wrapper(
|
||||
content: string,
|
||||
keyData: string
|
||||
) {
|
||||
if (!content) {
|
||||
console.error('No content provided. Returning empty string.');
|
||||
return '';
|
||||
}
|
||||
if (!keyData) {
|
||||
console.error('No keyData provided. Returning empty string.');
|
||||
return '';
|
||||
}
|
||||
const { base64, iv } = await encrypt_content(content, keyData);
|
||||
const combined = combine_iv_and_base64(base64, iv);
|
||||
return combined;
|
||||
}
|
||||
|
||||
// This does not handle errors (invalid key/password) well.
|
||||
// Updated 2025-05-08
|
||||
export let decrypt_content = async function decrypt_content(
|
||||
base64Content: string,
|
||||
iv: Uint8Array,
|
||||
keyData: string
|
||||
) {
|
||||
const keyBytes = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(keyData));
|
||||
const key = await crypto.subtle.importKey('raw', keyBytes, { name: 'AES-CBC' }, false, ['decrypt']);
|
||||
const encryptedContent = Uint8Array.from(atob(base64Content), c => c.charCodeAt(0));
|
||||
const decryptedContent = await crypto.subtle.decrypt({ name: 'AES-CBC', iv }, key, encryptedContent);
|
||||
const decodedContent = new TextDecoder().decode(decryptedContent);
|
||||
// console.log('Decrypted Content:', decodedContent);
|
||||
return decodedContent;
|
||||
}
|
||||
|
||||
// Updated 2025-05-08
|
||||
export let split_iv_and_base64 = function split_iv_and_base64(
|
||||
combined: string
|
||||
) {
|
||||
if (!combined) {
|
||||
console.error('No combined string provided. Returning empty object.');
|
||||
return { iv: new Uint8Array(), base64: '' };
|
||||
}
|
||||
let [iv_hex, encrypted_base64_string] = combined.split(':');
|
||||
let base64 = encrypted_base64_string
|
||||
let iv = new Uint8Array(iv_hex.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
|
||||
if (log_lvl) {
|
||||
console.log(`IV: ${iv}; Encrypted:`, base64);
|
||||
}
|
||||
return { iv, base64 };
|
||||
}
|
||||
|
||||
// Updated 2025-05-15
|
||||
export let decrypt_wrapper = async function decrypt_wrapper(
|
||||
combined: string,
|
||||
keyData: string
|
||||
) {
|
||||
if (!combined) {
|
||||
console.error('No combined string provided. Returning empty string.');
|
||||
return false;
|
||||
}
|
||||
const { iv, base64 } = split_iv_and_base64(combined);
|
||||
let decrypted;
|
||||
try {
|
||||
decrypted = await decrypt_content(base64, iv, keyData);
|
||||
if (log_lvl > 1) {
|
||||
console.log(`IV: ${iv}; Decrypted:`, decrypted);
|
||||
} else if (log_lvl) {
|
||||
console.log(`IV: ${iv}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Decryption failed:', error);
|
||||
return false;
|
||||
}
|
||||
return decrypted;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ export let iso_datetime_formatter = function iso_datetime_formatter(
|
||||
// datetime_iso 'YYYY-MM-DD HH:mm:ss'
|
||||
// datetime_iso_12 'YYYY-MM-DD hh:mm:ss A'
|
||||
// datetime_iso_12_short 'YY-MM-DD hh:mm A'
|
||||
// datetime_iso_tz 'YYYY-MM-DD HH:mm:ss Z'
|
||||
// datetime_iso_tz 'YYYY-MM-DD HH:mm:ss'
|
||||
|
||||
// datetime_12_no_seconds 'YYYY-MM-DD hh:mm A'
|
||||
|
||||
@@ -37,8 +37,6 @@ export let iso_datetime_formatter = function iso_datetime_formatter(
|
||||
|
||||
// time_iso 'HH:mm:ss'
|
||||
// time_iso_12 'hh:mm:ss A'
|
||||
// time_iso_tz 'HH:mm:ss Z'
|
||||
// time_iso_12_tz 'hh:mm:ss A Z'
|
||||
|
||||
// time_long 'hh:mm:ss A'
|
||||
// time_medium 'h:m:s A'
|
||||
@@ -65,15 +63,9 @@ export let iso_datetime_formatter = function iso_datetime_formatter(
|
||||
case 'datetime_iso_12_short_month':
|
||||
datetime_string = dayjs(raw_datetime).format('MM-DD hh:mm A');
|
||||
break;
|
||||
case 'datetime_iso_tz':
|
||||
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss Z');
|
||||
break;
|
||||
case 'datetime_iso_12_no_seconds':
|
||||
case 'datetime_12_no_seconds':
|
||||
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD hh:mm A');
|
||||
break;
|
||||
// case 'datetime_12_no_seconds':
|
||||
// datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD hh:mm A');
|
||||
// break;
|
||||
case 'datetime_short':
|
||||
datetime_string = dayjs(raw_datetime).format('MMM D, YY HH:mm');
|
||||
break;
|
||||
@@ -92,12 +84,6 @@ export let iso_datetime_formatter = function iso_datetime_formatter(
|
||||
case 'datetime_12_long':
|
||||
datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY hh:mm A');
|
||||
break;
|
||||
case 'datetime_medium_sec':
|
||||
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY H:mm:ss');
|
||||
break;
|
||||
case 'datetime_12_medium_sec':
|
||||
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY h:mm:ss A');
|
||||
break;
|
||||
case 'datetime_short_month':
|
||||
datetime_string = dayjs(raw_datetime).format('MMM D hh:mm A');
|
||||
break;
|
||||
@@ -131,9 +117,6 @@ export let iso_datetime_formatter = function iso_datetime_formatter(
|
||||
case 'time_iso':
|
||||
datetime_string = dayjs(raw_datetime).format('HH:mm:ss');
|
||||
break;
|
||||
case 'time_iso_12_tz':
|
||||
datetime_string = dayjs(raw_datetime).format('hh:mm:ss A Z');
|
||||
break;
|
||||
case 'time_long':
|
||||
datetime_string = dayjs(raw_datetime).format('HH:mm:ss A');
|
||||
break;
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
type key_val = {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
/* This utility function looks for any form data with the prefixed name passed and returns a new object.
|
||||
* This function is used heavily! Be very careful making changes!!!
|
||||
* If rm_empty_id then it will remove/ignore fields matching. This helps with the API and new records/objects
|
||||
* If rm_empty then it will remove/ignore fields matching. Sometimes this is needed.
|
||||
* If trim_values then it will trim string values.
|
||||
* If bool_tf_str then it will convert string values of true/false (case insensitive) to boolean values.
|
||||
* REMINDER: An unchecked checkbox will not be sent in the form data. This is a browser thing.
|
||||
* Updated 2023-12-22
|
||||
*/
|
||||
export let extract_prefixed_form_data = function extract_prefixed_form_data(
|
||||
{
|
||||
prefix = null,
|
||||
form_data = {},
|
||||
rm_empty_id = true,
|
||||
rm_empty = false,
|
||||
trim_values = false,
|
||||
bool_tf_str = false,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
prefix: string|null,
|
||||
form_data: any,
|
||||
rm_empty_id?: boolean,
|
||||
rm_empty?: boolean,
|
||||
trim_values?: boolean,
|
||||
bool_tf_str?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log('*** extract_prefixed_form_data() ***');
|
||||
if (prefix) {
|
||||
console.log(`Looking for prefixed fields: ${prefix}; Removing emptry ID fields: ${rm_empty_id}; Removing empty fields: ${rm_empty}; Trim string values: ${trim_values}; Convert true/false string values to boolean: ${bool_tf_str}`);
|
||||
} else {
|
||||
console.log(`No prefix set. Looking at all fields. Removing emptry ID fields: ${rm_empty_id}; Removing empty fields: ${rm_empty}; Trim string values: ${trim_values}; Convert true/false string values to boolean: ${bool_tf_str}`);
|
||||
}
|
||||
}
|
||||
if (log_lvl > 1) {
|
||||
console.log('Form Data:');
|
||||
console.log(form_data);
|
||||
}
|
||||
|
||||
// const data_obj: any = {}; // future TS
|
||||
let data_obj: key_val = {};
|
||||
for (let field of form_data) {
|
||||
let [obj_prop_name, obj_prop_value] = field;
|
||||
if (log_lvl > 1) {
|
||||
console.log(`${obj_prop_name}: ${obj_prop_value} type=${typeof obj_prop_value}`);
|
||||
}
|
||||
|
||||
// Trim string values if needed
|
||||
if (trim_values && typeof obj_prop_value === 'string') {
|
||||
if (log_lvl && obj_prop_value.trim() != obj_prop_value) {
|
||||
console.log('Trimming string value!');
|
||||
obj_prop_value = obj_prop_value.trim();
|
||||
}
|
||||
}
|
||||
|
||||
// Convert string to boolean if needed
|
||||
if (bool_tf_str && typeof obj_prop_value === 'string') {
|
||||
// console.log('Flag set for converting true/false string values to boolean!');
|
||||
|
||||
if (obj_prop_value.toLowerCase() === 'true') {
|
||||
if (log_lvl) {
|
||||
console.log('Converting string to boolean value: true');
|
||||
}
|
||||
obj_prop_value = true;
|
||||
} else if (obj_prop_value.toLowerCase() === 'false') {
|
||||
if (log_lvl) {
|
||||
console.log('Converting string to boolean value: false');
|
||||
}
|
||||
obj_prop_value = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (prefix && obj_prop_name.startsWith(prefix)) { // Prefix set
|
||||
// if (obj_prop_name.startsWith(prefix)) {
|
||||
obj_prop_name = obj_prop_name.replace(prefix, '');
|
||||
if (log_lvl) {
|
||||
console.log(`Checking: (${prefix})${obj_prop_name} value=${obj_prop_value}`);
|
||||
}
|
||||
if (rm_empty_id && obj_prop_name.endsWith('id_random') && !obj_prop_value) {
|
||||
if (log_lvl) {
|
||||
console.log(`Match but empty *_id_random. Ignoring/removing: ${obj_prop_name}`);
|
||||
}
|
||||
} else if (rm_empty && !obj_prop_value) {
|
||||
if (log_lvl) {
|
||||
console.log(`Match but empty. Ignoring/removing: ${obj_prop_name}`);
|
||||
}
|
||||
} else {
|
||||
if (log_lvl) {
|
||||
console.log(`Match: ${prefix})${obj_prop_name} value=${obj_prop_value}`);
|
||||
}
|
||||
data_obj[obj_prop_name] = obj_prop_value;
|
||||
}
|
||||
} else if (prefix && !obj_prop_name.startsWith(prefix)) { // Prefix set
|
||||
if (log_lvl > 1) {
|
||||
console.log('Did not start with prefix. Ignoring');
|
||||
}
|
||||
} else { // No prefix set
|
||||
if (log_lvl) {
|
||||
console.log(`Checking: ${obj_prop_name} value=${obj_prop_value}`);
|
||||
}
|
||||
if (rm_empty_id && obj_prop_name.endsWith('id_random') && !obj_prop_value) {
|
||||
if (log_lvl > 1) {
|
||||
console.log(`Match but empty *_id_random. Ignoring/removing: ${obj_prop_name}`);
|
||||
}
|
||||
} else if (rm_empty && !obj_prop_value) {
|
||||
if (log_lvl > 1) {
|
||||
console.log(`Match but empty. Ignoring/removing: ${obj_prop_name}`);
|
||||
}
|
||||
} else {
|
||||
if (log_lvl > 1) {
|
||||
console.log(`Match: ${obj_prop_name} value=${obj_prop_value}`);
|
||||
}
|
||||
data_obj[obj_prop_name] = obj_prop_value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (log_lvl > 1) {
|
||||
console.log(data_obj);
|
||||
}
|
||||
return data_obj;
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
import type { key_str } from "./ae_utils";
|
||||
|
||||
// Updated 2024-06-19
|
||||
export function file_extension_icon(
|
||||
extension: string) {
|
||||
// console.log('*** file_extension_icon() ***');
|
||||
let file_icons: key_str = {
|
||||
'file': 'file',
|
||||
'3gp': 'file-video',
|
||||
'7z': 'file-archive',
|
||||
'aac': 'file-audio',
|
||||
'ac3': 'file-audio',
|
||||
'aif': 'file-audio',
|
||||
'aiff': 'file-audio',
|
||||
'avi': 'file-video',
|
||||
'bmp': 'file-image',
|
||||
'csv': 'file-csv',
|
||||
'doc': 'file-word',
|
||||
'docx': 'file-word',
|
||||
'eps': 'file-image',
|
||||
'flac': 'file-audio',
|
||||
'gif': 'file-image',
|
||||
'htm': 'file-code',
|
||||
'html': 'file-code',
|
||||
'jpeg': 'file-image',
|
||||
'jpg': 'file-image',
|
||||
'key': 'file-powerpoint',
|
||||
'mkv': 'file-video',
|
||||
'mov': 'file-video',
|
||||
'mp3': 'file-audio',
|
||||
'mp4': 'file-video',
|
||||
'odp': 'file-powerpoint',
|
||||
'pdf': 'file-pdf',
|
||||
'png': 'file-image',
|
||||
'ppt': 'file-powerpoint',
|
||||
'pptx': 'file-powerpoint',
|
||||
'txt': 'file-alt',
|
||||
'wav': 'file-audio',
|
||||
'webp': 'file-image',
|
||||
'xls': 'file-excel',
|
||||
'xlsx': 'file-excel',
|
||||
'zip': 'file-archive'
|
||||
};
|
||||
|
||||
if (file_icons[extension]) {
|
||||
return file_icons[extension];
|
||||
} else {
|
||||
// return null;
|
||||
return file_icons['file'];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,5 @@
|
||||
// These are all file related functions.
|
||||
|
||||
// Use a defined list of unacceptable characters to remove from a filename.
|
||||
// Updated 2024-10-18
|
||||
export let clean_filename = function clean_filename(filename: any|string, unacceptable_chars: RegExp = /[ <>:"/\\|?*]/g, replacement_char: string = '_') {
|
||||
// console.log('*** clean_filename() ***');
|
||||
if (!filename) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let cleaned_filename = filename.replace(unacceptable_chars, replacement_char);
|
||||
// console.log(cleaned_filename);
|
||||
return cleaned_filename;
|
||||
}
|
||||
|
||||
|
||||
export let format_bytes = function format_bytes(
|
||||
bytes: number,
|
||||
decimals: number = 2
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
|
||||
/* Returns a list of objects that have a matching property value. */
|
||||
// Updated 2023-06-28
|
||||
export let get_obj_li_w_match_prop = function get_obj_li_w_match_prop(
|
||||
{
|
||||
obj_li,
|
||||
property,
|
||||
value,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_li: any[],
|
||||
property: string,
|
||||
value: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log('Search Object List:', obj_li);
|
||||
console.log(`Property: ${property}`);
|
||||
console.log(`Value: ${value}`);
|
||||
}
|
||||
if (log_lvl > 1) {
|
||||
console.log(`Type Of: ${typeof value}`);
|
||||
}
|
||||
|
||||
// Create an empty array to store the matching objects.
|
||||
const matching_obj_li = [];
|
||||
|
||||
// Iterate through the list of objects.
|
||||
for (const object of obj_li) {
|
||||
// Check if the object has the specified property and the value of the property matches the specified value.
|
||||
if (object.hasOwnProperty(property)) {
|
||||
// console.log('Has property at least....', object[property], typeof object[property]);
|
||||
}
|
||||
if (object.hasOwnProperty(property) && object[property] === value) {
|
||||
// Add the object to the array of matching objects.
|
||||
matching_obj_li.push(object);
|
||||
}
|
||||
}
|
||||
|
||||
// Return the array of matching objects.
|
||||
if (log_lvl > 1) {
|
||||
console.log('Matching Object List:', matching_obj_li);
|
||||
}
|
||||
return matching_obj_li;
|
||||
}
|
||||
@@ -2,16 +2,12 @@
|
||||
export let is_datetime_recent = function is_datetime_recent(
|
||||
{
|
||||
datetime,
|
||||
minutes,
|
||||
log_lvl = 0
|
||||
minutes
|
||||
}: {
|
||||
datetime: string,
|
||||
minutes: number,
|
||||
log_lvl?: number
|
||||
minutes: number
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** is_datetime_recent() *** datetime=${datetime} minutes=${minutes}`);
|
||||
}
|
||||
console.log(`*** is_datetime_recent() *** datetime=${datetime} minutes=${minutes}`);
|
||||
|
||||
let now: any = new Date();
|
||||
let then: any = new Date(datetime);
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
import type { key_val } from "./ae_utils";
|
||||
|
||||
/* This utility function processes specific data string.
|
||||
* MECARD
|
||||
* OBJ = OBJ:ot:example,oi:asdf1234
|
||||
* ot = Aether object type; oi = Aether object ID random
|
||||
* KV = KV:"key":"value"
|
||||
* JS = {"id":123,"name":"example name"}
|
||||
* http or https?
|
||||
* Common short keys used:
|
||||
* bdg: Badge ID Random
|
||||
* reg: Registration ID Random
|
||||
* exid: External ID
|
||||
* gn: Given First Name
|
||||
* fn: Family Last Name
|
||||
* em: Email Address
|
||||
*/
|
||||
// Updated 2022-02-11
|
||||
|
||||
|
||||
export let process_data_string = function process_data_string(data_string: string) {
|
||||
console.log('*** process_data_string() ***');
|
||||
// console.log(data_string);
|
||||
if (!data_string || data_string.length < 1) {
|
||||
console.log('No data string found.');
|
||||
return false;
|
||||
}
|
||||
|
||||
let obj: key_val = {};
|
||||
|
||||
let colon_index = data_string.indexOf(':');
|
||||
if (colon_index) {
|
||||
let data_string_type = data_string.slice(0, colon_index);
|
||||
console.log(data_string_type);
|
||||
|
||||
obj['qr_type'] = data_string_type;
|
||||
|
||||
if (data_string_type == 'MECARD') {
|
||||
let mecard_str = data_string.slice(colon_index + 1);
|
||||
console.log(mecard_str);
|
||||
|
||||
obj['str'] = mecard_str;
|
||||
} else if (data_string_type == 'OBJ') {
|
||||
let key_value_str = data_string.slice(colon_index + 1);
|
||||
console.log(key_value_str);
|
||||
let key_value_array = key_value_str.split(',');
|
||||
// console.log(key_value_array);
|
||||
let ot_colon_index = key_value_array[0].indexOf(':');
|
||||
let obj_type = key_value_array[0].slice(ot_colon_index + 1);
|
||||
// console.log(obj_type);
|
||||
let oi_colon_index = key_value_array[1].indexOf(':');
|
||||
let obj_id = key_value_array[1].slice(oi_colon_index + 1);
|
||||
// console.log(obj_id);
|
||||
obj['type'] = obj_type;
|
||||
obj['id'] = obj_id;
|
||||
} else if (data_string_type == 'JSON') {
|
||||
let partial_json_str = data_string.slice(colon_index + 1);
|
||||
console.log(partial_json_str);
|
||||
let json_str = `{${partial_json_str}}`;
|
||||
console.log(json_str);
|
||||
|
||||
obj['json'] = JSON.parse(json_str);
|
||||
} else if (data_string_type == 'STR') {
|
||||
let str = data_string.slice(colon_index + 1);
|
||||
console.log(str);
|
||||
|
||||
obj['str'] = str;
|
||||
} else if (data_string_type == 'http' || data_string_type == 'https') {
|
||||
console.log(`http or https: ${data_string}`);
|
||||
|
||||
obj['type'] = 'url';
|
||||
obj['url'] = data_string;
|
||||
} else {
|
||||
console.log('The unknown data string type was found. Returning the string part.');
|
||||
let unknown_str = data_string.slice(colon_index + 1);
|
||||
console.log(unknown_str);
|
||||
|
||||
obj['str'] = unknown_str;
|
||||
}
|
||||
} else {
|
||||
console.log('The data string type was not found. Returning the entire string.');
|
||||
console.log(data_string);
|
||||
|
||||
obj['qr_type'] = 'UNKNOWN';
|
||||
obj['str'] = data_string;
|
||||
// return false;
|
||||
}
|
||||
|
||||
console.log(obj);
|
||||
return obj; // Returns an object
|
||||
};
|
||||
@@ -1,66 +0,0 @@
|
||||
export function return_obj_type_path({ obj_type = null, obj_type_prop_name = null }) {
|
||||
console.log('*** return_obj_type_path() ***');
|
||||
|
||||
let obj_type_path = null;
|
||||
|
||||
let known_obj_type_li = ['account', 'address', 'archive', 'archive_content', 'contact', 'event_badge', 'event_exhibit', 'event_file', 'event_location', 'event_person', 'event_presentation', 'event_presenter', 'event_registration', 'event_session', 'event', 'hosted_file', 'order_line', 'order', 'person', 'post', 'post_comment', 'user'];
|
||||
|
||||
let known_obj_type_li_dict = [
|
||||
{ name: 'account', display: 'Account', path: 'account' },
|
||||
{ name: 'archive', display: 'Archive', path: 'archive' },
|
||||
{ name: 'address', display: 'Address', path: 'address' },
|
||||
{ name: 'archive', display: 'Archive', path: 'archive' },
|
||||
{ name: 'archive_content', display: 'Archive Content', path: 'archive/content' },
|
||||
{ name: 'contact', display: 'Contact', path: 'contact' },
|
||||
{ name: 'data_store', display: 'Data Store', path: 'data_store' },
|
||||
{ name: 'event_abstract', display: 'Event Abstract', path: 'event/abstract' },
|
||||
{ name: 'event_badge', display: 'Event Badge', path: 'event/badge' },
|
||||
{ name: 'event_device', display: 'Event Device', path: 'event/device' },
|
||||
{ name: 'event_exhibit', display: 'Event Exhibit', path: 'event/exhibit' },
|
||||
{ name: 'event_file', display: 'Event File', path: 'event/file' },
|
||||
{ name: 'event_location', display: 'Event Location', path: 'event/location' },
|
||||
{ name: 'event_person', display: 'Event Person', path: 'event/person' },
|
||||
{ name: 'event_presentation', display: 'Event Presentation', path: 'event/' },
|
||||
{ name: 'event_presenter', display: 'Event Presenter', path: 'event/presenter' },
|
||||
{ name: 'event_registration', display: 'Event Registration', path: 'event/registration' },
|
||||
{ name: 'event_session', display: 'Event Session', path: 'event/session' },
|
||||
{ name: 'event', display: 'Event', path: 'event' },
|
||||
{ name: 'hosted_file', display: 'Hosted File', path: 'hosted_file' },
|
||||
{ name: 'journal', display: 'Journal', path: 'journal' },
|
||||
{ name: 'journal_entry', display: 'Journal Entry', path: 'journal/entry' },
|
||||
{ name: 'order_line', display: 'Order Line', path: 'order/line' },
|
||||
{ name: 'order', display: 'Order', path: 'order' },
|
||||
{ name: 'person', display: 'Person', path: 'person' },
|
||||
{ name: 'post', display: 'Archive', path: 'post' },
|
||||
{ name: 'post_comment', display: 'Archive Content', path: 'post/comment' },
|
||||
{ name: 'user', display: 'User', path: 'user' },
|
||||
];
|
||||
|
||||
if (obj_type) {
|
||||
// Need to loop through known for safety?
|
||||
obj_type_path = obj_type_prop_name.replaceAll('_', '/');
|
||||
|
||||
} else if (obj_type_prop_name) {
|
||||
let found_obj_type_name = null;
|
||||
let found_obj_type_path = null;
|
||||
|
||||
for (let i = 0; i < known_obj_type_li_dict.length; i++) {
|
||||
// console.log(known_obj_type_li_dict[i]);
|
||||
// let guessed_obj_type = prop_name.startsWith(known_obj_type_li_dict[i]
|
||||
if (obj_type_prop_name.startsWith(known_obj_type_li_dict[i].name)) {
|
||||
console.log(`Found ${known_obj_type_li_dict[i].name}`);
|
||||
found_obj_type_name = known_obj_type_li_dict[i].name;
|
||||
found_obj_type_path = known_obj_type_li_dict[i].path;
|
||||
// obj_type_path = obj_type_prop_name.replaceAll('_', '/');
|
||||
obj_type_path = found_obj_type_path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log('Missing required parameters');
|
||||
return false;
|
||||
}
|
||||
|
||||
return obj_type_path;
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
import { to_title_case } from "./ae_utils__to_title_case";
|
||||
|
||||
// Updated 2023-08-18
|
||||
export function set_obj_prop_display_name({ prop_name, obj_type = null, prefix_w_obj_type = true, prefix_all_w_obj_type = false, replace_underscores = true, title_case = true, override = null }) {
|
||||
console.log('*** set_obj_prop_display_name() ***');
|
||||
|
||||
if (override) {
|
||||
return override;
|
||||
}
|
||||
|
||||
let known_obj_type_li = ['account', 'address', 'contact', 'event_badge', 'event_exhibit', 'event_file', 'event_location', 'event_person', 'event_presentation', 'event_presenter', 'event_registration', 'event_session', 'event', 'hosted_file', 'order_line', 'order', 'person', 'user'];
|
||||
|
||||
|
||||
let known_obj_type_li_dict = [
|
||||
{ name: 'account', display: 'Account' },
|
||||
{ name: 'address', display: 'Address' },
|
||||
{ name: 'contact', display: 'Contact' },
|
||||
{ name: 'event_badge', display: 'Event Badge' },
|
||||
{ name: 'event_exhibit', display: 'Event Exhibit' },
|
||||
{ name: 'event_file', display: 'Event File' },
|
||||
{ name: 'event_location', display: 'Event Location' },
|
||||
{ name: 'event_person', display: 'Event Person' },
|
||||
{ name: 'event_presentation', display: 'Event Presentation' },
|
||||
{ name: 'event_presenter', display: 'Event Presenter' },
|
||||
{ name: 'event_registration', display: 'Event Registration' },
|
||||
{ name: 'event_session', display: 'Event Session' },
|
||||
{ name: 'event', display: 'Event' },
|
||||
{ name: 'hosted_file', display: 'Hosted File' },
|
||||
{ name: 'order_line', display: 'Order Line' },
|
||||
{ name: 'order', display: 'Order' },
|
||||
{ name: 'person', display: 'Person' },
|
||||
{ name: 'user', display: 'User' },
|
||||
];
|
||||
|
||||
let prop_display_name = prop_name;
|
||||
|
||||
if (!prefix_w_obj_type) {
|
||||
if (obj_type) {
|
||||
prop_display_name = prop_name.replace(obj_type, '');
|
||||
} else {
|
||||
for (let i = 0; i < known_obj_type_li_dict.length; i++) {
|
||||
// console.log(known_obj_type_li_dict[i]);
|
||||
if (prop_name.startsWith(known_obj_type_li_dict[i].name)) {
|
||||
// console.log(`Found ${known_obj_type_li_dict[i].name}`);
|
||||
prop_display_name = prop_name.replace(known_obj_type_li_dict[i].name, '');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// for (let i = 0; i < known_obj_type_li.length; i++) {
|
||||
// // console.log(known_obj_type_li[i]);
|
||||
// if (prop_name.startsWith(known_obj_type_li[i])) {
|
||||
// console.log(`Found ${known_obj_type_li[i]}`);
|
||||
// prop_display_name = prop_name.replace(known_obj_type_li[i], '');
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
if (!prefix_all_w_obj_type) {
|
||||
for (let i = 0; i < known_obj_type_li.length; i++) {
|
||||
// console.log(known_obj_type_li[i]);
|
||||
let found_obj_type = null;
|
||||
|
||||
if (prop_name.startsWith(known_obj_type_li_dict[i].name)) {
|
||||
// if (prop_name.startsWith(known_obj_type_li[i])) {
|
||||
// console.log(`Found ${known_obj_type_li_dict[i].name}`);
|
||||
found_obj_type = known_obj_type_li_dict[i].name;
|
||||
if (found_obj_type == obj_type) {
|
||||
prop_display_name = prop_name.replace(known_obj_type_li_dict[i].name, '');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if (obj_type) {
|
||||
// prop_display_name = prop_name.replace(obj_type, '');
|
||||
// } else {
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(prop_display_name);
|
||||
if (prop_display_name.search('ID')) {
|
||||
}
|
||||
prop_display_name = prop_display_name.replace('id_random', 'ID');
|
||||
|
||||
if (replace_underscores) {
|
||||
prop_display_name = prop_display_name.replaceAll('_', ' ');
|
||||
}
|
||||
|
||||
if (title_case) {
|
||||
prop_display_name = to_title_case(prop_display_name);
|
||||
}
|
||||
|
||||
// console.log(prop_display_name);
|
||||
return prop_display_name;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/* Adapted from: To Title Case © 2018 David Gouch | https://github.com/gouch/to-title-case */
|
||||
// eslint-disable-next-line no-extend-native
|
||||
export function to_title_case(text_string) {
|
||||
// console.log('*** to_title_case() ***');
|
||||
let smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|v.?|vs.?|via)$/i;
|
||||
let alphanumericPattern = /([A-Za-z0-9\u00C0-\u00FF])/;
|
||||
let wordSeparators = /([ :–—-])/;
|
||||
|
||||
return text_string.split(wordSeparators)
|
||||
.map(function (current, index, array) {
|
||||
if (
|
||||
/* Check for small words */
|
||||
current.search(smallWords) > -1 &&
|
||||
/* Skip first and last word */
|
||||
index !== 0 &&
|
||||
index !== array.length - 1 &&
|
||||
/* Ignore title end and subtitle start */
|
||||
array[index - 3] !== ':' &&
|
||||
array[index + 1] !== ':' &&
|
||||
/* Ignore small words that start a hyphenated phrase */
|
||||
(array[index + 1] !== '-' ||
|
||||
(array[index - 1] === '-' && array[index + 1] === '-'))) {
|
||||
return current.toLowerCase();
|
||||
}
|
||||
|
||||
/* Ignore intentional capitalization */
|
||||
if (current.substr(1).search(/[A-Z]|\../) > -1) {
|
||||
return current;
|
||||
}
|
||||
|
||||
/* Ignore URLs */
|
||||
if (array[index + 1] === ':' && array[index + 2] !== '') {
|
||||
return current;
|
||||
}
|
||||
|
||||
/* Capitalize the first letter */
|
||||
return current.replace(alphanumericPattern, function (match) {
|
||||
return match.toUpperCase();
|
||||
});
|
||||
})
|
||||
.join('');
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
<script lang="ts">
|
||||
export let log_lvl: number = 0;
|
||||
// import { page } from '$app/stores'
|
||||
|
||||
export let site_google_tracking_id: string = '';
|
||||
if (log_lvl) {
|
||||
console.log(`AE Analytics: site_google_tracking_id = `, site_google_tracking_id);
|
||||
}
|
||||
console.log(`site_google_tracking_id = `, site_google_tracking_id);
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
@@ -13,10 +11,14 @@ if (typeof window !== 'undefined') {
|
||||
};
|
||||
window.gtag('js', new Date());
|
||||
window.gtag('config', site_google_tracking_id);
|
||||
if (log_lvl) {
|
||||
console.log(`AE Analytics: Google Analytics Tracking ID = `, site_google_tracking_id);
|
||||
}
|
||||
}
|
||||
|
||||
// $: if (typeof gtag !== 'undefined') {
|
||||
// gtag('config', site_google_tracking_id, {
|
||||
// page_title: document.title,
|
||||
// page_path: $page.url.pathname,
|
||||
// })
|
||||
// }
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -24,4 +26,14 @@ if (typeof window !== 'undefined') {
|
||||
async
|
||||
src="https://www.googletagmanager.com/gtag/js?id={site_google_tracking_id}">
|
||||
</script>
|
||||
<!-- <script>
|
||||
window.dataLayer = window.dataLayer || []
|
||||
|
||||
function gtag() {
|
||||
dataLayer.push(arguments)
|
||||
}
|
||||
|
||||
gtag('js', new Date())
|
||||
gtag('config', site_google_tracking_id)
|
||||
</script> -->
|
||||
</svelte:head>
|
||||
|
||||
@@ -109,7 +109,7 @@ export let get_ae_obj_li_for_lu = async function get_ae_obj_li_for_lu(
|
||||
endpoint: endpoint,
|
||||
headers: headers,
|
||||
params: params,
|
||||
// return_meta: return_meta,
|
||||
return_meta: return_meta,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
@@ -172,8 +172,6 @@ export let create_ae_obj_crud = async function create_ae_obj_crud(
|
||||
let endpoint = '';
|
||||
if (obj_type == 'account') {
|
||||
endpoint = `/crud/account`;
|
||||
} else if (obj_type == 'activity_log') {
|
||||
endpoint = `/crud/activity_log`;
|
||||
} else if (obj_type == 'address') {
|
||||
endpoint = `/crud/address`;
|
||||
} else if (obj_type == 'archive') {
|
||||
@@ -319,7 +317,7 @@ export let update_ae_obj_id_crud = async function update_ae_obj_id_crud(
|
||||
return_obj = false,
|
||||
obj_v_name = '',
|
||||
return_meta = false,
|
||||
log_lvl = 0
|
||||
log_lvl = 3
|
||||
}: {
|
||||
api_cfg: any,
|
||||
obj_type: string,
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
[Dolphin]
|
||||
Timestamp=2024,12,2,17,34,30.327
|
||||
Version=4
|
||||
ViewMode=1
|
||||
|
||||
[Settings]
|
||||
HiddenFilesShown=true
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"rules": {
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"warn",
|
||||
{
|
||||
"argsIgnorePattern": "^_",
|
||||
"varsIgnorePattern": "^\\$\\$(Props|Events|Slots|Generic)$"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { mode } from 'mode-watcher';
|
||||
let { hex = $bindable() }: { hex: string } = $props();
|
||||
import ColorPicker from 'svelte-awesome-color-picker';
|
||||
</script>
|
||||
|
||||
<div class:dark={$mode === 'dark'}>
|
||||
<ColorPicker
|
||||
bind:hex
|
||||
sliderDirection="vertical"
|
||||
label="Pick a color"
|
||||
isTextInput={false}
|
||||
isAlpha
|
||||
--picker-indicator-size="1rem"
|
||||
--input-size="1rem"
|
||||
/>
|
||||
</div>
|
||||
@@ -1,28 +0,0 @@
|
||||
import { Extension } from '@tiptap/core';
|
||||
import { Plugin } from '@tiptap/pm/state';
|
||||
|
||||
import findColors from '../utils.js';
|
||||
|
||||
export const ColorHighlighter = Extension.create({
|
||||
name: 'colorHighlighter',
|
||||
|
||||
addProseMirrorPlugins() {
|
||||
return [
|
||||
new Plugin({
|
||||
state: {
|
||||
init(_, { doc }) {
|
||||
return findColors(doc);
|
||||
},
|
||||
apply(transaction, oldState) {
|
||||
return transaction.docChanged ? findColors(transaction.doc) : oldState;
|
||||
}
|
||||
},
|
||||
props: {
|
||||
decorations(state) {
|
||||
return this.getState(state);
|
||||
}
|
||||
}
|
||||
})
|
||||
];
|
||||
}
|
||||
});
|
||||
@@ -1,32 +0,0 @@
|
||||
import { SvelteNodeViewRenderer } from 'svelte-tiptap';
|
||||
import ImageExtendedComponent from '../image-extended-component.svelte';
|
||||
import Image from '@tiptap/extension-image';
|
||||
|
||||
export const ImageExtension = Image.extend({
|
||||
addAttributes() {
|
||||
return {
|
||||
src: {
|
||||
default: null
|
||||
},
|
||||
alt: {
|
||||
default: null
|
||||
},
|
||||
title: {
|
||||
default: null
|
||||
},
|
||||
width: {
|
||||
default: '100%'
|
||||
},
|
||||
height: {
|
||||
default: null
|
||||
},
|
||||
align: {
|
||||
default: 'left'
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
addNodeView: () => {
|
||||
return SvelteNodeViewRenderer(ImageExtendedComponent);
|
||||
}
|
||||
});
|
||||
@@ -1,406 +0,0 @@
|
||||
// MIT License
|
||||
|
||||
// Copyright (c) 2023 - 2024 Jeet Mandaliya (Github Username: sereneinserenade)
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
import { Extension, type Range, type Dispatch } from '@tiptap/core';
|
||||
import { Decoration, DecorationSet } from '@tiptap/pm/view';
|
||||
import { Plugin, PluginKey, type EditorState, type Transaction } from '@tiptap/pm/state';
|
||||
import { Node as PMNode } from '@tiptap/pm/model';
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands<ReturnType> {
|
||||
search: {
|
||||
/**
|
||||
* @description Set search term in extension.
|
||||
*/
|
||||
setSearchTerm: (searchTerm: string) => ReturnType;
|
||||
/**
|
||||
* @description Set replace term in extension.
|
||||
*/
|
||||
setReplaceTerm: (replaceTerm: string) => ReturnType;
|
||||
/**
|
||||
* @description Set case sensitivity in extension.
|
||||
*/
|
||||
setCaseSensitive: (caseSensitive: boolean) => ReturnType;
|
||||
/**
|
||||
* @description Reset current search result to first instance.
|
||||
*/
|
||||
resetIndex: () => ReturnType;
|
||||
/**
|
||||
* @description Find next instance of search result.
|
||||
*/
|
||||
nextSearchResult: () => ReturnType;
|
||||
/**
|
||||
* @description Find previous instance of search result.
|
||||
*/
|
||||
previousSearchResult: () => ReturnType;
|
||||
/**
|
||||
* @description Replace first instance of search result with given replace term.
|
||||
*/
|
||||
replace: () => ReturnType;
|
||||
/**
|
||||
* @description Replace all instances of search result with given replace term.
|
||||
*/
|
||||
replaceAll: () => ReturnType;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
interface TextNodesWithPosition {
|
||||
text: string;
|
||||
pos: number;
|
||||
}
|
||||
|
||||
const getRegex = (s: string, disableRegex: boolean, caseSensitive: boolean): RegExp => {
|
||||
return RegExp(
|
||||
disableRegex ? s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') : s,
|
||||
caseSensitive ? 'gu' : 'gui'
|
||||
);
|
||||
};
|
||||
|
||||
interface ProcessedSearches {
|
||||
decorationsToReturn: DecorationSet;
|
||||
results: Range[];
|
||||
}
|
||||
|
||||
function processSearches(
|
||||
doc: PMNode,
|
||||
searchTerm: RegExp,
|
||||
searchResultClass: string,
|
||||
resultIndex: number
|
||||
): ProcessedSearches {
|
||||
const decorations: Decoration[] = [];
|
||||
const results: Range[] = [];
|
||||
|
||||
let textNodesWithPosition: TextNodesWithPosition[] = [];
|
||||
let index = 0;
|
||||
|
||||
if (!searchTerm) {
|
||||
return {
|
||||
decorationsToReturn: DecorationSet.empty,
|
||||
results: []
|
||||
};
|
||||
}
|
||||
|
||||
doc?.descendants((node, pos) => {
|
||||
if (node.isText) {
|
||||
if (textNodesWithPosition[index]) {
|
||||
textNodesWithPosition[index] = {
|
||||
text: textNodesWithPosition[index].text + node.text,
|
||||
pos: textNodesWithPosition[index].pos
|
||||
};
|
||||
} else {
|
||||
textNodesWithPosition[index] = {
|
||||
text: `${node.text}`,
|
||||
pos
|
||||
};
|
||||
}
|
||||
} else {
|
||||
index += 1;
|
||||
}
|
||||
});
|
||||
|
||||
textNodesWithPosition = textNodesWithPosition.filter(Boolean);
|
||||
|
||||
for (const element of textNodesWithPosition) {
|
||||
const { text, pos } = element;
|
||||
const matches = Array.from(text.matchAll(searchTerm)).filter(([matchText]) => matchText.trim());
|
||||
|
||||
for (const m of matches) {
|
||||
if (m[0] === '') break;
|
||||
|
||||
if (m.index !== undefined) {
|
||||
results.push({
|
||||
from: pos + m.index,
|
||||
to: pos + m.index + m[0].length
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < results.length; i += 1) {
|
||||
const r = results[i];
|
||||
const className =
|
||||
i === resultIndex ? `${searchResultClass} ${searchResultClass}-current` : searchResultClass;
|
||||
const decoration: Decoration = Decoration.inline(r.from, r.to, {
|
||||
class: className
|
||||
});
|
||||
|
||||
decorations.push(decoration);
|
||||
}
|
||||
|
||||
return {
|
||||
decorationsToReturn: DecorationSet.create(doc, decorations),
|
||||
results
|
||||
};
|
||||
}
|
||||
|
||||
const replace = (
|
||||
replaceTerm: string,
|
||||
results: Range[],
|
||||
{ state, dispatch }: { state: EditorState; dispatch: Dispatch }
|
||||
) => {
|
||||
const firstResult = results[0];
|
||||
|
||||
if (!firstResult) return;
|
||||
|
||||
const { from, to } = results[0];
|
||||
|
||||
if (dispatch) dispatch(state.tr.insertText(replaceTerm, from, to));
|
||||
};
|
||||
|
||||
const rebaseNextResult = (
|
||||
replaceTerm: string,
|
||||
index: number,
|
||||
lastOffset: number,
|
||||
results: Range[]
|
||||
): [number, Range[]] | null => {
|
||||
const nextIndex = index + 1;
|
||||
|
||||
if (!results[nextIndex]) return null;
|
||||
|
||||
const { from: currentFrom, to: currentTo } = results[index];
|
||||
|
||||
const offset = currentTo - currentFrom - replaceTerm.length + lastOffset;
|
||||
|
||||
const { from, to } = results[nextIndex];
|
||||
|
||||
results[nextIndex] = {
|
||||
to: to - offset,
|
||||
from: from - offset
|
||||
};
|
||||
|
||||
return [offset, results];
|
||||
};
|
||||
|
||||
const replaceAll = (
|
||||
replaceTerm: string,
|
||||
results: Range[],
|
||||
{ tr, dispatch }: { tr: Transaction; dispatch: Dispatch }
|
||||
) => {
|
||||
let offset = 0;
|
||||
|
||||
let resultsCopy = results.slice();
|
||||
|
||||
if (!resultsCopy.length) return;
|
||||
|
||||
for (let i = 0; i < resultsCopy.length; i += 1) {
|
||||
const { from, to } = resultsCopy[i];
|
||||
|
||||
tr.insertText(replaceTerm, from, to);
|
||||
|
||||
const rebaseNextResultResponse = rebaseNextResult(replaceTerm, i, offset, resultsCopy);
|
||||
|
||||
if (!rebaseNextResultResponse) continue;
|
||||
|
||||
offset = rebaseNextResultResponse[0];
|
||||
resultsCopy = rebaseNextResultResponse[1];
|
||||
}
|
||||
|
||||
dispatch(tr);
|
||||
};
|
||||
|
||||
export const searchAndReplacePluginKey = new PluginKey('searchAndReplacePlugin');
|
||||
|
||||
export interface SearchAndReplaceOptions {
|
||||
searchResultClass: string;
|
||||
disableRegex: boolean;
|
||||
}
|
||||
|
||||
export interface SearchAndReplaceStorage {
|
||||
searchTerm: string;
|
||||
replaceTerm: string;
|
||||
results: Range[];
|
||||
lastSearchTerm: string;
|
||||
caseSensitive: boolean;
|
||||
lastCaseSensitive: boolean;
|
||||
resultIndex: number;
|
||||
lastResultIndex: number;
|
||||
}
|
||||
|
||||
export const SearchAndReplace = Extension.create<SearchAndReplaceOptions, SearchAndReplaceStorage>({
|
||||
name: 'searchAndReplace',
|
||||
|
||||
addOptions() {
|
||||
return {
|
||||
searchResultClass: 'search-result',
|
||||
disableRegex: true
|
||||
};
|
||||
},
|
||||
|
||||
addStorage() {
|
||||
return {
|
||||
searchTerm: '',
|
||||
replaceTerm: '',
|
||||
results: [],
|
||||
lastSearchTerm: '',
|
||||
caseSensitive: false,
|
||||
lastCaseSensitive: false,
|
||||
resultIndex: 0,
|
||||
lastResultIndex: 0
|
||||
};
|
||||
},
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
setSearchTerm:
|
||||
(searchTerm: string) =>
|
||||
({ editor }) => {
|
||||
editor.storage.searchAndReplace.searchTerm = searchTerm;
|
||||
|
||||
return false;
|
||||
},
|
||||
setReplaceTerm:
|
||||
(replaceTerm: string) =>
|
||||
({ editor }) => {
|
||||
editor.storage.searchAndReplace.replaceTerm = replaceTerm;
|
||||
|
||||
return false;
|
||||
},
|
||||
setCaseSensitive:
|
||||
(caseSensitive: boolean) =>
|
||||
({ editor }) => {
|
||||
editor.storage.searchAndReplace.caseSensitive = caseSensitive;
|
||||
|
||||
return false;
|
||||
},
|
||||
resetIndex:
|
||||
() =>
|
||||
({ editor }) => {
|
||||
editor.storage.searchAndReplace.resultIndex = 0;
|
||||
|
||||
return false;
|
||||
},
|
||||
nextSearchResult:
|
||||
() =>
|
||||
({ editor }) => {
|
||||
const { results, resultIndex } = editor.storage.searchAndReplace;
|
||||
|
||||
const nextIndex = resultIndex + 1;
|
||||
|
||||
if (results[nextIndex]) {
|
||||
editor.storage.searchAndReplace.resultIndex = nextIndex;
|
||||
} else {
|
||||
editor.storage.searchAndReplace.resultIndex = 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
previousSearchResult:
|
||||
() =>
|
||||
({ editor }) => {
|
||||
const { results, resultIndex } = editor.storage.searchAndReplace;
|
||||
|
||||
const prevIndex = resultIndex - 1;
|
||||
|
||||
if (results[prevIndex]) {
|
||||
editor.storage.searchAndReplace.resultIndex = prevIndex;
|
||||
} else {
|
||||
editor.storage.searchAndReplace.resultIndex = results.length - 1;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
replace:
|
||||
() =>
|
||||
({ editor, state, dispatch }) => {
|
||||
const { replaceTerm, results } = editor.storage.searchAndReplace;
|
||||
|
||||
replace(replaceTerm, results, { state, dispatch });
|
||||
|
||||
return false;
|
||||
},
|
||||
replaceAll:
|
||||
() =>
|
||||
({ editor, tr, dispatch }) => {
|
||||
const { replaceTerm, results } = editor.storage.searchAndReplace;
|
||||
|
||||
replaceAll(replaceTerm, results, { tr, dispatch });
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
addProseMirrorPlugins() {
|
||||
const editor = this.editor;
|
||||
const { searchResultClass, disableRegex } = this.options;
|
||||
|
||||
const setLastSearchTerm = (t: string) => (editor.storage.searchAndReplace.lastSearchTerm = t);
|
||||
const setLastCaseSensitive = (t: boolean) =>
|
||||
(editor.storage.searchAndReplace.lastCaseSensitive = t);
|
||||
const setLastResultIndex = (t: number) => (editor.storage.searchAndReplace.lastResultIndex = t);
|
||||
|
||||
return [
|
||||
new Plugin({
|
||||
key: searchAndReplacePluginKey,
|
||||
state: {
|
||||
init: () => DecorationSet.empty,
|
||||
apply({ doc, docChanged }, oldState) {
|
||||
const {
|
||||
searchTerm,
|
||||
lastSearchTerm,
|
||||
caseSensitive,
|
||||
lastCaseSensitive,
|
||||
resultIndex,
|
||||
lastResultIndex
|
||||
} = editor.storage.searchAndReplace;
|
||||
|
||||
if (
|
||||
!docChanged &&
|
||||
lastSearchTerm === searchTerm &&
|
||||
lastCaseSensitive === caseSensitive &&
|
||||
lastResultIndex === resultIndex
|
||||
)
|
||||
return oldState;
|
||||
|
||||
setLastSearchTerm(searchTerm);
|
||||
setLastCaseSensitive(caseSensitive);
|
||||
setLastResultIndex(resultIndex);
|
||||
|
||||
if (!searchTerm) {
|
||||
editor.storage.searchAndReplace.results = [];
|
||||
return DecorationSet.empty;
|
||||
}
|
||||
|
||||
const { decorationsToReturn, results } = processSearches(
|
||||
doc,
|
||||
getRegex(searchTerm, disableRegex, caseSensitive),
|
||||
searchResultClass,
|
||||
resultIndex
|
||||
);
|
||||
|
||||
editor.storage.searchAndReplace.results = results;
|
||||
|
||||
return decorationsToReturn;
|
||||
}
|
||||
},
|
||||
props: {
|
||||
decorations(state) {
|
||||
return this.getState(state);
|
||||
}
|
||||
}
|
||||
})
|
||||
];
|
||||
}
|
||||
});
|
||||
|
||||
export default SearchAndReplace;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user