feat: Migrate ESLint to flat config and resolve initial linting errors
Migrated the ESLint configuration to the new flat config format () and addressed several initial linting errors. Key changes include: - Updated ESLint configuration to treat as warnings instead of errors. - Fixed errors in by declaring and . - Corrected error in by using instead of an out-of-scope . - Resolved error in by replacing the undefined directive with the component. - Addressed errors in by replacing with and with . - Fixed errors in by importing necessary modules (, , ) and adding missing props (, , , , ).
This commit is contained in:
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@@ -1,7 +1,5 @@
|
|||||||
{
|
{
|
||||||
"prettier.documentSelectors": [
|
"prettier.documentSelectors": ["**/*.svelte"],
|
||||||
"**/*.svelte"
|
|
||||||
],
|
|
||||||
"tailwindCSS.classAttributes": [
|
"tailwindCSS.classAttributes": [
|
||||||
"class",
|
"class",
|
||||||
"accent",
|
"accent",
|
||||||
@@ -118,4 +116,4 @@
|
|||||||
"zIndex"
|
"zIndex"
|
||||||
],
|
],
|
||||||
"explorer.fileNesting.enabled": false
|
"explorer.fileNesting.enabled": false
|
||||||
}
|
}
|
||||||
|
|||||||
153
ARCHITECTURE.md
153
ARCHITECTURE.md
@@ -3,111 +3,140 @@
|
|||||||
This document outlines the overall architecture and key technologies used in the Aether SvelteKit frontend project.
|
This document outlines the overall architecture and key technologies used in the Aether SvelteKit frontend project.
|
||||||
|
|
||||||
## 1. Project Overview
|
## 1. Project Overview
|
||||||
|
|
||||||
The Aether project is a Svelte and SvelteKit based application, utilizing Tailwind CSS and Skeleton for styling and UI elements. It serves as the frontend UI/UX for the Aether system, which interacts with a Python FastAPI backend.
|
The Aether project is a Svelte and SvelteKit based application, utilizing Tailwind CSS and Skeleton for styling and UI elements. It serves as the frontend UI/UX for the Aether system, which interacts with a Python FastAPI backend.
|
||||||
|
|
||||||
## 2. Core Technologies
|
## 2. Core Technologies
|
||||||
* **Frontend Framework:** Svelte 5 and SvelteKit v2
|
|
||||||
* **Routing:** SvelteKit's file-system based routing.
|
- **Frontend Framework:** Svelte 5 and SvelteKit v2
|
||||||
* **Styling:** Tailwind CSS 3.x (with plans to upgrade to 4.x when ShadCN is ready)
|
- **Routing:** SvelteKit's file-system based routing.
|
||||||
* **UI Component Libraries:**
|
- **Styling:** Tailwind CSS 3.x (with plans to upgrade to 4.x when ShadCN is ready)
|
||||||
* Skeleton (Design System, Tailwind Components, Functional Components - with plans to upgrade to v3)
|
- **UI Component Libraries:**
|
||||||
* Flowbite (Tailwind Components)
|
- Skeleton (Design System, Tailwind Components, Functional Components - with plans to upgrade to v3)
|
||||||
* **Note:** ShadCN is currently used but is planned for removal.
|
- Flowbite (Tailwind Components)
|
||||||
* **Text/Code Editors:**
|
- **Note:** ShadCN is currently used but is planned for removal.
|
||||||
* CodeMirror 6.x (primary text and code editor, planned for rich text editing)
|
- **Text/Code Editors:**
|
||||||
* Edra (TipTap based Rich Text Editor)
|
- CodeMirror 6.x (primary text and code editor, planned for rich text editing)
|
||||||
* **Note:** ShadEditor TipTap is present but marked for removal, with CodeMirror being the preferred solution for all text editing needs.
|
- Edra (TipTap based Rich Text Editor)
|
||||||
* **Icons:** Lucide Icons (SVG Icons)
|
- **Note:** ShadEditor TipTap is present but marked for removal, with CodeMirror being the preferred solution for all text editing needs.
|
||||||
* **Markdown Parsing:** `marked` library
|
- **Icons:** Lucide Icons (SVG Icons)
|
||||||
* **State Management:** Svelte stores, potentially with `liveQuery` from Dexie for reactive IndexedDB interactions.
|
- **Markdown Parsing:** `marked` library
|
||||||
|
- **State Management:** Svelte stores, potentially with `liveQuery` from Dexie for reactive IndexedDB interactions.
|
||||||
|
|
||||||
## 3. Module Structure
|
## 3. Module Structure
|
||||||
|
|
||||||
The Aether project is organized into several modules, categorized as Core, Extended, and Custom.
|
The Aether project is organized into several modules, categorized as Core, Extended, and Custom.
|
||||||
|
|
||||||
### 3.1. Official Modules
|
### 3.1. Official Modules
|
||||||
|
|
||||||
#### Core Modules
|
#### Core Modules
|
||||||
|
|
||||||
These are foundational modules essential for the application's basic functionality.
|
These are foundational modules essential for the application's basic functionality.
|
||||||
* **Accounts:** Minimal implementation.
|
|
||||||
* **Files:** Manages hosted files.
|
- **Accounts:** Minimal implementation.
|
||||||
* **People:** Minimal implementation for person records.
|
- **Files:** Manages hosted files.
|
||||||
* **Sites:** Minimal implementation for site configurations.
|
- **People:** Minimal implementation for person records.
|
||||||
* **Users:** Minimal implementation for user management.
|
- **Sites:** Minimal implementation for site configurations.
|
||||||
|
- **Users:** Minimal implementation for user management.
|
||||||
|
|
||||||
#### Extended Modules
|
#### Extended Modules
|
||||||
|
|
||||||
These modules provide additional features and functionalities.
|
These modules provide additional features and functionalities.
|
||||||
* **Archives:** Minimal implementation.
|
|
||||||
* **Events:** Includes features for Badges and Presentation Management.
|
- **Archives:** Minimal implementation.
|
||||||
* **Posts:** Minimal implementation.
|
- **Events:** Includes features for Badges and Presentation Management.
|
||||||
* **Journals:** Manages journal entries.
|
- **Posts:** Minimal implementation.
|
||||||
|
- **Journals:** Manages journal entries.
|
||||||
|
|
||||||
#### Custom Modules
|
#### Custom Modules
|
||||||
|
|
||||||
These modules are tailored for specific client needs.
|
These modules are tailored for specific client needs.
|
||||||
* **IDAA:** Includes Archives, Bulletin Board (BB), and Recovery Meetings functionalities.
|
|
||||||
|
- **IDAA:** Includes Archives, Bulletin Board (BB), and Recovery Meetings functionalities.
|
||||||
|
|
||||||
## 4. Data Storage Mechanisms
|
## 4. Data Storage Mechanisms
|
||||||
|
|
||||||
### 4.1. Local Storage
|
### 4.1. Local Storage
|
||||||
|
|
||||||
Used for client-side persistence of various application states and configurations.
|
Used for client-side persistence of various application states and configurations.
|
||||||
* `api`: API-related settings.
|
|
||||||
* `app`: Global application settings.
|
- `api`: API-related settings.
|
||||||
* `core`: Settings and data specific to core modules.
|
- `app`: Global application settings.
|
||||||
* `<module>`: Settings and data specific to extended modules.
|
- `core`: Settings and data specific to core modules.
|
||||||
* `<custom>`: Settings and data specific to custom modules.
|
- `<module>`: Settings and data specific to extended modules.
|
||||||
|
- `<custom>`: Settings and data specific to custom modules.
|
||||||
|
|
||||||
### 4.2. IndexedDB (Dexie.js)
|
### 4.2. IndexedDB (Dexie.js)
|
||||||
|
|
||||||
Used for more structured client-side data storage, often for caching and offline capabilities.
|
Used for more structured client-side data storage, often for caching and offline capabilities.
|
||||||
* `ae_core_db`: Core database instance.
|
|
||||||
* `<module>`: Module-specific database instances.
|
- `ae_core_db`: Core database instance.
|
||||||
* `<custom>`: Custom module-specific database instances (none currently defined).
|
- `<module>`: Module-specific database instances.
|
||||||
|
- `<custom>`: Custom module-specific database instances (none currently defined).
|
||||||
|
|
||||||
## 5. Data Sorting
|
## 5. Data Sorting
|
||||||
|
|
||||||
Standardized sorting orders are applied across various data lists.
|
Standardized sorting orders are applied across various data lists.
|
||||||
* **Default/General:** `group > priority > sort > updated_on/created_on`
|
|
||||||
* **Specific (e.g., Events):** `type > start_date/time > code or name`
|
- **Default/General:** `group > priority > sort > updated_on/created_on`
|
||||||
|
- **Specific (e.g., Events):** `type > start_date/time > code or name`
|
||||||
|
|
||||||
## 6. Object Properties and Fields
|
## 6. Object Properties and Fields
|
||||||
|
|
||||||
A set of standardized field names and types are used across Aether objects.
|
A set of standardized field names and types are used across Aether objects.
|
||||||
|
|
||||||
### 6.1. Core Standard Fields
|
### 6.1. Core Standard Fields
|
||||||
|
|
||||||
These fields are expected to be present in most Aether objects.
|
These fields are expected to be present in most Aether objects.
|
||||||
* `id`: Primary key for an object (internal use, often a UUID).
|
|
||||||
* `id_random`: Randomly generated ID for an object (often used for external exposure or URL parameters).
|
- `id`: Primary key for an object (internal use, often a UUID).
|
||||||
* `<object_type>_id_random`: Specific random ID for an object (e.g., `person_id_random`).
|
- `id_random`: Randomly generated ID for an object (often used for external exposure or URL parameters).
|
||||||
* `code`: Short, unique identifier.
|
- `<object_type>_id_random`: Specific random ID for an object (e.g., `person_id_random`).
|
||||||
* `name`: Display name.
|
- `code`: Short, unique identifier.
|
||||||
* `enable`: Boolean for active/inactive status.
|
- `name`: Display name.
|
||||||
* `hide`: Boolean for visibility.
|
- `enable`: Boolean for active/inactive status.
|
||||||
* `priority`: Numeric value for ordering.
|
- `hide`: Boolean for visibility.
|
||||||
* `sort`: Numeric value for ordering.
|
- `priority`: Numeric value for ordering.
|
||||||
* `group`: Categorization string.
|
- `sort`: Numeric value for ordering.
|
||||||
* `notes`: General notes/comments.
|
- `group`: Categorization string.
|
||||||
* `created_on`: Timestamp of creation.
|
- `notes`: General notes/comments.
|
||||||
* `updated_on`: Timestamp of last update.
|
- `created_on`: Timestamp of creation.
|
||||||
|
- `updated_on`: Timestamp of last update.
|
||||||
|
|
||||||
### 6.2. Special Use Fields
|
### 6.2. Special Use Fields
|
||||||
|
|
||||||
Fields with specific purposes or conditional usage.
|
Fields with specific purposes or conditional usage.
|
||||||
* `for_type`: Indicates the type of object this object is linked to.
|
|
||||||
* `for_id`: The ID of the object this object is linked to.
|
- `for_type`: Indicates the type of object this object is linked to.
|
||||||
* `archive_on`: Timestamp for archiving.
|
- `for_id`: The ID of the object this object is linked to.
|
||||||
* `passcode`: Password or access code.
|
- `archive_on`: Timestamp for archiving.
|
||||||
* `external_id`: ID from an external system.
|
- `passcode`: Password or access code.
|
||||||
|
- `external_id`: ID from an external system.
|
||||||
|
|
||||||
### 6.3. Configuration and JSON Fields
|
### 6.3. Configuration and JSON Fields
|
||||||
|
|
||||||
Fields designed to store JSON data.
|
Fields designed to store JSON data.
|
||||||
* `cfg_json`: Configuration data in JSON format.
|
|
||||||
* `data_json`: General data in JSON format.
|
- `cfg_json`: Configuration data in JSON format.
|
||||||
* `linked_li_json`: List of linked items in JSON format.
|
- `data_json`: General data in JSON format.
|
||||||
|
- `linked_li_json`: List of linked items in JSON format.
|
||||||
|
|
||||||
### 6.4. Special Generated Fields (Client-side)
|
### 6.4. Special Generated Fields (Client-side)
|
||||||
|
|
||||||
Fields generated on the client-side, primarily for sorting or UI logic.
|
Fields generated on the client-side, primarily for sorting or UI logic.
|
||||||
* `tmp_sort_1`
|
|
||||||
* `tmp_sort_2`
|
- `tmp_sort_1`
|
||||||
* `tmp_sort_3`
|
- `tmp_sort_2`
|
||||||
|
- `tmp_sort_3`
|
||||||
|
|
||||||
### 6.5. Future Standard Fields
|
### 6.5. Future Standard Fields
|
||||||
|
|
||||||
A list of potential future standard fields, often prefixed with `obj_`. These are currently conceptual and not yet fully integrated.
|
A list of potential future standard fields, often prefixed with `obj_`. These are currently conceptual and not yet fully integrated.
|
||||||
* `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`.
|
|
||||||
|
- `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`.
|
||||||
|
|
||||||
## 7. IndexedDB LiveQuery Usage
|
## 7. IndexedDB LiveQuery Usage
|
||||||
* `lq__xyz_obj`: Used for general read-only access to liveQuery results.
|
|
||||||
* `lqw__xyz_obj`: Used for forms and binding values, representing a writable snapshot of liveQuery results.
|
- `lq__xyz_obj`: Used for general read-only access to liveQuery results.
|
||||||
* **Note:** Care must be taken when binding to `lqw__xyz_obj` to manage updates and potential conflicts with the underlying liveQuery.
|
- `lqw__xyz_obj`: Used for forms and binding values, representing a writable snapshot of liveQuery results.
|
||||||
|
- **Note:** Care must be taken when binding to `lqw__xyz_obj` to manage updates and potential conflicts with the underlying liveQuery.
|
||||||
|
|||||||
220
COMPONENTS.md
220
COMPONENTS.md
@@ -5,128 +5,144 @@ This document details the various UI components used throughout the Aether Svelt
|
|||||||
## 1. Aether Components (UI/UX)
|
## 1. Aether Components (UI/UX)
|
||||||
|
|
||||||
### 1.1. System Components
|
### 1.1. System Components
|
||||||
|
|
||||||
These components are part of the core application shell and provide global functionalities.
|
These components are part of the core application shell and provide global functionalities.
|
||||||
* **`header`**: Application-wide header.
|
|
||||||
* **`main/module`s**: Main content area for modules.
|
- **`header`**: Application-wide header.
|
||||||
* **`footer`**: Application-wide footer.
|
- **`main/module`s**: Main content area for modules.
|
||||||
* **`app`**: Provides global application functionalities such as:
|
- **`footer`**: Application-wide footer.
|
||||||
* Refresh application state.
|
- **`app`**: Provides global application functionalities such as:
|
||||||
* Clear IndexedDB.
|
- Refresh application state.
|
||||||
* Clear local storage (settings).
|
- Clear IndexedDB.
|
||||||
* Toggle iframe visibility (also updates URL parameter).
|
- Clear local storage (settings).
|
||||||
* Copy current URL.
|
- Toggle iframe visibility (also updates URL parameter).
|
||||||
* Generate and display QR codes.
|
- Copy current URL.
|
||||||
* **`menu`**: Various menus for different purposes:
|
- Generate and display QR codes.
|
||||||
* **`mode`**: Edit mode toggle, more options (all or details).
|
- **`menu`**: Various menus for different purposes:
|
||||||
* **`access_type`**: Passcode input, clear access.
|
- **`mode`**: Edit mode toggle, more options (all or details).
|
||||||
* **`user`**: Sign in/out, reset password, email link, change username and email.
|
- **`access_type`**: Passcode input, clear access.
|
||||||
* **`theme`**: Mode (light/dark), name (theme list).
|
- **`user`**: Sign in/out, reset password, email link, change username and email.
|
||||||
* **`debug`**: Developer-facing tools:
|
- **`theme`**: Mode (light/dark), name (theme list).
|
||||||
* Toggle debug mode (also updates URL parameter).
|
- **`debug`**: Developer-facing tools:
|
||||||
* Show core and module storages.
|
- Toggle debug mode (also updates URL parameter).
|
||||||
* Manually set initial timestamp.
|
- Show core and module storages.
|
||||||
* **`scroll_to`**: Navigation controls for scrolling:
|
- Manually set initial timestamp.
|
||||||
* Scroll to top of the page.
|
- **`scroll_to`**: Navigation controls for scrolling:
|
||||||
* Scroll page up.
|
- Scroll to top of the page.
|
||||||
* Scroll page down.
|
- Scroll page up.
|
||||||
* Scroll to bottom of the page.
|
- Scroll page down.
|
||||||
|
- Scroll to bottom of the page.
|
||||||
|
|
||||||
### 1.2. Core Components
|
### 1.2. Core Components
|
||||||
|
|
||||||
These are reusable components that provide common functionalities across different modules.
|
These are reusable components that provide common functionalities across different modules.
|
||||||
* **`copy_btn`**: A button to copy content to the clipboard.
|
|
||||||
* Properties: `clipboard`, `bind:value`, `btn_text`, `btn_html`.
|
- **`copy_btn`**: A button to copy content to the clipboard.
|
||||||
* **`txt_editor`**: A basic text area editor.
|
- Properties: `clipboard`, `bind:value`, `btn_text`, `btn_html`.
|
||||||
* **`md_editor`**: Markdown editor.
|
- **`txt_editor`**: A basic text area editor.
|
||||||
* Uses CodeMirror (planned for rich text editing).
|
- **`md_editor`**: Markdown editor.
|
||||||
* **Note:** ShadEditor TipTap is present but marked for removal. ShadCN components are also being phased out in favor of CodeMirror for text editing.
|
- Uses CodeMirror (planned for rich text editing).
|
||||||
* **`html_editor`**: HTML editor.
|
- **Note:** ShadEditor TipTap is present but marked for removal. ShadCN components are also being phased out in favor of CodeMirror for text editing.
|
||||||
* **`media_player`**: Component for playing media files.
|
- **`html_editor`**: HTML editor.
|
||||||
* Properties: `hosted_file`, `archive_content`, `media_player`.
|
- **`media_player`**: Component for playing media files.
|
||||||
* Bindings: `bind:host_id`, `bind:media_type`.
|
- Properties: `hosted_file`, `archive_content`, `media_player`.
|
||||||
* Status: `stopped`, `paused`, `playing`.
|
- Bindings: `bind:host_id`, `bind:media_type`.
|
||||||
* **`hosted_file_li`**: Manages a list of hosted files, making them available for selection.
|
- Status: `stopped`, `paused`, `playing`.
|
||||||
* **`hosted_file_link_to`**: Lists links per object, with bindings to add/remove links.
|
- **`hosted_file_li`**: Manages a list of hosted files, making them available for selection.
|
||||||
* **`upload_to_host`**: Component for uploading files to the host.
|
- **`hosted_file_link_to`**: Lists links per object, with bindings to add/remove links.
|
||||||
* Handles multiple files.
|
- **`upload_to_host`**: Component for uploading files to the host.
|
||||||
* Properties: `link_type`, `link_id`, `inner fragment` (label html).
|
- Handles multiple files.
|
||||||
* Bindings: `bind:trigger`, `bind:show_spinner`, `bind:show_percent`.
|
- Properties: `link_type`, `link_id`, `inner fragment` (label html).
|
||||||
* Status: `started`, `uploading`, `finished`.
|
- Bindings: `bind:trigger`, `bind:show_spinner`, `bind:show_percent`.
|
||||||
* **`upload_file_tbl`**: Table for uploaded files, includes checks for duplicate file hashes and removal from the list.
|
- Status: `started`, `uploading`, `finished`.
|
||||||
* **`download_from_host`**: Component for downloading files from the host.
|
- **`upload_file_tbl`**: Table for uploaded files, includes checks for duplicate file hashes and removal from the list.
|
||||||
* Bindings: `bind:host_file_id`, `bind:filename`, `bind:file_ext`.
|
- **`download_from_host`**: Component for downloading files from the host.
|
||||||
* Properties: `btn inner fragment`.
|
- Bindings: `bind:host_file_id`, `bind:filename`, `bind:file_ext`.
|
||||||
* Bindings: `bind:trigger`, `bind:show_spinner`, `bind:show_percent`.
|
- Properties: `btn inner fragment`.
|
||||||
* Status: `started`, `downloading`, `finished`.
|
- Bindings: `bind:trigger`, `bind:show_spinner`, `bind:show_percent`.
|
||||||
* **`data_store`**: Component for interacting with data stores.
|
- Status: `started`, `downloading`, `finished`.
|
||||||
* **`ae_crud`**: Generic CRUD (Create, Read, Update, Delete) component.
|
- **`data_store`**: Component for interacting with data stores.
|
||||||
* **Note:** Needs simplification.
|
- **`ae_crud`**: Generic CRUD (Create, Read, Update, Delete) component.
|
||||||
* Properties: `obj`, `prop`, `current_value`.
|
- **Note:** Needs simplification.
|
||||||
* Bindings: `bind:value`, `bind:trigger`, `inner fragment`.
|
- Properties: `obj`, `prop`, `current_value`.
|
||||||
* **`ae_obj_prop_val`**: A wrapper for a function to manage object property values.
|
- Bindings: `bind:value`, `bind:trigger`, `inner fragment`.
|
||||||
* Bindings: `bind:obj_type`, `bind:obj_id`, `bind:obj_prop`, `bind:obj_value`, `bind:obj_new_value`, `bind:trigger`, `bind:show_spinner`, `bind:show_percent`.
|
- **`ae_obj_prop_val`**: A wrapper for a function to manage object property values.
|
||||||
* Status: `status`, `result`.
|
- Bindings: `bind:obj_type`, `bind:obj_id`, `bind:obj_prop`, `bind:obj_value`, `bind:obj_new_value`, `bind:trigger`, `bind:show_spinner`, `bind:show_percent`.
|
||||||
* **`sql_qry`**: Component for executing SQL queries.
|
- Status: `status`, `result`.
|
||||||
* **`obj_tbl`**: Object SQL results table or similar.
|
- **`sql_qry`**: Component for executing SQL queries.
|
||||||
* **`qr_scanner`**: Component for scanning QR codes.
|
- **`obj_tbl`**: Object SQL results table or similar.
|
||||||
* **`websocket`**: Component for WebSocket communication.
|
- **`qr_scanner`**: Component for scanning QR codes.
|
||||||
|
- **`websocket`**: Component for WebSocket communication.
|
||||||
|
|
||||||
### 1.3. Main / Module Components
|
### 1.3. Main / Module Components
|
||||||
|
|
||||||
These are components specific to main application sections or individual modules.
|
These are components specific to main application sections or individual modules.
|
||||||
* **`menu`**:
|
|
||||||
* **`options`**: Various settings, show/hide content and options, limit, sorting options.
|
- **`menu`**:
|
||||||
* **`actions`**: Various actions, sign in/out, email.
|
- **`options`**: Various settings, show/hide content and options, limit, sorting options.
|
||||||
|
- **`actions`**: Various actions, sign in/out, email.
|
||||||
|
|
||||||
### 1.4. Object Menu
|
### 1.4. Object Menu
|
||||||
|
|
||||||
A standardized menu for interacting with objects.
|
A standardized menu for interacting with objects.
|
||||||
* **Properties Displayed:** `id`, `name`, `group`, `priority`, `sort`, `alert`, `hide`, `enable`, `note`.
|
|
||||||
* **Future Properties:** `ext_id`, `ext_sys_id`, `code` (not yet ready).
|
- **Properties Displayed:** `id`, `name`, `group`, `priority`, `sort`, `alert`, `hide`, `enable`, `note`.
|
||||||
* **Actions:** `create`, `view`, `edit`, `update`, `hide`, `disable`, `delete`, `alert` (message), `archive` (not yet ready).
|
- **Future Properties:** `ext_id`, `ext_sys_id`, `code` (not yet ready).
|
||||||
* **Future Actions:** `copy`, `import`.
|
- **Actions:** `create`, `view`, `edit`, `update`, `hide`, `disable`, `delete`, `alert` (message), `archive` (not yet ready).
|
||||||
* **Sort Options:**
|
- **Future Actions:** `copy`, `import`.
|
||||||
* `[default]`: `group > priority > sort (ASC/DESC) > alert > name`
|
- **Sort Options:**
|
||||||
* `[sort_updated]`: `group > priority > sort (ASC/DESC) > alert > updated_on > created_on`
|
- `[default]`: `group > priority > sort (ASC/DESC) > alert > name`
|
||||||
* `[priority_updated]`: `group > priority > updated_on (ASC/DESC) > created_on`
|
- `[sort_updated]`: `group > priority > sort (ASC/DESC) > alert > updated_on > created_on`
|
||||||
* `[priority_name]`: `group > priority > name (ASC/DESC) > sort > alert > updated_on > created_on`
|
- `[priority_updated]`: `group > priority > updated_on (ASC/DESC) > created_on`
|
||||||
* `[name]`: `priority > name (ASC/DESC) > sort > alert > updated_on > created_on`
|
- `[priority_name]`: `group > priority > name (ASC/DESC) > sort > alert > updated_on > created_on`
|
||||||
* `[created_on]`: `priority > created_on (ASC/DESC)`
|
- `[name]`: `priority > name (ASC/DESC) > sort > alert > updated_on > created_on`
|
||||||
* `[updated_on]`: `priority > updated_on (ASC/DESC) > created_on`
|
- `[created_on]`: `priority > created_on (ASC/DESC)`
|
||||||
|
- `[updated_on]`: `priority > updated_on (ASC/DESC) > created_on`
|
||||||
|
|
||||||
## 2. Pop-ups
|
## 2. Pop-ups
|
||||||
|
|
||||||
Standardized structure for various types of pop-up elements.
|
Standardized structure for various types of pop-up elements.
|
||||||
* **`modal_header`**:
|
|
||||||
* `title`
|
- **`modal_header`**:
|
||||||
* `close` button
|
- `title`
|
||||||
* **`modal_main`**: Main content area of the modal.
|
- `close` button
|
||||||
* **`modal_meta`**: Meta-information section.
|
- **`modal_main`**: Main content area of the modal.
|
||||||
* **`modal_footer`**:
|
- **`modal_meta`**: Meta-information section.
|
||||||
* `close` button
|
- **`modal_footer`**:
|
||||||
* **`Pop-up Modal (blocking)`**: A modal that blocks interaction with the rest of the page.
|
- `close` button
|
||||||
* `modal position`
|
- **`Pop-up Modal (blocking)`**: A modal that blocks interaction with the rest of the page.
|
||||||
* **`Pop-up Modal Inline`**: A modal that appears inline with content.
|
- `modal position`
|
||||||
* `inline`, `inline-block`, `block` display options.
|
- **`Pop-up Modal Inline`**: A modal that appears inline with content.
|
||||||
* **`Pop-up Dialog`**: A dialog box.
|
- `inline`, `inline-block`, `block` display options.
|
||||||
* `dialog position`
|
- **`Pop-up Dialog`**: A dialog box.
|
||||||
|
- `dialog position`
|
||||||
|
|
||||||
## 3. Containers
|
## 3. Containers
|
||||||
|
|
||||||
Generic container types used for layout and grouping.
|
Generic container types used for layout and grouping.
|
||||||
|
|
||||||
### 3.1. Navigation
|
### 3.1. Navigation
|
||||||
* `link`
|
|
||||||
* `download`
|
- `link`
|
||||||
|
- `download`
|
||||||
|
|
||||||
### 3.2. Forms
|
### 3.2. Forms
|
||||||
* `save` button/action
|
|
||||||
* `clear value` action
|
- `save` button/action
|
||||||
* `set null value` action
|
- `clear value` action
|
||||||
|
- `set null value` action
|
||||||
|
|
||||||
### 3.3. Other Containers
|
### 3.3. Other Containers
|
||||||
* `help`: Blue themed container.
|
|
||||||
* `info`: Blue themed container.
|
- `help`: Blue themed container.
|
||||||
* `alert`: Yellow themed container.
|
- `info`: Blue themed container.
|
||||||
* `warning`: Orange themed container.
|
- `alert`: Yellow themed container.
|
||||||
* `error`: Red themed container.
|
- `warning`: Orange themed container.
|
||||||
* `message`: Green themed container.
|
- `error`: Red themed container.
|
||||||
|
- `message`: Green themed container.
|
||||||
|
|
||||||
## 4. CSS Styling for UI Elements
|
## 4. CSS Styling for UI Elements
|
||||||
* **Warning/Hide Buttons:** `variant-soft-warning hover:variant-filled-warning`
|
|
||||||
* **Error/Delete/Disable Buttons:** `variant-soft-error hover:variant-filled-error`
|
- **Warning/Hide Buttons:** `variant-soft-warning hover:variant-filled-warning`
|
||||||
* **Submenu:** `flex flex-row items-center justify-center gap-1`
|
- **Error/Delete/Disable Buttons:** `variant-soft-error hover:variant-filled-error`
|
||||||
|
- **Submenu:** `flex flex-row items-center justify-center gap-1`
|
||||||
|
|||||||
@@ -5,68 +5,86 @@ This document outlines the key data structures and their properties used within
|
|||||||
## 1. Object Properties and Fields
|
## 1. Object Properties and Fields
|
||||||
|
|
||||||
### 1.1. Core Standard Fields
|
### 1.1. Core Standard Fields
|
||||||
|
|
||||||
These fields are expected to be present in most Aether objects, providing a consistent base structure.
|
These fields are expected to be present in most Aether objects, providing a consistent base structure.
|
||||||
* `id`: Primary key for an object (internal use, often a UUID).
|
|
||||||
* `id_random`: Randomly generated ID for an object (often used for external exposure or URL parameters).
|
- `id`: Primary key for an object (internal use, often a UUID).
|
||||||
* `<object_type>_id_random`: Specific random ID for an object (e.g., `person_id_random`).
|
- `id_random`: Randomly generated ID for an object (often used for external exposure or URL parameters).
|
||||||
* `code`: Short, unique identifier.
|
- `<object_type>_id_random`: Specific random ID for an object (e.g., `person_id_random`).
|
||||||
* `name`: Display name.
|
- `code`: Short, unique identifier.
|
||||||
* `enable`: Boolean for active/inactive status.
|
- `name`: Display name.
|
||||||
* `hide`: Boolean for visibility.
|
- `enable`: Boolean for active/inactive status.
|
||||||
* `priority`: Numeric value for ordering.
|
- `hide`: Boolean for visibility.
|
||||||
* `sort`: Numeric value for ordering.
|
- `priority`: Numeric value for ordering.
|
||||||
* `group`: Categorization string.
|
- `sort`: Numeric value for ordering.
|
||||||
* `notes`: General notes/comments.
|
- `group`: Categorization string.
|
||||||
* `created_on`: Timestamp of creation.
|
- `notes`: General notes/comments.
|
||||||
* `updated_on`: Timestamp of last update.
|
- `created_on`: Timestamp of creation.
|
||||||
|
- `updated_on`: Timestamp of last update.
|
||||||
|
|
||||||
### 1.2. Special Use Fields
|
### 1.2. Special Use Fields
|
||||||
|
|
||||||
Fields with specific purposes or conditional usage across different object types.
|
Fields with specific purposes or conditional usage across different object types.
|
||||||
* `for_type`: Indicates the type of object this object is linked to (e.g., 'account', 'event').
|
|
||||||
* `for_id`: The ID of the object this object is linked to.
|
- `for_type`: Indicates the type of object this object is linked to (e.g., 'account', 'event').
|
||||||
* `archive_on`: Timestamp indicating when an object was archived.
|
- `for_id`: The ID of the object this object is linked to.
|
||||||
* `passcode`: A password or access code associated with an object.
|
- `archive_on`: Timestamp indicating when an object was archived.
|
||||||
* `external_id`: An identifier from an external system.
|
- `passcode`: A password or access code associated with an object.
|
||||||
|
- `external_id`: An identifier from an external system.
|
||||||
|
|
||||||
### 1.3. Configuration and JSON Fields
|
### 1.3. Configuration and JSON Fields
|
||||||
|
|
||||||
Fields designed to store structured data in JSON format.
|
Fields designed to store structured data in JSON format.
|
||||||
* `cfg_json`: Configuration data for an object, stored as a JSON string.
|
|
||||||
* `data_json`: General purpose data for an object, stored as a JSON string.
|
- `cfg_json`: Configuration data for an object, stored as a JSON string.
|
||||||
* `linked_li_json`: A list of linked items, stored as a JSON string.
|
- `data_json`: General purpose data for an object, stored as a JSON string.
|
||||||
|
- `linked_li_json`: A list of linked items, stored as a JSON string.
|
||||||
|
|
||||||
### 1.4. Special Generated Fields (Client-side)
|
### 1.4. Special Generated Fields (Client-side)
|
||||||
|
|
||||||
These fields are generated on the client-side, primarily for facilitating UI logic, such as sorting. They are not typically stored in the backend database.
|
These fields are generated on the client-side, primarily for facilitating UI logic, such as sorting. They are not typically stored in the backend database.
|
||||||
* `tmp_sort_1`: Temporary sort field 1.
|
|
||||||
* `tmp_sort_2`: Temporary sort field 2.
|
- `tmp_sort_1`: Temporary sort field 1.
|
||||||
* `tmp_sort_3`: Temporary sort field 3.
|
- `tmp_sort_2`: Temporary sort field 2.
|
||||||
|
- `tmp_sort_3`: Temporary sort field 3.
|
||||||
|
|
||||||
### 1.5. Future Standard Fields
|
### 1.5. Future Standard Fields
|
||||||
|
|
||||||
A list of potential future standard fields, often prefixed with `obj_`. These are conceptual and represent planned expansions to the data model.
|
A list of potential future standard fields, often prefixed with `obj_`. These are conceptual and represent planned expansions to the data model.
|
||||||
* `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`.
|
|
||||||
|
- `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`.
|
||||||
|
|
||||||
## 2. Data Sorting
|
## 2. Data Sorting
|
||||||
|
|
||||||
Standardized sorting orders are applied across various data lists to ensure consistent presentation.
|
Standardized sorting orders are applied across various data lists to ensure consistent presentation.
|
||||||
* **Default/General Sorting:** `group > priority > sort > updated_on/created_on`
|
|
||||||
* **Specific Sorting (e.g., for time-based events):** `type > start_date/time > code or name`
|
- **Default/General Sorting:** `group > priority > sort > updated_on/created_on`
|
||||||
|
- **Specific Sorting (e.g., for time-based events):** `type > start_date/time > code or name`
|
||||||
|
|
||||||
## 3. Data Storage Mechanisms
|
## 3. Data Storage Mechanisms
|
||||||
|
|
||||||
### 3.1. Local Storage
|
### 3.1. Local Storage
|
||||||
|
|
||||||
Used for client-side persistence of various application states and configurations.
|
Used for client-side persistence of various application states and configurations.
|
||||||
* `api`: Stores API-related settings and tokens.
|
|
||||||
* `app`: Stores global application settings and preferences.
|
- `api`: Stores API-related settings and tokens.
|
||||||
* `core`: Stores settings and data specific to core modules.
|
- `app`: Stores global application settings and preferences.
|
||||||
* `<module>`: Stores settings and data specific to extended modules (e.g., `journals`, `events`).
|
- `core`: Stores settings and data specific to core modules.
|
||||||
* `<custom>`: Stores settings and data specific to custom modules (e.g., `idaa`).
|
- `<module>`: Stores settings and data specific to extended modules (e.g., `journals`, `events`).
|
||||||
|
- `<custom>`: Stores settings and data specific to custom modules (e.g., `idaa`).
|
||||||
|
|
||||||
### 3.2. IndexedDB (Dexie.js)
|
### 3.2. IndexedDB (Dexie.js)
|
||||||
|
|
||||||
Used for more structured client-side data storage, often for caching, offline capabilities, and larger datasets.
|
Used for more structured client-side data storage, often for caching, offline capabilities, and larger datasets.
|
||||||
* `ae_core_db`: The primary Dexie database instance for core application data.
|
|
||||||
* `<module>`: Module-specific database instances (e.g., `db_journals` for journal data).
|
- `ae_core_db`: The primary Dexie database instance for core application data.
|
||||||
* `<custom>`: Custom module-specific database instances (none currently defined, but reserved for future use).
|
- `<module>`: Module-specific database instances (e.g., `db_journals` for journal data).
|
||||||
|
- `<custom>`: Custom module-specific database instances (none currently defined, but reserved for future use).
|
||||||
|
|
||||||
### 3.3. IndexedDB LiveQuery Usage
|
### 3.3. IndexedDB LiveQuery Usage
|
||||||
|
|
||||||
Dexie's `liveQuery` is used to provide reactive data streams from IndexedDB.
|
Dexie's `liveQuery` is used to provide reactive data streams from IndexedDB.
|
||||||
* `lq__xyz_obj`: Represents a read-only liveQuery result for a single object.
|
|
||||||
* `lqw__xyz_obj`: Represents a writable liveQuery result, typically used for forms and data binding.
|
- `lq__xyz_obj`: Represents a read-only liveQuery result for a single object.
|
||||||
* **Note:** When using `lqw__xyz_obj`, developers must carefully manage updates to avoid conflicts with the underlying liveQuery and ensure data integrity.
|
- `lqw__xyz_obj`: Represents a writable liveQuery result, typically used for forms and data binding.
|
||||||
|
- **Note:** When using `lqw__xyz_obj`, developers must carefully manage updates to avoid conflicts with the underlying liveQuery and ensure data integrity.
|
||||||
|
|||||||
60
GEMINI.md
60
GEMINI.md
@@ -3,31 +3,35 @@
|
|||||||
This project is a Svelte and SvelteKit based application, part of the Aether (AE) system. It uses Tailwind CSS and Skeleton for styling and some elements. This is the frontend UI/UX. The backend API uses Python FastAPI.
|
This project is a Svelte and SvelteKit based application, part of the Aether (AE) system. It uses Tailwind CSS and Skeleton for styling and some elements. This is the frontend UI/UX. The backend API uses Python FastAPI.
|
||||||
|
|
||||||
Core Aether modules
|
Core Aether modules
|
||||||
* accounts - client account, not user account
|
|
||||||
* hosted_files
|
- accounts - client account, not user account
|
||||||
* people
|
- hosted_files
|
||||||
* users
|
- people
|
||||||
* sites and site_domains
|
- users
|
||||||
|
- sites and site_domains
|
||||||
|
|
||||||
Additional Aether modules
|
Additional Aether modules
|
||||||
* events
|
|
||||||
* presentation management - import the program data (events, session, presentations, presenters, event files, locations/rooms, devices)
|
- events
|
||||||
* launcher - Technically this is used with presentation management. It is part of the native app that uses Electron. One of the libraries is for functions that only work when the site is opened in an Electron app. For example the regular browser can not move files around on the local computer or run local commands.
|
- presentation management - import the program data (events, session, presentations, presenters, event files, locations/rooms, devices)
|
||||||
* badge printing
|
- launcher - Technically this is used with presentation management. It is part of the native app that uses Electron. One of the libraries is for functions that only work when the site is opened in an Electron app. For example the regular browser can not move files around on the local computer or run local commands.
|
||||||
* lead retrieval - attendee tracking; QR codes
|
- badge printing
|
||||||
* journals - journal, documentation, notes, diary, blog, etc
|
- lead retrieval - attendee tracking; QR codes
|
||||||
* idaa - One of my clients
|
- journals - journal, documentation, notes, diary, blog, etc
|
||||||
|
- idaa - One of my clients
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
* TODO.md
|
|
||||||
* Svelte - Introducing runes - https://svelte.dev/blog/runes
|
- TODO.md
|
||||||
* Svelte - Breaking changes in runes mode - https://svelte.dev/docs/svelte/v5-migration-guide#Breaking-changes-in-runes-mode
|
- Svelte - Introducing runes - https://svelte.dev/blog/runes
|
||||||
* Dexie.js - Getting Started - https://dexie.org/docs/Tutorial/Getting-started
|
- Svelte - Breaking changes in runes mode - https://svelte.dev/docs/svelte/v5-migration-guide#Breaking-changes-in-runes-mode
|
||||||
* Dexie.js - API Quick Reference - https://dexie.org/docs/API-Reference#quick-reference
|
- Dexie.js - Getting Started - https://dexie.org/docs/Tutorial/Getting-started
|
||||||
|
- Dexie.js - API Quick Reference - https://dexie.org/docs/API-Reference#quick-reference
|
||||||
|
|
||||||
## Ignored Directories
|
## Ignored Directories
|
||||||
|
|
||||||
The following directories are ignored for various operations (e.g., search, file listing) to focus on relevant source code:
|
The following directories are ignored for various operations (e.g., search, file listing) to focus on relevant source code:
|
||||||
|
|
||||||
- `build`
|
- `build`
|
||||||
- `node_modules`
|
- `node_modules`
|
||||||
- `tests`
|
- `tests`
|
||||||
@@ -44,16 +48,16 @@ The refactoring strategy involved creating a local, non-exported `_process_gener
|
|||||||
|
|
||||||
**Key aspects of the refactoring:**
|
**Key aspects of the refactoring:**
|
||||||
|
|
||||||
* **In-file Generic Helper (`_process_generic_props`):** This function handles common data transformations:
|
- **In-file Generic Helper (`_process_generic_props`):** This function handles common data transformations:
|
||||||
* **`*_random` ID Aliasing:** It automatically iterates over object keys and creates a non-suffixed alias for any key ending in `_random` (e.g., `person_id_random` becomes `person_id`). This is crucial for client-side logic that expects standard ID fields.
|
- **`*_random` ID Aliasing:** It automatically iterates over object keys and creates a non-suffixed alias for any key ending in `_random` (e.g., `person_id_random` becomes `person_id`). This is crucial for client-side logic that expects standard ID fields.
|
||||||
* **`tmp_sort` Field Generation:** It creates a set of basic `tmp_sort` fields for client-side sorting.
|
- **`tmp_sort` Field Generation:** It creates a set of basic `tmp_sort` fields for client-side sorting.
|
||||||
|
|
||||||
* **`specific_processor` Callback:** Module-specific logic is handled by a `specific_processor` callback function passed to the `_process_generic_props` helper. This allows for:
|
- **`specific_processor` Callback:** Module-specific logic is handled by a `specific_processor` callback function passed to the `_process_generic_props` helper. This allows for:
|
||||||
* **Unique `tmp_sort` Logic:** Modules can override the default `tmp_sort` fields with their own specific sorting requirements.
|
- **Unique `tmp_sort` Logic:** Modules can override the default `tmp_sort` fields with their own specific sorting requirements.
|
||||||
* **Content Processing:** Asynchronous operations like Markdown parsing (using `marked.parse`) are handled within the `specific_processor` for the relevant modules (e.g., `ae_journals__journal_entry.ts`).
|
- **Content Processing:** Asynchronous operations like Markdown parsing (using `marked.parse`) are handled within the `specific_processor` for the relevant modules (e.g., `ae_journals__journal_entry.ts`).
|
||||||
* **Other Special Cases:** Any other module-specific data transformations are handled in this callback.
|
- **Other Special Cases:** Any other module-specific data transformations are handled in this callback.
|
||||||
|
|
||||||
* **`core__crud_generic.ts` Cleanup:** The generic CRUD functions in `src/lib/ae_core/core__crud_generic.ts` were simplified:
|
- **`core__crud_generic.ts` Cleanup:** The generic CRUD functions in `src/lib/ae_core/core__crud_generic.ts` were simplified:
|
||||||
* The `process_ae_obj__props` function in this file was deprecated.
|
- The `process_ae_obj__props` function in this file was deprecated.
|
||||||
* All calls to `process_ae_obj__props` and `db_save_ae_obj_li__ae_obj` were removed from the generic CRUD functions (`load_ae_obj_id`, `load_ae_obj_li`, etc.).
|
- All calls to `process_ae_obj__props` and `db_save_ae_obj_li__ae_obj` were removed from the generic CRUD functions (`load_ae_obj_id`, `load_ae_obj_li`, etc.).
|
||||||
* These functions are now responsible only for API interaction, delegating all data processing and caching to the module-specific functions that call them. This enforces a cleaner separation of concerns.
|
- These functions are now responsible only for API interaction, delegating all data processing and caching to the module-specific functions that call them. This enforces a cleaner separation of concerns.
|
||||||
|
|||||||
@@ -1,83 +1,93 @@
|
|||||||
# Aether Project Naming Conventions
|
# Aether Project Naming Conventions
|
||||||
|
|
||||||
## 1. General Principles
|
## 1. General Principles
|
||||||
* **Clarity:** Names should clearly convey their purpose and meaning.
|
|
||||||
* **Consistency:** Adhere strictly to these guidelines across the entire codebase.
|
- **Clarity:** Names should clearly convey their purpose and meaning.
|
||||||
* **Readability:** Prioritize names that are easy to read and understand.
|
- **Consistency:** Adhere strictly to these guidelines across the entire codebase.
|
||||||
* **Conciseness:** Avoid unnecessary verbosity, but not at the expense of clarity.
|
- **Readability:** Prioritize names that are easy to read and understand.
|
||||||
|
- **Conciseness:** Avoid unnecessary verbosity, but not at the expense of clarity.
|
||||||
|
|
||||||
## 2. File Naming
|
## 2. File Naming
|
||||||
* **Logic/Service Files:** `ae_<module>__<concept>.ts` (e.g., `ae_core__account.ts`, `ae_events__event.ts`)
|
|
||||||
* **Database Definition Files:** `db_<module>.ts` (e.g., `db_core.ts`, `db_journals.ts`)
|
- **Logic/Service Files:** `ae_<module>__<concept>.ts` (e.g., `ae_core__account.ts`, `ae_events__event.ts`)
|
||||||
* **Svelte Store Files:** `ae_<module>_stores.ts` (e.g., `ae_core_stores.ts`, `ae_journals_stores.ts`)
|
- **Database Definition Files:** `db_<module>.ts` (e.g., `db_core.ts`, `db_journals.ts`)
|
||||||
* **Svelte Components:**
|
- **Svelte Store Files:** `ae_<module>_stores.ts` (e.g., `ae_core_stores.ts`, `ae_journals_stores.ts`)
|
||||||
* **Module-specific components:** `ae_comp__<module>__<component_name>.svelte` (e.g., `ae_comp__events__event_card.svelte`)
|
- **Svelte Components:**
|
||||||
* **Generic/reusable components:** `element_<component_name>.svelte` (e.g., `element_input_file.svelte`, `element_qr_scanner_v2.svelte`)
|
- **Module-specific components:** `ae_comp__<module>__<component_name>.svelte` (e.g., `ae_comp__events__event_card.svelte`)
|
||||||
* **SvelteKit Routes:** Follow SvelteKit's standard routing conventions (e.g., `+page.svelte`, `+layout.svelte`, `[id]/+page.svelte`).
|
- **Generic/reusable components:** `element_<component_name>.svelte` (e.g., `element_input_file.svelte`, `element_qr_scanner_v2.svelte`)
|
||||||
* **CSS Files:** `ae-<module>-<purpose>.css` (e.g., `ae-c-idaa-light.css`, `ae-osit-default.css`)
|
- **SvelteKit Routes:** Follow SvelteKit's standard routing conventions (e.g., `+page.svelte`, `+layout.svelte`, `[id]/+page.svelte`).
|
||||||
|
- **CSS Files:** `ae-<module>-<purpose>.css` (e.g., `ae-c-idaa-light.css`, `ae-osit-default.css`)
|
||||||
|
|
||||||
## 3. Function and Variable Naming
|
## 3. Function and Variable Naming
|
||||||
* **Style:** Strictly `snake_case` for all function and variable names.
|
|
||||||
* **Deprecated:** `camelCase` should be refactored to `snake_case`.
|
- **Style:** Strictly `snake_case` for all function and variable names.
|
||||||
* **Prefixes:**
|
- **Deprecated:** `camelCase` should be refactored to `snake_case`.
|
||||||
* `load_ae_obj_id__<object_type>`: For loading a single Aether object by ID.
|
- **Prefixes:**
|
||||||
* `load_ae_obj_li__<object_type>`: For loading a list of Aether objects.
|
- `load_ae_obj_id__<object_type>`: For loading a single Aether object by ID.
|
||||||
* `create_ae_obj__<object_type>`: For creating an Aether object.
|
- `load_ae_obj_li__<object_type>`: For loading a list of Aether objects.
|
||||||
* `update_ae_obj__<object_type>`: For updating an Aether object.
|
- `create_ae_obj__<object_type>`: For creating an Aether object.
|
||||||
* `delete_ae_obj_id__<object_type>`: For deleting an Aether object by ID.
|
- `update_ae_obj__<object_type>`: For updating an Aether object.
|
||||||
* `db_save_ae_obj_li__<object_type>`: For saving a list of Aether objects to IndexedDB.
|
- `delete_ae_obj_id__<object_type>`: For deleting an Aether object by ID.
|
||||||
* `db_update_ae_obj_id__<object_type>`: For updating an Aether object in IndexedDB.
|
- `db_save_ae_obj_li__<object_type>`: For saving a list of Aether objects to IndexedDB.
|
||||||
* `process_ae_obj__<object_type>_props`: For module-specific data transformation functions.
|
- `db_update_ae_obj_id__<object_type>`: For updating an Aether object in IndexedDB.
|
||||||
* **Deprecated:** Ambiguous `handle_` prefixes should be replaced with more descriptive `snake_case` names (e.g., `handle_submit_form` -> `submit_form`).
|
- `process_ae_obj__<object_type>_props`: For module-specific data transformation functions.
|
||||||
|
- **Deprecated:** Ambiguous `handle_` prefixes should be replaced with more descriptive `snake_case` names (e.g., `handle_submit_form` -> `submit_form`).
|
||||||
|
|
||||||
## 4. Object and Property Naming
|
## 4. Object and Property Naming
|
||||||
* **Singularity:** Use singular nouns for objects and properties (e.g., `example.id`, not `examples.id`).
|
|
||||||
* **IDs:**
|
- **Singularity:** Use singular nouns for objects and properties (e.g., `example.id`, not `examples.id`).
|
||||||
* `id`: Primary key for an object (internal use, often a UUID).
|
- **IDs:**
|
||||||
* `<object_type>_id`: Specific ID for an object (e.g., `person_id`).
|
- `id`: Primary key for an object (internal use, often a UUID).
|
||||||
* `<object_type>_id_random`: Randomly generated ID for an object (often used for external exposure or URL parameters).
|
- `<object_type>_id`: Specific ID for an object (e.g., `person_id`).
|
||||||
* `account_id`, `site_id`, `user_id`, etc.: Foreign keys.
|
- `<object_type>_id_random`: Randomly generated ID for an object (often used for external exposure or URL parameters).
|
||||||
* **Common Properties:**
|
- `account_id`, `site_id`, `user_id`, etc.: Foreign keys.
|
||||||
* `code`: Short, unique identifier.
|
- **Common Properties:**
|
||||||
* `name`: Display name.
|
- `code`: Short, unique identifier.
|
||||||
* `description`: Longer text description.
|
- `name`: Display name.
|
||||||
* `enable`: Boolean for active/inactive status.
|
- `description`: Longer text description.
|
||||||
* `hide`: Boolean for visibility.
|
- `enable`: Boolean for active/inactive status.
|
||||||
* `priority`: Numeric value for ordering.
|
- `hide`: Boolean for visibility.
|
||||||
* `sort`: Numeric value for ordering.
|
- `priority`: Numeric value for ordering.
|
||||||
* `group`: Categorization string.
|
- `sort`: Numeric value for ordering.
|
||||||
* `notes`: General notes/comments.
|
- `group`: Categorization string.
|
||||||
* `created_on`: Timestamp of creation.
|
- `notes`: General notes/comments.
|
||||||
* `updated_on`: Timestamp of last update.
|
- `created_on`: Timestamp of creation.
|
||||||
* **Special Use Properties:** `for_type`, `for_id`, `archive_on`, `passcode`, `external_id`.
|
- `updated_on`: Timestamp of last update.
|
||||||
* **Config/JSON Properties:** `cfg_json`, `data_json`, `linked_li_json`.
|
- **Special Use Properties:** `for_type`, `for_id`, `archive_on`, `passcode`, `external_id`.
|
||||||
* **Special Generated Fields (Client-side):** `tmp_sort_1`, `tmp_sort_2`, `tmp_sort_3` (for client-side sorting).
|
- **Config/JSON Properties:** `cfg_json`, `data_json`, `linked_li_json`.
|
||||||
|
- **Special Generated Fields (Client-side):** `tmp_sort_1`, `tmp_sort_2`, `tmp_sort_3` (for client-side sorting).
|
||||||
|
|
||||||
## 5. List Suffixes
|
## 5. List Suffixes
|
||||||
* **Simple Arrays:** Use `_li` suffix for simple, unordered arrays (e.g., `user_li`, `hosted_file_id_li`).
|
|
||||||
* **Key-Value Maps/Objects:** Use `_kv` suffix for key-value objects/maps (e.g., `user_kv`, `hosted_file_obj_kv`).
|
- **Simple Arrays:** Use `_li` suffix for simple, unordered arrays (e.g., `user_li`, `hosted_file_id_li`).
|
||||||
|
- **Key-Value Maps/Objects:** Use `_kv` suffix for key-value objects/maps (e.g., `user_kv`, `hosted_file_obj_kv`).
|
||||||
|
|
||||||
## 6. Interface and Type Naming
|
## 6. Interface and Type Naming
|
||||||
* **Style:** Use `PascalCase` for interface and type names (e.g., `Account`, `HostedFile`, `GenericCrudArgs`).
|
|
||||||
|
- **Style:** Use `PascalCase` for interface and type names (e.g., `Account`, `HostedFile`, `GenericCrudArgs`).
|
||||||
|
|
||||||
## 7. Constants
|
## 7. Constants
|
||||||
* **Style:** Use `SCREAMING_SNAKE_CASE` for constants (e.g., `MAX_RETRIES`, `DEFAULT_TIMEOUT`).
|
|
||||||
|
- **Style:** Use `SCREAMING_SNAKE_CASE` for constants (e.g., `MAX_RETRIES`, `DEFAULT_TIMEOUT`).
|
||||||
|
|
||||||
## 8. CSS Classes and IDs
|
## 8. CSS Classes and IDs
|
||||||
* **Style:** Use `kebab-case` for CSS classes and IDs (e.g., `my-component-class`, `main-header-id`).
|
|
||||||
|
- **Style:** Use `kebab-case` for CSS classes and IDs (e.g., `my-component-class`, `main-header-id`).
|
||||||
|
|
||||||
## 9. Data Sorting
|
## 9. Data Sorting
|
||||||
* **Standard Order:** `group > priority > sort > updated_on/created_on`
|
|
||||||
* **Specific Order:** `type > start_date/time > code or name`
|
- **Standard Order:** `group > priority > sort > updated_on/created_on`
|
||||||
|
- **Specific Order:** `type > start_date/time > code or name`
|
||||||
|
|
||||||
## 10. Local Storage and IndexedDB Keys
|
## 10. Local Storage and IndexedDB Keys
|
||||||
* **Local Storage:**
|
|
||||||
* `api`
|
- **Local Storage:**
|
||||||
* `app` (global)
|
- `api`
|
||||||
* `core` (core modules)
|
- `app` (global)
|
||||||
* `<module>` (extended modules)
|
- `core` (core modules)
|
||||||
* `<custom>` (custom modules)
|
- `<module>` (extended modules)
|
||||||
* **IndexedDB:**
|
- `<custom>` (custom modules)
|
||||||
* `ae_core_db`
|
- **IndexedDB:**
|
||||||
* `<module>`
|
- `ae_core_db`
|
||||||
* `<custom>`
|
- `<module>`
|
||||||
|
- `<custom>`
|
||||||
|
|||||||
@@ -1,120 +1,137 @@
|
|||||||
# AE UI Components, Layout, and Style Standards (HTML/CSS)
|
# AE UI Components, Layout, and Style Standards (HTML/CSS)
|
||||||
|
|
||||||
## Aether Components
|
## Aether Components
|
||||||
|
|
||||||
### System Components
|
### System Components
|
||||||
* [header]
|
|
||||||
* [main/module]s
|
- [header]
|
||||||
* [footer]
|
- [main/module]s
|
||||||
* [app] refresh, clear IDB, clear local storage (settings), iframe toggle (also updates URL param), copy URL, generate and show QR
|
- [footer]
|
||||||
* [menu][mode] edit, more (all or details)
|
- [app] refresh, clear IDB, clear local storage (settings), iframe toggle (also updates URL param), copy URL, generate and show QR
|
||||||
* [menu][access_type] passcode input, clear
|
- [menu][mode] edit, more (all or details)
|
||||||
* [menu][user] sign in/out, reset password, email link, change username and email
|
- [menu][access_type] passcode input, clear
|
||||||
* [menu][theme] mode (light/dark), name (theme list)
|
- [menu][user] sign in/out, reset password, email link, change username and email
|
||||||
* [debug] toggle (also updates URL param), show core and module storages, manually set init timestamp
|
- [menu][theme] mode (light/dark), name (theme list)
|
||||||
* [scroll_to] top, page up, page down, bottom
|
- [debug] toggle (also updates URL param), show core and module storages, manually set init timestamp
|
||||||
|
- [scroll_to] top, page up, page down, bottom
|
||||||
|
|
||||||
### Core Components
|
### Core Components
|
||||||
* [copy_btn] clipboard, bind:value, btn_text, btn_html
|
|
||||||
* [txt_editor] textarea
|
- [copy_btn] clipboard, bind:value, btn_text, btn_html
|
||||||
* [md_editor] CodeMirror, ShadEditor TipTap (need to remove)
|
- [txt_editor] textarea
|
||||||
* [html_editor]
|
- [md_editor] CodeMirror, ShadEditor TipTap (need to remove)
|
||||||
* [media_player]
|
- [html_editor]
|
||||||
* hosted_file archive_content media_player,
|
- [media_player]
|
||||||
* bind:host_id,
|
- hosted_file archive_content media_player,
|
||||||
* bind:media_type
|
- bind:host_id,
|
||||||
* status - stopped, paused, playing
|
- bind:media_type
|
||||||
* [hosted_file_li] manage_hosted_file_li, make available for selection
|
- status - stopped, paused, playing
|
||||||
* [hosted_file_link_to] list links per object, bind:add link, bind:remove link
|
- [hosted_file_li] manage_hosted_file_li, make available for selection
|
||||||
* [upload_to_host] - input_hosted_file; needs to handle multiple files
|
- [hosted_file_link_to] list links per object, bind:add link, bind:remove link
|
||||||
* link_type,
|
- [upload_to_host] - input_hosted_file; needs to handle multiple files
|
||||||
* link_id,
|
- link_type,
|
||||||
* inner fragment - label html
|
- link_id,
|
||||||
* bind:trigger
|
- inner fragment - label html
|
||||||
* bind:show_spinner
|
- bind:trigger
|
||||||
* bind:show_percent
|
- bind:show_spinner
|
||||||
* status
|
- bind:show_percent
|
||||||
* result - started, uploading, finished
|
- status
|
||||||
* [upload_file_tbl] input_hosted_file_tbl, check for dup file hash, remove from list
|
- result - started, uploading, finished
|
||||||
* [download_from_host]
|
- [upload_file_tbl] input_hosted_file_tbl, check for dup file hash, remove from list
|
||||||
* bind:host_file_id
|
- [download_from_host]
|
||||||
* bind:filename
|
- bind:host_file_id
|
||||||
* bind:file_ext
|
- bind:filename
|
||||||
* btn inner fragment
|
- bind:file_ext
|
||||||
* bind:trigger
|
- btn inner fragment
|
||||||
* bind:show_spinner
|
- bind:trigger
|
||||||
* bind:show_percent
|
- bind:show_spinner
|
||||||
* status
|
- bind:show_percent
|
||||||
* result - started, downloading, finished
|
- status
|
||||||
* [data_store]
|
- result - started, downloading, finished
|
||||||
* [ae_crud] need to simplify! obj, prop, current_value, bind:value, bind:trigger, inner fragment
|
- [data_store]
|
||||||
* [ae_obj_prop_val] - essentially a wrapper for the function
|
- [ae_crud] need to simplify! obj, prop, current_value, bind:value, bind:trigger, inner fragment
|
||||||
* bind:obj_type
|
- [ae_obj_prop_val] - essentially a wrapper for the function
|
||||||
* bind:obj_id
|
- bind:obj_type
|
||||||
* bind:obj_prop
|
- bind:obj_id
|
||||||
* bind:obj_value
|
- bind:obj_prop
|
||||||
* bind:obj_new_value
|
- bind:obj_value
|
||||||
* bind:trigger
|
- bind:obj_new_value
|
||||||
* bind:show_spinner
|
- bind:trigger
|
||||||
* bind:show_percent
|
- bind:show_spinner
|
||||||
* status
|
- bind:show_percent
|
||||||
* result
|
- status
|
||||||
* [sql_qry]
|
- result
|
||||||
* [obj_tbl] obj sql results tbl or similar
|
- [sql_qry]
|
||||||
* [qr_scanner]
|
- [obj_tbl] obj sql results tbl or similar
|
||||||
* [websocket]
|
- [qr_scanner]
|
||||||
|
- [websocket]
|
||||||
|
|
||||||
### Main / Module Components
|
### Main / Module Components
|
||||||
* [menu][options] various settings, show/hide content and options, limit, sorting options, etc
|
|
||||||
* [menu][actions] various actions, sign in/out, email
|
- [menu][options] various settings, show/hide content and options, limit, sorting options, etc
|
||||||
|
- [menu][actions] various actions, sign in/out, email
|
||||||
|
|
||||||
### Object Menu
|
### Object Menu
|
||||||
* properties: id, name, group, priority, sort, alert, hide, enable, note
|
|
||||||
* future properties: ext_id (not ready yet), ext_sys_id (not ready yet), code (not ready yet)
|
- properties: id, name, group, priority, sort, alert, hide, enable, note
|
||||||
* actions: create, view, edit, update, hide, disable, delete, alert (message), archive (not ready yet)
|
- future properties: ext_id (not ready yet), ext_sys_id (not ready yet), code (not ready yet)
|
||||||
* future actions: copy, import
|
- actions: create, view, edit, update, hide, disable, delete, alert (message), archive (not ready yet)
|
||||||
* sort options:
|
- future actions: copy, import
|
||||||
* [default] group > priority > sort (ASC/DESC) > alert > name
|
- sort options:
|
||||||
* [sort_updated] group > priority > sort (ASC/DESC) > alert > updated_on > created_on
|
- [default] group > priority > sort (ASC/DESC) > alert > name
|
||||||
* [priority_updated] group > priority > updated_on (ASC/DESC) > created_on
|
- [sort_updated] group > priority > sort (ASC/DESC) > alert > updated_on > created_on
|
||||||
* [priority_name] group > priority > name (ASC/DESC) > sort > alert > updated_on > created_on
|
- [priority_updated] group > priority > updated_on (ASC/DESC) > created_on
|
||||||
* [name] priority > name (ASC/DESC) > sort > alert > updated_on > created_on
|
- [priority_name] group > priority > name (ASC/DESC) > sort > alert > updated_on > created_on
|
||||||
* [created_on] priority > created_on (ASC/DESC)
|
- [name] priority > name (ASC/DESC) > sort > alert > updated_on > created_on
|
||||||
* [updated_on] priority > updated_on (ASC/DESC) > created_on
|
- [created_on] priority > created_on (ASC/DESC)
|
||||||
|
- [updated_on] priority > updated_on (ASC/DESC) > created_on
|
||||||
|
|
||||||
### Pop-ups:
|
### Pop-ups:
|
||||||
* modal_header
|
|
||||||
* title
|
- modal_header
|
||||||
* close
|
- title
|
||||||
* modal_main
|
- close
|
||||||
* modal_meta
|
- modal_main
|
||||||
* modal_footer
|
- modal_meta
|
||||||
* close
|
- modal_footer
|
||||||
|
- close
|
||||||
|
|
||||||
#### Pop-up Modal (blocking)
|
#### Pop-up Modal (blocking)
|
||||||
* modal position
|
|
||||||
|
- modal position
|
||||||
|
|
||||||
#### Pop-up Modal Inline
|
#### Pop-up Modal Inline
|
||||||
* inline, inline-block, block
|
|
||||||
|
- inline, inline-block, block
|
||||||
|
|
||||||
#### Pop-up Dialog
|
#### Pop-up Dialog
|
||||||
* dialog position
|
|
||||||
|
- dialog position
|
||||||
|
|
||||||
## Containers
|
## Containers
|
||||||
|
|
||||||
### Navigation
|
### Navigation
|
||||||
* link
|
|
||||||
* download
|
- link
|
||||||
|
- download
|
||||||
|
|
||||||
### Forms
|
### Forms
|
||||||
* save
|
|
||||||
* clear value
|
- save
|
||||||
* set null value
|
- clear value
|
||||||
|
- set null value
|
||||||
|
|
||||||
### Other Containers
|
### Other Containers
|
||||||
* help - blue
|
|
||||||
* info - blue
|
- help - blue
|
||||||
* alert - yellow
|
- info - blue
|
||||||
* warning - orange
|
- alert - yellow
|
||||||
* error - red
|
- warning - orange
|
||||||
* message - green
|
- error - red
|
||||||
|
- message - green
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Need to organize:
|
## Need to organize:
|
||||||
* lu: id, account_id, for_obj_id, code, name, description, group, sort, priority, enable, perm_level
|
|
||||||
|
- lu: id, account_id, for_obj_id, code, name, description, group, sort, priority, enable, perm_level
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
# One Sky IT's Aether App - UI and UX Guidelines and Rules
|
# One Sky IT's Aether App - UI and UX Guidelines and Rules
|
||||||
|
|
||||||
|
|
||||||
## General
|
## General
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
#### layout header
|
#### layout header
|
||||||
|
|
||||||
#### layout footer
|
#### layout footer
|
||||||
|
|
||||||
### Journals
|
### Journals
|
||||||
|
|
||||||
#### buttons
|
#### buttons
|
||||||
|
|
||||||
##### alert
|
##### alert
|
||||||
|
|
||||||
##### info
|
##### info
|
||||||
@@ -15,52 +19,62 @@
|
|||||||
##### priority, flag
|
##### priority, flag
|
||||||
|
|
||||||
##### warning, hide
|
##### warning, hide
|
||||||
|
|
||||||
```css
|
```css
|
||||||
variant-soft-warning hover:variant-filled-warning
|
variant-soft-warning hover:variant-filled-warning
|
||||||
```
|
```
|
||||||
|
|
||||||
##### error, delete, disable
|
##### error, delete, disable
|
||||||
|
|
||||||
```css
|
```css
|
||||||
variant-soft-error hover:variant-filled-error
|
variant-soft-error hover:variant-filled-error
|
||||||
```
|
```
|
||||||
|
|
||||||
#### new root layout header
|
#### new root layout header
|
||||||
|
|
||||||
#### submenu
|
#### submenu
|
||||||
|
|
||||||
```css
|
```css
|
||||||
flex flex-row items-center justify-center gap-1
|
flex flex-row items-center justify-center gap-1
|
||||||
```
|
```
|
||||||
#### new layout footer
|
|
||||||
|
|
||||||
|
#### new layout footer
|
||||||
|
|
||||||
## Svelte 5 and SvelteKit v2 (framework and routing)
|
## Svelte 5 and SvelteKit v2 (framework and routing)
|
||||||
|
|
||||||
|
|
||||||
## Tailwind 3.x CSS (styles)
|
## 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
|
|
||||||
|
|
||||||
|
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)
|
## CodeMirror 6.x (text and code editor)
|
||||||
* https://codemirror.net
|
|
||||||
|
- https://codemirror.net
|
||||||
|
|
||||||
## ShadCN (Tailwind Components)
|
## ShadCN (Tailwind Components)
|
||||||
* https://ui.shadcn.com/docs
|
|
||||||
* https://github.com/shadcn-ui/ui
|
|
||||||
|
|
||||||
|
- https://ui.shadcn.com/docs
|
||||||
|
- https://github.com/shadcn-ui/ui
|
||||||
|
|
||||||
## Skeleton (Design System, Tailwind Components, Functional Components)
|
## Skeleton (Design System, Tailwind Components, Functional Components)
|
||||||
|
|
||||||
Waiting to upgrade to Skeleton v3. Mostly because of the Tailwind 4.x upgrade needed for ShadCN.
|
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
|
|
||||||
|
- https://www.skeleton.dev/docs/get-started/migrate-from-v2
|
||||||
|
|
||||||
## Flowbite (Tailwind Components)
|
## Flowbite (Tailwind Components)
|
||||||
|
|
||||||
|
|
||||||
## Lucide Icons (SVG Icons)
|
## Lucide Icons (SVG Icons)
|
||||||
* https://lucide.dev/icons/
|
|
||||||
|
|
||||||
|
- https://lucide.dev/icons/
|
||||||
|
|
||||||
## Markdown
|
## Markdown
|
||||||
Using marked for Markdown parsing.
|
|
||||||
* https://marked.js.org/
|
|
||||||
|
|
||||||
|
Using marked for Markdown parsing.
|
||||||
|
|
||||||
|
- https://marked.js.org/
|
||||||
|
|
||||||
## Edra (TipTap based Rich Text Editor)
|
## Edra (TipTap based Rich Text Editor)
|
||||||
* https://edra.tsuzat.com/
|
|
||||||
|
- https://edra.tsuzat.com/
|
||||||
|
|||||||
@@ -1,68 +1,86 @@
|
|||||||
# AE Svelte and SvelteKit Technical Standards
|
# AE Svelte and SvelteKit Technical Standards
|
||||||
|
|
||||||
## Official Modules
|
## Official Modules
|
||||||
|
|
||||||
### Core
|
### Core
|
||||||
* Accounts - Minimal
|
|
||||||
* Files
|
- Accounts - Minimal
|
||||||
* People - Minimal
|
- Files
|
||||||
* Sites - Minimal
|
- People - Minimal
|
||||||
* Users - Minimal
|
- Sites - Minimal
|
||||||
|
- Users - Minimal
|
||||||
|
|
||||||
### Extended
|
### Extended
|
||||||
|
|
||||||
Archives - Minimal, Events - Badges, Events - Presentation Management, Posts - Minimal, Journals
|
Archives - Minimal, Events - Badges, Events - Presentation Management, Posts - Minimal, Journals
|
||||||
|
|
||||||
### Custom
|
### Custom
|
||||||
|
|
||||||
IDAA - Archives, IDAA - BB, IDAA - Recovery Meetings
|
IDAA - Archives, IDAA - BB, IDAA - Recovery Meetings
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## localStorage:
|
## localStorage:
|
||||||
* api
|
|
||||||
* app - global
|
- api
|
||||||
* core - core modules
|
- app - global
|
||||||
* [module] - extended modules
|
- core - core modules
|
||||||
* [custom] - custom modules
|
- [module] - extended modules
|
||||||
|
- [custom] - custom modules
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Indexed DB
|
## Indexed DB
|
||||||
* ae_core_db
|
|
||||||
* [module]
|
- ae_core_db
|
||||||
* [custom] - custom modules: none currently
|
- [module]
|
||||||
|
- [custom] - custom modules: none currently
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Data Sorting
|
## Data Sorting
|
||||||
* group > priority > sort > updated/created on
|
|
||||||
* type > start date/time > code or name
|
- group > priority > sort > updated/created on
|
||||||
|
- type > start date/time > code or name
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Objects
|
## Objects
|
||||||
|
|
||||||
### Function - Obj Prop Update
|
### Function - Obj Prop Update
|
||||||
* obj_type
|
|
||||||
* obj_id
|
- obj_type
|
||||||
* obj_prop
|
- obj_id
|
||||||
* obj_value
|
- obj_prop
|
||||||
|
- obj_value
|
||||||
|
|
||||||
### Core
|
### Core
|
||||||
|
|
||||||
### Extended
|
### Extended
|
||||||
|
|
||||||
### Custom
|
### Custom
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Object Properties or Fields
|
## Object Properties or Fields
|
||||||
|
|
||||||
### Core
|
### Core
|
||||||
Expected standard field names: id, id_random, [obj-type]_id_random, code, name, enable, hide, priority, sort, group, notes, created_on, updated_on
|
|
||||||
|
Expected standard field names: id, id_random, [obj-type]\_id_random, code, name, enable, hide, priority, sort, group, notes, created_on, updated_on
|
||||||
Special use field names: for_type, for_id, archive_on, passcode, external_id
|
Special use field names: for_type, for_id, archive_on, passcode, external_id
|
||||||
|
|
||||||
### Configs and Fields with JSON
|
### Configs and Fields with JSON
|
||||||
* cfg_json
|
|
||||||
* data_json
|
- cfg_json
|
||||||
* linked_li_json
|
- data_json
|
||||||
|
- linked_li_json
|
||||||
|
|
||||||
### Special Generated Fields
|
### Special Generated Fields
|
||||||
|
|
||||||
tmp_sort_1, tmp_sort_2,
|
tmp_sort_1, tmp_sort_2,
|
||||||
|
|
||||||
|
|
||||||
### Future standard fields!!!
|
### Future standard fields!!!
|
||||||
|
|
||||||
obj_id?: null|string;
|
obj_id?: null|string;
|
||||||
obj_ext_uid?: null|string; // Probably not needed for journals
|
obj_ext_uid?: null|string; // Probably not needed for journals
|
||||||
obj_ext_id?: null|string; // Probably not needed for journals
|
obj_ext_id?: null|string; // Probably not needed for journals
|
||||||
@@ -89,59 +107,65 @@ obj_created_on?: Date;
|
|||||||
obj_updated_on?: null|Date;
|
obj_updated_on?: null|Date;
|
||||||
|
|
||||||
## Dixie IDB liveQuery with Select Objects (slct) and Lists of Objects (slct_x_li)
|
## Dixie IDB liveQuery with Select Objects (slct) and Lists of Objects (slct_x_li)
|
||||||
Use this method below to create a read/write snapshot of the current liveQuery results. This allows you to use it as part of a form and binding values. It might make since to call this something like "lqw__x_obj" and "lqw__x_obj_li". lqw = liveQuery writable
|
|
||||||
|
|
||||||
lq__xyz_obj - Use for general read only
|
Use this method below to create a read/write snapshot of the current liveQuery results. This allows you to use it as part of a form and binding values. It might make since to call this something like "lqw**x_obj" and "lqw**x_obj_li". lqw = liveQuery writable
|
||||||
lqw__xyz_obj - Use for forms and binding values. What happens if the actual LQ obj is updated after the bind?
|
|
||||||
|
lq**xyz_obj - Use for general read only
|
||||||
|
lqw**xyz_obj - Use for forms and binding values. What happens if the actual LQ obj is updated after the bind?
|
||||||
$slct or $lqw ?
|
$slct or $lqw ?
|
||||||
|
|
||||||
|
Sort of related.... more permission/security though: Create a new table that will be attached to every v\_ view in the DB. This new table would be a field permission list. It could work similar to the data_store table and related view. This seems like a good idea????? 2025-08-11
|
||||||
Sort of related.... more permission/security though: Create a new table that will be attached to every v_ view in the DB. This new table would be a field permission list. It could work similar to the data_store table and related view. This seems like a good idea????? 2025-08-11
|
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
let lq__post_obj = $derived(liveQuery(async () => {
|
let lq__post_obj = $derived(
|
||||||
if (log_lvl) {
|
liveQuery(async () => {
|
||||||
console.log(`lq__post_obj: post_id = ${$idaa_slct?.post_id}`);
|
if (log_lvl) {
|
||||||
}
|
console.log(`lq__post_obj: post_id = ${$idaa_slct?.post_id}`);
|
||||||
let results = await db_posts.post
|
}
|
||||||
.get($idaa_slct.post_id ?? ''); // null or undefined does not reset things like '' does
|
let results = await db_posts.post.get($idaa_slct.post_id ?? ''); // null or undefined does not reset things like '' does
|
||||||
|
|
||||||
// Check if results are different than the current $idaa_slct.post_obj
|
// Check if results are different than the current $idaa_slct.post_obj
|
||||||
if ($idaa_slct.post_obj && results) {
|
if ($idaa_slct.post_obj && results) {
|
||||||
if (JSON.stringify($idaa_slct.post_obj) !== JSON.stringify(results)) {
|
if (JSON.stringify($idaa_slct.post_obj) !== JSON.stringify(results)) {
|
||||||
$idaa_slct.post_obj = { ...results};
|
$idaa_slct.post_obj = { ...results };
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`$idaa_slct.post_obj = `, $idaa_slct.post_obj);
|
console.log(`$idaa_slct.post_obj = `, $idaa_slct.post_obj);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`Post object has not changed for post_id: ${$idaa_slct.post_id}`);
|
console.log(`Post object has not changed for post_id: ${$idaa_slct.post_id}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}));
|
})
|
||||||
|
);
|
||||||
|
|
||||||
let lq__post_comment_obj_li = $derived(liveQuery(async () => {
|
let lq__post_comment_obj_li = $derived(
|
||||||
let results = await db_posts.comment
|
liveQuery(async () => {
|
||||||
.where('post_id')
|
let results = await db_posts.comment
|
||||||
.equals($idaa_slct.post_id ?? '') // null or undefined does not reset things like '' does
|
.where('post_id')
|
||||||
.reverse()
|
.equals($idaa_slct.post_id ?? '') // null or undefined does not reset things like '' does
|
||||||
.sortBy('updated_on');
|
.reverse()
|
||||||
// .sortBy('title');
|
.sortBy('updated_on');
|
||||||
|
// .sortBy('title');
|
||||||
|
|
||||||
if ($idaa_slct.post_comment_obj_li && JSON.stringify($idaa_slct.post_comment_obj_li) !== JSON.stringify(results)) {
|
if (
|
||||||
$idaa_slct.post_comment_obj_li = [...results];
|
$idaa_slct.post_comment_obj_li &&
|
||||||
if (log_lvl) {
|
JSON.stringify($idaa_slct.post_comment_obj_li) !== JSON.stringify(results)
|
||||||
console.log(`$idaa_slct.post_comment_obj_li = `, $idaa_slct.post_comment_obj_li);
|
) {
|
||||||
}
|
$idaa_slct.post_comment_obj_li = [...results];
|
||||||
} else {
|
if (log_lvl) {
|
||||||
if (log_lvl) {
|
console.log(`$idaa_slct.post_comment_obj_li = `, $idaa_slct.post_comment_obj_li);
|
||||||
console.log(`Post comment object list has not changed for post_id: ${$idaa_slct.post_id}`);
|
}
|
||||||
}
|
} else {
|
||||||
}
|
if (log_lvl) {
|
||||||
|
console.log(`Post comment object list has not changed for post_id: ${$idaa_slct.post_id}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}));
|
})
|
||||||
```
|
);
|
||||||
|
```
|
||||||
|
|||||||
68
README.md
68
README.md
@@ -2,38 +2,46 @@
|
|||||||
|
|
||||||
This uses SvelteKit version 2.x with Svelte version 5.x, TailwindCSS 4.1, and Skelton.
|
This uses SvelteKit version 2.x with Svelte version 5.x, TailwindCSS 4.1, and Skelton.
|
||||||
|
|
||||||
|
|
||||||
# Current Modules
|
# Current Modules
|
||||||
|
|
||||||
## AE Events - Speakers (/events_speakers)
|
## AE Events - Speakers (/events_speakers)
|
||||||
|
|
||||||
### Components
|
### Components
|
||||||
* +page.svelte - The main page for the Events - Speakers module
|
|
||||||
* 10_edit_modal__event_presenter_obj.svelte - The modal for editing a presenter
|
- +page.svelte - The main page for the Events - Speakers module
|
||||||
* 10_list__event_presenter_obj.svelte - The list of presenters/speakers
|
- 10_edit_modal\_\_event_presenter_obj.svelte - The modal for editing a presenter
|
||||||
* 10_view_modal__event_presenter_obj.svelte - The modal for viewing 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]
|
### Path [slug]
|
||||||
* +page.svelte - The main page for the presenter ID [slug]
|
|
||||||
|
- +page.svelte - The main page for the presenter ID [slug]
|
||||||
|
|
||||||
## AE Sponsorships (/sponsorships)
|
## AE Sponsorships (/sponsorships)
|
||||||
* +page.svelte - The main page for the Sponsorships module
|
|
||||||
* 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]
|
|
||||||
* +page.svelte - The main page for the sponsorship ID [slug]
|
|
||||||
|
|
||||||
|
- +page.svelte - The main page for the Sponsorships module
|
||||||
|
- 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]
|
||||||
|
|
||||||
|
- +page.svelte - The main page for the sponsorship ID [slug]
|
||||||
|
|
||||||
# Future Modules
|
# Future Modules
|
||||||
|
|
||||||
## AE Events - Badges (/events_badges)
|
## AE Events - Badges (/events_badges)
|
||||||
* +page.svelte - The main page for the Events - Badges module
|
|
||||||
* 10_list__event_badge_obj.svelte - The list of badges
|
- +page.svelte - The main page for the Events - Badges module
|
||||||
* 10_view_modal__event_badge_obj.svelte - The modal for viewing a badge
|
- 10_list\_\_event_badge_obj.svelte - The list of badges
|
||||||
|
- 10_view_modal\_\_event_badge_obj.svelte - The modal for viewing a badge
|
||||||
|
|
||||||
## AE Events - Exhibit Leads (/events_exhibit_leads)
|
## AE Events - Exhibit Leads (/events_exhibit_leads)
|
||||||
|
|
||||||
## AE Events - Presentation Management (/events_pres_mgmt)
|
## AE Events - Presentation Management (/events_pres_mgmt)
|
||||||
|
|
||||||
|
|
||||||
# How to build and deploy SvelteKit:
|
# How to build and deploy SvelteKit:
|
||||||
|
|
||||||
Copy the contents of the "build" directory to ./npm_deploy/build/
|
Copy the contents of the "build" directory to ./npm_deploy/build/
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -41,6 +49,7 @@ npm run build
|
|||||||
```
|
```
|
||||||
|
|
||||||
If this is just a quick build update then only the build directory needs to be copied (rsync).
|
If this is just a quick build update then only the build directory needs to be copied (rsync).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
rsync -vhrz --exclude 'node_modules' ~/OSIT_dev/ae_app_svelte_tailwind_skeleton/build/ ~/OSIT_dev/ae_env_node_app/npm_deploy/build/ --delete
|
rsync -vhrz --exclude 'node_modules' ~/OSIT_dev/ae_app_svelte_tailwind_skeleton/build/ ~/OSIT_dev/ae_env_node_app/npm_deploy/build/ --delete
|
||||||
|
|
||||||
@@ -50,6 +59,7 @@ rsync -vhrz ~/OSIT_dev/ae_env_node_app/npm_deploy/build/ scott@linode.oneskyit.c
|
|||||||
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 (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.
|
||||||
|
|
||||||
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.
|
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
|
```bash
|
||||||
npm ci --omit dev
|
npm ci --omit dev
|
||||||
|
|
||||||
@@ -63,10 +73,10 @@ npm install
|
|||||||
|
|
||||||
Everything should be ready to run on the development server and production server.
|
Everything should be ready to run on the development server and production server.
|
||||||
|
|
||||||
|
|
||||||
# Rebuild the node_modules directory and manually install extra Svelte packages
|
# Rebuild the node_modules directory and manually install extra Svelte packages
|
||||||
|
|
||||||
Run the npm update to fix the node_modules directory and package.json
|
Run the npm update to fix the node_modules directory and package.json
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm list
|
npm list
|
||||||
npm outdated
|
npm outdated
|
||||||
@@ -77,6 +87,7 @@ npm list
|
|||||||
|
|
||||||
Other installs?:
|
Other installs?:
|
||||||
Are both still needed? I know at least one of these is. 2024-07-23
|
Are both still needed? I know at least one of these is. 2024-07-23
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install --save-dev svelte-highlight
|
npm install --save-dev svelte-highlight
|
||||||
npm install --save-dev typescript-svelte-plugin
|
npm install --save-dev typescript-svelte-plugin
|
||||||
@@ -96,13 +107,15 @@ npm install flowbite flowbite-svelte tailwind-merge @popperjs/core
|
|||||||
I am slowly switching from Font-Awesome to Lucide
|
I am slowly switching from Font-Awesome to Lucide
|
||||||
|
|
||||||
## Tiptap Editor
|
## Tiptap Editor
|
||||||
* Eventually use Edra? https://edra.tsuzat.com/
|
|
||||||
* Best Rich Text Editor, made for Svelte Developers with Tiptap
|
- Eventually use Edra? https://edra.tsuzat.com/
|
||||||
* ShadEditor is "evolving" to be Edra.
|
- Best Rich Text Editor, made for Svelte Developers with Tiptap
|
||||||
* 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.
|
- ShadEditor is "evolving" to be Edra.
|
||||||
* [https://github.com/huntabyte/shadcn-svelte/issues/1643](https://github.com/huntabyte/shadcn-svelte/issues/1643)
|
- 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.
|
Need to install ShadCN and Lucide for the Tiptap editor.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install shadcn-svelte
|
npm install shadcn-svelte
|
||||||
npm install lucide-svelte
|
npm install lucide-svelte
|
||||||
@@ -110,6 +123,7 @@ npm install mode-watcher
|
|||||||
```
|
```
|
||||||
|
|
||||||
Now we initialize the ShadCN and ShadEditor packages. Follow the command line instructions.
|
Now we initialize the ShadCN and ShadEditor packages. Follow the command line instructions.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npx shadcn-svelte@next init
|
npx shadcn-svelte@next init
|
||||||
npx shadcn-svelte@next add dropdown-menu button tooltip input popover separator
|
npx shadcn-svelte@next add dropdown-menu button tooltip input popover separator
|
||||||
@@ -117,6 +131,7 @@ npx shadeditor init
|
|||||||
```
|
```
|
||||||
|
|
||||||
More packages related to the Tiptap editor???
|
More packages related to the Tiptap editor???
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install @tiptap/extension-link @tiptap/extension-bullet-list @tiptap/extension-history @tiptap/extension-typography @tiptap/extension-underline
|
npm install @tiptap/extension-link @tiptap/extension-bullet-list @tiptap/extension-history @tiptap/extension-typography @tiptap/extension-underline
|
||||||
```
|
```
|
||||||
@@ -124,23 +139,31 @@ npm install @tiptap/extension-link @tiptap/extension-bullet-list @tiptap/extensi
|
|||||||
## Build
|
## Build
|
||||||
|
|
||||||
## Environment file
|
## Environment file
|
||||||
|
|
||||||
### ".env"
|
### ".env"
|
||||||
|
|
||||||
This is the default used if others are not found when when "npm run dev" or "npm run build" is run.
|
This is the default used if others are not found when when "npm run dev" or "npm run build" is run.
|
||||||
|
|
||||||
### ".env.local"
|
### ".env.local"
|
||||||
|
|
||||||
This is used when "npm run dev" is run. This is not used in the production build.
|
This is used when "npm run dev" is run. This is not used in the production build.
|
||||||
|
|
||||||
### ".env.production"
|
### ".env.production"
|
||||||
|
|
||||||
This is used when "npm run build" is run. This is not used in the development build.
|
This is used when "npm run build" is run. This is not used in the development build.
|
||||||
|
|
||||||
### ".env:prod"
|
### ".env:prod"
|
||||||
|
|
||||||
This is modified to allow for a staging environment and production environment built.
|
This is modified to allow for a staging environment and production environment built.
|
||||||
|
|
||||||
### ".env:staging"
|
### ".env:staging"
|
||||||
|
|
||||||
This is modified to allow for a staging environment and production environment built.
|
This is modified to allow for a staging environment and production environment built.
|
||||||
|
|
||||||
### Example Important Values when running in dev:
|
### 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: 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...
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
DOCKER_AE_API_DEV_SERVER_EXTRA_HOST=dev-api.oneskyit.com:108.48.200.147
|
DOCKER_AE_API_DEV_SERVER_EXTRA_HOST=dev-api.oneskyit.com:108.48.200.147
|
||||||
|
|
||||||
@@ -150,7 +173,6 @@ PUBLIC_AE_API_SERVER=api.oneskyit.com
|
|||||||
PUBLIC_AE_API_BAK_SERVER=bak-api.oneskyit.com
|
PUBLIC_AE_API_BAK_SERVER=bak-api.oneskyit.com
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
# create-svelte
|
# create-svelte
|
||||||
|
|
||||||
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).
|
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ Svelte 5 introduces "runes" as a new way to manage reactivity. This is a major c
|
|||||||
|
|
||||||
### Key Breaking Changes
|
### Key Breaking Changes
|
||||||
|
|
||||||
* **`let` is no longer reactive:** In Svelte 4, any `let` variable declared in the top-level scope of a component was automatically reactive. In Svelte 5, you must explicitly declare reactive state using the `$state` rune.
|
- **`let` is no longer reactive:** In Svelte 4, any `let` variable declared in the top-level scope of a component was automatically reactive. In Svelte 5, you must explicitly declare reactive state using the `$state` rune.
|
||||||
* **`$:` is replaced by `$derived` and `$effect`:** The `$` label is no longer used for reactive statements. Instead, you should use the `$derived` rune for computed values and the `$effect` rune for side effects.
|
- **`$:` is replaced by `$derived` and `$effect`:** The `$` label is no longer used for reactive statements. Instead, you should use the `$derived` rune for computed values and the `$effect` rune for side effects.
|
||||||
* **`export let` is replaced by `$props`:** Component props are now declared using the `$props` rune, which provides a more flexible and explicit way to define component APIs.
|
- **`export let` is replaced by `$props`:** Component props are now declared using the `$props` rune, which provides a more flexible and explicit way to define component APIs.
|
||||||
* **Event handling:** The `on:` directive is replaced by event attributes (e.g., `onclick`). Component events are now handled using callback props instead of `createEventDispatcher`.
|
- **Event handling:** The `on:` directive is replaced by event attributes (e.g., `onclick`). Component events are now handled using callback props instead of `createEventDispatcher`.
|
||||||
* **Slots are replaced by snippets:** The `<slot>` element is replaced by the `{#snippet ...}` block, which provides a more powerful and flexible way to pass content to components.
|
- **Slots are replaced by snippets:** The `<slot>` element is replaced by the `{#snippet ...}` block, which provides a more powerful and flexible way to pass content to components.
|
||||||
|
|
||||||
For a complete list of breaking changes, refer to the [Svelte 5 migration guide](https://svelte.dev/docs/svelte/v5-migration-guide).
|
For a complete list of breaking changes, refer to the [Svelte 5 migration guide](https://svelte.dev/docs/svelte/v5-migration-guide).
|
||||||
|
|
||||||
@@ -22,24 +22,24 @@ Dexie.js is a lightweight, minimalistic wrapper for IndexedDB that makes it easi
|
|||||||
|
|
||||||
### Key Classes and Methods
|
### Key Classes and Methods
|
||||||
|
|
||||||
* **`Dexie`:** The main class for creating and managing IndexedDB databases.
|
- **`Dexie`:** The main class for creating and managing IndexedDB databases.
|
||||||
* `new Dexie(databaseName)`: Creates a new database instance.
|
- `new Dexie(databaseName)`: Creates a new database instance.
|
||||||
* `version(versionNumber).stores({ ... })`: Defines the database schema.
|
- `version(versionNumber).stores({ ... })`: Defines the database schema.
|
||||||
* **`Table`:** Represents an object store (table) in the database.
|
- **`Table`:** Represents an object store (table) in the database.
|
||||||
* `add(item)`: Adds a new item to the table.
|
- `add(item)`: Adds a new item to the table.
|
||||||
* `put(item)`: Adds or updates an item in the table.
|
- `put(item)`: Adds or updates an item in the table.
|
||||||
* `update(key, changes)`: Updates an existing item.
|
- `update(key, changes)`: Updates an existing item.
|
||||||
* `delete(key)`: Deletes an item by its primary key.
|
- `delete(key)`: Deletes an item by its primary key.
|
||||||
* `get(key)`: Retrieves an item by its primary key.
|
- `get(key)`: Retrieves an item by its primary key.
|
||||||
* `where(index)`: Starts a query using an index.
|
- `where(index)`: Starts a query using an index.
|
||||||
* `toArray()`: Retrieves all items from the table as an array.
|
- `toArray()`: Retrieves all items from the table as an array.
|
||||||
* **`Collection`:** Represents a collection of items resulting from a query.
|
- **`Collection`:** Represents a collection of items resulting from a query.
|
||||||
* `toArray()`: Retrieves all items in the collection as an array.
|
- `toArray()`: Retrieves all items in the collection as an array.
|
||||||
* `first()`: Retrieves the first item in the collection.
|
- `first()`: Retrieves the first item in the collection.
|
||||||
* `last()`: Retrieves the last item in the collection.
|
- `last()`: Retrieves the last item in the collection.
|
||||||
* `each(callback)`: Iterates over each item in the collection.
|
- `each(callback)`: Iterates over each item in the collection.
|
||||||
* `modify(changes)`: Updates all items in the collection.
|
- `modify(changes)`: Updates all items in the collection.
|
||||||
* `delete()`: Deletes all items in the collection.
|
- `delete()`: Deletes all items in the collection.
|
||||||
|
|
||||||
For a complete list of API methods, refer to the [Dexie.js API Reference](https://dexie.org/docs/API-Reference).
|
For a complete list of API methods, refer to the [Dexie.js API Reference](https://dexie.org/docs/API-Reference).
|
||||||
|
|
||||||
@@ -63,13 +63,13 @@ import { readable } from 'svelte/store';
|
|||||||
import { db } from './db'; // Your Dexie database instance
|
import { db } from './db'; // Your Dexie database instance
|
||||||
|
|
||||||
export function createLiveQueryStore<T>(query: () => T | Promise<T>) {
|
export function createLiveQueryStore<T>(query: () => T | Promise<T>) {
|
||||||
return readable<T | undefined>(undefined, (set) => {
|
return readable<T | undefined>(undefined, (set) => {
|
||||||
const subscription = liveQuery(query).subscribe({
|
const subscription = liveQuery(query).subscribe({
|
||||||
next: (result) => set(result),
|
next: (result) => set(result),
|
||||||
error: (error) => console.error(error),
|
error: (error) => console.error(error)
|
||||||
});
|
});
|
||||||
return () => subscription.unsubscribe();
|
return () => subscription.unsubscribe();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -77,18 +77,16 @@ export function createLiveQueryStore<T>(query: () => T | Promise<T>) {
|
|||||||
|
|
||||||
```html
|
```html
|
||||||
<script>
|
<script>
|
||||||
import { createLiveQueryStore } from './stores';
|
import { createLiveQueryStore } from './stores';
|
||||||
import { db } from './db';
|
import { db } from './db';
|
||||||
|
|
||||||
const friends = createLiveQueryStore(() => db.friends.toArray());
|
const friends = createLiveQueryStore(() => db.friends.toArray());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{#if $friends}
|
{#if $friends} {#each $friends as friend}
|
||||||
{#each $friends as friend}
|
<li>{friend.name}</li>
|
||||||
<li>{friend.name}</li>
|
{/each} {/if}
|
||||||
{/each}
|
|
||||||
{/if}
|
|
||||||
</ul>
|
</ul>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
66
TODO.md
66
TODO.md
@@ -4,17 +4,30 @@ This is a list of tasks to be completed before the next event/show/conference.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Recent Accomplishments
|
||||||
|
|
||||||
|
- [x] **Refactoring:** Standardized data processing in `events`, `archives`, `posts`, and `sponsorships` modules using a new generic pattern.
|
||||||
|
- [x] **Bug Fix:** Corrected data fetching logic for session-related presentations and files that were not displaying correctly due to `id` vs `id_random` issues.
|
||||||
|
- [x] **Core:** Defined `Account`, `Site`, and `Site_Domain` interfaces in new files under `src/lib/ae_core/`.
|
||||||
|
- [x] **Journals:** Improve the empty state message in `src/routes/journals/+page.svelte`.
|
||||||
|
- [x] **Journals:** Add a loading indicator to the main journals page.
|
||||||
|
- [x] **IDAA:** Add a loading indicator to the archives page (`src/routes/idaa/(idaa)/archives/+page.svelte`).
|
||||||
|
- [x] **Events:** Add pagination to the main event list in `src/routes/events/+page.svelte`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Big Picture Goals
|
## Big Picture Goals
|
||||||
|
|
||||||
* Able to cache data and mostly work offline.
|
- Able to cache data and mostly work offline.
|
||||||
* The new Events Launcher must be able to work offline and query the API for changes to data.
|
- The new Events Launcher must be able to work offline and query the API for changes to data.
|
||||||
* The new Events Launcher must be able to run inside an Electron app and have access to local files and commands. This includes loading a special library that only works in Electron.
|
- The new Events Launcher must be able to run inside an Electron app and have access to local files and commands. This includes loading a special library that only works in Electron.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Codebase Standardization
|
## Codebase Standardization
|
||||||
|
|
||||||
### 1. Naming Conventions
|
### 1. Naming Conventions
|
||||||
|
|
||||||
- [ ] **Goal:** Enforce a single, consistent naming standard across the entire codebase.
|
- [ ] **Goal:** Enforce a single, consistent naming standard across the entire codebase.
|
||||||
- [ ] **Files:**
|
- [ ] **Files:**
|
||||||
- Logic: `ae_<module>__<concept>.ts`
|
- Logic: `ae_<module>__<concept>.ts`
|
||||||
@@ -35,6 +48,7 @@ This is a list of tasks to be completed before the next event/show/conference.
|
|||||||
- **Update 2025-11-13:** `ae_core_functions.ts` has been temporarily restored to resolve a critical issue. The refactoring of `process_ae_obj__*_props()` functions will now proceed module by module, ensuring stability at each step.
|
- **Update 2025-11-13:** `ae_core_functions.ts` has been temporarily restored to resolve a critical issue. The refactoring of `process_ae_obj__*_props()` functions will now proceed module by module, ensuring stability at each step.
|
||||||
|
|
||||||
### 2. Component Standardization
|
### 2. Component Standardization
|
||||||
|
|
||||||
- [ ] **CodeMirror Migration:** Plan and execute the replacement of the `shad-editor` and potentially other text editors (like Tiptap) with `CodeMirror` to standardize rich text editing.
|
- [ ] **CodeMirror Migration:** Plan and execute the replacement of the `shad-editor` and potentially other text editors (like Tiptap) with `CodeMirror` to standardize rich text editing.
|
||||||
- [ ] **Component Review:** Audit third-party components to understand their conventions and isolate them from internal standards.
|
- [ ] **Component Review:** Audit third-party components to understand their conventions and isolate them from internal standards.
|
||||||
|
|
||||||
@@ -42,11 +56,7 @@ This is a list of tasks to be completed before the next event/show/conference.
|
|||||||
|
|
||||||
## Priority Tasks (Easy & Quick)
|
## Priority Tasks (Easy & Quick)
|
||||||
|
|
||||||
- [x] **Core:** Define `Account`, `Site`, and `Site_Domain` interfaces in new files under `src/lib/ae_core/`.
|
- [ ] **Formatting:** Run `npm run format` to fix code style issues across the project.
|
||||||
- [x] **Journals:** Improve the empty state message in `src/routes/journals/+page.svelte`.
|
|
||||||
- [x] **Journals:** Add a loading indicator to the main journals page.
|
|
||||||
- [x] **IDAA:** Add a loading indicator to the archives page (`src/routes/idaa/(idaa)/archives/+page.svelte`).
|
|
||||||
- [x] **Events:** Add pagination to the main event list in `src/routes/events/+page.svelte`.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -55,21 +65,21 @@ This is a list of tasks to be completed before the next event/show/conference.
|
|||||||
These functions are frequently used and critical to the application's data flow. Reviewing and cleaning them up will significantly improve the codebase.
|
These functions are frequently used and critical to the application's data flow. Reviewing and cleaning them up will significantly improve the codebase.
|
||||||
|
|
||||||
1. **`get_ae_obj_li_for_obj_id_crud_v2()`** (from `src/lib/ae_api/api_get__crud_obj_li_v2.ts`)
|
1. **`get_ae_obj_li_for_obj_id_crud_v2()`** (from `src/lib/ae_api/api_get__crud_obj_li_v2.ts`)
|
||||||
- **Why:** This is the main function for fetching lists of data from the backend, used extensively across all modules.
|
- **Why:** This is the main function for fetching lists of data from the backend, used extensively across all modules.
|
||||||
- **Cleanup:** Review parameters and return types for consistency, improve error handling, and add more detailed logging for debugging.
|
- **Cleanup:** Review parameters and return types for consistency, improve error handling, and add more detailed logging for debugging.
|
||||||
|
|
||||||
2. **`db_save_ae_obj_li__ae_obj()`** (from `src/lib/ae_core/core__idb_dexie.ts`)
|
2. **`db_save_ae_obj_li__ae_obj()`** (from `src/lib/ae_core/core__idb_dexie.ts`)
|
||||||
- **Why:** This function is the single point of entry for saving data to the local Dexie database, critical for performance and reliability.
|
- **Why:** This function is the single point of entry for saving data to the local Dexie database, critical for performance and reliability.
|
||||||
- **Cleanup:** Optimize for bulk operations, add robust error handling and logging, and ensure correct handling of updates to existing objects.
|
- **Cleanup:** Optimize for bulk operations, add robust error handling and logging, and ensure correct handling of updates to existing objects.
|
||||||
|
|
||||||
3. **The `process_ae_obj__*_props()` family of functions** (e.g., `process_ae_obj__journal_props()` from `src/lib/ae_journals/ae_journals__journal.ts`)
|
3. **The `process_ae_obj__*_props()` family of functions** (e.g., `process_ae_obj__journal_props()` from `src/lib/ae_journals/ae_journals__journal.ts`)
|
||||||
- **Why:** These functions transform API data for the frontend and are a common source of bugs and inconsistencies.
|
- **Why:** These functions transform API data for the frontend and are a common source of bugs and inconsistencies.
|
||||||
- **Cleanup:** Standardize their structure across all modules, ensure they are pure functions, and add unit tests for correctness.
|
- **Cleanup:** Standardize their structure across all modules, ensure they are pure functions, and add unit tests for correctness.
|
||||||
- **Update 2025-11-13 (Temporary Rollback):** The previous refactoring of these functions has been temporarily rolled back due to an `InternalError`. `ae_core_functions.ts` has been restored. The new plan is to refactor these functions module by module, ensuring stability at each step. The generic CRUD functions in `core__crud_generic.ts` were simplified to remove data processing and caching, delegating those responsibilities to the module-specific functions. The deprecated `process_ae_obj__props` function in that file was left in place but is no longer used by the generic CRUD functions.
|
- **Update 2025-11-13 (Temporary Rollback):** The previous refactoring of these functions has been temporarily rolled back due to an `InternalError`. `ae_core_functions.ts` has been restored. The new plan is to refactor these functions module by module, ensuring stability at each step. The generic CRUD functions in `core__crud_generic.ts` were simplified to remove data processing and caching, delegating those responsibilities to the module-specific functions. The deprecated `process_ae_obj__props` function in that file was left in place but is no longer used by the generic CRUD functions.
|
||||||
|
|
||||||
4. **Usage of `liveQuery` from Dexie**
|
4. **Usage of `liveQuery` from Dexie**
|
||||||
- **Why:** `liveQuery` is powerful for reactive UIs, but current usage suggests complexity and potential issues.
|
- **Why:** `liveQuery` is powerful for reactive UIs, but current usage suggests complexity and potential issues.
|
||||||
- **Cleanup:** Review `liveQuery` usage throughout the application, simplify queries, and investigate reactivity issues. Consider wrapping `liveQuery` in a custom Svelte store for a more predictable interface.
|
- **Cleanup:** Review `liveQuery` usage throughout the application, simplify queries, and investigate reactivity issues. Consider wrapping `liveQuery` in a custom Svelte store for a more predictable interface.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -80,9 +90,11 @@ These functions are frequently used and critical to the application's data flow.
|
|||||||
## Core Module Improvements
|
## Core Module Improvements
|
||||||
|
|
||||||
### 1. Core Module Dashboard
|
### 1. Core Module Dashboard
|
||||||
|
|
||||||
- [ ] Create a central dashboard at `/core` to provide an overview and links to all core data management pages.
|
- [ ] Create a central dashboard at `/core` to provide an overview and links to all core data management pages.
|
||||||
|
|
||||||
### 2. Account Management
|
### 2. Account Management
|
||||||
|
|
||||||
- [ ] **Route:** Create a new route at `/core/accounts`.
|
- [ ] **Route:** Create a new route at `/core/accounts`.
|
||||||
- [ ] **Data:** Define the `Account` interface in a new file `src/lib/ae_core/core__account.ts`.
|
- [ ] **Data:** Define the `Account` interface in a new file `src/lib/ae_core/core__account.ts`.
|
||||||
- [ ] **API:** Implement functions in `core__account.ts` for CRUD operations on accounts.
|
- [ ] **API:** Implement functions in `core__account.ts` for CRUD operations on accounts.
|
||||||
@@ -91,6 +103,7 @@ These functions are frequently used and critical to the application's data flow.
|
|||||||
- [ ] Create a `[account_id]` dynamic route to view and edit account details.
|
- [ ] Create a `[account_id]` dynamic route to view and edit account details.
|
||||||
|
|
||||||
### 3. Site & Domain Management
|
### 3. Site & Domain Management
|
||||||
|
|
||||||
- [ ] **Route:** Create a new route at `/core/sites`.
|
- [ ] **Route:** Create a new route at `/core/sites`.
|
||||||
- [ ] **Data:** Define `Site` and `Site_Domain` interfaces in a new file `src/lib/ae_core/core__site.ts`.
|
- [ ] **Data:** Define `Site` and `Site_Domain` interfaces in a new file `src/lib/ae_core/core__site.ts`.
|
||||||
- [ ] **API:** Implement functions in `core__site.ts` for CRUD operations on sites and domains.
|
- [ ] **API:** Implement functions in `core__site.ts` for CRUD operations on sites and domains.
|
||||||
@@ -99,12 +112,14 @@ These functions are frequently used and critical to the application's data flow.
|
|||||||
- [ ] Create a `[site_id]` dynamic route to view and edit site details and manage associated domains.
|
- [ ] Create a `[site_id]` dynamic route to view and edit site details and manage associated domains.
|
||||||
|
|
||||||
### 4. Person Management
|
### 4. Person Management
|
||||||
|
|
||||||
- [ ] **Enhance:** Improve the existing person management components under `/core/person`.
|
- [ ] **Enhance:** Improve the existing person management components under `/core/person`.
|
||||||
- [ ] **UI:**
|
- [ ] **UI:**
|
||||||
- [ ] Create a dedicated page for creating new person records.
|
- [ ] Create a dedicated page for creating new person records.
|
||||||
- [ ] Add search and filtering capabilities to the person list.
|
- [ ] Add search and filtering capabilities to the person list.
|
||||||
|
|
||||||
### 5. User Management
|
### 5. User Management
|
||||||
|
|
||||||
- [ ] **Route:** Create a new route at `/core/users`.
|
- [ ] **Route:** Create a new route at `/core/users`.
|
||||||
- [ ] **UI:**
|
- [ ] **UI:**
|
||||||
- [ ] Create a `+page.svelte` to list all users.
|
- [ ] Create a `+page.svelte` to list all users.
|
||||||
@@ -112,6 +127,7 @@ These functions are frequently used and critical to the application's data flow.
|
|||||||
- [ ] Implement a component to link users to person records.
|
- [ ] Implement a component to link users to person records.
|
||||||
|
|
||||||
### 6. Hosted File Management
|
### 6. Hosted File Management
|
||||||
|
|
||||||
- [ ] **Route:** Create a new route at `/core/hosted_files`.
|
- [ ] **Route:** Create a new route at `/core/hosted_files`.
|
||||||
- [ ] **UI:**
|
- [ ] **UI:**
|
||||||
- [ ] Create a `+page.svelte` to list all hosted files with filters (e.g., by file type, uploader).
|
- [ ] Create a `+page.svelte` to list all hosted files with filters (e.g., by file type, uploader).
|
||||||
@@ -119,6 +135,7 @@ These functions are frequently used and critical to the application's data flow.
|
|||||||
- [ ] Add functionality to upload new files and associate them with other objects (e.g., a person, a journal entry).
|
- [ ] Add functionality to upload new files and associate them with other objects (e.g., a person, a journal entry).
|
||||||
|
|
||||||
### 7. Shared Lookup Lists
|
### 7. Shared Lookup Lists
|
||||||
|
|
||||||
- [ ] **Route:** Create a new route at `/core/lookups`.
|
- [ ] **Route:** Create a new route at `/core/lookups`.
|
||||||
- [ ] **UI:**
|
- [ ] **UI:**
|
||||||
- [ ] Create a simple UI to view and manage the shared lookup lists (e.g., `countries`, `time_zones`).
|
- [ ] Create a simple UI to view and manage the shared lookup lists (e.g., `countries`, `time_zones`).
|
||||||
@@ -128,6 +145,7 @@ These functions are frequently used and critical to the application's data flow.
|
|||||||
## Journals Module Improvements
|
## Journals Module Improvements
|
||||||
|
|
||||||
### Code Cleanup & Refactoring
|
### Code Cleanup & Refactoring
|
||||||
|
|
||||||
- [ ] **Consolidate Data Functions:** Refactor `ae_journals__journal.ts` and `ae_journals__journal_entry.ts` to reduce code duplication, especially in data loading and processing functions.
|
- [ ] **Consolidate Data Functions:** Refactor `ae_journals__journal.ts` and `ae_journals__journal_entry.ts` to reduce code duplication, especially in data loading and processing functions.
|
||||||
- [ ] **Remove Dead Code:** Clean up commented-out code blocks and unused variables across the module.
|
- [ ] **Remove Dead Code:** Clean up commented-out code blocks and unused variables across the module.
|
||||||
- [ ] **Logging:** Implement a more structured logging solution to replace the widespread use of `console.log`.
|
- [ ] **Logging:** Implement a more structured logging solution to replace the widespread use of `console.log`.
|
||||||
@@ -135,6 +153,7 @@ These functions are frequently used and critical to the application's data flow.
|
|||||||
- [ ] **Type Safety:** Replace `any` types with more specific interfaces, particularly in function parameters and API responses.
|
- [ ] **Type Safety:** Replace `any` types with more specific interfaces, particularly in function parameters and API responses.
|
||||||
|
|
||||||
### Features & Enhancements
|
### Features & Enhancements
|
||||||
|
|
||||||
- [ ] **Offline Support:** Improve offline capabilities by pre-fetching and caching more data. Review the current Dexie implementation for optimizations.
|
- [ ] **Offline Support:** Improve offline capabilities by pre-fetching and caching more data. Review the current Dexie implementation for optimizations.
|
||||||
- [ ] **Search & Filtering:** Enhance the UI with more advanced search and filtering options for journals and entries (e.g., by date range, content, tags).
|
- [ ] **Search & Filtering:** Enhance the UI with more advanced search and filtering options for journals and entries (e.g., by date range, content, tags).
|
||||||
- [ ] **User Experience (UX):**
|
- [ ] **User Experience (UX):**
|
||||||
@@ -145,6 +164,7 @@ These functions are frequently used and critical to the application's data flow.
|
|||||||
- [ ] **Templates:** Fully implement and document the "templates" feature for creating new journals and entries.
|
- [ ] **Templates:** Fully implement and document the "templates" feature for creating new journals and entries.
|
||||||
|
|
||||||
### Bug Fixes & Potential Issues
|
### Bug Fixes & Potential Issues
|
||||||
|
|
||||||
- [ ] **Reactivity:** Investigate potential reactivity issues between Svelte stores and Dexie's `liveQuery`.
|
- [ ] **Reactivity:** Investigate potential reactivity issues between Svelte stores and Dexie's `liveQuery`.
|
||||||
- [ ] **Data Sync:** Add logic to handle data synchronization conflicts between the local database and the server.
|
- [ ] **Data Sync:** Add logic to handle data synchronization conflicts between the local database and the server.
|
||||||
- [ ] **Performance:** Profile the application with a large number of journals and entries to identify and address any performance bottlenecks.
|
- [ ] **Performance:** Profile the application with a large number of journals and entries to identify and address any performance bottlenecks.
|
||||||
@@ -154,10 +174,12 @@ These functions are frequently used and critical to the application's data flow.
|
|||||||
## IDAA Modules Improvements
|
## IDAA Modules Improvements
|
||||||
|
|
||||||
### General
|
### General
|
||||||
|
|
||||||
- [ ] **Component Refactoring:** Audit the `ae_idaa_comp__` components and refactor them to be more generic and reusable where possible.
|
- [ ] **Component Refactoring:** Audit the `ae_idaa_comp__` components and refactor them to be more generic and reusable where possible.
|
||||||
- [ ] **State Management:** Simplify state management by reducing the number of stores and triggers, and relying more on derived state and component props.
|
- [ ] **State Management:** Simplify state management by reducing the number of stores and triggers, and relying more on derived state and component props.
|
||||||
|
|
||||||
### Archives Module (`/idaa/archives`)
|
### Archives Module (`/idaa/archives`)
|
||||||
|
|
||||||
- [ ] **UI/UX:**
|
- [ ] **UI/UX:**
|
||||||
- [ ] Add a loading indicator while archives are being fetched.
|
- [ ] Add a loading indicator while archives are being fetched.
|
||||||
- [ ] Implement a more engaging "empty state" when no archives are available.
|
- [ ] Implement a more engaging "empty state" when no archives are available.
|
||||||
@@ -165,6 +187,7 @@ These functions are frequently used and critical to the application's data flow.
|
|||||||
- [ ] Implement pagination or infinite scrolling for the archive list.
|
- [ ] Implement pagination or infinite scrolling for the archive list.
|
||||||
|
|
||||||
### Bulletin Board Module (`/idaa/bb`)
|
### Bulletin Board Module (`/idaa/bb`)
|
||||||
|
|
||||||
- [ ] **UI/UX:**
|
- [ ] **UI/UX:**
|
||||||
- [ ] Improve the UI for creating and editing posts and comments.
|
- [ ] Improve the UI for creating and editing posts and comments.
|
||||||
- [ ] Add a rich text editor for a better writing experience.
|
- [ ] Add a rich text editor for a better writing experience.
|
||||||
@@ -172,6 +195,7 @@ These functions are frequently used and critical to the application's data flow.
|
|||||||
- [ ] Implement user-specific features, such as editing their own posts and comments.
|
- [ ] Implement user-specific features, such as editing their own posts and comments.
|
||||||
|
|
||||||
### Recovery Meetings Module (`/idaa/recovery_meetings`)
|
### Recovery Meetings Module (`/idaa/recovery_meetings`)
|
||||||
|
|
||||||
- [ ] **Refactoring:**
|
- [ ] **Refactoring:**
|
||||||
- [ ] Simplify the search and filtering logic. The current implementation with `setInterval` is complex and could be replaced with a more modern approach using debouncing or reactive statements.
|
- [ ] Simplify the search and filtering logic. The current implementation with `setInterval` is complex and could be replaced with a more modern approach using debouncing or reactive statements.
|
||||||
- [ ] **UI/UX:**
|
- [ ] **UI/UX:**
|
||||||
@@ -185,11 +209,13 @@ These functions are frequently used and critical to the application's data flow.
|
|||||||
## Aether Events Module Improvements
|
## Aether Events Module Improvements
|
||||||
|
|
||||||
### General
|
### General
|
||||||
|
|
||||||
- [ ] **Dashboard:** Create a central dashboard for each event at `/events/[event_id]` that provides an overview of the event and links to all the management pages.
|
- [ ] **Dashboard:** Create a central dashboard for each event at `/events/[event_id]` that provides an overview of the event and links to all the management pages.
|
||||||
- [ ] **Component Refactoring:** The module has a large number of `ae_comp__` components. Audit and refactor them to be more modular and reusable.
|
- [ ] **Component Refactoring:** The module has a large number of `ae_comp__` components. Audit and refactor them to be more modular and reusable.
|
||||||
- [ ] **UI/UX Consistency:** Ensure a consistent look and feel across all the different event management pages.
|
- [ ] **UI/UX Consistency:** Ensure a consistent look and feel across all the different event management pages.
|
||||||
|
|
||||||
### Core Event Management
|
### Core Event Management
|
||||||
|
|
||||||
- [ ] **Event List (`/events`):**
|
- [ ] **Event List (`/events`):**
|
||||||
- [ ] Add search and filtering capabilities to the main event list.
|
- [ ] Add search and filtering capabilities to the main event list.
|
||||||
- [ ] Implement pagination for the event list.
|
- [ ] Implement pagination for the event list.
|
||||||
@@ -197,6 +223,7 @@ These functions are frequently used and critical to the application's data flow.
|
|||||||
- [ ] Create a dedicated page or modal for creating and editing events.
|
- [ ] Create a dedicated page or modal for creating and editing events.
|
||||||
|
|
||||||
### Sub-modules (`/events/[event_id]/...`)
|
### Sub-modules (`/events/[event_id]/...`)
|
||||||
|
|
||||||
- [ ] **Sessions, Presentations, Presenters, etc.:**
|
- [ ] **Sessions, Presentations, Presenters, etc.:**
|
||||||
- [ ] For each sub-module (sessions, presentations, etc.), implement a consistent set of features:
|
- [ ] For each sub-module (sessions, presentations, etc.), implement a consistent set of features:
|
||||||
- [ ] List view with search and filtering.
|
- [ ] List view with search and filtering.
|
||||||
@@ -206,14 +233,15 @@ These functions are frequently used and critical to the application's data flow.
|
|||||||
- [ ] **File Management:**
|
- [ ] **File Management:**
|
||||||
- [ ] Improve the file upload component (`ae_comp__event_files_upload.svelte`) with features like drag-and-drop and progress bars.
|
- [ ] Improve the file upload component (`ae_comp__event_files_upload.svelte`) with features like drag-and-drop and progress bars.
|
||||||
- [ ] Enhance the file list view with more details and actions.
|
- [ ] Enhance the file list view with more details and actions.
|
||||||
- [ ] **Launcher (`/events/[event_id]/launcher`):
|
- [ ] \*\*Launcher (`/events/[event_id]/launcher`):
|
||||||
- [ ] Add documentation to explain the purpose and usage of the launcher.
|
- [ ] Add documentation to explain the purpose and usage of the launcher.
|
||||||
- [ ] Improve the UI to make it more intuitive for users.
|
- [ ] Improve the UI to make it more intuitive for users.
|
||||||
- [ ] **Badges (`/events/[event_id]/badges`):
|
- [ ] \*\*Badges (`/events/[event_id]/badges`):
|
||||||
- [ ] Enhance the badge printing interface with more customization options.
|
- [ ] Enhance the badge printing interface with more customization options.
|
||||||
- [ ] Add a preview of the badge before printing.
|
- [ ] Add a preview of the badge before printing.
|
||||||
|
|
||||||
### Performance
|
### Performance
|
||||||
|
|
||||||
- [ ] **Live Queries:** Review the use of `liveQuery` throughout the module and optimize for performance, especially on pages with a large amount of data.
|
- [ ] **Live Queries:** Review the use of `liveQuery` throughout the module and optimize for performance, especially on pages with a large amount of data.
|
||||||
- [ ] **Data Loading:** Implement more efficient data loading strategies to avoid fetching unnecessary data.
|
- [ ] **Data Loading:** Implement more efficient data loading strategies to avoid fetching unnecessary data.
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,8 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
"cSpell.words": [
|
"cSpell.words": ["filelist"],
|
||||||
"filelist"
|
|
||||||
],
|
|
||||||
"git.autofetch": true,
|
"git.autofetch": true,
|
||||||
"editor.defaultFormatter": "svelte.svelte-vscode"
|
"editor.defaultFormatter": "svelte.svelte-vscode"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
71
eslint.config.cjs
Normal file
71
eslint.config.cjs
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
const { defineConfig, globalIgnores } = require('eslint/config');
|
||||||
|
|
||||||
|
const tsParser = require('@typescript-eslint/parser');
|
||||||
|
const typescriptEslint = require('@typescript-eslint/eslint-plugin');
|
||||||
|
const globals = require('globals');
|
||||||
|
const parser = require('svelte-eslint-parser');
|
||||||
|
const js = require('@eslint/js');
|
||||||
|
|
||||||
|
const { FlatCompat } = require('@eslint/eslintrc');
|
||||||
|
|
||||||
|
const compat = new FlatCompat({
|
||||||
|
baseDirectory: __dirname,
|
||||||
|
recommendedConfig: js.configs.recommended,
|
||||||
|
allConfig: js.configs.all
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = defineConfig([
|
||||||
|
{
|
||||||
|
extends: compat.extends(
|
||||||
|
'eslint:recommended',
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'prettier'
|
||||||
|
),
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
parser: tsParser,
|
||||||
|
sourceType: 'module',
|
||||||
|
ecmaVersion: 2020,
|
||||||
|
|
||||||
|
parserOptions: {
|
||||||
|
extraFileExtensions: ['.svelte']
|
||||||
|
},
|
||||||
|
|
||||||
|
globals: {
|
||||||
|
...globals.browser,
|
||||||
|
...globals.node
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
plugins: {
|
||||||
|
'@typescript-eslint': typescriptEslint
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/no-unused-vars': 'warn'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['**/*.svelte'],
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
parser: parser,
|
||||||
|
|
||||||
|
parserOptions: {
|
||||||
|
parser: '@typescript-eslint/parser'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
globalIgnores([
|
||||||
|
'**/.DS_Store',
|
||||||
|
'**/node_modules',
|
||||||
|
'build',
|
||||||
|
'.svelte-kit',
|
||||||
|
'package',
|
||||||
|
'**/.env',
|
||||||
|
'**/.env.*',
|
||||||
|
'!**/.env.example',
|
||||||
|
'**/pnpm-lock.yaml',
|
||||||
|
'**/package-lock.json',
|
||||||
|
'**/yarn.lock'
|
||||||
|
])
|
||||||
|
]);
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"paths": {
|
"paths": {
|
||||||
"$lib/*": ["./src/lib/*"]
|
"$lib/*": ["./src/lib/*"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17993
package-lock.json
generated
17993
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
249
package.json
249
package.json
@@ -1,124 +1,129 @@
|
|||||||
{
|
{
|
||||||
"name": "osit-aether-app-svelte",
|
"name": "osit-aether-app-svelte",
|
||||||
"version": "3.9.6",
|
"version": "3.9.6",
|
||||||
"description": "One Sky IT's Aether App created with Svelte, SvelteKit, Tailwind CSS, Lucide, Font Awesome, and Skeleton UI. -Scott Idem",
|
"description": "One Sky IT's Aether App created with Svelte, SvelteKit, Tailwind CSS, Lucide, Font Awesome, and Skeleton UI. -Scott Idem",
|
||||||
"homepage": "https://oneskyit.com/",
|
"homepage": "https://oneskyit.com/",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"build:prod": "cp .env.prod .env.production && vite build",
|
"build:prod": "cp .env.prod .env.production && vite build",
|
||||||
"build:staging": "cp .env.staging .env.production && vite build",
|
"build:staging": "cp .env.staging .env.production && vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test": "npm run test:integration && npm run test:unit",
|
"test": "npm run test:integration && npm run test:unit",
|
||||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||||
"lint": "prettier --check . && eslint .",
|
"lint": "prettier --check . && eslint .",
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
"test:integration": "playwright test",
|
"test:integration": "playwright test",
|
||||||
"test:unit": "vitest"
|
"test:unit": "vitest"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@playwright/test": "^1.28.1",
|
"@eslint/eslintrc": "^3.3.1",
|
||||||
"@skeletonlabs/skeleton": "^3.1.3",
|
"@eslint/js": "^9.39.1",
|
||||||
"@skeletonlabs/skeleton-svelte": "^1.2.3",
|
"@playwright/test": "^1.28.1",
|
||||||
"@sveltejs/adapter-auto": "^6.0.0",
|
"@skeletonlabs/skeleton": "^3.1.3",
|
||||||
"@sveltejs/adapter-node": "^5.0.0",
|
"@skeletonlabs/skeleton-svelte": "^1.2.3",
|
||||||
"@sveltejs/adapter-static": "^3.0.1",
|
"@sveltejs/adapter-auto": "^6.0.0",
|
||||||
"@sveltejs/kit": "^2.5.0",
|
"@sveltejs/adapter-node": "^5.0.0",
|
||||||
"@sveltejs/vite-plugin-svelte": "^5.0.0",
|
"@sveltejs/adapter-static": "^3.0.1",
|
||||||
"@tailwindcss/forms": "^0.5.7",
|
"@sveltejs/kit": "^2.5.0",
|
||||||
"@tailwindcss/typography": "^0.5.10",
|
"@sveltejs/vite-plugin-svelte": "^5.0.0",
|
||||||
"@tiptap/core": "^2.10.3",
|
"@tailwindcss/forms": "^0.5.7",
|
||||||
"@tiptap/extension-bubble-menu": "^2.10.3",
|
"@tailwindcss/typography": "^0.5.10",
|
||||||
"@tiptap/extension-code-block-lowlight": "^2.10.3",
|
"@tiptap/core": "^2.10.3",
|
||||||
"@tiptap/extension-color": "^2.10.3",
|
"@tiptap/extension-bubble-menu": "^2.10.3",
|
||||||
"@tiptap/extension-highlight": "^2.10.3",
|
"@tiptap/extension-code-block-lowlight": "^2.10.3",
|
||||||
"@tiptap/extension-image": "^2.10.3",
|
"@tiptap/extension-color": "^2.10.3",
|
||||||
"@tiptap/extension-link": "^2.10.3",
|
"@tiptap/extension-highlight": "^2.10.3",
|
||||||
"@tiptap/extension-subscript": "^2.10.3",
|
"@tiptap/extension-image": "^2.10.3",
|
||||||
"@tiptap/extension-superscript": "^2.10.3",
|
"@tiptap/extension-link": "^2.10.3",
|
||||||
"@tiptap/extension-table": "^2.10.3",
|
"@tiptap/extension-subscript": "^2.10.3",
|
||||||
"@tiptap/extension-table-cell": "^2.10.3",
|
"@tiptap/extension-superscript": "^2.10.3",
|
||||||
"@tiptap/extension-table-header": "^2.10.3",
|
"@tiptap/extension-table": "^2.10.3",
|
||||||
"@tiptap/extension-table-row": "^2.10.3",
|
"@tiptap/extension-table-cell": "^2.10.3",
|
||||||
"@tiptap/extension-task-item": "^2.10.3",
|
"@tiptap/extension-table-header": "^2.10.3",
|
||||||
"@tiptap/extension-task-list": "^2.10.3",
|
"@tiptap/extension-table-row": "^2.10.3",
|
||||||
"@tiptap/extension-text": "^2.10.3",
|
"@tiptap/extension-task-item": "^2.10.3",
|
||||||
"@tiptap/extension-text-align": "^2.10.3",
|
"@tiptap/extension-task-list": "^2.10.3",
|
||||||
"@tiptap/extension-text-style": "^2.10.3",
|
"@tiptap/extension-text": "^2.10.3",
|
||||||
"@tiptap/extension-typography": "^2.10.3",
|
"@tiptap/extension-text-align": "^2.10.3",
|
||||||
"@tiptap/extension-underline": "^2.10.3",
|
"@tiptap/extension-text-style": "^2.10.3",
|
||||||
"@tiptap/pm": "^2.10.3",
|
"@tiptap/extension-typography": "^2.10.3",
|
||||||
"@tiptap/starter-kit": "^2.10.3",
|
"@tiptap/extension-underline": "^2.10.3",
|
||||||
"@types/eslint": "^9.0.0",
|
"@tiptap/pm": "^2.10.3",
|
||||||
"@types/node": "^24.0.0",
|
"@tiptap/starter-kit": "^2.10.3",
|
||||||
"@types/qrcode": "^1.5.5",
|
"@types/eslint": "^9.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
"@types/node": "^24.0.0",
|
||||||
"@typescript-eslint/parser": "^8.0.0",
|
"@types/qrcode": "^1.5.5",
|
||||||
"bits-ui": "^2.0.0",
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
||||||
"clsx": "^2.1.1",
|
"@typescript-eslint/parser": "^8.0.0",
|
||||||
"eslint": "^9.0.0",
|
"bits-ui": "^2.0.0",
|
||||||
"eslint-config-prettier": "^10.0.0",
|
"clsx": "^2.1.1",
|
||||||
"eslint-plugin-svelte": "^3.0.0",
|
"eslint": "^9.0.0",
|
||||||
"flowbite": "^3.0.0",
|
"eslint-config-prettier": "^10.0.0",
|
||||||
"highlight.js": "^11.10.0",
|
"eslint-plugin-svelte": "^3.0.0",
|
||||||
"lowlight": "^3.2.0",
|
"flowbite": "^3.0.0",
|
||||||
"mode-watcher": "^1.0.0",
|
"globals": "^16.5.0",
|
||||||
"prettier": "^3.1.1",
|
"highlight.js": "^11.10.0",
|
||||||
"prettier-plugin-svelte": "^3.1.2",
|
"lowlight": "^3.2.0",
|
||||||
"sass-embedded": "^1.81.0",
|
"mode-watcher": "^1.0.0",
|
||||||
"svelte": "^5.0.0",
|
"prettier": "^3.1.1",
|
||||||
"svelte-awesome-color-picker": "^4.0.0",
|
"prettier-plugin-svelte": "^3.1.2",
|
||||||
"svelte-check": "^4.0.0",
|
"sass-embedded": "^1.81.0",
|
||||||
"svelte-highlight": "^7.8.4",
|
"svelte": "^5.0.0",
|
||||||
"svelte-idle": "^3.0.1",
|
"svelte-awesome-color-picker": "^4.0.0",
|
||||||
"svelte-tiptap": "^2.1.0",
|
"svelte-check": "^4.0.0",
|
||||||
"tailwind-merge": "^3.0.0",
|
"svelte-highlight": "^7.8.4",
|
||||||
"tailwind-variants": "^2.1.0",
|
"svelte-idle": "^3.0.1",
|
||||||
"tailwindcss": "^4.1.10",
|
"svelte-tiptap": "^2.1.0",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwind-merge": "^3.0.0",
|
||||||
"tslib": "^2.4.1",
|
"tailwind-variants": "^2.1.0",
|
||||||
"typescript": "^5.0.0",
|
"tailwindcss": "^4.1.10",
|
||||||
"typescript-svelte-plugin": "^0.3.50",
|
"tailwindcss-animate": "^1.0.7",
|
||||||
"vite": "^6.0.0",
|
"tslib": "^2.4.1",
|
||||||
"vitest": "^3.0.0"
|
"typescript": "^5.0.0",
|
||||||
},
|
"typescript-svelte-plugin": "^0.3.50",
|
||||||
"vitest": {
|
"vite": "^6.0.0",
|
||||||
"exclude": ["tests"]
|
"vitest": "^3.0.0"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"vitest": {
|
||||||
"dependencies": {
|
"exclude": [
|
||||||
"@codemirror/commands": "^6.8.1",
|
"tests"
|
||||||
"@codemirror/gutter": "^0.19.9",
|
]
|
||||||
"@codemirror/lang-css": "^6.3.1",
|
},
|
||||||
"@codemirror/lang-html": "^6.4.9",
|
"type": "module",
|
||||||
"@codemirror/lang-javascript": "^6.2.3",
|
"dependencies": {
|
||||||
"@codemirror/lang-json": "^6.0.1",
|
"@codemirror/commands": "^6.8.1",
|
||||||
"@codemirror/lang-markdown": "^6.3.2",
|
"@codemirror/gutter": "^0.19.9",
|
||||||
"@codemirror/language": "^6.11.0",
|
"@codemirror/lang-css": "^6.3.1",
|
||||||
"@codemirror/language-data": "^6.5.1",
|
"@codemirror/lang-html": "^6.4.9",
|
||||||
"@codemirror/theme-one-dark": "^6.1.2",
|
"@codemirror/lang-javascript": "^6.2.3",
|
||||||
"@codemirror/view": "^6.36.8",
|
"@codemirror/lang-json": "^6.0.1",
|
||||||
"@floating-ui/dom": "^1.6.0",
|
"@codemirror/lang-markdown": "^6.3.2",
|
||||||
"@lucide/svelte": "0.*.0",
|
"@codemirror/language": "^6.11.0",
|
||||||
"@popperjs/core": "^2.11.0",
|
"@codemirror/language-data": "^6.5.1",
|
||||||
"@tailwindcss/vite": "^4.1.10",
|
"@codemirror/theme-one-dark": "^6.1.2",
|
||||||
"@tiptap/extension-bullet-list": "^2.10.2",
|
"@codemirror/view": "^6.36.8",
|
||||||
"@tiptap/extension-document": "^2.10.2",
|
"@floating-ui/dom": "^1.6.0",
|
||||||
"@tiptap/extension-history": "^2.10.2",
|
"@lucide/svelte": "0.*.0",
|
||||||
"@tiptap/extension-paragraph": "^2.10.2",
|
"@popperjs/core": "^2.11.0",
|
||||||
"axios": "^1.7.0",
|
"@tailwindcss/vite": "^4.1.10",
|
||||||
"codemirror": "^6.0.1",
|
"@tiptap/extension-bullet-list": "^2.10.2",
|
||||||
"dayjs": "^1.11.10",
|
"@tiptap/extension-document": "^2.10.2",
|
||||||
"dexie": "^4.0.0",
|
"@tiptap/extension-history": "^2.10.2",
|
||||||
"flowbite-svelte": "^1.7.0",
|
"@tiptap/extension-paragraph": "^2.10.2",
|
||||||
"html5-qrcode": "^2.3.8",
|
"axios": "^1.7.0",
|
||||||
"lucide-svelte": "0.*.0",
|
"codemirror": "^6.0.1",
|
||||||
"marked": "^16.0.0",
|
"dayjs": "^1.11.10",
|
||||||
"openai": "^5.20.1",
|
"dexie": "^4.0.0",
|
||||||
"qrcode": "^1.5.4",
|
"flowbite-svelte": "^1.7.0",
|
||||||
"shadcn-svelte": "^1.0.0",
|
"html5-qrcode": "^2.3.8",
|
||||||
"svelte-persisted-store": "^0.12.0"
|
"lucide-svelte": "0.*.0",
|
||||||
}
|
"marked": "^16.0.0",
|
||||||
|
"openai": "^5.20.1",
|
||||||
|
"qrcode": "^1.5.4",
|
||||||
|
"shadcn-svelte": "^1.0.0",
|
||||||
|
"svelte-persisted-store": "^0.12.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { PlaywrightTestConfig } from '@playwright/test';
|
|||||||
const config: PlaywrightTestConfig = {
|
const config: PlaywrightTestConfig = {
|
||||||
webServer: {
|
webServer: {
|
||||||
command: 'npm run build && npm run preview',
|
command: 'npm run build && npm run preview',
|
||||||
port: 4173,
|
port: 4173
|
||||||
// url: 'http://scott.localhost:5173',
|
// url: 'http://scott.localhost:5173',
|
||||||
// reuseExistingServer: true,
|
// reuseExistingServer: true,
|
||||||
// stderr: 'pipe',
|
// stderr: 'pipe',
|
||||||
@@ -14,8 +14,8 @@ const config: PlaywrightTestConfig = {
|
|||||||
reporter: 'list',
|
reporter: 'list',
|
||||||
use: {
|
use: {
|
||||||
// Collect trace when retrying the failed test.
|
// Collect trace when retrying the failed test.
|
||||||
trace: 'on-first-retry',
|
trace: 'on-first-retry'
|
||||||
},
|
}
|
||||||
// grep: /@node_modules/,
|
// grep: /@node_modules/,
|
||||||
// grepInverse: /@node_modules/,
|
// grepInverse: /@node_modules/,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,10 +48,6 @@
|
|||||||
|
|
||||||
--color-primary-contrast-light: var(--color-primary-50);
|
--color-primary-contrast-light: var(--color-primary-50);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--color-primary-contrast-500: var(--color-primary-contrast-light);
|
--color-primary-contrast-500: var(--color-primary-contrast-light);
|
||||||
--color-primary-contrast-600: 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-700: var(--color-primary-contrast-light);
|
||||||
@@ -72,11 +68,6 @@
|
|||||||
|
|
||||||
--color-secondary-contrast-light: var(--color-secondary-50);
|
--color-secondary-contrast-light: var(--color-secondary-50);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--color-secondary-contrast-600: 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-700: var(--color-secondary-contrast-light);
|
||||||
--color-secondary-contrast-800: var(--color-secondary-contrast-light);
|
--color-secondary-contrast-800: var(--color-secondary-contrast-light);
|
||||||
@@ -96,13 +87,6 @@
|
|||||||
|
|
||||||
--color-tertiary-contrast-light: var(--color-tertiary-50);
|
--color-tertiary-contrast-light: var(--color-tertiary-50);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--color-tertiary-contrast-800: 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-900: var(--color-tertiary-contrast-light);
|
||||||
--color-tertiary-contrast-950: var(--color-tertiary-contrast-light);
|
--color-tertiary-contrast-950: var(--color-tertiary-contrast-light);
|
||||||
@@ -120,13 +104,6 @@
|
|||||||
|
|
||||||
--color-success-contrast-light: var(--color-success-50);
|
--color-success-contrast-light: var(--color-success-50);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--color-success-contrast-800: 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-900: var(--color-success-contrast-light);
|
||||||
--color-success-contrast-950: var(--color-success-contrast-light);
|
--color-success-contrast-950: var(--color-success-contrast-light);
|
||||||
@@ -144,13 +121,6 @@
|
|||||||
|
|
||||||
--color-warning-contrast-light: var(--color-warning-50);
|
--color-warning-contrast-light: var(--color-warning-50);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--color-warning-contrast-800: 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-900: var(--color-warning-contrast-light);
|
||||||
--color-warning-contrast-950: var(--color-warning-contrast-light);
|
--color-warning-contrast-950: var(--color-warning-contrast-light);
|
||||||
@@ -168,9 +138,6 @@
|
|||||||
|
|
||||||
--color-error-contrast-light: var(--color-error-50);
|
--color-error-contrast-light: var(--color-error-50);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--color-error-contrast-400: var(--color-error-contrast-light);
|
--color-error-contrast-400: var(--color-error-contrast-light);
|
||||||
--color-error-contrast-500: 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-600: var(--color-error-contrast-light);
|
||||||
@@ -192,14 +159,8 @@
|
|||||||
|
|
||||||
--color-surface-contrast-light: var(--color-surface-50);
|
--color-surface-contrast-light: var(--color-surface-50);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--color-surface-contrast-700: var(--color-surface-contrast-light);
|
--color-surface-contrast-700: var(--color-surface-contrast-light);
|
||||||
--color-surface-contrast-800: 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-900: var(--color-surface-contrast-light);
|
||||||
--color-surface-contrast-950: var(--color-surface-contrast-light);
|
--color-surface-contrast-950: var(--color-surface-contrast-light);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,4 +202,4 @@
|
|||||||
--color-surface-contrast-800: 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-900: var(--color-surface-contrast-light);
|
||||||
--color-surface-contrast-950: var(--color-surface-contrast-light);
|
--color-surface-contrast-950: var(--color-surface-contrast-light);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,4 +202,4 @@
|
|||||||
--color-surface-contrast-800: 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-900: var(--color-surface-contrast-light);
|
||||||
--color-surface-contrast-950: var(--color-surface-contrast-light);
|
--color-surface-contrast-950: var(--color-surface-contrast-light);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,4 +202,4 @@
|
|||||||
--color-surface-contrast-800: 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-900: var(--color-surface-contrast-light);
|
||||||
--color-surface-contrast-950: var(--color-surface-contrast-light);
|
--color-surface-contrast-950: var(--color-surface-contrast-light);
|
||||||
}
|
}
|
||||||
|
|||||||
635
src/app.css
635
src/app.css
File diff suppressed because it is too large
Load Diff
57
src/app.html
57
src/app.html
@@ -1,30 +1,43 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="en" class="light" data-theme="">
|
<html lang="en" class="light" data-theme="">
|
||||||
<head>
|
<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">
|
<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, initial-scale=1.0" />
|
||||||
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
|
<link
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Serif:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
|
href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap"
|
||||||
<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">
|
rel="stylesheet"
|
||||||
|
/>
|
||||||
|
<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
|
||||||
|
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 href="app.css" rel="stylesheet"> -->
|
||||||
|
|
||||||
%sveltekit.head%
|
%sveltekit.head%
|
||||||
</head>
|
</head>
|
||||||
<!-- h-full w-full overflow-auto -->
|
<!-- h-full w-full overflow-auto -->
|
||||||
<!-- overflow-x-scroll -->
|
<!-- overflow-x-scroll -->
|
||||||
<body data-sveltekit-preload-data="hover" class="h-full w-full">
|
<body data-sveltekit-preload-data="hover" class="h-full w-full">
|
||||||
|
<div style="display: contents" class="">%sveltekit.body%</div>
|
||||||
<div style="display: contents" class="">%sveltekit.body%</div>
|
</body>
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,546 +0,0 @@
|
|||||||
@import "tailwindcss/preflight";
|
|
||||||
@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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* 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; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
.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,130 @@
|
|||||||
// import axios from 'axios';
|
// import axios from 'axios';
|
||||||
|
|
||||||
// Updated 2024-05-23
|
// Updated 2024-05-23
|
||||||
export let delete_object = async function delete_object(
|
export const delete_object = async function delete_object({
|
||||||
{
|
api_cfg = null,
|
||||||
api_cfg = null,
|
endpoint = '',
|
||||||
endpoint = '',
|
params = {},
|
||||||
params = {},
|
data = {},
|
||||||
data = {},
|
return_meta = false,
|
||||||
return_meta = false,
|
log_lvl = 0,
|
||||||
log_lvl = 0,
|
retry_count = 5 // Number of retry attempts
|
||||||
retry_count = 5 // Number of retry attempts
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
endpoint: string;
|
||||||
endpoint: string,
|
params?: any;
|
||||||
params?: any,
|
data?: any;
|
||||||
data?: any,
|
return_meta?: boolean;
|
||||||
return_meta?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number,
|
retry_count?: number;
|
||||||
retry_count?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** delete_object() *** Endpoint: ${endpoint}`);
|
||||||
if (log_lvl) {
|
console.log('Params:', params);
|
||||||
console.log(`*** delete_object() *** Endpoint: ${endpoint}`);
|
if (log_lvl > 1) {
|
||||||
console.log('Params:', params);
|
console.log('Data:', data);
|
||||||
if (log_lvl > 1) {
|
}
|
||||||
console.log('Data:', data);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!api_cfg) {
|
if (!api_cfg) {
|
||||||
console.error('No API Config was provided. Returning false.');
|
console.error('No API Config was provided. Returning false.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the URL with query parameters
|
// Construct the URL with query parameters
|
||||||
const url = new URL(endpoint, api_cfg['base_url']);
|
const url = new URL(endpoint, api_cfg['base_url']);
|
||||||
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));
|
Object.keys(params).forEach((key) => url.searchParams.append(key, params[key]));
|
||||||
|
|
||||||
// Clean the headers
|
// Clean the headers
|
||||||
let headers_cleaned: Record<string, string> = {};
|
const headers_cleaned: Record<string, string> = {};
|
||||||
for (const prop in api_cfg['headers']) {
|
for (const prop in api_cfg['headers']) {
|
||||||
let prop_cleaned = prop.replaceAll('_', '-');
|
const prop_cleaned = prop.replaceAll('_', '-');
|
||||||
headers_cleaned[prop_cleaned] = api_cfg['headers'][prop];
|
headers_cleaned[prop_cleaned] = api_cfg['headers'][prop];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log('Cleaned Headers:', headers_cleaned);
|
console.log('Cleaned Headers:', headers_cleaned);
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchOptions: RequestInit = {
|
const fetchOptions: RequestInit = {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
...headers_cleaned,
|
...headers_cleaned,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify(data)
|
body: JSON.stringify(data)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log('Fetch Options:', fetchOptions);
|
console.log('Fetch Options:', fetchOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let attempt = 1; attempt <= retry_count; attempt++) {
|
for (let attempt = 1; attempt <= retry_count; attempt++) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url.toString(), fetchOptions);
|
const response = await fetch(url.toString(), fetchOptions);
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`Response: status=${response.status} attempt=${attempt}`);
|
console.log(`Response: status=${response.status} attempt=${attempt}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
if (response.status === 404) {
|
if (response.status === 404) {
|
||||||
console.warn('404 Not Found. Returning null.');
|
console.warn('404 Not Found. Returning null.');
|
||||||
return null; // Returning null since there were no results
|
return null; // Returning null since there were no results
|
||||||
}
|
}
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
|
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log('Response JSON:', json);
|
console.log('Response JSON:', json);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the response data or metadata
|
// Return the response data or metadata
|
||||||
return return_meta ? json : json.data;
|
return return_meta ? json : json.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`API DELETE error on attempt ${attempt}:`, error);
|
console.error(`API DELETE error on attempt ${attempt}:`, error);
|
||||||
|
|
||||||
// If this is the last attempt, return false
|
// If this is the last attempt, return false
|
||||||
if (attempt === retry_count) {
|
if (attempt === retry_count) {
|
||||||
console.error('Max retry attempts reached. Returning false.');
|
console.error('Max retry attempts reached. Returning false.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log retry information
|
// Log retry information
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`Retrying... (${attempt}/${retry_count})`);
|
console.log(`Retrying... (${attempt}/${retry_count})`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://stackoverflow.com/questions/51069552/axios-delete-request-with-body-and-headers
|
||||||
|
|
||||||
// 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'];
|
||||||
|
|
||||||
// let axios_api = axios.create({
|
// //OLD: axios_api.delete(endpoint, { 'data': data })
|
||||||
// baseURL: api_cfg['base_url'],
|
// let response_data = await axios_api.delete(endpoint, { params: params, 'data': data })
|
||||||
// // timeout: 2000,
|
// .then(function (response) {
|
||||||
// /* other custom settings */
|
// console.log(response.data);
|
||||||
// });
|
// return response.data;
|
||||||
// axios_api.defaults.headers = api_cfg['headers'];
|
// })
|
||||||
|
// .catch(function (error: any) {
|
||||||
|
// 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;
|
||||||
|
// });
|
||||||
|
|
||||||
// //OLD: axios_api.delete(endpoint, { 'data': data })
|
// if (log_lvl > 1) {
|
||||||
// let response_data = await axios_api.delete(endpoint, { params: params, 'data': data })
|
// console.log(response_data);
|
||||||
// .then(function (response) {
|
// }
|
||||||
// console.log(response.data);
|
// return response_data;
|
||||||
// return response.data;
|
};
|
||||||
// })
|
|
||||||
// .catch(function (error: any) {
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,174 +2,171 @@ import type { key_val } from '$lib/stores/ae_stores';
|
|||||||
import { get_object } from './api_get_object';
|
import { get_object } from './api_get_object';
|
||||||
|
|
||||||
// Updated 2023-12-01
|
// Updated 2023-12-01
|
||||||
export async function get_ae_obj_id_crud(
|
export async function get_ae_obj_id_crud({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
no_account_id = false,
|
||||||
no_account_id = false,
|
obj_type,
|
||||||
obj_type,
|
obj_id,
|
||||||
obj_id,
|
use_alt_table = false,
|
||||||
use_alt_table = false,
|
use_alt_base = false,
|
||||||
use_alt_base = false,
|
inc = {},
|
||||||
inc = {},
|
enabled = 'enabled',
|
||||||
enabled = 'enabled',
|
hidden = 'not_hidden',
|
||||||
hidden = 'not_hidden',
|
limit = 999999,
|
||||||
limit = 999999,
|
offset = 0,
|
||||||
offset = 0,
|
data = {},
|
||||||
data = {},
|
// key,
|
||||||
// key,
|
// jwt = null,
|
||||||
// jwt = null,
|
headers = {},
|
||||||
headers = {},
|
params = {},
|
||||||
params = {},
|
timeout = 25000,
|
||||||
timeout = 25000,
|
return_meta = false,
|
||||||
return_meta = false,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
no_account_id?: boolean;
|
||||||
no_account_id?: boolean,
|
obj_type: string;
|
||||||
obj_type: string,
|
obj_id: string;
|
||||||
obj_id: string,
|
use_alt_table?: boolean;
|
||||||
use_alt_table?: boolean,
|
use_alt_base?: boolean;
|
||||||
use_alt_base?: boolean,
|
inc?: any;
|
||||||
inc?: any,
|
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
|
||||||
enabled?: "enabled" | "all" | "not_enabled" | undefined,
|
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
|
||||||
hidden?: "hidden" | "all" | "not_hidden" | undefined,
|
limit?: number;
|
||||||
limit?: number,
|
offset?: number;
|
||||||
offset?: number,
|
data?: any;
|
||||||
data?: any,
|
// key: string,
|
||||||
// key: string,
|
// jwt?: string,
|
||||||
// jwt?: string,
|
headers?: any;
|
||||||
headers?: any,
|
params?: key_val;
|
||||||
params?: key_val,
|
timeout?: number;
|
||||||
timeout?: number,
|
return_meta?: boolean;
|
||||||
return_meta?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log('*** get_ae_obj_id_crud() ***');
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log('*** get_ae_obj_id_crud() ***');
|
|
||||||
}
|
|
||||||
|
|
||||||
// data = {};
|
// data = {};
|
||||||
// data['super_key'] = key;
|
// data['super_key'] = key;
|
||||||
// data['jwt'] = jwt;
|
// data['jwt'] = jwt;
|
||||||
// NOTE: The key and or JWT should be in the header of the DELETE, GET, PATCH, POST
|
// NOTE: The key and or JWT should be in the header of the DELETE, GET, PATCH, POST
|
||||||
|
|
||||||
let endpoint = '';
|
let endpoint = '';
|
||||||
if (obj_type == 'account') {
|
if (obj_type == 'account') {
|
||||||
endpoint = `/crud/account/${obj_id}`;
|
endpoint = `/crud/account/${obj_id}`;
|
||||||
} else if (obj_type == 'address') {
|
} else if (obj_type == 'address') {
|
||||||
endpoint = `/crud/address/${obj_id}`;
|
endpoint = `/crud/address/${obj_id}`;
|
||||||
} else if (obj_type == 'archive') {
|
} else if (obj_type == 'archive') {
|
||||||
endpoint = `/crud/archive/${obj_id}`;
|
endpoint = `/crud/archive/${obj_id}`;
|
||||||
} else if (obj_type == 'archive_content') {
|
} else if (obj_type == 'archive_content') {
|
||||||
endpoint = `/crud/archive/content/${obj_id}`;
|
endpoint = `/crud/archive/content/${obj_id}`;
|
||||||
} else if (obj_type == 'contact') {
|
} else if (obj_type == 'contact') {
|
||||||
endpoint = `/crud/contact/${obj_id}`;
|
endpoint = `/crud/contact/${obj_id}`;
|
||||||
} else if (obj_type == 'data_store') {
|
} else if (obj_type == 'data_store') {
|
||||||
endpoint = `/crud/data_store/${obj_id}`;
|
endpoint = `/crud/data_store/${obj_id}`;
|
||||||
} else if (obj_type == 'event') {
|
} else if (obj_type == 'event') {
|
||||||
endpoint = `/crud/event/${obj_id}`;
|
endpoint = `/crud/event/${obj_id}`;
|
||||||
} else if (obj_type == 'event_abstract') {
|
} else if (obj_type == 'event_abstract') {
|
||||||
endpoint = `/crud/event/abstract/${obj_id}`;
|
endpoint = `/crud/event/abstract/${obj_id}`;
|
||||||
} else if (obj_type == 'event_badge') {
|
} else if (obj_type == 'event_badge') {
|
||||||
endpoint = `/crud/event/badge/${obj_id}`;
|
endpoint = `/crud/event/badge/${obj_id}`;
|
||||||
} else if (obj_type == 'event_device') {
|
} else if (obj_type == 'event_device') {
|
||||||
endpoint = `/crud/event/device/${obj_id}`;
|
endpoint = `/crud/event/device/${obj_id}`;
|
||||||
} else if (obj_type == 'event_exhibit') {
|
} else if (obj_type == 'event_exhibit') {
|
||||||
endpoint = `/crud/event/exhibit/${obj_id}`;
|
endpoint = `/crud/event/exhibit/${obj_id}`;
|
||||||
} else if (obj_type == 'event_exhibit_tracking') {
|
} else if (obj_type == 'event_exhibit_tracking') {
|
||||||
endpoint = `/crud/event/exhibit/tracking/${obj_id}`;
|
endpoint = `/crud/event/exhibit/tracking/${obj_id}`;
|
||||||
} else if (obj_type == 'event_file') {
|
} else if (obj_type == 'event_file') {
|
||||||
endpoint = `/crud/event/file/${obj_id}`;
|
endpoint = `/crud/event/file/${obj_id}`;
|
||||||
} else if (obj_type == 'event_location') {
|
} else if (obj_type == 'event_location') {
|
||||||
endpoint = `/crud/event/location/${obj_id}`;
|
endpoint = `/crud/event/location/${obj_id}`;
|
||||||
} else if (obj_type == 'event_person') {
|
} else if (obj_type == 'event_person') {
|
||||||
endpoint = `/crud/event/person/${obj_id}`;
|
endpoint = `/crud/event/person/${obj_id}`;
|
||||||
} else if (obj_type == 'event_presentation') {
|
} else if (obj_type == 'event_presentation') {
|
||||||
endpoint = `/crud/event/presentation/${obj_id}`;
|
endpoint = `/crud/event/presentation/${obj_id}`;
|
||||||
} else if (obj_type == 'event_presenter') {
|
} else if (obj_type == 'event_presenter') {
|
||||||
endpoint = `/crud/event/presenter/${obj_id}`;
|
endpoint = `/crud/event/presenter/${obj_id}`;
|
||||||
} else if (obj_type == 'event_session') {
|
} else if (obj_type == 'event_session') {
|
||||||
endpoint = `/crud/event/session/${obj_id}`;
|
endpoint = `/crud/event/session/${obj_id}`;
|
||||||
} else if (obj_type == 'event_track') {
|
} else if (obj_type == 'event_track') {
|
||||||
endpoint = `/crud/event/track/${obj_id}`;
|
endpoint = `/crud/event/track/${obj_id}`;
|
||||||
} else if (obj_type == 'grant') {
|
} else if (obj_type == 'grant') {
|
||||||
endpoint = `/crud/grant/${obj_id}`;
|
endpoint = `/crud/grant/${obj_id}`;
|
||||||
} else if (obj_type == 'hosted_file') {
|
} else if (obj_type == 'hosted_file') {
|
||||||
endpoint = `/crud/hosted_file/${obj_id}`;
|
endpoint = `/crud/hosted_file/${obj_id}`;
|
||||||
} else if (obj_type == 'journal') {
|
} else if (obj_type == 'journal') {
|
||||||
endpoint = `/crud/journal/${obj_id}`;
|
endpoint = `/crud/journal/${obj_id}`;
|
||||||
} else if (obj_type == 'journal_entry') {
|
} else if (obj_type == 'journal_entry') {
|
||||||
endpoint = `/crud/journal/entry/${obj_id}`;
|
endpoint = `/crud/journal/entry/${obj_id}`;
|
||||||
} else if (obj_type == 'order') {
|
} else if (obj_type == 'order') {
|
||||||
endpoint = `/crud/order/${obj_id}`;
|
endpoint = `/crud/order/${obj_id}`;
|
||||||
} else if (obj_type == 'order_line') {
|
} else if (obj_type == 'order_line') {
|
||||||
endpoint = `/crud/order/line/${obj_id}`;
|
endpoint = `/crud/order/line/${obj_id}`;
|
||||||
} else if (obj_type == 'page') {
|
} else if (obj_type == 'page') {
|
||||||
endpoint = `/crud/page/${obj_id}`;
|
endpoint = `/crud/page/${obj_id}`;
|
||||||
} else if (obj_type == 'person') {
|
} else if (obj_type == 'person') {
|
||||||
endpoint = `/crud/person/${obj_id}`;
|
endpoint = `/crud/person/${obj_id}`;
|
||||||
} else if (obj_type == 'post') {
|
} else if (obj_type == 'post') {
|
||||||
endpoint = `/crud/post/${obj_id}`;
|
endpoint = `/crud/post/${obj_id}`;
|
||||||
} else if (obj_type == 'post_comment') {
|
} else if (obj_type == 'post_comment') {
|
||||||
endpoint = `/crud/post/comment/${obj_id}`;
|
endpoint = `/crud/post/comment/${obj_id}`;
|
||||||
} else if (obj_type == 'site') {
|
} else if (obj_type == 'site') {
|
||||||
endpoint = `/crud/site/${obj_id}`;
|
endpoint = `/crud/site/${obj_id}`;
|
||||||
} else if (obj_type == 'site_domain') {
|
} else if (obj_type == 'site_domain') {
|
||||||
endpoint = `/crud/site/domain/${obj_id}`;
|
endpoint = `/crud/site/domain/${obj_id}`;
|
||||||
} else if (obj_type == 'sponsorship_cfg') {
|
} else if (obj_type == 'sponsorship_cfg') {
|
||||||
endpoint = `/crud/sponsorship/cfg/${obj_id}`;
|
endpoint = `/crud/sponsorship/cfg/${obj_id}`;
|
||||||
} else if (obj_type == 'sponsorship') {
|
} else if (obj_type == 'sponsorship') {
|
||||||
endpoint = `/crud/sponsorship/${obj_id}`;
|
endpoint = `/crud/sponsorship/${obj_id}`;
|
||||||
// } else if (obj_type == 'user') {
|
// } else if (obj_type == 'user') {
|
||||||
// endpoint = `/crud/user/${obj_id}`;
|
// endpoint = `/crud/user/${obj_id}`;
|
||||||
} else {
|
} else {
|
||||||
console.log(`Unknown object type: ${obj_type}`);
|
console.log(`Unknown object type: ${obj_type}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Endpoint:', endpoint);
|
console.log('Endpoint:', endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
params['use_alt_table'] = use_alt_table;
|
params['use_alt_table'] = use_alt_table;
|
||||||
params['use_alt_base'] = use_alt_base;
|
params['use_alt_base'] = use_alt_base;
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Params:', params);
|
console.log('Params:', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (no_account_id) {
|
if (no_account_id) {
|
||||||
headers['x-no-account-id'] = 'Nothing to See Here';
|
headers['x-no-account-id'] = 'Nothing to See Here';
|
||||||
delete headers['x-account-id'];
|
delete headers['x-account-id'];
|
||||||
delete api_cfg['headers']['x-account-id'];
|
delete api_cfg['headers']['x-account-id'];
|
||||||
// headers['x-account-id'] = null;
|
// headers['x-account-id'] = null;
|
||||||
// headers['x-account-id'] = '_XY7DXtc9Mxx';
|
// headers['x-account-id'] = '_XY7DXtc9Mxx';
|
||||||
// params['x_no_account_id_token'] = 'Nothing to See Here';
|
// params['x_no_account_id_token'] = 'Nothing to See Here';
|
||||||
|
|
||||||
// Remove the x-account-id header
|
// Remove the x-account-id header
|
||||||
// if (headers['x-account-id']) {
|
// if (headers['x-account-id']) {
|
||||||
// delete headers['x-account-id'];
|
// delete headers['x-account-id'];
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// headers['x-account-id'] = null;
|
// headers['x-account-id'] = null;
|
||||||
// headers['x-no-account-id-token'] = 'Nothing to See Here'; // get_object() will fix the underscores to dashes
|
// headers['x-no-account-id-token'] = 'Nothing to See Here'; // get_object() will fix the underscores to dashes
|
||||||
}
|
}
|
||||||
|
|
||||||
let object_obj_get_promise = await get_object({
|
const object_obj_get_promise = await get_object({
|
||||||
api_cfg: api_cfg,
|
api_cfg: api_cfg,
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
params: params,
|
params: params,
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
log_lvl: log_lvl
|
log_lvl: log_lvl
|
||||||
})
|
}).catch(function (error: any) {
|
||||||
.catch(function (error: any) {
|
console.log('API GET CRUD object ID request failed.', error);
|
||||||
console.log('API GET CRUD object ID request failed.', error);
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log('GET Object result =', object_obj_get_promise);
|
console.log('GET Object result =', object_obj_get_promise);
|
||||||
}
|
}
|
||||||
|
|
||||||
return object_obj_get_promise;
|
return object_obj_get_promise;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,227 +3,227 @@ import { get_object } from './api_get_object';
|
|||||||
|
|
||||||
// The lookup "obj_type" should broken out into a separate function. - 2024-08-07
|
// The lookup "obj_type" should broken out into a separate function. - 2024-08-07
|
||||||
// Updated 2023-11-15
|
// Updated 2023-11-15
|
||||||
export async function get_ae_obj_li_for_obj_id_crud(
|
export async function get_ae_obj_li_for_obj_id_crud({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
obj_type,
|
||||||
obj_type,
|
for_obj_type,
|
||||||
for_obj_type,
|
for_obj_id, // NOTE: Changed 2023-12-06 to no longer required
|
||||||
for_obj_id, // NOTE: Changed 2023-12-06 to no longer required
|
use_alt_table = false,
|
||||||
use_alt_table = false,
|
use_alt_base = false,
|
||||||
use_alt_base = false,
|
// inc = {},
|
||||||
// inc = {},
|
enabled = 'enabled',
|
||||||
enabled = 'enabled',
|
hidden = 'not_hidden',
|
||||||
hidden = 'not_hidden',
|
order_by_li = null,
|
||||||
order_by_li = null,
|
limit = 999999,
|
||||||
limit = 999999,
|
offset = 0,
|
||||||
offset = 0,
|
// key,
|
||||||
// key,
|
// jwt = null,
|
||||||
// jwt = null,
|
headers = {},
|
||||||
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" } }
|
||||||
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.
|
||||||
// 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 = {},
|
||||||
params = {},
|
return_meta = false,
|
||||||
return_meta = false,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
obj_type: string;
|
||||||
obj_type: string,
|
for_obj_type: null | string;
|
||||||
for_obj_type: null|string,
|
for_obj_id?: string;
|
||||||
for_obj_id?: string,
|
use_alt_table?: boolean;
|
||||||
use_alt_table?: boolean,
|
use_alt_base?: boolean;
|
||||||
use_alt_base?: boolean,
|
// inc?: key_val
|
||||||
// inc?: key_val
|
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
|
||||||
enabled?: "enabled" | "all" | "not_enabled" | undefined,
|
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
|
||||||
hidden?: "hidden" | "all" | "not_hidden" | undefined,
|
order_by_li?: any;
|
||||||
order_by_li?: any,
|
limit?: number;
|
||||||
limit?: number,
|
offset?: number;
|
||||||
offset?: number,
|
// key: string,
|
||||||
// key: string,
|
// jwt?: string,
|
||||||
// jwt?: string,
|
headers?: any;
|
||||||
headers?: any,
|
params_json?: any;
|
||||||
params_json?: any,
|
// json_obj?: any,
|
||||||
// json_obj?: any,
|
params?: key_val;
|
||||||
params?: key_val,
|
return_meta?: boolean;
|
||||||
return_meta?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** get_ae_obj_li_for_obj_id_crud() *** [${obj_type}]`);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`*** get_ae_obj_li_for_obj_id_crud() *** [${obj_type}]`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// data = {};
|
// data = {};
|
||||||
// data['super_key'] = key;
|
// data['super_key'] = key;
|
||||||
// data['jwt'] = jwt;
|
// data['jwt'] = jwt;
|
||||||
// NOTE: The key and or JWT should be in the header of the DELETE, GET, PATCH, POST
|
// NOTE: The key and or JWT should be in the header of the DELETE, GET, PATCH, POST
|
||||||
|
|
||||||
// const endpoint = `/crud/${obj_type}/list`;
|
// const endpoint = `/crud/${obj_type}/list`;
|
||||||
|
|
||||||
let endpoint = '';
|
let endpoint = '';
|
||||||
if (obj_type == 'account') {
|
if (obj_type == 'account') {
|
||||||
endpoint = `/crud/account/list`;
|
endpoint = `/crud/account/list`;
|
||||||
} else if (obj_type == 'address') {
|
} else if (obj_type == 'address') {
|
||||||
endpoint = `/crud/address/list`;
|
endpoint = `/crud/address/list`;
|
||||||
} else if (obj_type == 'archive') {
|
} else if (obj_type == 'archive') {
|
||||||
endpoint = `/crud/archive/list`;
|
endpoint = `/crud/archive/list`;
|
||||||
} else if (obj_type == 'archive_content') {
|
} else if (obj_type == 'archive_content') {
|
||||||
endpoint = `/crud/archive/content/list`;
|
endpoint = `/crud/archive/content/list`;
|
||||||
} else if (obj_type == 'contact') {
|
} else if (obj_type == 'contact') {
|
||||||
endpoint = `/crud/contact/list`;
|
endpoint = `/crud/contact/list`;
|
||||||
} else if (obj_type == 'data_store') {
|
} else if (obj_type == 'data_store') {
|
||||||
endpoint = `/crud/data_store/list`;
|
endpoint = `/crud/data_store/list`;
|
||||||
} else if (obj_type == 'event') {
|
} else if (obj_type == 'event') {
|
||||||
endpoint = `/crud/event/list`;
|
endpoint = `/crud/event/list`;
|
||||||
} else if (obj_type == 'event_abstract') {
|
} else if (obj_type == 'event_abstract') {
|
||||||
endpoint = `/crud/event/abstract/list`;
|
endpoint = `/crud/event/abstract/list`;
|
||||||
} else if (obj_type == 'event_badge') {
|
} else if (obj_type == 'event_badge') {
|
||||||
endpoint = `/crud/event/badge/list`;
|
endpoint = `/crud/event/badge/list`;
|
||||||
} else if (obj_type == 'event_device') {
|
} else if (obj_type == 'event_device') {
|
||||||
endpoint = `/crud/event/device/list`;
|
endpoint = `/crud/event/device/list`;
|
||||||
} else if (obj_type == 'event_exhibit') {
|
} else if (obj_type == 'event_exhibit') {
|
||||||
endpoint = `/crud/event/exhibit/list`;
|
endpoint = `/crud/event/exhibit/list`;
|
||||||
} else if (obj_type == 'event_exhibit_tracking') {
|
} else if (obj_type == 'event_exhibit_tracking') {
|
||||||
endpoint = `/crud/event/exhibit/tracking/list`;
|
endpoint = `/crud/event/exhibit/tracking/list`;
|
||||||
} else if (obj_type == 'event_file') {
|
} else if (obj_type == 'event_file') {
|
||||||
endpoint = `/crud/event/file/list`;
|
endpoint = `/crud/event/file/list`;
|
||||||
} else if (obj_type == 'event_location') {
|
} else if (obj_type == 'event_location') {
|
||||||
endpoint = `/crud/event/location/list`;
|
endpoint = `/crud/event/location/list`;
|
||||||
} else if (obj_type == 'event_person') {
|
} else if (obj_type == 'event_person') {
|
||||||
endpoint = `/crud/event/person/list`;
|
endpoint = `/crud/event/person/list`;
|
||||||
} else if (obj_type == 'event_presentation') {
|
} else if (obj_type == 'event_presentation') {
|
||||||
endpoint = `/crud/event/presentation/list`;
|
endpoint = `/crud/event/presentation/list`;
|
||||||
} else if (obj_type == 'event_presenter') {
|
} else if (obj_type == 'event_presenter') {
|
||||||
endpoint = `/crud/event/presenter/list`;
|
endpoint = `/crud/event/presenter/list`;
|
||||||
} else if (obj_type == 'event_session') {
|
} else if (obj_type == 'event_session') {
|
||||||
endpoint = `/crud/event/session/list`;
|
endpoint = `/crud/event/session/list`;
|
||||||
} else if (obj_type == 'event_track') {
|
} else if (obj_type == 'event_track') {
|
||||||
endpoint = `/crud/event/track/list`;
|
endpoint = `/crud/event/track/list`;
|
||||||
} else if (obj_type == 'grant') {
|
} else if (obj_type == 'grant') {
|
||||||
endpoint = `/crud/grant/list`;
|
endpoint = `/crud/grant/list`;
|
||||||
} else if (obj_type == 'hosted_file') {
|
} else if (obj_type == 'hosted_file') {
|
||||||
endpoint = `/crud/hosted_file/list`;
|
endpoint = `/crud/hosted_file/list`;
|
||||||
} else if (obj_type == 'journal') {
|
} else if (obj_type == 'journal') {
|
||||||
endpoint = `/crud/journal/list`;
|
endpoint = `/crud/journal/list`;
|
||||||
} else if (obj_type == 'journal_entry') {
|
} else if (obj_type == 'journal_entry') {
|
||||||
endpoint = `/crud/journal/entry/list`;
|
endpoint = `/crud/journal/entry/list`;
|
||||||
} else if (obj_type == 'order') {
|
} else if (obj_type == 'order') {
|
||||||
endpoint = `/crud/order/list`;
|
endpoint = `/crud/order/list`;
|
||||||
} else if (obj_type == 'order_line') {
|
} else if (obj_type == 'order_line') {
|
||||||
endpoint = `/crud/order/line/list`;
|
endpoint = `/crud/order/line/list`;
|
||||||
} else if (obj_type == 'page') {
|
} else if (obj_type == 'page') {
|
||||||
endpoint = `/crud/page/list`;
|
endpoint = `/crud/page/list`;
|
||||||
} else if (obj_type == 'person') {
|
} else if (obj_type == 'person') {
|
||||||
endpoint = `/crud/person/list`;
|
endpoint = `/crud/person/list`;
|
||||||
} else if (obj_type == 'post') {
|
} else if (obj_type == 'post') {
|
||||||
endpoint = `/crud/post/list`;
|
endpoint = `/crud/post/list`;
|
||||||
} else if (obj_type == 'post_comment') {
|
} else if (obj_type == 'post_comment') {
|
||||||
endpoint = `/crud/post/comment/list`;
|
endpoint = `/crud/post/comment/list`;
|
||||||
} else if (obj_type == 'site') {
|
} else if (obj_type == 'site') {
|
||||||
endpoint = `/crud/site/list`;
|
endpoint = `/crud/site/list`;
|
||||||
} else if (obj_type == 'sponsorship_cfg') {
|
} else if (obj_type == 'sponsorship_cfg') {
|
||||||
endpoint = `/crud/sponsorship/cfg/list`;
|
endpoint = `/crud/sponsorship/cfg/list`;
|
||||||
} else if (obj_type == 'sponsorship') {
|
} else if (obj_type == 'sponsorship') {
|
||||||
endpoint = `/crud/sponsorship/list`;
|
endpoint = `/crud/sponsorship/list`;
|
||||||
// } else if (obj_type == 'user') {
|
// } else if (obj_type == 'user') {
|
||||||
// endpoint = `/crud/user/list`;
|
// endpoint = `/crud/user/list`;
|
||||||
} else if (obj_type == 'lu' && for_obj_type == 'country_subdivision') {
|
} else if (obj_type == 'lu' && for_obj_type == 'country_subdivision') {
|
||||||
endpoint = `/crud/lu/country_subdivision/list`;
|
endpoint = `/crud/lu/country_subdivision/list`;
|
||||||
for_obj_type = null;
|
for_obj_type = null;
|
||||||
} else if (obj_type == 'lu' && for_obj_type == 'country') {
|
} else if (obj_type == 'lu' && for_obj_type == 'country') {
|
||||||
endpoint = `/crud/lu/country/list`;
|
endpoint = `/crud/lu/country/list`;
|
||||||
for_obj_type = null;
|
for_obj_type = null;
|
||||||
} else if (obj_type == 'lu' && for_obj_type == 'time_zone') {
|
} else if (obj_type == 'lu' && for_obj_type == 'time_zone') {
|
||||||
endpoint = `/crud/lu/time_zone/list`;
|
endpoint = `/crud/lu/time_zone/list`;
|
||||||
for_obj_type = null;
|
for_obj_type = null;
|
||||||
} else {
|
} else {
|
||||||
console.log(`Unknown object type: ${obj_type}`);
|
console.log(`Unknown object type: ${obj_type}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Endpoint:', endpoint);
|
console.log('Endpoint:', endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (for_obj_type) {
|
if (for_obj_type) {
|
||||||
params['for_obj_type'] = for_obj_type;
|
params['for_obj_type'] = for_obj_type;
|
||||||
}
|
}
|
||||||
if (for_obj_id) {
|
if (for_obj_id) {
|
||||||
params['for_obj_id'] = for_obj_id;
|
params['for_obj_id'] = for_obj_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
params['use_alt_table'] = use_alt_table;
|
params['use_alt_table'] = use_alt_table;
|
||||||
params['use_alt_base'] = use_alt_base;
|
params['use_alt_base'] = use_alt_base;
|
||||||
|
|
||||||
/* Need to deal with inc params here */
|
/* Need to deal with inc params here */
|
||||||
|
|
||||||
let allowed_enabled_list = ['all', 'enabled', 'not_enabled']
|
const allowed_enabled_list = ['all', 'enabled', 'not_enabled'];
|
||||||
if (allowed_enabled_list.includes(enabled) ) {
|
if (allowed_enabled_list.includes(enabled)) {
|
||||||
params['enabled'] = enabled;
|
params['enabled'] = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
let allowed_hidden_list = ['all', 'hidden', 'not_hidden'];
|
const allowed_hidden_list = ['all', 'hidden', 'not_hidden'];
|
||||||
if (allowed_hidden_list.includes(hidden) ) {
|
if (allowed_hidden_list.includes(hidden)) {
|
||||||
params['hidden'] = hidden;
|
params['hidden'] = hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: The order_by_li variable is in the "headers" because if is a the URL GET params do not handle multiple values very well. Maybe base64 encore in the future or something? Reminder that GET requests should not have a body (no JSON).
|
// NOTE: The order_by_li 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)
|
// 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) {
|
if (order_by_li) {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Order By:', order_by_li);
|
console.log('Order By:', order_by_li);
|
||||||
}
|
}
|
||||||
headers['order_by_li'] = order_by_li;
|
headers['order_by_li'] = order_by_li;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (limit >= 0) {
|
if (limit >= 0) {
|
||||||
params['limit'] = limit;
|
params['limit'] = limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset >= 0) {
|
if (offset >= 0) {
|
||||||
params['offset'] = offset;
|
params['offset'] = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params_json) {
|
if (params_json) {
|
||||||
// NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the search endpoint.
|
// NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the search endpoint.
|
||||||
// Max characters for a GET request is 2083. This is a limitation of the browser (Microsoft IE and Edge).
|
// Max characters for a GET request is 2083. This is a limitation of the browser (Microsoft IE and Edge).
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('JSON Object:', params_json);
|
console.log('JSON Object:', params_json);
|
||||||
console.log(JSON.stringify(params_json));
|
console.log(JSON.stringify(params_json));
|
||||||
}
|
}
|
||||||
// NOTE: "jp" stands for "JSON Params"
|
// NOTE: "jp" stands for "JSON Params"
|
||||||
params['jp'] = encodeURIComponent(JSON.stringify(params_json));
|
params['jp'] = encodeURIComponent(JSON.stringify(params_json));
|
||||||
if (params['jp'].length > 2083) {
|
if (params['jp'].length > 2083) {
|
||||||
console.log(`The JSON object is too large to be used as a GET parameter. The overall max URL length is 2083 characters. Please use the POST endpoint instead. Length = ${params['jp'].length} [THIS DOES NOT EXIST YET]`);
|
console.log(
|
||||||
return false;
|
`The JSON object is too large to be used as a GET parameter. The overall max URL length is 2083 characters. Please use the POST endpoint instead. Length = ${params['jp'].length} [THIS DOES NOT EXIST YET]`
|
||||||
}
|
);
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if (json_obj) {
|
// if (json_obj) {
|
||||||
// // NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the search endpoint.
|
// // NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the search endpoint.
|
||||||
// // Max characters for a GET request is 2083. This is a limitation of the browser (Microsoft IE and Edge).
|
// // Max characters for a GET request is 2083. This is a limitation of the browser (Microsoft IE and Edge).
|
||||||
// console.log('JSON Object:', json_obj);
|
// console.log('JSON Object:', json_obj);
|
||||||
// params['json_str'] = encodeURIComponent(JSON.stringify(json_obj));
|
// params['json_str'] = encodeURIComponent(JSON.stringify(json_obj));
|
||||||
// if (params['json_str'].length > 2083) {
|
// if (params['json_str'].length > 2083) {
|
||||||
// console.log(`The JSON object is too large to be used as a GET parameter. The overall max URL length is 2083 characters. Please use the POST endpoint instead. Length = ${params['json_str'].length} [THIS DOES NOT EXIST YET]`);
|
// console.log(`The JSON object is too large to be used as a GET parameter. The overall max URL length is 2083 characters. Please use the POST endpoint instead. Length = ${params['json_str'].length} [THIS DOES NOT EXIST YET]`);
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Params:', params);
|
console.log('Params:', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
let object_li_get_promise = await get_object({
|
const object_li_get_promise = await get_object({
|
||||||
api_cfg: api_cfg,
|
api_cfg: api_cfg,
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
params: params,
|
params: params,
|
||||||
return_meta: return_meta,
|
return_meta: return_meta,
|
||||||
log_lvl: log_lvl
|
log_lvl: log_lvl
|
||||||
});
|
});
|
||||||
|
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log(object_li_get_promise);
|
console.log(object_li_get_promise);
|
||||||
}
|
}
|
||||||
|
|
||||||
return object_li_get_promise;
|
return object_li_get_promise;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,213 +1,236 @@
|
|||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
|
|
||||||
export let temp_get_blob_percent_completed = 0;
|
export let temp_get_blob_percent_completed = 0;
|
||||||
export let get_blob_percent_completed = temp_get_blob_percent_completed;
|
export const get_blob_percent_completed = temp_get_blob_percent_completed;
|
||||||
|
|
||||||
export let temp_get_object_percent_completed = 0;
|
export const temp_get_object_percent_completed = 0;
|
||||||
export let get_object_percent_completed = temp_get_object_percent_completed;
|
export const get_object_percent_completed = temp_get_object_percent_completed;
|
||||||
|
|
||||||
export let get_object = async function get_object(
|
export const get_object = async function get_object({
|
||||||
{
|
api_cfg = null,
|
||||||
api_cfg = null,
|
endpoint = '',
|
||||||
endpoint = '',
|
headers = {},
|
||||||
headers = {},
|
params = {},
|
||||||
params = {},
|
data = {},
|
||||||
data = {},
|
timeout = 60000,
|
||||||
timeout = 60000,
|
return_meta = false,
|
||||||
return_meta = false,
|
return_blob = false,
|
||||||
return_blob = false,
|
filename = '',
|
||||||
filename = '',
|
auto_download = false,
|
||||||
auto_download = false,
|
as_list = false, // Is this still really needed?
|
||||||
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.
|
||||||
// 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(),
|
||||||
task_id = crypto.randomUUID(),
|
log_lvl = 0,
|
||||||
log_lvl = 0,
|
retry_count = 5 // Number of retry attempts
|
||||||
retry_count = 5 // Number of retry attempts
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
endpoint: string;
|
||||||
endpoint: string,
|
headers?: any;
|
||||||
headers?: any,
|
params?: any;
|
||||||
params?: any,
|
data?: any;
|
||||||
data?: any,
|
timeout?: number;
|
||||||
timeout?: number,
|
return_meta?: boolean;
|
||||||
return_meta?: boolean,
|
return_blob?: boolean;
|
||||||
return_blob?: boolean,
|
filename?: null | string;
|
||||||
filename?: null | string,
|
auto_download?: boolean;
|
||||||
auto_download?: boolean,
|
as_list?: boolean;
|
||||||
as_list?: boolean,
|
task_id?: string;
|
||||||
task_id?: string,
|
log_lvl?: number;
|
||||||
log_lvl?: number,
|
retry_count?: number;
|
||||||
retry_count?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** get_object() *** Endpoint: ${endpoint} AE Task ID: ${task_id}`);
|
||||||
if (log_lvl) {
|
console.log('Params:', params);
|
||||||
console.log(`*** get_object() *** Endpoint: ${endpoint} AE Task ID: ${task_id}`);
|
if (log_lvl > 1) {
|
||||||
console.log('Params:', params);
|
console.log('Data:', data);
|
||||||
if (log_lvl > 1) {
|
}
|
||||||
console.log('Data:', data);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!api_cfg) {
|
if (!api_cfg) {
|
||||||
console.log('No API Config was provided. Returning false.');
|
console.log('No API Config was provided. Returning false.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = new URL(endpoint, api_cfg['base_url']);
|
const url = new URL(endpoint, api_cfg['base_url']);
|
||||||
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));
|
Object.keys(params).forEach((key) => url.searchParams.append(key, params[key]));
|
||||||
|
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
||||||
|
|
||||||
// Remove a header parameter if it is set to null
|
// 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) {
|
if (
|
||||||
delete api_cfg['headers']['x-no-account-id'];
|
api_cfg['headers'].hasOwnProperty('x-no-account-id') &&
|
||||||
}
|
api_cfg['headers']['x-no-account-id'] === null
|
||||||
|
) {
|
||||||
|
delete api_cfg['headers']['x-no-account-id'];
|
||||||
|
}
|
||||||
|
|
||||||
// Clean the headers
|
// Clean the headers
|
||||||
let headers_cleaned: key_val = {};
|
const headers_cleaned: key_val = {};
|
||||||
for (const prop in headers) {
|
for (const prop in headers) {
|
||||||
let prop_cleaned = prop.replaceAll('_', '-');
|
const prop_cleaned = prop.replaceAll('_', '-');
|
||||||
if (typeof headers[prop] != 'string') {
|
if (typeof headers[prop] != 'string') {
|
||||||
headers[prop] = JSON.stringify(headers[prop]);
|
headers[prop] = JSON.stringify(headers[prop]);
|
||||||
}
|
}
|
||||||
headers_cleaned[prop_cleaned] = headers[prop];
|
headers_cleaned[prop_cleaned] = headers[prop];
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log(`${prop_cleaned}: ${headers_cleaned[prop_cleaned]}`);
|
console.log(`${prop_cleaned}: ${headers_cleaned[prop_cleaned]}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
headers = headers_cleaned;
|
headers = headers_cleaned;
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log('All headers cleaned:', headers);
|
console.log('All headers cleaned:', headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchOptions: RequestInit = {
|
const fetchOptions: RequestInit = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
...api_cfg['headers'],
|
...api_cfg['headers'],
|
||||||
...headers
|
...headers
|
||||||
},
|
},
|
||||||
signal: controller.signal
|
signal: controller.signal
|
||||||
};
|
};
|
||||||
|
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log('Fetch options:', fetchOptions);
|
console.log('Fetch options:', fetchOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
let fetch_method: any = fetch;
|
let fetch_method: any = fetch;
|
||||||
if (api_cfg.fetch) {
|
if (api_cfg.fetch) {
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log('Using custom fetch function from api_cfg!!!');
|
console.log('Using custom fetch function from api_cfg!!!');
|
||||||
}
|
}
|
||||||
fetch_method = api_cfg.fetch;
|
fetch_method = api_cfg.fetch;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let attempt = 1; attempt <= retry_count; attempt++) {
|
for (let attempt = 1; attempt <= retry_count; attempt++) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch_method(url.toString(), fetchOptions)
|
const response = await fetch_method(url.toString(), fetchOptions).catch(function (
|
||||||
.catch(function (error: any) {
|
error: any
|
||||||
console.log('API GET Object *fetch* request was aborted or failed in an unexpected way.', error);
|
) {
|
||||||
});
|
console.log(
|
||||||
clearTimeout(timeoutId);
|
'API GET Object *fetch* request was aborted or failed in an unexpected way.',
|
||||||
|
error
|
||||||
|
);
|
||||||
|
});
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log('API GET Object: Something went wrong with *fetch* request. Returning false? Throwing an error!');
|
console.log(
|
||||||
}
|
'API GET Object: Something went wrong with *fetch* request. Returning false? Throwing an 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
|
}
|
||||||
}
|
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
|
||||||
|
}
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`Response: status=${response.status} statusText=${response.statusText} url=${response.url} attempt=${attempt}`);
|
console.log(
|
||||||
}
|
`Response: status=${response.status} statusText=${response.statusText} url=${response.url} attempt=${attempt}`
|
||||||
if (log_lvl > 1) {
|
);
|
||||||
console.log('Response:', response);
|
}
|
||||||
}
|
if (log_lvl > 1) {
|
||||||
|
console.log('Response:', response);
|
||||||
|
}
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
if (response.status === 404) {
|
if (response.status === 404) {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('The response was a 404 not found "error". Returning null.');
|
console.log('The response was a 404 not found "error". Returning null.');
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
console.log('The response was not ok. Throwing an error!');
|
console.log('The response was not ok. Throwing an error!');
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!return_blob) {
|
if (!return_blob) {
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log('Response JSON:', json);
|
console.log('Response JSON:', json);
|
||||||
}
|
}
|
||||||
if (!Array.isArray(json.data) && as_list) {
|
if (!Array.isArray(json.data) && as_list) {
|
||||||
return [json.data];
|
return [json.data];
|
||||||
}
|
}
|
||||||
return json.data || json;
|
return json.data || json;
|
||||||
} else {
|
} else {
|
||||||
const reader = response.body?.getReader();
|
const reader = response.body?.getReader();
|
||||||
const contentLength = +response.headers.get('Content-Length')!;
|
const contentLength = +response.headers.get('Content-Length')!;
|
||||||
let receivedLength = 0;
|
let receivedLength = 0;
|
||||||
const chunks = [];
|
const chunks = [];
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const { done, value } = await reader!.read();
|
const { done, value } = await reader!.read();
|
||||||
if (done) break;
|
if (done) break;
|
||||||
chunks.push(value);
|
chunks.push(value);
|
||||||
receivedLength += value.length;
|
receivedLength += value.length;
|
||||||
|
|
||||||
const percent_completed = Math.round((receivedLength * 100) / contentLength);
|
const percent_completed = Math.round((receivedLength * 100) / contentLength);
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log('GET Blob Progress:', percent_completed, 'Total:', contentLength, 'Loaded:', receivedLength, 'Percent Completed', percent_completed);
|
console.log(
|
||||||
}
|
'GET Blob Progress:',
|
||||||
|
percent_completed,
|
||||||
|
'Total:',
|
||||||
|
contentLength,
|
||||||
|
'Loaded:',
|
||||||
|
receivedLength,
|
||||||
|
'Percent Completed',
|
||||||
|
percent_completed
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
temp_get_blob_percent_completed = percent_completed;
|
temp_get_blob_percent_completed = percent_completed;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
window.postMessage({
|
window.postMessage(
|
||||||
type: 'api_download_blob',
|
{
|
||||||
status: 'downloading',
|
type: 'api_download_blob',
|
||||||
task_id: task_id,
|
status: 'downloading',
|
||||||
endpoint: endpoint,
|
task_id: task_id,
|
||||||
filename: filename,
|
endpoint: endpoint,
|
||||||
size_total: contentLength,
|
filename: filename,
|
||||||
size_loaded: receivedLength,
|
size_total: contentLength,
|
||||||
percent_completed: percent_completed
|
size_loaded: receivedLength,
|
||||||
}, '*');
|
percent_completed: percent_completed
|
||||||
}
|
},
|
||||||
} catch (e) {
|
'*'
|
||||||
console.error('Error posting message:', e);
|
);
|
||||||
}
|
}
|
||||||
}
|
} catch (e) {
|
||||||
|
console.error('Error posting message:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const blob = new Blob(chunks);
|
const blob = new Blob(chunks);
|
||||||
if (auto_download) {
|
if (auto_download) {
|
||||||
const downloadUrl = window.URL.createObjectURL(blob);
|
const downloadUrl = window.URL.createObjectURL(blob);
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = downloadUrl;
|
link.href = downloadUrl;
|
||||||
link.setAttribute('download', filename || 'download');
|
link.setAttribute('download', filename || 'download');
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
link.remove();
|
link.remove();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return blob;
|
return blob;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`API GET object request *fetch* error on attempt ${attempt}:`, error);
|
console.log(`API GET object request *fetch* error on attempt ${attempt}:`, error);
|
||||||
|
|
||||||
if (attempt === retry_count) {
|
if (attempt === retry_count) {
|
||||||
console.log('Max retry attempts reached. Returning false.');
|
console.log('Max retry attempts reached. Returning false.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log retry information
|
// Log retry information
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`Retrying... (${attempt}/${retry_count})`);
|
console.log(`Retrying... (${attempt}/${retry_count})`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,493 +4,517 @@ import type { key_val } from '$lib/stores/ae_stores';
|
|||||||
|
|
||||||
export let temp_get_blob_percent_completed = 0;
|
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 = readable(temp_get_blob_percent_completed);
|
||||||
export let get_blob_percent_completed = temp_get_blob_percent_completed;
|
export const get_blob_percent_completed = temp_get_blob_percent_completed;
|
||||||
|
|
||||||
export let temp_get_object_percent_completed = 0;
|
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 = readable(temp_get_object_percent_completed);
|
||||||
export let get_object_percent_completed = temp_get_object_percent_completed;
|
export const get_object_percent_completed = temp_get_object_percent_completed;
|
||||||
|
|
||||||
// Updated 2024-05-23
|
// Updated 2024-05-23
|
||||||
export let get_object = async function get_object(
|
export const get_object = async function get_object({
|
||||||
{
|
api_cfg = null,
|
||||||
api_cfg=null,
|
endpoint = '',
|
||||||
endpoint='',
|
headers = {},
|
||||||
headers={},
|
params = {},
|
||||||
params={},
|
data = {},
|
||||||
data={},
|
timeout = 60000,
|
||||||
timeout=60000,
|
return_meta = false,
|
||||||
return_meta=false,
|
return_blob = false,
|
||||||
return_blob=false,
|
filename = '',
|
||||||
filename='',
|
auto_download = false,
|
||||||
auto_download=false,
|
as_list = 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.
|
||||||
// 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(),
|
||||||
task_id=crypto.randomUUID(),
|
log_lvl = 0
|
||||||
log_lvl=0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
endpoint: string;
|
||||||
endpoint: string,
|
headers?: any;
|
||||||
headers?: any,
|
params?: any;
|
||||||
params?: any,
|
data?: any;
|
||||||
data?: any,
|
timeout?: number;
|
||||||
timeout?: number,
|
return_meta?: boolean;
|
||||||
return_meta?: boolean,
|
return_blob?: boolean;
|
||||||
return_blob?: boolean,
|
filename?: null | string;
|
||||||
filename?: null|string,
|
auto_download?: boolean;
|
||||||
auto_download?: boolean,
|
as_list?: boolean;
|
||||||
as_list?: boolean,
|
task_id?: string;
|
||||||
task_id?: string,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** get_object() *** Endpoint: ${endpoint} AE Task ID: ${task_id}`);
|
||||||
if (log_lvl) {
|
console.log('Params:', params);
|
||||||
console.log(`*** get_object() *** Endpoint: ${endpoint} AE Task ID: ${task_id}`);
|
if (log_lvl > 1) {
|
||||||
console.log('Params:', params);
|
console.log('Data:', data);
|
||||||
if (log_lvl > 1) {
|
console.log(`Base URL: ${api_cfg['base_url']}; Timeout: ${timeout}`);
|
||||||
console.log('Data:', data);
|
console.log('API Config:', api_cfg);
|
||||||
console.log(`Base URL: ${api_cfg['base_url']}; Timeout: ${timeout}`);
|
}
|
||||||
console.log('API Config:', api_cfg);
|
if (log_lvl > 2) {
|
||||||
}
|
console.log(
|
||||||
if (log_lvl > 2) {
|
`Return Meta: ${return_meta}; Return Blob: ${return_blob}; Filename: ${filename}; Auto Download: ${auto_download}`
|
||||||
console.log(`Return Meta: ${return_meta}; Return Blob: ${return_blob}; Filename: ${filename}; Auto Download: ${auto_download}`);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!api_cfg) {
|
if (!api_cfg) {
|
||||||
console.log('No API Config was provided. Returning false.');
|
console.log('No API Config was provided. Returning false.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let axios_api = axios.create({
|
const axios_api = axios.create({
|
||||||
baseURL: api_cfg['base_url'],
|
baseURL: api_cfg['base_url'],
|
||||||
timeout: timeout, // in milliseconds; 60000 = 60 seconds
|
timeout: timeout // in milliseconds; 60000 = 60 seconds
|
||||||
/* other custom settings */
|
/* other custom settings */
|
||||||
});
|
});
|
||||||
axios_api.defaults.headers = api_cfg['headers'];
|
axios_api.defaults.headers = api_cfg['headers'];
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('axios_api.defaults.headers:', axios_api.defaults.headers);
|
console.log('axios_api.defaults.headers:', axios_api.defaults.headers);
|
||||||
console.log('Additional headers:', headers);
|
console.log('Additional headers:', headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('Clean the headers. No _underscores_!')
|
// console.log('Clean the headers. No _underscores_!')
|
||||||
let headers_cleaned: key_val = {};
|
const headers_cleaned: key_val = {};
|
||||||
for (const prop in headers) {
|
for (const prop in headers) {
|
||||||
// No underscores allowed in the header parameters!
|
// No underscores allowed in the header parameters!
|
||||||
let prop_cleaned = prop.replaceAll('_', '-');
|
const prop_cleaned = prop.replaceAll('_', '-');
|
||||||
|
|
||||||
// The value must be a string for the header!
|
// The value must be a string for the header!
|
||||||
if (typeof headers[prop] != 'string') {
|
if (typeof headers[prop] != 'string') {
|
||||||
headers[prop] = JSON.stringify(headers[prop]);
|
headers[prop] = JSON.stringify(headers[prop]);
|
||||||
}
|
}
|
||||||
|
|
||||||
headers_cleaned[prop_cleaned] = headers[prop];
|
headers_cleaned[prop_cleaned] = headers[prop];
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`${prop_cleaned}: ${headers_cleaned[prop_cleaned]}`);
|
console.log(`${prop_cleaned}: ${headers_cleaned[prop_cleaned]}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
headers = headers_cleaned;
|
headers = headers_cleaned;
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('All headers cleaned:', headers);
|
console.log('All headers cleaned:', headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('URL params:');
|
console.log('URL params:');
|
||||||
}
|
}
|
||||||
for (const prop in params) {
|
for (const prop in params) {
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log(`URL param: ${prop}: ${params[prop]}`);
|
console.log(`URL param: ${prop}: ${params[prop]}`);
|
||||||
}
|
}
|
||||||
if (params[prop] === null ) {
|
if (params[prop] === null) {
|
||||||
params[prop] = 'null';
|
params[prop] = 'null';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle the case where there is no Blob expected to be returned. Mainly JSON and text data.
|
// Handle the case where there is no Blob expected to be returned. Mainly JSON and text data.
|
||||||
if (!return_blob) {
|
if (!return_blob) {
|
||||||
let response_data_promise = await axios_api.get(
|
const response_data_promise = await axios_api
|
||||||
endpoint,
|
.get(endpoint, {
|
||||||
{
|
headers: headers,
|
||||||
headers: headers,
|
params: params,
|
||||||
params: params,
|
onDownloadProgress: (progressEvent) => {
|
||||||
onDownloadProgress: (progressEvent) => {
|
const percent_completed = Math.round((progressEvent.loaded * 100) / progressEvent.total);
|
||||||
let percent_completed = Math.round(
|
if (log_lvl > 1) {
|
||||||
(progressEvent.loaded * 100) / progressEvent.total
|
console.log(
|
||||||
);
|
'GET Data Progress:',
|
||||||
if (log_lvl > 1) {
|
progressEvent.progress,
|
||||||
console.log('GET Data Progress:', progressEvent.progress, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed);
|
'Total:',
|
||||||
}
|
progressEvent.total,
|
||||||
|
'Loaded:',
|
||||||
|
progressEvent.loaded,
|
||||||
|
'Percent Completed',
|
||||||
|
percent_completed
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
temp_get_object_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.
|
// WARNING: This needs to be tied to an object type and ID. This is a temporary solution.
|
||||||
try {
|
try {
|
||||||
// Check if window is defined. This is to prevent errors in SvelteKit.
|
// Check if window is defined. This is to prevent errors in SvelteKit.
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
window.postMessage({
|
window.postMessage(
|
||||||
type: 'api_download_data',
|
{
|
||||||
status: 'downloading',
|
type: 'api_download_data',
|
||||||
task_id: task_id,
|
status: 'downloading',
|
||||||
endpoint: endpoint,
|
task_id: task_id,
|
||||||
filename: filename,
|
endpoint: endpoint,
|
||||||
size_total: progressEvent.total,
|
filename: filename,
|
||||||
size_loaded: progressEvent.loaded,
|
size_total: progressEvent.total,
|
||||||
percent_completed: percent_completed,
|
size_loaded: progressEvent.loaded,
|
||||||
},
|
percent_completed: percent_completed
|
||||||
'*'
|
},
|
||||||
);
|
'*'
|
||||||
}
|
);
|
||||||
} catch (error) {
|
}
|
||||||
console.log('Error posting message to window:', error);
|
} catch (error) {
|
||||||
}
|
console.log('Error posting message to window:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
if (log_lvl) {
|
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)}`);
|
console.log(
|
||||||
}
|
`GET Response: status=${response.status} statusText=${response.statusText} baseURL=${response.config.baseURL} url=${response.config.url} method=${response.config.method} headers=${response.config.headers} params=${JSON.stringify(response.config.params)}`
|
||||||
if (log_lvl > 1) {
|
);
|
||||||
console.log('GET Response:', response);
|
}
|
||||||
}
|
if (log_lvl > 1) {
|
||||||
|
console.log('GET Response:', response);
|
||||||
|
}
|
||||||
|
|
||||||
// Post file download message
|
// Post file download message
|
||||||
try {
|
try {
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
window.postMessage({
|
window.postMessage(
|
||||||
type: 'api_download_data',
|
{
|
||||||
status: 'complete',
|
type: 'api_download_data',
|
||||||
task_id: task_id,
|
status: 'complete',
|
||||||
endpoint: endpoint,
|
task_id: task_id,
|
||||||
filename: filename,
|
endpoint: endpoint,
|
||||||
size_total: 0,
|
filename: filename,
|
||||||
size_loaded: 0,
|
size_total: 0,
|
||||||
percent_completed: 100,
|
size_loaded: 0,
|
||||||
},
|
percent_completed: 100
|
||||||
'*'
|
},
|
||||||
);
|
'*'
|
||||||
}
|
);
|
||||||
} catch (error) {
|
}
|
||||||
console.log('Error posting message to window:', error);
|
} catch (error) {
|
||||||
}
|
console.log('Error posting message to window:', error);
|
||||||
|
}
|
||||||
|
|
||||||
if (!Array.isArray(response.data['data']) && as_list) {
|
if (!Array.isArray(response.data['data']) && as_list) {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Data result is a dictionary/object, not an array/list. Forcing return as an array/list');
|
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;
|
const return_data = [];
|
||||||
} else if (response.data['data']) {
|
return_data.push(response.data['data']);
|
||||||
let return_data = response.data['data'];
|
return return_data;
|
||||||
if (log_lvl) {
|
} else if (response.data['data']) {
|
||||||
if (Array.isArray(return_data)) {
|
const return_data = response.data['data'];
|
||||||
console.log(`Data result is an array/list. Array length: ${return_data.length}`);
|
if (log_lvl) {
|
||||||
} else {
|
if (Array.isArray(return_data)) {
|
||||||
console.log(`Data result is a dictionary/object, not an array/list.`);
|
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;
|
return return_data;
|
||||||
if (log_lvl) {
|
} else {
|
||||||
if (Array.isArray(return_data)) {
|
const return_data = response.data;
|
||||||
console.log(`Not a standard response from Aether's API. Data result is an array/list. Array length: ${return_data.length}`);
|
if (log_lvl) {
|
||||||
} else {
|
if (Array.isArray(return_data)) {
|
||||||
console.log(`Not a standard response from Aether's API. Data result is a dictionary/object, not an array/list.`);
|
console.log(
|
||||||
}
|
`Not a standard response from Aether's API. Data result is an array/list. Array length: ${return_data.length}`
|
||||||
}
|
);
|
||||||
return return_data;
|
} else {
|
||||||
}
|
console.log(
|
||||||
})
|
`Not a standard response from Aether's API. Data result is a dictionary/object, not an array/list.`
|
||||||
.catch(function (error: any) {
|
);
|
||||||
// Handle the common and expected 404 "error" first
|
}
|
||||||
if (error.response && error.response.status === 404) {
|
}
|
||||||
if (log_lvl) {
|
return return_data;
|
||||||
console.log('The response was a 404 not found "error". Returning null.');
|
}
|
||||||
}
|
})
|
||||||
if (log_lvl > 1) {
|
.catch(function (error: any) {
|
||||||
console.log(error.response);
|
// Handle the common and expected 404 "error" first
|
||||||
}
|
if (error.response && error.response.status === 404) {
|
||||||
if (log_lvl > 2) {
|
if (log_lvl) {
|
||||||
console.log(error);
|
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
|
// Post file download message
|
||||||
try {
|
try {
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
window.postMessage({
|
window.postMessage(
|
||||||
type: 'api_download_data',
|
{
|
||||||
status: 'complete',
|
type: 'api_download_data',
|
||||||
task_id: task_id,
|
status: 'complete',
|
||||||
endpoint: endpoint,
|
task_id: task_id,
|
||||||
filename: filename,
|
endpoint: endpoint,
|
||||||
size_total: 0,
|
filename: filename,
|
||||||
size_loaded: 0,
|
size_total: 0,
|
||||||
percent_completed: 0,
|
size_loaded: 0,
|
||||||
},
|
percent_completed: 0
|
||||||
'*'
|
},
|
||||||
);
|
'*'
|
||||||
}
|
);
|
||||||
} catch (error) {
|
}
|
||||||
console.log('Error posting message to window:', error);
|
} catch (error) {
|
||||||
}
|
console.log('Error posting message to window:', error);
|
||||||
return null; // Returning null since there were no results
|
}
|
||||||
}
|
return null; // Returning null since there were no results
|
||||||
|
}
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`Base URL: ${api_cfg['base_url']} | Endpoint: ${endpoint}`);
|
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???
|
console.log('Error Message:', error.message); // Is this needed here or below in the in the else portion???
|
||||||
|
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
// The request was made and the server responded with a status code that falls out of the range of 2xx
|
// 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 Data', error.response.data);
|
||||||
console.log('Error Response Status', error.response.status);
|
console.log('Error Response Status', error.response.status);
|
||||||
console.log('Error Response Headers', error.response.headers);
|
console.log('Error Response Headers', error.response.headers);
|
||||||
} else if (error.request) {
|
} 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
|
// 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) {
|
if (log_lvl > 1) {
|
||||||
console.log('Error Request', error.request);
|
console.log('Error Request', error.request);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Something happened in setting up the request that triggered an Error
|
// Something happened in setting up the request that triggered an Error
|
||||||
console.log('Error Message', error.message);
|
console.log('Error Message', error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (log_lvl > 2) {
|
if (log_lvl > 2) {
|
||||||
console.log('Error:', error);
|
console.log('Error:', error);
|
||||||
console.log(error.config);
|
console.log(error.config);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error.code === 'ECONNABORTED') {
|
if (error.code === 'ECONNABORTED') {
|
||||||
// Timeout Error (You can implement retry here where suitable)
|
// Timeout Error (You can implement retry here where suitable)
|
||||||
console.log('Timeout Error: ', error.message);
|
console.log('Timeout Error: ', error.message);
|
||||||
}
|
}
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('The response was an error. Returning false.');
|
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 false; // Returning false since something may have gone wrong. This includes timeouts. Also more in line with what the API returns.
|
||||||
// return error;
|
// return error;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
// console.log(`Response Data: ${response_data_promise}`);
|
// console.log(`Response Data: ${response_data_promise}`);
|
||||||
console.log(`Response Data:`, response_data_promise);
|
console.log(`Response Data:`, response_data_promise);
|
||||||
// console.log(response_data_promise);
|
// console.log(response_data_promise);
|
||||||
}
|
}
|
||||||
if (response_data_promise) {
|
if (response_data_promise) {
|
||||||
// The most common and expected response.
|
// The most common and expected response.
|
||||||
// console.log('Returning result. This is generally expected.');
|
// console.log('Returning result. This is generally expected.');
|
||||||
return response_data_promise;
|
return response_data_promise;
|
||||||
} else if (response_data_promise === null) {
|
} else if (response_data_promise === null) {
|
||||||
// Less common, but expected response if no results were returned.
|
// Less common, but expected response if no results were returned.
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Returning null. This is expected if no results were found. (404)');
|
console.log('Returning null. This is expected if no results were found. (404)');
|
||||||
}
|
}
|
||||||
return response_data_promise;
|
return response_data_promise;
|
||||||
} else if (response_data_promise === false) {
|
} else if (response_data_promise === false) {
|
||||||
// Not common, but expected response if the request to the API had an issue.
|
// 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.');
|
console.log('Returning false. There may have been an issue with this request.');
|
||||||
return response_data_promise;
|
return response_data_promise;
|
||||||
} else {
|
} else {
|
||||||
// This generally should not happen. It likely means the query was bad or an API issue.
|
// 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.');
|
console.log('Returning (JSON/text) unknown. This should not happen in most cases.');
|
||||||
Promise.reject(new Error('fail')).then(resolved, rejected);
|
Promise.reject(new Error('fail')).then(resolved, rejected);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle the case where a Blob is expected to be returned.
|
// Handle the case where a Blob is expected to be returned.
|
||||||
} else {
|
} else {
|
||||||
|
// console.log('Expecting a Blob to be returned...');
|
||||||
|
|
||||||
// console.log('Expecting a Blob to be returned...');
|
const response_data_promise = await axios_api
|
||||||
|
.get(endpoint, {
|
||||||
|
params: params,
|
||||||
|
responseType: 'blob',
|
||||||
|
onDownloadProgress: (progressEvent) => {
|
||||||
|
const 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
|
||||||
|
);
|
||||||
|
|
||||||
let response_data_promise = await axios_api.get(
|
temp_get_blob_percent_completed = percent_completed;
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
// WARNING: This needs to be tied to an object type and ID. This is a temporary solution.
|
const { data, headers } = response;
|
||||||
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';
|
||||||
|
}
|
||||||
|
|
||||||
// Careful if this download filename needs to be changed to a different file extension. The browser/client may not know how to handle it.
|
// WARNING: This needs to be tied to an object type and ID. This is a temporary solution.
|
||||||
if (filename) {
|
try {
|
||||||
} else if (headers['content-disposition']) {
|
if (typeof window !== 'undefined') {
|
||||||
filename = headers['content-disposition'].replace(/\w+;filename=(.*)/, '$1');
|
window.postMessage(
|
||||||
} else {
|
{
|
||||||
filename = 'unknown_file.ext';
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
// WARNING: This needs to be tied to an object type and ID. This is a temporary solution.
|
if (auto_download) {
|
||||||
try {
|
if (log_lvl) {
|
||||||
if (typeof window !== 'undefined') {
|
console.log(`Auto Download: ${filename}`);
|
||||||
window.postMessage({
|
}
|
||||||
type: 'api_download_blob',
|
const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||||
status: 'complete',
|
const link = document.createElement('a');
|
||||||
task_id: task_id,
|
link.href = url;
|
||||||
endpoint: endpoint,
|
link.setAttribute('download', filename);
|
||||||
filename: filename,
|
document.body.appendChild(link);
|
||||||
size_total: 0,
|
link.click();
|
||||||
size_loaded: 0,
|
return true;
|
||||||
percent_completed: 100,
|
} else {
|
||||||
},
|
return response;
|
||||||
'*'
|
}
|
||||||
);
|
})
|
||||||
}
|
.catch(function (error: any) {
|
||||||
} catch (error) {
|
// Handle the common and expected 404 "error" first
|
||||||
console.log('Error posting message to window:', error);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
if (auto_download) {
|
// Post file download message
|
||||||
if (log_lvl) {
|
try {
|
||||||
console.log(`Auto Download: ${filename}`);
|
if (typeof window !== 'undefined') {
|
||||||
}
|
window.postMessage(
|
||||||
const url = window.URL.createObjectURL(new Blob([response.data]));
|
{
|
||||||
const link = document.createElement('a');
|
type: 'api_download_blob',
|
||||||
link.href = url;
|
status: 'complete',
|
||||||
link.setAttribute('download', filename);
|
task_id: task_id,
|
||||||
document.body.appendChild(link);
|
endpoint: endpoint,
|
||||||
link.click();
|
filename: filename,
|
||||||
return true;
|
size_total: 0,
|
||||||
} else {
|
size_loaded: 0,
|
||||||
return response;
|
percent_completed: 0
|
||||||
}
|
},
|
||||||
})
|
'*'
|
||||||
.catch(function (error: any) {
|
);
|
||||||
// Handle the common and expected 404 "error" first
|
}
|
||||||
if (error.response && error.response.status === 404) {
|
} catch (error) {
|
||||||
if (log_lvl) {
|
console.log('Error posting message to window:', error);
|
||||||
console.log('The response was a 404 not found "error". Returning null.');
|
}
|
||||||
}
|
return null; // Returning null since there were no results
|
||||||
if (log_lvl > 1) {
|
}
|
||||||
console.log(error.response);
|
|
||||||
}
|
|
||||||
if (log_lvl > 2) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Post file download message
|
if (log_lvl) {
|
||||||
try {
|
console.log(`Base URL: ${api_cfg['base_url']} | Endpoint: ${endpoint}`);
|
||||||
if (typeof window !== 'undefined') {
|
console.log('Error Message:', error.message); // Is this needed here or below in the in the else portion???
|
||||||
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) {
|
if (error.response) {
|
||||||
console.log(`Base URL: ${api_cfg['base_url']} | Endpoint: ${endpoint}`);
|
// The request was made and the server responded with a status code that falls out of the range of 2xx
|
||||||
console.log('Error Message:', error.message); // Is this needed here or below in the in the else portion???
|
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.response) {
|
if (error.code === 'ECONNABORTED') {
|
||||||
// The request was made and the server responded with a status code that falls out of the range of 2xx
|
// Timeout Error (You can implement retry here where suitable)
|
||||||
console.log('Error Response Data', error.response.data);
|
console.log('Timeout Error: ', error.message);
|
||||||
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') {
|
if (log_lvl) {
|
||||||
// Timeout Error (You can implement retry here where suitable)
|
console.log('The response was an error. Returning false.');
|
||||||
console.log('Timeout Error: ', error.message);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (log_lvl) {
|
return false; // Returning false since something may have gone wrong. This includes timeouts. Also more in line with what the API returns.
|
||||||
console.log('The response was an error. Returning false.');
|
// return error;
|
||||||
}
|
});
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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) {
|
function resolved(result: any) {
|
||||||
console.log('Resolved');
|
console.log('Resolved');
|
||||||
}
|
}
|
||||||
|
|
||||||
function rejected(result: any) {
|
function rejected(result: any) {
|
||||||
console.error(result);
|
console.error(result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,149 +1,144 @@
|
|||||||
// import axios from 'axios';
|
// import axios from 'axios';
|
||||||
|
|
||||||
// Updated 2024-05-23
|
// Updated 2024-05-23
|
||||||
export let patch_object = async function patch_object(
|
export const patch_object = async function patch_object({
|
||||||
{
|
api_cfg = null,
|
||||||
api_cfg = null,
|
endpoint = '',
|
||||||
endpoint = '',
|
params = {},
|
||||||
params = {},
|
data = {},
|
||||||
data = {},
|
return_meta = false,
|
||||||
return_meta = false,
|
log_lvl = 0,
|
||||||
log_lvl = 0,
|
retry_count = 5 // Number of retry attempts
|
||||||
retry_count = 5 // Number of retry attempts
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
endpoint: string;
|
||||||
endpoint: string,
|
params?: any;
|
||||||
params?: any,
|
data?: any;
|
||||||
data?: any,
|
return_meta?: boolean;
|
||||||
return_meta?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number,
|
retry_count?: number;
|
||||||
retry_count?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** patch_object() *** Endpoint: ${endpoint}`);
|
||||||
if (log_lvl) {
|
console.log('Params:', params);
|
||||||
console.log(`*** patch_object() *** Endpoint: ${endpoint}`);
|
if (log_lvl > 1) {
|
||||||
console.log('Params:', params);
|
console.log('Data:', data);
|
||||||
if (log_lvl > 1) {
|
}
|
||||||
console.log('Data:', data);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!api_cfg) {
|
if (!api_cfg) {
|
||||||
console.error('No API Config was provided. Returning false.');
|
console.error('No API Config was provided. Returning false.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the URL with query parameters
|
// Construct the URL with query parameters
|
||||||
const url = new URL(endpoint, api_cfg['base_url']);
|
const url = new URL(endpoint, api_cfg['base_url']);
|
||||||
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));
|
Object.keys(params).forEach((key) => url.searchParams.append(key, params[key]));
|
||||||
|
|
||||||
// Clean the headers
|
// Clean the headers
|
||||||
let headers_cleaned: Record<string, string> = {};
|
const headers_cleaned: Record<string, string> = {};
|
||||||
for (const prop in api_cfg['headers']) {
|
for (const prop in api_cfg['headers']) {
|
||||||
let prop_cleaned = prop.replaceAll('_', '-');
|
const prop_cleaned = prop.replaceAll('_', '-');
|
||||||
headers_cleaned[prop_cleaned] = api_cfg['headers'][prop];
|
headers_cleaned[prop_cleaned] = api_cfg['headers'][prop];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log('Cleaned Headers:', headers_cleaned);
|
console.log('Cleaned Headers:', headers_cleaned);
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchOptions: RequestInit = {
|
const fetchOptions: RequestInit = {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
headers: {
|
headers: {
|
||||||
...headers_cleaned,
|
...headers_cleaned,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify(data)
|
body: JSON.stringify(data)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log('Fetch Options:', fetchOptions);
|
console.log('Fetch Options:', fetchOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let attempt = 1; attempt <= retry_count; attempt++) {
|
for (let attempt = 1; attempt <= retry_count; attempt++) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url.toString(), fetchOptions);
|
const response = await fetch(url.toString(), fetchOptions);
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`Response: status=${response.status} attempt=${attempt}`);
|
console.log(`Response: status=${response.status} attempt=${attempt}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
if (response.status === 404) {
|
if (response.status === 404) {
|
||||||
console.warn('404 Not Found. Returning null.');
|
console.warn('404 Not Found. Returning null.');
|
||||||
return null; // Returning null since there were no results
|
return null; // Returning null since there were no results
|
||||||
}
|
}
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
|
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log('Response JSON:', json);
|
console.log('Response JSON:', json);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the response data or metadata
|
// Return the response data or metadata
|
||||||
return return_meta ? json : json.data;
|
return return_meta ? json : json.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`API PATCH error on attempt ${attempt}:`, error);
|
console.error(`API PATCH error on attempt ${attempt}:`, error);
|
||||||
|
|
||||||
// If this is the last attempt, return false
|
// If this is the last attempt, return false
|
||||||
if (attempt === retry_count) {
|
if (attempt === retry_count) {
|
||||||
console.error('Max retry attempts reached. Returning false.');
|
console.error('Max retry attempts reached. Returning false.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log retry information
|
// Log retry information
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`Retrying... (${attempt}/${retry_count})`);
|
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);
|
||||||
|
// }
|
||||||
|
|
||||||
// let axios_api = axios.create({
|
// // Return the response data
|
||||||
// baseURL: api_cfg['base_url'],
|
// return response.data['data'];
|
||||||
// /* other custom settings */
|
// } catch (error) {
|
||||||
// });
|
// if (log_lvl) {
|
||||||
// axios_api.defaults.headers = api_cfg['headers'];
|
// console.error(`Error on attempt ${attempt}:`, error);
|
||||||
|
// }
|
||||||
|
|
||||||
// for (let attempt = 1; attempt <= retry_count; attempt++) {
|
// // Handle specific errors (e.g., 404)
|
||||||
// try {
|
// if (error.response && error.response.status === 404) {
|
||||||
// const response = await axios_api.patch(endpoint, data, { params: params });
|
// console.warn('404 Not Found. Returning null.');
|
||||||
// if (log_lvl) {
|
// return null; // Returning null since there were no results
|
||||||
// console.log(`Response: status=${response.status} attempt=${attempt}`);
|
// }
|
||||||
// }
|
|
||||||
// if (log_lvl > 1) {
|
|
||||||
// console.log('Response Data:', response.data);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Return the response data
|
// // If this is the last attempt, return false
|
||||||
// return response.data['data'];
|
// if (attempt === retry_count) {
|
||||||
// } catch (error) {
|
// console.error('Max retry attempts reached. Returning false.');
|
||||||
// if (log_lvl) {
|
// return false;
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// // Log retry information
|
||||||
|
// if (log_lvl) {
|
||||||
|
// console.log(`Retrying... (${attempt}/${retry_count})`);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return response_data;
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,350 +1,346 @@
|
|||||||
// import axios from 'axios';
|
// import axios from 'axios';
|
||||||
|
|
||||||
export let temp_post_blob_percent_completed = 0;
|
export const temp_post_blob_percent_completed = 0;
|
||||||
export let post_blob_percent_completed = temp_post_blob_percent_completed;
|
export const post_blob_percent_completed = temp_post_blob_percent_completed;
|
||||||
export let temp_post_object_percent_completed = 0;
|
export const temp_post_object_percent_completed = 0;
|
||||||
export let post_object_percent_completed = temp_post_object_percent_completed;
|
export const post_object_percent_completed = temp_post_object_percent_completed;
|
||||||
|
|
||||||
// Updated 2024-05-23
|
// Updated 2024-05-23
|
||||||
export let post_object = async function post_object(
|
export const post_object = async function post_object({
|
||||||
{
|
api_cfg = null,
|
||||||
api_cfg = null,
|
endpoint = '',
|
||||||
endpoint = '',
|
params = {},
|
||||||
params = {},
|
data = {},
|
||||||
data = {},
|
form_data = null,
|
||||||
form_data = null,
|
return_meta = false,
|
||||||
return_meta = false,
|
return_blob = false,
|
||||||
return_blob = false,
|
filename = '',
|
||||||
filename = '',
|
auto_download = false,
|
||||||
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.
|
||||||
// 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(),
|
||||||
task_id = crypto.randomUUID(),
|
log_lvl = 0,
|
||||||
log_lvl = 0,
|
retry_count = 5
|
||||||
retry_count = 5
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
endpoint: string;
|
||||||
endpoint: string,
|
params?: any;
|
||||||
params?: any,
|
data?: any;
|
||||||
data?: any,
|
form_data?: any;
|
||||||
form_data?: any,
|
return_meta?: boolean;
|
||||||
return_meta?: boolean,
|
return_blob?: boolean;
|
||||||
return_blob?: boolean,
|
filename?: string;
|
||||||
filename?: string,
|
auto_download?: boolean;
|
||||||
auto_download?: boolean,
|
task_id?: string;
|
||||||
task_id?: string,
|
log_lvl?: number;
|
||||||
log_lvl?: number,
|
retry_count?: number;
|
||||||
retry_count?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** post_object() *** Endpoint: ${endpoint} Task ID: ${task_id}`);
|
||||||
|
console.log('Params:', params);
|
||||||
|
if (log_lvl > 1) {
|
||||||
|
console.log('Data:', data);
|
||||||
|
console.log(typeof data);
|
||||||
|
console.log(`Base URL: ${api_cfg['base_url']}`);
|
||||||
|
console.log('API Config:', api_cfg);
|
||||||
|
}
|
||||||
|
if (log_lvl > 2) {
|
||||||
|
console.log(`Return Meta: ${return_meta}`);
|
||||||
|
console.log(`Return Blob: ${return_blob}`);
|
||||||
|
console.log(`Filename: ${filename}`);
|
||||||
|
console.log(`Auto Download: ${auto_download}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (log_lvl) {
|
// console.log('HERE!! API POST 0');
|
||||||
console.log(`*** post_object() *** Endpoint: ${endpoint} Task ID: ${task_id}`);
|
|
||||||
console.log('Params:', params);
|
|
||||||
if (log_lvl > 1) {
|
|
||||||
console.log('Data:', data);
|
|
||||||
console.log(typeof data);
|
|
||||||
console.log(`Base URL: ${api_cfg['base_url']}`);
|
|
||||||
console.log('API Config:', api_cfg);
|
|
||||||
}
|
|
||||||
if (log_lvl > 2) {
|
|
||||||
console.log(`Return Meta: ${return_meta}`);
|
|
||||||
console.log(`Return Blob: ${return_blob}`);
|
|
||||||
console.log(`Filename: ${filename}`);
|
|
||||||
console.log(`Auto Download: ${auto_download}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// console.log('HERE!! API POST 0');
|
if (!api_cfg) {
|
||||||
|
console.error('No API Config was provided. Returning false.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!api_cfg) {
|
// console.log('HERE!! API POST 1');
|
||||||
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]));
|
||||||
|
}
|
||||||
|
|
||||||
// Construct the URL with query parameters
|
// console.log('HERE!! API POST 2');
|
||||||
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
|
||||||
|
const headers_cleaned: Record<string, string> = {};
|
||||||
|
for (const prop in api_cfg['headers']) {
|
||||||
|
const prop_cleaned = prop.replaceAll('_', '-');
|
||||||
|
headers_cleaned[prop_cleaned] = api_cfg['headers'][prop];
|
||||||
|
}
|
||||||
|
|
||||||
// Clean the headers
|
// console.log('HERE!! API POST 3');
|
||||||
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');
|
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);
|
||||||
|
} else {
|
||||||
|
headers_cleaned['Content-Type'] = 'application/json';
|
||||||
|
}
|
||||||
|
|
||||||
if (form_data) {
|
if (log_lvl > 1) {
|
||||||
// headers_cleaned['Content-Type'] = 'multipart/form-data';
|
console.log('Cleaned Headers:', headers_cleaned);
|
||||||
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);
|
|
||||||
} else {
|
|
||||||
headers_cleaned['Content-Type'] = 'application/json';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (log_lvl > 1) {
|
// console.log('HERE!! API POST 4');
|
||||||
console.log('Cleaned Headers:', headers_cleaned);
|
|
||||||
}
|
|
||||||
|
|
||||||
// console.log('HERE!! API POST 4');
|
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
|
||||||
|
};
|
||||||
|
|
||||||
for (let attempt = 1; attempt <= retry_count; attempt++) {
|
if (log_lvl > 1) {
|
||||||
try {
|
console.log('Fetch Options:', fetchOptions);
|
||||||
const controller = new AbortController();
|
}
|
||||||
const fetchOptions: RequestInit = {
|
|
||||||
method: 'POST',
|
|
||||||
headers: headers_cleaned,
|
|
||||||
body: form_data ? form_data : JSON.stringify(data),
|
|
||||||
signal: controller.signal
|
|
||||||
};
|
|
||||||
|
|
||||||
if (log_lvl > 1) {
|
const response = await fetch(url.toString(), fetchOptions);
|
||||||
console.log('Fetch Options:', fetchOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await fetch(url.toString(), fetchOptions);
|
if (log_lvl) {
|
||||||
|
console.log(`Response: status=${response.status} attempt=${attempt}`);
|
||||||
|
}
|
||||||
|
|
||||||
if (log_lvl) {
|
if (!response.ok) {
|
||||||
console.log(`Response: status=${response.status} attempt=${attempt}`);
|
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 (!response.ok) {
|
if (!return_blob) {
|
||||||
if (response.status === 404) {
|
const json = await response.json();
|
||||||
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) {
|
if (log_lvl > 1) {
|
||||||
const json = await response.json();
|
console.log('Response JSON:', json);
|
||||||
|
}
|
||||||
|
|
||||||
if (log_lvl > 1) {
|
// Post a message to the window indicating the upload is complete
|
||||||
console.log('Response JSON:', json);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
// Post a message to the window indicating the upload is complete
|
// Return the response data or metadata
|
||||||
try {
|
return return_meta ? json : json.data;
|
||||||
window.postMessage({
|
} else {
|
||||||
type: 'api_post_json_form',
|
const blob = await response.blob();
|
||||||
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
|
if (auto_download) {
|
||||||
return return_meta ? json : json.data;
|
const downloadUrl = window.URL.createObjectURL(blob);
|
||||||
} else {
|
const link = document.createElement('a');
|
||||||
const blob = await response.blob();
|
link.href = downloadUrl;
|
||||||
|
link.setAttribute('download', filename || 'download');
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
link.remove();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return blob;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`API POST error on attempt ${attempt}:`, error);
|
||||||
|
|
||||||
if (auto_download) {
|
// If this is the last attempt, return false
|
||||||
const downloadUrl = window.URL.createObjectURL(blob);
|
if (attempt === retry_count) {
|
||||||
const link = document.createElement('a');
|
console.error('Max retry attempts reached. Returning false.');
|
||||||
link.href = downloadUrl;
|
return false;
|
||||||
link.setAttribute('download', filename || 'download');
|
}
|
||||||
document.body.appendChild(link);
|
|
||||||
link.click();
|
|
||||||
link.remove();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return blob;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`API POST error on attempt ${attempt}:`, error);
|
|
||||||
|
|
||||||
// If this is the last attempt, return false
|
// Log retry information
|
||||||
if (attempt === retry_count) {
|
if (log_lvl) {
|
||||||
console.error('Max retry attempts reached. Returning false.');
|
console.log(`Retrying... (${attempt}/${retry_count})`);
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Log retry information
|
// let axios_api = axios.create({
|
||||||
if (log_lvl) {
|
// baseURL: api_cfg['base_url'],
|
||||||
console.log(`Retrying... (${attempt}/${retry_count})`);
|
// /* 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);
|
||||||
|
|
||||||
// let axios_api = axios.create({
|
// temp_post_object_percent_completed = percent_completed;
|
||||||
// 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') {
|
// try {
|
||||||
// if (form_data) {
|
// window.postMessage({
|
||||||
// axios_api.defaults.headers['content-type'] = 'multipart/form-data';
|
// type: 'api_post_json_form',
|
||||||
// data = form_data;
|
// status: 'uploading',
|
||||||
// } else {
|
// task_id: task_id,
|
||||||
// axios_api.defaults.headers['content-type'] = 'application/json';
|
// 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: any) {
|
||||||
|
// 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 (!return_blob) {
|
// if (log_lvl > 1) {
|
||||||
// let response_data = await axios_api.post(
|
// console.log('Response Data:', response_data);
|
||||||
// endpoint,
|
// }
|
||||||
// data,
|
// axios_api.defaults.headers['content-type'] = 'application/json';
|
||||||
// {
|
// return response_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;
|
// } else {
|
||||||
|
// // console.log('Expecting a Blob to be returned...');
|
||||||
|
|
||||||
// try {
|
// let response_data_promise = await axios_api.post(
|
||||||
// window.postMessage({
|
// endpoint,
|
||||||
// type: 'api_post_json_form',
|
// data,
|
||||||
// status: 'uploading',
|
// {
|
||||||
// task_id: task_id,
|
// params: params,
|
||||||
// endpoint: endpoint,
|
// responseType: 'blob',
|
||||||
// size_total: progressEvent.total,
|
// onDownloadProgress: (progressEvent) => {
|
||||||
// size_loaded: progressEvent.loaded,
|
// let percent_completed = Math.round(
|
||||||
// percent_completed: percent_completed,
|
// (progressEvent.loaded * 100) / progressEvent.total
|
||||||
// progress: progressEvent.progress,
|
// );
|
||||||
// rate: progressEvent.rate,
|
// console.log('POST Blob Progress:', progressEvent.progress, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed);
|
||||||
// },
|
|
||||||
// '*'
|
|
||||||
// );
|
|
||||||
// } 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) {
|
// temp_post_blob_percent_completed = percent_completed;
|
||||||
// // 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 {
|
// .then(function (response) {
|
||||||
// // This should mean that the request was successful, and a result with data was returned from Aether API.
|
// if (log_lvl) {
|
||||||
// // console.log('Returning data after POST');
|
// console.log(response);
|
||||||
// return response.data['data'];
|
// }
|
||||||
// }
|
|
||||||
// //return response.data;
|
|
||||||
// })
|
|
||||||
// .catch(function (error: any) {
|
|
||||||
// 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) {
|
// const { data, headers } = response
|
||||||
// console.log('Response Data:', response_data);
|
// console.log(headers);
|
||||||
// }
|
|
||||||
// axios_api.defaults.headers['content-type'] = 'application/json';
|
|
||||||
// return response_data;
|
|
||||||
|
|
||||||
// } else {
|
// if (filename) {
|
||||||
// // console.log('Expecting a Blob to be returned...');
|
// } else if (headers['content-disposition']) {
|
||||||
|
// filename = headers['content-disposition'].replace(/\w+;filename=(.*)/, '$1');
|
||||||
|
// } else {
|
||||||
|
// filename = 'unknown_file.ext';
|
||||||
|
// }
|
||||||
|
|
||||||
// let response_data_promise = await axios_api.post(
|
// if (auto_download) {
|
||||||
// endpoint,
|
// const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||||
// data,
|
// const link = document.createElement('a');
|
||||||
// {
|
// link.href = url;
|
||||||
// params: params,
|
// // link.setAttribute('download', 'event_exhibit_tracking_export.xlsx'); //or any other extension
|
||||||
// responseType: 'blob',
|
// link.setAttribute('download', filename); //or any other extension
|
||||||
// onDownloadProgress: (progressEvent) => {
|
// document.body.appendChild(link);
|
||||||
// let percent_completed = Math.round(
|
// link.click();
|
||||||
// (progressEvent.loaded * 100) / progressEvent.total
|
// return true;
|
||||||
// );
|
// } else {
|
||||||
// console.log('POST Blob Progress:', progressEvent.progress, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed);
|
// return response;
|
||||||
|
// }
|
||||||
// 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);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// 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) {
|
// function resolved(result: any) {
|
||||||
// console.log('Resolved');
|
// console.log('Resolved');
|
||||||
@@ -352,4 +348,4 @@ export let post_object = async function post_object(
|
|||||||
|
|
||||||
// function rejected(result: any) {
|
// function rejected(result: any) {
|
||||||
// console.error(result);
|
// console.error(result);
|
||||||
// }
|
// }
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,475 +1,482 @@
|
|||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
|
|
||||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
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/ae_archives/db_archives';
|
||||||
|
|
||||||
let ae_promises: key_val = {};
|
|
||||||
|
|
||||||
|
const 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
|
// 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
|
// Updated 2024-09-25
|
||||||
export async function load_ae_obj_id__archive_content(
|
export async function load_ae_obj_id__archive_content({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
archive_content_id,
|
||||||
archive_content_id,
|
// enabled = 'enabled',
|
||||||
// enabled = 'enabled',
|
// hidden = 'not_hidden',
|
||||||
// hidden = 'not_hidden',
|
// limit = 99,
|
||||||
// limit = 99,
|
// offset = 0,
|
||||||
// offset = 0,
|
params = {},
|
||||||
params = {},
|
try_cache = true,
|
||||||
try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
archive_content_id: string;
|
||||||
archive_content_id: string,
|
// enabled?: "enabled" | "all" | "not_enabled" | undefined,
|
||||||
// enabled?: "enabled" | "all" | "not_enabled" | undefined,
|
// hidden?: "hidden" | "all" | "not_hidden" | undefined,
|
||||||
// hidden?: "hidden" | "all" | "not_hidden" | undefined,
|
// limit?: number,
|
||||||
// limit?: number,
|
// offset?: number,
|
||||||
// offset?: number,
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(
|
||||||
if (log_lvl) {
|
`*** 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}`);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ae_promises.load__archive_content_obj = await api.get_ae_obj_id_crud({
|
ae_promises.load__archive_content_obj = await api
|
||||||
api_cfg: api_cfg,
|
.get_ae_obj_id_crud({
|
||||||
obj_type: 'archive_content',
|
api_cfg: api_cfg,
|
||||||
obj_id: archive_content_id,
|
obj_type: 'archive_content',
|
||||||
use_alt_table: false,
|
obj_id: archive_content_id,
|
||||||
use_alt_base: false,
|
use_alt_table: false,
|
||||||
params: params,
|
use_alt_base: false,
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(async function (archive_content_obj_get_result) {
|
})
|
||||||
if (archive_content_obj_get_result) {
|
.then(async function (archive_content_obj_get_result) {
|
||||||
if (try_cache) {
|
if (archive_content_obj_get_result) {
|
||||||
// Process the results first
|
if (try_cache) {
|
||||||
let processed_obj_li = await process_ae_obj__archive_content_props({
|
// Process the results first
|
||||||
obj_li: [archive_content_obj_get_result],
|
const processed_obj_li = await process_ae_obj__archive_content_props({
|
||||||
log_lvl: log_lvl,
|
obj_li: [archive_content_obj_get_result],
|
||||||
});
|
log_lvl: log_lvl
|
||||||
if (log_lvl) {
|
});
|
||||||
console.log('Processed object list:', 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) {
|
// Save the updated results list to the database
|
||||||
console.log('Saving to DB...');
|
if (log_lvl) {
|
||||||
}
|
console.log('Saving to DB...');
|
||||||
await db_save_ae_obj_li__ae_obj({
|
}
|
||||||
db_instance: db_archives,
|
await db_save_ae_obj_li__ae_obj({
|
||||||
table_name: 'content',
|
db_instance: db_archives,
|
||||||
obj_li: processed_obj_li,
|
table_name: 'content',
|
||||||
properties_to_save: properties_to_save,
|
obj_li: processed_obj_li,
|
||||||
log_lvl: log_lvl,
|
properties_to_save: properties_to_save,
|
||||||
});
|
log_lvl: log_lvl
|
||||||
if (log_lvl) {
|
});
|
||||||
console.log('DB save completed.');
|
if (log_lvl) {
|
||||||
}
|
console.log('DB save completed.');
|
||||||
|
}
|
||||||
|
|
||||||
// // This is expecting a list
|
// // This is expecting a list
|
||||||
// await db_save_ae_obj_li__archive_content({
|
// await db_save_ae_obj_li__archive_content({
|
||||||
// obj_type: 'archive_content',
|
// obj_type: 'archive_content',
|
||||||
// obj_li: [archive_content_obj_get_result]
|
// obj_li: [archive_content_obj_get_result]
|
||||||
|
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
return archive_content_obj_get_result;
|
return archive_content_obj_get_result;
|
||||||
} else {
|
} else {
|
||||||
console.log('No results returned.');
|
console.log('No results returned.');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function (error: any) {
|
.catch(function (error: any) {
|
||||||
console.log('No results returned or failed.', error);
|
console.log('No results returned or failed.', error);
|
||||||
});
|
});
|
||||||
|
|
||||||
return ae_promises.load__archive_content_obj;
|
return ae_promises.load__archive_content_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-11-20
|
// Updated 2024-11-20
|
||||||
export async function load_ae_obj_li__archive_content(
|
export async function load_ae_obj_li__archive_content({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
for_obj_type = 'archive',
|
||||||
for_obj_type = 'archive',
|
for_obj_id,
|
||||||
for_obj_id,
|
enabled = 'enabled',
|
||||||
enabled = 'enabled',
|
hidden = 'not_hidden',
|
||||||
hidden = 'not_hidden',
|
limit = 99,
|
||||||
limit = 99,
|
offset = 0,
|
||||||
offset = 0,
|
order_by_li = {
|
||||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'original_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
priority: 'DESC',
|
||||||
params = {},
|
sort: 'DESC',
|
||||||
try_cache = true,
|
original_datetime: 'ASC',
|
||||||
log_lvl = 0
|
name: 'ASC',
|
||||||
}: {
|
updated_on: 'DESC',
|
||||||
api_cfg: any,
|
created_on: 'DESC'
|
||||||
for_obj_type: string,
|
},
|
||||||
for_obj_id: string,
|
params = {},
|
||||||
enabled?: "enabled" | "all" | "not_enabled" | undefined,
|
try_cache = true,
|
||||||
hidden?: "hidden" | "all" | "not_hidden" | undefined,
|
log_lvl = 0
|
||||||
limit?: number,
|
}: {
|
||||||
offset?: number,
|
api_cfg: any;
|
||||||
order_by_li?: key_val,
|
for_obj_type: string;
|
||||||
params?: key_val,
|
for_obj_id: string;
|
||||||
try_cache?: boolean,
|
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
|
||||||
log_lvl?: number
|
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
|
||||||
}
|
limit?: number;
|
||||||
) {
|
offset?: number;
|
||||||
if (log_lvl) {
|
order_by_li?: key_val;
|
||||||
console.log(`*** load_ae_obj_li__archive_content() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
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}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let params_json: key_val = {};
|
const params_json: key_val = {};
|
||||||
|
|
||||||
// console('params_json:', params_json);
|
// 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
|
||||||
api_cfg: api_cfg,
|
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||||
obj_type: 'archive_content',
|
api_cfg: api_cfg,
|
||||||
for_obj_type: for_obj_type,
|
obj_type: 'archive_content',
|
||||||
for_obj_id: for_obj_id,
|
for_obj_type: for_obj_type,
|
||||||
use_alt_tbl: false,
|
for_obj_id: for_obj_id,
|
||||||
use_alt_mdl: false,
|
use_alt_tbl: false,
|
||||||
use_alt_exp: false,
|
use_alt_mdl: false,
|
||||||
enabled: enabled,
|
use_alt_exp: false,
|
||||||
hidden: hidden,
|
enabled: enabled,
|
||||||
order_by_li: order_by_li,
|
hidden: hidden,
|
||||||
limit: limit,
|
order_by_li: order_by_li,
|
||||||
offset: offset,
|
limit: limit,
|
||||||
params_json: params_json,
|
offset: offset,
|
||||||
params: params,
|
params_json: params_json,
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(async function (archive_content_obj_li_get_result) {
|
})
|
||||||
if (archive_content_obj_li_get_result) {
|
.then(async function (archive_content_obj_li_get_result) {
|
||||||
if (try_cache) {
|
if (archive_content_obj_li_get_result) {
|
||||||
// Process the results first
|
if (try_cache) {
|
||||||
let processed_obj_li = await process_ae_obj__archive_content_props({
|
// Process the results first
|
||||||
obj_li: archive_content_obj_li_get_result,
|
const processed_obj_li = await process_ae_obj__archive_content_props({
|
||||||
log_lvl: log_lvl,
|
obj_li: archive_content_obj_li_get_result,
|
||||||
});
|
log_lvl: log_lvl
|
||||||
if (log_lvl) {
|
});
|
||||||
console.log('Processed object list:', 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) {
|
// Save the updated results list to the database
|
||||||
console.log('Saving to DB...');
|
if (log_lvl) {
|
||||||
}
|
console.log('Saving to DB...');
|
||||||
await db_save_ae_obj_li__ae_obj({
|
}
|
||||||
db_instance: db_archives,
|
await db_save_ae_obj_li__ae_obj({
|
||||||
table_name: 'content',
|
db_instance: db_archives,
|
||||||
obj_li: processed_obj_li,
|
table_name: 'content',
|
||||||
properties_to_save: properties_to_save,
|
obj_li: processed_obj_li,
|
||||||
log_lvl: log_lvl,
|
properties_to_save: properties_to_save,
|
||||||
});
|
log_lvl: log_lvl
|
||||||
if (log_lvl) {
|
});
|
||||||
console.log('DB save completed.');
|
if (log_lvl) {
|
||||||
}
|
console.log('DB save completed.');
|
||||||
|
}
|
||||||
|
|
||||||
// await db_save_ae_obj_li__archive_content({
|
// await db_save_ae_obj_li__archive_content({
|
||||||
// obj_type: 'archive_content', obj_li: archive_content_obj_li_get_result
|
// obj_type: 'archive_content', obj_li: archive_content_obj_li_get_result
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
return archive_content_obj_li_get_result;
|
return archive_content_obj_li_get_result;
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function (error: any) {
|
.catch(function (error: any) {
|
||||||
console.log('No results returned or failed.', error);
|
console.log('No results returned or failed.', error);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.load__archive_content_obj_li:', ae_promises.load__archive_content_obj_li);
|
console.log(
|
||||||
}
|
'ae_promises.load__archive_content_obj_li:',
|
||||||
|
ae_promises.load__archive_content_obj_li
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return ae_promises.load__archive_content_obj_li;
|
return ae_promises.load__archive_content_obj_li;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2025-06-23
|
// Updated 2025-06-23
|
||||||
export async function create_ae_obj__archive_content(
|
export async function create_ae_obj__archive_content({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
archive_id,
|
||||||
archive_id,
|
data_kv,
|
||||||
data_kv,
|
params = {},
|
||||||
params={},
|
try_cache = true,
|
||||||
try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
archive_id: string;
|
||||||
archive_id: string,
|
data_kv: key_val;
|
||||||
data_kv: key_val,
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** create_ae_obj__archive_content() *** archive_id=${archive_id}`);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`*** create_ae_obj__archive_content() *** archive_id=${archive_id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!archive_id) {
|
if (!archive_id) {
|
||||||
console.log(`ERROR: Archives - Content - archive_id required to create`);
|
console.log(`ERROR: Archives - Content - archive_id required to create`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ae_promises.create__archive_content = await api.create_ae_obj_crud({
|
ae_promises.create__archive_content = await api
|
||||||
api_cfg: api_cfg,
|
.create_ae_obj_crud({
|
||||||
obj_type: 'archive_content',
|
api_cfg: api_cfg,
|
||||||
fields: {
|
obj_type: 'archive_content',
|
||||||
archive_id_random: archive_id,
|
fields: {
|
||||||
...data_kv
|
archive_id_random: archive_id,
|
||||||
},
|
...data_kv
|
||||||
key: api_cfg.api_crud_super_key,
|
},
|
||||||
params: params,
|
key: api_cfg.api_crud_super_key,
|
||||||
return_obj: true,
|
params: params,
|
||||||
log_lvl: log_lvl
|
return_obj: true,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(async function (archive_content_obj_create_result) {
|
})
|
||||||
if (archive_content_obj_create_result) {
|
.then(async function (archive_content_obj_create_result) {
|
||||||
if (try_cache) {
|
if (archive_content_obj_create_result) {
|
||||||
// Process the results first
|
if (try_cache) {
|
||||||
let processed_obj_li = await process_ae_obj__archive_content_props({
|
// Process the results first
|
||||||
obj_li: [archive_content_obj_create_result],
|
const processed_obj_li = await process_ae_obj__archive_content_props({
|
||||||
log_lvl: log_lvl,
|
obj_li: [archive_content_obj_create_result],
|
||||||
});
|
log_lvl: log_lvl
|
||||||
if (log_lvl) {
|
});
|
||||||
console.log('Processed object list:', 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) {
|
// Save the updated results list to the database
|
||||||
console.log('Saving to DB...');
|
if (log_lvl) {
|
||||||
}
|
console.log('Saving to DB...');
|
||||||
await db_save_ae_obj_li__ae_obj({
|
}
|
||||||
db_instance: db_archives,
|
await db_save_ae_obj_li__ae_obj({
|
||||||
table_name: 'content',
|
db_instance: db_archives,
|
||||||
obj_li: processed_obj_li,
|
table_name: 'content',
|
||||||
properties_to_save: properties_to_save,
|
obj_li: processed_obj_li,
|
||||||
log_lvl: log_lvl,
|
properties_to_save: properties_to_save,
|
||||||
});
|
log_lvl: log_lvl
|
||||||
if (log_lvl) {
|
});
|
||||||
console.log('DB save completed.');
|
if (log_lvl) {
|
||||||
}
|
console.log('DB save completed.');
|
||||||
|
}
|
||||||
|
|
||||||
// await db_save_ae_obj_li__archive_content(
|
// await db_save_ae_obj_li__archive_content(
|
||||||
// {
|
// {
|
||||||
// obj_type: 'archive_content',
|
// obj_type: 'archive_content',
|
||||||
// obj_li: [archive_content_obj_create_result]
|
// obj_li: [archive_content_obj_create_result]
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
return archive_content_obj_create_result;
|
return archive_content_obj_create_result;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function (error: any) {
|
.catch(function (error: any) {
|
||||||
console.log('No results returned or failed.', error);
|
console.log('No results returned or failed.', error);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.create__archive_content:', ae_promises.create__archive_content);
|
console.log('ae_promises.create__archive_content:', ae_promises.create__archive_content);
|
||||||
}
|
}
|
||||||
return ae_promises.create__archive_content;
|
return ae_promises.create__archive_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-11-08
|
// Updated 2024-11-08
|
||||||
export async function delete_ae_obj_id__archive_content(
|
export async function delete_ae_obj_id__archive_content({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
archive_content_id,
|
||||||
archive_content_id,
|
method = 'delete', // 'delete', 'disable', 'hide'
|
||||||
method = 'delete', // 'delete', 'disable', 'hide'
|
params = {},
|
||||||
params = {},
|
try_cache = true,
|
||||||
try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
archive_content_id: string;
|
||||||
archive_content_id: string,
|
method?: string;
|
||||||
method?: string,
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(
|
||||||
if (log_lvl) {
|
`*** delete_ae_obj_id__archive_content() *** archive_content_id=${archive_content_id}`
|
||||||
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({
|
ae_promises.delete__archive_content_obj = await api
|
||||||
api_cfg: api_cfg,
|
.delete_ae_obj_id_crud({
|
||||||
obj_type: 'archive_content',
|
api_cfg: api_cfg,
|
||||||
obj_id: archive_content_id,
|
obj_type: 'archive_content',
|
||||||
key: api_cfg.api_crud_super_key,
|
obj_id: archive_content_id,
|
||||||
params: params,
|
key: api_cfg.api_crud_super_key,
|
||||||
method: method,
|
params: params,
|
||||||
log_lvl: log_lvl
|
method: method,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
})
|
console.log('No results returned or failed.', error);
|
||||||
.finally(function () {
|
})
|
||||||
if (try_cache) {
|
.finally(function () {
|
||||||
if (log_lvl) {
|
if (try_cache) {
|
||||||
console.log(`Attempting to remove IDB entry for archive_content_id=${archive_content_id}`);
|
if (log_lvl) {
|
||||||
}
|
console.log(
|
||||||
db_archives.content.delete(archive_content_id); // Delete from the DB no matter what.
|
`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) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.delete__archive_content_obj:', ae_promises.delete__archive_content_obj);
|
console.log(
|
||||||
}
|
'ae_promises.delete__archive_content_obj:',
|
||||||
|
ae_promises.delete__archive_content_obj
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return ae_promises.delete__archive_content_obj;
|
return ae_promises.delete__archive_content_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2025-06-23
|
// Updated 2025-06-23
|
||||||
export async function update_ae_obj__archive_content(
|
export async function update_ae_obj__archive_content({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
archive_content_id,
|
||||||
archive_content_id,
|
data_kv,
|
||||||
data_kv,
|
params = {},
|
||||||
params = {},
|
try_cache = true,
|
||||||
try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
archive_content_id: string;
|
||||||
archive_content_id: string,
|
data_kv: key_val;
|
||||||
data_kv: key_val,
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(
|
||||||
if (log_lvl) {
|
`*** update_ae_obj__archive_content() *** archive_content_id=${archive_content_id}`,
|
||||||
console.log(`*** update_ae_obj__archive_content() *** archive_content_id=${archive_content_id}`, data_kv);
|
data_kv
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Perform the API update
|
// Perform the API update
|
||||||
const result = await api.update_ae_obj_id_crud({
|
const result = await api.update_ae_obj_id_crud({
|
||||||
api_cfg: api_cfg,
|
api_cfg: api_cfg,
|
||||||
obj_type: 'archive_content',
|
obj_type: 'archive_content',
|
||||||
obj_id: archive_content_id,
|
obj_id: archive_content_id,
|
||||||
fields: data_kv,
|
fields: data_kv,
|
||||||
key: api_cfg.api_crud_super_key,
|
key: api_cfg.api_crud_super_key,
|
||||||
params: params,
|
params: params,
|
||||||
return_obj: true,
|
return_obj: true,
|
||||||
log_lvl: log_lvl,
|
log_lvl: log_lvl
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle the result
|
// Handle the result
|
||||||
if (result) {
|
if (result) {
|
||||||
if (try_cache) {
|
if (try_cache) {
|
||||||
// Process the results first
|
// Process the results first
|
||||||
let processed_obj_li = await process_ae_obj__archive_content_props({
|
const processed_obj_li = await process_ae_obj__archive_content_props({
|
||||||
obj_li: [result],
|
obj_li: [result],
|
||||||
log_lvl: log_lvl,
|
log_lvl: log_lvl
|
||||||
});
|
});
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Processed object list:', processed_obj_li);
|
console.log('Processed object list:', processed_obj_li);
|
||||||
}
|
}
|
||||||
// Save the updated results list to the database
|
// Save the updated results list to the database
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Saving to DB...');
|
console.log('Saving to DB...');
|
||||||
}
|
}
|
||||||
await db_save_ae_obj_li__ae_obj({
|
await db_save_ae_obj_li__ae_obj({
|
||||||
db_instance: db_archives,
|
db_instance: db_archives,
|
||||||
table_name: 'content',
|
table_name: 'content',
|
||||||
obj_li: processed_obj_li,
|
obj_li: processed_obj_li,
|
||||||
properties_to_save: properties_to_save,
|
properties_to_save: properties_to_save,
|
||||||
log_lvl: log_lvl,
|
log_lvl: log_lvl
|
||||||
});
|
});
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('DB save completed.');
|
console.log('DB save completed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// await db_save_ae_obj_li__archive_content({
|
// await db_save_ae_obj_li__archive_content({
|
||||||
// obj_type: 'archive_content',
|
// obj_type: 'archive_content',
|
||||||
// obj_li: [result],
|
// obj_li: [result],
|
||||||
// log_lvl: log_lvl,
|
// log_lvl: log_lvl,
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
console.error('Failed to update archive content.');
|
console.error('Failed to update archive content.');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Updated 2025-06-04
|
// Updated 2025-06-04
|
||||||
export const properties_to_save = [
|
export const properties_to_save = [
|
||||||
'id',
|
'id',
|
||||||
'archive_content_id',
|
'archive_content_id',
|
||||||
// 'archive_content_id_random',
|
// 'archive_content_id_random',
|
||||||
|
|
||||||
'archive_id',
|
'archive_id',
|
||||||
// 'archive_id_random',
|
// 'archive_id_random',
|
||||||
|
|
||||||
'archive_content_type',
|
'archive_content_type',
|
||||||
|
|
||||||
'name',
|
'name',
|
||||||
'description',
|
'description',
|
||||||
|
|
||||||
'content_html',
|
'content_html',
|
||||||
'content_json',
|
'content_json',
|
||||||
|
|
||||||
'url',
|
'url',
|
||||||
'url_text',
|
'url_text',
|
||||||
|
|
||||||
'hosted_file_id',
|
'hosted_file_id',
|
||||||
'hosted_file_id_random',
|
'hosted_file_id_random',
|
||||||
|
|
||||||
'file_path',
|
'file_path',
|
||||||
|
|
||||||
'filename',
|
'filename',
|
||||||
'file_extension',
|
'file_extension',
|
||||||
|
|
||||||
'original_datetime',
|
'original_datetime',
|
||||||
'original_timezone',
|
'original_timezone',
|
||||||
'original_location',
|
'original_location',
|
||||||
'original_url',
|
'original_url',
|
||||||
'original_url_text',
|
'original_url_text',
|
||||||
|
|
||||||
'enable_for_public',
|
'enable_for_public',
|
||||||
|
|
||||||
'cfg_json',
|
'cfg_json',
|
||||||
|
|
||||||
'enable',
|
'enable',
|
||||||
'hide',
|
'hide',
|
||||||
'priority',
|
'priority',
|
||||||
'sort',
|
'sort',
|
||||||
'group',
|
'group',
|
||||||
'notes',
|
'notes',
|
||||||
'created_on',
|
'created_on',
|
||||||
'updated_on',
|
'updated_on',
|
||||||
|
|
||||||
// Generated fields for sorting locally only
|
// Generated fields for sorting locally only
|
||||||
'tmp_sort_1',
|
'tmp_sort_1',
|
||||||
'tmp_sort_2',
|
'tmp_sort_2',
|
||||||
// 'tmp_sort_a',
|
// 'tmp_sort_a',
|
||||||
// 'tmp_sort_b',
|
// 'tmp_sort_b',
|
||||||
|
|
||||||
// From SQL view
|
// From SQL view
|
||||||
'archive_code',
|
'archive_code',
|
||||||
'archive_name',
|
'archive_name',
|
||||||
|
|
||||||
'hash_sha256'
|
'hash_sha256'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NON-EXPORTED LOCAL HELPER
|
* NON-EXPORTED LOCAL HELPER
|
||||||
* Processes a list of Aether objects by applying common and specific transformations.
|
* Processes a list of Aether objects by applying common and specific transformations.
|
||||||
@@ -538,7 +545,6 @@ async function _process_generic_props<T extends Record<string, any>>({
|
|||||||
return processed_obj_li;
|
return processed_obj_li;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2025-06-04
|
// Updated 2025-06-04
|
||||||
export async function process_ae_obj__archive_content_props({
|
export async function process_ae_obj__archive_content_props({
|
||||||
obj_li,
|
obj_li,
|
||||||
@@ -557,9 +563,11 @@ export async function process_ae_obj__archive_content_props({
|
|||||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||||
}_${obj.original_datetime ?? ''}`;
|
}_${obj.original_datetime ?? ''}`;
|
||||||
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.original_datetime ?? ''}_${
|
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.original_datetime ?? ''}_${
|
||||||
obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}`;
|
obj.priority ? '1' : '0'
|
||||||
|
}_${obj.sort?.toString().padStart(3, '0') ?? ''}`;
|
||||||
obj.tmp_sort_3 = `${obj.original_datetime ?? ''}_${obj.group ?? ''}_${
|
obj.tmp_sort_3 = `${obj.original_datetime ?? ''}_${obj.group ?? ''}_${
|
||||||
obj.priority ? '1' : '0'}_${obj.sort?.toString().padStart(3, '0') ?? ''}`;
|
obj.priority ? '1' : '0'
|
||||||
|
}_${obj.sort?.toString().padStart(3, '0') ?? ''}`;
|
||||||
|
|
||||||
obj.hash_sha256 = obj.hosted_file_hash_sha256;
|
obj.hash_sha256 = obj.hosted_file_hash_sha256;
|
||||||
|
|
||||||
|
|||||||
@@ -1,38 +1,32 @@
|
|||||||
// This file is used to export all the functions that are used for Aether Posts related functions.
|
// This file is used to export all the functions that are used for Aether Posts related functions.
|
||||||
|
|
||||||
import {
|
import {
|
||||||
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
|
||||||
|
} from '$lib/ae_archives/ae_archives__archive';
|
||||||
} from "$lib/ae_archives/ae_archives__archive";
|
|
||||||
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
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
|
||||||
|
} from '$lib/ae_archives/ae_archives__archive_content';
|
||||||
|
|
||||||
} from "$lib/ae_archives/ae_archives__archive_content";
|
const export_obj = {
|
||||||
|
load_ae_obj_id__archive: load_ae_obj_id__archive,
|
||||||
|
load_ae_obj_li__archive: load_ae_obj_li__archive,
|
||||||
let export_obj = {
|
create_ae_obj__archive: create_ae_obj__archive,
|
||||||
load_ae_obj_id__archive: load_ae_obj_id__archive,
|
delete_ae_obj_id__archive: delete_ae_obj_id__archive,
|
||||||
load_ae_obj_li__archive: load_ae_obj_li__archive,
|
update_ae_obj__archive: update_ae_obj__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,
|
|
||||||
|
|
||||||
|
|
||||||
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,
|
|
||||||
|
|
||||||
|
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
|
||||||
};
|
};
|
||||||
export let archives_func = export_obj;
|
export const archives_func = export_obj;
|
||||||
|
|||||||
@@ -7,136 +7,135 @@ import type { key_val } from '$lib/stores/ae_stores';
|
|||||||
|
|
||||||
// Updated 2024-09-25
|
// Updated 2024-09-25
|
||||||
export interface Archive {
|
export interface Archive {
|
||||||
id: string;
|
id: string;
|
||||||
// id_random: string;
|
// id_random: string;
|
||||||
archive_id: string;
|
archive_id: string;
|
||||||
// archive_id_random: string;
|
// archive_id_random: string;
|
||||||
|
|
||||||
code?: null|string;
|
code?: null | string;
|
||||||
|
|
||||||
account_id: string;
|
account_id: string;
|
||||||
// account_id_random: string;
|
// account_id_random: string;
|
||||||
|
|
||||||
// archive_type: string;
|
// archive_type: string;
|
||||||
|
|
||||||
// type: string;
|
// type: string;
|
||||||
name: string;
|
name: string;
|
||||||
// summary?: null|string;
|
// summary?: null|string;
|
||||||
description?: null|string;
|
description?: null | string;
|
||||||
|
|
||||||
content_html?: null|string;
|
content_html?: null | string;
|
||||||
content_json?: null|string;
|
content_json?: null | string;
|
||||||
content_url?: null|string;
|
content_url?: null | string;
|
||||||
content_url_text?: null|string;
|
content_url_text?: null | string;
|
||||||
|
|
||||||
original_datetime?: Date;
|
original_datetime?: Date;
|
||||||
original_timezone?: null|string;
|
original_timezone?: null | string;
|
||||||
original_location?: null|string;
|
original_location?: null | string;
|
||||||
|
|
||||||
original_url?: null|string;
|
original_url?: null | string;
|
||||||
original_url_text?: null|string;
|
original_url_text?: null | string;
|
||||||
|
|
||||||
// meta_data?: null|string;
|
// meta_data?: null|string;
|
||||||
// access_key?: null|string; /// Rename this to "passcode" if used later
|
// access_key?: null|string; /// Rename this to "passcode" if used later
|
||||||
|
|
||||||
sort_by?: null|string;
|
sort_by?: null | string;
|
||||||
sort_by_desc?: null|string;
|
sort_by_desc?: null | string;
|
||||||
|
|
||||||
cfg_json?: null|key_val;
|
cfg_json?: null | key_val;
|
||||||
|
|
||||||
enable: null|boolean;
|
enable: null | boolean;
|
||||||
hide?: null|boolean;
|
hide?: null | boolean;
|
||||||
priority?: null|boolean
|
priority?: null | boolean;
|
||||||
sort?: null|number;
|
sort?: null | number;
|
||||||
group?: null|string;
|
group?: null | string;
|
||||||
notes?: null|string;
|
notes?: null | string;
|
||||||
created_on: Date;
|
created_on: Date;
|
||||||
updated_on?: null|Date;
|
updated_on?: null | Date;
|
||||||
|
|
||||||
// Generated fields for sorting locally only
|
// Generated fields for sorting locally only
|
||||||
tmp_sort_1?: null|string;
|
tmp_sort_1?: null | string;
|
||||||
tmp_sort_2?: null|string;
|
tmp_sort_2?: null | string;
|
||||||
|
|
||||||
// Additional fields for convenience (database views)
|
// Additional fields for convenience (database views)
|
||||||
// archive_content_count?: number;
|
// archive_content_count?: number;
|
||||||
// archive_content_kv?: null|key_val;
|
// archive_content_kv?: null|key_val;
|
||||||
// archive_content_li?: null|[];
|
// archive_content_li?: null|[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updated 2024-09-25
|
// Updated 2024-09-25
|
||||||
export interface Archive_Content {
|
export interface Archive_Content {
|
||||||
id: string;
|
id: string;
|
||||||
// id_random: string;
|
// id_random: string;
|
||||||
archive_content_id: string;
|
archive_content_id: string;
|
||||||
// archive_content_id_random: string;
|
// archive_content_id_random: string;
|
||||||
|
|
||||||
archive_id: string;
|
archive_id: string;
|
||||||
// archive_id_random: string;
|
// archive_id_random: string;
|
||||||
|
|
||||||
archive_content_type: string;
|
archive_content_type: string;
|
||||||
|
|
||||||
name: string;
|
name: string;
|
||||||
description?: null|string;
|
description?: null | string;
|
||||||
|
|
||||||
content_html?: null|string;
|
content_html?: null | string;
|
||||||
content_json?: null|string;
|
content_json?: null | string;
|
||||||
|
|
||||||
// linked_li_json?: null|string; // For future use? linked content list instead of one content item
|
// linked_li_json?: null|string; // For future use? linked content list instead of one content item
|
||||||
|
|
||||||
url?: null|string;
|
url?: null | string;
|
||||||
url_text?: null|string;
|
url_text?: null | string;
|
||||||
|
|
||||||
hosted_file_id?: string;
|
hosted_file_id?: string;
|
||||||
|
|
||||||
file_path?: null|string;
|
file_path?: null | string;
|
||||||
|
|
||||||
filename?: null|string;
|
filename?: null | string;
|
||||||
file_extension?: null|string;
|
file_extension?: null | string;
|
||||||
|
|
||||||
original_datetime?: Date;
|
original_datetime?: Date;
|
||||||
original_timezone?: null|string;
|
original_timezone?: null | string;
|
||||||
original_location?: null|string;
|
original_location?: null | string;
|
||||||
original_url?: null|string;
|
original_url?: null | string;
|
||||||
original_url_text?: null|string;
|
original_url_text?: null | string;
|
||||||
|
|
||||||
// meta_data?: null|string;
|
// meta_data?: null|string;
|
||||||
// access_key?: null|string; /// Rename this to "passcode" if used later
|
// access_key?: null|string; /// Rename this to "passcode" if used later
|
||||||
|
|
||||||
enable_for_public?: boolean;
|
enable_for_public?: boolean;
|
||||||
|
|
||||||
cfg_json?: null|key_val;
|
cfg_json?: null | key_val;
|
||||||
|
|
||||||
enable: null|boolean;
|
enable: null | boolean;
|
||||||
hide?: null|boolean;
|
hide?: null | boolean;
|
||||||
priority?: null|boolean
|
priority?: null | boolean;
|
||||||
sort?: null|number;
|
sort?: null | number;
|
||||||
group?: null|string;
|
group?: null | string;
|
||||||
notes?: null|string;
|
notes?: null | string;
|
||||||
created_on: Date;
|
created_on: Date;
|
||||||
updated_on?: null|Date;
|
updated_on?: null | Date;
|
||||||
|
|
||||||
// Generated fields for sorting locally only
|
// Generated fields for sorting locally only
|
||||||
tmp_sort_1?: null|string;
|
tmp_sort_1?: null | string;
|
||||||
tmp_sort_2?: null|string;
|
tmp_sort_2?: null | string;
|
||||||
|
|
||||||
// Additional fields for convenience (database views)
|
// Additional fields for convenience (database views)
|
||||||
archive_code?: null|string;
|
archive_code?: null | string;
|
||||||
archive_name?: null|string;
|
archive_name?: null | string;
|
||||||
|
|
||||||
hash_sha256?: null|string;
|
hash_sha256?: null | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-09-25
|
// Updated 2024-09-25
|
||||||
export class MySubClassedDexie extends Dexie {
|
export class MySubClassedDexie extends Dexie {
|
||||||
// We just tell the typing system this is the case
|
// We just tell the typing system this is the case
|
||||||
archive!: Table<Archive>;
|
archive!: Table<Archive>;
|
||||||
content!: Table<Archive_Content>;
|
content!: Table<Archive_Content>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super('ae_archives_db');
|
super('ae_archives_db');
|
||||||
this.version(1).stores({
|
this.version(1).stores({
|
||||||
archive: `
|
archive: `
|
||||||
id, archive_id,
|
id, archive_id,
|
||||||
code,
|
code,
|
||||||
account_id,
|
account_id,
|
||||||
@@ -144,7 +143,7 @@ export class MySubClassedDexie extends Dexie {
|
|||||||
original_datetime, original_timezone, original_location,
|
original_datetime, original_timezone, original_location,
|
||||||
tmp_sort_1, tmp_sort_2,
|
tmp_sort_1, tmp_sort_2,
|
||||||
enable, hide, priority, sort, group, notes, created_on, updated_on`,
|
enable, hide, priority, sort, group, notes, created_on, updated_on`,
|
||||||
content: `
|
content: `
|
||||||
id, archive_content_id,
|
id, archive_content_id,
|
||||||
archive_id,
|
archive_id,
|
||||||
archive_content_type,
|
archive_content_type,
|
||||||
@@ -153,14 +152,14 @@ export class MySubClassedDexie extends Dexie {
|
|||||||
original_datetime, original_timezone, original_location,
|
original_datetime, original_timezone, original_location,
|
||||||
[group+original_datetime],
|
[group+original_datetime],
|
||||||
tmp_sort_1, tmp_sort_2,
|
tmp_sort_1, tmp_sort_2,
|
||||||
enable, hide, priority, sort, group, notes, created_on, updated_on, [group+priority+sort+updated_on]`,
|
enable, hide, priority, sort, group, notes, created_on, updated_on, [group+priority+sort+updated_on]`
|
||||||
});
|
});
|
||||||
|
|
||||||
// file_path,
|
// file_path,
|
||||||
// filename, file_extension,
|
// filename, file_extension,
|
||||||
// original_datetime, original_timezone, original_location, original_url, original_url_text,
|
// original_datetime, original_timezone, original_location, original_url, original_url_text,
|
||||||
// enable_for_public,
|
// enable_for_public,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const db_archives = new MySubClassedDexie();
|
export const db_archives = new MySubClassedDexie();
|
||||||
|
|||||||
@@ -1,367 +1,387 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { preventDefault } from 'svelte/legacy';
|
import { preventDefault } from 'svelte/legacy';
|
||||||
|
|
||||||
// Imports
|
// Imports
|
||||||
// Import components and elements
|
// Import components and elements
|
||||||
// import Element_input_files_tbl from '$lib/element_input_files_tbl.svelte';
|
// import Element_input_files_tbl from '$lib/element_input_files_tbl.svelte';
|
||||||
|
|
||||||
// Import storage, functions, and libraries
|
// Import storage, functions, and libraries
|
||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
|
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
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/stores/ae_stores';
|
import {
|
||||||
|
ae_snip,
|
||||||
|
ae_loc,
|
||||||
|
ae_sess,
|
||||||
|
ae_api,
|
||||||
|
ae_trig,
|
||||||
|
slct,
|
||||||
|
slct_trigger
|
||||||
|
} from '$lib/stores/ae_stores';
|
||||||
|
|
||||||
// Exports
|
// Exports
|
||||||
|
|
||||||
|
// export let input_name = 'file_list';
|
||||||
|
// export let multiple: boolean = true;
|
||||||
|
// export let required: boolean = true;
|
||||||
|
|
||||||
// export let input_name = 'file_list';
|
// export let input_class_li: string[] = ['file_drop_area'];
|
||||||
// export let multiple: boolean = true;
|
|
||||||
// export let required: boolean = true;
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// export let input_class_li: string[] = ['file_drop_area'];
|
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 = {};
|
||||||
|
|
||||||
interface Props {
|
// let input_element_id = 'ae_comp__hosted_files_upload__input';
|
||||||
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 {
|
// let form_kv: key_val = {
|
||||||
log_lvl = $bindable(0),
|
// start_time: null,
|
||||||
link_to_type = $bindable(),
|
// end_time: null,
|
||||||
link_to_id = $bindable(),
|
// reencode: null,
|
||||||
class_li_default = 'flex flex-col gap-1 items-center justify-center w-full max-w-2xl mx-auto my-1',
|
// video_file: null,
|
||||||
class_li = $bindable(''),
|
// };
|
||||||
clip_complete = $bindable(false),
|
// let download_clip_src: string;
|
||||||
submit_status = $bindable(null),
|
// let download_clip_filename: string;
|
||||||
// hosted_file_id_li = [],
|
|
||||||
// hosted_file_obj_li = [],
|
|
||||||
hosted_file_obj_kv = $bindable({}),
|
|
||||||
video_clip_file_kv = $bindable({})
|
|
||||||
}: Props = $props();
|
|
||||||
|
|
||||||
|
$ae_sess.files.obj = {
|
||||||
|
obj: null
|
||||||
|
};
|
||||||
|
|
||||||
// Local Variables
|
// *** Functions and Logic
|
||||||
let task_id = link_to_id;
|
function handle_clip_video(event) {
|
||||||
// let input_file_list: any = null;
|
console.log('*** handle_clip_video() ***');
|
||||||
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';
|
submit_status = 'clipping';
|
||||||
|
clip_complete = false;
|
||||||
|
|
||||||
// let form_kv: key_val = {
|
let hosted_file_id = event.target.hosted_file_id.value;
|
||||||
// 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 = {
|
$ae_sess.files.processed_file_kv[hosted_file_id] = {};
|
||||||
obj: null,
|
$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;
|
||||||
|
|
||||||
// *** Functions and Logic
|
let endpoint = `/hosted_file/${hosted_file_id}/clip_video`;
|
||||||
function handle_clip_video(event) {
|
|
||||||
console.log('*** handle_clip_video() ***');
|
|
||||||
|
|
||||||
submit_status = 'clipping';
|
let params = {
|
||||||
clip_complete = false;
|
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
|
||||||
|
};
|
||||||
|
|
||||||
let hosted_file_id = event.target.hosted_file_id.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);
|
||||||
|
|
||||||
$ae_sess.files.processed_file_kv[hosted_file_id] = {};
|
video_clip_file_kv[result.hosted_file_id_random] = {};
|
||||||
$ae_sess.files.processed_file_kv[hosted_file_id].submit_status = 'clipping';
|
video_clip_file_kv[result.hosted_file_id_random] = result;
|
||||||
$ae_sess.files.processed_file_kv[hosted_file_id].clip_complete = false;
|
|
||||||
|
|
||||||
// $ae_sess.files.disable_submit__hosted_file_obj = true;
|
// $ae_loc.files.video_clip_file_kv[result.hosted_file_id_random] = {};
|
||||||
$ae_loc.files.processed_file_kv[hosted_file_id] = {};
|
// $ae_loc.files.video_clip_file_kv[result.hosted_file_id_random] = result;
|
||||||
$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`;
|
$ae_sess.files.processed_file_kv[hosted_file_id].submit_status = 'clipped';
|
||||||
|
$ae_sess.files.processed_file_kv[hosted_file_id].clip_complete = true;
|
||||||
|
|
||||||
let params = {
|
$ae_loc.files.processed_file_kv[hosted_file_id].submit_status = 'clipped';
|
||||||
link_to_type: link_to_type,
|
$ae_loc.files.processed_file_kv[hosted_file_id].clip_complete = true;
|
||||||
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] = {};
|
submit_status = 'clipped';
|
||||||
// .convert__hosted_file_obj
|
clip_complete = true;
|
||||||
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] = {};
|
// let file_blob = new Blob([result.data]);
|
||||||
video_clip_file_kv[result.hosted_file_id_random] = result;
|
// // 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;
|
||||||
|
|
||||||
// $ae_loc.files.video_clip_file_kv[result.hosted_file_id_random] = {};
|
return true;
|
||||||
// $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>
|
</script>
|
||||||
|
|
||||||
|
<section class="{class_li_default} {class_li}">
|
||||||
<section
|
<!-- <h3 class="h3">{hosted_file_obj_li.length}× files uploaded</h3>
|
||||||
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} -->
|
{#each hosted_file_obj_li as hosted_file_obj, i} -->
|
||||||
|
|
||||||
<h3
|
<h3 class="h3">
|
||||||
class="h3"
|
{Object.entries(hosted_file_obj_kv).length}× files uploaded
|
||||||
>
|
</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]}
|
{#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">
|
<div class="border border-gray-300 rounded-lg p-2 m-2">
|
||||||
<!-- {#if $ae_sess.files[hosted_file_id].upload_complete}
|
<!-- {#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>
|
<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} -->
|
{/if} -->
|
||||||
|
|
||||||
<div class="flex flex-row flex-wrap gap-1 justify-center items-center w-full">
|
<div class="flex flex-row flex-wrap gap-1 justify-center items-center w-full">
|
||||||
<!-- Remove from uploaded file kv list -->
|
<!-- Remove from uploaded file kv list -->
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onclick={() => {
|
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.
|
// 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);
|
console.log(
|
||||||
// delete $ae_sess.files.uploaded_file_kv[hosted_file_id];
|
`Removed hosted file ID: ${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 = {...$ae_loc.files.uploaded_file_kv};
|
);
|
||||||
delete hosted_file_obj_kv[hosted_file_id];
|
// delete $ae_sess.files.uploaded_file_kv[hosted_file_id];
|
||||||
hosted_file_obj_kv = {...hosted_file_obj_kv};
|
delete $ae_loc.files.uploaded_file_kv[hosted_file_id];
|
||||||
// delete $ae_loc.files.uploaded_file_kv[hosted_file_obj.hosted_file_id];
|
$ae_loc.files.uploaded_file_kv = { ...$ae_loc.files.uploaded_file_kv };
|
||||||
console.log(`Removed hosted file ID: ${hosted_file_obj.hosted_file_id}`, $ae_loc.files.uploaded_file_kv);
|
delete hosted_file_obj_kv[hosted_file_id];
|
||||||
}}
|
hosted_file_obj_kv = { ...hosted_file_obj_kv };
|
||||||
class="btn btn-sm preset-tonal-warning hover:preset-filled-warning-500"
|
// delete $ae_loc.files.uploaded_file_kv[hosted_file_obj.hosted_file_id];
|
||||||
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}`}
|
console.log(
|
||||||
>
|
`Removed hosted file ID: ${hosted_file_obj.hosted_file_id}`,
|
||||||
<span class="fas fa-minus-circle m-1"></span>
|
$ae_loc.files.uploaded_file_kv
|
||||||
<span class="">Remove</span>
|
);
|
||||||
</button>
|
}}
|
||||||
|
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 -->
|
<!-- Download the file -->
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
disabled={!$ae_loc.trusted_access}
|
disabled={!$ae_loc.trusted_access}
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
ae_promises[hosted_file_id] = api.download_hosted_file({
|
ae_promises[hosted_file_id] = api.download_hosted_file({
|
||||||
api_cfg: $ae_api,
|
api_cfg: $ae_api,
|
||||||
hosted_file_id: hosted_file_id,
|
hosted_file_id: hosted_file_id,
|
||||||
return_file: true,
|
return_file: true,
|
||||||
filename: hosted_file_obj.filename,
|
filename: hosted_file_obj.filename,
|
||||||
auto_download: true,
|
auto_download: true,
|
||||||
log_lvl: 0
|
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 }, '*');
|
// 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: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"
|
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}`}
|
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]}
|
{#await ae_promises[hosted_file_id]}
|
||||||
<span class="fas fa-spinner fa-spin mx-1"></span>
|
<span class="fas fa-spinner fa-spin mx-1"></span>
|
||||||
{#if submit_status == 'clipping'}
|
{#if submit_status == 'clipping'}
|
||||||
<span class="">Clipping</span>
|
<span class="">Clipping</span>
|
||||||
{:else}
|
{:else}
|
||||||
<span class="">
|
<span class="">
|
||||||
Downloading
|
Downloading
|
||||||
{#if $ae_sess.api_download_kv[hosted_file_id]}
|
{#if $ae_sess.api_download_kv[hosted_file_id]}
|
||||||
{$ae_sess.api_download_kv[hosted_file_id].percent_completed}%
|
{$ae_sess.api_download_kv[hosted_file_id].percent_completed}%
|
||||||
{/if}
|
{/if}
|
||||||
:
|
:
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
{:then}
|
{:then}
|
||||||
<span class="fas fa-{ae_util.file_extension_icon(hosted_file_obj?.file_extension)}"></span>
|
<span class="fas fa-{ae_util.file_extension_icon(hosted_file_obj?.file_extension)}"
|
||||||
{/await}
|
></span>
|
||||||
|
{/await}
|
||||||
|
|
||||||
<span class="grow">
|
<span class="grow">
|
||||||
{ae_util.shorten_filename({filename: hosted_file_obj?.filename, max_length: 30})}
|
{ae_util.shorten_filename({ filename: hosted_file_obj?.filename, max_length: 30 })}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<span>{ae_util.shorten_filename({filename: hosted_file_obj?.filename, max_length: 30})}</span>
|
<span
|
||||||
<span>
|
>{ae_util.shorten_filename({ filename: hosted_file_obj?.filename, max_length: 30 })}</span
|
||||||
<span class="text-sm font-bold">
|
>
|
||||||
File ID:
|
<span>
|
||||||
</span>
|
<span class="text-sm font-bold"> File ID: </span>
|
||||||
{hosted_file_obj.hosted_file_id_random}</span>
|
{hosted_file_obj.hosted_file_id_random}</span
|
||||||
<span>
|
>
|
||||||
<span class="text-sm font-bold">
|
<span>
|
||||||
Type:
|
<span class="text-sm font-bold"> Type: </span>
|
||||||
</span>
|
{hosted_file_obj.extension}</span
|
||||||
{hosted_file_obj.extension}</span>
|
>
|
||||||
<!-- <span>{hosted_file_obj.filename}</span> -->
|
<!-- <span>{hosted_file_obj.filename}</span> -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form
|
<form onsubmit={preventDefault(handle_clip_video)} class="{class_li_default} {class_li}">
|
||||||
onsubmit={preventDefault(handle_clip_video)}
|
<!-- {$ae_sess?.files[hosted_file_obj?.hosted_file_id_random ?? 'obj'].submit_status ?? 'not set'} -->
|
||||||
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}" />
|
<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">
|
<div class="flex flex-row gap-1 justify-center items-center w-full">
|
||||||
<span class="text-xs font-bold w-32">New Filename:</span>
|
<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} />
|
<input
|
||||||
</div>
|
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">
|
<div class="max-w-(--breakpoint-sm) flex flex-row gap-1 justify-center items-center w-full">
|
||||||
<label class="label w-48"
|
<label
|
||||||
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."
|
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"
|
<span class="text-xs font-bold">Start time (HH:MM:SS)</span>
|
||||||
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'}
|
<input
|
||||||
placeholder="HH:MM:SS (00:01:30)" class="input w-32" />
|
type="text"
|
||||||
</label>
|
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"
|
<label
|
||||||
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."
|
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"
|
<span class="text-xs font-bold">End time (HH:MM:SS)</span>
|
||||||
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'}
|
<input
|
||||||
placeholder="HH:MM:SS (01:05:25)" class="input w-32" />
|
type="text"
|
||||||
</label>
|
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"
|
<span
|
||||||
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."
|
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 class="text-xs font-bold"> Re-encode? </span>
|
||||||
</span>
|
<label class="inline-block">
|
||||||
<label class="inline-block">
|
<input type="radio" name="reencode" value="true" class="radio" checked />
|
||||||
<input type="radio" name="reencode" value="true" class="radio" checked />
|
True
|
||||||
True
|
</label>
|
||||||
</label>
|
<label class="inline-block">
|
||||||
<label class="inline-block">
|
<input type="radio" name="reencode" value="false" class="radio" />
|
||||||
<input type="radio" name="reencode" value="false" class="radio" />
|
False
|
||||||
False
|
</label>
|
||||||
</label>
|
</span>
|
||||||
</span>
|
|
||||||
|
|
||||||
<span class="flex flex-col gap-1 items-center justify-center"
|
<span
|
||||||
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."
|
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 class="text-xs font-bold"> Scale down? </span>
|
||||||
</span>
|
<label class="inline-block">
|
||||||
<label class="inline-block">
|
<input type="radio" name="scale_down" value="true" class="radio" checked />
|
||||||
<input type="radio" name="scale_down" value="true" class="radio" checked />
|
True
|
||||||
True
|
</label>
|
||||||
</label>
|
<label class="inline-block">
|
||||||
<label class="inline-block">
|
<input type="radio" name="scale_down" value="false" class="radio" />
|
||||||
<input type="radio" name="scale_down" value="false" class="radio" />
|
False
|
||||||
False
|
</label>
|
||||||
</label>
|
</span>
|
||||||
</span>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
class="btn btn-lg btn-primary preset-tonal-primary border border-primary-500"
|
class="btn btn-lg btn-primary preset-tonal-primary border border-primary-500"
|
||||||
disabled={submit_status == 'clipping'}
|
disabled={submit_status == 'clipping'}
|
||||||
>
|
>
|
||||||
<!-- {#await ae_promises[hosted_file_id]} -->
|
<!-- {#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'}
|
{#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="fas fa-spinner fa-spin m-1"></span>
|
||||||
<span class="highlight">Clipping...</span>
|
<span class="highlight">Clipping...</span>
|
||||||
{:else}
|
{:else}
|
||||||
<!-- {#if ae_promises[hosted_file_id]} -->
|
<!-- {#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'}
|
{#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>
|
<span class="fas fa-check m-1"></span>
|
||||||
Clipped
|
Clipped
|
||||||
{:else}
|
{:else}
|
||||||
<span class="fas fa-cut m-1"></span>
|
<span class="fas fa-cut m-1"></span>
|
||||||
Clip Video
|
Clip Video
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
<!-- <span class="fas fa-cut m-1"></span>
|
<!-- <span class="fas fa-cut m-1"></span>
|
||||||
Clip Video -->
|
Clip Video -->
|
||||||
</button>
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
</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}
|
||||||
|
|
||||||
{#await ae_promises[hosted_file_id]}
|
<!-- <hr />
|
||||||
<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}
|
{#await ae_promises.upload__hosted_file_obj}
|
||||||
<span class="fas fa-spinner fa-spin m-1"></span>
|
<span class="fas fa-spinner fa-spin m-1"></span>
|
||||||
@@ -373,5 +393,4 @@ function handle_clip_video(event) {
|
|||||||
<p>Fill out the form and select the video file to clip.</p>
|
<p>Fill out the form and select the video file to clip.</p>
|
||||||
{/if}
|
{/if}
|
||||||
{/await} -->
|
{/await} -->
|
||||||
|
</section>
|
||||||
</section>
|
|
||||||
|
|||||||
@@ -1,88 +1,90 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
// Imports
|
||||||
|
// Import components and elements
|
||||||
|
|
||||||
// Imports
|
// Import storage, functions, and libraries
|
||||||
// Import components and elements
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
|
|
||||||
// Import storage, functions, and libraries
|
import { api } from '$lib/api/api';
|
||||||
import type { key_val } from '$lib/stores/ae_stores';
|
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/stores/ae_stores';
|
||||||
|
|
||||||
import { api } from '$lib/api/api';
|
// Exports
|
||||||
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/stores/ae_stores';
|
|
||||||
|
|
||||||
// Exports
|
// export let hosted_file_id_li: string[] = [];
|
||||||
|
// export let hosted_file_obj_li: any[] = [];
|
||||||
|
|
||||||
// export let hosted_file_id_li: string[] = [];
|
interface Props {
|
||||||
// export let hosted_file_obj_li: any[] = [];
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
interface Props {
|
let {
|
||||||
log_lvl?: number;
|
log_lvl = 0,
|
||||||
// export let hosted_file_obj_kv: key_val = {};
|
video_clip_file_kv = $bindable({}),
|
||||||
video_clip_file_kv?: key_val;
|
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_default?: string;
|
class_li = '',
|
||||||
class_li?: string;
|
link_to_type,
|
||||||
link_to_type: string;
|
link_to_id
|
||||||
link_to_id: string;
|
}: Props = $props();
|
||||||
}
|
|
||||||
|
|
||||||
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({});
|
|
||||||
|
|
||||||
|
let ae_promises: key_val = $state({});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<h3 class="h3">{Object.entries($ae_loc.files).length}× files clipped</h3>
|
<h3 class="h3">{Object.entries($ae_loc.files).length}× files clipped</h3>
|
||||||
<div class="{class_li_default} {class_li} ">
|
<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
|
||||||
|
});
|
||||||
|
|
||||||
{#each Object.entries(video_clip_file_kv) as [hosted_file_id, hosted_file_obj]}
|
// 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 }, '*');
|
||||||
<button
|
}}
|
||||||
type="button"
|
class="novi_btn btn btn-sm lg:btn-md preset-tonal-primary hover:preset-filled-primary-500 min-w-72 lg:min-w-96"
|
||||||
disabled={!$ae_loc.trusted_access}
|
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}`}
|
||||||
onclick={() => {
|
>
|
||||||
ae_promises[hosted_file_id] = api.download_hosted_file({
|
{#await ae_promises[hosted_file_id]}
|
||||||
api_cfg: $ae_api,
|
<span class="fas fa-spinner fa-spin mx-1"></span>
|
||||||
hosted_file_id: hosted_file_id,
|
<span class="">
|
||||||
return_file: true,
|
Downloading
|
||||||
filename: hosted_file_obj.filename,
|
{#if $ae_sess.api_download_kv[hosted_file_id]}
|
||||||
auto_download: true,
|
{$ae_sess.api_download_kv[hosted_file_id].percent_completed}%
|
||||||
log_lvl: log_lvl
|
{/if}
|
||||||
});
|
:
|
||||||
|
</span>
|
||||||
|
{:then}
|
||||||
|
<span class="fas fa-{ae_util.file_extension_icon(hosted_file_obj?.file_extension)}"></span>
|
||||||
|
{/await}
|
||||||
|
|
||||||
// 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 }, '*');
|
<span class="grow">
|
||||||
}}
|
{ae_util.shorten_filename({ filename: hosted_file_obj?.filename, max_length: 30 })}
|
||||||
class="novi_btn btn btn-sm lg:btn-md preset-tonal-primary hover:preset-filled-primary-500 min-w-72 lg:min-w-96"
|
</span>
|
||||||
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="shrink">
|
||||||
<span class="fas fa-spinner fa-spin mx-1"></span>
|
{ae_util.format_bytes(hosted_file_obj?.size)}
|
||||||
<span class="">
|
</span>
|
||||||
Downloading
|
</button>
|
||||||
{#if $ae_sess.api_download_kv[hosted_file_id]}
|
{/each}
|
||||||
{$ae_sess.api_download_kv[hosted_file_id].percent_completed}%
|
</div>
|
||||||
{/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 +1,408 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let log_lvl: number = 0;
|
export let log_lvl: number = 0;
|
||||||
|
|
||||||
// Imports
|
// Imports
|
||||||
// Import components and elements
|
// Import components and elements
|
||||||
import Element_input_files_tbl from '$lib/elements/element_input_files_tbl.svelte';
|
import Element_input_files_tbl from '$lib/elements/element_input_files_tbl.svelte';
|
||||||
|
|
||||||
// Import storage, functions, and libraries
|
// Import storage, functions, and libraries
|
||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
|
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/stores/ae_stores';
|
import {
|
||||||
|
ae_snip,
|
||||||
|
ae_loc,
|
||||||
|
ae_sess,
|
||||||
|
ae_api,
|
||||||
|
ae_trig,
|
||||||
|
slct,
|
||||||
|
slct_trigger
|
||||||
|
} from '$lib/stores/ae_stores';
|
||||||
|
|
||||||
// Exports
|
// Exports
|
||||||
// Expecting these for link_to_type: 'event', 'event_location', 'archive_content', etc
|
// Expecting these for link_to_type: 'event', 'event_location', 'archive_content', etc
|
||||||
export let link_to_type: string;
|
export let link_to_type: string;
|
||||||
export let link_to_id: string;
|
export let link_to_id: string;
|
||||||
|
|
||||||
export let input_name = 'file_list';
|
export let input_name = 'file_list';
|
||||||
export let multiple: boolean = true;
|
export let multiple: boolean = true;
|
||||||
export let required: 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 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_default: string =
|
||||||
export let class_li: string = '';
|
'flex flex-col gap-1 items-center justify-center w-full max-w-2xl mx-auto my-1';
|
||||||
export let input_class_li: string[] = ['file_drop_area'];
|
export let class_li: string = '';
|
||||||
export let table_class_li: string[] = ['table', 'table-sm', 'table-striped', '' , 'text-sm'];
|
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 upload_complete: boolean = false;
|
||||||
export let submit_status: null|string = null;
|
export let submit_status: null | string = null;
|
||||||
|
|
||||||
export let hosted_file_id_li: string[] = [];
|
export let hosted_file_id_li: string[] = [];
|
||||||
export let hosted_file_obj_li: any[] = [];
|
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 = {};
|
||||||
|
|
||||||
// Local Variables
|
let input_element_id = 'ae_comp__hosted_files_upload__input';
|
||||||
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;
|
||||||
|
|
||||||
let form_kv: key_val = {
|
// *** Functions and Logic
|
||||||
start_time: null,
|
async function handle_submit_form_files(event) {
|
||||||
end_time: null,
|
console.log('*** handle_submit_form() ***');
|
||||||
reencode: null,
|
|
||||||
video_file: null,
|
|
||||||
};
|
|
||||||
let download_clip_src: string;
|
|
||||||
let download_clip_filename: string;
|
|
||||||
|
|
||||||
// *** Functions and Logic
|
$ae_sess.files.disable_submit__hosted_file_obj = true;
|
||||||
async function handle_submit_form_files(event) {
|
$ae_sess.files.submit_status = 'saving';
|
||||||
console.log('*** handle_submit_form() ***');
|
submit_status = 'saving';
|
||||||
|
upload_complete = false;
|
||||||
|
|
||||||
$ae_sess.files.disable_submit__hosted_file_obj = true;
|
hosted_file_id_li = [];
|
||||||
$ae_sess.files.submit_status = 'saving';
|
hosted_file_obj_li = [];
|
||||||
submit_status = 'saving';
|
|
||||||
upload_complete = false;
|
|
||||||
|
|
||||||
hosted_file_id_li = [];
|
let hosted_file_results;
|
||||||
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]
|
||||||
|
};
|
||||||
|
|
||||||
form_kv = {
|
// const form_data = new FormData();
|
||||||
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],
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// form_data.append('start_time', event.target.start_time.value);
|
||||||
|
// form_data.append('end_time', event.target.end_time.value);
|
||||||
|
|
||||||
// const form_data = new FormData();
|
// 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('start_time', event.target.start_time.value);
|
// form_data.append(`video_file`, event.target.video_file.files[0]);
|
||||||
// form_data.append('end_time', event.target.end_time.value);
|
|
||||||
|
|
||||||
// if (event.target.reencode.value == '1' || event.target.reencode.value == 'true') {
|
// let download_filename = `clipped_file_test.mp4`;
|
||||||
// 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 params = null;
|
||||||
|
|
||||||
// let download_filename = `clipped_file_test.mp4`;
|
// let endpoint = '/hosted_file/clip_video';
|
||||||
|
|
||||||
// let params = null;
|
// console.log(form_data);
|
||||||
|
|
||||||
// let endpoint = '/hosted_file/clip_video';
|
// params = null;
|
||||||
|
|
||||||
// console.log(form_data);
|
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?
|
||||||
|
|
||||||
// params = null;
|
// 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;
|
||||||
|
|
||||||
if (event.target[input_element_id].files.length > 0) {
|
hosted_file_results = await handle_input_upload_files([tmp_file], form_kv, task_id);
|
||||||
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
|
if (hosted_file_results) {
|
||||||
// The task_id should be the file hash.
|
console.log(`hosted_file_results:`, hosted_file_results);
|
||||||
// processed_file_list[i] has the file hash_sha256, hash_sha256_match, warnings, uploaded, uploaded_bytes, filename, and file_size_bytes.
|
} else {
|
||||||
for (let i = 0; i < event.target[input_element_id].files.length; i++) {
|
console.log(`hosted_file_results:`, hosted_file_results);
|
||||||
let tmp_file = event.target[input_element_id].files[i];
|
}
|
||||||
|
}
|
||||||
|
// 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();
|
||||||
|
|
||||||
task_id = $ae_sess.files.processed_file_list[i].hash_sha256;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
hosted_file_results = await handle_input_upload_files([tmp_file], form_kv, task_id);
|
$ae_sess.files.disable_submit__hosted_file_obj = false;
|
||||||
|
$ae_sess.files.submit_status = 'saved';
|
||||||
|
submit_status = 'saved';
|
||||||
|
upload_complete = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (hosted_file_results) {
|
async function handle_input_upload_files(input_upload_files, form_kv, task_id) {
|
||||||
console.log(`hosted_file_results:`, hosted_file_results);
|
console.log('*** handle_input_upload_files() ***');
|
||||||
} else {
|
console.log(input_upload_files);
|
||||||
console.log(`hosted_file_results:`, hosted_file_results);
|
console.log(form_kv);
|
||||||
}
|
|
||||||
}
|
|
||||||
// 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) {
|
const form_data = new FormData();
|
||||||
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;
|
// form_data.append('account_id', $ae_loc.account_id);
|
||||||
$ae_sess.files.submit_status = 'saved';
|
// form_data.append('link_to_type', link_to_type);
|
||||||
submit_status = 'saved';
|
// form_data.append('link_to_id', link_to_id);
|
||||||
upload_complete = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
form_data.append('start_time', form_kv.start_time);
|
||||||
|
form_data.append('end_time', form_kv.end_time);
|
||||||
|
|
||||||
async function handle_input_upload_files(input_upload_files, form_kv, task_id) {
|
if (form_kv.reencode == '1' || form_kv.reencode == 'true') {
|
||||||
console.log('*** handle_input_upload_files() ***');
|
form_data.append('reencode', 'true');
|
||||||
console.log(input_upload_files);
|
} else {
|
||||||
console.log(form_kv);
|
form_data.append('reencode', 'false');
|
||||||
|
}
|
||||||
|
|
||||||
const form_data = new FormData();
|
// 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]);
|
||||||
|
}
|
||||||
|
|
||||||
// form_data.append('account_id', $ae_loc.account_id);
|
// hash_sha256, uploaded, uploaded_bytes
|
||||||
// form_data.append('link_to_type', link_to_type);
|
// $ae_sess.files.processed_file_list[i] = {
|
||||||
// form_data.append('link_to_id', link_to_id);
|
// ...$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,
|
||||||
|
// };
|
||||||
|
|
||||||
form_data.append('start_time', form_kv.start_time);
|
let params = null;
|
||||||
form_data.append('end_time', form_kv.end_time);
|
|
||||||
|
|
||||||
if (form_kv.reencode == '1' || form_kv.reencode == 'true') {
|
let endpoint = '/hosted_file/clip_video';
|
||||||
form_data.append('reencode', 'true');
|
|
||||||
} else {
|
|
||||||
form_data.append('reencode', 'false');
|
|
||||||
}
|
|
||||||
|
|
||||||
// There should really only be one file uploaded at a time for now.
|
console.log(form_data);
|
||||||
for (let i = 0; i < input_upload_files.length; i++) {
|
|
||||||
form_data.append(`video_file`, input_upload_files[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// hash_sha256, uploaded, uploaded_bytes
|
params = null;
|
||||||
// $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;
|
// 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 endpoint = '/hosted_file/clip_video';
|
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;
|
||||||
|
|
||||||
console.log(form_data);
|
return true;
|
||||||
|
|
||||||
params = null;
|
// // 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];
|
||||||
|
|
||||||
// Uncomment and the post_promise is not seen by the "await" below
|
// let hosted_file_id = hosted_file_obj.hosted_file_id_random;
|
||||||
// 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]);
|
// hosted_file_id_li.push(hosted_file_id);
|
||||||
// console.log(file_blob);
|
// hosted_file_obj_li.push(hosted_file_obj);
|
||||||
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;
|
// 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;
|
||||||
|
|
||||||
// // WARNING!!!! ONLY ONE FILE IS EXPECTED TO BE UPLOADED AT A TIME!!!
|
// $ae_sess.files.new_upload_list[i].uploaded_bytes = 10; // fake 10 bytes at least...
|
||||||
// // 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;
|
// 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;
|
||||||
|
// });
|
||||||
|
|
||||||
// hosted_file_id_li.push(hosted_file_id);
|
// return event_file_id;
|
||||||
// hosted_file_obj_li.push(hosted_file_obj);
|
})
|
||||||
|
// .then(function (hosted_file_data) {
|
||||||
|
// return hosted_file_data;
|
||||||
|
// })
|
||||||
|
.catch(function (error: any) {
|
||||||
|
console.log('Something went wrong.');
|
||||||
|
console.log(error);
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
.finally(function () {
|
||||||
|
// $slct_trigger = 'load__hosted_file_obj_li';
|
||||||
|
});
|
||||||
|
|
||||||
// let hosted_file_data: key_val = {};
|
console.log(ae_promises.upload__hosted_file_obj);
|
||||||
// hosted_file_data['hosted_file_id_random'] = hosted_file_id;
|
let hosted_file_result = ae_promises.upload__hosted_file_obj;
|
||||||
// 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: any) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return hosted_file_result;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<!-- class:hidden={!$ae_loc.trusted_access} -->
|
<!-- class:hidden={!$ae_loc.trusted_access} -->
|
||||||
<form
|
<form on:submit|preventDefault={handle_submit_form_files} class="{class_li_default} {class_li}">
|
||||||
on:submit|preventDefault={handle_submit_form_files}
|
<label class="label"
|
||||||
class="{class_li_default} {class_li}"
|
>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">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"
|
||||||
<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>
|
>Re-encode (true or false) <input
|
||||||
|
type="text"
|
||||||
|
name="reencode"
|
||||||
|
value="false"
|
||||||
|
placeholder="true"
|
||||||
|
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}
|
||||||
|
|
||||||
{#await ae_promises.upload__hosted_file_obj}
|
<label
|
||||||
<div class="text-lg flex flex-row gap-1 items-center justify-center">
|
for="ae_comp__hosted_files_upload__input"
|
||||||
<span class="fas fa-spinner fa-spin m-1"></span>
|
class="svelte_input_file_label text-center"
|
||||||
<span class="">
|
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
|
||||||
Uploading
|
>
|
||||||
{#if $ae_sess.api_upload_kv[task_id]}
|
<slot name="label">
|
||||||
{$ae_sess.api_upload_kv[task_id].percent_completed}%
|
<div>
|
||||||
{/if}
|
<span class="fas fa-upload"></span>
|
||||||
</span>
|
<!-- Select files to upload -->
|
||||||
</div>
|
<!-- <span class="fas fa-file-archive"></span> -->
|
||||||
{/await}
|
<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>
|
||||||
|
|
||||||
<label
|
<input
|
||||||
for="ae_comp__hosted_files_upload__input"
|
id={input_element_id}
|
||||||
class="svelte_input_file_label text-center"
|
type="file"
|
||||||
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
|
bind:files={input_file_list}
|
||||||
>
|
{multiple}
|
||||||
<slot name="label">
|
{required}
|
||||||
<div>
|
{accept}
|
||||||
<span class="fas fa-upload"></span>
|
name={input_name}
|
||||||
<!-- Select files to upload -->
|
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(
|
||||||
<!-- <span class="fas fa-file-archive"></span> -->
|
' '
|
||||||
<strong class="bg-blue-300 p-1">Upload files</strong>
|
)}"
|
||||||
<!-- (drag and drop) -->
|
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
|
||||||
</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
|
<Element_input_files_tbl
|
||||||
id={input_element_id}
|
bind:input_file_list
|
||||||
type="file"
|
bind:file_list_status={$ae_sess.files.status__file_list}
|
||||||
bind:files={input_file_list}
|
bind:processed_file_list={$ae_sess.files.processed_file_list}
|
||||||
{multiple}
|
{table_class_li}
|
||||||
{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
|
<button
|
||||||
bind:input_file_list={input_file_list}
|
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"
|
||||||
bind:file_list_status={$ae_sess.files.status__file_list}
|
disabled={$ae_sess.files.disable_submit__hosted_file_obj ||
|
||||||
bind:processed_file_list={$ae_sess.files.processed_file_list}
|
$ae_sess.files.status__file_list != 'ready'}
|
||||||
table_class_li={table_class_li}
|
>
|
||||||
/>
|
{#await ae_promises.upload__hosted_file_obj}
|
||||||
|
<span class="fas fa-spinner fa-spin m-1"></span>
|
||||||
<button
|
<span class="">
|
||||||
type="submit"
|
Uploading
|
||||||
class="btn btn-lg btn-primary preset-tonal-primary border border-primary-500 hover:preset-tonal-success border border-success-500 w-54"
|
{#if $ae_sess.api_upload_kv[task_id]}
|
||||||
disabled={$ae_sess.files.disable_submit__hosted_file_obj || $ae_sess.files.status__file_list != 'ready'}
|
{$ae_sess.api_upload_kv[task_id].percent_completed}%
|
||||||
>
|
{/if}
|
||||||
{#await ae_promises.upload__hosted_file_obj}
|
</span>
|
||||||
<span class="fas fa-spinner fa-spin m-1"></span>
|
{:then}
|
||||||
<span class="">
|
<span class="fas fa-upload m-1"></span>
|
||||||
Uploading
|
<span class="text-sm"> Upload? </span>
|
||||||
{#if $ae_sess.api_upload_kv[task_id]}
|
<!-- <span class="fas fa-save m-1"></span> -->
|
||||||
{$ae_sess.api_upload_kv[task_id].percent_completed}%
|
<span class="grow font-bold">
|
||||||
{/if}
|
{#if $ae_sess.files.processed_file_list?.length > 0}
|
||||||
</span>
|
<!-- {#each $ae_sess.files.processed_file_list as file_obj, index}
|
||||||
{: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">
|
<span class="text-xs">
|
||||||
{file_obj.filename}
|
{file_obj.filename}
|
||||||
</span>
|
</span>
|
||||||
{/each} -->
|
{/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`}
|
{$ae_sess.files.processed_file_list.length == 1
|
||||||
{:else}
|
? `${$ae_sess.files.processed_file_list.length} file`
|
||||||
<span class="text-xs">
|
: `${$ae_sess.files.processed_file_list.length} files`}
|
||||||
No files selected
|
{:else}
|
||||||
</span>
|
<span class="text-xs"> No files selected </span>
|
||||||
{/if}
|
{/if}
|
||||||
<!-- Files -->
|
<!-- Files -->
|
||||||
</span>
|
</span>
|
||||||
{/await}
|
{/await}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
<hr />
|
{#await ae_promises.upload__hosted_file_obj}
|
||||||
|
<span class="fas fa-spinner fa-spin m-1"></span>
|
||||||
{#await ae_promises.upload__hosted_file_obj}
|
<p class="highlight">Converting... This may take a few minutes.</p>
|
||||||
<span class="fas fa-spinner fa-spin m-1"></span>
|
{:then}
|
||||||
<p class="highlight">Converting... This may take a few minutes.</p>
|
{#if ae_promises.upload__hosted_file_obj}
|
||||||
{:then}
|
<a
|
||||||
{#if ae_promises.upload__hosted_file_obj}
|
href={download_clip_src}
|
||||||
<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>
|
download={download_clip_filename}
|
||||||
{:else}
|
class="ae_btn btn_lg btn_primary"><span class="fas fa-download"></span> Ready to Download</a
|
||||||
<p>Fill out the form and select the video file to clip.</p>
|
>
|
||||||
{/if}
|
{:else}
|
||||||
{/await}
|
<p>Fill out the form and select the video file to clip.</p>
|
||||||
|
{/if}
|
||||||
</div>
|
{/await}
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -1,152 +1,153 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
// *** Import Svelte specific
|
// *** Import Svelte specific
|
||||||
|
|
||||||
// Eventually this should use Lucide icons instead of FontAwesome
|
// Eventually this should use Lucide icons instead of FontAwesome
|
||||||
// import {
|
// import {
|
||||||
// ArrowDown01, ArrowDown10, ArrowDownUp,
|
// ArrowDown01, ArrowDown10, ArrowDownUp,
|
||||||
// BookHeart, BriefcaseBusiness,
|
// BookHeart, BriefcaseBusiness,
|
||||||
// CalendarClock, CalendarOff, Clock, CodeXml, Copy,
|
// CalendarClock, CalendarOff, Clock, CodeXml, Copy,
|
||||||
// Eye, EyeOff,
|
// Eye, EyeOff,
|
||||||
// Flag, FlagOff, FileX, Fingerprint,
|
// Flag, FlagOff, FileX, Fingerprint,
|
||||||
// Globe, Group,
|
// Globe, Group,
|
||||||
// Hash, History,
|
// Hash, History,
|
||||||
// LockKeyhole, LockKeyholeOpen,
|
// LockKeyhole, LockKeyholeOpen,
|
||||||
// MessageSquareWarning, Menu, Minus,
|
// MessageSquareWarning, Menu, Minus,
|
||||||
// NotebookPen, NotebookText, NotepadTextDashed,
|
// NotebookPen, NotebookText, NotepadTextDashed,
|
||||||
// Pencil, PenLine, Plus,
|
// Pencil, PenLine, Plus,
|
||||||
// RemoveFormatting,
|
// RemoveFormatting,
|
||||||
// Search, Settings,
|
// Search, Settings,
|
||||||
// Shapes, Share2, ShieldCheck, ShieldMinus, Siren, Skull,
|
// Shapes, Share2, ShieldCheck, ShieldMinus, Siren, Skull,
|
||||||
// SquareLibrary,
|
// SquareLibrary,
|
||||||
// Tags, Trash2, TypeOutline,
|
// Tags, Trash2, TypeOutline,
|
||||||
// X
|
// X
|
||||||
// } from '@lucide/svelte';
|
// } from '@lucide/svelte';
|
||||||
|
|
||||||
// *** Import Aether specific variables and functions
|
// *** Import Aether specific variables and functions
|
||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/stores/ae_stores';
|
import {
|
||||||
|
ae_snip,
|
||||||
|
ae_loc,
|
||||||
|
ae_sess,
|
||||||
|
ae_api,
|
||||||
|
ae_trig,
|
||||||
|
slct,
|
||||||
|
slct_trigger
|
||||||
|
} from '$lib/stores/ae_stores';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
log_lvl?: number;
|
log_lvl?: number;
|
||||||
hosted_file_id: null|string;
|
hosted_file_id: null | string;
|
||||||
hosted_file_obj: null|key_val;
|
hosted_file_obj: null | key_val;
|
||||||
filename?: null|string;
|
filename?: null | string;
|
||||||
max_length?: number;
|
max_length?: number;
|
||||||
auto_download?: boolean;
|
auto_download?: boolean;
|
||||||
linked_to_type?: null|string;
|
linked_to_type?: null | string;
|
||||||
linked_to_id?: null|string;
|
linked_to_id?: null | string;
|
||||||
download_complete?: null|boolean;
|
download_complete?: null | boolean;
|
||||||
download_percent?: number;
|
download_percent?: number;
|
||||||
download_status_msg?: string;
|
download_status_msg?: string;
|
||||||
classes?: string;
|
classes?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
log_lvl = 0,
|
log_lvl = 0,
|
||||||
hosted_file_id,
|
hosted_file_id,
|
||||||
hosted_file_obj,
|
hosted_file_obj,
|
||||||
filename = $bindable(null),
|
filename = $bindable(null),
|
||||||
max_length = $bindable(30),
|
max_length = $bindable(30),
|
||||||
auto_download = true,
|
auto_download = true,
|
||||||
linked_to_type = $bindable(null),
|
linked_to_type = $bindable(null),
|
||||||
linked_to_id = $bindable(null),
|
linked_to_id = $bindable(null),
|
||||||
download_complete = $bindable(),
|
download_complete = $bindable(),
|
||||||
download_percent = $bindable(),
|
download_percent = $bindable(),
|
||||||
download_status_msg = $bindable('Not started'),
|
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'
|
classes = 'btn btn-sm lg:btn-md preset-tonal-tertiary border border-tertiary-500 hover:preset-filled-tertiary-500 min-w-48'
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`ae_comp__hosted_files_download_button.svelte hosted_file_id=${hosted_file_id}`, hosted_file_obj);
|
console.log(
|
||||||
}
|
`ae_comp__hosted_files_download_button.svelte hosted_file_id=${hosted_file_id}`,
|
||||||
|
hosted_file_obj
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let ae_promises: key_val = $state({});
|
let ae_promises: key_val = $state({});
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
$effect(() => {
|
if ($ae_sess?.api_download_kv[hosted_file_obj?.hosted_file_id_random]?.percent_completed) {
|
||||||
if ($ae_sess?.api_download_kv[hosted_file_obj?.hosted_file_id_random]?.percent_completed) {
|
download_percent =
|
||||||
download_percent = $ae_sess.api_download_kv[hosted_file_obj?.hosted_file_id_random].percent_completed;
|
$ae_sess.api_download_kv[hosted_file_obj?.hosted_file_id_random].percent_completed;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
{#if hosted_file_id && hosted_file_obj}
|
{#if hosted_file_id && hosted_file_obj}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
disabled={!$ae_loc.trusted_access}
|
disabled={!$ae_loc.trusted_access}
|
||||||
class="{classes ?? 'btn'}"
|
class={classes ?? 'btn'}
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
download_complete = false;
|
download_complete = false;
|
||||||
download_status_msg = 'Downloading...';
|
download_status_msg = 'Downloading...';
|
||||||
ae_promises[hosted_file_obj.hosted_file_id_random] = api.download_hosted_file({
|
ae_promises[hosted_file_obj.hosted_file_id_random] = api
|
||||||
api_cfg: $ae_api,
|
.download_hosted_file({
|
||||||
hosted_file_id: hosted_file_obj.hosted_file_id_random,
|
api_cfg: $ae_api,
|
||||||
return_file: true,
|
hosted_file_id: hosted_file_obj.hosted_file_id_random,
|
||||||
filename: filename ?? hosted_file_obj.filename,
|
return_file: true,
|
||||||
auto_download: auto_download,
|
filename: filename ?? hosted_file_obj.filename,
|
||||||
log_lvl: log_lvl
|
auto_download: auto_download,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then((result) => {
|
})
|
||||||
if (result === null) {
|
.then((result) => {
|
||||||
console.log('File not found (404)');
|
if (result === null) {
|
||||||
download_complete = null;
|
console.log('File not found (404)');
|
||||||
download_status_msg = 'File not found';
|
download_complete = null;
|
||||||
} else if (result === false) {
|
download_status_msg = 'File not found';
|
||||||
console.log('Possible error with API server (check network and server status)');
|
} else if (result === false) {
|
||||||
download_complete = false;
|
console.log('Possible error with API server (check network and server status)');
|
||||||
download_status_msg = 'Failed to download';
|
download_complete = false;
|
||||||
} else {
|
download_status_msg = 'Failed to download';
|
||||||
// console.log('File found and downloaded');
|
} else {
|
||||||
download_complete = true;
|
// console.log('File found and downloaded');
|
||||||
download_status_msg = 'File downloaded';
|
download_complete = true;
|
||||||
}
|
download_status_msg = 'File downloaded';
|
||||||
return result;
|
}
|
||||||
});
|
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}
|
||||||
|
|
||||||
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}`}
|
{#if download_complete === null}
|
||||||
>
|
<span class="text-red-800 dark:text-red-200">File not found</span>
|
||||||
{#await ae_promises[hosted_file_obj.hosted_file_id_random]}
|
{:else if download_complete === false}
|
||||||
<span class="fas fa-spinner fa-spin mx-1"></span>
|
<span class="text-red-800 dark:text-red-200">Failed to download!</span>
|
||||||
<span class="">
|
{/if}
|
||||||
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>
|
|
||||||
|
|
||||||
|
<span class="grow">
|
||||||
|
{ae_util.shorten_filename({
|
||||||
|
filename: filename ?? hosted_file_obj?.filename,
|
||||||
|
max_length: max_length
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
{:else}
|
{:else}
|
||||||
|
<button type="button" disabled class={classes ?? 'btn'} title="No file selected">
|
||||||
<button
|
<span class="fas fa-{ae_util.file_extension_icon(hosted_file_obj?.extension)}"></span>
|
||||||
type="button"
|
<span class="grow"> No file info </span>
|
||||||
disabled
|
</button>
|
||||||
class="{classes ?? 'btn'}"
|
{/if}
|
||||||
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,275 +1,281 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let log_lvl: number = 0;
|
export let log_lvl: number = 0;
|
||||||
|
|
||||||
// Imports
|
// Imports
|
||||||
// Import components and elements
|
// Import components and elements
|
||||||
import Element_input_files_tbl from '$lib/elements/element_input_files_tbl.svelte';
|
import Element_input_files_tbl from '$lib/elements/element_input_files_tbl.svelte';
|
||||||
|
|
||||||
// Import storage, functions, and libraries
|
// Import storage, functions, and libraries
|
||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
|
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/stores/ae_stores';
|
import {
|
||||||
|
ae_snip,
|
||||||
|
ae_loc,
|
||||||
|
ae_sess,
|
||||||
|
ae_api,
|
||||||
|
ae_trig,
|
||||||
|
slct,
|
||||||
|
slct_trigger
|
||||||
|
} from '$lib/stores/ae_stores';
|
||||||
|
|
||||||
// Exports
|
// Exports
|
||||||
// Expecting these for link_to_type: 'event', 'event_location', 'archive_content', etc
|
// Expecting these for link_to_type: 'event', 'event_location', 'archive_content', etc
|
||||||
export let link_to_type: string;
|
export let link_to_type: string;
|
||||||
export let link_to_id: string;
|
export let link_to_id: string;
|
||||||
|
|
||||||
export let input_name = 'file_list';
|
export let input_name = 'file_list';
|
||||||
export let multiple: boolean = true;
|
export let multiple: boolean = true;
|
||||||
export let required: 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 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_default: string =
|
||||||
export let class_li: string = '';
|
'flex flex-col gap-1 items-center justify-center w-full max-w-2xl mx-auto my-1';
|
||||||
export let input_class_li: string[] = ['file_drop_area'];
|
export let class_li: string = '';
|
||||||
export let table_class_li: string[] = ['table', 'table-sm', 'table-striped', '' , 'text-sm'];
|
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 upload_complete: boolean = false;
|
||||||
export let submit_status: null|string = null;
|
export let submit_status: null | string = null;
|
||||||
|
|
||||||
export let hosted_file_id_li: string[] = [];
|
export let hosted_file_id_li: string[] = [];
|
||||||
export let hosted_file_obj_li: any[] = [];
|
export let hosted_file_obj_li: any[] = [];
|
||||||
export let hosted_file_obj_kv: key_val = {};
|
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 = {};
|
||||||
|
|
||||||
// Local Variables
|
let input_element_id = 'ae_comp__hosted_files_upload__input';
|
||||||
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() ***');
|
||||||
|
|
||||||
// *** Functions and Logic
|
if (!event) {
|
||||||
async function handle_submit_form_files(event: SubmitEvent) {
|
return;
|
||||||
console.log('*** handle_submit_form() ***');
|
}
|
||||||
|
|
||||||
if (!event) {
|
$ae_sess.files.disable_submit__hosted_file_obj = true;
|
||||||
return;
|
$ae_sess.files.submit_status = 'saving';
|
||||||
}
|
submit_status = 'saving';
|
||||||
|
upload_complete = false;
|
||||||
|
|
||||||
$ae_sess.files.disable_submit__hosted_file_obj = true;
|
hosted_file_id_li = [];
|
||||||
$ae_sess.files.submit_status = 'saving';
|
hosted_file_obj_li = [];
|
||||||
submit_status = 'saving';
|
hosted_file_obj_kv = {};
|
||||||
upload_complete = false;
|
|
||||||
|
|
||||||
hosted_file_id_li = [];
|
let hosted_file_results;
|
||||||
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?
|
||||||
|
|
||||||
const target = event.target as HTMLFormElement;
|
// Loop through each file and upload them individually in event.target[input_element_id].files
|
||||||
if (target && target[input_element_id] && (target[input_element_id] as HTMLInputElement)?.files && (target[input_element_id] as HTMLInputElement).files.length > 0) {
|
// The task_id should be the file hash.
|
||||||
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?
|
// 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];
|
||||||
|
|
||||||
// Loop through each file and upload them individually in event.target[input_element_id].files
|
task_id = $ae_sess.files.processed_file_list[i].hash_sha256;
|
||||||
// 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
|
||||||
|
});
|
||||||
|
|
||||||
// hosted_file_results = await handle_input_upload_files([tmp_file], task_id);
|
if (hosted_file_results) {
|
||||||
hosted_file_results = await handle_input_upload_files({
|
console.log(`hosted_file_results:`, hosted_file_results);
|
||||||
input_upload_files: [tmp_file],
|
} else {
|
||||||
task_id: task_id
|
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 (hosted_file_results) {
|
if (log_lvl) {
|
||||||
console.log(`hosted_file_results:`, hosted_file_results);
|
console.log(`hosted_file_id_li: ${hosted_file_id_li}`, hosted_file_id_li);
|
||||||
} else {
|
} else if (log_lvl > 1) {
|
||||||
console.log(`hosted_file_results:`, hosted_file_results);
|
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) {
|
$ae_sess.files.disable_submit__hosted_file_obj = false;
|
||||||
console.log(`hosted_file_id_li: ${hosted_file_id_li}`, hosted_file_id_li);
|
$ae_sess.files.submit_status = 'saved';
|
||||||
} else if (log_lvl > 1) {
|
submit_status = 'saved';
|
||||||
console.log('hosted_file_results:', hosted_file_results);
|
upload_complete = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$ae_sess.files.disable_submit__hosted_file_obj = false;
|
async function handle_input_upload_files({
|
||||||
$ae_sess.files.submit_status = 'saved';
|
input_upload_files,
|
||||||
submit_status = 'saved';
|
task_id
|
||||||
upload_complete = true;
|
}: {
|
||||||
}
|
input_upload_files: any[];
|
||||||
|
task_id: string;
|
||||||
|
}) {
|
||||||
|
console.log('*** handle_input_upload_files() ***');
|
||||||
|
|
||||||
|
const form_data = new FormData();
|
||||||
|
|
||||||
async function handle_input_upload_files(
|
form_data.append('account_id', $ae_loc.account_id);
|
||||||
{
|
form_data.append('link_to_type', link_to_type);
|
||||||
input_upload_files,
|
form_data.append('link_to_id', link_to_id);
|
||||||
task_id
|
|
||||||
} : {
|
|
||||||
input_upload_files: any[],
|
|
||||||
task_id: string
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
console.log('*** handle_input_upload_files() ***');
|
|
||||||
|
|
||||||
const form_data = new FormData();
|
for (let i = 0; i < input_upload_files.length; i++) {
|
||||||
|
form_data.append(`file_list`, input_upload_files[i]);
|
||||||
|
}
|
||||||
|
|
||||||
form_data.append('account_id', $ae_loc.account_id);
|
// hash_sha256, uploaded, uploaded_bytes
|
||||||
form_data.append('link_to_type', link_to_type);
|
// $ae_sess.files.processed_file_list[i] = {
|
||||||
form_data.append('link_to_id', link_to_id);
|
// ...$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,
|
||||||
|
// };
|
||||||
|
|
||||||
for (let i = 0; i < input_upload_files.length; i++) {
|
let params = null;
|
||||||
form_data.append(`file_list`, input_upload_files[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// hash_sha256, uploaded, uploaded_bytes
|
let endpoint = '/hosted_file/upload_files';
|
||||||
// $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;
|
console.log(form_data);
|
||||||
|
|
||||||
let endpoint = '/hosted_file/upload_files';
|
params = null;
|
||||||
|
|
||||||
console.log(form_data);
|
// 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];
|
||||||
|
|
||||||
params = null;
|
let hosted_file_id = hosted_file_obj.hosted_file_id_random;
|
||||||
|
|
||||||
// Uncomment and the post_promise is not seen by the "await" below
|
hosted_file_id_li.push(hosted_file_id);
|
||||||
// post_promise = await api.post_object({api_cfg: $cfg.api, endpoint: endpoint, params: params, data:form_data});
|
hosted_file_obj_li.push(hosted_file_obj);
|
||||||
// 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;
|
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_id_li.push(hosted_file_id);
|
hosted_file_obj_kv[hosted_file_id] = hosted_file_data;
|
||||||
hosted_file_obj_li.push(hosted_file_obj);
|
|
||||||
|
|
||||||
let hosted_file_data: key_val = {};
|
return hosted_file_data;
|
||||||
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;
|
// $ae_sess.files.new_upload_list[i].uploaded_bytes = 10; // fake 10 bytes at least...
|
||||||
|
|
||||||
return hosted_file_data;
|
// 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;
|
||||||
|
// });
|
||||||
|
|
||||||
// $ae_sess.files.new_upload_list[i].uploaded_bytes = 10; // fake 10 bytes at least...
|
// return event_file_id;
|
||||||
|
})
|
||||||
|
.then(function (hosted_file_data) {
|
||||||
|
return hosted_file_data;
|
||||||
|
})
|
||||||
|
.catch(function (error: any) {
|
||||||
|
console.log('Something went wrong.');
|
||||||
|
console.log(error);
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
.finally(function () {
|
||||||
|
$slct_trigger = 'load__hosted_file_obj_li';
|
||||||
|
});
|
||||||
|
|
||||||
// let event_file_id = await events_func.create_hosted_file_obj_from_hosted_file_async({
|
console.log(ae_promises.upload__hosted_file_obj);
|
||||||
// api_cfg: $ae_api,
|
let hosted_file_result = ae_promises.upload__hosted_file_obj;
|
||||||
// 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: any) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return hosted_file_result;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<!-- class:hidden={!$ae_loc.trusted_access} -->
|
<!-- class:hidden={!$ae_loc.trusted_access} -->
|
||||||
<form
|
<form on:submit|preventDefault={handle_submit_form_files} class="{class_li_default} {class_li}">
|
||||||
on:submit|preventDefault={handle_submit_form_files}
|
{#await ae_promises.upload__hosted_file_obj}
|
||||||
class="{class_li_default} {class_li}"
|
<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}
|
||||||
|
|
||||||
{#await ae_promises.upload__hosted_file_obj}
|
<label
|
||||||
<div class="text-lg flex flex-row gap-1 items-center justify-center">
|
for="ae_comp__hosted_files_upload__input"
|
||||||
<span class="fas fa-spinner fa-spin m-1"></span>
|
class="svelte_input_file_label text-center"
|
||||||
<span class="">
|
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
|
||||||
Uploading
|
>
|
||||||
{#if $ae_sess.api_upload_kv[task_id]}
|
<slot name="label">
|
||||||
{$ae_sess.api_upload_kv[task_id].percent_completed}%
|
<div>
|
||||||
{/if}
|
<span class="fas fa-upload"></span>
|
||||||
</span>
|
<!-- Select files to upload -->
|
||||||
</div>
|
<!-- <span class="fas fa-file-archive"></span> -->
|
||||||
{/await}
|
<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>
|
||||||
|
|
||||||
<label
|
<input
|
||||||
for="ae_comp__hosted_files_upload__input"
|
id={input_element_id}
|
||||||
class="svelte_input_file_label text-center"
|
type="file"
|
||||||
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
|
bind:files={input_file_list}
|
||||||
>
|
{multiple}
|
||||||
<slot name="label">
|
{required}
|
||||||
<div>
|
{accept}
|
||||||
<span class="fas fa-upload"></span>
|
name={input_name}
|
||||||
<!-- Select files to upload -->
|
class="
|
||||||
<!-- <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
|
svelte_input_file_element
|
||||||
file-dropzone-input
|
file-dropzone-input
|
||||||
px-1
|
px-1
|
||||||
@@ -280,51 +286,49 @@ async function handle_input_upload_files(
|
|||||||
g-gray-50 dark:text-gray-400 focus:outline-hidden dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400
|
g-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(' ')}
|
{input_class_li.join(' ')}
|
||||||
"
|
"
|
||||||
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
|
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Element_input_files_tbl
|
<Element_input_files_tbl
|
||||||
bind:input_file_list={input_file_list}
|
bind: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}
|
||||||
|
/>
|
||||||
|
|
||||||
bind:file_list_status={$ae_sess.files.status__file_list}
|
<button
|
||||||
bind:processed_file_list={$ae_sess.files.processed_file_list}
|
type="submit"
|
||||||
table_class_li={table_class_li}
|
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'}
|
||||||
<button
|
>
|
||||||
type="submit"
|
{#await ae_promises.upload__hosted_file_obj}
|
||||||
class="btn btn-lg btn-primary preset-tonal-primary border border-primary-500 hover:preset-tonal-success border border-success-500 w-54"
|
<span class="fas fa-spinner fa-spin m-1"></span>
|
||||||
disabled={$ae_sess.files.disable_submit__hosted_file_obj || $ae_sess.files.status__file_list != 'ready'}
|
<span class="">
|
||||||
>
|
Uploading
|
||||||
{#await ae_promises.upload__hosted_file_obj}
|
{#if $ae_sess.api_upload_kv[task_id]}
|
||||||
<span class="fas fa-spinner fa-spin m-1"></span>
|
{$ae_sess.api_upload_kv[task_id].percent_completed}%
|
||||||
<span class="">
|
{/if}
|
||||||
Uploading
|
</span>
|
||||||
{#if $ae_sess.api_upload_kv[task_id]}
|
{:then}
|
||||||
{$ae_sess.api_upload_kv[task_id].percent_completed}%
|
<span class="fas fa-upload m-1"></span>
|
||||||
{/if}
|
<span class="text-sm"> Upload? </span>
|
||||||
</span>
|
<!-- <span class="fas fa-save m-1"></span> -->
|
||||||
{:then}
|
<span class="grow font-bold">
|
||||||
<span class="fas fa-upload m-1"></span>
|
{#if $ae_sess.files.processed_file_list?.length > 0}
|
||||||
<span class="text-sm">
|
<!-- {#each $ae_sess.files.processed_file_list as file_obj, index}
|
||||||
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">
|
<span class="text-xs">
|
||||||
{file_obj.filename}
|
{file_obj.filename}
|
||||||
</span>
|
</span>
|
||||||
{/each} -->
|
{/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`}
|
{$ae_sess.files.processed_file_list.length == 1
|
||||||
{:else}
|
? `${$ae_sess.files.processed_file_list.length} file`
|
||||||
<span class="text-xs">
|
: `${$ae_sess.files.processed_file_list.length} files`}
|
||||||
No files selected
|
{:else}
|
||||||
</span>
|
<span class="text-xs"> No files selected </span>
|
||||||
{/if}
|
{/if}
|
||||||
<!-- Files -->
|
<!-- Files -->
|
||||||
</span>
|
</span>
|
||||||
{/await}
|
{/await}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,23 +1,23 @@
|
|||||||
export interface Account {
|
export interface Account {
|
||||||
id: string;
|
id: string;
|
||||||
// id_random: string;
|
// id_random: string;
|
||||||
account_id: string;
|
account_id: string;
|
||||||
account_id_random: string;
|
account_id_random: string;
|
||||||
|
|
||||||
code?: string;
|
code?: string;
|
||||||
name: string;
|
name: string;
|
||||||
short_name?: null|string;
|
short_name?: null | string;
|
||||||
description?: null|string;
|
description?: null | string;
|
||||||
|
|
||||||
enable: null|boolean;
|
enable: null | boolean;
|
||||||
enable_from?: null|Date;
|
enable_from?: null | Date;
|
||||||
enable_to?: null|Date;
|
enable_to?: null | Date;
|
||||||
|
|
||||||
hide?: null|boolean;
|
hide?: null | boolean;
|
||||||
priority?: null|boolean
|
priority?: null | boolean;
|
||||||
sort?: null|number;
|
sort?: null | number;
|
||||||
group?: null|string;
|
group?: null | string;
|
||||||
notes?: null|string;
|
notes?: null | string;
|
||||||
created_on: Date;
|
created_on: Date;
|
||||||
updated_on?: null|Date;
|
updated_on?: null | Date;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,361 +1,364 @@
|
|||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
|
|
||||||
let ae_promises: key_val = {};
|
const ae_promises: key_val = {};
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-10-23
|
// Updated 2024-10-23
|
||||||
export async function load_ae_obj_id__activity_log(
|
export async function load_ae_obj_id__activity_log({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
activity_log_id,
|
||||||
activity_log_id,
|
// inc_other_li = false,
|
||||||
// inc_other_li = false,
|
try_cache = false,
|
||||||
try_cache = false,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
activity_log_id: string;
|
||||||
activity_log_id: string,
|
// inc_other_li?: boolean,
|
||||||
// inc_other_li?: boolean,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
console.log(`*** load_ae_obj_id__activity_log() *** activity_log_id=${activity_log_id}`);
|
||||||
) {
|
|
||||||
console.log(`*** load_ae_obj_id__activity_log() *** activity_log_id=${activity_log_id}`);
|
|
||||||
|
|
||||||
let params = {};
|
const params = {};
|
||||||
|
|
||||||
ae_promises.load__activity_log_obj = await api.get_ae_obj_id_crud({
|
ae_promises.load__activity_log_obj = await api
|
||||||
api_cfg: api_cfg,
|
.get_ae_obj_id_crud({
|
||||||
obj_type: 'activity_log',
|
api_cfg: api_cfg,
|
||||||
obj_id: activity_log_id, // NOTE: This is the FQDN, not normally the ID.
|
obj_type: 'activity_log',
|
||||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
obj_id: activity_log_id, // NOTE: This is the FQDN, not normally the ID.
|
||||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||||
params: params,
|
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(function (activity_log_obj_get_result) {
|
})
|
||||||
if (activity_log_obj_get_result) {
|
.then(function (activity_log_obj_get_result) {
|
||||||
// if (try_cache) {
|
if (activity_log_obj_get_result) {
|
||||||
// // This is expecting a list
|
// if (try_cache) {
|
||||||
// db_save_ae_obj_li__activity_log({
|
// // This is expecting a list
|
||||||
// obj_type: 'activity_log',
|
// db_save_ae_obj_li__activity_log({
|
||||||
// obj_li: [activity_log_obj_get_result]
|
// obj_type: 'activity_log',
|
||||||
// });
|
// obj_li: [activity_log_obj_get_result]
|
||||||
// }
|
// });
|
||||||
return activity_log_obj_get_result;
|
// }
|
||||||
} else {
|
return activity_log_obj_get_result;
|
||||||
console.log('No results returned.');
|
} else {
|
||||||
return null;
|
console.log('No results returned.');
|
||||||
}
|
return null;
|
||||||
})
|
}
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
});
|
console.log('No results returned or failed.', error);
|
||||||
|
});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.load__activity_log_obj:', ae_promises.load__activity_log_obj);
|
console.log('ae_promises.load__activity_log_obj:', ae_promises.load__activity_log_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ae_promises.load__activity_log_obj;
|
return ae_promises.load__activity_log_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-10-23
|
// Updated 2024-10-23
|
||||||
export async function load_ae_obj_li__activity_log(
|
export async function load_ae_obj_li__activity_log({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
for_obj_type = 'account',
|
||||||
for_obj_type = 'account',
|
for_obj_id,
|
||||||
for_obj_id,
|
// inc_other_li = false,
|
||||||
// inc_other_li = false,
|
order_by_li = {
|
||||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
priority: 'DESC',
|
||||||
params = {},
|
sort: 'DESC',
|
||||||
try_cache = false,
|
name: 'ASC',
|
||||||
log_lvl = 0
|
updated_on: 'DESC',
|
||||||
}: {
|
created_on: 'DESC'
|
||||||
api_cfg: any,
|
},
|
||||||
for_obj_type: string,
|
params = {},
|
||||||
for_obj_id: string,
|
try_cache = false,
|
||||||
// inc_other_li?: boolean,
|
log_lvl = 0
|
||||||
order_by_li?: key_val,
|
}: {
|
||||||
params?: key_val,
|
api_cfg: any;
|
||||||
try_cache?: boolean,
|
for_obj_type: string;
|
||||||
log_lvl?: number
|
for_obj_id: string;
|
||||||
}
|
// inc_other_li?: boolean,
|
||||||
) {
|
order_by_li?: key_val;
|
||||||
console.log(`*** load_ae_obj_li__activity_log() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
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
|
const enabled: string = params.qry__enabled ?? 'enabled'; // all, disabled, enabled
|
||||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
const hidden: string = params.qry__hidden ?? 'not_hidden'; // all, hidden, not_hidden
|
||||||
let limit: number = (params.qry__limit ?? 99); // 99
|
const limit: number = params.qry__limit ?? 99; // 99
|
||||||
let offset: number = (params.qry__offset ?? 0); // 0
|
const offset: number = params.qry__offset ?? 0; // 0
|
||||||
|
|
||||||
let params_json: key_val = {};
|
const params_json: key_val = {};
|
||||||
|
|
||||||
// console.log('params_json:', params_json);
|
// console.log('params_json:', params_json);
|
||||||
|
|
||||||
ae_promises.load__activity_log_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
ae_promises.load__activity_log_obj_li = await api
|
||||||
api_cfg: api_cfg,
|
.get_ae_obj_li_for_obj_id_crud({
|
||||||
obj_type: 'activity_log',
|
api_cfg: api_cfg,
|
||||||
for_obj_type: for_obj_type,
|
obj_type: 'activity_log',
|
||||||
for_obj_id: for_obj_id,
|
for_obj_type: for_obj_type,
|
||||||
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
for_obj_id: for_obj_id,
|
||||||
use_alt_base: 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.
|
||||||
enabled: enabled,
|
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||||
hidden: hidden,
|
enabled: enabled,
|
||||||
order_by_li: order_by_li,
|
hidden: hidden,
|
||||||
limit: limit,
|
order_by_li: order_by_li,
|
||||||
offset: offset,
|
limit: limit,
|
||||||
params_json: params_json,
|
offset: offset,
|
||||||
params: params,
|
params_json: params_json,
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(function (activity_log_obj_li_get_result) {
|
})
|
||||||
if (activity_log_obj_li_get_result) {
|
.then(function (activity_log_obj_li_get_result) {
|
||||||
// if (try_cache) {
|
if (activity_log_obj_li_get_result) {
|
||||||
// db_save_ae_obj_li__activity_log({
|
// if (try_cache) {
|
||||||
// obj_type: 'activity_log',
|
// db_save_ae_obj_li__activity_log({
|
||||||
// obj_li: activity_log_obj_li_get_result
|
// obj_type: 'activity_log',
|
||||||
// });
|
// obj_li: activity_log_obj_li_get_result
|
||||||
// }
|
// });
|
||||||
return activity_log_obj_li_get_result;
|
// }
|
||||||
} else {
|
return activity_log_obj_li_get_result;
|
||||||
return [];
|
} else {
|
||||||
}
|
return [];
|
||||||
})
|
}
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
});
|
console.log('No results returned or failed.', error);
|
||||||
|
});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.load__activity_log_obj_li:', ae_promises.load__activity_log_obj_li);
|
console.log('ae_promises.load__activity_log_obj_li:', ae_promises.load__activity_log_obj_li);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ae_promises.load__activity_log_obj_li;
|
return ae_promises.load__activity_log_obj_li;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-10-23
|
// Updated 2024-10-23
|
||||||
export async function create_ae_obj__activity_log(
|
export async function create_ae_obj__activity_log({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
account_id,
|
||||||
account_id,
|
data_kv,
|
||||||
data_kv,
|
params = {},
|
||||||
params = {},
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
account_id: string;
|
||||||
account_id: string,
|
data_kv: key_val;
|
||||||
data_kv: key_val,
|
params?: key_val;
|
||||||
params?: key_val,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
console.log(`*** create_ae_obj__activity_log() *** account_id=${account_id}`);
|
||||||
) {
|
|
||||||
console.log(`*** create_ae_obj__activity_log() *** account_id=${account_id}`);
|
|
||||||
|
|
||||||
ae_promises.create__activity_log = await api.create_ae_obj_crud({
|
ae_promises.create__activity_log = await api
|
||||||
api_cfg: api_cfg,
|
.create_ae_obj_crud({
|
||||||
obj_type: 'activity_log',
|
api_cfg: api_cfg,
|
||||||
fields: {
|
obj_type: 'activity_log',
|
||||||
account_id_random: account_id,
|
fields: {
|
||||||
...data_kv
|
account_id_random: account_id,
|
||||||
},
|
...data_kv
|
||||||
key: api_cfg.api_crud_super_key,
|
},
|
||||||
params: params,
|
key: api_cfg.api_crud_super_key,
|
||||||
return_obj: true,
|
params: params,
|
||||||
log_lvl: log_lvl
|
return_obj: true,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(function (activity_log_obj_create_result) {
|
})
|
||||||
if (activity_log_obj_create_result) {
|
.then(function (activity_log_obj_create_result) {
|
||||||
// db_save_ae_obj_li__activity_log(
|
if (activity_log_obj_create_result) {
|
||||||
// {
|
// db_save_ae_obj_li__activity_log(
|
||||||
// obj_type: 'activity_log',
|
// {
|
||||||
// obj_li: [activity_log_obj_create_result]
|
// obj_type: 'activity_log',
|
||||||
// });
|
// obj_li: [activity_log_obj_create_result]
|
||||||
return activity_log_obj_create_result;
|
// });
|
||||||
} else {
|
return activity_log_obj_create_result;
|
||||||
return null;
|
} else {
|
||||||
}
|
return null;
|
||||||
})
|
}
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
})
|
console.log('No results returned or failed.', error);
|
||||||
.finally(function () {
|
})
|
||||||
});
|
.finally(function () {});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.create__activity_log:', ae_promises.create__activity_log);
|
console.log('ae_promises.create__activity_log:', ae_promises.create__activity_log);
|
||||||
}
|
}
|
||||||
return ae_promises.create__activity_log;
|
return ae_promises.create__activity_log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-10-23
|
// Updated 2024-10-23
|
||||||
export async function update_ae_obj__activity_log(
|
export async function update_ae_obj__activity_log({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
activity_log_id,
|
||||||
activity_log_id,
|
data_kv,
|
||||||
data_kv,
|
params = {},
|
||||||
params = {},
|
try_cache = false,
|
||||||
try_cache = false,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
activity_log_id: string;
|
||||||
activity_log_id: string,
|
data_kv: key_val;
|
||||||
data_kv: key_val,
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(
|
||||||
if (log_lvl) {
|
`*** update_ae_obj__activity_log() *** activity_log_id=${activity_log_id}`,
|
||||||
console.log(`*** update_ae_obj__activity_log() *** activity_log_id=${activity_log_id}`, data_kv);
|
data_kv
|
||||||
}
|
);
|
||||||
ae_promises.update__activity_log_obj = await api.update_ae_obj_id_crud({
|
}
|
||||||
api_cfg: api_cfg,
|
ae_promises.update__activity_log_obj = await api
|
||||||
obj_type: 'activity_log',
|
.update_ae_obj_id_crud({
|
||||||
obj_id: activity_log_id,
|
api_cfg: api_cfg,
|
||||||
fields: data_kv,
|
obj_type: 'activity_log',
|
||||||
key: api_cfg.api_crud_super_key,
|
obj_id: activity_log_id,
|
||||||
params: params,
|
fields: data_kv,
|
||||||
return_obj: true,
|
key: api_cfg.api_crud_super_key,
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
return_obj: true,
|
||||||
.then(function (activity_log_obj_update_result) {
|
log_lvl: log_lvl
|
||||||
if (activity_log_obj_update_result) {
|
})
|
||||||
// if (try_cache) {
|
.then(function (activity_log_obj_update_result) {
|
||||||
// db_save_ae_obj_li__activity_log({
|
if (activity_log_obj_update_result) {
|
||||||
// obj_type: 'activity_log', obj_li: [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;
|
return activity_log_obj_update_result;
|
||||||
}
|
} else {
|
||||||
})
|
return null;
|
||||||
.catch(function (error: any) {
|
}
|
||||||
console.log('No results returned or failed.', error);
|
})
|
||||||
})
|
.catch(function (error: any) {
|
||||||
.finally(function () {
|
console.log('No results returned or failed.', error);
|
||||||
});
|
})
|
||||||
|
.finally(function () {});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.update__activity_log_obj:', ae_promises.update__activity_log_obj);
|
console.log('ae_promises.update__activity_log_obj:', ae_promises.update__activity_log_obj);
|
||||||
}
|
}
|
||||||
return 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.
|
// This new function is using CRUD v2. This should allow for more flexibility in the queries.
|
||||||
// Updated 2024-10-23
|
// Updated 2024-10-23
|
||||||
export async function qry__activity_log(
|
export async function qry__activity_log({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
activity_log_id,
|
||||||
activity_log_id,
|
qry_str,
|
||||||
qry_str,
|
qry_files,
|
||||||
qry_files,
|
qry_start_datetime, // Example greater than: '2024-10-24'
|
||||||
qry_start_datetime, // Example greater than: '2024-10-24'
|
enabled = 'enabled',
|
||||||
enabled = 'enabled',
|
hidden = 'not_hidden',
|
||||||
hidden = 'not_hidden',
|
limit = 50,
|
||||||
limit = 50,
|
offset = 0,
|
||||||
offset = 0,
|
params = {},
|
||||||
params = {},
|
try_cache = false,
|
||||||
try_cache = false,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
activity_log_id: any;
|
||||||
activity_log_id: any,
|
qry_str?: string;
|
||||||
qry_str?: string,
|
qry_files?: null | boolean;
|
||||||
qry_files?: null|boolean,
|
qry_start_datetime?: null | string; // Greater than this datetime
|
||||||
qry_start_datetime?: null|string, // Greater than this datetime
|
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined; // all, disabled, enabled
|
||||||
enabled?: "enabled" | "all" | "not_enabled" | undefined, // all, disabled, enabled
|
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined; // all, hidden, not_hidden
|
||||||
hidden?: "hidden" | "all" | "not_hidden" | undefined, // all, hidden, not_hidden
|
limit?: number;
|
||||||
limit?: number,
|
offset?: number;
|
||||||
offset?: number,
|
params?: any;
|
||||||
params?: any,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
console.log(`*** qry__activity_log() *** activity_log_id=${activity_log_id} qry_str=${qry_str}`);
|
||||||
) {
|
|
||||||
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 enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||||
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||||
// let limit: number = (params.qry__limit ?? 25); // 99
|
// let limit: number = (params.qry__limit ?? 25); // 99
|
||||||
// let offset: number = (params.qry__offset ?? 0); // 0
|
// let offset: number = (params.qry__offset ?? 0); // 0
|
||||||
|
|
||||||
let params_json: key_val = {};
|
const params_json: key_val = {};
|
||||||
|
|
||||||
// if (qry_str && qry_str.length > 2) {
|
// if (qry_str && qry_str.length > 2) {
|
||||||
// params_json['ft_qry'] = {};
|
// params_json['ft_qry'] = {};
|
||||||
// params_json['ft_qry']['default_qry_str'] = qry_str;
|
// params_json['ft_qry']['default_qry_str'] = qry_str;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
params_json['qry'] = [];
|
params_json['qry'] = [];
|
||||||
|
|
||||||
if (qry_files === true) {
|
if (qry_files === true) {
|
||||||
let qry_param =
|
const qry_param = {
|
||||||
{
|
type: 'AND',
|
||||||
type: "AND",
|
field: 'file_count_all',
|
||||||
field: "file_count_all",
|
operator: '>',
|
||||||
operator: ">",
|
value: 0
|
||||||
value: 0
|
};
|
||||||
};
|
params_json['qry'].push(qry_param);
|
||||||
params_json['qry'].push(qry_param);
|
} else if (qry_files === false) {
|
||||||
} else if (qry_files === false) {
|
const qry_param = {
|
||||||
let qry_param =
|
type: 'AND',
|
||||||
{
|
field: 'file_count_all',
|
||||||
type: "AND",
|
operator: 'IS',
|
||||||
field: "file_count_all",
|
value: null
|
||||||
operator: "IS",
|
};
|
||||||
value: null
|
params_json['qry'].push(qry_param);
|
||||||
};
|
}
|
||||||
params_json['qry'].push(qry_param);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qry_start_datetime) {
|
if (qry_start_datetime) {
|
||||||
let qry_param =
|
const qry_param = {
|
||||||
{
|
type: 'AND',
|
||||||
type: "AND",
|
field: 'start_datetime',
|
||||||
field: "start_datetime",
|
operator: '>',
|
||||||
operator: ">",
|
value: qry_start_datetime
|
||||||
value: qry_start_datetime
|
};
|
||||||
};
|
params_json['qry'].push(qry_param);
|
||||||
params_json['qry'].push(qry_param);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let order_by_li: { [key: string]: "ASC" | "DESC" }[] = [{'priority': 'DESC'}, {'sort': 'DESC'}, {'start_datetime': 'ASC'}, {'name': 'ASC'}, {'updated_on': 'DESC'}, {'created_on': 'DESC'}];
|
const order_by_li: { [key: string]: 'ASC' | 'DESC' }[] = [
|
||||||
|
{ 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({
|
ae_promises.load__activity_log_obj_li = await api
|
||||||
api_cfg: api_cfg,
|
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||||
obj_type: 'activity_log',
|
api_cfg: api_cfg,
|
||||||
for_obj_type: 'account',
|
obj_type: 'activity_log',
|
||||||
for_obj_id: activity_log_id,
|
for_obj_type: 'account',
|
||||||
use_alt_tbl: true, // NOTE: We want to use the alt table for activity_log searching
|
for_obj_id: activity_log_id,
|
||||||
use_alt_mdl: false,
|
use_alt_tbl: true, // NOTE: We want to use the alt table for activity_log searching
|
||||||
use_alt_exp: false,
|
use_alt_mdl: false,
|
||||||
enabled: enabled,
|
use_alt_exp: false,
|
||||||
hidden: hidden,
|
enabled: enabled,
|
||||||
order_by_li: order_by_li,
|
hidden: hidden,
|
||||||
limit: limit,
|
order_by_li: order_by_li,
|
||||||
offset: offset,
|
limit: limit,
|
||||||
params_json: params_json,
|
offset: offset,
|
||||||
params: params,
|
params_json: params_json,
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(function (activity_log_obj_li_get_result) {
|
})
|
||||||
if (activity_log_obj_li_get_result) {
|
.then(function (activity_log_obj_li_get_result) {
|
||||||
// db_save_ae_obj_li__activity_log({
|
if (activity_log_obj_li_get_result) {
|
||||||
// obj_type: 'activity_log',
|
// db_save_ae_obj_li__activity_log({
|
||||||
// obj_li: activity_log_obj_li_get_result
|
// obj_type: 'activity_log',
|
||||||
// });
|
// obj_li: activity_log_obj_li_get_result
|
||||||
return activity_log_obj_li_get_result;
|
// });
|
||||||
} else {
|
return activity_log_obj_li_get_result;
|
||||||
return [];
|
} else {
|
||||||
}
|
return [];
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.load__activity_log_obj_li:', ae_promises.load__activity_log_obj_li);
|
console.log('ae_promises.load__activity_log_obj_li:', ae_promises.load__activity_log_obj_li);
|
||||||
}
|
}
|
||||||
return ae_promises.load__activity_log_obj_li;
|
return ae_promises.load__activity_log_obj_li;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,69 +1,57 @@
|
|||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
|
|
||||||
|
|
||||||
// Updated 2025-01-28
|
// Updated 2025-01-28
|
||||||
export function add_url_params(
|
export function add_url_params({
|
||||||
{
|
base_url = '',
|
||||||
base_url = '',
|
endpoint,
|
||||||
endpoint,
|
params,
|
||||||
params,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
base_url?: string;
|
||||||
base_url?: string,
|
endpoint: string;
|
||||||
endpoint: string,
|
params: key_val;
|
||||||
params: key_val,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** add_url_params() *** base_url=${base_url} endpoint=${endpoint}`, params);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`*** add_url_params() *** base_url=${base_url} endpoint=${endpoint}`, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
const url_obj = new URL(endpoint, base_url);
|
const url_obj = new URL(endpoint, base_url);
|
||||||
|
|
||||||
Object.keys(params).forEach(key => url_obj.searchParams.append(key, params[key]));
|
Object.keys(params).forEach((key) => url_obj.searchParams.append(key, params[key]));
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('New URL:', url_obj.toString());
|
console.log('New URL:', url_obj.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return url_obj.toString();
|
return url_obj.toString();
|
||||||
// return 'test';
|
// return 'test';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This is used to clean the header property names. Not underscores allowed in the header names.
|
// This is used to clean the header property names. Not underscores allowed in the header names.
|
||||||
// Updated 2025-01-28
|
// Updated 2025-01-28
|
||||||
export function clean_headers(
|
export function clean_headers({ headers, log_lvl = 0 }: { headers: any; log_lvl?: number }) {
|
||||||
{
|
if (log_lvl) {
|
||||||
headers,
|
console.log(`*** clean_headers() ***`, headers);
|
||||||
log_lvl = 0
|
}
|
||||||
}: {
|
|
||||||
headers: any,
|
|
||||||
log_lvl?: number
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
if (log_lvl) {
|
|
||||||
console.log(`*** clean_headers() ***`, headers);
|
|
||||||
}
|
|
||||||
|
|
||||||
let headers_cleaned: key_val = {};
|
const headers_cleaned: key_val = {};
|
||||||
for (const prop in headers) {
|
for (const prop in headers) {
|
||||||
let prop_cleaned = prop.replaceAll('_', '-');
|
const prop_cleaned = prop.replaceAll('_', '-');
|
||||||
if (typeof headers[prop] != 'string') {
|
if (typeof headers[prop] != 'string') {
|
||||||
headers[prop] = JSON.stringify(headers[prop]);
|
headers[prop] = JSON.stringify(headers[prop]);
|
||||||
}
|
}
|
||||||
headers_cleaned[prop_cleaned] = headers[prop];
|
headers_cleaned[prop_cleaned] = headers[prop];
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log(`${prop_cleaned}: ${headers_cleaned[prop_cleaned]}`);
|
console.log(`${prop_cleaned}: ${headers_cleaned[prop_cleaned]}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object.keys(headers).forEach(key => {
|
// Object.keys(headers).forEach(key => {
|
||||||
// if (headers[key]) {
|
// if (headers[key]) {
|
||||||
// headers_cleaned[key] = headers[key];
|
// headers_cleaned[key] = headers[key];
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
return headers_cleaned;
|
return headers_cleaned;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +1,34 @@
|
|||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-10-02
|
// Updated 2024-10-02
|
||||||
export async function check_hosted_file_obj_w_hash(
|
export async function check_hosted_file_obj_w_hash({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
hosted_file_hash,
|
||||||
hosted_file_hash,
|
check_for_local = true, // Forces a check on the host server for the file.
|
||||||
check_for_local = true, // Forces a check on the host server for the file.
|
params = {},
|
||||||
params = {},
|
return_meta = false,
|
||||||
return_meta = false,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
} : {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
hosted_file_hash: string;
|
||||||
hosted_file_hash: string,
|
check_for_local?: boolean;
|
||||||
check_for_local?: boolean,
|
params?: key_val;
|
||||||
params?: key_val,
|
return_meta?: boolean;
|
||||||
return_meta?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
console.log('*** stores_event_api.js: check_hosted_file_obj_w_hash() ***');
|
||||||
) {
|
|
||||||
console.log('*** stores_event_api.js: check_hosted_file_obj_w_hash() ***');
|
|
||||||
|
|
||||||
const endpoint = `/hosted_file/hash/${hosted_file_hash}`;
|
const endpoint = `/hosted_file/hash/${hosted_file_hash}`;
|
||||||
if (check_for_local) {
|
if (check_for_local) {
|
||||||
params['check_for_local'] = true;
|
params['check_for_local'] = true;
|
||||||
}
|
}
|
||||||
let check_hosted_file_obj_w_hash_get_promise = await api.get_object({
|
const check_hosted_file_obj_w_hash_get_promise = await api.get_object({
|
||||||
api_cfg: api_cfg,
|
api_cfg: api_cfg,
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
params: params,
|
params: params,
|
||||||
return_meta: return_meta,
|
return_meta: return_meta,
|
||||||
log_lvl: log_lvl
|
log_lvl: log_lvl
|
||||||
});
|
});
|
||||||
return check_hosted_file_obj_w_hash_get_promise;
|
return check_hosted_file_obj_w_hash_get_promise;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,73 +1,71 @@
|
|||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
|
|
||||||
import { db_core } from "$lib/ae_core/db_core";
|
import { db_core } from '$lib/ae_core/db_core';
|
||||||
|
|
||||||
let ae_promises: key_val = {};
|
|
||||||
|
|
||||||
|
const ae_promises: key_val = {};
|
||||||
|
|
||||||
// Updated 2024-10-14
|
// Updated 2024-10-14
|
||||||
export async function load_ae_obj_li__country(
|
export async function load_ae_obj_li__country({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
// account_id,
|
||||||
// account_id,
|
enabled = 'enabled',
|
||||||
enabled = 'enabled',
|
hidden = 'not_hidden',
|
||||||
hidden = 'not_hidden',
|
limit = 299,
|
||||||
limit = 299,
|
offset = 0,
|
||||||
offset = 0,
|
order_by_li = { sort: 'DESC', english_short_name: 'ASC', alpha_2_code: 'ASC' },
|
||||||
order_by_li = {'sort': 'DESC', 'english_short_name': 'ASC', 'alpha_2_code': 'ASC'},
|
params = {},
|
||||||
params = {},
|
try_cache = true,
|
||||||
try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
// account_id: string,
|
||||||
// account_id: string,
|
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
|
||||||
enabled?: "enabled" | "all" | "not_enabled" | undefined,
|
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
|
||||||
hidden?: "hidden" | "all" | "not_hidden" | undefined,
|
limit?: number;
|
||||||
limit?: number,
|
offset?: number;
|
||||||
offset?: number,
|
order_by_li?: key_val;
|
||||||
order_by_li?: key_val
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** load_ae_obj_li__country() ***`);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`*** load_ae_obj_li__country() ***`);
|
|
||||||
}
|
|
||||||
|
|
||||||
let params_json: key_val = {};
|
const params_json: key_val = {};
|
||||||
|
|
||||||
// console.log('params_json:', params_json);
|
// console.log('params_json:', params_json);
|
||||||
|
|
||||||
ae_promises.load__country_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
ae_promises.load__country_li = await api
|
||||||
api_cfg: api_cfg,
|
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||||
obj_type: 'lu',
|
api_cfg: api_cfg,
|
||||||
for_obj_type: 'country',
|
obj_type: 'lu',
|
||||||
// for_obj_id: account_id,
|
for_obj_type: 'country',
|
||||||
use_alt_tbl: false,
|
// for_obj_id: account_id,
|
||||||
use_alt_mdl: false,
|
use_alt_tbl: false,
|
||||||
enabled: enabled,
|
use_alt_mdl: false,
|
||||||
hidden: hidden,
|
enabled: enabled,
|
||||||
order_by_li: order_by_li,
|
hidden: hidden,
|
||||||
limit: limit,
|
order_by_li: order_by_li,
|
||||||
offset: offset,
|
limit: limit,
|
||||||
params_json: params_json,
|
offset: offset,
|
||||||
params: params,
|
params_json: params_json,
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(function (country_li_get_result) {
|
})
|
||||||
if (country_li_get_result) {
|
.then(function (country_li_get_result) {
|
||||||
// handle_db_save_ae_obj_li__country({obj_type: 'country', obj_li: country_li_get_result});
|
if (country_li_get_result) {
|
||||||
return country_li_get_result;
|
// handle_db_save_ae_obj_li__country({obj_type: 'country', obj_li: country_li_get_result});
|
||||||
} else {
|
return country_li_get_result;
|
||||||
return [];
|
} else {
|
||||||
}
|
return [];
|
||||||
})
|
}
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
});
|
console.log('No results returned or failed.', error);
|
||||||
|
});
|
||||||
|
|
||||||
console.log('ae_promises.load__country_li:', ae_promises.load__country_li);
|
console.log('ae_promises.load__country_li:', ae_promises.load__country_li);
|
||||||
return ae_promises.load__country_li;
|
return ae_promises.load__country_li;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,73 +1,74 @@
|
|||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
|
|
||||||
import { db_core } from "$lib/ae_core/db_core";
|
import { db_core } from '$lib/ae_core/db_core';
|
||||||
|
|
||||||
let ae_promises: key_val = {};
|
|
||||||
|
|
||||||
|
const ae_promises: key_val = {};
|
||||||
|
|
||||||
// Updated 2024-10-14
|
// Updated 2024-10-14
|
||||||
export async function load_ae_obj_li__country_subdivision(
|
export async function load_ae_obj_li__country_subdivision({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
// account_id,
|
||||||
// account_id,
|
enabled = 'enabled',
|
||||||
enabled = 'enabled',
|
hidden = 'not_hidden',
|
||||||
hidden = 'not_hidden',
|
limit = 399,
|
||||||
limit = 399,
|
offset = 0,
|
||||||
offset = 0,
|
order_by_li = { sort: 'DESC', name: 'ASC', code: 'ASC' },
|
||||||
order_by_li = {'sort': 'DESC', 'name': 'ASC', 'code': 'ASC'},
|
params = {},
|
||||||
params = {},
|
try_cache = true,
|
||||||
try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
// account_id: string,
|
||||||
// account_id: string,
|
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
|
||||||
enabled?: "enabled" | "all" | "not_enabled" | undefined,
|
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
|
||||||
hidden?: "hidden" | "all" | "not_hidden" | undefined,
|
limit?: number;
|
||||||
limit?: number,
|
offset?: number;
|
||||||
offset?: number,
|
order_by_li?: key_val;
|
||||||
order_by_li?: key_val
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** load_ae_obj_li__country_subdivision() ***`);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`*** load_ae_obj_li__country_subdivision() ***`);
|
|
||||||
}
|
|
||||||
|
|
||||||
let params_json: key_val = {};
|
const params_json: key_val = {};
|
||||||
|
|
||||||
// console.log('params_json:', params_json);
|
// console.log('params_json:', params_json);
|
||||||
|
|
||||||
ae_promises.load__country_subdivision_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
ae_promises.load__country_subdivision_li = await api
|
||||||
api_cfg: api_cfg,
|
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||||
obj_type: 'lu',
|
api_cfg: api_cfg,
|
||||||
for_obj_type: 'country_subdivision',
|
obj_type: 'lu',
|
||||||
// for_obj_id: account_id,
|
for_obj_type: 'country_subdivision',
|
||||||
use_alt_tbl: false,
|
// for_obj_id: account_id,
|
||||||
use_alt_mdl: false,
|
use_alt_tbl: false,
|
||||||
enabled: enabled,
|
use_alt_mdl: false,
|
||||||
hidden: hidden,
|
enabled: enabled,
|
||||||
order_by_li: order_by_li,
|
hidden: hidden,
|
||||||
limit: limit,
|
order_by_li: order_by_li,
|
||||||
offset: offset,
|
limit: limit,
|
||||||
params_json: params_json,
|
offset: offset,
|
||||||
params: params,
|
params_json: params_json,
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(function (country_subdivision_li_get_result) {
|
})
|
||||||
if (country_subdivision_li_get_result) {
|
.then(function (country_subdivision_li_get_result) {
|
||||||
// handle_db_save_ae_obj_li__country_subdivision({obj_type: 'country_subdivision', obj_li: country_subdivision_li_get_result});
|
if (country_subdivision_li_get_result) {
|
||||||
return country_subdivision_li_get_result;
|
// handle_db_save_ae_obj_li__country_subdivision({obj_type: 'country_subdivision', obj_li: country_subdivision_li_get_result});
|
||||||
} else {
|
return country_subdivision_li_get_result;
|
||||||
return [];
|
} else {
|
||||||
}
|
return [];
|
||||||
})
|
}
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
});
|
console.log('No results returned or failed.', error);
|
||||||
|
});
|
||||||
|
|
||||||
console.log('ae_promises.load__country_subdivision_li:', ae_promises.load__country_subdivision_li);
|
console.log(
|
||||||
return ae_promises.load__country_subdivision_li;
|
'ae_promises.load__country_subdivision_li:',
|
||||||
|
ae_promises.load__country_subdivision_li
|
||||||
|
);
|
||||||
|
return ae_promises.load__country_subdivision_li;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,352 +3,333 @@ import { marked } from 'marked';
|
|||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
|
|
||||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
|
||||||
|
|
||||||
// Define generic CRUD args
|
// Define generic CRUD args
|
||||||
export interface GenericCrudArgs {
|
export interface GenericCrudArgs {
|
||||||
api_cfg: any;
|
api_cfg: any;
|
||||||
obj_type: string;
|
obj_type: string;
|
||||||
obj_id?: string;
|
obj_id?: string;
|
||||||
for_obj_type?: string;
|
for_obj_type?: string;
|
||||||
for_obj_id?: string;
|
for_obj_id?: string;
|
||||||
|
|
||||||
db_instance?: any; // Optional DB instance for caching
|
db_instance?: any; // Optional DB instance for caching
|
||||||
db_field_li?: string[]; // Optional list of fields to save in DB
|
db_field_li?: string[]; // Optional list of fields to save in DB
|
||||||
|
|
||||||
// Flags to include related core object models
|
// Flags to include related core object models
|
||||||
inc_account_li?: boolean;
|
inc_account_li?: boolean;
|
||||||
inc_address_li?: boolean;
|
inc_address_li?: boolean;
|
||||||
inc_contact_li?: boolean;
|
inc_contact_li?: boolean;
|
||||||
inc_person_li?: boolean;
|
inc_person_li?: boolean;
|
||||||
inc_site_li?: boolean;
|
inc_site_li?: boolean;
|
||||||
inc_site_domain_li?: boolean;
|
inc_site_domain_li?: boolean;
|
||||||
inc_user_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;
|
||||||
|
|
||||||
// Flags to include related other object models
|
inc_obj_type_li?: string[]; // Optional list of object types to include
|
||||||
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';
|
||||||
data_kv?: key_val;
|
hidden?: 'not_hidden' | 'hidden' | 'all';
|
||||||
enabled?: 'enabled' | 'disabled' | 'all';
|
limit?: number;
|
||||||
hidden?: 'not_hidden' | 'hidden' | 'all';
|
offset?: number;
|
||||||
limit?: number;
|
order_by_li?: key_val;
|
||||||
offset?: number;
|
params?: key_val;
|
||||||
order_by_li?: key_val;
|
try_cache?: boolean;
|
||||||
params?: key_val;
|
log_lvl?: number;
|
||||||
try_cache?: boolean;
|
|
||||||
log_lvl?: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic function: Load single object by ID
|
// Generic function: Load single object by ID
|
||||||
export async function load_ae_obj_id(
|
export async function load_ae_obj_id(args: GenericCrudArgs): Promise<any> {
|
||||||
args: GenericCrudArgs
|
const { api_cfg, obj_type, obj_id, log_lvl = 0 } = args;
|
||||||
): Promise<any> {
|
|
||||||
const { api_cfg, obj_type, obj_id, log_lvl = 0 } = args;
|
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** load_ae_obj_id() *** obj_type=${obj_type} obj_id=${obj_id}`);
|
console.log(`*** load_ae_obj_id() *** obj_type=${obj_type} obj_id=${obj_id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = await api.get_ae_obj_id_crud({
|
const result = await api.get_ae_obj_id_crud({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
obj_type,
|
obj_type,
|
||||||
obj_id,
|
obj_id,
|
||||||
params: {},
|
params: {},
|
||||||
log_lvl
|
log_lvl
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic function: Load list of objects
|
// Generic function: Load list of objects
|
||||||
export async function load_ae_obj_li(
|
export async function load_ae_obj_li(args: GenericCrudArgs): Promise<any> {
|
||||||
args: GenericCrudArgs
|
const {
|
||||||
): Promise<any> {
|
api_cfg,
|
||||||
const {
|
obj_type,
|
||||||
api_cfg,
|
for_obj_type = '',
|
||||||
obj_type,
|
for_obj_id,
|
||||||
for_obj_type = '',
|
inc_obj_type_li,
|
||||||
for_obj_id,
|
enabled = 'enabled',
|
||||||
inc_obj_type_li,
|
hidden = 'not_hidden',
|
||||||
enabled = 'enabled',
|
limit = 99,
|
||||||
hidden = 'not_hidden',
|
offset = 0,
|
||||||
limit = 99,
|
order_by_li = {},
|
||||||
offset = 0,
|
params = {},
|
||||||
order_by_li = {},
|
try_cache = true,
|
||||||
params = {},
|
log_lvl = 0
|
||||||
try_cache = true,
|
} = args;
|
||||||
log_lvl = 0
|
|
||||||
} = args;
|
|
||||||
|
|
||||||
if (log_lvl) {
|
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}`);
|
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 = {};
|
const params_json: key_val = {};
|
||||||
|
|
||||||
let result = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
const result = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
obj_type,
|
obj_type,
|
||||||
for_obj_type,
|
for_obj_type,
|
||||||
for_obj_id,
|
for_obj_id,
|
||||||
enabled,
|
enabled,
|
||||||
hidden,
|
hidden,
|
||||||
order_by_li,
|
order_by_li,
|
||||||
limit,
|
limit,
|
||||||
offset,
|
offset,
|
||||||
params_json: {},
|
params_json: {},
|
||||||
params,
|
params,
|
||||||
log_lvl
|
log_lvl
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic function: Create object
|
// Generic function: Create object
|
||||||
export async function create_ae_obj(
|
export async function create_ae_obj(args: GenericCrudArgs): Promise<any> {
|
||||||
args: GenericCrudArgs
|
const { api_cfg, obj_type, data_kv, log_lvl = 0 } = args;
|
||||||
): Promise<any> {
|
|
||||||
const { api_cfg, obj_type, data_kv, log_lvl = 0 } = args;
|
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** create_ae_obj() *** obj_type=${obj_type}`, data_kv);
|
console.log(`*** create_ae_obj() *** obj_type=${obj_type}`, data_kv);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = await api.create_ae_obj_crud({
|
const result = await api.create_ae_obj_crud({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
obj_type,
|
obj_type,
|
||||||
fields: data_kv,
|
fields: data_kv,
|
||||||
key: api_cfg.api_crud_super_key,
|
key: api_cfg.api_crud_super_key,
|
||||||
params: {},
|
params: {},
|
||||||
return_obj: true,
|
return_obj: true,
|
||||||
log_lvl
|
log_lvl
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic function: Update object
|
// Generic function: Update object
|
||||||
export async function update_ae_obj(
|
export async function update_ae_obj(args: GenericCrudArgs): Promise<any> {
|
||||||
args: GenericCrudArgs
|
const { api_cfg, obj_type, obj_id, data_kv, log_lvl = 0 } = args;
|
||||||
): Promise<any> {
|
|
||||||
const { api_cfg, obj_type, obj_id, data_kv, log_lvl = 0 } = args;
|
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** update_ae_obj() *** obj_type=${obj_type} obj_id=${obj_id}`, data_kv);
|
console.log(`*** update_ae_obj() *** obj_type=${obj_type} obj_id=${obj_id}`, data_kv);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = await api.update_ae_obj_id_crud({
|
const result = await api.update_ae_obj_id_crud({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
obj_type,
|
obj_type,
|
||||||
obj_id,
|
obj_id,
|
||||||
fields: data_kv,
|
fields: data_kv,
|
||||||
key: api_cfg.api_crud_super_key,
|
key: api_cfg.api_crud_super_key,
|
||||||
params: {},
|
params: {},
|
||||||
return_obj: true,
|
return_obj: true,
|
||||||
log_lvl
|
log_lvl
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic function: Delete object
|
// Generic function: Delete object
|
||||||
export async function delete_ae_obj_id(
|
export async function delete_ae_obj_id(args: GenericCrudArgs): Promise<any> {
|
||||||
args: GenericCrudArgs
|
const { api_cfg, obj_type, obj_id, method = 'delete', log_lvl = 0 } = args;
|
||||||
): Promise<any> {
|
|
||||||
const { api_cfg, obj_type, obj_id, method = 'delete', log_lvl = 0 } = args;
|
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** delete_ae_obj_id() *** obj_type=${obj_type} obj_id=${obj_id}`);
|
console.log(`*** delete_ae_obj_id() *** obj_type=${obj_type} obj_id=${obj_id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = await api.delete_ae_obj_id_crud({
|
const result = await api.delete_ae_obj_id_crud({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
obj_type,
|
obj_type,
|
||||||
obj_id,
|
obj_id,
|
||||||
key: api_cfg.api_crud_super_key,
|
key: api_cfg.api_crud_super_key,
|
||||||
params: {},
|
params: {},
|
||||||
method,
|
method,
|
||||||
log_lvl
|
log_lvl
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Additional Modules that might be needed for reloads
|
// Additional Modules that might be needed for reloads
|
||||||
import { load_ae_obj_id__archive } from "$lib/ae_archives/ae_archives__archive";
|
import { load_ae_obj_id__archive } from '$lib/ae_archives/ae_archives__archive';
|
||||||
import { load_ae_obj_id__archive_content } from "$lib/ae_archives/ae_archives__archive_content";
|
import { load_ae_obj_id__archive_content } from '$lib/ae_archives/ae_archives__archive_content';
|
||||||
import { load_ae_obj_id__event } from "$lib/ae_events/ae_events__event";
|
import { load_ae_obj_id__event } from '$lib/ae_events/ae_events__event';
|
||||||
import { load_ae_obj_id__event_device } from "$lib/ae_events/ae_events__event_device";
|
import { load_ae_obj_id__event_device } from '$lib/ae_events/ae_events__event_device';
|
||||||
import { load_ae_obj_id__event_file } from "$lib/ae_events/ae_events__event_file";
|
import { load_ae_obj_id__event_file } from '$lib/ae_events/ae_events__event_file';
|
||||||
import { load_ae_obj_id__event_location } from "$lib/ae_events/ae_events__event_location";
|
import { load_ae_obj_id__event_location } from '$lib/ae_events/ae_events__event_location';
|
||||||
import { load_ae_obj_id__event_presentation } from "$lib/ae_events/ae_events__event_presentation";
|
import { load_ae_obj_id__event_presentation } from '$lib/ae_events/ae_events__event_presentation';
|
||||||
import { load_ae_obj_id__event_presenter } from "$lib/ae_events/ae_events__event_presenter";
|
import { load_ae_obj_id__event_presenter } from '$lib/ae_events/ae_events__event_presenter';
|
||||||
import { load_ae_obj_id__event_session } from "$lib/ae_events/ae_events__event_session";
|
import { load_ae_obj_id__event_session } from '$lib/ae_events/ae_events__event_session';
|
||||||
import { load_ae_obj_id__journal } from "$lib/ae_journals/ae_journals__journal";
|
import { load_ae_obj_id__journal } from '$lib/ae_journals/ae_journals__journal';
|
||||||
import { load_ae_obj_id__journal_entry } from "$lib/ae_journals/ae_journals__journal_entry";
|
import { load_ae_obj_id__journal_entry } from '$lib/ae_journals/ae_journals__journal_entry';
|
||||||
import { load_ae_obj_id__post } from "$lib/ae_posts/ae_posts__post";
|
import { load_ae_obj_id__post } from '$lib/ae_posts/ae_posts__post';
|
||||||
import { load_ae_obj_id__post_comment } from "$lib/ae_posts/ae_posts__post_comment";
|
import { load_ae_obj_id__post_comment } from '$lib/ae_posts/ae_posts__post_comment';
|
||||||
import { load_ae_obj_id__person } from "$lib/ae_core/core__person";
|
import { load_ae_obj_id__person } from '$lib/ae_core/core__person';
|
||||||
|
|
||||||
|
export async function update_ae_obj_id_crud_v2({
|
||||||
|
api_cfg,
|
||||||
|
object_type,
|
||||||
|
object_id,
|
||||||
|
object_reload = false,
|
||||||
|
field_name,
|
||||||
|
new_field_value,
|
||||||
|
log_lvl = 0
|
||||||
|
}: {
|
||||||
|
api_cfg: any;
|
||||||
|
object_type: string;
|
||||||
|
object_id: string;
|
||||||
|
object_reload?: boolean;
|
||||||
|
field_name: string;
|
||||||
|
new_field_value: any;
|
||||||
|
log_lvl?: number;
|
||||||
|
}) {
|
||||||
|
if (log_lvl) {
|
||||||
|
console.log(
|
||||||
|
`*** update_ae_obj_id_crud_v2() *** object_type=${object_type}, object_id=${object_id}, object_reload=${object_reload}, field_name=${field_name}, new_field_value=`,
|
||||||
|
new_field_value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const results = await api.update_ae_obj_id_crud({
|
||||||
|
api_cfg: api_cfg,
|
||||||
|
obj_type: object_type,
|
||||||
|
obj_id: object_id,
|
||||||
|
field_name: field_name,
|
||||||
|
field_value: new_field_value,
|
||||||
|
key: api_cfg.api_crud_super_key,
|
||||||
|
log_lvl: log_lvl
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!results) {
|
||||||
|
console.log(
|
||||||
|
`Not Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}; Account ID: ${api_cfg.account_id}`
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}`);
|
||||||
|
|
||||||
export async function update_ae_obj_id_crud_v2(
|
if (object_reload) {
|
||||||
{
|
if (log_lvl) console.log(`Reloading the object after patching...`);
|
||||||
api_cfg,
|
|
||||||
object_type,
|
|
||||||
object_id,
|
|
||||||
object_reload = false,
|
|
||||||
field_name,
|
|
||||||
new_field_value,
|
|
||||||
log_lvl = 0
|
|
||||||
}: {
|
|
||||||
api_cfg: any,
|
|
||||||
object_type: string,
|
|
||||||
object_id: string,
|
|
||||||
object_reload?: boolean,
|
|
||||||
field_name: string,
|
|
||||||
new_field_value: any,
|
|
||||||
log_lvl?: number
|
|
||||||
}) {
|
|
||||||
if (log_lvl) {
|
|
||||||
console.log(`*** update_ae_obj_id_crud_v2() *** object_type=${object_type}, object_id=${object_id}, object_reload=${object_reload}, field_name=${field_name}, new_field_value=`, new_field_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
const reload_fns: { [key: string]: (args: any) => Promise<any> } = {
|
||||||
const results = await api.update_ae_obj_id_crud({
|
person: load_ae_obj_id__person,
|
||||||
api_cfg: api_cfg,
|
archive: load_ae_obj_id__archive,
|
||||||
obj_type: object_type,
|
archive_content: load_ae_obj_id__archive_content,
|
||||||
obj_id: object_id,
|
journal: load_ae_obj_id__journal,
|
||||||
field_name: field_name,
|
journal_entry: load_ae_obj_id__journal_entry,
|
||||||
field_value: new_field_value,
|
event: load_ae_obj_id__event,
|
||||||
key: api_cfg.api_crud_super_key,
|
event_device: load_ae_obj_id__event_device,
|
||||||
log_lvl: log_lvl
|
event_file: load_ae_obj_id__event_file,
|
||||||
});
|
event_location: load_ae_obj_id__event_location,
|
||||||
|
event_presentation: load_ae_obj_id__event_presentation,
|
||||||
|
event_presenter: load_ae_obj_id__event_presenter,
|
||||||
|
event_session: load_ae_obj_id__event_session,
|
||||||
|
post: load_ae_obj_id__post,
|
||||||
|
post_comment: load_ae_obj_id__post_comment
|
||||||
|
};
|
||||||
|
|
||||||
if (!results) {
|
const reload_fn = reload_fns[object_type];
|
||||||
console.log(`Not Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}; Account ID: ${api_cfg.account_id}`);
|
if (reload_fn) {
|
||||||
return false;
|
const id_key = `${object_type}_id`;
|
||||||
}
|
return await reload_fn({ api_cfg, [id_key]: object_id, log_lvl });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log(`Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}`);
|
return true;
|
||||||
|
} catch (error) {
|
||||||
if (object_reload) {
|
console.log('Something went wrong patching the record.', error);
|
||||||
if (log_lvl) console.log(`Reloading the object after patching...`);
|
return false;
|
||||||
|
}
|
||||||
const reload_fns: { [key: string]: (args: any) => Promise<any> } = {
|
|
||||||
person: load_ae_obj_id__person,
|
|
||||||
archive: load_ae_obj_id__archive,
|
|
||||||
archive_content: load_ae_obj_id__archive_content,
|
|
||||||
journal: load_ae_obj_id__journal,
|
|
||||||
journal_entry: load_ae_obj_id__journal_entry,
|
|
||||||
event: load_ae_obj_id__event,
|
|
||||||
event_device: load_ae_obj_id__event_device,
|
|
||||||
event_file: load_ae_obj_id__event_file,
|
|
||||||
event_location: load_ae_obj_id__event_location,
|
|
||||||
event_presentation: load_ae_obj_id__event_presentation,
|
|
||||||
event_presenter: load_ae_obj_id__event_presenter,
|
|
||||||
event_session: load_ae_obj_id__event_session,
|
|
||||||
post: load_ae_obj_id__post,
|
|
||||||
post_comment: load_ae_obj_id__post_comment,
|
|
||||||
};
|
|
||||||
|
|
||||||
const reload_fn = reload_fns[object_type];
|
|
||||||
if (reload_fn) {
|
|
||||||
const id_key = `${object_type}_id`;
|
|
||||||
return await reload_fn({ api_cfg, [id_key]: object_id, log_lvl });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.log('Something went wrong patching the record.', error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function download_export_li({
|
||||||
|
api_cfg,
|
||||||
|
get_obj_type,
|
||||||
|
for_obj_type,
|
||||||
|
for_obj_id,
|
||||||
|
exp_alt = null,
|
||||||
|
file_type = 'CSV',
|
||||||
|
return_file = true,
|
||||||
|
filename = 'no_filename.csv',
|
||||||
|
auto_download = false,
|
||||||
|
limit = 5000,
|
||||||
|
params = {},
|
||||||
|
log_lvl = 0
|
||||||
|
}: {
|
||||||
|
api_cfg: any;
|
||||||
|
get_obj_type: string;
|
||||||
|
for_obj_type: string;
|
||||||
|
for_obj_id: string;
|
||||||
|
exp_alt?: null | string;
|
||||||
|
file_type?: string;
|
||||||
|
return_file?: boolean;
|
||||||
|
filename?: string;
|
||||||
|
auto_download?: boolean;
|
||||||
|
limit?: number;
|
||||||
|
params?: key_val;
|
||||||
|
log_lvl?: number;
|
||||||
|
}) {
|
||||||
|
if (log_lvl) console.log('*** download_export_li() ***');
|
||||||
|
|
||||||
export async function download_export_li(
|
const endpoint = `/v2/crud/${get_obj_type}/list`;
|
||||||
{
|
params['for_obj_type'] = for_obj_type;
|
||||||
api_cfg,
|
params['for_obj_id'] = for_obj_id;
|
||||||
get_obj_type,
|
|
||||||
for_obj_type,
|
|
||||||
for_obj_id,
|
|
||||||
exp_alt = null,
|
|
||||||
file_type = 'CSV',
|
|
||||||
return_file = true,
|
|
||||||
filename = 'no_filename.csv',
|
|
||||||
auto_download = false,
|
|
||||||
limit = 5000,
|
|
||||||
params = {},
|
|
||||||
log_lvl = 0
|
|
||||||
}: {
|
|
||||||
api_cfg: any,
|
|
||||||
get_obj_type: string,
|
|
||||||
for_obj_type: string,
|
|
||||||
for_obj_id: string,
|
|
||||||
exp_alt?: null|string,
|
|
||||||
file_type?: string,
|
|
||||||
return_file?: boolean,
|
|
||||||
filename?: string,
|
|
||||||
auto_download?: boolean,
|
|
||||||
limit?: number,
|
|
||||||
params?: key_val,
|
|
||||||
log_lvl?: number
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
if (log_lvl) console.log('*** download_export_li() ***');
|
|
||||||
|
|
||||||
const endpoint = `/v2/crud/${get_obj_type}/list`;
|
if (file_type === 'CSV' || file_type === 'Excel') {
|
||||||
params['for_obj_type'] = for_obj_type;
|
params['file_type'] = file_type;
|
||||||
params['for_obj_id'] = for_obj_id;
|
}
|
||||||
|
params['return_file'] = true;
|
||||||
|
params['mdl_alt'] = 'out';
|
||||||
|
|
||||||
if (file_type === 'CSV' || file_type === 'Excel') {
|
if (exp_alt) {
|
||||||
params['file_type'] = file_type;
|
params['exp_alt'] = exp_alt;
|
||||||
}
|
}
|
||||||
params['return_file'] = true;
|
|
||||||
params['mdl_alt'] = 'out';
|
|
||||||
|
|
||||||
if (exp_alt) {
|
const clean_filename = filename.replace(/[^a-zA-Z0-9\[\]-_.]/gi, '_');
|
||||||
params['exp_alt'] = exp_alt;
|
|
||||||
}
|
|
||||||
|
|
||||||
const clean_filename = filename.replace(/[^a-zA-Z0-9\[\]-_.]/gi, '_');
|
if (limit >= 0) {
|
||||||
|
params['limit'] = limit;
|
||||||
|
}
|
||||||
|
|
||||||
if (limit >= 0) {
|
const download_result = await api.get_object({
|
||||||
params['limit'] = limit;
|
api_cfg: api_cfg,
|
||||||
}
|
endpoint: endpoint,
|
||||||
|
params: params,
|
||||||
|
timeout: 90000,
|
||||||
|
return_blob: return_file,
|
||||||
|
filename: clean_filename,
|
||||||
|
auto_download: auto_download,
|
||||||
|
task_id: for_obj_id,
|
||||||
|
log_lvl: log_lvl
|
||||||
|
});
|
||||||
|
|
||||||
const download_result = await api.get_object({
|
if (log_lvl) console.log('download_result:', download_result);
|
||||||
api_cfg: api_cfg,
|
return download_result;
|
||||||
endpoint: endpoint,
|
|
||||||
params: params,
|
|
||||||
timeout: 90000,
|
|
||||||
return_blob: return_file,
|
|
||||||
filename: clean_filename,
|
|
||||||
auto_download: auto_download,
|
|
||||||
task_id: for_obj_id,
|
|
||||||
log_lvl: log_lvl
|
|
||||||
});
|
|
||||||
|
|
||||||
if (log_lvl) console.log('download_result:', download_result);
|
|
||||||
return download_result;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,23 @@ import type { key_val } from '$lib/stores/ae_stores';
|
|||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
|
|
||||||
export interface Data_Store {
|
export interface Data_Store {
|
||||||
id: string;
|
id: string;
|
||||||
account_id: string;
|
account_id: string;
|
||||||
code: string;
|
code: string;
|
||||||
name: string;
|
name: string;
|
||||||
type: string;
|
type: string;
|
||||||
for_type?: string | null;
|
for_type?: string | null;
|
||||||
for_id?: string | null;
|
for_id?: string | null;
|
||||||
access_read?: string | null;
|
access_read?: string | null;
|
||||||
access_write?: string | null;
|
access_write?: string | null;
|
||||||
access_delete?: string | null;
|
access_delete?: string | null;
|
||||||
html?: string | null;
|
html?: string | null;
|
||||||
json?: key_val | null;
|
json?: key_val | null;
|
||||||
md?: string | null;
|
md?: string | null;
|
||||||
text?: string | null;
|
text?: string | null;
|
||||||
updated_on?: string | null;
|
updated_on?: string | null;
|
||||||
chk_account_id?: string;
|
chk_account_id?: string;
|
||||||
loaded_on?: string;
|
loaded_on?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,83 +33,80 @@ export interface Data_Store {
|
|||||||
* @param log_lvl - The logging level.
|
* @param log_lvl - The logging level.
|
||||||
* @returns The data from the data store (e.g., text content or JSON object).
|
* @returns The data from the data store (e.g., text content or JSON object).
|
||||||
*/
|
*/
|
||||||
export async function load_ae_obj_by_code__data_store(
|
export async function load_ae_obj_by_code__data_store({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
code,
|
||||||
code,
|
data_type = 'text',
|
||||||
data_type = 'text',
|
save_idb = false,
|
||||||
save_idb = false,
|
timeout = 9000,
|
||||||
timeout = 9000,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
code: string;
|
||||||
code: string,
|
data_type?: string;
|
||||||
data_type?: string,
|
save_idb?: boolean;
|
||||||
save_idb?: boolean,
|
timeout?: number;
|
||||||
timeout?: number,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}): Promise<any> {
|
||||||
}
|
if (log_lvl) {
|
||||||
): Promise<any> {
|
console.log(`*** load_ae_obj_by_code__data_store() *** code=${code}`);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`*** load_ae_obj_by_code__data_store() *** code=${code}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!code) {
|
if (!code) {
|
||||||
console.log(`*ae_func* No code provided!`);
|
console.log(`*ae_func* No code provided!`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!api_cfg.account_id) {
|
if (!api_cfg.account_id) {
|
||||||
console.log(`*ae_func* No account_id found in API config!`);
|
console.log(`*ae_func* No account_id found in API config!`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const get_ds_result = await api.get_data_store_obj_w_code({
|
const get_ds_result = await api.get_data_store_obj_w_code({
|
||||||
api_cfg: api_cfg,
|
api_cfg: api_cfg,
|
||||||
data_store_code: code,
|
data_store_code: code,
|
||||||
data_type: data_type,
|
data_type: data_type,
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
log_lvl: log_lvl
|
log_lvl: log_lvl
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!get_ds_result) {
|
if (!get_ds_result) {
|
||||||
console.log('*ae_func* No results returned.');
|
console.log('*ae_func* No results returned.');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*ae_func* Got a result for code ${code}`);
|
console.log(`*ae_func* Got a result for code ${code}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!get_ds_result.data_store_id_random) {
|
if (!get_ds_result.data_store_id_random) {
|
||||||
console.log('*ae_func* Something went wrong? No data store ID found.');
|
console.log('*ae_func* Something went wrong? No data store ID found.');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let return_this: any = null;
|
let return_this: any = null;
|
||||||
|
|
||||||
// Simplified data extraction
|
// Simplified data extraction
|
||||||
if (data_type === 'html') {
|
if (data_type === 'html') {
|
||||||
return_this = get_ds_result.html;
|
return_this = get_ds_result.html;
|
||||||
} else if (data_type === 'json') {
|
} else if (data_type === 'json') {
|
||||||
return_this = get_ds_result.json;
|
return_this = get_ds_result.json;
|
||||||
} else {
|
} else {
|
||||||
return_this = get_ds_result.text;
|
return_this = get_ds_result.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (save_idb && browser) {
|
if (save_idb && browser) {
|
||||||
const key_prefix = 'ae_ds__';
|
const key_prefix = 'ae_ds__';
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*ae_func* localStorage key: ${code}, value:`, get_ds_result);
|
console.log(`*ae_func* localStorage key: ${code}, value:`, get_ds_result);
|
||||||
}
|
}
|
||||||
localStorage.setItem(`${key_prefix}${code}`, JSON.stringify(get_ds_result));
|
localStorage.setItem(`${key_prefix}${code}`, JSON.stringify(get_ds_result));
|
||||||
}
|
}
|
||||||
|
|
||||||
return return_this;
|
return return_this;
|
||||||
|
} catch (error) {
|
||||||
} catch (error) {
|
console.log('*ae_func* No results returned or failed.', error);
|
||||||
console.log('*ae_func* No results returned or failed.', error);
|
return null;
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,357 +1,360 @@
|
|||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
|
|
||||||
import { db_core } from "$lib/ae_core/db_core";
|
import { db_core } from '$lib/ae_core/db_core';
|
||||||
|
|
||||||
let ae_promises: key_val = {};
|
|
||||||
|
|
||||||
|
const ae_promises: key_val = {};
|
||||||
|
|
||||||
// Updated 2024-06-14
|
// Updated 2024-06-14
|
||||||
export async function load_ae_obj_id__hosted_file(
|
export async function load_ae_obj_id__hosted_file({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
hosted_file_id,
|
||||||
hosted_file_id,
|
try_cache = false,
|
||||||
try_cache = false,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
hosted_file_id: string;
|
||||||
hosted_file_id: string,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** load_ae_obj_id__hosted_file() *** hosted_file_id=${hosted_file_id}`);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`*** load_ae_obj_id__hosted_file() *** hosted_file_id=${hosted_file_id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
let params = {};
|
const params = {};
|
||||||
|
|
||||||
ae_promises.load__hosted_file_obj = await api.get_ae_obj_id_crud({
|
ae_promises.load__hosted_file_obj = await api
|
||||||
api_cfg: api_cfg,
|
.get_ae_obj_id_crud({
|
||||||
obj_type: 'hosted_file',
|
api_cfg: api_cfg,
|
||||||
obj_id: hosted_file_id, // NOTE: This is the FQDN, not normally the ID.
|
obj_type: 'hosted_file',
|
||||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
obj_id: hosted_file_id, // NOTE: This is the FQDN, not normally the ID.
|
||||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||||
params: params,
|
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(function (hosted_file_obj_get_result) {
|
})
|
||||||
if (hosted_file_obj_get_result) {
|
.then(function (hosted_file_obj_get_result) {
|
||||||
// This is expecting a list
|
if (hosted_file_obj_get_result) {
|
||||||
db_save_ae_obj_li__hosted_file({obj_type: 'hosted_file', obj_li: [hosted_file_obj_get_result]});
|
// This is expecting a list
|
||||||
return hosted_file_obj_get_result;
|
db_save_ae_obj_li__hosted_file({
|
||||||
} else {
|
obj_type: 'hosted_file',
|
||||||
console.log('No results returned.');
|
obj_li: [hosted_file_obj_get_result]
|
||||||
return null;
|
});
|
||||||
}
|
return hosted_file_obj_get_result;
|
||||||
})
|
} else {
|
||||||
.catch(function (error: any) {
|
console.log('No results returned.');
|
||||||
console.log('No results returned or failed.', error);
|
return null;
|
||||||
});
|
}
|
||||||
|
})
|
||||||
|
.catch(function (error: any) {
|
||||||
|
console.log('No results returned or failed.', error);
|
||||||
|
});
|
||||||
|
|
||||||
return ae_promises.load__hosted_file_obj;
|
return ae_promises.load__hosted_file_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-07-03
|
// Updated 2024-07-03
|
||||||
export async function load_ae_obj_li__hosted_file(
|
export async function load_ae_obj_li__hosted_file({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
for_obj_type,
|
||||||
for_obj_type,
|
for_obj_id,
|
||||||
for_obj_id,
|
enabled = 'enabled',
|
||||||
enabled = 'enabled',
|
hidden = 'not_hidden',
|
||||||
hidden = 'not_hidden',
|
limit = 99,
|
||||||
limit = 99,
|
offset = 0,
|
||||||
offset = 0,
|
order_by_li = { priority: 'DESC', sort: 'DESC', updated_on: 'DESC', created_on: 'DESC' },
|
||||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
params = {},
|
||||||
params = {},
|
try_cache = true,
|
||||||
try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
for_obj_type: string;
|
||||||
for_obj_type: string,
|
for_obj_id: string;
|
||||||
for_obj_id: string,
|
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
|
||||||
enabled?: "enabled" | "all" | "not_enabled" | undefined,
|
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
|
||||||
hidden?: "hidden" | "all" | "not_hidden" | undefined,
|
limit?: number;
|
||||||
limit?: number,
|
offset?: number;
|
||||||
offset?: number,
|
order_by_li?: key_val;
|
||||||
order_by_li?: key_val,
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(
|
||||||
if (log_lvl) {
|
`*** load_ae_obj_li__hosted_file() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`
|
||||||
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:
|
// 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'];
|
const valid_for_obj_types = [
|
||||||
if (!valid_for_obj_types.includes(for_obj_type)) {
|
'account',
|
||||||
console.log(`Invalid for_obj_type: ${for_obj_type}`);
|
'archive',
|
||||||
return [];
|
'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 enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||||
// let hidden: string = (params.qry__hidden ?? 'all'); // all, hidden, not_hidden
|
// let hidden: string = (params.qry__hidden ?? 'all'); // all, hidden, not_hidden
|
||||||
// let limit: number = (params.qry__limit ?? 99); // 99
|
// let limit: number = (params.qry__limit ?? 99); // 99
|
||||||
// let offset: number = (params.qry__offset ?? 0); // 0
|
// let offset: number = (params.qry__offset ?? 0); // 0
|
||||||
|
|
||||||
let params_json: key_val = {};
|
const params_json: key_val = {};
|
||||||
|
|
||||||
// console.log('params_json:', params_json);
|
// console.log('params_json:', params_json);
|
||||||
|
|
||||||
ae_promises.load__hosted_file_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
ae_promises.load__hosted_file_obj_li = await api
|
||||||
api_cfg: api_cfg,
|
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||||
obj_type: 'hosted_file',
|
api_cfg: api_cfg,
|
||||||
for_obj_type: for_obj_type,
|
obj_type: 'hosted_file',
|
||||||
for_obj_id: for_obj_id,
|
for_obj_type: for_obj_type,
|
||||||
use_alt_tbl: false,
|
for_obj_id: for_obj_id,
|
||||||
use_alt_mdl: false,
|
use_alt_tbl: false,
|
||||||
use_alt_exp: false,
|
use_alt_mdl: false,
|
||||||
enabled: enabled,
|
use_alt_exp: false,
|
||||||
hidden: hidden,
|
enabled: enabled,
|
||||||
order_by_li: order_by_li,
|
hidden: hidden,
|
||||||
limit: limit,
|
order_by_li: order_by_li,
|
||||||
offset: offset,
|
limit: limit,
|
||||||
params_json: params_json,
|
offset: offset,
|
||||||
params: params,
|
params_json: params_json,
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(function (hosted_file_obj_li_get_result) {
|
})
|
||||||
if (hosted_file_obj_li_get_result) {
|
.then(function (hosted_file_obj_li_get_result) {
|
||||||
if (try_cache) {
|
if (hosted_file_obj_li_get_result) {
|
||||||
db_save_ae_obj_li__hosted_file({
|
if (try_cache) {
|
||||||
obj_type: 'hosted_file',
|
db_save_ae_obj_li__hosted_file({
|
||||||
obj_li: hosted_file_obj_li_get_result,
|
obj_type: 'hosted_file',
|
||||||
log_lvl: log_lvl
|
obj_li: hosted_file_obj_li_get_result,
|
||||||
});
|
log_lvl: log_lvl
|
||||||
}
|
});
|
||||||
return hosted_file_obj_li_get_result;
|
}
|
||||||
} else {
|
return hosted_file_obj_li_get_result;
|
||||||
console.log('No results returned.');
|
} else {
|
||||||
return [];
|
console.log('No results returned.');
|
||||||
}
|
return [];
|
||||||
})
|
}
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
});
|
console.log('No results returned or failed.', error);
|
||||||
|
});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.load__hosted_file_obj_li:', ae_promises.load__hosted_file_obj_li);
|
console.log('ae_promises.load__hosted_file_obj_li:', ae_promises.load__hosted_file_obj_li);
|
||||||
}
|
}
|
||||||
return ae_promises.load__hosted_file_obj_li;
|
return ae_promises.load__hosted_file_obj_li;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-11-07
|
// Updated 2024-11-07
|
||||||
export async function delete_ae_obj_id__hosted_file(
|
export async function delete_ae_obj_id__hosted_file({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
hosted_file_id,
|
||||||
hosted_file_id,
|
link_to_type, // Ideally this should be required...
|
||||||
link_to_type, // Ideally this should be required...
|
link_to_id, // Ideally this should be required...
|
||||||
link_to_id, // Ideally this should be required...
|
rm_orphan = false,
|
||||||
rm_orphan = false,
|
fake_delete = false, // Fake the delete result to "true"
|
||||||
fake_delete = false, // Fake the delete result to "true"
|
params = {},
|
||||||
params = {},
|
try_cache = true,
|
||||||
try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
hosted_file_id: string;
|
||||||
hosted_file_id: string,
|
link_to_type: string;
|
||||||
link_to_type: string,
|
link_to_id: string;
|
||||||
link_to_id: string,
|
rm_orphan?: boolean;
|
||||||
rm_orphan?: boolean,
|
fake_delete?: boolean;
|
||||||
fake_delete?: boolean,
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** delete_ae_obj_id__hosted_file() *** hosted_file_id=${hosted_file_id}`);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`*** delete_ae_obj_id__hosted_file() *** hosted_file_id=${hosted_file_id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const endpoint = `/hosted_file/${hosted_file_id}`;
|
const endpoint = `/hosted_file/${hosted_file_id}`;
|
||||||
|
|
||||||
params['link_to_type'] = link_to_type;
|
params['link_to_type'] = link_to_type;
|
||||||
params['link_to_id'] = link_to_id;
|
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.
|
params['rm_orphan'] = rm_orphan; // This is what actually allows the hosted file to be deleted from the server.
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`delete_ae_obj_id__hosted_file() params=`, params);
|
console.log(`delete_ae_obj_id__hosted_file() params=`, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fake_delete) {
|
if (fake_delete) {
|
||||||
console.log(`*** FAKE DELETE!!! ***`);
|
console.log(`*** FAKE DELETE!!! ***`);
|
||||||
ae_promises.delete__hosted_file_obj = true;
|
ae_promises.delete__hosted_file_obj = true;
|
||||||
return ae_promises.delete__hosted_file_obj;
|
return ae_promises.delete__hosted_file_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
ae_promises.delete__hosted_file_obj = await api.delete_object({
|
ae_promises.delete__hosted_file_obj = await api
|
||||||
api_cfg: api_cfg,
|
.delete_object({
|
||||||
endpoint: endpoint,
|
api_cfg: api_cfg,
|
||||||
params: params,
|
endpoint: endpoint,
|
||||||
// return_meta: return_meta,
|
params: params,
|
||||||
log_lvl: log_lvl
|
// return_meta: return_meta,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(function (hosted_file_obj_li_get_result) {
|
})
|
||||||
if (hosted_file_obj_li_get_result) {
|
.then(function (hosted_file_obj_li_get_result) {
|
||||||
if (try_cache) {
|
if (hosted_file_obj_li_get_result) {
|
||||||
if (log_lvl) {
|
if (try_cache) {
|
||||||
console.log(`Attempting to remove IDB entry for hosted_file_id=${hosted_file_id}`);
|
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.
|
}
|
||||||
}
|
db_core.file.delete(hosted_file_id); // Delete from the DB no matter what.
|
||||||
return hosted_file_obj_li_get_result;
|
}
|
||||||
} else {
|
return hosted_file_obj_li_get_result;
|
||||||
console.log('No results returned.');
|
} else {
|
||||||
return [];
|
console.log('No results returned.');
|
||||||
}
|
return [];
|
||||||
})
|
}
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
});
|
console.log('No results returned or failed.', error);
|
||||||
|
});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.delete__hosted_file_obj:', ae_promises.delete__hosted_file_obj);
|
console.log('ae_promises.delete__hosted_file_obj:', ae_promises.delete__hosted_file_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 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.
|
// This function will loop through the hosted_file_obj_li and save each one to the DB.
|
||||||
// Updated 2025-01-07
|
// Updated 2025-01-07
|
||||||
export function db_save_ae_obj_li__hosted_file(
|
export function db_save_ae_obj_li__hosted_file({
|
||||||
{
|
obj_type,
|
||||||
obj_type,
|
obj_li,
|
||||||
obj_li,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
obj_type: string;
|
||||||
obj_type: string,
|
obj_li: any;
|
||||||
obj_li: any,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** db_save_ae_obj_li__hosted_file() ***`);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`*** db_save_ae_obj_li__hosted_file() ***`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj_li && obj_li.length) {
|
if (obj_li && obj_li.length) {
|
||||||
obj_li.forEach(async function (obj: any) {
|
obj_li.forEach(async function (obj: any) {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`ae_obj ${obj_type}:`, obj);
|
console.log(`ae_obj ${obj_type}:`, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const id_random = await db_core.file.put({
|
const id_random = await db_core.file.put({
|
||||||
id: obj.hosted_file_id_random,
|
id: obj.hosted_file_id_random,
|
||||||
id_random: obj.hosted_file_id_random,
|
id_random: obj.hosted_file_id_random,
|
||||||
hosted_file_id: obj.hosted_file_id_random,
|
hosted_file_id: obj.hosted_file_id_random,
|
||||||
hosted_file_id_random: 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
|
hash_sha256: obj.hash_sha256, // Renamed with alias in FastAPI model
|
||||||
|
|
||||||
for_type: obj.for_type,
|
for_type: obj.for_type,
|
||||||
for_id: obj.for_id_id_random,
|
for_id: obj.for_id_id_random,
|
||||||
for_id_random: obj.for_id_random,
|
for_id_random: obj.for_id_random,
|
||||||
|
|
||||||
account_id: obj.account_id_random,
|
account_id: obj.account_id_random,
|
||||||
|
|
||||||
filename: obj.filename,
|
filename: obj.filename,
|
||||||
extension: obj.extension,
|
extension: obj.extension,
|
||||||
content_type: obj.content_type,
|
content_type: obj.content_type,
|
||||||
size: obj.size,
|
size: obj.size,
|
||||||
|
|
||||||
enable: obj.enable,
|
enable: obj.enable,
|
||||||
hide: obj.hide,
|
hide: obj.hide,
|
||||||
// priority: obj.priority,
|
// priority: obj.priority,
|
||||||
// sort: obj.sort,
|
// sort: obj.sort,
|
||||||
group: obj.group,
|
group: obj.group,
|
||||||
notes: obj.notes,
|
notes: obj.notes,
|
||||||
created_on: obj.created_on,
|
created_on: obj.created_on,
|
||||||
updated_on: obj.updated_on,
|
updated_on: obj.updated_on,
|
||||||
|
|
||||||
filename_no_ext: obj.filename_no_ext,
|
filename_no_ext: obj.filename_no_ext,
|
||||||
filename_w_ext: obj.filename_w_ext,
|
filename_w_ext: obj.filename_w_ext
|
||||||
});
|
});
|
||||||
// console.log(`Put obj with ID: ${obj.hosted_file_id_random} or ${id_random}`);
|
// console.log(`Put obj with ID: ${obj.hosted_file_id_random} or ${id_random}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let status = `Failed to put ${obj.hosted_file_id_random}: ${error}`;
|
const status = `Failed to put ${obj.hosted_file_id_random}: ${error}`;
|
||||||
console.log(status);
|
console.log(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// const id_random = await db_core.file.put(obj);
|
// const id_random = await db_core.file.put(obj);
|
||||||
// console.log(`Put obj with ID: ${obj.hosted_file_id_random}`);
|
// console.log(`Put obj with ID: ${obj.hosted_file_id_random}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2025-01-07
|
// Updated 2025-01-07
|
||||||
export function db_update_ae_obj_id__hosted_file(
|
export function db_update_ae_obj_id__hosted_file({
|
||||||
{
|
obj_type,
|
||||||
obj_type,
|
obj_id,
|
||||||
obj_id,
|
data_kv,
|
||||||
data_kv,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
obj_type: string;
|
||||||
obj_type: string,
|
obj_id: string;
|
||||||
obj_id: string,
|
data_kv: key_val;
|
||||||
data_kv: key_val,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** db_update_ae_obj_id__hosted_file() ***`);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`*** db_update_ae_obj_id__hosted_file() ***`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj_id) {
|
if (obj_id) {
|
||||||
console.log(`ae_obj ${obj_type}:`, obj_id);
|
console.log(`ae_obj ${obj_type}:`, obj_id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// db_core.file.update(obj_id, data_kv);
|
// db_core.file.update(obj_id, data_kv);
|
||||||
db_core.file.update(obj_id,
|
db_core.file.update(obj_id, {
|
||||||
{
|
// for_type: data_kv.for_type,
|
||||||
// for_type: data_kv.for_type,
|
// for_id: data_kv.for_id_id_random,
|
||||||
// for_id: data_kv.for_id_id_random,
|
// for_id_random: data_kv.for_id_random,
|
||||||
// for_id_random: data_kv.for_id_random,
|
|
||||||
|
|
||||||
filename: data_kv.filename,
|
filename: data_kv.filename,
|
||||||
extension: data_kv.extension,
|
extension: data_kv.extension,
|
||||||
content_type: data_kv.content_type,
|
content_type: data_kv.content_type,
|
||||||
size: data_kv.size,
|
size: data_kv.size,
|
||||||
|
|
||||||
// enable: data_kv.enable,
|
// enable: data_kv.enable,
|
||||||
// hide: data_kv.hide,
|
// hide: data_kv.hide,
|
||||||
// priority: data_kv.priority,
|
// priority: data_kv.priority,
|
||||||
// sort: data_kv.sort,
|
// sort: data_kv.sort,
|
||||||
// group: data_kv.group,
|
// group: data_kv.group,
|
||||||
// notes: data_kv.notes,
|
// notes: data_kv.notes,
|
||||||
// created_on: data_kv.created_on,
|
// created_on: data_kv.created_on,
|
||||||
// updated_on: data_kv.updated_on,
|
// updated_on: data_kv.updated_on,
|
||||||
|
|
||||||
filename_no_ext: data_kv.filename_no_ext,
|
filename_no_ext: data_kv.filename_no_ext,
|
||||||
filename_w_ext: data_kv.filename_w_ext,
|
filename_w_ext: data_kv.filename_w_ext
|
||||||
// hosted_file_content_type: data_kv.hosted_file_content_type,
|
// hosted_file_content_type: data_kv.hosted_file_content_type,
|
||||||
// file_size: data_kv.file_size,
|
// file_size: data_kv.file_size,
|
||||||
// hosted_file_size: data_kv.hosted_file_size,
|
// hosted_file_size: data_kv.hosted_file_size,
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
console.log(`Update obj with ID: ${obj_id}`);
|
console.log(`Update obj with ID: ${obj_id}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let status = `Failed to update ${obj_id}: ${error}`;
|
const status = `Failed to update ${obj_id}: ${error}`;
|
||||||
console.log(status);
|
console.log(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// const id_random = await db_core.file.put(obj);
|
// const id_random = await db_core.file.put(obj);
|
||||||
// console.log(`Put obj with ID: ${data_kv.hosted_file_id_random}`);
|
// console.log(`Put obj with ID: ${data_kv.hosted_file_id_random}`);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,11 @@ import type { Dexie, Table } from 'dexie';
|
|||||||
* @param log_lvl The logging level.
|
* @param log_lvl The logging level.
|
||||||
* @returns The found ID, or undefined if no ID could be found.
|
* @returns The found ID, or undefined if no ID could be found.
|
||||||
*/
|
*/
|
||||||
function find_object_id(obj: any, table_name: string, log_lvl: number): string | number | undefined {
|
function find_object_id(
|
||||||
|
obj: any,
|
||||||
|
table_name: string,
|
||||||
|
log_lvl: number
|
||||||
|
): string | number | undefined {
|
||||||
const potential_keys = ['id', `${table_name}_id`, `${table_name}_id_random`];
|
const potential_keys = ['id', `${table_name}_id`, `${table_name}_id_random`];
|
||||||
|
|
||||||
for (const key of potential_keys) {
|
for (const key of potential_keys) {
|
||||||
@@ -112,4 +116,4 @@ export async function db_save_ae_obj_li__ae_obj<T extends Record<string, any>>({
|
|||||||
// Re-throw the error to let the caller handle it.
|
// Re-throw the error to let the caller handle it.
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,146 +1,149 @@
|
|||||||
import QRCode from 'qrcode'
|
import QRCode from 'qrcode';
|
||||||
|
|
||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
|
|
||||||
import { db_core } from "$lib/ae_core/db_core";
|
import { db_core } from '$lib/ae_core/db_core';
|
||||||
|
|
||||||
let ae_promises: key_val = {};
|
const ae_promises: key_val = {};
|
||||||
|
|
||||||
// I recently made significant updates to this with the help of Copilot. I think it is correct.
|
// I recently made significant updates to this with the help of Copilot. I think it is correct.
|
||||||
// Updated 2025-10-03
|
// Updated 2025-10-03
|
||||||
export async function generate_qr_code(
|
export async function generate_qr_code({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
account_id,
|
||||||
account_id,
|
qr_type, // mecard, obj, str, vcard
|
||||||
qr_type, // mecard, obj, str, vcard
|
qr_id, // This is essentially the filename it can be found at /qr/{account_id}/{qr_id}
|
||||||
qr_id, // This is essentially the filename it can be found at /qr/{account_id}/{qr_id}
|
qr_data, // vcard fields:
|
||||||
qr_data, // vcard fields:
|
obj_type,
|
||||||
obj_type,
|
obj_id,
|
||||||
obj_id,
|
str, // For encoding a string (like a URL) into a QR code.
|
||||||
str, // For encoding a string (like a URL) into a QR code.
|
return_blob = true, // blob or url?
|
||||||
return_blob = true, // blob or url?
|
try_cache = false,
|
||||||
try_cache = false,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
account_id: string;
|
||||||
account_id: string,
|
qr_type: string;
|
||||||
qr_type: string,
|
qr_id: string;
|
||||||
qr_id: string,
|
qr_data?: any;
|
||||||
qr_data?: any,
|
obj_type?: string;
|
||||||
obj_type?: string,
|
obj_id?: string;
|
||||||
obj_id?: string,
|
str?: string;
|
||||||
str?: string,
|
return_blob?: boolean;
|
||||||
return_blob?: boolean,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** generate_qr_code() *** qr_id=${qr_id}`);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`*** generate_qr_code() *** qr_id=${qr_id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
let endpoint = `/qr/${account_id}/${qr_id}`;
|
const endpoint = `/qr/${account_id}/${qr_id}`;
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Endpoint', endpoint);
|
console.log('Endpoint', endpoint);
|
||||||
}
|
}
|
||||||
let params: key_val = {
|
const params: key_val = {
|
||||||
'regen': true, // Regenerate the file even if nothing has changed.
|
regen: true, // Regenerate the file even if nothing has changed.
|
||||||
'return_file': return_blob,
|
return_file: return_blob,
|
||||||
'qr_type': qr_type, // mecard, obj, vcard
|
qr_type: qr_type, // mecard, obj, vcard
|
||||||
'qr_send': return_blob
|
qr_send: return_blob
|
||||||
};
|
};
|
||||||
|
|
||||||
if (qr_type == 'vcard') {
|
if (qr_type == 'vcard') {
|
||||||
if (qr_data.informal_name) {
|
if (qr_data.informal_name) {
|
||||||
params['n'] = `${qr_data.family_name};${qr_data.given_name};${qr_data.informal_name}`;
|
params['n'] = `${qr_data.family_name};${qr_data.given_name};${qr_data.informal_name}`;
|
||||||
} else {
|
} else {
|
||||||
params['n'] = `${qr_data.family_name};${qr_data.given_name}`;
|
params['n'] = `${qr_data.family_name};${qr_data.given_name}`;
|
||||||
}
|
}
|
||||||
params['fn'] = qr_data.full_name_override;
|
params['fn'] = qr_data.full_name_override;
|
||||||
if (qr_data.affiliations) { params['org'] = qr_data.affiliations; }
|
if (qr_data.affiliations) {
|
||||||
params['email'] = qr_data.email;
|
params['org'] = qr_data.affiliations;
|
||||||
if (qr_data.phone) { params['tel'] = qr_data.phone; }
|
}
|
||||||
params['adr'] = qr_data.location_override;
|
params['email'] = qr_data.email;
|
||||||
if (qr_data.address_line_1) { params['adr_str'] = qr_data.address_line_1; }
|
if (qr_data.phone) {
|
||||||
params['adr_loc'] = qr_data.city;
|
params['tel'] = qr_data.phone;
|
||||||
params['adr_reg'] = qr_data.state_province;
|
}
|
||||||
params['adr_postal'] = qr_data.postal_code;
|
params['adr'] = qr_data.location_override;
|
||||||
params['adr_country'] = qr_data.country;
|
if (qr_data.address_line_1) {
|
||||||
} else if (qr_type == 'obj') {
|
params['adr_str'] = qr_data.address_line_1;
|
||||||
params['obj_type'] = obj_type;
|
}
|
||||||
params['obj_id'] = obj_id;
|
params['adr_loc'] = qr_data.city;
|
||||||
} else if (qr_type == 'str') {
|
params['adr_reg'] = qr_data.state_province;
|
||||||
params['str'] = str;
|
params['adr_postal'] = qr_data.postal_code;
|
||||||
}
|
params['adr_country'] = qr_data.country;
|
||||||
|
} else if (qr_type == 'obj') {
|
||||||
|
params['obj_type'] = obj_type;
|
||||||
|
params['obj_id'] = obj_id;
|
||||||
|
} else if (qr_type == 'str') {
|
||||||
|
params['str'] = str;
|
||||||
|
}
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Params', params);
|
console.log('Params', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
let filename = null;
|
const filename = null;
|
||||||
|
|
||||||
// Await the API call
|
// Await the API call
|
||||||
ae_promises.generate_qr_code = await api.get_object({
|
ae_promises.generate_qr_code = await api.get_object({
|
||||||
api_cfg: api_cfg,
|
api_cfg: api_cfg,
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
params: params,
|
params: params,
|
||||||
return_blob: return_blob,
|
return_blob: return_blob,
|
||||||
filename: filename,
|
filename: filename,
|
||||||
auto_download: false,
|
auto_download: false,
|
||||||
log_lvl: log_lvl
|
log_lvl: log_lvl
|
||||||
});
|
});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('QR code API response:', ae_promises.generate_qr_code);
|
console.log('QR code API response:', ae_promises.generate_qr_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If return_blob is true, ensure we return an object URL for use in <img src=...>
|
// If return_blob is true, ensure we return an object URL for use in <img src=...>
|
||||||
if (return_blob) {
|
if (return_blob) {
|
||||||
let data = ae_promises.generate_qr_code.data ?? ae_promises.generate_qr_code;
|
const data = ae_promises.generate_qr_code.data ?? ae_promises.generate_qr_code;
|
||||||
|
|
||||||
// If already a Blob, use it directly
|
// If already a Blob, use it directly
|
||||||
if (data instanceof Blob) {
|
if (data instanceof Blob) {
|
||||||
return URL.createObjectURL(data);
|
return URL.createObjectURL(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's a Response (from fetch), convert to Blob
|
// If it's a Response (from fetch), convert to Blob
|
||||||
if (data instanceof Response) {
|
if (data instanceof Response) {
|
||||||
const blob = await data.blob();
|
const blob = await data.blob();
|
||||||
return URL.createObjectURL(blob);
|
return URL.createObjectURL(blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's an ArrayBuffer or Uint8Array, convert to Blob
|
// If it's an ArrayBuffer or Uint8Array, convert to Blob
|
||||||
if (data instanceof ArrayBuffer || data instanceof Uint8Array) {
|
if (data instanceof ArrayBuffer || data instanceof Uint8Array) {
|
||||||
const blob = new Blob([data], { type: "image/png" });
|
const blob = new Blob([data], { type: 'image/png' });
|
||||||
return URL.createObjectURL(blob);
|
return URL.createObjectURL(blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's a base64 string, return as data URL
|
// If it's a base64 string, return as data URL
|
||||||
if (typeof data === "string" && data.startsWith("data:image")) {
|
if (typeof data === 'string' && data.startsWith('data:image')) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's a raw string (base64), convert to data URL
|
// If it's a raw string (base64), convert to data URL
|
||||||
if (typeof data === "string") {
|
if (typeof data === 'string') {
|
||||||
return `data:image/png;base64,${data}`;
|
return `data:image/png;base64,${data}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback: try to create a Blob from whatever is left
|
// Fallback: try to create a Blob from whatever is left
|
||||||
try {
|
try {
|
||||||
const blob = new Blob([data], { type: "image/png" });
|
const blob = new Blob([data], { type: 'image/png' });
|
||||||
return URL.createObjectURL(blob);
|
return URL.createObjectURL(blob);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (log_lvl) console.error("Could not create QR code image blob:", e, data);
|
if (log_lvl) console.error('Could not create QR code image blob:', e, data);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not returning a blob, return the raw API response
|
// If not returning a blob, return the raw API response
|
||||||
return ae_promises.generate_qr_code;
|
return ae_promises.generate_qr_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2025-10-09
|
// Updated 2025-10-09
|
||||||
/**
|
/**
|
||||||
* Generates a QR code image as a Base64 data URL based on provided parameters.
|
* Generates a QR code image as a Base64 data URL based on provided parameters.
|
||||||
@@ -156,85 +159,105 @@ export async function generate_qr_code(
|
|||||||
* @throws {Error} If the qr_type is unknown or data is missing.
|
* @throws {Error} If the qr_type is unknown or data is missing.
|
||||||
*/
|
*/
|
||||||
export async function js_generate_qr_code(qr_type, params = {}) {
|
export async function js_generate_qr_code(qr_type, params = {}) {
|
||||||
const {
|
const {
|
||||||
n = '', fn = '', org = '', url = '', email = '', tel = '',
|
n = '',
|
||||||
adr_poa = '', adr_ext = '', adr_str = '', adr_loc = '', adr_reg = '', adr_postal = '', adr_country = '',
|
fn = '',
|
||||||
obj_type, obj_id, key, val, js, str
|
org = '',
|
||||||
} = params;
|
url = '',
|
||||||
|
email = '',
|
||||||
|
tel = '',
|
||||||
|
adr_poa = '',
|
||||||
|
adr_ext = '',
|
||||||
|
adr_str = '',
|
||||||
|
adr_loc = '',
|
||||||
|
adr_reg = '',
|
||||||
|
adr_postal = '',
|
||||||
|
adr_country = '',
|
||||||
|
obj_type,
|
||||||
|
obj_id,
|
||||||
|
key,
|
||||||
|
val,
|
||||||
|
js,
|
||||||
|
str
|
||||||
|
} = params;
|
||||||
|
|
||||||
console.log(`*** js_generate_qr_code() *** qr_type=${qr_type}`, params);
|
console.log(`*** js_generate_qr_code() *** qr_type=${qr_type}`, params);
|
||||||
|
|
||||||
let qr_data = null;
|
let qr_data = null;
|
||||||
|
|
||||||
// --- 1. Replicate Data Formatting Logic ---
|
// --- 1. Replicate Data Formatting Logic ---
|
||||||
switch (qr_type) {
|
switch (qr_type) {
|
||||||
case 'mecard':
|
case 'mecard':
|
||||||
// Format: MECARD:N:name;EMAIL:email;ADR:address;;
|
// Format: MECARD:N:name;EMAIL:email;ADR:address;;
|
||||||
// Note: The original Python code had adr, but we'll use n and email as a minimum.
|
// Note: The original Python code had adr, but we'll use n and email as a minimum.
|
||||||
qr_data = `MECARD:N:${n};EMAIL:${email};;`;
|
qr_data = `MECARD:N:${n};EMAIL:${email};;`;
|
||||||
// You can enhance this with other MeCard fields if needed.
|
// You can enhance this with other MeCard fields if needed.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'vcard':
|
case 'vcard':
|
||||||
// Format: BEGIN:VCARD...END:VCARD
|
// Format: BEGIN:VCARD...END:VCARD
|
||||||
qr_data = `BEGIN:VCARD\nVERSION:3.0\nN:${n}\nFN:${fn}\nORG:${org}\nEMAIL:${email}\n`;
|
qr_data = `BEGIN:VCARD\nVERSION:3.0\nN:${n}\nFN:${fn}\nORG:${org}\nEMAIL:${email}\n`;
|
||||||
|
|
||||||
if (url) { qr_data += `URL:${url}\n`; }
|
if (url) {
|
||||||
if (tel) { qr_data += `TEL:${tel}\n`; }
|
qr_data += `URL:${url}\n`;
|
||||||
if (adr_loc) {
|
}
|
||||||
// ADR format: TYPE=postal:Po box;Ext;Street;Locality;Region;Postal code;Country
|
if (tel) {
|
||||||
qr_data += `ADR:${adr_poa};${adr_ext};${adr_str};${adr_loc};${adr_reg};${adr_postal};${adr_country}\n`;
|
qr_data += `TEL:${tel}\n`;
|
||||||
}
|
}
|
||||||
qrData += 'END:VCARD';
|
if (adr_loc) {
|
||||||
break;
|
// ADR format: TYPE=postal:Po box;Ext;Street;Locality;Region;Postal code;Country
|
||||||
|
qr_data += `ADR:${adr_poa};${adr_ext};${adr_str};${adr_loc};${adr_reg};${adr_postal};${adr_country}\n`;
|
||||||
|
}
|
||||||
|
qrData += 'END:VCARD';
|
||||||
|
break;
|
||||||
|
|
||||||
case 'obj':
|
case 'obj':
|
||||||
// Custom format: OBJ:ot:obj_type,oi:obj_id
|
// Custom format: OBJ:ot:obj_type,oi:obj_id
|
||||||
if (!obj_type || !obj_id) throw new Error('Missing obj_type or obj_id for type "obj".');
|
if (!obj_type || !obj_id) throw new Error('Missing obj_type or obj_id for type "obj".');
|
||||||
qr_data = `OBJ:ot:${obj_type},oi:${obj_id}`;
|
qr_data = `OBJ:ot:${obj_type},oi:${obj_id}`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'kv':
|
case 'kv':
|
||||||
// Custom format: KV:k:"key",v:"val"
|
// Custom format: KV:k:"key",v:"val"
|
||||||
if (!key || !val) throw new Error('Missing key or val for type "kv".');
|
if (!key || !val) throw new Error('Missing key or val for type "kv".');
|
||||||
qr_data = `KV:k:"${key}",v:"${val}"`;
|
qr_data = `KV:k:"${key}",v:"${val}"`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'js':
|
case 'js':
|
||||||
// Assumes 'js' is a stringified JSON object
|
// Assumes 'js' is a stringified JSON object
|
||||||
if (!js) throw new Error('Missing js string for type "js".');
|
if (!js) throw new Error('Missing js string for type "js".');
|
||||||
qr_data = `JS:${js}`;
|
qr_data = `JS:${js}`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'str':
|
case 'str':
|
||||||
// Raw string data
|
// Raw string data
|
||||||
if (!str) throw new Error('Missing raw string data for type "str".');
|
if (!str) throw new Error('Missing raw string data for type "str".');
|
||||||
qr_data = str;
|
qr_data = str;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unknown QR type: ${qr_type}`);
|
throw new Error(`Unknown QR type: ${qr_type}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!qr_data) {
|
if (!qr_data) {
|
||||||
throw new Error('Failed to create QR code data string.');
|
throw new Error('Failed to create QR code data string.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- 2. Generate QR Code Image ---
|
// --- 2. Generate QR Code Image ---
|
||||||
try {
|
try {
|
||||||
// Options match the Python 'qrcode' library defaults closely:
|
// Options match the Python 'qrcode' library defaults closely:
|
||||||
// error_correction = qrcode.constants.ERROR_CORRECT_M
|
// error_correction = qrcode.constants.ERROR_CORRECT_M
|
||||||
// box_size = 10, border = 1
|
// box_size = 10, border = 1
|
||||||
const data_url = await QRCode.toDataURL(qr_data, {
|
const data_url = await QRCode.toDataURL(qr_data, {
|
||||||
errorCorrectionLevel: 'M',
|
errorCorrectionLevel: 'M',
|
||||||
margin: 1, // Corresponds to border
|
margin: 1, // Corresponds to border
|
||||||
scale: 10, // Corresponds to box_size
|
scale: 10, // Corresponds to box_size
|
||||||
type: 'image/png',
|
type: 'image/png'
|
||||||
});
|
});
|
||||||
console.log('Generated QR code data URL:', data_url);
|
console.log('Generated QR code data URL:', data_url);
|
||||||
return data_url;
|
return data_url;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error generating QR code:', error);
|
console.error('Error generating QR code:', error);
|
||||||
throw new Error('Could not generate QR code image.');
|
throw new Error('Could not generate QR code image.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,50 +1,50 @@
|
|||||||
export interface Site {
|
export interface Site {
|
||||||
id: string;
|
id: string;
|
||||||
// id_random: string;
|
// id_random: string;
|
||||||
site_id: string;
|
site_id: string;
|
||||||
site_id_random?: string;
|
site_id_random?: string;
|
||||||
|
|
||||||
code?: string;
|
code?: string;
|
||||||
|
|
||||||
account_id: string;
|
account_id: string;
|
||||||
account_id_random?: string;
|
account_id_random?: string;
|
||||||
|
|
||||||
name: string;
|
name: string;
|
||||||
description?: null|string;
|
description?: null | string;
|
||||||
|
|
||||||
restrict_access?: null|boolean;
|
restrict_access?: null | boolean;
|
||||||
access_key?: null|string;
|
access_key?: null | string;
|
||||||
access_code_kv_json?: null|string;
|
access_code_kv_json?: null | string;
|
||||||
|
|
||||||
logo_path?: null|string;
|
logo_path?: null | string;
|
||||||
logo_bg_color?: null|string; // Not really used currently.
|
logo_bg_color?: null | string; // Not really used currently.
|
||||||
// background_image_path?: null|string; // Legacy field
|
// background_image_path?: null|string; // Legacy field
|
||||||
// background_bg_color?: null|string; // Legacy field
|
// background_bg_color?: null|string; // Legacy field
|
||||||
title?: null|string;
|
title?: null | string;
|
||||||
|
|
||||||
// header_html?: null|string; // Legacy field
|
// header_html?: null|string; // Legacy field
|
||||||
// header_css?: null|string; // Legacy field
|
// header_css?: null|string; // Legacy field
|
||||||
// header_image_path?: null|string; // Legacy field
|
// header_image_path?: null|string; // Legacy field
|
||||||
// header_image_bg_color?: null|string; // Legacy field
|
// header_image_bg_color?: null|string; // Legacy field
|
||||||
// body_html?: null|string; // Legacy field
|
// body_html?: null|string; // Legacy field
|
||||||
tagline?: null|string;
|
tagline?: null | string;
|
||||||
// site_header_h1?: null|string; // Legacy field
|
// site_header_h1?: null|string; // Legacy field
|
||||||
// site_header_h2?: null|string; // Legacy field
|
// site_header_h2?: null|string; // Legacy field
|
||||||
style_href?: null|string; // Legacy field
|
style_href?: null | string; // Legacy field
|
||||||
// script_src?: null|string; // Legacy field
|
// script_src?: null|string; // Legacy field
|
||||||
google_tracking_id?: null|string;
|
google_tracking_id?: null | string;
|
||||||
|
|
||||||
cfg_json?: null|string; // key value config json
|
cfg_json?: null | string; // key value config json
|
||||||
|
|
||||||
enable: null|boolean;
|
enable: null | boolean;
|
||||||
enable_from?: null|Date;
|
enable_from?: null | Date;
|
||||||
enable_to?: null|Date;
|
enable_to?: null | Date;
|
||||||
|
|
||||||
hide?: null|boolean;
|
hide?: null | boolean;
|
||||||
priority?: null|boolean
|
priority?: null | boolean;
|
||||||
sort?: null|number;
|
sort?: null | number;
|
||||||
group?: null|string;
|
group?: null | string;
|
||||||
notes?: null|string;
|
notes?: null | string;
|
||||||
created_on: Date;
|
created_on: Date;
|
||||||
updated_on?: null|Date;
|
updated_on?: null | Date;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,76 +1,75 @@
|
|||||||
export interface Site_Domain {
|
export interface Site_Domain {
|
||||||
id: string;
|
id: string;
|
||||||
// id_random: string;
|
// id_random: string;
|
||||||
site_id: string;
|
site_id: string;
|
||||||
site_id_random?: string;
|
site_id_random?: string;
|
||||||
|
|
||||||
fqdn: string;
|
fqdn: string;
|
||||||
access_key?: null|string;
|
access_key?: null | string;
|
||||||
required_referrer?: null|string;
|
required_referrer?: null | string;
|
||||||
valid_for?: null|number; // In hours
|
valid_for?: null | number; // In hours
|
||||||
|
|
||||||
enable: null|boolean;
|
enable: null | boolean;
|
||||||
hide?: null|boolean;
|
hide?: null | boolean;
|
||||||
priority?: null|boolean
|
priority?: null | boolean;
|
||||||
sort?: null|number;
|
sort?: null | number;
|
||||||
group?: null|string;
|
group?: null | string;
|
||||||
notes?: null|string;
|
notes?: null | string;
|
||||||
created_on: Date;
|
created_on: Date;
|
||||||
updated_on?: null|Date;
|
updated_on?: null | Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches a site_domain object by its Fully Qualified Domain Name (FQDN).
|
* Fetches a site_domain object by its Fully Qualified Domain Name (FQDN).
|
||||||
*
|
*
|
||||||
* @param api_cfg - The API configuration object.
|
* @param api_cfg - The API configuration object.
|
||||||
* @param fqdn - The FQDN of the site domain to fetch.
|
* @param fqdn - The FQDN of the site domain to fetch.
|
||||||
* @param timeout - The request timeout in milliseconds.
|
* @param timeout - The request timeout in milliseconds.
|
||||||
* @param log_lvl - The logging level.
|
* @param log_lvl - The logging level.
|
||||||
* @returns The site domain object or null if not found.
|
* @returns The site domain object or null if not found.
|
||||||
*/
|
*/
|
||||||
export async function load_ae_obj_by_fqdn__site_domain(
|
export async function load_ae_obj_by_fqdn__site_domain({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
fqdn,
|
||||||
fqdn,
|
timeout = 7000,
|
||||||
timeout = 7000,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
fqdn: string;
|
||||||
fqdn: string,
|
timeout?: number;
|
||||||
timeout?: number,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}): Promise<any> {
|
||||||
}
|
if (log_lvl) {
|
||||||
): Promise<any> {
|
console.log(
|
||||||
if (log_lvl) {
|
`*** load_ae_obj_by_fqdn__site_domain() *** api.base_url=${api_cfg.base_url}, fqdn=${fqdn}, timeout=${timeout}`
|
||||||
console.log(`*** load_ae_obj_by_fqdn__site_domain() *** api.base_url=${api_cfg.base_url}, fqdn=${fqdn}, timeout=${timeout}`);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = {};
|
const params = {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const site_domain_obj = await api.get_ae_obj_id_crud({
|
const site_domain_obj = await api.get_ae_obj_id_crud({
|
||||||
api_cfg: api_cfg,
|
api_cfg: api_cfg,
|
||||||
no_account_id: true, // This seems to be a special case for this endpoint
|
no_account_id: true, // This seems to be a special case for this endpoint
|
||||||
obj_type: 'site_domain',
|
obj_type: 'site_domain',
|
||||||
obj_id: fqdn, // NOTE: This is the FQDN, not the ID.
|
obj_id: fqdn, // NOTE: This is the FQDN, not the ID.
|
||||||
use_alt_table: true,
|
use_alt_table: true,
|
||||||
use_alt_base: true,
|
use_alt_base: true,
|
||||||
params: params,
|
params: params,
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
log_lvl: log_lvl
|
log_lvl: log_lvl
|
||||||
});
|
});
|
||||||
|
|
||||||
if (site_domain_obj) {
|
if (site_domain_obj) {
|
||||||
return site_domain_obj;
|
return site_domain_obj;
|
||||||
} else {
|
} else {
|
||||||
console.log('No results returned.');
|
console.log('No results returned.');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('No results returned or failed.', error);
|
console.log('No results returned or failed.', error);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,74 +1,72 @@
|
|||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
|
|
||||||
import { db_core } from "$lib/ae_core/db_core";
|
import { db_core } from '$lib/ae_core/db_core';
|
||||||
|
|
||||||
let ae_promises: key_val = {};
|
|
||||||
|
|
||||||
|
const ae_promises: key_val = {};
|
||||||
|
|
||||||
// Updated 2024-10-14
|
// Updated 2024-10-14
|
||||||
export async function load_ae_obj_li__time_zone(
|
export async function load_ae_obj_li__time_zone({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
// account_id,
|
||||||
// account_id,
|
enabled = 'enabled',
|
||||||
enabled = 'enabled',
|
hidden = 'not_hidden',
|
||||||
hidden = 'not_hidden',
|
limit = 99,
|
||||||
limit = 99,
|
offset = 0,
|
||||||
offset = 0,
|
// order_by_li = {'priority': 'DESC', 'group': 'ASC', 'sort': 'DESC', 'name': 'ASC'},
|
||||||
// order_by_li = {'priority': 'DESC', 'group': 'ASC', 'sort': 'DESC', 'name': 'ASC'},
|
order_by_li = { priority: 'DESC', sort: 'DESC', name: 'ASC' },
|
||||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC'},
|
params = {},
|
||||||
params = {},
|
try_cache = true,
|
||||||
try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
// account_id: string,
|
||||||
// account_id: string,
|
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
|
||||||
enabled?: "enabled" | "all" | "not_enabled" | undefined,
|
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
|
||||||
hidden?: "hidden" | "all" | "not_hidden" | undefined,
|
limit?: number;
|
||||||
limit?: number,
|
offset?: number;
|
||||||
offset?: number,
|
order_by_li?: key_val;
|
||||||
order_by_li?: key_val,
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** load_ae_obj_li__time_zone() ***`);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`*** load_ae_obj_li__time_zone() ***`);
|
|
||||||
}
|
|
||||||
|
|
||||||
let params_json: key_val = {};
|
const params_json: key_val = {};
|
||||||
|
|
||||||
// console.log('params_json:', params_json);
|
// console.log('params_json:', params_json);
|
||||||
|
|
||||||
ae_promises.load__time_zone_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
ae_promises.load__time_zone_li = await api
|
||||||
api_cfg: api_cfg,
|
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||||
obj_type: 'lu',
|
api_cfg: api_cfg,
|
||||||
for_obj_type: 'time_zone',
|
obj_type: 'lu',
|
||||||
// for_obj_id: account_id,
|
for_obj_type: 'time_zone',
|
||||||
use_alt_tbl: true, // NOTE: Using this with the time zones to use the view named "v_lu_time_zone_cust"
|
// for_obj_id: account_id,
|
||||||
use_alt_mdl: false,
|
use_alt_tbl: true, // NOTE: Using this with the time zones to use the view named "v_lu_time_zone_cust"
|
||||||
enabled: enabled,
|
use_alt_mdl: false,
|
||||||
hidden: hidden,
|
enabled: enabled,
|
||||||
order_by_li: order_by_li,
|
hidden: hidden,
|
||||||
limit: limit,
|
order_by_li: order_by_li,
|
||||||
offset: offset,
|
limit: limit,
|
||||||
params_json: params_json,
|
offset: offset,
|
||||||
params: params,
|
params_json: params_json,
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(function (time_zone_li_get_result) {
|
})
|
||||||
if (time_zone_li_get_result) {
|
.then(function (time_zone_li_get_result) {
|
||||||
// handle_db_save_ae_obj_li__time_zone({obj_type: 'time_zone', obj_li: time_zone_li_get_result});
|
if (time_zone_li_get_result) {
|
||||||
return time_zone_li_get_result;
|
// handle_db_save_ae_obj_li__time_zone({obj_type: 'time_zone', obj_li: time_zone_li_get_result});
|
||||||
} else {
|
return time_zone_li_get_result;
|
||||||
return [];
|
} else {
|
||||||
}
|
return [];
|
||||||
})
|
}
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
});
|
console.log('No results returned or failed.', error);
|
||||||
|
});
|
||||||
|
|
||||||
console.log('ae_promises.load__time_zone_li:', ae_promises.load__time_zone_li);
|
console.log('ae_promises.load__time_zone_li:', ae_promises.load__time_zone_li);
|
||||||
return ae_promises.load__time_zone_li;
|
return ae_promises.load__time_zone_li;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,339 +1,335 @@
|
|||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
|
|
||||||
import { db_core } from "$lib/ae_core/db_core";
|
import { db_core } from '$lib/ae_core/db_core';
|
||||||
|
|
||||||
let ae_promises: key_val = {};
|
|
||||||
|
|
||||||
|
const ae_promises: key_val = {};
|
||||||
|
|
||||||
// Updated 2025-04-04
|
// Updated 2025-04-04
|
||||||
export async function auth_ae_obj__username_password(
|
export async function auth_ae_obj__username_password({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
account_id,
|
||||||
account_id,
|
null_account_id = false,
|
||||||
null_account_id = false,
|
username,
|
||||||
username,
|
password,
|
||||||
password,
|
params = {},
|
||||||
params = {},
|
try_cache = true,
|
||||||
try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
account_id: string;
|
||||||
account_id: string,
|
null_account_id?: boolean;
|
||||||
null_account_id?: boolean,
|
username: string;
|
||||||
username: string,
|
password: string;
|
||||||
password: string,
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(
|
||||||
if (log_lvl) {
|
`*** auth_ae_obj__username_password() *** account_id=${account_id} username=${username} password=${password}`
|
||||||
console.log(`*** auth_ae_obj__username_password() *** account_id=${account_id} username=${username} password=${password}`);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let endpoint = '/user/authenticate';
|
const endpoint = '/user/authenticate';
|
||||||
|
|
||||||
if (null_account_id) {
|
if (null_account_id) {
|
||||||
params['null_account_id'] = true;
|
params['null_account_id'] = true;
|
||||||
}
|
}
|
||||||
params['username'] = username; // Required
|
params['username'] = username; // Required
|
||||||
params['password'] = password; // Required
|
params['password'] = password; // Required
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log(`auth_ae_obj__username_password() - params:`, params);
|
console.log(`auth_ae_obj__username_password() - params:`, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
ae_promises.auth__username_password = await api.get_object({
|
ae_promises.auth__username_password = await api
|
||||||
api_cfg: api_cfg,
|
.get_object({
|
||||||
endpoint: endpoint,
|
api_cfg: api_cfg,
|
||||||
params: params,
|
endpoint: endpoint,
|
||||||
// data: {},
|
params: params,
|
||||||
log_lvl: log_lvl
|
// data: {},
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(async function (user_obj_get_result) {
|
})
|
||||||
if (user_obj_get_result) {
|
.then(async function (user_obj_get_result) {
|
||||||
// if (try_cache) {
|
if (user_obj_get_result) {
|
||||||
// // This is expecting a list
|
// if (try_cache) {
|
||||||
// db_save_ae_obj_li__user({
|
// // This is expecting a list
|
||||||
// obj_type: 'user',
|
// db_save_ae_obj_li__user({
|
||||||
// obj_li: [user_obj_get_result],
|
// obj_type: 'user',
|
||||||
// log_lvl: log_lvl
|
// obj_li: [user_obj_get_result],
|
||||||
// });
|
// log_lvl: log_lvl
|
||||||
// }
|
// });
|
||||||
return user_obj_get_result;
|
// }
|
||||||
} else {
|
return user_obj_get_result;
|
||||||
console.log('No results returned.');
|
} else {
|
||||||
return null;
|
console.log('No results returned.');
|
||||||
}
|
return null;
|
||||||
})
|
}
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
});
|
console.log('No results returned or failed.', error);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (log_lvl) {
|
||||||
|
console.log('ae_promises.auth__username_password:', ae_promises.auth__username_password);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log('ae_promises.auth__username_password:', ae_promises.auth__username_password);
|
return ae_promises.auth__username_password;
|
||||||
}
|
|
||||||
return ae_promises.auth__username_password;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2025-04-04
|
// Updated 2025-04-04
|
||||||
export async function auth_ae_obj__user_id_user_auth_key(
|
export async function auth_ae_obj__user_id_user_auth_key({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
account_id,
|
||||||
account_id,
|
user_id,
|
||||||
user_id,
|
user_auth_key,
|
||||||
user_auth_key,
|
params = {},
|
||||||
params = {},
|
try_cache = true,
|
||||||
try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
account_id: string;
|
||||||
account_id: string,
|
user_id: string;
|
||||||
user_id: string,
|
user_auth_key: string;
|
||||||
user_auth_key: string,
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(
|
||||||
if (log_lvl) {
|
`*** auth_ae_obj__user_id_user_auth_key() *** account_id=${account_id} user_id=${user_id}`
|
||||||
console.log(`*** auth_ae_obj__user_id_user_auth_key() *** account_id=${account_id} user_id=${user_id}`);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let endpoint = '/user/authenticate';
|
const endpoint = '/user/authenticate';
|
||||||
|
|
||||||
params['user_id'] = user_id; // Required
|
params['user_id'] = user_id; // Required
|
||||||
params['auth_key'] = user_auth_key; // Required
|
params['auth_key'] = user_auth_key; // Required
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log(`auth_ae_obj__user_id_user_auth_key() - params:`, params);
|
console.log(`auth_ae_obj__user_id_user_auth_key() - params:`, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
ae_promises.auth__user_id_user_key = await api.get_object({
|
ae_promises.auth__user_id_user_key = await api
|
||||||
api_cfg: api_cfg,
|
.get_object({
|
||||||
endpoint: endpoint,
|
api_cfg: api_cfg,
|
||||||
params: params,
|
endpoint: endpoint,
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(async function (user_obj_get_result) {
|
})
|
||||||
if (user_obj_get_result) {
|
.then(async function (user_obj_get_result) {
|
||||||
return user_obj_get_result;
|
if (user_obj_get_result) {
|
||||||
} else {
|
return user_obj_get_result;
|
||||||
console.log('No results returned.');
|
} else {
|
||||||
return null;
|
console.log('No results returned.');
|
||||||
}
|
return null;
|
||||||
})
|
}
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
});
|
console.log('No results returned or failed.', error);
|
||||||
|
});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.auth__user_id_user_key:', ae_promises.auth__user_id_user_key);
|
console.log('ae_promises.auth__user_id_user_key:', ae_promises.auth__user_id_user_key);
|
||||||
}
|
}
|
||||||
return 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.
|
// 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
|
// Updated 2025-04-08
|
||||||
export async function send_email_auth_ae_obj__user_id(
|
export async function send_email_auth_ae_obj__user_id({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
account_id,
|
||||||
account_id,
|
user_id,
|
||||||
user_id,
|
base_url,
|
||||||
base_url,
|
key_param_name = 'user_key', // API defaults to 'auth_key'
|
||||||
key_param_name = 'user_key', // API defaults to 'auth_key'
|
params = {},
|
||||||
params = {},
|
// try_cache = true,
|
||||||
// try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
account_id: string;
|
||||||
account_id: string,
|
user_id: string;
|
||||||
user_id: string,
|
base_url?: string;
|
||||||
base_url?: string,
|
key_param_name?: string;
|
||||||
key_param_name?: string,
|
params?: key_val;
|
||||||
params?: key_val,
|
// try_cache?: boolean,
|
||||||
// try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(
|
||||||
if (log_lvl) {
|
`*** send_email_auth_ae_obj__user_id() *** account_id=${account_id} user_id=${user_id}`
|
||||||
console.log(`*** send_email_auth_ae_obj__user_id() *** account_id=${account_id} user_id=${user_id}`);
|
);
|
||||||
}
|
}
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log(api_cfg);
|
console.log(api_cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
let email_auth_key_endpoint = `user/${user_id}/email_auth_key_url`;
|
const email_auth_key_endpoint = `user/${user_id}/email_auth_key_url`;
|
||||||
params = {
|
params = {
|
||||||
'root_url': base_url,
|
root_url: base_url,
|
||||||
'key_param_name': key_param_name
|
key_param_name: key_param_name
|
||||||
}
|
};
|
||||||
ae_promises.auth_key__send_email = await api.get_object({
|
ae_promises.auth_key__send_email = await api.get_object({
|
||||||
api_cfg: api_cfg,
|
api_cfg: api_cfg,
|
||||||
endpoint: email_auth_key_endpoint,
|
endpoint: email_auth_key_endpoint,
|
||||||
params: params,
|
params: params,
|
||||||
log_lvl: log_lvl
|
log_lvl: log_lvl
|
||||||
});
|
});
|
||||||
|
|
||||||
return ae_promises.auth_key__send_email;
|
return ae_promises.auth_key__send_email;
|
||||||
|
|
||||||
// let endpoint = `/user/${user_id}/new_auth_key`;
|
// let endpoint = `/user/${user_id}/new_auth_key`;
|
||||||
|
|
||||||
// // params['user_id'] = user_id; // Required
|
// // params['user_id'] = user_id; // Required
|
||||||
// if (log_lvl > 1) {
|
// if (log_lvl > 1) {
|
||||||
// console.log(`send_email_auth_ae_obj__user_id() - params:`, params);
|
// console.log(`send_email_auth_ae_obj__user_id() - params:`, params);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// ae_promises.auth_key__gen_auth_key = await api.get_object({
|
// ae_promises.auth_key__gen_auth_key = await api.get_object({
|
||||||
// api_cfg: api_cfg,
|
// api_cfg: api_cfg,
|
||||||
// endpoint: endpoint,
|
// endpoint: endpoint,
|
||||||
// params: params,
|
// params: params,
|
||||||
// log_lvl: log_lvl
|
// log_lvl: log_lvl
|
||||||
// })
|
// })
|
||||||
// .then(async function (email_send_result) {
|
// .then(async function (email_send_result) {
|
||||||
// if (email_send_result) {
|
// if (email_send_result) {
|
||||||
// let email_auth_key_endpoint = `user/${user_id}/email_auth_key_url`;
|
// let email_auth_key_endpoint = `user/${user_id}/email_auth_key_url`;
|
||||||
// params = {
|
// params = {
|
||||||
// 'root_url': 'https://test.oneskyit.com'
|
// 'root_url': 'https://test.oneskyit.com'
|
||||||
// }
|
// }
|
||||||
// ae_promises.auth_key__send_email = await api.get_object({
|
// ae_promises.auth_key__send_email = await api.get_object({
|
||||||
// api_cfg: api_cfg,
|
// api_cfg: api_cfg,
|
||||||
// endpoint: email_auth_key_endpoint,
|
// endpoint: email_auth_key_endpoint,
|
||||||
// params: params,
|
// params: params,
|
||||||
// log_lvl: log_lvl
|
// log_lvl: log_lvl
|
||||||
// })
|
// })
|
||||||
|
|
||||||
// return email_send_result;
|
// return email_send_result;
|
||||||
// } else {
|
// } else {
|
||||||
// console.log('No results returned.');
|
// console.log('No results returned.');
|
||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
// .catch(function (error: any) {
|
// .catch(function (error: any) {
|
||||||
// console.log('No results returned or failed.', error);
|
// console.log('No results returned or failed.', error);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// if (log_lvl) {
|
// if (log_lvl) {
|
||||||
// console.log('ae_promises.send_email_auth__user_id:', ae_promises.send_email_auth__user_id);
|
// console.log('ae_promises.send_email_auth__user_id:', ae_promises.send_email_auth__user_id);
|
||||||
// }
|
// }
|
||||||
// return ae_promises.send_email_auth__user_id;
|
// return ae_promises.send_email_auth__user_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look up user based on email address provided
|
// Look up user based on email address provided
|
||||||
// Updated 2025-04-08
|
// Updated 2025-04-08
|
||||||
export async function qry_ae_obj_li__user_email(
|
export async function qry_ae_obj_li__user_email({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
account_id,
|
||||||
account_id,
|
null_account_id = false,
|
||||||
null_account_id = false,
|
email,
|
||||||
email,
|
params = {},
|
||||||
params = {},
|
try_cache = true,
|
||||||
try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
account_id: string;
|
||||||
account_id: string,
|
null_account_id?: boolean;
|
||||||
null_account_id?: boolean,
|
email: string;
|
||||||
email: string,
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** qry_ae_obj_li__user_email() *** account_id=${account_id} email=${email}`);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`*** qry_ae_obj_li__user_email() *** account_id=${account_id} email=${email}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
let endpoint = '/user/lookup_email';
|
const endpoint = '/user/lookup_email';
|
||||||
|
|
||||||
params['email'] = email; // Required
|
params['email'] = email; // Required
|
||||||
params['null_account_id'] = null_account_id || false;
|
params['null_account_id'] = null_account_id || false;
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log(`qry_ae_obj_li__user_email() - params:`, params);
|
console.log(`qry_ae_obj_li__user_email() - params:`, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
ae_promises.qry__user_email = await api.get_object({
|
ae_promises.qry__user_email = await api
|
||||||
api_cfg: api_cfg,
|
.get_object({
|
||||||
endpoint: endpoint,
|
api_cfg: api_cfg,
|
||||||
params: params,
|
endpoint: endpoint,
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(async function (user_obj_get_result) {
|
})
|
||||||
if (user_obj_get_result) {
|
.then(async function (user_obj_get_result) {
|
||||||
return user_obj_get_result;
|
if (user_obj_get_result) {
|
||||||
} else {
|
return user_obj_get_result;
|
||||||
console.log('No results returned.');
|
} else {
|
||||||
return null;
|
console.log('No results returned.');
|
||||||
}
|
return null;
|
||||||
})
|
}
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
});
|
console.log('No results returned or failed.', error);
|
||||||
|
});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.qry__user_email:', ae_promises.qry__user_email);
|
console.log('ae_promises.qry__user_email:', ae_promises.qry__user_email);
|
||||||
}
|
}
|
||||||
return ae_promises.qry__user_email;
|
return ae_promises.qry__user_email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Change user password
|
// Change user password
|
||||||
// endpoint: PATCH /user/{user_id}/change_password
|
// endpoint: PATCH /user/{user_id}/change_password
|
||||||
// params:
|
// params:
|
||||||
// data_kv: password (the new password)
|
// data_kv: password (the new password)
|
||||||
// Updated 2025-04-11
|
// Updated 2025-04-11
|
||||||
export async function auth_ae_obj__user_id_change_password(
|
export async function auth_ae_obj__user_id_change_password({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
account_id,
|
||||||
account_id,
|
user_id,
|
||||||
user_id,
|
password,
|
||||||
password,
|
params = {},
|
||||||
params = {},
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
account_id: string;
|
||||||
account_id: string,
|
user_id: string;
|
||||||
user_id: string,
|
password: string;
|
||||||
password: string,
|
params?: key_val;
|
||||||
params?: key_val,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(
|
||||||
if (log_lvl) {
|
`*** auth_ae_obj__user_id_change_password() *** account_id=${account_id} user_id=${user_id}`
|
||||||
console.log(`*** auth_ae_obj__user_id_change_password() *** account_id=${account_id} user_id=${user_id}`);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let endpoint = `/user/${user_id}/change_password`;
|
const endpoint = `/user/${user_id}/change_password`;
|
||||||
|
|
||||||
params['user_id'] = user_id; // Required
|
params['user_id'] = user_id; // Required
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log(`auth_ae_obj__user_id_change_password() - params:`, params);
|
console.log(`auth_ae_obj__user_id_change_password() - params:`, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
ae_promises.change_password__user_id = await api.patch_object({
|
ae_promises.change_password__user_id = await api
|
||||||
api_cfg: api_cfg,
|
.patch_object({
|
||||||
endpoint: endpoint,
|
api_cfg: api_cfg,
|
||||||
params: params,
|
endpoint: endpoint,
|
||||||
data: { password: password },
|
params: params,
|
||||||
log_lvl: log_lvl
|
data: { password: password },
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(async function (change_password_result) {
|
})
|
||||||
if (change_password_result) {
|
.then(async function (change_password_result) {
|
||||||
return change_password_result;
|
if (change_password_result) {
|
||||||
} else {
|
return change_password_result;
|
||||||
console.log('No results returned.');
|
} else {
|
||||||
return null;
|
console.log('No results returned.');
|
||||||
}
|
return null;
|
||||||
})
|
}
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
});
|
console.log('No results returned or failed.', error);
|
||||||
|
});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.change_password__user_id:', ae_promises.change_password__user_id);
|
console.log('ae_promises.change_password__user_id:', ae_promises.change_password__user_id);
|
||||||
}
|
}
|
||||||
return ae_promises.change_password__user_id;
|
return ae_promises.change_password__user_id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,145 +5,143 @@ import Dexie, { type Table } from 'dexie';
|
|||||||
|
|
||||||
// Updated 2025-01-07
|
// Updated 2025-01-07
|
||||||
export interface File {
|
export interface File {
|
||||||
id: string;
|
id: string;
|
||||||
id_random: string;
|
id_random: string;
|
||||||
hosted_file_id: string;
|
hosted_file_id: string;
|
||||||
hosted_file_id_random: string;
|
hosted_file_id_random: string;
|
||||||
|
|
||||||
hash_sha256: string;
|
hash_sha256: string;
|
||||||
|
|
||||||
for_type?: string;
|
for_type?: string;
|
||||||
for_id?: string;
|
for_id?: string;
|
||||||
for_id_random?: string;
|
for_id_random?: string;
|
||||||
|
|
||||||
account_id: string;
|
account_id: string;
|
||||||
|
|
||||||
filename: string;
|
filename: string;
|
||||||
extension: string;
|
extension: string;
|
||||||
content_type: string;
|
content_type: string;
|
||||||
size: number; // In bytes
|
size: number; // In bytes
|
||||||
|
|
||||||
enable: null|boolean;
|
enable: null | boolean;
|
||||||
hide?: null|boolean;
|
hide?: null | boolean;
|
||||||
priority?: null|boolean
|
priority?: null | boolean;
|
||||||
sort?: null|number;
|
sort?: null | number;
|
||||||
group?: null|string;
|
group?: null | string;
|
||||||
notes?: null|string;
|
notes?: null | string;
|
||||||
created_on: Date;
|
created_on: Date;
|
||||||
updated_on?: null|Date;
|
updated_on?: null | Date;
|
||||||
|
|
||||||
// Additional fields for convenience (database views)
|
// Additional fields for convenience (database views)
|
||||||
filename_no_ext: string;
|
filename_no_ext: string;
|
||||||
filename_w_ext: string;
|
filename_w_ext: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-07-17
|
// Updated 2024-07-17
|
||||||
export interface Person {
|
export interface Person {
|
||||||
id: string;
|
id: string;
|
||||||
// id_random: string;
|
// id_random: string;
|
||||||
person_id: string;
|
person_id: string;
|
||||||
person_id_random: string;
|
person_id_random: string;
|
||||||
|
|
||||||
external_id?: string; // This may be semi-random or unique only withing the account.
|
external_id?: string; // This may be semi-random or unique only withing the account.
|
||||||
external_sys_id?: string; // Generated by an external system. Ideally this should be something like a UUID. It may be the same as the external_id if nothing given.
|
external_sys_id?: string; // Generated by an external system. Ideally this should be something like a UUID. It may be the same as the external_id if nothing given.
|
||||||
code?: string; // Not currently used.
|
code?: string; // Not currently used.
|
||||||
|
|
||||||
account_id?: string; // Technically this is not required for global users.
|
account_id?: string; // Technically this is not required for global users.
|
||||||
account_id_random?: string; // Technically this is not required for global users.
|
account_id_random?: string; // Technically this is not required for global users.
|
||||||
|
|
||||||
person_profile_id?: null|string;
|
person_profile_id?: null | string;
|
||||||
person_profile_id_random?: null|string; // The new table person_profile will be used soon...
|
person_profile_id_random?: null | string; // The new table person_profile will be used soon...
|
||||||
|
|
||||||
user_id?: string;
|
user_id?: string;
|
||||||
user_id_random?: string;
|
user_id_random?: string;
|
||||||
|
|
||||||
pronouns?: null|string;
|
pronouns?: null | string;
|
||||||
informal_name?: null|string;
|
informal_name?: null | string;
|
||||||
title_names?: null|string;
|
title_names?: null | string;
|
||||||
given_name: string;
|
given_name: string;
|
||||||
middle_name?: null|string;
|
middle_name?: null | string;
|
||||||
family_name: null|string;
|
family_name: null | string;
|
||||||
designations?: null|string;
|
designations?: null | string;
|
||||||
|
|
||||||
professional_title?: null|string;
|
professional_title?: null | string;
|
||||||
|
|
||||||
full_name?: string;
|
full_name?: string;
|
||||||
full_name_override?: null|string; // was called display_name
|
full_name_override?: null | string; // was called display_name
|
||||||
|
|
||||||
affiliations?: null|string;
|
affiliations?: null | string;
|
||||||
|
|
||||||
primary_email?: string;
|
primary_email?: string;
|
||||||
|
|
||||||
biography?: null|string;
|
biography?: null | string;
|
||||||
|
|
||||||
agree?: null|boolean;
|
agree?: null | boolean;
|
||||||
comments?: null|string;
|
comments?: null | string;
|
||||||
|
|
||||||
allow_auth_key?: null|boolean; // For sign in without password
|
allow_auth_key?: null | boolean; // For sign in without password
|
||||||
auth_key?: null|string; // Should this be saved locally?
|
auth_key?: null | string; // Should this be saved locally?
|
||||||
passcode?: null|string;
|
passcode?: null | string;
|
||||||
|
|
||||||
data_json?: null|string;
|
data_json?: null | string;
|
||||||
|
|
||||||
enable: null|boolean;
|
enable: null | boolean;
|
||||||
hide?: null|boolean;
|
hide?: null | boolean;
|
||||||
priority?: null|boolean
|
priority?: null | boolean;
|
||||||
sort?: null|number;
|
sort?: null | number;
|
||||||
group?: null|string;
|
group?: null | string;
|
||||||
notes?: null|string;
|
notes?: null | string;
|
||||||
created_on: Date;
|
created_on: Date;
|
||||||
updated_on?: null|Date;
|
updated_on?: null | Date;
|
||||||
|
|
||||||
// Generated fields for sorting locally only
|
// Generated fields for sorting locally only
|
||||||
tmp_sort_1?: null|string;
|
tmp_sort_1?: null | string;
|
||||||
tmp_sort_2?: null|string;
|
tmp_sort_2?: null | string;
|
||||||
tmp_sort_3?: null|string;
|
tmp_sort_3?: null | string;
|
||||||
|
|
||||||
// Additional fields for convenience (database views)
|
// Additional fields for convenience (database views)
|
||||||
username?: string; // Same as user_username
|
username?: string; // Same as user_username
|
||||||
// user_username?: null|string; // Same as username
|
// user_username?: null|string; // Same as username
|
||||||
user_name?: null|string;
|
user_name?: null | string;
|
||||||
user_email?: null|string;
|
user_email?: null | string;
|
||||||
user_allow_auth_key?: null|boolean; // For sign in without password
|
user_allow_auth_key?: null | boolean; // For sign in without password
|
||||||
user_super?: boolean;
|
user_super?: boolean;
|
||||||
user_manager?: boolean;
|
user_manager?: boolean;
|
||||||
user_administrator?: boolean;
|
user_administrator?: boolean;
|
||||||
user_public?: boolean;
|
user_public?: boolean;
|
||||||
|
|
||||||
organization_id?: null|string; // The organization this person belongs to, if any.
|
organization_id?: null | string; // The organization this person belongs to, if any.
|
||||||
organization_id_random?: null|string; // The random ID of the organization this person belongs to, if any.
|
organization_id_random?: null | string; // The random ID of the organization this person belongs to, if any.
|
||||||
organization_name?: null|string;
|
organization_name?: null | string;
|
||||||
|
|
||||||
contact_id?: null|string; // The contact ID of the person, if any.
|
contact_id?: null | string; // The contact ID of the person, if any.
|
||||||
contact_id_random?: null|string; // The random ID of the contact, if any.
|
contact_id_random?: null | string; // The random ID of the contact, if any.
|
||||||
contact_name?: null|string;
|
contact_name?: null | string;
|
||||||
contact_email?: null|string;
|
contact_email?: null | string;
|
||||||
contact_cc_email?: null|string;
|
contact_cc_email?: null | string;
|
||||||
contact_phone_mobile?: null|string;
|
contact_phone_mobile?: null | string;
|
||||||
contact_phone_home?: null|string;
|
contact_phone_home?: null | string;
|
||||||
contact_phone_office?: null|string;
|
contact_phone_office?: null | string;
|
||||||
contact_phone_landline?: null|string;
|
contact_phone_landline?: null | string;
|
||||||
contact_phone_fax?: null|string;
|
contact_phone_fax?: null | string;
|
||||||
contact_phone_other?: null|string;
|
contact_phone_other?: null | string;
|
||||||
|
|
||||||
address_id?: null|string; // The address ID of the person, if any.
|
address_id?: null | string; // The address ID of the person, if any.
|
||||||
address_id_random?: null|string; // The random ID of the address, if any.
|
address_id_random?: null | string; // The random ID of the address, if any.
|
||||||
address_city?: null|string;
|
address_city?: null | string;
|
||||||
address_country_alpha_2_code?: null|string; // ISO 3166-1 alpha-2 country code
|
address_country_alpha_2_code?: null | string; // ISO 3166-1 alpha-2 country code
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2025-01-07
|
// Updated 2025-01-07
|
||||||
export class MySubClassedDexie extends Dexie {
|
export class MySubClassedDexie extends Dexie {
|
||||||
file!: Table<File>;
|
file!: Table<File>;
|
||||||
person!: Table<Person>;
|
person!: Table<Person>;
|
||||||
// user!: Table<User>;
|
// user!: Table<User>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super('ae_core_db');
|
super('ae_core_db');
|
||||||
this.version(1).stores({
|
this.version(1).stores({
|
||||||
file: `
|
file: `
|
||||||
id, id_random, hosted_file_id, hosted_file_id_random,
|
id, id_random, hosted_file_id, hosted_file_id_random,
|
||||||
hash_sha256,
|
hash_sha256,
|
||||||
account_id,
|
account_id,
|
||||||
@@ -152,7 +150,7 @@ export class MySubClassedDexie extends Dexie {
|
|||||||
content_type, size,
|
content_type, size,
|
||||||
enable, hide, priority, sort, group, created_on, updated_on`,
|
enable, hide, priority, sort, group, created_on, updated_on`,
|
||||||
|
|
||||||
person: `
|
person: `
|
||||||
id, person_id, person_id_random,
|
id, person_id, person_id_random,
|
||||||
external_id, code,
|
external_id, code,
|
||||||
account_id, user_id,
|
account_id, user_id,
|
||||||
@@ -162,9 +160,9 @@ export class MySubClassedDexie extends Dexie {
|
|||||||
given_name, family_name,
|
given_name, family_name,
|
||||||
full_name, affiliations, email,
|
full_name, affiliations, email,
|
||||||
agree,
|
agree,
|
||||||
enable, hide, priority, sort, group, created_on, updated_on`,
|
enable, hide, priority, sort, group, created_on, updated_on`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const db_core = new MySubClassedDexie();
|
export const db_core = new MySubClassedDexie();
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,87 +1,84 @@
|
|||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
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/ae_events/db_events';
|
||||||
|
|
||||||
let ae_promises: key_val = {};
|
|
||||||
|
|
||||||
|
const ae_promises: key_val = {};
|
||||||
|
|
||||||
// --- PROPERTIES TO SAVE ---
|
// --- PROPERTIES TO SAVE ---
|
||||||
export const properties_to_save = [
|
export const properties_to_save = [
|
||||||
'id',
|
'id',
|
||||||
'event_badge_template_id',
|
'event_badge_template_id',
|
||||||
// 'event_badge_template_id_random',
|
// 'event_badge_template_id_random',
|
||||||
|
|
||||||
'event_id',
|
'event_id',
|
||||||
// 'event_id_random',
|
// 'event_id_random',
|
||||||
|
|
||||||
'name',
|
'name',
|
||||||
'description',
|
'description',
|
||||||
|
|
||||||
// 'template_code',
|
// 'template_code',
|
||||||
// 'template_type',
|
// 'template_type',
|
||||||
// 'template_json',
|
// 'template_json',
|
||||||
// 'template_svg',
|
// 'template_svg',
|
||||||
// 'template_css',
|
// 'template_css',
|
||||||
// 'template_html',
|
// 'template_html',
|
||||||
|
|
||||||
'logo_filename',
|
'logo_filename',
|
||||||
'logo_path',
|
'logo_path',
|
||||||
|
|
||||||
'header_path',
|
'header_path',
|
||||||
'secondary_header_path',
|
'secondary_header_path',
|
||||||
'footer_path',
|
'footer_path',
|
||||||
|
|
||||||
'header_row_1',
|
'header_row_1',
|
||||||
'header_row_2',
|
'header_row_2',
|
||||||
|
|
||||||
// 'footer_title',
|
// 'footer_title',
|
||||||
// 'footer_left',
|
// 'footer_left',
|
||||||
// 'footer_right',
|
// 'footer_right',
|
||||||
// 'header_background',
|
// 'header_background',
|
||||||
// 'footer_background',
|
// 'footer_background',
|
||||||
|
|
||||||
'badge_type_list',
|
'badge_type_list',
|
||||||
'ticket_list',
|
'ticket_list',
|
||||||
|
|
||||||
'ticket_1_text',
|
'ticket_1_text',
|
||||||
'ticket_2_text',
|
'ticket_2_text',
|
||||||
'ticket_3_text',
|
'ticket_3_text',
|
||||||
'ticket_4_text',
|
'ticket_4_text',
|
||||||
'ticket_5_text',
|
'ticket_5_text',
|
||||||
'ticket_6_text',
|
'ticket_6_text',
|
||||||
'ticket_7_text',
|
'ticket_7_text',
|
||||||
'ticket_8_text',
|
'ticket_8_text',
|
||||||
// 'ticket_9_text',
|
// 'ticket_9_text',
|
||||||
// 'ticket_10_text',
|
// 'ticket_10_text',
|
||||||
|
|
||||||
'wireless_ssid',
|
'wireless_ssid',
|
||||||
'wireless_password',
|
'wireless_password',
|
||||||
|
|
||||||
'show_qr_front',
|
'show_qr_front',
|
||||||
'show_qr_back',
|
'show_qr_back',
|
||||||
|
|
||||||
'layout',
|
'layout',
|
||||||
'style_filename',
|
'style_filename',
|
||||||
// 'style_href',
|
// 'style_href',
|
||||||
|
|
||||||
|
// 'default',
|
||||||
|
'enable',
|
||||||
|
'hide',
|
||||||
|
'priority',
|
||||||
|
'sort',
|
||||||
|
'group',
|
||||||
|
'notes',
|
||||||
|
'created_on',
|
||||||
|
'updated_on',
|
||||||
|
|
||||||
// 'default',
|
// Generated fields for sorting locally only
|
||||||
'enable',
|
'tmp_sort_1',
|
||||||
'hide',
|
'tmp_sort_2'
|
||||||
'priority',
|
|
||||||
'sort',
|
|
||||||
'group',
|
|
||||||
'notes',
|
|
||||||
'created_on',
|
|
||||||
'updated_on',
|
|
||||||
|
|
||||||
// Generated fields for sorting locally only
|
|
||||||
'tmp_sort_1',
|
|
||||||
'tmp_sort_2',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NON-EXPORTED LOCAL HELPER
|
* NON-EXPORTED LOCAL HELPER
|
||||||
* Processes a list of Aether objects by applying common and specific transformations.
|
* Processes a list of Aether objects by applying common and specific transformations.
|
||||||
@@ -150,7 +147,6 @@ async function _process_generic_props<T extends Record<string, any>>({
|
|||||||
return processed_obj_li;
|
return processed_obj_li;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --- PROCESS FUNCTION ---
|
// --- PROCESS FUNCTION ---
|
||||||
export async function process_ae_obj__event_badge_template_props({
|
export async function process_ae_obj__event_badge_template_props({
|
||||||
obj_li,
|
obj_li,
|
||||||
@@ -177,361 +173,377 @@ export async function process_ae_obj__event_badge_template_props({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// --- CRUD FUNCTIONS ---
|
// --- CRUD FUNCTIONS ---
|
||||||
export async function load_ae_obj_id__event_badge_template({
|
export async function load_ae_obj_id__event_badge_template({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
event_badge_template_id,
|
event_badge_template_id,
|
||||||
try_cache = true,
|
try_cache = true,
|
||||||
log_lvl = 0
|
log_lvl = 0
|
||||||
}: {
|
}: {
|
||||||
api_cfg: any,
|
api_cfg: any;
|
||||||
event_badge_template_id: string,
|
event_badge_template_id: string;
|
||||||
try_cache?: boolean,
|
try_cache?: boolean;
|
||||||
log_lvl?: number
|
log_lvl?: number;
|
||||||
}) {
|
}) {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** load_ae_obj_id__event_badge_template() *** event_badge_template_id=${event_badge_template_id}`);
|
console.log(
|
||||||
}
|
`*** load_ae_obj_id__event_badge_template() *** event_badge_template_id=${event_badge_template_id}`
|
||||||
let params = {};
|
);
|
||||||
ae_promises.load__event_badge_template_obj = await api.get_ae_obj_id_crud({
|
}
|
||||||
api_cfg,
|
const params = {};
|
||||||
obj_type: 'event_badge_template',
|
ae_promises.load__event_badge_template_obj = await api
|
||||||
obj_id: event_badge_template_id,
|
.get_ae_obj_id_crud({
|
||||||
use_alt_table: false,
|
api_cfg,
|
||||||
use_alt_base: false,
|
obj_type: 'event_badge_template',
|
||||||
params,
|
obj_id: event_badge_template_id,
|
||||||
log_lvl
|
use_alt_table: false,
|
||||||
})
|
use_alt_base: false,
|
||||||
.then(async function (obj_get_result) {
|
params,
|
||||||
if (obj_get_result) {
|
log_lvl
|
||||||
if (try_cache) {
|
})
|
||||||
let processed_obj_li = await process_ae_obj__event_badge_template_props({
|
.then(async function (obj_get_result) {
|
||||||
obj_li: [obj_get_result],
|
if (obj_get_result) {
|
||||||
log_lvl
|
if (try_cache) {
|
||||||
});
|
const processed_obj_li = await process_ae_obj__event_badge_template_props({
|
||||||
await db_save_ae_obj_li__ae_obj({
|
obj_li: [obj_get_result],
|
||||||
db_instance: db_events,
|
log_lvl
|
||||||
table_name: 'badge_template',
|
});
|
||||||
obj_li: processed_obj_li,
|
await db_save_ae_obj_li__ae_obj({
|
||||||
properties_to_save,
|
db_instance: db_events,
|
||||||
log_lvl,
|
table_name: 'badge_template',
|
||||||
});
|
obj_li: processed_obj_li,
|
||||||
}
|
properties_to_save,
|
||||||
return obj_get_result;
|
log_lvl
|
||||||
} else {
|
});
|
||||||
if (log_lvl) console.log('No results returned.');
|
}
|
||||||
return null;
|
return obj_get_result;
|
||||||
}
|
} else {
|
||||||
})
|
if (log_lvl) console.log('No results returned.');
|
||||||
.catch(function (error: any) {
|
return null;
|
||||||
console.log('No results returned or failed.', error);
|
}
|
||||||
});
|
})
|
||||||
return ae_promises.load__event_badge_template_obj;
|
.catch(function (error: any) {
|
||||||
|
console.log('No results returned or failed.', error);
|
||||||
|
});
|
||||||
|
return ae_promises.load__event_badge_template_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function load_ae_obj_li__event_badge_template({
|
export async function load_ae_obj_li__event_badge_template({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
event_id,
|
event_id,
|
||||||
enabled = 'enabled',
|
enabled = 'enabled',
|
||||||
hidden = 'not_hidden',
|
hidden = 'not_hidden',
|
||||||
limit = 49,
|
limit = 49,
|
||||||
offset = 0,
|
offset = 0,
|
||||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
order_by_li = { priority: 'DESC', sort: 'DESC', updated_on: 'DESC', created_on: 'DESC' },
|
||||||
params = {},
|
params = {},
|
||||||
try_cache = true,
|
try_cache = true,
|
||||||
log_lvl = 0
|
log_lvl = 0
|
||||||
}: {
|
}: {
|
||||||
api_cfg: any,
|
api_cfg: any;
|
||||||
event_id: string,
|
event_id: string;
|
||||||
enabled?: "enabled" | "all" | "not_enabled" | undefined,
|
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
|
||||||
hidden?: "hidden" | "all" | "not_hidden" | undefined,
|
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
|
||||||
limit?: number,
|
limit?: number;
|
||||||
offset?: number,
|
offset?: number;
|
||||||
order_by_li?: key_val,
|
order_by_li?: key_val;
|
||||||
params?: key_val,
|
params?: key_val;
|
||||||
try_cache?: boolean,
|
try_cache?: boolean;
|
||||||
log_lvl?: number
|
log_lvl?: number;
|
||||||
}) {
|
}) {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** load_ae_obj_li__event_badge_template() *** event_id=${event_id}`);
|
console.log(`*** load_ae_obj_li__event_badge_template() *** event_id=${event_id}`);
|
||||||
}
|
}
|
||||||
let params_json: key_val = {};
|
const params_json: key_val = {};
|
||||||
// ae_promises.load__event_badge_template_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
// ae_promises.load__event_badge_template_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||||
ae_promises.load__event_badge_template_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
ae_promises.load__event_badge_template_obj_li = await api
|
||||||
api_cfg,
|
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||||
obj_type: 'event_badge_template',
|
api_cfg,
|
||||||
for_obj_type: 'event',
|
obj_type: 'event_badge_template',
|
||||||
for_obj_id: event_id,
|
for_obj_type: 'event',
|
||||||
use_alt_tbl: false,
|
for_obj_id: event_id,
|
||||||
use_alt_mdl: false,
|
use_alt_tbl: false,
|
||||||
enabled,
|
use_alt_mdl: false,
|
||||||
hidden,
|
enabled,
|
||||||
order_by_li,
|
hidden,
|
||||||
limit,
|
order_by_li,
|
||||||
offset,
|
limit,
|
||||||
params_json,
|
offset,
|
||||||
params,
|
params_json,
|
||||||
log_lvl
|
params,
|
||||||
})
|
log_lvl
|
||||||
.then(async function (obj_li_get_result) {
|
})
|
||||||
if (obj_li_get_result) {
|
.then(async function (obj_li_get_result) {
|
||||||
if (try_cache) {
|
if (obj_li_get_result) {
|
||||||
let processed_obj_li = await process_ae_obj__event_badge_template_props({
|
if (try_cache) {
|
||||||
obj_li: obj_li_get_result,
|
const processed_obj_li = await process_ae_obj__event_badge_template_props({
|
||||||
log_lvl
|
obj_li: obj_li_get_result,
|
||||||
});
|
log_lvl
|
||||||
await db_save_ae_obj_li__ae_obj({
|
});
|
||||||
db_instance: db_events,
|
await db_save_ae_obj_li__ae_obj({
|
||||||
table_name: 'badge_template',
|
db_instance: db_events,
|
||||||
obj_li: processed_obj_li,
|
table_name: 'badge_template',
|
||||||
properties_to_save,
|
obj_li: processed_obj_li,
|
||||||
log_lvl,
|
properties_to_save,
|
||||||
});
|
log_lvl
|
||||||
}
|
});
|
||||||
return obj_li_get_result;
|
}
|
||||||
} else {
|
return obj_li_get_result;
|
||||||
return [];
|
} else {
|
||||||
}
|
return [];
|
||||||
})
|
}
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
});
|
console.log('No results returned or failed.', error);
|
||||||
return ae_promises.load__event_badge_template_obj_li;
|
});
|
||||||
|
return ae_promises.load__event_badge_template_obj_li;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function create_ae_obj__event_badge_template({
|
export async function create_ae_obj__event_badge_template({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
event_id,
|
event_id,
|
||||||
data_kv,
|
data_kv,
|
||||||
params = {},
|
params = {},
|
||||||
try_cache = true,
|
try_cache = true,
|
||||||
log_lvl = 0
|
log_lvl = 0
|
||||||
}: {
|
}: {
|
||||||
api_cfg: any,
|
api_cfg: any;
|
||||||
event_id: string,
|
event_id: string;
|
||||||
data_kv: key_val,
|
data_kv: key_val;
|
||||||
params?: key_val,
|
params?: key_val;
|
||||||
try_cache?: boolean,
|
try_cache?: boolean;
|
||||||
log_lvl?: number
|
log_lvl?: number;
|
||||||
}) {
|
}) {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** create_ae_obj__event_badge_template() *** event_id=${event_id}`);
|
console.log(`*** create_ae_obj__event_badge_template() *** event_id=${event_id}`);
|
||||||
}
|
}
|
||||||
ae_promises.create__event_badge_template = await api.create_ae_obj_crud({
|
ae_promises.create__event_badge_template = await api
|
||||||
api_cfg,
|
.create_ae_obj_crud({
|
||||||
obj_type: 'event_badge_template',
|
api_cfg,
|
||||||
fields: {
|
obj_type: 'event_badge_template',
|
||||||
event_id_random: event_id,
|
fields: {
|
||||||
...data_kv
|
event_id_random: event_id,
|
||||||
},
|
...data_kv
|
||||||
key: api_cfg.api_crud_super_key,
|
},
|
||||||
params,
|
key: api_cfg.api_crud_super_key,
|
||||||
return_obj: true,
|
params,
|
||||||
log_lvl
|
return_obj: true,
|
||||||
})
|
log_lvl
|
||||||
.then(async function (obj_create_result) {
|
})
|
||||||
if (obj_create_result) {
|
.then(async function (obj_create_result) {
|
||||||
if (try_cache) {
|
if (obj_create_result) {
|
||||||
let processed_obj_li = await process_ae_obj__event_badge_template_props({
|
if (try_cache) {
|
||||||
obj_li: [obj_create_result],
|
const processed_obj_li = await process_ae_obj__event_badge_template_props({
|
||||||
log_lvl
|
obj_li: [obj_create_result],
|
||||||
});
|
log_lvl
|
||||||
db_save_ae_obj_li__ae_obj({
|
});
|
||||||
db_instance: db_events,
|
db_save_ae_obj_li__ae_obj({
|
||||||
table_name: 'badge_template',
|
db_instance: db_events,
|
||||||
obj_li: processed_obj_li,
|
table_name: 'badge_template',
|
||||||
properties_to_save,
|
obj_li: processed_obj_li,
|
||||||
log_lvl,
|
properties_to_save,
|
||||||
});
|
log_lvl
|
||||||
}
|
});
|
||||||
return obj_create_result;
|
}
|
||||||
} else {
|
return obj_create_result;
|
||||||
return null;
|
} else {
|
||||||
}
|
return null;
|
||||||
})
|
}
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
});
|
console.log('No results returned or failed.', error);
|
||||||
return ae_promises.create__event_badge_template;
|
});
|
||||||
|
return ae_promises.create__event_badge_template;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function delete_ae_obj_id__event_badge_template({
|
export async function delete_ae_obj_id__event_badge_template({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
event_badge_template_id,
|
event_badge_template_id,
|
||||||
method = 'delete',
|
method = 'delete',
|
||||||
params = {},
|
params = {},
|
||||||
try_cache = true,
|
try_cache = true,
|
||||||
log_lvl = 0
|
log_lvl = 0
|
||||||
}: {
|
}: {
|
||||||
api_cfg: any,
|
api_cfg: any;
|
||||||
event_badge_template_id: string,
|
event_badge_template_id: string;
|
||||||
method?: string,
|
method?: string;
|
||||||
params?: key_val,
|
params?: key_val;
|
||||||
try_cache?: boolean,
|
try_cache?: boolean;
|
||||||
log_lvl?: number
|
log_lvl?: number;
|
||||||
}) {
|
}) {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** delete_ae_obj_id__event_badge_template() *** event_badge_template_id=${event_badge_template_id}`);
|
console.log(
|
||||||
}
|
`*** delete_ae_obj_id__event_badge_template() *** event_badge_template_id=${event_badge_template_id}`
|
||||||
ae_promises.delete__event_badge_template_obj = await api.delete_ae_obj_id_crud({
|
);
|
||||||
api_cfg,
|
}
|
||||||
obj_type: 'event_badge_template',
|
ae_promises.delete__event_badge_template_obj = await api
|
||||||
obj_id: event_badge_template_id,
|
.delete_ae_obj_id_crud({
|
||||||
key: api_cfg.api_crud_super_key,
|
api_cfg,
|
||||||
params,
|
obj_type: 'event_badge_template',
|
||||||
method,
|
obj_id: event_badge_template_id,
|
||||||
log_lvl
|
key: api_cfg.api_crud_super_key,
|
||||||
})
|
params,
|
||||||
.catch(function (error: any) {
|
method,
|
||||||
console.log('No results returned or failed.', error);
|
log_lvl
|
||||||
})
|
})
|
||||||
.finally(function () {
|
.catch(function (error: any) {
|
||||||
if (try_cache) {
|
console.log('No results returned or failed.', error);
|
||||||
if (log_lvl) {
|
})
|
||||||
console.log(`Attempting to remove IDB entry for event_badge_template_id=${event_badge_template_id}`);
|
.finally(function () {
|
||||||
}
|
if (try_cache) {
|
||||||
db_events.badge_template.delete(event_badge_template_id);
|
if (log_lvl) {
|
||||||
}
|
console.log(
|
||||||
});
|
`Attempting to remove IDB entry for event_badge_template_id=${event_badge_template_id}`
|
||||||
return ae_promises.delete__event_badge_template_obj;
|
);
|
||||||
|
}
|
||||||
|
db_events.badge_template.delete(event_badge_template_id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return ae_promises.delete__event_badge_template_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function update_ae_obj__event_badge_template({
|
export async function update_ae_obj__event_badge_template({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
event_badge_template_id,
|
event_badge_template_id,
|
||||||
data_kv,
|
data_kv,
|
||||||
params = {},
|
params = {},
|
||||||
try_cache = true,
|
try_cache = true,
|
||||||
log_lvl = 0
|
log_lvl = 0
|
||||||
}: {
|
}: {
|
||||||
api_cfg: any,
|
api_cfg: any;
|
||||||
event_badge_template_id: string,
|
event_badge_template_id: string;
|
||||||
data_kv: key_val,
|
data_kv: key_val;
|
||||||
params?: key_val,
|
params?: key_val;
|
||||||
try_cache?: boolean,
|
try_cache?: boolean;
|
||||||
log_lvl?: number
|
log_lvl?: number;
|
||||||
}) {
|
}) {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** update_ae_obj__event_badge_template() *** event_badge_template_id=${event_badge_template_id}`);
|
console.log(
|
||||||
}
|
`*** update_ae_obj__event_badge_template() *** event_badge_template_id=${event_badge_template_id}`
|
||||||
ae_promises.update__event_badge_template_obj = await api.update_ae_obj_id_crud({
|
);
|
||||||
api_cfg,
|
}
|
||||||
obj_type: 'event_badge_template',
|
ae_promises.update__event_badge_template_obj = await api
|
||||||
obj_id: event_badge_template_id,
|
.update_ae_obj_id_crud({
|
||||||
fields: data_kv,
|
api_cfg,
|
||||||
key: api_cfg.api_crud_super_key,
|
obj_type: 'event_badge_template',
|
||||||
params,
|
obj_id: event_badge_template_id,
|
||||||
return_obj: true,
|
fields: data_kv,
|
||||||
log_lvl
|
key: api_cfg.api_crud_super_key,
|
||||||
})
|
params,
|
||||||
.then(async function (obj_update_result) {
|
return_obj: true,
|
||||||
if (obj_update_result) {
|
log_lvl
|
||||||
if (try_cache) {
|
})
|
||||||
let processed_obj_li = await process_ae_obj__event_badge_template_props({
|
.then(async function (obj_update_result) {
|
||||||
obj_li: [obj_update_result],
|
if (obj_update_result) {
|
||||||
log_lvl
|
if (try_cache) {
|
||||||
});
|
const processed_obj_li = await process_ae_obj__event_badge_template_props({
|
||||||
db_save_ae_obj_li__ae_obj({
|
obj_li: [obj_update_result],
|
||||||
db_instance: db_events,
|
log_lvl
|
||||||
table_name: 'badge_template',
|
});
|
||||||
obj_li: processed_obj_li,
|
db_save_ae_obj_li__ae_obj({
|
||||||
properties_to_save,
|
db_instance: db_events,
|
||||||
log_lvl,
|
table_name: 'badge_template',
|
||||||
});
|
obj_li: processed_obj_li,
|
||||||
}
|
properties_to_save,
|
||||||
return obj_update_result;
|
log_lvl
|
||||||
} else {
|
});
|
||||||
return null;
|
}
|
||||||
}
|
return obj_update_result;
|
||||||
})
|
} else {
|
||||||
.catch(function (error: any) {
|
return null;
|
||||||
console.log('No results returned or failed.', error);
|
}
|
||||||
});
|
})
|
||||||
return ae_promises.update__event_badge_template_obj;
|
.catch(function (error: any) {
|
||||||
|
console.log('No results returned or failed.', error);
|
||||||
|
});
|
||||||
|
return ae_promises.update__event_badge_template_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- SEARCH FUNCTION ---
|
// --- SEARCH FUNCTION ---
|
||||||
export async function search__event_badge_template({
|
export async function search__event_badge_template({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
event_id,
|
event_id,
|
||||||
fulltext_search_qry_str,
|
fulltext_search_qry_str,
|
||||||
like_search_qry_str = null,
|
like_search_qry_str = null,
|
||||||
enabled = 'enabled',
|
enabled = 'enabled',
|
||||||
hidden = 'not_hidden',
|
hidden = 'not_hidden',
|
||||||
limit = 25,
|
limit = 25,
|
||||||
offset = 0,
|
offset = 0,
|
||||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
order_by_li = {
|
||||||
params = {},
|
priority: 'DESC',
|
||||||
try_cache = true,
|
sort: 'DESC',
|
||||||
log_lvl = 0
|
name: 'ASC',
|
||||||
|
updated_on: 'DESC',
|
||||||
|
created_on: 'DESC'
|
||||||
|
},
|
||||||
|
params = {},
|
||||||
|
try_cache = true,
|
||||||
|
log_lvl = 0
|
||||||
}: {
|
}: {
|
||||||
api_cfg: any,
|
api_cfg: any;
|
||||||
event_id: string,
|
event_id: string;
|
||||||
fulltext_search_qry_str?: null|string,
|
fulltext_search_qry_str?: null | string;
|
||||||
like_search_qry_str?: null|string,
|
like_search_qry_str?: null | string;
|
||||||
enabled?: "enabled" | "all" | "not_enabled" | undefined,
|
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
|
||||||
hidden?: "hidden" | "all" | "not_hidden" | undefined,
|
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
|
||||||
limit?: number,
|
limit?: number;
|
||||||
offset?: number,
|
offset?: number;
|
||||||
order_by_li?: key_val,
|
order_by_li?: key_val;
|
||||||
params?: key_val,
|
params?: key_val;
|
||||||
try_cache?: boolean,
|
try_cache?: boolean;
|
||||||
log_lvl?: number
|
log_lvl?: number;
|
||||||
}) {
|
}) {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** search__event_badge_template() *** event_id=${event_id}`);
|
console.log(`*** search__event_badge_template() *** event_id=${event_id}`);
|
||||||
}
|
}
|
||||||
let params_json: key_val = {};
|
const params_json: key_val = {};
|
||||||
if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
|
if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
|
||||||
params_json['ft_qry'] = { 'default_qry_str': fulltext_search_qry_str };
|
params_json['ft_qry'] = { default_qry_str: fulltext_search_qry_str };
|
||||||
}
|
}
|
||||||
if (like_search_qry_str && like_search_qry_str.length > 2) {
|
if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||||
params_json['and_like'] = { 'default_qry_str': like_search_qry_str };
|
params_json['and_like'] = { default_qry_str: like_search_qry_str };
|
||||||
}
|
}
|
||||||
params_json['and_qry'] = {};
|
params_json['and_qry'] = {};
|
||||||
// ae_promises.search__event_badge_template_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
// ae_promises.search__event_badge_template_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||||
ae_promises.load__event_badge_template_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
ae_promises.load__event_badge_template_obj_li = await api
|
||||||
api_cfg,
|
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||||
obj_type: 'event_badge_template',
|
api_cfg,
|
||||||
for_obj_type: 'event',
|
obj_type: 'event_badge_template',
|
||||||
for_obj_id: event_id,
|
for_obj_type: 'event',
|
||||||
use_alt_tbl: false,
|
for_obj_id: event_id,
|
||||||
use_alt_mdl: false,
|
use_alt_tbl: false,
|
||||||
enabled,
|
use_alt_mdl: false,
|
||||||
hidden,
|
enabled,
|
||||||
order_by_li,
|
hidden,
|
||||||
limit,
|
order_by_li,
|
||||||
offset,
|
limit,
|
||||||
params_json,
|
offset,
|
||||||
params,
|
params_json,
|
||||||
log_lvl
|
params,
|
||||||
})
|
log_lvl
|
||||||
.then(async function (obj_li_get_result) {
|
})
|
||||||
if (obj_li_get_result) {
|
.then(async function (obj_li_get_result) {
|
||||||
if (try_cache) {
|
if (obj_li_get_result) {
|
||||||
let processed_obj_li = await process_ae_obj__event_badge_template_props({
|
if (try_cache) {
|
||||||
obj_li: obj_li_get_result,
|
const processed_obj_li = await process_ae_obj__event_badge_template_props({
|
||||||
log_lvl
|
obj_li: obj_li_get_result,
|
||||||
});
|
log_lvl
|
||||||
await db_save_ae_obj_li__ae_obj({
|
});
|
||||||
db_instance: db_events,
|
await db_save_ae_obj_li__ae_obj({
|
||||||
table_name: 'badge_template',
|
db_instance: db_events,
|
||||||
obj_li: processed_obj_li,
|
table_name: 'badge_template',
|
||||||
properties_to_save,
|
obj_li: processed_obj_li,
|
||||||
log_lvl,
|
properties_to_save,
|
||||||
});
|
log_lvl
|
||||||
}
|
});
|
||||||
return obj_li_get_result;
|
}
|
||||||
} else {
|
return obj_li_get_result;
|
||||||
return [];
|
} else {
|
||||||
}
|
return [];
|
||||||
})
|
}
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
});
|
console.log('No results returned or failed.', error);
|
||||||
return ae_promises.search__event_badge_template_obj_li;
|
});
|
||||||
|
return ae_promises.search__event_badge_template_obj_li;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,131 +1,131 @@
|
|||||||
// This file is used to export all the functions that are used for Aether Events related functions.
|
// 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 all the functions from this library:
|
||||||
import * as event from "$lib/ae_events/ae_events__event";
|
import * as event from '$lib/ae_events/ae_events__event';
|
||||||
import * as event_device from "$lib/ae_events/ae_events__event_device";
|
import * as event_device from '$lib/ae_events/ae_events__event_device';
|
||||||
|
|
||||||
import * as event_file from "$lib/ae_events/ae_events__event_file";
|
import * as event_file from '$lib/ae_events/ae_events__event_file';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
load_ae_obj_id__exhibit,
|
load_ae_obj_id__exhibit,
|
||||||
load_ae_obj_li__exhibit,
|
load_ae_obj_li__exhibit,
|
||||||
load_ae_obj_id__exhibit_tracking,
|
load_ae_obj_id__exhibit_tracking,
|
||||||
load_ae_obj_li__exhibit_tracking,
|
load_ae_obj_li__exhibit_tracking,
|
||||||
create_ae_obj__exhibit_tracking,
|
create_ae_obj__exhibit_tracking,
|
||||||
update_ae_obj__exhibit_tracking,
|
update_ae_obj__exhibit_tracking,
|
||||||
download_export__event_exhibit_tracking,
|
download_export__event_exhibit_tracking
|
||||||
// db_save_ae_obj_li__exhibitor,
|
// db_save_ae_obj_li__exhibitor,
|
||||||
} from "$lib/ae_events/ae_events__exhibit";
|
} from '$lib/ae_events/ae_events__exhibit';
|
||||||
|
|
||||||
import * as event_location from "$lib/ae_events/ae_events__event_location";
|
import * as event_location from '$lib/ae_events/ae_events__event_location';
|
||||||
|
|
||||||
import * as event_session from "$lib/ae_events/ae_events__event_session";
|
import * as event_session from '$lib/ae_events/ae_events__event_session';
|
||||||
|
|
||||||
import * as event_presentation from "$lib/ae_events/ae_events__event_presentation";
|
import * as event_presentation from '$lib/ae_events/ae_events__event_presentation';
|
||||||
|
|
||||||
import * as event_presenter from "$lib/ae_events/ae_events__event_presenter";
|
import * as event_presenter from '$lib/ae_events/ae_events__event_presenter';
|
||||||
|
|
||||||
import * as event_badge from "$lib/ae_events/ae_events__event_badge";
|
import * as event_badge from '$lib/ae_events/ae_events__event_badge';
|
||||||
|
|
||||||
import * as event_badge_template from "$lib/ae_events/ae_events__event_badge_template";
|
import * as event_badge_template from '$lib/ae_events/ae_events__event_badge_template';
|
||||||
|
|
||||||
|
const export_obj = {
|
||||||
|
// Events
|
||||||
|
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,
|
||||||
|
|
||||||
let export_obj = {
|
// Event Badges
|
||||||
// Events
|
load_ae_obj_id__event_badge: event_badge.load_ae_obj_id__event_badge,
|
||||||
load_ae_obj_id__event: event.load_ae_obj_id__event,
|
load_ae_obj_li__event_badge: event_badge.load_ae_obj_li__event_badge,
|
||||||
load_ae_obj_li__event: event.load_ae_obj_li__event,
|
create_ae_obj__event_badge: event_badge.create_ae_obj__event_badge,
|
||||||
qry_ae_obj_li__event: event.qry_ae_obj_li__event,
|
delete_ae_obj_id__event_badge: event_badge.delete_ae_obj_id__event_badge,
|
||||||
create_ae_obj__event: event.create_ae_obj__event,
|
update_ae_obj__event_badge: event_badge.update_ae_obj__event_badge,
|
||||||
delete_ae_obj_id__event: event.delete_ae_obj_id__event,
|
qry__event_badge: event_badge.qry__event_badge,
|
||||||
update_ae_obj__event: event.update_ae_obj__event,
|
search__event_badge: event_badge.search__event_badge,
|
||||||
// db_save_ae_obj_li__event: event.db_save_ae_obj_li__event,
|
// handle_load_ae_obj_id__badge: event_badge.handle_load_ae_obj_id__badge,
|
||||||
sync_config__event_pres_mgmt: event.sync_config__event_pres_mgmt,
|
// handle_load_ae_obj_li__badge: event_badge.handle_load_ae_obj_li__badge,
|
||||||
|
// handle_search__event_badge: event_badge.handle_search__event_badge,
|
||||||
|
// db_save_ae_obj_li__event_badge: event_badge.db_save_ae_obj_li__event_badge,
|
||||||
|
|
||||||
// Event Badges
|
// Event Badge Templates
|
||||||
load_ae_obj_id__event_badge: event_badge.load_ae_obj_id__event_badge,
|
load_ae_obj_id__event_badge_template: event_badge_template.load_ae_obj_id__event_badge_template,
|
||||||
load_ae_obj_li__event_badge: event_badge.load_ae_obj_li__event_badge,
|
load_ae_obj_li__event_badge_template: event_badge_template.load_ae_obj_li__event_badge_template,
|
||||||
create_ae_obj__event_badge: event_badge.create_ae_obj__event_badge,
|
create_ae_obj__event_badge_template: event_badge_template.create_ae_obj__event_badge_template,
|
||||||
delete_ae_obj_id__event_badge: event_badge.delete_ae_obj_id__event_badge,
|
delete_ae_obj_id__event_badge_template:
|
||||||
update_ae_obj__event_badge: event_badge.update_ae_obj__event_badge,
|
event_badge_template.delete_ae_obj_id__event_badge_template,
|
||||||
qry__event_badge: event_badge.qry__event_badge,
|
update_ae_obj__event_badge_template: event_badge_template.update_ae_obj__event_badge_template,
|
||||||
search__event_badge: event_badge.search__event_badge,
|
search__event_badge_template: event_badge_template.search__event_badge_template,
|
||||||
// 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,
|
|
||||||
// db_save_ae_obj_li__event_badge: event_badge.db_save_ae_obj_li__event_badge,
|
|
||||||
|
|
||||||
// Event Badge Templates
|
// Event Devices
|
||||||
load_ae_obj_id__event_badge_template: event_badge_template.load_ae_obj_id__event_badge_template,
|
load_ae_obj_id__event_device: event_device.load_ae_obj_id__event_device,
|
||||||
load_ae_obj_li__event_badge_template: event_badge_template.load_ae_obj_li__event_badge_template,
|
load_ae_obj_li__event_device: event_device.load_ae_obj_li__event_device,
|
||||||
create_ae_obj__event_badge_template: event_badge_template.create_ae_obj__event_badge_template,
|
create_ae_obj__event_device: event_device.create_ae_obj__event_device,
|
||||||
delete_ae_obj_id__event_badge_template: event_badge_template.delete_ae_obj_id__event_badge_template,
|
delete_ae_obj_id__event_device: event_device.delete_ae_obj_id__event_device,
|
||||||
update_ae_obj__event_badge_template: event_badge_template.update_ae_obj__event_badge_template,
|
update_ae_obj__event_device: event_device.update_ae_obj__event_device,
|
||||||
search__event_badge_template: event_badge_template.search__event_badge_template,
|
// db_save_ae_obj_li__event_device: event_device.db_save_ae_obj_li__event_device,
|
||||||
|
|
||||||
// Event Devices
|
// Event Exhibits
|
||||||
load_ae_obj_id__event_device: event_device.load_ae_obj_id__event_device,
|
handle_load_ae_obj_id__exhibit: load_ae_obj_id__exhibit,
|
||||||
load_ae_obj_li__event_device: event_device.load_ae_obj_li__event_device,
|
handle_load_ae_obj_li__exhibit: load_ae_obj_li__exhibit,
|
||||||
create_ae_obj__event_device: event_device.create_ae_obj__event_device,
|
handle_load_ae_obj_id__exhibit_tracking: load_ae_obj_id__exhibit_tracking,
|
||||||
delete_ae_obj_id__event_device: event_device.delete_ae_obj_id__event_device,
|
handle_load_ae_obj_li__exhibit_tracking: load_ae_obj_li__exhibit_tracking,
|
||||||
update_ae_obj__event_device: event_device.update_ae_obj__event_device,
|
handle_create_ae_obj__exhibit_tracking: create_ae_obj__exhibit_tracking,
|
||||||
// db_save_ae_obj_li__event_device: event_device.db_save_ae_obj_li__event_device,
|
handle_update_ae_obj__exhibit_tracking: update_ae_obj__exhibit_tracking,
|
||||||
|
handle_download_export__event_exhibit_tracking: download_export__event_exhibit_tracking,
|
||||||
|
// handle_db_save_ae_obj_li__exhibitor: db_save_ae_obj_li__exhibitor,
|
||||||
|
|
||||||
// Event Exhibits
|
// Event Files
|
||||||
handle_load_ae_obj_id__exhibit: load_ae_obj_id__exhibit,
|
load_ae_obj_id__event_file: event_file.load_ae_obj_id__event_file,
|
||||||
handle_load_ae_obj_li__exhibit: load_ae_obj_li__exhibit,
|
load_ae_obj_li__event_file: event_file.load_ae_obj_li__event_file,
|
||||||
handle_load_ae_obj_id__exhibit_tracking: load_ae_obj_id__exhibit_tracking,
|
create_event_file_obj_from_hosted_file_async:
|
||||||
handle_load_ae_obj_li__exhibit_tracking: load_ae_obj_li__exhibit_tracking,
|
event_file.create_event_file_obj_from_hosted_file_async,
|
||||||
handle_create_ae_obj__exhibit_tracking: create_ae_obj__exhibit_tracking,
|
delete_ae_obj_id__event_file: event_file.delete_ae_obj_id__event_file,
|
||||||
handle_update_ae_obj__exhibit_tracking: update_ae_obj__exhibit_tracking,
|
update_ae_obj__event_file: event_file.update_ae_obj__event_file,
|
||||||
handle_download_export__event_exhibit_tracking: download_export__event_exhibit_tracking,
|
qry__event_file: event_file.qry__event_file,
|
||||||
// handle_db_save_ae_obj_li__exhibitor: db_save_ae_obj_li__exhibitor,
|
search__event_file: event_file.search__event_file,
|
||||||
|
// db_save_ae_obj_li__event_file: event_file.db_save_ae_obj_li__event_file,
|
||||||
|
|
||||||
// Event Files
|
// Event Locations
|
||||||
load_ae_obj_id__event_file: event_file.load_ae_obj_id__event_file,
|
load_ae_obj_id__event_location: event_location.load_ae_obj_id__event_location,
|
||||||
load_ae_obj_li__event_file: event_file.load_ae_obj_li__event_file,
|
load_ae_obj_li__event_location: event_location.load_ae_obj_li__event_location,
|
||||||
create_event_file_obj_from_hosted_file_async: event_file.create_event_file_obj_from_hosted_file_async,
|
create_ae_obj__event_location: event_location.create_ae_obj__event_location,
|
||||||
delete_ae_obj_id__event_file: event_file.delete_ae_obj_id__event_file,
|
delete_ae_obj_id__event_location: event_location.delete_ae_obj_id__event_location,
|
||||||
update_ae_obj__event_file: event_file.update_ae_obj__event_file,
|
update_ae_obj__event_location: event_location.update_ae_obj__event_location,
|
||||||
qry__event_file: event_file.qry__event_file,
|
// db_save_ae_obj_li__event_location: event_location.db_save_ae_obj_li__event_location,
|
||||||
search__event_file: event_file.search__event_file,
|
|
||||||
// db_save_ae_obj_li__event_file: event_file.db_save_ae_obj_li__event_file,
|
|
||||||
|
|
||||||
// Event Locations
|
// Event Sessions
|
||||||
load_ae_obj_id__event_location: event_location.load_ae_obj_id__event_location,
|
load_ae_obj_id__event_session: event_session.load_ae_obj_id__event_session,
|
||||||
load_ae_obj_li__event_location: event_location.load_ae_obj_li__event_location,
|
load_ae_obj_li__event_session: event_session.load_ae_obj_li__event_session,
|
||||||
create_ae_obj__event_location: event_location.create_ae_obj__event_location,
|
create_ae_obj__event_session: event_session.create_ae_obj__event_session,
|
||||||
delete_ae_obj_id__event_location: event_location.delete_ae_obj_id__event_location,
|
delete_ae_obj_id__event_session: event_session.delete_ae_obj_id__event_session,
|
||||||
update_ae_obj__event_location: event_location.update_ae_obj__event_location,
|
update_ae_obj__event_session: event_session.update_ae_obj__event_session,
|
||||||
// db_save_ae_obj_li__event_location: event_location.db_save_ae_obj_li__event_location,
|
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,
|
||||||
|
|
||||||
// Event Sessions
|
// Event Presentations
|
||||||
load_ae_obj_id__event_session: event_session.load_ae_obj_id__event_session,
|
load_ae_obj_id__event_presentation: event_presentation.load_ae_obj_id__event_presentation,
|
||||||
load_ae_obj_li__event_session: event_session.load_ae_obj_li__event_session,
|
load_ae_obj_li__event_presentation: event_presentation.load_ae_obj_li__event_presentation,
|
||||||
create_ae_obj__event_session: event_session.create_ae_obj__event_session,
|
create_ae_obj__event_presentation: event_presentation.create_ae_obj__event_presentation,
|
||||||
delete_ae_obj_id__event_session: event_session.delete_ae_obj_id__event_session,
|
delete_ae_obj_id__event_presentation: event_presentation.delete_ae_obj_id__event_presentation,
|
||||||
update_ae_obj__event_session: event_session.update_ae_obj__event_session,
|
update_ae_obj__event_presentation: event_presentation.update_ae_obj__event_presentation,
|
||||||
qry__event_session: event_session.qry__event_session,
|
// db_save_ae_obj_li__event_presentation: event_presentation.db_save_ae_obj_li__event_presentation,
|
||||||
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,
|
|
||||||
|
|
||||||
// Event Presentations
|
|
||||||
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,
|
|
||||||
|
|
||||||
// Event Presenters
|
|
||||||
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,
|
|
||||||
|
|
||||||
|
// Event Presenters
|
||||||
|
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
|
||||||
};
|
};
|
||||||
export let events_func = export_obj;
|
export const events_func = export_obj;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,22 +1,21 @@
|
|||||||
// This file is used to export all the functions that are used for Aether Journals related functions.
|
// 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 from '$lib/ae_journals/ae_journals__journal';
|
||||||
import * as journal_entry from "$lib/ae_journals/ae_journals__journal_entry";
|
import * as journal_entry from '$lib/ae_journals/ae_journals__journal_entry';
|
||||||
|
|
||||||
|
const export_obj = {
|
||||||
let export_obj = {
|
load_ae_obj_id__journal: journal.load_ae_obj_id__journal,
|
||||||
load_ae_obj_id__journal: journal.load_ae_obj_id__journal,
|
load_ae_obj_li__journal: journal.load_ae_obj_li__journal,
|
||||||
load_ae_obj_li__journal: journal.load_ae_obj_li__journal,
|
create_ae_obj__journal: journal.create_ae_obj__journal,
|
||||||
create_ae_obj__journal: journal.create_ae_obj__journal,
|
delete_ae_obj_id__journal: journal.delete_ae_obj_id__journal,
|
||||||
delete_ae_obj_id__journal: journal.delete_ae_obj_id__journal,
|
update_ae_obj__journal: journal.update_ae_obj__journal,
|
||||||
update_ae_obj__journal: journal.update_ae_obj__journal,
|
// db_save_ae_obj_li__journal: journal.db_save_ae_obj_li__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_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,
|
||||||
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,
|
||||||
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,
|
||||||
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,
|
||||||
update_ae_obj__journal_entry: journal_entry.update_ae_obj__journal_entry,
|
qry__journal_entry: journal_entry.qry__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,
|
||||||
// db_save_ae_obj_li__journal_entry: journal_entry.db_save_ae_obj_li__journal_entry,
|
|
||||||
};
|
};
|
||||||
export let journals_func = export_obj;
|
export const journals_func = export_obj;
|
||||||
|
|||||||
@@ -5,182 +5,181 @@ import type { Writable } from 'svelte/store';
|
|||||||
|
|
||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
|
|
||||||
|
|
||||||
/* *** BEGIN *** Initialize journals_local_data_struct */
|
/* *** BEGIN *** Initialize journals_local_data_struct */
|
||||||
// This is for longer term or sticky app data. This should be stored to *local* storage.
|
// This is for longer term or sticky app data. This should be stored to *local* storage.
|
||||||
// Updated 2025-03-20
|
// Updated 2025-03-20
|
||||||
let journals_local_data_struct: key_val = {
|
const journals_local_data_struct: key_val = {
|
||||||
ver: '2024-08-20_19',
|
ver: '2024-08-20_19',
|
||||||
// Shared
|
// Shared
|
||||||
name: 'Aether - Journals (SvelteKit 2.x Svelte 5.x)',
|
name: 'Aether - Journals (SvelteKit 2.x Svelte 5.x)',
|
||||||
title: `OSIT's Æ Journals`, // Æ
|
title: `OSIT's Æ Journals`, // Æ
|
||||||
|
|
||||||
mode__edit: false,
|
mode__edit: false,
|
||||||
mode__debug: false,
|
mode__debug: false,
|
||||||
|
|
||||||
datetime_format: 'datetime_12_long',
|
datetime_format: 'datetime_12_long',
|
||||||
time_format: 'time_12_short',
|
time_format: 'time_12_short',
|
||||||
time_hours: 12, // 12 or 24
|
time_hours: 12, // 12 or 24
|
||||||
|
|
||||||
qry__enabled: 'enabled', // all, disabled, enabled
|
qry__enabled: 'enabled', // all, disabled, enabled
|
||||||
qry__hidden: 'not_hidden', // all, hidden, not_hidden
|
qry__hidden: 'not_hidden', // all, hidden, not_hidden
|
||||||
qry__limit: 20,
|
qry__limit: 20,
|
||||||
qry__order_by_li: {
|
qry__order_by_li: {
|
||||||
// 'created_on': 'desc',
|
// 'created_on': 'desc',
|
||||||
// 'updated_on': 'desc',
|
// 'updated_on': 'desc',
|
||||||
},
|
},
|
||||||
qry__offset: 0,
|
qry__offset: 0,
|
||||||
qry__journal_id: null,
|
qry__journal_id: null,
|
||||||
|
|
||||||
journal_view_history_li: [], // Appended each time the journal is loaded.
|
journal_view_history_li: [], // Appended each time the journal is loaded.
|
||||||
entry_view_history_li: [], // NO LONGER USED: Appended each time the entry is loaded.
|
entry_view_history_li: [], // NO LONGER USED: Appended each time the entry is loaded.
|
||||||
entry_view_history_kv: {}, // Keyed by journal_entry_id for quick lookup.
|
entry_view_history_kv: {}, // Keyed by journal_entry_id for quick lookup.
|
||||||
entry_view_history_max: 15, // Maximum number of journal entries to keep in history.
|
entry_view_history_max: 15, // Maximum number of journal entries to keep in history.
|
||||||
|
|
||||||
llm__api_base_url: 'https://ai.dgrzone.com/api',
|
llm__api_base_url: 'https://ai.dgrzone.com/api',
|
||||||
llm__api_model: 'dgrzone-deepseek-8b-quick',
|
llm__api_model: 'dgrzone-deepseek-8b-quick',
|
||||||
llm__api_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVhYjI2MzdlLThiMjktNGM2Zi05MzVhLWFkYjU1MDkwMGU5MCJ9.VObfR91GrX3j1vHbHZqGsOWEyrL981cbSWWjaXfYbUQ',
|
llm__api_token:
|
||||||
llm__api_dangerous_browser: false, // This allows for use of localhost.
|
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVhYjI2MzdlLThiMjktNGM2Zi05MzVhLWFkYjU1MDkwMGU5MCJ9.VObfR91GrX3j1vHbHZqGsOWEyrL981cbSWWjaXfYbUQ',
|
||||||
llm__stream: false, // Whether to use streaming or not. Not all APIs support this.
|
llm__api_dangerous_browser: false, // This allows for use of localhost.
|
||||||
llm__timeout_ms: 60000, // 60 seconds
|
llm__stream: false, // Whether to use streaming or not. Not all APIs support this.
|
||||||
llm__max_retries: 3, // Number of times to retry a failed LLM API call.
|
llm__timeout_ms: 60000, // 60 seconds
|
||||||
llm__retry_delay_ms: 2000, // 2 seconds between retries.
|
llm__max_retries: 3, // Number of times to retry a failed LLM API call.
|
||||||
|
llm__retry_delay_ms: 2000, // 2 seconds between retries.
|
||||||
|
|
||||||
llm__system_prompt: 'You are a helpful assistant that helps people find information.',
|
llm__system_prompt: 'You are a helpful assistant that helps people find information.',
|
||||||
llm__max_tokens: 1024,
|
llm__max_tokens: 1024,
|
||||||
llm__temperature: 0.7,
|
llm__temperature: 0.7,
|
||||||
llm__top_p: 1.0,
|
llm__top_p: 1.0,
|
||||||
llm__n: 1,
|
llm__n: 1,
|
||||||
llm__frequency_penalty: 0.0,
|
llm__frequency_penalty: 0.0,
|
||||||
llm__presence_penalty: 0.0,
|
llm__presence_penalty: 0.0,
|
||||||
|
|
||||||
journal: {
|
journal: {
|
||||||
edit: false,
|
edit: false,
|
||||||
edit_kv: {},
|
edit_kv: {},
|
||||||
|
|
||||||
type_code_li: [
|
type_code_li: [
|
||||||
{ code: 'diary', name: 'Diary' },
|
{ code: 'diary', name: 'Diary' },
|
||||||
{ code: 'log', name: 'Log' },
|
{ code: 'log', name: 'Log' },
|
||||||
{ code: 'journal', name: 'Journal' },
|
{ code: 'journal', name: 'Journal' },
|
||||||
{ code: 'notebook', name: 'Notebook' },
|
{ code: 'notebook', name: 'Notebook' },
|
||||||
{ code: 'personal', name: 'Personal' },
|
{ code: 'personal', name: 'Personal' },
|
||||||
{ code: 'professional', name: 'Professional' },
|
{ code: 'professional', name: 'Professional' },
|
||||||
{ code: 'tracking', name: 'Tracking' },
|
{ code: 'tracking', name: 'Tracking' },
|
||||||
{ code: 'other', name: 'Other' },
|
{ code: 'other', name: 'Other' },
|
||||||
{ code: 'test', name: 'Test' },
|
{ code: 'test', name: 'Test' }
|
||||||
// { code: 'notepad', name: 'Notepad' },
|
// { code: 'notepad', name: 'Notepad' },
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
entry: {
|
entry: {
|
||||||
llm__system_prompt: 'Summarize the following journal entry content in a concise manner, focusing on key points and insights.',
|
llm__system_prompt:
|
||||||
llm__max_tokens: 512,
|
'Summarize the following journal entry content in a concise manner, focusing on key points and insights.',
|
||||||
llm__temperature: 0.7,
|
llm__max_tokens: 512,
|
||||||
llm__top_p: 1.0,
|
llm__temperature: 0.7,
|
||||||
llm__n: 1,
|
llm__top_p: 1.0,
|
||||||
llm__frequency_penalty: 0.0,
|
llm__n: 1,
|
||||||
llm__presence_penalty: 0.0,
|
llm__frequency_penalty: 0.0,
|
||||||
|
llm__presence_penalty: 0.0,
|
||||||
edit: false,
|
|
||||||
edit_kv: {},
|
|
||||||
},
|
|
||||||
|
|
||||||
|
edit: false,
|
||||||
|
edit_kv: {}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// console.log(`AE Stores - App Journals Local Storage Data:`, journals_local_data_struct);
|
// console.log(`AE Stores - App Journals Local Storage Data:`, journals_local_data_struct);
|
||||||
|
|
||||||
// This works and uses *local* storage:
|
// This works and uses *local* storage:
|
||||||
export let journals_loc: Writable<key_val> = persisted('ae_journals_loc', journals_local_data_struct);
|
export const journals_loc: Writable<key_val> = persisted(
|
||||||
|
'ae_journals_loc',
|
||||||
|
journals_local_data_struct
|
||||||
|
);
|
||||||
// console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
|
// console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
|
||||||
|
|
||||||
|
|
||||||
/* *** BEGIN *** Initialize journals_session_data_struct */
|
/* *** 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.
|
// 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
|
// Updated 2025-03-20
|
||||||
let journals_session_data_struct: key_val = {
|
const journals_session_data_struct: key_val = {
|
||||||
ver: '2024-08-20_19',
|
ver: '2024-08-20_19',
|
||||||
log_lvl: 1,
|
log_lvl: 1,
|
||||||
|
|
||||||
// Shared Triggers
|
// Shared Triggers
|
||||||
trigger: null,
|
trigger: null,
|
||||||
trigger__journal_id: null,
|
trigger__journal_id: null,
|
||||||
// trigger__journal_li: null,
|
// trigger__journal_li: null,
|
||||||
|
|
||||||
show__modal__journals_config: false,
|
show__modal__journals_config: false,
|
||||||
|
|
||||||
show__modal_edit__journal_obj: false,
|
show__modal_edit__journal_obj: false,
|
||||||
show__modal_new__journal_obj: false,
|
show__modal_new__journal_obj: false,
|
||||||
show__modal_view__journal_id: null,
|
show__modal_view__journal_id: null,
|
||||||
show_list__journal_entry_li_group: true,
|
show_list__journal_entry_li_group: true,
|
||||||
show__modal_view__journal_entry_id: null,
|
show__modal_view__journal_entry_id: null,
|
||||||
show__modal_edit__journal_entry_id: null,
|
show__modal_edit__journal_entry_id: null,
|
||||||
|
|
||||||
show__content__journal_entry_history: false,
|
show__content__journal_entry_history: false,
|
||||||
|
|
||||||
journal: {
|
journal: {
|
||||||
edit: false,
|
edit: false,
|
||||||
edit_kv: {},
|
edit_kv: {},
|
||||||
|
|
||||||
new_journal_name: '',
|
new_journal_name: '',
|
||||||
new_journal_type_code: '',
|
new_journal_type_code: '',
|
||||||
|
|
||||||
tmp_obj: {},
|
tmp_obj: {}
|
||||||
},
|
},
|
||||||
entry: {
|
entry: {
|
||||||
show__ai_summary: false,
|
show__ai_summary: false,
|
||||||
ai_summary: '',
|
ai_summary: '',
|
||||||
decrypt_kv: {}, // Essentially flag that the entry (content and history) can be decrypted.
|
decrypt_kv: {}, // Essentially flag that the entry (content and history) can be decrypted.
|
||||||
edit: false,
|
edit: false,
|
||||||
edit_kv: {},
|
edit_kv: {},
|
||||||
|
|
||||||
tmp_obj: {},
|
tmp_obj: {}
|
||||||
},
|
},
|
||||||
|
|
||||||
journal_kv: {
|
journal_kv: {
|
||||||
// journal_id: {},
|
// journal_id: {},
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
// console.log(`AE Stores - App Journals Session Storage Data:`, journals_session_data_struct);
|
// console.log(`AE Stores - App Journals Session Storage Data:`, journals_session_data_struct);
|
||||||
export let journals_sess = writable(journals_session_data_struct);
|
export const journals_sess = writable(journals_session_data_struct);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* *** BEGIN *** Initialize journals_slct and journals_trig */
|
/* *** 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. */
|
/* 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.
|
// Intended for temporary session storage.
|
||||||
// Updated 2024-08-20
|
// Updated 2024-08-20
|
||||||
let journals_slct_obj_template: key_val = {
|
const journals_slct_obj_template: key_val = {
|
||||||
// Top level
|
// Top level
|
||||||
'journal_id': null,
|
journal_id: null,
|
||||||
'journal_obj': {},
|
journal_obj: {},
|
||||||
'journal_obj_li': [],
|
journal_obj_li: [],
|
||||||
|
|
||||||
'tmp_journal_obj': {}, // Temporary object for new journal
|
tmp_journal_obj: {}, // Temporary object for new journal
|
||||||
'tmp_journal_entry_obj': {}, // Temporary object for new journal entry
|
tmp_journal_entry_obj: {}, // Temporary object for new journal entry
|
||||||
|
|
||||||
'lq__journal_obj': {}, // Testing passing a LiveQuery object around...
|
lq__journal_obj: {} // Testing passing a LiveQuery object around...
|
||||||
};
|
};
|
||||||
// console.log(`AE Stores - Selected Journals Objects:`, journals_slct_obj_template);
|
// console.log(`AE Stores - Selected Journals Objects:`, journals_slct_obj_template);
|
||||||
|
|
||||||
// This works, and uses *session* (not local) storage:
|
// This works, and uses *session* (not local) storage:
|
||||||
export let journals_slct = writable(journals_slct_obj_template);
|
export const journals_slct = writable(journals_slct_obj_template);
|
||||||
|
|
||||||
|
|
||||||
/* *** BEGIN *** Initialize journals_trig */
|
/* *** BEGIN *** Initialize journals_trig */
|
||||||
// Intended for temporary session storage.
|
// Intended for temporary session storage.
|
||||||
// Updated 2025-03-16
|
// Updated 2025-03-16
|
||||||
let journals_trig_template: key_val = {
|
const journals_trig_template: key_val = {
|
||||||
journal_id: false,
|
journal_id: false,
|
||||||
journal_entry_li: false,
|
journal_entry_li: false
|
||||||
};
|
};
|
||||||
export let journals_trig: any = writable(journals_trig_template);
|
export const journals_trig: any = writable(journals_trig_template);
|
||||||
// console.log(`AE Journals Stores - Journals Trigger:`, journals_trig);
|
// console.log(`AE Journals Stores - Journals Trigger:`, journals_trig);
|
||||||
|
|
||||||
|
|
||||||
/* *** BEGIN *** Initialize journals_prom */
|
/* *** BEGIN *** Initialize journals_prom */
|
||||||
// Intended for temporary session storage.
|
// Intended for temporary session storage.
|
||||||
// Updated 2025-03-16
|
// Updated 2025-03-16
|
||||||
let journals_prom_template: key_val = {
|
const journals_prom_template: key_val = {
|
||||||
journal_id: false,
|
journal_id: false,
|
||||||
journal_entry_li: false,};
|
journal_entry_li: false
|
||||||
export let journals_prom: any = writable(journals_prom_template);
|
};
|
||||||
|
export const journals_prom: any = writable(journals_prom_template);
|
||||||
// console.log(`AE Journals Stores - Journals Trigger:`, journals_prom);
|
// console.log(`AE Journals Stores - Journals Trigger:`, journals_prom);
|
||||||
|
|||||||
@@ -9,512 +9,510 @@ import type { key_val } from '$lib/stores/ae_stores';
|
|||||||
// LLM = Large Language Model (AI)
|
// LLM = Large Language Model (AI)
|
||||||
// Updated 2025-03-15
|
// Updated 2025-03-15
|
||||||
|
|
||||||
|
|
||||||
export interface Journal {
|
export interface Journal {
|
||||||
id: string; // actually "id_random"
|
id: string; // actually "id_random"
|
||||||
journal_id: string;
|
journal_id: string;
|
||||||
|
|
||||||
// Essentially this is a change log of journals
|
// Essentially this is a change log of journals
|
||||||
snapshot_id?: string; // This is the original journal ID. If deleted, then delete all children 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
|
previous_id?: null | string; // This is the old or parent journal ID
|
||||||
next_id?: null|string; // This is the new or child journal ID
|
next_id?: null | string; // This is the new or child journal ID
|
||||||
|
|
||||||
external_id?: null|string;
|
external_id?: null | string;
|
||||||
import_id?: null|string;
|
import_id?: null | string;
|
||||||
code?: null|string;
|
code?: null | string;
|
||||||
|
|
||||||
for_type?: null|string;
|
for_type?: null | string;
|
||||||
for_id?: null|string;
|
for_id?: null | string;
|
||||||
|
|
||||||
// template?: null|boolean; // Is this a template journal? If true, it can be used to create new journals.
|
// template?: null|boolean; // Is this a template journal? If true, it can be used to create new journals.
|
||||||
|
|
||||||
type_code?: null|string;
|
type_code?: null | string;
|
||||||
|
|
||||||
account_id?: null|string; // Owner account of the journal
|
account_id?: null | string; // Owner account of the journal
|
||||||
person_id?: null|string; // Owner person of the journal
|
person_id?: null | string; // Owner person of the journal
|
||||||
// event_id?: null|string; // Assign to an event???
|
// event_id?: null|string; // Assign to an event???
|
||||||
// location_id?: null|string; // Assign to a location???
|
// location_id?: null|string; // Assign to a location???
|
||||||
|
|
||||||
name: string; // or the title
|
name: string; // or the title
|
||||||
short_name?: null|string; // Short name for the journal, if any. Used for display purposes.
|
short_name?: null | string; // Short name for the journal, if any. Used for display purposes.
|
||||||
summary?: null|string; // LLM (AI) generated summary...???
|
summary?: null | string; // LLM (AI) generated summary...???
|
||||||
outline?: null|string; // LLM (AI) generated outline...???
|
outline?: null | string; // LLM (AI) generated outline...???
|
||||||
|
|
||||||
description?: null|string;
|
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?: 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_md_html_alt?: null | string; // Markdown converted to HTML based on description. Uses marked or similar library for conversion.
|
||||||
description_html?: null|string;
|
description_html?: null | string;
|
||||||
description_json?: null|string;
|
description_json?: null | string;
|
||||||
|
|
||||||
start_datetime?: null|Date;
|
start_datetime?: null | Date;
|
||||||
end_datetime?: null|Date;
|
end_datetime?: null | Date;
|
||||||
timezone?: null|string;
|
timezone?: null | string;
|
||||||
|
|
||||||
alert?: null|boolean; // LLM (AI) generated summary...???
|
alert?: null | boolean; // LLM (AI) generated summary...???
|
||||||
alert_msg?: null|string; // LLM (AI) generated summary...???
|
alert_msg?: null | string; // LLM (AI) generated summary...???
|
||||||
|
|
||||||
sort_by?: null|string; // This is the sort by field
|
sort_by?: null | string; // This is the sort by field
|
||||||
sort_by_desc?: null|string; // This is the sort by field description
|
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
|
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...
|
data_json?: null | key_val; // We always need to store something extra...
|
||||||
|
|
||||||
ux_mode?: null|string; // 'mobile' or 'desktop'
|
ux_mode?: null | string; // 'mobile' or 'desktop'
|
||||||
|
|
||||||
// This only allows for basic access to the data.
|
// This only allows for basic access to the data.
|
||||||
passcode_read?: null|string; // For LLM (AI) generated summary...???
|
passcode_read?: null | string; // For LLM (AI) generated summary...???
|
||||||
passcode_read_expire?: null|Date;
|
passcode_read_expire?: null | Date;
|
||||||
passcode_write?: null|string;
|
passcode_write?: null | string;
|
||||||
passcode_write_expire?: null|Date
|
passcode_write_expire?: null | Date;
|
||||||
|
|
||||||
passcode?: null|string; // For Journal Entry encryption password
|
passcode?: null | string; // For Journal Entry encryption password
|
||||||
passcode_timeout?: null|number; // Timeout in seconds
|
passcode_timeout?: null | number; // Timeout in seconds
|
||||||
|
|
||||||
private_passcode?: null|string; // Combine with the Journal passcode for Journal Entry encryption password
|
private_passcode?: null | string; // Combine with the Journal passcode for Journal Entry encryption password
|
||||||
|
|
||||||
auth_key?: null|string; // For Journal authorization without sign in
|
auth_key?: null | string; // For Journal authorization without sign in
|
||||||
|
|
||||||
enable: null|boolean;
|
enable: null | boolean;
|
||||||
hide?: null|boolean;
|
hide?: null | boolean;
|
||||||
archive?: null|boolean; // Archive the journal
|
archive?: null | boolean; // Archive the journal
|
||||||
archive_on?: null|Date;
|
archive_on?: null | Date;
|
||||||
priority?: null|boolean
|
priority?: null | boolean;
|
||||||
sort?: null|number;
|
sort?: null | number;
|
||||||
group?: null|string;
|
group?: null | string;
|
||||||
notes?: null|string;
|
notes?: null | string;
|
||||||
created_on: Date;
|
created_on: Date;
|
||||||
updated_on?: null|Date;
|
updated_on?: null | Date;
|
||||||
|
|
||||||
// Generated fields for sorting locally only
|
// Generated fields for sorting locally only
|
||||||
tmp_sort_1?: null|string;
|
tmp_sort_1?: null | string;
|
||||||
tmp_sort_2?: null|string;
|
tmp_sort_2?: null | string;
|
||||||
tmp_sort_3?: null|string;
|
tmp_sort_3?: null | string;
|
||||||
|
|
||||||
combined_passcode?: null|string; // For Journal Entry encryption password
|
combined_passcode?: null | string; // For Journal Entry encryption password
|
||||||
|
|
||||||
// Additional fields for convenience (database views)
|
// Additional fields for convenience (database views)
|
||||||
file_count?: null|number; // Only files directly under a journal
|
file_count?: null | number; // Only files directly under a journal
|
||||||
journal_file_id_li_json?: null|string;
|
journal_file_id_li_json?: null | string;
|
||||||
|
|
||||||
// One person
|
// One person
|
||||||
person__given_name?: null|string;
|
person__given_name?: null | string;
|
||||||
person__family_name?: null|string;
|
person__family_name?: null | string;
|
||||||
person__full_name?: null|string;
|
person__full_name?: null | string;
|
||||||
person__primary_email?: null|string;
|
person__primary_email?: null | string;
|
||||||
person__passcode?: null|string;
|
person__passcode?: null | string;
|
||||||
|
|
||||||
// JSON formatted key value pairs for multiple people: {id: name, email, etc.}
|
// JSON formatted key value pairs for multiple people: {id: name, email, etc.}
|
||||||
person__kv_json?: null|string;
|
person__kv_json?: null | string;
|
||||||
|
|
||||||
journal_name?: null|string;
|
journal_name?: null | string;
|
||||||
|
|
||||||
journal_location_code?: null|string;
|
journal_location_code?: null | string;
|
||||||
journal_location_name?: null|string;
|
journal_location_name?: null | string;
|
||||||
|
|
||||||
journal_entry_count?: null|number;
|
journal_entry_count?: null | number;
|
||||||
|
|
||||||
// A key value list of the entries
|
// A key value list of the entries
|
||||||
journal_entry_kv?: null|key_val;
|
journal_entry_kv?: null | key_val;
|
||||||
journal_entry_li?: null|[];
|
journal_entry_li?: null | [];
|
||||||
// A key value list of the files
|
// A key value list of the files
|
||||||
journal_file_kv?: null|key_val;
|
journal_file_kv?: null | key_val;
|
||||||
journal_file_li?: null|[];
|
journal_file_li?: null | [];
|
||||||
|
|
||||||
// journal_collection_id?: null|string; // For a collection of journals?
|
// journal_collection_id?: null|string; // For a collection of journals?
|
||||||
|
|
||||||
// Future standard fields!!!
|
// Future standard fields!!!
|
||||||
obj_id?: null|string;
|
obj_id?: null | string;
|
||||||
obj_ext_uid?: null|string; // Probably not needed for journals
|
obj_ext_uid?: null | string; // Probably not needed for journals
|
||||||
obj_ext_id?: 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_import_id?: null | string; // Probably not needed for journals
|
||||||
obj_code?: null|string;
|
obj_code?: null | string;
|
||||||
obj_account_id?: null|string;
|
obj_account_id?: null | string;
|
||||||
obj_passcode?: null|string;
|
obj_passcode?: null | string;
|
||||||
obj_type?: null|string; // Should always be 'journal' in this case
|
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_type_ver_id?: null | string; // The ID from the table for the object type
|
||||||
obj_name?: null|string;
|
obj_name?: null | string;
|
||||||
obj_summary?: null|string; // LLM (AI) generated summary...???
|
obj_summary?: null | string; // LLM (AI) generated summary...???
|
||||||
obj_outline?: null|string; // LLM (AI) generated outline...???
|
obj_outline?: null | string; // LLM (AI) generated outline...???
|
||||||
obj_description?: null|string; // Probably not needed for journals
|
obj_description?: null | string; // Probably not needed for journals
|
||||||
obj_enable?: null|boolean;
|
obj_enable?: null | boolean;
|
||||||
obj_enable_on?: null|Date;
|
obj_enable_on?: null | Date;
|
||||||
obj_archive_on?: null|Date;
|
obj_archive_on?: null | Date;
|
||||||
obj_hide?: null|boolean;
|
obj_hide?: null | boolean;
|
||||||
obj_priority?: null|number;
|
obj_priority?: null | number;
|
||||||
obj_sort?: null|number;
|
obj_sort?: null | number;
|
||||||
obj_group?: null|string;
|
obj_group?: null | string;
|
||||||
obj_cfg_json?: null|string;
|
obj_cfg_json?: null | string;
|
||||||
obj_notes?: null|string;
|
obj_notes?: null | string;
|
||||||
obj_created_on?: Date;
|
obj_created_on?: Date;
|
||||||
obj_updated_on?: null|Date;
|
obj_updated_on?: null | Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const journal_field_li = [
|
export const journal_field_li = [
|
||||||
'id',
|
'id',
|
||||||
'journal_id',
|
'journal_id',
|
||||||
'snapshot_id',
|
'snapshot_id',
|
||||||
'previous_id',
|
'previous_id',
|
||||||
'next_id',
|
'next_id',
|
||||||
'external_id',
|
'external_id',
|
||||||
'import_id',
|
'import_id',
|
||||||
'code',
|
'code',
|
||||||
'for_type',
|
'for_type',
|
||||||
'for_id',
|
'for_id',
|
||||||
'type_code',
|
'type_code',
|
||||||
'account_id',
|
'account_id',
|
||||||
'person_id',
|
'person_id',
|
||||||
'name',
|
'name',
|
||||||
'short_name',
|
'short_name',
|
||||||
'summary',
|
'summary',
|
||||||
'outline',
|
'outline',
|
||||||
'description',
|
'description',
|
||||||
'description_md_html',
|
'description_md_html',
|
||||||
'description_md_html_alt',
|
'description_md_html_alt',
|
||||||
'description_html',
|
'description_html',
|
||||||
'description_json',
|
'description_json',
|
||||||
'start_datetime',
|
'start_datetime',
|
||||||
'end_datetime',
|
'end_datetime',
|
||||||
'timezone',
|
'timezone',
|
||||||
'alert',
|
'alert',
|
||||||
'alert_msg',
|
'alert_msg',
|
||||||
'sort_by',
|
'sort_by',
|
||||||
'sort_by_desc',
|
'sort_by_desc',
|
||||||
'cfg_json',
|
'cfg_json',
|
||||||
'data_json',
|
'data_json',
|
||||||
'ux_mode',
|
'ux_mode',
|
||||||
'passcode_read',
|
'passcode_read',
|
||||||
'passcode_read_expire',
|
'passcode_read_expire',
|
||||||
'passcode_write',
|
'passcode_write',
|
||||||
'passcode_write_expire',
|
'passcode_write_expire',
|
||||||
'passcode_timeout',
|
'passcode_timeout',
|
||||||
'private_passcode',
|
'private_passcode',
|
||||||
'auth_key',
|
'auth_key',
|
||||||
'enable',
|
'enable',
|
||||||
'hide',
|
'hide',
|
||||||
'archive', // Archive the journal
|
'archive', // Archive the journal
|
||||||
'archive_on', // Archive date
|
'archive_on', // Archive date
|
||||||
'priority', // Priority flag
|
'priority', // Priority flag
|
||||||
'sort', // Sort order
|
'sort', // Sort order
|
||||||
'group', // Group name
|
'group', // Group name
|
||||||
'notes', // Notes about the journal
|
'notes', // Notes about the journal
|
||||||
'created_on', // Creation date
|
'created_on', // Creation date
|
||||||
'updated_on', // Last updated date
|
'updated_on', // Last updated date
|
||||||
|
|
||||||
'tmp_sort_1', // Temporary sort field 1
|
'tmp_sort_1', // Temporary sort field 1
|
||||||
'tmp_sort_2', // Temporary sort field 2
|
'tmp_sort_2', // Temporary sort field 2
|
||||||
'tmp_sort_3', // Temporary sort field 3
|
'tmp_sort_3', // Temporary sort field 3
|
||||||
|
|
||||||
'combined_passcode', // For Journal Entry encryption password
|
'combined_passcode', // For Journal Entry encryption password
|
||||||
'file_count', // Only files directly under a journal
|
'file_count', // Only files directly under a journal
|
||||||
'journal_file_id_li_json', // JSON string of file IDs
|
'journal_file_id_li_json', // JSON string of file IDs
|
||||||
'person__given_name', // Person's given name
|
'person__given_name', // Person's given name
|
||||||
'person__family_name', // Person's family name
|
'person__family_name', // Person's family name
|
||||||
'person__full_name', // Person's full name
|
'person__full_name', // Person's full name
|
||||||
'person__primary_email', // Person's primary email
|
'person__primary_email', // Person's primary email
|
||||||
'person__passcode', // Person's passcode
|
'person__passcode', // Person's passcode
|
||||||
'person__kv_json', // JSON formatted key value pairs for multiple people
|
'person__kv_json', // JSON formatted key value pairs for multiple people
|
||||||
'journal_name', // Journal name
|
'journal_name', // Journal name
|
||||||
'journal_location_code', // Journal location code
|
'journal_location_code', // Journal location code
|
||||||
'journal_location_name', // Journal location name
|
'journal_location_name', // Journal location name
|
||||||
'journal_entry_count', // Count of journal entries
|
'journal_entry_count', // Count of journal entries
|
||||||
'journal_entry_kv', // Key value list of the entries
|
'journal_entry_kv', // Key value list of the entries
|
||||||
'journal_entry_li', // List of journal entries
|
'journal_entry_li', // List of journal entries
|
||||||
'journal_file_kv', // Key value list of the files
|
'journal_file_kv', // Key value list of the files
|
||||||
'journal_file_li', // List of journal files
|
'journal_file_li', // List of journal files
|
||||||
|
|
||||||
'obj_id', // Object ID
|
'obj_id', // Object ID
|
||||||
'obj_ext_uid', // External UID
|
'obj_ext_uid', // External UID
|
||||||
'obj_ext_id', // External ID
|
'obj_ext_id', // External ID
|
||||||
'obj_import_id', // Import ID
|
'obj_import_id', // Import ID
|
||||||
'obj_code', // Object code
|
'obj_code', // Object code
|
||||||
'obj_account_id', // Object account ID
|
'obj_account_id', // Object account ID
|
||||||
'obj_passcode', // Object passcode
|
'obj_passcode', // Object passcode
|
||||||
'obj_type', // Object type
|
'obj_type', // Object type
|
||||||
'obj_type_ver_id', // Object type version ID
|
'obj_type_ver_id', // Object type version ID
|
||||||
'obj_name', // Object name
|
'obj_name', // Object name
|
||||||
'obj_summary', // Object summary
|
'obj_summary', // Object summary
|
||||||
'obj_outline', // Object outline
|
'obj_outline', // Object outline
|
||||||
'obj_description', // Object description
|
'obj_description', // Object description
|
||||||
'obj_enable', // Object enable flag
|
'obj_enable', // Object enable flag
|
||||||
'obj_enable_on', // Object enable date
|
'obj_enable_on', // Object enable date
|
||||||
'obj_archive_on', // Object archive date
|
'obj_archive_on', // Object archive date
|
||||||
'obj_hide', // Object hide flag
|
'obj_hide', // Object hide flag
|
||||||
'obj_priority', // Object priority
|
'obj_priority', // Object priority
|
||||||
'obj_sort', // Object sort order
|
'obj_sort', // Object sort order
|
||||||
'obj_group', // Object group name
|
'obj_group', // Object group name
|
||||||
'obj_cfg_json', // Object configuration JSON
|
'obj_cfg_json', // Object configuration JSON
|
||||||
'obj_notes', // Object notes
|
'obj_notes', // Object notes
|
||||||
'obj_created_on', // Object creation date
|
'obj_created_on', // Object creation date
|
||||||
'obj_updated_on' // Object last updated date
|
'obj_updated_on' // Object last updated date
|
||||||
];
|
];
|
||||||
|
|
||||||
// Updated 2025-04-02
|
// Updated 2025-04-02
|
||||||
export interface Journal_Entry {
|
export interface Journal_Entry {
|
||||||
id: string; // actually "id_random"
|
id: string; // actually "id_random"
|
||||||
journal_entry_id: string;
|
journal_entry_id: string;
|
||||||
|
|
||||||
journal_id: string; // This is the parent journal ID. If deleted, then delete all children journal entries.
|
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
|
// 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.
|
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
|
previous_id?: null | string; // This is the old or parent journal ID
|
||||||
next_id?: null|string; // This is the new or child journal ID
|
next_id?: null | string; // This is the new or child journal ID
|
||||||
|
|
||||||
external_id?: null|string;
|
external_id?: null | string;
|
||||||
import_id?: null|string;
|
import_id?: null | string;
|
||||||
code?: null|string;
|
code?: null | string;
|
||||||
|
|
||||||
for_type?: null|string;
|
for_type?: null | string;
|
||||||
for_id?: 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.
|
template?: null | boolean; // Is this a template journal entry? If true, it can be used to create new journal entries.
|
||||||
|
|
||||||
activity_code?: null|string;
|
activity_code?: null | string;
|
||||||
category_code?: null|string;
|
category_code?: null | string;
|
||||||
topic_code?: null|string;
|
topic_code?: null | string;
|
||||||
type_code?: null|string;
|
type_code?: null | string;
|
||||||
tags?: null|string; // Comma separated tags
|
tags?: null | string; // Comma separated tags
|
||||||
|
|
||||||
journal_entry_type?: null|string; // This is the type of journal entry
|
journal_entry_type?: null | string; // This is the type of journal entry
|
||||||
|
|
||||||
account_id?: null|string; // Owner account of the journal
|
account_id?: null | string; // Owner account of the journal
|
||||||
person_id?: null|string; // Owner person of the journal
|
person_id?: null | string; // Owner person of the journal
|
||||||
// event_id?: null|string; // Assign to an event???
|
// event_id?: null|string; // Assign to an event???
|
||||||
// location_id?: null|string; // Assign to a location???
|
// location_id?: null|string; // Assign to a location???
|
||||||
|
|
||||||
public?: null|boolean;
|
public?: null | boolean;
|
||||||
private?: null|boolean;
|
private?: null | boolean;
|
||||||
personal?: null|boolean;
|
personal?: null | boolean;
|
||||||
professional?: null|boolean;
|
professional?: null | boolean;
|
||||||
|
|
||||||
name: string; // or the title
|
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.
|
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...???
|
summary?: null | string; // LLM (AI) generated summary...???
|
||||||
outline?: null|string; // LLM (AI) generated outline...???
|
outline?: null | string; // LLM (AI) generated outline...???
|
||||||
// description?: null|string; // This is the description of the journal entry
|
// description?: null|string; // This is the description of the journal entry
|
||||||
|
|
||||||
content?: null|string;
|
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?: 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_md_html_alt?: null | string; // Markdown converted to HTML based on content. Uses marked or similar library for conversion.
|
||||||
content_html?: null|string;
|
content_html?: null | string;
|
||||||
content_json?: null|string;
|
content_json?: null | string;
|
||||||
content_encrypted?: null|string; // This is the encrypted content of the journal entry
|
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?: 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
|
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
|
passcode_hash?: null | string; // This is the passcode hash for the journal entry to look up the passcode
|
||||||
|
|
||||||
start_datetime?: null|Date;
|
start_datetime?: null | Date;
|
||||||
end_datetime?: null|Date;
|
end_datetime?: null | Date;
|
||||||
timezone?: null|string;
|
timezone?: null | string;
|
||||||
seconds?: null|number; // Duration in seconds
|
seconds?: null | number; // Duration in seconds
|
||||||
|
|
||||||
location?: null|string; // Location of the journal entry
|
location?: null | string; // Location of the journal entry
|
||||||
latitude?: null|number; // Latitude of the journal entry
|
latitude?: null | number; // Latitude of the journal entry
|
||||||
longitude?: null|number; // Longitude of the journal entry
|
longitude?: null | number; // Longitude of the journal entry
|
||||||
|
|
||||||
billable?: null|boolean; // Is this billable?
|
billable?: null | boolean; // Is this billable?
|
||||||
bill_to?: null|string; // Who to bill for this journal entry
|
bill_to?: null | string; // Who to bill for this journal entry
|
||||||
bill_rate?: null|number; // Rate 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
|
billable_minutes?: null | number; // Billable minutes for this journal entry
|
||||||
|
|
||||||
alert?: null|boolean; // LLM (AI) generated summary...???
|
alert?: null | boolean; // LLM (AI) generated summary...???
|
||||||
alert_msg?: null|string; // 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.
|
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
|
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
|
// 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...
|
data_json?: null | key_val; // We always need to store something extra...
|
||||||
|
|
||||||
// This only allows for basic access to the content.
|
// This only allows for basic access to the content.
|
||||||
passcode_read?: null|string; // For LLM (AI) generated summary...???
|
passcode_read?: null | string; // For LLM (AI) generated summary...???
|
||||||
passcode_read_expire?: null|Date;
|
passcode_read_expire?: null | Date;
|
||||||
passcode_write?: null|string;
|
passcode_write?: null | string;
|
||||||
passcode_write_expire?: null|Date
|
passcode_write_expire?: null | Date;
|
||||||
|
|
||||||
enable: null|boolean;
|
enable: null | boolean;
|
||||||
hide?: null|boolean;
|
hide?: null | boolean;
|
||||||
priority?: null|boolean
|
priority?: null | boolean;
|
||||||
sort?: null|number;
|
sort?: null | number;
|
||||||
group?: null|string;
|
group?: null | string;
|
||||||
notes?: null|string;
|
notes?: null | string;
|
||||||
created_on: Date;
|
created_on: Date;
|
||||||
updated_on?: null|Date;
|
updated_on?: null | Date;
|
||||||
|
|
||||||
// Generated fields for sorting locally only
|
// Generated fields for sorting locally only
|
||||||
tmp_sort_1?: null|string;
|
tmp_sort_1?: null | string;
|
||||||
tmp_sort_2?: null|string;
|
tmp_sort_2?: null | string;
|
||||||
tmp_sort_3?: null|string;
|
tmp_sort_3?: null | string;
|
||||||
|
|
||||||
// Additional fields for convenience (database views)
|
// Additional fields for convenience (database views)
|
||||||
file_count?: null|number; // Only files directly under a journal
|
file_count?: null | number; // Only files directly under a journal
|
||||||
journal_file_id_li_json?: null|string;
|
journal_file_id_li_json?: null | string;
|
||||||
|
|
||||||
journal_code?: null|string; // This is the code for the journal entry
|
journal_code?: null | string; // This is the code for the journal entry
|
||||||
journal_name?: null|string; // This is the name for the journal entry
|
journal_name?: null | string; // This is the name for the journal entry
|
||||||
|
|
||||||
// One person
|
// One person
|
||||||
person__given_name?: null|string;
|
person__given_name?: null | string;
|
||||||
person__family_name?: null|string;
|
person__family_name?: null | string;
|
||||||
person__full_name?: null|string;
|
person__full_name?: null | string;
|
||||||
person__primary_email?: null|string;
|
person__primary_email?: null | string;
|
||||||
person__passcode?: null|string;
|
person__passcode?: null | string;
|
||||||
|
|
||||||
// JSON formatted key value pairs for multiple people: {id: name, email, etc.}
|
// JSON formatted key value pairs for multiple people: {id: name, email, etc.}
|
||||||
person__kv_json?: null|string;
|
person__kv_json?: null | string;
|
||||||
|
|
||||||
// A key value list of the files
|
// A key value list of the files
|
||||||
journal_file_kv?: null|key_val;
|
journal_file_kv?: null | key_val;
|
||||||
journal_file_li?: null|[];
|
journal_file_li?: null | [];
|
||||||
|
|
||||||
// journal_collection_id?: null|string; // For a collection of journal entries?
|
// journal_collection_id?: null|string; // For a collection of journal entries?
|
||||||
|
|
||||||
// Future standard fields!!!
|
// Future standard fields!!!
|
||||||
obj_id?: null|string;
|
obj_id?: null | string;
|
||||||
obj_ext_uid?: null|string; // Probably not needed for journal entries
|
obj_ext_uid?: null | string; // Probably not needed for journal entries
|
||||||
obj_ext_id?: 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_import_id?: null | string; // Probably not needed for journal entries
|
||||||
obj_code?: null|string;
|
obj_code?: null | string;
|
||||||
obj_account_id?: null|string;
|
obj_account_id?: null | string;
|
||||||
obj_passcode?: null|string;
|
obj_passcode?: null | string;
|
||||||
obj_type?: null|string; // Should always be 'journal' in this case
|
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_type_ver_id?: null | string; // The ID from the table for the object type
|
||||||
obj_name?: null|string;
|
obj_name?: null | string;
|
||||||
obj_summary?: null|string; // LLM (AI) generated summary...???
|
obj_summary?: null | string; // LLM (AI) generated summary...???
|
||||||
obj_outline?: null|string; // LLM (AI) generated outline...???
|
obj_outline?: null | string; // LLM (AI) generated outline...???
|
||||||
obj_description?: null|string; // Probably not needed for journal entries
|
obj_description?: null | string; // Probably not needed for journal entries
|
||||||
obj_enable?: null|boolean;
|
obj_enable?: null | boolean;
|
||||||
obj_enable_on?: null|Date;
|
obj_enable_on?: null | Date;
|
||||||
obj_archive_on?: null|Date;
|
obj_archive_on?: null | Date;
|
||||||
obj_hide?: null|boolean;
|
obj_hide?: null | boolean;
|
||||||
obj_priority?: null|number;
|
obj_priority?: null | number;
|
||||||
obj_sort?: null|number;
|
obj_sort?: null | number;
|
||||||
obj_group?: null|string;
|
obj_group?: null | string;
|
||||||
obj_cfg_json?: null|string;
|
obj_cfg_json?: null | string;
|
||||||
obj_notes?: null|string;
|
obj_notes?: null | string;
|
||||||
obj_created_on?: Date;
|
obj_created_on?: Date;
|
||||||
obj_updated_on?: null|Date;
|
obj_updated_on?: null | Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const journal_entry_field_li = [
|
export const journal_entry_field_li = [
|
||||||
'id',
|
'id',
|
||||||
'journal_entry_id',
|
'journal_entry_id',
|
||||||
'journal_id',
|
'journal_id',
|
||||||
'code',
|
'code',
|
||||||
'for_type',
|
'for_type',
|
||||||
'for_id',
|
'for_id',
|
||||||
'template',
|
'template',
|
||||||
'activity_code',
|
'activity_code',
|
||||||
'category_code',
|
'category_code',
|
||||||
'topic_code',
|
'topic_code',
|
||||||
'type_code',
|
'type_code',
|
||||||
'tags',
|
'tags',
|
||||||
'journal_entry_type',
|
'journal_entry_type',
|
||||||
'account_id',
|
'account_id',
|
||||||
'person_id',
|
'person_id',
|
||||||
'public',
|
'public',
|
||||||
'private',
|
'private',
|
||||||
'personal',
|
'personal',
|
||||||
'professional',
|
'professional',
|
||||||
'name',
|
'name',
|
||||||
'short_name',
|
'short_name',
|
||||||
'summary',
|
'summary',
|
||||||
'outline',
|
'outline',
|
||||||
'content',
|
'content',
|
||||||
'content_md_html',
|
'content_md_html',
|
||||||
'content_md_html_alt',
|
'content_md_html_alt',
|
||||||
'content_html',
|
'content_html',
|
||||||
'content_json',
|
'content_json',
|
||||||
'content_encrypted',
|
'content_encrypted',
|
||||||
'history',
|
'history',
|
||||||
'history_encrypted',
|
'history_encrypted',
|
||||||
'passcode_hash',
|
'passcode_hash',
|
||||||
'start_datetime',
|
'start_datetime',
|
||||||
'end_datetime',
|
'end_datetime',
|
||||||
'timezone',
|
'timezone',
|
||||||
'seconds',
|
'seconds',
|
||||||
'location',
|
'location',
|
||||||
'latitude',
|
'latitude',
|
||||||
'longitude',
|
'longitude',
|
||||||
'billable',
|
'billable',
|
||||||
'bill_to',
|
'bill_to',
|
||||||
'bill_rate',
|
'bill_rate',
|
||||||
'billable_minutes',
|
'billable_minutes',
|
||||||
'alert',
|
'alert',
|
||||||
'alert_msg',
|
'alert_msg',
|
||||||
'parent_id',
|
'parent_id',
|
||||||
'related_entry_id_li',
|
'related_entry_id_li',
|
||||||
'data_json',
|
'data_json',
|
||||||
'passcode_read',
|
'passcode_read',
|
||||||
'passcode_read_expire',
|
'passcode_read_expire',
|
||||||
'passcode_write',
|
'passcode_write',
|
||||||
'passcode_write_expire',
|
'passcode_write_expire',
|
||||||
'enable',
|
'enable',
|
||||||
'hide',
|
'hide',
|
||||||
'priority',
|
'priority',
|
||||||
'sort',
|
'sort',
|
||||||
'group',
|
'group',
|
||||||
'notes',
|
'notes',
|
||||||
'created_on',
|
'created_on',
|
||||||
'updated_on',
|
'updated_on',
|
||||||
|
|
||||||
'tmp_sort_1',
|
'tmp_sort_1',
|
||||||
'tmp_sort_2',
|
'tmp_sort_2',
|
||||||
'tmp_sort_3',
|
'tmp_sort_3',
|
||||||
|
|
||||||
'file_count',
|
'file_count',
|
||||||
'journal_file_id_li_json',
|
'journal_file_id_li_json',
|
||||||
'journal_code',
|
'journal_code',
|
||||||
'journal_name',
|
'journal_name',
|
||||||
'person__given_name',
|
'person__given_name',
|
||||||
'person__family_name',
|
'person__family_name',
|
||||||
'person__full_name',
|
'person__full_name',
|
||||||
'person__primary_email',
|
'person__primary_email',
|
||||||
'person__passcode',
|
'person__passcode',
|
||||||
'person__kv_json',
|
'person__kv_json',
|
||||||
'journal_file_kv',
|
'journal_file_kv',
|
||||||
'journal_file_li',
|
'journal_file_li',
|
||||||
|
|
||||||
'obj_id',
|
'obj_id',
|
||||||
'obj_ext_uid',
|
'obj_ext_uid',
|
||||||
'obj_ext_id',
|
'obj_ext_id',
|
||||||
'obj_import_id',
|
'obj_import_id',
|
||||||
'obj_code',
|
'obj_code',
|
||||||
'obj_account_id',
|
'obj_account_id',
|
||||||
'obj_passcode',
|
'obj_passcode',
|
||||||
'obj_type',
|
'obj_type',
|
||||||
'obj_type_ver_id',
|
'obj_type_ver_id',
|
||||||
'obj_name',
|
'obj_name',
|
||||||
'obj_summary',
|
'obj_summary',
|
||||||
'obj_outline',
|
'obj_outline',
|
||||||
'obj_description',
|
'obj_description',
|
||||||
'obj_enable',
|
'obj_enable',
|
||||||
'obj_enable_on',
|
'obj_enable_on',
|
||||||
'obj_archive_on',
|
'obj_archive_on',
|
||||||
'obj_hide',
|
'obj_hide',
|
||||||
'obj_priority',
|
'obj_priority',
|
||||||
'obj_sort',
|
'obj_sort',
|
||||||
'obj_group',
|
'obj_group',
|
||||||
'obj_cfg_json',
|
'obj_cfg_json',
|
||||||
'obj_notes',
|
'obj_notes',
|
||||||
'obj_created_on',
|
'obj_created_on',
|
||||||
'obj_updated_on'
|
'obj_updated_on'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-06-10
|
// Updated 2024-06-10
|
||||||
export class MySubClassedDexie extends Dexie {
|
export class MySubClassedDexie extends Dexie {
|
||||||
// We just tell the typing system this is the case
|
// We just tell the typing system this is the case
|
||||||
journal!: Table<Journal>;
|
journal!: Table<Journal>;
|
||||||
journal_entry!: Table<Journal_Entry>;
|
journal_entry!: Table<Journal_Entry>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super('ae_journals_db');
|
super('ae_journals_db');
|
||||||
this.version(4).stores({
|
this.version(4).stores({
|
||||||
journal: `
|
journal: `
|
||||||
id, journal_id,
|
id, journal_id,
|
||||||
code,
|
code,
|
||||||
account_id,
|
account_id,
|
||||||
@@ -525,7 +523,7 @@ export class MySubClassedDexie extends Dexie {
|
|||||||
timezone,
|
timezone,
|
||||||
tmp_sort_1, tmp_sort_2, tmp_sort_3,
|
tmp_sort_1, tmp_sort_2, tmp_sort_3,
|
||||||
enable, hide, priority, sort, group, created_on, updated_on`,
|
enable, hide, priority, sort, group, created_on, updated_on`,
|
||||||
journal_entry: `
|
journal_entry: `
|
||||||
id, journal_entry_id,
|
id, journal_entry_id,
|
||||||
journal_id,
|
journal_id,
|
||||||
code,
|
code,
|
||||||
@@ -535,9 +533,9 @@ export class MySubClassedDexie extends Dexie {
|
|||||||
start_datetime, end_datetime,
|
start_datetime, end_datetime,
|
||||||
timezone,
|
timezone,
|
||||||
tmp_sort_1, tmp_sort_2, tmp_sort_3,
|
tmp_sort_1, tmp_sort_2, tmp_sort_3,
|
||||||
enable, hide, priority, sort, group, created_on, updated_on`,
|
enable, hide, priority, sort, group, created_on, updated_on`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const db_journals = new MySubClassedDexie();
|
export const db_journals = new MySubClassedDexie();
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,462 +1,456 @@
|
|||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
|
|
||||||
import { db_save_ae_obj_li__ae_obj } from "$lib/ae_core/core__idb_dexie";
|
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
|
||||||
|
|
||||||
import { db_posts } from "$lib/ae_posts/db_posts";
|
import { db_posts } from '$lib/ae_posts/db_posts';
|
||||||
|
|
||||||
let ae_promises: key_val = {};
|
|
||||||
|
|
||||||
|
const ae_promises: key_val = {};
|
||||||
|
|
||||||
// Updated 2025-06-23
|
// Updated 2025-06-23
|
||||||
export async function load_ae_obj_id__post_comment(
|
export async function load_ae_obj_id__post_comment({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
post_comment_id,
|
||||||
post_comment_id,
|
enabled = 'enabled',
|
||||||
enabled = 'enabled',
|
hidden = 'not_hidden',
|
||||||
hidden = 'not_hidden',
|
limit = 99,
|
||||||
limit = 99,
|
offset = 0,
|
||||||
offset = 0,
|
params = {},
|
||||||
params = {},
|
try_cache = true,
|
||||||
try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
post_comment_id: string;
|
||||||
post_comment_id: string,
|
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
|
||||||
enabled?: "enabled" | "all" | "not_enabled" | undefined,
|
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
|
||||||
hidden?: "hidden" | "all" | "not_hidden" | undefined,
|
limit?: number;
|
||||||
limit?: number,
|
offset?: number;
|
||||||
offset?: number,
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** load_ae_obj_id__post_comment() *** post_comment_id=${post_comment_id}`);
|
||||||
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({
|
ae_promises.load__post_comment_obj = await api
|
||||||
api_cfg: api_cfg,
|
.get_ae_obj_id_crud({
|
||||||
obj_type: 'post_comment',
|
api_cfg: api_cfg,
|
||||||
obj_id: post_comment_id,
|
obj_type: 'post_comment',
|
||||||
use_alt_table: false,
|
obj_id: post_comment_id,
|
||||||
use_alt_base: false,
|
use_alt_table: false,
|
||||||
params: params,
|
use_alt_base: false,
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(async function (post_comment_obj_get_result) {
|
})
|
||||||
if (post_comment_obj_get_result) {
|
.then(async function (post_comment_obj_get_result) {
|
||||||
if (try_cache) {
|
if (post_comment_obj_get_result) {
|
||||||
// Process the results first
|
if (try_cache) {
|
||||||
let processed_obj_li = await process_ae_obj__post_comment_props({
|
// Process the results first
|
||||||
obj_li: [post_comment_obj_get_result],
|
const processed_obj_li = await process_ae_obj__post_comment_props({
|
||||||
log_lvl: log_lvl,
|
obj_li: [post_comment_obj_get_result],
|
||||||
});
|
log_lvl: log_lvl
|
||||||
if (log_lvl) {
|
});
|
||||||
console.log('Processed object list:', 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) {
|
// Save the updated results list to the database
|
||||||
console.log('Saving to DB...');
|
if (log_lvl) {
|
||||||
}
|
console.log('Saving to DB...');
|
||||||
await db_save_ae_obj_li__ae_obj({
|
}
|
||||||
db_instance: db_posts,
|
await db_save_ae_obj_li__ae_obj({
|
||||||
table_name: 'comment',
|
db_instance: db_posts,
|
||||||
obj_li: processed_obj_li,
|
table_name: 'comment',
|
||||||
properties_to_save: properties_to_save,
|
obj_li: processed_obj_li,
|
||||||
log_lvl: log_lvl,
|
properties_to_save: properties_to_save,
|
||||||
});
|
log_lvl: log_lvl
|
||||||
if (log_lvl) {
|
});
|
||||||
console.log('DB save completed.');
|
if (log_lvl) {
|
||||||
}
|
console.log('DB save completed.');
|
||||||
|
}
|
||||||
|
|
||||||
// // This is expecting a list
|
// // This is expecting a list
|
||||||
// db_save_ae_obj_li__post_comment({
|
// db_save_ae_obj_li__post_comment({
|
||||||
// obj_type: 'post_comment',
|
// obj_type: 'post_comment',
|
||||||
// obj_li: [post_comment_obj_get_result],
|
// obj_li: [post_comment_obj_get_result],
|
||||||
// log_lvl: log_lvl
|
// log_lvl: log_lvl
|
||||||
|
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
return post_comment_obj_get_result;
|
return post_comment_obj_get_result;
|
||||||
} else {
|
} else {
|
||||||
console.log('No results returned.');
|
console.log('No results returned.');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function (error: any) {
|
.catch(function (error: any) {
|
||||||
console.log('No results returned or failed.', error);
|
console.log('No results returned or failed.', error);
|
||||||
});
|
});
|
||||||
|
|
||||||
return ae_promises.load__post_comment_obj;
|
return ae_promises.load__post_comment_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2025-06-23
|
// Updated 2025-06-23
|
||||||
export async function load_ae_obj_li__post_comment(
|
export async function load_ae_obj_li__post_comment({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
for_obj_type = 'post',
|
||||||
for_obj_type = 'post',
|
for_obj_id,
|
||||||
for_obj_id,
|
enabled = 'enabled',
|
||||||
enabled = 'enabled',
|
hidden = 'not_hidden',
|
||||||
hidden = 'not_hidden',
|
limit = 99,
|
||||||
limit = 99,
|
offset = 0,
|
||||||
offset = 0,
|
order_by_li = {
|
||||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'title': 'ASC'},
|
priority: 'DESC',
|
||||||
params = {},
|
sort: 'DESC',
|
||||||
try_cache = true,
|
updated_on: 'DESC',
|
||||||
log_lvl = 0
|
created_on: 'DESC',
|
||||||
}: {
|
title: 'ASC'
|
||||||
api_cfg: any,
|
},
|
||||||
for_obj_type: string,
|
params = {},
|
||||||
for_obj_id: string,
|
try_cache = true,
|
||||||
enabled?: "enabled" | "all" | "not_enabled" | undefined,
|
log_lvl = 0
|
||||||
hidden?: "hidden" | "all" | "not_hidden" | undefined,
|
}: {
|
||||||
limit?: number,
|
api_cfg: any;
|
||||||
offset?: number,
|
for_obj_type: string;
|
||||||
order_by_li?: key_val,
|
for_obj_id: string;
|
||||||
params?: key_val,
|
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
|
||||||
try_cache?: boolean,
|
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
|
||||||
log_lvl?: number
|
limit?: number;
|
||||||
}
|
offset?: number;
|
||||||
) {
|
order_by_li?: key_val;
|
||||||
if (log_lvl) {
|
params?: key_val;
|
||||||
console.log(`*** load_ae_obj_li__post_comment() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
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 = {};
|
const params_json: key_val = {};
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('params_json:', params_json);
|
console.log('params_json:', params_json);
|
||||||
}
|
}
|
||||||
|
|
||||||
ae_promises.load__post_comment_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
ae_promises.load__post_comment_obj_li = await api
|
||||||
api_cfg: api_cfg,
|
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||||
obj_type: 'post_comment',
|
api_cfg: api_cfg,
|
||||||
for_obj_type: for_obj_type,
|
obj_type: 'post_comment',
|
||||||
for_obj_id: for_obj_id,
|
for_obj_type: for_obj_type,
|
||||||
use_alt_tbl: false,
|
for_obj_id: for_obj_id,
|
||||||
use_alt_mdl: false,
|
use_alt_tbl: false,
|
||||||
use_alt_exp: false,
|
use_alt_mdl: false,
|
||||||
enabled: enabled,
|
use_alt_exp: false,
|
||||||
hidden: hidden,
|
enabled: enabled,
|
||||||
order_by_li: order_by_li,
|
hidden: hidden,
|
||||||
limit: limit,
|
order_by_li: order_by_li,
|
||||||
offset: offset,
|
limit: limit,
|
||||||
params_json: params_json,
|
offset: offset,
|
||||||
params: params,
|
params_json: params_json,
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(async function (post_comment_obj_li_get_result) {
|
})
|
||||||
if (post_comment_obj_li_get_result) {
|
.then(async function (post_comment_obj_li_get_result) {
|
||||||
if (try_cache) {
|
if (post_comment_obj_li_get_result) {
|
||||||
// Process the results first
|
if (try_cache) {
|
||||||
let processed_obj_li = await process_ae_obj__post_comment_props({
|
// Process the results first
|
||||||
obj_li: post_comment_obj_li_get_result,
|
const processed_obj_li = await process_ae_obj__post_comment_props({
|
||||||
log_lvl: log_lvl,
|
obj_li: post_comment_obj_li_get_result,
|
||||||
});
|
log_lvl: log_lvl
|
||||||
if (log_lvl) {
|
});
|
||||||
console.log('Processed object list:', 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) {
|
// Save the updated results list to the database
|
||||||
console.log('Saving to DB...');
|
if (log_lvl) {
|
||||||
}
|
console.log('Saving to DB...');
|
||||||
await db_save_ae_obj_li__ae_obj({
|
}
|
||||||
db_instance: db_posts,
|
await db_save_ae_obj_li__ae_obj({
|
||||||
table_name: 'comment',
|
db_instance: db_posts,
|
||||||
obj_li: processed_obj_li,
|
table_name: 'comment',
|
||||||
properties_to_save: properties_to_save,
|
obj_li: processed_obj_li,
|
||||||
log_lvl: log_lvl,
|
properties_to_save: properties_to_save,
|
||||||
});
|
log_lvl: log_lvl
|
||||||
if (log_lvl) {
|
});
|
||||||
console.log('DB save completed.');
|
if (log_lvl) {
|
||||||
}
|
console.log('DB save completed.');
|
||||||
|
}
|
||||||
|
|
||||||
// db_save_ae_obj_li__post_comment({
|
// db_save_ae_obj_li__post_comment({
|
||||||
// obj_type: 'post_comment',
|
// obj_type: 'post_comment',
|
||||||
// obj_li: post_comment_obj_li_get_result,
|
// obj_li: post_comment_obj_li_get_result,
|
||||||
// log_lvl: log_lvl
|
// log_lvl: log_lvl
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
return post_comment_obj_li_get_result;
|
return post_comment_obj_li_get_result;
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function (error: any) {
|
.catch(function (error: any) {
|
||||||
console.log('No results returned or failed.', error);
|
console.log('No results returned or failed.', error);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.load__post_comment_obj_li:', ae_promises.load__post_comment_obj_li);
|
console.log('ae_promises.load__post_comment_obj_li:', ae_promises.load__post_comment_obj_li);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ae_promises.load__post_comment_obj_li;
|
return ae_promises.load__post_comment_obj_li;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2025-06-23
|
// Updated 2025-06-23
|
||||||
export async function create_ae_obj__post_comment(
|
export async function create_ae_obj__post_comment({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
post_id,
|
||||||
post_id,
|
data_kv,
|
||||||
data_kv,
|
params = {},
|
||||||
params = {},
|
try_cache = true,
|
||||||
try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
post_id: string;
|
||||||
post_id: string,
|
data_kv: key_val;
|
||||||
data_kv: key_val,
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** create_ae_obj__post_comment() *** post_id=${post_id}`);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`*** create_ae_obj__post_comment() *** post_id=${post_id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!post_id) {
|
if (!post_id) {
|
||||||
console.log(`ERROR: Posts - Comment - post_id required to create`);
|
console.log(`ERROR: Posts - Comment - post_id required to create`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ae_promises.create__post_comment = await api.create_ae_obj_crud({
|
ae_promises.create__post_comment = await api
|
||||||
api_cfg: api_cfg,
|
.create_ae_obj_crud({
|
||||||
obj_type: 'post_comment',
|
api_cfg: api_cfg,
|
||||||
fields: {
|
obj_type: 'post_comment',
|
||||||
post_id_random: post_id,
|
fields: {
|
||||||
...data_kv
|
post_id_random: post_id,
|
||||||
},
|
...data_kv
|
||||||
key: api_cfg.api_crud_super_key,
|
},
|
||||||
params: params,
|
key: api_cfg.api_crud_super_key,
|
||||||
return_obj: true,
|
params: params,
|
||||||
log_lvl: log_lvl
|
return_obj: true,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(async function (post_comment_obj_create_result) {
|
})
|
||||||
if (post_comment_obj_create_result) {
|
.then(async function (post_comment_obj_create_result) {
|
||||||
if (try_cache) {
|
if (post_comment_obj_create_result) {
|
||||||
// Process the results first
|
if (try_cache) {
|
||||||
let processed_obj_li = await process_ae_obj__post_comment_props({
|
// Process the results first
|
||||||
obj_li: [post_comment_obj_create_result],
|
const processed_obj_li = await process_ae_obj__post_comment_props({
|
||||||
log_lvl: log_lvl,
|
obj_li: [post_comment_obj_create_result],
|
||||||
});
|
log_lvl: log_lvl
|
||||||
if (log_lvl) {
|
});
|
||||||
console.log('Processed object list:', 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) {
|
// Save the updated results list to the database
|
||||||
console.log('Saving to DB...');
|
if (log_lvl) {
|
||||||
}
|
console.log('Saving to DB...');
|
||||||
await db_save_ae_obj_li__ae_obj({
|
}
|
||||||
db_instance: db_posts,
|
await db_save_ae_obj_li__ae_obj({
|
||||||
table_name: 'comment',
|
db_instance: db_posts,
|
||||||
obj_li: processed_obj_li,
|
table_name: 'comment',
|
||||||
properties_to_save: properties_to_save,
|
obj_li: processed_obj_li,
|
||||||
log_lvl: log_lvl,
|
properties_to_save: properties_to_save,
|
||||||
});
|
log_lvl: log_lvl
|
||||||
if (log_lvl) {
|
});
|
||||||
console.log('DB save completed.');
|
if (log_lvl) {
|
||||||
}
|
console.log('DB save completed.');
|
||||||
|
}
|
||||||
|
|
||||||
// db_save_ae_obj_li__post_comment(
|
// db_save_ae_obj_li__post_comment(
|
||||||
// {
|
// {
|
||||||
// obj_type: 'post_comment',
|
// obj_type: 'post_comment',
|
||||||
// obj_li: [post_comment_obj_create_result],
|
// obj_li: [post_comment_obj_create_result],
|
||||||
// log_lvl: log_lvl
|
// log_lvl: log_lvl
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
return post_comment_obj_create_result;
|
return post_comment_obj_create_result;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function (error: any) {
|
.catch(function (error: any) {
|
||||||
console.log('No results returned or failed.', error);
|
console.log('No results returned or failed.', error);
|
||||||
})
|
})
|
||||||
.finally(function () {
|
.finally(function () {});
|
||||||
});
|
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.create__post_comment:', ae_promises.create__post_comment);
|
console.log('ae_promises.create__post_comment:', ae_promises.create__post_comment);
|
||||||
}
|
}
|
||||||
return ae_promises.create__post_comment;
|
return ae_promises.create__post_comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-11-08
|
// Updated 2024-11-08
|
||||||
export async function delete_ae_obj_id__post_comment(
|
export async function delete_ae_obj_id__post_comment({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
post_comment_id,
|
||||||
post_comment_id,
|
method = 'delete', // 'delete', 'disable', 'hide'
|
||||||
method = 'delete', // 'delete', 'disable', 'hide'
|
params = {},
|
||||||
params = {},
|
try_cache = true,
|
||||||
try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
post_comment_id: string;
|
||||||
post_comment_id: string,
|
method?: string;
|
||||||
method?: string,
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** delete_ae_obj_id__post_comment() *** post_comment_id=${post_comment_id}`);
|
||||||
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({
|
ae_promises.delete__post_comment_obj = await api
|
||||||
api_cfg: api_cfg,
|
.delete_ae_obj_id_crud({
|
||||||
obj_type: 'post_comment',
|
api_cfg: api_cfg,
|
||||||
obj_id: post_comment_id,
|
obj_type: 'post_comment',
|
||||||
key: api_cfg.api_crud_super_key,
|
obj_id: post_comment_id,
|
||||||
params: params,
|
key: api_cfg.api_crud_super_key,
|
||||||
method: method,
|
params: params,
|
||||||
log_lvl: log_lvl
|
method: method,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.catch(function (error: any) {
|
})
|
||||||
console.log('No results returned or failed.', error);
|
.catch(function (error: any) {
|
||||||
})
|
console.log('No results returned or failed.', error);
|
||||||
.finally(function () {
|
})
|
||||||
if (try_cache) {
|
.finally(function () {
|
||||||
if (log_lvl) {
|
if (try_cache) {
|
||||||
console.log(`Attempting to remove IDB entry for post_comment_id=${post_comment_id}`);
|
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.
|
}
|
||||||
}
|
db_posts.comment.delete(post_comment_id); // Delete from the DB no matter what.
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.delete__post_comment_obj:', ae_promises.delete__post_comment_obj);
|
console.log('ae_promises.delete__post_comment_obj:', ae_promises.delete__post_comment_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ae_promises.delete__post_comment_obj;
|
return ae_promises.delete__post_comment_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2025-06-23
|
// Updated 2025-06-23
|
||||||
export async function update_ae_obj__post_comment(
|
export async function update_ae_obj__post_comment({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
post_comment_id,
|
||||||
post_comment_id,
|
data_kv,
|
||||||
data_kv,
|
params = {},
|
||||||
params = {},
|
try_cache = true,
|
||||||
try_cache = true,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
post_comment_id: string;
|
||||||
post_comment_id: string,
|
data_kv: key_val;
|
||||||
data_kv: key_val,
|
params?: key_val;
|
||||||
params?: key_val,
|
try_cache?: boolean;
|
||||||
try_cache?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(
|
||||||
if (log_lvl) {
|
`*** update_ae_obj__post_comment() *** post_comment_id=${post_comment_id}`,
|
||||||
console.log(`*** update_ae_obj__post_comment() *** post_comment_id=${post_comment_id}`, data_kv);
|
data_kv
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Perform the API update
|
// Perform the API update
|
||||||
const result = await api.update_ae_obj_id_crud({
|
const result = await api.update_ae_obj_id_crud({
|
||||||
api_cfg: api_cfg,
|
api_cfg: api_cfg,
|
||||||
obj_type: 'post_comment',
|
obj_type: 'post_comment',
|
||||||
obj_id: post_comment_id,
|
obj_id: post_comment_id,
|
||||||
fields: data_kv,
|
fields: data_kv,
|
||||||
key: api_cfg.api_crud_super_key,
|
key: api_cfg.api_crud_super_key,
|
||||||
params: params,
|
params: params,
|
||||||
return_obj: true,
|
return_obj: true,
|
||||||
log_lvl: log_lvl,
|
log_lvl: log_lvl
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle the result
|
// Handle the result
|
||||||
if (result) {
|
if (result) {
|
||||||
if (try_cache) {
|
if (try_cache) {
|
||||||
// Process the results first
|
// Process the results first
|
||||||
let processed_obj_li = await process_ae_obj__post_comment_props({
|
const processed_obj_li = await process_ae_obj__post_comment_props({
|
||||||
obj_li: [result],
|
obj_li: [result],
|
||||||
log_lvl: log_lvl,
|
log_lvl: log_lvl
|
||||||
});
|
});
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Processed object list:', processed_obj_li);
|
console.log('Processed object list:', processed_obj_li);
|
||||||
}
|
}
|
||||||
// Save the updated results list to the database
|
// Save the updated results list to the database
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Saving to DB...');
|
console.log('Saving to DB...');
|
||||||
}
|
}
|
||||||
await db_save_ae_obj_li__ae_obj({
|
await db_save_ae_obj_li__ae_obj({
|
||||||
db_instance: db_posts,
|
db_instance: db_posts,
|
||||||
table_name: 'comment',
|
table_name: 'comment',
|
||||||
obj_li: processed_obj_li,
|
obj_li: processed_obj_li,
|
||||||
properties_to_save: properties_to_save,
|
properties_to_save: properties_to_save,
|
||||||
log_lvl: log_lvl,
|
log_lvl: log_lvl
|
||||||
});
|
});
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('DB save completed.');
|
console.log('DB save completed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// await db_save_ae_obj_li__post_comment({
|
// await db_save_ae_obj_li__post_comment({
|
||||||
// obj_type: 'post_comment',
|
// obj_type: 'post_comment',
|
||||||
// obj_li: [result],
|
// obj_li: [result],
|
||||||
// log_lvl: log_lvl,
|
// log_lvl: log_lvl,
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
console.error('Failed to update post comment.');
|
console.error('Failed to update post comment.');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Updated 2025-06-04
|
// Updated 2025-06-04
|
||||||
export const properties_to_save = [
|
export const properties_to_save = [
|
||||||
'id',
|
'id',
|
||||||
'post_comment_id',
|
'post_comment_id',
|
||||||
// 'post_comment_id_random',
|
// 'post_comment_id_random',
|
||||||
|
|
||||||
'post_id',
|
'post_id',
|
||||||
// 'post_id_random',
|
// 'post_id_random',
|
||||||
|
|
||||||
'external_person_id',
|
'external_person_id',
|
||||||
|
|
||||||
'name',
|
'name',
|
||||||
'title',
|
'title',
|
||||||
'content',
|
'content',
|
||||||
|
|
||||||
'anonymous',
|
'anonymous',
|
||||||
'full_name',
|
'full_name',
|
||||||
'email',
|
'email',
|
||||||
'notify',
|
'notify',
|
||||||
|
|
||||||
'linked_li_json',
|
'linked_li_json',
|
||||||
'cfg_json',
|
'cfg_json',
|
||||||
|
|
||||||
'enable',
|
'enable',
|
||||||
'hide',
|
'hide',
|
||||||
'priority',
|
'priority',
|
||||||
'sort',
|
'sort',
|
||||||
'group',
|
'group',
|
||||||
'notes',
|
'notes',
|
||||||
'created_on',
|
'created_on',
|
||||||
'updated_on',
|
'updated_on',
|
||||||
|
|
||||||
// Generated fields for sorting locally only
|
// Generated fields for sorting locally only
|
||||||
'tmp_sort_1',
|
'tmp_sort_1',
|
||||||
'tmp_sort_2',
|
'tmp_sort_2'
|
||||||
// 'tmp_sort_a',
|
// 'tmp_sort_a',
|
||||||
// 'tmp_sort_b',
|
// 'tmp_sort_b',
|
||||||
|
|
||||||
// From SQL view
|
// From SQL view
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NON-EXPORTED LOCAL HELPER
|
* NON-EXPORTED LOCAL HELPER
|
||||||
* Processes a list of Aether objects by applying common and specific transformations.
|
* Processes a list of Aether objects by applying common and specific transformations.
|
||||||
@@ -525,7 +519,6 @@ async function _process_generic_props<T extends Record<string, any>>({
|
|||||||
return processed_obj_li;
|
return processed_obj_li;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2025-06-04
|
// Updated 2025-06-04
|
||||||
export async function process_ae_obj__post_comment_props({
|
export async function process_ae_obj__post_comment_props({
|
||||||
obj_li,
|
obj_li,
|
||||||
@@ -550,4 +543,4 @@ export async function process_ae_obj__post_comment_props({
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +1,32 @@
|
|||||||
// This file is used to export all the functions that are used for Aether Posts related functions.
|
// This file is used to export all the functions that are used for Aether Posts related functions.
|
||||||
|
|
||||||
import {
|
import {
|
||||||
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
|
||||||
|
} from '$lib/ae_posts/ae_posts__post';
|
||||||
} from "$lib/ae_posts/ae_posts__post";
|
|
||||||
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
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
|
||||||
|
} from '$lib/ae_posts/ae_posts__post_comment';
|
||||||
|
|
||||||
} from "$lib/ae_posts/ae_posts__post_comment";
|
const export_obj = {
|
||||||
|
load_ae_obj_id__post: load_ae_obj_id__post,
|
||||||
|
load_ae_obj_li__post: load_ae_obj_li__post,
|
||||||
let export_obj = {
|
create_ae_obj__post: create_ae_obj__post,
|
||||||
load_ae_obj_id__post: load_ae_obj_id__post,
|
delete_ae_obj_id__post: delete_ae_obj_id__post,
|
||||||
load_ae_obj_li__post: load_ae_obj_li__post,
|
update_ae_obj__post: update_ae_obj__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,
|
|
||||||
|
|
||||||
|
|
||||||
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,
|
|
||||||
|
|
||||||
|
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
|
||||||
};
|
};
|
||||||
export let posts_func = export_obj;
|
export const posts_func = export_obj;
|
||||||
|
|||||||
@@ -7,115 +7,113 @@ import type { key_val } from '$lib/stores/ae_stores';
|
|||||||
|
|
||||||
// Updated 2024-11-13
|
// Updated 2024-11-13
|
||||||
export interface Post {
|
export interface Post {
|
||||||
id: string;
|
id: string;
|
||||||
// id_random: string;
|
// id_random: string;
|
||||||
post_id: string;
|
post_id: string;
|
||||||
// post_id_random: string;
|
// post_id_random: string;
|
||||||
|
|
||||||
account_id: string;
|
account_id: string;
|
||||||
// account_id_random: string;
|
// account_id_random: string;
|
||||||
|
|
||||||
person_id?: null|string;
|
person_id?: null | string;
|
||||||
external_person_id?: null|string; // For IDAA this is the Novi UUID
|
external_person_id?: null | string; // For IDAA this is the Novi UUID
|
||||||
user_id?: null|string;
|
user_id?: null | string;
|
||||||
|
|
||||||
topic_id?: string;
|
topic_id?: string;
|
||||||
topic?: string; // or topic_name?
|
topic?: string; // or topic_name?
|
||||||
topic_name?: string;
|
topic_name?: string;
|
||||||
|
|
||||||
name: null|string;
|
name: null | string;
|
||||||
title: null|string;
|
title: null | string;
|
||||||
// summary?: null|string;
|
// summary?: null|string;
|
||||||
content?: null|string;
|
content?: null | string;
|
||||||
|
|
||||||
anonymous?: null|boolean;
|
anonymous?: null | boolean;
|
||||||
full_name?: null|string;
|
full_name?: null | string;
|
||||||
email?: null|string;
|
email?: null | string;
|
||||||
notify?: null|boolean;
|
notify?: null | boolean;
|
||||||
|
|
||||||
enable_comments?: null|boolean;
|
enable_comments?: null | boolean;
|
||||||
|
|
||||||
archive?: null|boolean;
|
archive?: null | boolean;
|
||||||
archive_on?: null|Date;
|
archive_on?: null | Date;
|
||||||
|
|
||||||
linked_li_json?: null|string;
|
linked_li_json?: null | string;
|
||||||
cfg_json?: null|key_val;
|
cfg_json?: null | key_val;
|
||||||
|
|
||||||
enable: null|boolean;
|
enable: null | boolean;
|
||||||
hide?: null|boolean;
|
hide?: null | boolean;
|
||||||
priority?: null|boolean
|
priority?: null | boolean;
|
||||||
sort?: null|number;
|
sort?: null | number;
|
||||||
group?: null|string;
|
group?: null | string;
|
||||||
notes?: null|string;
|
notes?: null | string;
|
||||||
created_on: Date;
|
created_on: Date;
|
||||||
updated_on?: null|Date;
|
updated_on?: null | Date;
|
||||||
|
|
||||||
// Generated fields for sorting locally only
|
// Generated fields for sorting locally only
|
||||||
tmp_sort_1?: null|string;
|
tmp_sort_1?: null | string;
|
||||||
tmp_sort_2?: null|string;
|
tmp_sort_2?: null | string;
|
||||||
|
|
||||||
// Additional fields for convenience (database views)
|
// Additional fields for convenience (database views)
|
||||||
post_comment_count?: number;
|
post_comment_count?: number;
|
||||||
|
|
||||||
// Placeholder for generated temp data
|
// Placeholder for generated temp data
|
||||||
hosted_file_id_li?: null|Array<string>;
|
hosted_file_id_li?: null | Array<string>;
|
||||||
hosted_file_obj_li?: null|Array<any>;
|
hosted_file_obj_li?: null | Array<any>;
|
||||||
upload_complete?: boolean;
|
upload_complete?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-11-13
|
// Updated 2024-11-13
|
||||||
export interface Post_Comment {
|
export interface Post_Comment {
|
||||||
id: string;
|
id: string;
|
||||||
// id_random: string;
|
// id_random: string;
|
||||||
post_comment_id: string;
|
post_comment_id: string;
|
||||||
// post_comment_id_random: string;
|
// post_comment_id_random: string;
|
||||||
|
|
||||||
post_id: string;
|
post_id: string;
|
||||||
// post_id_random: string;
|
// post_id_random: string;
|
||||||
|
|
||||||
external_person_id?: null|string; // For IDAA this is the Novi UUID
|
external_person_id?: null | string; // For IDAA this is the Novi UUID
|
||||||
|
|
||||||
name: null|string;
|
name: null | string;
|
||||||
title: null|string;
|
title: null | string;
|
||||||
// summary?: null|string;
|
// summary?: null|string;
|
||||||
content?: null|string;
|
content?: null | string;
|
||||||
|
|
||||||
anonymous?: null|boolean;
|
anonymous?: null | boolean;
|
||||||
full_name?: null|string;
|
full_name?: null | string;
|
||||||
email?: null|string;
|
email?: null | string;
|
||||||
notify?: null|boolean;
|
notify?: null | boolean;
|
||||||
|
|
||||||
linked_li_json?: null|string;
|
linked_li_json?: null | string;
|
||||||
cfg_json?: null|key_val;
|
cfg_json?: null | key_val;
|
||||||
|
|
||||||
enable: null|boolean;
|
enable: null | boolean;
|
||||||
hide?: null|boolean;
|
hide?: null | boolean;
|
||||||
priority?: null|boolean
|
priority?: null | boolean;
|
||||||
sort?: null|number;
|
sort?: null | number;
|
||||||
group?: null|string;
|
group?: null | string;
|
||||||
notes?: null|string;
|
notes?: null | string;
|
||||||
created_on: Date;
|
created_on: Date;
|
||||||
updated_on?: null|Date;
|
updated_on?: null | Date;
|
||||||
|
|
||||||
// Generated fields for sorting locally only
|
// Generated fields for sorting locally only
|
||||||
tmp_sort_1?: null|string;
|
tmp_sort_1?: null | string;
|
||||||
tmp_sort_2?: null|string;
|
tmp_sort_2?: null | string;
|
||||||
|
|
||||||
// Additional fields for convenience (database views)
|
// Additional fields for convenience (database views)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-09-25
|
// Updated 2024-09-25
|
||||||
export class MySubClassedDexie extends Dexie {
|
export class MySubClassedDexie extends Dexie {
|
||||||
// We just tell the typing system this is the case
|
// We just tell the typing system this is the case
|
||||||
post!: Table<Post>;
|
post!: Table<Post>;
|
||||||
comment!: Table<Post_Comment>;
|
comment!: Table<Post_Comment>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super('ae_posts_db');
|
super('ae_posts_db');
|
||||||
this.version(1).stores({
|
this.version(1).stores({
|
||||||
post: `
|
post: `
|
||||||
id, post_id,
|
id, post_id,
|
||||||
account_id,
|
account_id,
|
||||||
topic_id, topic,
|
topic_id, topic,
|
||||||
@@ -126,16 +124,16 @@ export class MySubClassedDexie extends Dexie {
|
|||||||
tmp_sort_1, tmp_sort_2,
|
tmp_sort_1, tmp_sort_2,
|
||||||
enable, hide, priority, sort, group, notes, created_on, updated_on, [updated_on+created_on], [created_on+updated_on]`,
|
enable, hide, priority, sort, group, notes, created_on, updated_on, [updated_on+created_on], [created_on+updated_on]`,
|
||||||
|
|
||||||
comment: `
|
comment: `
|
||||||
id, post_comment_id,
|
id, post_comment_id,
|
||||||
post_id,
|
post_id,
|
||||||
name,
|
name,
|
||||||
title,
|
title,
|
||||||
full_name, email,
|
full_name, email,
|
||||||
tmp_sort_1, tmp_sort_2,
|
tmp_sort_1, tmp_sort_2,
|
||||||
enable, hide, priority, sort, group, notes, created_on, updated_on, [updated_on+created_on]`,
|
enable, hide, priority, sort, group, notes, created_on, updated_on, [updated_on+created_on]`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const db_posts = new MySubClassedDexie();
|
export const db_posts = new MySubClassedDexie();
|
||||||
|
|||||||
@@ -1,36 +1,35 @@
|
|||||||
import type { key_val } from '$lib/stores/ae_stores';
|
import type { key_val } from '$lib/stores/ae_stores';
|
||||||
import { api } from '$lib/api/api';
|
import { api } from '$lib/api/api';
|
||||||
|
|
||||||
import { db_sponsorships } from "$lib/ae_sponsorships/db_sponsorships";
|
import { db_sponsorships } from '$lib/ae_sponsorships/db_sponsorships';
|
||||||
|
|
||||||
// import { liveQuery } from "dexie";
|
// import { liveQuery } from "dexie";
|
||||||
// import { db_core } from "$lib/db_core";
|
// import { db_core } from "$lib/db_core";
|
||||||
|
|
||||||
// --- PROPERTIES TO SAVE ---
|
// --- PROPERTIES TO SAVE ---
|
||||||
export const properties_to_save_sponsorship_cfg = [
|
export const properties_to_save_sponsorship_cfg = [
|
||||||
'id',
|
'id',
|
||||||
'sponsorship_cfg_id',
|
'sponsorship_cfg_id',
|
||||||
'account_id',
|
'account_id',
|
||||||
'for_type',
|
'for_type',
|
||||||
'for_id',
|
'for_id',
|
||||||
'level_li_json',
|
'level_li_json',
|
||||||
'option_li_json',
|
'option_li_json',
|
||||||
'schedule_li_json',
|
'schedule_li_json',
|
||||||
'cfg_json',
|
'cfg_json',
|
||||||
'enable',
|
'enable',
|
||||||
'hide',
|
'hide',
|
||||||
'priority',
|
'priority',
|
||||||
'sort',
|
'sort',
|
||||||
'group',
|
'group',
|
||||||
'notes',
|
'notes',
|
||||||
'created_on',
|
'created_on',
|
||||||
'updated_on',
|
'updated_on',
|
||||||
// Generated fields for sorting locally only
|
// Generated fields for sorting locally only
|
||||||
'tmp_sort_1',
|
'tmp_sort_1',
|
||||||
'tmp_sort_2',
|
'tmp_sort_2'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
// --- PROCESS FUNCTION ---
|
// --- PROCESS FUNCTION ---
|
||||||
export async function process_ae_obj__sponsorship_cfg_props({
|
export async function process_ae_obj__sponsorship_cfg_props({
|
||||||
obj_li,
|
obj_li,
|
||||||
@@ -57,48 +56,46 @@ export async function process_ae_obj__sponsorship_cfg_props({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --- PROPERTIES TO SAVE ---
|
// --- PROPERTIES TO SAVE ---
|
||||||
export const properties_to_save_sponsorship = [
|
export const properties_to_save_sponsorship = [
|
||||||
'id',
|
'id',
|
||||||
'sponsorship_id',
|
'sponsorship_id',
|
||||||
'account_id',
|
'account_id',
|
||||||
'organization_id',
|
'organization_id',
|
||||||
'person_id',
|
'person_id',
|
||||||
'poc_person_id',
|
'poc_person_id',
|
||||||
'poc_json',
|
'poc_json',
|
||||||
'name',
|
'name',
|
||||||
'name_override',
|
'name_override',
|
||||||
'description',
|
'description',
|
||||||
'email',
|
'email',
|
||||||
'website_url',
|
'website_url',
|
||||||
'logo_li_json',
|
'logo_li_json',
|
||||||
'media_li_json',
|
'media_li_json',
|
||||||
'social_li_json',
|
'social_li_json',
|
||||||
'address_li_json',
|
'address_li_json',
|
||||||
'contact_li_json',
|
'contact_li_json',
|
||||||
'guest_li_json',
|
'guest_li_json',
|
||||||
'level_num',
|
'level_num',
|
||||||
'level_str',
|
'level_str',
|
||||||
'amount',
|
'amount',
|
||||||
'questions_li_json',
|
'questions_li_json',
|
||||||
'agree',
|
'agree',
|
||||||
'comments',
|
'comments',
|
||||||
'staff_notes',
|
'staff_notes',
|
||||||
'enable',
|
'enable',
|
||||||
'hide',
|
'hide',
|
||||||
'priority',
|
'priority',
|
||||||
'sort',
|
'sort',
|
||||||
'group',
|
'group',
|
||||||
'notes',
|
'notes',
|
||||||
'created_on',
|
'created_on',
|
||||||
'updated_on',
|
'updated_on',
|
||||||
// Generated fields for sorting locally only
|
// Generated fields for sorting locally only
|
||||||
'tmp_sort_1',
|
'tmp_sort_1',
|
||||||
'tmp_sort_2',
|
'tmp_sort_2'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
// --- PROCESS FUNCTION ---
|
// --- PROCESS FUNCTION ---
|
||||||
export async function process_ae_obj__sponsorship_props({
|
export async function process_ae_obj__sponsorship_props({
|
||||||
obj_li,
|
obj_li,
|
||||||
@@ -125,7 +122,6 @@ export async function process_ae_obj__sponsorship_props({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NON-EXPORTED LOCAL HELPER
|
* NON-EXPORTED LOCAL HELPER
|
||||||
* Processes a list of Aether objects by applying common and specific transformations.
|
* Processes a list of Aether objects by applying common and specific transformations.
|
||||||
@@ -194,310 +190,315 @@ async function _process_generic_props<T extends Record<string, any>>({
|
|||||||
return processed_obj_li;
|
return processed_obj_li;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-03-29
|
// Updated 2024-03-29
|
||||||
async function load_ae_obj_id__sponsorship_cfg(
|
async function load_ae_obj_id__sponsorship_cfg({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
sponsorship_cfg_id,
|
||||||
sponsorship_cfg_id,
|
try_cache = false,
|
||||||
try_cache = false,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
sponsorship_cfg_id: string;
|
||||||
sponsorship_cfg_id: string,
|
try_cache: boolean;
|
||||||
try_cache: boolean,
|
log_lvl: number;
|
||||||
log_lvl: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(
|
||||||
if (log_lvl) {
|
`*** load_ae_obj_id__sponsorship_cfg() *** sponsorship_cfg_id=${sponsorship_cfg_id}`
|
||||||
console.log(`*** load_ae_obj_id__sponsorship_cfg() *** sponsorship_cfg_id=${sponsorship_cfg_id}`);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let params = {};
|
const params = {};
|
||||||
|
|
||||||
ae_promises.load__sponsorship_cfg_obj = api.get_ae_obj_id_crud({
|
ae_promises.load__sponsorship_cfg_obj = api
|
||||||
api_cfg: api_cfg,
|
.get_ae_obj_id_crud({
|
||||||
obj_type: 'sponsorship_cfg',
|
api_cfg: api_cfg,
|
||||||
obj_id: sponsorship_cfg_id,
|
obj_type: 'sponsorship_cfg',
|
||||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
obj_id: sponsorship_cfg_id,
|
||||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||||
params: params,
|
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(async function (sponsorship_cfg_obj_get_result) {
|
})
|
||||||
if (sponsorship_cfg_obj_get_result) {
|
.then(async function (sponsorship_cfg_obj_get_result) {
|
||||||
if (log_lvl) {
|
if (sponsorship_cfg_obj_get_result) {
|
||||||
console.log(`*spons_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}`);
|
if (log_lvl) {
|
||||||
} else if (log_lvl > 1) {
|
console.log(`*spons_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}`);
|
||||||
console.log(`*spons_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}:`, sponsorship_cfg_obj_get_result);
|
} else if (log_lvl > 1) {
|
||||||
}
|
console.log(
|
||||||
if (try_cache) {
|
`*spons_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}:`,
|
||||||
// Process the results first
|
sponsorship_cfg_obj_get_result
|
||||||
let processed_obj_li = await process_ae_obj__sponsorship_cfg_props({
|
);
|
||||||
obj_li: [sponsorship_cfg_obj_get_result],
|
}
|
||||||
log_lvl: log_lvl,
|
if (try_cache) {
|
||||||
});
|
// Process the results first
|
||||||
if (log_lvl) {
|
const processed_obj_li = await process_ae_obj__sponsorship_cfg_props({
|
||||||
console.log('Processed object list:', processed_obj_li);
|
obj_li: [sponsorship_cfg_obj_get_result],
|
||||||
}
|
log_lvl: log_lvl
|
||||||
// Save the updated results list to the database
|
});
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Saving to DB...');
|
console.log('Processed object list:', processed_obj_li);
|
||||||
}
|
}
|
||||||
await db_save_ae_obj_li__ae_obj({
|
// Save the updated results list to the database
|
||||||
db_instance: db_sponsorships,
|
if (log_lvl) {
|
||||||
table_name: 'cfg',
|
console.log('Saving to DB...');
|
||||||
obj_li: processed_obj_li,
|
}
|
||||||
properties_to_save: properties_to_save_sponsorship_cfg,
|
await db_save_ae_obj_li__ae_obj({
|
||||||
log_lvl: log_lvl,
|
db_instance: db_sponsorships,
|
||||||
});
|
table_name: 'cfg',
|
||||||
if (log_lvl) {
|
obj_li: processed_obj_li,
|
||||||
console.log('DB save completed.');
|
properties_to_save: properties_to_save_sponsorship_cfg,
|
||||||
}
|
log_lvl: log_lvl
|
||||||
}
|
});
|
||||||
return sponsorship_cfg_obj_get_result;
|
if (log_lvl) {
|
||||||
} else {
|
console.log('DB save completed.');
|
||||||
console.log('No results returned.');
|
}
|
||||||
return null;
|
}
|
||||||
}
|
return sponsorship_cfg_obj_get_result;
|
||||||
})
|
} else {
|
||||||
.catch(function (error: any) {
|
console.log('No results returned.');
|
||||||
console.log('No results returned or failed.', error);
|
return null;
|
||||||
});
|
}
|
||||||
|
})
|
||||||
|
.catch(function (error: any) {
|
||||||
|
console.log('No results returned or failed.', error);
|
||||||
|
});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.load__sponsorship_cfg_obj:', ae_promises.load__sponsorship_cfg_obj);
|
console.log('ae_promises.load__sponsorship_cfg_obj:', ae_promises.load__sponsorship_cfg_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ae_promises.load__sponsorship_cfg_obj;
|
return ae_promises.load__sponsorship_cfg_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-03-29
|
// Updated 2024-03-29
|
||||||
async function load_ae_obj_id__sponsorship(
|
async function load_ae_obj_id__sponsorship({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
sponsorship_id,
|
||||||
sponsorship_id,
|
try_cache = false,
|
||||||
try_cache = false,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
api_cfg: any;
|
||||||
api_cfg: any,
|
sponsorship_id: string;
|
||||||
sponsorship_id: string,
|
try_cache: boolean;
|
||||||
try_cache: boolean,
|
log_lvl: number;
|
||||||
log_lvl: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log(`*** load_ae_obj_id__sponsorship() *** sponsorship_id=${sponsorship_id}`);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`*** load_ae_obj_id__sponsorship() *** sponsorship_id=${sponsorship_id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
let params = {};
|
const params = {};
|
||||||
|
|
||||||
ae_promises.load__sponsorship_obj = api.get_ae_obj_id_crud({
|
ae_promises.load__sponsorship_obj = api
|
||||||
api_cfg: api_cfg,
|
.get_ae_obj_id_crud({
|
||||||
obj_type: 'sponsorship',
|
api_cfg: api_cfg,
|
||||||
obj_id: sponsorship_id,
|
obj_type: 'sponsorship',
|
||||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
obj_id: sponsorship_id,
|
||||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||||
params: params,
|
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(async function (sponsorship_obj_get_result) {
|
})
|
||||||
if (sponsorship_obj_get_result) {
|
.then(async function (sponsorship_obj_get_result) {
|
||||||
if (log_lvl) {
|
if (sponsorship_obj_get_result) {
|
||||||
console.log(`*spons_func* Got a result for sponsorship_id ${sponsorship_id}`);
|
if (log_lvl) {
|
||||||
} else if (log_lvl > 1) {
|
console.log(`*spons_func* Got a result for sponsorship_id ${sponsorship_id}`);
|
||||||
console.log(`*spons_func* Got a result for sponsorship_id ${sponsorship_id}:`, sponsorship_obj_get_result);
|
} else if (log_lvl > 1) {
|
||||||
}
|
console.log(
|
||||||
if (try_cache) {
|
`*spons_func* Got a result for sponsorship_id ${sponsorship_id}:`,
|
||||||
// Process the results first
|
sponsorship_obj_get_result
|
||||||
let processed_obj_li = await process_ae_obj__sponsorship_props({
|
);
|
||||||
obj_li: [sponsorship_obj_get_result],
|
}
|
||||||
log_lvl: log_lvl,
|
if (try_cache) {
|
||||||
});
|
// Process the results first
|
||||||
if (log_lvl) {
|
const processed_obj_li = await process_ae_obj__sponsorship_props({
|
||||||
console.log('Processed object list:', processed_obj_li);
|
obj_li: [sponsorship_obj_get_result],
|
||||||
}
|
log_lvl: log_lvl
|
||||||
// Save the updated results list to the database
|
});
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Saving to DB...');
|
console.log('Processed object list:', processed_obj_li);
|
||||||
}
|
}
|
||||||
await db_save_ae_obj_li__ae_obj({
|
// Save the updated results list to the database
|
||||||
db_instance: db_sponsorships,
|
if (log_lvl) {
|
||||||
table_name: 'sponsorship',
|
console.log('Saving to DB...');
|
||||||
obj_li: processed_obj_li,
|
}
|
||||||
properties_to_save: properties_to_save_sponsorship,
|
await db_save_ae_obj_li__ae_obj({
|
||||||
log_lvl: log_lvl,
|
db_instance: db_sponsorships,
|
||||||
});
|
table_name: 'sponsorship',
|
||||||
if (log_lvl) {
|
obj_li: processed_obj_li,
|
||||||
console.log('DB save completed.');
|
properties_to_save: properties_to_save_sponsorship,
|
||||||
}
|
log_lvl: log_lvl
|
||||||
}
|
});
|
||||||
return sponsorship_obj_get_result;
|
if (log_lvl) {
|
||||||
} else {
|
console.log('DB save completed.');
|
||||||
console.log('No results returned.');
|
}
|
||||||
return null;
|
}
|
||||||
}
|
return sponsorship_obj_get_result;
|
||||||
})
|
} else {
|
||||||
.catch(function (error: any) {
|
console.log('No results returned.');
|
||||||
console.log('No results returned or failed.', error);
|
return null;
|
||||||
});
|
}
|
||||||
|
})
|
||||||
|
.catch(function (error: any) {
|
||||||
|
console.log('No results returned or failed.', error);
|
||||||
|
});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.load__sponsorship_obj:', ae_promises.load__sponsorship_obj);
|
console.log('ae_promises.load__sponsorship_obj:', ae_promises.load__sponsorship_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ae_promises.load__sponsorship_obj;
|
return ae_promises.load__sponsorship_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updated 2025-01-15
|
// Updated 2025-01-15
|
||||||
async function load_ae_obj_li__sponsorship(
|
async function load_ae_obj_li__sponsorship({
|
||||||
{
|
api_cfg,
|
||||||
api_cfg,
|
for_obj_type = 'account',
|
||||||
for_obj_type = 'account',
|
for_obj_id,
|
||||||
for_obj_id,
|
enabled = 'enabled',
|
||||||
enabled = 'enabled',
|
hidden = 'not_hidden',
|
||||||
hidden = 'not_hidden',
|
limit = 99,
|
||||||
limit = 99,
|
offset = 0,
|
||||||
offset = 0,
|
order_by_li = {
|
||||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
priority: 'DESC',
|
||||||
params = {},
|
sort: 'DESC',
|
||||||
try_cache = true,
|
name: 'ASC',
|
||||||
log_lvl = 0
|
updated_on: 'DESC',
|
||||||
}: {
|
created_on: 'DESC'
|
||||||
api_cfg: any,
|
},
|
||||||
for_obj_type: string,
|
params = {},
|
||||||
for_obj_id: string,
|
try_cache = true,
|
||||||
inc_content_li?: boolean,
|
log_lvl = 0
|
||||||
enabled?: "enabled" | "all" | "not_enabled" | undefined,
|
}: {
|
||||||
hidden?: "hidden" | "all" | "not_hidden" | undefined,
|
api_cfg: any;
|
||||||
limit?: number,
|
for_obj_type: string;
|
||||||
offset?: number,
|
for_obj_id: string;
|
||||||
order_by_li?: key_val,
|
inc_content_li?: boolean;
|
||||||
params?: key_val,
|
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
|
||||||
try_cache?: boolean,
|
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
|
||||||
log_lvl?: number
|
limit?: number;
|
||||||
}
|
offset?: number;
|
||||||
) {
|
order_by_li?: key_val;
|
||||||
if (log_lvl) {
|
params?: key_val;
|
||||||
console.log(`*** load_ae_obj_li__sponsorship() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
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 = {};
|
const params_json: key_val = {};
|
||||||
|
|
||||||
ae_promises.load__sponsorship_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
|
ae_promises.load__sponsorship_obj_li = await api
|
||||||
api_cfg: api_cfg,
|
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||||
obj_type: 'sponsorship',
|
api_cfg: api_cfg,
|
||||||
for_obj_type: for_obj_type,
|
obj_type: 'sponsorship',
|
||||||
for_obj_id: for_obj_id,
|
for_obj_type: for_obj_type,
|
||||||
use_alt_tbl: false,
|
for_obj_id: for_obj_id,
|
||||||
use_alt_mdl: false,
|
use_alt_tbl: false,
|
||||||
use_alt_exp: false,
|
use_alt_mdl: false,
|
||||||
enabled: enabled,
|
use_alt_exp: false,
|
||||||
hidden: hidden,
|
enabled: enabled,
|
||||||
order_by_li: order_by_li,
|
hidden: hidden,
|
||||||
limit: limit,
|
order_by_li: order_by_li,
|
||||||
offset: offset,
|
limit: limit,
|
||||||
params_json: params_json,
|
offset: offset,
|
||||||
params: params,
|
params_json: params_json,
|
||||||
log_lvl: log_lvl
|
params: params,
|
||||||
})
|
log_lvl: log_lvl
|
||||||
.then(async function (sponsorship_obj_li_get_result) {
|
})
|
||||||
if (sponsorship_obj_li_get_result) {
|
.then(async function (sponsorship_obj_li_get_result) {
|
||||||
if (try_cache) {
|
if (sponsorship_obj_li_get_result) {
|
||||||
// Process the results first
|
if (try_cache) {
|
||||||
let processed_obj_li = await process_ae_obj__sponsorship_props({
|
// Process the results first
|
||||||
obj_li: sponsorship_obj_li_get_result,
|
const processed_obj_li = await process_ae_obj__sponsorship_props({
|
||||||
log_lvl: log_lvl,
|
obj_li: sponsorship_obj_li_get_result,
|
||||||
});
|
log_lvl: log_lvl
|
||||||
if (log_lvl) {
|
});
|
||||||
console.log('Processed object list:', 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) {
|
// Save the updated results list to the database
|
||||||
console.log('Saving to DB...');
|
if (log_lvl) {
|
||||||
}
|
console.log('Saving to DB...');
|
||||||
await db_save_ae_obj_li__ae_obj({
|
}
|
||||||
db_instance: db_sponsorships,
|
await db_save_ae_obj_li__ae_obj({
|
||||||
table_name: 'sponsorship',
|
db_instance: db_sponsorships,
|
||||||
obj_li: processed_obj_li,
|
table_name: 'sponsorship',
|
||||||
properties_to_save: properties_to_save_sponsorship,
|
obj_li: processed_obj_li,
|
||||||
log_lvl: log_lvl,
|
properties_to_save: properties_to_save_sponsorship,
|
||||||
});
|
log_lvl: log_lvl
|
||||||
if (log_lvl) {
|
});
|
||||||
console.log('DB save completed.');
|
if (log_lvl) {
|
||||||
}
|
console.log('DB save completed.');
|
||||||
}
|
}
|
||||||
return sponsorship_obj_li_get_result;
|
}
|
||||||
} else {
|
return sponsorship_obj_li_get_result;
|
||||||
return [];
|
} else {
|
||||||
}
|
return [];
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('ae_promises.load__sponsorship_obj_li:', ae_promises.load__sponsorship_obj_li);
|
console.log('ae_promises.load__sponsorship_obj_li:', ae_promises.load__sponsorship_obj_li);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ae_promises.load__sponsorship_obj_li;
|
return ae_promises.load__sponsorship_obj_li;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function 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;
|
||||||
|
|
||||||
export async function download_export__sponsorship(
|
if (file_type == 'CSV' || file_type == 'Excel') {
|
||||||
{
|
params['file_type'] = file_type;
|
||||||
api_cfg,
|
}
|
||||||
account_id,
|
params['return_file'] = true;
|
||||||
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`;
|
ae_promises.download__sponsorship_export_file = await api.get_object({
|
||||||
params['for_obj_type'] = 'account';
|
api_cfg: api_cfg,
|
||||||
params['for_obj_id'] = account_id;
|
endpoint: endpoint,
|
||||||
|
params: params,
|
||||||
|
return_blob: return_file,
|
||||||
|
filename: filename,
|
||||||
|
auto_download: auto_download,
|
||||||
|
log_lvl: log_lvl
|
||||||
|
});
|
||||||
|
|
||||||
if (file_type == 'CSV' || file_type == 'Excel') {
|
console.log(
|
||||||
params['file_type'] = file_type;
|
'ae_promises.download__sponsorship_export_file:',
|
||||||
}
|
ae_promises.download__sponsorship_export_file
|
||||||
params['return_file'] = true;
|
);
|
||||||
|
return ae_promises.download__sponsorship_export_file;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const 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,
|
||||||
|
download_export__sponsorship: download_export__sponsorship
|
||||||
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,
|
|
||||||
download_export__sponsorship: download_export__sponsorship,
|
|
||||||
};
|
};
|
||||||
export let spons_func = export_obj;
|
export const spons_func = export_obj;
|
||||||
|
|||||||
@@ -7,115 +7,113 @@ import type { key_val } from '$lib/stores/ae_stores';
|
|||||||
|
|
||||||
// Updated 2025-01-15
|
// Updated 2025-01-15
|
||||||
export interface Sponsorship {
|
export interface Sponsorship {
|
||||||
id: string;
|
id: string;
|
||||||
// id_random: string;
|
// id_random: string;
|
||||||
sponsorship_id: string;
|
sponsorship_id: string;
|
||||||
// sponsorship_id_random: string;
|
// sponsorship_id_random: string;
|
||||||
|
|
||||||
account_id: string;
|
account_id: string;
|
||||||
// account_id_random: string;
|
// account_id_random: string;
|
||||||
|
|
||||||
organization_id?: null|string;
|
organization_id?: null | string;
|
||||||
person_id?: null|string;
|
person_id?: null | string;
|
||||||
|
|
||||||
poc_person_id?: null|string;
|
poc_person_id?: null | string;
|
||||||
poc_json?: null|string;
|
poc_json?: null | string;
|
||||||
|
|
||||||
name: null|string;
|
name: null | string;
|
||||||
name_override: null|string;
|
name_override: null | string;
|
||||||
|
|
||||||
description?: null|string;
|
description?: null | string;
|
||||||
|
|
||||||
email?: null|string;
|
email?: null | string;
|
||||||
website_url?: null|string;
|
website_url?: null | string;
|
||||||
|
|
||||||
// html_text?: null|string;
|
// html_text?: null|string;
|
||||||
// thumbnail_url?: null|string;
|
// thumbnail_url?: null|string;
|
||||||
// picture_url?: null|string;
|
// picture_url?: null|string;
|
||||||
// video_url?: null|string;
|
// video_url?: null|string;
|
||||||
// audio_url?: null|string;
|
// audio_url?: null|string;
|
||||||
// image_url?: null|string;
|
// image_url?: null|string;
|
||||||
// document_url?: null|string;
|
// document_url?: null|string;
|
||||||
// logo_url?: null|string;
|
// logo_url?: null|string;
|
||||||
|
|
||||||
logo_li_json?: null|string;
|
logo_li_json?: null | string;
|
||||||
media_li_json?: null|string;
|
media_li_json?: null | string;
|
||||||
social_li_json?: null|string;
|
social_li_json?: null | string;
|
||||||
address_li_json?: null|string;
|
address_li_json?: null | string;
|
||||||
contact_li_json?: null|string;
|
contact_li_json?: null | string;
|
||||||
guest_li_json?: null|string;
|
guest_li_json?: null | string;
|
||||||
|
|
||||||
level_num?: null|number;
|
level_num?: null | number;
|
||||||
level_str?: null|string;
|
level_str?: null | string;
|
||||||
|
|
||||||
amount?: null|number; // In dollars
|
amount?: null | number; // In dollars
|
||||||
|
|
||||||
questions_li_json?: null|string;
|
questions_li_json?: null | string;
|
||||||
|
|
||||||
agree?: null|boolean; // Catchall agree or consent
|
agree?: null | boolean; // Catchall agree or consent
|
||||||
|
|
||||||
comments?: null|string; // From the sponsor
|
comments?: null | string; // From the sponsor
|
||||||
staff_notes?: null|string; // Internal use; from staff
|
staff_notes?: null | string; // Internal use; from staff
|
||||||
|
|
||||||
enable: null|boolean;
|
enable: null | boolean;
|
||||||
hide?: null|boolean;
|
hide?: null | boolean;
|
||||||
priority?: null|boolean
|
priority?: null | boolean;
|
||||||
sort?: null|number;
|
sort?: null | number;
|
||||||
group?: null|string;
|
group?: null | string;
|
||||||
notes?: null|string;
|
notes?: null | string;
|
||||||
created_on: Date;
|
created_on: Date;
|
||||||
updated_on?: null|Date;
|
updated_on?: null | Date;
|
||||||
|
|
||||||
// Generated fields for sorting locally only
|
// Generated fields for sorting locally only
|
||||||
tmp_sort_1?: null|string;
|
tmp_sort_1?: null | string;
|
||||||
tmp_sort_2?: null|string;
|
tmp_sort_2?: null | string;
|
||||||
|
|
||||||
// Additional fields for convenience (database views)
|
// Additional fields for convenience (database views)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2025-01-15
|
// Updated 2025-01-15
|
||||||
export interface Sponsorship_Cfg {
|
export interface Sponsorship_Cfg {
|
||||||
id: string;
|
id: string;
|
||||||
// id_random: string;
|
// id_random: string;
|
||||||
sponsorship_cfg_id: string;
|
sponsorship_cfg_id: string;
|
||||||
// sponsorship_cfg_id_random: string;
|
// sponsorship_cfg_id_random: string;
|
||||||
|
|
||||||
account_id: string;
|
account_id: string;
|
||||||
// account_id_random: string;
|
// account_id_random: string;
|
||||||
|
|
||||||
for_type?: null|string;
|
for_type?: null | string;
|
||||||
for_id?: null|number;
|
for_id?: null | number;
|
||||||
|
|
||||||
level_li_json?: null|string;
|
level_li_json?: null | string;
|
||||||
option_li_json?: null|string;
|
option_li_json?: null | string;
|
||||||
schedule_li_json?: null|string;
|
schedule_li_json?: null | string;
|
||||||
|
|
||||||
cfg_json?: null|key_val;
|
cfg_json?: null | key_val;
|
||||||
|
|
||||||
enable: null|boolean;
|
enable: null | boolean;
|
||||||
hide?: null|boolean;
|
hide?: null | boolean;
|
||||||
priority?: null|boolean
|
priority?: null | boolean;
|
||||||
sort?: null|number;
|
sort?: null | number;
|
||||||
group?: null|string;
|
group?: null | string;
|
||||||
notes?: null|string;
|
notes?: null | string;
|
||||||
created_on: Date;
|
created_on: Date;
|
||||||
updated_on?: null|Date;
|
updated_on?: null | Date;
|
||||||
|
|
||||||
// Additional fields for convenience (database views)
|
// Additional fields for convenience (database views)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-09-25
|
// Updated 2024-09-25
|
||||||
export class MySubClassedDexie extends Dexie {
|
export class MySubClassedDexie extends Dexie {
|
||||||
// We just tell the typing system this is the case
|
// We just tell the typing system this is the case
|
||||||
sponsorship!: Table<Sponsorship>;
|
sponsorship!: Table<Sponsorship>;
|
||||||
cfg!: Table<Sponsorship_Cfg>;
|
cfg!: Table<Sponsorship_Cfg>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super('ae_sponsorships_db');
|
super('ae_sponsorships_db');
|
||||||
this.version(1).stores({
|
this.version(1).stores({
|
||||||
sponsorship: `
|
sponsorship: `
|
||||||
id, sponsorship_id,
|
id, sponsorship_id,
|
||||||
account_id,
|
account_id,
|
||||||
poc_person_id,
|
poc_person_id,
|
||||||
@@ -124,12 +122,12 @@ export class MySubClassedDexie extends Dexie {
|
|||||||
agree,
|
agree,
|
||||||
enable, hide, priority, sort, group, notes, created_on, updated_on, [updated_on+created_on], [created_on+updated_on]`,
|
enable, hide, priority, sort, group, notes, created_on, updated_on, [updated_on+created_on], [created_on+updated_on]`,
|
||||||
|
|
||||||
cfg: `
|
cfg: `
|
||||||
id, sponsorship_cfg_id,
|
id, sponsorship_cfg_id,
|
||||||
account_id,
|
account_id,
|
||||||
for_type, for_id`,
|
for_type, for_id`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const db_sponsorships = new MySubClassedDexie();
|
export const db_sponsorships = new MySubClassedDexie();
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
// Import external files first. Eventually this will be broken up in to smaller files.
|
// 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 {
|
||||||
import { get_obj_li_w_match_prop} from './ae_utils__get_obj_li_w_match_prop';
|
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 { file_extension_icon } from './ae_utils__file_extension_icon';
|
||||||
import { process_permission_checks } from './ae_utils__perm_checks';
|
import { process_permission_checks } from './ae_utils__perm_checks';
|
||||||
import { iso_datetime_formatter } from './ae_utils__datetime_format';
|
import { iso_datetime_formatter } from './ae_utils__datetime_format';
|
||||||
@@ -10,24 +16,27 @@ import { to_title_case } from './ae_utils__to_title_case';
|
|||||||
import { process_data_string } from './ae_utils__process_data_string';
|
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 { 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 { 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 {
|
||||||
|
combine_iv_and_base64,
|
||||||
|
encrypt_content,
|
||||||
|
encrypt_wrapper,
|
||||||
|
decrypt_content,
|
||||||
|
decrypt_wrapper
|
||||||
|
} from './ae_utils__crypto';
|
||||||
|
|
||||||
export type key_str = {
|
export type key_str = {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type key_val = {
|
export type key_val = {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* This utility function will add commas to a number. */
|
/* This utility function will add commas to a number. */
|
||||||
function number_w_commas(x) {
|
function number_w_commas(x) {
|
||||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This function will update the URL and send a message to the parent window (iframe).
|
// This function will update the URL and send a message to the parent window (iframe).
|
||||||
// The name should be something like "example_id".
|
// The name should be something like "example_id".
|
||||||
// Svelte specific:
|
// Svelte specific:
|
||||||
@@ -35,80 +44,113 @@ function number_w_commas(x) {
|
|||||||
// Updated 2024-03-02
|
// 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}`);
|
||||||
|
|
||||||
|
const location = window.location.href;
|
||||||
|
// console.log('location:', location);
|
||||||
|
const url = new URL(location);
|
||||||
|
// console.log('url:', url);
|
||||||
|
|
||||||
function handle_url_and_message(name: string, value: null|string) {
|
if (value) {
|
||||||
console.log(`*** handle_url_and_message() *** name=${name} value=${value}`);
|
url.searchParams.set(name, value);
|
||||||
|
history.pushState({}, '', url);
|
||||||
|
|
||||||
let location = window.location.href;
|
// console.log('url:', url);
|
||||||
// console.log('location:', location);
|
// pushState(url.href, {});
|
||||||
const url = new URL(location);
|
// pushState(url.search, {});
|
||||||
// console.log('url:', url);
|
// replaceState(url.href, {});
|
||||||
|
|
||||||
if (value) {
|
const message = { name: value };
|
||||||
url.searchParams.set(name, value);
|
window.parent.postMessage(message, '*');
|
||||||
history.pushState({}, '', url);
|
} else {
|
||||||
|
url.searchParams.delete(name);
|
||||||
|
history.pushState({}, '', url);
|
||||||
|
|
||||||
// console.log('url:', url);
|
// console.log('url:', url);
|
||||||
// pushState(url.href, {});
|
// pushState({}, '', url.search);
|
||||||
// pushState(url.search, {});
|
// pushState(url.href, {});
|
||||||
// replaceState(url.href, {});
|
// replaceState(url.href, {});
|
||||||
|
|
||||||
let message = {name: value};
|
const message = { name: null };
|
||||||
window.parent.postMessage(message, "*");
|
window.parent.postMessage(message, '*');
|
||||||
} else {
|
}
|
||||||
url.searchParams.delete(name);
|
// console.log('Message sent to parent (iframe):', message);
|
||||||
history.pushState({}, '', url);
|
|
||||||
|
|
||||||
// console.log('url:', url);
|
|
||||||
// pushState({}, '', url.search);
|
|
||||||
// pushState(url.href, {});
|
|
||||||
// replaceState(url.href, {});
|
|
||||||
|
|
||||||
let message = {name: null};
|
|
||||||
window.parent.postMessage(message, "*");
|
|
||||||
}
|
|
||||||
// console.log('Message sent to parent (iframe):', message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_a_element({
|
||||||
function create_a_element({account_id, base_url, hosted_file_id, filename=null, extension=null, text="Download", class_li='text-blue-500'}) {
|
account_id,
|
||||||
return `<a href="${base_url}/hosted_file/${hosted_file_id}/download?x_no_account_id_token=${account_id}&filename=${filename}" class="${class_li}">${text}</a>`;
|
base_url,
|
||||||
|
hosted_file_id,
|
||||||
|
filename = null,
|
||||||
|
extension = null,
|
||||||
|
text = 'Download',
|
||||||
|
class_li = 'text-blue-500'
|
||||||
|
}) {
|
||||||
|
return `<a href="${base_url}/hosted_file/${hosted_file_id}/download?x_no_account_id_token=${account_id}&filename=${filename}" class="${class_li}">${text}</a>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_img_element({account_id, base_url, hosted_file_id, filename=null, extension=null, class_li='max-w-64', style="", inc_link=false}) {
|
function create_img_element({
|
||||||
let img_html = '';
|
account_id,
|
||||||
if (filename) {
|
base_url,
|
||||||
img_html = `<img src="${base_url}/hosted_file/${hosted_file_id}/download?x_no_account_id_token=${account_id}&filename=${filename}" class="${class_li}" style="${style}" />`;
|
hosted_file_id,
|
||||||
} else {
|
filename = null,
|
||||||
img_html = `<img src="${base_url}/hosted_file/${hosted_file_id}/download?x_no_account_id_token=${account_id}" class="${class_li}" style="${style}" />`;
|
extension = null,
|
||||||
}
|
class_li = 'max-w-64',
|
||||||
|
style = '',
|
||||||
|
inc_link = false
|
||||||
|
}) {
|
||||||
|
let img_html = '';
|
||||||
|
if (filename) {
|
||||||
|
img_html = `<img src="${base_url}/hosted_file/${hosted_file_id}/download?x_no_account_id_token=${account_id}&filename=${filename}" class="${class_li}" style="${style}" />`;
|
||||||
|
} else {
|
||||||
|
img_html = `<img src="${base_url}/hosted_file/${hosted_file_id}/download?x_no_account_id_token=${account_id}" class="${class_li}" style="${style}" />`;
|
||||||
|
}
|
||||||
|
|
||||||
if (inc_link) {
|
if (inc_link) {
|
||||||
let a_html = create_a_element({account_id: account_id, base_url: base_url, hosted_file_id: hosted_file_id, filename: filename, extension: extension});
|
const a_html = create_a_element({
|
||||||
img_html = `<div class="ae_img ae_a">${img_html}${a_html}</div>`;
|
account_id: account_id,
|
||||||
}
|
base_url: base_url,
|
||||||
|
hosted_file_id: hosted_file_id,
|
||||||
|
filename: filename,
|
||||||
|
extension: extension
|
||||||
|
});
|
||||||
|
img_html = `<div class="ae_img ae_a">${img_html}${a_html}</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
return img_html;
|
return img_html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_video_element({account_id, base_url, hosted_file_id, filename=null, extension=null, class_li='max-w-64', inc_link=false}) {
|
function create_video_element({
|
||||||
let video_html = '';
|
account_id,
|
||||||
if (filename) {
|
base_url,
|
||||||
video_html = `<video src="${base_url}/hosted_file/${hosted_file_id}/download?x_no_account_id_token=${account_id}&filename=${filename}" controls class="${class_li}"></video>`;
|
hosted_file_id,
|
||||||
} else {
|
filename = null,
|
||||||
video_html = `<video src="${base_url}/hosted_file/${hosted_file_id}/download?x_no_account_id_token=${account_id}" controls class="${class_li}"></video>`;
|
extension = null,
|
||||||
}
|
class_li = 'max-w-64',
|
||||||
|
inc_link = false
|
||||||
|
}) {
|
||||||
|
let video_html = '';
|
||||||
|
if (filename) {
|
||||||
|
video_html = `<video src="${base_url}/hosted_file/${hosted_file_id}/download?x_no_account_id_token=${account_id}&filename=${filename}" controls class="${class_li}"></video>`;
|
||||||
|
} else {
|
||||||
|
video_html = `<video src="${base_url}/hosted_file/${hosted_file_id}/download?x_no_account_id_token=${account_id}" controls class="${class_li}"></video>`;
|
||||||
|
}
|
||||||
|
|
||||||
if (inc_link) {
|
if (inc_link) {
|
||||||
let a_html = create_a_element({account_id: account_id, base_url: base_url, hosted_file_id: hosted_file_id, filename: filename, extension: extension});
|
const a_html = create_a_element({
|
||||||
video_html = `<div class="ae_video ae_a">${video_html}${a_html}</div>`;
|
account_id: account_id,
|
||||||
}
|
base_url: base_url,
|
||||||
|
hosted_file_id: hosted_file_id,
|
||||||
|
filename: filename,
|
||||||
|
extension: extension
|
||||||
|
});
|
||||||
|
video_html = `<div class="ae_video ae_a">${video_html}${a_html}</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
return video_html;
|
return video_html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// // Clear the quick access type
|
// // Clear the quick access type
|
||||||
// function clear_access_type() {
|
// function clear_access_type() {
|
||||||
// // NOTE: I think it makes since to reset this to anonymous even if logged in as an admin or similar.
|
// // NOTE: I think it makes since to reset this to anonymous even if logged in as an admin or similar.
|
||||||
@@ -127,146 +169,138 @@ function create_video_element({account_id, base_url, hosted_file_id, filename=nu
|
|||||||
// return true;
|
// return true;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// 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 paragraphs) of text and return an estimated number of words.
|
||||||
function count_words(text: string) {
|
function count_words(text: string) {
|
||||||
if (!text || text.length < 1) {
|
if (!text || text.length < 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let count = text.trim().split(/\s+/).length;
|
const count = text.trim().split(/\s+/).length;
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updated 2024-06-19
|
// Updated 2024-06-19
|
||||||
// This function behaves weirdly. It needs to be reviewed and updated.
|
// This function behaves weirdly. It needs to be reviewed and updated.
|
||||||
export let shorten_string = function shorten_string(
|
export const shorten_string = function shorten_string({
|
||||||
{
|
string,
|
||||||
string,
|
max_length = 45,
|
||||||
max_length = 45,
|
begin_length = 15,
|
||||||
begin_length = 15,
|
end_length = 5,
|
||||||
end_length = 5,
|
wildcard_length = 3
|
||||||
wildcard_length = 3
|
}: {
|
||||||
}: {
|
string: undefined | string;
|
||||||
string: undefined|string,
|
max_length?: number;
|
||||||
max_length?: number,
|
begin_length?: number;
|
||||||
begin_length?: number,
|
end_length?: number;
|
||||||
end_length?: number,
|
wildcard_length?: number;
|
||||||
wildcard_length?: number
|
}) {
|
||||||
}
|
// console.log('*** shorten_filename() ***');
|
||||||
) {
|
|
||||||
// console.log('*** shorten_filename() ***');
|
|
||||||
|
|
||||||
if (!string || typeof string != 'string') {
|
if (!string || typeof string != 'string') {
|
||||||
// console.log('Invalid string value passed');
|
// console.log('Invalid string value passed');
|
||||||
// return false;
|
// return false;
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: max_length is not the actual end result length. The actual max will be 45 characters.
|
// NOTE: max_length is not the actual end result length. The actual max will be 45 characters.
|
||||||
// 20 part 1 characters, 5 part 2 characters, 20 part 3 characters
|
// 20 part 1 characters, 5 part 2 characters, 20 part 3 characters
|
||||||
|
|
||||||
// let length = string.length;
|
// let length = string.length;
|
||||||
let char_over = string.length-max_length;
|
const char_over = string.length - max_length;
|
||||||
let new_string = null;
|
let new_string = null;
|
||||||
let wildcards = char_over;
|
let wildcards = char_over;
|
||||||
if (char_over > 0) {
|
if (char_over > 0) {
|
||||||
let part1 = string.slice(0, begin_length);
|
const part1 = string.slice(0, begin_length);
|
||||||
|
|
||||||
let part2 = '';
|
let part2 = '';
|
||||||
if (char_over > 5) {
|
if (char_over > 5) {
|
||||||
wildcards = 5;
|
wildcards = 5;
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wildcard_length) {
|
if (wildcard_length) {
|
||||||
part2 = '.'.repeat(wildcard_length);
|
part2 = '.'.repeat(wildcard_length);
|
||||||
} else {
|
} else {
|
||||||
part2 = '.'.repeat(wildcards);
|
part2 = '.'.repeat(wildcards);
|
||||||
}
|
}
|
||||||
|
|
||||||
let part3 = string.slice(end_length*-1);
|
const part3 = string.slice(end_length * -1);
|
||||||
|
|
||||||
new_string = part1+part2+part3;
|
|
||||||
} else {
|
|
||||||
new_string = string;
|
|
||||||
}
|
|
||||||
return new_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
new_string = part1 + part2 + part3;
|
||||||
|
} else {
|
||||||
|
new_string = string;
|
||||||
|
}
|
||||||
|
return new_string;
|
||||||
|
};
|
||||||
|
|
||||||
// Updated 2024-06-19
|
// Updated 2024-06-19
|
||||||
// This function should return a shorted version of a filename if over the max length. It should always contain at least the first character of the original filename and the complete extension.
|
// This function should return a shorted version of a filename if over the max length. It should always contain at least the first character of the original filename and the complete extension.
|
||||||
// Example 1: The Original Long File Name.pdf -> The Orig....pdf
|
// Example 1: The Original Long File Name.pdf -> The Orig....pdf
|
||||||
// Example 2: The Original Long File Name.html -> The Ori....html
|
// Example 2: The Original Long File Name.html -> The Ori....html
|
||||||
function shorten_filename(
|
function shorten_filename({
|
||||||
{
|
filename,
|
||||||
filename,
|
max_length = 20,
|
||||||
max_length = 20,
|
slice_end_at = 15,
|
||||||
slice_end_at = 15,
|
max_end_length = 5
|
||||||
max_end_length = 5
|
}: {
|
||||||
}: {
|
filename: string;
|
||||||
filename: string,
|
max_length?: number;
|
||||||
max_length?: number,
|
slice_end_at?: number;
|
||||||
slice_end_at?: number,
|
max_end_length?: number;
|
||||||
max_end_length?: number
|
}) {
|
||||||
}
|
// console.log('*** shorten_filename() ***');
|
||||||
) {
|
|
||||||
// console.log('*** shorten_filename() ***');
|
|
||||||
|
|
||||||
if (typeof filename !== 'string' || filename.length <= max_length) {
|
if (typeof filename !== 'string' || filename.length <= max_length) {
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
let new_filename = null;
|
let new_filename = null;
|
||||||
let char_over = filename.length - max_length;
|
const char_over = filename.length - max_length;
|
||||||
let wildcards = char_over - 4; // The number of characters over the max length
|
let wildcards = char_over - 4; // The number of characters over the max length
|
||||||
if (wildcards < 1) {
|
if (wildcards < 1) {
|
||||||
return filename; // No point in changing the filename?
|
return filename; // No point in changing the filename?
|
||||||
}
|
}
|
||||||
|
|
||||||
let part_1 = filename.slice(0, slice_end_at);
|
const part_1 = filename.slice(0, slice_end_at);
|
||||||
if (wildcards > 3) {
|
if (wildcards > 3) {
|
||||||
wildcards = 3;
|
wildcards = 3;
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
let part_2 = '.'.repeat(wildcards);
|
const part_2 = '.'.repeat(wildcards);
|
||||||
let part_3 = filename.slice(max_end_length*-1);
|
const part_3 = filename.slice(max_end_length * -1);
|
||||||
|
|
||||||
new_filename = part_1+part_2+part_3;
|
new_filename = part_1 + part_2 + part_3;
|
||||||
|
|
||||||
return new_filename;
|
return new_filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const ae_util = {
|
||||||
export let ae_util = {
|
is_datetime_recent: is_datetime_recent,
|
||||||
is_datetime_recent: is_datetime_recent,
|
process_permission_checks: process_permission_checks,
|
||||||
process_permission_checks: process_permission_checks,
|
iso_datetime_formatter: iso_datetime_formatter,
|
||||||
iso_datetime_formatter: iso_datetime_formatter,
|
clean_filename: clean_filename,
|
||||||
clean_filename: clean_filename,
|
format_bytes: format_bytes,
|
||||||
format_bytes: format_bytes,
|
number_w_commas: number_w_commas,
|
||||||
number_w_commas: number_w_commas,
|
guess_file_name: guess_file_name,
|
||||||
guess_file_name: guess_file_name,
|
guess_file_extension: guess_file_extension,
|
||||||
guess_file_extension: guess_file_extension,
|
get_file_hash: get_file_hash,
|
||||||
get_file_hash: get_file_hash,
|
get_obj_li_w_match_prop: get_obj_li_w_match_prop,
|
||||||
get_obj_li_w_match_prop: get_obj_li_w_match_prop,
|
extract_prefixed_form_data: extract_prefixed_form_data,
|
||||||
extract_prefixed_form_data: extract_prefixed_form_data,
|
process_data_string: process_data_string,
|
||||||
process_data_string: process_data_string,
|
handle_url_and_message: handle_url_and_message,
|
||||||
handle_url_and_message: handle_url_and_message,
|
create_a_element: create_a_element,
|
||||||
create_a_element: create_a_element,
|
create_img_element: create_img_element,
|
||||||
create_img_element: create_img_element,
|
create_video_element: create_video_element,
|
||||||
create_video_element: create_video_element,
|
count_words: count_words,
|
||||||
count_words: count_words,
|
to_title_case: to_title_case,
|
||||||
to_title_case: to_title_case,
|
shorten_string: shorten_string,
|
||||||
shorten_string: shorten_string,
|
shorten_filename: shorten_filename,
|
||||||
shorten_filename: shorten_filename,
|
file_extension_icon: file_extension_icon,
|
||||||
file_extension_icon: file_extension_icon,
|
set_obj_prop_display_name: set_obj_prop_display_name,
|
||||||
set_obj_prop_display_name: set_obj_prop_display_name,
|
return_obj_type_path: return_obj_type_path,
|
||||||
return_obj_type_path: return_obj_type_path,
|
combine_iv_and_base64: combine_iv_and_base64,
|
||||||
combine_iv_and_base64: combine_iv_and_base64,
|
encrypt_content: encrypt_content,
|
||||||
encrypt_content: encrypt_content,
|
encrypt_wrapper: encrypt_wrapper,
|
||||||
encrypt_wrapper: encrypt_wrapper,
|
decrypt_content: decrypt_content,
|
||||||
decrypt_content: decrypt_content,
|
decrypt_wrapper: decrypt_wrapper
|
||||||
decrypt_wrapper: decrypt_wrapper,
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,121 +1,127 @@
|
|||||||
let log_lvl = 0; // 0 = no logging, 1 = some logging, 2 = all logging
|
const log_lvl = 0; // 0 = no logging, 1 = some logging, 2 = all logging
|
||||||
|
|
||||||
// Updated 2025-05-08
|
// Updated 2025-05-08
|
||||||
async function generate_iv() {
|
async function generate_iv() {
|
||||||
const data = new Uint8Array(16);
|
const data = new Uint8Array(16);
|
||||||
crypto.getRandomValues(data);
|
crypto.getRandomValues(data);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updated 2025-05-08
|
// Updated 2025-05-08
|
||||||
export let encrypt_content = async function encrypt_content(
|
export const encrypt_content = async function encrypt_content(content: string, keyData: string) {
|
||||||
content: string,
|
const iv = await generate_iv();
|
||||||
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, [
|
||||||
const iv = await generate_iv();
|
'encrypt'
|
||||||
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(
|
||||||
const encodedContent = await crypto.subtle.encrypt({ name: 'AES-CBC', iv }, key, new TextEncoder().encode(content));
|
{ name: 'AES-CBC', iv },
|
||||||
const base64 = btoa(String.fromCharCode(...new Uint8Array(encodedContent)));
|
key,
|
||||||
if (log_lvl) {
|
new TextEncoder().encode(content)
|
||||||
console.log(`IV: ${iv}; Encrypted:`, base64);
|
);
|
||||||
}
|
const base64 = btoa(String.fromCharCode(...new Uint8Array(encodedContent)));
|
||||||
return { base64, iv };
|
if (log_lvl) {
|
||||||
}
|
console.log(`IV: ${iv}; Encrypted:`, base64);
|
||||||
|
}
|
||||||
|
return { base64, iv };
|
||||||
|
};
|
||||||
|
|
||||||
// Updated 2025-05-08
|
// Updated 2025-05-08
|
||||||
export let combine_iv_and_base64 = function combine_iv_and_base64(
|
export const combine_iv_and_base64 = function combine_iv_and_base64(
|
||||||
base64: string,
|
base64: string,
|
||||||
iv: Uint8Array
|
iv: Uint8Array
|
||||||
) {
|
) {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`IV: ${iv}; Encrypted:`, base64);
|
console.log(`IV: ${iv}; Encrypted:`, base64);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Combine the IV and encrypted content
|
// Combine the IV and encrypted content
|
||||||
const combined = Array.from(iv).map(byte => byte.toString(16).padStart(2, '0')).join('') + ':' + base64;
|
const combined =
|
||||||
if (log_lvl) {
|
Array.from(iv)
|
||||||
console.log('Combined IV and Base64:', combined);
|
.map((byte) => byte.toString(16).padStart(2, '0'))
|
||||||
}
|
.join('') +
|
||||||
// const ivBase64 = btoa(String.fromCharCode(...iv));
|
':' +
|
||||||
// const combined = `${ivBase64}:${base64}`;
|
base64;
|
||||||
// console.log('Combined IV and Base64 v2:', combined);
|
if (log_lvl) {
|
||||||
return combined;
|
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
|
// Updated 2025-05-08
|
||||||
export let encrypt_wrapper = async function encrypt_wrapper(
|
export const encrypt_wrapper = async function encrypt_wrapper(content: string, keyData: string) {
|
||||||
content: string,
|
if (!content) {
|
||||||
keyData: string
|
console.error('No content provided. Returning empty string.');
|
||||||
) {
|
return '';
|
||||||
if (!content) {
|
}
|
||||||
console.error('No content provided. Returning empty string.');
|
if (!keyData) {
|
||||||
return '';
|
console.error('No keyData provided. Returning empty string.');
|
||||||
}
|
return '';
|
||||||
if (!keyData) {
|
}
|
||||||
console.error('No keyData provided. Returning empty string.');
|
const { base64, iv } = await encrypt_content(content, keyData);
|
||||||
return '';
|
const combined = combine_iv_and_base64(base64, iv);
|
||||||
}
|
return combined;
|
||||||
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.
|
// This does not handle errors (invalid key/password) well.
|
||||||
// Updated 2025-05-08
|
// Updated 2025-05-08
|
||||||
export let decrypt_content = async function decrypt_content(
|
export const decrypt_content = async function decrypt_content(
|
||||||
base64Content: string,
|
base64Content: string,
|
||||||
iv: Uint8Array,
|
iv: Uint8Array,
|
||||||
keyData: string
|
keyData: string
|
||||||
) {
|
) {
|
||||||
const keyBytes = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(keyData));
|
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 key = await crypto.subtle.importKey('raw', keyBytes, { name: 'AES-CBC' }, false, [
|
||||||
const encryptedContent = Uint8Array.from(atob(base64Content), c => c.charCodeAt(0));
|
'decrypt'
|
||||||
const decryptedContent = await crypto.subtle.decrypt({ name: 'AES-CBC', iv }, key, encryptedContent);
|
]);
|
||||||
const decodedContent = new TextDecoder().decode(decryptedContent);
|
const encryptedContent = Uint8Array.from(atob(base64Content), (c) => c.charCodeAt(0));
|
||||||
// console.log('Decrypted Content:', decodedContent);
|
const decryptedContent = await crypto.subtle.decrypt(
|
||||||
return decodedContent;
|
{ name: 'AES-CBC', iv },
|
||||||
}
|
key,
|
||||||
|
encryptedContent
|
||||||
|
);
|
||||||
|
const decodedContent = new TextDecoder().decode(decryptedContent);
|
||||||
|
// console.log('Decrypted Content:', decodedContent);
|
||||||
|
return decodedContent;
|
||||||
|
};
|
||||||
|
|
||||||
// Updated 2025-05-08
|
// Updated 2025-05-08
|
||||||
export let split_iv_and_base64 = function split_iv_and_base64(
|
export const split_iv_and_base64 = function split_iv_and_base64(combined: string) {
|
||||||
combined: string
|
if (!combined) {
|
||||||
) {
|
console.error('No combined string provided. Returning empty object.');
|
||||||
if (!combined) {
|
return { iv: new Uint8Array(), base64: '' };
|
||||||
console.error('No combined string provided. Returning empty object.');
|
}
|
||||||
return { iv: new Uint8Array(), base64: '' };
|
const [iv_hex, encrypted_base64_string] = combined.split(':');
|
||||||
}
|
const base64 = encrypted_base64_string;
|
||||||
let [iv_hex, encrypted_base64_string] = combined.split(':');
|
const iv = new Uint8Array(iv_hex.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
|
||||||
let base64 = encrypted_base64_string
|
if (log_lvl) {
|
||||||
let iv = new Uint8Array(iv_hex.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
|
console.log(`IV: ${iv}; Encrypted:`, base64);
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`IV: ${iv}; Encrypted:`, base64);
|
return { iv, base64 };
|
||||||
}
|
};
|
||||||
return { iv, base64 };
|
|
||||||
}
|
|
||||||
|
|
||||||
// Updated 2025-05-15
|
// Updated 2025-05-15
|
||||||
export let decrypt_wrapper = async function decrypt_wrapper(
|
export const decrypt_wrapper = async function decrypt_wrapper(combined: string, keyData: string) {
|
||||||
combined: string,
|
if (!combined) {
|
||||||
keyData: string
|
console.error('No combined string provided. Returning empty string.');
|
||||||
) {
|
return false;
|
||||||
if (!combined) {
|
}
|
||||||
console.error('No combined string provided. Returning empty string.');
|
const { iv, base64 } = split_iv_and_base64(combined);
|
||||||
return false;
|
console.log(`IV: ${iv}; Encrypted:`, base64);
|
||||||
}
|
let decrypted;
|
||||||
const { iv, base64 } = split_iv_and_base64(combined);
|
try {
|
||||||
console.log(`IV: ${iv}; Encrypted:`, base64);
|
decrypted = await decrypt_content(base64, iv, keyData);
|
||||||
let decrypted;
|
if (log_lvl > 1) {
|
||||||
try {
|
console.log(`IV: ${iv}; Decrypted:`, decrypted);
|
||||||
decrypted = await decrypt_content(base64, iv, keyData);
|
} else if (log_lvl) {
|
||||||
if (log_lvl > 1) {
|
console.log(`IV: ${iv}`);
|
||||||
console.log(`IV: ${iv}; Decrypted:`, decrypted);
|
}
|
||||||
} else if (log_lvl) {
|
} catch (error) {
|
||||||
console.log(`IV: ${iv}`);
|
console.error('Decryption failed:', error);
|
||||||
}
|
return false;
|
||||||
} catch (error) {
|
}
|
||||||
console.error('Decryption failed:', error);
|
return decrypted;
|
||||||
return false;
|
};
|
||||||
}
|
|
||||||
return decrypted;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,176 +1,176 @@
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
export let iso_datetime_formatter = function iso_datetime_formatter(
|
export const iso_datetime_formatter = function iso_datetime_formatter(
|
||||||
raw_datetime: null|string|Date = null,
|
raw_datetime: null | string | Date = null,
|
||||||
named_format: string = 'datetime_iso_no_seconds', // date_iso, datetime_iso_no_seconds
|
named_format: string = 'datetime_iso_no_seconds', // date_iso, datetime_iso_no_seconds
|
||||||
time_24_hours: boolean = false
|
time_24_hours: boolean = false
|
||||||
) {
|
) {
|
||||||
// console.log('*** iso_datetime_formatter() ***');
|
// console.log('*** iso_datetime_formatter() ***');
|
||||||
|
|
||||||
// https://en.wikipedia.org/wiki/ISO_8601
|
// https://en.wikipedia.org/wiki/ISO_8601
|
||||||
// https://day.js.org/docs/en/display/format
|
// https://day.js.org/docs/en/display/format
|
||||||
// ISO 8601-1:2019 includes the T before the time portion
|
// ISO 8601-1:2019 includes the T before the time portion
|
||||||
// ISO 8601-1:2019 midnight may only be referred to as "00:00", corresponding to the beginning of a calendar day
|
// ISO 8601-1:2019 midnight may only be referred to as "00:00", corresponding to the beginning of a calendar day
|
||||||
// and "24:00" is no longer allowed corresponding to the end of a day
|
// and "24:00" is no longer allowed corresponding to the end of a day
|
||||||
// 60 is only used to denote an added leap second
|
// 60 is only used to denote an added leap second
|
||||||
|
|
||||||
// ISO 8601 UTC: 2021-03-04T19:04:44+00:00
|
// ISO 8601 UTC: 2021-03-04T19:04:44+00:00
|
||||||
// ISO 8601 UTC: 2021-03-04T19:04:44Z
|
// ISO 8601 UTC: 2021-03-04T19:04:44Z
|
||||||
// ISO 8601 UTC: 20210304T190444Z
|
// ISO 8601 UTC: 20210304T190444Z
|
||||||
|
|
||||||
// datetime_iso 'YYYY-MM-DD HH:mm:ss'
|
// datetime_iso 'YYYY-MM-DD HH:mm:ss'
|
||||||
// datetime_iso_12 'YYYY-MM-DD hh:mm:ss A'
|
// datetime_iso_12 'YYYY-MM-DD hh:mm:ss A'
|
||||||
// datetime_iso_12_short 'YY-MM-DD hh:mm 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 Z'
|
||||||
|
|
||||||
// datetime_12_no_seconds 'YYYY-MM-DD hh:mm A'
|
// datetime_12_no_seconds 'YYYY-MM-DD hh:mm A'
|
||||||
|
|
||||||
// datetime_long 'dddd, MMMM D, YYYY hh:mm:ss A'
|
// datetime_long 'dddd, MMMM D, YYYY hh:mm:ss A'
|
||||||
// datetime_medium 'ddd, MMM D, YYYY hh:mm:ss A'
|
// datetime_medium 'ddd, MMM D, YYYY hh:mm:ss A'
|
||||||
// datetime_short 'MMM D, YY hh:mm A'
|
// datetime_short 'MMM D, YY hh:mm A'
|
||||||
|
|
||||||
// date_iso 'YYYY-MM-DD'
|
// date_iso 'YYYY-MM-DD'
|
||||||
|
|
||||||
// date_long 'dddd, MMMM D, YYYY'
|
// date_long 'dddd, MMMM D, YYYY'
|
||||||
// date_medium 'ddd, MMM D, YYYY'
|
// date_medium 'ddd, MMM D, YYYY'
|
||||||
// date_short 'MMM D, YY'
|
// date_short 'MMM D, YY'
|
||||||
|
|
||||||
// time_iso 'HH:mm:ss'
|
// time_iso 'HH:mm:ss'
|
||||||
// time_iso_12 'hh:mm:ss A'
|
// time_iso_12 'hh:mm:ss A'
|
||||||
// time_iso_tz 'HH:mm:ss Z'
|
// time_iso_tz 'HH:mm:ss Z'
|
||||||
// time_iso_12_tz 'hh:mm:ss A Z'
|
// time_iso_12_tz 'hh:mm:ss A Z'
|
||||||
|
|
||||||
// time_long 'hh:mm:ss A'
|
// time_long 'hh:mm:ss A'
|
||||||
// time_medium 'h:m:s A'
|
// time_medium 'h:m:s A'
|
||||||
// time_short 'hh:mm A'
|
// time_short 'hh:mm A'
|
||||||
|
|
||||||
// dayjs(raw_datetime).format('dddd, MMMM D, YYYY hh:mm:ss A');
|
// dayjs(raw_datetime).format('dddd, MMMM D, YYYY hh:mm:ss A');
|
||||||
|
|
||||||
if (!raw_datetime) {
|
if (!raw_datetime) {
|
||||||
raw_datetime = new Date(); // Get the current datetime if one was not passed.
|
raw_datetime = new Date(); // Get the current datetime if one was not passed.
|
||||||
}
|
}
|
||||||
|
|
||||||
let datetime_string = null;
|
let datetime_string = null;
|
||||||
|
|
||||||
switch (named_format) {
|
switch (named_format) {
|
||||||
case 'datetime_iso':
|
case 'datetime_iso':
|
||||||
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss');
|
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss');
|
||||||
break;
|
break;
|
||||||
case 'datetime_iso_no_seconds':
|
case 'datetime_iso_no_seconds':
|
||||||
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm');
|
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm');
|
||||||
break;
|
break;
|
||||||
case 'datetime_iso_12_short':
|
case 'datetime_iso_12_short':
|
||||||
datetime_string = dayjs(raw_datetime).format('YY-MM-DD hh:mm A');
|
datetime_string = dayjs(raw_datetime).format('YY-MM-DD hh:mm A');
|
||||||
break;
|
break;
|
||||||
case 'datetime_iso_12_short_month':
|
case 'datetime_iso_12_short_month':
|
||||||
datetime_string = dayjs(raw_datetime).format('MM-DD hh:mm A');
|
datetime_string = dayjs(raw_datetime).format('MM-DD hh:mm A');
|
||||||
break;
|
break;
|
||||||
case 'datetime_iso_tz':
|
case 'datetime_iso_tz':
|
||||||
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss Z');
|
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss Z');
|
||||||
break;
|
break;
|
||||||
case 'datetime_iso_12_no_seconds':
|
case 'datetime_iso_12_no_seconds':
|
||||||
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD hh:mm A');
|
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD hh:mm A');
|
||||||
break;
|
break;
|
||||||
// case 'datetime_12_no_seconds':
|
// case 'datetime_12_no_seconds':
|
||||||
// datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD hh:mm A');
|
// datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD hh:mm A');
|
||||||
// break;
|
// break;
|
||||||
case 'datetime_us':
|
case 'datetime_us':
|
||||||
datetime_string = dayjs(raw_datetime).format('MM/DD/YYYY hh:mm:ss A');
|
datetime_string = dayjs(raw_datetime).format('MM/DD/YYYY hh:mm:ss A');
|
||||||
break;
|
break;
|
||||||
case 'datetime_short':
|
case 'datetime_short':
|
||||||
datetime_string = dayjs(raw_datetime).format('MMM D, YY HH:mm');
|
datetime_string = dayjs(raw_datetime).format('MMM D, YY HH:mm');
|
||||||
break;
|
break;
|
||||||
case 'datetime_12_short':
|
case 'datetime_12_short':
|
||||||
datetime_string = dayjs(raw_datetime).format('MMM D, YY hh:mm A');
|
datetime_string = dayjs(raw_datetime).format('MMM D, YY hh:mm A');
|
||||||
break;
|
break;
|
||||||
case 'datetime_medium':
|
case 'datetime_medium':
|
||||||
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY H:mm');
|
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY H:mm');
|
||||||
break;
|
break;
|
||||||
case 'datetime_12_medium':
|
case 'datetime_12_medium':
|
||||||
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY h:mm A');
|
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY h:mm A');
|
||||||
break;
|
break;
|
||||||
case 'datetime_long':
|
case 'datetime_long':
|
||||||
datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY HH:mm');
|
datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY HH:mm');
|
||||||
break;
|
break;
|
||||||
case 'datetime_12_long':
|
case 'datetime_12_long':
|
||||||
datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY hh:mm A');
|
datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY hh:mm A');
|
||||||
break;
|
break;
|
||||||
case 'datetime_medium_sec':
|
case 'datetime_medium_sec':
|
||||||
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY H:mm:ss');
|
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY H:mm:ss');
|
||||||
break;
|
break;
|
||||||
case 'datetime_12_medium_sec':
|
case 'datetime_12_medium_sec':
|
||||||
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY h:mm:ss A');
|
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY h:mm:ss A');
|
||||||
break;
|
break;
|
||||||
case 'datetime_short_month':
|
case 'datetime_short_month':
|
||||||
datetime_string = dayjs(raw_datetime).format('MMM D hh:mm A');
|
datetime_string = dayjs(raw_datetime).format('MMM D hh:mm A');
|
||||||
break;
|
break;
|
||||||
case 'datetime_long_month':
|
case 'datetime_long_month':
|
||||||
datetime_string = dayjs(raw_datetime).format('MMMM D hh:mm A');
|
datetime_string = dayjs(raw_datetime).format('MMMM D hh:mm A');
|
||||||
break;
|
break;
|
||||||
case 'datetime_short_day':
|
case 'datetime_short_day':
|
||||||
datetime_string = dayjs(raw_datetime).format('D hh:mm A');
|
datetime_string = dayjs(raw_datetime).format('D hh:mm A');
|
||||||
break;
|
break;
|
||||||
case 'date_iso':
|
case 'date_iso':
|
||||||
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD');
|
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD');
|
||||||
break;
|
break;
|
||||||
case 'date_us':
|
case 'date_us':
|
||||||
datetime_string = dayjs(raw_datetime).format('MM/DD/YYYY');
|
datetime_string = dayjs(raw_datetime).format('MM/DD/YYYY');
|
||||||
break;
|
break;
|
||||||
case 'date_long_month_day':
|
case 'date_long_month_day':
|
||||||
datetime_string = dayjs(raw_datetime).format('MMMM D');
|
datetime_string = dayjs(raw_datetime).format('MMMM D');
|
||||||
break;
|
break;
|
||||||
case 'date_short':
|
case 'date_short':
|
||||||
datetime_string = dayjs(raw_datetime).format('MMM D, YY');
|
datetime_string = dayjs(raw_datetime).format('MMM D, YY');
|
||||||
break;
|
break;
|
||||||
case 'date_short_no_year':
|
case 'date_short_no_year':
|
||||||
datetime_string = dayjs(raw_datetime).format('MMM D');
|
datetime_string = dayjs(raw_datetime).format('MMM D');
|
||||||
break;
|
break;
|
||||||
case 'date_long':
|
case 'date_long':
|
||||||
datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY');
|
datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY');
|
||||||
break;
|
break;
|
||||||
case 'date_full':
|
case 'date_full':
|
||||||
datetime_string = dayjs(raw_datetime).format('dddd, MMMM D, YYYY');
|
datetime_string = dayjs(raw_datetime).format('dddd, MMMM D, YYYY');
|
||||||
break;
|
break;
|
||||||
case 'date_full_no_year':
|
case 'date_full_no_year':
|
||||||
datetime_string = dayjs(raw_datetime).format('dddd, MMMM D');
|
datetime_string = dayjs(raw_datetime).format('dddd, MMMM D');
|
||||||
break;
|
break;
|
||||||
case 'time_iso':
|
case 'time_iso':
|
||||||
datetime_string = dayjs(raw_datetime).format('HH:mm:ss');
|
datetime_string = dayjs(raw_datetime).format('HH:mm:ss');
|
||||||
break;
|
break;
|
||||||
case 'time_iso_12_tz':
|
case 'time_iso_12_tz':
|
||||||
datetime_string = dayjs(raw_datetime).format('hh:mm:ss A Z');
|
datetime_string = dayjs(raw_datetime).format('hh:mm:ss A Z');
|
||||||
break;
|
break;
|
||||||
case 'time_long':
|
case 'time_long':
|
||||||
datetime_string = dayjs(raw_datetime).format('HH:mm:ss');
|
datetime_string = dayjs(raw_datetime).format('HH:mm:ss');
|
||||||
break;
|
break;
|
||||||
case 'time_12_long':
|
case 'time_12_long':
|
||||||
datetime_string = dayjs(raw_datetime).format('hh:mm:ss A');
|
datetime_string = dayjs(raw_datetime).format('hh:mm:ss A');
|
||||||
break;
|
break;
|
||||||
case 'time_short':
|
case 'time_short':
|
||||||
datetime_string = dayjs(raw_datetime).format('HH:mm');
|
datetime_string = dayjs(raw_datetime).format('HH:mm');
|
||||||
break;
|
break;
|
||||||
case 'time_short_no_leading':
|
case 'time_short_no_leading':
|
||||||
datetime_string = dayjs(raw_datetime).format('H:mm');
|
datetime_string = dayjs(raw_datetime).format('H:mm');
|
||||||
break;
|
break;
|
||||||
case 'time_12_short':
|
case 'time_12_short':
|
||||||
datetime_string = dayjs(raw_datetime).format('hh:mm A');
|
datetime_string = dayjs(raw_datetime).format('hh:mm A');
|
||||||
break;
|
break;
|
||||||
case 'time_12_short_no_leading':
|
case 'time_12_short_no_leading':
|
||||||
datetime_string = dayjs(raw_datetime).format('h:mm A');
|
datetime_string = dayjs(raw_datetime).format('h:mm A');
|
||||||
break;
|
break;
|
||||||
case 'week_long':
|
case 'week_long':
|
||||||
datetime_string = dayjs(raw_datetime).format('dddd');
|
datetime_string = dayjs(raw_datetime).format('dddd');
|
||||||
break;
|
break;
|
||||||
case 'week_medium':
|
case 'week_medium':
|
||||||
datetime_string = dayjs(raw_datetime).format('ddd');
|
datetime_string = dayjs(raw_datetime).format('ddd');
|
||||||
break;
|
break;
|
||||||
case 'week_short':
|
case 'week_short':
|
||||||
datetime_string = dayjs(raw_datetime).format('dd');
|
datetime_string = dayjs(raw_datetime).format('dd');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// console.log(`The named format passed (${named_format}) did not match a common name. Trying to format with the named format value.`);
|
// console.log(`The named format passed (${named_format}) did not match a common name. Trying to format with the named format value.`);
|
||||||
datetime_string = dayjs(raw_datetime).format(named_format);
|
datetime_string = dayjs(raw_datetime).format(named_format);
|
||||||
// datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss');
|
// datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss');
|
||||||
}
|
}
|
||||||
return datetime_string;
|
return datetime_string;
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
type key_val = {
|
type key_val = {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This utility function looks for any form data with the prefixed name passed and returns a new object.
|
/* This utility function looks for any form data with the prefixed name passed and returns a new object.
|
||||||
@@ -11,118 +11,122 @@ type key_val = {
|
|||||||
* REMINDER: An unchecked checkbox will not be sent in the form data. This is a browser thing.
|
* REMINDER: An unchecked checkbox will not be sent in the form data. This is a browser thing.
|
||||||
* Updated 2023-12-22
|
* Updated 2023-12-22
|
||||||
*/
|
*/
|
||||||
export let extract_prefixed_form_data = function extract_prefixed_form_data(
|
export const extract_prefixed_form_data = function extract_prefixed_form_data({
|
||||||
{
|
prefix = null,
|
||||||
prefix = null,
|
form_data = {},
|
||||||
form_data = {},
|
rm_empty_id = true,
|
||||||
rm_empty_id = true,
|
rm_empty = false,
|
||||||
rm_empty = false,
|
trim_values = false,
|
||||||
trim_values = false,
|
bool_tf_str = false,
|
||||||
bool_tf_str = false,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
prefix: string | null;
|
||||||
prefix: string|null,
|
form_data: any;
|
||||||
form_data: any,
|
rm_empty_id?: boolean;
|
||||||
rm_empty_id?: boolean,
|
rm_empty?: boolean;
|
||||||
rm_empty?: boolean,
|
trim_values?: boolean;
|
||||||
trim_values?: boolean,
|
bool_tf_str?: boolean;
|
||||||
bool_tf_str?: boolean,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log('*** extract_prefixed_form_data() ***');
|
||||||
if (log_lvl) {
|
if (prefix) {
|
||||||
console.log('*** extract_prefixed_form_data() ***');
|
console.log(
|
||||||
if (prefix) {
|
`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}`
|
||||||
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 {
|
} 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}`);
|
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);
|
if (log_lvl > 1) {
|
||||||
}
|
console.log('Form Data:');
|
||||||
|
console.log(form_data);
|
||||||
|
}
|
||||||
|
|
||||||
// const data_obj: any = {}; // future TS
|
// const data_obj: any = {}; // future TS
|
||||||
let data_obj: key_val = {};
|
const data_obj: key_val = {};
|
||||||
for (let field of form_data) {
|
for (const field of form_data) {
|
||||||
let [obj_prop_name, obj_prop_value] = field;
|
let [obj_prop_name, obj_prop_value] = field;
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log(`${obj_prop_name}: ${obj_prop_value} type=${typeof obj_prop_value}`);
|
console.log(`${obj_prop_name}: ${obj_prop_value} type=${typeof obj_prop_value}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trim string values if needed
|
// Trim string values if needed
|
||||||
if (trim_values && typeof obj_prop_value === 'string') {
|
if (trim_values && typeof obj_prop_value === 'string') {
|
||||||
if (log_lvl && obj_prop_value.trim() != obj_prop_value) {
|
if (log_lvl && obj_prop_value.trim() != obj_prop_value) {
|
||||||
console.log('Trimming string value!');
|
console.log('Trimming string value!');
|
||||||
obj_prop_value = obj_prop_value.trim();
|
obj_prop_value = obj_prop_value.trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert string to boolean if needed
|
// Convert string to boolean if needed
|
||||||
if (bool_tf_str && typeof obj_prop_value === 'string') {
|
if (bool_tf_str && typeof obj_prop_value === 'string') {
|
||||||
// console.log('Flag set for converting true/false string values to boolean!');
|
// console.log('Flag set for converting true/false string values to boolean!');
|
||||||
|
|
||||||
if (obj_prop_value.toLowerCase() === 'true') {
|
if (obj_prop_value.toLowerCase() === 'true') {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Converting string to boolean value: true');
|
console.log('Converting string to boolean value: true');
|
||||||
}
|
}
|
||||||
obj_prop_value = true;
|
obj_prop_value = true;
|
||||||
} else if (obj_prop_value.toLowerCase() === 'false') {
|
} else if (obj_prop_value.toLowerCase() === 'false') {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log('Converting string to boolean value: false');
|
console.log('Converting string to boolean value: false');
|
||||||
}
|
}
|
||||||
obj_prop_value = false;
|
obj_prop_value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefix && obj_prop_name.startsWith(prefix)) { // Prefix set
|
if (prefix && obj_prop_name.startsWith(prefix)) {
|
||||||
// if (obj_prop_name.startsWith(prefix)) {
|
// Prefix set
|
||||||
obj_prop_name = obj_prop_name.replace(prefix, '');
|
// if (obj_prop_name.startsWith(prefix)) {
|
||||||
if (log_lvl) {
|
obj_prop_name = obj_prop_name.replace(prefix, '');
|
||||||
console.log(`Checking: (${prefix})${obj_prop_name} value=${obj_prop_value}`);
|
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) {
|
if (rm_empty_id && obj_prop_name.endsWith('id_random') && !obj_prop_value) {
|
||||||
console.log(`Match but empty *_id_random. Ignoring/removing: ${obj_prop_name}`);
|
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) {
|
} else if (rm_empty && !obj_prop_value) {
|
||||||
console.log(`Match but empty. Ignoring/removing: ${obj_prop_name}`);
|
if (log_lvl) {
|
||||||
}
|
console.log(`Match but empty. Ignoring/removing: ${obj_prop_name}`);
|
||||||
} else {
|
}
|
||||||
if (log_lvl) {
|
} else {
|
||||||
console.log(`Match: ${prefix})${obj_prop_name} value=${obj_prop_value}`);
|
if (log_lvl) {
|
||||||
}
|
console.log(`Match: ${prefix})${obj_prop_name} value=${obj_prop_value}`);
|
||||||
data_obj[obj_prop_name] = 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) {
|
} else if (prefix && !obj_prop_name.startsWith(prefix)) {
|
||||||
console.log('Did not start with prefix. Ignoring');
|
// Prefix set
|
||||||
}
|
if (log_lvl > 1) {
|
||||||
} else { // No prefix set
|
console.log('Did not start with prefix. Ignoring');
|
||||||
if (log_lvl) {
|
}
|
||||||
console.log(`Checking: ${obj_prop_name} value=${obj_prop_value}`);
|
} else {
|
||||||
}
|
// No prefix set
|
||||||
if (rm_empty_id && obj_prop_name.endsWith('id_random') && !obj_prop_value) {
|
if (log_lvl) {
|
||||||
if (log_lvl > 1) {
|
console.log(`Checking: ${obj_prop_name} value=${obj_prop_value}`);
|
||||||
console.log(`Match but empty *_id_random. Ignoring/removing: ${obj_prop_name}`);
|
}
|
||||||
}
|
if (rm_empty_id && obj_prop_name.endsWith('id_random') && !obj_prop_value) {
|
||||||
} else if (rm_empty && !obj_prop_value) {
|
if (log_lvl > 1) {
|
||||||
if (log_lvl > 1) {
|
console.log(`Match but empty *_id_random. Ignoring/removing: ${obj_prop_name}`);
|
||||||
console.log(`Match but empty. Ignoring/removing: ${obj_prop_name}`);
|
}
|
||||||
}
|
} else if (rm_empty && !obj_prop_value) {
|
||||||
} else {
|
if (log_lvl > 1) {
|
||||||
if (log_lvl > 1) {
|
console.log(`Match but empty. Ignoring/removing: ${obj_prop_name}`);
|
||||||
console.log(`Match: ${obj_prop_name} value=${obj_prop_value}`);
|
}
|
||||||
}
|
} else {
|
||||||
data_obj[obj_prop_name] = obj_prop_value;
|
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);
|
}
|
||||||
}
|
if (log_lvl > 1) {
|
||||||
return data_obj;
|
console.log(data_obj);
|
||||||
}
|
}
|
||||||
|
return data_obj;
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,51 +1,50 @@
|
|||||||
import type { key_str } from "./ae_utils";
|
import type { key_str } from './ae_utils';
|
||||||
|
|
||||||
// Updated 2024-06-19
|
// Updated 2024-06-19
|
||||||
export function file_extension_icon(
|
export function file_extension_icon(extension: string) {
|
||||||
extension: string) {
|
// console.log('*** file_extension_icon() ***');
|
||||||
// console.log('*** file_extension_icon() ***');
|
const file_icons: key_str = {
|
||||||
let file_icons: key_str = {
|
file: 'file',
|
||||||
'file': 'file',
|
'3gp': 'file-video',
|
||||||
'3gp': 'file-video',
|
'7z': 'file-archive',
|
||||||
'7z': 'file-archive',
|
aac: 'file-audio',
|
||||||
'aac': 'file-audio',
|
ac3: 'file-audio',
|
||||||
'ac3': 'file-audio',
|
aif: 'file-audio',
|
||||||
'aif': 'file-audio',
|
aiff: 'file-audio',
|
||||||
'aiff': 'file-audio',
|
avi: 'file-video',
|
||||||
'avi': 'file-video',
|
bmp: 'file-image',
|
||||||
'bmp': 'file-image',
|
csv: 'file-csv',
|
||||||
'csv': 'file-csv',
|
doc: 'file-word',
|
||||||
'doc': 'file-word',
|
docx: 'file-word',
|
||||||
'docx': 'file-word',
|
eps: 'file-image',
|
||||||
'eps': 'file-image',
|
flac: 'file-audio',
|
||||||
'flac': 'file-audio',
|
gif: 'file-image',
|
||||||
'gif': 'file-image',
|
htm: 'file-code',
|
||||||
'htm': 'file-code',
|
html: 'file-code',
|
||||||
'html': 'file-code',
|
jpeg: 'file-image',
|
||||||
'jpeg': 'file-image',
|
jpg: 'file-image',
|
||||||
'jpg': 'file-image',
|
key: 'file-powerpoint',
|
||||||
'key': 'file-powerpoint',
|
mkv: 'file-video',
|
||||||
'mkv': 'file-video',
|
mov: 'file-video',
|
||||||
'mov': 'file-video',
|
mp3: 'file-audio',
|
||||||
'mp3': 'file-audio',
|
mp4: 'file-video',
|
||||||
'mp4': 'file-video',
|
odp: 'file-powerpoint',
|
||||||
'odp': 'file-powerpoint',
|
pdf: 'file-pdf',
|
||||||
'pdf': 'file-pdf',
|
png: 'file-image',
|
||||||
'png': 'file-image',
|
ppt: 'file-powerpoint',
|
||||||
'ppt': 'file-powerpoint',
|
pptx: 'file-powerpoint',
|
||||||
'pptx': 'file-powerpoint',
|
txt: 'file-alt',
|
||||||
'txt': 'file-alt',
|
wav: 'file-audio',
|
||||||
'wav': 'file-audio',
|
webp: 'file-image',
|
||||||
'webp': 'file-image',
|
xls: 'file-excel',
|
||||||
'xls': 'file-excel',
|
xlsx: 'file-excel',
|
||||||
'xlsx': 'file-excel',
|
zip: 'file-archive'
|
||||||
'zip': 'file-archive'
|
};
|
||||||
};
|
|
||||||
|
|
||||||
if (file_icons[extension]) {
|
if (file_icons[extension]) {
|
||||||
return file_icons[extension];
|
return file_icons[extension];
|
||||||
} else {
|
} else {
|
||||||
// return null;
|
// return null;
|
||||||
return file_icons['file'];
|
return file_icons['file'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,85 +2,85 @@
|
|||||||
|
|
||||||
// Use a defined list of unacceptable characters to remove from a filename.
|
// Use a defined list of unacceptable characters to remove from a filename.
|
||||||
// Updated 2024-10-18
|
// Updated 2024-10-18
|
||||||
export let clean_filename = function clean_filename(filename: any|string, unacceptable_chars: RegExp = /[ <>:"/\\|?*]/g, replacement_char: string = '_') {
|
export const clean_filename = function clean_filename(
|
||||||
// console.log('*** clean_filename() ***');
|
filename: any | string,
|
||||||
if (!filename) {
|
unacceptable_chars: RegExp = /[ <>:"/\\|?*]/g,
|
||||||
return '';
|
replacement_char: string = '_'
|
||||||
}
|
) {
|
||||||
|
// console.log('*** clean_filename() ***');
|
||||||
|
if (!filename) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
let cleaned_filename = filename.replace(unacceptable_chars, replacement_char);
|
const cleaned_filename = filename.replace(unacceptable_chars, replacement_char);
|
||||||
// console.log(cleaned_filename);
|
// console.log(cleaned_filename);
|
||||||
return cleaned_filename;
|
return cleaned_filename;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
export const format_bytes = function format_bytes(bytes: number, decimals: number = 2) {
|
||||||
|
if (bytes === 0) return '0 Bytes';
|
||||||
|
|
||||||
export let format_bytes = function format_bytes(
|
const k = 1024;
|
||||||
bytes: number,
|
const dm = decimals < 0 ? 0 : decimals;
|
||||||
decimals: number = 2
|
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||||
) {
|
|
||||||
if (bytes === 0) return '0 Bytes';
|
|
||||||
|
|
||||||
const k = 1024;
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||||
const dm = decimals < 0 ? 0 : decimals;
|
|
||||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
||||||
|
|
||||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
||||||
|
};
|
||||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Updated 2024-08-12
|
// Updated 2024-08-12
|
||||||
export let guess_file_name = function guess_file_name(filename_string: string) {
|
export const guess_file_name = function guess_file_name(filename_string: string) {
|
||||||
// console.log('*** guess_file_name() ***');
|
// console.log('*** guess_file_name() ***');
|
||||||
if (!filename_string) {
|
if (!filename_string) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename_string.includes('.')) {
|
|
||||||
let file_name = filename_string.substring(0, filename_string.lastIndexOf('.'));
|
|
||||||
// console.log(file_name);
|
|
||||||
return file_name;
|
|
||||||
} else {
|
|
||||||
return filename_string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (filename_string.includes('.')) {
|
||||||
|
const file_name = filename_string.substring(0, filename_string.lastIndexOf('.'));
|
||||||
|
// console.log(file_name);
|
||||||
|
return file_name;
|
||||||
|
} else {
|
||||||
|
return filename_string;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Updated 2024-08-12
|
// Updated 2024-08-12
|
||||||
export let guess_file_extension = function guess_file_extension(filename_string: string) {
|
export const guess_file_extension = function guess_file_extension(filename_string: string) {
|
||||||
// console.log('*** guess_file_extension() ***');
|
// console.log('*** guess_file_extension() ***');
|
||||||
if (!filename_string) {
|
if (!filename_string) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filename_string.includes('.')) {
|
if (!filename_string.includes('.')) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
let file_extension = filename_string.substring(filename_string.lastIndexOf('.') + 1, filename_string.length) || filename_string;
|
|
||||||
// console.log(file_extension);
|
|
||||||
return file_extension;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const file_extension =
|
||||||
|
filename_string.substring(filename_string.lastIndexOf('.') + 1, filename_string.length) ||
|
||||||
|
filename_string;
|
||||||
|
// console.log(file_extension);
|
||||||
|
return file_extension;
|
||||||
|
};
|
||||||
|
|
||||||
// Updated 2024-08-12
|
// Updated 2024-08-12
|
||||||
export let get_file_hash = async function get_file_hash(file) {
|
export const get_file_hash = async function get_file_hash(file) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let file_reader = new FileReader();
|
const file_reader = new FileReader();
|
||||||
|
|
||||||
file_reader.onload = async function() {
|
file_reader.onload = async function () {
|
||||||
if (file_reader.result.byteLength !== file.size) {
|
if (file_reader.result.byteLength !== file.size) {
|
||||||
console.log('File was not read completely');
|
console.log('File was not read completely');
|
||||||
reject("Error reading the file");
|
reject('Error reading the file');
|
||||||
}
|
}
|
||||||
|
|
||||||
const hash_buffer = await crypto.subtle.digest('SHA-256', file_reader.result);
|
const hash_buffer = await crypto.subtle.digest('SHA-256', file_reader.result);
|
||||||
const hash_array = Array.from(new Uint8Array(hash_buffer));
|
const hash_array = Array.from(new Uint8Array(hash_buffer));
|
||||||
const hash_hex = hash_array.map(b => b.toString(16).padStart(2, '0')).join('');
|
const hash_hex = hash_array.map((b) => b.toString(16).padStart(2, '0')).join('');
|
||||||
|
|
||||||
resolve(hash_hex);
|
resolve(hash_hex);
|
||||||
};
|
};
|
||||||
|
|
||||||
file_reader.readAsArrayBuffer(file);
|
file_reader.readAsArrayBuffer(file);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -1,46 +1,43 @@
|
|||||||
|
|
||||||
/* Returns a list of objects that have a matching property value. */
|
/* Returns a list of objects that have a matching property value. */
|
||||||
// Updated 2023-06-28
|
// Updated 2023-06-28
|
||||||
export let get_obj_li_w_match_prop = function get_obj_li_w_match_prop(
|
export const get_obj_li_w_match_prop = function get_obj_li_w_match_prop({
|
||||||
{
|
obj_li,
|
||||||
obj_li,
|
property,
|
||||||
property,
|
value,
|
||||||
value,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
obj_li: any[];
|
||||||
obj_li: any[],
|
property: string;
|
||||||
property: string,
|
value: any;
|
||||||
value: any,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}
|
if (log_lvl) {
|
||||||
) {
|
console.log('Search Object List:', obj_li);
|
||||||
if (log_lvl) {
|
console.log(`Property: ${property}`);
|
||||||
console.log('Search Object List:', obj_li);
|
console.log(`Value: ${value}`);
|
||||||
console.log(`Property: ${property}`);
|
}
|
||||||
console.log(`Value: ${value}`);
|
if (log_lvl > 1) {
|
||||||
}
|
console.log(`Type Of: ${typeof value}`);
|
||||||
if (log_lvl > 1) {
|
}
|
||||||
console.log(`Type Of: ${typeof value}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create an empty array to store the matching objects.
|
// Create an empty array to store the matching objects.
|
||||||
const matching_obj_li = [];
|
const matching_obj_li = [];
|
||||||
|
|
||||||
// Iterate through the list of objects.
|
// Iterate through the list of objects.
|
||||||
for (const object of obj_li) {
|
for (const object of obj_li) {
|
||||||
// Check if the object has the specified property and the value of the property matches the specified value.
|
// Check if the object has the specified property and the value of the property matches the specified value.
|
||||||
if (object.hasOwnProperty(property)) {
|
if (object.hasOwnProperty(property)) {
|
||||||
// console.log('Has property at least....', object[property], typeof object[property]);
|
// console.log('Has property at least....', object[property], typeof object[property]);
|
||||||
}
|
}
|
||||||
if (object.hasOwnProperty(property) && object[property] === value) {
|
if (object.hasOwnProperty(property) && object[property] === value) {
|
||||||
// Add the object to the array of matching objects.
|
// Add the object to the array of matching objects.
|
||||||
matching_obj_li.push(object);
|
matching_obj_li.push(object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the array of matching objects.
|
// Return the array of matching objects.
|
||||||
if (log_lvl > 1) {
|
if (log_lvl > 1) {
|
||||||
console.log('Matching Object List:', matching_obj_li);
|
console.log('Matching Object List:', matching_obj_li);
|
||||||
}
|
}
|
||||||
return matching_obj_li;
|
return matching_obj_li;
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -1,27 +1,26 @@
|
|||||||
// Function to check if the file (or anything) timestamp was created within the last X minutes
|
// Function to check if the file (or anything) timestamp was created within the last X minutes
|
||||||
export let is_datetime_recent = function is_datetime_recent(
|
export const is_datetime_recent = function is_datetime_recent({
|
||||||
{
|
datetime,
|
||||||
datetime,
|
minutes,
|
||||||
minutes,
|
log_lvl = 0
|
||||||
log_lvl = 0
|
}: {
|
||||||
}: {
|
datetime: string;
|
||||||
datetime: string,
|
minutes: number;
|
||||||
minutes: number,
|
log_lvl?: number;
|
||||||
log_lvl?: number
|
}) {
|
||||||
}) {
|
if (log_lvl) {
|
||||||
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();
|
const now: any = new Date();
|
||||||
let then: any = new Date(datetime);
|
const then: any = new Date(datetime);
|
||||||
|
|
||||||
let diff = now - then;
|
const diff = now - then;
|
||||||
let diff_minutes = Math.floor(diff / 60000);
|
const diff_minutes = Math.floor(diff / 60000);
|
||||||
|
|
||||||
if (diff_minutes < minutes) {
|
if (diff_minutes < minutes) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -1,199 +1,199 @@
|
|||||||
type key_val = {
|
type key_val = {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOTE: I know there is a better more efficient way to do this, but I don't have time for that right now.
|
// NOTE: I know there is a better more efficient way to do this, but I don't have time for that right now.
|
||||||
export let process_permission_checks = function process_permission_checks(access_type: string) {
|
export const process_permission_checks = function process_permission_checks(access_type: string) {
|
||||||
// let access_checks = { 'access_type': null, 'super_check': null };
|
// let access_checks = { 'access_type': null, 'super_check': null };
|
||||||
let access_checks: key_val = {};
|
const access_checks: key_val = {};
|
||||||
|
|
||||||
if (access_type == 'super') {
|
if (access_type == 'super') {
|
||||||
access_checks.allow_access = true;
|
access_checks.allow_access = true;
|
||||||
access_checks.access_type = 'super';
|
access_checks.access_type = 'super';
|
||||||
|
|
||||||
access_checks.super_check = true;
|
access_checks.super_check = true;
|
||||||
access_checks.manager_check = false;
|
access_checks.manager_check = false;
|
||||||
access_checks.administrator_check = false;
|
access_checks.administrator_check = false;
|
||||||
access_checks.support_check = false;
|
access_checks.support_check = false;
|
||||||
access_checks.assistant_check = false;
|
access_checks.assistant_check = false;
|
||||||
access_checks.trusted_check = false;
|
access_checks.trusted_check = false;
|
||||||
access_checks.verified_check = false;
|
access_checks.verified_check = false;
|
||||||
access_checks.provisional_check = false;
|
access_checks.provisional_check = false;
|
||||||
access_checks.public_check = false;
|
access_checks.public_check = false;
|
||||||
access_checks.authenticated_check = true;
|
access_checks.authenticated_check = true;
|
||||||
access_checks.anonymous_check = false;
|
access_checks.anonymous_check = false;
|
||||||
|
|
||||||
access_checks.super_access = true;
|
access_checks.super_access = true;
|
||||||
access_checks.manager_access = true;
|
access_checks.manager_access = true;
|
||||||
access_checks.administrator_access = true;
|
access_checks.administrator_access = true;
|
||||||
access_checks.support_access = true;
|
access_checks.support_access = true;
|
||||||
access_checks.assistant_access = true;
|
access_checks.assistant_access = true;
|
||||||
access_checks.trusted_access = true;
|
access_checks.trusted_access = true;
|
||||||
access_checks.verified_access = true;
|
access_checks.verified_access = true;
|
||||||
access_checks.provisional_access = true;
|
access_checks.provisional_access = true;
|
||||||
access_checks.public_access = true;
|
access_checks.public_access = true;
|
||||||
access_checks.authenticated_access = true;
|
access_checks.authenticated_access = true;
|
||||||
access_checks.anonymous_access = true;
|
access_checks.anonymous_access = true;
|
||||||
} else if (access_type == 'manager') {
|
} else if (access_type == 'manager') {
|
||||||
access_checks.allow_access = true;
|
access_checks.allow_access = true;
|
||||||
access_checks.access_type = 'manager';
|
access_checks.access_type = 'manager';
|
||||||
|
|
||||||
access_checks.super_check = false;
|
access_checks.super_check = false;
|
||||||
access_checks.manager_check = true;
|
access_checks.manager_check = true;
|
||||||
access_checks.administrator_check = false;
|
access_checks.administrator_check = false;
|
||||||
access_checks.support_check = false;
|
access_checks.support_check = false;
|
||||||
access_checks.assistant_check = false;
|
access_checks.assistant_check = false;
|
||||||
access_checks.trusted_check = false;
|
access_checks.trusted_check = false;
|
||||||
access_checks.verified_check = false;
|
access_checks.verified_check = false;
|
||||||
access_checks.provisional_check = false;
|
access_checks.provisional_check = false;
|
||||||
access_checks.public_check = false;
|
access_checks.public_check = false;
|
||||||
access_checks.authenticated_check = true;
|
access_checks.authenticated_check = true;
|
||||||
access_checks.anonymous_check = false;
|
access_checks.anonymous_check = false;
|
||||||
|
|
||||||
access_checks.super_access = false;
|
access_checks.super_access = false;
|
||||||
access_checks.manager_access = true;
|
access_checks.manager_access = true;
|
||||||
access_checks.administrator_access = true;
|
access_checks.administrator_access = true;
|
||||||
access_checks.support_access = true;
|
access_checks.support_access = true;
|
||||||
access_checks.assistant_access = true;
|
access_checks.assistant_access = true;
|
||||||
access_checks.trusted_access = true;
|
access_checks.trusted_access = true;
|
||||||
access_checks.verified_access = true;
|
access_checks.verified_access = true;
|
||||||
access_checks.provisional_access = true;
|
access_checks.provisional_access = true;
|
||||||
access_checks.public_access = true;
|
access_checks.public_access = true;
|
||||||
access_checks.authenticated_access = true;
|
access_checks.authenticated_access = true;
|
||||||
access_checks.anonymous_access = true;
|
access_checks.anonymous_access = true;
|
||||||
} else if (access_type == 'administrator') {
|
} else if (access_type == 'administrator') {
|
||||||
access_checks.allow_access = true;
|
access_checks.allow_access = true;
|
||||||
access_checks.access_type = 'administrator';
|
access_checks.access_type = 'administrator';
|
||||||
|
|
||||||
access_checks.super_check = false;
|
access_checks.super_check = false;
|
||||||
access_checks.manager_check = false;
|
access_checks.manager_check = false;
|
||||||
access_checks.administrator_check = true;
|
access_checks.administrator_check = true;
|
||||||
access_checks.support_check = false;
|
access_checks.support_check = false;
|
||||||
access_checks.assistant_check = false;
|
access_checks.assistant_check = false;
|
||||||
access_checks.trusted_check = false;
|
access_checks.trusted_check = false;
|
||||||
access_checks.verified_check = false;
|
access_checks.verified_check = false;
|
||||||
access_checks.provisional_check = false;
|
access_checks.provisional_check = false;
|
||||||
access_checks.public_check = false;
|
access_checks.public_check = false;
|
||||||
access_checks.authenticated_check = false;
|
access_checks.authenticated_check = false;
|
||||||
access_checks.anonymous_check = false;
|
access_checks.anonymous_check = false;
|
||||||
|
|
||||||
access_checks.super_access = false;
|
access_checks.super_access = false;
|
||||||
access_checks.manager_access = false;
|
access_checks.manager_access = false;
|
||||||
access_checks.administrator_access = true;
|
access_checks.administrator_access = true;
|
||||||
access_checks.support_access = true;
|
access_checks.support_access = true;
|
||||||
access_checks.assistant_access = true;
|
access_checks.assistant_access = true;
|
||||||
access_checks.trusted_access = true;
|
access_checks.trusted_access = true;
|
||||||
access_checks.verified_access = true;
|
access_checks.verified_access = true;
|
||||||
access_checks.provisional_access = true;
|
access_checks.provisional_access = true;
|
||||||
access_checks.public_access = true;
|
access_checks.public_access = true;
|
||||||
access_checks.authenticated_access = true;
|
access_checks.authenticated_access = true;
|
||||||
access_checks.anonymous_access = true;
|
access_checks.anonymous_access = true;
|
||||||
} else if (access_type == 'trusted') {
|
} else if (access_type == 'trusted') {
|
||||||
access_checks.allow_access = true; // Should this be true?? -2024-10-03
|
access_checks.allow_access = true; // Should this be true?? -2024-10-03
|
||||||
access_checks.access_type = 'trusted';
|
access_checks.access_type = 'trusted';
|
||||||
|
|
||||||
access_checks.super_check = false;
|
access_checks.super_check = false;
|
||||||
access_checks.manager_check = false;
|
access_checks.manager_check = false;
|
||||||
access_checks.administrator_check = false;
|
access_checks.administrator_check = false;
|
||||||
access_checks.support_check = false;
|
access_checks.support_check = false;
|
||||||
access_checks.assistant_check = false;
|
access_checks.assistant_check = false;
|
||||||
access_checks.trusted_check = true;
|
access_checks.trusted_check = true;
|
||||||
access_checks.verified_check = false;
|
access_checks.verified_check = false;
|
||||||
access_checks.provisional_check = false;
|
access_checks.provisional_check = false;
|
||||||
access_checks.public_check = false;
|
access_checks.public_check = false;
|
||||||
access_checks.authenticated_check = true;
|
access_checks.authenticated_check = true;
|
||||||
access_checks.anonymous_check = false;
|
access_checks.anonymous_check = false;
|
||||||
|
|
||||||
access_checks.super_access = false;
|
access_checks.super_access = false;
|
||||||
access_checks.manager_access = false;
|
access_checks.manager_access = false;
|
||||||
access_checks.administrator_access = false;
|
access_checks.administrator_access = false;
|
||||||
access_checks.support_access = false;
|
access_checks.support_access = false;
|
||||||
access_checks.assistant_access = false;
|
access_checks.assistant_access = false;
|
||||||
access_checks.trusted_access = true;
|
access_checks.trusted_access = true;
|
||||||
access_checks.verified_access = true;
|
access_checks.verified_access = true;
|
||||||
access_checks.provisional_access = true;
|
access_checks.provisional_access = true;
|
||||||
access_checks.public_access = true;
|
access_checks.public_access = true;
|
||||||
access_checks.authenticated_access = true;
|
access_checks.authenticated_access = true;
|
||||||
access_checks.anonymous_access = true;
|
access_checks.anonymous_access = true;
|
||||||
} else if (access_type == 'public') {
|
} else if (access_type == 'public') {
|
||||||
access_checks.access_type = 'public';
|
access_checks.access_type = 'public';
|
||||||
|
|
||||||
access_checks.super_check = false;
|
access_checks.super_check = false;
|
||||||
access_checks.manager_check = false;
|
access_checks.manager_check = false;
|
||||||
access_checks.administrator_check = false;
|
access_checks.administrator_check = false;
|
||||||
access_checks.support_check = false;
|
access_checks.support_check = false;
|
||||||
access_checks.assistant_check = false;
|
access_checks.assistant_check = false;
|
||||||
access_checks.trusted_check = false;
|
access_checks.trusted_check = false;
|
||||||
access_checks.verified_check = false;
|
access_checks.verified_check = false;
|
||||||
access_checks.provisional_check = false;
|
access_checks.provisional_check = false;
|
||||||
access_checks.public_check = true;
|
access_checks.public_check = true;
|
||||||
access_checks.authenticated_check = false;
|
access_checks.authenticated_check = false;
|
||||||
access_checks.anonymous_check = false;
|
access_checks.anonymous_check = false;
|
||||||
|
|
||||||
access_checks.super_access = false;
|
access_checks.super_access = false;
|
||||||
access_checks.manager_access = false;
|
access_checks.manager_access = false;
|
||||||
access_checks.administrator_access = false;
|
access_checks.administrator_access = false;
|
||||||
access_checks.support_access = false;
|
access_checks.support_access = false;
|
||||||
access_checks.assistant_access = false;
|
access_checks.assistant_access = false;
|
||||||
access_checks.trusted_access = false;
|
access_checks.trusted_access = false;
|
||||||
access_checks.verified_access = false;
|
access_checks.verified_access = false;
|
||||||
access_checks.provisional_access = false;
|
access_checks.provisional_access = false;
|
||||||
access_checks.public_access = true;
|
access_checks.public_access = true;
|
||||||
access_checks.authenticated_access = true;
|
access_checks.authenticated_access = true;
|
||||||
access_checks.anonymous_access = true;
|
access_checks.anonymous_access = true;
|
||||||
} else if (access_type == 'authenticated') {
|
} else if (access_type == 'authenticated') {
|
||||||
access_checks.access_type = 'authenticated';
|
access_checks.access_type = 'authenticated';
|
||||||
|
|
||||||
access_checks.super_check = false;
|
access_checks.super_check = false;
|
||||||
access_checks.manager_check = false;
|
access_checks.manager_check = false;
|
||||||
access_checks.administrator_check = false;
|
access_checks.administrator_check = false;
|
||||||
access_checks.support_check = false;
|
access_checks.support_check = false;
|
||||||
access_checks.assistant_check = false;
|
access_checks.assistant_check = false;
|
||||||
access_checks.trusted_check = false;
|
access_checks.trusted_check = false;
|
||||||
access_checks.verified_check = false;
|
access_checks.verified_check = false;
|
||||||
access_checks.provisional_check = false;
|
access_checks.provisional_check = false;
|
||||||
access_checks.public_check = false;
|
access_checks.public_check = false;
|
||||||
access_checks.authenticated_check = true;
|
access_checks.authenticated_check = true;
|
||||||
access_checks.anonymous_check = false;
|
access_checks.anonymous_check = false;
|
||||||
|
|
||||||
access_checks.super_access = false;
|
access_checks.super_access = false;
|
||||||
access_checks.manager_access = false;
|
access_checks.manager_access = false;
|
||||||
access_checks.administrator_access = false;
|
access_checks.administrator_access = false;
|
||||||
access_checks.support_access = false;
|
access_checks.support_access = false;
|
||||||
access_checks.assistant_access = false;
|
access_checks.assistant_access = false;
|
||||||
access_checks.trusted_access = false;
|
access_checks.trusted_access = false;
|
||||||
access_checks.verified_access = false;
|
access_checks.verified_access = false;
|
||||||
access_checks.provisional_access = false;
|
access_checks.provisional_access = false;
|
||||||
access_checks.public_access = false;
|
access_checks.public_access = false;
|
||||||
access_checks.authenticated_access = true;
|
access_checks.authenticated_access = true;
|
||||||
access_checks.anonymous_access = true;
|
access_checks.anonymous_access = true;
|
||||||
} else {
|
} else {
|
||||||
access_checks.access_type = 'anonymous';
|
access_checks.access_type = 'anonymous';
|
||||||
|
|
||||||
access_checks.super_check = false;
|
access_checks.super_check = false;
|
||||||
access_checks.manager_check = false;
|
access_checks.manager_check = false;
|
||||||
access_checks.administrator_check = false;
|
access_checks.administrator_check = false;
|
||||||
access_checks.support_check = false;
|
access_checks.support_check = false;
|
||||||
access_checks.assistant_check = false;
|
access_checks.assistant_check = false;
|
||||||
access_checks.trusted_check = false;
|
access_checks.trusted_check = false;
|
||||||
access_checks.verified_check = false;
|
access_checks.verified_check = false;
|
||||||
access_checks.provisional_check = false;
|
access_checks.provisional_check = false;
|
||||||
access_checks.public_check = false;
|
access_checks.public_check = false;
|
||||||
access_checks.authenticated_check = false;
|
access_checks.authenticated_check = false;
|
||||||
access_checks.anonymous_check = true;
|
access_checks.anonymous_check = true;
|
||||||
|
|
||||||
access_checks.super_access = false;
|
access_checks.super_access = false;
|
||||||
access_checks.manager_access = false;
|
access_checks.manager_access = false;
|
||||||
access_checks.administrator_access = false;
|
access_checks.administrator_access = false;
|
||||||
access_checks.support_access = false;
|
access_checks.support_access = false;
|
||||||
access_checks.assistant_access = false;
|
access_checks.assistant_access = false;
|
||||||
access_checks.trusted_access = false;
|
access_checks.trusted_access = false;
|
||||||
access_checks.verified_access = false;
|
access_checks.verified_access = false;
|
||||||
access_checks.provisional_access = false;
|
access_checks.provisional_access = false;
|
||||||
access_checks.public_access = false;
|
access_checks.public_access = false;
|
||||||
access_checks.authenticated_access = false;
|
access_checks.authenticated_access = false;
|
||||||
access_checks.anonymous_access = true;
|
access_checks.anonymous_access = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return access_checks;
|
return access_checks;
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { key_val } from "./ae_utils";
|
import type { key_val } from './ae_utils';
|
||||||
|
|
||||||
/* This utility function processes specific data string.
|
/* This utility function processes specific data string.
|
||||||
* MECARD
|
* MECARD
|
||||||
@@ -14,78 +14,77 @@ import type { key_val } from "./ae_utils";
|
|||||||
* gn: Given First Name
|
* gn: Given First Name
|
||||||
* fn: Family Last Name
|
* fn: Family Last Name
|
||||||
* em: Email Address
|
* em: Email Address
|
||||||
*/
|
*/
|
||||||
// Updated 2022-02-11
|
// Updated 2022-02-11
|
||||||
|
|
||||||
|
export const 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;
|
||||||
|
}
|
||||||
|
|
||||||
export let process_data_string = function process_data_string(data_string: string) {
|
const obj: key_val = {};
|
||||||
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 = {};
|
const colon_index = data_string.indexOf(':');
|
||||||
|
if (colon_index) {
|
||||||
|
const data_string_type = data_string.slice(0, colon_index);
|
||||||
|
console.log(data_string_type);
|
||||||
|
|
||||||
let colon_index = data_string.indexOf(':');
|
obj['qr_type'] = data_string_type;
|
||||||
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') {
|
||||||
|
const mecard_str = data_string.slice(colon_index + 1);
|
||||||
|
console.log(mecard_str);
|
||||||
|
|
||||||
if (data_string_type == 'MECARD') {
|
obj['str'] = mecard_str;
|
||||||
let mecard_str = data_string.slice(colon_index + 1);
|
} else if (data_string_type == 'OBJ') {
|
||||||
console.log(mecard_str);
|
const key_value_str = data_string.slice(colon_index + 1);
|
||||||
|
console.log(key_value_str);
|
||||||
|
const key_value_array = key_value_str.split(',');
|
||||||
|
// console.log(key_value_array);
|
||||||
|
const ot_colon_index = key_value_array[0].indexOf(':');
|
||||||
|
const obj_type = key_value_array[0].slice(ot_colon_index + 1);
|
||||||
|
// console.log(obj_type);
|
||||||
|
const oi_colon_index = key_value_array[1].indexOf(':');
|
||||||
|
const 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') {
|
||||||
|
const partial_json_str = data_string.slice(colon_index + 1);
|
||||||
|
console.log(partial_json_str);
|
||||||
|
const json_str = `{${partial_json_str}}`;
|
||||||
|
console.log(json_str);
|
||||||
|
|
||||||
obj['str'] = mecard_str;
|
obj['json'] = JSON.parse(json_str);
|
||||||
} else if (data_string_type == 'OBJ') {
|
} else if (data_string_type == 'STR') {
|
||||||
let key_value_str = data_string.slice(colon_index + 1);
|
const str = data_string.slice(colon_index + 1);
|
||||||
console.log(key_value_str);
|
console.log(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);
|
obj['str'] = str;
|
||||||
} else if (data_string_type == 'STR') {
|
} else if (data_string_type == 'http' || data_string_type == 'https') {
|
||||||
let str = data_string.slice(colon_index + 1);
|
console.log(`http or https: ${data_string}`);
|
||||||
console.log(str);
|
|
||||||
|
|
||||||
obj['str'] = str;
|
obj['type'] = 'url';
|
||||||
} else if (data_string_type == 'http' || data_string_type == 'https') {
|
obj['url'] = data_string;
|
||||||
console.log(`http or https: ${data_string}`);
|
} else {
|
||||||
|
console.log('The unknown data string type was found. Returning the string part.');
|
||||||
|
const unknown_str = data_string.slice(colon_index + 1);
|
||||||
|
console.log(unknown_str);
|
||||||
|
|
||||||
obj['type'] = 'url';
|
obj['str'] = unknown_str;
|
||||||
obj['url'] = data_string;
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('The unknown data string type was found. Returning the string part.');
|
console.log('The data string type was not found. Returning the entire string.');
|
||||||
let unknown_str = data_string.slice(colon_index + 1);
|
console.log(data_string);
|
||||||
console.log(unknown_str);
|
|
||||||
|
|
||||||
obj['str'] = unknown_str;
|
obj['qr_type'] = 'UNKNOWN';
|
||||||
}
|
obj['str'] = data_string;
|
||||||
} else {
|
// return false;
|
||||||
console.log('The data string type was not found. Returning the entire string.');
|
}
|
||||||
console.log(data_string);
|
|
||||||
|
|
||||||
obj['qr_type'] = 'UNKNOWN';
|
console.log(obj);
|
||||||
obj['str'] = data_string;
|
return obj; // Returns an object
|
||||||
// return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(obj);
|
|
||||||
return obj; // Returns an object
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,66 +1,87 @@
|
|||||||
export function return_obj_type_path({ obj_type = null, obj_type_prop_name = null }) {
|
export function return_obj_type_path({ obj_type = null, obj_type_prop_name = null }) {
|
||||||
console.log('*** return_obj_type_path() ***');
|
console.log('*** return_obj_type_path() ***');
|
||||||
|
|
||||||
let obj_type_path = null;
|
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'];
|
const 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 = [
|
const known_obj_type_li_dict = [
|
||||||
{ name: 'account', display: 'Account', path: 'account' },
|
{ name: 'account', display: 'Account', path: 'account' },
|
||||||
{ name: 'archive', display: 'Archive', path: 'archive' },
|
{ name: 'archive', display: 'Archive', path: 'archive' },
|
||||||
{ name: 'address', display: 'Address', path: 'address' },
|
{ name: 'address', display: 'Address', path: 'address' },
|
||||||
{ name: 'archive', display: 'Archive', path: 'archive' },
|
{ name: 'archive', display: 'Archive', path: 'archive' },
|
||||||
{ name: 'archive_content', display: 'Archive Content', path: 'archive/content' },
|
{ name: 'archive_content', display: 'Archive Content', path: 'archive/content' },
|
||||||
{ name: 'contact', display: 'Contact', path: 'contact' },
|
{ name: 'contact', display: 'Contact', path: 'contact' },
|
||||||
{ name: 'data_store', display: 'Data Store', path: 'data_store' },
|
{ name: 'data_store', display: 'Data Store', path: 'data_store' },
|
||||||
{ name: 'event_abstract', display: 'Event Abstract', path: 'event/abstract' },
|
{ name: 'event_abstract', display: 'Event Abstract', path: 'event/abstract' },
|
||||||
{ name: 'event_badge', display: 'Event Badge', path: 'event/badge' },
|
{ name: 'event_badge', display: 'Event Badge', path: 'event/badge' },
|
||||||
{ name: 'event_device', display: 'Event Device', path: 'event/device' },
|
{ name: 'event_device', display: 'Event Device', path: 'event/device' },
|
||||||
{ name: 'event_exhibit', display: 'Event Exhibit', path: 'event/exhibit' },
|
{ name: 'event_exhibit', display: 'Event Exhibit', path: 'event/exhibit' },
|
||||||
{ name: 'event_file', display: 'Event File', path: 'event/file' },
|
{ name: 'event_file', display: 'Event File', path: 'event/file' },
|
||||||
{ name: 'event_location', display: 'Event Location', path: 'event/location' },
|
{ name: 'event_location', display: 'Event Location', path: 'event/location' },
|
||||||
{ name: 'event_person', display: 'Event Person', path: 'event/person' },
|
{ name: 'event_person', display: 'Event Person', path: 'event/person' },
|
||||||
{ name: 'event_presentation', display: 'Event Presentation', path: 'event/' },
|
{ name: 'event_presentation', display: 'Event Presentation', path: 'event/' },
|
||||||
{ name: 'event_presenter', display: 'Event Presenter', path: 'event/presenter' },
|
{ name: 'event_presenter', display: 'Event Presenter', path: 'event/presenter' },
|
||||||
{ name: 'event_registration', display: 'Event Registration', path: 'event/registration' },
|
{ name: 'event_registration', display: 'Event Registration', path: 'event/registration' },
|
||||||
{ name: 'event_session', display: 'Event Session', path: 'event/session' },
|
{ name: 'event_session', display: 'Event Session', path: 'event/session' },
|
||||||
{ name: 'event', display: 'Event', path: 'event' },
|
{ name: 'event', display: 'Event', path: 'event' },
|
||||||
{ name: 'hosted_file', display: 'Hosted File', path: 'hosted_file' },
|
{ name: 'hosted_file', display: 'Hosted File', path: 'hosted_file' },
|
||||||
{ name: 'journal', display: 'Journal', path: 'journal' },
|
{ name: 'journal', display: 'Journal', path: 'journal' },
|
||||||
{ name: 'journal_entry', display: 'Journal Entry', path: 'journal/entry' },
|
{ name: 'journal_entry', display: 'Journal Entry', path: 'journal/entry' },
|
||||||
{ name: 'order_line', display: 'Order Line', path: 'order/line' },
|
{ name: 'order_line', display: 'Order Line', path: 'order/line' },
|
||||||
{ name: 'order', display: 'Order', path: 'order' },
|
{ name: 'order', display: 'Order', path: 'order' },
|
||||||
{ name: 'person', display: 'Person', path: 'person' },
|
{ name: 'person', display: 'Person', path: 'person' },
|
||||||
{ name: 'post', display: 'Archive', path: 'post' },
|
{ name: 'post', display: 'Archive', path: 'post' },
|
||||||
{ name: 'post_comment', display: 'Archive Content', path: 'post/comment' },
|
{ name: 'post_comment', display: 'Archive Content', path: 'post/comment' },
|
||||||
{ name: 'user', display: 'User', path: 'user' },
|
{ name: 'user', display: 'User', path: 'user' }
|
||||||
];
|
];
|
||||||
|
|
||||||
if (obj_type) {
|
if (obj_type) {
|
||||||
// Need to loop through known for safety?
|
// Need to loop through known for safety?
|
||||||
obj_type_path = obj_type_prop_name.replaceAll('_', '/');
|
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;
|
||||||
|
|
||||||
} else if (obj_type_prop_name) {
|
for (let i = 0; i < known_obj_type_li_dict.length; i++) {
|
||||||
let found_obj_type_name = null;
|
// console.log(known_obj_type_li_dict[i]);
|
||||||
let found_obj_type_path = null;
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
for (let i = 0; i < known_obj_type_li_dict.length; i++) {
|
return obj_type_path;
|
||||||
// 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 +1,124 @@
|
|||||||
import { to_title_case } from "./ae_utils__to_title_case";
|
import { to_title_case } from './ae_utils__to_title_case';
|
||||||
|
|
||||||
// Updated 2023-08-18
|
// 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 }) {
|
export function set_obj_prop_display_name({
|
||||||
console.log('*** 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) {
|
if (override) {
|
||||||
return 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'];
|
const 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'
|
||||||
|
];
|
||||||
|
|
||||||
|
const 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 known_obj_type_li_dict = [
|
let prop_display_name = prop_name;
|
||||||
{ 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!prefix_w_obj_type) {
|
// for (let i = 0; i < known_obj_type_li.length; i++) {
|
||||||
if (obj_type) {
|
// // console.log(known_obj_type_li[i]);
|
||||||
prop_display_name = prop_name.replace(obj_type, '');
|
// if (prop_name.startsWith(known_obj_type_li[i])) {
|
||||||
} else {
|
// console.log(`Found ${known_obj_type_li[i]}`);
|
||||||
for (let i = 0; i < known_obj_type_li_dict.length; i++) {
|
// prop_display_name = prop_name.replace(known_obj_type_li[i], '');
|
||||||
// console.log(known_obj_type_li_dict[i]);
|
// break;
|
||||||
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;
|
} 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;
|
||||||
|
|
||||||
// for (let i = 0; i < known_obj_type_li.length; i++) {
|
if (prop_name.startsWith(known_obj_type_li_dict[i].name)) {
|
||||||
// // console.log(known_obj_type_li[i]);
|
// if (prop_name.startsWith(known_obj_type_li[i])) {
|
||||||
// if (prop_name.startsWith(known_obj_type_li[i])) {
|
// console.log(`Found ${known_obj_type_li_dict[i].name}`);
|
||||||
// console.log(`Found ${known_obj_type_li[i]}`);
|
found_obj_type = known_obj_type_li_dict[i].name;
|
||||||
// prop_display_name = prop_name.replace(known_obj_type_li[i], '');
|
if (found_obj_type == obj_type) {
|
||||||
// break;
|
prop_display_name = prop_name.replace(known_obj_type_li_dict[i].name, '');
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
}
|
|
||||||
} 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)) {
|
break;
|
||||||
// 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 {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if (obj_type) {
|
// console.log(prop_display_name);
|
||||||
// prop_display_name = prop_name.replace(obj_type, '');
|
if (prop_display_name.search('ID')) {
|
||||||
// } else {
|
}
|
||||||
}
|
prop_display_name = prop_display_name.replace('id_random', 'ID');
|
||||||
}
|
|
||||||
|
|
||||||
// console.log(prop_display_name);
|
if (replace_underscores) {
|
||||||
if (prop_display_name.search('ID')) {
|
prop_display_name = prop_display_name.replaceAll('_', ' ');
|
||||||
}
|
}
|
||||||
prop_display_name = prop_display_name.replace('id_random', 'ID');
|
|
||||||
|
|
||||||
if (replace_underscores) {
|
if (title_case) {
|
||||||
prop_display_name = prop_display_name.replaceAll('_', ' ');
|
prop_display_name = to_title_case(prop_display_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (title_case) {
|
// console.log(prop_display_name);
|
||||||
prop_display_name = to_title_case(prop_display_name);
|
return prop_display_name;
|
||||||
}
|
|
||||||
|
|
||||||
// console.log(prop_display_name);
|
|
||||||
return prop_display_name;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +1,43 @@
|
|||||||
/* Adapted from: To Title Case © 2018 David Gouch | https://github.com/gouch/to-title-case */
|
/* 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) {
|
export function to_title_case(text_string) {
|
||||||
// console.log('*** to_title_case() ***');
|
// 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;
|
const 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])/;
|
const alphanumericPattern = /([A-Za-z0-9\u00C0-\u00FF])/;
|
||||||
let wordSeparators = /([ :–—-])/;
|
const wordSeparators = /([ :–—-])/;
|
||||||
|
|
||||||
return text_string.split(wordSeparators)
|
return text_string
|
||||||
.map(function (current, index, array) {
|
.split(wordSeparators)
|
||||||
if (
|
.map(function (current, index, array) {
|
||||||
/* Check for small words */
|
if (
|
||||||
current.search(smallWords) > -1 &&
|
/* Check for small words */
|
||||||
/* Skip first and last word */
|
current.search(smallWords) > -1 &&
|
||||||
index !== 0 &&
|
/* Skip first and last word */
|
||||||
index !== array.length - 1 &&
|
index !== 0 &&
|
||||||
/* Ignore title end and subtitle start */
|
index !== array.length - 1 &&
|
||||||
array[index - 3] !== ':' &&
|
/* Ignore title end and subtitle start */
|
||||||
array[index + 1] !== ':' &&
|
array[index - 3] !== ':' &&
|
||||||
/* Ignore small words that start a hyphenated phrase */
|
array[index + 1] !== ':' &&
|
||||||
(array[index + 1] !== '-' ||
|
/* Ignore small words that start a hyphenated phrase */
|
||||||
(array[index - 1] === '-' && array[index + 1] === '-'))) {
|
(array[index + 1] !== '-' || (array[index - 1] === '-' && array[index + 1] === '-'))
|
||||||
return current.toLowerCase();
|
) {
|
||||||
}
|
return current.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
/* Ignore intentional capitalization */
|
/* Ignore intentional capitalization */
|
||||||
if (current.substr(1).search(/[A-Z]|\../) > -1) {
|
if (current.substr(1).search(/[A-Z]|\../) > -1) {
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ignore URLs */
|
/* Ignore URLs */
|
||||||
if (array[index + 1] === ':' && array[index + 2] !== '') {
|
if (array[index + 1] === ':' && array[index + 2] !== '') {
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Capitalize the first letter */
|
/* Capitalize the first letter */
|
||||||
return current.replace(alphanumericPattern, function (match) {
|
return current.replace(alphanumericPattern, function (match) {
|
||||||
return match.toUpperCase();
|
return match.toUpperCase();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.join('');
|
.join('');
|
||||||
}
|
}
|
||||||
|
|||||||
1623
src/lib/api/api.ts
1623
src/lib/api/api.ts
File diff suppressed because it is too large
Load Diff
@@ -1,27 +1,25 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let log_lvl: number = 0;
|
export let log_lvl: number = 0;
|
||||||
|
|
||||||
export let site_google_tracking_id: string = '';
|
export let site_google_tracking_id: string = '';
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`AE Analytics: site_google_tracking_id = `, site_google_tracking_id);
|
console.log(`AE Analytics: site_google_tracking_id = `, site_google_tracking_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
window.dataLayer = window.dataLayer || [];
|
window.dataLayer = window.dataLayer || [];
|
||||||
window.gtag = function gtag(): void {
|
window.gtag = function gtag(): void {
|
||||||
window.dataLayer.push(arguments);
|
window.dataLayer.push(arguments);
|
||||||
};
|
};
|
||||||
window.gtag('js', new Date());
|
window.gtag('js', new Date());
|
||||||
window.gtag('config', site_google_tracking_id);
|
window.gtag('config', site_google_tracking_id);
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`AE Analytics: Google Analytics Tracking ID = `, site_google_tracking_id);
|
console.log(`AE Analytics: Google Analytics Tracking ID = `, site_google_tracking_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<script
|
<script async src="https://www.googletagmanager.com/gtag/js?id={site_google_tracking_id}">
|
||||||
async
|
</script>
|
||||||
src="https://www.googletagmanager.com/gtag/js?id={site_google_tracking_id}">
|
|
||||||
</script>
|
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|||||||
@@ -1,286 +1,299 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
// *** Import Svelte specific
|
||||||
|
import { onDestroy, onMount, tick } from 'svelte';
|
||||||
|
import { afterNavigate } from '$app/navigation';
|
||||||
|
|
||||||
|
// *** Import other supporting libraries
|
||||||
|
// import { liveQuery } from "dexie";
|
||||||
|
import {
|
||||||
|
ShieldEllipsis,
|
||||||
|
ShieldMinus,
|
||||||
|
ShieldPlus,
|
||||||
|
ShieldUser,
|
||||||
|
User,
|
||||||
|
UserCheck
|
||||||
|
} from '@lucide/svelte';
|
||||||
|
|
||||||
|
// *** Import Aether specific variables and functions
|
||||||
|
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||||
|
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/stores/ae_stores';
|
||||||
|
// import { core_func } from '$lib/ae_core/ae_core_functions';
|
||||||
|
// Ideally the Event related stores should not be imported here?
|
||||||
|
import { events_loc } from '$lib/stores/ae_events_stores';
|
||||||
|
// import { db_events } from "$lib/db_events";
|
||||||
|
|
||||||
|
// export let hidden: boolean = false;
|
||||||
|
|
||||||
|
// *** Setup Svelte properties
|
||||||
|
interface Props {
|
||||||
|
log_lvl?: number;
|
||||||
|
hide?: null | boolean;
|
||||||
|
focus_input: boolean;
|
||||||
|
expand?: boolean;
|
||||||
|
show_passcode_input: boolean;
|
||||||
|
trigger_clear_access: null | boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
log_lvl = $bindable(0),
|
||||||
|
hide = $bindable(false),
|
||||||
|
focus_input = $bindable(false),
|
||||||
|
expand = $bindable(false),
|
||||||
|
show_passcode_input = $bindable(false),
|
||||||
|
trigger_clear_access = $bindable(null)
|
||||||
|
}: Props = $props();
|
||||||
|
|
||||||
|
let entered_passcode: null | string = $state(null);
|
||||||
|
let checked_passcode: null | string = $state(null);
|
||||||
|
// let password_checked: boolean = $state(false);
|
||||||
|
// let entered_passcode: null|string = '';
|
||||||
|
// let show_passcode_input: boolean = $state(false);
|
||||||
|
// let show_passcode_input: boolean = false;
|
||||||
|
|
||||||
|
// let trigger: null|string|boolean = null;
|
||||||
|
let trigger: null | string | boolean = $state(null);
|
||||||
|
|
||||||
|
// const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
|
// WARNING: There is a bug (I think) around here related to the entered_passcode not being cleared. There seems to be something different about how Svelte handles state in this component compared to the others. This might be related to the `$effect` or `$derived` usage. Maybe there are conflicting things trying to update the $ae_loc store at the same time.
|
||||||
|
onMount(() => {
|
||||||
|
log_lvl = 2;
|
||||||
|
if (log_lvl > 1) {
|
||||||
|
console.log('** Element Mounted: ** Element Access Type');
|
||||||
|
}
|
||||||
|
entered_passcode = '';
|
||||||
|
trigger = null;
|
||||||
|
|
||||||
|
// /** @type {HTMLElement | null} */
|
||||||
|
// const to_focus = document.getElementById('access_passcode_input');
|
||||||
|
// to_focus?.focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
onDestroy(() => {
|
||||||
|
if (log_lvl > 1) {
|
||||||
|
console.log('** Element Destroyed: ** Element Access Type');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean up any references or listeners if needed
|
||||||
|
entered_passcode = null; // Clear the entered passcode
|
||||||
|
show_passcode_input = false;
|
||||||
|
|
||||||
|
// Reset trigger
|
||||||
|
trigger = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
// afterNavigate(() => {
|
||||||
|
// /** @type {HTMLElement | null} */
|
||||||
|
// const to_focus = document.getElementById('access_passcode_input');
|
||||||
|
// to_focus?.focus();
|
||||||
|
// });
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
if (entered_passcode && entered_passcode.length >= 5 && entered_passcode != checked_passcode) {
|
||||||
|
checked_passcode = entered_passcode;
|
||||||
|
if (log_lvl) {
|
||||||
|
console.log(`entered_passcode=${entered_passcode}`);
|
||||||
|
}
|
||||||
|
handle_check_access_type_passcode();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
if (trigger && $ae_loc.access_type) {
|
||||||
|
trigger = false;
|
||||||
|
if (log_lvl) {
|
||||||
|
console.log(`$ae_loc.access_type=${$ae_loc.access_type}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
let access_checks_results = ae_util.process_permission_checks($ae_loc.access_type);
|
||||||
|
|
||||||
|
$ae_loc = { ...$ae_loc, ...access_checks_results };
|
||||||
|
$ae_loc = $ae_loc;
|
||||||
|
$ae_loc.sys_menu.expand = false;
|
||||||
|
} else if (trigger) {
|
||||||
|
trigger = false;
|
||||||
|
if (log_lvl) {
|
||||||
|
console.log(`$ae_loc.access_type=not set`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send an empty string to reset the permissions. This is the same as sending 'anonymous'.
|
||||||
|
let access_checks_results = ae_util.process_permission_checks('');
|
||||||
|
|
||||||
|
$ae_loc = { ...$ae_loc, ...access_checks_results };
|
||||||
|
$ae_loc = $ae_loc;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// This does not seem to work. I feel like it should though...?
|
||||||
|
$effect(() => {
|
||||||
|
if (!hide && focus_input) {
|
||||||
|
focus_input = false;
|
||||||
|
log_lvl = 2;
|
||||||
|
// await tick();
|
||||||
|
// document.getElementById('access_passcode_input')?.focus();
|
||||||
|
if (log_lvl > 1) {
|
||||||
|
console.log('Effect: Setting focus on the passcode input field');
|
||||||
|
}
|
||||||
|
/** @type {HTMLElement | null} */
|
||||||
|
const to_focus = document.getElementById('access_passcode_input');
|
||||||
|
to_focus?.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$effect(async () => {
|
||||||
|
if (trigger_clear_access) {
|
||||||
|
trigger_clear_access = false;
|
||||||
|
if (log_lvl) {
|
||||||
|
console.log(`trigger_clear_access=${trigger_clear_access}`);
|
||||||
|
}
|
||||||
|
handle_clear_access();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function handle_check_access_type_passcode() {
|
||||||
|
if (log_lvl > 1) {
|
||||||
|
console.log(
|
||||||
|
`*** handle_check_access_type_passcode() *** passcode list:`,
|
||||||
|
$ae_loc.site_access_code_kv
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reminder: super > manager > administrator > trusted > public > authenticated > anonymous
|
||||||
|
|
||||||
|
if (entered_passcode && entered_passcode.length >= 5) {
|
||||||
|
if (
|
||||||
|
$ae_loc.site_access_code_kv.super.length >= 8 &&
|
||||||
|
$ae_loc.site_access_code_kv.super == entered_passcode
|
||||||
|
) {
|
||||||
|
console.log('Super passcode matched');
|
||||||
|
|
||||||
|
window.localStorage.setItem('access_type', 'super');
|
||||||
|
|
||||||
|
$ae_loc.access_type = 'super';
|
||||||
|
} else if (
|
||||||
|
$ae_loc.site_access_code_kv.manager.length >= 5 &&
|
||||||
|
$ae_loc.site_access_code_kv.manager == entered_passcode
|
||||||
|
) {
|
||||||
|
console.log('Manager passcode matched');
|
||||||
|
|
||||||
|
window.localStorage.setItem('access_type', 'manager');
|
||||||
|
|
||||||
|
$ae_loc.access_type = 'manager';
|
||||||
|
} else if (
|
||||||
|
$ae_loc.site_access_code_kv.administrator.length >= 5 &&
|
||||||
|
$ae_loc.site_access_code_kv.administrator == entered_passcode
|
||||||
|
) {
|
||||||
|
console.log('Administrator passcode matched');
|
||||||
|
|
||||||
|
window.localStorage.setItem('access_type', 'administrator');
|
||||||
|
|
||||||
|
$ae_loc.access_type = 'administrator';
|
||||||
|
} else if (
|
||||||
|
$ae_loc.site_access_code_kv.trusted.length >= 5 &&
|
||||||
|
$ae_loc.site_access_code_kv.trusted == entered_passcode
|
||||||
|
) {
|
||||||
|
console.log('Trusted passcode matched');
|
||||||
|
|
||||||
|
window.localStorage.setItem('access_type', 'trusted');
|
||||||
|
|
||||||
|
$ae_loc.access_type = 'trusted';
|
||||||
|
} else if (
|
||||||
|
$ae_loc.site_access_code_kv.public.length >= 5 &&
|
||||||
|
$ae_loc.site_access_code_kv.public == entered_passcode
|
||||||
|
) {
|
||||||
|
console.log('Public passcode matched');
|
||||||
|
|
||||||
|
window.localStorage.setItem('access_type', 'public');
|
||||||
|
|
||||||
|
$ae_loc.access_type = 'public';
|
||||||
|
} else if ($ae_loc.site_access_code_kv.authenticated == entered_passcode) {
|
||||||
|
console.log('Authenticated passcode matched');
|
||||||
|
|
||||||
|
window.localStorage.setItem('access_type', 'authenticated');
|
||||||
|
|
||||||
|
$ae_loc.access_type = 'authenticated';
|
||||||
|
} else {
|
||||||
|
if (log_lvl > 1) {
|
||||||
|
console.log('Entered passcode does not match any of the site access codes.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ae_loc.access_type != 'anonymous') {
|
||||||
|
console.log('Access type is not anonymous');
|
||||||
|
}
|
||||||
|
// window.localStorage.setItem('access_type', 'anonymous');
|
||||||
|
|
||||||
|
// $ae_loc.access_type = 'anonymous';
|
||||||
|
|
||||||
|
// trigger = 'process_permission_check';
|
||||||
|
|
||||||
|
// $ae_loc = $ae_loc; // Trigger Svelte just in case
|
||||||
|
// ae_loc.set($ae_loc);
|
||||||
|
// console.log($ae_loc);
|
||||||
|
|
||||||
|
// dispatch_access_type_changed();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
entered_passcode = '';
|
||||||
|
trigger = 'process_permission_check';
|
||||||
|
|
||||||
|
$ae_loc.app_cfg.show_element__menu = false;
|
||||||
|
$ae_loc.app_cfg.show_element__menu_btn = true;
|
||||||
|
|
||||||
|
// WARNING 2024-08-21: For some reason the config element does not auto show or hide when the access type changes.
|
||||||
|
if (!$ae_loc.iframe && $ae_loc.authenticated_access) {
|
||||||
|
$ae_loc.app_cfg.show_element__access_type = true;
|
||||||
|
$ae_loc.app_cfg.show_element__cfg = true;
|
||||||
|
} else if ($ae_loc.iframe && $ae_loc.trusted_access) {
|
||||||
|
$ae_loc.app_cfg.show_element__access_type = true;
|
||||||
|
$ae_loc.app_cfg.show_element__cfg = true;
|
||||||
|
} else {
|
||||||
|
$ae_loc.app_cfg.show_element__access_type = true;
|
||||||
|
$ae_loc.app_cfg.show_element__cfg = false;
|
||||||
|
}
|
||||||
|
|
||||||
// *** Import Svelte specific
|
// dispatch_access_type_changed();
|
||||||
import { onDestroy, onMount, tick } from 'svelte';
|
|
||||||
import { afterNavigate } from '$app/navigation';
|
|
||||||
|
|
||||||
// *** Import other supporting libraries
|
|
||||||
// import { liveQuery } from "dexie";
|
|
||||||
import {
|
|
||||||
ShieldEllipsis, ShieldMinus, ShieldPlus, ShieldUser,
|
|
||||||
User, UserCheck
|
|
||||||
} from '@lucide/svelte';
|
|
||||||
|
|
||||||
// *** Import Aether specific variables and functions
|
|
||||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
|
||||||
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/stores/ae_stores';
|
|
||||||
// import { core_func } from '$lib/ae_core/ae_core_functions';
|
|
||||||
// Ideally the Event related stores should not be imported here?
|
|
||||||
import { events_loc } from '$lib/stores/ae_events_stores';
|
|
||||||
// import { db_events } from "$lib/db_events";
|
|
||||||
|
|
||||||
// export let hidden: boolean = false;
|
|
||||||
|
|
||||||
// *** Setup Svelte properties
|
|
||||||
interface Props {
|
|
||||||
log_lvl?: number;
|
|
||||||
hide?: null|boolean;
|
|
||||||
focus_input: boolean;
|
|
||||||
expand?: boolean;
|
|
||||||
show_passcode_input: boolean;
|
|
||||||
trigger_clear_access: null|boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
let {
|
|
||||||
log_lvl = $bindable(0),
|
|
||||||
hide = $bindable(false),
|
|
||||||
focus_input = $bindable(false),
|
|
||||||
expand = $bindable(false),
|
|
||||||
show_passcode_input = $bindable(false),
|
|
||||||
trigger_clear_access = $bindable(null),
|
|
||||||
}: Props = $props();
|
|
||||||
|
|
||||||
|
|
||||||
let entered_passcode: null|string = $state(null);
|
|
||||||
let checked_passcode: null|string = $state(null);
|
|
||||||
// let password_checked: boolean = $state(false);
|
|
||||||
// let entered_passcode: null|string = '';
|
|
||||||
// let show_passcode_input: boolean = $state(false);
|
|
||||||
// let show_passcode_input: boolean = false;
|
|
||||||
|
|
||||||
// let trigger: null|string|boolean = null;
|
|
||||||
let trigger: null|string|boolean = $state(null);
|
|
||||||
|
|
||||||
// const dispatch = createEventDispatcher();
|
|
||||||
|
|
||||||
|
|
||||||
// WARNING: There is a bug (I think) around here related to the entered_passcode not being cleared. There seems to be something different about how Svelte handles state in this component compared to the others. This might be related to the `$effect` or `$derived` usage. Maybe there are conflicting things trying to update the $ae_loc store at the same time.
|
|
||||||
onMount(() => {
|
|
||||||
log_lvl = 2;
|
|
||||||
if (log_lvl > 1) {
|
|
||||||
console.log('** Element Mounted: ** Element Access Type');
|
|
||||||
}
|
|
||||||
entered_passcode = '';
|
|
||||||
trigger = null;
|
|
||||||
|
|
||||||
// /** @type {HTMLElement | null} */
|
|
||||||
// const to_focus = document.getElementById('access_passcode_input');
|
|
||||||
// to_focus?.focus();
|
|
||||||
});
|
|
||||||
|
|
||||||
onDestroy(() => {
|
|
||||||
if (log_lvl > 1) {
|
|
||||||
console.log('** Element Destroyed: ** Element Access Type');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clean up any references or listeners if needed
|
|
||||||
entered_passcode = null; // Clear the entered passcode
|
|
||||||
show_passcode_input = false;
|
|
||||||
|
|
||||||
// Reset trigger
|
|
||||||
trigger = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// afterNavigate(() => {
|
|
||||||
// /** @type {HTMLElement | null} */
|
|
||||||
// const to_focus = document.getElementById('access_passcode_input');
|
|
||||||
// to_focus?.focus();
|
|
||||||
// });
|
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
if (entered_passcode && entered_passcode.length >= 5 && entered_passcode != checked_passcode) {
|
|
||||||
checked_passcode = entered_passcode;
|
|
||||||
if (log_lvl) {
|
|
||||||
console.log(`entered_passcode=${entered_passcode}`);
|
|
||||||
}
|
|
||||||
handle_check_access_type_passcode();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
if (trigger && $ae_loc.access_type) {
|
|
||||||
trigger = false;
|
|
||||||
if (log_lvl) {
|
|
||||||
console.log(`$ae_loc.access_type=${$ae_loc.access_type}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
let access_checks_results = ae_util.process_permission_checks($ae_loc.access_type);
|
|
||||||
|
|
||||||
$ae_loc = {...$ae_loc, ...access_checks_results};
|
|
||||||
$ae_loc = $ae_loc;
|
|
||||||
$ae_loc.sys_menu.expand = false;
|
|
||||||
} else if (trigger) {
|
|
||||||
trigger = false;
|
|
||||||
if (log_lvl) {
|
|
||||||
console.log(`$ae_loc.access_type=not set`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send an empty string to reset the permissions. This is the same as sending 'anonymous'.
|
|
||||||
let access_checks_results = ae_util.process_permission_checks('');
|
|
||||||
|
|
||||||
$ae_loc = {...$ae_loc, ...access_checks_results};
|
|
||||||
$ae_loc = $ae_loc;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// This does not seem to work. I feel like it should though...?
|
|
||||||
$effect(() => {
|
|
||||||
if (!hide && focus_input) {
|
|
||||||
focus_input = false;
|
|
||||||
log_lvl = 2;
|
|
||||||
// await tick();
|
|
||||||
// document.getElementById('access_passcode_input')?.focus();
|
|
||||||
if (log_lvl > 1) {
|
|
||||||
console.log('Effect: Setting focus on the passcode input field');
|
|
||||||
}
|
|
||||||
/** @type {HTMLElement | null} */
|
|
||||||
const to_focus = document.getElementById('access_passcode_input');
|
|
||||||
to_focus?.focus();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$effect(async () => {
|
|
||||||
if (trigger_clear_access) {
|
|
||||||
trigger_clear_access = false;
|
|
||||||
if (log_lvl) {
|
|
||||||
console.log(`trigger_clear_access=${trigger_clear_access}`);
|
|
||||||
}
|
|
||||||
handle_clear_access();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
function handle_check_access_type_passcode() {
|
|
||||||
if (log_lvl > 1) {
|
|
||||||
console.log(`*** handle_check_access_type_passcode() *** passcode list:`, $ae_loc.site_access_code_kv);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reminder: super > manager > administrator > trusted > public > authenticated > anonymous
|
|
||||||
|
|
||||||
if (entered_passcode && entered_passcode.length >= 5) {
|
|
||||||
|
|
||||||
if ($ae_loc.site_access_code_kv.super.length >= 8 && $ae_loc.site_access_code_kv.super == entered_passcode) {
|
|
||||||
console.log('Super passcode matched');
|
|
||||||
|
|
||||||
window.localStorage.setItem('access_type', 'super');
|
|
||||||
|
|
||||||
$ae_loc.access_type = 'super';
|
|
||||||
} else if ($ae_loc.site_access_code_kv.manager.length >= 5 && $ae_loc.site_access_code_kv.manager == entered_passcode) {
|
|
||||||
console.log('Manager passcode matched');
|
|
||||||
|
|
||||||
window.localStorage.setItem('access_type', 'manager');
|
|
||||||
|
|
||||||
$ae_loc.access_type = 'manager';
|
|
||||||
} else if ($ae_loc.site_access_code_kv.administrator.length >= 5 && $ae_loc.site_access_code_kv.administrator == entered_passcode) {
|
|
||||||
console.log('Administrator passcode matched');
|
|
||||||
|
|
||||||
window.localStorage.setItem('access_type', 'administrator');
|
return true;
|
||||||
|
} else {
|
||||||
|
if (log_lvl > 1) {
|
||||||
|
console.log('Entered passcode too short.');
|
||||||
|
}
|
||||||
|
|
||||||
$ae_loc.access_type = 'administrator';
|
// $ae_loc.access_type = null; // 'anonymous';
|
||||||
} else if ($ae_loc.site_access_code_kv.trusted.length >= 5 && $ae_loc.site_access_code_kv.trusted == entered_passcode) {
|
|
||||||
console.log('Trusted passcode matched');
|
|
||||||
|
|
||||||
window.localStorage.setItem('access_type', 'trusted');
|
// dispatch_access_type_changed()
|
||||||
|
|
||||||
$ae_loc.access_type = 'trusted';
|
|
||||||
} else if ($ae_loc.site_access_code_kv.public.length >= 5 && $ae_loc.site_access_code_kv.public == entered_passcode) {
|
|
||||||
console.log('Public passcode matched');
|
|
||||||
|
|
||||||
window.localStorage.setItem('access_type', 'public');
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$ae_loc.access_type = 'public';
|
function handle_clear_access() {
|
||||||
} else if ($ae_loc.site_access_code_kv.authenticated == entered_passcode) {
|
// console.log('handle_clear_access()');
|
||||||
console.log('Authenticated passcode matched');
|
// NOTE: I think it makes since to reset this to anonymous even if logged in as an admin or similar.
|
||||||
|
window.localStorage.setItem('access_type', 'anonymous');
|
||||||
|
|
||||||
window.localStorage.setItem('access_type', 'authenticated');
|
// $ae_loc.access_type = null; // 'anonymous';
|
||||||
|
// Revert back to the user's access type after quick access (temporarily escalate permissions) is turned off.
|
||||||
|
$ae_loc.access_type = $ae_loc.user_access_type ?? 'anonymous';
|
||||||
|
trigger = 'process_permission_check';
|
||||||
|
|
||||||
$ae_loc.access_type = 'authenticated';
|
entered_passcode = ''; // Clear the entered passcode
|
||||||
} else {
|
show_passcode_input = true;
|
||||||
if (log_lvl > 1) {
|
|
||||||
console.log('Entered passcode does not match any of the site access codes.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ae_loc.access_type != 'anonymous') {
|
$ae_loc.app_cfg.show_element__menu = false;
|
||||||
console.log('Access type is not anonymous');
|
$ae_loc.app_cfg.show_element__menu_btn = true;
|
||||||
}
|
|
||||||
// window.localStorage.setItem('access_type', 'anonymous');
|
|
||||||
|
|
||||||
// $ae_loc.access_type = 'anonymous';
|
$ae_loc.edit_mode = false;
|
||||||
|
|
||||||
// trigger = 'process_permission_check';
|
|
||||||
|
|
||||||
// $ae_loc = $ae_loc; // Trigger Svelte just in case
|
|
||||||
// ae_loc.set($ae_loc);
|
|
||||||
// console.log($ae_loc);
|
|
||||||
|
|
||||||
// dispatch_access_type_changed();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
entered_passcode = '';
|
|
||||||
trigger = 'process_permission_check';
|
|
||||||
|
|
||||||
|
|
||||||
$ae_loc.app_cfg.show_element__menu = false;
|
|
||||||
$ae_loc.app_cfg.show_element__menu_btn = true;
|
|
||||||
|
|
||||||
// WARNING 2024-08-21: For some reason the config element does not auto show or hide when the access type changes.
|
|
||||||
if (!$ae_loc.iframe && $ae_loc.authenticated_access) {
|
|
||||||
$ae_loc.app_cfg.show_element__access_type = true;
|
|
||||||
$ae_loc.app_cfg.show_element__cfg = true;
|
|
||||||
} else if ($ae_loc.iframe && $ae_loc.trusted_access) {
|
|
||||||
$ae_loc.app_cfg.show_element__access_type = true;
|
|
||||||
$ae_loc.app_cfg.show_element__cfg = true;
|
|
||||||
} else {
|
|
||||||
$ae_loc.app_cfg.show_element__access_type = true;
|
|
||||||
$ae_loc.app_cfg.show_element__cfg = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// dispatch_access_type_changed();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
if (log_lvl > 1) {
|
|
||||||
console.log('Entered passcode too short.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// $ae_loc.access_type = null; // 'anonymous';
|
|
||||||
|
|
||||||
// dispatch_access_type_changed()
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handle_clear_access() {
|
|
||||||
// console.log('handle_clear_access()');
|
|
||||||
// NOTE: I think it makes since to reset this to anonymous even if logged in as an admin or similar.
|
|
||||||
window.localStorage.setItem('access_type', 'anonymous');
|
|
||||||
|
|
||||||
// $ae_loc.access_type = null; // 'anonymous';
|
|
||||||
// Revert back to the user's access type after quick access (temporarily escalate permissions) is turned off.
|
|
||||||
$ae_loc.access_type = $ae_loc.user_access_type ?? 'anonymous';
|
|
||||||
trigger = 'process_permission_check';
|
|
||||||
|
|
||||||
entered_passcode = ''; // Clear the entered passcode
|
|
||||||
show_passcode_input = true;
|
|
||||||
|
|
||||||
$ae_loc.app_cfg.show_element__menu = false;
|
|
||||||
$ae_loc.app_cfg.show_element__menu_btn = true;
|
|
||||||
|
|
||||||
$ae_loc.edit_mode = false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<section
|
<section
|
||||||
id="AE-Quick-Access-Type"
|
id="AE-Quick-Access-Type"
|
||||||
class="
|
class="
|
||||||
ae_access_type
|
ae_access_type
|
||||||
hidden-print
|
hidden-print
|
||||||
|
|
||||||
@@ -297,20 +310,15 @@ function handle_clear_access() {
|
|||||||
duration-300 delay-150 hover:delay-1000 hover:ease-out
|
duration-300 delay-150 hover:delay-1000 hover:ease-out
|
||||||
transition-all
|
transition-all
|
||||||
"
|
"
|
||||||
class:hidden={hide}
|
class:hidden={hide}
|
||||||
>
|
>
|
||||||
|
<!-- class:hidden={!$ae_sess.show__sign_in_out__fields} -->
|
||||||
|
<header class="ae_header hidden">
|
||||||
|
<h2 class="text-sm text-center font-semibold">Passcode Sign In</h2>
|
||||||
|
</header>
|
||||||
|
|
||||||
<!-- class:hidden={!$ae_sess.show__sign_in_out__fields} -->
|
<!-- Show list of authorized sessions and presentations for a user -->
|
||||||
<header
|
<!-- {#if $ae_loc.access_type == 'administrator'}
|
||||||
class="ae_header hidden"
|
|
||||||
>
|
|
||||||
<h2 class="text-sm text-center font-semibold">
|
|
||||||
Passcode Sign In
|
|
||||||
</h2>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<!-- Show list of authorized sessions and presentations for a user -->
|
|
||||||
<!-- {#if $ae_loc.access_type == 'administrator'}
|
|
||||||
{#if $events_loc.auth__kv.session}
|
{#if $events_loc.auth__kv.session}
|
||||||
Sessions:
|
Sessions:
|
||||||
<ul>
|
<ul>
|
||||||
@@ -323,58 +331,53 @@ function handle_clear_access() {
|
|||||||
{/if}
|
{/if}
|
||||||
{/if} -->
|
{/if} -->
|
||||||
|
|
||||||
|
<div class="transition-all">
|
||||||
|
{#if $ae_loc.trusted_access && $ae_loc.edit_mode}
|
||||||
|
{#if $ae_loc.manager_access}
|
||||||
|
{#if $ae_loc?.sync_local_config}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onclick={() => {
|
||||||
|
$ae_loc.sync_local_config = false;
|
||||||
|
$events_loc.pres_mgmt.sync_local_config = false;
|
||||||
|
|
||||||
<div class="transition-all">
|
$ae_loc.lock_config = false;
|
||||||
{#if $ae_loc.trusted_access && $ae_loc.edit_mode}
|
$events_loc.pres_mgmt.lock_config = false;
|
||||||
{#if $ae_loc.manager_access}
|
|
||||||
{#if $ae_loc?.sync_local_config}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onclick={() => {
|
|
||||||
$ae_loc.sync_local_config = false;
|
|
||||||
$events_loc.pres_mgmt.sync_local_config = false;
|
|
||||||
|
|
||||||
$ae_loc.lock_config = false;
|
// dispatch_sync_local_config_changed();
|
||||||
$events_loc.pres_mgmt.lock_config = false;
|
// tick();
|
||||||
|
return false;
|
||||||
|
}}
|
||||||
|
class="btn btn-sm preset-tonal-success border border-success-500 hover:preset-filled-success-500 transition-all hover:transition-all *:hover:inline"
|
||||||
|
title="Syncing the local configuration with the remote configuration."
|
||||||
|
>
|
||||||
|
<span class="fas fa-sync m-1"></span>
|
||||||
|
<span class="hidden"> Sync </span>
|
||||||
|
</button>
|
||||||
|
{:else}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onclick={() => {
|
||||||
|
$ae_loc.sync_local_config = true;
|
||||||
|
$events_loc.pres_mgmt.sync_local_config = true;
|
||||||
|
|
||||||
// dispatch_sync_local_config_changed();
|
$ae_loc.lock_config = true;
|
||||||
// tick();
|
$events_loc.pres_mgmt.lock_config = true;
|
||||||
return false;
|
|
||||||
}}
|
|
||||||
class="btn btn-sm preset-tonal-success border border-success-500 hover:preset-filled-success-500 transition-all hover:transition-all *:hover:inline"
|
|
||||||
title="Syncing the local configuration with the remote configuration."
|
|
||||||
>
|
|
||||||
<span class="fas fa-sync m-1"></span>
|
|
||||||
<span class="hidden">
|
|
||||||
Sync
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
{:else}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onclick={() => {
|
|
||||||
$ae_loc.sync_local_config = true;
|
|
||||||
$events_loc.pres_mgmt.sync_local_config = true;
|
|
||||||
|
|
||||||
$ae_loc.lock_config = true;
|
// dispatch_sync_local_config_changed();
|
||||||
$events_loc.pres_mgmt.lock_config = true;
|
// tick();
|
||||||
|
return true;
|
||||||
|
}}
|
||||||
|
class="btn btn-sm preset-tonal-warning border border-warning-500 hover:preset-filled-warning-500 transition-all hover:transition-all *:hover:inline"
|
||||||
|
title="Currently not syncing with the remote server. Re-sync the local configuration with the remote configuration?"
|
||||||
|
>
|
||||||
|
<span class="fas fa-unlink m-1"></span>
|
||||||
|
<span class="hidden"> Re-sync? </span>
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
|
||||||
// dispatch_sync_local_config_changed();
|
<!-- {#if $ae_loc.edit_mode}
|
||||||
// tick();
|
|
||||||
return true;
|
|
||||||
}}
|
|
||||||
class="btn btn-sm preset-tonal-warning border border-warning-500 hover:preset-filled-warning-500 transition-all hover:transition-all *:hover:inline"
|
|
||||||
title="Currently not syncing with the remote server. Re-sync the local configuration with the remote configuration?"
|
|
||||||
>
|
|
||||||
<span class="fas fa-unlink m-1"></span>
|
|
||||||
<span class="hidden">
|
|
||||||
Re-sync?
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
{/if}
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<!-- {#if $ae_loc.edit_mode}
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
@@ -404,133 +407,127 @@ function handle_clear_access() {
|
|||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
{/if} -->
|
{/if} -->
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-row flex-wrap gap-1 items-end justify-end w-full transition-all">
|
<div class="flex flex-row flex-wrap gap-1 items-end justify-end w-full transition-all">
|
||||||
|
{#if $ae_loc?.access_type && $ae_loc?.access_type == 'anonymous' && 1 == 3}
|
||||||
|
<span>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onclick={() => {
|
||||||
|
// handle_check_access_type_passcode();
|
||||||
|
trigger = true;
|
||||||
|
}}
|
||||||
|
class="btn btn-sm preset-tonal-success hover:preset-filled-warning-500 access_type_unlock_btn transition-all"
|
||||||
|
title="Anonymous public access is currently set. Access mode is disabled/locked."
|
||||||
|
>
|
||||||
|
<span class="fas fa-lock mx-1"></span>
|
||||||
|
<span class="lock_icon">Locked</span>
|
||||||
|
|
||||||
{#if $ae_loc?.access_type && $ae_loc?.access_type == 'anonymous' && 1==3}
|
<span class="fas fa-unlock mx-1 unlock_icon hidden"></span>
|
||||||
<span>
|
{#if show_passcode_input}
|
||||||
<button
|
<span class="unlock_text">Cancel</span>
|
||||||
type="button"
|
{:else}
|
||||||
onclick={() => {
|
<span class="unlock_text">Access?</span>
|
||||||
// handle_check_access_type_passcode();
|
{/if}
|
||||||
trigger = true;
|
</button>
|
||||||
}}
|
</span>
|
||||||
class="btn btn-sm preset-tonal-success hover:preset-filled-warning-500 access_type_unlock_btn transition-all"
|
{/if}
|
||||||
title="Anonymous public access is currently set. Access mode is disabled/locked."
|
|
||||||
>
|
|
||||||
<span class="fas fa-lock mx-1"></span>
|
|
||||||
<span class="lock_icon">Locked</span>
|
|
||||||
|
|
||||||
<span class="fas fa-unlock mx-1 unlock_icon hidden"></span>
|
{#if $ae_loc?.access_type && $ae_loc?.access_type != 'anonymous'}
|
||||||
{#if (show_passcode_input)}
|
<span class="flex flex-row gap-1 items-center justify-center">
|
||||||
<span class="unlock_text">Cancel</span>
|
<!-- <span class="fas fa-unlock mx-1"></span> -->
|
||||||
{:else}
|
<ShieldPlus class="inline-block" />
|
||||||
<span class="unlock_text">Access?</span>
|
|
||||||
{/if}
|
|
||||||
</button>
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if ($ae_loc?.access_type && $ae_loc?.access_type != 'anonymous')}
|
<span class="*:hover:inline" title={`Current access type/level: ${$ae_loc.access_type}`}>
|
||||||
<span class="flex flex-row gap-1 items-center justify-center">
|
{#if $ae_loc.access_type == 'super'}
|
||||||
<!-- <span class="fas fa-unlock mx-1"></span> -->
|
<span class="fas fa-hat-wizard m-1"></span>
|
||||||
<ShieldPlus class="inline-block" />
|
<span class="hidden">Super</span>
|
||||||
|
{:else if $ae_loc.access_type == 'manager'}
|
||||||
|
<span class="fas fa-user-shield m-1"></span>
|
||||||
|
<span class="hidden">Manager</span>
|
||||||
|
{:else if $ae_loc.access_type == 'administrator'}
|
||||||
|
<span class="fas fa-user-ninja m-1"></span>
|
||||||
|
<span class="hidden">Administrator</span>
|
||||||
|
{:else if $ae_loc.access_type == 'trusted'}
|
||||||
|
<span class="fas fa-user-check m-1"></span>
|
||||||
|
<span class="hidden">Trusted Access</span>
|
||||||
|
{:else if $ae_loc.access_type == 'public'}
|
||||||
|
Public
|
||||||
|
<span class="hidden">Access</span>
|
||||||
|
{:else if $ae_loc.access_type == 'authenticated'}
|
||||||
|
Authenticated
|
||||||
|
<span class="hidden">Access</span>
|
||||||
|
{:else if $ae_loc.access_type == 'anonymous'}
|
||||||
|
Anonymous Access
|
||||||
|
{:else}
|
||||||
|
Unknown Access
|
||||||
|
{/if}
|
||||||
|
</span>
|
||||||
|
|
||||||
<span
|
{#if $ae_loc?.user_access_type && $ae_loc?.access_type == $ae_loc?.user_access_type && !show_passcode_input}
|
||||||
class="*:hover:inline"
|
<button
|
||||||
title={`Current access type/level: ${$ae_loc.access_type}`}
|
type="button"
|
||||||
>
|
onclick={() => {
|
||||||
{#if $ae_loc.access_type == 'super'}
|
// handle_clear_access();
|
||||||
<span class="fas fa-hat-wizard m-1"></span>
|
// trigger_clear_access = true;
|
||||||
<span class="hidden">Super</span>
|
show_passcode_input = true;
|
||||||
{:else if $ae_loc.access_type == 'manager'}
|
}}
|
||||||
<span class="fas fa-user-shield m-1"></span>
|
class="btn btn-sm variant-outline-surface hover:preset-tonal-warning border border-warning-500 transition-all"
|
||||||
<span class="hidden">Manager</span>
|
title={`Current user access level: "${$ae_loc.user_access_type}". Click use passcode for a different access level.`}
|
||||||
{:else if $ae_loc.access_type == 'administrator'}
|
>
|
||||||
<span class="fas fa-user-ninja m-1"></span>
|
<!-- <span class="fas fa-lock mx-1"></span> -->
|
||||||
<span class="hidden">Administrator</span>
|
<!-- <ShieldMinus /> -->
|
||||||
{:else if $ae_loc.access_type == 'trusted'}
|
<ShieldEllipsis class="inline-block" />
|
||||||
<span class="fas fa-user-check m-1"></span>
|
Passcode?
|
||||||
<span class="hidden">Trusted Access</span>
|
</button>
|
||||||
{:else if $ae_loc.access_type == 'public'}
|
{:else if !show_passcode_input}
|
||||||
Public
|
<button
|
||||||
<span class="hidden">Access</span>
|
type="button"
|
||||||
{:else if $ae_loc.access_type == 'authenticated'}
|
onclick={() => {
|
||||||
Authenticated
|
// handle_clear_access();
|
||||||
<span class="hidden">Access</span>
|
trigger_clear_access = true;
|
||||||
{:else if $ae_loc.access_type == 'anonymous'}
|
show_passcode_input = true;
|
||||||
Anonymous Access
|
// show_passcode_input = true;
|
||||||
{:else}
|
}}
|
||||||
Unknown Access
|
class="btn btn-sm variant-outline-warning hover:preset-tonal-warning border border-warning-500 transition-all"
|
||||||
{/if}
|
title={`Current access level: "${$ae_loc.access_type}". Click to clear the temporary access level.`}
|
||||||
</span>
|
>
|
||||||
|
<!-- <span class="fas fa-lock mx-1"></span> -->
|
||||||
|
<ShieldMinus class="inline-block" />
|
||||||
|
Clear?
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if $ae_loc?.user_access_type && $ae_loc?.access_type == $ae_loc?.user_access_type && !show_passcode_input}
|
{#if show_passcode_input}
|
||||||
<button
|
<span class="flex flex-row gap-1 items-center justify-between w-full">
|
||||||
type="button"
|
<span>
|
||||||
onclick={() => {
|
<ShieldEllipsis class="inline-block text-gray-500" />
|
||||||
// handle_clear_access();
|
<span class="unlock_text text-sm">Passcode:</span>
|
||||||
// trigger_clear_access = true;
|
</span>
|
||||||
show_passcode_input = true;
|
|
||||||
}}
|
|
||||||
class="btn btn-sm variant-outline-surface hover:preset-tonal-warning border border-warning-500 transition-all"
|
|
||||||
title={`Current user access level: "${$ae_loc.user_access_type}". Click use passcode for a different access level.`}
|
|
||||||
>
|
|
||||||
<!-- <span class="fas fa-lock mx-1"></span> -->
|
|
||||||
<!-- <ShieldMinus /> -->
|
|
||||||
<ShieldEllipsis class="inline-block" />
|
|
||||||
Passcode?
|
|
||||||
</button>
|
|
||||||
{:else if (!show_passcode_input)}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onclick={() => {
|
|
||||||
// handle_clear_access();
|
|
||||||
trigger_clear_access = true;
|
|
||||||
show_passcode_input = true;
|
|
||||||
// show_passcode_input = true;
|
|
||||||
}}
|
|
||||||
class="btn btn-sm variant-outline-warning hover:preset-tonal-warning border border-warning-500 transition-all"
|
|
||||||
title={`Current access level: "${$ae_loc.access_type}". Click to clear the temporary access level.`}
|
|
||||||
>
|
|
||||||
<!-- <span class="fas fa-lock mx-1"></span> -->
|
|
||||||
<ShieldMinus class="inline-block" />
|
|
||||||
Clear?
|
|
||||||
</button>
|
|
||||||
{/if}
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if (show_passcode_input)}
|
<!-- svelte-ignore a11y_autofocus -->
|
||||||
<span class="flex flex-row gap-1 items-center justify-between w-full">
|
<input
|
||||||
<span>
|
id="access_passcode_input"
|
||||||
<ShieldEllipsis class="inline-block text-gray-500" />
|
bind:value={entered_passcode}
|
||||||
<span class="unlock_text text-sm">Passcode:</span>
|
class="input w-32 transition-all"
|
||||||
</span>
|
class:hidden={!show_passcode_input}
|
||||||
|
type="text"
|
||||||
<!-- svelte-ignore a11y_autofocus -->
|
placeholder="Passcode"
|
||||||
<input
|
autofocus={show_passcode_input}
|
||||||
id="access_passcode_input"
|
/>
|
||||||
bind:value={entered_passcode}
|
<!-- <div class="current_text transition-all">{$ae_loc.access_type}</div> -->
|
||||||
class="input w-32 transition-all"
|
</span>
|
||||||
class:hidden={!show_passcode_input}
|
{/if}
|
||||||
type="text"
|
</div>
|
||||||
placeholder="Passcode"
|
|
||||||
autofocus={show_passcode_input}
|
|
||||||
/>
|
|
||||||
<!-- <div class="current_text transition-all">{$ae_loc.access_type}</div> -->
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
/* BEGIN: AE's Svelte Quick Access Type component */
|
/* BEGIN: AE's Svelte Quick Access Type component */
|
||||||
/*
|
/*
|
||||||
#xxx-AE-Quick-Access-Type {
|
#xxx-AE-Quick-Access-Type {
|
||||||
// position: absolute;
|
// position: absolute;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
@@ -568,7 +565,7 @@ function handle_clear_access() {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#xxx-AE-Quick-Access-Type:hover {
|
#xxx-AE-Quick-Access-Type:hover {
|
||||||
|
|
||||||
border-top: solid thin hsla(0,0%,0%,.95);
|
border-top: solid thin hsla(0,0%,0%,.95);
|
||||||
@@ -585,29 +582,29 @@ function handle_clear_access() {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* #Access-Type .unlock_text {
|
/* #Access-Type .unlock_text {
|
||||||
transition: width 2s, height 2s, background-color 2s, transform 2s;
|
transition: width 2s, height 2s, background-color 2s, transform 2s;
|
||||||
} */
|
} */
|
||||||
/* END: Svelte Access Type component */
|
/* END: Svelte Access Type component */
|
||||||
|
|
||||||
.access_type_unlock_btn:hover .lock_icon {
|
.access_type_unlock_btn:hover .lock_icon {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.access_type_unlock_btn:hover .unlock_icon {
|
.access_type_unlock_btn:hover .unlock_icon {
|
||||||
display: initial;
|
display: initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
.access_type_unlock_btn .unlock_text {
|
.access_type_unlock_btn .unlock_text {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.access_type_unlock_btn:hover .unlock_text {
|
.access_type_unlock_btn:hover .unlock_text {
|
||||||
display: initial;
|
display: initial;
|
||||||
/* outline: solid thin red; */
|
/* outline: solid thin red; */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
.ae_access_type .current_text {
|
.ae_access_type .current_text {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,116 +1,109 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { Settings } from '@lucide/svelte';
|
||||||
|
|
||||||
import {
|
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||||
Settings
|
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/stores/ae_stores';
|
||||||
} from '@lucide/svelte';
|
|
||||||
|
|
||||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
// import Element_theme from '$lib/e_app_theme.svelte';
|
||||||
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/stores/ae_stores';
|
|
||||||
|
|
||||||
// import Element_theme from '$lib/e_app_theme.svelte';
|
let notes: null | string = null;
|
||||||
|
let all: boolean = false;
|
||||||
|
|
||||||
let notes: null|string = null;
|
interface Props {
|
||||||
let all: boolean = false;
|
log_lvl?: number;
|
||||||
|
hide?: null | boolean;
|
||||||
|
expand?: boolean;
|
||||||
|
// export let theme_mode: null|string = null;
|
||||||
|
// set_theme_mode?: null|boolean;
|
||||||
|
// export let theme_name: null|string = null;
|
||||||
|
// set_theme_name?: null|boolean;
|
||||||
|
}
|
||||||
|
|
||||||
interface Props {
|
let {
|
||||||
log_lvl?: number;
|
log_lvl = $bindable(0),
|
||||||
hide?: null|boolean;
|
hide = $bindable(false),
|
||||||
expand?: boolean;
|
expand = $bindable(false)
|
||||||
// export let theme_mode: null|string = null;
|
// set_theme_mode = null,
|
||||||
// set_theme_mode?: null|boolean;
|
// set_theme_name = null
|
||||||
// export let theme_name: null|string = null;
|
}: Props = $props();
|
||||||
// set_theme_name?: null|boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
let {
|
// const dispatch = createEventDispatcher();
|
||||||
log_lvl = $bindable(0),
|
|
||||||
hide = $bindable(false),
|
|
||||||
expand = $bindable(false),
|
|
||||||
// set_theme_mode = null,
|
|
||||||
// set_theme_name = null
|
|
||||||
}: Props = $props();
|
|
||||||
|
|
||||||
// const dispatch = createEventDispatcher();
|
// onMount(() => {
|
||||||
|
// // console.log('** Element Mounted: ** Element App Config');
|
||||||
|
// if (set_theme_mode) {
|
||||||
|
// $slct_trigger = 'set_theme_mode';
|
||||||
|
// }
|
||||||
|
// if (set_theme_name) {
|
||||||
|
// $slct_trigger = 'set_theme_name';
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
// $: if ($slct_trigger == 'set_theme_mode' && $ae_loc?.app_cfg?.theme_mode) {
|
||||||
|
// console.log(`$ae_loc.app_cfg.theme_mode=${$ae_loc?.app_cfg?.theme_mode}`);
|
||||||
|
// $slct_trigger = null;
|
||||||
|
// if ($ae_loc.app_cfg.theme_mode == 'light') {
|
||||||
|
// document.documentElement.classList.remove('dark');
|
||||||
|
// document.documentElement.classList.add('light');
|
||||||
|
// } else if ($ae_loc.app_cfg.theme_mode == 'dark') {
|
||||||
|
// document.documentElement.classList.remove('light');
|
||||||
|
// document.documentElement.classList.add('dark');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// onMount(() => {
|
// $: if ($slct_trigger == 'set_theme_name' && $ae_loc?.app_cfg?.theme_name) {
|
||||||
// // console.log('** Element Mounted: ** Element App Config');
|
// console.log(`$ae_loc?.app_cfg?.theme_name=${$ae_loc?.app_cfg?.theme_name}`);
|
||||||
// if (set_theme_mode) {
|
// $slct_trigger = null;
|
||||||
// $slct_trigger = 'set_theme_mode';
|
// // Update the body attribute named "data-theme" to the current theme name.
|
||||||
// }
|
// document.body.setAttribute('data-theme', $ae_loc?.app_cfg?.theme_name);
|
||||||
// if (set_theme_name) {
|
// }
|
||||||
// $slct_trigger = 'set_theme_name';
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// $: if ($slct_trigger == 'set_theme_mode' && $ae_loc?.app_cfg?.theme_mode) {
|
// $: if (entered_passcode && entered_passcode.length >= 5) {
|
||||||
// console.log(`$ae_loc.app_cfg.theme_mode=${$ae_loc?.app_cfg?.theme_mode}`);
|
// console.log(`entered_passcode=${entered_passcode}`);
|
||||||
// $slct_trigger = null;
|
// handle_check_access_type_passcode();
|
||||||
// if ($ae_loc.app_cfg.theme_mode == 'light') {
|
// }
|
||||||
// document.documentElement.classList.remove('dark');
|
|
||||||
// document.documentElement.classList.add('light');
|
|
||||||
// } else if ($ae_loc.app_cfg.theme_mode == 'dark') {
|
|
||||||
// document.documentElement.classList.remove('light');
|
|
||||||
// document.documentElement.classList.add('dark');
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $: if ($slct_trigger == 'set_theme_name' && $ae_loc?.app_cfg?.theme_name) {
|
// $: if (trigger && $ae_loc.access_type) {
|
||||||
// console.log(`$ae_loc?.app_cfg?.theme_name=${$ae_loc?.app_cfg?.theme_name}`);
|
// console.log(`$ae_loc.access_type=${$ae_loc.access_type}`);
|
||||||
// $slct_trigger = null;
|
|
||||||
// // Update the body attribute named "data-theme" to the current theme name.
|
|
||||||
// document.body.setAttribute('data-theme', $ae_loc?.app_cfg?.theme_name);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $: if (entered_passcode && entered_passcode.length >= 5) {
|
// let access_checks_results = ae_util.process_permission_checks($ae_loc.access_type);
|
||||||
// console.log(`entered_passcode=${entered_passcode}`);
|
|
||||||
// handle_check_access_type_passcode();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $: if (trigger && $ae_loc.access_type) {
|
// $ae_loc = {...$ae_loc, ...access_checks_results};
|
||||||
// console.log(`$ae_loc.access_type=${$ae_loc.access_type}`);
|
// } else if (trigger) {
|
||||||
|
// console.log(`$ae_loc.access_type=not set`);
|
||||||
|
|
||||||
// let access_checks_results = ae_util.process_permission_checks($ae_loc.access_type);
|
// // Send an empty string to reset the permissions. This is the same as sending 'anonymous'.
|
||||||
|
// let access_checks_results = ae_util.process_permission_checks('');
|
||||||
|
|
||||||
// $ae_loc = {...$ae_loc, ...access_checks_results};
|
// $ae_loc = {...$ae_loc, ...access_checks_results};
|
||||||
// } else if (trigger) {
|
// }
|
||||||
// console.log(`$ae_loc.access_type=not set`);
|
|
||||||
|
|
||||||
// // Send an empty string to reset the permissions. This is the same as sending 'anonymous'.
|
function handle_something() {
|
||||||
// let access_checks_results = ae_util.process_permission_checks('');
|
// console.log('*** handle_something() ***');
|
||||||
|
}
|
||||||
|
|
||||||
// $ae_loc = {...$ae_loc, ...access_checks_results};
|
function handle_clear_storage(item: null | string) {
|
||||||
// }
|
// console.log('*** handle_clear_storage() ***');
|
||||||
|
// window.localStorage.setItem('access_type', 'anonymous');
|
||||||
|
// return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// function dispatch_something_changed() {
|
||||||
|
// console.log('*** dispatch_something_changed() ***');
|
||||||
|
|
||||||
function handle_something() {
|
// console.log(ae_util);
|
||||||
// console.log('*** handle_something() ***');
|
// console.log($ae_loc);
|
||||||
|
|
||||||
}
|
// dispatch('access_type_changed', {
|
||||||
|
// access_type: $ae_loc.access_type
|
||||||
function handle_clear_storage(item: null|string) {
|
// });
|
||||||
// console.log('*** handle_clear_storage() ***');
|
// }
|
||||||
// window.localStorage.setItem('access_type', 'anonymous');
|
|
||||||
// return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// function dispatch_something_changed() {
|
|
||||||
// console.log('*** dispatch_something_changed() ***');
|
|
||||||
|
|
||||||
// console.log(ae_util);
|
|
||||||
// console.log($ae_loc);
|
|
||||||
|
|
||||||
// dispatch('access_type_changed', {
|
|
||||||
// access_type: $ae_loc.access_type
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<!-- transition duration-500 delay-1000 hover:duration-500 hover:delay-1000 hover:transition-all -->
|
<!-- transition duration-500 delay-1000 hover:duration-500 hover:delay-1000 hover:transition-all -->
|
||||||
<section
|
<section
|
||||||
id="AE-App-Cfg"
|
id="AE-App-Cfg"
|
||||||
class="
|
class="
|
||||||
ae_app_cfg
|
ae_app_cfg
|
||||||
hidden-print
|
hidden-print
|
||||||
|
|
||||||
@@ -127,48 +120,39 @@ function handle_clear_storage(item: null|string) {
|
|||||||
duration-300 delay-150 hover:delay-1000 hover:ease-out
|
duration-300 delay-150 hover:delay-1000 hover:ease-out
|
||||||
transition-all
|
transition-all
|
||||||
"
|
"
|
||||||
class:hidden={hide}
|
class:hidden={hide}
|
||||||
>
|
>
|
||||||
|
<header class:hidden={!expand} class="ae_header w-full">
|
||||||
|
<h2 class="text-sm text-center font-semibold">Config</h2>
|
||||||
|
</header>
|
||||||
|
|
||||||
<header
|
<div
|
||||||
class:hidden={!expand}
|
class="ae_cfg_content text-xs space-y-4 my-4"
|
||||||
class="ae_header w-full"
|
class:hidden={!expand}
|
||||||
>
|
data-sveltekit-preload-data="false"
|
||||||
<h2 class="text-sm text-center font-semibold">
|
>
|
||||||
Config
|
<section class="space-y-2">
|
||||||
</h2>
|
<div>
|
||||||
</header>
|
<h2 class="strong">Access Type:</h2>
|
||||||
|
</div>
|
||||||
|
{#if $ae_loc.access_type && $ae_loc.access_type != 'anonymous'}
|
||||||
|
{#if $ae_loc.access_type == 'super'}
|
||||||
|
<span class="fas fa-secret mx-1"></span> Super Access
|
||||||
|
{:else if $ae_loc.access_type == 'manager'}
|
||||||
|
<span class="fas fa-user-shield mx-1"></span> Manager Access
|
||||||
|
{:else if $ae_loc.access_type == 'administrator'}
|
||||||
|
<span class="fas fa-user-ninja mx-1"></span> Administrator Access
|
||||||
|
{:else if $ae_loc.access_type == 'trusted'}
|
||||||
|
<span class="fas fa-user-nurse mx-1"></span> Trusted Access
|
||||||
|
{:else if $ae_loc.access_type == 'authenticated'}
|
||||||
|
<span class="fas fa-user-friends mx-1"></span> Authenticated Access
|
||||||
|
{:else if $ae_loc.access_type == 'anonymous'}
|
||||||
|
<span class="fas fa-users mx-1"></span> Anonymous Access
|
||||||
|
{:else}
|
||||||
|
<span class="fas fa-unlock mx-1"></span> Unknown Access
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<!-- <button
|
||||||
<div
|
|
||||||
class="ae_cfg_content text-xs space-y-4 my-4"
|
|
||||||
class:hidden={!expand}
|
|
||||||
data-sveltekit-preload-data="false"
|
|
||||||
>
|
|
||||||
|
|
||||||
|
|
||||||
<section class="space-y-2">
|
|
||||||
<div>
|
|
||||||
<h2 class="strong">Access Type:</h2>
|
|
||||||
</div>
|
|
||||||
{#if $ae_loc.access_type && $ae_loc.access_type != 'anonymous'}
|
|
||||||
{#if $ae_loc.access_type == 'super'}
|
|
||||||
<span class="fas fa-secret mx-1"></span> Super Access
|
|
||||||
{:else if $ae_loc.access_type == 'manager'}
|
|
||||||
<span class="fas fa-user-shield mx-1"></span> Manager Access
|
|
||||||
{:else if $ae_loc.access_type == 'administrator'}
|
|
||||||
<span class="fas fa-user-ninja mx-1"></span> Administrator Access
|
|
||||||
{:else if $ae_loc.access_type == 'trusted'}
|
|
||||||
<span class="fas fa-user-nurse mx-1"></span> Trusted Access
|
|
||||||
{:else if $ae_loc.access_type == 'authenticated'}
|
|
||||||
<span class="fas fa-user-friends mx-1"></span> Authenticated Access
|
|
||||||
{:else if $ae_loc.access_type == 'anonymous'}
|
|
||||||
<span class="fas fa-users mx-1"></span> Anonymous Access
|
|
||||||
{:else}
|
|
||||||
<span class="fas fa-unlock mx-1"></span> Unknown Access
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<!-- <button
|
|
||||||
class="btn btn-sm variant-glass-secondary access_type_lock_btn hover:transition-all"
|
class="btn btn-sm variant-glass-secondary access_type_lock_btn hover:transition-all"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
handle_clear_access();
|
handle_clear_access();
|
||||||
@@ -177,115 +161,96 @@ function handle_clear_storage(item: null|string) {
|
|||||||
>
|
>
|
||||||
<span class="fas fa-lock mx-1"></span> Lock
|
<span class="fas fa-lock mx-1"></span> Lock
|
||||||
</button> -->
|
</button> -->
|
||||||
{:else}
|
{:else}
|
||||||
Not logged in
|
Not logged in
|
||||||
{/if}
|
{/if}
|
||||||
</section>
|
</section>
|
||||||
<!-- END: Access Type -->
|
<!-- END: Access Type -->
|
||||||
|
|
||||||
|
<section class="space-y-2">
|
||||||
|
<h2 class="strong">Utilities:</h2>
|
||||||
|
<a class="btn btn-sm preset-tonal-secondary" href="/hosted_files">
|
||||||
|
<span class="fas fa-code mx-1"></span>
|
||||||
|
Util: Convert Videos
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{#if $ae_loc.iframe}
|
||||||
|
<a class="btn btn-sm preset-tonal-secondary" href="/?iframe=false">
|
||||||
|
<span class="fas fa-code mx-1"></span>
|
||||||
|
Exit iframe Mode
|
||||||
|
</a>
|
||||||
|
{:else}
|
||||||
|
<a class="btn btn-sm preset-tonal-secondary" href="/?iframe=true">
|
||||||
|
<span class="fas fa-code mx-1"></span>
|
||||||
|
Use iframe Mode
|
||||||
|
</a>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
class="btn btn-sm preset-tonal-warning"
|
||||||
|
title="Reload and clear the page cache"
|
||||||
|
onclick={() => {
|
||||||
|
// $ae_loc.
|
||||||
|
window.location.reload(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span class="fas fa-sync mx-1"></span>
|
||||||
|
Reload &
|
||||||
|
<span class="fas fa-trash mx-1"></span>
|
||||||
|
Clear Cache
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="btn btn-sm preset-tonal-warning"
|
||||||
|
title="Clear the browser storage for this page"
|
||||||
|
onclick={() => {
|
||||||
|
if (!confirm('Are you sure you want to clear the local and session storage?')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
<section class="space-y-2">
|
// Clear the local and session storage
|
||||||
|
localStorage.clear();
|
||||||
|
sessionStorage.clear();
|
||||||
|
|
||||||
<h2 class="strong">Utilities:</h2>
|
// Clear Indexed DB as well
|
||||||
<a
|
indexedDB.deleteDatabase('ae_core_db');
|
||||||
class="btn btn-sm preset-tonal-secondary"
|
indexedDB.deleteDatabase('ae_events_db');
|
||||||
href="/hosted_files"
|
|
||||||
>
|
|
||||||
<span class="fas fa-code mx-1"></span>
|
|
||||||
Util: Convert Videos
|
|
||||||
</a>
|
|
||||||
|
|
||||||
{#if $ae_loc.iframe}
|
window.location.reload();
|
||||||
<a
|
// alert('Local and Session Storage cleared and Indexed DBs deleted. You will probably want to refresh the page.');
|
||||||
class="btn btn-sm preset-tonal-secondary"
|
}}
|
||||||
href="/?iframe=false"
|
>
|
||||||
>
|
<span class="fas fa-eraser mx-1"></span>
|
||||||
<span class="fas fa-code mx-1"></span>
|
Clear Storage & DB
|
||||||
Exit iframe Mode
|
</button>
|
||||||
</a>
|
</div>
|
||||||
{:else}
|
</section>
|
||||||
<a
|
<!-- END: Utilities -->
|
||||||
class="btn btn-sm preset-tonal-secondary"
|
</div>
|
||||||
href="/?iframe=true"
|
|
||||||
>
|
|
||||||
<span class="fas fa-code mx-1"></span>
|
|
||||||
Use iframe Mode
|
|
||||||
</a>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<div>
|
<!-- class:justify-between={expand}
|
||||||
<button
|
|
||||||
class="btn btn-sm preset-tonal-warning"
|
|
||||||
title="Reload and clear the page cache"
|
|
||||||
onclick={() => {
|
|
||||||
// $ae_loc.
|
|
||||||
window.location.reload(true);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span class="fas fa-sync mx-1"></span>
|
|
||||||
Reload
|
|
||||||
&
|
|
||||||
<span class="fas fa-trash mx-1"></span>
|
|
||||||
Clear Cache
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="btn btn-sm preset-tonal-warning"
|
|
||||||
title="Clear the browser storage for this page"
|
|
||||||
onclick={() => {
|
|
||||||
if (!confirm('Are you sure you want to clear the local and session storage?')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear the local and session storage
|
|
||||||
localStorage.clear();
|
|
||||||
sessionStorage.clear();
|
|
||||||
|
|
||||||
// Clear Indexed DB as well
|
|
||||||
indexedDB.deleteDatabase('ae_core_db');
|
|
||||||
indexedDB.deleteDatabase('ae_events_db');
|
|
||||||
|
|
||||||
window.location.reload();
|
|
||||||
// alert('Local and Session Storage cleared and Indexed DBs deleted. You will probably want to refresh the page.');
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span class="fas fa-eraser mx-1"></span>
|
|
||||||
Clear Storage & DB
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
<!-- END: Utilities -->
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- class:justify-between={expand}
|
|
||||||
class:justify-end={!expand} -->
|
class:justify-end={!expand} -->
|
||||||
<div
|
<div class="flex flex-row gap-2 items-center justify-between w-full">
|
||||||
class="flex flex-row gap-2 items-center justify-between w-full"
|
<!-- {#if !expand} -->
|
||||||
>
|
<span>
|
||||||
<!-- {#if !expand} -->
|
{#if $ae_loc.access_type && $ae_loc.access_type != 'anonymous'}
|
||||||
<span>
|
{#if $ae_loc.access_type == 'super'}
|
||||||
{#if $ae_loc.access_type && $ae_loc.access_type != 'anonymous'}
|
<span class="fas fa-secret mx-1"></span> Super Access
|
||||||
{#if $ae_loc.access_type == 'super'}
|
{:else if $ae_loc.access_type == 'manager'}
|
||||||
<span class="fas fa-secret mx-1"></span> Super Access
|
<span class="fas fa-user-shield mx-1"></span> Manager Access
|
||||||
{:else if $ae_loc.access_type == 'manager'}
|
{:else if $ae_loc.access_type == 'administrator'}
|
||||||
<span class="fas fa-user-shield mx-1"></span> Manager Access
|
<span class="fas fa-user-ninja mx-1"></span> Administrator Access
|
||||||
{:else if $ae_loc.access_type == 'administrator'}
|
{:else if $ae_loc.access_type == 'trusted'}
|
||||||
<span class="fas fa-user-ninja mx-1"></span> Administrator Access
|
<span class="fas fa-user-nurse mx-1"></span> Trusted Access
|
||||||
{:else if $ae_loc.access_type == 'trusted'}
|
{:else if $ae_loc.access_type == 'authenticated'}
|
||||||
<span class="fas fa-user-nurse mx-1"></span> Trusted Access
|
<span class="fas fa-user-friends mx-1"></span> Authenticated Access
|
||||||
{:else if $ae_loc.access_type == 'authenticated'}
|
{:else if $ae_loc.access_type == 'anonymous'}
|
||||||
<span class="fas fa-user-friends mx-1"></span> Authenticated Access
|
<span class="fas fa-users mx-1"></span> Anonymous Access
|
||||||
{:else if $ae_loc.access_type == 'anonymous'}
|
{:else}
|
||||||
<span class="fas fa-users mx-1"></span> Anonymous Access
|
<span class="fas fa-unlock mx-1"></span> Unknown Access
|
||||||
{:else}
|
{/if}
|
||||||
<span class="fas fa-unlock mx-1"></span> Unknown Access
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<!-- <button
|
<!-- <button
|
||||||
class="btn btn-sm variant-glass-secondary access_type_lock_btn hover:transition-all"
|
class="btn btn-sm variant-glass-secondary access_type_lock_btn hover:transition-all"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
handle_clear_access();
|
handle_clear_access();
|
||||||
@@ -294,59 +259,56 @@ class:justify-end={!expand} -->
|
|||||||
>
|
>
|
||||||
<span class="fas fa-lock mx-1"></span> Lock
|
<span class="fas fa-lock mx-1"></span> Lock
|
||||||
</button> -->
|
</button> -->
|
||||||
{:else}
|
{:else}
|
||||||
Not logged in
|
Not logged in
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
<!-- {/if} -->
|
<!-- {/if} -->
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="
|
class="
|
||||||
ae_cfg_btn
|
ae_cfg_btn
|
||||||
btn btn-sm text-sm
|
btn btn-sm text-sm
|
||||||
preset-tonal-warning
|
preset-tonal-warning
|
||||||
group transition-all
|
group transition-all
|
||||||
"
|
"
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
expand = !expand;
|
expand = !expand;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<!-- <span class="fas fa-cog m-1"></span> -->
|
<!-- <span class="fas fa-cog m-1"></span> -->
|
||||||
<span class="inline-block" title="Settings">
|
<span class="inline-block" title="Settings">
|
||||||
<Settings class="m-1" />
|
<Settings class="m-1" />
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
class="
|
class="
|
||||||
cfg_text
|
cfg_text
|
||||||
hidden
|
hidden
|
||||||
group-hover:inline
|
group-hover:inline
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
Settings
|
Settings
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
<style lang="postcss">
|
<style lang="postcss">
|
||||||
|
.ae_cfg_btn .cfg_text {
|
||||||
|
/* display: none; */
|
||||||
|
}
|
||||||
|
|
||||||
.ae_cfg_btn .cfg_text {
|
.ae_cfg_btn:hover .cfg_text {
|
||||||
/* display: none; */
|
/* display: initial; */
|
||||||
}
|
/* outline: solid thin red; */
|
||||||
|
}
|
||||||
|
|
||||||
.ae_cfg_btn:hover .cfg_text {
|
/* .access_type .current_text {
|
||||||
/* display: initial; */
|
|
||||||
/* outline: solid thin red; */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* .access_type .current_text {
|
|
||||||
display: none;
|
display: none;
|
||||||
} */
|
} */
|
||||||
|
|
||||||
/* .access_type:hover .current_text {
|
/* .access_type:hover .current_text {
|
||||||
display: initial;
|
display: initial;
|
||||||
} */
|
} */
|
||||||
/* END: AE's Svelte App Config component */
|
/* END: AE's Svelte App Config component */
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,119 +1,108 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
interface Props {
|
||||||
|
children?: import('svelte').Snippet;
|
||||||
|
log_lvl?: number;
|
||||||
|
value: any;
|
||||||
|
success?: boolean;
|
||||||
|
btn_text?: string;
|
||||||
|
btn_title?: string;
|
||||||
|
btn_class?: string;
|
||||||
|
hide_icon?: boolean;
|
||||||
|
hide_text?: boolean;
|
||||||
|
icon_name?: string;
|
||||||
|
}
|
||||||
|
|
||||||
interface Props {
|
let {
|
||||||
children?: import('svelte').Snippet;
|
children,
|
||||||
log_lvl?: number;
|
log_lvl = 0,
|
||||||
value: any;
|
value = $bindable(''),
|
||||||
success?: boolean;
|
success = $bindable(false),
|
||||||
btn_text?: string;
|
btn_text = 'Copy to Clipboard',
|
||||||
btn_title?: string;
|
btn_title = 'Copy to Clipboard',
|
||||||
btn_class?: string;
|
btn_class = 'btn btn-sm preset-tonal-warning text-warning-500 m-1',
|
||||||
hide_icon?: boolean;
|
hide_icon = false,
|
||||||
hide_text?: boolean;
|
hide_text = false,
|
||||||
icon_name?: string;
|
icon_name = 'copy' // copy, check, link
|
||||||
}
|
}: Props = $props();
|
||||||
|
|
||||||
let {
|
// *** Import Svelte specific
|
||||||
children,
|
// import { browser } from '$app/environment';
|
||||||
log_lvl = 0,
|
|
||||||
value = $bindable(''),
|
|
||||||
success = $bindable(false),
|
|
||||||
btn_text = 'Copy to Clipboard',
|
|
||||||
btn_title = 'Copy to Clipboard',
|
|
||||||
btn_class = 'btn btn-sm preset-tonal-warning text-warning-500 m-1',
|
|
||||||
hide_icon = false,
|
|
||||||
hide_text = false,
|
|
||||||
icon_name = 'copy', // copy, check, link
|
|
||||||
}: Props = $props();
|
|
||||||
|
|
||||||
// *** Import Svelte specific
|
// *** Import other supporting libraries
|
||||||
// import { browser } from '$app/environment';
|
import {
|
||||||
|
// ArrowBigRight,
|
||||||
|
// CircleX,
|
||||||
|
CircleCheck,
|
||||||
|
Copy,
|
||||||
|
// Eye, EyeOff,
|
||||||
|
// Key,
|
||||||
|
Link
|
||||||
|
// LogIn, LogOut, LockKeyhole,
|
||||||
|
// Mail, MailCheck,
|
||||||
|
// Menu,
|
||||||
|
// RefreshCw, RefreshCcw, RefreshCcwDot,
|
||||||
|
// ShieldEllipsis, ShieldMinus, ShieldPlus, ShieldUser,
|
||||||
|
// User, UserCheck
|
||||||
|
} from '@lucide/svelte';
|
||||||
|
|
||||||
// *** Import other supporting libraries
|
if (log_lvl) {
|
||||||
import {
|
console.log(`Clipboard component initialized with value:`, value);
|
||||||
// ArrowBigRight,
|
}
|
||||||
// CircleX,
|
|
||||||
CircleCheck,
|
|
||||||
Copy,
|
|
||||||
// Eye, EyeOff,
|
|
||||||
// Key,
|
|
||||||
Link,
|
|
||||||
// LogIn, LogOut, LockKeyhole,
|
|
||||||
// Mail, MailCheck,
|
|
||||||
// Menu,
|
|
||||||
// RefreshCw, RefreshCcw, RefreshCcwDot,
|
|
||||||
// ShieldEllipsis, ShieldMinus, ShieldPlus, ShieldUser,
|
|
||||||
// User, UserCheck
|
|
||||||
} from '@lucide/svelte';
|
|
||||||
|
|
||||||
if (log_lvl) {
|
// Select your trigger element
|
||||||
console.log(`Clipboard component initialized with value:`, value);
|
// const elemButton: HTMLButtonElement | null = document.querySelector('[data-button]');
|
||||||
}
|
|
||||||
|
|
||||||
// Select your trigger element
|
// Add a click event handler to the trigger
|
||||||
// const elemButton: HTMLButtonElement | null = document.querySelector('[data-button]');
|
// elemButton?.addEventListener('click', () => {
|
||||||
|
// // Call the Clipboard API
|
||||||
// Add a click event handler to the trigger
|
// navigator.clipboard
|
||||||
// elemButton?.addEventListener('click', () => {
|
// // Use the `writeText` method write content to the clipboard
|
||||||
// // Call the Clipboard API
|
// .writeText(value)
|
||||||
// navigator.clipboard
|
// // Handle confirmation
|
||||||
// // Use the `writeText` method write content to the clipboard
|
// .then(() => {
|
||||||
// .writeText(value)
|
// if (log_lvl) {
|
||||||
// // Handle confirmation
|
// console.log(`Clipboard write successful: ${value}`);
|
||||||
// .then(() => {
|
// }
|
||||||
// if (log_lvl) {
|
// success = true;
|
||||||
// console.log(`Clipboard write successful: ${value}`);
|
// });
|
||||||
// }
|
// });
|
||||||
// success = true;
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
data-button
|
data-button
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
// if (browser) {
|
// if (browser) {
|
||||||
// Call the Clipboard API
|
// Call the Clipboard API
|
||||||
navigator.clipboard
|
navigator.clipboard
|
||||||
// Use the `writeText` method write content to the clipboard
|
// Use the `writeText` method write content to the clipboard
|
||||||
.writeText(value)
|
.writeText(value)
|
||||||
// Handle confirmation
|
// Handle confirmation
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`Clipboard write successful: ${value}`);
|
console.log(`Clipboard write successful: ${value}`);
|
||||||
}
|
}
|
||||||
success = true;
|
success = true;
|
||||||
});
|
});
|
||||||
// } else {
|
// } else {
|
||||||
// if (log_lvl) {
|
// if (log_lvl) {
|
||||||
// console.log(`Clipboard write attempted in non-browser environment.`);
|
// console.log(`Clipboard write attempted in non-browser environment.`);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}}
|
}}
|
||||||
class={btn_class}
|
class={btn_class}
|
||||||
title={btn_title}
|
title={btn_title}
|
||||||
>
|
>
|
||||||
<!-- {@render btn_text} -->
|
<!-- {@render btn_text} -->
|
||||||
{#if icon_name === 'link'}
|
{#if icon_name === 'link'}
|
||||||
<Link
|
<Link class="mx-1 {hide_icon ? 'hidden' : 'inline-block'}" size="1.2em" />
|
||||||
class="mx-1 {hide_icon ? 'hidden' : 'inline-block' }"
|
{:else if icon_name === 'check'}
|
||||||
size="1.2em"
|
<CircleCheck class="mx-1 {hide_icon ? 'hidden' : 'inline-block'}" size="1.2em" />
|
||||||
/>
|
{:else}
|
||||||
{:else if icon_name === 'check'}
|
<Copy class="mx-1 {hide_icon ? 'hidden' : 'inline-block'}" size="1.2em" />
|
||||||
<CircleCheck
|
{/if}
|
||||||
class="mx-1 {hide_icon ? 'hidden' : 'inline-block' }"
|
<span class={hide_text ? 'hidden' : 'inline-block'}>
|
||||||
size="1.2em"
|
{btn_text}
|
||||||
/>
|
</span>
|
||||||
{:else}
|
{@render children?.()}
|
||||||
<Copy
|
|
||||||
class="mx-1 {hide_icon ? 'hidden' : 'inline-block' }"
|
|
||||||
size="1.2em"
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
<span class="{hide_text ? 'hidden' : 'inline-block' }">
|
|
||||||
{btn_text}
|
|
||||||
</span>
|
|
||||||
{@render children?.()}
|
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user