style: Apply Prettier formatting with 4-space indentation

Applied consistent code formatting across the project using Prettier, now configured to use 4-space indentation instead of tabs.
This commit is contained in:
Scott Idem
2025-11-18 18:40:50 -05:00
parent 6d1f9989d0
commit 0987cd6ad9
346 changed files with 86645 additions and 84459 deletions

View File

@@ -2,129 +2,129 @@
// Updated 2024-05-23
export const delete_object = async function delete_object({
api_cfg = null,
endpoint = '',
params = {},
data = {},
return_meta = false,
log_lvl = 0,
retry_count = 5 // Number of retry attempts
api_cfg = null,
endpoint = '',
params = {},
data = {},
return_meta = false,
log_lvl = 0,
retry_count = 5 // Number of retry attempts
}: {
api_cfg: any;
endpoint: string;
params?: any;
data?: any;
return_meta?: boolean;
log_lvl?: number;
retry_count?: number;
api_cfg: any;
endpoint: string;
params?: any;
data?: any;
return_meta?: boolean;
log_lvl?: number;
retry_count?: number;
}) {
if (log_lvl) {
console.log(`*** delete_object() *** Endpoint: ${endpoint}`);
console.log('Params:', params);
if (log_lvl > 1) {
console.log('Data:', data);
}
}
if (log_lvl) {
console.log(`*** delete_object() *** Endpoint: ${endpoint}`);
console.log('Params:', params);
if (log_lvl > 1) {
console.log('Data:', data);
}
}
if (!api_cfg) {
console.error('No API Config was provided. Returning false.');
return false;
}
if (!api_cfg) {
console.error('No API Config was provided. Returning false.');
return false;
}
// Construct the URL with query parameters
const url = new URL(endpoint, api_cfg['base_url']);
Object.keys(params).forEach((key) => url.searchParams.append(key, params[key]));
// Construct the URL with query parameters
const url = new URL(endpoint, api_cfg['base_url']);
Object.keys(params).forEach((key) => url.searchParams.append(key, params[key]));
// Clean the headers
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
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];
}
if (log_lvl > 1) {
console.log('Cleaned Headers:', headers_cleaned);
}
if (log_lvl > 1) {
console.log('Cleaned Headers:', headers_cleaned);
}
const fetchOptions: RequestInit = {
method: 'DELETE',
headers: {
...headers_cleaned,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
};
const fetchOptions: RequestInit = {
method: 'DELETE',
headers: {
...headers_cleaned,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
};
if (log_lvl > 1) {
console.log('Fetch Options:', fetchOptions);
}
if (log_lvl > 1) {
console.log('Fetch Options:', fetchOptions);
}
for (let attempt = 1; attempt <= retry_count; attempt++) {
try {
const response = await fetch(url.toString(), fetchOptions);
for (let attempt = 1; attempt <= retry_count; attempt++) {
try {
const response = await fetch(url.toString(), fetchOptions);
if (log_lvl) {
console.log(`Response: status=${response.status} attempt=${attempt}`);
}
if (log_lvl) {
console.log(`Response: status=${response.status} attempt=${attempt}`);
}
if (!response.ok) {
if (response.status === 404) {
console.warn('404 Not Found. Returning null.');
return null; // Returning null since there were no results
}
throw new Error(`HTTP error! status: ${response.status}`);
}
if (!response.ok) {
if (response.status === 404) {
console.warn('404 Not Found. Returning null.');
return null; // Returning null since there were no results
}
throw new Error(`HTTP error! status: ${response.status}`);
}
const json = await response.json();
const json = await response.json();
if (log_lvl > 1) {
console.log('Response JSON:', json);
}
if (log_lvl > 1) {
console.log('Response JSON:', json);
}
// Return the response data or metadata
return return_meta ? json : json.data;
} catch (error) {
console.error(`API DELETE error on attempt ${attempt}:`, error);
// Return the response data or metadata
return return_meta ? json : json.data;
} catch (error) {
console.error(`API DELETE error on attempt ${attempt}:`, error);
// If this is the last attempt, return false
if (attempt === retry_count) {
console.error('Max retry attempts reached. Returning false.');
return false;
}
// 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})`);
}
}
}
// Log retry information
if (log_lvl) {
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({
// baseURL: api_cfg['base_url'],
// // timeout: 2000,
// /* other custom settings */
// });
// axios_api.defaults.headers = api_cfg['headers'];
// //OLD: axios_api.delete(endpoint, { 'data': data })
// let response_data = await axios_api.delete(endpoint, { params: params, 'data': data })
// .then(function (response) {
// console.log(response.data);
// return response.data;
// })
// .catch(function (error: 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 })
// let response_data = await axios_api.delete(endpoint, { params: params, 'data': data })
// .then(function (response) {
// console.log(response.data);
// return response.data;
// })
// .catch(function (error: 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;
// if (log_lvl > 1) {
// console.log(response_data);
// }
// return response_data;
};

View File

@@ -3,170 +3,170 @@ import { get_object } from './api_get_object';
// Updated 2023-12-01
export async function get_ae_obj_id_crud({
api_cfg,
no_account_id = false,
obj_type,
obj_id,
use_alt_table = false,
use_alt_base = false,
inc = {},
enabled = 'enabled',
hidden = 'not_hidden',
limit = 999999,
offset = 0,
data = {},
// key,
// jwt = null,
headers = {},
params = {},
timeout = 25000,
return_meta = false,
log_lvl = 0
api_cfg,
no_account_id = false,
obj_type,
obj_id,
use_alt_table = false,
use_alt_base = false,
inc = {},
enabled = 'enabled',
hidden = 'not_hidden',
limit = 999999,
offset = 0,
data = {},
// key,
// jwt = null,
headers = {},
params = {},
timeout = 25000,
return_meta = false,
log_lvl = 0
}: {
api_cfg: any;
no_account_id?: boolean;
obj_type: string;
obj_id: string;
use_alt_table?: boolean;
use_alt_base?: boolean;
inc?: any;
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
offset?: number;
data?: any;
// key: string,
// jwt?: string,
headers?: any;
params?: key_val;
timeout?: number;
return_meta?: boolean;
log_lvl?: number;
api_cfg: any;
no_account_id?: boolean;
obj_type: string;
obj_id: string;
use_alt_table?: boolean;
use_alt_base?: boolean;
inc?: any;
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
offset?: number;
data?: any;
// key: string,
// jwt?: string,
headers?: any;
params?: key_val;
timeout?: number;
return_meta?: boolean;
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['super_key'] = key;
// data['jwt'] = jwt;
// NOTE: The key and or JWT should be in the header of the DELETE, GET, PATCH, POST
// data = {};
// data['super_key'] = key;
// data['jwt'] = jwt;
// NOTE: The key and or JWT should be in the header of the DELETE, GET, PATCH, POST
let endpoint = '';
if (obj_type == 'account') {
endpoint = `/crud/account/${obj_id}`;
} else if (obj_type == 'address') {
endpoint = `/crud/address/${obj_id}`;
} else if (obj_type == 'archive') {
endpoint = `/crud/archive/${obj_id}`;
} else if (obj_type == 'archive_content') {
endpoint = `/crud/archive/content/${obj_id}`;
} else if (obj_type == 'contact') {
endpoint = `/crud/contact/${obj_id}`;
} else if (obj_type == 'data_store') {
endpoint = `/crud/data_store/${obj_id}`;
} else if (obj_type == 'event') {
endpoint = `/crud/event/${obj_id}`;
} else if (obj_type == 'event_abstract') {
endpoint = `/crud/event/abstract/${obj_id}`;
} else if (obj_type == 'event_badge') {
endpoint = `/crud/event/badge/${obj_id}`;
} else if (obj_type == 'event_device') {
endpoint = `/crud/event/device/${obj_id}`;
} else if (obj_type == 'event_exhibit') {
endpoint = `/crud/event/exhibit/${obj_id}`;
} else if (obj_type == 'event_exhibit_tracking') {
endpoint = `/crud/event/exhibit/tracking/${obj_id}`;
} else if (obj_type == 'event_file') {
endpoint = `/crud/event/file/${obj_id}`;
} else if (obj_type == 'event_location') {
endpoint = `/crud/event/location/${obj_id}`;
} else if (obj_type == 'event_person') {
endpoint = `/crud/event/person/${obj_id}`;
} else if (obj_type == 'event_presentation') {
endpoint = `/crud/event/presentation/${obj_id}`;
} else if (obj_type == 'event_presenter') {
endpoint = `/crud/event/presenter/${obj_id}`;
} else if (obj_type == 'event_session') {
endpoint = `/crud/event/session/${obj_id}`;
} else if (obj_type == 'event_track') {
endpoint = `/crud/event/track/${obj_id}`;
} else if (obj_type == 'grant') {
endpoint = `/crud/grant/${obj_id}`;
} else if (obj_type == 'hosted_file') {
endpoint = `/crud/hosted_file/${obj_id}`;
} else if (obj_type == 'journal') {
endpoint = `/crud/journal/${obj_id}`;
} else if (obj_type == 'journal_entry') {
endpoint = `/crud/journal/entry/${obj_id}`;
} else if (obj_type == 'order') {
endpoint = `/crud/order/${obj_id}`;
} else if (obj_type == 'order_line') {
endpoint = `/crud/order/line/${obj_id}`;
} else if (obj_type == 'page') {
endpoint = `/crud/page/${obj_id}`;
} else if (obj_type == 'person') {
endpoint = `/crud/person/${obj_id}`;
} else if (obj_type == 'post') {
endpoint = `/crud/post/${obj_id}`;
} else if (obj_type == 'post_comment') {
endpoint = `/crud/post/comment/${obj_id}`;
} else if (obj_type == 'site') {
endpoint = `/crud/site/${obj_id}`;
} else if (obj_type == 'site_domain') {
endpoint = `/crud/site/domain/${obj_id}`;
} else if (obj_type == 'sponsorship_cfg') {
endpoint = `/crud/sponsorship/cfg/${obj_id}`;
} else if (obj_type == 'sponsorship') {
endpoint = `/crud/sponsorship/${obj_id}`;
// } else if (obj_type == 'user') {
// endpoint = `/crud/user/${obj_id}`;
} else {
console.log(`Unknown object type: ${obj_type}`);
return false;
}
if (log_lvl) {
console.log('Endpoint:', endpoint);
}
let endpoint = '';
if (obj_type == 'account') {
endpoint = `/crud/account/${obj_id}`;
} else if (obj_type == 'address') {
endpoint = `/crud/address/${obj_id}`;
} else if (obj_type == 'archive') {
endpoint = `/crud/archive/${obj_id}`;
} else if (obj_type == 'archive_content') {
endpoint = `/crud/archive/content/${obj_id}`;
} else if (obj_type == 'contact') {
endpoint = `/crud/contact/${obj_id}`;
} else if (obj_type == 'data_store') {
endpoint = `/crud/data_store/${obj_id}`;
} else if (obj_type == 'event') {
endpoint = `/crud/event/${obj_id}`;
} else if (obj_type == 'event_abstract') {
endpoint = `/crud/event/abstract/${obj_id}`;
} else if (obj_type == 'event_badge') {
endpoint = `/crud/event/badge/${obj_id}`;
} else if (obj_type == 'event_device') {
endpoint = `/crud/event/device/${obj_id}`;
} else if (obj_type == 'event_exhibit') {
endpoint = `/crud/event/exhibit/${obj_id}`;
} else if (obj_type == 'event_exhibit_tracking') {
endpoint = `/crud/event/exhibit/tracking/${obj_id}`;
} else if (obj_type == 'event_file') {
endpoint = `/crud/event/file/${obj_id}`;
} else if (obj_type == 'event_location') {
endpoint = `/crud/event/location/${obj_id}`;
} else if (obj_type == 'event_person') {
endpoint = `/crud/event/person/${obj_id}`;
} else if (obj_type == 'event_presentation') {
endpoint = `/crud/event/presentation/${obj_id}`;
} else if (obj_type == 'event_presenter') {
endpoint = `/crud/event/presenter/${obj_id}`;
} else if (obj_type == 'event_session') {
endpoint = `/crud/event/session/${obj_id}`;
} else if (obj_type == 'event_track') {
endpoint = `/crud/event/track/${obj_id}`;
} else if (obj_type == 'grant') {
endpoint = `/crud/grant/${obj_id}`;
} else if (obj_type == 'hosted_file') {
endpoint = `/crud/hosted_file/${obj_id}`;
} else if (obj_type == 'journal') {
endpoint = `/crud/journal/${obj_id}`;
} else if (obj_type == 'journal_entry') {
endpoint = `/crud/journal/entry/${obj_id}`;
} else if (obj_type == 'order') {
endpoint = `/crud/order/${obj_id}`;
} else if (obj_type == 'order_line') {
endpoint = `/crud/order/line/${obj_id}`;
} else if (obj_type == 'page') {
endpoint = `/crud/page/${obj_id}`;
} else if (obj_type == 'person') {
endpoint = `/crud/person/${obj_id}`;
} else if (obj_type == 'post') {
endpoint = `/crud/post/${obj_id}`;
} else if (obj_type == 'post_comment') {
endpoint = `/crud/post/comment/${obj_id}`;
} else if (obj_type == 'site') {
endpoint = `/crud/site/${obj_id}`;
} else if (obj_type == 'site_domain') {
endpoint = `/crud/site/domain/${obj_id}`;
} else if (obj_type == 'sponsorship_cfg') {
endpoint = `/crud/sponsorship/cfg/${obj_id}`;
} else if (obj_type == 'sponsorship') {
endpoint = `/crud/sponsorship/${obj_id}`;
// } else if (obj_type == 'user') {
// endpoint = `/crud/user/${obj_id}`;
} else {
console.log(`Unknown object type: ${obj_type}`);
return false;
}
if (log_lvl) {
console.log('Endpoint:', endpoint);
}
params['use_alt_table'] = use_alt_table;
params['use_alt_base'] = use_alt_base;
params['use_alt_table'] = use_alt_table;
params['use_alt_base'] = use_alt_base;
if (log_lvl) {
console.log('Params:', params);
}
if (log_lvl) {
console.log('Params:', params);
}
if (no_account_id) {
headers['x-no-account-id'] = 'Nothing to See Here';
delete headers['x-account-id'];
delete api_cfg['headers']['x-account-id'];
// headers['x-account-id'] = null;
// headers['x-account-id'] = '_XY7DXtc9Mxx';
// params['x_no_account_id_token'] = 'Nothing to See Here';
if (no_account_id) {
headers['x-no-account-id'] = 'Nothing to See Here';
delete headers['x-account-id'];
delete api_cfg['headers']['x-account-id'];
// headers['x-account-id'] = null;
// headers['x-account-id'] = '_XY7DXtc9Mxx';
// params['x_no_account_id_token'] = 'Nothing to See Here';
// Remove the x-account-id header
// if (headers['x-account-id']) {
// delete headers['x-account-id'];
// }
// Remove the x-account-id header
// if (headers['x-account-id']) {
// delete headers['x-account-id'];
// }
// headers['x-account-id'] = null;
// headers['x-no-account-id-token'] = 'Nothing to See Here'; // get_object() will fix the underscores to dashes
}
// headers['x-account-id'] = null;
// headers['x-no-account-id-token'] = 'Nothing to See Here'; // get_object() will fix the underscores to dashes
}
const object_obj_get_promise = await get_object({
api_cfg: api_cfg,
endpoint: endpoint,
headers: headers,
params: params,
timeout: timeout,
log_lvl: log_lvl
}).catch(function (error: any) {
console.log('API GET CRUD object ID request failed.', error);
});
const object_obj_get_promise = await get_object({
api_cfg: api_cfg,
endpoint: endpoint,
headers: headers,
params: params,
timeout: timeout,
log_lvl: log_lvl
}).catch(function (error: any) {
console.log('API GET CRUD object ID request failed.', error);
});
if (log_lvl > 1) {
console.log('GET Object result =', object_obj_get_promise);
}
if (log_lvl > 1) {
console.log('GET Object result =', object_obj_get_promise);
}
return object_obj_get_promise;
return object_obj_get_promise;
}

View File

@@ -4,226 +4,226 @@ import { get_object } from './api_get_object';
// The lookup "obj_type" should broken out into a separate function. - 2024-08-07
// Updated 2023-11-15
export async function get_ae_obj_li_for_obj_id_crud({
api_cfg,
obj_type,
for_obj_type,
for_obj_id, // NOTE: Changed 2023-12-06 to no longer required
use_alt_table = false,
use_alt_base = false,
// inc = {},
enabled = 'enabled',
hidden = 'not_hidden',
order_by_li = null,
limit = 999999,
offset = 0,
// key,
// jwt = null,
headers = {},
params_json = null, // NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the API endpoint. Example: { "fulltext_search": { "default_qry_str": "Search string for default", "address_default_qry_str": "Search string for address", "contact_1_default_qry_str": "Search string for contact_1" } }
// json_obj = null, // NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the search endpoint.
params = {},
return_meta = false,
log_lvl = 0
api_cfg,
obj_type,
for_obj_type,
for_obj_id, // NOTE: Changed 2023-12-06 to no longer required
use_alt_table = false,
use_alt_base = false,
// inc = {},
enabled = 'enabled',
hidden = 'not_hidden',
order_by_li = null,
limit = 999999,
offset = 0,
// key,
// jwt = null,
headers = {},
params_json = null, // NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the API endpoint. Example: { "fulltext_search": { "default_qry_str": "Search string for default", "address_default_qry_str": "Search string for address", "contact_1_default_qry_str": "Search string for contact_1" } }
// json_obj = null, // NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the search endpoint.
params = {},
return_meta = false,
log_lvl = 0
}: {
api_cfg: any;
obj_type: string;
for_obj_type: null | string;
for_obj_id?: string;
use_alt_table?: boolean;
use_alt_base?: boolean;
// inc?: key_val
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
order_by_li?: any;
limit?: number;
offset?: number;
// key: string,
// jwt?: string,
headers?: any;
params_json?: any;
// json_obj?: any,
params?: key_val;
return_meta?: boolean;
log_lvl?: number;
api_cfg: any;
obj_type: string;
for_obj_type: null | string;
for_obj_id?: string;
use_alt_table?: boolean;
use_alt_base?: boolean;
// inc?: key_val
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
order_by_li?: any;
limit?: number;
offset?: number;
// key: string,
// jwt?: string,
headers?: any;
params_json?: any;
// json_obj?: any,
params?: key_val;
return_meta?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** 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['super_key'] = key;
// data['jwt'] = jwt;
// NOTE: The key and or JWT should be in the header of the DELETE, GET, PATCH, POST
// data = {};
// data['super_key'] = key;
// data['jwt'] = jwt;
// NOTE: The key and or JWT should be in the header of the DELETE, GET, PATCH, POST
// const endpoint = `/crud/${obj_type}/list`;
// const endpoint = `/crud/${obj_type}/list`;
let endpoint = '';
if (obj_type == 'account') {
endpoint = `/crud/account/list`;
} else if (obj_type == 'address') {
endpoint = `/crud/address/list`;
} else if (obj_type == 'archive') {
endpoint = `/crud/archive/list`;
} else if (obj_type == 'archive_content') {
endpoint = `/crud/archive/content/list`;
} else if (obj_type == 'contact') {
endpoint = `/crud/contact/list`;
} else if (obj_type == 'data_store') {
endpoint = `/crud/data_store/list`;
} else if (obj_type == 'event') {
endpoint = `/crud/event/list`;
} else if (obj_type == 'event_abstract') {
endpoint = `/crud/event/abstract/list`;
} else if (obj_type == 'event_badge') {
endpoint = `/crud/event/badge/list`;
} else if (obj_type == 'event_device') {
endpoint = `/crud/event/device/list`;
} else if (obj_type == 'event_exhibit') {
endpoint = `/crud/event/exhibit/list`;
} else if (obj_type == 'event_exhibit_tracking') {
endpoint = `/crud/event/exhibit/tracking/list`;
} else if (obj_type == 'event_file') {
endpoint = `/crud/event/file/list`;
} else if (obj_type == 'event_location') {
endpoint = `/crud/event/location/list`;
} else if (obj_type == 'event_person') {
endpoint = `/crud/event/person/list`;
} else if (obj_type == 'event_presentation') {
endpoint = `/crud/event/presentation/list`;
} else if (obj_type == 'event_presenter') {
endpoint = `/crud/event/presenter/list`;
} else if (obj_type == 'event_session') {
endpoint = `/crud/event/session/list`;
} else if (obj_type == 'event_track') {
endpoint = `/crud/event/track/list`;
} else if (obj_type == 'grant') {
endpoint = `/crud/grant/list`;
} else if (obj_type == 'hosted_file') {
endpoint = `/crud/hosted_file/list`;
} else if (obj_type == 'journal') {
endpoint = `/crud/journal/list`;
} else if (obj_type == 'journal_entry') {
endpoint = `/crud/journal/entry/list`;
} else if (obj_type == 'order') {
endpoint = `/crud/order/list`;
} else if (obj_type == 'order_line') {
endpoint = `/crud/order/line/list`;
} else if (obj_type == 'page') {
endpoint = `/crud/page/list`;
} else if (obj_type == 'person') {
endpoint = `/crud/person/list`;
} else if (obj_type == 'post') {
endpoint = `/crud/post/list`;
} else if (obj_type == 'post_comment') {
endpoint = `/crud/post/comment/list`;
} else if (obj_type == 'site') {
endpoint = `/crud/site/list`;
} else if (obj_type == 'sponsorship_cfg') {
endpoint = `/crud/sponsorship/cfg/list`;
} else if (obj_type == 'sponsorship') {
endpoint = `/crud/sponsorship/list`;
// } else if (obj_type == 'user') {
// endpoint = `/crud/user/list`;
} else if (obj_type == 'lu' && for_obj_type == 'country_subdivision') {
endpoint = `/crud/lu/country_subdivision/list`;
for_obj_type = null;
} else if (obj_type == 'lu' && for_obj_type == 'country') {
endpoint = `/crud/lu/country/list`;
for_obj_type = null;
} else if (obj_type == 'lu' && for_obj_type == 'time_zone') {
endpoint = `/crud/lu/time_zone/list`;
for_obj_type = null;
} else {
console.log(`Unknown object type: ${obj_type}`);
return false;
}
if (log_lvl) {
console.log('Endpoint:', endpoint);
}
let endpoint = '';
if (obj_type == 'account') {
endpoint = `/crud/account/list`;
} else if (obj_type == 'address') {
endpoint = `/crud/address/list`;
} else if (obj_type == 'archive') {
endpoint = `/crud/archive/list`;
} else if (obj_type == 'archive_content') {
endpoint = `/crud/archive/content/list`;
} else if (obj_type == 'contact') {
endpoint = `/crud/contact/list`;
} else if (obj_type == 'data_store') {
endpoint = `/crud/data_store/list`;
} else if (obj_type == 'event') {
endpoint = `/crud/event/list`;
} else if (obj_type == 'event_abstract') {
endpoint = `/crud/event/abstract/list`;
} else if (obj_type == 'event_badge') {
endpoint = `/crud/event/badge/list`;
} else if (obj_type == 'event_device') {
endpoint = `/crud/event/device/list`;
} else if (obj_type == 'event_exhibit') {
endpoint = `/crud/event/exhibit/list`;
} else if (obj_type == 'event_exhibit_tracking') {
endpoint = `/crud/event/exhibit/tracking/list`;
} else if (obj_type == 'event_file') {
endpoint = `/crud/event/file/list`;
} else if (obj_type == 'event_location') {
endpoint = `/crud/event/location/list`;
} else if (obj_type == 'event_person') {
endpoint = `/crud/event/person/list`;
} else if (obj_type == 'event_presentation') {
endpoint = `/crud/event/presentation/list`;
} else if (obj_type == 'event_presenter') {
endpoint = `/crud/event/presenter/list`;
} else if (obj_type == 'event_session') {
endpoint = `/crud/event/session/list`;
} else if (obj_type == 'event_track') {
endpoint = `/crud/event/track/list`;
} else if (obj_type == 'grant') {
endpoint = `/crud/grant/list`;
} else if (obj_type == 'hosted_file') {
endpoint = `/crud/hosted_file/list`;
} else if (obj_type == 'journal') {
endpoint = `/crud/journal/list`;
} else if (obj_type == 'journal_entry') {
endpoint = `/crud/journal/entry/list`;
} else if (obj_type == 'order') {
endpoint = `/crud/order/list`;
} else if (obj_type == 'order_line') {
endpoint = `/crud/order/line/list`;
} else if (obj_type == 'page') {
endpoint = `/crud/page/list`;
} else if (obj_type == 'person') {
endpoint = `/crud/person/list`;
} else if (obj_type == 'post') {
endpoint = `/crud/post/list`;
} else if (obj_type == 'post_comment') {
endpoint = `/crud/post/comment/list`;
} else if (obj_type == 'site') {
endpoint = `/crud/site/list`;
} else if (obj_type == 'sponsorship_cfg') {
endpoint = `/crud/sponsorship/cfg/list`;
} else if (obj_type == 'sponsorship') {
endpoint = `/crud/sponsorship/list`;
// } else if (obj_type == 'user') {
// endpoint = `/crud/user/list`;
} else if (obj_type == 'lu' && for_obj_type == 'country_subdivision') {
endpoint = `/crud/lu/country_subdivision/list`;
for_obj_type = null;
} else if (obj_type == 'lu' && for_obj_type == 'country') {
endpoint = `/crud/lu/country/list`;
for_obj_type = null;
} else if (obj_type == 'lu' && for_obj_type == 'time_zone') {
endpoint = `/crud/lu/time_zone/list`;
for_obj_type = null;
} else {
console.log(`Unknown object type: ${obj_type}`);
return false;
}
if (log_lvl) {
console.log('Endpoint:', endpoint);
}
if (for_obj_type) {
params['for_obj_type'] = for_obj_type;
}
if (for_obj_id) {
params['for_obj_id'] = for_obj_id;
}
if (for_obj_type) {
params['for_obj_type'] = for_obj_type;
}
if (for_obj_id) {
params['for_obj_id'] = for_obj_id;
}
params['use_alt_table'] = use_alt_table;
params['use_alt_base'] = use_alt_base;
params['use_alt_table'] = use_alt_table;
params['use_alt_base'] = use_alt_base;
/* Need to deal with inc params here */
/* Need to deal with inc params here */
const allowed_enabled_list = ['all', 'enabled', 'not_enabled'];
if (allowed_enabled_list.includes(enabled)) {
params['enabled'] = enabled;
}
const allowed_enabled_list = ['all', 'enabled', 'not_enabled'];
if (allowed_enabled_list.includes(enabled)) {
params['enabled'] = enabled;
}
const allowed_hidden_list = ['all', 'hidden', 'not_hidden'];
if (allowed_hidden_list.includes(hidden)) {
params['hidden'] = hidden;
}
const allowed_hidden_list = ['all', 'hidden', 'not_hidden'];
if (allowed_hidden_list.includes(hidden)) {
params['hidden'] = hidden;
}
// NOTE: The order_by_li variable is in the "headers" because if is a the URL GET params do not handle multiple values very well. Maybe base64 encore in the future or something? Reminder that GET requests should not have a body (no JSON).
// NOTE: The order_by_li should be a key value pair of the property/DB field to sort and how to sort (ASC or DESC)
if (order_by_li) {
if (log_lvl) {
console.log('Order By:', order_by_li);
}
headers['order_by_li'] = order_by_li;
}
// NOTE: The order_by_li variable is in the "headers" because if is a the URL GET params do not handle multiple values very well. Maybe base64 encore in the future or something? Reminder that GET requests should not have a body (no JSON).
// NOTE: The order_by_li should be a key value pair of the property/DB field to sort and how to sort (ASC or DESC)
if (order_by_li) {
if (log_lvl) {
console.log('Order By:', order_by_li);
}
headers['order_by_li'] = order_by_li;
}
if (limit >= 0) {
params['limit'] = limit;
}
if (limit >= 0) {
params['limit'] = limit;
}
if (offset >= 0) {
params['offset'] = offset;
}
if (offset >= 0) {
params['offset'] = offset;
}
if (params_json) {
// NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the search endpoint.
// Max characters for a GET request is 2083. This is a limitation of the browser (Microsoft IE and Edge).
if (log_lvl) {
console.log('JSON Object:', params_json);
console.log(JSON.stringify(params_json));
}
// NOTE: "jp" stands for "JSON Params"
params['jp'] = encodeURIComponent(JSON.stringify(params_json));
if (params['jp'].length > 2083) {
console.log(
`The JSON object is too large to be used as a GET parameter. The overall max URL length is 2083 characters. Please use the POST endpoint instead. Length = ${params['jp'].length} [THIS DOES NOT EXIST YET]`
);
return false;
}
}
if (params_json) {
// NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the search endpoint.
// Max characters for a GET request is 2083. This is a limitation of the browser (Microsoft IE and Edge).
if (log_lvl) {
console.log('JSON Object:', params_json);
console.log(JSON.stringify(params_json));
}
// NOTE: "jp" stands for "JSON Params"
params['jp'] = encodeURIComponent(JSON.stringify(params_json));
if (params['jp'].length > 2083) {
console.log(
`The JSON object is too large to be used as a GET parameter. The overall max URL length is 2083 characters. Please use the POST endpoint instead. Length = ${params['jp'].length} [THIS DOES NOT EXIST YET]`
);
return false;
}
}
// if (json_obj) {
// // NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the search endpoint.
// // Max characters for a GET request is 2083. This is a limitation of the browser (Microsoft IE and Edge).
// console.log('JSON Object:', json_obj);
// params['json_str'] = encodeURIComponent(JSON.stringify(json_obj));
// if (params['json_str'].length > 2083) {
// console.log(`The JSON object is too large to be used as a GET parameter. The overall max URL length is 2083 characters. Please use the POST endpoint instead. Length = ${params['json_str'].length} [THIS DOES NOT EXIST YET]`);
// return false;
// }
// }
// if (json_obj) {
// // NOTE: This is a JSON object that needs to be safely converted to a string for the params. This is used for the search endpoint.
// // Max characters for a GET request is 2083. This is a limitation of the browser (Microsoft IE and Edge).
// console.log('JSON Object:', json_obj);
// params['json_str'] = encodeURIComponent(JSON.stringify(json_obj));
// if (params['json_str'].length > 2083) {
// console.log(`The JSON object is too large to be used as a GET parameter. The overall max URL length is 2083 characters. Please use the POST endpoint instead. Length = ${params['json_str'].length} [THIS DOES NOT EXIST YET]`);
// return false;
// }
// }
if (log_lvl) {
console.log('Params:', params);
}
if (log_lvl) {
console.log('Params:', params);
}
const object_li_get_promise = await get_object({
api_cfg: api_cfg,
endpoint: endpoint,
headers: headers,
params: params,
return_meta: return_meta,
log_lvl: log_lvl
});
const object_li_get_promise = await get_object({
api_cfg: api_cfg,
endpoint: endpoint,
headers: headers,
params: params,
return_meta: return_meta,
log_lvl: log_lvl
});
if (log_lvl > 1) {
console.log(object_li_get_promise);
}
if (log_lvl > 1) {
console.log(object_li_get_promise);
}
return object_li_get_promise;
return object_li_get_promise;
}

View File

@@ -3,172 +3,172 @@ import { get_object } from './api_get_object';
// Refactored 2025-11-13 to use a lookup map for endpoints.
const objTypeToEndpointMap: Record<string, string> = {
account: '/crud/account/list',
address: '/crud/address/list',
archive: '/crud/archive/list',
archive_content: '/crud/archive/content/list',
contact: '/crud/contact/list',
data_store: '/crud/data_store/list',
event: '/crud/event/list',
event_abstract: '/crud/event/abstract/list',
event_badge: '/crud/event/badge/list',
event_badge_template: '/crud/event/badge/template/list',
event_device: '/crud/event/device/list',
event_exhibit: '/crud/event/exhibit/list',
event_exhibit_tracking: '/crud/event/exhibit/tracking/list',
event_file: '/crud/event/file/list',
event_location: '/crud/event/location/list',
event_person: '/crud/event/person/list',
event_presentation: '/crud/event/presentation/list',
event_presenter: '/crud/event/presenter/list',
event_session: '/crud/event/session/list',
event_track: '/crud/event/track/list',
grant: '/crud/grant/list',
hosted_file: '/crud/hosted_file/list',
journal: '/crud/journal/list',
journal_entry: '/crud/journal/entry/list',
order: '/crud/order/list',
order_line: '/crud/order/line/list',
page: '/crud/page/list',
person: '/crud/person/list',
post: '/crud/post/list',
post_comment: '/crud/post/comment/list',
site: '/crud/site/list',
sponsorship_cfg: '/crud/sponsorship/cfg/list',
sponsorship: '/crud/sponsorship/list',
// user: '/crud/user/list',
'lu-country_subdivision': '/crud/lu/country_subdivision/list',
'lu-country': '/crud/lu/country/list',
'lu-time_zone': '/crud/lu/time_zone/list'
account: '/crud/account/list',
address: '/crud/address/list',
archive: '/crud/archive/list',
archive_content: '/crud/archive/content/list',
contact: '/crud/contact/list',
data_store: '/crud/data_store/list',
event: '/crud/event/list',
event_abstract: '/crud/event/abstract/list',
event_badge: '/crud/event/badge/list',
event_badge_template: '/crud/event/badge/template/list',
event_device: '/crud/event/device/list',
event_exhibit: '/crud/event/exhibit/list',
event_exhibit_tracking: '/crud/event/exhibit/tracking/list',
event_file: '/crud/event/file/list',
event_location: '/crud/event/location/list',
event_person: '/crud/event/person/list',
event_presentation: '/crud/event/presentation/list',
event_presenter: '/crud/event/presenter/list',
event_session: '/crud/event/session/list',
event_track: '/crud/event/track/list',
grant: '/crud/grant/list',
hosted_file: '/crud/hosted_file/list',
journal: '/crud/journal/list',
journal_entry: '/crud/journal/entry/list',
order: '/crud/order/list',
order_line: '/crud/order/line/list',
page: '/crud/page/list',
person: '/crud/person/list',
post: '/crud/post/list',
post_comment: '/crud/post/comment/list',
site: '/crud/site/list',
sponsorship_cfg: '/crud/sponsorship/cfg/list',
sponsorship: '/crud/sponsorship/list',
// user: '/crud/user/list',
'lu-country_subdivision': '/crud/lu/country_subdivision/list',
'lu-country': '/crud/lu/country/list',
'lu-time_zone': '/crud/lu/time_zone/list'
};
function getEndpointForObjType(obj_type: string, for_obj_type?: string): string {
if (obj_type === 'lu' && for_obj_type) {
const key = `lu-${for_obj_type}`;
const endpoint = objTypeToEndpointMap[key];
if (endpoint) return endpoint;
}
if (obj_type === 'lu' && for_obj_type) {
const key = `lu-${for_obj_type}`;
const endpoint = objTypeToEndpointMap[key];
if (endpoint) return endpoint;
}
const endpoint = objTypeToEndpointMap[obj_type];
if (endpoint) return endpoint;
const endpoint = objTypeToEndpointMap[obj_type];
if (endpoint) return endpoint;
throw new Error(`Unknown object type: ${obj_type}`);
throw new Error(`Unknown object type: ${obj_type}`);
}
type OrderBy = { [key: string]: 'ASC' | 'DESC' };
interface GetAeObjLiForObjIdCrudV2Params {
api_cfg: any; // Consider defining a specific type for api_cfg
obj_type: string;
for_obj_type: string;
for_obj_id?: string;
use_alt_tbl?: boolean | string;
use_alt_mdl?: boolean | string;
use_alt_exp?: boolean | string;
inc?: key_val;
enabled?: 'all' | 'enabled' | 'not_enabled';
hidden?: 'all' | 'hidden' | 'not_hidden';
order_by_li?: OrderBy[] | null;
limit?: number;
offset?: number;
headers?: Record<string, string>;
params_json?: any;
params?: key_val;
log_lvl?: number;
api_cfg: any; // Consider defining a specific type for api_cfg
obj_type: string;
for_obj_type: string;
for_obj_id?: string;
use_alt_tbl?: boolean | string;
use_alt_mdl?: boolean | string;
use_alt_exp?: boolean | string;
inc?: key_val;
enabled?: 'all' | 'enabled' | 'not_enabled';
hidden?: 'all' | 'hidden' | 'not_hidden';
order_by_li?: OrderBy[] | null;
limit?: number;
offset?: number;
headers?: Record<string, string>;
params_json?: any;
params?: key_val;
log_lvl?: number;
}
export async function get_ae_obj_li_for_obj_id_crud_v2({
api_cfg,
obj_type,
for_obj_type,
for_obj_id,
use_alt_tbl = false,
use_alt_mdl = false,
use_alt_exp = false,
enabled = 'enabled',
hidden = 'not_hidden',
order_by_li = null,
limit = 999999,
offset = 0,
headers = {},
params_json = null,
params = {},
log_lvl = 0
api_cfg,
obj_type,
for_obj_type,
for_obj_id,
use_alt_tbl = false,
use_alt_mdl = false,
use_alt_exp = false,
enabled = 'enabled',
hidden = 'not_hidden',
order_by_li = null,
limit = 999999,
offset = 0,
headers = {},
params_json = null,
params = {},
log_lvl = 0
}: GetAeObjLiForObjIdCrudV2Params) {
if (log_lvl) {
console.log('*** get_ae_obj_li_for_obj_id_crud_v2() ***');
}
if (log_lvl) {
console.log('*** get_ae_obj_li_for_obj_id_crud_v2() ***');
}
try {
const endpoint = `/v2${getEndpointForObjType(obj_type, for_obj_type)}`;
if (log_lvl) {
console.log('Endpoint:', endpoint);
}
try {
const endpoint = `/v2${getEndpointForObjType(obj_type, for_obj_type)}`;
if (log_lvl) {
console.log('Endpoint:', endpoint);
}
// We need to remove a few parameters from the params object that are not allowed.
delete params['qry__enabled'];
delete params['qry__hidden'];
delete params['qry__limit'];
delete params['qry__offset'];
// We need to remove a few parameters from the params object that are not allowed.
delete params['qry__enabled'];
delete params['qry__hidden'];
delete params['qry__limit'];
delete params['qry__offset'];
if (for_obj_type) params['for_obj_type'] = for_obj_type;
if (for_obj_id) params['for_obj_id'] = for_obj_id;
if (for_obj_type) params['for_obj_type'] = for_obj_type;
if (for_obj_id) params['for_obj_id'] = for_obj_id;
if (use_alt_tbl === true) params['tbl_alt'] = 'alt';
if (use_alt_mdl === true) params['mdl_alt'] = 'alt';
if (use_alt_exp === true) params['exp_alt'] = 'alt';
if (use_alt_tbl === true) params['tbl_alt'] = 'alt';
if (use_alt_mdl === true) params['mdl_alt'] = 'alt';
if (use_alt_exp === true) params['exp_alt'] = 'alt';
const allowed_enabled_list = ['all', 'enabled', 'not_enabled'];
if (allowed_enabled_list.includes(enabled)) {
params['enabled'] = enabled;
}
const allowed_enabled_list = ['all', 'enabled', 'not_enabled'];
if (allowed_enabled_list.includes(enabled)) {
params['enabled'] = enabled;
}
const allowed_hidden_list = ['all', 'hidden', 'not_hidden'];
if (allowed_hidden_list.includes(hidden)) {
params['hidden'] = hidden;
}
const allowed_hidden_list = ['all', 'hidden', 'not_hidden'];
if (allowed_hidden_list.includes(hidden)) {
params['hidden'] = hidden;
}
// NOTE: The order_by_li variable is in the "headers" because URL GET params do not handle complex objects very well.
if (order_by_li) {
headers['order_by_li'] = JSON.stringify(order_by_li);
}
// NOTE: The order_by_li variable is in the "headers" because URL GET params do not handle complex objects very well.
if (order_by_li) {
headers['order_by_li'] = JSON.stringify(order_by_li);
}
if (limit > 0) params['limit'] = limit;
if (offset > 0) params['offset'] = offset;
if (limit > 0) params['limit'] = limit;
if (offset > 0) params['offset'] = offset;
if (params_json) {
// NOTE: "jp" stands for "JSON Params". This is a JSON object that needs to be safely converted to a string for the params.
// Max characters for a GET request is ~2000. This is a limitation of the browser.
const json_params_str = encodeURIComponent(JSON.stringify(params_json));
if (json_params_str.length > 2083) {
// Using console.error instead of throwing an error to avoid crashing the app for a known limitation.
console.error(
`The JSON object is too large to be used as a GET parameter. Max length is 2083 characters. Length = ${json_params_str.length}`
);
return false;
}
params['jp'] = json_params_str;
}
if (params_json) {
// NOTE: "jp" stands for "JSON Params". This is a JSON object that needs to be safely converted to a string for the params.
// Max characters for a GET request is ~2000. This is a limitation of the browser.
const json_params_str = encodeURIComponent(JSON.stringify(params_json));
if (json_params_str.length > 2083) {
// Using console.error instead of throwing an error to avoid crashing the app for a known limitation.
console.error(
`The JSON object is too large to be used as a GET parameter. Max length is 2083 characters. Length = ${json_params_str.length}`
);
return false;
}
params['jp'] = json_params_str;
}
if (log_lvl) {
console.log('Params:', params);
}
if (log_lvl) {
console.log('Params:', params);
}
const object_li_get_promise = await get_object({
api_cfg: api_cfg,
endpoint: endpoint,
headers: headers,
params: params,
log_lvl: log_lvl
});
const object_li_get_promise = await get_object({
api_cfg: api_cfg,
endpoint: endpoint,
headers: headers,
params: params,
log_lvl: log_lvl
});
if (log_lvl > 1) {
console.log(object_li_get_promise);
}
if (log_lvl > 1) {
console.log(object_li_get_promise);
}
return object_li_get_promise;
} catch (error) {
console.error('Error in get_ae_obj_li_for_obj_id_crud_v2:', error);
return false; // Or handle the error as appropriate
}
return object_li_get_promise;
} catch (error) {
console.error('Error in get_ae_obj_li_for_obj_id_crud_v2:', error);
return false; // Or handle the error as appropriate
}
}

View File

@@ -7,230 +7,230 @@ export const temp_get_object_percent_completed = 0;
export const get_object_percent_completed = temp_get_object_percent_completed;
export const get_object = async function get_object({
api_cfg = null,
endpoint = '',
headers = {},
params = {},
data = {},
timeout = 60000,
return_meta = false,
return_blob = false,
filename = '',
auto_download = false,
as_list = false, // Is this still really needed?
// The task_id value should be a random string that is unique to the task. This is used to identify the task in the message event.
task_id = crypto.randomUUID(),
log_lvl = 0,
retry_count = 5 // Number of retry attempts
api_cfg = null,
endpoint = '',
headers = {},
params = {},
data = {},
timeout = 60000,
return_meta = false,
return_blob = false,
filename = '',
auto_download = false,
as_list = false, // Is this still really needed?
// The task_id value should be a random string that is unique to the task. This is used to identify the task in the message event.
task_id = crypto.randomUUID(),
log_lvl = 0,
retry_count = 5 // Number of retry attempts
}: {
api_cfg: any;
endpoint: string;
headers?: any;
params?: any;
data?: any;
timeout?: number;
return_meta?: boolean;
return_blob?: boolean;
filename?: null | string;
auto_download?: boolean;
as_list?: boolean;
task_id?: string;
log_lvl?: number;
retry_count?: number;
api_cfg: any;
endpoint: string;
headers?: any;
params?: any;
data?: any;
timeout?: number;
return_meta?: boolean;
return_blob?: boolean;
filename?: null | string;
auto_download?: boolean;
as_list?: boolean;
task_id?: string;
log_lvl?: number;
retry_count?: number;
}) {
if (log_lvl) {
console.log(`*** get_object() *** Endpoint: ${endpoint} AE Task ID: ${task_id}`);
console.log('Params:', params);
if (log_lvl > 1) {
console.log('Data:', data);
}
}
if (log_lvl) {
console.log(`*** get_object() *** Endpoint: ${endpoint} AE Task ID: ${task_id}`);
console.log('Params:', params);
if (log_lvl > 1) {
console.log('Data:', data);
}
}
if (!api_cfg) {
console.log('No API Config was provided. Returning false.');
return false;
}
if (!api_cfg) {
console.log('No API Config was provided. Returning false.');
return false;
}
const url = new URL(endpoint, api_cfg['base_url']);
Object.keys(params).forEach((key) => url.searchParams.append(key, params[key]));
const url = new URL(endpoint, api_cfg['base_url']);
Object.keys(params).forEach((key) => url.searchParams.append(key, params[key]));
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), timeout);
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), timeout);
// Remove a header parameter if it is set to null
if (
api_cfg['headers'].hasOwnProperty('x-no-account-id') &&
api_cfg['headers']['x-no-account-id'] === null
) {
delete api_cfg['headers']['x-no-account-id'];
}
// Remove a header parameter if it is set to null
if (
api_cfg['headers'].hasOwnProperty('x-no-account-id') &&
api_cfg['headers']['x-no-account-id'] === null
) {
delete api_cfg['headers']['x-no-account-id'];
}
// Clean the headers
const headers_cleaned: key_val = {};
for (const prop in headers) {
const prop_cleaned = prop.replaceAll('_', '-');
if (typeof headers[prop] != 'string') {
headers[prop] = JSON.stringify(headers[prop]);
}
headers_cleaned[prop_cleaned] = headers[prop];
if (log_lvl > 1) {
console.log(`${prop_cleaned}: ${headers_cleaned[prop_cleaned]}`);
}
}
headers = headers_cleaned;
if (log_lvl > 1) {
console.log('All headers cleaned:', headers);
}
// Clean the headers
const headers_cleaned: key_val = {};
for (const prop in headers) {
const prop_cleaned = prop.replaceAll('_', '-');
if (typeof headers[prop] != 'string') {
headers[prop] = JSON.stringify(headers[prop]);
}
headers_cleaned[prop_cleaned] = headers[prop];
if (log_lvl > 1) {
console.log(`${prop_cleaned}: ${headers_cleaned[prop_cleaned]}`);
}
}
headers = headers_cleaned;
if (log_lvl > 1) {
console.log('All headers cleaned:', headers);
}
const fetchOptions: RequestInit = {
method: 'GET',
headers: {
...api_cfg['headers'],
...headers
},
signal: controller.signal
};
const fetchOptions: RequestInit = {
method: 'GET',
headers: {
...api_cfg['headers'],
...headers
},
signal: controller.signal
};
if (log_lvl > 1) {
console.log('Fetch options:', fetchOptions);
}
if (log_lvl > 1) {
console.log('Fetch options:', fetchOptions);
}
let fetch_method: any = fetch;
if (api_cfg.fetch) {
if (log_lvl > 1) {
console.log('Using custom fetch function from api_cfg!!!');
}
fetch_method = api_cfg.fetch;
}
let fetch_method: any = fetch;
if (api_cfg.fetch) {
if (log_lvl > 1) {
console.log('Using custom fetch function from api_cfg!!!');
}
fetch_method = api_cfg.fetch;
}
for (let attempt = 1; attempt <= retry_count; attempt++) {
try {
const response = await fetch_method(url.toString(), fetchOptions).catch(function (
error: any
) {
console.log(
'API GET Object *fetch* request was aborted or failed in an unexpected way.',
error
);
});
clearTimeout(timeoutId);
for (let attempt = 1; attempt <= retry_count; attempt++) {
try {
const response = await fetch_method(url.toString(), fetchOptions).catch(function (
error: any
) {
console.log(
'API GET Object *fetch* request was aborted or failed in an unexpected way.',
error
);
});
clearTimeout(timeoutId);
if (!response) {
if (log_lvl > 1) {
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
}
if (!response) {
if (log_lvl > 1) {
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
}
if (log_lvl) {
console.log(
`Response: status=${response.status} statusText=${response.statusText} url=${response.url} attempt=${attempt}`
);
}
if (log_lvl > 1) {
console.log('Response:', response);
}
if (log_lvl) {
console.log(
`Response: status=${response.status} statusText=${response.statusText} url=${response.url} attempt=${attempt}`
);
}
if (log_lvl > 1) {
console.log('Response:', response);
}
if (!response.ok) {
if (response.status === 404) {
if (log_lvl) {
console.log('The response was a 404 not found "error". Returning null.');
}
return null;
}
console.log('The response was not ok. Throwing an error!');
throw new Error(`HTTP error! status: ${response.status}`);
}
if (!response.ok) {
if (response.status === 404) {
if (log_lvl) {
console.log('The response was a 404 not found "error". Returning null.');
}
return null;
}
console.log('The response was not ok. Throwing an error!');
throw new Error(`HTTP error! status: ${response.status}`);
}
if (!return_blob) {
const json = await response.json();
if (log_lvl > 1) {
console.log('Response JSON:', json);
}
if (!Array.isArray(json.data) && as_list) {
return [json.data];
}
return json.data || json;
} else {
const reader = response.body?.getReader();
const contentLength = +response.headers.get('Content-Length')!;
let receivedLength = 0;
const chunks = [];
if (!return_blob) {
const json = await response.json();
if (log_lvl > 1) {
console.log('Response JSON:', json);
}
if (!Array.isArray(json.data) && as_list) {
return [json.data];
}
return json.data || json;
} else {
const reader = response.body?.getReader();
const contentLength = +response.headers.get('Content-Length')!;
let receivedLength = 0;
const chunks = [];
while (true) {
const { done, value } = await reader!.read();
if (done) break;
chunks.push(value);
receivedLength += value.length;
while (true) {
const { done, value } = await reader!.read();
if (done) break;
chunks.push(value);
receivedLength += value.length;
const percent_completed = Math.round((receivedLength * 100) / contentLength);
if (log_lvl > 1) {
console.log(
'GET Blob Progress:',
percent_completed,
'Total:',
contentLength,
'Loaded:',
receivedLength,
'Percent Completed',
percent_completed
);
}
const percent_completed = Math.round((receivedLength * 100) / contentLength);
if (log_lvl > 1) {
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 {
if (typeof window !== 'undefined') {
window.postMessage(
{
type: 'api_download_blob',
status: 'downloading',
task_id: task_id,
endpoint: endpoint,
filename: filename,
size_total: contentLength,
size_loaded: receivedLength,
percent_completed: percent_completed
},
'*'
);
}
} catch (e) {
console.error('Error posting message:', e);
}
}
try {
if (typeof window !== 'undefined') {
window.postMessage(
{
type: 'api_download_blob',
status: 'downloading',
task_id: task_id,
endpoint: endpoint,
filename: filename,
size_total: contentLength,
size_loaded: receivedLength,
percent_completed: percent_completed
},
'*'
);
}
} catch (e) {
console.error('Error posting message:', e);
}
}
const blob = new Blob(chunks);
if (auto_download) {
const downloadUrl = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = downloadUrl;
link.setAttribute('download', filename || 'download');
document.body.appendChild(link);
link.click();
link.remove();
return true;
} else {
return blob;
}
}
} catch (error) {
console.log(`API GET object request *fetch* error on attempt ${attempt}:`, error);
const blob = new Blob(chunks);
if (auto_download) {
const downloadUrl = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = downloadUrl;
link.setAttribute('download', filename || 'download');
document.body.appendChild(link);
link.click();
link.remove();
return true;
} else {
return blob;
}
}
} catch (error) {
console.log(`API GET object request *fetch* error on attempt ${attempt}:`, error);
if (attempt === retry_count) {
console.log('Max retry attempts reached. Returning false.');
return false;
}
if (attempt === retry_count) {
console.log('Max retry attempts reached. Returning false.');
return false;
}
// Log retry information
if (log_lvl) {
console.log(`Retrying... (${attempt}/${retry_count})`);
}
}
}
// Log retry information
if (log_lvl) {
console.log(`Retrying... (${attempt}/${retry_count})`);
}
}
}
};

View File

@@ -12,509 +12,515 @@ export const get_object_percent_completed = temp_get_object_percent_completed;
// Updated 2024-05-23
export const get_object = async function get_object({
api_cfg = null,
endpoint = '',
headers = {},
params = {},
data = {},
timeout = 60000,
return_meta = false,
return_blob = false,
filename = '',
auto_download = false,
as_list = false,
// The task_id value should be a random string that is unique to the task. This is used to identify the task in the message event.
task_id = crypto.randomUUID(),
log_lvl = 0
api_cfg = null,
endpoint = '',
headers = {},
params = {},
data = {},
timeout = 60000,
return_meta = false,
return_blob = false,
filename = '',
auto_download = false,
as_list = false,
// The task_id value should be a random string that is unique to the task. This is used to identify the task in the message event.
task_id = crypto.randomUUID(),
log_lvl = 0
}: {
api_cfg: any;
endpoint: string;
headers?: any;
params?: any;
data?: any;
timeout?: number;
return_meta?: boolean;
return_blob?: boolean;
filename?: null | string;
auto_download?: boolean;
as_list?: boolean;
task_id?: string;
log_lvl?: number;
api_cfg: any;
endpoint: string;
headers?: any;
params?: any;
data?: any;
timeout?: number;
return_meta?: boolean;
return_blob?: boolean;
filename?: null | string;
auto_download?: boolean;
as_list?: boolean;
task_id?: string;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** get_object() *** Endpoint: ${endpoint} AE Task ID: ${task_id}`);
console.log('Params:', params);
if (log_lvl > 1) {
console.log('Data:', data);
console.log(`Base URL: ${api_cfg['base_url']}; Timeout: ${timeout}`);
console.log('API Config:', api_cfg);
}
if (log_lvl > 2) {
console.log(
`Return Meta: ${return_meta}; Return Blob: ${return_blob}; Filename: ${filename}; Auto Download: ${auto_download}`
);
}
}
if (log_lvl) {
console.log(`*** get_object() *** Endpoint: ${endpoint} AE Task ID: ${task_id}`);
console.log('Params:', params);
if (log_lvl > 1) {
console.log('Data:', data);
console.log(`Base URL: ${api_cfg['base_url']}; Timeout: ${timeout}`);
console.log('API Config:', api_cfg);
}
if (log_lvl > 2) {
console.log(
`Return Meta: ${return_meta}; Return Blob: ${return_blob}; Filename: ${filename}; Auto Download: ${auto_download}`
);
}
}
if (!api_cfg) {
console.log('No API Config was provided. Returning false.');
return false;
}
if (!api_cfg) {
console.log('No API Config was provided. Returning false.');
return false;
}
const axios_api = axios.create({
baseURL: api_cfg['base_url'],
timeout: timeout // in milliseconds; 60000 = 60 seconds
/* other custom settings */
});
axios_api.defaults.headers = api_cfg['headers'];
if (log_lvl) {
console.log('axios_api.defaults.headers:', axios_api.defaults.headers);
console.log('Additional headers:', headers);
}
const axios_api = axios.create({
baseURL: api_cfg['base_url'],
timeout: timeout // in milliseconds; 60000 = 60 seconds
/* other custom settings */
});
axios_api.defaults.headers = api_cfg['headers'];
if (log_lvl) {
console.log('axios_api.defaults.headers:', axios_api.defaults.headers);
console.log('Additional headers:', headers);
}
// console.log('Clean the headers. No _underscores_!')
const headers_cleaned: key_val = {};
for (const prop in headers) {
// No underscores allowed in the header parameters!
const prop_cleaned = prop.replaceAll('_', '-');
// console.log('Clean the headers. No _underscores_!')
const headers_cleaned: key_val = {};
for (const prop in headers) {
// No underscores allowed in the header parameters!
const prop_cleaned = prop.replaceAll('_', '-');
// The value must be a string for the header!
if (typeof headers[prop] != 'string') {
headers[prop] = JSON.stringify(headers[prop]);
}
// The value must be a string for the header!
if (typeof headers[prop] != 'string') {
headers[prop] = JSON.stringify(headers[prop]);
}
headers_cleaned[prop_cleaned] = headers[prop];
headers_cleaned[prop_cleaned] = headers[prop];
if (log_lvl) {
console.log(`${prop_cleaned}: ${headers_cleaned[prop_cleaned]}`);
}
}
headers = headers_cleaned;
if (log_lvl) {
console.log('All headers cleaned:', headers);
}
if (log_lvl) {
console.log(`${prop_cleaned}: ${headers_cleaned[prop_cleaned]}`);
}
}
headers = headers_cleaned;
if (log_lvl) {
console.log('All headers cleaned:', headers);
}
if (log_lvl) {
console.log('URL params:');
}
for (const prop in params) {
if (log_lvl > 1) {
console.log(`URL param: ${prop}: ${params[prop]}`);
}
if (params[prop] === null) {
params[prop] = 'null';
}
}
if (log_lvl) {
console.log('URL params:');
}
for (const prop in params) {
if (log_lvl > 1) {
console.log(`URL param: ${prop}: ${params[prop]}`);
}
if (params[prop] === null) {
params[prop] = 'null';
}
}
// Handle the case where there is no Blob expected to be returned. Mainly JSON and text data.
if (!return_blob) {
const response_data_promise = await axios_api
.get(endpoint, {
headers: headers,
params: params,
onDownloadProgress: (progressEvent) => {
const percent_completed = Math.round((progressEvent.loaded * 100) / progressEvent.total);
if (log_lvl > 1) {
console.log(
'GET Data Progress:',
progressEvent.progress,
'Total:',
progressEvent.total,
'Loaded:',
progressEvent.loaded,
'Percent Completed',
percent_completed
);
}
// Handle the case where there is no Blob expected to be returned. Mainly JSON and text data.
if (!return_blob) {
const response_data_promise = await axios_api
.get(endpoint, {
headers: headers,
params: params,
onDownloadProgress: (progressEvent) => {
const percent_completed = Math.round(
(progressEvent.loaded * 100) / progressEvent.total
);
if (log_lvl > 1) {
console.log(
'GET Data Progress:',
progressEvent.progress,
'Total:',
progressEvent.total,
'Loaded:',
progressEvent.loaded,
'Percent Completed',
percent_completed
);
}
temp_get_object_percent_completed = percent_completed;
temp_get_object_percent_completed = percent_completed;
// WARNING: This needs to be tied to an object type and ID. This is a temporary solution.
try {
// Check if window is defined. This is to prevent errors in SvelteKit.
if (typeof window !== 'undefined') {
window.postMessage(
{
type: 'api_download_data',
status: 'downloading',
task_id: task_id,
endpoint: endpoint,
filename: filename,
size_total: progressEvent.total,
size_loaded: progressEvent.loaded,
percent_completed: percent_completed
},
'*'
);
}
} catch (error) {
console.log('Error posting message to window:', error);
}
}
})
.then(function (response) {
if (log_lvl) {
console.log(
`GET Response: status=${response.status} statusText=${response.statusText} baseURL=${response.config.baseURL} url=${response.config.url} method=${response.config.method} headers=${response.config.headers} params=${JSON.stringify(response.config.params)}`
);
}
if (log_lvl > 1) {
console.log('GET Response:', response);
}
// WARNING: This needs to be tied to an object type and ID. This is a temporary solution.
try {
// Check if window is defined. This is to prevent errors in SvelteKit.
if (typeof window !== 'undefined') {
window.postMessage(
{
type: 'api_download_data',
status: 'downloading',
task_id: task_id,
endpoint: endpoint,
filename: filename,
size_total: progressEvent.total,
size_loaded: progressEvent.loaded,
percent_completed: percent_completed
},
'*'
);
}
} catch (error) {
console.log('Error posting message to window:', error);
}
}
})
.then(function (response) {
if (log_lvl) {
console.log(
`GET Response: status=${response.status} statusText=${response.statusText} baseURL=${response.config.baseURL} url=${response.config.url} method=${response.config.method} headers=${response.config.headers} params=${JSON.stringify(response.config.params)}`
);
}
if (log_lvl > 1) {
console.log('GET Response:', response);
}
// Post file download message
try {
if (typeof window !== 'undefined') {
window.postMessage(
{
type: 'api_download_data',
status: 'complete',
task_id: task_id,
endpoint: endpoint,
filename: filename,
size_total: 0,
size_loaded: 0,
percent_completed: 100
},
'*'
);
}
} catch (error) {
console.log('Error posting message to window:', error);
}
// Post file download message
try {
if (typeof window !== 'undefined') {
window.postMessage(
{
type: 'api_download_data',
status: 'complete',
task_id: task_id,
endpoint: endpoint,
filename: filename,
size_total: 0,
size_loaded: 0,
percent_completed: 100
},
'*'
);
}
} catch (error) {
console.log('Error posting message to window:', error);
}
if (!Array.isArray(response.data['data']) && as_list) {
if (log_lvl) {
console.log(
'Data result is a dictionary/object, not an array/list. Forcing return as an array/list'
);
}
const return_data = [];
return_data.push(response.data['data']);
return return_data;
} else if (response.data['data']) {
const return_data = response.data['data'];
if (log_lvl) {
if (Array.isArray(return_data)) {
console.log(`Data result is an array/list. Array length: ${return_data.length}`);
} else {
console.log(`Data result is a dictionary/object, not an array/list.`);
}
}
return return_data;
} else {
const return_data = response.data;
if (log_lvl) {
if (Array.isArray(return_data)) {
console.log(
`Not a standard response from Aether's API. Data result is an array/list. Array length: ${return_data.length}`
);
} else {
console.log(
`Not a standard response from Aether's API. Data result is a dictionary/object, not an array/list.`
);
}
}
return return_data;
}
})
.catch(function (error: any) {
// Handle the common and expected 404 "error" first
if (error.response && error.response.status === 404) {
if (log_lvl) {
console.log('The response was a 404 not found "error". Returning null.');
}
if (log_lvl > 1) {
console.log(error.response);
}
if (log_lvl > 2) {
console.log(error);
}
if (!Array.isArray(response.data['data']) && as_list) {
if (log_lvl) {
console.log(
'Data result is a dictionary/object, not an array/list. Forcing return as an array/list'
);
}
const return_data = [];
return_data.push(response.data['data']);
return return_data;
} else if (response.data['data']) {
const return_data = response.data['data'];
if (log_lvl) {
if (Array.isArray(return_data)) {
console.log(
`Data result is an array/list. Array length: ${return_data.length}`
);
} else {
console.log(`Data result is a dictionary/object, not an array/list.`);
}
}
return return_data;
} else {
const return_data = response.data;
if (log_lvl) {
if (Array.isArray(return_data)) {
console.log(
`Not a standard response from Aether's API. Data result is an array/list. Array length: ${return_data.length}`
);
} else {
console.log(
`Not a standard response from Aether's API. Data result is a dictionary/object, not an array/list.`
);
}
}
return return_data;
}
})
.catch(function (error: any) {
// Handle the common and expected 404 "error" first
if (error.response && error.response.status === 404) {
if (log_lvl) {
console.log('The response was a 404 not found "error". Returning null.');
}
if (log_lvl > 1) {
console.log(error.response);
}
if (log_lvl > 2) {
console.log(error);
}
// Post file download message
try {
if (typeof window !== 'undefined') {
window.postMessage(
{
type: 'api_download_data',
status: 'complete',
task_id: task_id,
endpoint: endpoint,
filename: filename,
size_total: 0,
size_loaded: 0,
percent_completed: 0
},
'*'
);
}
} catch (error) {
console.log('Error posting message to window:', error);
}
return null; // Returning null since there were no results
}
// Post file download message
try {
if (typeof window !== 'undefined') {
window.postMessage(
{
type: 'api_download_data',
status: 'complete',
task_id: task_id,
endpoint: endpoint,
filename: filename,
size_total: 0,
size_loaded: 0,
percent_completed: 0
},
'*'
);
}
} catch (error) {
console.log('Error posting message to window:', error);
}
return null; // Returning null since there were no results
}
if (log_lvl) {
console.log(`Base URL: ${api_cfg['base_url']} | Endpoint: ${endpoint}`);
console.log('Error Message:', error.message); // Is this needed here or below in the in the else portion???
if (log_lvl) {
console.log(`Base URL: ${api_cfg['base_url']} | Endpoint: ${endpoint}`);
console.log('Error Message:', error.message); // Is this needed here or below in the in the else portion???
if (error.response) {
// The request was made and the server responded with a status code that falls out of the range of 2xx
console.log('Error Response Data', error.response.data);
console.log('Error Response Status', error.response.status);
console.log('Error Response Headers', error.response.headers);
} else if (error.request) {
// The request was made but no response was received `error.request` is an instance of XMLHttpRequest in the browser and an instance of http.ClientRequest in node.js
if (log_lvl > 1) {
console.log('Error Request', error.request);
}
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error Message', error.message);
}
}
if (log_lvl > 2) {
console.log('Error:', error);
console.log(error.config);
}
if (error.response) {
// The request was made and the server responded with a status code that falls out of the range of 2xx
console.log('Error Response Data', error.response.data);
console.log('Error Response Status', error.response.status);
console.log('Error Response Headers', error.response.headers);
} else if (error.request) {
// The request was made but no response was received `error.request` is an instance of XMLHttpRequest in the browser and an instance of http.ClientRequest in node.js
if (log_lvl > 1) {
console.log('Error Request', error.request);
}
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error Message', error.message);
}
}
if (log_lvl > 2) {
console.log('Error:', error);
console.log(error.config);
}
if (error.code === 'ECONNABORTED') {
// Timeout Error (You can implement retry here where suitable)
console.log('Timeout Error: ', error.message);
}
if (log_lvl) {
console.log('The response was an error. Returning false.');
}
if (error.code === 'ECONNABORTED') {
// Timeout Error (You can implement retry here where suitable)
console.log('Timeout Error: ', error.message);
}
if (log_lvl) {
console.log('The response was an error. Returning false.');
}
return false; // Returning false since something may have gone wrong. This includes timeouts. Also more in line with what the API returns.
// return error;
});
return false; // Returning false since something may have gone wrong. This includes timeouts. Also more in line with what the API returns.
// return error;
});
if (log_lvl > 1) {
// console.log(`Response Data: ${response_data_promise}`);
console.log(`Response Data:`, response_data_promise);
// console.log(response_data_promise);
}
if (response_data_promise) {
// The most common and expected response.
// console.log('Returning result. This is generally expected.');
return response_data_promise;
} else if (response_data_promise === null) {
// Less common, but expected response if no results were returned.
if (log_lvl) {
console.log('Returning null. This is expected if no results were found. (404)');
}
return response_data_promise;
} else if (response_data_promise === false) {
// Not common, but expected response if the request to the API had an issue.
console.log('Returning false. There may have been an issue with this request.');
return response_data_promise;
} else {
// This generally should not happen. It likely means the query was bad or an API issue.
console.log('Returning (JSON/text) unknown. This should not happen in most cases.');
Promise.reject(new Error('fail')).then(resolved, rejected);
}
if (log_lvl > 1) {
// console.log(`Response Data: ${response_data_promise}`);
console.log(`Response Data:`, response_data_promise);
// console.log(response_data_promise);
}
if (response_data_promise) {
// The most common and expected response.
// console.log('Returning result. This is generally expected.');
return response_data_promise;
} else if (response_data_promise === null) {
// Less common, but expected response if no results were returned.
if (log_lvl) {
console.log('Returning null. This is expected if no results were found. (404)');
}
return response_data_promise;
} else if (response_data_promise === false) {
// Not common, but expected response if the request to the API had an issue.
console.log('Returning false. There may have been an issue with this request.');
return response_data_promise;
} else {
// This generally should not happen. It likely means the query was bad or an API issue.
console.log('Returning (JSON/text) unknown. This should not happen in most cases.');
Promise.reject(new Error('fail')).then(resolved, rejected);
}
// Handle the case where a Blob is expected to be returned.
} else {
// console.log('Expecting a Blob to be returned...');
// Handle the case where a Blob is expected to be returned.
} else {
// 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
);
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
);
temp_get_blob_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.
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;
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.
if (filename) {
} else if (headers['content-disposition']) {
filename = headers['content-disposition'].replace(/\w+;filename=(.*)/, '$1');
} else {
filename = 'unknown_file.ext';
}
// WARNING: This needs to be tied to an object type and ID. This is a temporary solution.
try {
if (typeof window !== 'undefined') {
window.postMessage(
{
type: 'api_download_blob',
status: 'complete',
task_id: task_id,
endpoint: endpoint,
filename: filename,
size_total: 0,
size_loaded: 0,
percent_completed: 100
},
'*'
);
}
} catch (error) {
console.log('Error posting message to window:', error);
}
// WARNING: This needs to be tied to an object type and ID. This is a temporary solution.
try {
if (typeof window !== 'undefined') {
window.postMessage(
{
type: 'api_download_blob',
status: 'complete',
task_id: task_id,
endpoint: endpoint,
filename: filename,
size_total: 0,
size_loaded: 0,
percent_completed: 100
},
'*'
);
}
} catch (error) {
console.log('Error posting message to window:', error);
}
if (auto_download) {
if (log_lvl) {
console.log(`Auto Download: ${filename}`);
}
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', filename);
document.body.appendChild(link);
link.click();
return true;
} else {
return response;
}
})
.catch(function (error: any) {
// Handle the common and expected 404 "error" first
if (error.response && error.response.status === 404) {
if (log_lvl) {
console.log('The response was a 404 not found "error". Returning null.');
}
if (log_lvl > 1) {
console.log(error.response);
}
if (log_lvl > 2) {
console.log(error);
}
if (auto_download) {
if (log_lvl) {
console.log(`Auto Download: ${filename}`);
}
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', filename);
document.body.appendChild(link);
link.click();
return true;
} else {
return response;
}
})
.catch(function (error: any) {
// Handle the common and expected 404 "error" first
if (error.response && error.response.status === 404) {
if (log_lvl) {
console.log('The response was a 404 not found "error". Returning null.');
}
if (log_lvl > 1) {
console.log(error.response);
}
if (log_lvl > 2) {
console.log(error);
}
// Post file download message
try {
if (typeof window !== 'undefined') {
window.postMessage(
{
type: 'api_download_blob',
status: 'complete',
task_id: task_id,
endpoint: endpoint,
filename: filename,
size_total: 0,
size_loaded: 0,
percent_completed: 0
},
'*'
);
}
} catch (error) {
console.log('Error posting message to window:', error);
}
return null; // Returning null since there were no results
}
// Post file download message
try {
if (typeof window !== 'undefined') {
window.postMessage(
{
type: 'api_download_blob',
status: 'complete',
task_id: task_id,
endpoint: endpoint,
filename: filename,
size_total: 0,
size_loaded: 0,
percent_completed: 0
},
'*'
);
}
} catch (error) {
console.log('Error posting message to window:', error);
}
return null; // Returning null since there were no results
}
if (log_lvl) {
console.log(`Base URL: ${api_cfg['base_url']} | Endpoint: ${endpoint}`);
console.log('Error Message:', error.message); // Is this needed here or below in the in the else portion???
if (log_lvl) {
console.log(`Base URL: ${api_cfg['base_url']} | Endpoint: ${endpoint}`);
console.log('Error Message:', error.message); // Is this needed here or below in the in the else portion???
if (error.response) {
// The request was made and the server responded with a status code that falls out of the range of 2xx
console.log('Error Response Data', error.response.data);
console.log('Error Response Status', error.response.status);
console.log('Error Response Headers', error.response.headers);
} else if (error.request) {
// The request was made but no response was received `error.request` is an instance of XMLHttpRequest in the browser and an instance of http.ClientRequest in node.js
if (log_lvl > 1) {
console.log('Error Request', error.request);
}
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error Message', error.message);
}
}
if (error.response) {
// The request was made and the server responded with a status code that falls out of the range of 2xx
console.log('Error Response Data', error.response.data);
console.log('Error Response Status', error.response.status);
console.log('Error Response Headers', error.response.headers);
} else if (error.request) {
// The request was made but no response was received `error.request` is an instance of XMLHttpRequest in the browser and an instance of http.ClientRequest in node.js
if (log_lvl > 1) {
console.log('Error Request', error.request);
}
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error Message', error.message);
}
}
if (error.code === 'ECONNABORTED') {
// Timeout Error (You can implement retry here where suitable)
console.log('Timeout Error: ', error.message);
}
if (error.code === 'ECONNABORTED') {
// Timeout Error (You can implement retry here where suitable)
console.log('Timeout Error: ', error.message);
}
if (log_lvl) {
console.log('The response was an error. Returning false.');
}
if (log_lvl) {
console.log('The response was an error. Returning false.');
}
return false; // Returning false since something may have gone wrong. This includes timeouts. Also more in line with what the API returns.
// return error;
});
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) {
console.log('Resolved');
console.log('Resolved');
}
function rejected(result: any) {
console.error(result);
console.error(result);
}

View File

@@ -2,143 +2,143 @@
// Updated 2024-05-23
export const patch_object = async function patch_object({
api_cfg = null,
endpoint = '',
params = {},
data = {},
return_meta = false,
log_lvl = 0,
retry_count = 5 // Number of retry attempts
api_cfg = null,
endpoint = '',
params = {},
data = {},
return_meta = false,
log_lvl = 0,
retry_count = 5 // Number of retry attempts
}: {
api_cfg: any;
endpoint: string;
params?: any;
data?: any;
return_meta?: boolean;
log_lvl?: number;
retry_count?: number;
api_cfg: any;
endpoint: string;
params?: any;
data?: any;
return_meta?: boolean;
log_lvl?: number;
retry_count?: number;
}) {
if (log_lvl) {
console.log(`*** patch_object() *** Endpoint: ${endpoint}`);
console.log('Params:', params);
if (log_lvl > 1) {
console.log('Data:', data);
}
}
if (log_lvl) {
console.log(`*** patch_object() *** Endpoint: ${endpoint}`);
console.log('Params:', params);
if (log_lvl > 1) {
console.log('Data:', data);
}
}
if (!api_cfg) {
console.error('No API Config was provided. Returning false.');
return false;
}
if (!api_cfg) {
console.error('No API Config was provided. Returning false.');
return false;
}
// Construct the URL with query parameters
const url = new URL(endpoint, api_cfg['base_url']);
Object.keys(params).forEach((key) => url.searchParams.append(key, params[key]));
// Construct the URL with query parameters
const url = new URL(endpoint, api_cfg['base_url']);
Object.keys(params).forEach((key) => url.searchParams.append(key, params[key]));
// Clean the headers
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
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];
}
if (log_lvl > 1) {
console.log('Cleaned Headers:', headers_cleaned);
}
if (log_lvl > 1) {
console.log('Cleaned Headers:', headers_cleaned);
}
const fetchOptions: RequestInit = {
method: 'PATCH',
headers: {
...headers_cleaned,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
};
const fetchOptions: RequestInit = {
method: 'PATCH',
headers: {
...headers_cleaned,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
};
if (log_lvl > 1) {
console.log('Fetch Options:', fetchOptions);
}
if (log_lvl > 1) {
console.log('Fetch Options:', fetchOptions);
}
for (let attempt = 1; attempt <= retry_count; attempt++) {
try {
const response = await fetch(url.toString(), fetchOptions);
for (let attempt = 1; attempt <= retry_count; attempt++) {
try {
const response = await fetch(url.toString(), fetchOptions);
if (log_lvl) {
console.log(`Response: status=${response.status} attempt=${attempt}`);
}
if (log_lvl) {
console.log(`Response: status=${response.status} attempt=${attempt}`);
}
if (!response.ok) {
if (response.status === 404) {
console.warn('404 Not Found. Returning null.');
return null; // Returning null since there were no results
}
throw new Error(`HTTP error! status: ${response.status}`);
}
if (!response.ok) {
if (response.status === 404) {
console.warn('404 Not Found. Returning null.');
return null; // Returning null since there were no results
}
throw new Error(`HTTP error! status: ${response.status}`);
}
const json = await response.json();
const json = await response.json();
if (log_lvl > 1) {
console.log('Response JSON:', json);
}
if (log_lvl > 1) {
console.log('Response JSON:', json);
}
// Return the response data or metadata
return return_meta ? json : json.data;
} catch (error) {
console.error(`API PATCH error on attempt ${attempt}:`, error);
// Return the response data or metadata
return return_meta ? json : json.data;
} catch (error) {
console.error(`API PATCH error on attempt ${attempt}:`, error);
// If this is the last attempt, return false
if (attempt === retry_count) {
console.error('Max retry attempts reached. Returning false.');
return false;
}
// 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})`);
}
}
}
// Log retry information
if (log_lvl) {
console.log(`Retrying... (${attempt}/${retry_count})`);
}
}
}
// let axios_api = axios.create({
// baseURL: api_cfg['base_url'],
// /* other custom settings */
// });
// axios_api.defaults.headers = api_cfg['headers'];
// 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);
// }
// for (let attempt = 1; attempt <= retry_count; attempt++) {
// try {
// const response = await axios_api.patch(endpoint, data, { params: params });
// if (log_lvl) {
// console.log(`Response: status=${response.status} attempt=${attempt}`);
// }
// if (log_lvl > 1) {
// console.log('Response Data:', response.data);
// }
// // Return the response data
// return response.data['data'];
// } catch (error) {
// if (log_lvl) {
// console.error(`Error on attempt ${attempt}:`, error);
// }
// // Return the response data
// return response.data['data'];
// } catch (error) {
// if (log_lvl) {
// console.error(`Error on attempt ${attempt}:`, error);
// }
// // Handle specific errors (e.g., 404)
// if (error.response && error.response.status === 404) {
// console.warn('404 Not Found. Returning null.');
// return null; // Returning null since there were no results
// }
// // 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;
// }
// // 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;
};

View File

@@ -7,339 +7,339 @@ export const post_object_percent_completed = temp_post_object_percent_completed;
// Updated 2024-05-23
export const post_object = async function post_object({
api_cfg = null,
endpoint = '',
params = {},
data = {},
form_data = null,
return_meta = false,
return_blob = false,
filename = '',
auto_download = false,
// The task_id value should be a random string that is unique to the task. This is used to identify the task in the message event.
task_id = crypto.randomUUID(),
log_lvl = 0,
retry_count = 5
api_cfg = null,
endpoint = '',
params = {},
data = {},
form_data = null,
return_meta = false,
return_blob = false,
filename = '',
auto_download = false,
// The task_id value should be a random string that is unique to the task. This is used to identify the task in the message event.
task_id = crypto.randomUUID(),
log_lvl = 0,
retry_count = 5
}: {
api_cfg: any;
endpoint: string;
params?: any;
data?: any;
form_data?: any;
return_meta?: boolean;
return_blob?: boolean;
filename?: string;
auto_download?: boolean;
task_id?: string;
log_lvl?: number;
retry_count?: number;
api_cfg: any;
endpoint: string;
params?: any;
data?: any;
form_data?: any;
return_meta?: boolean;
return_blob?: boolean;
filename?: string;
auto_download?: boolean;
task_id?: string;
log_lvl?: 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(`*** 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');
// console.log('HERE!! API POST 0');
if (!api_cfg) {
console.error('No API Config was provided. Returning false.');
return false;
}
if (!api_cfg) {
console.error('No API Config was provided. Returning false.');
return false;
}
// console.log('HERE!! API POST 1');
// 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
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');
// 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
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];
}
// console.log('HERE!! API POST 3');
// 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) {
// 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 (log_lvl > 1) {
console.log('Cleaned Headers:', headers_cleaned);
}
if (log_lvl > 1) {
console.log('Cleaned Headers:', headers_cleaned);
}
// console.log('HERE!! API POST 4');
// 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++) {
try {
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) {
console.log('Fetch Options:', fetchOptions);
}
if (log_lvl > 1) {
console.log('Fetch Options:', fetchOptions);
}
const response = await fetch(url.toString(), fetchOptions);
const response = await fetch(url.toString(), fetchOptions);
if (log_lvl) {
console.log(`Response: status=${response.status} attempt=${attempt}`);
}
if (log_lvl) {
console.log(`Response: status=${response.status} attempt=${attempt}`);
}
if (!response.ok) {
if (response.status === 404) {
console.warn('404 Not Found. Returning null.');
return null; // Returning null since there were no results
}
throw new Error(`HTTP error! status: ${response.status}`);
}
if (!response.ok) {
if (response.status === 404) {
console.warn('404 Not Found. Returning null.');
return null; // Returning null since there were no results
}
throw new Error(`HTTP error! status: ${response.status}`);
}
if (!return_blob) {
const json = await response.json();
if (!return_blob) {
const json = await response.json();
if (log_lvl > 1) {
console.log('Response JSON:', json);
}
if (log_lvl > 1) {
console.log('Response JSON:', json);
}
// Post a message to the window indicating the upload is complete
try {
window.postMessage(
{
type: 'api_post_json_form',
status: 'complete',
task_id: task_id,
endpoint: endpoint,
size_total: 0,
size_loaded: 0,
percent_completed: 100,
progress: 100,
rate: 0
},
'*'
);
} catch (error) {
console.error('Error posting message to window:', error);
}
// Post a message to the window indicating the upload is complete
try {
window.postMessage(
{
type: 'api_post_json_form',
status: 'complete',
task_id: task_id,
endpoint: endpoint,
size_total: 0,
size_loaded: 0,
percent_completed: 100,
progress: 100,
rate: 0
},
'*'
);
} catch (error) {
console.error('Error posting message to window:', error);
}
// Return the response data or metadata
return return_meta ? json : json.data;
} else {
const blob = await response.blob();
// Return the response data or metadata
return return_meta ? json : json.data;
} else {
const blob = await response.blob();
if (auto_download) {
const downloadUrl = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = downloadUrl;
link.setAttribute('download', filename || 'download');
document.body.appendChild(link);
link.click();
link.remove();
return true;
} else {
return blob;
}
}
} catch (error) {
console.error(`API POST error on attempt ${attempt}:`, error);
if (auto_download) {
const downloadUrl = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = downloadUrl;
link.setAttribute('download', filename || 'download');
document.body.appendChild(link);
link.click();
link.remove();
return true;
} else {
return blob;
}
}
} catch (error) {
console.error(`API POST error on attempt ${attempt}:`, error);
// If this is the last attempt, return false
if (attempt === retry_count) {
console.error('Max retry attempts reached. Returning false.');
return false;
}
// 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})`);
}
}
}
// Log retry information
if (log_lvl) {
console.log(`Retrying... (${attempt}/${retry_count})`);
}
}
}
// let axios_api = axios.create({
// baseURL: api_cfg['base_url'],
// /* other custom settings */
// });
// axios_api.defaults.headers = api_cfg['headers'];
// console.log('Axios API', axios_api);
// // console.log('Axios API POST', axios_api.post);
// let axios_api = axios.create({
// baseURL: api_cfg['base_url'],
// /* other custom settings */
// });
// axios_api.defaults.headers = api_cfg['headers'];
// console.log('Axios API', axios_api);
// // console.log('Axios API POST', axios_api.post);
// // if (typeof data == 'FormData') {
// if (form_data) {
// axios_api.defaults.headers['content-type'] = 'multipart/form-data';
// data = form_data;
// } else {
// axios_api.defaults.headers['content-type'] = 'application/json';
// }
// // if (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);
// if (!return_blob) {
// let response_data = await axios_api.post(
// endpoint,
// data,
// {
// params: params,
// onUploadProgress: (progressEvent) => {
// let percent_completed = Math.round(
// (progressEvent.loaded * 100) / progressEvent.total
// );
// console.log('POST Progress:', progressEvent.progress, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed);
// temp_post_object_percent_completed = percent_completed;
// temp_post_object_percent_completed = percent_completed;
// try {
// window.postMessage({
// type: 'api_post_json_form',
// status: 'uploading',
// task_id: task_id,
// endpoint: endpoint,
// size_total: progressEvent.total,
// size_loaded: progressEvent.loaded,
// percent_completed: percent_completed,
// progress: progressEvent.progress,
// rate: progressEvent.rate,
// },
// '*'
// );
// } catch (error) {
// console.log('Error posting message to window:', error);
// }
// }
// }
// )
// .then(function (response) {
// console.log('POST Response Data:', response.data);
// try {
// window.postMessage({
// type: 'api_post_json_form',
// status: 'complete',
// task_id: task_id,
// endpoint: endpoint,
// size_total: 0,
// size_loaded: 0,
// percent_completed: 100,
// progress: 100,
// rate: 0,
// },
// '*'
// );
// } catch (error) {
// console.log('Error posting message to window:', error);
// }
// try {
// window.postMessage({
// type: 'api_post_json_form',
// status: 'uploading',
// task_id: task_id,
// endpoint: endpoint,
// size_total: progressEvent.total,
// size_loaded: progressEvent.loaded,
// percent_completed: percent_completed,
// progress: progressEvent.progress,
// rate: progressEvent.rate,
// },
// '*'
// );
// } catch (error) {
// console.log('Error posting message to window:', error);
// }
// }
// }
// )
// .then(function (response) {
// console.log('POST Response Data:', response.data);
// try {
// window.postMessage({
// type: 'api_post_json_form',
// status: 'complete',
// task_id: task_id,
// endpoint: endpoint,
// size_total: 0,
// size_loaded: 0,
// percent_completed: 100,
// progress: 100,
// rate: 0,
// },
// '*'
// );
// } catch (error) {
// console.log('Error posting message to window:', error);
// }
// if (response.data['data'].result === null) {
// // This should mean that the request was successful, but a result of None/null was returned from Aether API.
// // console.log('Returning null after POST');
// return null;
// } else {
// // This should mean that the request was successful, and a result with data was returned from Aether API.
// // console.log('Returning data after POST');
// return response.data['data'];
// }
// //return response.data;
// })
// .catch(function (error: 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 (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 (log_lvl > 1) {
// console.log('Response Data:', response_data);
// }
// axios_api.defaults.headers['content-type'] = 'application/json';
// return response_data;
// if (log_lvl > 1) {
// console.log('Response Data:', response_data);
// }
// axios_api.defaults.headers['content-type'] = 'application/json';
// return response_data;
// } else {
// // console.log('Expecting a Blob to be returned...');
// } else {
// // console.log('Expecting a Blob to be returned...');
// let response_data_promise = await axios_api.post(
// endpoint,
// data,
// {
// params: params,
// responseType: 'blob',
// onDownloadProgress: (progressEvent) => {
// let percent_completed = Math.round(
// (progressEvent.loaded * 100) / progressEvent.total
// );
// console.log('POST Blob Progress:', progressEvent.progress, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed);
// let response_data_promise = await axios_api.post(
// endpoint,
// data,
// {
// params: params,
// responseType: 'blob',
// onDownloadProgress: (progressEvent) => {
// let percent_completed = Math.round(
// (progressEvent.loaded * 100) / progressEvent.total
// );
// console.log('POST Blob Progress:', progressEvent.progress, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed);
// temp_post_blob_percent_completed = percent_completed;
// }
// }
// )
// .then(function (response) {
// if (log_lvl) {
// console.log(response);
// }
// temp_post_blob_percent_completed = percent_completed;
// }
// }
// )
// .then(function (response) {
// if (log_lvl) {
// console.log(response);
// }
// const { data, headers } = response
// console.log(headers);
// 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 (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 (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) {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,32 +1,32 @@
// This file is used to export all the functions that are used for Aether Posts related functions.
import {
load_ae_obj_id__archive,
load_ae_obj_li__archive,
create_ae_obj__archive,
delete_ae_obj_id__archive,
update_ae_obj__archive
load_ae_obj_id__archive,
load_ae_obj_li__archive,
create_ae_obj__archive,
delete_ae_obj_id__archive,
update_ae_obj__archive
} from '$lib/ae_archives/ae_archives__archive';
import {
load_ae_obj_id__archive_content,
load_ae_obj_li__archive_content,
create_ae_obj__archive_content,
delete_ae_obj_id__archive_content,
update_ae_obj__archive_content
load_ae_obj_id__archive_content,
load_ae_obj_li__archive_content,
create_ae_obj__archive_content,
delete_ae_obj_id__archive_content,
update_ae_obj__archive_content
} 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,
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: 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,
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 const archives_func = export_obj;

View File

@@ -7,135 +7,135 @@ import type { key_val } from '$lib/stores/ae_stores';
// Updated 2024-09-25
export interface Archive {
id: string;
// id_random: string;
archive_id: string;
// archive_id_random: string;
id: string;
// id_random: string;
archive_id: string;
// archive_id_random: string;
code?: null | string;
code?: null | string;
account_id: string;
// account_id_random: string;
account_id: string;
// account_id_random: string;
// archive_type: string;
// archive_type: string;
// type: string;
name: string;
// summary?: null|string;
description?: null | string;
// type: string;
name: string;
// summary?: null|string;
description?: null | string;
content_html?: null | string;
content_json?: null | string;
content_url?: null | string;
content_url_text?: null | string;
content_html?: null | string;
content_json?: null | string;
content_url?: null | string;
content_url_text?: null | string;
original_datetime?: Date;
original_timezone?: null | string;
original_location?: null | string;
original_datetime?: Date;
original_timezone?: null | string;
original_location?: null | string;
original_url?: null | string;
original_url_text?: null | string;
original_url?: null | string;
original_url_text?: null | string;
// meta_data?: null|string;
// access_key?: null|string; /// Rename this to "passcode" if used later
// meta_data?: null|string;
// access_key?: null|string; /// Rename this to "passcode" if used later
sort_by?: null | string;
sort_by_desc?: null | string;
sort_by?: null | string;
sort_by_desc?: null | string;
cfg_json?: null | key_val;
cfg_json?: null | key_val;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
// Generated fields for sorting locally only
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
// Generated fields for sorting locally only
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
// Additional fields for convenience (database views)
// archive_content_count?: number;
// archive_content_kv?: null|key_val;
// archive_content_li?: null|[];
// Additional fields for convenience (database views)
// archive_content_count?: number;
// archive_content_kv?: null|key_val;
// archive_content_li?: null|[];
}
// Updated 2024-09-25
export interface Archive_Content {
id: string;
// id_random: string;
archive_content_id: string;
// archive_content_id_random: string;
id: string;
// id_random: string;
archive_content_id: string;
// archive_content_id_random: string;
archive_id: string;
// archive_id_random: string;
archive_id: string;
// archive_id_random: string;
archive_content_type: string;
archive_content_type: string;
name: string;
description?: null | string;
name: string;
description?: null | string;
content_html?: null | string;
content_json?: null | string;
content_html?: 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_text?: null | string;
url?: 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;
file_extension?: null | string;
filename?: null | string;
file_extension?: null | string;
original_datetime?: Date;
original_timezone?: null | string;
original_location?: null | string;
original_url?: null | string;
original_url_text?: null | string;
original_datetime?: Date;
original_timezone?: null | string;
original_location?: null | string;
original_url?: null | string;
original_url_text?: null | string;
// meta_data?: null|string;
// access_key?: null|string; /// Rename this to "passcode" if used later
// meta_data?: null|string;
// 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;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
// Generated fields for sorting locally only
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
// Generated fields for sorting locally only
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
// Additional fields for convenience (database views)
archive_code?: null | string;
archive_name?: null | string;
// Additional fields for convenience (database views)
archive_code?: null | string;
archive_name?: null | string;
hash_sha256?: null | string;
hash_sha256?: null | string;
}
// Updated 2024-09-25
export class MySubClassedDexie extends Dexie {
// We just tell the typing system this is the case
archive!: Table<Archive>;
content!: Table<Archive_Content>;
// We just tell the typing system this is the case
archive!: Table<Archive>;
content!: Table<Archive_Content>;
constructor() {
super('ae_archives_db');
this.version(1).stores({
archive: `
constructor() {
super('ae_archives_db');
this.version(1).stores({
archive: `
id, archive_id,
code,
account_id,
@@ -143,7 +143,7 @@ export class MySubClassedDexie extends Dexie {
original_datetime, original_timezone, original_location,
tmp_sort_1, tmp_sort_2,
enable, hide, priority, sort, group, notes, created_on, updated_on`,
content: `
content: `
id, archive_content_id,
archive_id,
archive_content_type,
@@ -153,13 +153,13 @@ export class MySubClassedDexie extends Dexie {
[group+original_datetime],
tmp_sort_1, tmp_sort_2,
enable, hide, priority, sort, group, notes, created_on, updated_on, [group+priority+sort+updated_on]`
});
});
// file_path,
// filename, file_extension,
// original_datetime, original_timezone, original_location, original_url, original_url_text,
// enable_for_public,
}
// file_path,
// filename, file_extension,
// original_datetime, original_timezone, original_location, original_url, original_url_text,
// enable_for_public,
}
}
export const db_archives = new MySubClassedDexie();

View File

@@ -1,387 +1,418 @@
<script lang="ts">
import { preventDefault } from 'svelte/legacy';
import { preventDefault } from 'svelte/legacy';
// Imports
// Import components and elements
// import Element_input_files_tbl from '$lib/element_input_files_tbl.svelte';
// Imports
// Import components and elements
// import Element_input_files_tbl from '$lib/element_input_files_tbl.svelte';
// Import storage, functions, and libraries
import type { key_val } from '$lib/stores/ae_stores';
// Import storage, functions, and libraries
import type { key_val } from '$lib/stores/ae_stores';
import { api } from '$lib/api/api';
import { ae_util } from '$lib/ae_utils/ae_utils';
import {
ae_snip,
ae_loc,
ae_sess,
ae_api,
ae_trig,
slct,
slct_trigger
} from '$lib/stores/ae_stores';
import { api } from '$lib/api/api';
import { ae_util } from '$lib/ae_utils/ae_utils';
import {
ae_snip,
ae_loc,
ae_sess,
ae_api,
ae_trig,
slct,
slct_trigger
} from '$lib/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 multiple: boolean = true;
// export let required: boolean = true;
// export let input_class_li: string[] = ['file_drop_area'];
// export let input_class_li: string[] = ['file_drop_area'];
interface Props {
log_lvl?: number;
// Expecting these for link_to_type: 'event', 'event_location', 'archive_content', etc
link_to_type: string;
link_to_id: string;
// export let accept: string = 'audio/*, image/*, video/*, .bak, .cfg, .css, .csv, .doc, .docx, .gz, .htm, .html, .ini, .iso, .j2, .json, .key, .keynote, .md, .pdf, .ppt, .pptx, .rar, .rtf, .sql, .svelte, ttf, .txt, .xls, .xlsx, .xz, .zip, .bin, .dmg, .exe, .js, .msi, .php, .py, .sh';
class_li_default?: string;
class_li?: string;
// export let table_class_li: string[] = ['table', 'table-sm', 'table-striped', 'table-hover' , 'text-sm'];
clip_complete?: boolean;
// export let upload_complete: boolean = false;
submit_status?: null | string;
// hosted_file_id_li?: string[];
// hosted_file_obj_li?: any[];
hosted_file_obj_kv?: key_val;
video_clip_file_kv?: key_val;
}
interface Props {
log_lvl?: number;
// Expecting these for link_to_type: 'event', 'event_location', 'archive_content', etc
link_to_type: string;
link_to_id: string;
// export let accept: string = 'audio/*, image/*, video/*, .bak, .cfg, .css, .csv, .doc, .docx, .gz, .htm, .html, .ini, .iso, .j2, .json, .key, .keynote, .md, .pdf, .ppt, .pptx, .rar, .rtf, .sql, .svelte, ttf, .txt, .xls, .xlsx, .xz, .zip, .bin, .dmg, .exe, .js, .msi, .php, .py, .sh';
class_li_default?: string;
class_li?: string;
// export let table_class_li: string[] = ['table', 'table-sm', 'table-striped', 'table-hover' , 'text-sm'];
clip_complete?: boolean;
// export let upload_complete: boolean = false;
submit_status?: null | string;
// hosted_file_id_li?: string[];
// hosted_file_obj_li?: any[];
hosted_file_obj_kv?: key_val;
video_clip_file_kv?: key_val;
}
let {
log_lvl = $bindable(0),
link_to_type = $bindable(),
link_to_id = $bindable(),
class_li_default = 'flex flex-col gap-1 items-center justify-center w-full max-w-2xl mx-auto my-1',
class_li = $bindable(''),
clip_complete = $bindable(false),
submit_status = $bindable(null),
// hosted_file_id_li = [],
// hosted_file_obj_li = [],
hosted_file_obj_kv = $bindable({}),
video_clip_file_kv = $bindable({})
}: Props = $props();
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 = {};
// Local Variables
let task_id = link_to_id;
// let input_file_list: any = null;
let ae_promises: key_val = $state({});
// let ae_promises_clipping: key_val = {};
// let ae_triggers: key_val = {};
// let input_element_id = 'ae_comp__hosted_files_upload__input';
// let 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 = {
// start_time: null,
// end_time: null,
// reencode: null,
// video_file: null,
// };
// let download_clip_src: string;
// let download_clip_filename: string;
$ae_sess.files.obj = {
obj: null
};
$ae_sess.files.obj = {
obj: null
};
// *** Functions and Logic
function handle_clip_video(event) {
console.log('*** handle_clip_video() ***');
// *** Functions and Logic
function handle_clip_video(event) {
console.log('*** handle_clip_video() ***');
submit_status = 'clipping';
clip_complete = false;
submit_status = 'clipping';
clip_complete = false;
let hosted_file_id = event.target.hosted_file_id.value;
let hosted_file_id = event.target.hosted_file_id.value;
$ae_sess.files.processed_file_kv[hosted_file_id] = {};
$ae_sess.files.processed_file_kv[hosted_file_id].submit_status = 'clipping';
$ae_sess.files.processed_file_kv[hosted_file_id].clip_complete = false;
$ae_sess.files.processed_file_kv[hosted_file_id] = {};
$ae_sess.files.processed_file_kv[hosted_file_id].submit_status = 'clipping';
$ae_sess.files.processed_file_kv[hosted_file_id].clip_complete = false;
// $ae_sess.files.disable_submit__hosted_file_obj = true;
$ae_loc.files.processed_file_kv[hosted_file_id] = {};
$ae_loc.files.processed_file_kv[hosted_file_id].submit_status = 'clipping';
$ae_loc.files.processed_file_kv[hosted_file_id].start_time = event.target.start_time.value;
$ae_loc.files.processed_file_kv[hosted_file_id].end_time = event.target.end_time.value;
$ae_loc.files.processed_file_kv[hosted_file_id].reencode = event.target.reencode.value;
$ae_loc.files.processed_file_kv[hosted_file_id].scale_down = event.target.scale_down.value;
$ae_loc.files.processed_file_kv[hosted_file_id].new_filename = event.target.new_filename.value;
$ae_loc.files.processed_file_kv[hosted_file_id].clip_complete = false;
// $ae_sess.files.disable_submit__hosted_file_obj = true;
$ae_loc.files.processed_file_kv[hosted_file_id] = {};
$ae_loc.files.processed_file_kv[hosted_file_id].submit_status = 'clipping';
$ae_loc.files.processed_file_kv[hosted_file_id].start_time = event.target.start_time.value;
$ae_loc.files.processed_file_kv[hosted_file_id].end_time = event.target.end_time.value;
$ae_loc.files.processed_file_kv[hosted_file_id].reencode = event.target.reencode.value;
$ae_loc.files.processed_file_kv[hosted_file_id].scale_down = event.target.scale_down.value;
$ae_loc.files.processed_file_kv[hosted_file_id].new_filename =
event.target.new_filename.value;
$ae_loc.files.processed_file_kv[hosted_file_id].clip_complete = false;
let endpoint = `/hosted_file/${hosted_file_id}/clip_video`;
let endpoint = `/hosted_file/${hosted_file_id}/clip_video`;
let params = {
link_to_type: link_to_type,
link_to_id: link_to_id,
filename_no_ext: event.target.new_filename.value.replace('.mp4', ''),
from_type: 'mp4', // Video file type being converted
to_type: 'mp4', // Video file type to convert to
start_time: event.target.start_time.value,
end_time: event.target.end_time.value,
reencode: event.target.reencode.value,
scale_down: event.target.scale_down.value
};
let params = {
link_to_type: link_to_type,
link_to_id: link_to_id,
filename_no_ext: event.target.new_filename.value.replace('.mp4', ''),
from_type: 'mp4', // Video file type being converted
to_type: 'mp4', // Video file type to convert to
start_time: event.target.start_time.value,
end_time: event.target.end_time.value,
reencode: event.target.reencode.value,
scale_down: event.target.scale_down.value
};
ae_promises[hosted_file_id] = {};
// .convert__hosted_file_obj
ae_promises[hosted_file_id] = api
.get_object({
api_cfg: $ae_api,
endpoint: endpoint,
params: params,
timeout: 300000, // 5 minutes
// return_blob: true,
// filename: event.target.new_filename.value,
// auto_download: false,
task_id: task_id,
log_lvl: log_lvl
})
.then(function (result) {
console.log(result);
ae_promises[hosted_file_id] = {};
// .convert__hosted_file_obj
ae_promises[hosted_file_id] = api
.get_object({
api_cfg: $ae_api,
endpoint: endpoint,
params: params,
timeout: 300000, // 5 minutes
// return_blob: true,
// filename: event.target.new_filename.value,
// auto_download: false,
task_id: task_id,
log_lvl: log_lvl
})
.then(function (result) {
console.log(result);
video_clip_file_kv[result.hosted_file_id_random] = {};
video_clip_file_kv[result.hosted_file_id_random] = result;
video_clip_file_kv[result.hosted_file_id_random] = {};
video_clip_file_kv[result.hosted_file_id_random] = result;
// $ae_loc.files.video_clip_file_kv[result.hosted_file_id_random] = {};
// $ae_loc.files.video_clip_file_kv[result.hosted_file_id_random] = result;
// $ae_loc.files.video_clip_file_kv[result.hosted_file_id_random] = {};
// $ae_loc.files.video_clip_file_kv[result.hosted_file_id_random] = result;
$ae_sess.files.processed_file_kv[hosted_file_id].submit_status = 'clipped';
$ae_sess.files.processed_file_kv[hosted_file_id].clip_complete = true;
$ae_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;
$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;
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;
// 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;
});
}
return true;
});
}
</script>
<section class="{class_li_default} {class_li}">
<!-- <h3 class="h3">{hosted_file_obj_li.length}&times; files uploaded</h3>
<!-- <h3 class="h3">{hosted_file_obj_li.length}&times; files uploaded</h3>
{#each hosted_file_obj_li as hosted_file_obj, i} -->
<h3 class="h3">
{Object.entries(hosted_file_obj_kv).length}× files uploaded
</h3>
<h3 class="h3">
{Object.entries(hosted_file_obj_kv).length}× files uploaded
</h3>
{#each Object.entries(hosted_file_obj_kv) as [hosted_file_id, hosted_file_obj]}
<div class="border border-gray-300 rounded-lg p-2 m-2">
<!-- {#if $ae_sess.files[hosted_file_id].upload_complete}
{#each Object.entries(hosted_file_obj_kv) as [hosted_file_id, hosted_file_obj]}
<div class="border border-gray-300 rounded-lg p-2 m-2">
<!-- {#if $ae_sess.files[hosted_file_id].upload_complete}
<a href="/hosted_file/{hosted_file_id}/download?x_no_account_id_token=direct-download" download={$ae_sess.files[hosted_file_id].new_filename} class="ae_btn btn_lg btn_primary"><span class="fas fa-download"></span> Ready to Download</a>
{/if} -->
<div class="flex flex-row flex-wrap gap-1 justify-center items-center w-full">
<!-- Remove from uploaded file kv list -->
<button
type="button"
onclick={() => {
// This (uploaded_file_kv) is referenced by other AE components. Currently it is only used with the manage hosted file list and clip video components.
console.log(
`Removed hosted file ID: ${hosted_file_id}`,
$ae_loc.files.uploaded_file_kv
);
// delete $ae_sess.files.uploaded_file_kv[hosted_file_id];
delete $ae_loc.files.uploaded_file_kv[hosted_file_id];
$ae_loc.files.uploaded_file_kv = { ...$ae_loc.files.uploaded_file_kv };
delete hosted_file_obj_kv[hosted_file_id];
hosted_file_obj_kv = { ...hosted_file_obj_kv };
// delete $ae_loc.files.uploaded_file_kv[hosted_file_obj.hosted_file_id];
console.log(
`Removed hosted file ID: ${hosted_file_obj.hosted_file_id}`,
$ae_loc.files.uploaded_file_kv
);
}}
class="btn btn-sm preset-tonal-warning hover:preset-filled-warning-500"
title={`Remove this file from list of videos:\n${hosted_file_obj.filename}\n[API] SHA256: ${hosted_file_obj?.hash_sha256?.slice(0, 10)}... Hosted ID: ${hosted_file_obj.hosted_file_id_random}`}
>
<span class="fas fa-minus-circle m-1"></span>
<span class="">Remove</span>
</button>
<div class="flex flex-row flex-wrap gap-1 justify-center items-center w-full">
<!-- Remove from uploaded file kv list -->
<button
type="button"
onclick={() => {
// This (uploaded_file_kv) is referenced by other AE components. Currently it is only used with the manage hosted file list and clip video components.
console.log(
`Removed hosted file ID: ${hosted_file_id}`,
$ae_loc.files.uploaded_file_kv
);
// delete $ae_sess.files.uploaded_file_kv[hosted_file_id];
delete $ae_loc.files.uploaded_file_kv[hosted_file_id];
$ae_loc.files.uploaded_file_kv = { ...$ae_loc.files.uploaded_file_kv };
delete hosted_file_obj_kv[hosted_file_id];
hosted_file_obj_kv = { ...hosted_file_obj_kv };
// delete $ae_loc.files.uploaded_file_kv[hosted_file_obj.hosted_file_id];
console.log(
`Removed hosted file ID: ${hosted_file_obj.hosted_file_id}`,
$ae_loc.files.uploaded_file_kv
);
}}
class="btn btn-sm preset-tonal-warning hover:preset-filled-warning-500"
title={`Remove this file from list of videos:\n${hosted_file_obj.filename}\n[API] SHA256: ${hosted_file_obj?.hash_sha256?.slice(0, 10)}... Hosted ID: ${hosted_file_obj.hosted_file_id_random}`}
>
<span class="fas fa-minus-circle m-1"></span>
<span class="">Remove</span>
</button>
<!-- Download the file -->
<button
type="button"
disabled={!$ae_loc.trusted_access}
onclick={() => {
ae_promises[hosted_file_id] = api.download_hosted_file({
api_cfg: $ae_api,
hosted_file_id: hosted_file_id,
return_file: true,
filename: hosted_file_obj.filename,
auto_download: true,
log_lvl: 0
});
<!-- Download the file -->
<button
type="button"
disabled={!$ae_loc.trusted_access}
onclick={() => {
ae_promises[hosted_file_id] = api.download_hosted_file({
api_cfg: $ae_api,
hosted_file_id: hosted_file_id,
return_file: true,
filename: hosted_file_obj.filename,
auto_download: true,
log_lvl: 0
});
// window.postMessage({ type: 'download_event_file', hosted_file_id: idaa_archive_content_obj.hosted_file_id, filename: idaa_archive_content_obj.filename, auto_download: true }, '*');
}}
class:hidden={!$ae_loc.edit_mode}
class="novi_btn btn btn-sm lg:btn-md preset-tonal-primary hover:preset-filled-primary-500 min-w-72 lg:min-w-96"
title={`Download this file:\n${hosted_file_obj.filename}\n[API] SHA256: ${hosted_file_obj?.hash_sha256?.slice(0, 10)}... Hosted ID: ${hosted_file_obj.hosted_file_id_random}`}
>
{#await ae_promises[hosted_file_id]}
<span class="fas fa-spinner fa-spin mx-1"></span>
{#if submit_status == 'clipping'}
<span class="">Clipping</span>
{:else}
<span class="">
Downloading
{#if $ae_sess.api_download_kv[hosted_file_id]}
{$ae_sess.api_download_kv[hosted_file_id].percent_completed}%
{/if}
:
</span>
{/if}
{:then}
<span class="fas fa-{ae_util.file_extension_icon(hosted_file_obj?.file_extension)}"
></span>
{/await}
// window.postMessage({ type: 'download_event_file', hosted_file_id: idaa_archive_content_obj.hosted_file_id, filename: idaa_archive_content_obj.filename, auto_download: true }, '*');
}}
class:hidden={!$ae_loc.edit_mode}
class="novi_btn btn btn-sm lg:btn-md preset-tonal-primary hover:preset-filled-primary-500 min-w-72 lg:min-w-96"
title={`Download this file:\n${hosted_file_obj.filename}\n[API] SHA256: ${hosted_file_obj?.hash_sha256?.slice(0, 10)}... Hosted ID: ${hosted_file_obj.hosted_file_id_random}`}
>
{#await ae_promises[hosted_file_id]}
<span class="fas fa-spinner fa-spin mx-1"></span>
{#if submit_status == 'clipping'}
<span class="">Clipping</span>
{:else}
<span class="">
Downloading
{#if $ae_sess.api_download_kv[hosted_file_id]}
{$ae_sess.api_download_kv[hosted_file_id].percent_completed}%
{/if}
:
</span>
{/if}
{:then}
<span
class="fas fa-{ae_util.file_extension_icon(
hosted_file_obj?.file_extension
)}"
></span>
{/await}
<span class="grow">
{ae_util.shorten_filename({ filename: hosted_file_obj?.filename, max_length: 30 })}
</span>
</button>
<span
>{ae_util.shorten_filename({ filename: hosted_file_obj?.filename, max_length: 30 })}</span
>
<span>
<span class="text-sm font-bold"> File ID: </span>
{hosted_file_obj.hosted_file_id_random}</span
>
<span>
<span class="text-sm font-bold"> Type: </span>
{hosted_file_obj.extension}</span
>
<!-- <span>{hosted_file_obj.filename}</span> -->
</div>
<span class="grow">
{ae_util.shorten_filename({
filename: hosted_file_obj?.filename,
max_length: 30
})}
</span>
</button>
<span
>{ae_util.shorten_filename({
filename: hosted_file_obj?.filename,
max_length: 30
})}</span
>
<span>
<span class="text-sm font-bold"> File ID: </span>
{hosted_file_obj.hosted_file_id_random}</span
>
<span>
<span class="text-sm font-bold"> Type: </span>
{hosted_file_obj.extension}</span
>
<!-- <span>{hosted_file_obj.filename}</span> -->
</div>
<form onsubmit={preventDefault(handle_clip_video)} class="{class_li_default} {class_li}">
<!-- {$ae_sess?.files[hosted_file_obj?.hosted_file_id_random ?? 'obj'].submit_status ?? 'not set'} -->
<form
onsubmit={preventDefault(handle_clip_video)}
class="{class_li_default} {class_li}"
>
<!-- {$ae_sess?.files[hosted_file_obj?.hosted_file_id_random ?? 'obj'].submit_status ?? 'not set'} -->
<input type="hidden" name="hosted_file_id" value={hosted_file_obj.hosted_file_id_random} />
<input
type="hidden"
name="hosted_file_id"
value={hosted_file_obj.hosted_file_id_random}
/>
<div class="flex flex-row gap-1 justify-center items-center w-full">
<span class="text-xs font-bold w-32">New Filename:</span>
<input
type="text"
class="input w-full text-sm"
name="new_filename"
value={hosted_file_obj.filename}
/>
</div>
<div class="flex flex-row gap-1 justify-center items-center w-full">
<span class="text-xs font-bold w-32">New Filename:</span>
<input
type="text"
class="input w-full text-sm"
name="new_filename"
value={hosted_file_obj.filename}
/>
</div>
<div class="max-w-(--breakpoint-sm) flex flex-row gap-1 justify-center items-center w-full">
<label
class="label w-48"
title="The start time of the clip. This is the time in the video where the clip will start. You may need to subtract a few seconds to get the exact start time."
>
<span class="text-xs font-bold">Start time (HH:MM:SS)</span>
<input
type="text"
name="start_time"
value={$ae_loc.files.processed_file_kv &&
$ae_loc.files.processed_file_kv[hosted_file_id] &&
$ae_loc.files.processed_file_kv[hosted_file_id].start_time
? $ae_loc.files.processed_file_kv[hosted_file_id].start_time
: '00:00:00'}
placeholder="HH:MM:SS (00:01:30)"
class="input w-32"
/>
</label>
<div
class="max-w-(--breakpoint-sm) flex flex-row gap-1 justify-center items-center w-full"
>
<label
class="label w-48"
title="The start time of the clip. This is the time in the video where the clip will start. You may need to subtract a few seconds to get the exact start time."
>
<span class="text-xs font-bold">Start time (HH:MM:SS)</span>
<input
type="text"
name="start_time"
value={$ae_loc.files.processed_file_kv &&
$ae_loc.files.processed_file_kv[hosted_file_id] &&
$ae_loc.files.processed_file_kv[hosted_file_id].start_time
? $ae_loc.files.processed_file_kv[hosted_file_id].start_time
: '00:00:00'}
placeholder="HH:MM:SS (00:01:30)"
class="input w-32"
/>
</label>
<label
class="label w-48"
title="The end time of the clip. This is the time in the video where the clip will end. You may need to add a few seconds to get the exact end time."
>
<span class="text-xs font-bold">End time (HH:MM:SS)</span>
<input
type="text"
name="end_time"
value={$ae_loc.files.processed_file_kv &&
$ae_loc.files.processed_file_kv[hosted_file_id] &&
$ae_loc.files.processed_file_kv[hosted_file_id].end_time
? $ae_loc.files.processed_file_kv[hosted_file_id].end_time
: '00:45:59'}
placeholder="HH:MM:SS (01:05:25)"
class="input w-32"
/>
</label>
<label
class="label w-48"
title="The end time of the clip. This is the time in the video where the clip will end. You may need to add a few seconds to get the exact end time."
>
<span class="text-xs font-bold">End time (HH:MM:SS)</span>
<input
type="text"
name="end_time"
value={$ae_loc.files.processed_file_kv &&
$ae_loc.files.processed_file_kv[hosted_file_id] &&
$ae_loc.files.processed_file_kv[hosted_file_id].end_time
? $ae_loc.files.processed_file_kv[hosted_file_id].end_time
: '00:45:59'}
placeholder="HH:MM:SS (01:05:25)"
class="input w-32"
/>
</label>
<span
class="flex flex-col gap-1 items-center justify-center"
title="Re-encode the video file? This does cause some minor quality loss. Re-encoding is useful if the audio or video seems to be chopped off at the beginning or end of the clip. It can also help with partially corrupted files."
>
<span class="text-xs font-bold"> Re-encode? </span>
<label class="inline-block">
<input type="radio" name="reencode" value="true" class="radio" checked />
True
</label>
<label class="inline-block">
<input type="radio" name="reencode" value="false" class="radio" />
False
</label>
</span>
<span
class="flex flex-col gap-1 items-center justify-center"
title="Re-encode the video file? This does cause some minor quality loss. Re-encoding is useful if the audio or video seems to be chopped off at the beginning or end of the clip. It can also help with partially corrupted files."
>
<span class="text-xs font-bold"> Re-encode? </span>
<label class="inline-block">
<input
type="radio"
name="reencode"
value="true"
class="radio"
checked
/>
True
</label>
<label class="inline-block">
<input type="radio" name="reencode" value="false" class="radio" />
False
</label>
</span>
<span
class="flex flex-col gap-1 items-center justify-center"
title="Scale the video file down to 1920x1080? This does cause some minor quality loss. Re-encoding is useful if the audio or video seems to be chopped off at the beginning or end of the clip. It can also help with partially corrupted files."
>
<span class="text-xs font-bold"> Scale down? </span>
<label class="inline-block">
<input type="radio" name="scale_down" value="true" class="radio" checked />
True
</label>
<label class="inline-block">
<input type="radio" name="scale_down" value="false" class="radio" />
False
</label>
</span>
</div>
<span
class="flex flex-col gap-1 items-center justify-center"
title="Scale the video file down to 1920x1080? This does cause some minor quality loss. Re-encoding is useful if the audio or video seems to be chopped off at the beginning or end of the clip. It can also help with partially corrupted files."
>
<span class="text-xs font-bold"> Scale down? </span>
<label class="inline-block">
<input
type="radio"
name="scale_down"
value="true"
class="radio"
checked
/>
True
</label>
<label class="inline-block">
<input type="radio" name="scale_down" value="false" class="radio" />
False
</label>
</span>
</div>
<button
type="submit"
class="btn btn-lg btn-primary preset-tonal-primary border border-primary-500"
disabled={submit_status == 'clipping'}
>
<!-- {#await ae_promises[hosted_file_id]} -->
{#if $ae_loc.files.processed_file_kv[hosted_file_id] && $ae_loc.files.processed_file_kv[hosted_file_id].submit_status == 'clipping'}
<span class="fas fa-spinner fa-spin m-1"></span>
<span class="highlight">Clipping...</span>
{:else}
<!-- {#if ae_promises[hosted_file_id]} -->
{#if $ae_loc.files.processed_file_kv[hosted_file_id] && $ae_loc.files.processed_file_kv[hosted_file_id].submit_status == 'clipped'}
<span class="fas fa-check m-1"></span>
Clipped
{:else}
<span class="fas fa-cut m-1"></span>
Clip Video
{/if}
{/if}
<!-- <span class="fas fa-cut m-1"></span>
<button
type="submit"
class="btn btn-lg btn-primary preset-tonal-primary border border-primary-500"
disabled={submit_status == 'clipping'}
>
<!-- {#await ae_promises[hosted_file_id]} -->
{#if $ae_loc.files.processed_file_kv[hosted_file_id] && $ae_loc.files.processed_file_kv[hosted_file_id].submit_status == 'clipping'}
<span class="fas fa-spinner fa-spin m-1"></span>
<span class="highlight">Clipping...</span>
{:else}
<!-- {#if ae_promises[hosted_file_id]} -->
{#if $ae_loc.files.processed_file_kv[hosted_file_id] && $ae_loc.files.processed_file_kv[hosted_file_id].submit_status == 'clipped'}
<span class="fas fa-check m-1"></span>
Clipped
{:else}
<span class="fas fa-cut m-1"></span>
Clip Video
{/if}
{/if}
<!-- <span class="fas fa-cut m-1"></span>
Clip Video -->
</button>
</form>
</button>
</form>
{#await ae_promises[hosted_file_id]}
<span class="fas fa-spinner fa-spin m-1"></span>
<span class="highlight">Processing... This may take a few minutes.</span>
{:then}
{#if ae_promises[hosted_file_id]}
<span class="fas fa-download"></span> Ready to download below!
{:else}
<!-- <p>Fill out the form and select the video file to clip.</p> -->
{/if}
{/await}
</div>
{/each}
{#await ae_promises[hosted_file_id]}
<span class="fas fa-spinner fa-spin m-1"></span>
<span class="highlight">Processing... This may take a few minutes.</span>
{:then}
{#if ae_promises[hosted_file_id]}
<span class="fas fa-download"></span> Ready to download below!
{:else}
<!-- <p>Fill out the form and select the video file to clip.</p> -->
{/if}
{/await}
</div>
{/each}
<!-- <hr />
<!-- <hr />
{#await ae_promises.upload__hosted_file_obj}
<span class="fas fa-spinner fa-spin m-1"></span>

View File

@@ -1,90 +1,91 @@
<script lang="ts">
// Imports
// Import components and elements
// Imports
// Import components and elements
// Import storage, functions, and libraries
import type { key_val } from '$lib/stores/ae_stores';
// Import storage, functions, and libraries
import type { key_val } from '$lib/stores/ae_stores';
import { api } from '$lib/api/api';
import { ae_util } from '$lib/ae_utils/ae_utils';
import {
ae_snip,
ae_loc,
ae_sess,
ae_api,
ae_trig,
slct,
slct_trigger
} from '$lib/stores/ae_stores';
import { api } from '$lib/api/api';
import { ae_util } from '$lib/ae_utils/ae_utils';
import {
ae_snip,
ae_loc,
ae_sess,
ae_api,
ae_trig,
slct,
slct_trigger
} from '$lib/stores/ae_stores';
// Exports
// Exports
// export let hosted_file_id_li: string[] = [];
// export let hosted_file_obj_li: any[] = [];
// export let hosted_file_id_li: string[] = [];
// export let hosted_file_obj_li: any[] = [];
interface Props {
log_lvl?: number;
// export let hosted_file_obj_kv: key_val = {};
video_clip_file_kv?: key_val;
class_li_default?: string;
class_li?: string;
link_to_type: string;
link_to_id: string;
}
interface Props {
log_lvl?: number;
// export let hosted_file_obj_kv: key_val = {};
video_clip_file_kv?: key_val;
class_li_default?: string;
class_li?: string;
link_to_type: string;
link_to_id: string;
}
let {
log_lvl = 0,
video_clip_file_kv = $bindable({}),
class_li_default = 'flex flex-row flex-wrap gap-2 items-center justify-center w-full max-w-2xl p-2 mx-auto my-1 border border-gray-300 rounded-lg',
class_li = '',
link_to_type,
link_to_id
}: Props = $props();
let {
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>
<h3 class="h3">{Object.entries($ae_loc.files).length}× files clipped</h3>
<div class="{class_li_default} {class_li} ">
{#each Object.entries(video_clip_file_kv) as [hosted_file_id, hosted_file_obj]}
<button
type="button"
disabled={!$ae_loc.trusted_access}
onclick={() => {
ae_promises[hosted_file_id] = api.download_hosted_file({
api_cfg: $ae_api,
hosted_file_id: hosted_file_id,
return_file: true,
filename: hosted_file_obj.filename,
auto_download: true,
log_lvl: log_lvl
});
{#each Object.entries(video_clip_file_kv) as [hosted_file_id, hosted_file_obj]}
<button
type="button"
disabled={!$ae_loc.trusted_access}
onclick={() => {
ae_promises[hosted_file_id] = api.download_hosted_file({
api_cfg: $ae_api,
hosted_file_id: hosted_file_id,
return_file: true,
filename: hosted_file_obj.filename,
auto_download: true,
log_lvl: log_lvl
});
// window.postMessage({ type: 'download_event_file', hosted_file_id: idaa_archive_content_obj.hosted_file_id, filename: idaa_archive_content_obj.filename, auto_download: true }, '*');
}}
class="novi_btn btn btn-sm lg:btn-md preset-tonal-primary hover:preset-filled-primary-500 min-w-72 lg:min-w-96"
title={`Download this file:\n${hosted_file_obj.filename}\n[API] SHA256: ${hosted_file_obj?.hash_sha256?.slice(0, 10)}... Hosted ID: ${hosted_file_obj.hosted_file_id_random}`}
>
{#await ae_promises[hosted_file_id]}
<span class="fas fa-spinner fa-spin mx-1"></span>
<span class="">
Downloading
{#if $ae_sess.api_download_kv[hosted_file_id]}
{$ae_sess.api_download_kv[hosted_file_id].percent_completed}%
{/if}
:
</span>
{:then}
<span class="fas fa-{ae_util.file_extension_icon(hosted_file_obj?.file_extension)}"></span>
{/await}
// window.postMessage({ type: 'download_event_file', hosted_file_id: idaa_archive_content_obj.hosted_file_id, filename: idaa_archive_content_obj.filename, auto_download: true }, '*');
}}
class="novi_btn btn btn-sm lg:btn-md preset-tonal-primary hover:preset-filled-primary-500 min-w-72 lg:min-w-96"
title={`Download this file:\n${hosted_file_obj.filename}\n[API] SHA256: ${hosted_file_obj?.hash_sha256?.slice(0, 10)}... Hosted ID: ${hosted_file_obj.hosted_file_id_random}`}
>
{#await ae_promises[hosted_file_id]}
<span class="fas fa-spinner fa-spin mx-1"></span>
<span class="">
Downloading
{#if $ae_sess.api_download_kv[hosted_file_id]}
{$ae_sess.api_download_kv[hosted_file_id].percent_completed}%
{/if}
:
</span>
{:then}
<span class="fas fa-{ae_util.file_extension_icon(hosted_file_obj?.file_extension)}"
></span>
{/await}
<span class="grow">
{ae_util.shorten_filename({ filename: hosted_file_obj?.filename, max_length: 30 })}
</span>
<span class="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}
<span class="shrink">
{ae_util.format_bytes(hosted_file_obj?.size)}
</span>
</button>
{/each}
</div>

View File

@@ -1,408 +1,409 @@
<script lang="ts">
export let log_lvl: number = 0;
export let log_lvl: number = 0;
// Imports
// Import components and elements
import Element_input_files_tbl from '$lib/elements/element_input_files_tbl.svelte';
// Imports
// Import components and elements
import Element_input_files_tbl from '$lib/elements/element_input_files_tbl.svelte';
// Import storage, functions, and libraries
import type { key_val } from '$lib/stores/ae_stores';
// Import storage, functions, and libraries
import type { key_val } from '$lib/stores/ae_stores';
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 { api } from '$lib/api/api';
import {
ae_snip,
ae_loc,
ae_sess,
ae_api,
ae_trig,
slct,
slct_trigger
} from '$lib/stores/ae_stores';
// Exports
// Expecting these for link_to_type: 'event', 'event_location', 'archive_content', etc
export let link_to_type: string;
export let link_to_id: string;
// Exports
// Expecting these for link_to_type: 'event', 'event_location', 'archive_content', etc
export let link_to_type: string;
export let link_to_id: string;
export let input_name = 'file_list';
export let multiple: boolean = true;
export let required: boolean = true;
export let accept: string =
'audio/*, image/*, video/*, .bak, .cfg, .css, .csv, .doc, .docx, .gz, .htm, .html, .ini, .iso, .j2, .json, .key, .keynote, .md, .pdf, .ppt, .pptx, .rar, .rtf, .sql, .svelte, ttf, .txt, .xls, .xlsx, .xz, .zip, .bin, .dmg, .exe, .js, .msi, .php, .py, .sh';
export let input_name = 'file_list';
export let multiple: boolean = true;
export let required: boolean = true;
export let accept: string =
'audio/*, image/*, video/*, .bak, .cfg, .css, .csv, .doc, .docx, .gz, .htm, .html, .ini, .iso, .j2, .json, .key, .keynote, .md, .pdf, .ppt, .pptx, .rar, .rtf, .sql, .svelte, ttf, .txt, .xls, .xlsx, .xz, .zip, .bin, .dmg, .exe, .js, .msi, .php, .py, .sh';
export let class_li_default: string =
'flex flex-col gap-1 items-center justify-center w-full max-w-2xl mx-auto my-1';
export let class_li: string = '';
export let input_class_li: string[] = ['file_drop_area'];
export let table_class_li: string[] = ['table', 'table-sm', 'table-striped', '', 'text-sm'];
export let class_li_default: string =
'flex flex-col gap-1 items-center justify-center w-full max-w-2xl mx-auto my-1';
export let class_li: string = '';
export let input_class_li: string[] = ['file_drop_area'];
export let table_class_li: string[] = ['table', 'table-sm', 'table-striped', '', 'text-sm'];
export let upload_complete: boolean = false;
export let submit_status: null | string = null;
export let upload_complete: boolean = false;
export let submit_status: null | string = null;
export let hosted_file_id_li: string[] = [];
export let hosted_file_obj_li: any[] = [];
export let hosted_file_id_li: string[] = [];
export let hosted_file_obj_li: any[] = [];
// Local Variables
let task_id = link_to_id;
let input_file_list: any = null;
let ae_promises: key_val = {}; // Promise<any>;
let ae_triggers: key_val = {};
// Local Variables
let task_id = link_to_id;
let input_file_list: any = null;
let ae_promises: key_val = {}; // Promise<any>;
let ae_triggers: key_val = {};
let input_element_id = 'ae_comp__hosted_files_upload__input';
let 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 = {
start_time: null,
end_time: null,
reencode: null,
video_file: null
};
let download_clip_src: string;
let download_clip_filename: string;
// *** Functions and Logic
async function handle_submit_form_files(event) {
console.log('*** handle_submit_form() ***');
// *** Functions and Logic
async function handle_submit_form_files(event) {
console.log('*** handle_submit_form() ***');
$ae_sess.files.disable_submit__hosted_file_obj = true;
$ae_sess.files.submit_status = 'saving';
submit_status = 'saving';
upload_complete = false;
$ae_sess.files.disable_submit__hosted_file_obj = true;
$ae_sess.files.submit_status = 'saving';
submit_status = 'saving';
upload_complete = false;
hosted_file_id_li = [];
hosted_file_obj_li = [];
hosted_file_id_li = [];
hosted_file_obj_li = [];
let hosted_file_results;
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 = {
start_time: event.target.start_time.value,
end_time: event.target.end_time.value,
reencode: event.target.reencode.value,
video_file: event.target.file_list.files[0]
};
// const form_data = new FormData();
// const form_data = new FormData();
// form_data.append('start_time', event.target.start_time.value);
// form_data.append('end_time', event.target.end_time.value);
// form_data.append('start_time', event.target.start_time.value);
// form_data.append('end_time', event.target.end_time.value);
// if (event.target.reencode.value == '1' || event.target.reencode.value == 'true') {
// form_data.append('reencode', 'true');
// } else {
// form_data.append('reencode', 'false');
// }
// form_data.append('reencode', event.target.reencode.value);
// if (event.target.reencode.value == '1' || event.target.reencode.value == 'true') {
// form_data.append('reencode', 'true');
// } else {
// form_data.append('reencode', 'false');
// }
// form_data.append('reencode', event.target.reencode.value);
// form_data.append(`video_file`, event.target.video_file.files[0]);
// form_data.append(`video_file`, event.target.video_file.files[0]);
// let download_filename = `clipped_file_test.mp4`;
// let download_filename = `clipped_file_test.mp4`;
// let params = null;
// let params = null;
// let endpoint = '/hosted_file/clip_video';
// let endpoint = '/hosted_file/clip_video';
// console.log(form_data);
// console.log(form_data);
// params = null;
// params = null;
if (event.target[input_element_id].files.length > 0) {
task_id = link_to_id; // Ideally this should be the file hash, but we may be uploading multiple files at once. This should be done with a loop instead?
if (event.target[input_element_id].files.length > 0) {
task_id = link_to_id; // Ideally this should be the file hash, but we may be uploading multiple files at once. This should be done with a loop instead?
// Loop through each file and upload them individually in event.target[input_element_id].files
// The task_id should be the file hash.
// processed_file_list[i] has the file hash_sha256, hash_sha256_match, warnings, uploaded, uploaded_bytes, filename, and file_size_bytes.
for (let i = 0; i < event.target[input_element_id].files.length; i++) {
let tmp_file = event.target[input_element_id].files[i];
// 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;
task_id = $ae_sess.files.processed_file_list[i].hash_sha256;
hosted_file_results = await handle_input_upload_files([tmp_file], form_kv, task_id);
hosted_file_results = await handle_input_upload_files([tmp_file], form_kv, task_id);
if (hosted_file_results) {
console.log(`hosted_file_results:`, hosted_file_results);
} else {
console.log(`hosted_file_results:`, hosted_file_results);
}
}
// hosted_file_results = await handle_input_upload_files(event.target[input_element_id].files, task_id);
$ae_sess.files.processed_file_list = [];
$ae_sess = $ae_sess;
event.target.reset();
// await tick();
if (hosted_file_results) {
console.log(`hosted_file_results:`, hosted_file_results);
} else {
console.log(`hosted_file_results:`, hosted_file_results);
}
}
// hosted_file_results = await handle_input_upload_files(event.target[input_element_id].files, task_id);
$ae_sess.files.processed_file_list = [];
$ae_sess = $ae_sess;
event.target.reset();
// await tick();
if (log_lvl) {
console.log(`hosted_file_id_li: ${hosted_file_id_li}`, hosted_file_id_li);
} else if (log_lvl > 1) {
console.log('hosted_file_results:', hosted_file_results);
}
}
if (log_lvl) {
console.log(`hosted_file_id_li: ${hosted_file_id_li}`, hosted_file_id_li);
} else if (log_lvl > 1) {
console.log('hosted_file_results:', hosted_file_results);
}
}
$ae_sess.files.disable_submit__hosted_file_obj = false;
$ae_sess.files.submit_status = 'saved';
submit_status = 'saved';
upload_complete = true;
}
$ae_sess.files.disable_submit__hosted_file_obj = false;
$ae_sess.files.submit_status = 'saved';
submit_status = 'saved';
upload_complete = true;
}
async function handle_input_upload_files(input_upload_files, form_kv, task_id) {
console.log('*** handle_input_upload_files() ***');
console.log(input_upload_files);
console.log(form_kv);
async function handle_input_upload_files(input_upload_files, form_kv, task_id) {
console.log('*** handle_input_upload_files() ***');
console.log(input_upload_files);
console.log(form_kv);
const form_data = new FormData();
const form_data = new FormData();
// form_data.append('account_id', $ae_loc.account_id);
// form_data.append('link_to_type', link_to_type);
// form_data.append('link_to_id', link_to_id);
// form_data.append('account_id', $ae_loc.account_id);
// form_data.append('link_to_type', link_to_type);
// form_data.append('link_to_id', link_to_id);
form_data.append('start_time', form_kv.start_time);
form_data.append('end_time', form_kv.end_time);
form_data.append('start_time', form_kv.start_time);
form_data.append('end_time', form_kv.end_time);
if (form_kv.reencode == '1' || form_kv.reencode == 'true') {
form_data.append('reencode', 'true');
} else {
form_data.append('reencode', 'false');
}
if (form_kv.reencode == '1' || form_kv.reencode == 'true') {
form_data.append('reencode', 'true');
} else {
form_data.append('reencode', 'false');
}
// There should really only be one file uploaded at a time for now.
for (let i = 0; i < input_upload_files.length; i++) {
form_data.append(`video_file`, input_upload_files[i]);
}
// There should really only be one file uploaded at a time for now.
for (let i = 0; i < input_upload_files.length; i++) {
form_data.append(`video_file`, input_upload_files[i]);
}
// hash_sha256, uploaded, uploaded_bytes
// $ae_sess.files.processed_file_list[i] = {
// ...$ae_sess.files.processed_file_list[i],
// uploaded: $ae_sess.api_upload_kv[link_to_id].percent_completed,
// uploaded_bytes: $ae_sess.api_upload_kv[link_to_id].uploaded_bytes,
// };
// hash_sha256, uploaded, uploaded_bytes
// $ae_sess.files.processed_file_list[i] = {
// ...$ae_sess.files.processed_file_list[i],
// uploaded: $ae_sess.api_upload_kv[link_to_id].percent_completed,
// uploaded_bytes: $ae_sess.api_upload_kv[link_to_id].uploaded_bytes,
// };
let params = null;
let params = null;
let endpoint = '/hosted_file/clip_video';
let endpoint = '/hosted_file/clip_video';
console.log(form_data);
console.log(form_data);
params = null;
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);
// Uncomment and the post_promise is not seen by the "await" below
// post_promise = await api.post_object({api_cfg: $cfg.api, endpoint: endpoint, params: params, data:form_data});
// Uncomment so that the post_promise is not seen by the "await" below
ae_promises.upload__hosted_file_obj = api
.post_object({
api_cfg: $ae_api,
endpoint: endpoint,
params: params,
form_data: form_data,
return_blob: true,
filename: 'clipped_video_test.mp4',
auto_download: false,
task_id: task_id,
log_lvl: log_lvl
// retry_count: 1,
})
.then(async function (result) {
console.log(result);
let file_blob = new Blob([result.data]);
// console.log(file_blob);
let file_obj_url = window.URL.createObjectURL(file_blob); // The img src
// const url = window.URL.createObjectURL(new Blob([result.data]));
download_clip_src = file_obj_url;
// download_filename = file_obj_url;
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;
return true;
// // WARNING!!!! ONLY ONE FILE IS EXPECTED TO BE UPLOADED AT A TIME!!!
// // NOTE: The /hosted_file/upload_files endpoint will always return a list of successful files uploaded. In this case we are only uploading one file and expecting a list of one item.
// let x = 0;
// console.log(result[x]);
// let hosted_file_obj = result[x];
// // 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_id = hosted_file_obj.hosted_file_id_random;
// hosted_file_id_li.push(hosted_file_id);
// hosted_file_obj_li.push(hosted_file_obj);
// hosted_file_id_li.push(hosted_file_id);
// hosted_file_obj_li.push(hosted_file_obj);
// let hosted_file_data: key_val = {};
// hosted_file_data['hosted_file_id_random'] = hosted_file_id;
// hosted_file_data['for_type'] = link_to_type;
// hosted_file_data['for_id_random'] = link_to_id;
// hosted_file_data['filename'] = hosted_file_obj.filename;
// hosted_file_data['extension'] = hosted_file_obj.extension;
// hosted_file_data['enable'] = true;
// console.log(hosted_file_data);
// 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;
// return hosted_file_data;
// $ae_sess.files.new_upload_list[i].uploaded_bytes = 10; // fake 10 bytes at least...
// $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;
// });
// 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';
});
// 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;
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>
<div>
<!-- class:hidden={!$ae_loc.trusted_access} -->
<form on:submit|preventDefault={handle_submit_form_files} class="{class_li_default} {class_li}">
<label class="label"
>Start time (HH:MM:SS) <input
type="text"
name="start_time"
value="00:00:00"
placeholder="HH:MM:SS (00:01:30)"
class="input w-32"
/></label
>
<label class="label"
>End time (HH:MM:SS) <input
type="text"
name="end_time"
value="00:01:15"
placeholder="HH:MM:SS (01:05:25)"
class="input w-32"
/></label
>
<!-- class:hidden={!$ae_loc.trusted_access} -->
<form on:submit|preventDefault={handle_submit_form_files} class="{class_li_default} {class_li}">
<label class="label"
>Start time (HH:MM:SS) <input
type="text"
name="start_time"
value="00:00:00"
placeholder="HH:MM:SS (00:01:30)"
class="input w-32"
/></label
>
<label class="label"
>End time (HH:MM:SS) <input
type="text"
name="end_time"
value="00:01:15"
placeholder="HH:MM:SS (01:05:25)"
class="input w-32"
/></label
>
<label class="label"
>Re-encode (true or false) <input
type="text"
name="reencode"
value="false"
placeholder="true"
class="input w-32"
/></label
>
<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}
<div class="text-lg flex flex-row gap-1 items-center justify-center">
<span class="fas fa-spinner fa-spin m-1"></span>
<span class="">
Uploading
{#if $ae_sess.api_upload_kv[task_id]}
{$ae_sess.api_upload_kv[task_id].percent_completed}%
{/if}
</span>
</div>
{/await}
<label
for="ae_comp__hosted_files_upload__input"
class="svelte_input_file_label text-center"
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
>
<slot name="label">
<div>
<span class="fas fa-upload"></span>
<!-- Select files to upload -->
<!-- <span class="fas fa-file-archive"></span> -->
<strong class="bg-blue-300 p-1">Upload files</strong>
<!-- (drag and drop) -->
</div>
<span class="text-sm text-gray-600 dark:text-gray-400 italic">
<strong>Video files only</strong><br />
(mp4 or mkv)
</span>
</slot>
</label>
<label
for="ae_comp__hosted_files_upload__input"
class="svelte_input_file_label text-center"
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
>
<slot name="label">
<div>
<span class="fas fa-upload"></span>
<!-- Select files to upload -->
<!-- <span class="fas fa-file-archive"></span> -->
<strong class="bg-blue-300 p-1">Upload files</strong>
<!-- (drag and drop) -->
</div>
<span class="text-sm text-gray-600 dark:text-gray-400 italic">
<strong>Video files only</strong><br />
(mp4 or mkv)
</span>
</slot>
</label>
<input
id={input_element_id}
type="file"
bind:files={input_file_list}
{multiple}
{required}
{accept}
name={input_name}
class="svelte_input_file_element file-dropzone-input block w-full text-lg text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 dark:text-gray-400 focus:outline-hidden dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 {input_class_li.join(
' '
)}"
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
/>
<input
id={input_element_id}
type="file"
bind:files={input_file_list}
{multiple}
{required}
{accept}
name={input_name}
class="svelte_input_file_element file-dropzone-input block w-full text-lg text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 dark:text-gray-400 focus:outline-hidden dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 {input_class_li.join(
' '
)}"
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
/>
<Element_input_files_tbl
bind:input_file_list
bind:file_list_status={$ae_sess.files.status__file_list}
bind:processed_file_list={$ae_sess.files.processed_file_list}
{table_class_li}
/>
<Element_input_files_tbl
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}
/>
<button
type="submit"
class="btn btn-lg btn-primary preset-tonal-primary border border-primary-500 hover:preset-tonal-success border border-success-500 w-54"
disabled={$ae_sess.files.disable_submit__hosted_file_obj ||
$ae_sess.files.status__file_list != 'ready'}
>
{#await ae_promises.upload__hosted_file_obj}
<span class="fas fa-spinner fa-spin m-1"></span>
<span class="">
Uploading
{#if $ae_sess.api_upload_kv[task_id]}
{$ae_sess.api_upload_kv[task_id].percent_completed}%
{/if}
</span>
{:then}
<span class="fas fa-upload m-1"></span>
<span class="text-sm"> Upload? </span>
<!-- <span class="fas fa-save m-1"></span> -->
<span class="grow font-bold">
{#if $ae_sess.files.processed_file_list?.length > 0}
<!-- {#each $ae_sess.files.processed_file_list as file_obj, index}
<button
type="submit"
class="btn btn-lg btn-primary preset-tonal-primary border border-primary-500 hover:preset-tonal-success border border-success-500 w-54"
disabled={$ae_sess.files.disable_submit__hosted_file_obj ||
$ae_sess.files.status__file_list != 'ready'}
>
{#await ae_promises.upload__hosted_file_obj}
<span class="fas fa-spinner fa-spin m-1"></span>
<span class="">
Uploading
{#if $ae_sess.api_upload_kv[task_id]}
{$ae_sess.api_upload_kv[task_id].percent_completed}%
{/if}
</span>
{:then}
<span class="fas fa-upload m-1"></span>
<span class="text-sm"> Upload? </span>
<!-- <span class="fas fa-save m-1"></span> -->
<span class="grow font-bold">
{#if $ae_sess.files.processed_file_list?.length > 0}
<!-- {#each $ae_sess.files.processed_file_list as file_obj, index}
<span class="text-xs">
{file_obj.filename}
</span>
{/each} -->
{$ae_sess.files.processed_file_list.length == 1
? `${$ae_sess.files.processed_file_list.length} file`
: `${$ae_sess.files.processed_file_list.length} files`}
{:else}
<span class="text-xs"> No files selected </span>
{/if}
<!-- Files -->
</span>
{/await}
</button>
</form>
{$ae_sess.files.processed_file_list.length == 1
? `${$ae_sess.files.processed_file_list.length} file`
: `${$ae_sess.files.processed_file_list.length} files`}
{:else}
<span class="text-xs"> No files selected </span>
{/if}
<!-- Files -->
</span>
{/await}
</button>
</form>
<hr />
<hr />
{#await ae_promises.upload__hosted_file_obj}
<span class="fas fa-spinner fa-spin m-1"></span>
<p class="highlight">Converting... This may take a few minutes.</p>
{:then}
{#if ae_promises.upload__hosted_file_obj}
<a
href={download_clip_src}
download={download_clip_filename}
class="ae_btn btn_lg btn_primary"><span class="fas fa-download"></span> Ready to Download</a
>
{:else}
<p>Fill out the form and select the video file to clip.</p>
{/if}
{/await}
{#await ae_promises.upload__hosted_file_obj}
<span class="fas fa-spinner fa-spin m-1"></span>
<p class="highlight">Converting... This may take a few minutes.</p>
{:then}
{#if ae_promises.upload__hosted_file_obj}
<a
href={download_clip_src}
download={download_clip_filename}
class="ae_btn btn_lg btn_primary"
><span class="fas fa-download"></span> Ready to Download</a
>
{:else}
<p>Fill out the form and select the video file to clip.</p>
{/if}
{/await}
</div>

View File

@@ -1,153 +1,156 @@
<script lang="ts">
// *** Import Svelte specific
// *** Import Svelte specific
// Eventually this should use Lucide icons instead of FontAwesome
// import {
// ArrowDown01, ArrowDown10, ArrowDownUp,
// BookHeart, BriefcaseBusiness,
// CalendarClock, CalendarOff, Clock, CodeXml, Copy,
// Eye, EyeOff,
// Flag, FlagOff, FileX, Fingerprint,
// Globe, Group,
// Hash, History,
// LockKeyhole, LockKeyholeOpen,
// MessageSquareWarning, Menu, Minus,
// NotebookPen, NotebookText, NotepadTextDashed,
// Pencil, PenLine, Plus,
// RemoveFormatting,
// Search, Settings,
// Shapes, Share2, ShieldCheck, ShieldMinus, Siren, Skull,
// SquareLibrary,
// Tags, Trash2, TypeOutline,
// X
// } from '@lucide/svelte';
// Eventually this should use Lucide icons instead of FontAwesome
// import {
// ArrowDown01, ArrowDown10, ArrowDownUp,
// BookHeart, BriefcaseBusiness,
// CalendarClock, CalendarOff, Clock, CodeXml, Copy,
// Eye, EyeOff,
// Flag, FlagOff, FileX, Fingerprint,
// Globe, Group,
// Hash, History,
// LockKeyhole, LockKeyholeOpen,
// MessageSquareWarning, Menu, Minus,
// NotebookPen, NotebookText, NotepadTextDashed,
// Pencil, PenLine, Plus,
// RemoveFormatting,
// Search, Settings,
// Shapes, Share2, ShieldCheck, ShieldMinus, Siren, Skull,
// SquareLibrary,
// Tags, Trash2, TypeOutline,
// X
// } from '@lucide/svelte';
// *** Import Aether specific variables and functions
import type { key_val } from '$lib/stores/ae_stores';
import { ae_util } from '$lib/ae_utils/ae_utils';
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 Aether specific variables and functions
import type { key_val } from '$lib/stores/ae_stores';
import { ae_util } from '$lib/ae_utils/ae_utils';
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';
interface Props {
log_lvl?: number;
hosted_file_id: null | string;
hosted_file_obj: null | key_val;
filename?: null | string;
max_length?: number;
auto_download?: boolean;
linked_to_type?: null | string;
linked_to_id?: null | string;
download_complete?: null | boolean;
download_percent?: number;
download_status_msg?: string;
classes?: string;
}
interface Props {
log_lvl?: number;
hosted_file_id: null | string;
hosted_file_obj: null | key_val;
filename?: null | string;
max_length?: number;
auto_download?: boolean;
linked_to_type?: null | string;
linked_to_id?: null | string;
download_complete?: null | boolean;
download_percent?: number;
download_status_msg?: string;
classes?: string;
}
let {
log_lvl = 0,
hosted_file_id,
hosted_file_obj,
filename = $bindable(null),
max_length = $bindable(30),
auto_download = true,
linked_to_type = $bindable(null),
linked_to_id = $bindable(null),
download_complete = $bindable(),
download_percent = $bindable(),
download_status_msg = $bindable('Not started'),
classes = 'btn btn-sm lg:btn-md preset-tonal-tertiary border border-tertiary-500 hover:preset-filled-tertiary-500 min-w-48'
}: Props = $props();
let {
log_lvl = 0,
hosted_file_id,
hosted_file_obj,
filename = $bindable(null),
max_length = $bindable(30),
auto_download = true,
linked_to_type = $bindable(null),
linked_to_id = $bindable(null),
download_complete = $bindable(),
download_percent = $bindable(),
download_status_msg = $bindable('Not started'),
classes = 'btn btn-sm lg:btn-md preset-tonal-tertiary border border-tertiary-500 hover:preset-filled-tertiary-500 min-w-48'
}: Props = $props();
if (log_lvl) {
console.log(
`ae_comp__hosted_files_download_button.svelte hosted_file_id=${hosted_file_id}`,
hosted_file_obj
);
}
if (log_lvl) {
console.log(
`ae_comp__hosted_files_download_button.svelte hosted_file_id=${hosted_file_id}`,
hosted_file_obj
);
}
let ae_promises: key_val = $state({});
let ae_promises: key_val = $state({});
$effect(() => {
if ($ae_sess?.api_download_kv[hosted_file_obj?.hosted_file_id_random]?.percent_completed) {
download_percent =
$ae_sess.api_download_kv[hosted_file_obj?.hosted_file_id_random].percent_completed;
}
});
$effect(() => {
if ($ae_sess?.api_download_kv[hosted_file_obj?.hosted_file_id_random]?.percent_completed) {
download_percent =
$ae_sess.api_download_kv[hosted_file_obj?.hosted_file_id_random].percent_completed;
}
});
</script>
{#if hosted_file_id && hosted_file_obj}
<button
type="button"
disabled={!$ae_loc.trusted_access}
class={classes ?? 'btn'}
onclick={() => {
download_complete = false;
download_status_msg = 'Downloading...';
ae_promises[hosted_file_obj.hosted_file_id_random] = api
.download_hosted_file({
api_cfg: $ae_api,
hosted_file_id: hosted_file_obj.hosted_file_id_random,
return_file: true,
filename: filename ?? hosted_file_obj.filename,
auto_download: auto_download,
log_lvl: log_lvl
})
.then((result) => {
if (result === null) {
console.log('File not found (404)');
download_complete = null;
download_status_msg = 'File not found';
} else if (result === false) {
console.log('Possible error with API server (check network and server status)');
download_complete = false;
download_status_msg = 'Failed to download';
} else {
// console.log('File found and downloaded');
download_complete = true;
download_status_msg = 'File downloaded';
}
return result;
});
}}
title={`Download this file:\n${filename ?? hosted_file_obj?.filename}\n[API] SHA256: ${hosted_file_obj?.hash_sha256?.slice(0, 10)}...\nHosted ID: ${hosted_file_obj?.hosted_file_id_random}\n Linked to: ${linked_to_type} ID: ${linked_to_id}`}
>
{#await ae_promises[hosted_file_obj.hosted_file_id_random]}
<span class="fas fa-spinner fa-spin mx-1"></span>
<span class="">
Downloading
{#if $ae_sess.api_download_kv[hosted_file_obj.hosted_file_id_random]}
{$ae_sess.api_download_kv[hosted_file_obj.hosted_file_id_random].percent_completed}%
{/if}
:
</span>
{:then}
<span class="fas fa-{ae_util.file_extension_icon(hosted_file_obj?.extension)}"></span>
{/await}
<button
type="button"
disabled={!$ae_loc.trusted_access}
class={classes ?? 'btn'}
onclick={() => {
download_complete = false;
download_status_msg = 'Downloading...';
ae_promises[hosted_file_obj.hosted_file_id_random] = api
.download_hosted_file({
api_cfg: $ae_api,
hosted_file_id: hosted_file_obj.hosted_file_id_random,
return_file: true,
filename: filename ?? hosted_file_obj.filename,
auto_download: auto_download,
log_lvl: log_lvl
})
.then((result) => {
if (result === null) {
console.log('File not found (404)');
download_complete = null;
download_status_msg = 'File not found';
} else if (result === false) {
console.log(
'Possible error with API server (check network and server status)'
);
download_complete = false;
download_status_msg = 'Failed to download';
} else {
// console.log('File found and downloaded');
download_complete = true;
download_status_msg = 'File downloaded';
}
return result;
});
}}
title={`Download this file:\n${filename ?? hosted_file_obj?.filename}\n[API] SHA256: ${hosted_file_obj?.hash_sha256?.slice(0, 10)}...\nHosted ID: ${hosted_file_obj?.hosted_file_id_random}\n Linked to: ${linked_to_type} ID: ${linked_to_id}`}
>
{#await ae_promises[hosted_file_obj.hosted_file_id_random]}
<span class="fas fa-spinner fa-spin mx-1"></span>
<span class="">
Downloading
{#if $ae_sess.api_download_kv[hosted_file_obj.hosted_file_id_random]}
{$ae_sess.api_download_kv[hosted_file_obj.hosted_file_id_random]
.percent_completed}%
{/if}
:
</span>
{:then}
<span class="fas fa-{ae_util.file_extension_icon(hosted_file_obj?.extension)}"></span>
{/await}
{#if download_complete === null}
<span class="text-red-800 dark:text-red-200">File not found</span>
{:else if download_complete === false}
<span class="text-red-800 dark:text-red-200">Failed to download!</span>
{/if}
{#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}
<button type="button" disabled class={classes ?? 'btn'} title="No file selected">
<span class="fas fa-{ae_util.file_extension_icon(hosted_file_obj?.extension)}"></span>
<span class="grow"> No file info </span>
</button>
<button type="button" disabled class={classes ?? 'btn'} title="No file selected">
<span class="fas fa-{ae_util.file_extension_icon(hosted_file_obj?.extension)}"></span>
<span class="grow"> No file info </span>
</button>
{/if}

View File

@@ -1,281 +1,281 @@
<script lang="ts">
export let log_lvl: number = 0;
export let log_lvl: number = 0;
// Imports
// Import components and elements
import Element_input_files_tbl from '$lib/elements/element_input_files_tbl.svelte';
// Imports
// Import components and elements
import Element_input_files_tbl from '$lib/elements/element_input_files_tbl.svelte';
// Import storage, functions, and libraries
import type { key_val } from '$lib/stores/ae_stores';
// Import storage, functions, and libraries
import type { key_val } from '$lib/stores/ae_stores';
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 { api } from '$lib/api/api';
import {
ae_snip,
ae_loc,
ae_sess,
ae_api,
ae_trig,
slct,
slct_trigger
} from '$lib/stores/ae_stores';
// Exports
// Expecting these for link_to_type: 'event', 'event_location', 'archive_content', etc
export let link_to_type: string;
export let link_to_id: string;
// Exports
// Expecting these for link_to_type: 'event', 'event_location', 'archive_content', etc
export let link_to_type: string;
export let link_to_id: string;
export let input_name = 'file_list';
export let multiple: boolean = true;
export let required: boolean = true;
export let accept: string =
'audio/*, image/*, video/*, .bak, .cfg, .css, .csv, .doc, .docx, .gz, .htm, .html, .ini, .iso, .j2, .json, .key, .keynote, .md, .pdf, .ppt, .pptx, .rar, .rtf, .sql, .svelte, ttf, .txt, .xls, .xlsx, .xz, .zip, .bin, .dmg, .exe, .js, .msi, .php, .py, .sh';
export let input_name = 'file_list';
export let multiple: boolean = true;
export let required: boolean = true;
export let accept: string =
'audio/*, image/*, video/*, .bak, .cfg, .css, .csv, .doc, .docx, .gz, .htm, .html, .ini, .iso, .j2, .json, .key, .keynote, .md, .pdf, .ppt, .pptx, .rar, .rtf, .sql, .svelte, ttf, .txt, .xls, .xlsx, .xz, .zip, .bin, .dmg, .exe, .js, .msi, .php, .py, .sh';
export let class_li_default: string =
'flex flex-col gap-1 items-center justify-center w-full max-w-2xl mx-auto my-1';
export let class_li: string = '';
export let input_class_li: string[] = ['file_drop_area'];
export let table_class_li: string[] = ['table', 'table-sm', 'table-striped', '', 'text-sm'];
export let class_li_default: string =
'flex flex-col gap-1 items-center justify-center w-full max-w-2xl mx-auto my-1';
export let class_li: string = '';
export let input_class_li: string[] = ['file_drop_area'];
export let table_class_li: string[] = ['table', 'table-sm', 'table-striped', '', 'text-sm'];
export let upload_complete: boolean = false;
export let submit_status: null | string = null;
export let upload_complete: boolean = false;
export let submit_status: null | string = null;
export let hosted_file_id_li: string[] = [];
export let hosted_file_obj_li: any[] = [];
export let hosted_file_obj_kv: key_val = {};
export let hosted_file_id_li: string[] = [];
export let hosted_file_obj_li: any[] = [];
export let hosted_file_obj_kv: key_val = {};
// Local Variables
let task_id = link_to_id;
let input_file_list: any = null;
let ae_promises: key_val = {}; // Promise<any>;
let ae_triggers: key_val = {};
// Local Variables
let task_id = link_to_id;
let input_file_list: any = null;
let ae_promises: key_val = {}; // Promise<any>;
let ae_triggers: key_val = {};
let input_element_id = 'ae_comp__hosted_files_upload__input';
let 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
async function handle_submit_form_files(event: SubmitEvent) {
console.log('*** handle_submit_form() ***');
if (!event) {
return;
}
if (!event) {
return;
}
$ae_sess.files.disable_submit__hosted_file_obj = true;
$ae_sess.files.submit_status = 'saving';
submit_status = 'saving';
upload_complete = false;
$ae_sess.files.disable_submit__hosted_file_obj = true;
$ae_sess.files.submit_status = 'saving';
submit_status = 'saving';
upload_complete = false;
hosted_file_id_li = [];
hosted_file_obj_li = [];
hosted_file_obj_kv = {};
hosted_file_id_li = [];
hosted_file_obj_li = [];
hosted_file_obj_kv = {};
let hosted_file_results;
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;
if (
target &&
target[input_element_id] &&
(target[input_element_id] as HTMLInputElement)?.files &&
(target[input_element_id] as HTMLInputElement).files.length > 0
) {
task_id = link_to_id; // Ideally this should be the file hash, but we may be uploading multiple files at once. This should be done with a loop instead?
// Loop through each file and upload them individually in event.target[input_element_id].files
// The task_id should be the file hash.
// processed_file_list[i] has the file hash_sha256, hash_sha256_match, warnings, uploaded, uploaded_bytes, filename, and file_size_bytes.
for (let i = 0; i < event.target[input_element_id].files.length; i++) {
let tmp_file = event.target[input_element_id].files[i];
// 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;
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);
hosted_file_results = await handle_input_upload_files({
input_upload_files: [tmp_file],
task_id: task_id
});
if (hosted_file_results) {
console.log(`hosted_file_results:`, hosted_file_results);
} else {
console.log(`hosted_file_results:`, hosted_file_results);
}
}
// hosted_file_results = await handle_input_upload_files(event.target[input_element_id].files, task_id);
$ae_sess.files.processed_file_list = [];
$ae_sess = $ae_sess; // Is this needed? 2025-03-17
event.target.reset();
// await tick();
if (hosted_file_results) {
console.log(`hosted_file_results:`, hosted_file_results);
} else {
console.log(`hosted_file_results:`, hosted_file_results);
}
}
// hosted_file_results = await handle_input_upload_files(event.target[input_element_id].files, task_id);
$ae_sess.files.processed_file_list = [];
$ae_sess = $ae_sess; // Is this needed? 2025-03-17
event.target.reset();
// await tick();
if (log_lvl) {
console.log(`hosted_file_id_li: ${hosted_file_id_li}`, hosted_file_id_li);
} else if (log_lvl > 1) {
console.log('hosted_file_results:', hosted_file_results);
}
}
if (log_lvl) {
console.log(`hosted_file_id_li: ${hosted_file_id_li}`, hosted_file_id_li);
} else if (log_lvl > 1) {
console.log('hosted_file_results:', hosted_file_results);
}
}
$ae_sess.files.disable_submit__hosted_file_obj = false;
$ae_sess.files.submit_status = 'saved';
submit_status = 'saved';
upload_complete = true;
}
$ae_sess.files.disable_submit__hosted_file_obj = false;
$ae_sess.files.submit_status = 'saved';
submit_status = 'saved';
upload_complete = true;
}
async function handle_input_upload_files({
input_upload_files,
task_id
}: {
input_upload_files: any[];
task_id: string;
}) {
console.log('*** handle_input_upload_files() ***');
async function handle_input_upload_files({
input_upload_files,
task_id
}: {
input_upload_files: any[];
task_id: string;
}) {
console.log('*** handle_input_upload_files() ***');
const form_data = new FormData();
const form_data = new FormData();
form_data.append('account_id', $ae_loc.account_id);
form_data.append('link_to_type', link_to_type);
form_data.append('link_to_id', link_to_id);
form_data.append('account_id', $ae_loc.account_id);
form_data.append('link_to_type', link_to_type);
form_data.append('link_to_id', link_to_id);
for (let i = 0; i < input_upload_files.length; i++) {
form_data.append(`file_list`, input_upload_files[i]);
}
for (let i = 0; i < input_upload_files.length; i++) {
form_data.append(`file_list`, input_upload_files[i]);
}
// hash_sha256, uploaded, uploaded_bytes
// $ae_sess.files.processed_file_list[i] = {
// ...$ae_sess.files.processed_file_list[i],
// uploaded: $ae_sess.api_upload_kv[link_to_id].percent_completed,
// uploaded_bytes: $ae_sess.api_upload_kv[link_to_id].uploaded_bytes,
// };
// hash_sha256, uploaded, uploaded_bytes
// $ae_sess.files.processed_file_list[i] = {
// ...$ae_sess.files.processed_file_list[i],
// uploaded: $ae_sess.api_upload_kv[link_to_id].percent_completed,
// uploaded_bytes: $ae_sess.api_upload_kv[link_to_id].uploaded_bytes,
// };
let params = null;
let params = null;
let endpoint = '/hosted_file/upload_files';
let endpoint = '/hosted_file/upload_files';
console.log(form_data);
console.log(form_data);
params = null;
params = null;
// Uncomment and the post_promise is not seen by the "await" below
// post_promise = await api.post_object({api_cfg: $cfg.api, endpoint: endpoint, params: params, data:form_data});
// Uncomment so that the post_promise is not seen by the "await" below
ae_promises.upload__hosted_file_obj = api
.post_object({
api_cfg: $ae_api,
endpoint: endpoint,
// params: params,
form_data: form_data,
task_id: task_id,
log_lvl: log_lvl
// retry_count: 1,
})
.then(async function (result) {
// WARNING!!!! ONLY ONE FILE IS EXPECTED TO BE UPLOADED AT A TIME!!!
// NOTE: The /hosted_file/upload_files endpoint will always return a list of successful files uploaded. In this case we are only uploading one file and expecting a list of one item.
let x = 0;
console.log(result[x]);
let hosted_file_obj = result[x];
// Uncomment and the post_promise is not seen by the "await" below
// post_promise = await api.post_object({api_cfg: $cfg.api, endpoint: endpoint, params: params, data:form_data});
// Uncomment so that the post_promise is not seen by the "await" below
ae_promises.upload__hosted_file_obj = api
.post_object({
api_cfg: $ae_api,
endpoint: endpoint,
// params: params,
form_data: form_data,
task_id: task_id,
log_lvl: log_lvl
// retry_count: 1,
})
.then(async function (result) {
// WARNING!!!! ONLY ONE FILE IS EXPECTED TO BE UPLOADED AT A TIME!!!
// NOTE: The /hosted_file/upload_files endpoint will always return a list of successful files uploaded. In this case we are only uploading one file and expecting a list of one item.
let x = 0;
console.log(result[x]);
let hosted_file_obj = result[x];
let hosted_file_id = hosted_file_obj.hosted_file_id_random;
let hosted_file_id = hosted_file_obj.hosted_file_id_random;
hosted_file_id_li.push(hosted_file_id);
hosted_file_obj_li.push(hosted_file_obj);
hosted_file_id_li.push(hosted_file_id);
hosted_file_obj_li.push(hosted_file_obj);
let hosted_file_data: key_val = {};
hosted_file_data['id'] = hosted_file_id;
hosted_file_data['hosted_file_id'] = hosted_file_id;
hosted_file_data['hosted_file_id_random'] = hosted_file_id;
hosted_file_data['for_type'] = link_to_type;
hosted_file_data['for_id'] = link_to_id;
hosted_file_data['for_id_random'] = link_to_id;
hosted_file_data['hash_sha256'] = hosted_file_obj.hash_sha256;
hosted_file_data['filename'] = hosted_file_obj.filename;
hosted_file_data['extension'] = hosted_file_obj.extension;
hosted_file_data['content_type'] = hosted_file_obj.content_type;
hosted_file_data['size'] = hosted_file_obj.size;
hosted_file_data['enable'] = true;
hosted_file_data['created_on'] = hosted_file_obj.created_on;
hosted_file_data['updated_on'] = hosted_file_obj.updated_on;
console.log(hosted_file_data);
let hosted_file_data: key_val = {};
hosted_file_data['id'] = hosted_file_id;
hosted_file_data['hosted_file_id'] = hosted_file_id;
hosted_file_data['hosted_file_id_random'] = hosted_file_id;
hosted_file_data['for_type'] = link_to_type;
hosted_file_data['for_id'] = link_to_id;
hosted_file_data['for_id_random'] = link_to_id;
hosted_file_data['hash_sha256'] = hosted_file_obj.hash_sha256;
hosted_file_data['filename'] = hosted_file_obj.filename;
hosted_file_data['extension'] = hosted_file_obj.extension;
hosted_file_data['content_type'] = hosted_file_obj.content_type;
hosted_file_data['size'] = hosted_file_obj.size;
hosted_file_data['enable'] = true;
hosted_file_data['created_on'] = hosted_file_obj.created_on;
hosted_file_data['updated_on'] = hosted_file_obj.updated_on;
console.log(hosted_file_data);
hosted_file_obj_kv[hosted_file_id] = hosted_file_data;
hosted_file_obj_kv[hosted_file_id] = hosted_file_data;
return hosted_file_data;
return hosted_file_data;
// $ae_sess.files.new_upload_list[i].uploaded_bytes = 10; // fake 10 bytes at least...
// $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;
// });
// 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';
});
// 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;
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>
<!-- class:hidden={!$ae_loc.trusted_access} -->
<form on:submit|preventDefault={handle_submit_form_files} class="{class_li_default} {class_li}">
{#await ae_promises.upload__hosted_file_obj}
<div class="text-lg flex flex-row gap-1 items-center justify-center">
<span class="fas fa-spinner fa-spin m-1"></span>
<span class="">
Uploading
{#if $ae_sess.api_upload_kv[task_id]}
{$ae_sess.api_upload_kv[task_id].percent_completed}%
{/if}
</span>
</div>
{/await}
{#await ae_promises.upload__hosted_file_obj}
<div class="text-lg flex flex-row gap-1 items-center justify-center">
<span class="fas fa-spinner fa-spin m-1"></span>
<span class="">
Uploading
{#if $ae_sess.api_upload_kv[task_id]}
{$ae_sess.api_upload_kv[task_id].percent_completed}%
{/if}
</span>
</div>
{/await}
<label
for="ae_comp__hosted_files_upload__input"
class="svelte_input_file_label text-center"
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
>
<slot name="label">
<div>
<span class="fas fa-upload"></span>
<!-- Select files to upload -->
<!-- <span class="fas fa-file-archive"></span> -->
<strong class="bg-blue-300 p-1">Upload files</strong>
<!-- (drag and drop) -->
</div>
<span class="text-sm text-gray-600 dark:text-gray-400 italic">
<strong>Presentation related files only</strong><br />
(PowerPoint, Keynote, PDF, mp4, Word Doc, Excel, txt, etc)
</span>
</slot>
</label>
<label
for="ae_comp__hosted_files_upload__input"
class="svelte_input_file_label text-center"
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
>
<slot name="label">
<div>
<span class="fas fa-upload"></span>
<!-- Select files to upload -->
<!-- <span class="fas fa-file-archive"></span> -->
<strong class="bg-blue-300 p-1">Upload files</strong>
<!-- (drag and drop) -->
</div>
<span class="text-sm text-gray-600 dark:text-gray-400 italic">
<strong>Presentation related files only</strong><br />
(PowerPoint, Keynote, PDF, mp4, Word Doc, Excel, txt, etc)
</span>
</slot>
</label>
<input
id={input_element_id}
type="file"
bind:files={input_file_list}
{multiple}
{required}
{accept}
name={input_name}
class="
<input
id={input_element_id}
type="file"
bind:files={input_file_list}
{multiple}
{required}
{accept}
name={input_name}
class="
svelte_input_file_element
file-dropzone-input
px-1
@@ -286,49 +286,49 @@
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(' ')}
"
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
/>
class:hidden={$ae_sess.files.disable_submit__hosted_file_obj}
/>
<Element_input_files_tbl
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}
/>
<Element_input_files_tbl
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}
/>
<button
type="submit"
class="btn btn-lg btn-primary preset-tonal-primary border border-primary-500 hover:preset-tonal-success border border-success-500 w-54"
disabled={$ae_sess.files.disable_submit__hosted_file_obj ||
$ae_sess.files.status__file_list != 'ready'}
>
{#await ae_promises.upload__hosted_file_obj}
<span class="fas fa-spinner fa-spin m-1"></span>
<span class="">
Uploading
{#if $ae_sess.api_upload_kv[task_id]}
{$ae_sess.api_upload_kv[task_id].percent_completed}%
{/if}
</span>
{:then}
<span class="fas fa-upload m-1"></span>
<span class="text-sm"> Upload? </span>
<!-- <span class="fas fa-save m-1"></span> -->
<span class="grow font-bold">
{#if $ae_sess.files.processed_file_list?.length > 0}
<!-- {#each $ae_sess.files.processed_file_list as file_obj, index}
<button
type="submit"
class="btn btn-lg btn-primary preset-tonal-primary border border-primary-500 hover:preset-tonal-success border border-success-500 w-54"
disabled={$ae_sess.files.disable_submit__hosted_file_obj ||
$ae_sess.files.status__file_list != 'ready'}
>
{#await ae_promises.upload__hosted_file_obj}
<span class="fas fa-spinner fa-spin m-1"></span>
<span class="">
Uploading
{#if $ae_sess.api_upload_kv[task_id]}
{$ae_sess.api_upload_kv[task_id].percent_completed}%
{/if}
</span>
{:then}
<span class="fas fa-upload m-1"></span>
<span class="text-sm"> Upload? </span>
<!-- <span class="fas fa-save m-1"></span> -->
<span class="grow font-bold">
{#if $ae_sess.files.processed_file_list?.length > 0}
<!-- {#each $ae_sess.files.processed_file_list as file_obj, index}
<span class="text-xs">
{file_obj.filename}
</span>
{/each} -->
{$ae_sess.files.processed_file_list.length == 1
? `${$ae_sess.files.processed_file_list.length} file`
: `${$ae_sess.files.processed_file_list.length} files`}
{:else}
<span class="text-xs"> No files selected </span>
{/if}
<!-- Files -->
</span>
{/await}
</button>
{$ae_sess.files.processed_file_list.length == 1
? `${$ae_sess.files.processed_file_list.length} file`
: `${$ae_sess.files.processed_file_list.length} files`}
{:else}
<span class="text-xs"> No files selected </span>
{/if}
<!-- Files -->
</span>
{/await}
</button>
</form>

File diff suppressed because it is too large Load Diff

View File

@@ -1,23 +1,23 @@
export interface Account {
id: string;
// id_random: string;
account_id: string;
account_id_random: string;
id: string;
// id_random: string;
account_id: string;
account_id_random: string;
code?: string;
name: string;
short_name?: null | string;
description?: null | string;
code?: string;
name: string;
short_name?: null | string;
description?: null | string;
enable: null | boolean;
enable_from?: null | Date;
enable_to?: null | Date;
enable: null | boolean;
enable_from?: null | Date;
enable_to?: null | Date;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
}

View File

@@ -5,360 +5,368 @@ const ae_promises: key_val = {};
// Updated 2024-10-23
export async function load_ae_obj_id__activity_log({
api_cfg,
activity_log_id,
// inc_other_li = false,
try_cache = false,
log_lvl = 0
api_cfg,
activity_log_id,
// inc_other_li = false,
try_cache = false,
log_lvl = 0
}: {
api_cfg: any;
activity_log_id: string;
// inc_other_li?: boolean,
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
activity_log_id: string;
// inc_other_li?: boolean,
try_cache?: boolean;
log_lvl?: number;
}) {
console.log(`*** load_ae_obj_id__activity_log() *** activity_log_id=${activity_log_id}`);
console.log(`*** load_ae_obj_id__activity_log() *** activity_log_id=${activity_log_id}`);
const params = {};
const params = {};
ae_promises.load__activity_log_obj = await api
.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'activity_log',
obj_id: activity_log_id, // NOTE: This is the FQDN, not normally the ID.
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
params: params,
log_lvl: log_lvl
})
.then(function (activity_log_obj_get_result) {
if (activity_log_obj_get_result) {
// if (try_cache) {
// // This is expecting a list
// db_save_ae_obj_li__activity_log({
// obj_type: 'activity_log',
// obj_li: [activity_log_obj_get_result]
// });
// }
return activity_log_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
ae_promises.load__activity_log_obj = await api
.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'activity_log',
obj_id: activity_log_id, // NOTE: This is the FQDN, not normally the ID.
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
params: params,
log_lvl: log_lvl
})
.then(function (activity_log_obj_get_result) {
if (activity_log_obj_get_result) {
// if (try_cache) {
// // This is expecting a list
// db_save_ae_obj_li__activity_log({
// obj_type: 'activity_log',
// obj_li: [activity_log_obj_get_result]
// });
// }
return activity_log_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.load__activity_log_obj:', ae_promises.load__activity_log_obj);
}
if (log_lvl) {
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
export async function load_ae_obj_li__activity_log({
api_cfg,
for_obj_type = 'account',
for_obj_id,
// inc_other_li = false,
order_by_li = {
priority: 'DESC',
sort: 'DESC',
name: 'ASC',
updated_on: 'DESC',
created_on: 'DESC'
},
params = {},
try_cache = false,
log_lvl = 0
api_cfg,
for_obj_type = 'account',
for_obj_id,
// inc_other_li = false,
order_by_li = {
priority: 'DESC',
sort: 'DESC',
name: 'ASC',
updated_on: 'DESC',
created_on: 'DESC'
},
params = {},
try_cache = false,
log_lvl = 0
}: {
api_cfg: any;
for_obj_type: string;
for_obj_id: string;
// inc_other_li?: boolean,
order_by_li?: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
for_obj_type: string;
for_obj_id: string;
// inc_other_li?: boolean,
order_by_li?: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
console.log(
`*** load_ae_obj_li__activity_log() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`
);
console.log(
`*** load_ae_obj_li__activity_log() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`
);
const enabled: string = params.qry__enabled ?? 'enabled'; // all, disabled, enabled
const hidden: string = params.qry__hidden ?? 'not_hidden'; // all, hidden, not_hidden
const limit: number = params.qry__limit ?? 99; // 99
const offset: number = params.qry__offset ?? 0; // 0
const enabled: string = params.qry__enabled ?? 'enabled'; // all, disabled, enabled
const hidden: string = params.qry__hidden ?? 'not_hidden'; // all, hidden, not_hidden
const limit: number = params.qry__limit ?? 99; // 99
const offset: number = params.qry__offset ?? 0; // 0
const 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({
api_cfg: api_cfg,
obj_type: 'activity_log',
for_obj_type: for_obj_type,
for_obj_id: for_obj_id,
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (activity_log_obj_li_get_result) {
if (activity_log_obj_li_get_result) {
// if (try_cache) {
// db_save_ae_obj_li__activity_log({
// obj_type: 'activity_log',
// obj_li: activity_log_obj_li_get_result
// });
// }
return activity_log_obj_li_get_result;
} else {
return [];
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
ae_promises.load__activity_log_obj_li = await api
.get_ae_obj_li_for_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'activity_log',
for_obj_type: for_obj_type,
for_obj_id: for_obj_id,
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (activity_log_obj_li_get_result) {
if (activity_log_obj_li_get_result) {
// if (try_cache) {
// db_save_ae_obj_li__activity_log({
// obj_type: 'activity_log',
// obj_li: activity_log_obj_li_get_result
// });
// }
return activity_log_obj_li_get_result;
} else {
return [];
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.load__activity_log_obj_li:', ae_promises.load__activity_log_obj_li);
}
if (log_lvl) {
console.log(
'ae_promises.load__activity_log_obj_li:',
ae_promises.load__activity_log_obj_li
);
}
return ae_promises.load__activity_log_obj_li;
return ae_promises.load__activity_log_obj_li;
}
// Updated 2024-10-23
export async function create_ae_obj__activity_log({
api_cfg,
account_id,
data_kv,
params = {},
log_lvl = 0
api_cfg,
account_id,
data_kv,
params = {},
log_lvl = 0
}: {
api_cfg: any;
account_id: string;
data_kv: key_val;
params?: key_val;
log_lvl?: number;
api_cfg: any;
account_id: string;
data_kv: key_val;
params?: key_val;
log_lvl?: number;
}) {
console.log(`*** create_ae_obj__activity_log() *** account_id=${account_id}`);
console.log(`*** create_ae_obj__activity_log() *** account_id=${account_id}`);
ae_promises.create__activity_log = await api
.create_ae_obj_crud({
api_cfg: api_cfg,
obj_type: 'activity_log',
fields: {
account_id_random: account_id,
...data_kv
},
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
})
.then(function (activity_log_obj_create_result) {
if (activity_log_obj_create_result) {
// db_save_ae_obj_li__activity_log(
// {
// obj_type: 'activity_log',
// obj_li: [activity_log_obj_create_result]
// });
return activity_log_obj_create_result;
} else {
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
})
.finally(function () {});
ae_promises.create__activity_log = await api
.create_ae_obj_crud({
api_cfg: api_cfg,
obj_type: 'activity_log',
fields: {
account_id_random: account_id,
...data_kv
},
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
})
.then(function (activity_log_obj_create_result) {
if (activity_log_obj_create_result) {
// db_save_ae_obj_li__activity_log(
// {
// obj_type: 'activity_log',
// obj_li: [activity_log_obj_create_result]
// });
return activity_log_obj_create_result;
} else {
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
})
.finally(function () {});
if (log_lvl) {
console.log('ae_promises.create__activity_log:', ae_promises.create__activity_log);
}
return ae_promises.create__activity_log;
if (log_lvl) {
console.log('ae_promises.create__activity_log:', ae_promises.create__activity_log);
}
return ae_promises.create__activity_log;
}
// Updated 2024-10-23
export async function update_ae_obj__activity_log({
api_cfg,
activity_log_id,
data_kv,
params = {},
try_cache = false,
log_lvl = 0
api_cfg,
activity_log_id,
data_kv,
params = {},
try_cache = false,
log_lvl = 0
}: {
api_cfg: any;
activity_log_id: string;
data_kv: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
activity_log_id: string;
data_kv: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(
`*** update_ae_obj__activity_log() *** activity_log_id=${activity_log_id}`,
data_kv
);
}
ae_promises.update__activity_log_obj = await api
.update_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'activity_log',
obj_id: activity_log_id,
fields: data_kv,
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
})
.then(function (activity_log_obj_update_result) {
if (activity_log_obj_update_result) {
// if (try_cache) {
// db_save_ae_obj_li__activity_log({
// obj_type: 'activity_log', obj_li: [activity_log_obj_update_result]
// });
// }
return activity_log_obj_update_result;
} else {
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
})
.finally(function () {});
if (log_lvl) {
console.log(
`*** update_ae_obj__activity_log() *** activity_log_id=${activity_log_id}`,
data_kv
);
}
ae_promises.update__activity_log_obj = await api
.update_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'activity_log',
obj_id: activity_log_id,
fields: data_kv,
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
})
.then(function (activity_log_obj_update_result) {
if (activity_log_obj_update_result) {
// if (try_cache) {
// db_save_ae_obj_li__activity_log({
// obj_type: 'activity_log', obj_li: [activity_log_obj_update_result]
// });
// }
return activity_log_obj_update_result;
} else {
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
})
.finally(function () {});
if (log_lvl) {
console.log('ae_promises.update__activity_log_obj:', ae_promises.update__activity_log_obj);
}
return ae_promises.update__activity_log_obj;
if (log_lvl) {
console.log('ae_promises.update__activity_log_obj:', ae_promises.update__activity_log_obj);
}
return ae_promises.update__activity_log_obj;
}
// This new function is using CRUD v2. This should allow for more flexibility in the queries.
// Updated 2024-10-23
export async function qry__activity_log({
api_cfg,
activity_log_id,
qry_str,
qry_files,
qry_start_datetime, // Example greater than: '2024-10-24'
enabled = 'enabled',
hidden = 'not_hidden',
limit = 50,
offset = 0,
params = {},
try_cache = false,
log_lvl = 0
api_cfg,
activity_log_id,
qry_str,
qry_files,
qry_start_datetime, // Example greater than: '2024-10-24'
enabled = 'enabled',
hidden = 'not_hidden',
limit = 50,
offset = 0,
params = {},
try_cache = false,
log_lvl = 0
}: {
api_cfg: any;
activity_log_id: any;
qry_str?: string;
qry_files?: null | boolean;
qry_start_datetime?: null | string; // Greater than this datetime
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined; // all, disabled, enabled
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined; // all, hidden, not_hidden
limit?: number;
offset?: number;
params?: any;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
activity_log_id: any;
qry_str?: string;
qry_files?: null | boolean;
qry_start_datetime?: null | string; // Greater than this datetime
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined; // all, disabled, enabled
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined; // all, hidden, not_hidden
limit?: number;
offset?: number;
params?: any;
try_cache?: boolean;
log_lvl?: number;
}) {
console.log(`*** qry__activity_log() *** activity_log_id=${activity_log_id} qry_str=${qry_str}`);
console.log(
`*** qry__activity_log() *** activity_log_id=${activity_log_id} qry_str=${qry_str}`
);
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
// let limit: number = (params.qry__limit ?? 25); // 99
// let offset: number = (params.qry__offset ?? 0); // 0
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
// let limit: number = (params.qry__limit ?? 25); // 99
// let offset: number = (params.qry__offset ?? 0); // 0
const params_json: key_val = {};
const params_json: key_val = {};
// if (qry_str && qry_str.length > 2) {
// params_json['ft_qry'] = {};
// params_json['ft_qry']['default_qry_str'] = qry_str;
// }
// if (qry_str && qry_str.length > 2) {
// params_json['ft_qry'] = {};
// params_json['ft_qry']['default_qry_str'] = qry_str;
// }
params_json['qry'] = [];
params_json['qry'] = [];
if (qry_files === true) {
const qry_param = {
type: 'AND',
field: 'file_count_all',
operator: '>',
value: 0
};
params_json['qry'].push(qry_param);
} else if (qry_files === false) {
const qry_param = {
type: 'AND',
field: 'file_count_all',
operator: 'IS',
value: null
};
params_json['qry'].push(qry_param);
}
if (qry_files === true) {
const qry_param = {
type: 'AND',
field: 'file_count_all',
operator: '>',
value: 0
};
params_json['qry'].push(qry_param);
} else if (qry_files === false) {
const qry_param = {
type: 'AND',
field: 'file_count_all',
operator: 'IS',
value: null
};
params_json['qry'].push(qry_param);
}
if (qry_start_datetime) {
const qry_param = {
type: 'AND',
field: 'start_datetime',
operator: '>',
value: qry_start_datetime
};
params_json['qry'].push(qry_param);
}
if (qry_start_datetime) {
const qry_param = {
type: 'AND',
field: 'start_datetime',
operator: '>',
value: qry_start_datetime
};
params_json['qry'].push(qry_param);
}
const 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({
api_cfg: api_cfg,
obj_type: 'activity_log',
for_obj_type: 'account',
for_obj_id: activity_log_id,
use_alt_tbl: true, // NOTE: We want to use the alt table for activity_log searching
use_alt_mdl: false,
use_alt_exp: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (activity_log_obj_li_get_result) {
if (activity_log_obj_li_get_result) {
// db_save_ae_obj_li__activity_log({
// obj_type: 'activity_log',
// obj_li: activity_log_obj_li_get_result
// });
return activity_log_obj_li_get_result;
} else {
return [];
}
});
ae_promises.load__activity_log_obj_li = await api
.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg: api_cfg,
obj_type: 'activity_log',
for_obj_type: 'account',
for_obj_id: activity_log_id,
use_alt_tbl: true, // NOTE: We want to use the alt table for activity_log searching
use_alt_mdl: false,
use_alt_exp: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (activity_log_obj_li_get_result) {
if (activity_log_obj_li_get_result) {
// db_save_ae_obj_li__activity_log({
// obj_type: 'activity_log',
// obj_li: activity_log_obj_li_get_result
// });
return activity_log_obj_li_get_result;
} else {
return [];
}
});
if (log_lvl) {
console.log('ae_promises.load__activity_log_obj_li:', ae_promises.load__activity_log_obj_li);
}
return ae_promises.load__activity_log_obj_li;
if (log_lvl) {
console.log(
'ae_promises.load__activity_log_obj_li:',
ae_promises.load__activity_log_obj_li
);
}
return ae_promises.load__activity_log_obj_li;
}

View File

@@ -2,56 +2,56 @@ import type { key_val } from '$lib/stores/ae_stores';
// Updated 2025-01-28
export function add_url_params({
base_url = '',
endpoint,
params,
log_lvl = 0
base_url = '',
endpoint,
params,
log_lvl = 0
}: {
base_url?: string;
endpoint: string;
params: key_val;
log_lvl?: number;
base_url?: string;
endpoint: string;
params: key_val;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** add_url_params() *** base_url=${base_url} endpoint=${endpoint}`, params);
}
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) {
console.log('New URL:', url_obj.toString());
}
if (log_lvl) {
console.log('New URL:', url_obj.toString());
}
return url_obj.toString();
// return 'test';
return url_obj.toString();
// return 'test';
}
// This is used to clean the header property names. Not underscores allowed in the header names.
// Updated 2025-01-28
export function clean_headers({ headers, log_lvl = 0 }: { headers: any; log_lvl?: number }) {
if (log_lvl) {
console.log(`*** clean_headers() ***`, headers);
}
if (log_lvl) {
console.log(`*** clean_headers() ***`, headers);
}
const headers_cleaned: key_val = {};
for (const prop in headers) {
const prop_cleaned = prop.replaceAll('_', '-');
if (typeof headers[prop] != 'string') {
headers[prop] = JSON.stringify(headers[prop]);
}
headers_cleaned[prop_cleaned] = headers[prop];
if (log_lvl > 1) {
console.log(`${prop_cleaned}: ${headers_cleaned[prop_cleaned]}`);
}
}
const headers_cleaned: key_val = {};
for (const prop in headers) {
const prop_cleaned = prop.replaceAll('_', '-');
if (typeof headers[prop] != 'string') {
headers[prop] = JSON.stringify(headers[prop]);
}
headers_cleaned[prop_cleaned] = headers[prop];
if (log_lvl > 1) {
console.log(`${prop_cleaned}: ${headers_cleaned[prop_cleaned]}`);
}
}
// Object.keys(headers).forEach(key => {
// if (headers[key]) {
// headers_cleaned[key] = headers[key];
// }
// });
// Object.keys(headers).forEach(key => {
// if (headers[key]) {
// headers_cleaned[key] = headers[key];
// }
// });
return headers_cleaned;
return headers_cleaned;
}

View File

@@ -3,32 +3,32 @@ import { api } from '$lib/api/api';
// Updated 2024-10-02
export async function check_hosted_file_obj_w_hash({
api_cfg,
hosted_file_hash,
check_for_local = true, // Forces a check on the host server for the file.
params = {},
return_meta = false,
log_lvl = 0
api_cfg,
hosted_file_hash,
check_for_local = true, // Forces a check on the host server for the file.
params = {},
return_meta = false,
log_lvl = 0
}: {
api_cfg: any;
hosted_file_hash: string;
check_for_local?: boolean;
params?: key_val;
return_meta?: boolean;
log_lvl?: number;
api_cfg: any;
hosted_file_hash: string;
check_for_local?: boolean;
params?: key_val;
return_meta?: boolean;
log_lvl?: number;
}) {
console.log('*** stores_event_api.js: check_hosted_file_obj_w_hash() ***');
console.log('*** stores_event_api.js: check_hosted_file_obj_w_hash() ***');
const endpoint = `/hosted_file/hash/${hosted_file_hash}`;
if (check_for_local) {
params['check_for_local'] = true;
}
const check_hosted_file_obj_w_hash_get_promise = await api.get_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
return_meta: return_meta,
log_lvl: log_lvl
});
return check_hosted_file_obj_w_hash_get_promise;
const endpoint = `/hosted_file/hash/${hosted_file_hash}`;
if (check_for_local) {
params['check_for_local'] = true;
}
const check_hosted_file_obj_w_hash_get_promise = await api.get_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
return_meta: return_meta,
log_lvl: log_lvl
});
return check_hosted_file_obj_w_hash_get_promise;
}

View File

@@ -7,65 +7,65 @@ const ae_promises: key_val = {};
// Updated 2024-10-14
export async function load_ae_obj_li__country({
api_cfg,
// account_id,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 299,
offset = 0,
order_by_li = { sort: 'DESC', english_short_name: 'ASC', alpha_2_code: 'ASC' },
params = {},
try_cache = true,
log_lvl = 0
api_cfg,
// account_id,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 299,
offset = 0,
order_by_li = { sort: 'DESC', english_short_name: 'ASC', alpha_2_code: 'ASC' },
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
// account_id: string,
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
offset?: number;
order_by_li?: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
// account_id: string,
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
offset?: number;
order_by_li?: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** load_ae_obj_li__country() ***`);
}
if (log_lvl) {
console.log(`*** load_ae_obj_li__country() ***`);
}
const 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({
api_cfg: api_cfg,
obj_type: 'lu',
for_obj_type: 'country',
// for_obj_id: account_id,
use_alt_tbl: false,
use_alt_mdl: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (country_li_get_result) {
if (country_li_get_result) {
// handle_db_save_ae_obj_li__country({obj_type: 'country', obj_li: country_li_get_result});
return country_li_get_result;
} else {
return [];
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
ae_promises.load__country_li = await api
.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg: api_cfg,
obj_type: 'lu',
for_obj_type: 'country',
// for_obj_id: account_id,
use_alt_tbl: false,
use_alt_mdl: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (country_li_get_result) {
if (country_li_get_result) {
// handle_db_save_ae_obj_li__country({obj_type: 'country', obj_li: country_li_get_result});
return country_li_get_result;
} else {
return [];
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
console.log('ae_promises.load__country_li:', ae_promises.load__country_li);
return ae_promises.load__country_li;
console.log('ae_promises.load__country_li:', ae_promises.load__country_li);
return ae_promises.load__country_li;
}

View File

@@ -7,68 +7,68 @@ const ae_promises: key_val = {};
// Updated 2024-10-14
export async function load_ae_obj_li__country_subdivision({
api_cfg,
// account_id,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 399,
offset = 0,
order_by_li = { sort: 'DESC', name: 'ASC', code: 'ASC' },
params = {},
try_cache = true,
log_lvl = 0
api_cfg,
// account_id,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 399,
offset = 0,
order_by_li = { sort: 'DESC', name: 'ASC', code: 'ASC' },
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
// account_id: string,
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
offset?: number;
order_by_li?: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
// account_id: string,
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
offset?: number;
order_by_li?: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** load_ae_obj_li__country_subdivision() ***`);
}
if (log_lvl) {
console.log(`*** load_ae_obj_li__country_subdivision() ***`);
}
const 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({
api_cfg: api_cfg,
obj_type: 'lu',
for_obj_type: 'country_subdivision',
// for_obj_id: account_id,
use_alt_tbl: false,
use_alt_mdl: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (country_subdivision_li_get_result) {
if (country_subdivision_li_get_result) {
// handle_db_save_ae_obj_li__country_subdivision({obj_type: 'country_subdivision', obj_li: country_subdivision_li_get_result});
return country_subdivision_li_get_result;
} else {
return [];
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
ae_promises.load__country_subdivision_li = await api
.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg: api_cfg,
obj_type: 'lu',
for_obj_type: 'country_subdivision',
// for_obj_id: account_id,
use_alt_tbl: false,
use_alt_mdl: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (country_subdivision_li_get_result) {
if (country_subdivision_li_get_result) {
// handle_db_save_ae_obj_li__country_subdivision({obj_type: 'country_subdivision', obj_li: country_subdivision_li_get_result});
return country_subdivision_li_get_result;
} else {
return [];
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
console.log(
'ae_promises.load__country_subdivision_li:',
ae_promises.load__country_subdivision_li
);
return ae_promises.load__country_subdivision_li;
console.log(
'ae_promises.load__country_subdivision_li:',
ae_promises.load__country_subdivision_li
);
return ae_promises.load__country_subdivision_li;
}

View File

@@ -7,172 +7,172 @@ import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
// Define generic CRUD args
export interface GenericCrudArgs {
api_cfg: any;
obj_type: string;
obj_id?: string;
for_obj_type?: string;
for_obj_id?: string;
api_cfg: any;
obj_type: string;
obj_id?: string;
for_obj_type?: string;
for_obj_id?: string;
db_instance?: any; // Optional DB instance for caching
db_field_li?: string[]; // Optional list of fields to save in DB
db_instance?: any; // Optional DB instance for caching
db_field_li?: string[]; // Optional list of fields to save in DB
// Flags to include related core object models
inc_account_li?: boolean;
inc_address_li?: boolean;
inc_contact_li?: boolean;
inc_person_li?: boolean;
inc_site_li?: boolean;
inc_site_domain_li?: boolean;
inc_user_li?: boolean;
// Flags to include related core object models
inc_account_li?: boolean;
inc_address_li?: boolean;
inc_contact_li?: boolean;
inc_person_li?: boolean;
inc_site_li?: boolean;
inc_site_domain_li?: boolean;
inc_user_li?: boolean;
// Flags to include related other object models
inc_archive_li?: boolean;
inc_archive_entry_li?: boolean;
inc_event_li?: boolean;
inc_event_session_li?: boolean;
inc_post_li?: boolean;
inc_post_comment_li?: boolean;
inc_journal_li?: boolean;
inc_journal_entry_li?: boolean;
// Flags to include related other object models
inc_archive_li?: boolean;
inc_archive_entry_li?: boolean;
inc_event_li?: boolean;
inc_event_session_li?: boolean;
inc_post_li?: boolean;
inc_post_comment_li?: boolean;
inc_journal_li?: boolean;
inc_journal_entry_li?: boolean;
inc_obj_type_li?: string[]; // Optional list of object types to include
inc_obj_type_li?: string[]; // Optional list of object types to include
data_kv?: key_val;
enabled?: 'enabled' | 'disabled' | 'all';
hidden?: 'not_hidden' | 'hidden' | 'all';
limit?: number;
offset?: number;
order_by_li?: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
data_kv?: key_val;
enabled?: 'enabled' | 'disabled' | 'all';
hidden?: 'not_hidden' | 'hidden' | 'all';
limit?: number;
offset?: number;
order_by_li?: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}
// Generic function: Load single object by ID
export async function load_ae_obj_id(args: GenericCrudArgs): Promise<any> {
const { api_cfg, obj_type, obj_id, log_lvl = 0 } = args;
const { api_cfg, obj_type, obj_id, log_lvl = 0 } = args;
if (log_lvl) {
console.log(`*** load_ae_obj_id() *** obj_type=${obj_type} obj_id=${obj_id}`);
}
if (log_lvl) {
console.log(`*** load_ae_obj_id() *** obj_type=${obj_type} obj_id=${obj_id}`);
}
const result = await api.get_ae_obj_id_crud({
api_cfg,
obj_type,
obj_id,
params: {},
log_lvl
});
const result = await api.get_ae_obj_id_crud({
api_cfg,
obj_type,
obj_id,
params: {},
log_lvl
});
return result;
return result;
}
// Generic function: Load list of objects
export async function load_ae_obj_li(args: GenericCrudArgs): Promise<any> {
const {
api_cfg,
obj_type,
for_obj_type = '',
for_obj_id,
inc_obj_type_li,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
order_by_li = {},
params = {},
try_cache = true,
log_lvl = 0
} = args;
const {
api_cfg,
obj_type,
for_obj_type = '',
for_obj_id,
inc_obj_type_li,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
order_by_li = {},
params = {},
try_cache = true,
log_lvl = 0
} = args;
if (log_lvl) {
console.log(
`*** load_ae_obj_li() *** obj_type=${obj_type} for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`
);
}
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}`
);
}
const params_json: key_val = {};
const params_json: key_val = {};
const result = await api.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg,
obj_type,
for_obj_type,
for_obj_id,
enabled,
hidden,
order_by_li,
limit,
offset,
params_json: {},
params,
log_lvl
});
const result = await api.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg,
obj_type,
for_obj_type,
for_obj_id,
enabled,
hidden,
order_by_li,
limit,
offset,
params_json: {},
params,
log_lvl
});
return result;
return result;
}
// Generic function: Create object
export async function create_ae_obj(args: GenericCrudArgs): Promise<any> {
const { api_cfg, obj_type, data_kv, log_lvl = 0 } = args;
const { api_cfg, obj_type, data_kv, log_lvl = 0 } = args;
if (log_lvl) {
console.log(`*** create_ae_obj() *** obj_type=${obj_type}`, data_kv);
}
if (log_lvl) {
console.log(`*** create_ae_obj() *** obj_type=${obj_type}`, data_kv);
}
const result = await api.create_ae_obj_crud({
api_cfg,
obj_type,
fields: data_kv,
key: api_cfg.api_crud_super_key,
params: {},
return_obj: true,
log_lvl
});
const result = await api.create_ae_obj_crud({
api_cfg,
obj_type,
fields: data_kv,
key: api_cfg.api_crud_super_key,
params: {},
return_obj: true,
log_lvl
});
return result;
return result;
}
// Generic function: Update object
export async function update_ae_obj(args: GenericCrudArgs): Promise<any> {
const { api_cfg, obj_type, obj_id, data_kv, log_lvl = 0 } = args;
const { api_cfg, obj_type, obj_id, data_kv, log_lvl = 0 } = args;
if (log_lvl) {
console.log(`*** update_ae_obj() *** obj_type=${obj_type} obj_id=${obj_id}`, data_kv);
}
if (log_lvl) {
console.log(`*** update_ae_obj() *** obj_type=${obj_type} obj_id=${obj_id}`, data_kv);
}
const result = await api.update_ae_obj_id_crud({
api_cfg,
obj_type,
obj_id,
fields: data_kv,
key: api_cfg.api_crud_super_key,
params: {},
return_obj: true,
log_lvl
});
const result = await api.update_ae_obj_id_crud({
api_cfg,
obj_type,
obj_id,
fields: data_kv,
key: api_cfg.api_crud_super_key,
params: {},
return_obj: true,
log_lvl
});
return result;
return result;
}
// Generic function: Delete object
export async function delete_ae_obj_id(args: GenericCrudArgs): Promise<any> {
const { api_cfg, obj_type, obj_id, method = 'delete', log_lvl = 0 } = args;
const { api_cfg, obj_type, obj_id, method = 'delete', log_lvl = 0 } = args;
if (log_lvl) {
console.log(`*** delete_ae_obj_id() *** obj_type=${obj_type} obj_id=${obj_id}`);
}
if (log_lvl) {
console.log(`*** delete_ae_obj_id() *** obj_type=${obj_type} obj_id=${obj_id}`);
}
const result = await api.delete_ae_obj_id_crud({
api_cfg,
obj_type,
obj_id,
key: api_cfg.api_crud_super_key,
params: {},
method,
log_lvl
});
const result = await api.delete_ae_obj_id_crud({
api_cfg,
obj_type,
obj_id,
key: api_cfg.api_crud_super_key,
params: {},
method,
log_lvl
});
return result;
return result;
}
// Additional Modules that might be needed for reloads
@@ -192,144 +192,144 @@ import { load_ae_obj_id__post_comment } from '$lib/ae_posts/ae_posts__post_comme
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,
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;
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
);
}
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
});
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;
}
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}`);
console.log(`Patched - Field Name: ${field_name} with new Field Value: ${new_field_value}`);
if (object_reload) {
if (log_lvl) console.log(`Reloading the object after patching...`);
if (object_reload) {
if (log_lvl) console.log(`Reloading the object after patching...`);
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_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 });
}
}
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;
}
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,
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;
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() ***');
if (log_lvl) console.log('*** download_export_li() ***');
const endpoint = `/v2/crud/${get_obj_type}/list`;
params['for_obj_type'] = for_obj_type;
params['for_obj_id'] = for_obj_id;
const endpoint = `/v2/crud/${get_obj_type}/list`;
params['for_obj_type'] = for_obj_type;
params['for_obj_id'] = for_obj_id;
if (file_type === 'CSV' || file_type === 'Excel') {
params['file_type'] = file_type;
}
params['return_file'] = true;
params['mdl_alt'] = 'out';
if (file_type === 'CSV' || file_type === 'Excel') {
params['file_type'] = file_type;
}
params['return_file'] = true;
params['mdl_alt'] = 'out';
if (exp_alt) {
params['exp_alt'] = exp_alt;
}
if (exp_alt) {
params['exp_alt'] = exp_alt;
}
const clean_filename = filename.replace(/[^a-zA-Z0-9\[\]-_.]/gi, '_');
const clean_filename = filename.replace(/[^a-zA-Z0-9\[\]-_.]/gi, '_');
if (limit >= 0) {
params['limit'] = limit;
}
if (limit >= 0) {
params['limit'] = limit;
}
const download_result = await api.get_object({
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({
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
});
if (log_lvl) console.log('download_result:', download_result);
return download_result;
if (log_lvl) console.log('download_result:', download_result);
return download_result;
}

View File

@@ -3,23 +3,23 @@ import type { key_val } from '$lib/stores/ae_stores';
import { api } from '$lib/api/api';
export interface Data_Store {
id: string;
account_id: string;
code: string;
name: string;
type: string;
for_type?: string | null;
for_id?: string | null;
access_read?: string | null;
access_write?: string | null;
access_delete?: string | null;
html?: string | null;
json?: key_val | null;
md?: string | null;
text?: string | null;
updated_on?: string | null;
chk_account_id?: string;
loaded_on?: string;
id: string;
account_id: string;
code: string;
name: string;
type: string;
for_type?: string | null;
for_id?: string | null;
access_read?: string | null;
access_write?: string | null;
access_delete?: string | null;
html?: string | null;
json?: key_val | null;
md?: string | null;
text?: string | null;
updated_on?: string | null;
chk_account_id?: string;
loaded_on?: string;
}
/**
@@ -34,79 +34,79 @@ export interface Data_Store {
* @returns The data from the data store (e.g., text content or JSON object).
*/
export async function load_ae_obj_by_code__data_store({
api_cfg,
code,
data_type = 'text',
save_idb = false,
timeout = 9000,
log_lvl = 0
api_cfg,
code,
data_type = 'text',
save_idb = false,
timeout = 9000,
log_lvl = 0
}: {
api_cfg: any;
code: string;
data_type?: string;
save_idb?: boolean;
timeout?: number;
log_lvl?: number;
api_cfg: any;
code: string;
data_type?: string;
save_idb?: boolean;
timeout?: number;
log_lvl?: number;
}): Promise<any> {
if (log_lvl) {
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) {
console.log(`*ae_func* No code provided!`);
return null;
}
if (!code) {
console.log(`*ae_func* No code provided!`);
return null;
}
if (!api_cfg.account_id) {
console.log(`*ae_func* No account_id found in API config!`);
return null;
}
if (!api_cfg.account_id) {
console.log(`*ae_func* No account_id found in API config!`);
return null;
}
try {
const get_ds_result = await api.get_data_store_obj_w_code({
api_cfg: api_cfg,
data_store_code: code,
data_type: data_type,
timeout: timeout,
log_lvl: log_lvl
});
try {
const get_ds_result = await api.get_data_store_obj_w_code({
api_cfg: api_cfg,
data_store_code: code,
data_type: data_type,
timeout: timeout,
log_lvl: log_lvl
});
if (!get_ds_result) {
console.log('*ae_func* No results returned.');
return null;
}
if (!get_ds_result) {
console.log('*ae_func* No results returned.');
return null;
}
if (log_lvl) {
console.log(`*ae_func* Got a result for code ${code}`);
}
if (log_lvl) {
console.log(`*ae_func* Got a result for code ${code}`);
}
if (!get_ds_result.data_store_id_random) {
console.log('*ae_func* Something went wrong? No data store ID found.');
return null;
}
if (!get_ds_result.data_store_id_random) {
console.log('*ae_func* Something went wrong? No data store ID found.');
return null;
}
let return_this: any = null;
let return_this: any = null;
// Simplified data extraction
if (data_type === 'html') {
return_this = get_ds_result.html;
} else if (data_type === 'json') {
return_this = get_ds_result.json;
} else {
return_this = get_ds_result.text;
}
// Simplified data extraction
if (data_type === 'html') {
return_this = get_ds_result.html;
} else if (data_type === 'json') {
return_this = get_ds_result.json;
} else {
return_this = get_ds_result.text;
}
if (save_idb && browser) {
const key_prefix = 'ae_ds__';
if (log_lvl) {
console.log(`*ae_func* localStorage key: ${code}, value:`, get_ds_result);
}
localStorage.setItem(`${key_prefix}${code}`, JSON.stringify(get_ds_result));
}
if (save_idb && browser) {
const key_prefix = 'ae_ds__';
if (log_lvl) {
console.log(`*ae_func* localStorage key: ${code}, value:`, get_ds_result);
}
localStorage.setItem(`${key_prefix}${code}`, JSON.stringify(get_ds_result));
}
return return_this;
} catch (error) {
console.log('*ae_func* No results returned or failed.', error);
return null;
}
return return_this;
} catch (error) {
console.log('*ae_func* No results returned or failed.', error);
return null;
}
}

View File

@@ -7,354 +7,356 @@ const ae_promises: key_val = {};
// Updated 2024-06-14
export async function load_ae_obj_id__hosted_file({
api_cfg,
hosted_file_id,
try_cache = false,
log_lvl = 0
api_cfg,
hosted_file_id,
try_cache = false,
log_lvl = 0
}: {
api_cfg: any;
hosted_file_id: string;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
hosted_file_id: string;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** load_ae_obj_id__hosted_file() *** hosted_file_id=${hosted_file_id}`);
}
if (log_lvl) {
console.log(`*** load_ae_obj_id__hosted_file() *** hosted_file_id=${hosted_file_id}`);
}
const params = {};
const params = {};
ae_promises.load__hosted_file_obj = await api
.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'hosted_file',
obj_id: hosted_file_id, // NOTE: This is the FQDN, not normally the ID.
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
params: params,
log_lvl: log_lvl
})
.then(function (hosted_file_obj_get_result) {
if (hosted_file_obj_get_result) {
// This is expecting a list
db_save_ae_obj_li__hosted_file({
obj_type: 'hosted_file',
obj_li: [hosted_file_obj_get_result]
});
return hosted_file_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
ae_promises.load__hosted_file_obj = await api
.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'hosted_file',
obj_id: hosted_file_id, // NOTE: This is the FQDN, not normally the ID.
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
params: params,
log_lvl: log_lvl
})
.then(function (hosted_file_obj_get_result) {
if (hosted_file_obj_get_result) {
// This is expecting a list
db_save_ae_obj_li__hosted_file({
obj_type: 'hosted_file',
obj_li: [hosted_file_obj_get_result]
});
return hosted_file_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: 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
export async function load_ae_obj_li__hosted_file({
api_cfg,
for_obj_type,
for_obj_id,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
order_by_li = { priority: 'DESC', sort: 'DESC', updated_on: 'DESC', created_on: 'DESC' },
params = {},
try_cache = true,
log_lvl = 0
api_cfg,
for_obj_type,
for_obj_id,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
order_by_li = { priority: 'DESC', sort: 'DESC', updated_on: 'DESC', created_on: 'DESC' },
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
for_obj_type: string;
for_obj_id: string;
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
offset?: number;
order_by_li?: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
for_obj_type: string;
for_obj_id: string;
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
offset?: number;
order_by_li?: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(
`*** load_ae_obj_li__hosted_file() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`
);
}
if (log_lvl) {
console.log(
`*** load_ae_obj_li__hosted_file() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`
);
}
// Check if for_obj_type is in the list of valid Aether object types:
const valid_for_obj_types = [
'account',
'archive',
'archive_content',
'event',
'event_session',
'event_presentation',
'event_presenter',
'event_location',
'journal',
'journal_entry',
'post',
'post_comment'
];
if (!valid_for_obj_types.includes(for_obj_type)) {
console.log(`Invalid for_obj_type: ${for_obj_type}`);
return [];
}
// Check if for_obj_type is in the list of valid Aether object types:
const valid_for_obj_types = [
'account',
'archive',
'archive_content',
'event',
'event_session',
'event_presentation',
'event_presenter',
'event_location',
'journal',
'journal_entry',
'post',
'post_comment'
];
if (!valid_for_obj_types.includes(for_obj_type)) {
console.log(`Invalid for_obj_type: ${for_obj_type}`);
return [];
}
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
// let hidden: string = (params.qry__hidden ?? 'all'); // all, hidden, not_hidden
// let limit: number = (params.qry__limit ?? 99); // 99
// let offset: number = (params.qry__offset ?? 0); // 0
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
// let hidden: string = (params.qry__hidden ?? 'all'); // all, hidden, not_hidden
// let limit: number = (params.qry__limit ?? 99); // 99
// let offset: number = (params.qry__offset ?? 0); // 0
const 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({
api_cfg: api_cfg,
obj_type: 'hosted_file',
for_obj_type: for_obj_type,
for_obj_id: for_obj_id,
use_alt_tbl: false,
use_alt_mdl: false,
use_alt_exp: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (hosted_file_obj_li_get_result) {
if (hosted_file_obj_li_get_result) {
if (try_cache) {
db_save_ae_obj_li__hosted_file({
obj_type: 'hosted_file',
obj_li: hosted_file_obj_li_get_result,
log_lvl: log_lvl
});
}
return hosted_file_obj_li_get_result;
} else {
console.log('No results returned.');
return [];
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
ae_promises.load__hosted_file_obj_li = await api
.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg: api_cfg,
obj_type: 'hosted_file',
for_obj_type: for_obj_type,
for_obj_id: for_obj_id,
use_alt_tbl: false,
use_alt_mdl: false,
use_alt_exp: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (hosted_file_obj_li_get_result) {
if (hosted_file_obj_li_get_result) {
if (try_cache) {
db_save_ae_obj_li__hosted_file({
obj_type: 'hosted_file',
obj_li: hosted_file_obj_li_get_result,
log_lvl: log_lvl
});
}
return hosted_file_obj_li_get_result;
} else {
console.log('No results returned.');
return [];
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.load__hosted_file_obj_li:', ae_promises.load__hosted_file_obj_li);
}
return ae_promises.load__hosted_file_obj_li;
if (log_lvl) {
console.log('ae_promises.load__hosted_file_obj_li:', ae_promises.load__hosted_file_obj_li);
}
return ae_promises.load__hosted_file_obj_li;
}
// Updated 2024-11-07
export async function delete_ae_obj_id__hosted_file({
api_cfg,
hosted_file_id,
link_to_type, // Ideally this should be required...
link_to_id, // Ideally this should be required...
rm_orphan = false,
fake_delete = false, // Fake the delete result to "true"
params = {},
try_cache = true,
log_lvl = 0
api_cfg,
hosted_file_id,
link_to_type, // Ideally this should be required...
link_to_id, // Ideally this should be required...
rm_orphan = false,
fake_delete = false, // Fake the delete result to "true"
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
hosted_file_id: string;
link_to_type: string;
link_to_id: string;
rm_orphan?: boolean;
fake_delete?: boolean;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
hosted_file_id: string;
link_to_type: string;
link_to_id: string;
rm_orphan?: boolean;
fake_delete?: boolean;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** delete_ae_obj_id__hosted_file() *** hosted_file_id=${hosted_file_id}`);
}
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_id'] = link_to_id;
params['rm_orphan'] = rm_orphan; // This is what actually allows the hosted file to be deleted from the server.
if (log_lvl) {
console.log(`delete_ae_obj_id__hosted_file() params=`, params);
}
params['link_to_type'] = link_to_type;
params['link_to_id'] = link_to_id;
params['rm_orphan'] = rm_orphan; // This is what actually allows the hosted file to be deleted from the server.
if (log_lvl) {
console.log(`delete_ae_obj_id__hosted_file() params=`, params);
}
if (fake_delete) {
console.log(`*** FAKE DELETE!!! ***`);
ae_promises.delete__hosted_file_obj = true;
return ae_promises.delete__hosted_file_obj;
}
if (fake_delete) {
console.log(`*** FAKE DELETE!!! ***`);
ae_promises.delete__hosted_file_obj = true;
return ae_promises.delete__hosted_file_obj;
}
ae_promises.delete__hosted_file_obj = await api
.delete_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
// return_meta: return_meta,
log_lvl: log_lvl
})
.then(function (hosted_file_obj_li_get_result) {
if (hosted_file_obj_li_get_result) {
if (try_cache) {
if (log_lvl) {
console.log(`Attempting to remove IDB entry for hosted_file_id=${hosted_file_id}`);
}
db_core.file.delete(hosted_file_id); // Delete from the DB no matter what.
}
return hosted_file_obj_li_get_result;
} else {
console.log('No results returned.');
return [];
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
ae_promises.delete__hosted_file_obj = await api
.delete_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
// return_meta: return_meta,
log_lvl: log_lvl
})
.then(function (hosted_file_obj_li_get_result) {
if (hosted_file_obj_li_get_result) {
if (try_cache) {
if (log_lvl) {
console.log(
`Attempting to remove IDB entry for hosted_file_id=${hosted_file_id}`
);
}
db_core.file.delete(hosted_file_id); // Delete from the DB no matter what.
}
return hosted_file_obj_li_get_result;
} else {
console.log('No results returned.');
return [];
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.delete__hosted_file_obj:', ae_promises.delete__hosted_file_obj);
}
if (log_lvl) {
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.
// Updated 2025-01-07
export function db_save_ae_obj_li__hosted_file({
obj_type,
obj_li,
log_lvl = 0
obj_type,
obj_li,
log_lvl = 0
}: {
obj_type: string;
obj_li: any;
log_lvl?: number;
obj_type: string;
obj_li: any;
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) {
obj_li.forEach(async function (obj: any) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj: any) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
try {
const id_random = await db_core.file.put({
id: obj.hosted_file_id_random,
id_random: obj.hosted_file_id_random,
hosted_file_id: obj.hosted_file_id_random,
hosted_file_id_random: obj.hosted_file_id_random,
try {
const id_random = await db_core.file.put({
id: obj.hosted_file_id_random,
id_random: obj.hosted_file_id_random,
hosted_file_id: obj.hosted_file_id_random,
hosted_file_id_random: obj.hosted_file_id_random,
hash_sha256: obj.hash_sha256, // Renamed with alias in FastAPI model
hash_sha256: obj.hash_sha256, // Renamed with alias in FastAPI model
for_type: obj.for_type,
for_id: obj.for_id_id_random,
for_id_random: obj.for_id_random,
for_type: obj.for_type,
for_id: obj.for_id_id_random,
for_id_random: obj.for_id_random,
account_id: obj.account_id_random,
account_id: obj.account_id_random,
filename: obj.filename,
extension: obj.extension,
content_type: obj.content_type,
size: obj.size,
filename: obj.filename,
extension: obj.extension,
content_type: obj.content_type,
size: obj.size,
enable: obj.enable,
hide: obj.hide,
// priority: obj.priority,
// sort: obj.sort,
group: obj.group,
notes: obj.notes,
created_on: obj.created_on,
updated_on: obj.updated_on,
enable: obj.enable,
hide: obj.hide,
// priority: obj.priority,
// sort: obj.sort,
group: obj.group,
notes: obj.notes,
created_on: obj.created_on,
updated_on: obj.updated_on,
filename_no_ext: obj.filename_no_ext,
filename_w_ext: obj.filename_w_ext
});
// console.log(`Put obj with ID: ${obj.hosted_file_id_random} or ${id_random}`);
} catch (error) {
const status = `Failed to put ${obj.hosted_file_id_random}: ${error}`;
console.log(status);
}
filename_no_ext: obj.filename_no_ext,
filename_w_ext: obj.filename_w_ext
});
// console.log(`Put obj with ID: ${obj.hosted_file_id_random} or ${id_random}`);
} catch (error) {
const status = `Failed to put ${obj.hosted_file_id_random}: ${error}`;
console.log(status);
}
// const id_random = await db_core.file.put(obj);
// console.log(`Put obj with ID: ${obj.hosted_file_id_random}`);
});
// const id_random = await db_core.file.put(obj);
// console.log(`Put obj with ID: ${obj.hosted_file_id_random}`);
});
return true;
}
return false;
return true;
}
return false;
}
// Updated 2025-01-07
export function db_update_ae_obj_id__hosted_file({
obj_type,
obj_id,
data_kv,
log_lvl = 0
obj_type,
obj_id,
data_kv,
log_lvl = 0
}: {
obj_type: string;
obj_id: string;
data_kv: key_val;
log_lvl?: number;
obj_type: string;
obj_id: string;
data_kv: key_val;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** db_update_ae_obj_id__hosted_file() ***`);
}
if (log_lvl) {
console.log(`*** db_update_ae_obj_id__hosted_file() ***`);
}
if (obj_id) {
console.log(`ae_obj ${obj_type}:`, obj_id);
if (obj_id) {
console.log(`ae_obj ${obj_type}:`, obj_id);
try {
// db_core.file.update(obj_id, data_kv);
db_core.file.update(obj_id, {
// for_type: data_kv.for_type,
// for_id: data_kv.for_id_id_random,
// for_id_random: data_kv.for_id_random,
try {
// db_core.file.update(obj_id, data_kv);
db_core.file.update(obj_id, {
// for_type: data_kv.for_type,
// for_id: data_kv.for_id_id_random,
// for_id_random: data_kv.for_id_random,
filename: data_kv.filename,
extension: data_kv.extension,
content_type: data_kv.content_type,
size: data_kv.size,
filename: data_kv.filename,
extension: data_kv.extension,
content_type: data_kv.content_type,
size: data_kv.size,
// enable: data_kv.enable,
// hide: data_kv.hide,
// priority: data_kv.priority,
// sort: data_kv.sort,
// group: data_kv.group,
// notes: data_kv.notes,
// created_on: data_kv.created_on,
// updated_on: data_kv.updated_on,
// enable: data_kv.enable,
// hide: data_kv.hide,
// priority: data_kv.priority,
// sort: data_kv.sort,
// group: data_kv.group,
// notes: data_kv.notes,
// created_on: data_kv.created_on,
// updated_on: data_kv.updated_on,
filename_no_ext: data_kv.filename_no_ext,
filename_w_ext: data_kv.filename_w_ext
// hosted_file_content_type: data_kv.hosted_file_content_type,
// file_size: data_kv.file_size,
// hosted_file_size: data_kv.hosted_file_size,
});
filename_no_ext: data_kv.filename_no_ext,
filename_w_ext: data_kv.filename_w_ext
// hosted_file_content_type: data_kv.hosted_file_content_type,
// file_size: data_kv.file_size,
// hosted_file_size: data_kv.hosted_file_size,
});
console.log(`Update obj with ID: ${obj_id}`);
} catch (error) {
const status = `Failed to update ${obj_id}: ${error}`;
console.log(status);
}
console.log(`Update obj with ID: ${obj_id}`);
} catch (error) {
const status = `Failed to update ${obj_id}: ${error}`;
console.log(status);
}
// const id_random = await db_core.file.put(obj);
// console.log(`Put obj with ID: ${data_kv.hosted_file_id_random}`);
return true;
}
return false;
// const id_random = await db_core.file.put(obj);
// console.log(`Put obj with ID: ${data_kv.hosted_file_id_random}`);
return true;
}
return false;
}

View File

@@ -8,26 +8,29 @@ import type { Dexie, Table } from 'dexie';
* @returns The found ID, or undefined if no ID could be found.
*/
function find_object_id(
obj: any,
table_name: string,
log_lvl: number
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) {
if (obj[key]) {
if (key !== 'id' && log_lvl > 0) {
console.warn(
`Found legacy ID key "${key}" for table "${table_name}". Consider standardizing to "id".`,
obj
);
}
return obj[key];
}
}
for (const key of potential_keys) {
if (obj[key]) {
if (key !== 'id' && log_lvl > 0) {
console.warn(
`Found legacy ID key "${key}" for table "${table_name}". Consider standardizing to "id".`,
obj
);
}
return obj[key];
}
}
console.error(`Object is missing a valid ID for table "${table_name}". It will be skipped.`, obj);
return undefined;
console.error(
`Object is missing a valid ID for table "${table_name}". It will be skipped.`,
obj
);
return undefined;
}
/**
@@ -46,74 +49,74 @@ function find_object_id(
* @since 2025-11-13
*/
export async function db_save_ae_obj_li__ae_obj<T extends Record<string, any>>({
db_instance,
table_name,
obj_li,
properties_to_save,
log_lvl = 0
db_instance,
table_name,
obj_li,
properties_to_save,
log_lvl = 0
}: {
db_instance: Dexie;
table_name: string;
obj_li: T[];
properties_to_save: (keyof T)[];
log_lvl?: number;
db_instance: Dexie;
table_name: string;
obj_li: T[];
properties_to_save: (keyof T)[];
log_lvl?: number;
}) {
if (log_lvl > 0) {
console.log(
`*** db_save_ae_obj_li__ae_obj: Attempting to save ${obj_li.length} objects to table "${table_name}" ***`
);
}
if (log_lvl > 0) {
console.log(
`*** db_save_ae_obj_li__ae_obj: Attempting to save ${obj_li.length} objects to table "${table_name}" ***`
);
}
if (!obj_li || obj_li.length === 0) {
if (log_lvl > 0) console.log('No objects to save.');
return [];
}
if (!obj_li || obj_li.length === 0) {
if (log_lvl > 0) console.log('No objects to save.');
return [];
}
const db_table: Table<T> = db_instance.table(table_name);
if (!db_table) {
const error_msg = `Table not found in Dexie instance: ${table_name}`;
console.error(error_msg);
throw new Error(error_msg);
}
const db_table: Table<T> = db_instance.table(table_name);
if (!db_table) {
const error_msg = `Table not found in Dexie instance: ${table_name}`;
console.error(error_msg);
throw new Error(error_msg);
}
const data_to_save = obj_li
.map((obj) => {
const record: Partial<T> = {};
const data_to_save = obj_li
.map((obj) => {
const record: Partial<T> = {};
// Extract only the specified properties to save.
for (const prop of properties_to_save) {
record[prop] = obj[prop];
}
// Extract only the specified properties to save.
for (const prop of properties_to_save) {
record[prop] = obj[prop];
}
// Ensure the primary key is included, attempting to find it from various legacy keys.
const id = find_object_id(obj, table_name, log_lvl);
// Ensure the primary key is included, attempting to find it from various legacy keys.
const id = find_object_id(obj, table_name, log_lvl);
if (id === undefined) {
return null; // Skip objects without a valid ID.
}
if (id === undefined) {
return null; // Skip objects without a valid ID.
}
(record as any).id = id;
return record;
})
.filter(Boolean) as T[];
(record as any).id = id;
return record;
})
.filter(Boolean) as T[];
if (data_to_save.length === 0) {
if (log_lvl > 0) {
console.warn('All objects were skipped, likely due to missing IDs.');
}
return [];
}
if (data_to_save.length === 0) {
if (log_lvl > 0) {
console.warn('All objects were skipped, likely due to missing IDs.');
}
return [];
}
try {
// bulkPut efficiently handles both inserts and updates.
const keys = await db_table.bulkPut(data_to_save);
if (log_lvl > 0) {
console.log(`Successfully saved ${keys.length} objects to "${table_name}".`);
}
return keys;
} catch (error) {
console.error(`Failed to save objects to "${table_name}":`, error);
// Re-throw the error to let the caller handle it.
throw error;
}
try {
// bulkPut efficiently handles both inserts and updates.
const keys = await db_table.bulkPut(data_to_save);
if (log_lvl > 0) {
console.log(`Successfully saved ${keys.length} objects to "${table_name}".`);
}
return keys;
} catch (error) {
console.error(`Failed to save objects to "${table_name}":`, error);
// Re-throw the error to let the caller handle it.
throw error;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -10,138 +10,138 @@ const ae_promises: key_val = {};
// I recently made significant updates to this with the help of Copilot. I think it is correct.
// Updated 2025-10-03
export async function generate_qr_code({
api_cfg,
account_id,
qr_type, // mecard, obj, str, vcard
qr_id, // This is essentially the filename it can be found at /qr/{account_id}/{qr_id}
qr_data, // vcard fields:
obj_type,
obj_id,
str, // For encoding a string (like a URL) into a QR code.
return_blob = true, // blob or url?
try_cache = false,
log_lvl = 0
api_cfg,
account_id,
qr_type, // mecard, obj, str, vcard
qr_id, // This is essentially the filename it can be found at /qr/{account_id}/{qr_id}
qr_data, // vcard fields:
obj_type,
obj_id,
str, // For encoding a string (like a URL) into a QR code.
return_blob = true, // blob or url?
try_cache = false,
log_lvl = 0
}: {
api_cfg: any;
account_id: string;
qr_type: string;
qr_id: string;
qr_data?: any;
obj_type?: string;
obj_id?: string;
str?: string;
return_blob?: boolean;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
account_id: string;
qr_type: string;
qr_id: string;
qr_data?: any;
obj_type?: string;
obj_id?: string;
str?: string;
return_blob?: boolean;
try_cache?: boolean;
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}`);
}
const endpoint = `/qr/${account_id}/${qr_id}`;
if (log_lvl) {
console.log('Endpoint', endpoint);
}
const params: key_val = {
regen: true, // Regenerate the file even if nothing has changed.
return_file: return_blob,
qr_type: qr_type, // mecard, obj, vcard
qr_send: return_blob
};
const endpoint = `/qr/${account_id}/${qr_id}`;
if (log_lvl) {
console.log('Endpoint', endpoint);
}
const params: key_val = {
regen: true, // Regenerate the file even if nothing has changed.
return_file: return_blob,
qr_type: qr_type, // mecard, obj, vcard
qr_send: return_blob
};
if (qr_type == 'vcard') {
if (qr_data.informal_name) {
params['n'] = `${qr_data.family_name};${qr_data.given_name};${qr_data.informal_name}`;
} else {
params['n'] = `${qr_data.family_name};${qr_data.given_name}`;
}
params['fn'] = qr_data.full_name_override;
if (qr_data.affiliations) {
params['org'] = qr_data.affiliations;
}
params['email'] = qr_data.email;
if (qr_data.phone) {
params['tel'] = qr_data.phone;
}
params['adr'] = qr_data.location_override;
if (qr_data.address_line_1) {
params['adr_str'] = qr_data.address_line_1;
}
params['adr_loc'] = qr_data.city;
params['adr_reg'] = qr_data.state_province;
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 (qr_type == 'vcard') {
if (qr_data.informal_name) {
params['n'] = `${qr_data.family_name};${qr_data.given_name};${qr_data.informal_name}`;
} else {
params['n'] = `${qr_data.family_name};${qr_data.given_name}`;
}
params['fn'] = qr_data.full_name_override;
if (qr_data.affiliations) {
params['org'] = qr_data.affiliations;
}
params['email'] = qr_data.email;
if (qr_data.phone) {
params['tel'] = qr_data.phone;
}
params['adr'] = qr_data.location_override;
if (qr_data.address_line_1) {
params['adr_str'] = qr_data.address_line_1;
}
params['adr_loc'] = qr_data.city;
params['adr_reg'] = qr_data.state_province;
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) {
console.log('Params', params);
}
if (log_lvl) {
console.log('Params', params);
}
const filename = null;
const filename = null;
// Await the API call
ae_promises.generate_qr_code = await api.get_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
return_blob: return_blob,
filename: filename,
auto_download: false,
log_lvl: log_lvl
});
// Await the API call
ae_promises.generate_qr_code = await api.get_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
return_blob: return_blob,
filename: filename,
auto_download: false,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('QR code API response:', ae_promises.generate_qr_code);
}
if (log_lvl) {
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) {
const data = ae_promises.generate_qr_code.data ?? ae_promises.generate_qr_code;
// If return_blob is true, ensure we return an object URL for use in <img src=...>
if (return_blob) {
const data = ae_promises.generate_qr_code.data ?? ae_promises.generate_qr_code;
// If already a Blob, use it directly
if (data instanceof Blob) {
return URL.createObjectURL(data);
}
// If already a Blob, use it directly
if (data instanceof Blob) {
return URL.createObjectURL(data);
}
// If it's a Response (from fetch), convert to Blob
if (data instanceof Response) {
const blob = await data.blob();
return URL.createObjectURL(blob);
}
// If it's a Response (from fetch), convert to Blob
if (data instanceof Response) {
const blob = await data.blob();
return URL.createObjectURL(blob);
}
// If it's an ArrayBuffer or Uint8Array, convert to Blob
if (data instanceof ArrayBuffer || data instanceof Uint8Array) {
const blob = new Blob([data], { type: 'image/png' });
return URL.createObjectURL(blob);
}
// If it's an ArrayBuffer or Uint8Array, convert to Blob
if (data instanceof ArrayBuffer || data instanceof Uint8Array) {
const blob = new Blob([data], { type: 'image/png' });
return URL.createObjectURL(blob);
}
// If it's a base64 string, return as data URL
if (typeof data === 'string' && data.startsWith('data:image')) {
return data;
}
// If it's a base64 string, return as data URL
if (typeof data === 'string' && data.startsWith('data:image')) {
return data;
}
// If it's a raw string (base64), convert to data URL
if (typeof data === 'string') {
return `data:image/png;base64,${data}`;
}
// If it's a raw string (base64), convert to data URL
if (typeof data === 'string') {
return `data:image/png;base64,${data}`;
}
// Fallback: try to create a Blob from whatever is left
try {
const blob = new Blob([data], { type: 'image/png' });
return URL.createObjectURL(blob);
} catch (e) {
if (log_lvl) console.error('Could not create QR code image blob:', e, data);
return null;
}
}
// Fallback: try to create a Blob from whatever is left
try {
const blob = new Blob([data], { type: 'image/png' });
return URL.createObjectURL(blob);
} catch (e) {
if (log_lvl) console.error('Could not create QR code image blob:', e, data);
return null;
}
}
// If not returning a blob, return the raw API response
return ae_promises.generate_qr_code;
// If not returning a blob, return the raw API response
return ae_promises.generate_qr_code;
}
// Updated 2025-10-09
@@ -159,105 +159,105 @@ export async function generate_qr_code({
* @throws {Error} If the qr_type is unknown or data is missing.
*/
export async function js_generate_qr_code(qr_type, params = {}) {
const {
n = '',
fn = '',
org = '',
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;
const {
n = '',
fn = '',
org = '',
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 ---
switch (qr_type) {
case 'mecard':
// 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.
qr_data = `MECARD:N:${n};EMAIL:${email};;`;
// You can enhance this with other MeCard fields if needed.
break;
// --- 1. Replicate Data Formatting Logic ---
switch (qr_type) {
case 'mecard':
// 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.
qr_data = `MECARD:N:${n};EMAIL:${email};;`;
// You can enhance this with other MeCard fields if needed.
break;
case 'vcard':
// Format: BEGIN:VCARD...END:VCARD
qr_data = `BEGIN:VCARD\nVERSION:3.0\nN:${n}\nFN:${fn}\nORG:${org}\nEMAIL:${email}\n`;
case 'vcard':
// Format: BEGIN:VCARD...END:VCARD
qr_data = `BEGIN:VCARD\nVERSION:3.0\nN:${n}\nFN:${fn}\nORG:${org}\nEMAIL:${email}\n`;
if (url) {
qr_data += `URL:${url}\n`;
}
if (tel) {
qr_data += `TEL:${tel}\n`;
}
if (adr_loc) {
// 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;
if (url) {
qr_data += `URL:${url}\n`;
}
if (tel) {
qr_data += `TEL:${tel}\n`;
}
if (adr_loc) {
// 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':
// 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".');
qr_data = `OBJ:ot:${obj_type},oi:${obj_id}`;
break;
case 'obj':
// 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".');
qr_data = `OBJ:ot:${obj_type},oi:${obj_id}`;
break;
case 'kv':
// Custom format: KV:k:"key",v:"val"
if (!key || !val) throw new Error('Missing key or val for type "kv".');
qr_data = `KV:k:"${key}",v:"${val}"`;
break;
case 'kv':
// Custom format: KV:k:"key",v:"val"
if (!key || !val) throw new Error('Missing key or val for type "kv".');
qr_data = `KV:k:"${key}",v:"${val}"`;
break;
case 'js':
// Assumes 'js' is a stringified JSON object
if (!js) throw new Error('Missing js string for type "js".');
qr_data = `JS:${js}`;
break;
case 'js':
// Assumes 'js' is a stringified JSON object
if (!js) throw new Error('Missing js string for type "js".');
qr_data = `JS:${js}`;
break;
case 'str':
// Raw string data
if (!str) throw new Error('Missing raw string data for type "str".');
qr_data = str;
break;
case 'str':
// Raw string data
if (!str) throw new Error('Missing raw string data for type "str".');
qr_data = str;
break;
default:
throw new Error(`Unknown QR type: ${qr_type}`);
}
default:
throw new Error(`Unknown QR type: ${qr_type}`);
}
if (!qr_data) {
throw new Error('Failed to create QR code data string.');
}
if (!qr_data) {
throw new Error('Failed to create QR code data string.');
}
// --- 2. Generate QR Code Image ---
try {
// Options match the Python 'qrcode' library defaults closely:
// error_correction = qrcode.constants.ERROR_CORRECT_M
// box_size = 10, border = 1
const data_url = await QRCode.toDataURL(qr_data, {
errorCorrectionLevel: 'M',
margin: 1, // Corresponds to border
scale: 10, // Corresponds to box_size
type: 'image/png'
});
console.log('Generated QR code data URL:', data_url);
return data_url;
} catch (error) {
console.error('Error generating QR code:', error);
throw new Error('Could not generate QR code image.');
}
// --- 2. Generate QR Code Image ---
try {
// Options match the Python 'qrcode' library defaults closely:
// error_correction = qrcode.constants.ERROR_CORRECT_M
// box_size = 10, border = 1
const data_url = await QRCode.toDataURL(qr_data, {
errorCorrectionLevel: 'M',
margin: 1, // Corresponds to border
scale: 10, // Corresponds to box_size
type: 'image/png'
});
console.log('Generated QR code data URL:', data_url);
return data_url;
} catch (error) {
console.error('Error generating QR code:', error);
throw new Error('Could not generate QR code image.');
}
}

View File

@@ -1,50 +1,50 @@
export interface Site {
id: string;
// id_random: string;
site_id: string;
site_id_random?: string;
id: string;
// id_random: string;
site_id: string;
site_id_random?: string;
code?: string;
code?: string;
account_id: string;
account_id_random?: string;
account_id: string;
account_id_random?: string;
name: string;
description?: null | string;
name: string;
description?: null | string;
restrict_access?: null | boolean;
access_key?: null | string;
access_code_kv_json?: null | string;
restrict_access?: null | boolean;
access_key?: null | string;
access_code_kv_json?: null | string;
logo_path?: null | string;
logo_bg_color?: null | string; // Not really used currently.
// background_image_path?: null|string; // Legacy field
// background_bg_color?: null|string; // Legacy field
title?: null | string;
logo_path?: null | string;
logo_bg_color?: null | string; // Not really used currently.
// background_image_path?: null|string; // Legacy field
// background_bg_color?: null|string; // Legacy field
title?: null | string;
// header_html?: null|string; // Legacy field
// header_css?: null|string; // Legacy field
// header_image_path?: null|string; // Legacy field
// header_image_bg_color?: null|string; // Legacy field
// body_html?: null|string; // Legacy field
tagline?: null | string;
// site_header_h1?: null|string; // Legacy field
// site_header_h2?: null|string; // Legacy field
style_href?: null | string; // Legacy field
// script_src?: null|string; // Legacy field
google_tracking_id?: null | string;
// header_html?: null|string; // Legacy field
// header_css?: null|string; // Legacy field
// header_image_path?: null|string; // Legacy field
// header_image_bg_color?: null|string; // Legacy field
// body_html?: null|string; // Legacy field
tagline?: null | string;
// site_header_h1?: null|string; // Legacy field
// site_header_h2?: null|string; // Legacy field
style_href?: null | string; // Legacy field
// script_src?: null|string; // Legacy field
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_from?: null | Date;
enable_to?: null | Date;
enable: null | boolean;
enable_from?: null | Date;
enable_to?: null | Date;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
}

View File

@@ -1,22 +1,22 @@
export interface Site_Domain {
id: string;
// id_random: string;
site_id: string;
site_id_random?: string;
id: string;
// id_random: string;
site_id: string;
site_id_random?: string;
fqdn: string;
access_key?: null | string;
required_referrer?: null | string;
valid_for?: null | number; // In hours
fqdn: string;
access_key?: null | string;
required_referrer?: null | string;
valid_for?: null | number; // In hours
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
}
import { api } from '$lib/api/api';
@@ -31,45 +31,45 @@ import { api } from '$lib/api/api';
* @returns The site domain object or null if not found.
*/
export async function load_ae_obj_by_fqdn__site_domain({
api_cfg,
fqdn,
timeout = 7000,
log_lvl = 0
api_cfg,
fqdn,
timeout = 7000,
log_lvl = 0
}: {
api_cfg: any;
fqdn: string;
timeout?: number;
log_lvl?: number;
api_cfg: any;
fqdn: string;
timeout?: number;
log_lvl?: number;
}): Promise<any> {
if (log_lvl) {
console.log(
`*** load_ae_obj_by_fqdn__site_domain() *** api.base_url=${api_cfg.base_url}, fqdn=${fqdn}, timeout=${timeout}`
);
}
if (log_lvl) {
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 {
const site_domain_obj = await api.get_ae_obj_id_crud({
api_cfg: api_cfg,
no_account_id: true, // This seems to be a special case for this endpoint
obj_type: 'site_domain',
obj_id: fqdn, // NOTE: This is the FQDN, not the ID.
use_alt_table: true,
use_alt_base: true,
params: params,
timeout: timeout,
log_lvl: log_lvl
});
try {
const site_domain_obj = await api.get_ae_obj_id_crud({
api_cfg: api_cfg,
no_account_id: true, // This seems to be a special case for this endpoint
obj_type: 'site_domain',
obj_id: fqdn, // NOTE: This is the FQDN, not the ID.
use_alt_table: true,
use_alt_base: true,
params: params,
timeout: timeout,
log_lvl: log_lvl
});
if (site_domain_obj) {
return site_domain_obj;
} else {
console.log('No results returned.');
return null;
}
} catch (error) {
console.log('No results returned or failed.', error);
return null;
}
if (site_domain_obj) {
return site_domain_obj;
} else {
console.log('No results returned.');
return null;
}
} catch (error) {
console.log('No results returned or failed.', error);
return null;
}
}

View File

@@ -7,66 +7,66 @@ const ae_promises: key_val = {};
// Updated 2024-10-14
export async function load_ae_obj_li__time_zone({
api_cfg,
// account_id,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
// order_by_li = {'priority': 'DESC', 'group': 'ASC', 'sort': 'DESC', 'name': 'ASC'},
order_by_li = { priority: 'DESC', sort: 'DESC', name: 'ASC' },
params = {},
try_cache = true,
log_lvl = 0
api_cfg,
// account_id,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
// order_by_li = {'priority': 'DESC', 'group': 'ASC', 'sort': 'DESC', 'name': 'ASC'},
order_by_li = { priority: 'DESC', sort: 'DESC', name: 'ASC' },
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
// account_id: string,
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
offset?: number;
order_by_li?: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
// account_id: string,
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
offset?: number;
order_by_li?: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** load_ae_obj_li__time_zone() ***`);
}
if (log_lvl) {
console.log(`*** load_ae_obj_li__time_zone() ***`);
}
const 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({
api_cfg: api_cfg,
obj_type: 'lu',
for_obj_type: 'time_zone',
// for_obj_id: account_id,
use_alt_tbl: true, // NOTE: Using this with the time zones to use the view named "v_lu_time_zone_cust"
use_alt_mdl: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (time_zone_li_get_result) {
if (time_zone_li_get_result) {
// handle_db_save_ae_obj_li__time_zone({obj_type: 'time_zone', obj_li: time_zone_li_get_result});
return time_zone_li_get_result;
} else {
return [];
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
ae_promises.load__time_zone_li = await api
.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg: api_cfg,
obj_type: 'lu',
for_obj_type: 'time_zone',
// for_obj_id: account_id,
use_alt_tbl: true, // NOTE: Using this with the time zones to use the view named "v_lu_time_zone_cust"
use_alt_mdl: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (time_zone_li_get_result) {
if (time_zone_li_get_result) {
// handle_db_save_ae_obj_li__time_zone({obj_type: 'time_zone', obj_li: time_zone_li_get_result});
return time_zone_li_get_result;
} else {
return [];
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
console.log('ae_promises.load__time_zone_li:', ae_promises.load__time_zone_li);
return ae_promises.load__time_zone_li;
console.log('ae_promises.load__time_zone_li:', ae_promises.load__time_zone_li);
return ae_promises.load__time_zone_li;
}

View File

@@ -7,272 +7,272 @@ const ae_promises: key_val = {};
// Updated 2025-04-04
export async function auth_ae_obj__username_password({
api_cfg,
account_id,
null_account_id = false,
username,
password,
params = {},
try_cache = true,
log_lvl = 0
api_cfg,
account_id,
null_account_id = false,
username,
password,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
account_id: string;
null_account_id?: boolean;
username: string;
password: string;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
account_id: string;
null_account_id?: boolean;
username: string;
password: string;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(
`*** auth_ae_obj__username_password() *** account_id=${account_id} username=${username} password=${password}`
);
}
if (log_lvl) {
console.log(
`*** auth_ae_obj__username_password() *** account_id=${account_id} username=${username} password=${password}`
);
}
const endpoint = '/user/authenticate';
const endpoint = '/user/authenticate';
if (null_account_id) {
params['null_account_id'] = true;
}
params['username'] = username; // Required
params['password'] = password; // Required
if (log_lvl > 1) {
console.log(`auth_ae_obj__username_password() - params:`, params);
}
if (null_account_id) {
params['null_account_id'] = true;
}
params['username'] = username; // Required
params['password'] = password; // Required
if (log_lvl > 1) {
console.log(`auth_ae_obj__username_password() - params:`, params);
}
ae_promises.auth__username_password = await api
.get_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
// data: {},
log_lvl: log_lvl
})
.then(async function (user_obj_get_result) {
if (user_obj_get_result) {
// if (try_cache) {
// // This is expecting a list
// db_save_ae_obj_li__user({
// obj_type: 'user',
// obj_li: [user_obj_get_result],
// log_lvl: log_lvl
// });
// }
return user_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
ae_promises.auth__username_password = await api
.get_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
// data: {},
log_lvl: log_lvl
})
.then(async function (user_obj_get_result) {
if (user_obj_get_result) {
// if (try_cache) {
// // This is expecting a list
// db_save_ae_obj_li__user({
// obj_type: 'user',
// obj_li: [user_obj_get_result],
// log_lvl: log_lvl
// });
// }
return user_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.auth__username_password:', ae_promises.auth__username_password);
}
return ae_promises.auth__username_password;
if (log_lvl) {
console.log('ae_promises.auth__username_password:', ae_promises.auth__username_password);
}
return ae_promises.auth__username_password;
}
// Updated 2025-04-04
export async function auth_ae_obj__user_id_user_auth_key({
api_cfg,
account_id,
user_id,
user_auth_key,
params = {},
try_cache = true,
log_lvl = 0
api_cfg,
account_id,
user_id,
user_auth_key,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
account_id: string;
user_id: string;
user_auth_key: string;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
account_id: string;
user_id: string;
user_auth_key: string;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(
`*** auth_ae_obj__user_id_user_auth_key() *** account_id=${account_id} user_id=${user_id}`
);
}
if (log_lvl) {
console.log(
`*** auth_ae_obj__user_id_user_auth_key() *** account_id=${account_id} user_id=${user_id}`
);
}
const endpoint = '/user/authenticate';
const endpoint = '/user/authenticate';
params['user_id'] = user_id; // Required
params['auth_key'] = user_auth_key; // Required
if (log_lvl > 1) {
console.log(`auth_ae_obj__user_id_user_auth_key() - params:`, params);
}
params['user_id'] = user_id; // Required
params['auth_key'] = user_auth_key; // Required
if (log_lvl > 1) {
console.log(`auth_ae_obj__user_id_user_auth_key() - params:`, params);
}
ae_promises.auth__user_id_user_key = await api
.get_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
log_lvl: log_lvl
})
.then(async function (user_obj_get_result) {
if (user_obj_get_result) {
return user_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
ae_promises.auth__user_id_user_key = await api
.get_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
log_lvl: log_lvl
})
.then(async function (user_obj_get_result) {
if (user_obj_get_result) {
return user_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.auth__user_id_user_key:', ae_promises.auth__user_id_user_key);
}
return ae_promises.auth__user_id_user_key;
if (log_lvl) {
console.log('ae_promises.auth__user_id_user_key:', ae_promises.auth__user_id_user_key);
}
return ae_promises.auth__user_id_user_key;
}
// Send an email to the user with a new one time use authentication key. The new key must be generated and returned first.
// Updated 2025-04-08
export async function send_email_auth_ae_obj__user_id({
api_cfg,
account_id,
user_id,
base_url,
key_param_name = 'user_key', // API defaults to 'auth_key'
params = {},
// try_cache = true,
log_lvl = 0
api_cfg,
account_id,
user_id,
base_url,
key_param_name = 'user_key', // API defaults to 'auth_key'
params = {},
// try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
account_id: string;
user_id: string;
base_url?: string;
key_param_name?: string;
params?: key_val;
// try_cache?: boolean,
log_lvl?: number;
api_cfg: any;
account_id: string;
user_id: string;
base_url?: string;
key_param_name?: string;
params?: key_val;
// try_cache?: boolean,
log_lvl?: number;
}) {
if (log_lvl) {
console.log(
`*** send_email_auth_ae_obj__user_id() *** account_id=${account_id} user_id=${user_id}`
);
}
if (log_lvl > 1) {
console.log(api_cfg);
}
if (log_lvl) {
console.log(
`*** send_email_auth_ae_obj__user_id() *** account_id=${account_id} user_id=${user_id}`
);
}
if (log_lvl > 1) {
console.log(api_cfg);
}
const email_auth_key_endpoint = `user/${user_id}/email_auth_key_url`;
params = {
root_url: base_url,
key_param_name: key_param_name
};
ae_promises.auth_key__send_email = await api.get_object({
api_cfg: api_cfg,
endpoint: email_auth_key_endpoint,
params: params,
log_lvl: log_lvl
});
const email_auth_key_endpoint = `user/${user_id}/email_auth_key_url`;
params = {
root_url: base_url,
key_param_name: key_param_name
};
ae_promises.auth_key__send_email = await api.get_object({
api_cfg: api_cfg,
endpoint: email_auth_key_endpoint,
params: params,
log_lvl: log_lvl
});
return ae_promises.auth_key__send_email;
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
// if (log_lvl > 1) {
// console.log(`send_email_auth_ae_obj__user_id() - params:`, params);
// }
// // params['user_id'] = user_id; // Required
// if (log_lvl > 1) {
// console.log(`send_email_auth_ae_obj__user_id() - params:`, params);
// }
// ae_promises.auth_key__gen_auth_key = await api.get_object({
// api_cfg: api_cfg,
// endpoint: endpoint,
// params: params,
// log_lvl: log_lvl
// })
// .then(async function (email_send_result) {
// if (email_send_result) {
// let email_auth_key_endpoint = `user/${user_id}/email_auth_key_url`;
// params = {
// 'root_url': 'https://test.oneskyit.com'
// }
// ae_promises.auth_key__send_email = await api.get_object({
// api_cfg: api_cfg,
// endpoint: email_auth_key_endpoint,
// params: params,
// log_lvl: log_lvl
// })
// ae_promises.auth_key__gen_auth_key = await api.get_object({
// api_cfg: api_cfg,
// endpoint: endpoint,
// params: params,
// log_lvl: log_lvl
// })
// .then(async function (email_send_result) {
// if (email_send_result) {
// let email_auth_key_endpoint = `user/${user_id}/email_auth_key_url`;
// params = {
// 'root_url': 'https://test.oneskyit.com'
// }
// ae_promises.auth_key__send_email = await api.get_object({
// api_cfg: api_cfg,
// endpoint: email_auth_key_endpoint,
// params: params,
// log_lvl: log_lvl
// })
// return email_send_result;
// } else {
// console.log('No results returned.');
// return null;
// }
// })
// .catch(function (error: any) {
// console.log('No results returned or failed.', error);
// });
// return email_send_result;
// } else {
// console.log('No results returned.');
// return null;
// }
// })
// .catch(function (error: any) {
// console.log('No results returned or failed.', error);
// });
// if (log_lvl) {
// console.log('ae_promises.send_email_auth__user_id:', ae_promises.send_email_auth__user_id);
// }
// return ae_promises.send_email_auth__user_id;
// if (log_lvl) {
// console.log('ae_promises.send_email_auth__user_id:', ae_promises.send_email_auth__user_id);
// }
// return ae_promises.send_email_auth__user_id;
}
// Look up user based on email address provided
// Updated 2025-04-08
export async function qry_ae_obj_li__user_email({
api_cfg,
account_id,
null_account_id = false,
email,
params = {},
try_cache = true,
log_lvl = 0
api_cfg,
account_id,
null_account_id = false,
email,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
account_id: string;
null_account_id?: boolean;
email: string;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
account_id: string;
null_account_id?: boolean;
email: string;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** qry_ae_obj_li__user_email() *** account_id=${account_id} email=${email}`);
}
if (log_lvl) {
console.log(`*** qry_ae_obj_li__user_email() *** account_id=${account_id} email=${email}`);
}
const endpoint = '/user/lookup_email';
const endpoint = '/user/lookup_email';
params['email'] = email; // Required
params['null_account_id'] = null_account_id || false;
if (log_lvl > 1) {
console.log(`qry_ae_obj_li__user_email() - params:`, params);
}
params['email'] = email; // Required
params['null_account_id'] = null_account_id || false;
if (log_lvl > 1) {
console.log(`qry_ae_obj_li__user_email() - params:`, params);
}
ae_promises.qry__user_email = await api
.get_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
log_lvl: log_lvl
})
.then(async function (user_obj_get_result) {
if (user_obj_get_result) {
return user_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
ae_promises.qry__user_email = await api
.get_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
log_lvl: log_lvl
})
.then(async function (user_obj_get_result) {
if (user_obj_get_result) {
return user_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.qry__user_email:', ae_promises.qry__user_email);
}
return ae_promises.qry__user_email;
if (log_lvl) {
console.log('ae_promises.qry__user_email:', ae_promises.qry__user_email);
}
return ae_promises.qry__user_email;
}
// Change user password
@@ -281,55 +281,55 @@ export async function qry_ae_obj_li__user_email({
// data_kv: password (the new password)
// Updated 2025-04-11
export async function auth_ae_obj__user_id_change_password({
api_cfg,
account_id,
user_id,
password,
params = {},
log_lvl = 0
api_cfg,
account_id,
user_id,
password,
params = {},
log_lvl = 0
}: {
api_cfg: any;
account_id: string;
user_id: string;
password: string;
params?: key_val;
log_lvl?: number;
api_cfg: any;
account_id: string;
user_id: string;
password: string;
params?: key_val;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(
`*** auth_ae_obj__user_id_change_password() *** account_id=${account_id} user_id=${user_id}`
);
}
if (log_lvl) {
console.log(
`*** auth_ae_obj__user_id_change_password() *** account_id=${account_id} user_id=${user_id}`
);
}
const endpoint = `/user/${user_id}/change_password`;
const endpoint = `/user/${user_id}/change_password`;
params['user_id'] = user_id; // Required
if (log_lvl > 1) {
console.log(`auth_ae_obj__user_id_change_password() - params:`, params);
}
params['user_id'] = user_id; // Required
if (log_lvl > 1) {
console.log(`auth_ae_obj__user_id_change_password() - params:`, params);
}
ae_promises.change_password__user_id = await api
.patch_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
data: { password: password },
log_lvl: log_lvl
})
.then(async function (change_password_result) {
if (change_password_result) {
return change_password_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
ae_promises.change_password__user_id = await api
.patch_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
data: { password: password },
log_lvl: log_lvl
})
.then(async function (change_password_result) {
if (change_password_result) {
return change_password_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.change_password__user_id:', ae_promises.change_password__user_id);
}
return ae_promises.change_password__user_id;
if (log_lvl) {
console.log('ae_promises.change_password__user_id:', ae_promises.change_password__user_id);
}
return ae_promises.change_password__user_id;
}

View File

@@ -5,143 +5,143 @@ import Dexie, { type Table } from 'dexie';
// Updated 2025-01-07
export interface File {
id: string;
id_random: string;
hosted_file_id: string;
hosted_file_id_random: string;
id: string;
id_random: string;
hosted_file_id: string;
hosted_file_id_random: string;
hash_sha256: string;
hash_sha256: string;
for_type?: string;
for_id?: string;
for_id_random?: string;
for_type?: string;
for_id?: string;
for_id_random?: string;
account_id: string;
account_id: string;
filename: string;
extension: string;
content_type: string;
size: number; // In bytes
filename: string;
extension: string;
content_type: string;
size: number; // In bytes
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
// Additional fields for convenience (database views)
filename_no_ext: string;
filename_w_ext: string;
// Additional fields for convenience (database views)
filename_no_ext: string;
filename_w_ext: string;
}
// Updated 2024-07-17
export interface Person {
id: string;
// id_random: string;
person_id: string;
person_id_random: string;
id: string;
// id_random: string;
person_id: string;
person_id_random: string;
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.
code?: string; // Not currently used.
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.
code?: string; // Not currently used.
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?: 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_random?: null | string; // The new table person_profile will be used soon...
person_profile_id?: null | string;
person_profile_id_random?: null | string; // The new table person_profile will be used soon...
user_id?: string;
user_id_random?: string;
user_id?: string;
user_id_random?: string;
pronouns?: null | string;
informal_name?: null | string;
title_names?: null | string;
given_name: string;
middle_name?: null | string;
family_name: null | string;
designations?: null | string;
pronouns?: null | string;
informal_name?: null | string;
title_names?: null | string;
given_name: string;
middle_name?: null | string;
family_name: null | string;
designations?: null | string;
professional_title?: null | string;
professional_title?: null | string;
full_name?: string;
full_name_override?: null | string; // was called display_name
full_name?: string;
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;
comments?: null | string;
agree?: null | boolean;
comments?: null | string;
allow_auth_key?: null | boolean; // For sign in without password
auth_key?: null | string; // Should this be saved locally?
passcode?: null | string;
allow_auth_key?: null | boolean; // For sign in without password
auth_key?: null | string; // Should this be saved locally?
passcode?: null | string;
data_json?: null | string;
data_json?: null | string;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
// Generated fields for sorting locally only
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
tmp_sort_3?: null | string;
// Generated fields for sorting locally only
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
tmp_sort_3?: null | string;
// Additional fields for convenience (database views)
username?: string; // Same as user_username
// user_username?: null|string; // Same as username
user_name?: null | string;
user_email?: null | string;
user_allow_auth_key?: null | boolean; // For sign in without password
user_super?: boolean;
user_manager?: boolean;
user_administrator?: boolean;
user_public?: boolean;
// Additional fields for convenience (database views)
username?: string; // Same as user_username
// user_username?: null|string; // Same as username
user_name?: null | string;
user_email?: null | string;
user_allow_auth_key?: null | boolean; // For sign in without password
user_super?: boolean;
user_manager?: boolean;
user_administrator?: boolean;
user_public?: boolean;
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_name?: null | string;
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_name?: null | string;
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_name?: null | string;
contact_email?: null | string;
contact_cc_email?: null | string;
contact_phone_mobile?: null | string;
contact_phone_home?: null | string;
contact_phone_office?: null | string;
contact_phone_landline?: null | string;
contact_phone_fax?: null | string;
contact_phone_other?: null | string;
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_name?: null | string;
contact_email?: null | string;
contact_cc_email?: null | string;
contact_phone_mobile?: null | string;
contact_phone_home?: null | string;
contact_phone_office?: null | string;
contact_phone_landline?: null | string;
contact_phone_fax?: null | string;
contact_phone_other?: null | string;
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_city?: null | string;
address_country_alpha_2_code?: null | string; // ISO 3166-1 alpha-2 country code
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_city?: null | string;
address_country_alpha_2_code?: null | string; // ISO 3166-1 alpha-2 country code
}
// Updated 2025-01-07
export class MySubClassedDexie extends Dexie {
file!: Table<File>;
person!: Table<Person>;
// user!: Table<User>;
file!: Table<File>;
person!: Table<Person>;
// user!: Table<User>;
constructor() {
super('ae_core_db');
this.version(1).stores({
file: `
constructor() {
super('ae_core_db');
this.version(1).stores({
file: `
id, id_random, hosted_file_id, hosted_file_id_random,
hash_sha256,
account_id,
@@ -150,7 +150,7 @@ export class MySubClassedDexie extends Dexie {
content_type, size,
enable, hide, priority, sort, group, created_on, updated_on`,
person: `
person: `
id, person_id, person_id_random,
external_id, code,
account_id, user_id,
@@ -161,8 +161,8 @@ export class MySubClassedDexie extends Dexie {
full_name, affiliations, email,
agree,
enable, hide, priority, sort, group, created_on, updated_on`
});
}
});
}
}
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

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

File diff suppressed because it is too large Load Diff

View File

@@ -7,14 +7,14 @@ 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 {
load_ae_obj_id__exhibit,
load_ae_obj_li__exhibit,
load_ae_obj_id__exhibit_tracking,
load_ae_obj_li__exhibit_tracking,
create_ae_obj__exhibit_tracking,
update_ae_obj__exhibit_tracking,
download_export__event_exhibit_tracking
// db_save_ae_obj_li__exhibitor,
load_ae_obj_id__exhibit,
load_ae_obj_li__exhibit,
load_ae_obj_id__exhibit_tracking,
load_ae_obj_li__exhibit_tracking,
create_ae_obj__exhibit_tracking,
update_ae_obj__exhibit_tracking,
download_export__event_exhibit_tracking
// db_save_ae_obj_li__exhibitor,
} from '$lib/ae_events/ae_events__exhibit';
import * as event_location from '$lib/ae_events/ae_events__event_location';
@@ -30,102 +30,102 @@ 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';
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,
// 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,
// Event Badges
load_ae_obj_id__event_badge: event_badge.load_ae_obj_id__event_badge,
load_ae_obj_li__event_badge: event_badge.load_ae_obj_li__event_badge,
create_ae_obj__event_badge: event_badge.create_ae_obj__event_badge,
delete_ae_obj_id__event_badge: event_badge.delete_ae_obj_id__event_badge,
update_ae_obj__event_badge: event_badge.update_ae_obj__event_badge,
qry__event_badge: event_badge.qry__event_badge,
search__event_badge: event_badge.search__event_badge,
// 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 Badges
load_ae_obj_id__event_badge: event_badge.load_ae_obj_id__event_badge,
load_ae_obj_li__event_badge: event_badge.load_ae_obj_li__event_badge,
create_ae_obj__event_badge: event_badge.create_ae_obj__event_badge,
delete_ae_obj_id__event_badge: event_badge.delete_ae_obj_id__event_badge,
update_ae_obj__event_badge: event_badge.update_ae_obj__event_badge,
qry__event_badge: event_badge.qry__event_badge,
search__event_badge: event_badge.search__event_badge,
// 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
load_ae_obj_id__event_badge_template: event_badge_template.load_ae_obj_id__event_badge_template,
load_ae_obj_li__event_badge_template: event_badge_template.load_ae_obj_li__event_badge_template,
create_ae_obj__event_badge_template: event_badge_template.create_ae_obj__event_badge_template,
delete_ae_obj_id__event_badge_template:
event_badge_template.delete_ae_obj_id__event_badge_template,
update_ae_obj__event_badge_template: event_badge_template.update_ae_obj__event_badge_template,
search__event_badge_template: event_badge_template.search__event_badge_template,
// Event Badge Templates
load_ae_obj_id__event_badge_template: event_badge_template.load_ae_obj_id__event_badge_template,
load_ae_obj_li__event_badge_template: event_badge_template.load_ae_obj_li__event_badge_template,
create_ae_obj__event_badge_template: event_badge_template.create_ae_obj__event_badge_template,
delete_ae_obj_id__event_badge_template:
event_badge_template.delete_ae_obj_id__event_badge_template,
update_ae_obj__event_badge_template: event_badge_template.update_ae_obj__event_badge_template,
search__event_badge_template: event_badge_template.search__event_badge_template,
// Event Devices
load_ae_obj_id__event_device: event_device.load_ae_obj_id__event_device,
load_ae_obj_li__event_device: event_device.load_ae_obj_li__event_device,
create_ae_obj__event_device: event_device.create_ae_obj__event_device,
delete_ae_obj_id__event_device: event_device.delete_ae_obj_id__event_device,
update_ae_obj__event_device: event_device.update_ae_obj__event_device,
// db_save_ae_obj_li__event_device: event_device.db_save_ae_obj_li__event_device,
// Event Devices
load_ae_obj_id__event_device: event_device.load_ae_obj_id__event_device,
load_ae_obj_li__event_device: event_device.load_ae_obj_li__event_device,
create_ae_obj__event_device: event_device.create_ae_obj__event_device,
delete_ae_obj_id__event_device: event_device.delete_ae_obj_id__event_device,
update_ae_obj__event_device: event_device.update_ae_obj__event_device,
// db_save_ae_obj_li__event_device: event_device.db_save_ae_obj_li__event_device,
// Event Exhibits
handle_load_ae_obj_id__exhibit: load_ae_obj_id__exhibit,
handle_load_ae_obj_li__exhibit: load_ae_obj_li__exhibit,
handle_load_ae_obj_id__exhibit_tracking: load_ae_obj_id__exhibit_tracking,
handle_load_ae_obj_li__exhibit_tracking: load_ae_obj_li__exhibit_tracking,
handle_create_ae_obj__exhibit_tracking: create_ae_obj__exhibit_tracking,
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
handle_load_ae_obj_id__exhibit: load_ae_obj_id__exhibit,
handle_load_ae_obj_li__exhibit: load_ae_obj_li__exhibit,
handle_load_ae_obj_id__exhibit_tracking: load_ae_obj_id__exhibit_tracking,
handle_load_ae_obj_li__exhibit_tracking: load_ae_obj_li__exhibit_tracking,
handle_create_ae_obj__exhibit_tracking: create_ae_obj__exhibit_tracking,
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 Files
load_ae_obj_id__event_file: event_file.load_ae_obj_id__event_file,
load_ae_obj_li__event_file: event_file.load_ae_obj_li__event_file,
create_event_file_obj_from_hosted_file_async:
event_file.create_event_file_obj_from_hosted_file_async,
delete_ae_obj_id__event_file: event_file.delete_ae_obj_id__event_file,
update_ae_obj__event_file: event_file.update_ae_obj__event_file,
qry__event_file: event_file.qry__event_file,
search__event_file: event_file.search__event_file,
// db_save_ae_obj_li__event_file: event_file.db_save_ae_obj_li__event_file,
// Event Files
load_ae_obj_id__event_file: event_file.load_ae_obj_id__event_file,
load_ae_obj_li__event_file: event_file.load_ae_obj_li__event_file,
create_event_file_obj_from_hosted_file_async:
event_file.create_event_file_obj_from_hosted_file_async,
delete_ae_obj_id__event_file: event_file.delete_ae_obj_id__event_file,
update_ae_obj__event_file: event_file.update_ae_obj__event_file,
qry__event_file: event_file.qry__event_file,
search__event_file: event_file.search__event_file,
// db_save_ae_obj_li__event_file: event_file.db_save_ae_obj_li__event_file,
// Event Locations
load_ae_obj_id__event_location: event_location.load_ae_obj_id__event_location,
load_ae_obj_li__event_location: event_location.load_ae_obj_li__event_location,
create_ae_obj__event_location: event_location.create_ae_obj__event_location,
delete_ae_obj_id__event_location: event_location.delete_ae_obj_id__event_location,
update_ae_obj__event_location: event_location.update_ae_obj__event_location,
// db_save_ae_obj_li__event_location: event_location.db_save_ae_obj_li__event_location,
// Event Locations
load_ae_obj_id__event_location: event_location.load_ae_obj_id__event_location,
load_ae_obj_li__event_location: event_location.load_ae_obj_li__event_location,
create_ae_obj__event_location: event_location.create_ae_obj__event_location,
delete_ae_obj_id__event_location: event_location.delete_ae_obj_id__event_location,
update_ae_obj__event_location: event_location.update_ae_obj__event_location,
// db_save_ae_obj_li__event_location: event_location.db_save_ae_obj_li__event_location,
// Event Sessions
load_ae_obj_id__event_session: event_session.load_ae_obj_id__event_session,
load_ae_obj_li__event_session: event_session.load_ae_obj_li__event_session,
create_ae_obj__event_session: event_session.create_ae_obj__event_session,
delete_ae_obj_id__event_session: event_session.delete_ae_obj_id__event_session,
update_ae_obj__event_session: event_session.update_ae_obj__event_session,
qry__event_session: event_session.qry__event_session,
search__event_session: event_session.search__event_session,
email_sign_in__event_session: event_session.email_sign_in__event_session,
// db_save_ae_obj_li__event_session: event_session.db_save_ae_obj_li__event_session,
// Event Sessions
load_ae_obj_id__event_session: event_session.load_ae_obj_id__event_session,
load_ae_obj_li__event_session: event_session.load_ae_obj_li__event_session,
create_ae_obj__event_session: event_session.create_ae_obj__event_session,
delete_ae_obj_id__event_session: event_session.delete_ae_obj_id__event_session,
update_ae_obj__event_session: event_session.update_ae_obj__event_session,
qry__event_session: event_session.qry__event_session,
search__event_session: event_session.search__event_session,
email_sign_in__event_session: event_session.email_sign_in__event_session,
// db_save_ae_obj_li__event_session: event_session.db_save_ae_obj_li__event_session,
// 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 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 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

View File

@@ -4,18 +4,18 @@ import * as journal from '$lib/ae_journals/ae_journals__journal';
import * as journal_entry from '$lib/ae_journals/ae_journals__journal_entry';
const export_obj = {
load_ae_obj_id__journal: journal.load_ae_obj_id__journal,
load_ae_obj_li__journal: journal.load_ae_obj_li__journal,
create_ae_obj__journal: journal.create_ae_obj__journal,
delete_ae_obj_id__journal: journal.delete_ae_obj_id__journal,
update_ae_obj__journal: journal.update_ae_obj__journal,
// db_save_ae_obj_li__journal: journal.db_save_ae_obj_li__journal,
load_ae_obj_id__journal_entry: journal_entry.load_ae_obj_id__journal_entry,
load_ae_obj_li__journal_entry: journal_entry.load_ae_obj_li__journal_entry,
create_ae_obj__journal_entry: journal_entry.create_ae_obj__journal_entry,
delete_ae_obj_id__journal_entry: journal_entry.delete_ae_obj_id__journal_entry,
update_ae_obj__journal_entry: journal_entry.update_ae_obj__journal_entry,
qry__journal_entry: journal_entry.qry__journal_entry
// db_save_ae_obj_li__journal_entry: journal_entry.db_save_ae_obj_li__journal_entry,
load_ae_obj_id__journal: journal.load_ae_obj_id__journal,
load_ae_obj_li__journal: journal.load_ae_obj_li__journal,
create_ae_obj__journal: journal.create_ae_obj__journal,
delete_ae_obj_id__journal: journal.delete_ae_obj_id__journal,
update_ae_obj__journal: journal.update_ae_obj__journal,
// db_save_ae_obj_li__journal: journal.db_save_ae_obj_li__journal,
load_ae_obj_id__journal_entry: journal_entry.load_ae_obj_id__journal_entry,
load_ae_obj_li__journal_entry: journal_entry.load_ae_obj_li__journal_entry,
create_ae_obj__journal_entry: journal_entry.create_ae_obj__journal_entry,
delete_ae_obj_id__journal_entry: journal_entry.delete_ae_obj_id__journal_entry,
update_ae_obj__journal_entry: journal_entry.update_ae_obj__journal_entry,
qry__journal_entry: journal_entry.qry__journal_entry
// db_save_ae_obj_li__journal_entry: journal_entry.db_save_ae_obj_li__journal_entry,
};
export const journals_func = export_obj;

View File

@@ -9,88 +9,88 @@ import type { key_val } from '$lib/stores/ae_stores';
// This is for longer term or sticky app data. This should be stored to *local* storage.
// Updated 2025-03-20
const journals_local_data_struct: key_val = {
ver: '2024-08-20_19',
// Shared
name: 'Aether - Journals (SvelteKit 2.x Svelte 5.x)',
title: `OSIT's Æ Journals`, // &AElig;
ver: '2024-08-20_19',
// Shared
name: 'Aether - Journals (SvelteKit 2.x Svelte 5.x)',
title: `OSIT's Æ Journals`, // &AElig;
mode__edit: false,
mode__debug: false,
mode__edit: false,
mode__debug: false,
datetime_format: 'datetime_12_long',
time_format: 'time_12_short',
time_hours: 12, // 12 or 24
datetime_format: 'datetime_12_long',
time_format: 'time_12_short',
time_hours: 12, // 12 or 24
qry__enabled: 'enabled', // all, disabled, enabled
qry__hidden: 'not_hidden', // all, hidden, not_hidden
qry__limit: 20,
qry__order_by_li: {
// 'created_on': 'desc',
// 'updated_on': 'desc',
},
qry__offset: 0,
qry__journal_id: null,
qry__enabled: 'enabled', // all, disabled, enabled
qry__hidden: 'not_hidden', // all, hidden, not_hidden
qry__limit: 20,
qry__order_by_li: {
// 'created_on': 'desc',
// 'updated_on': 'desc',
},
qry__offset: 0,
qry__journal_id: null,
journal_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_kv: {}, // Keyed by journal_entry_id for quick lookup.
entry_view_history_max: 15, // Maximum number of journal entries to keep in history.
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_kv: {}, // Keyed by journal_entry_id for quick lookup.
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_model: 'dgrzone-deepseek-8b-quick',
llm__api_token:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVhYjI2MzdlLThiMjktNGM2Zi05MzVhLWFkYjU1MDkwMGU5MCJ9.VObfR91GrX3j1vHbHZqGsOWEyrL981cbSWWjaXfYbUQ',
llm__api_dangerous_browser: false, // This allows for use of localhost.
llm__stream: false, // Whether to use streaming or not. Not all APIs support this.
llm__timeout_ms: 60000, // 60 seconds
llm__max_retries: 3, // Number of times to retry a failed LLM API call.
llm__retry_delay_ms: 2000, // 2 seconds between retries.
llm__api_base_url: 'https://ai.dgrzone.com/api',
llm__api_model: 'dgrzone-deepseek-8b-quick',
llm__api_token:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVhYjI2MzdlLThiMjktNGM2Zi05MzVhLWFkYjU1MDkwMGU5MCJ9.VObfR91GrX3j1vHbHZqGsOWEyrL981cbSWWjaXfYbUQ',
llm__api_dangerous_browser: false, // This allows for use of localhost.
llm__stream: false, // Whether to use streaming or not. Not all APIs support this.
llm__timeout_ms: 60000, // 60 seconds
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__max_tokens: 1024,
llm__temperature: 0.7,
llm__top_p: 1.0,
llm__n: 1,
llm__frequency_penalty: 0.0,
llm__presence_penalty: 0.0,
llm__system_prompt: 'You are a helpful assistant that helps people find information.',
llm__max_tokens: 1024,
llm__temperature: 0.7,
llm__top_p: 1.0,
llm__n: 1,
llm__frequency_penalty: 0.0,
llm__presence_penalty: 0.0,
journal: {
edit: false,
edit_kv: {},
journal: {
edit: false,
edit_kv: {},
type_code_li: [
{ code: 'diary', name: 'Diary' },
{ code: 'log', name: 'Log' },
{ code: 'journal', name: 'Journal' },
{ code: 'notebook', name: 'Notebook' },
{ code: 'personal', name: 'Personal' },
{ code: 'professional', name: 'Professional' },
{ code: 'tracking', name: 'Tracking' },
{ code: 'other', name: 'Other' },
{ code: 'test', name: 'Test' }
// { code: 'notepad', name: 'Notepad' },
]
},
entry: {
llm__system_prompt:
'Summarize the following journal entry content in a concise manner, focusing on key points and insights.',
llm__max_tokens: 512,
llm__temperature: 0.7,
llm__top_p: 1.0,
llm__n: 1,
llm__frequency_penalty: 0.0,
llm__presence_penalty: 0.0,
type_code_li: [
{ code: 'diary', name: 'Diary' },
{ code: 'log', name: 'Log' },
{ code: 'journal', name: 'Journal' },
{ code: 'notebook', name: 'Notebook' },
{ code: 'personal', name: 'Personal' },
{ code: 'professional', name: 'Professional' },
{ code: 'tracking', name: 'Tracking' },
{ code: 'other', name: 'Other' },
{ code: 'test', name: 'Test' }
// { code: 'notepad', name: 'Notepad' },
]
},
entry: {
llm__system_prompt:
'Summarize the following journal entry content in a concise manner, focusing on key points and insights.',
llm__max_tokens: 512,
llm__temperature: 0.7,
llm__top_p: 1.0,
llm__n: 1,
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);
// This works and uses *local* storage:
export const journals_loc: Writable<key_val> = persisted(
'ae_journals_loc',
journals_local_data_struct
'ae_journals_loc',
journals_local_data_struct
);
// console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
@@ -98,47 +98,47 @@ export const journals_loc: Writable<key_val> = persisted(
// 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
const journals_session_data_struct: key_val = {
ver: '2024-08-20_19',
log_lvl: 1,
ver: '2024-08-20_19',
log_lvl: 1,
// Shared Triggers
trigger: null,
trigger__journal_id: null,
// trigger__journal_li: null,
// Shared Triggers
trigger: null,
trigger__journal_id: null,
// trigger__journal_li: null,
show__modal__journals_config: false,
show__modal__journals_config: false,
show__modal_edit__journal_obj: false,
show__modal_new__journal_obj: false,
show__modal_view__journal_id: null,
show_list__journal_entry_li_group: true,
show__modal_view__journal_entry_id: null,
show__modal_edit__journal_entry_id: null,
show__modal_edit__journal_obj: false,
show__modal_new__journal_obj: false,
show__modal_view__journal_id: null,
show_list__journal_entry_li_group: true,
show__modal_view__journal_entry_id: null,
show__modal_edit__journal_entry_id: null,
show__content__journal_entry_history: false,
show__content__journal_entry_history: false,
journal: {
edit: false,
edit_kv: {},
journal: {
edit: false,
edit_kv: {},
new_journal_name: '',
new_journal_type_code: '',
new_journal_name: '',
new_journal_type_code: '',
tmp_obj: {}
},
entry: {
show__ai_summary: false,
ai_summary: '',
decrypt_kv: {}, // Essentially flag that the entry (content and history) can be decrypted.
edit: false,
edit_kv: {},
tmp_obj: {}
},
entry: {
show__ai_summary: false,
ai_summary: '',
decrypt_kv: {}, // Essentially flag that the entry (content and history) can be decrypted.
edit: false,
edit_kv: {},
tmp_obj: {}
},
tmp_obj: {}
},
journal_kv: {
// journal_id: {},
}
journal_kv: {
// journal_id: {},
}
};
// console.log(`AE Stores - App Journals Session Storage Data:`, journals_session_data_struct);
export const journals_sess = writable(journals_session_data_struct);
@@ -149,15 +149,15 @@ export const journals_sess = writable(journals_session_data_struct);
// Intended for temporary session storage.
// Updated 2024-08-20
const journals_slct_obj_template: key_val = {
// Top level
journal_id: null,
journal_obj: {},
journal_obj_li: [],
// Top level
journal_id: null,
journal_obj: {},
journal_obj_li: [],
tmp_journal_obj: {}, // Temporary object for new journal
tmp_journal_entry_obj: {}, // Temporary object for new journal entry
tmp_journal_obj: {}, // Temporary object for new journal
tmp_journal_entry_obj: {}, // Temporary object for new journal entry
lq__journal_obj: {} // Testing passing a LiveQuery object around...
lq__journal_obj: {} // Testing passing a LiveQuery object around...
};
// console.log(`AE Stores - Selected Journals Objects:`, journals_slct_obj_template);
@@ -168,8 +168,8 @@ export const journals_slct = writable(journals_slct_obj_template);
// Intended for temporary session storage.
// Updated 2025-03-16
const journals_trig_template: key_val = {
journal_id: false,
journal_entry_li: false
journal_id: false,
journal_entry_li: false
};
export const journals_trig: any = writable(journals_trig_template);
// console.log(`AE Journals Stores - Journals Trigger:`, journals_trig);
@@ -178,8 +178,8 @@ export const journals_trig: any = writable(journals_trig_template);
// Intended for temporary session storage.
// Updated 2025-03-16
const journals_prom_template: key_val = {
journal_id: false,
journal_entry_li: false
journal_id: false,
journal_entry_li: false
};
export const journals_prom: any = writable(journals_prom_template);
// console.log(`AE Journals Stores - Journals Trigger:`, journals_prom);

View File

@@ -10,509 +10,509 @@ import type { key_val } from '$lib/stores/ae_stores';
// Updated 2025-03-15
export interface Journal {
id: string; // actually "id_random"
journal_id: string;
id: string; // actually "id_random"
journal_id: string;
// Essentially this is a change log of journals
snapshot_id?: string; // This is the original journal ID. If deleted, then delete all children journals.
previous_id?: null | string; // This is the old or parent journal ID
next_id?: null | string; // This is the new or child journal ID
// Essentially this is a change log of journals
snapshot_id?: string; // This is the original journal ID. If deleted, then delete all children journals.
previous_id?: null | string; // This is the old or parent journal ID
next_id?: null | string; // This is the new or child journal ID
external_id?: null | string;
import_id?: null | string;
code?: null | string;
external_id?: null | string;
import_id?: null | string;
code?: null | string;
for_type?: null | string;
for_id?: null | string;
for_type?: null | string;
for_id?: null | string;
// template?: null|boolean; // Is this a template journal? If true, it can be used to create new journals.
// 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
person_id?: null | string; // Owner person of the journal
// event_id?: null|string; // Assign to an event???
// location_id?: null|string; // Assign to a location???
account_id?: null | string; // Owner account of the journal
person_id?: null | string; // Owner person of the journal
// event_id?: null|string; // Assign to an event???
// location_id?: null|string; // Assign to a location???
name: string; // or the title
short_name?: null | string; // Short name for the journal, if any. Used for display purposes.
summary?: null | string; // LLM (AI) generated summary...???
outline?: null | string; // LLM (AI) generated outline...???
name: string; // or the title
short_name?: null | string; // Short name for the journal, if any. Used for display purposes.
summary?: null | string; // LLM (AI) generated summary...???
outline?: null | string; // LLM (AI) generated outline...???
description?: null | string;
description_md_html?: null | string; // Markdown converted to HTML based on description. Uses marked or similar library for conversion.
description_md_html_alt?: null | string; // Markdown converted to HTML based on description. Uses marked or similar library for conversion.
description_html?: null | string;
description_json?: null | string;
description?: null | string;
description_md_html?: null | string; // Markdown converted to HTML based on description. Uses marked or similar library for conversion.
description_md_html_alt?: null | string; // Markdown converted to HTML based on description. Uses marked or similar library for conversion.
description_html?: null | string;
description_json?: null | string;
start_datetime?: null | Date;
end_datetime?: null | Date;
timezone?: null | string;
start_datetime?: null | Date;
end_datetime?: null | Date;
timezone?: null | string;
alert?: null | boolean; // LLM (AI) generated summary...???
alert_msg?: null | string; // LLM (AI) generated summary...???
alert?: null | boolean; // LLM (AI) generated summary...???
alert_msg?: null | string; // LLM (AI) generated summary...???
sort_by?: null | string; // This is the sort by field
sort_by_desc?: null | string; // This is the sort by field description
sort_by?: null | string; // This is the sort by field
sort_by_desc?: null | string; // This is the sort by field description
cfg_json?: null | key_val; // This is the configuration JSON for the journal
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.
passcode_read?: null | string; // For LLM (AI) generated summary...???
passcode_read_expire?: null | Date;
passcode_write?: null | string;
passcode_write_expire?: null | Date;
// This only allows for basic access to the data.
passcode_read?: null | string; // For LLM (AI) generated summary...???
passcode_read_expire?: null | Date;
passcode_write?: null | string;
passcode_write_expire?: null | Date;
passcode?: null | string; // For Journal Entry encryption password
passcode_timeout?: null | number; // Timeout in seconds
passcode?: null | string; // For Journal Entry encryption password
passcode_timeout?: null | number; // Timeout in seconds
private_passcode?: null | string; // Combine with the Journal passcode for Journal Entry encryption password
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;
hide?: null | boolean;
archive?: null | boolean; // Archive the journal
archive_on?: null | Date;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
enable: null | boolean;
hide?: null | boolean;
archive?: null | boolean; // Archive the journal
archive_on?: null | Date;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
// Generated fields for sorting locally only
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
tmp_sort_3?: null | string;
// Generated fields for sorting locally only
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
tmp_sort_3?: null | string;
combined_passcode?: null | string; // For Journal Entry encryption password
combined_passcode?: null | string; // For Journal Entry encryption password
// Additional fields for convenience (database views)
file_count?: null | number; // Only files directly under a journal
journal_file_id_li_json?: null | string;
// Additional fields for convenience (database views)
file_count?: null | number; // Only files directly under a journal
journal_file_id_li_json?: null | string;
// One person
person__given_name?: null | string;
person__family_name?: null | string;
person__full_name?: null | string;
person__primary_email?: null | string;
person__passcode?: null | string;
// One person
person__given_name?: null | string;
person__family_name?: null | string;
person__full_name?: null | string;
person__primary_email?: null | string;
person__passcode?: null | string;
// JSON formatted key value pairs for multiple people: {id: name, email, etc.}
person__kv_json?: null | string;
// JSON formatted key value pairs for multiple people: {id: name, email, etc.}
person__kv_json?: null | string;
journal_name?: null | string;
journal_name?: null | string;
journal_location_code?: null | string;
journal_location_name?: null | string;
journal_location_code?: null | string;
journal_location_name?: null | string;
journal_entry_count?: null | number;
journal_entry_count?: null | number;
// A key value list of the entries
journal_entry_kv?: null | key_val;
journal_entry_li?: null | [];
// A key value list of the files
journal_file_kv?: null | key_val;
journal_file_li?: null | [];
// A key value list of the entries
journal_entry_kv?: null | key_val;
journal_entry_li?: null | [];
// A key value list of the files
journal_file_kv?: null | key_val;
journal_file_li?: null | [];
// journal_collection_id?: null|string; // For a collection of journals?
// journal_collection_id?: null|string; // For a collection of journals?
// Future standard fields!!!
obj_id?: null | string;
obj_ext_uid?: null | string; // Probably not needed for journals
obj_ext_id?: null | string; // Probably not needed for journals
obj_import_id?: null | string; // Probably not needed for journals
obj_code?: null | string;
obj_account_id?: null | string;
obj_passcode?: null | string;
obj_type?: null | string; // Should always be 'journal' in this case
obj_type_ver_id?: null | string; // The ID from the table for the object type
obj_name?: null | string;
obj_summary?: null | string; // LLM (AI) generated summary...???
obj_outline?: null | string; // LLM (AI) generated outline...???
obj_description?: null | string; // Probably not needed for journals
obj_enable?: null | boolean;
obj_enable_on?: null | Date;
obj_archive_on?: null | Date;
obj_hide?: null | boolean;
obj_priority?: null | number;
obj_sort?: null | number;
obj_group?: null | string;
obj_cfg_json?: null | string;
obj_notes?: null | string;
obj_created_on?: Date;
obj_updated_on?: null | Date;
// Future standard fields!!!
obj_id?: null | string;
obj_ext_uid?: null | string; // Probably not needed for journals
obj_ext_id?: null | string; // Probably not needed for journals
obj_import_id?: null | string; // Probably not needed for journals
obj_code?: null | string;
obj_account_id?: null | string;
obj_passcode?: null | string;
obj_type?: null | string; // Should always be 'journal' in this case
obj_type_ver_id?: null | string; // The ID from the table for the object type
obj_name?: null | string;
obj_summary?: null | string; // LLM (AI) generated summary...???
obj_outline?: null | string; // LLM (AI) generated outline...???
obj_description?: null | string; // Probably not needed for journals
obj_enable?: null | boolean;
obj_enable_on?: null | Date;
obj_archive_on?: null | Date;
obj_hide?: null | boolean;
obj_priority?: null | number;
obj_sort?: null | number;
obj_group?: null | string;
obj_cfg_json?: null | string;
obj_notes?: null | string;
obj_created_on?: Date;
obj_updated_on?: null | Date;
}
export const journal_field_li = [
'id',
'journal_id',
'snapshot_id',
'previous_id',
'next_id',
'external_id',
'import_id',
'code',
'for_type',
'for_id',
'type_code',
'account_id',
'person_id',
'name',
'short_name',
'summary',
'outline',
'description',
'description_md_html',
'description_md_html_alt',
'description_html',
'description_json',
'start_datetime',
'end_datetime',
'timezone',
'alert',
'alert_msg',
'sort_by',
'sort_by_desc',
'cfg_json',
'data_json',
'ux_mode',
'passcode_read',
'passcode_read_expire',
'passcode_write',
'passcode_write_expire',
'passcode_timeout',
'private_passcode',
'auth_key',
'enable',
'hide',
'archive', // Archive the journal
'archive_on', // Archive date
'priority', // Priority flag
'sort', // Sort order
'group', // Group name
'notes', // Notes about the journal
'created_on', // Creation date
'updated_on', // Last updated date
'id',
'journal_id',
'snapshot_id',
'previous_id',
'next_id',
'external_id',
'import_id',
'code',
'for_type',
'for_id',
'type_code',
'account_id',
'person_id',
'name',
'short_name',
'summary',
'outline',
'description',
'description_md_html',
'description_md_html_alt',
'description_html',
'description_json',
'start_datetime',
'end_datetime',
'timezone',
'alert',
'alert_msg',
'sort_by',
'sort_by_desc',
'cfg_json',
'data_json',
'ux_mode',
'passcode_read',
'passcode_read_expire',
'passcode_write',
'passcode_write_expire',
'passcode_timeout',
'private_passcode',
'auth_key',
'enable',
'hide',
'archive', // Archive the journal
'archive_on', // Archive date
'priority', // Priority flag
'sort', // Sort order
'group', // Group name
'notes', // Notes about the journal
'created_on', // Creation date
'updated_on', // Last updated date
'tmp_sort_1', // Temporary sort field 1
'tmp_sort_2', // Temporary sort field 2
'tmp_sort_3', // Temporary sort field 3
'tmp_sort_1', // Temporary sort field 1
'tmp_sort_2', // Temporary sort field 2
'tmp_sort_3', // Temporary sort field 3
'combined_passcode', // For Journal Entry encryption password
'file_count', // Only files directly under a journal
'journal_file_id_li_json', // JSON string of file IDs
'person__given_name', // Person's given name
'person__family_name', // Person's family name
'person__full_name', // Person's full name
'person__primary_email', // Person's primary email
'person__passcode', // Person's passcode
'person__kv_json', // JSON formatted key value pairs for multiple people
'journal_name', // Journal name
'journal_location_code', // Journal location code
'journal_location_name', // Journal location name
'journal_entry_count', // Count of journal entries
'journal_entry_kv', // Key value list of the entries
'journal_entry_li', // List of journal entries
'journal_file_kv', // Key value list of the files
'journal_file_li', // List of journal files
'combined_passcode', // For Journal Entry encryption password
'file_count', // Only files directly under a journal
'journal_file_id_li_json', // JSON string of file IDs
'person__given_name', // Person's given name
'person__family_name', // Person's family name
'person__full_name', // Person's full name
'person__primary_email', // Person's primary email
'person__passcode', // Person's passcode
'person__kv_json', // JSON formatted key value pairs for multiple people
'journal_name', // Journal name
'journal_location_code', // Journal location code
'journal_location_name', // Journal location name
'journal_entry_count', // Count of journal entries
'journal_entry_kv', // Key value list of the entries
'journal_entry_li', // List of journal entries
'journal_file_kv', // Key value list of the files
'journal_file_li', // List of journal files
'obj_id', // Object ID
'obj_ext_uid', // External UID
'obj_ext_id', // External ID
'obj_import_id', // Import ID
'obj_code', // Object code
'obj_account_id', // Object account ID
'obj_passcode', // Object passcode
'obj_type', // Object type
'obj_type_ver_id', // Object type version ID
'obj_name', // Object name
'obj_summary', // Object summary
'obj_outline', // Object outline
'obj_description', // Object description
'obj_enable', // Object enable flag
'obj_enable_on', // Object enable date
'obj_archive_on', // Object archive date
'obj_hide', // Object hide flag
'obj_priority', // Object priority
'obj_sort', // Object sort order
'obj_group', // Object group name
'obj_cfg_json', // Object configuration JSON
'obj_notes', // Object notes
'obj_created_on', // Object creation date
'obj_updated_on' // Object last updated date
'obj_id', // Object ID
'obj_ext_uid', // External UID
'obj_ext_id', // External ID
'obj_import_id', // Import ID
'obj_code', // Object code
'obj_account_id', // Object account ID
'obj_passcode', // Object passcode
'obj_type', // Object type
'obj_type_ver_id', // Object type version ID
'obj_name', // Object name
'obj_summary', // Object summary
'obj_outline', // Object outline
'obj_description', // Object description
'obj_enable', // Object enable flag
'obj_enable_on', // Object enable date
'obj_archive_on', // Object archive date
'obj_hide', // Object hide flag
'obj_priority', // Object priority
'obj_sort', // Object sort order
'obj_group', // Object group name
'obj_cfg_json', // Object configuration JSON
'obj_notes', // Object notes
'obj_created_on', // Object creation date
'obj_updated_on' // Object last updated date
];
// Updated 2025-04-02
export interface Journal_Entry {
id: string; // actually "id_random"
journal_entry_id: string;
id: string; // actually "id_random"
journal_entry_id: string;
journal_id: string; // This is the parent journal ID. If deleted, then delete all children journal entries.
journal_id: string; // This is the parent journal ID. If deleted, then delete all children journal entries.
// Essentially this is a change log of journal entries
snapshot_id?: string; // This is the original journal ID. If deleted, then delete all children journal entries.
previous_id?: null | string; // This is the old or parent journal ID
next_id?: null | string; // This is the new or child journal ID
// Essentially this is a change log of journal entries
snapshot_id?: string; // This is the original journal ID. If deleted, then delete all children journal entries.
previous_id?: null | string; // This is the old or parent journal ID
next_id?: null | string; // This is the new or child journal ID
external_id?: null | string;
import_id?: null | string;
code?: null | string;
external_id?: null | string;
import_id?: null | string;
code?: null | string;
for_type?: null | string;
for_id?: null | string;
for_type?: null | string;
for_id?: null | string;
template?: null | boolean; // Is this a template journal entry? If true, it can be used to create new journal entries.
template?: null | boolean; // Is this a template journal entry? If true, it can be used to create new journal entries.
activity_code?: null | string;
category_code?: null | string;
topic_code?: null | string;
type_code?: null | string;
tags?: null | string; // Comma separated tags
activity_code?: null | string;
category_code?: null | string;
topic_code?: null | string;
type_code?: null | string;
tags?: null | string; // Comma separated tags
journal_entry_type?: null | string; // This is the type of journal entry
journal_entry_type?: null | string; // This is the type of journal entry
account_id?: null | string; // Owner account of the journal
person_id?: null | string; // Owner person of the journal
// event_id?: null|string; // Assign to an event???
// location_id?: null|string; // Assign to a location???
account_id?: null | string; // Owner account of the journal
person_id?: null | string; // Owner person of the journal
// event_id?: null|string; // Assign to an event???
// location_id?: null|string; // Assign to a location???
public?: null | boolean;
private?: null | boolean;
personal?: null | boolean;
professional?: null | boolean;
public?: null | boolean;
private?: null | boolean;
personal?: null | boolean;
professional?: null | boolean;
name: string; // or the title
short_name?: null | string; // Short name for the journal entry, if any. Used for display purposes. Most likely for the templates list.
summary?: null | string; // LLM (AI) generated summary...???
outline?: null | string; // LLM (AI) generated outline...???
// description?: null|string; // This is the description of the journal entry
name: string; // or the title
short_name?: null | string; // Short name for the journal entry, if any. Used for display purposes. Most likely for the templates list.
summary?: null | string; // LLM (AI) generated summary...???
outline?: null | string; // LLM (AI) generated outline...???
// description?: null|string; // This is the description of the journal entry
content?: null | string;
content_md_html?: null | string; // Markdown converted to HTML based on content. Uses marked or similar library for conversion.
content_md_html_alt?: null | string; // Markdown converted to HTML based on content. Uses marked or similar library for conversion.
content_html?: null | string;
content_json?: null | string;
content_encrypted?: null | string; // This is the encrypted content of the journal entry
content?: null | string;
content_md_html?: null | string; // Markdown converted to HTML based on content. Uses marked or similar library for conversion.
content_md_html_alt?: null | string; // Markdown converted to HTML based on content. Uses marked or similar library for conversion.
content_html?: null | string;
content_json?: null | string;
content_encrypted?: null | string; // This is the encrypted content of the journal entry
history?: null | string; // This is the history of the journal entry; a log
history_encrypted?: null | string; // This is the encrypted history of the journal entry
history?: null | string; // This is the history of the journal entry; a log
history_encrypted?: null | string; // This is the encrypted history of the journal entry
passcode_hash?: null | string; // This is the passcode hash for the journal entry to look up the passcode
passcode_hash?: null | string; // This is the passcode hash for the journal entry to look up the passcode
start_datetime?: null | Date;
end_datetime?: null | Date;
timezone?: null | string;
seconds?: null | number; // Duration in seconds
start_datetime?: null | Date;
end_datetime?: null | Date;
timezone?: null | string;
seconds?: null | number; // Duration in seconds
location?: null | string; // Location of the journal entry
latitude?: null | number; // Latitude of the journal entry
longitude?: null | number; // Longitude of the journal entry
location?: null | string; // Location of the journal entry
latitude?: null | number; // Latitude of the journal entry
longitude?: null | number; // Longitude of the journal entry
billable?: null | boolean; // Is this billable?
bill_to?: null | string; // Who to bill for this journal entry
bill_rate?: null | number; // Rate to bill for this journal entry
billable_minutes?: null | number; // Billable minutes for this journal entry
billable?: null | boolean; // Is this billable?
bill_to?: null | string; // Who to bill for this journal entry
bill_rate?: null | number; // Rate to bill for this journal entry
billable_minutes?: null | number; // Billable minutes for this journal entry
alert?: null | boolean; // LLM (AI) generated summary...???
alert_msg?: null | string; // LLM (AI) generated summary...???
alert?: null | boolean; // LLM (AI) generated summary...???
alert_msg?: null | string; // LLM (AI) generated summary...???
parent_id?: null | string; // This is the parent journal entry ID. If deleted, then delete all children journal entries.
related_entry_id_li?: null | key_val; // List of related journal entry IDs
parent_id?: null | string; // This is the parent journal entry ID. If deleted, then delete all children journal entries.
related_entry_id_li?: null | key_val; // List of related journal entry IDs
// cfg_json?: null|key_val; // This is the configuration JSON for the journal entry
data_json?: null | key_val; // We always need to store something extra...
// cfg_json?: null|key_val; // This is the configuration JSON for the journal entry
data_json?: null | key_val; // We always need to store something extra...
// This only allows for basic access to the content.
passcode_read?: null | string; // For LLM (AI) generated summary...???
passcode_read_expire?: null | Date;
passcode_write?: null | string;
passcode_write_expire?: null | Date;
// This only allows for basic access to the content.
passcode_read?: null | string; // For LLM (AI) generated summary...???
passcode_read_expire?: null | Date;
passcode_write?: null | string;
passcode_write_expire?: null | Date;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
// Generated fields for sorting locally only
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
tmp_sort_3?: null | string;
// Generated fields for sorting locally only
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
tmp_sort_3?: null | string;
// Additional fields for convenience (database views)
file_count?: null | number; // Only files directly under a journal
journal_file_id_li_json?: null | string;
// Additional fields for convenience (database views)
file_count?: null | number; // Only files directly under a journal
journal_file_id_li_json?: null | string;
journal_code?: null | string; // This is the code for the journal entry
journal_name?: null | string; // This is the name for the journal entry
journal_code?: null | string; // This is the code for the journal entry
journal_name?: null | string; // This is the name for the journal entry
// One person
person__given_name?: null | string;
person__family_name?: null | string;
person__full_name?: null | string;
person__primary_email?: null | string;
person__passcode?: null | string;
// One person
person__given_name?: null | string;
person__family_name?: null | string;
person__full_name?: null | string;
person__primary_email?: null | string;
person__passcode?: null | string;
// JSON formatted key value pairs for multiple people: {id: name, email, etc.}
person__kv_json?: null | string;
// JSON formatted key value pairs for multiple people: {id: name, email, etc.}
person__kv_json?: null | string;
// A key value list of the files
journal_file_kv?: null | key_val;
journal_file_li?: null | [];
// A key value list of the files
journal_file_kv?: null | key_val;
journal_file_li?: null | [];
// journal_collection_id?: null|string; // For a collection of journal entries?
// journal_collection_id?: null|string; // For a collection of journal entries?
// Future standard fields!!!
obj_id?: null | string;
obj_ext_uid?: null | string; // Probably not needed for journal entries
obj_ext_id?: null | string; // Probably not needed for journal entries
obj_import_id?: null | string; // Probably not needed for journal entries
obj_code?: null | string;
obj_account_id?: null | string;
obj_passcode?: null | string;
obj_type?: null | string; // Should always be 'journal' in this case
obj_type_ver_id?: null | string; // The ID from the table for the object type
obj_name?: null | string;
obj_summary?: null | string; // LLM (AI) generated summary...???
obj_outline?: null | string; // LLM (AI) generated outline...???
obj_description?: null | string; // Probably not needed for journal entries
obj_enable?: null | boolean;
obj_enable_on?: null | Date;
obj_archive_on?: null | Date;
obj_hide?: null | boolean;
obj_priority?: null | number;
obj_sort?: null | number;
obj_group?: null | string;
obj_cfg_json?: null | string;
obj_notes?: null | string;
obj_created_on?: Date;
obj_updated_on?: null | Date;
// Future standard fields!!!
obj_id?: null | string;
obj_ext_uid?: null | string; // Probably not needed for journal entries
obj_ext_id?: null | string; // Probably not needed for journal entries
obj_import_id?: null | string; // Probably not needed for journal entries
obj_code?: null | string;
obj_account_id?: null | string;
obj_passcode?: null | string;
obj_type?: null | string; // Should always be 'journal' in this case
obj_type_ver_id?: null | string; // The ID from the table for the object type
obj_name?: null | string;
obj_summary?: null | string; // LLM (AI) generated summary...???
obj_outline?: null | string; // LLM (AI) generated outline...???
obj_description?: null | string; // Probably not needed for journal entries
obj_enable?: null | boolean;
obj_enable_on?: null | Date;
obj_archive_on?: null | Date;
obj_hide?: null | boolean;
obj_priority?: null | number;
obj_sort?: null | number;
obj_group?: null | string;
obj_cfg_json?: null | string;
obj_notes?: null | string;
obj_created_on?: Date;
obj_updated_on?: null | Date;
}
export const journal_entry_field_li = [
'id',
'journal_entry_id',
'journal_id',
'code',
'for_type',
'for_id',
'template',
'activity_code',
'category_code',
'topic_code',
'type_code',
'tags',
'journal_entry_type',
'account_id',
'person_id',
'public',
'private',
'personal',
'professional',
'name',
'short_name',
'summary',
'outline',
'content',
'content_md_html',
'content_md_html_alt',
'content_html',
'content_json',
'content_encrypted',
'history',
'history_encrypted',
'passcode_hash',
'start_datetime',
'end_datetime',
'timezone',
'seconds',
'location',
'latitude',
'longitude',
'billable',
'bill_to',
'bill_rate',
'billable_minutes',
'alert',
'alert_msg',
'parent_id',
'related_entry_id_li',
'data_json',
'passcode_read',
'passcode_read_expire',
'passcode_write',
'passcode_write_expire',
'enable',
'hide',
'priority',
'sort',
'group',
'notes',
'created_on',
'updated_on',
'id',
'journal_entry_id',
'journal_id',
'code',
'for_type',
'for_id',
'template',
'activity_code',
'category_code',
'topic_code',
'type_code',
'tags',
'journal_entry_type',
'account_id',
'person_id',
'public',
'private',
'personal',
'professional',
'name',
'short_name',
'summary',
'outline',
'content',
'content_md_html',
'content_md_html_alt',
'content_html',
'content_json',
'content_encrypted',
'history',
'history_encrypted',
'passcode_hash',
'start_datetime',
'end_datetime',
'timezone',
'seconds',
'location',
'latitude',
'longitude',
'billable',
'bill_to',
'bill_rate',
'billable_minutes',
'alert',
'alert_msg',
'parent_id',
'related_entry_id_li',
'data_json',
'passcode_read',
'passcode_read_expire',
'passcode_write',
'passcode_write_expire',
'enable',
'hide',
'priority',
'sort',
'group',
'notes',
'created_on',
'updated_on',
'tmp_sort_1',
'tmp_sort_2',
'tmp_sort_3',
'tmp_sort_1',
'tmp_sort_2',
'tmp_sort_3',
'file_count',
'journal_file_id_li_json',
'journal_code',
'journal_name',
'person__given_name',
'person__family_name',
'person__full_name',
'person__primary_email',
'person__passcode',
'person__kv_json',
'journal_file_kv',
'journal_file_li',
'file_count',
'journal_file_id_li_json',
'journal_code',
'journal_name',
'person__given_name',
'person__family_name',
'person__full_name',
'person__primary_email',
'person__passcode',
'person__kv_json',
'journal_file_kv',
'journal_file_li',
'obj_id',
'obj_ext_uid',
'obj_ext_id',
'obj_import_id',
'obj_code',
'obj_account_id',
'obj_passcode',
'obj_type',
'obj_type_ver_id',
'obj_name',
'obj_summary',
'obj_outline',
'obj_description',
'obj_enable',
'obj_enable_on',
'obj_archive_on',
'obj_hide',
'obj_priority',
'obj_sort',
'obj_group',
'obj_cfg_json',
'obj_notes',
'obj_created_on',
'obj_updated_on'
'obj_id',
'obj_ext_uid',
'obj_ext_id',
'obj_import_id',
'obj_code',
'obj_account_id',
'obj_passcode',
'obj_type',
'obj_type_ver_id',
'obj_name',
'obj_summary',
'obj_outline',
'obj_description',
'obj_enable',
'obj_enable_on',
'obj_archive_on',
'obj_hide',
'obj_priority',
'obj_sort',
'obj_group',
'obj_cfg_json',
'obj_notes',
'obj_created_on',
'obj_updated_on'
];
// Updated 2024-06-10
export class MySubClassedDexie extends Dexie {
// We just tell the typing system this is the case
journal!: Table<Journal>;
journal_entry!: Table<Journal_Entry>;
// We just tell the typing system this is the case
journal!: Table<Journal>;
journal_entry!: Table<Journal_Entry>;
constructor() {
super('ae_journals_db');
this.version(4).stores({
journal: `
constructor() {
super('ae_journals_db');
this.version(4).stores({
journal: `
id, journal_id,
code,
account_id,
@@ -523,7 +523,7 @@ export class MySubClassedDexie extends Dexie {
timezone,
tmp_sort_1, tmp_sort_2, tmp_sort_3,
enable, hide, priority, sort, group, created_on, updated_on`,
journal_entry: `
journal_entry: `
id, journal_entry_id,
journal_id,
code,
@@ -534,8 +534,8 @@ export class MySubClassedDexie extends Dexie {
timezone,
tmp_sort_1, tmp_sort_2, tmp_sort_3,
enable, hide, priority, sort, group, created_on, updated_on`
});
}
});
}
}
export const db_journals = new MySubClassedDexie();

File diff suppressed because it is too large Load Diff

View File

@@ -9,446 +9,451 @@ const ae_promises: key_val = {};
// Updated 2025-06-23
export async function load_ae_obj_id__post_comment({
api_cfg,
post_comment_id,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
params = {},
try_cache = true,
log_lvl = 0
api_cfg,
post_comment_id,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
post_comment_id: string;
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
offset?: number;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
post_comment_id: string;
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
offset?: number;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** load_ae_obj_id__post_comment() *** post_comment_id=${post_comment_id}`);
}
if (log_lvl) {
console.log(`*** load_ae_obj_id__post_comment() *** post_comment_id=${post_comment_id}`);
}
ae_promises.load__post_comment_obj = await api
.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'post_comment',
obj_id: post_comment_id,
use_alt_table: false,
use_alt_base: false,
params: params,
log_lvl: log_lvl
})
.then(async function (post_comment_obj_get_result) {
if (post_comment_obj_get_result) {
if (try_cache) {
// Process the results first
const processed_obj_li = await process_ae_obj__post_comment_props({
obj_li: [post_comment_obj_get_result],
log_lvl: log_lvl
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'comment',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('DB save completed.');
}
ae_promises.load__post_comment_obj = await api
.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'post_comment',
obj_id: post_comment_id,
use_alt_table: false,
use_alt_base: false,
params: params,
log_lvl: log_lvl
})
.then(async function (post_comment_obj_get_result) {
if (post_comment_obj_get_result) {
if (try_cache) {
// Process the results first
const processed_obj_li = await process_ae_obj__post_comment_props({
obj_li: [post_comment_obj_get_result],
log_lvl: log_lvl
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'comment',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('DB save completed.');
}
// // This is expecting a list
// db_save_ae_obj_li__post_comment({
// obj_type: 'post_comment',
// obj_li: [post_comment_obj_get_result],
// log_lvl: log_lvl
// // This is expecting a list
// db_save_ae_obj_li__post_comment({
// obj_type: 'post_comment',
// obj_li: [post_comment_obj_get_result],
// log_lvl: log_lvl
// });
}
return post_comment_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
// });
}
return post_comment_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
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
export async function load_ae_obj_li__post_comment({
api_cfg,
for_obj_type = 'post',
for_obj_id,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
order_by_li = {
priority: 'DESC',
sort: 'DESC',
updated_on: 'DESC',
created_on: 'DESC',
title: 'ASC'
},
params = {},
try_cache = true,
log_lvl = 0
api_cfg,
for_obj_type = 'post',
for_obj_id,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
order_by_li = {
priority: 'DESC',
sort: 'DESC',
updated_on: 'DESC',
created_on: 'DESC',
title: 'ASC'
},
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
for_obj_type: string;
for_obj_id: string;
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
offset?: number;
order_by_li?: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
for_obj_type: string;
for_obj_id: string;
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
offset?: number;
order_by_li?: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(
`*** load_ae_obj_li__post_comment() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`
);
}
if (log_lvl) {
console.log(
`*** load_ae_obj_li__post_comment() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`
);
}
const params_json: key_val = {};
const params_json: key_val = {};
if (log_lvl) {
console.log('params_json:', params_json);
}
if (log_lvl) {
console.log('params_json:', params_json);
}
ae_promises.load__post_comment_obj_li = await api
.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg: api_cfg,
obj_type: 'post_comment',
for_obj_type: for_obj_type,
for_obj_id: for_obj_id,
use_alt_tbl: false,
use_alt_mdl: false,
use_alt_exp: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(async function (post_comment_obj_li_get_result) {
if (post_comment_obj_li_get_result) {
if (try_cache) {
// Process the results first
const processed_obj_li = await process_ae_obj__post_comment_props({
obj_li: post_comment_obj_li_get_result,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'comment',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('DB save completed.');
}
ae_promises.load__post_comment_obj_li = await api
.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg: api_cfg,
obj_type: 'post_comment',
for_obj_type: for_obj_type,
for_obj_id: for_obj_id,
use_alt_tbl: false,
use_alt_mdl: false,
use_alt_exp: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(async function (post_comment_obj_li_get_result) {
if (post_comment_obj_li_get_result) {
if (try_cache) {
// Process the results first
const processed_obj_li = await process_ae_obj__post_comment_props({
obj_li: post_comment_obj_li_get_result,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'comment',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('DB save completed.');
}
// db_save_ae_obj_li__post_comment({
// obj_type: 'post_comment',
// obj_li: post_comment_obj_li_get_result,
// log_lvl: log_lvl
// });
}
return post_comment_obj_li_get_result;
} else {
return [];
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
// db_save_ae_obj_li__post_comment({
// obj_type: 'post_comment',
// obj_li: post_comment_obj_li_get_result,
// log_lvl: log_lvl
// });
}
return post_comment_obj_li_get_result;
} else {
return [];
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.load__post_comment_obj_li:', ae_promises.load__post_comment_obj_li);
}
if (log_lvl) {
console.log(
'ae_promises.load__post_comment_obj_li:',
ae_promises.load__post_comment_obj_li
);
}
return ae_promises.load__post_comment_obj_li;
return ae_promises.load__post_comment_obj_li;
}
// Updated 2025-06-23
export async function create_ae_obj__post_comment({
api_cfg,
post_id,
data_kv,
params = {},
try_cache = true,
log_lvl = 0
api_cfg,
post_id,
data_kv,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
post_id: string;
data_kv: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
post_id: string;
data_kv: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** create_ae_obj__post_comment() *** post_id=${post_id}`);
}
if (log_lvl) {
console.log(`*** create_ae_obj__post_comment() *** post_id=${post_id}`);
}
if (!post_id) {
console.log(`ERROR: Posts - Comment - post_id required to create`);
return false;
}
if (!post_id) {
console.log(`ERROR: Posts - Comment - post_id required to create`);
return false;
}
ae_promises.create__post_comment = await api
.create_ae_obj_crud({
api_cfg: api_cfg,
obj_type: 'post_comment',
fields: {
post_id_random: post_id,
...data_kv
},
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
})
.then(async function (post_comment_obj_create_result) {
if (post_comment_obj_create_result) {
if (try_cache) {
// Process the results first
const processed_obj_li = await process_ae_obj__post_comment_props({
obj_li: [post_comment_obj_create_result],
log_lvl: log_lvl
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'comment',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('DB save completed.');
}
ae_promises.create__post_comment = await api
.create_ae_obj_crud({
api_cfg: api_cfg,
obj_type: 'post_comment',
fields: {
post_id_random: post_id,
...data_kv
},
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
})
.then(async function (post_comment_obj_create_result) {
if (post_comment_obj_create_result) {
if (try_cache) {
// Process the results first
const processed_obj_li = await process_ae_obj__post_comment_props({
obj_li: [post_comment_obj_create_result],
log_lvl: log_lvl
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'comment',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('DB save completed.');
}
// db_save_ae_obj_li__post_comment(
// {
// obj_type: 'post_comment',
// obj_li: [post_comment_obj_create_result],
// log_lvl: log_lvl
// });
}
return post_comment_obj_create_result;
} else {
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
})
.finally(function () {});
// db_save_ae_obj_li__post_comment(
// {
// obj_type: 'post_comment',
// obj_li: [post_comment_obj_create_result],
// log_lvl: log_lvl
// });
}
return post_comment_obj_create_result;
} else {
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
})
.finally(function () {});
if (log_lvl) {
console.log('ae_promises.create__post_comment:', ae_promises.create__post_comment);
}
return ae_promises.create__post_comment;
if (log_lvl) {
console.log('ae_promises.create__post_comment:', ae_promises.create__post_comment);
}
return ae_promises.create__post_comment;
}
// Updated 2024-11-08
export async function delete_ae_obj_id__post_comment({
api_cfg,
post_comment_id,
method = 'delete', // 'delete', 'disable', 'hide'
params = {},
try_cache = true,
log_lvl = 0
api_cfg,
post_comment_id,
method = 'delete', // 'delete', 'disable', 'hide'
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
post_comment_id: string;
method?: string;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
post_comment_id: string;
method?: string;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** delete_ae_obj_id__post_comment() *** post_comment_id=${post_comment_id}`);
}
if (log_lvl) {
console.log(`*** delete_ae_obj_id__post_comment() *** post_comment_id=${post_comment_id}`);
}
ae_promises.delete__post_comment_obj = await api
.delete_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'post_comment',
obj_id: post_comment_id,
key: api_cfg.api_crud_super_key,
params: params,
method: method,
log_lvl: log_lvl
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
})
.finally(function () {
if (try_cache) {
if (log_lvl) {
console.log(`Attempting to remove IDB entry for post_comment_id=${post_comment_id}`);
}
db_posts.comment.delete(post_comment_id); // Delete from the DB no matter what.
}
});
ae_promises.delete__post_comment_obj = await api
.delete_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'post_comment',
obj_id: post_comment_id,
key: api_cfg.api_crud_super_key,
params: params,
method: method,
log_lvl: log_lvl
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
})
.finally(function () {
if (try_cache) {
if (log_lvl) {
console.log(
`Attempting to remove IDB entry for post_comment_id=${post_comment_id}`
);
}
db_posts.comment.delete(post_comment_id); // Delete from the DB no matter what.
}
});
if (log_lvl) {
console.log('ae_promises.delete__post_comment_obj:', ae_promises.delete__post_comment_obj);
}
if (log_lvl) {
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
export async function update_ae_obj__post_comment({
api_cfg,
post_comment_id,
data_kv,
params = {},
try_cache = true,
log_lvl = 0
api_cfg,
post_comment_id,
data_kv,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
post_comment_id: string;
data_kv: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
post_comment_id: string;
data_kv: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(
`*** update_ae_obj__post_comment() *** post_comment_id=${post_comment_id}`,
data_kv
);
}
if (log_lvl) {
console.log(
`*** update_ae_obj__post_comment() *** post_comment_id=${post_comment_id}`,
data_kv
);
}
// Perform the API update
const result = await api.update_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'post_comment',
obj_id: post_comment_id,
fields: data_kv,
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
});
// Perform the API update
const result = await api.update_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'post_comment',
obj_id: post_comment_id,
fields: data_kv,
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
});
// Handle the result
if (result) {
if (try_cache) {
// Process the results first
const processed_obj_li = await process_ae_obj__post_comment_props({
obj_li: [result],
log_lvl: log_lvl
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'comment',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('DB save completed.');
}
// Handle the result
if (result) {
if (try_cache) {
// Process the results first
const processed_obj_li = await process_ae_obj__post_comment_props({
obj_li: [result],
log_lvl: log_lvl
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'comment',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('DB save completed.');
}
// await db_save_ae_obj_li__post_comment({
// obj_type: 'post_comment',
// obj_li: [result],
// log_lvl: log_lvl,
// });
}
return result;
} else {
console.error('Failed to update post comment.');
return null;
}
// await db_save_ae_obj_li__post_comment({
// obj_type: 'post_comment',
// obj_li: [result],
// log_lvl: log_lvl,
// });
}
return result;
} else {
console.error('Failed to update post comment.');
return null;
}
}
// Updated 2025-06-04
export const properties_to_save = [
'id',
'post_comment_id',
// 'post_comment_id_random',
'id',
'post_comment_id',
// 'post_comment_id_random',
'post_id',
// 'post_id_random',
'post_id',
// 'post_id_random',
'external_person_id',
'external_person_id',
'name',
'title',
'content',
'name',
'title',
'content',
'anonymous',
'full_name',
'email',
'notify',
'anonymous',
'full_name',
'email',
'notify',
'linked_li_json',
'cfg_json',
'linked_li_json',
'cfg_json',
'enable',
'hide',
'priority',
'sort',
'group',
'notes',
'created_on',
'updated_on',
'enable',
'hide',
'priority',
'sort',
'group',
'notes',
'created_on',
'updated_on',
// Generated fields for sorting locally only
'tmp_sort_1',
'tmp_sort_2'
// 'tmp_sort_a',
// 'tmp_sort_b',
// Generated fields for sorting locally only
'tmp_sort_1',
'tmp_sort_2'
// 'tmp_sort_a',
// 'tmp_sort_b',
// From SQL view
// From SQL view
];
/**
@@ -456,91 +461,91 @@ export const properties_to_save = [
* Processes a list of Aether objects by applying common and specific transformations.
*/
async function _process_generic_props<T extends Record<string, any>>({
obj_li,
obj_type,
log_lvl = 0,
specific_processor
obj_li,
obj_type,
log_lvl = 0,
specific_processor
}: {
obj_li: T[];
obj_type: string;
log_lvl?: number;
specific_processor?: (obj: T) => Promise<T> | T;
obj_li: T[];
obj_type: string;
log_lvl?: number;
specific_processor?: (obj: T) => Promise<T> | T;
}): Promise<T[]> {
if (log_lvl > 0) {
console.log(
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
);
}
if (log_lvl > 0) {
console.log(
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
);
}
if (!obj_li || obj_li.length === 0) {
if (log_lvl > 0) console.log('No objects to process.');
return [];
}
if (!obj_li || obj_li.length === 0) {
if (log_lvl > 0) console.log('No objects to process.');
return [];
}
const processed_obj_li: T[] = [];
const processed_obj_li: T[] = [];
for (const original_obj of obj_li) {
let processed_obj = { ...original_obj };
for (const original_obj of obj_li) {
let processed_obj = { ...original_obj };
// --- Common Transformations ---
// --- Common Transformations ---
// 1. Standardize ID and other '_random' fields
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
for (const key in processed_obj) {
if (key.endsWith('_random')) {
const newKey = key.slice(0, -7); // Remove '_random' suffix
processed_obj[newKey] = processed_obj[key];
}
}
// Ensure 'id' is set from '[obj_type]_id_random'
const randomIdKey = `${obj_type}_id_random`;
if (processed_obj[randomIdKey]) {
(processed_obj as any).id = processed_obj[randomIdKey];
}
// 1. Standardize ID and other '_random' fields
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
for (const key in processed_obj) {
if (key.endsWith('_random')) {
const newKey = key.slice(0, -7); // Remove '_random' suffix
processed_obj[newKey] = processed_obj[key];
}
}
// Ensure 'id' is set from '[obj_type]_id_random'
const randomIdKey = `${obj_type}_id_random`;
if (processed_obj[randomIdKey]) {
(processed_obj as any).id = processed_obj[randomIdKey];
}
// 2. Create common computed properties for client-side sorting.
const group = processed_obj.group ?? '0';
const priority = processed_obj.priority ? 1 : 0;
const sort = processed_obj.sort ?? '0';
const updated = processed_obj.updated_on ?? processed_obj.created_on;
const name = processed_obj.name ?? '';
// 2. Create common computed properties for client-side sorting.
const group = processed_obj.group ?? '0';
const priority = processed_obj.priority ? 1 : 0;
const sort = processed_obj.sort ?? '0';
const updated = processed_obj.updated_on ?? processed_obj.created_on;
const name = processed_obj.name ?? '';
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
// --- Specific Transformations ---
if (specific_processor) {
processed_obj = await Promise.resolve(specific_processor(processed_obj));
}
// --- Specific Transformations ---
if (specific_processor) {
processed_obj = await Promise.resolve(specific_processor(processed_obj));
}
processed_obj_li.push(processed_obj as T);
}
processed_obj_li.push(processed_obj as T);
}
return processed_obj_li;
return processed_obj_li;
}
// Updated 2025-06-04
export async function process_ae_obj__post_comment_props({
obj_li,
log_lvl = 0
obj_li,
log_lvl = 0
}: {
obj_li: any[];
log_lvl?: number;
obj_li: any[];
log_lvl?: number;
}) {
return _process_generic_props({
obj_li,
obj_type: 'post_comment',
log_lvl,
specific_processor: (obj) => {
// Post comment-specific computed sort fields, overriding generic ones if needed
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on ?? obj.created_on}`;
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(2, '0') ?? ''
}_${obj.updated_on}_${obj.created_on}`;
return _process_generic_props({
obj_li,
obj_type: 'post_comment',
log_lvl,
specific_processor: (obj) => {
// Post comment-specific computed sort fields, overriding generic ones if needed
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on ?? obj.created_on}`;
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(2, '0') ?? ''
}_${obj.updated_on}_${obj.created_on}`;
return obj;
}
});
return obj;
}
});
}

View File

@@ -1,32 +1,32 @@
// This file is used to export all the functions that are used for Aether Posts related functions.
import {
load_ae_obj_id__post,
load_ae_obj_li__post,
create_ae_obj__post,
delete_ae_obj_id__post,
update_ae_obj__post
load_ae_obj_id__post,
load_ae_obj_li__post,
create_ae_obj__post,
delete_ae_obj_id__post,
update_ae_obj__post
} from '$lib/ae_posts/ae_posts__post';
import {
load_ae_obj_id__post_comment,
load_ae_obj_li__post_comment,
create_ae_obj__post_comment,
delete_ae_obj_id__post_comment,
update_ae_obj__post_comment
load_ae_obj_id__post_comment,
load_ae_obj_li__post_comment,
create_ae_obj__post_comment,
delete_ae_obj_id__post_comment,
update_ae_obj__post_comment
} 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,
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: 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,
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 const posts_func = export_obj;

View File

@@ -7,113 +7,113 @@ import type { key_val } from '$lib/stores/ae_stores';
// Updated 2024-11-13
export interface Post {
id: string;
// id_random: string;
post_id: string;
// post_id_random: string;
id: string;
// id_random: string;
post_id: string;
// post_id_random: string;
account_id: string;
// account_id_random: string;
account_id: string;
// account_id_random: string;
person_id?: null | string;
external_person_id?: null | string; // For IDAA this is the Novi UUID
user_id?: null | string;
person_id?: null | string;
external_person_id?: null | string; // For IDAA this is the Novi UUID
user_id?: null | string;
topic_id?: string;
topic?: string; // or topic_name?
topic_name?: string;
topic_id?: string;
topic?: string; // or topic_name?
topic_name?: string;
name: null | string;
title: null | string;
// summary?: null|string;
content?: null | string;
name: null | string;
title: null | string;
// summary?: null|string;
content?: null | string;
anonymous?: null | boolean;
full_name?: null | string;
email?: null | string;
notify?: null | boolean;
anonymous?: null | boolean;
full_name?: null | string;
email?: null | string;
notify?: null | boolean;
enable_comments?: null | boolean;
enable_comments?: null | boolean;
archive?: null | boolean;
archive_on?: null | Date;
archive?: null | boolean;
archive_on?: null | Date;
linked_li_json?: null | string;
cfg_json?: null | key_val;
linked_li_json?: null | string;
cfg_json?: null | key_val;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
// Generated fields for sorting locally only
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
// Generated fields for sorting locally only
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
// Additional fields for convenience (database views)
post_comment_count?: number;
// Additional fields for convenience (database views)
post_comment_count?: number;
// Placeholder for generated temp data
hosted_file_id_li?: null | Array<string>;
hosted_file_obj_li?: null | Array<any>;
upload_complete?: boolean;
// Placeholder for generated temp data
hosted_file_id_li?: null | Array<string>;
hosted_file_obj_li?: null | Array<any>;
upload_complete?: boolean;
}
// Updated 2024-11-13
export interface Post_Comment {
id: string;
// id_random: string;
post_comment_id: string;
// post_comment_id_random: string;
id: string;
// id_random: string;
post_comment_id: string;
// post_comment_id_random: string;
post_id: string;
// post_id_random: string;
post_id: 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;
title: null | string;
// summary?: null|string;
content?: null | string;
name: null | string;
title: null | string;
// summary?: null|string;
content?: null | string;
anonymous?: null | boolean;
full_name?: null | string;
email?: null | string;
notify?: null | boolean;
anonymous?: null | boolean;
full_name?: null | string;
email?: null | string;
notify?: null | boolean;
linked_li_json?: null | string;
cfg_json?: null | key_val;
linked_li_json?: null | string;
cfg_json?: null | key_val;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
// Generated fields for sorting locally only
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
// Generated fields for sorting locally only
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
// Additional fields for convenience (database views)
// Additional fields for convenience (database views)
}
// Updated 2024-09-25
export class MySubClassedDexie extends Dexie {
// We just tell the typing system this is the case
post!: Table<Post>;
comment!: Table<Post_Comment>;
// We just tell the typing system this is the case
post!: Table<Post>;
comment!: Table<Post_Comment>;
constructor() {
super('ae_posts_db');
this.version(1).stores({
post: `
constructor() {
super('ae_posts_db');
this.version(1).stores({
post: `
id, post_id,
account_id,
topic_id, topic,
@@ -124,7 +124,7 @@ export class MySubClassedDexie extends Dexie {
tmp_sort_1, tmp_sort_2,
enable, hide, priority, sort, group, notes, created_on, updated_on, [updated_on+created_on], [created_on+updated_on]`,
comment: `
comment: `
id, post_comment_id,
post_id,
name,
@@ -132,8 +132,8 @@ export class MySubClassedDexie extends Dexie {
full_name, email,
tmp_sort_1, tmp_sort_2,
enable, hide, priority, sort, group, notes, created_on, updated_on, [updated_on+created_on]`
});
}
});
}
}
export const db_posts = new MySubClassedDexie();

View File

@@ -8,118 +8,118 @@ import { db_sponsorships } from '$lib/ae_sponsorships/db_sponsorships';
// --- PROPERTIES TO SAVE ---
export const properties_to_save_sponsorship_cfg = [
'id',
'sponsorship_cfg_id',
'account_id',
'for_type',
'for_id',
'level_li_json',
'option_li_json',
'schedule_li_json',
'cfg_json',
'enable',
'hide',
'priority',
'sort',
'group',
'notes',
'created_on',
'updated_on',
// Generated fields for sorting locally only
'tmp_sort_1',
'tmp_sort_2'
'id',
'sponsorship_cfg_id',
'account_id',
'for_type',
'for_id',
'level_li_json',
'option_li_json',
'schedule_li_json',
'cfg_json',
'enable',
'hide',
'priority',
'sort',
'group',
'notes',
'created_on',
'updated_on',
// Generated fields for sorting locally only
'tmp_sort_1',
'tmp_sort_2'
];
// --- PROCESS FUNCTION ---
export async function process_ae_obj__sponsorship_cfg_props({
obj_li,
log_lvl = 0
obj_li,
log_lvl = 0
}: {
obj_li: any[];
log_lvl?: number;
obj_li: any[];
log_lvl?: number;
}) {
return _process_generic_props({
obj_li,
obj_type: 'sponsorship_cfg',
log_lvl,
specific_processor: (obj) => {
// Sponsorship Cfg-specific computed sort fields, overriding generic ones if needed
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on ?? obj.created_on}`;
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on}_${obj.created_on}`;
return _process_generic_props({
obj_li,
obj_type: 'sponsorship_cfg',
log_lvl,
specific_processor: (obj) => {
// Sponsorship Cfg-specific computed sort fields, overriding generic ones if needed
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on ?? obj.created_on}`;
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on}_${obj.created_on}`;
return obj;
}
});
return obj;
}
});
}
// --- PROPERTIES TO SAVE ---
export const properties_to_save_sponsorship = [
'id',
'sponsorship_id',
'account_id',
'organization_id',
'person_id',
'poc_person_id',
'poc_json',
'name',
'name_override',
'description',
'email',
'website_url',
'logo_li_json',
'media_li_json',
'social_li_json',
'address_li_json',
'contact_li_json',
'guest_li_json',
'level_num',
'level_str',
'amount',
'questions_li_json',
'agree',
'comments',
'staff_notes',
'enable',
'hide',
'priority',
'sort',
'group',
'notes',
'created_on',
'updated_on',
// Generated fields for sorting locally only
'tmp_sort_1',
'tmp_sort_2'
'id',
'sponsorship_id',
'account_id',
'organization_id',
'person_id',
'poc_person_id',
'poc_json',
'name',
'name_override',
'description',
'email',
'website_url',
'logo_li_json',
'media_li_json',
'social_li_json',
'address_li_json',
'contact_li_json',
'guest_li_json',
'level_num',
'level_str',
'amount',
'questions_li_json',
'agree',
'comments',
'staff_notes',
'enable',
'hide',
'priority',
'sort',
'group',
'notes',
'created_on',
'updated_on',
// Generated fields for sorting locally only
'tmp_sort_1',
'tmp_sort_2'
];
// --- PROCESS FUNCTION ---
export async function process_ae_obj__sponsorship_props({
obj_li,
log_lvl = 0
obj_li,
log_lvl = 0
}: {
obj_li: any[];
log_lvl?: number;
obj_li: any[];
log_lvl?: number;
}) {
return _process_generic_props({
obj_li,
obj_type: 'sponsorship',
log_lvl,
specific_processor: (obj) => {
// Sponsorship-specific computed sort fields, overriding generic ones if needed
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on ?? obj.created_on}`;
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on}_${obj.created_on}`;
return _process_generic_props({
obj_li,
obj_type: 'sponsorship',
log_lvl,
specific_processor: (obj) => {
// Sponsorship-specific computed sort fields, overriding generic ones if needed
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on ?? obj.created_on}`;
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on}_${obj.created_on}`;
return obj;
}
});
return obj;
}
});
}
/**
@@ -127,378 +127,383 @@ export async function process_ae_obj__sponsorship_props({
* Processes a list of Aether objects by applying common and specific transformations.
*/
async function _process_generic_props<T extends Record<string, any>>({
obj_li,
obj_type,
log_lvl = 0,
specific_processor
obj_li,
obj_type,
log_lvl = 0,
specific_processor
}: {
obj_li: T[];
obj_type: string;
log_lvl?: number;
specific_processor?: (obj: T) => Promise<T> | T;
obj_li: T[];
obj_type: string;
log_lvl?: number;
specific_processor?: (obj: T) => Promise<T> | T;
}): Promise<T[]> {
if (log_lvl > 0) {
console.log(
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
);
}
if (log_lvl > 0) {
console.log(
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
);
}
if (!obj_li || obj_li.length === 0) {
if (log_lvl > 0) console.log('No objects to process.');
return [];
}
if (!obj_li || obj_li.length === 0) {
if (log_lvl > 0) console.log('No objects to process.');
return [];
}
const processed_obj_li: T[] = [];
const processed_obj_li: T[] = [];
for (const original_obj of obj_li) {
let processed_obj = { ...original_obj };
for (const original_obj of obj_li) {
let processed_obj = { ...original_obj };
// --- Common Transformations ---
// --- Common Transformations ---
// 1. Standardize ID and other '_random' fields
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
for (const key in processed_obj) {
if (key.endsWith('_random')) {
const newKey = key.slice(0, -7); // Remove '_random' suffix
processed_obj[newKey] = processed_obj[key];
}
}
// Ensure 'id' is set from '[obj_type]_id_random'
const randomIdKey = `${obj_type}_id_random`;
if (processed_obj[randomIdKey]) {
(processed_obj as any).id = processed_obj[randomIdKey];
}
// 1. Standardize ID and other '_random' fields
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
for (const key in processed_obj) {
if (key.endsWith('_random')) {
const newKey = key.slice(0, -7); // Remove '_random' suffix
processed_obj[newKey] = processed_obj[key];
}
}
// Ensure 'id' is set from '[obj_type]_id_random'
const randomIdKey = `${obj_type}_id_random`;
if (processed_obj[randomIdKey]) {
(processed_obj as any).id = processed_obj[randomIdKey];
}
// 2. Create common computed properties for client-side sorting.
const group = processed_obj.group ?? '0';
const priority = processed_obj.priority ? 1 : 0;
const sort = processed_obj.sort ?? '0';
const updated = processed_obj.updated_on ?? processed_obj.created_on;
const name = processed_obj.name ?? '';
// 2. Create common computed properties for client-side sorting.
const group = processed_obj.group ?? '0';
const priority = processed_obj.priority ? 1 : 0;
const sort = processed_obj.sort ?? '0';
const updated = processed_obj.updated_on ?? processed_obj.created_on;
const name = processed_obj.name ?? '';
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
// --- Specific Transformations ---
if (specific_processor) {
processed_obj = await Promise.resolve(specific_processor(processed_obj));
}
// --- Specific Transformations ---
if (specific_processor) {
processed_obj = await Promise.resolve(specific_processor(processed_obj));
}
processed_obj_li.push(processed_obj as T);
}
processed_obj_li.push(processed_obj as T);
}
return processed_obj_li;
return processed_obj_li;
}
// Updated 2024-03-29
async function load_ae_obj_id__sponsorship_cfg({
api_cfg,
sponsorship_cfg_id,
try_cache = false,
log_lvl = 0
api_cfg,
sponsorship_cfg_id,
try_cache = false,
log_lvl = 0
}: {
api_cfg: any;
sponsorship_cfg_id: string;
try_cache: boolean;
log_lvl: number;
api_cfg: any;
sponsorship_cfg_id: string;
try_cache: boolean;
log_lvl: number;
}) {
if (log_lvl) {
console.log(
`*** load_ae_obj_id__sponsorship_cfg() *** sponsorship_cfg_id=${sponsorship_cfg_id}`
);
}
if (log_lvl) {
console.log(
`*** load_ae_obj_id__sponsorship_cfg() *** sponsorship_cfg_id=${sponsorship_cfg_id}`
);
}
const params = {};
const params = {};
ae_promises.load__sponsorship_cfg_obj = api
.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'sponsorship_cfg',
obj_id: sponsorship_cfg_id,
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
params: params,
log_lvl: log_lvl
})
.then(async function (sponsorship_cfg_obj_get_result) {
if (sponsorship_cfg_obj_get_result) {
if (log_lvl) {
console.log(`*spons_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}`);
} else if (log_lvl > 1) {
console.log(
`*spons_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}:`,
sponsorship_cfg_obj_get_result
);
}
if (try_cache) {
// Process the results first
const processed_obj_li = await process_ae_obj__sponsorship_cfg_props({
obj_li: [sponsorship_cfg_obj_get_result],
log_lvl: log_lvl
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_sponsorships,
table_name: 'cfg',
obj_li: processed_obj_li,
properties_to_save: properties_to_save_sponsorship_cfg,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return sponsorship_cfg_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
ae_promises.load__sponsorship_cfg_obj = api
.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'sponsorship_cfg',
obj_id: sponsorship_cfg_id,
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
params: params,
log_lvl: log_lvl
})
.then(async function (sponsorship_cfg_obj_get_result) {
if (sponsorship_cfg_obj_get_result) {
if (log_lvl) {
console.log(
`*spons_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}`
);
} else if (log_lvl > 1) {
console.log(
`*spons_func* Got a result for sponsorship_cfg_id ${sponsorship_cfg_id}:`,
sponsorship_cfg_obj_get_result
);
}
if (try_cache) {
// Process the results first
const processed_obj_li = await process_ae_obj__sponsorship_cfg_props({
obj_li: [sponsorship_cfg_obj_get_result],
log_lvl: log_lvl
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_sponsorships,
table_name: 'cfg',
obj_li: processed_obj_li,
properties_to_save: properties_to_save_sponsorship_cfg,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return sponsorship_cfg_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.load__sponsorship_cfg_obj:', ae_promises.load__sponsorship_cfg_obj);
}
if (log_lvl) {
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
async function load_ae_obj_id__sponsorship({
api_cfg,
sponsorship_id,
try_cache = false,
log_lvl = 0
api_cfg,
sponsorship_id,
try_cache = false,
log_lvl = 0
}: {
api_cfg: any;
sponsorship_id: string;
try_cache: boolean;
log_lvl: number;
api_cfg: any;
sponsorship_id: string;
try_cache: boolean;
log_lvl: number;
}) {
if (log_lvl) {
console.log(`*** load_ae_obj_id__sponsorship() *** sponsorship_id=${sponsorship_id}`);
}
if (log_lvl) {
console.log(`*** load_ae_obj_id__sponsorship() *** sponsorship_id=${sponsorship_id}`);
}
const params = {};
const params = {};
ae_promises.load__sponsorship_obj = api
.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'sponsorship',
obj_id: sponsorship_id,
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
params: params,
log_lvl: log_lvl
})
.then(async function (sponsorship_obj_get_result) {
if (sponsorship_obj_get_result) {
if (log_lvl) {
console.log(`*spons_func* Got a result for sponsorship_id ${sponsorship_id}`);
} else if (log_lvl > 1) {
console.log(
`*spons_func* Got a result for sponsorship_id ${sponsorship_id}:`,
sponsorship_obj_get_result
);
}
if (try_cache) {
// Process the results first
const processed_obj_li = await process_ae_obj__sponsorship_props({
obj_li: [sponsorship_obj_get_result],
log_lvl: log_lvl
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_sponsorships,
table_name: 'sponsorship',
obj_li: processed_obj_li,
properties_to_save: properties_to_save_sponsorship,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return sponsorship_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
ae_promises.load__sponsorship_obj = api
.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'sponsorship',
obj_id: sponsorship_id,
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
params: params,
log_lvl: log_lvl
})
.then(async function (sponsorship_obj_get_result) {
if (sponsorship_obj_get_result) {
if (log_lvl) {
console.log(`*spons_func* Got a result for sponsorship_id ${sponsorship_id}`);
} else if (log_lvl > 1) {
console.log(
`*spons_func* Got a result for sponsorship_id ${sponsorship_id}:`,
sponsorship_obj_get_result
);
}
if (try_cache) {
// Process the results first
const processed_obj_li = await process_ae_obj__sponsorship_props({
obj_li: [sponsorship_obj_get_result],
log_lvl: log_lvl
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_sponsorships,
table_name: 'sponsorship',
obj_li: processed_obj_li,
properties_to_save: properties_to_save_sponsorship,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return sponsorship_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error: any) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.load__sponsorship_obj:', ae_promises.load__sponsorship_obj);
}
if (log_lvl) {
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
async function load_ae_obj_li__sponsorship({
api_cfg,
for_obj_type = 'account',
for_obj_id,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
order_by_li = {
priority: 'DESC',
sort: 'DESC',
name: 'ASC',
updated_on: 'DESC',
created_on: 'DESC'
},
params = {},
try_cache = true,
log_lvl = 0
api_cfg,
for_obj_type = 'account',
for_obj_id,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
order_by_li = {
priority: 'DESC',
sort: 'DESC',
name: 'ASC',
updated_on: 'DESC',
created_on: 'DESC'
},
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
for_obj_type: string;
for_obj_id: string;
inc_content_li?: boolean;
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
offset?: number;
order_by_li?: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
api_cfg: any;
for_obj_type: string;
for_obj_id: string;
inc_content_li?: boolean;
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
limit?: number;
offset?: number;
order_by_li?: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(
`*** load_ae_obj_li__sponsorship() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`
);
}
if (log_lvl) {
console.log(
`*** load_ae_obj_li__sponsorship() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`
);
}
const 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({
api_cfg: api_cfg,
obj_type: 'sponsorship',
for_obj_type: for_obj_type,
for_obj_id: for_obj_id,
use_alt_tbl: false,
use_alt_mdl: false,
use_alt_exp: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(async function (sponsorship_obj_li_get_result) {
if (sponsorship_obj_li_get_result) {
if (try_cache) {
// Process the results first
const processed_obj_li = await process_ae_obj__sponsorship_props({
obj_li: sponsorship_obj_li_get_result,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_sponsorships,
table_name: 'sponsorship',
obj_li: processed_obj_li,
properties_to_save: properties_to_save_sponsorship,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return sponsorship_obj_li_get_result;
} else {
return [];
}
});
ae_promises.load__sponsorship_obj_li = await api
.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg: api_cfg,
obj_type: 'sponsorship',
for_obj_type: for_obj_type,
for_obj_id: for_obj_id,
use_alt_tbl: false,
use_alt_mdl: false,
use_alt_exp: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(async function (sponsorship_obj_li_get_result) {
if (sponsorship_obj_li_get_result) {
if (try_cache) {
// Process the results first
const processed_obj_li = await process_ae_obj__sponsorship_props({
obj_li: sponsorship_obj_li_get_result,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('Processed object list:', processed_obj_li);
}
// Save the updated results list to the database
if (log_lvl) {
console.log('Saving to DB...');
}
await db_save_ae_obj_li__ae_obj({
db_instance: db_sponsorships,
table_name: 'sponsorship',
obj_li: processed_obj_li,
properties_to_save: properties_to_save_sponsorship,
log_lvl: log_lvl
});
if (log_lvl) {
console.log('DB save completed.');
}
}
return sponsorship_obj_li_get_result;
} else {
return [];
}
});
if (log_lvl) {
console.log('ae_promises.load__sponsorship_obj_li:', ae_promises.load__sponsorship_obj_li);
}
if (log_lvl) {
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,
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;
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() ***');
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;
const endpoint = `/v2/crud/sponsorship/list`;
params['for_obj_type'] = 'account';
params['for_obj_id'] = account_id;
if (file_type == 'CSV' || file_type == 'Excel') {
params['file_type'] = file_type;
}
params['return_file'] = true;
if (file_type == 'CSV' || file_type == 'Excel') {
params['file_type'] = file_type;
}
params['return_file'] = true;
ae_promises.download__sponsorship_export_file = await api.get_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
return_blob: return_file,
filename: filename,
auto_download: auto_download,
log_lvl: log_lvl
});
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;
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
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 const spons_func = export_obj;

View File

@@ -7,113 +7,113 @@ import type { key_val } from '$lib/stores/ae_stores';
// Updated 2025-01-15
export interface Sponsorship {
id: string;
// id_random: string;
sponsorship_id: string;
// sponsorship_id_random: string;
id: string;
// id_random: string;
sponsorship_id: string;
// sponsorship_id_random: string;
account_id: string;
// account_id_random: string;
account_id: string;
// account_id_random: string;
organization_id?: null | string;
person_id?: null | string;
organization_id?: null | string;
person_id?: null | string;
poc_person_id?: null | string;
poc_json?: null | string;
poc_person_id?: null | string;
poc_json?: null | string;
name: null | string;
name_override: null | string;
name: null | string;
name_override: null | string;
description?: null | string;
description?: null | string;
email?: null | string;
website_url?: null | string;
email?: null | string;
website_url?: null | string;
// html_text?: null|string;
// thumbnail_url?: null|string;
// picture_url?: null|string;
// video_url?: null|string;
// audio_url?: null|string;
// image_url?: null|string;
// document_url?: null|string;
// logo_url?: null|string;
// html_text?: null|string;
// thumbnail_url?: null|string;
// picture_url?: null|string;
// video_url?: null|string;
// audio_url?: null|string;
// image_url?: null|string;
// document_url?: null|string;
// logo_url?: null|string;
logo_li_json?: null | string;
media_li_json?: null | string;
social_li_json?: null | string;
address_li_json?: null | string;
contact_li_json?: null | string;
guest_li_json?: null | string;
logo_li_json?: null | string;
media_li_json?: null | string;
social_li_json?: null | string;
address_li_json?: null | string;
contact_li_json?: null | string;
guest_li_json?: null | string;
level_num?: null | number;
level_str?: null | string;
level_num?: null | number;
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
staff_notes?: null | string; // Internal use; from staff
comments?: null | string; // From the sponsor
staff_notes?: null | string; // Internal use; from staff
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
// Generated fields for sorting locally only
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
// Generated fields for sorting locally only
tmp_sort_1?: null | string;
tmp_sort_2?: null | string;
// Additional fields for convenience (database views)
// Additional fields for convenience (database views)
}
// Updated 2025-01-15
export interface Sponsorship_Cfg {
id: string;
// id_random: string;
sponsorship_cfg_id: string;
// sponsorship_cfg_id_random: string;
id: string;
// id_random: string;
sponsorship_cfg_id: string;
// sponsorship_cfg_id_random: string;
account_id: string;
// account_id_random: string;
account_id: string;
// account_id_random: string;
for_type?: null | string;
for_id?: null | number;
for_type?: null | string;
for_id?: null | number;
level_li_json?: null | string;
option_li_json?: null | string;
schedule_li_json?: null | string;
level_li_json?: null | string;
option_li_json?: null | string;
schedule_li_json?: null | string;
cfg_json?: null | key_val;
cfg_json?: null | key_val;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
// Additional fields for convenience (database views)
// Additional fields for convenience (database views)
}
// Updated 2024-09-25
export class MySubClassedDexie extends Dexie {
// We just tell the typing system this is the case
sponsorship!: Table<Sponsorship>;
cfg!: Table<Sponsorship_Cfg>;
// We just tell the typing system this is the case
sponsorship!: Table<Sponsorship>;
cfg!: Table<Sponsorship_Cfg>;
constructor() {
super('ae_sponsorships_db');
this.version(1).stores({
sponsorship: `
constructor() {
super('ae_sponsorships_db');
this.version(1).stores({
sponsorship: `
id, sponsorship_id,
account_id,
poc_person_id,
@@ -122,12 +122,12 @@ export class MySubClassedDexie extends Dexie {
agree,
enable, hide, priority, sort, group, notes, created_on, updated_on, [updated_on+created_on], [created_on+updated_on]`,
cfg: `
cfg: `
id, sponsorship_cfg_id,
account_id,
for_type, for_id`
});
}
});
}
}
export const db_sponsorships = new MySubClassedDexie();

View File

@@ -1,10 +1,10 @@
// 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
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';
@@ -17,24 +17,24 @@ import { process_data_string } from './ae_utils__process_data_string';
import { set_obj_prop_display_name } from './ae_utils__set_obj_prop_display_name';
import { return_obj_type_path } from './ae_utils__return_obj_type_path';
import {
combine_iv_and_base64,
encrypt_content,
encrypt_wrapper,
decrypt_content,
decrypt_wrapper
combine_iv_and_base64,
encrypt_content,
encrypt_wrapper,
decrypt_content,
decrypt_wrapper
} from './ae_utils__crypto';
export type key_str = {
[key: string]: string;
[key: string]: string;
};
export type key_val = {
[key: string]: any;
[key: string]: any;
};
/* This utility function will add commas to a number. */
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).
@@ -45,110 +45,110 @@ function number_w_commas(x) {
// 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}`);
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);
const location = window.location.href;
// console.log('location:', location);
const url = new URL(location);
// console.log('url:', url);
if (value) {
url.searchParams.set(name, value);
history.pushState({}, '', url);
if (value) {
url.searchParams.set(name, value);
history.pushState({}, '', url);
// console.log('url:', url);
// pushState(url.href, {});
// pushState(url.search, {});
// replaceState(url.href, {});
// console.log('url:', url);
// pushState(url.href, {});
// pushState(url.search, {});
// replaceState(url.href, {});
const message = { name: value };
window.parent.postMessage(message, '*');
} else {
url.searchParams.delete(name);
history.pushState({}, '', url);
const message = { name: value };
window.parent.postMessage(message, '*');
} else {
url.searchParams.delete(name);
history.pushState({}, '', url);
// console.log('url:', url);
// pushState({}, '', url.search);
// pushState(url.href, {});
// replaceState(url.href, {});
// console.log('url:', url);
// pushState({}, '', url.search);
// pushState(url.href, {});
// replaceState(url.href, {});
const message = { name: null };
window.parent.postMessage(message, '*');
}
// console.log('Message sent to parent (iframe):', message);
const message = { name: null };
window.parent.postMessage(message, '*');
}
// console.log('Message sent to parent (iframe):', message);
}
function create_a_element({
account_id,
base_url,
hosted_file_id,
filename = null,
extension = null,
text = 'Download',
class_li = 'text-blue-500'
account_id,
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>`;
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
account_id,
base_url,
hosted_file_id,
filename = null,
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}" />`;
}
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) {
const a_html = create_a_element({
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>`;
}
if (inc_link) {
const a_html = create_a_element({
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
account_id,
base_url,
hosted_file_id,
filename = null,
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>`;
}
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) {
const a_html = create_a_element({
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>`;
}
if (inc_link) {
const a_html = create_a_element({
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
@@ -171,66 +171,66 @@ function create_video_element({
// This function will take a long string (sentences or paragraphs) of text and return an estimated number of words.
function count_words(text: string) {
if (!text || text.length < 1) {
return false;
}
const count = text.trim().split(/\s+/).length;
if (!text || text.length < 1) {
return false;
}
const count = text.trim().split(/\s+/).length;
return count;
return count;
}
// Updated 2024-06-19
// This function behaves weirdly. It needs to be reviewed and updated.
export const shorten_string = function shorten_string({
string,
max_length = 45,
begin_length = 15,
end_length = 5,
wildcard_length = 3
string,
max_length = 45,
begin_length = 15,
end_length = 5,
wildcard_length = 3
}: {
string: undefined | string;
max_length?: number;
begin_length?: number;
end_length?: number;
wildcard_length?: number;
string: undefined | string;
max_length?: number;
begin_length?: number;
end_length?: number;
wildcard_length?: number;
}) {
// console.log('*** shorten_filename() ***');
// console.log('*** shorten_filename() ***');
if (!string || typeof string != 'string') {
// console.log('Invalid string value passed');
// return false;
return '';
}
if (!string || typeof string != 'string') {
// console.log('Invalid string value passed');
// return false;
return '';
}
// 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
// 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
// let length = string.length;
const char_over = string.length - max_length;
let new_string = null;
let wildcards = char_over;
if (char_over > 0) {
const part1 = string.slice(0, begin_length);
// let length = string.length;
const char_over = string.length - max_length;
let new_string = null;
let wildcards = char_over;
if (char_over > 0) {
const part1 = string.slice(0, begin_length);
let part2 = '';
if (char_over > 5) {
wildcards = 5;
} else {
}
let part2 = '';
if (char_over > 5) {
wildcards = 5;
} else {
}
if (wildcard_length) {
part2 = '.'.repeat(wildcard_length);
} else {
part2 = '.'.repeat(wildcards);
}
if (wildcard_length) {
part2 = '.'.repeat(wildcard_length);
} else {
part2 = '.'.repeat(wildcards);
}
const 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
@@ -238,69 +238,69 @@ export const shorten_string = function shorten_string({
// Example 1: The Original Long File Name.pdf -> The Orig....pdf
// Example 2: The Original Long File Name.html -> The Ori....html
function shorten_filename({
filename,
max_length = 20,
slice_end_at = 15,
max_end_length = 5
filename,
max_length = 20,
slice_end_at = 15,
max_end_length = 5
}: {
filename: string;
max_length?: number;
slice_end_at?: number;
max_end_length?: number;
filename: string;
max_length?: number;
slice_end_at?: number;
max_end_length?: number;
}) {
// console.log('*** shorten_filename() ***');
// console.log('*** shorten_filename() ***');
if (typeof filename !== 'string' || filename.length <= max_length) {
return filename;
}
if (typeof filename !== 'string' || filename.length <= max_length) {
return filename;
}
let new_filename = null;
const char_over = filename.length - max_length;
let wildcards = char_over - 4; // The number of characters over the max length
if (wildcards < 1) {
return filename; // No point in changing the filename?
}
let new_filename = null;
const char_over = filename.length - max_length;
let wildcards = char_over - 4; // The number of characters over the max length
if (wildcards < 1) {
return filename; // No point in changing the filename?
}
const part_1 = filename.slice(0, slice_end_at);
if (wildcards > 3) {
wildcards = 3;
} else {
}
const part_2 = '.'.repeat(wildcards);
const part_3 = filename.slice(max_end_length * -1);
const part_1 = filename.slice(0, slice_end_at);
if (wildcards > 3) {
wildcards = 3;
} else {
}
const part_2 = '.'.repeat(wildcards);
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 = {
is_datetime_recent: is_datetime_recent,
process_permission_checks: process_permission_checks,
iso_datetime_formatter: iso_datetime_formatter,
clean_filename: clean_filename,
format_bytes: format_bytes,
number_w_commas: number_w_commas,
guess_file_name: guess_file_name,
guess_file_extension: guess_file_extension,
get_file_hash: get_file_hash,
get_obj_li_w_match_prop: get_obj_li_w_match_prop,
extract_prefixed_form_data: extract_prefixed_form_data,
process_data_string: process_data_string,
handle_url_and_message: handle_url_and_message,
create_a_element: create_a_element,
create_img_element: create_img_element,
create_video_element: create_video_element,
count_words: count_words,
to_title_case: to_title_case,
shorten_string: shorten_string,
shorten_filename: shorten_filename,
file_extension_icon: file_extension_icon,
set_obj_prop_display_name: set_obj_prop_display_name,
return_obj_type_path: return_obj_type_path,
combine_iv_and_base64: combine_iv_and_base64,
encrypt_content: encrypt_content,
encrypt_wrapper: encrypt_wrapper,
decrypt_content: decrypt_content,
decrypt_wrapper: decrypt_wrapper
is_datetime_recent: is_datetime_recent,
process_permission_checks: process_permission_checks,
iso_datetime_formatter: iso_datetime_formatter,
clean_filename: clean_filename,
format_bytes: format_bytes,
number_w_commas: number_w_commas,
guess_file_name: guess_file_name,
guess_file_extension: guess_file_extension,
get_file_hash: get_file_hash,
get_obj_li_w_match_prop: get_obj_li_w_match_prop,
extract_prefixed_form_data: extract_prefixed_form_data,
process_data_string: process_data_string,
handle_url_and_message: handle_url_and_message,
create_a_element: create_a_element,
create_img_element: create_img_element,
create_video_element: create_video_element,
count_words: count_words,
to_title_case: to_title_case,
shorten_string: shorten_string,
shorten_filename: shorten_filename,
file_extension_icon: file_extension_icon,
set_obj_prop_display_name: set_obj_prop_display_name,
return_obj_type_path: return_obj_type_path,
combine_iv_and_base64: combine_iv_and_base64,
encrypt_content: encrypt_content,
encrypt_wrapper: encrypt_wrapper,
decrypt_content: decrypt_content,
decrypt_wrapper: decrypt_wrapper
};

View File

@@ -2,126 +2,126 @@ const log_lvl = 0; // 0 = no logging, 1 = some logging, 2 = all logging
// Updated 2025-05-08
async function generate_iv() {
const data = new Uint8Array(16);
crypto.getRandomValues(data);
return data;
const data = new Uint8Array(16);
crypto.getRandomValues(data);
return data;
}
// Updated 2025-05-08
export const encrypt_content = async function encrypt_content(content: string, keyData: string) {
const iv = await generate_iv();
const keyBytes = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(keyData));
const key = await crypto.subtle.importKey('raw', keyBytes, { name: 'AES-CBC' }, false, [
'encrypt'
]);
const encodedContent = await crypto.subtle.encrypt(
{ name: 'AES-CBC', iv },
key,
new TextEncoder().encode(content)
);
const base64 = btoa(String.fromCharCode(...new Uint8Array(encodedContent)));
if (log_lvl) {
console.log(`IV: ${iv}; Encrypted:`, base64);
}
return { base64, iv };
const iv = await generate_iv();
const keyBytes = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(keyData));
const key = await crypto.subtle.importKey('raw', keyBytes, { name: 'AES-CBC' }, false, [
'encrypt'
]);
const encodedContent = await crypto.subtle.encrypt(
{ name: 'AES-CBC', iv },
key,
new TextEncoder().encode(content)
);
const base64 = btoa(String.fromCharCode(...new Uint8Array(encodedContent)));
if (log_lvl) {
console.log(`IV: ${iv}; Encrypted:`, base64);
}
return { base64, iv };
};
// Updated 2025-05-08
export const combine_iv_and_base64 = function combine_iv_and_base64(
base64: string,
iv: Uint8Array
base64: string,
iv: Uint8Array
) {
if (log_lvl) {
console.log(`IV: ${iv}; Encrypted:`, base64);
}
if (log_lvl) {
console.log(`IV: ${iv}; Encrypted:`, base64);
}
// Combine the IV and encrypted content
const combined =
Array.from(iv)
.map((byte) => byte.toString(16).padStart(2, '0'))
.join('') +
':' +
base64;
if (log_lvl) {
console.log('Combined IV and Base64:', combined);
}
// const ivBase64 = btoa(String.fromCharCode(...iv));
// const combined = `${ivBase64}:${base64}`;
// console.log('Combined IV and Base64 v2:', combined);
return combined;
// Combine the IV and encrypted content
const combined =
Array.from(iv)
.map((byte) => byte.toString(16).padStart(2, '0'))
.join('') +
':' +
base64;
if (log_lvl) {
console.log('Combined IV and Base64:', combined);
}
// const ivBase64 = btoa(String.fromCharCode(...iv));
// const combined = `${ivBase64}:${base64}`;
// console.log('Combined IV and Base64 v2:', combined);
return combined;
};
// Updated 2025-05-08
export const encrypt_wrapper = async function encrypt_wrapper(content: string, keyData: string) {
if (!content) {
console.error('No content provided. Returning empty string.');
return '';
}
if (!keyData) {
console.error('No keyData provided. Returning empty string.');
return '';
}
const { base64, iv } = await encrypt_content(content, keyData);
const combined = combine_iv_and_base64(base64, iv);
return combined;
if (!content) {
console.error('No content provided. Returning empty string.');
return '';
}
if (!keyData) {
console.error('No keyData provided. Returning empty string.');
return '';
}
const { base64, iv } = await encrypt_content(content, keyData);
const combined = combine_iv_and_base64(base64, iv);
return combined;
};
// This does not handle errors (invalid key/password) well.
// Updated 2025-05-08
export const decrypt_content = async function decrypt_content(
base64Content: string,
iv: Uint8Array,
keyData: string
base64Content: string,
iv: Uint8Array,
keyData: string
) {
const keyBytes = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(keyData));
const key = await crypto.subtle.importKey('raw', keyBytes, { name: 'AES-CBC' }, false, [
'decrypt'
]);
const encryptedContent = Uint8Array.from(atob(base64Content), (c) => c.charCodeAt(0));
const decryptedContent = await crypto.subtle.decrypt(
{ name: 'AES-CBC', iv },
key,
encryptedContent
);
const decodedContent = new TextDecoder().decode(decryptedContent);
// console.log('Decrypted Content:', decodedContent);
return decodedContent;
const keyBytes = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(keyData));
const key = await crypto.subtle.importKey('raw', keyBytes, { name: 'AES-CBC' }, false, [
'decrypt'
]);
const encryptedContent = Uint8Array.from(atob(base64Content), (c) => c.charCodeAt(0));
const decryptedContent = await crypto.subtle.decrypt(
{ name: 'AES-CBC', iv },
key,
encryptedContent
);
const decodedContent = new TextDecoder().decode(decryptedContent);
// console.log('Decrypted Content:', decodedContent);
return decodedContent;
};
// Updated 2025-05-08
export const split_iv_and_base64 = function split_iv_and_base64(combined: string) {
if (!combined) {
console.error('No combined string provided. Returning empty object.');
return { iv: new Uint8Array(), base64: '' };
}
const [iv_hex, encrypted_base64_string] = combined.split(':');
const base64 = encrypted_base64_string;
const iv = new Uint8Array(iv_hex.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
if (log_lvl) {
console.log(`IV: ${iv}; Encrypted:`, base64);
}
return { iv, base64 };
if (!combined) {
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;
const iv = new Uint8Array(iv_hex.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
if (log_lvl) {
console.log(`IV: ${iv}; Encrypted:`, base64);
}
return { iv, base64 };
};
// Updated 2025-05-15
export const decrypt_wrapper = async function decrypt_wrapper(combined: string, keyData: string) {
if (!combined) {
console.error('No combined string provided. Returning empty string.');
return false;
}
const { iv, base64 } = split_iv_and_base64(combined);
console.log(`IV: ${iv}; Encrypted:`, base64);
let decrypted;
try {
decrypted = await decrypt_content(base64, iv, keyData);
if (log_lvl > 1) {
console.log(`IV: ${iv}; Decrypted:`, decrypted);
} else if (log_lvl) {
console.log(`IV: ${iv}`);
}
} catch (error) {
console.error('Decryption failed:', error);
return false;
}
return decrypted;
if (!combined) {
console.error('No combined string provided. Returning empty string.');
return false;
}
const { iv, base64 } = split_iv_and_base64(combined);
console.log(`IV: ${iv}; Encrypted:`, base64);
let decrypted;
try {
decrypted = await decrypt_content(base64, iv, keyData);
if (log_lvl > 1) {
console.log(`IV: ${iv}; Decrypted:`, decrypted);
} else if (log_lvl) {
console.log(`IV: ${iv}`);
}
} catch (error) {
console.error('Decryption failed:', error);
return false;
}
return decrypted;
};

View File

@@ -1,176 +1,176 @@
import dayjs from 'dayjs';
export const iso_datetime_formatter = function iso_datetime_formatter(
raw_datetime: null | string | Date = null,
named_format: string = 'datetime_iso_no_seconds', // date_iso, datetime_iso_no_seconds
time_24_hours: boolean = false
raw_datetime: null | string | Date = null,
named_format: string = 'datetime_iso_no_seconds', // date_iso, datetime_iso_no_seconds
time_24_hours: boolean = false
) {
// console.log('*** iso_datetime_formatter() ***');
// console.log('*** iso_datetime_formatter() ***');
// https://en.wikipedia.org/wiki/ISO_8601
// https://day.js.org/docs/en/display/format
// 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
// and "24:00" is no longer allowed corresponding to the end of a day
// 60 is only used to denote an added leap second
// https://en.wikipedia.org/wiki/ISO_8601
// https://day.js.org/docs/en/display/format
// 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
// and "24:00" is no longer allowed corresponding to the end of a day
// 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:44Z
// ISO 8601 UTC: 20210304T190444Z
// ISO 8601 UTC: 2021-03-04T19:04:44+00:00
// ISO 8601 UTC: 2021-03-04T19:04:44Z
// ISO 8601 UTC: 20210304T190444Z
// datetime_iso 'YYYY-MM-DD HH:mm:ss'
// datetime_iso_12 'YYYY-MM-DD hh:mm:ss A'
// datetime_iso_12_short 'YY-MM-DD hh:mm A'
// datetime_iso_tz 'YYYY-MM-DD HH:mm:ss Z'
// datetime_iso 'YYYY-MM-DD HH:mm:ss'
// datetime_iso_12 'YYYY-MM-DD hh:mm:ss A'
// datetime_iso_12_short 'YY-MM-DD hh:mm A'
// datetime_iso_tz 'YYYY-MM-DD HH:mm:ss Z'
// datetime_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_medium 'ddd, MMM D, YYYY hh:mm:ss A'
// datetime_short 'MMM D, YY hh:mm A'
// datetime_long 'dddd, MMMM D, YYYY hh:mm:ss A'
// datetime_medium 'ddd, MMM D, YYYY hh:mm:ss 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_medium 'ddd, MMM D, YYYY'
// date_short 'MMM D, YY'
// date_long 'dddd, MMMM D, YYYY'
// date_medium 'ddd, MMM D, YYYY'
// date_short 'MMM D, YY'
// time_iso 'HH:mm:ss'
// time_iso_12 'hh:mm:ss A'
// time_iso_tz 'HH:mm:ss Z'
// time_iso_12_tz 'hh:mm:ss A Z'
// time_iso 'HH:mm:ss'
// time_iso_12 'hh:mm:ss A'
// time_iso_tz 'HH:mm:ss Z'
// time_iso_12_tz 'hh:mm:ss A Z'
// time_long 'hh:mm:ss A'
// time_medium 'h:m:s A'
// time_short 'hh:mm A'
// time_long 'hh:mm:ss A'
// time_medium 'h:m:s 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) {
raw_datetime = new Date(); // Get the current datetime if one was not passed.
}
if (!raw_datetime) {
raw_datetime = new Date(); // Get the current datetime if one was not passed.
}
let datetime_string = null;
let datetime_string = null;
switch (named_format) {
case 'datetime_iso':
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss');
break;
case 'datetime_iso_no_seconds':
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm');
break;
case 'datetime_iso_12_short':
datetime_string = dayjs(raw_datetime).format('YY-MM-DD hh:mm A');
break;
case 'datetime_iso_12_short_month':
datetime_string = dayjs(raw_datetime).format('MM-DD hh:mm A');
break;
case 'datetime_iso_tz':
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss Z');
break;
case 'datetime_iso_12_no_seconds':
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD hh:mm A');
break;
// case 'datetime_12_no_seconds':
// datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD hh:mm A');
// break;
case 'datetime_us':
datetime_string = dayjs(raw_datetime).format('MM/DD/YYYY hh:mm:ss A');
break;
case 'datetime_short':
datetime_string = dayjs(raw_datetime).format('MMM D, YY HH:mm');
break;
case 'datetime_12_short':
datetime_string = dayjs(raw_datetime).format('MMM D, YY hh:mm A');
break;
case 'datetime_medium':
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY H:mm');
break;
case 'datetime_12_medium':
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY h:mm A');
break;
case 'datetime_long':
datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY HH:mm');
break;
case 'datetime_12_long':
datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY hh:mm A');
break;
case 'datetime_medium_sec':
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY H:mm:ss');
break;
case 'datetime_12_medium_sec':
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY h:mm:ss A');
break;
case 'datetime_short_month':
datetime_string = dayjs(raw_datetime).format('MMM D hh:mm A');
break;
case 'datetime_long_month':
datetime_string = dayjs(raw_datetime).format('MMMM D hh:mm A');
break;
case 'datetime_short_day':
datetime_string = dayjs(raw_datetime).format('D hh:mm A');
break;
case 'date_iso':
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD');
break;
case 'date_us':
datetime_string = dayjs(raw_datetime).format('MM/DD/YYYY');
break;
case 'date_long_month_day':
datetime_string = dayjs(raw_datetime).format('MMMM D');
break;
case 'date_short':
datetime_string = dayjs(raw_datetime).format('MMM D, YY');
break;
case 'date_short_no_year':
datetime_string = dayjs(raw_datetime).format('MMM D');
break;
case 'date_long':
datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY');
break;
case 'date_full':
datetime_string = dayjs(raw_datetime).format('dddd, MMMM D, YYYY');
break;
case 'date_full_no_year':
datetime_string = dayjs(raw_datetime).format('dddd, MMMM D');
break;
case 'time_iso':
datetime_string = dayjs(raw_datetime).format('HH:mm:ss');
break;
case 'time_iso_12_tz':
datetime_string = dayjs(raw_datetime).format('hh:mm:ss A Z');
break;
case 'time_long':
datetime_string = dayjs(raw_datetime).format('HH:mm:ss');
break;
case 'time_12_long':
datetime_string = dayjs(raw_datetime).format('hh:mm:ss A');
break;
case 'time_short':
datetime_string = dayjs(raw_datetime).format('HH:mm');
break;
case 'time_short_no_leading':
datetime_string = dayjs(raw_datetime).format('H:mm');
break;
case 'time_12_short':
datetime_string = dayjs(raw_datetime).format('hh:mm A');
break;
case 'time_12_short_no_leading':
datetime_string = dayjs(raw_datetime).format('h:mm A');
break;
case 'week_long':
datetime_string = dayjs(raw_datetime).format('dddd');
break;
case 'week_medium':
datetime_string = dayjs(raw_datetime).format('ddd');
break;
case 'week_short':
datetime_string = dayjs(raw_datetime).format('dd');
break;
default:
// 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('YYYY-MM-DD HH:mm:ss');
}
return datetime_string;
switch (named_format) {
case 'datetime_iso':
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss');
break;
case 'datetime_iso_no_seconds':
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm');
break;
case 'datetime_iso_12_short':
datetime_string = dayjs(raw_datetime).format('YY-MM-DD hh:mm A');
break;
case 'datetime_iso_12_short_month':
datetime_string = dayjs(raw_datetime).format('MM-DD hh:mm A');
break;
case 'datetime_iso_tz':
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss Z');
break;
case 'datetime_iso_12_no_seconds':
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD hh:mm A');
break;
// case 'datetime_12_no_seconds':
// datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD hh:mm A');
// break;
case 'datetime_us':
datetime_string = dayjs(raw_datetime).format('MM/DD/YYYY hh:mm:ss A');
break;
case 'datetime_short':
datetime_string = dayjs(raw_datetime).format('MMM D, YY HH:mm');
break;
case 'datetime_12_short':
datetime_string = dayjs(raw_datetime).format('MMM D, YY hh:mm A');
break;
case 'datetime_medium':
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY H:mm');
break;
case 'datetime_12_medium':
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY h:mm A');
break;
case 'datetime_long':
datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY HH:mm');
break;
case 'datetime_12_long':
datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY hh:mm A');
break;
case 'datetime_medium_sec':
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY H:mm:ss');
break;
case 'datetime_12_medium_sec':
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY h:mm:ss A');
break;
case 'datetime_short_month':
datetime_string = dayjs(raw_datetime).format('MMM D hh:mm A');
break;
case 'datetime_long_month':
datetime_string = dayjs(raw_datetime).format('MMMM D hh:mm A');
break;
case 'datetime_short_day':
datetime_string = dayjs(raw_datetime).format('D hh:mm A');
break;
case 'date_iso':
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD');
break;
case 'date_us':
datetime_string = dayjs(raw_datetime).format('MM/DD/YYYY');
break;
case 'date_long_month_day':
datetime_string = dayjs(raw_datetime).format('MMMM D');
break;
case 'date_short':
datetime_string = dayjs(raw_datetime).format('MMM D, YY');
break;
case 'date_short_no_year':
datetime_string = dayjs(raw_datetime).format('MMM D');
break;
case 'date_long':
datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY');
break;
case 'date_full':
datetime_string = dayjs(raw_datetime).format('dddd, MMMM D, YYYY');
break;
case 'date_full_no_year':
datetime_string = dayjs(raw_datetime).format('dddd, MMMM D');
break;
case 'time_iso':
datetime_string = dayjs(raw_datetime).format('HH:mm:ss');
break;
case 'time_iso_12_tz':
datetime_string = dayjs(raw_datetime).format('hh:mm:ss A Z');
break;
case 'time_long':
datetime_string = dayjs(raw_datetime).format('HH:mm:ss');
break;
case 'time_12_long':
datetime_string = dayjs(raw_datetime).format('hh:mm:ss A');
break;
case 'time_short':
datetime_string = dayjs(raw_datetime).format('HH:mm');
break;
case 'time_short_no_leading':
datetime_string = dayjs(raw_datetime).format('H:mm');
break;
case 'time_12_short':
datetime_string = dayjs(raw_datetime).format('hh:mm A');
break;
case 'time_12_short_no_leading':
datetime_string = dayjs(raw_datetime).format('h:mm A');
break;
case 'week_long':
datetime_string = dayjs(raw_datetime).format('dddd');
break;
case 'week_medium':
datetime_string = dayjs(raw_datetime).format('ddd');
break;
case 'week_short':
datetime_string = dayjs(raw_datetime).format('dd');
break;
default:
// 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('YYYY-MM-DD HH:mm:ss');
}
return datetime_string;
};

View File

@@ -1,5 +1,5 @@
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.
@@ -12,121 +12,121 @@ type key_val = {
* Updated 2023-12-22
*/
export const extract_prefixed_form_data = function extract_prefixed_form_data({
prefix = null,
form_data = {},
rm_empty_id = true,
rm_empty = false,
trim_values = false,
bool_tf_str = false,
log_lvl = 0
prefix = null,
form_data = {},
rm_empty_id = true,
rm_empty = false,
trim_values = false,
bool_tf_str = false,
log_lvl = 0
}: {
prefix: string | null;
form_data: any;
rm_empty_id?: boolean;
rm_empty?: boolean;
trim_values?: boolean;
bool_tf_str?: boolean;
log_lvl?: number;
prefix: string | null;
form_data: any;
rm_empty_id?: boolean;
rm_empty?: boolean;
trim_values?: boolean;
bool_tf_str?: boolean;
log_lvl?: number;
}) {
if (log_lvl) {
console.log('*** extract_prefixed_form_data() ***');
if (prefix) {
console.log(
`Looking for prefixed fields: ${prefix}; Removing emptry ID fields: ${rm_empty_id}; Removing empty fields: ${rm_empty}; Trim string values: ${trim_values}; Convert true/false string values to boolean: ${bool_tf_str}`
);
} else {
console.log(
`No prefix set. Looking at all fields. Removing emptry ID fields: ${rm_empty_id}; Removing empty fields: ${rm_empty}; Trim string values: ${trim_values}; Convert true/false string values to boolean: ${bool_tf_str}`
);
}
}
if (log_lvl > 1) {
console.log('Form Data:');
console.log(form_data);
}
if (log_lvl) {
console.log('*** extract_prefixed_form_data() ***');
if (prefix) {
console.log(
`Looking for prefixed fields: ${prefix}; Removing emptry ID fields: ${rm_empty_id}; Removing empty fields: ${rm_empty}; Trim string values: ${trim_values}; Convert true/false string values to boolean: ${bool_tf_str}`
);
} else {
console.log(
`No prefix set. Looking at all fields. Removing emptry ID fields: ${rm_empty_id}; Removing empty fields: ${rm_empty}; Trim string values: ${trim_values}; Convert true/false string values to boolean: ${bool_tf_str}`
);
}
}
if (log_lvl > 1) {
console.log('Form Data:');
console.log(form_data);
}
// const data_obj: any = {}; // future TS
const data_obj: key_val = {};
for (const field of form_data) {
let [obj_prop_name, obj_prop_value] = field;
if (log_lvl > 1) {
console.log(`${obj_prop_name}: ${obj_prop_value} type=${typeof obj_prop_value}`);
}
// const data_obj: any = {}; // future TS
const data_obj: key_val = {};
for (const field of form_data) {
let [obj_prop_name, obj_prop_value] = field;
if (log_lvl > 1) {
console.log(`${obj_prop_name}: ${obj_prop_value} type=${typeof obj_prop_value}`);
}
// Trim string values if needed
if (trim_values && typeof obj_prop_value === 'string') {
if (log_lvl && obj_prop_value.trim() != obj_prop_value) {
console.log('Trimming string value!');
obj_prop_value = obj_prop_value.trim();
}
}
// Trim string values if needed
if (trim_values && typeof obj_prop_value === 'string') {
if (log_lvl && obj_prop_value.trim() != obj_prop_value) {
console.log('Trimming string value!');
obj_prop_value = obj_prop_value.trim();
}
}
// Convert string to boolean if needed
if (bool_tf_str && typeof obj_prop_value === 'string') {
// console.log('Flag set for converting true/false string values to boolean!');
// Convert string to boolean if needed
if (bool_tf_str && typeof obj_prop_value === 'string') {
// console.log('Flag set for converting true/false string values to boolean!');
if (obj_prop_value.toLowerCase() === 'true') {
if (log_lvl) {
console.log('Converting string to boolean value: true');
}
obj_prop_value = true;
} else if (obj_prop_value.toLowerCase() === 'false') {
if (log_lvl) {
console.log('Converting string to boolean value: false');
}
obj_prop_value = false;
}
}
if (obj_prop_value.toLowerCase() === 'true') {
if (log_lvl) {
console.log('Converting string to boolean value: true');
}
obj_prop_value = true;
} else if (obj_prop_value.toLowerCase() === 'false') {
if (log_lvl) {
console.log('Converting string to boolean value: false');
}
obj_prop_value = false;
}
}
if (prefix && obj_prop_name.startsWith(prefix)) {
// Prefix set
// if (obj_prop_name.startsWith(prefix)) {
obj_prop_name = obj_prop_name.replace(prefix, '');
if (log_lvl) {
console.log(`Checking: (${prefix})${obj_prop_name} value=${obj_prop_value}`);
}
if (rm_empty_id && obj_prop_name.endsWith('id_random') && !obj_prop_value) {
if (log_lvl) {
console.log(`Match but empty *_id_random. Ignoring/removing: ${obj_prop_name}`);
}
} else if (rm_empty && !obj_prop_value) {
if (log_lvl) {
console.log(`Match but empty. Ignoring/removing: ${obj_prop_name}`);
}
} else {
if (log_lvl) {
console.log(`Match: ${prefix})${obj_prop_name} value=${obj_prop_value}`);
}
data_obj[obj_prop_name] = obj_prop_value;
}
} else if (prefix && !obj_prop_name.startsWith(prefix)) {
// Prefix set
if (log_lvl > 1) {
console.log('Did not start with prefix. Ignoring');
}
} else {
// No prefix set
if (log_lvl) {
console.log(`Checking: ${obj_prop_name} value=${obj_prop_value}`);
}
if (rm_empty_id && obj_prop_name.endsWith('id_random') && !obj_prop_value) {
if (log_lvl > 1) {
console.log(`Match but empty *_id_random. Ignoring/removing: ${obj_prop_name}`);
}
} else if (rm_empty && !obj_prop_value) {
if (log_lvl > 1) {
console.log(`Match but empty. Ignoring/removing: ${obj_prop_name}`);
}
} else {
if (log_lvl > 1) {
console.log(`Match: ${obj_prop_name} value=${obj_prop_value}`);
}
data_obj[obj_prop_name] = obj_prop_value;
}
}
}
if (log_lvl > 1) {
console.log(data_obj);
}
return data_obj;
if (prefix && obj_prop_name.startsWith(prefix)) {
// Prefix set
// if (obj_prop_name.startsWith(prefix)) {
obj_prop_name = obj_prop_name.replace(prefix, '');
if (log_lvl) {
console.log(`Checking: (${prefix})${obj_prop_name} value=${obj_prop_value}`);
}
if (rm_empty_id && obj_prop_name.endsWith('id_random') && !obj_prop_value) {
if (log_lvl) {
console.log(`Match but empty *_id_random. Ignoring/removing: ${obj_prop_name}`);
}
} else if (rm_empty && !obj_prop_value) {
if (log_lvl) {
console.log(`Match but empty. Ignoring/removing: ${obj_prop_name}`);
}
} else {
if (log_lvl) {
console.log(`Match: ${prefix})${obj_prop_name} value=${obj_prop_value}`);
}
data_obj[obj_prop_name] = obj_prop_value;
}
} else if (prefix && !obj_prop_name.startsWith(prefix)) {
// Prefix set
if (log_lvl > 1) {
console.log('Did not start with prefix. Ignoring');
}
} else {
// No prefix set
if (log_lvl) {
console.log(`Checking: ${obj_prop_name} value=${obj_prop_value}`);
}
if (rm_empty_id && obj_prop_name.endsWith('id_random') && !obj_prop_value) {
if (log_lvl > 1) {
console.log(`Match but empty *_id_random. Ignoring/removing: ${obj_prop_name}`);
}
} else if (rm_empty && !obj_prop_value) {
if (log_lvl > 1) {
console.log(`Match but empty. Ignoring/removing: ${obj_prop_name}`);
}
} else {
if (log_lvl > 1) {
console.log(`Match: ${obj_prop_name} value=${obj_prop_value}`);
}
data_obj[obj_prop_name] = obj_prop_value;
}
}
}
if (log_lvl > 1) {
console.log(data_obj);
}
return data_obj;
};

View File

@@ -2,49 +2,49 @@ import type { key_str } from './ae_utils';
// Updated 2024-06-19
export function file_extension_icon(extension: string) {
// console.log('*** file_extension_icon() ***');
const file_icons: key_str = {
file: 'file',
'3gp': 'file-video',
'7z': 'file-archive',
aac: 'file-audio',
ac3: 'file-audio',
aif: 'file-audio',
aiff: 'file-audio',
avi: 'file-video',
bmp: 'file-image',
csv: 'file-csv',
doc: 'file-word',
docx: 'file-word',
eps: 'file-image',
flac: 'file-audio',
gif: 'file-image',
htm: 'file-code',
html: 'file-code',
jpeg: 'file-image',
jpg: 'file-image',
key: 'file-powerpoint',
mkv: 'file-video',
mov: 'file-video',
mp3: 'file-audio',
mp4: 'file-video',
odp: 'file-powerpoint',
pdf: 'file-pdf',
png: 'file-image',
ppt: 'file-powerpoint',
pptx: 'file-powerpoint',
txt: 'file-alt',
wav: 'file-audio',
webp: 'file-image',
xls: 'file-excel',
xlsx: 'file-excel',
zip: 'file-archive'
};
// console.log('*** file_extension_icon() ***');
const file_icons: key_str = {
file: 'file',
'3gp': 'file-video',
'7z': 'file-archive',
aac: 'file-audio',
ac3: 'file-audio',
aif: 'file-audio',
aiff: 'file-audio',
avi: 'file-video',
bmp: 'file-image',
csv: 'file-csv',
doc: 'file-word',
docx: 'file-word',
eps: 'file-image',
flac: 'file-audio',
gif: 'file-image',
htm: 'file-code',
html: 'file-code',
jpeg: 'file-image',
jpg: 'file-image',
key: 'file-powerpoint',
mkv: 'file-video',
mov: 'file-video',
mp3: 'file-audio',
mp4: 'file-video',
odp: 'file-powerpoint',
pdf: 'file-pdf',
png: 'file-image',
ppt: 'file-powerpoint',
pptx: 'file-powerpoint',
txt: 'file-alt',
wav: 'file-audio',
webp: 'file-image',
xls: 'file-excel',
xlsx: 'file-excel',
zip: 'file-archive'
};
if (file_icons[extension]) {
return file_icons[extension];
} else {
// return null;
return file_icons['file'];
}
if (file_icons[extension]) {
return file_icons[extension];
} else {
// return null;
return file_icons['file'];
}
}

View File

@@ -3,84 +3,84 @@
// Use a defined list of unacceptable characters to remove from a filename.
// Updated 2024-10-18
export const clean_filename = function clean_filename(
filename: any | string,
unacceptable_chars: RegExp = /[ <>:"/\\|?*]/g,
replacement_char: string = '_'
filename: any | string,
unacceptable_chars: RegExp = /[ <>:"/\\|?*]/g,
replacement_char: string = '_'
) {
// console.log('*** clean_filename() ***');
if (!filename) {
return '';
}
// console.log('*** clean_filename() ***');
if (!filename) {
return '';
}
const cleaned_filename = filename.replace(unacceptable_chars, replacement_char);
// console.log(cleaned_filename);
return cleaned_filename;
const cleaned_filename = filename.replace(unacceptable_chars, replacement_char);
// console.log(cleaned_filename);
return cleaned_filename;
};
export const format_bytes = function format_bytes(bytes: number, decimals: number = 2) {
if (bytes === 0) return '0 Bytes';
if (bytes === 0) return '0 Bytes';
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const k = 1024;
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));
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
export const guess_file_name = function guess_file_name(filename_string: string) {
// console.log('*** guess_file_name() ***');
if (!filename_string) {
return '';
}
// console.log('*** guess_file_name() ***');
if (!filename_string) {
return '';
}
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;
}
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
export const guess_file_extension = function guess_file_extension(filename_string: string) {
// console.log('*** guess_file_extension() ***');
if (!filename_string) {
return '';
}
// console.log('*** guess_file_extension() ***');
if (!filename_string) {
return '';
}
if (!filename_string.includes('.')) {
return '';
}
if (!filename_string.includes('.')) {
return '';
}
const 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
export const get_file_hash = async function get_file_hash(file) {
return new Promise((resolve, reject) => {
const file_reader = new FileReader();
return new Promise((resolve, reject) => {
const file_reader = new FileReader();
file_reader.onload = async function () {
if (file_reader.result.byteLength !== file.size) {
console.log('File was not read completely');
reject('Error reading the file');
}
file_reader.onload = async function () {
if (file_reader.result.byteLength !== file.size) {
console.log('File was not read completely');
reject('Error reading the file');
}
const hash_buffer = await crypto.subtle.digest('SHA-256', file_reader.result);
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_buffer = await crypto.subtle.digest('SHA-256', file_reader.result);
const hash_array = Array.from(new Uint8Array(hash_buffer));
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);
});
};

View File

@@ -1,43 +1,43 @@
/* Returns a list of objects that have a matching property value. */
// Updated 2023-06-28
export const get_obj_li_w_match_prop = function get_obj_li_w_match_prop({
obj_li,
property,
value,
log_lvl = 0
obj_li,
property,
value,
log_lvl = 0
}: {
obj_li: any[];
property: string;
value: any;
log_lvl?: number;
obj_li: any[];
property: string;
value: any;
log_lvl?: number;
}) {
if (log_lvl) {
console.log('Search Object List:', obj_li);
console.log(`Property: ${property}`);
console.log(`Value: ${value}`);
}
if (log_lvl > 1) {
console.log(`Type Of: ${typeof value}`);
}
if (log_lvl) {
console.log('Search Object List:', obj_li);
console.log(`Property: ${property}`);
console.log(`Value: ${value}`);
}
if (log_lvl > 1) {
console.log(`Type Of: ${typeof value}`);
}
// Create an empty array to store the matching objects.
const matching_obj_li = [];
// Create an empty array to store the matching objects.
const matching_obj_li = [];
// Iterate through the list of objects.
for (const object of obj_li) {
// Check if the object has the specified property and the value of the property matches the specified value.
if (object.hasOwnProperty(property)) {
// console.log('Has property at least....', object[property], typeof object[property]);
}
if (object.hasOwnProperty(property) && object[property] === value) {
// Add the object to the array of matching objects.
matching_obj_li.push(object);
}
}
// Iterate through the list of objects.
for (const object of obj_li) {
// Check if the object has the specified property and the value of the property matches the specified value.
if (object.hasOwnProperty(property)) {
// console.log('Has property at least....', object[property], typeof object[property]);
}
if (object.hasOwnProperty(property) && object[property] === value) {
// Add the object to the array of matching objects.
matching_obj_li.push(object);
}
}
// Return the array of matching objects.
if (log_lvl > 1) {
console.log('Matching Object List:', matching_obj_li);
}
return matching_obj_li;
// Return the array of matching objects.
if (log_lvl > 1) {
console.log('Matching Object List:', matching_obj_li);
}
return matching_obj_li;
};

View File

@@ -1,26 +1,26 @@
// Function to check if the file (or anything) timestamp was created within the last X minutes
export const is_datetime_recent = function is_datetime_recent({
datetime,
minutes,
log_lvl = 0
datetime,
minutes,
log_lvl = 0
}: {
datetime: string;
minutes: number;
log_lvl?: number;
datetime: string;
minutes: number;
log_lvl?: number;
}) {
if (log_lvl) {
console.log(`*** is_datetime_recent() *** datetime=${datetime} minutes=${minutes}`);
}
if (log_lvl) {
console.log(`*** is_datetime_recent() *** datetime=${datetime} minutes=${minutes}`);
}
const now: any = new Date();
const then: any = new Date(datetime);
const now: any = new Date();
const then: any = new Date(datetime);
const diff = now - then;
const diff_minutes = Math.floor(diff / 60000);
const diff = now - then;
const diff_minutes = Math.floor(diff / 60000);
if (diff_minutes < minutes) {
return true;
} else {
return false;
}
if (diff_minutes < minutes) {
return true;
} else {
return false;
}
};

View File

@@ -1,199 +1,199 @@
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.
export const process_permission_checks = function process_permission_checks(access_type: string) {
// let access_checks = { 'access_type': null, 'super_check': null };
const access_checks: key_val = {};
// let access_checks = { 'access_type': null, 'super_check': null };
const access_checks: key_val = {};
if (access_type == 'super') {
access_checks.allow_access = true;
access_checks.access_type = 'super';
if (access_type == 'super') {
access_checks.allow_access = true;
access_checks.access_type = 'super';
access_checks.super_check = true;
access_checks.manager_check = false;
access_checks.administrator_check = false;
access_checks.support_check = false;
access_checks.assistant_check = false;
access_checks.trusted_check = false;
access_checks.verified_check = false;
access_checks.provisional_check = false;
access_checks.public_check = false;
access_checks.authenticated_check = true;
access_checks.anonymous_check = false;
access_checks.super_check = true;
access_checks.manager_check = false;
access_checks.administrator_check = false;
access_checks.support_check = false;
access_checks.assistant_check = false;
access_checks.trusted_check = false;
access_checks.verified_check = false;
access_checks.provisional_check = false;
access_checks.public_check = false;
access_checks.authenticated_check = true;
access_checks.anonymous_check = false;
access_checks.super_access = true;
access_checks.manager_access = true;
access_checks.administrator_access = true;
access_checks.support_access = true;
access_checks.assistant_access = true;
access_checks.trusted_access = true;
access_checks.verified_access = true;
access_checks.provisional_access = true;
access_checks.public_access = true;
access_checks.authenticated_access = true;
access_checks.anonymous_access = true;
} else if (access_type == 'manager') {
access_checks.allow_access = true;
access_checks.access_type = 'manager';
access_checks.super_access = true;
access_checks.manager_access = true;
access_checks.administrator_access = true;
access_checks.support_access = true;
access_checks.assistant_access = true;
access_checks.trusted_access = true;
access_checks.verified_access = true;
access_checks.provisional_access = true;
access_checks.public_access = true;
access_checks.authenticated_access = true;
access_checks.anonymous_access = true;
} else if (access_type == 'manager') {
access_checks.allow_access = true;
access_checks.access_type = 'manager';
access_checks.super_check = false;
access_checks.manager_check = true;
access_checks.administrator_check = false;
access_checks.support_check = false;
access_checks.assistant_check = false;
access_checks.trusted_check = false;
access_checks.verified_check = false;
access_checks.provisional_check = false;
access_checks.public_check = false;
access_checks.authenticated_check = true;
access_checks.anonymous_check = false;
access_checks.super_check = false;
access_checks.manager_check = true;
access_checks.administrator_check = false;
access_checks.support_check = false;
access_checks.assistant_check = false;
access_checks.trusted_check = false;
access_checks.verified_check = false;
access_checks.provisional_check = false;
access_checks.public_check = false;
access_checks.authenticated_check = true;
access_checks.anonymous_check = false;
access_checks.super_access = false;
access_checks.manager_access = true;
access_checks.administrator_access = true;
access_checks.support_access = true;
access_checks.assistant_access = true;
access_checks.trusted_access = true;
access_checks.verified_access = true;
access_checks.provisional_access = true;
access_checks.public_access = true;
access_checks.authenticated_access = true;
access_checks.anonymous_access = true;
} else if (access_type == 'administrator') {
access_checks.allow_access = true;
access_checks.access_type = 'administrator';
access_checks.super_access = false;
access_checks.manager_access = true;
access_checks.administrator_access = true;
access_checks.support_access = true;
access_checks.assistant_access = true;
access_checks.trusted_access = true;
access_checks.verified_access = true;
access_checks.provisional_access = true;
access_checks.public_access = true;
access_checks.authenticated_access = true;
access_checks.anonymous_access = true;
} else if (access_type == 'administrator') {
access_checks.allow_access = true;
access_checks.access_type = 'administrator';
access_checks.super_check = false;
access_checks.manager_check = false;
access_checks.administrator_check = true;
access_checks.support_check = false;
access_checks.assistant_check = false;
access_checks.trusted_check = false;
access_checks.verified_check = false;
access_checks.provisional_check = false;
access_checks.public_check = false;
access_checks.authenticated_check = false;
access_checks.anonymous_check = false;
access_checks.super_check = false;
access_checks.manager_check = false;
access_checks.administrator_check = true;
access_checks.support_check = false;
access_checks.assistant_check = false;
access_checks.trusted_check = false;
access_checks.verified_check = false;
access_checks.provisional_check = false;
access_checks.public_check = false;
access_checks.authenticated_check = false;
access_checks.anonymous_check = false;
access_checks.super_access = false;
access_checks.manager_access = false;
access_checks.administrator_access = true;
access_checks.support_access = true;
access_checks.assistant_access = true;
access_checks.trusted_access = true;
access_checks.verified_access = true;
access_checks.provisional_access = true;
access_checks.public_access = true;
access_checks.authenticated_access = true;
access_checks.anonymous_access = true;
} else if (access_type == 'trusted') {
access_checks.allow_access = true; // Should this be true?? -2024-10-03
access_checks.access_type = 'trusted';
access_checks.super_access = false;
access_checks.manager_access = false;
access_checks.administrator_access = true;
access_checks.support_access = true;
access_checks.assistant_access = true;
access_checks.trusted_access = true;
access_checks.verified_access = true;
access_checks.provisional_access = true;
access_checks.public_access = true;
access_checks.authenticated_access = true;
access_checks.anonymous_access = true;
} else if (access_type == 'trusted') {
access_checks.allow_access = true; // Should this be true?? -2024-10-03
access_checks.access_type = 'trusted';
access_checks.super_check = false;
access_checks.manager_check = false;
access_checks.administrator_check = false;
access_checks.support_check = false;
access_checks.assistant_check = false;
access_checks.trusted_check = true;
access_checks.verified_check = false;
access_checks.provisional_check = false;
access_checks.public_check = false;
access_checks.authenticated_check = true;
access_checks.anonymous_check = false;
access_checks.super_check = false;
access_checks.manager_check = false;
access_checks.administrator_check = false;
access_checks.support_check = false;
access_checks.assistant_check = false;
access_checks.trusted_check = true;
access_checks.verified_check = false;
access_checks.provisional_check = false;
access_checks.public_check = false;
access_checks.authenticated_check = true;
access_checks.anonymous_check = false;
access_checks.super_access = false;
access_checks.manager_access = false;
access_checks.administrator_access = false;
access_checks.support_access = false;
access_checks.assistant_access = false;
access_checks.trusted_access = true;
access_checks.verified_access = true;
access_checks.provisional_access = true;
access_checks.public_access = true;
access_checks.authenticated_access = true;
access_checks.anonymous_access = true;
} else if (access_type == 'public') {
access_checks.access_type = 'public';
access_checks.super_access = false;
access_checks.manager_access = false;
access_checks.administrator_access = false;
access_checks.support_access = false;
access_checks.assistant_access = false;
access_checks.trusted_access = true;
access_checks.verified_access = true;
access_checks.provisional_access = true;
access_checks.public_access = true;
access_checks.authenticated_access = true;
access_checks.anonymous_access = true;
} else if (access_type == 'public') {
access_checks.access_type = 'public';
access_checks.super_check = false;
access_checks.manager_check = false;
access_checks.administrator_check = false;
access_checks.support_check = false;
access_checks.assistant_check = false;
access_checks.trusted_check = false;
access_checks.verified_check = false;
access_checks.provisional_check = false;
access_checks.public_check = true;
access_checks.authenticated_check = false;
access_checks.anonymous_check = false;
access_checks.super_check = false;
access_checks.manager_check = false;
access_checks.administrator_check = false;
access_checks.support_check = false;
access_checks.assistant_check = false;
access_checks.trusted_check = false;
access_checks.verified_check = false;
access_checks.provisional_check = false;
access_checks.public_check = true;
access_checks.authenticated_check = false;
access_checks.anonymous_check = false;
access_checks.super_access = false;
access_checks.manager_access = false;
access_checks.administrator_access = false;
access_checks.support_access = false;
access_checks.assistant_access = false;
access_checks.trusted_access = false;
access_checks.verified_access = false;
access_checks.provisional_access = false;
access_checks.public_access = true;
access_checks.authenticated_access = true;
access_checks.anonymous_access = true;
} else if (access_type == 'authenticated') {
access_checks.access_type = 'authenticated';
access_checks.super_access = false;
access_checks.manager_access = false;
access_checks.administrator_access = false;
access_checks.support_access = false;
access_checks.assistant_access = false;
access_checks.trusted_access = false;
access_checks.verified_access = false;
access_checks.provisional_access = false;
access_checks.public_access = true;
access_checks.authenticated_access = true;
access_checks.anonymous_access = true;
} else if (access_type == 'authenticated') {
access_checks.access_type = 'authenticated';
access_checks.super_check = false;
access_checks.manager_check = false;
access_checks.administrator_check = false;
access_checks.support_check = false;
access_checks.assistant_check = false;
access_checks.trusted_check = false;
access_checks.verified_check = false;
access_checks.provisional_check = false;
access_checks.public_check = false;
access_checks.authenticated_check = true;
access_checks.anonymous_check = false;
access_checks.super_check = false;
access_checks.manager_check = false;
access_checks.administrator_check = false;
access_checks.support_check = false;
access_checks.assistant_check = false;
access_checks.trusted_check = false;
access_checks.verified_check = false;
access_checks.provisional_check = false;
access_checks.public_check = false;
access_checks.authenticated_check = true;
access_checks.anonymous_check = false;
access_checks.super_access = false;
access_checks.manager_access = false;
access_checks.administrator_access = false;
access_checks.support_access = false;
access_checks.assistant_access = false;
access_checks.trusted_access = false;
access_checks.verified_access = false;
access_checks.provisional_access = false;
access_checks.public_access = false;
access_checks.authenticated_access = true;
access_checks.anonymous_access = true;
} else {
access_checks.access_type = 'anonymous';
access_checks.super_access = false;
access_checks.manager_access = false;
access_checks.administrator_access = false;
access_checks.support_access = false;
access_checks.assistant_access = false;
access_checks.trusted_access = false;
access_checks.verified_access = false;
access_checks.provisional_access = false;
access_checks.public_access = false;
access_checks.authenticated_access = true;
access_checks.anonymous_access = true;
} else {
access_checks.access_type = 'anonymous';
access_checks.super_check = false;
access_checks.manager_check = false;
access_checks.administrator_check = false;
access_checks.support_check = false;
access_checks.assistant_check = false;
access_checks.trusted_check = false;
access_checks.verified_check = false;
access_checks.provisional_check = false;
access_checks.public_check = false;
access_checks.authenticated_check = false;
access_checks.anonymous_check = true;
access_checks.super_check = false;
access_checks.manager_check = false;
access_checks.administrator_check = false;
access_checks.support_check = false;
access_checks.assistant_check = false;
access_checks.trusted_check = false;
access_checks.verified_check = false;
access_checks.provisional_check = false;
access_checks.public_check = false;
access_checks.authenticated_check = false;
access_checks.anonymous_check = true;
access_checks.super_access = false;
access_checks.manager_access = false;
access_checks.administrator_access = false;
access_checks.support_access = false;
access_checks.assistant_access = false;
access_checks.trusted_access = false;
access_checks.verified_access = false;
access_checks.provisional_access = false;
access_checks.public_access = false;
access_checks.authenticated_access = false;
access_checks.anonymous_access = true;
}
access_checks.super_access = false;
access_checks.manager_access = false;
access_checks.administrator_access = false;
access_checks.support_access = false;
access_checks.assistant_access = false;
access_checks.trusted_access = false;
access_checks.verified_access = false;
access_checks.provisional_access = false;
access_checks.public_access = false;
access_checks.authenticated_access = false;
access_checks.anonymous_access = true;
}
return access_checks;
return access_checks;
};

View File

@@ -18,73 +18,73 @@ import type { key_val } from './ae_utils';
// 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;
}
console.log('*** process_data_string() ***');
// console.log(data_string);
if (!data_string || data_string.length < 1) {
console.log('No data string found.');
return false;
}
const obj: key_val = {};
const 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);
const colon_index = data_string.indexOf(':');
if (colon_index) {
const data_string_type = data_string.slice(0, colon_index);
console.log(data_string_type);
obj['qr_type'] = 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') {
const mecard_str = data_string.slice(colon_index + 1);
console.log(mecard_str);
obj['str'] = mecard_str;
} else if (data_string_type == 'OBJ') {
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;
} else if (data_string_type == 'OBJ') {
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['json'] = JSON.parse(json_str);
} else if (data_string_type == 'STR') {
const str = data_string.slice(colon_index + 1);
console.log(str);
obj['json'] = JSON.parse(json_str);
} else if (data_string_type == 'STR') {
const str = data_string.slice(colon_index + 1);
console.log(str);
obj['str'] = str;
} else if (data_string_type == 'http' || data_string_type == 'https') {
console.log(`http or https: ${data_string}`);
obj['str'] = str;
} else if (data_string_type == 'http' || data_string_type == 'https') {
console.log(`http or https: ${data_string}`);
obj['type'] = 'url';
obj['url'] = data_string;
} else {
console.log('The unknown data string type was found. Returning the string part.');
const unknown_str = data_string.slice(colon_index + 1);
console.log(unknown_str);
obj['type'] = 'url';
obj['url'] = 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['str'] = unknown_str;
}
} else {
console.log('The data string type was not found. Returning the entire string.');
console.log(data_string);
obj['str'] = unknown_str;
}
} else {
console.log('The data string type was not found. Returning the entire string.');
console.log(data_string);
obj['qr_type'] = 'UNKNOWN';
obj['str'] = data_string;
// return false;
}
obj['qr_type'] = 'UNKNOWN';
obj['str'] = data_string;
// return false;
}
console.log(obj);
return obj; // Returns an object
console.log(obj);
return obj; // Returns an object
};

View File

@@ -1,87 +1,87 @@
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;
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'
];
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'
];
const known_obj_type_li_dict = [
{ name: 'account', display: 'Account', path: 'account' },
{ name: 'archive', display: 'Archive', path: 'archive' },
{ name: 'address', display: 'Address', path: 'address' },
{ name: 'archive', display: 'Archive', path: 'archive' },
{ name: 'archive_content', display: 'Archive Content', path: 'archive/content' },
{ name: 'contact', display: 'Contact', path: 'contact' },
{ name: 'data_store', display: 'Data Store', path: 'data_store' },
{ name: 'event_abstract', display: 'Event Abstract', path: 'event/abstract' },
{ name: 'event_badge', display: 'Event Badge', path: 'event/badge' },
{ name: 'event_device', display: 'Event Device', path: 'event/device' },
{ name: 'event_exhibit', display: 'Event Exhibit', path: 'event/exhibit' },
{ name: 'event_file', display: 'Event File', path: 'event/file' },
{ name: 'event_location', display: 'Event Location', path: 'event/location' },
{ name: 'event_person', display: 'Event Person', path: 'event/person' },
{ name: 'event_presentation', display: 'Event Presentation', path: 'event/' },
{ name: 'event_presenter', display: 'Event Presenter', path: 'event/presenter' },
{ name: 'event_registration', display: 'Event Registration', path: 'event/registration' },
{ name: 'event_session', display: 'Event Session', path: 'event/session' },
{ name: 'event', display: 'Event', path: 'event' },
{ name: 'hosted_file', display: 'Hosted File', path: 'hosted_file' },
{ name: 'journal', display: 'Journal', path: 'journal' },
{ name: 'journal_entry', display: 'Journal Entry', path: 'journal/entry' },
{ name: 'order_line', display: 'Order Line', path: 'order/line' },
{ name: 'order', display: 'Order', path: 'order' },
{ name: 'person', display: 'Person', path: 'person' },
{ name: 'post', display: 'Archive', path: 'post' },
{ name: 'post_comment', display: 'Archive Content', path: 'post/comment' },
{ name: 'user', display: 'User', path: 'user' }
];
const known_obj_type_li_dict = [
{ name: 'account', display: 'Account', path: 'account' },
{ name: 'archive', display: 'Archive', path: 'archive' },
{ name: 'address', display: 'Address', path: 'address' },
{ name: 'archive', display: 'Archive', path: 'archive' },
{ name: 'archive_content', display: 'Archive Content', path: 'archive/content' },
{ name: 'contact', display: 'Contact', path: 'contact' },
{ name: 'data_store', display: 'Data Store', path: 'data_store' },
{ name: 'event_abstract', display: 'Event Abstract', path: 'event/abstract' },
{ name: 'event_badge', display: 'Event Badge', path: 'event/badge' },
{ name: 'event_device', display: 'Event Device', path: 'event/device' },
{ name: 'event_exhibit', display: 'Event Exhibit', path: 'event/exhibit' },
{ name: 'event_file', display: 'Event File', path: 'event/file' },
{ name: 'event_location', display: 'Event Location', path: 'event/location' },
{ name: 'event_person', display: 'Event Person', path: 'event/person' },
{ name: 'event_presentation', display: 'Event Presentation', path: 'event/' },
{ name: 'event_presenter', display: 'Event Presenter', path: 'event/presenter' },
{ name: 'event_registration', display: 'Event Registration', path: 'event/registration' },
{ name: 'event_session', display: 'Event Session', path: 'event/session' },
{ name: 'event', display: 'Event', path: 'event' },
{ name: 'hosted_file', display: 'Hosted File', path: 'hosted_file' },
{ name: 'journal', display: 'Journal', path: 'journal' },
{ name: 'journal_entry', display: 'Journal Entry', path: 'journal/entry' },
{ name: 'order_line', display: 'Order Line', path: 'order/line' },
{ name: 'order', display: 'Order', path: 'order' },
{ name: 'person', display: 'Person', path: 'person' },
{ name: 'post', display: 'Archive', path: 'post' },
{ name: 'post_comment', display: 'Archive Content', path: 'post/comment' },
{ name: 'user', display: 'User', path: 'user' }
];
if (obj_type) {
// Need to loop through known for safety?
obj_type_path = obj_type_prop_name.replaceAll('_', '/');
} else if (obj_type_prop_name) {
let found_obj_type_name = null;
let found_obj_type_path = null;
if (obj_type) {
// Need to loop through known for safety?
obj_type_path = obj_type_prop_name.replaceAll('_', '/');
} else if (obj_type_prop_name) {
let found_obj_type_name = null;
let found_obj_type_path = null;
for (let i = 0; i < known_obj_type_li_dict.length; i++) {
// console.log(known_obj_type_li_dict[i]);
// let guessed_obj_type = prop_name.startsWith(known_obj_type_li_dict[i]
if (obj_type_prop_name.startsWith(known_obj_type_li_dict[i].name)) {
console.log(`Found ${known_obj_type_li_dict[i].name}`);
found_obj_type_name = known_obj_type_li_dict[i].name;
found_obj_type_path = known_obj_type_li_dict[i].path;
// obj_type_path = obj_type_prop_name.replaceAll('_', '/');
obj_type_path = found_obj_type_path;
break;
}
}
} else {
console.log('Missing required parameters');
return false;
}
for (let i = 0; i < known_obj_type_li_dict.length; i++) {
// console.log(known_obj_type_li_dict[i]);
// let guessed_obj_type = prop_name.startsWith(known_obj_type_li_dict[i]
if (obj_type_prop_name.startsWith(known_obj_type_li_dict[i].name)) {
console.log(`Found ${known_obj_type_li_dict[i].name}`);
found_obj_type_name = known_obj_type_li_dict[i].name;
found_obj_type_path = known_obj_type_li_dict[i].path;
// obj_type_path = obj_type_prop_name.replaceAll('_', '/');
obj_type_path = found_obj_type_path;
break;
}
}
} else {
console.log('Missing required parameters');
return false;
}
return obj_type_path;
return obj_type_path;
}

View File

@@ -2,123 +2,123 @@ import { to_title_case } from './ae_utils__to_title_case';
// Updated 2023-08-18
export function set_obj_prop_display_name({
prop_name,
obj_type = null,
prefix_w_obj_type = true,
prefix_all_w_obj_type = false,
replace_underscores = true,
title_case = true,
override = null
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() ***');
console.log('*** set_obj_prop_display_name() ***');
if (override) {
return override;
}
if (override) {
return override;
}
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 = [
'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' }
];
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 prop_display_name = prop_name;
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) {
if (obj_type) {
prop_display_name = prop_name.replace(obj_type, '');
} else {
for (let i = 0; i < known_obj_type_li_dict.length; i++) {
// console.log(known_obj_type_li_dict[i]);
if (prop_name.startsWith(known_obj_type_li_dict[i].name)) {
// console.log(`Found ${known_obj_type_li_dict[i].name}`);
prop_display_name = prop_name.replace(known_obj_type_li_dict[i].name, '');
break;
}
}
// for (let i = 0; i < known_obj_type_li.length; i++) {
// // console.log(known_obj_type_li[i]);
// if (prop_name.startsWith(known_obj_type_li[i])) {
// console.log(`Found ${known_obj_type_li[i]}`);
// prop_display_name = prop_name.replace(known_obj_type_li[i], '');
// break;
// }
// }
}
} else {
if (!prefix_all_w_obj_type) {
for (let i = 0; i < known_obj_type_li.length; i++) {
// console.log(known_obj_type_li[i]);
let found_obj_type = null;
// for (let i = 0; i < known_obj_type_li.length; i++) {
// // console.log(known_obj_type_li[i]);
// if (prop_name.startsWith(known_obj_type_li[i])) {
// console.log(`Found ${known_obj_type_li[i]}`);
// prop_display_name = prop_name.replace(known_obj_type_li[i], '');
// break;
// }
// }
}
} else {
if (!prefix_all_w_obj_type) {
for (let i = 0; i < known_obj_type_li.length; i++) {
// console.log(known_obj_type_li[i]);
let found_obj_type = null;
if (prop_name.startsWith(known_obj_type_li_dict[i].name)) {
// if (prop_name.startsWith(known_obj_type_li[i])) {
// console.log(`Found ${known_obj_type_li_dict[i].name}`);
found_obj_type = known_obj_type_li_dict[i].name;
if (found_obj_type == obj_type) {
prop_display_name = prop_name.replace(known_obj_type_li_dict[i].name, '');
}
if (prop_name.startsWith(known_obj_type_li_dict[i].name)) {
// if (prop_name.startsWith(known_obj_type_li[i])) {
// console.log(`Found ${known_obj_type_li_dict[i].name}`);
found_obj_type = known_obj_type_li_dict[i].name;
if (found_obj_type == obj_type) {
prop_display_name = prop_name.replace(known_obj_type_li_dict[i].name, '');
}
break;
}
}
break;
}
}
// if (obj_type) {
// prop_display_name = prop_name.replace(obj_type, '');
// } else {
}
}
// if (obj_type) {
// prop_display_name = prop_name.replace(obj_type, '');
// } else {
}
}
// console.log(prop_display_name);
if (prop_display_name.search('ID')) {
}
prop_display_name = prop_display_name.replace('id_random', 'ID');
// console.log(prop_display_name);
if (prop_display_name.search('ID')) {
}
prop_display_name = prop_display_name.replace('id_random', 'ID');
if (replace_underscores) {
prop_display_name = prop_display_name.replaceAll('_', ' ');
}
if (replace_underscores) {
prop_display_name = prop_display_name.replaceAll('_', ' ');
}
if (title_case) {
prop_display_name = to_title_case(prop_display_name);
}
if (title_case) {
prop_display_name = to_title_case(prop_display_name);
}
// console.log(prop_display_name);
return prop_display_name;
// console.log(prop_display_name);
return prop_display_name;
}

View File

@@ -1,43 +1,44 @@
/* Adapted from: To Title Case © 2018 David Gouch | https://github.com/gouch/to-title-case */
export function to_title_case(text_string) {
// console.log('*** to_title_case() ***');
const smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|v.?|vs.?|via)$/i;
const alphanumericPattern = /([A-Za-z0-9\u00C0-\u00FF])/;
const wordSeparators = /([ :–—-])/;
// console.log('*** to_title_case() ***');
const smallWords =
/^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|v.?|vs.?|via)$/i;
const alphanumericPattern = /([A-Za-z0-9\u00C0-\u00FF])/;
const wordSeparators = /([ :–—-])/;
return text_string
.split(wordSeparators)
.map(function (current, index, array) {
if (
/* Check for small words */
current.search(smallWords) > -1 &&
/* Skip first and last word */
index !== 0 &&
index !== array.length - 1 &&
/* Ignore title end and subtitle start */
array[index - 3] !== ':' &&
array[index + 1] !== ':' &&
/* Ignore small words that start a hyphenated phrase */
(array[index + 1] !== '-' || (array[index - 1] === '-' && array[index + 1] === '-'))
) {
return current.toLowerCase();
}
return text_string
.split(wordSeparators)
.map(function (current, index, array) {
if (
/* Check for small words */
current.search(smallWords) > -1 &&
/* Skip first and last word */
index !== 0 &&
index !== array.length - 1 &&
/* Ignore title end and subtitle start */
array[index - 3] !== ':' &&
array[index + 1] !== ':' &&
/* Ignore small words that start a hyphenated phrase */
(array[index + 1] !== '-' || (array[index - 1] === '-' && array[index + 1] === '-'))
) {
return current.toLowerCase();
}
/* Ignore intentional capitalization */
if (current.substr(1).search(/[A-Z]|\../) > -1) {
return current;
}
/* Ignore intentional capitalization */
if (current.substr(1).search(/[A-Z]|\../) > -1) {
return current;
}
/* Ignore URLs */
if (array[index + 1] === ':' && array[index + 2] !== '') {
return current;
}
/* Ignore URLs */
if (array[index + 1] === ':' && array[index + 2] !== '') {
return current;
}
/* Capitalize the first letter */
return current.replace(alphanumericPattern, function (match) {
return match.toUpperCase();
});
})
.join('');
/* Capitalize the first letter */
return current.replace(alphanumericPattern, function (match) {
return match.toUpperCase();
});
})
.join('');
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,25 +1,25 @@
<script lang="ts">
export let log_lvl: number = 0;
export let log_lvl: number = 0;
export let site_google_tracking_id: string = '';
if (log_lvl) {
console.log(`AE Analytics: site_google_tracking_id = `, site_google_tracking_id);
}
export let site_google_tracking_id: string = '';
if (log_lvl) {
console.log(`AE Analytics: site_google_tracking_id = `, site_google_tracking_id);
}
if (typeof window !== 'undefined') {
window.dataLayer = window.dataLayer || [];
window.gtag = function gtag(): void {
window.dataLayer.push(arguments);
};
window.gtag('js', new Date());
window.gtag('config', site_google_tracking_id);
if (log_lvl) {
console.log(`AE Analytics: Google Analytics Tracking ID = `, site_google_tracking_id);
}
}
if (typeof window !== 'undefined') {
window.dataLayer = window.dataLayer || [];
window.gtag = function gtag(): void {
window.dataLayer.push(arguments);
};
window.gtag('js', new Date());
window.gtag('config', site_google_tracking_id);
if (log_lvl) {
console.log(`AE Analytics: Google Analytics Tracking ID = `, site_google_tracking_id);
}
}
</script>
<svelte:head>
<script async src="https://www.googletagmanager.com/gtag/js?id={site_google_tracking_id}">
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id={site_google_tracking_id}">
</script>
</svelte:head>

View File

@@ -1,299 +1,303 @@
<script lang="ts">
// *** Import Svelte specific
import { onDestroy, onMount, tick } from 'svelte';
import { afterNavigate } from '$app/navigation';
// *** 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 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";
// *** 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;
// 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;
}
// *** 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 {
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 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);
// let trigger: null|string|boolean = null;
let trigger: null | string | boolean = $state(null);
// const dispatch = createEventDispatcher();
// 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;
// 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();
});
// /** @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');
}
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;
// Clean up any references or listeners if needed
entered_passcode = null; // Clear the entered passcode
show_passcode_input = false;
// Reset trigger
trigger = null;
});
// Reset trigger
trigger = null;
});
// afterNavigate(() => {
// /** @type {HTMLElement | null} */
// const to_focus = document.getElementById('access_passcode_input');
// to_focus?.focus();
// });
// 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 (
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}`);
}
$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);
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`);
}
$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('');
// 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;
}
});
$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();
}
});
// 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();
}
});
$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
);
}
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
// 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');
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');
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');
$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');
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');
$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');
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');
$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');
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');
$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');
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');
$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');
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.');
}
$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');
if ($ae_loc.access_type != 'anonymous') {
console.log('Access type is not anonymous');
}
// window.localStorage.setItem('access_type', 'anonymous');
// $ae_loc.access_type = 'anonymous';
// $ae_loc.access_type = 'anonymous';
// trigger = 'process_permission_check';
// trigger = 'process_permission_check';
// $ae_loc = $ae_loc; // Trigger Svelte just in case
// ae_loc.set($ae_loc);
// console.log($ae_loc);
// $ae_loc = $ae_loc; // Trigger Svelte just in case
// ae_loc.set($ae_loc);
// console.log($ae_loc);
// dispatch_access_type_changed();
// dispatch_access_type_changed();
return false;
}
return false;
}
entered_passcode = '';
trigger = 'process_permission_check';
entered_passcode = '';
trigger = 'process_permission_check';
$ae_loc.app_cfg.show_element__menu = false;
$ae_loc.app_cfg.show_element__menu_btn = true;
$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;
}
// 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();
// dispatch_access_type_changed();
return true;
} else {
if (log_lvl > 1) {
console.log('Entered passcode too short.');
}
return true;
} else {
if (log_lvl > 1) {
console.log('Entered passcode too short.');
}
// $ae_loc.access_type = null; // 'anonymous';
// $ae_loc.access_type = null; // 'anonymous';
// dispatch_access_type_changed()
// dispatch_access_type_changed()
return null;
}
}
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');
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';
// $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;
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.app_cfg.show_element__menu = false;
$ae_loc.app_cfg.show_element__menu_btn = true;
$ae_loc.edit_mode = false;
$ae_loc.edit_mode = false;
return true;
}
return true;
}
</script>
<section
id="AE-Quick-Access-Type"
class="
id="AE-Quick-Access-Type"
class="
ae_access_type
hidden-print
@@ -310,15 +314,15 @@
duration-300 delay-150 hover:delay-1000 hover:ease-out
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} -->
<header 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'}
<!-- Show list of authorized sessions and presentations for a user -->
<!-- {#if $ae_loc.access_type == 'administrator'}
{#if $events_loc.auth__kv.session}
Sessions:
<ul>
@@ -331,53 +335,53 @@
{/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">
{#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;
$ae_loc.lock_config = false;
$events_loc.pres_mgmt.lock_config = false;
$ae_loc.lock_config = false;
$events_loc.pres_mgmt.lock_config = false;
// dispatch_sync_local_config_changed();
// 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();
// 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;
$ae_loc.lock_config = true;
$events_loc.pres_mgmt.lock_config = true;
$ae_loc.lock_config = true;
$events_loc.pres_mgmt.lock_config = true;
// dispatch_sync_local_config_changed();
// 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();
// 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}
<!-- {#if $ae_loc.edit_mode}
<button
type="button"
onclick={() => {
@@ -407,127 +411,130 @@
</span>
</button>
{/if} -->
{/if}
</div>
{/if}
</div>
<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>
<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>
<span class="fas fa-unlock mx-1 unlock_icon hidden"></span>
{#if show_passcode_input}
<span class="unlock_text">Cancel</span>
{:else}
<span class="unlock_text">Access?</span>
{/if}
</button>
</span>
{/if}
<span class="fas fa-unlock mx-1 unlock_icon hidden"></span>
{#if show_passcode_input}
<span class="unlock_text">Cancel</span>
{:else}
<span class="unlock_text">Access?</span>
{/if}
</button>
</span>
{/if}
{#if $ae_loc?.access_type && $ae_loc?.access_type != 'anonymous'}
<span class="flex flex-row gap-1 items-center justify-center">
<!-- <span class="fas fa-unlock mx-1"></span> -->
<ShieldPlus class="inline-block" />
{#if $ae_loc?.access_type && $ae_loc?.access_type != 'anonymous'}
<span class="flex flex-row gap-1 items-center justify-center">
<!-- <span class="fas fa-unlock mx-1"></span> -->
<ShieldPlus class="inline-block" />
<span class="*:hover:inline" title={`Current access type/level: ${$ae_loc.access_type}`}>
{#if $ae_loc.access_type == 'super'}
<span class="fas fa-hat-wizard m-1"></span>
<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
class="*:hover:inline"
title={`Current access type/level: ${$ae_loc.access_type}`}
>
{#if $ae_loc.access_type == 'super'}
<span class="fas fa-hat-wizard m-1"></span>
<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>
{#if $ae_loc?.user_access_type && $ae_loc?.access_type == $ae_loc?.user_access_type && !show_passcode_input}
<button
type="button"
onclick={() => {
// handle_clear_access();
// trigger_clear_access = true;
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 $ae_loc?.user_access_type && $ae_loc?.access_type == $ae_loc?.user_access_type && !show_passcode_input}
<button
type="button"
onclick={() => {
// handle_clear_access();
// trigger_clear_access = true;
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}
<span class="flex flex-row gap-1 items-center justify-between w-full">
<span>
<ShieldEllipsis class="inline-block text-gray-500" />
<span class="unlock_text text-sm">Passcode:</span>
</span>
{#if show_passcode_input}
<span class="flex flex-row gap-1 items-center justify-between w-full">
<span>
<ShieldEllipsis class="inline-block text-gray-500" />
<span class="unlock_text text-sm">Passcode:</span>
</span>
<!-- svelte-ignore a11y_autofocus -->
<input
id="access_passcode_input"
bind:value={entered_passcode}
class="input w-32 transition-all"
class:hidden={!show_passcode_input}
type="text"
placeholder="Passcode"
autofocus={show_passcode_input}
/>
<!-- <div class="current_text transition-all">{$ae_loc.access_type}</div> -->
</span>
{/if}
</div>
<!-- svelte-ignore a11y_autofocus -->
<input
id="access_passcode_input"
bind:value={entered_passcode}
class="input w-32 transition-all"
class:hidden={!show_passcode_input}
type="text"
placeholder="Passcode"
autofocus={show_passcode_input}
/>
<!-- <div class="current_text transition-all">{$ae_loc.access_type}</div> -->
</span>
{/if}
</div>
</section>
<style lang="scss">
/* BEGIN: AE's Svelte Quick Access Type component */
/*
/* BEGIN: AE's Svelte Quick Access Type component */
/*
#xxx-AE-Quick-Access-Type {
// position: absolute;
position: fixed;
@@ -565,7 +572,7 @@
}
*/
/*
/*
#xxx-AE-Quick-Access-Type:hover {
border-top: solid thin hsla(0,0%,0%,.95);
@@ -582,29 +589,29 @@
}
*/
/* #Access-Type .unlock_text {
/* #Access-Type .unlock_text {
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 {
display: none;
}
.access_type_unlock_btn:hover .lock_icon {
display: none;
}
.access_type_unlock_btn:hover .unlock_icon {
display: initial;
}
.access_type_unlock_btn:hover .unlock_icon {
display: initial;
}
.access_type_unlock_btn .unlock_text {
display: none;
}
.access_type_unlock_btn .unlock_text {
display: none;
}
.access_type_unlock_btn:hover .unlock_text {
display: initial;
/* outline: solid thin red; */
}
.access_type_unlock_btn:hover .unlock_text {
display: initial;
/* outline: solid thin red; */
}
/*
/*
.ae_access_type .current_text {
display: none;
}

View File

@@ -1,109 +1,109 @@
<script lang="ts">
import { Settings } from '@lucide/svelte';
import { Settings } from '@lucide/svelte';
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 { ae_util } from '$lib/ae_utils/ae_utils';
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/stores/ae_stores';
// import Element_theme from '$lib/e_app_theme.svelte';
// import Element_theme from '$lib/e_app_theme.svelte';
let notes: null | string = null;
let all: boolean = false;
let notes: null | string = null;
let all: boolean = false;
interface Props {
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 {
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;
}
let {
log_lvl = $bindable(0),
hide = $bindable(false),
expand = $bindable(false)
// set_theme_mode = null,
// set_theme_name = null
}: Props = $props();
let {
log_lvl = $bindable(0),
hide = $bindable(false),
expand = $bindable(false)
// set_theme_mode = null,
// set_theme_name = null
}: Props = $props();
// const dispatch = createEventDispatcher();
// 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';
// }
// });
// 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');
// }
// }
// $: 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');
// }
// }
// $: if ($slct_trigger == 'set_theme_name' && $ae_loc?.app_cfg?.theme_name) {
// console.log(`$ae_loc?.app_cfg?.theme_name=${$ae_loc?.app_cfg?.theme_name}`);
// $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 ($slct_trigger == 'set_theme_name' && $ae_loc?.app_cfg?.theme_name) {
// console.log(`$ae_loc?.app_cfg?.theme_name=${$ae_loc?.app_cfg?.theme_name}`);
// $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) {
// console.log(`entered_passcode=${entered_passcode}`);
// handle_check_access_type_passcode();
// }
// $: if (entered_passcode && entered_passcode.length >= 5) {
// console.log(`entered_passcode=${entered_passcode}`);
// handle_check_access_type_passcode();
// }
// $: if (trigger && $ae_loc.access_type) {
// console.log(`$ae_loc.access_type=${$ae_loc.access_type}`);
// $: if (trigger && $ae_loc.access_type) {
// console.log(`$ae_loc.access_type=${$ae_loc.access_type}`);
// let access_checks_results = ae_util.process_permission_checks($ae_loc.access_type);
// let access_checks_results = ae_util.process_permission_checks($ae_loc.access_type);
// $ae_loc = {...$ae_loc, ...access_checks_results};
// } else if (trigger) {
// console.log(`$ae_loc.access_type=not set`);
// $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'.
// let access_checks_results = ae_util.process_permission_checks('');
// // 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};
// }
function handle_something() {
// console.log('*** handle_something() ***');
}
function handle_something() {
// console.log('*** handle_something() ***');
}
function handle_clear_storage(item: null | string) {
// console.log('*** handle_clear_storage() ***');
// window.localStorage.setItem('access_type', 'anonymous');
// return true;
}
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 dispatch_something_changed() {
// console.log('*** dispatch_something_changed() ***');
// console.log(ae_util);
// console.log($ae_loc);
// console.log(ae_util);
// console.log($ae_loc);
// dispatch('access_type_changed', {
// access_type: $ae_loc.access_type
// });
// }
// dispatch('access_type_changed', {
// access_type: $ae_loc.access_type
// });
// }
</script>
<!-- transition duration-500 delay-1000 hover:duration-500 hover:delay-1000 hover:transition-all -->
<section
id="AE-App-Cfg"
class="
id="AE-App-Cfg"
class="
ae_app_cfg
hidden-print
@@ -120,39 +120,39 @@
duration-300 delay-150 hover:delay-1000 hover:ease-out
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 class:hidden={!expand} class="ae_header w-full">
<h2 class="text-sm text-center font-semibold">Config</h2>
</header>
<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}
<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
<!-- <button
class="btn btn-sm variant-glass-secondary access_type_lock_btn hover:transition-all"
on:click={() => {
handle_clear_access();
@@ -161,96 +161,100 @@
>
<span class="fas fa-lock mx-1"></span> Lock
</button> -->
{:else}
Not logged in
{/if}
</section>
<!-- END: Access Type -->
{:else}
Not logged in
{/if}
</section>
<!-- 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>
<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}
{#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;
}
<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;
}
// Clear the local and session storage
localStorage.clear();
sessionStorage.clear();
// 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');
// 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>
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-between={expand}
class:justify-end={!expand} -->
<div class="flex flex-row gap-2 items-center justify-between w-full">
<!-- {#if !expand} -->
<span>
{#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}
<div class="flex flex-row gap-2 items-center justify-between w-full">
<!-- {#if !expand} -->
<span>
{#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
<!-- <button
class="btn btn-sm variant-glass-secondary access_type_lock_btn hover:transition-all"
on:click={() => {
handle_clear_access();
@@ -259,56 +263,56 @@ class:justify-end={!expand} -->
>
<span class="fas fa-lock mx-1"></span> Lock
</button> -->
{:else}
Not logged in
{/if}
</span>
<!-- {/if} -->
{:else}
Not logged in
{/if}
</span>
<!-- {/if} -->
<button
class="
<button
class="
ae_cfg_btn
btn btn-sm text-sm
preset-tonal-warning
group transition-all
"
onclick={() => {
expand = !expand;
}}
>
<!-- <span class="fas fa-cog m-1"></span> -->
<span class="inline-block" title="Settings">
<Settings class="m-1" />
</span>
<span
class="
onclick={() => {
expand = !expand;
}}
>
<!-- <span class="fas fa-cog m-1"></span> -->
<span class="inline-block" title="Settings">
<Settings class="m-1" />
</span>
<span
class="
cfg_text
hidden
group-hover:inline
"
>
Settings
</span>
</button>
</div>
>
Settings
</span>
</button>
</div>
</section>
<style lang="postcss">
.ae_cfg_btn .cfg_text {
/* display: none; */
}
.ae_cfg_btn .cfg_text {
/* display: none; */
}
.ae_cfg_btn:hover .cfg_text {
/* display: initial; */
/* outline: solid thin red; */
}
.ae_cfg_btn:hover .cfg_text {
/* display: initial; */
/* outline: solid thin red; */
}
/* .access_type .current_text {
/* .access_type .current_text {
display: none;
} */
/* .access_type:hover .current_text {
/* .access_type:hover .current_text {
display: initial;
} */
/* END: AE's Svelte App Config component */
/* END: AE's Svelte App Config component */
</style>

View File

@@ -1,108 +1,108 @@
<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 {
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;
}
let {
children,
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();
let {
children,
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 { browser } from '$app/environment';
// *** Import Svelte specific
// import { browser } from '$app/environment';
// *** Import other supporting libraries
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
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';
if (log_lvl) {
console.log(`Clipboard component initialized with value:`, value);
}
if (log_lvl) {
console.log(`Clipboard component initialized with value:`, value);
}
// Select your trigger element
// const elemButton: HTMLButtonElement | null = document.querySelector('[data-button]');
// Select your trigger element
// const elemButton: HTMLButtonElement | null = document.querySelector('[data-button]');
// Add a click event handler to the trigger
// elemButton?.addEventListener('click', () => {
// // Call the Clipboard API
// navigator.clipboard
// // Use the `writeText` method write content to the clipboard
// .writeText(value)
// // Handle confirmation
// .then(() => {
// if (log_lvl) {
// console.log(`Clipboard write successful: ${value}`);
// }
// success = true;
// });
// });
// Add a click event handler to the trigger
// elemButton?.addEventListener('click', () => {
// // Call the Clipboard API
// navigator.clipboard
// // Use the `writeText` method write content to the clipboard
// .writeText(value)
// // Handle confirmation
// .then(() => {
// if (log_lvl) {
// console.log(`Clipboard write successful: ${value}`);
// }
// success = true;
// });
// });
</script>
<button
type="button"
data-button
onclick={() => {
// if (browser) {
// Call the Clipboard API
navigator.clipboard
// Use the `writeText` method write content to the clipboard
.writeText(value)
// Handle confirmation
.then(() => {
if (log_lvl) {
console.log(`Clipboard write successful: ${value}`);
}
success = true;
});
// } else {
// if (log_lvl) {
// console.log(`Clipboard write attempted in non-browser environment.`);
// }
// }
}}
class={btn_class}
title={btn_title}
type="button"
data-button
onclick={() => {
// if (browser) {
// Call the Clipboard API
navigator.clipboard
// Use the `writeText` method write content to the clipboard
.writeText(value)
// Handle confirmation
.then(() => {
if (log_lvl) {
console.log(`Clipboard write successful: ${value}`);
}
success = true;
});
// } else {
// if (log_lvl) {
// console.log(`Clipboard write attempted in non-browser environment.`);
// }
// }
}}
class={btn_class}
title={btn_title}
>
<!-- {@render btn_text} -->
{#if icon_name === 'link'}
<Link class="mx-1 {hide_icon ? 'hidden' : 'inline-block'}" size="1.2em" />
{:else if icon_name === 'check'}
<CircleCheck class="mx-1 {hide_icon ? 'hidden' : 'inline-block'}" size="1.2em" />
{:else}
<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?.()}
<!-- {@render btn_text} -->
{#if icon_name === 'link'}
<Link class="mx-1 {hide_icon ? 'hidden' : 'inline-block'}" size="1.2em" />
{:else if icon_name === 'check'}
<CircleCheck class="mx-1 {hide_icon ? 'hidden' : 'inline-block'}" size="1.2em" />
{:else}
<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>

View File

@@ -1,182 +1,182 @@
<script lang="ts">
// This will be the wrapper for the CodeMirror editor. It should hide most of the configuration requirements.
// WARNING: This has not been fully updated to Svelte version 5. It is a work in progress.
// *** Import Svelte version 5 specific
import { browser } from '$app/environment';
// This will be the wrapper for the CodeMirror editor. It should hide most of the configuration requirements.
// WARNING: This has not been fully updated to Svelte version 5. It is a work in progress.
// *** Import Svelte version 5 specific
import { browser } from '$app/environment';
import { onMount, onDestroy } from 'svelte';
import { ensureCodeMirrorModules } from '../elements/codemirror_modules';
import { onMount, onDestroy } from 'svelte';
import { ensureCodeMirrorModules } from '../elements/codemirror_modules';
// Props
export let content: string = 'test test test test';
export let new_content: string = '';
// Props
export let content: string = 'test test test test';
export let new_content: string = '';
// export let language: Extension = markdown(); // javascript()
export let theme_mode: string = 'light'; // 'dark' | 'light'
export let extensions: any[] = []; // Changed to any[] because Extension type is not directly available here
// export let language: Extension = markdown(); // javascript()
export let theme_mode: string = 'light'; // 'dark' | 'light'
export let extensions: any[] = []; // Changed to any[] because Extension type is not directly available here
export let editable: boolean = true;
export let readonly: boolean = false;
export let editable: boolean = true;
export let readonly: boolean = false;
export let placeholder: string = 'Start typing...';
export let placeholder: string = 'Start typing...';
export let show_line_numbers: boolean = false;
export let wrap_lines: boolean = true;
export let use_tab: boolean = true;
export let tab_size: number = 4;
let classes = '';
export { classes as class };
export let show_line_numbers: boolean = false;
export let wrap_lines: boolean = true;
export let use_tab: boolean = true;
export let tab_size: number = 4;
let classes = '';
export { classes as class };
let editor_element: HTMLDivElement;
let editorView: any; // Changed to any
let editor_element: HTMLDivElement;
let editorView: any; // Changed to any
let cm_modules: any; // To hold the dynamically loaded CodeMirror modules
let cm_modules: any; // To hold the dynamically loaded CodeMirror modules
async function initializeCodeMirror() {
if (!browser) return;
async function initializeCodeMirror() {
if (!browser) return;
cm_modules = await ensureCodeMirrorModules();
if (!cm_modules) return;
cm_modules = await ensureCodeMirrorModules();
if (!cm_modules) return;
// Reactive declaration for extensions
let editor_extensions = [
// Core extensions
cm_modules.highlightSpecialChars(),
cm_modules.history(),
cm_modules.foldGutter(),
cm_modules.drawSelection(),
cm_modules.dropCursor(),
cm_modules.EditorState_allowMultipleSelections.of(true),
cm_modules.indentOnInput(),
cm_modules.bracketMatching(),
cm_modules.closeBrackets(),
cm_modules.autocompletion(),
cm_modules.rectangularSelection(),
cm_modules.crosshairCursor(),
cm_modules.highlightActiveLine(),
cm_modules.highlightActiveLineGutter(),
cm_modules.keymap.of([
...cm_modules.defaultKeymap,
...cm_modules.searchKeymap,
...cm_modules.historyKeymap,
...cm_modules.foldKeymap,
...cm_modules.completionKeymap,
...cm_modules.lintKeymap
]),
cm_modules.markdown({
base: cm_modules.markdownLanguage,
codeLanguages: cm_modules.languages
}),
theme_mode == 'dark' ? cm_modules.oneDark : cm_modules.EditorView.baseTheme(),
cm_modules.EditorView.contentAttributes.of({ spellcheck: 'true' }), // Enable spell check
// Reactive declaration for extensions
let editor_extensions = [
// Core extensions
cm_modules.highlightSpecialChars(),
cm_modules.history(),
cm_modules.foldGutter(),
cm_modules.drawSelection(),
cm_modules.dropCursor(),
cm_modules.EditorState_allowMultipleSelections.of(true),
cm_modules.indentOnInput(),
cm_modules.bracketMatching(),
cm_modules.closeBrackets(),
cm_modules.autocompletion(),
cm_modules.rectangularSelection(),
cm_modules.crosshairCursor(),
cm_modules.highlightActiveLine(),
cm_modules.highlightActiveLineGutter(),
cm_modules.keymap.of([
...cm_modules.defaultKeymap,
...cm_modules.searchKeymap,
...cm_modules.historyKeymap,
...cm_modules.foldKeymap,
...cm_modules.completionKeymap,
...cm_modules.lintKeymap
]),
cm_modules.markdown({
base: cm_modules.markdownLanguage,
codeLanguages: cm_modules.languages
}),
theme_mode == 'dark' ? cm_modules.oneDark : cm_modules.EditorView.baseTheme(),
cm_modules.EditorView.contentAttributes.of({ spellcheck: 'true' }), // Enable spell check
// Conditional extensions based on props
editable ? cm_modules.EditorView.editable.of(true) : null,
readonly ? cm_modules.EditorState.readOnly.of(true) : null,
placeholder ? cm_modules.placeholderExt(placeholder) : null,
show_line_numbers ? cm_modules.lineNumbers() : null,
wrap_lines ? cm_modules.EditorView_lineWrapping : null,
use_tab ? cm_modules.keymap.of([cm_modules.indentWithTab]) : null,
tab_size ? cm_modules.indentUnit.of(' '.repeat(tab_size)) : null,
// Conditional extensions based on props
editable ? cm_modules.EditorView.editable.of(true) : null,
readonly ? cm_modules.EditorState.readOnly.of(true) : null,
placeholder ? cm_modules.placeholderExt(placeholder) : null,
show_line_numbers ? cm_modules.lineNumbers() : null,
wrap_lines ? cm_modules.EditorView_lineWrapping : null,
use_tab ? cm_modules.keymap.of([cm_modules.indentWithTab]) : null,
tab_size ? cm_modules.indentUnit.of(' '.repeat(tab_size)) : null,
...extensions // Add any custom extensions passed in props
].filter(Boolean);
...extensions // Add any custom extensions passed in props
].filter(Boolean);
editorView = new cm_modules.EditorView({
state: cm_modules.EditorState.create({
doc: content,
extensions: editor_extensions
}),
parent: editor_element,
dispatch: (transaction: any) => {
editorView.update([transaction]);
if (transaction.docChanged) {
new_content = editorView.state.doc.toString();
}
}
});
}
editorView = new cm_modules.EditorView({
state: cm_modules.EditorState.create({
doc: content,
extensions: editor_extensions
}),
parent: editor_element,
dispatch: (transaction: any) => {
editorView.update([transaction]);
if (transaction.docChanged) {
new_content = editorView.state.doc.toString();
}
}
});
}
// Initialize CodeMirror on mount
onMount(async () => {
await initializeCodeMirror();
});
// Initialize CodeMirror on mount
onMount(async () => {
await initializeCodeMirror();
});
// Clean up on destroy
onDestroy(() => {
editorView?.destroy();
});
// Clean up on destroy
onDestroy(() => {
editorView?.destroy();
});
// Update editor content when `content` prop changes
$: if (cm_modules && editorView && editorView.state.doc.toString() !== content) {
editorView.setState(
cm_modules.EditorState.create({
doc: content,
extensions: editor_extensions // Use the reactive extensions
})
);
}
// Update editor content when `content` prop changes
$: if (cm_modules && editorView && editorView.state.doc.toString() !== content) {
editorView.setState(
cm_modules.EditorState.create({
doc: content,
extensions: editor_extensions // Use the reactive extensions
})
);
}
</script>
{#if browser}
<!-- flex flex-col flex-wrap items-center justify-center -->
<div
bind:this={editor_element}
class="codemirror-wrapper h-100 max-h-full w-100 max-w-6xl {classes}"
></div>
<!-- flex flex-col flex-wrap items-center justify-center -->
<div
bind:this={editor_element}
class="codemirror-wrapper h-100 max-h-full w-100 max-w-6xl {classes}"
></div>
{:else}
<div class="scm-waiting {classes}">
<div class="scm-waiting__loading scm-loading">
<p class="scm-loading__text">Loading editor...</p>
</div>
<div class="scm-waiting {classes}">
<div class="scm-waiting__loading scm-loading">
<p class="scm-loading__text">Loading editor...</p>
</div>
<pre class="scm-pre cm-editor">{content}</pre>
</div>
<pre class="scm-pre cm-editor">{content}</pre>
</div>
{/if}
<style>
/* .codemirror-wrapper :global(.cm-focused) {
/* .codemirror-wrapper :global(.cm-focused) {
outline: none;
} */
.codemirror-wrapper {
flex-grow: 1;
/* flex-shrink: 1; */
/* flex-basis: 100%; */
.codemirror-wrapper {
flex-grow: 1;
/* flex-shrink: 1; */
/* flex-basis: 100%; */
/* font-size: 1rem; */
width: 100%;
max-width: 100%;
height: 100%;
max-height: 100%;
/* overflow: auto; */
/* background-color: var(--cm-background); */
/* font-size: 1rem; */
width: 100%;
max-width: 100%;
height: 100%;
max-height: 100%;
/* overflow: auto; */
/* background-color: var(--cm-background); */
/* text-wrap: normal; */
/* text-wrap: balance; */
/* text-wrap: wrap; */
/* text-wrap: break-word; */
}
.codemirror-wrapper :global(.cm-editor) {
/* font-size: .8rem; */
/* text-wrap: normal; */
/* text-wrap: balance; */
/* text-wrap: wrap; */
/* text-wrap: break-word; */
/* text-wrap: normal; */
/* text-wrap: balance; */
/* text-wrap: wrap; */
/* text-wrap: break-word; */
}
.codemirror-wrapper :global(.cm-editor) {
/* font-size: .8rem; */
/* text-wrap: normal; */
/* text-wrap: balance; */
/* text-wrap: wrap; */
/* text-wrap: break-word; */
/* max-width: 100%; */
/* max-height: 100%; */
/* max-width: 100%; */
/* max-height: 100%; */
/* overflow: auto; */
/* overflow: auto; */
/* width: 100%; */
/* height: 100%; */
/* width: 100%; */
/* height: 100%; */
/* background-color: var(--cm-background); */
/* color: var(--cm-text); */
}
/* background-color: var(--cm-background); */
/* color: var(--cm-text); */
}
/* .codemirror-wrapper :global(.cm-gutters) {
/* .codemirror-wrapper :global(.cm-gutters) {
background-color: var(--cm-gutter-background);
color: var(--cm-gutter-text);
}

View File

@@ -1,25 +1,25 @@
<script lang="ts">
// *** Import Svelte specific
// *** Import Svelte specific
// *** Import other supporting libraries
import { Bug, CircleX, Info, ToggleLeft, ToggleRight, X } from '@lucide/svelte';
// *** Import other supporting libraries
import { Bug, CircleX, Info, ToggleLeft, ToggleRight, X } 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 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';
// *** Setup Svelte properties
interface Props {
log_lvl?: number;
hide?: null | boolean;
expand?: boolean;
}
// *** Setup Svelte properties
interface Props {
log_lvl?: number;
hide?: null | boolean;
expand?: boolean;
}
let {
log_lvl = $bindable(0),
hide = $bindable(false),
expand = $bindable(false)
}: Props = $props();
let {
log_lvl = $bindable(0),
hide = $bindable(false),
expand = $bindable(false)
}: Props = $props();
</script>
<!-- App Debug Menu -->
@@ -27,7 +27,7 @@
hover:opacity-100 -->
<!-- text-slate-400 hover:text-slate-800 -->
<section
class="
class="
ae_app__debug_menu
hidden-print
@@ -54,19 +54,19 @@ hover:opacity-100 -->
border-red-300 dark:border-red-700
hover:border-red-500 hover:dark:border-red-500
"
class:top-0={expand}
class:w-full={expand}
class:hidden={hide}
class:border-transparent={!expand}
class:dark:border-transparent={!expand}
class:hover:border-transparent={!expand}
class:hover:bg-transparent={!expand}
class:top-0={expand}
class:w-full={expand}
class:hidden={hide}
class:border-transparent={!expand}
class:dark:border-transparent={!expand}
class:hover:border-transparent={!expand}
class:hover:bg-transparent={!expand}
>
<div
class:hidden={!expand}
class:border-red-200={expand}
class:dark:border-red-800={expand}
class="
<div
class:hidden={!expand}
class:border-red-200={expand}
class:dark:border-red-800={expand}
class="
transition-all
transition-delay-1000
@@ -78,104 +78,104 @@ hover:opacity-100 -->
hover:opacity-100
relative
"
>
<!-- flex flex-col items-center justify-center max-h-full outline -->
<div>
<!-- <span class="fas fa-bug mx-1"></span> -->
<Bug class="inline-block mx-1" />
<span>Debug</span>
</div>
>
<!-- flex flex-col items-center justify-center max-h-full outline -->
<div>
<!-- <span class="fas fa-bug mx-1"></span> -->
<Bug class="inline-block mx-1" />
<span>Debug</span>
</div>
<pre class="text-xs">
<pre class="text-xs">
{JSON.stringify($ae_loc, null, 2)}
</pre>
</div>
</div>
<span class="absolute top-0 right-0 flex flex-row gap-1 items-center justify-center">
<button
type="button"
onclick={() => {
console.log('Debug ae_loc:', $ae_loc);
$ae_loc.debug_mode = !$ae_loc?.debug_mode;
}}
class="
<span class="absolute top-0 right-0 flex flex-row gap-1 items-center justify-center">
<button
type="button"
onclick={() => {
console.log('Debug ae_loc:', $ae_loc);
$ae_loc.debug_mode = !$ae_loc?.debug_mode;
}}
class="
btn btn-sm
preset-outlined-surface-400-600 preset-filled-suface-200-800
hover:preset-tonal-success
transition-all
"
title="Turn debug content and styles off and on"
>
{#if $ae_loc?.debug_mode}
<!-- <span class="fas fa-toggle-on mx-1"></span> -->
<ToggleRight strokeWidth="2.5" color="green" class="inline-block mx-1" />
<span>Debug</span>
<span class="hidden"> Mode On </span>
{:else}
<!-- <span class="fas fa-toggle-off mx-1"></span> -->
<ToggleLeft strokeWidth="1" color="gray" class="inline-block mx-1" />
<span>Debug?</span>
<span class="hidden"> Mode Off </span>
{/if}
<!-- <span class="fas fa-toggle-on mx-1"></span> -->
<!-- <ToggleRight class="inline-block mx-1" /> -->
<!-- <X class="inline-block mx-1" /> -->
</button>
title="Turn debug content and styles off and on"
>
{#if $ae_loc?.debug_mode}
<!-- <span class="fas fa-toggle-on mx-1"></span> -->
<ToggleRight strokeWidth="2.5" color="green" class="inline-block mx-1" />
<span>Debug</span>
<span class="hidden"> Mode On </span>
{:else}
<!-- <span class="fas fa-toggle-off mx-1"></span> -->
<ToggleLeft strokeWidth="1" color="gray" class="inline-block mx-1" />
<span>Debug?</span>
<span class="hidden"> Mode Off </span>
{/if}
<!-- <span class="fas fa-toggle-on mx-1"></span> -->
<!-- <ToggleRight class="inline-block mx-1" /> -->
<!-- <X class="inline-block mx-1" /> -->
</button>
<button
type="button"
onclick={() => {
if (log_lvl) {
console.log('Showing quick info/debug menu.');
}
expand = false;
$ae_sess.debug_menu.hide_quick_info = false;
}}
title="Show Quick Info"
class="
<button
type="button"
onclick={() => {
if (log_lvl) {
console.log('Showing quick info/debug menu.');
}
expand = false;
$ae_sess.debug_menu.hide_quick_info = false;
}}
title="Show Quick Info"
class="
btn btn-sm
preset-outlined-surface-400-600 preset-filled-suface-200-800
hover:preset-tonal-success
transition-all
"
>
<!-- <span class="fas fa-info-circle mx-1"></span> -->
<Info class="inline-block mx-1" />
Quick Info
</button>
>
<!-- <span class="fas fa-info-circle mx-1"></span> -->
<Info class="inline-block mx-1" />
Quick Info
</button>
<button
type="button"
onclick={() => {
console.log('Debug ae_loc:', $ae_loc);
// $ae_loc.debug_menu.expand = !$ae_loc?.debug_menu?.expand;
expand = !expand;
}}
class="
<button
type="button"
onclick={() => {
console.log('Debug ae_loc:', $ae_loc);
// $ae_loc.debug_menu.expand = !$ae_loc?.debug_menu?.expand;
expand = !expand;
}}
class="
btn btn-sm
preset-outlined-surface-400-600 preset-filled-suface-200-800
hover:preset-tonal-warning
transition-all
"
title="Turn debug content and styles off and on"
>
<!-- <span class="fas fa-toggle-on mx-1"></span> -->
<!-- <ToggleRight class="inline-block mx-1" /> -->
<CircleX class="inline-block mx-1" />
<span class="hidden"> Close </span>
<span>Debug</span>
</button>
</span>
title="Turn debug content and styles off and on"
>
<!-- <span class="fas fa-toggle-on mx-1"></span> -->
<!-- <ToggleRight class="inline-block mx-1" /> -->
<CircleX class="inline-block mx-1" />
<span class="hidden"> Close </span>
<span>Debug</span>
</button>
</span>
<button
type="button"
onclick={() => {
console.log('Debug ae_loc:', $ae_loc);
// $ae_loc.debug_menu.expand = !$ae_loc?.debug_menu?.expand;
expand = !expand;
}}
id="AE-Quick-Debug"
class="
<button
type="button"
onclick={() => {
console.log('Debug ae_loc:', $ae_loc);
// $ae_loc.debug_menu.expand = !$ae_loc?.debug_menu?.expand;
expand = !expand;
}}
id="AE-Quick-Debug"
class="
btn btn-icon
text-xs
p-1
@@ -187,10 +187,10 @@ hover:opacity-100 -->
text-neutral-300 hover:text-neutral-800
dark:text-neutral-700 dark:hover:text-neutral-200
"
title="Turn debug content and styles off and on"
>
<!-- absolute bottom-2 left-2 -->
<!-- fixed bottom-0 left-0 -->
&pi;
</button>
title="Turn debug content and styles off and on"
>
<!-- absolute bottom-2 left-2 -->
<!-- fixed bottom-0 left-0 -->
&pi;
</button>
</section>

View File

@@ -1,101 +1,101 @@
<script lang="ts">
interface Props {
log_lvl?: number;
additional_kv?: key_val;
e_success?: boolean;
e_class?: string;
e_title?: string;
e_text?: string;
e_class_h1?: string;
e_class_h2?: string;
e_class_form_hidden?: string;
e_class_form_showing?: string;
btn_text?: string;
btn_title?: string;
btn_class?: string;
show_btn_class?: string;
hide_icon?: boolean;
}
interface Props {
log_lvl?: number;
additional_kv?: key_val;
e_success?: boolean;
e_class?: string;
e_title?: string;
e_text?: string;
e_class_h1?: string;
e_class_h2?: string;
e_class_form_hidden?: string;
e_class_form_showing?: string;
btn_text?: string;
btn_title?: string;
btn_class?: string;
show_btn_class?: string;
hide_icon?: boolean;
}
let {
log_lvl = 0,
additional_kv = $bindable({}),
e_success = $bindable(false),
e_class = '',
e_title = 'Technical Help',
e_text = 'Request technical help for this application.',
e_class_h1 = $bindable(''),
e_class_h2 = $bindable(''),
e_class_form_hidden = $bindable(''),
e_class_form_showing = $bindable(''),
btn_text = 'Technical Help',
btn_title = 'Technical support help',
btn_class = '',
show_btn_class = '',
hide_icon = false
}: Props = $props();
let {
log_lvl = 0,
additional_kv = $bindable({}),
e_success = $bindable(false),
e_class = '',
e_title = 'Technical Help',
e_text = 'Request technical help for this application.',
e_class_h1 = $bindable(''),
e_class_h2 = $bindable(''),
e_class_form_hidden = $bindable(''),
e_class_form_showing = $bindable(''),
btn_text = 'Technical Help',
btn_title = 'Technical support help',
btn_class = '',
show_btn_class = '',
hide_icon = false
}: Props = $props();
// *** Import Svelte specific
import { goto } from '$app/navigation';
// *** Import Svelte specific
import { goto } from '$app/navigation';
// *** Import other supporting libraries
import {
// ArrowBigRight,
BadgeQuestionMark,
ChevronDown,
ChevronRight,
// CircleX,
// Copy,
// Eye, EyeOff,
// Key,
LifeBuoy,
// LogIn, LogOut, LockKeyhole,
// Mail, MailCheck,
// Menu,
RefreshCw,
RefreshCcw,
RefreshCcwDot,
// ShieldEllipsis, ShieldMinus, ShieldPlus, ShieldUser,
SquareX
// User, UserCheck
} from '@lucide/svelte';
// *** Import other supporting libraries
import {
// ArrowBigRight,
BadgeQuestionMark,
ChevronDown,
ChevronRight,
// CircleX,
// Copy,
// Eye, EyeOff,
// Key,
LifeBuoy,
// LogIn, LogOut, LockKeyhole,
// Mail, MailCheck,
// Menu,
RefreshCw,
RefreshCcw,
RefreshCcwDot,
// ShieldEllipsis, ShieldMinus, ShieldPlus, ShieldUser,
SquareX
// User, UserCheck
} from '@lucide/svelte';
// *** Import Aether specific variables and functions
import {
ae_snip,
ae_loc,
ae_sess,
ae_api,
ae_trig,
slct,
slct_trigger,
type key_val
} from '$lib/stores/ae_stores';
import { User } from 'lucide-svelte';
import { api } from '$lib/api/api';
// *** Import Aether specific variables and functions
import {
ae_snip,
ae_loc,
ae_sess,
ae_api,
ae_trig,
slct,
slct_trigger,
type key_val
} from '$lib/stores/ae_stores';
import { User } from 'lucide-svelte';
import { api } from '$lib/api/api';
if (log_lvl) {
console.log(`Help - technical support component loaded`);
}
if (log_lvl) {
console.log(`Help - technical support component loaded`);
}
let help_tech_text: string = $state('');
let hide_additional_info: boolean = $state(true);
let help_tech_text: string = $state('');
let hide_additional_info: boolean = $state(true);
function preventDefault<T extends Event>(fn: (event: T) => void) {
return function (event: T) {
event.preventDefault();
fn(event);
};
}
function preventDefault<T extends Event>(fn: (event: T) => void) {
return function (event: T) {
event.preventDefault();
fn(event);
};
}
function send_help_tech_email() {
if (log_lvl) {
console.log(`*** send_help_tech_email() ***`);
}
function send_help_tech_email() {
if (log_lvl) {
console.log(`*** send_help_tech_email() ***`);
}
let subject = `Technical Notification - ${$ae_loc.name}`;
let subject = `Technical Notification - ${$ae_loc.name}`;
let body_html = `
let body_html = `
<div>
Technical Notification,\n\n
<ul>
@@ -123,23 +123,23 @@
</div>
`;
api.send_email({
api_cfg: $ae_api,
from_email: $ae_loc.site_cfg_json?.noreply_email ?? 'noreply+tech@oneskyit.com',
from_name: $ae_loc.site_cfg_json?.noreply_name ?? 'IT NoReply',
// to_email: $ae_loc.site_cfg_json?.admin_email ?? 'admin+tech@oneskyit.com', // 'scott+idaabb@oneskyit.com',
to_email: 'it+tech@oneskyit.com',
// to_email: $idaa_slct.post_obj.email,
// to_email: 'scott+idaabb@oneskyit.com',
// to_name: $ae_loc.site_cfg_json?.admin_name ?? 'IT Tech',
to_name: 'IT Tech',
// to_name: $idaa_slct.post_obj.full_name ?? 'IDAA BB Poster',
subject: subject,
body_html: body_html
});
api.send_email({
api_cfg: $ae_api,
from_email: $ae_loc.site_cfg_json?.noreply_email ?? 'noreply+tech@oneskyit.com',
from_name: $ae_loc.site_cfg_json?.noreply_name ?? 'IT NoReply',
// to_email: $ae_loc.site_cfg_json?.admin_email ?? 'admin+tech@oneskyit.com', // 'scott+idaabb@oneskyit.com',
to_email: 'it+tech@oneskyit.com',
// to_email: $idaa_slct.post_obj.email,
// to_email: 'scott+idaabb@oneskyit.com',
// to_name: $ae_loc.site_cfg_json?.admin_name ?? 'IT Tech',
to_name: 'IT Tech',
// to_name: $idaa_slct.post_obj.full_name ?? 'IDAA BB Poster',
subject: subject,
body_html: body_html
});
help_tech_text = ''; // Clear the text area after sending
}
help_tech_text = ''; // Clear the text area after sending
}
</script>
<!-- class:bg-radial-[at_55%_50%]={$ae_sess.show_help_tech}
@@ -147,7 +147,7 @@ class:from-blue-400={$ae_sess.show_help_tech}
class:to-transparent={$ae_sess.show_help_tech}
class:to-90%={$ae_sess.show_help_tech} -->
<div
class="
class="
flex flex-row
items-center justify-center
rounded-lg shadow-2xl
@@ -157,21 +157,21 @@ class:to-90%={$ae_sess.show_help_tech} -->
{!$ae_sess.show_help_tech ? e_class_form_hidden : e_class_form_showing}
relative
"
class:w-xl={$ae_sess.show_help_tech}
class:w-fit={!$ae_sess.show_help_tech}
class:mx-auto={$ae_sess.show_help_tech}
class:m-2={$ae_sess.show_help_tech}
class:p-2={$ae_sess.show_help_tech}
class:hover:border-blue-400={$ae_sess.show_help_tech}
class:hover:dark:border-blue-600={$ae_sess.show_help_tech}
class:hover:shadow-blue-200={$ae_sess.show_help_tech}
class:hover:dark:shadow-blue-800={$ae_sess.show_help_tech}
class:bg-blue-100={$ae_sess.show_help_tech}
class:dark:bg-blue-900={$ae_sess.show_help_tech}
class:w-xl={$ae_sess.show_help_tech}
class:w-fit={!$ae_sess.show_help_tech}
class:mx-auto={$ae_sess.show_help_tech}
class:m-2={$ae_sess.show_help_tech}
class:p-2={$ae_sess.show_help_tech}
class:hover:border-blue-400={$ae_sess.show_help_tech}
class:hover:dark:border-blue-600={$ae_sess.show_help_tech}
class:hover:shadow-blue-200={$ae_sess.show_help_tech}
class:hover:dark:shadow-blue-800={$ae_sess.show_help_tech}
class:bg-blue-100={$ae_sess.show_help_tech}
class:dark:bg-blue-900={$ae_sess.show_help_tech}
>
{#if $ae_sess.show_help_tech}
<div
class="
{#if $ae_sess.show_help_tech}
<div
class="
w-xl
flex flex-col gap-1
items-center justify-center
@@ -181,44 +181,44 @@ class:to-90%={$ae_sess.show_help_tech} -->
dark:bg-blue-800
transition-all
"
>
<div
class="
>
<div
class="
d-flex align-items-center justify-content-between
flex flex-row gap-1 items-center justify-between
w-full
"
>
<h1
class="
>
<h1
class="
h1
text-base font-semibold text-gray-800 dark:text-gray-200
w-fit
{e_class_h1}
"
>
{#if e_success}
<span class="text-lg text-green-800 dark:text-green-200 font-semibold">
<BadgeQuestionMark class="inline-block mr-2" />
Help Requested
</span>
{:else}
<span class="text-lg text-gray-800 dark:text-gray-200 font-semibold">
<BadgeQuestionMark class="inline-block mr-2" />
<!-- Request Technical Help -->
Notify Technical Support
</span>
<!-- <span class="text-gray-500">
>
{#if e_success}
<span class="text-lg text-green-800 dark:text-green-200 font-semibold">
<BadgeQuestionMark class="inline-block mr-2" />
Help Requested
</span>
{:else}
<span class="text-lg text-gray-800 dark:text-gray-200 font-semibold">
<BadgeQuestionMark class="inline-block mr-2" />
<!-- Request Technical Help -->
Notify Technical Support
</span>
<!-- <span class="text-gray-500">
Send your help request with or without a description.
</span> -->
{/if}
{/if}
<!-- Cancel button -->
</h1>
<button
type="button"
onclick={() => ($ae_sess.show_help_tech = false)}
class="
<!-- Cancel button -->
</h1>
<button
type="button"
onclick={() => ($ae_sess.show_help_tech = false)}
class="
btn btn-base
preset-tonal-tertiary
preset-outlined-tertiary-100-900
@@ -226,33 +226,33 @@ class:to-90%={$ae_sess.show_help_tech} -->
transition-all
{btn_class}
"
title="Close Help Request Form"
>
<!-- <span class="fas fa-times"></span> -->
<SquareX size="1em" />
<span class="sr-only">Close</span>
</button>
</div>
title="Close Help Request Form"
>
<!-- <span class="fas fa-times"></span> -->
<SquareX size="1em" />
<span class="sr-only">Close</span>
</button>
</div>
<form
class="
<form
class="
m-1
flex flex-col gap-1
items-center justify-center
w-md max-w-lg
"
onsubmit={preventDefault(() => {
// Do stuff...
send_help_tech_email();
onsubmit={preventDefault(() => {
// Do stuff...
send_help_tech_email();
// Hide the request form
$ae_sess.show_help_tech = false;
// Hide the request form
$ae_sess.show_help_tech = false;
alert('Notification sent to the IT team.');
})}
>
<textarea
class="
alert('Notification sent to the IT team.');
})}
>
<textarea
class="
form-control
w-full max-w-lg h-24 p-2
border border-gray-300 rounded
@@ -261,13 +261,13 @@ class:to-90%={$ae_sess.show_help_tech} -->
hover:dark:bg-gray-50
hover:dark:text-gray-950
"
placeholder="Send with or without a description...."
bind:value={help_tech_text}
></textarea>
placeholder="Send with or without a description...."
bind:value={help_tech_text}
></textarea>
<button
type="submit"
class="
<button
type="submit"
class="
btn btn-lg
m-1
preset-tonal-warning
@@ -278,247 +278,254 @@ class:to-90%={$ae_sess.show_help_tech} -->
transition-all
{btn_class}
"
title={btn_title}
>
{#if !hide_icon}
<!-- <BadgeQuestionMark class="inline-block mr-2" /> -->
<LifeBuoy class="inline-block m-1" />
{/if}
title={btn_title}
>
{#if !hide_icon}
<!-- <BadgeQuestionMark class="inline-block mr-2" /> -->
<LifeBuoy class="inline-block m-1" />
{/if}
{#if !help_tech_text}
Notify Without Description
{:else}
Send Notification
{/if}
</button>
</form>
{#if !help_tech_text}
Notify Without Description
{:else}
Send Notification
{/if}
</button>
</form>
<div
class="
<div
class="
text-sm text-gray-700 dark:text-gray-300 text-center italic
"
>
This is intended for technical issues only. Please contact your organization's staff if you
have a question about your membership, recorded content, meetings, or posts.
</div>
>
This is intended for technical issues only. Please contact your organization's staff
if you have a question about your membership, recorded content, meetings, or posts.
</div>
<div
class="
<div
class="
border border-gray-300 rounded p-2
w-full
max-w-2xl
overflow-scroll
"
>
<div
class="
>
<div
class="
d-flex align-items-center justify-content-between
flex flex-row gap-1 items-center justify-between
w-full
"
>
<h2
class="
>
<h2
class="
h2
text-base font-semibold text-gray-800 dark:text-gray-200
{e_class_h2}
"
>
<span class="text-base font-semibold text-gray-800 dark:text-gray-200">
Additional Information Included
</span>
</h2>
<!-- Button to expand and show additional information -->
<button
type="button"
class="
>
<span class="text-base font-semibold text-gray-800 dark:text-gray-200">
Additional Information Included
</span>
</h2>
<!-- Button to expand and show additional information -->
<button
type="button"
class="
btn btn-sm preset-tonal-tertiary
{btn_class}
"
onclick={() => (hide_additional_info = !hide_additional_info)}
title="Toggle additional information"
>
<span>
{#if hide_additional_info}
<!-- <span class="fas fa-caret-right"></span> -->
<ChevronRight size="1em" class="inline-block" />
Show
{:else}
<!-- <span class="fas fa-caret-down"></span> -->
<ChevronDown size="1em" class="inline-block" />
Hide
{/if}
</span>
</button>
</div>
<ul
class="list-disc list-inside text-sm text-gray-800 dark:text-gray-200"
class:hidden={hide_additional_info}
>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Datetime =</span>
{new Date().toISOString()}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">URL =</span>
{window.location.href}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Browser =</span>
{navigator.userAgent}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Viewport Size =</span>
{window.innerWidth} x {window.innerHeight}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Screen Resolution =</span>
{window.screen.width} x {window.screen.height}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Dark mode =</span>
{window?.matchMedia?.('(prefers-color-scheme:dark)')?.matches ?? false}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">In iframe =</span>
{$ae_loc?.iframe}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Theme Mode =</span>
{$ae_loc?.theme_mode}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Theme Name =</span>
{$ae_loc?.theme_name}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Account ID =</span>
{$slct.account_id}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Access Type =</span>
{$ae_loc?.access_type}
</li>
{#if $ae_loc?.person_id}
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">person_id =</span>
{$ae_loc?.person_id}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">full_name =</span>
{$ae_loc?.full_name}
</li>
{/if}
{#if $ae_loc?.user_id}
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">user_id =</span>
{$ae_loc?.user_id}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">username =</span>
{$ae_loc?.username}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">email =</span>
{$ae_loc?.email}
</li>
{/if}
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">API Base URL =</span>
{$ae_api.base_url}
</li>
onclick={() => (hide_additional_info = !hide_additional_info)}
title="Toggle additional information"
>
<span>
{#if hide_additional_info}
<!-- <span class="fas fa-caret-right"></span> -->
<ChevronRight size="1em" class="inline-block" />
Show
{:else}
<!-- <span class="fas fa-caret-down"></span> -->
<ChevronDown size="1em" class="inline-block" />
Hide
{/if}
</span>
</button>
</div>
<ul
class="list-disc list-inside text-sm text-gray-800 dark:text-gray-200"
class:hidden={hide_additional_info}
>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Datetime =</span>
{new Date().toISOString()}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">URL =</span>
{window.location.href}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Browser =</span>
{navigator.userAgent}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Viewport Size =</span
>
{window.innerWidth} x {window.innerHeight}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400"
>Screen Resolution =</span
>
{window.screen.width} x {window.screen.height}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Dark mode =</span>
{window?.matchMedia?.('(prefers-color-scheme:dark)')?.matches ?? false}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">In iframe =</span>
{$ae_loc?.iframe}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Theme Mode =</span>
{$ae_loc?.theme_mode}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Theme Name =</span>
{$ae_loc?.theme_name}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Account ID =</span>
{$slct.account_id}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">Access Type =</span>
{$ae_loc?.access_type}
</li>
{#if $ae_loc?.person_id}
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">person_id =</span
>
{$ae_loc?.person_id}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">full_name =</span
>
{$ae_loc?.full_name}
</li>
{/if}
{#if $ae_loc?.user_id}
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">user_id =</span>
{$ae_loc?.user_id}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">username =</span>
{$ae_loc?.username}
</li>
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">email =</span>
{$ae_loc?.email}
</li>
{/if}
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">API Base URL =</span>
{$ae_api.base_url}
</li>
{#if additional_kv && Object.keys(additional_kv).length > 0}
<h2 class="text-base font-semibold text-gray-800">Component Info:</h2>
<ul class="list-disc list-inside text-gray-800 text-sm">
{#each Object.entries(additional_kv) as [key, value]}
<li>
<span class="text-sm text-gray-500 dark:text-gray-400">{key} =</span>
{value ?? '-- not set --'}
</li>
{/each}
</ul>
{/if}
</ul>
<div class="text-sm text-gray-700 dark:text-gray-300 text-center italic">
This information will be included in the help request to assist technical support in
diagnosing the issue.
</div>
</div>
{#if additional_kv && Object.keys(additional_kv).length > 0}
<h2 class="text-base font-semibold text-gray-800">Component Info:</h2>
<ul class="list-disc list-inside text-gray-800 text-sm">
{#each Object.entries(additional_kv) as [key, value]}
<li>
<span class="text-sm text-gray-500 dark:text-gray-400"
>{key} =</span
>
{value ?? '-- not set --'}
</li>
{/each}
</ul>
{/if}
</ul>
<div class="text-sm text-gray-700 dark:text-gray-300 text-center italic">
This information will be included in the help request to assist technical
support in diagnosing the issue.
</div>
</div>
<div
class="
<div
class="
flex flex-row gap-2 items-center justify-around
w-full
mt-2
"
>
<button
type="button"
onclick={() => {
if ($ae_loc.edit_mode) {
// Confirm before clearing
if (
!confirm(
'Are you sure you want to clear IndexedDB databases, localStorage, and sessionStorage? This will also reload the page.'
)
) {
return;
}
>
<button
type="button"
onclick={() => {
if ($ae_loc.edit_mode) {
// Confirm before clearing
if (
!confirm(
'Are you sure you want to clear IndexedDB databases, localStorage, and sessionStorage? This will also reload the page.'
)
) {
return;
}
console.log(
'Clearing IndexedDB, localStorage, sessionStorage, and reloading the page...'
);
console.log(
'Clearing IndexedDB, localStorage, sessionStorage, and reloading the page...'
);
// Clear Indexed DB
indexedDB.deleteDatabase('ae_archives_db'); // Archives module
indexedDB.deleteDatabase('ae_core_db');
indexedDB.deleteDatabase('ae_events_db'); // Events module
indexedDB.deleteDatabase('ae_journals_db'); // Journals module
indexedDB.deleteDatabase('ae_posts_db'); // Posts module
indexedDB.deleteDatabase('ae_sponsorships_db'); // Sponsorships module
// Clear Indexed DB
indexedDB.deleteDatabase('ae_archives_db'); // Archives module
indexedDB.deleteDatabase('ae_core_db');
indexedDB.deleteDatabase('ae_events_db'); // Events module
indexedDB.deleteDatabase('ae_journals_db'); // Journals module
indexedDB.deleteDatabase('ae_posts_db'); // Posts module
indexedDB.deleteDatabase('ae_sponsorships_db'); // Sponsorships module
// Clear localStorage and sessionStorage
// Clearing the localStorage will force it to be re-created.
localStorage.clear();
sessionStorage.clear();
// Clear localStorage and sessionStorage
// Clearing the localStorage will force it to be re-created.
localStorage.clear();
sessionStorage.clear();
goto('/', { invalidateAll: true });
goto('/', { invalidateAll: true });
// window.location.reload(true);
} else {
// Confirm before clearing
if (
!confirm(
'Are you sure you want to clear IndexedDB databases and some caches? This will also reload the page.'
)
) {
return;
}
// window.location.reload(true);
} else {
// Confirm before clearing
if (
!confirm(
'Are you sure you want to clear IndexedDB databases and some caches? This will also reload the page.'
)
) {
return;
}
console.log(
'Clearing IndexedDB, localStorage, sessionStorage, and reloading the page...'
);
console.log(
'Clearing IndexedDB, localStorage, sessionStorage, and reloading the page...'
);
// Clear Indexed DB
indexedDB.deleteDatabase('ae_archives_db'); // Archives module
indexedDB.deleteDatabase('ae_core_db');
indexedDB.deleteDatabase('ae_events_db'); // Events module
indexedDB.deleteDatabase('ae_journals_db'); // Journals module
indexedDB.deleteDatabase('ae_posts_db'); // Posts module
indexedDB.deleteDatabase('ae_sponsorships_db'); // Sponsorships module
// Clear Indexed DB
indexedDB.deleteDatabase('ae_archives_db'); // Archives module
indexedDB.deleteDatabase('ae_core_db');
indexedDB.deleteDatabase('ae_events_db'); // Events module
indexedDB.deleteDatabase('ae_journals_db'); // Journals module
indexedDB.deleteDatabase('ae_posts_db'); // Posts module
indexedDB.deleteDatabase('ae_sponsorships_db'); // Sponsorships module
window.location.reload(true);
}
window.location.reload(true);
}
// This does not seem to work fast enough or something?
// goto('/', {invalidateAll: true});
// This does not seem to work fast enough or something?
// goto('/', {invalidateAll: true});
// The page does usually seem to reload correctly?
// window.location.reload(true); // true only works with Firefox
// alert('Local and Session Storage cleared and Indexed DBs deleted. You will probably want to refresh the page.');
}}
class="
// The page does usually seem to reload correctly?
// window.location.reload(true); // true only works with Firefox
// alert('Local and Session Storage cleared and Indexed DBs deleted. You will probably want to refresh the page.');
}}
class="
btn btn-sm
preset-tonal-surface
preset-outlined-warning-100-900
@@ -526,19 +533,19 @@ class:to-90%={$ae_sess.show_help_tech} -->
transition-all
{btn_class}
"
title="Clear App Data & Settings: Clear IndexedDB and reload. If in edit mode localStorage and sessionStorage will also be cleared."
>
<!-- <span class="fas fa-eraser mx-1"></span> -->
<!-- <span class="fas fa-sync mx-1"></span> -->
<RefreshCw size="1em" class="inline-block" />
<span class="md:inline">Clear & Reload</span>
</button>
title="Clear App Data & Settings: Clear IndexedDB and reload. If in edit mode localStorage and sessionStorage will also be cleared."
>
<!-- <span class="fas fa-eraser mx-1"></span> -->
<!-- <span class="fas fa-sync mx-1"></span> -->
<RefreshCw size="1em" class="inline-block" />
<span class="md:inline">Clear & Reload</span>
</button>
<!-- Cancel button -->
<button
type="button"
onclick={() => ($ae_sess.show_help_tech = false)}
class="
<!-- Cancel button -->
<button
type="button"
onclick={() => ($ae_sess.show_help_tech = false)}
class="
btn btn-sm
preset-tonal-tertiary
preset-outlined-tertiary-100-900
@@ -546,19 +553,19 @@ class:to-90%={$ae_sess.show_help_tech} -->
transition-all
{btn_class}
"
title="Close Help Request Form"
>
<!-- <span class="fas fa-times"></span> -->
<SquareX size="1em" class="inline-block" />
<span class="">Cancel</span>
</button>
</div>
</div>
{:else}
<button
type="button"
onclick={() => ($ae_sess.show_help_tech = true)}
class="
title="Close Help Request Form"
>
<!-- <span class="fas fa-times"></span> -->
<SquareX size="1em" class="inline-block" />
<span class="">Cancel</span>
</button>
</div>
</div>
{:else}
<button
type="button"
onclick={() => ($ae_sess.show_help_tech = true)}
class="
btn btn-sm
preset-filled-tertiary-400-600
preset-outlined-tertiary-100-900
@@ -567,14 +574,14 @@ class:to-90%={$ae_sess.show_help_tech} -->
{btn_class}
{show_btn_class}
"
title={btn_title}
>
{#if !hide_icon}
<BadgeQuestionMark class="inline-block m-0.5" />
{/if}
<span class="hidden">
{btn_text}
</span>
</button>
{/if}
title={btn_title}
>
{#if !hide_icon}
<BadgeQuestionMark class="inline-block m-0.5" />
{/if}
<span class="hidden">
{btn_text}
</span>
</button>
{/if}
</div>

File diff suppressed because it is too large Load Diff

View File

@@ -1,54 +1,54 @@
<script lang="ts">
// *** Import Svelte specific
// import { tick } from 'svelte';
// import { goto, invalidateAll } from '$app/navigation';
// *** Import Svelte specific
// import { tick } from 'svelte';
// import { goto, invalidateAll } from '$app/navigation';
// *** Import other supporting libraries
import {
// ArrowBigRight,
// Bug,
CircleX,
// Eye, EyeOff,
// Key,
// LogIn, LogOut, LockKeyhole,
// Mail, MailCheck,
Menu,
// RefreshCw, RefreshCcwDot,
ShieldEllipsis,
ShieldMinus,
ShieldPlus,
ShieldUser,
// ToggleLeft, ToggleRight,
User,
UserCheck,
X
} from '@lucide/svelte';
// *** Import other supporting libraries
import {
// ArrowBigRight,
// Bug,
CircleX,
// Eye, EyeOff,
// Key,
// LogIn, LogOut, LockKeyhole,
// Mail, MailCheck,
Menu,
// RefreshCw, RefreshCcwDot,
ShieldEllipsis,
ShieldMinus,
ShieldPlus,
ShieldUser,
// ToggleLeft, ToggleRight,
User,
UserCheck,
X
} 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 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 Element_access_type from '$lib/app_components/e_app_access_type.svelte';
import Element_app_cfg from '$lib/app_components/e_app_cfg.svelte';
import Element_sign_in_out from '$lib/app_components/e_app_sign_in_out.svelte';
import Element_theme from '$lib/app_components/e_app_theme.svelte';
import Element_access_type from '$lib/app_components/e_app_access_type.svelte';
import Element_app_cfg from '$lib/app_components/e_app_cfg.svelte';
import Element_sign_in_out from '$lib/app_components/e_app_sign_in_out.svelte';
import Element_theme from '$lib/app_components/e_app_theme.svelte';
// *** Setup Svelte properties
interface Props {
log_lvl?: number;
data: any;
hide?: null | boolean;
expand?: boolean;
}
// *** Setup Svelte properties
interface Props {
log_lvl?: number;
data: any;
hide?: null | boolean;
expand?: boolean;
}
let {
log_lvl = $bindable(0),
data = null,
hide = $bindable(false),
expand = $bindable(false)
}: Props = $props();
let {
log_lvl = $bindable(0),
data = null,
hide = $bindable(false),
expand = $bindable(false)
}: Props = $props();
let trigger_clear_access: null | boolean = $state(null);
let trigger_clear_access: null | boolean = $state(null);
</script>
<!-- App System Menu -->
@@ -87,7 +87,7 @@ max-w-max -->
<!-- mx-1 my-2 -->
<!-- We need to be able to hide the menu button in certain situations. Mainly iframes. -->
<section
class="
class="
ae_app__sys_menu
hidden-print
@@ -116,21 +116,21 @@ max-w-max -->
duration-500 hover:duration-200
ease-in-out
"
class:top-0={expand && 1 == 3}
class:opacity-100={expand}
class:w-full={expand}
class:hidden={hide}
class:border-transparent={!expand}
class:bg-transparent={!expand}
class:top-0={expand && 1 == 3}
class:opacity-100={expand}
class:w-full={expand}
class:hidden={hide}
class:border-transparent={!expand}
class:bg-transparent={!expand}
>
<!-- class:hidden={!expand} -->
<!-- class:preset-filled-warning-100-900={expand} -->
<div
class:opacity-50={!expand}
class:opacity-100={expand}
class:light:bg-blue-500={expand}
class:dark:bg-blue-500={expand}
class="
<!-- class:hidden={!expand} -->
<!-- class:preset-filled-warning-100-900={expand} -->
<div
class:opacity-50={!expand}
class:opacity-100={expand}
class:light:bg-blue-500={expand}
class:dark:bg-blue-500={expand}
class="
hidden-print
flex flex-col items-end justify-end
gap-1
@@ -151,193 +151,202 @@ max-w-max -->
duration-200 hover:duration-200
ease-in-out
"
title="
title="
ID: {$ae_loc?.person_id ?? '-- not set --'} / {$ae_loc?.user_id ?? '-- not set --'}
Name: {$ae_loc?.person?.full_name ?? '-- not set --'}
Username: {$ae_loc?.user?.username ?? '-- not set --'}
Email: {$ae_loc?.user?.email ?? '-- not set --'}
Access Type: {$ae_loc?.access_type ?? '-- not set --'}
"
>
{#if $ae_loc?.person_id}
<div class="flex flex-row gap-1 items-center justify-end transition-all w-full group">
<User size="1em" class="mx-1 inline-block text-gray-500" />
<span class:hidden={!expand} class="group-hover:inline-block">
{$ae_loc?.person?.informal_name ?? $ae_loc?.person?.given_name}
</span>
</div>
{/if}
>
{#if $ae_loc?.person_id}
<div class="flex flex-row gap-1 items-center justify-end transition-all w-full group">
<User size="1em" class="mx-1 inline-block text-gray-500" />
<span class:hidden={!expand} class="group-hover:inline-block">
{$ae_loc?.person?.informal_name ?? $ae_loc?.person?.given_name}
</span>
</div>
{/if}
{#if $ae_loc?.user_id}
<!-- This is currently not set to show if not expanded. Saving space. -->
<div
class:hidden={!expand}
class="flex flex-row gap-1 items-center justify-end transition-all w-full group"
>
<ShieldUser size="1em" class="mx-1 inline-block text-gray-500" />
<span class:hidden={!expand} class="group-hover:inline-block">
{$ae_loc?.user?.username ?? '-- not set --'}
</span>
</div>
{/if}
{#if $ae_loc?.user_id}
<!-- This is currently not set to show if not expanded. Saving space. -->
<div
class:hidden={!expand}
class="flex flex-row gap-1 items-center justify-end transition-all w-full group"
>
<ShieldUser size="1em" class="mx-1 inline-block text-gray-500" />
<span class:hidden={!expand} class="group-hover:inline-block">
{$ae_loc?.user?.username ?? '-- not set --'}
</span>
</div>
{/if}
<div class="flex flex-row gap-1 items-center justify-end transition-all w-full group">
{#if $ae_loc.access_type && $ae_loc.access_type != 'anonymous'}
<span
class="flex flex-row-reverse gap-1 group text-base"
title={`Current access type/level: ${$ae_loc.access_type}`}
>
<!-- <span class="fas fa-unlock mx-1"></span> -->
<!-- <ShieldPlus class="inline-block" /> -->
<div class="flex flex-row gap-1 items-center justify-end transition-all w-full group">
{#if $ae_loc.access_type && $ae_loc.access_type != 'anonymous'}
<span
class="flex flex-row-reverse gap-1 group text-base"
title={`Current access type/level: ${$ae_loc.access_type}`}
>
<!-- <span class="fas fa-unlock mx-1"></span> -->
<!-- <ShieldPlus class="inline-block" /> -->
{#if $ae_loc.access_type == 'super'}
<span class="fas fa-hat-wizard m-1"></span>
<span class:hidden={!expand} class="hidden group-hover:inline-block">Super</span>
{:else if $ae_loc.access_type == 'manager'}
<span class="fas fa-user-shield m-1"></span>
<span class:hidden={!expand} class="hidden group-hover:inline-block">Manager</span>
{:else if $ae_loc.access_type == 'administrator'}
<span class="fas fa-user-ninja m-1"></span>
<span class:hidden={!expand} class="hidden group-hover:inline-block">Administrator</span
>
{:else if $ae_loc.access_type == 'trusted'}
<span class="fas fa-user-check m-1"></span>
<span class:hidden={!expand} class="hidden group-hover:inline-block"
>Trusted Access</span
>
{:else if $ae_loc.access_type == 'public'}
Public
<span class:hidden={!expand} class="hidden group-hover:inline-block">Access</span>
{:else if $ae_loc.access_type == 'authenticated'}
Authenticated
<span class:hidden={!expand} class="hidden group-hover:inline-block">Access</span>
{:else if $ae_loc.access_type == 'anonymous'}
Anonymous Access
{:else}
Unknown Access
{/if}
</span>
{#if $ae_loc.access_type == 'super'}
<span class="fas fa-hat-wizard m-1"></span>
<span class:hidden={!expand} class="hidden group-hover:inline-block"
>Super</span
>
{:else if $ae_loc.access_type == 'manager'}
<span class="fas fa-user-shield m-1"></span>
<span class:hidden={!expand} class="hidden group-hover:inline-block"
>Manager</span
>
{:else if $ae_loc.access_type == 'administrator'}
<span class="fas fa-user-ninja m-1"></span>
<span class:hidden={!expand} class="hidden group-hover:inline-block"
>Administrator</span
>
{:else if $ae_loc.access_type == 'trusted'}
<span class="fas fa-user-check m-1"></span>
<span class:hidden={!expand} class="hidden group-hover:inline-block"
>Trusted Access</span
>
{:else if $ae_loc.access_type == 'public'}
Public
<span class:hidden={!expand} class="hidden group-hover:inline-block"
>Access</span
>
{:else if $ae_loc.access_type == 'authenticated'}
Authenticated
<span class:hidden={!expand} class="hidden group-hover:inline-block"
>Access</span
>
{:else if $ae_loc.access_type == 'anonymous'}
Anonymous Access
{:else}
Unknown Access
{/if}
</span>
{#if $ae_loc?.user_access_type && $ae_loc?.access_type == $ae_loc?.user_access_type}
<button
type="button"
onclick={() => {
// handle_clear_access();
// trigger_clear_access = true;
// $ae_loc.app_cfg.show_element__passcode_input = !$ae_loc.app_cfg.show_element__passcode_input;
{#if $ae_loc?.user_access_type && $ae_loc?.access_type == $ae_loc?.user_access_type}
<button
type="button"
onclick={() => {
// handle_clear_access();
// trigger_clear_access = true;
// $ae_loc.app_cfg.show_element__passcode_input = !$ae_loc.app_cfg.show_element__passcode_input;
if (!expand) {
expand = true;
$ae_sess.sys_menu.expand = true;
$ae_loc.sys_menu.hide_access_type = false;
$ae_loc.sys_menu.expand_access_type = true;
// $ae_loc.sys_menu.expand_btn = false;
// $ae_loc.app_cfg.show_element__access_type = true;
// $ae_loc.app_cfg.show_element__passcode_input = true;
} else {
// expand = true;
// $ae_loc.sys_menu.expand = false;
$ae_loc.sys_menu.hide_access_type = false;
$ae_loc.sys_menu.expand_access_type = true;
if (!expand) {
expand = true;
$ae_sess.sys_menu.expand = true;
$ae_loc.sys_menu.hide_access_type = false;
$ae_loc.sys_menu.expand_access_type = true;
// $ae_loc.sys_menu.expand_btn = false;
// $ae_loc.app_cfg.show_element__access_type = true;
// $ae_loc.app_cfg.show_element__passcode_input = true;
} else {
// expand = true;
// $ae_loc.sys_menu.expand = false;
$ae_loc.sys_menu.hide_access_type = false;
$ae_loc.sys_menu.expand_access_type = true;
// $ae_loc.sys_menu.expand_btn = true;
}
}}
class="btn btn-sm text-xs variant-outline-surface hover:variant-ghost-warning transition-all group"
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 size="2em" class="inline-block" />
<span class="hidden group-hover:inline-block">Passcode?</span>
</button>
{:else}
<button
type="button"
onclick={() => {
trigger_clear_access = true;
// $ae_loc.sys_menu.expand_btn = true;
}
}}
class="btn btn-sm text-xs variant-outline-surface hover:variant-ghost-warning transition-all group"
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 size="2em" class="inline-block" />
<span class="hidden group-hover:inline-block">Passcode?</span>
</button>
{:else}
<button
type="button"
onclick={() => {
trigger_clear_access = true;
if (expand) {
$ae_loc.sys_menu.hide_access_type = false;
// $ae_loc.sys_menu.expand_access_type = false;
expand = false;
if (expand) {
$ae_loc.sys_menu.hide_access_type = false;
// $ae_loc.sys_menu.expand_access_type = false;
expand = false;
// $ae_loc.sys_menu.expand = true;
// $ae_loc.sys_menu.expand_btn = false;
$ae_loc.app_cfg.show_element__access_type = true;
$ae_sess.app_cfg.show_element__passcode_input = true;
// $ae_loc.sys_menu.expand = true;
// $ae_loc.sys_menu.expand_btn = false;
$ae_loc.app_cfg.show_element__access_type = true;
$ae_sess.app_cfg.show_element__passcode_input = true;
// await tick();
// console.log('Layout button click: Focus on passcode input!');
// /** @type {HTMLElement | null} */
// const to_focus = document.getElementById('access_passcode_input');
// to_focus?.focus();
} else {
$ae_loc.sys_menu.hide_access_type = false;
$ae_loc.sys_menu.expand_access_type = true;
// $ae_loc.sys_menu.expand = false;
// $ae_loc.sys_menu.expand_btn = true;
}
}}
class="
// await tick();
// console.log('Layout button click: Focus on passcode input!');
// /** @type {HTMLElement | null} */
// const to_focus = document.getElementById('access_passcode_input');
// to_focus?.focus();
} else {
$ae_loc.sys_menu.hide_access_type = false;
$ae_loc.sys_menu.expand_access_type = true;
// $ae_loc.sys_menu.expand = false;
// $ae_loc.sys_menu.expand_btn = true;
}
}}
class="
btn btn-sm text-xs
flex-row-reverse
variant-outline-surface hover:variant-ghost-warning
transition-all group
"
title={`Current access level: "${$ae_loc.access_type}". Click to clear the temporary access level.`}
>
<!-- <span class="fas fa-lock mx-1"></span> Lock? -->
<ShieldMinus class="inline-block" />
<span class="hidden group-hover:inline-block"> Clear? </span>
</button>
{/if}
{:else}
<button
type="button"
onclick={async () => {
expand = true;
$ae_sess.sys_menu.expand = true;
$ae_loc.sys_menu.hide_access_type = false;
$ae_loc.sys_menu.expand_access_type = true;
title={`Current access level: "${$ae_loc.access_type}". Click to clear the temporary access level.`}
>
<!-- <span class="fas fa-lock mx-1"></span> Lock? -->
<ShieldMinus class="inline-block" />
<span class="hidden group-hover:inline-block"> Clear? </span>
</button>
{/if}
{:else}
<button
type="button"
onclick={async () => {
expand = true;
$ae_sess.sys_menu.expand = true;
$ae_loc.sys_menu.hide_access_type = false;
$ae_loc.sys_menu.expand_access_type = true;
$ae_sess.app_cfg.show_element__passcode_input = true;
$ae_sess.sys_menu.focus_passcode_input = true;
$ae_sess.app_cfg.show_element__passcode_input = true;
$ae_sess.sys_menu.focus_passcode_input = true;
// $ae_loc.sys_menu.expand = true;
// $ae_loc.sys_menu.expand_btn = false;
// $ae_loc.app_cfg.show_element__access_type = true;
// $ae_loc.app_cfg.show_element__passcode_input = true;
// await tick();
console.log('Layout button click: Focus on passcode input!');
/** @type {HTMLElement | null} */
const to_focus = document.getElementById('access_passcode_input');
to_focus?.focus();
}}
class="
// $ae_loc.sys_menu.expand = true;
// $ae_loc.sys_menu.expand_btn = false;
// $ae_loc.app_cfg.show_element__access_type = true;
// $ae_loc.app_cfg.show_element__passcode_input = true;
// await tick();
console.log('Layout button click: Focus on passcode input!');
/** @type {HTMLElement | null} */
const to_focus = document.getElementById('access_passcode_input');
to_focus?.focus();
}}
class="
btn btn-sm text-xs
flex-row-reverse
variant-outline-surface hover:variant-ghost-success
transition-all group
"
title="Anonymous public access is currently set. You must Sign In or use a passcode to change your access level."
>
<!-- <span class="fas fa-lock mx-1 lock_icon"></span> -->
<!-- <span class="">Unlock?</span> -->
<ShieldUser class="inline-block" />
<span class="hidden group-hover:inline-block">Auth?</span>
</button>
{/if}
</div>
title="Anonymous public access is currently set. You must Sign In or use a passcode to change your access level."
>
<!-- <span class="fas fa-lock mx-1 lock_icon"></span> -->
<!-- <span class="">Unlock?</span> -->
<ShieldUser class="inline-block" />
<span class="hidden group-hover:inline-block">Auth?</span>
</button>
{/if}
</div>
{#if $ae_loc.edit_mode}
<button
type="button"
onclick={() => {
$ae_loc.edit_mode = false;
// dispatch_edit_mode_changed();
}}
class="
{#if $ae_loc.edit_mode}
<button
type="button"
onclick={() => {
$ae_loc.edit_mode = false;
// dispatch_edit_mode_changed();
}}
class="
btn btn-base text-sm
preset-tonal-warning
preset-outlined-warning-800-200
@@ -346,20 +355,20 @@ max-w-max -->
min-w-22 md:min-w-30 w-full max-w-fit
gap-1
"
title="Click to turn off edit mode. Edit mode is currently on."
>
<span class="fas fa-toggle-on m-1 inline-block"></span>
<span class="text-xs">Edit</span>
<span class="hidden group-hover:inline-block group-hover:text-xs"> Off </span>
</button>
{:else if $ae_loc.authenticated_access}
<button
type="button"
onclick={() => {
$ae_loc.edit_mode = true;
// dispatch_edit_mode_changed();
}}
class="
title="Click to turn off edit mode. Edit mode is currently on."
>
<span class="fas fa-toggle-on m-1 inline-block"></span>
<span class="text-xs">Edit</span>
<span class="hidden group-hover:inline-block group-hover:text-xs"> Off </span>
</button>
{:else if $ae_loc.authenticated_access}
<button
type="button"
onclick={() => {
$ae_loc.edit_mode = true;
// dispatch_edit_mode_changed();
}}
class="
btn btn-base text-sm
preset-tonal-surface
preset-outlined-warning-400-600
@@ -368,23 +377,23 @@ max-w-max -->
min-w-22 md:min-w-30 w-full max-w-fit
gap-1
"
title="Click to torn on/enable edit mode. Edit mode is currently off/disabled."
>
<span class="fas fa-toggle-off m-1 inline-block"></span>
<span class="text-xs">Edit</span>
<span class="hidden group-hover:inline-block group-hover:text-xs"> On? </span>
</button>
{/if}
title="Click to torn on/enable edit mode. Edit mode is currently off/disabled."
>
<span class="fas fa-toggle-off m-1 inline-block"></span>
<span class="text-xs">Edit</span>
<span class="hidden group-hover:inline-block group-hover:text-xs"> On? </span>
</button>
{/if}
<!-- <div> -->
<!-- class:visible={expand} -->
<!-- class:invisible={!expand} -->
<!-- class:hover:visible={true} -->
<!-- invisible -->
<button
type="button"
class:w-full={expand}
class="
<!-- <div> -->
<!-- class:visible={expand} -->
<!-- class:invisible={!expand} -->
<!-- class:hover:visible={true} -->
<!-- invisible -->
<button
type="button"
class:w-full={expand}
class="
btn btn-base text-sm
preset-filled-tertiary-400-600
preset-outlined-tertiary-400-600
@@ -393,62 +402,62 @@ max-w-max -->
min-w-22 md:min-w-30 w-full max-w-fit
transition-all group
"
title="Show/Hide the system menu"
onclick={async () => {
if (!expand) {
expand = true;
$ae_sess.sys_menu.expand = true;
title="Show/Hide the system menu"
onclick={async () => {
if (!expand) {
expand = true;
$ae_sess.sys_menu.expand = true;
// $ae_loc.sys_menu.expand = true;
// $ae_loc.sys_menu.expand_btn = false;
$ae_loc.app_cfg.show_element__access_type = true;
// $ae_loc.sys_menu.expand = true;
// $ae_loc.sys_menu.expand_btn = false;
$ae_loc.app_cfg.show_element__access_type = true;
if ($ae_loc?.access_type == 'anonymous') {
$ae_sess.sys_menu.focus_passcode_input = true;
// $ae_sess.app_cfg.show_element__passcode_input = true;
} else {
// $ae_sess.app_cfg.show_element__passcode_input = false;
$ae_loc.sys_menu.expand_user = false; // Not in use yet
$ae_sess.show__sign_in_out__fields = false;
}
// $ae_loc.app_cfg.show_element__passcode_input = true;
// await tick();
// console.log('Layout button click: Focus on passcode input!');
// /** @type {HTMLElement | null} */
// const to_focus = document.getElementById('access_passcode_input');
// to_focus?.focus();
} else {
expand = false;
$ae_sess.sys_menu.expand = false;
// $ae_loc.sys_menu.expand = false;
// $ae_loc.sys_menu.expand_btn = true;
// $ae_loc.app_cfg.show_element__passcode_input = false;
}
// $ae_loc.sys_menu.expand_btn = !expand_btn;
}}
>
<!-- <span class=""> -->
{#if expand}
<CircleX class="m-1 inline-block" />
{:else}
<Menu class="m-1 inline-block" />
{/if}
<span class="text-xs hidden group-hover:inline-block"> Menu </span>
<!-- </span> -->
</button>
<!-- </div> -->
</div>
if ($ae_loc?.access_type == 'anonymous') {
$ae_sess.sys_menu.focus_passcode_input = true;
// $ae_sess.app_cfg.show_element__passcode_input = true;
} else {
// $ae_sess.app_cfg.show_element__passcode_input = false;
$ae_loc.sys_menu.expand_user = false; // Not in use yet
$ae_sess.show__sign_in_out__fields = false;
}
// $ae_loc.app_cfg.show_element__passcode_input = true;
// await tick();
// console.log('Layout button click: Focus on passcode input!');
// /** @type {HTMLElement | null} */
// const to_focus = document.getElementById('access_passcode_input');
// to_focus?.focus();
} else {
expand = false;
$ae_sess.sys_menu.expand = false;
// $ae_loc.sys_menu.expand = false;
// $ae_loc.sys_menu.expand_btn = true;
// $ae_loc.app_cfg.show_element__passcode_input = false;
}
// $ae_loc.sys_menu.expand_btn = !expand_btn;
}}
>
<!-- <span class=""> -->
{#if expand}
<CircleX class="m-1 inline-block" />
{:else}
<Menu class="m-1 inline-block" />
{/if}
<span class="text-xs hidden group-hover:inline-block"> Menu </span>
<!-- </span> -->
</button>
<!-- </div> -->
</div>
<!-- Show menu on right side of page -->
<!-- min-h-96 -->
<!-- absolute right-0 bottom-10 -->
<!-- opacity-50 -->
<!-- hover:opacity-100 -->
<!-- bg-white dark:bg-gray-800 -->
<div
class:preset-filled-warning-200-800={expand}
class:hidden={!expand}
class="
<!-- Show menu on right side of page -->
<!-- min-h-96 -->
<!-- absolute right-0 bottom-10 -->
<!-- opacity-50 -->
<!-- hover:opacity-100 -->
<!-- bg-white dark:bg-gray-800 -->
<div
class:preset-filled-warning-200-800={expand}
class:hidden={!expand}
class="
ae_app__sys_menu
hidden-print
@@ -472,11 +481,11 @@ max-w-max -->
z-20 hover:z-30
"
>
<button
type="button"
class:w-full={expand}
class="
>
<button
type="button"
class:w-full={expand}
class="
btn btn-sm
preset-filled-tertiary-400-600
preset-outlined-tertiary-400-600
@@ -484,70 +493,70 @@ max-w-max -->
px-6 py-1
transition-all group
"
title="Show/Hide the system menu"
onclick={() => {
if (!expand) {
expand = true;
$ae_sess.sys_menu.expand = true;
// $ae_loc.sys_menu.expand_btn = false;
// $ae_loc.sys_menu.expand_access_type = true;
title="Show/Hide the system menu"
onclick={() => {
if (!expand) {
expand = true;
$ae_sess.sys_menu.expand = true;
// $ae_loc.sys_menu.expand_btn = false;
// $ae_loc.sys_menu.expand_access_type = true;
// $ae_sess.app_cfg.show_element__passcode_input = true;
$ae_sess.sys_menu.focus_passcode_input = true;
} else {
$ae_sess.sys_menu.expand = false;
$ae_loc.sys_menu.expand_user = false; // Not in use yet
$ae_sess.show__sign_in_out__fields = false;
// $ae_loc.sys_menu.expand_btn = true;
}
// $ae_loc.sys_menu.expand_btn = !expand_btn;
// $ae_loc.sys_menu.expand = !expand;
}}
>
{#if expand}
<CircleX class="m-1 inline-block" />
<span class="hidden group-hover:inline-block"> Hide Menu </span>
{:else}
<Menu class="m-1 inline-block" />
<span class="hidden group-hover:inline-block"> Menu </span>
{/if}
</button>
// $ae_sess.app_cfg.show_element__passcode_input = true;
$ae_sess.sys_menu.focus_passcode_input = true;
} else {
$ae_sess.sys_menu.expand = false;
$ae_loc.sys_menu.expand_user = false; // Not in use yet
$ae_sess.show__sign_in_out__fields = false;
// $ae_loc.sys_menu.expand_btn = true;
}
// $ae_loc.sys_menu.expand_btn = !expand_btn;
// $ae_loc.sys_menu.expand = !expand;
}}
>
{#if expand}
<CircleX class="m-1 inline-block" />
<span class="hidden group-hover:inline-block"> Hide Menu </span>
{:else}
<Menu class="m-1 inline-block" />
<span class="hidden group-hover:inline-block"> Menu </span>
{/if}
</button>
<!-- {#if $ae_loc?.app_cfg?.show_element__cfg} -->
<span class:hidden={!$ae_loc.edit_mode}>
<Element_app_cfg
hide={$ae_loc.sys_menu.hide_app_cfg}
expand={$ae_loc.sys_menu.expand_app_cfg}
/>
</span>
<span class:hidden={!$ae_loc.edit_mode}>
<Element_theme
hide={$ae_loc.sys_menu.hide_app_cfg}
expand={$ae_loc.sys_menu.expand_app_cfg}
set_theme_mode={true}
set_theme_name={true}
/>
</span>
<!-- {/if} -->
<!-- {#if $ae_loc?.app_cfg?.show_element__cfg} -->
<span class:hidden={!$ae_loc.edit_mode}>
<Element_app_cfg
hide={$ae_loc.sys_menu.hide_app_cfg}
expand={$ae_loc.sys_menu.expand_app_cfg}
/>
</span>
<span class:hidden={!$ae_loc.edit_mode}>
<Element_theme
hide={$ae_loc.sys_menu.hide_app_cfg}
expand={$ae_loc.sys_menu.expand_app_cfg}
set_theme_mode={true}
set_theme_name={true}
/>
</span>
<!-- {/if} -->
{#if $ae_loc?.app_cfg?.show_element__sign_in_out}
<!-- hide={$ae_loc.sys_menu.hide_user} -->
<!-- expand={$ae_loc.sys_menu.expand_user} -->
<Element_sign_in_out
{data}
hidden={$ae_loc.iframe || !$ae_loc.app_cfg?.show_element__sign_in_out}
/>
{/if}
{#if $ae_loc?.app_cfg?.show_element__sign_in_out}
<!-- hide={$ae_loc.sys_menu.hide_user} -->
<!-- expand={$ae_loc.sys_menu.expand_user} -->
<Element_sign_in_out
{data}
hidden={$ae_loc.iframe || !$ae_loc.app_cfg?.show_element__sign_in_out}
/>
{/if}
{#if !$ae_loc?.sys_menu?.hide_access_type && !$ae_loc?.iframe}
<!-- hidden={$ae_loc?.iframe && !$ae_loc?.trusted_access && !expand} -->
<Element_access_type
bind:hide={$ae_loc.sys_menu.hide_access_type}
bind:focus_input={$ae_sess.sys_menu.focus_passcode_input}
bind:expand={$ae_loc.sys_menu.expand_access_type}
bind:show_passcode_input={$ae_sess.app_cfg.show_element__passcode_input}
bind:trigger_clear_access
/>
{/if}
</div>
{#if !$ae_loc?.sys_menu?.hide_access_type && !$ae_loc?.iframe}
<!-- hidden={$ae_loc?.iframe && !$ae_loc?.trusted_access && !expand} -->
<Element_access_type
bind:hide={$ae_loc.sys_menu.hide_access_type}
bind:focus_input={$ae_sess.sys_menu.focus_passcode_input}
bind:expand={$ae_loc.sys_menu.expand_access_type}
bind:show_passcode_input={$ae_sess.app_cfg.show_element__passcode_input}
bind:trigger_clear_access
/>
{/if}
</div>
</section>

View File

@@ -1,23 +1,23 @@
<script lang="ts">
import { Moon, Sun } from '@lucide/svelte';
import { Moon, Sun } from '@lucide/svelte';
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/stores/ae_stores';
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/stores/ae_stores';
interface Props {
log_lvl?: number;
hide?: null | boolean;
expand?: boolean;
set_theme_mode: any;
set_theme_name: any;
}
interface Props {
log_lvl?: number;
hide?: null | boolean;
expand?: boolean;
set_theme_mode: any;
set_theme_name: any;
}
let {
log_lvl = $bindable(0),
hide = $bindable(false),
expand = $bindable(false),
set_theme_mode,
set_theme_name
}: Props = $props();
let {
log_lvl = $bindable(0),
hide = $bindable(false),
expand = $bindable(false),
set_theme_mode,
set_theme_name
}: Props = $props();
</script>
<!-- Change light and dark mode -->
@@ -31,8 +31,8 @@ if ($ae_loc.app_cfg.theme_mode == 'light') {
}
-->
<section
id="AE-App-Theme"
class="
id="AE-App-Theme"
class="
ae_app_theme
hidden-print
@@ -49,175 +49,175 @@ if ($ae_loc.app_cfg.theme_mode == 'light') {
duration-300 delay-150 hover:delay-1000 hover:ease-out
transition-all
"
class:hidden={hide}
class:hidden={hide}
>
<div
class:hidden={!expand}
class="flex flex-row flex-wrap gap-2 items-center justify-between w-full"
>
<!-- Theme Name: -->
<span class="text-sm font-semibold">
{$ae_loc.theme_name}
</span>
<select
onchange={(event) => {
// $slct_trigger = 'set_theme_name';
<div
class:hidden={!expand}
class="flex flex-row flex-wrap gap-2 items-center justify-between w-full"
>
<!-- Theme Name: -->
<span class="text-sm font-semibold">
{$ae_loc.theme_name}
</span>
<select
onchange={(event) => {
// $slct_trigger = 'set_theme_name';
let new_theme_name = event.target.value;
// document.documentElement.theme = new_theme_name;
let new_theme_name = event.target.value;
// document.documentElement.theme = new_theme_name;
console.log(`$ae_loc?.theme_name=${$ae_loc?.theme_name}`);
// $slct_trigger = null;
// Update the body attribute named "data-theme" to the current theme name.
// document.body.setAttribute('data-theme', new_theme_name);
// document.body.setAttribute('data-theme', $ae_loc?.theme_name);
console.log(`$ae_loc?.theme_name=${$ae_loc?.theme_name}`);
// $slct_trigger = null;
// Update the body attribute named "data-theme" to the current theme name.
// document.body.setAttribute('data-theme', new_theme_name);
// document.body.setAttribute('data-theme', $ae_loc?.theme_name);
// NEW for Tailwind v4: Update the html attribute named "data-theme" to the current theme name.
document.documentElement.setAttribute('data-theme', new_theme_name);
// NEW for Tailwind v4: Update the html attribute named "data-theme" to the current theme name.
document.documentElement.setAttribute('data-theme', new_theme_name);
// if ($ae_loc.theme_mode == 'light') {
// document.documentElement.classList.remove('dark');
// document.documentElement.classList.add('light');
// } else if ($ae_loc.theme_mode == 'dark') {
// document.documentElement.classList.remove('light');
// document.documentElement.classList.add('dark');
// }
}}
bind:value={$ae_loc.theme_name}
class="select w-32"
title="Theme name"
>
<option value="">-- None --</option>
<option value="cerberus">Cerberus</option>
<option value="concord">Concord</option>
<option value="crimson">Crimson</option>
<option value="hamlindigo">Hamlindigo</option>
<option value="modern">Modern</option>
<option value="nouveau">Nouveau</option>
<option value="rocket">Rocket</option>
<option value="terminus">Terminus</option>
<option value="vintage">Vintage</option>
<option value="wintry">Wintry</option>
<!-- <option value="ae_c_osit">OSIT</option> -->
<option value="AE_OSIT_default">OSIT</option>
<option value="AE_c_IDAA_light">IDAA - light</option>
<option value="AE_c_LCI">LCI</option>
</select>
</div>
// if ($ae_loc.theme_mode == 'light') {
// document.documentElement.classList.remove('dark');
// document.documentElement.classList.add('light');
// } else if ($ae_loc.theme_mode == 'dark') {
// document.documentElement.classList.remove('light');
// document.documentElement.classList.add('dark');
// }
}}
bind:value={$ae_loc.theme_name}
class="select w-32"
title="Theme name"
>
<option value="">-- None --</option>
<option value="cerberus">Cerberus</option>
<option value="concord">Concord</option>
<option value="crimson">Crimson</option>
<option value="hamlindigo">Hamlindigo</option>
<option value="modern">Modern</option>
<option value="nouveau">Nouveau</option>
<option value="rocket">Rocket</option>
<option value="terminus">Terminus</option>
<option value="vintage">Vintage</option>
<option value="wintry">Wintry</option>
<!-- <option value="ae_c_osit">OSIT</option> -->
<option value="AE_OSIT_default">OSIT</option>
<option value="AE_c_IDAA_light">IDAA - light</option>
<option value="AE_c_LCI">LCI</option>
</select>
</div>
<div
class="flex flex-row flex-wrap gap-2 items-center w-full"
class:justify-between={expand}
class:justify-end={!expand}
>
{#if expand}
<!-- Hide theme options -->
<button
class="
<div
class="flex flex-row flex-wrap gap-2 items-center w-full"
class:justify-between={expand}
class:justify-end={!expand}
>
{#if expand}
<!-- Hide theme options -->
<button
class="
btn btn-sm text-xs
preset-tonal-secondary hover:preset-filled-secondary-500
transition-all group
"
onclick={() => {
expand = !expand;
}}
title="Hide Theme Options"
>
<!-- <span class="fas fa-compress-alt"></span> -->
<span class="fas fa-compress-arrows-alt m-1"></span>
<span
class="
onclick={() => {
expand = !expand;
}}
title="Hide Theme Options"
>
<!-- <span class="fas fa-compress-alt"></span> -->
<span class="fas fa-compress-arrows-alt m-1"></span>
<span
class="
hidden
group-hover:inline-block
text-xs
"
>
Hide Theme Options
</span>
</button>
>
Hide Theme Options
</span>
</button>
<button
class="
<button
class="
btn btn-sm text-xs
preset-tonal-secondary hover:preset-filled-secondary-500
transition-all group
"
onclick={() => {
if ($ae_loc.theme_mode == 'light') {
$ae_loc.theme_mode = 'dark';
} else if ($ae_loc.theme_mode == 'dark') {
$ae_loc.theme_mode = 'light';
}
onclick={() => {
if ($ae_loc.theme_mode == 'light') {
$ae_loc.theme_mode = 'dark';
} else if ($ae_loc.theme_mode == 'dark') {
$ae_loc.theme_mode = 'light';
}
if ($ae_loc.theme_mode == 'light') {
document.documentElement.classList.remove('dark');
document.documentElement.classList.add('light');
} else if ($ae_loc.theme_mode == 'dark') {
document.documentElement.classList.remove('light');
document.documentElement.classList.add('dark');
}
}}
title="Change light and dark mode"
>
<!-- <span class="fas fa-adjust"></span> -->
{#if $ae_loc.theme_mode == 'light'}
<Sun class="m-1" />
<span class="hidden md:inline-block group-hover:inline-block">Light Mode</span>
{:else if $ae_loc.theme_mode == 'dark'}
<Moon class="m-1" />
<span class="hidden group-hover:inline-block">Dark Mode</span>
{/if}
<span
class="
if ($ae_loc.theme_mode == 'light') {
document.documentElement.classList.remove('dark');
document.documentElement.classList.add('light');
} else if ($ae_loc.theme_mode == 'dark') {
document.documentElement.classList.remove('light');
document.documentElement.classList.add('dark');
}
}}
title="Change light and dark mode"
>
<!-- <span class="fas fa-adjust"></span> -->
{#if $ae_loc.theme_mode == 'light'}
<Sun class="m-1" />
<span class="hidden md:inline-block group-hover:inline-block">Light Mode</span>
{:else if $ae_loc.theme_mode == 'dark'}
<Moon class="m-1" />
<span class="hidden group-hover:inline-block">Dark Mode</span>
{/if}
<span
class="
hidden
group-hover:inline-block
text-xs
"
>
Change
</span>
</button>
{:else}
<button
class="btn btn-sm preset-tonal-secondary hover:preset-filled-secondary-500 group"
onclick={() => {
if ($ae_loc.theme_mode == 'light') {
$ae_loc.theme_mode = 'dark';
} else if ($ae_loc.theme_mode == 'dark') {
$ae_loc.theme_mode = 'light';
}
>
Change
</span>
</button>
{:else}
<button
class="btn btn-sm preset-tonal-secondary hover:preset-filled-secondary-500 group"
onclick={() => {
if ($ae_loc.theme_mode == 'light') {
$ae_loc.theme_mode = 'dark';
} else if ($ae_loc.theme_mode == 'dark') {
$ae_loc.theme_mode = 'light';
}
if ($ae_loc.theme_mode == 'light') {
document.documentElement.classList.remove('dark');
document.documentElement.classList.add('light');
} else if ($ae_loc.theme_mode == 'dark') {
document.documentElement.classList.remove('light');
document.documentElement.classList.add('dark');
}
if ($ae_loc.theme_mode == 'light') {
document.documentElement.classList.remove('dark');
document.documentElement.classList.add('light');
} else if ($ae_loc.theme_mode == 'dark') {
document.documentElement.classList.remove('light');
document.documentElement.classList.add('dark');
}
expand = !expand;
}}
title="Change light and dark mode"
>
{#if $ae_loc.theme_mode == 'light'}
<span class="inline-block" title="Light Mode">
<Sun />
</span>
<span class="hidden group-hover:inline-block">Light Mode</span>
{:else if $ae_loc.theme_mode == 'dark'}
<span class="inline-block" title="Dark Mode">
<Moon />
</span>
<span class="hidden group-hover:inline-block">Dark Mode</span>
{/if}
</button>
{/if}
</div>
expand = !expand;
}}
title="Change light and dark mode"
>
{#if $ae_loc.theme_mode == 'light'}
<span class="inline-block" title="Light Mode">
<Sun />
</span>
<span class="hidden group-hover:inline-block">Light Mode</span>
{:else if $ae_loc.theme_mode == 'dark'}
<span class="inline-block" title="Dark Mode">
<Moon />
</span>
<span class="hidden group-hover:inline-block">Dark Mode</span>
{/if}
</button>
{/if}
</div>
<!-- <section class="space-y-2">
<!-- <section class="space-y-2">
<h2 class="strong">Theme:</h2> -->
<!-- Light/Dark Theme: -->
<!-- <div>
<!-- Light/Dark Theme: -->
<!-- <div>
<RadioGroup
active="variant-glass-success"
hover="hover:variant-ringed-surface"

View File

@@ -1,68 +1,74 @@
<script lang="ts" module>
import type { WithElementRef } from 'bits-ui';
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
import { type VariantProps, tv } from 'tailwind-variants';
import type { WithElementRef } from 'bits-ui';
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
import { type VariantProps, tv } from 'tailwind-variants';
export const buttonVariants = tv({
base: 'ring-offset-background focus-visible:ring-ring inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
variants: {
variant: {
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
outline: 'border-input bg-background hover:bg-accent hover:text-accent-foreground border',
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground',
link: 'text-primary underline-offset-4 hover:underline'
},
size: {
default: 'h-10 px-4 py-2',
sm: 'h-9 rounded-md px-3',
lg: 'h-11 rounded-md px-8',
icon: 'h-10 w-10'
}
},
defaultVariants: {
variant: 'default',
size: 'default'
}
});
export const buttonVariants = tv({
base: 'ring-offset-background focus-visible:ring-ring inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
variants: {
variant: {
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
outline:
'border-input bg-background hover:bg-accent hover:text-accent-foreground border',
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground',
link: 'text-primary underline-offset-4 hover:underline'
},
size: {
default: 'h-10 px-4 py-2',
sm: 'h-9 rounded-md px-3',
lg: 'h-11 rounded-md px-8',
icon: 'h-10 w-10'
}
},
defaultVariants: {
variant: 'default',
size: 'default'
}
});
export type ButtonVariant = VariantProps<typeof buttonVariants>['variant'];
export type ButtonSize = VariantProps<typeof buttonVariants>['size'];
export type ButtonVariant = VariantProps<typeof buttonVariants>['variant'];
export type ButtonSize = VariantProps<typeof buttonVariants>['size'];
export type ButtonProps = WithElementRef<HTMLButtonAttributes> &
WithElementRef<HTMLAnchorAttributes> & {
variant?: ButtonVariant;
size?: ButtonSize;
};
export type ButtonProps = WithElementRef<HTMLButtonAttributes> &
WithElementRef<HTMLAnchorAttributes> & {
variant?: ButtonVariant;
size?: ButtonSize;
};
</script>
<script lang="ts">
import { cn } from '$lib/utils/utils.js';
import { cn } from '$lib/utils/utils.js';
let {
class: className,
variant = 'default',
size = 'default',
ref = $bindable(null),
href = undefined,
type = 'button',
children,
...restProps
}: ButtonProps = $props();
let {
class: className,
variant = 'default',
size = 'default',
ref = $bindable(null),
href = undefined,
type = 'button',
children,
...restProps
}: ButtonProps = $props();
</script>
{#if href}
<a bind:this={ref} class={cn(buttonVariants({ variant, size, className }))} {href} {...restProps}>
{@render children?.()}
</a>
<a
bind:this={ref}
class={cn(buttonVariants({ variant, size, className }))}
{href}
{...restProps}
>
{@render children?.()}
</a>
{:else}
<button
bind:this={ref}
class={cn(buttonVariants({ variant, size, className }))}
{type}
{...restProps}
>
{@render children?.()}
</button>
<button
bind:this={ref}
class={cn(buttonVariants({ variant, size, className }))}
{type}
{...restProps}
>
{@render children?.()}
</button>
{/if}

View File

@@ -1,9 +1,9 @@
import Root, { buttonVariants } from './button.svelte';
export {
Root,
Root,
//
Root as Button,
buttonVariants
//
Root as Button,
buttonVariants
};

View File

@@ -1,17 +1,17 @@
import Root, {
type ButtonProps,
type ButtonSize,
type ButtonVariant,
buttonVariants
type ButtonProps,
type ButtonSize,
type ButtonVariant,
buttonVariants
} from './button.svelte';
export {
Root,
type ButtonProps as Props,
//
Root as Button,
buttonVariants,
type ButtonProps,
type ButtonSize,
type ButtonVariant
Root,
type ButtonProps as Props,
//
Root as Button,
buttonVariants,
type ButtonProps,
type ButtonSize,
type ButtonVariant
};

View File

@@ -1,40 +1,40 @@
<script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
import Check from 'lucide-svelte/icons/check';
import Minus from 'lucide-svelte/icons/minus';
import { cn } from '$lib/utils/utils.js';
import type { Snippet } from 'svelte';
import { DropdownMenu as DropdownMenuPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
import Check from 'lucide-svelte/icons/check';
import Minus from 'lucide-svelte/icons/minus';
import { cn } from '$lib/utils/utils.js';
import type { Snippet } from 'svelte';
let {
ref = $bindable(null),
checked = $bindable(false),
indeterminate = $bindable(false),
class: className,
children: childrenProp,
...restProps
}: WithoutChildrenOrChild<DropdownMenuPrimitive.CheckboxItemProps> & {
children?: Snippet;
} = $props();
let {
ref = $bindable(null),
checked = $bindable(false),
indeterminate = $bindable(false),
class: className,
children: childrenProp,
...restProps
}: WithoutChildrenOrChild<DropdownMenuPrimitive.CheckboxItemProps> & {
children?: Snippet;
} = $props();
</script>
<DropdownMenuPrimitive.CheckboxItem
bind:ref
bind:checked
bind:indeterminate
class={cn(
'data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-hidden data-disabled:pointer-events-none data-disabled:opacity-50',
className
)}
{...restProps}
bind:ref
bind:checked
bind:indeterminate
class={cn(
'data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-hidden data-disabled:pointer-events-none data-disabled:opacity-50',
className
)}
{...restProps}
>
{#snippet children({ checked, indeterminate })}
<span class="absolute left-2 flex size-3.5 items-center justify-center">
{#if indeterminate}
<Minus class="size-4" />
{:else}
<Check class={cn('size-4', !checked && 'text-transparent')} />
{/if}
</span>
{@render childrenProp?.()}
{/snippet}
{#snippet children({ checked, indeterminate })}
<span class="absolute left-2 flex size-3.5 items-center justify-center">
{#if indeterminate}
<Minus class="size-4" />
{:else}
<Check class={cn('size-4', !checked && 'text-transparent')} />
{/if}
</span>
{@render childrenProp?.()}
{/snippet}
</DropdownMenuPrimitive.CheckboxItem>

View File

@@ -1,26 +1,26 @@
<script lang="ts">
import { cn } from '$lib/utils/utils.js';
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
import { cn } from '$lib/utils/utils.js';
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
let {
ref = $bindable(null),
sideOffset = 4,
portalProps,
class: className,
...restProps
}: DropdownMenuPrimitive.ContentProps & {
portalProps?: DropdownMenuPrimitive.PortalProps;
} = $props();
let {
ref = $bindable(null),
sideOffset = 4,
portalProps,
class: className,
...restProps
}: DropdownMenuPrimitive.ContentProps & {
portalProps?: DropdownMenuPrimitive.PortalProps;
} = $props();
</script>
<DropdownMenuPrimitive.Portal {...portalProps}>
<DropdownMenuPrimitive.Content
bind:ref
{sideOffset}
class={cn(
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-32 overflow-hidden rounded-md border p-1 shadow-md outline-hidden',
className
)}
{...restProps}
/>
<DropdownMenuPrimitive.Content
bind:ref
{sideOffset}
class={cn(
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-32 overflow-hidden rounded-md border p-1 shadow-md outline-hidden',
className
)}
{...restProps}
/>
</DropdownMenuPrimitive.Portal>

View File

@@ -1,19 +1,19 @@
<script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
import { cn } from '$lib/utils/utils.js';
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
import { cn } from '$lib/utils/utils.js';
let {
ref = $bindable(null),
class: className,
inset,
...restProps
}: DropdownMenuPrimitive.GroupHeadingProps & {
inset?: boolean;
} = $props();
let {
ref = $bindable(null),
class: className,
inset,
...restProps
}: DropdownMenuPrimitive.GroupHeadingProps & {
inset?: boolean;
} = $props();
</script>
<DropdownMenuPrimitive.GroupHeading
bind:ref
class={cn('px-2 py-1.5 text-sm font-semibold', inset && 'pl-8', className)}
{...restProps}
bind:ref
class={cn('px-2 py-1.5 text-sm font-semibold', inset && 'pl-8', className)}
{...restProps}
/>

View File

@@ -1,23 +1,23 @@
<script lang="ts">
import { cn } from '$lib/utils/utils.js';
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
import { cn } from '$lib/utils/utils.js';
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
let {
ref = $bindable(null),
class: className,
inset,
...restProps
}: DropdownMenuPrimitive.ItemProps & {
inset?: boolean;
} = $props();
let {
ref = $bindable(null),
class: className,
inset,
...restProps
}: DropdownMenuPrimitive.ItemProps & {
inset?: boolean;
} = $props();
</script>
<DropdownMenuPrimitive.Item
bind:ref
class={cn(
'data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden transition-colors data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
inset && 'pl-8',
className
)}
{...restProps}
bind:ref
class={cn(
'data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden transition-colors data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
inset && 'pl-8',
className
)}
{...restProps}
/>

View File

@@ -1,23 +1,23 @@
<script lang="ts">
import { cn } from '$lib/utils/utils.js';
import { type WithElementRef } from 'bits-ui';
import type { HTMLAttributes } from 'svelte/elements';
import { cn } from '$lib/utils/utils.js';
import { type WithElementRef } from 'bits-ui';
import type { HTMLAttributes } from 'svelte/elements';
let {
ref = $bindable(null),
class: className,
inset,
children,
...restProps
}: WithElementRef<HTMLAttributes<HTMLDivElement>> & {
inset?: boolean;
} = $props();
let {
ref = $bindable(null),
class: className,
inset,
children,
...restProps
}: WithElementRef<HTMLAttributes<HTMLDivElement>> & {
inset?: boolean;
} = $props();
</script>
<div
bind:this={ref}
class={cn('px-2 py-1.5 text-sm font-semibold', inset && 'pl-8', className)}
{...restProps}
bind:this={ref}
class={cn('px-2 py-1.5 text-sm font-semibold', inset && 'pl-8', className)}
{...restProps}
>
{@render children?.()}
{@render children?.()}
</div>

View File

@@ -1,30 +1,30 @@
<script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive, type WithoutChild } from 'bits-ui';
import Circle from 'lucide-svelte/icons/circle';
import { cn } from '$lib/utils/utils.js';
import { DropdownMenu as DropdownMenuPrimitive, type WithoutChild } from 'bits-ui';
import Circle from 'lucide-svelte/icons/circle';
import { cn } from '$lib/utils/utils.js';
let {
ref = $bindable(null),
class: className,
children: childrenProp,
...restProps
}: WithoutChild<DropdownMenuPrimitive.RadioItemProps> = $props();
let {
ref = $bindable(null),
class: className,
children: childrenProp,
...restProps
}: WithoutChild<DropdownMenuPrimitive.RadioItemProps> = $props();
</script>
<DropdownMenuPrimitive.RadioItem
bind:ref
class={cn(
'data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-hidden data-disabled:pointer-events-none data-disabled:opacity-50',
className
)}
{...restProps}
bind:ref
class={cn(
'data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-hidden data-disabled:pointer-events-none data-disabled:opacity-50',
className
)}
{...restProps}
>
{#snippet children({ checked })}
<span class="absolute left-2 flex size-3.5 items-center justify-center">
{#if checked}
<Circle class="size-2 fill-current" />
{/if}
</span>
{@render childrenProp?.({ checked })}
{/snippet}
{#snippet children({ checked })}
<span class="absolute left-2 flex size-3.5 items-center justify-center">
{#if checked}
<Circle class="size-2 fill-current" />
{/if}
</span>
{@render childrenProp?.({ checked })}
{/snippet}
</DropdownMenuPrimitive.RadioItem>

View File

@@ -1,16 +1,16 @@
<script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
import { cn } from '$lib/utils/utils.js';
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
import { cn } from '$lib/utils/utils.js';
let {
ref = $bindable(null),
class: className,
...restProps
}: DropdownMenuPrimitive.SeparatorProps = $props();
let {
ref = $bindable(null),
class: className,
...restProps
}: DropdownMenuPrimitive.SeparatorProps = $props();
</script>
<DropdownMenuPrimitive.Separator
bind:ref
class={cn('bg-muted -mx-1 my-1 h-px', className)}
{...restProps}
bind:ref
class={cn('bg-muted -mx-1 my-1 h-px', className)}
{...restProps}
/>

View File

@@ -1,20 +1,20 @@
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';
import { type WithElementRef } from 'bits-ui';
import { cn } from '$lib/utils/utils.js';
import type { HTMLAttributes } from 'svelte/elements';
import { type WithElementRef } from 'bits-ui';
import { cn } from '$lib/utils/utils.js';
let {
ref = $bindable(null),
class: className,
children,
...restProps
}: WithElementRef<HTMLAttributes<HTMLSpanElement>> = $props();
let {
ref = $bindable(null),
class: className,
children,
...restProps
}: WithElementRef<HTMLAttributes<HTMLSpanElement>> = $props();
</script>
<span
bind:this={ref}
class={cn('ml-auto text-xs tracking-widest opacity-60', className)}
{...restProps}
bind:this={ref}
class={cn('ml-auto text-xs tracking-widest opacity-60', className)}
{...restProps}
>
{@render children?.()}
{@render children?.()}
</span>

View File

@@ -1,19 +1,19 @@
<script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
import { cn } from '$lib/utils/utils.js';
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
import { cn } from '$lib/utils/utils.js';
let {
ref = $bindable(null),
class: className,
...restProps
}: DropdownMenuPrimitive.SubContentProps = $props();
let {
ref = $bindable(null),
class: className,
...restProps
}: DropdownMenuPrimitive.SubContentProps = $props();
</script>
<DropdownMenuPrimitive.SubContent
bind:ref
class={cn(
'bg-popover text-popover-foreground z-50 min-w-32 rounded-md border p-1 shadow-lg focus:outline-hidden',
className
)}
{...restProps}
bind:ref
class={cn(
'bg-popover text-popover-foreground z-50 min-w-32 rounded-md border p-1 shadow-lg focus:outline-hidden',
className
)}
{...restProps}
/>

View File

@@ -1,28 +1,28 @@
<script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
import ChevronRight from 'lucide-svelte/icons/chevron-right';
import { cn } from '$lib/utils/utils.js';
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
import ChevronRight from 'lucide-svelte/icons/chevron-right';
import { cn } from '$lib/utils/utils.js';
let {
ref = $bindable(null),
class: className,
inset,
children,
...restProps
}: DropdownMenuPrimitive.SubTriggerProps & {
inset?: boolean;
} = $props();
let {
ref = $bindable(null),
class: className,
inset,
children,
...restProps
}: DropdownMenuPrimitive.SubTriggerProps & {
inset?: boolean;
} = $props();
</script>
<DropdownMenuPrimitive.SubTrigger
bind:ref
class={cn(
'data-[highlighted]:bg-accent data-[state=open]:bg-accent flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
inset && 'pl-8',
className
)}
{...restProps}
bind:ref
class={cn(
'data-[highlighted]:bg-accent data-[state=open]:bg-accent flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
inset && 'pl-8',
className
)}
{...restProps}
>
{@render children?.()}
<ChevronRight class="ml-auto" />
{@render children?.()}
<ChevronRight class="ml-auto" />
</DropdownMenuPrimitive.SubTrigger>

View File

@@ -17,34 +17,34 @@ const Group = DropdownMenuPrimitive.Group;
const RadioGroup = DropdownMenuPrimitive.RadioGroup;
export {
CheckboxItem,
Content,
Root as DropdownMenu,
CheckboxItem as DropdownMenuCheckboxItem,
Content as DropdownMenuContent,
Group as DropdownMenuGroup,
GroupHeading as DropdownMenuGroupHeading,
Item as DropdownMenuItem,
Label as DropdownMenuLabel,
RadioGroup as DropdownMenuRadioGroup,
RadioItem as DropdownMenuRadioItem,
Separator as DropdownMenuSeparator,
Shortcut as DropdownMenuShortcut,
Sub as DropdownMenuSub,
SubContent as DropdownMenuSubContent,
SubTrigger as DropdownMenuSubTrigger,
Trigger as DropdownMenuTrigger,
Group,
GroupHeading,
Item,
Label,
RadioGroup,
RadioItem,
Root,
Separator,
Shortcut,
Sub,
SubContent,
SubTrigger,
Trigger
CheckboxItem,
Content,
Root as DropdownMenu,
CheckboxItem as DropdownMenuCheckboxItem,
Content as DropdownMenuContent,
Group as DropdownMenuGroup,
GroupHeading as DropdownMenuGroupHeading,
Item as DropdownMenuItem,
Label as DropdownMenuLabel,
RadioGroup as DropdownMenuRadioGroup,
RadioItem as DropdownMenuRadioItem,
Separator as DropdownMenuSeparator,
Shortcut as DropdownMenuShortcut,
Sub as DropdownMenuSub,
SubContent as DropdownMenuSubContent,
SubTrigger as DropdownMenuSubTrigger,
Trigger as DropdownMenuTrigger,
Group,
GroupHeading,
Item,
Label,
RadioGroup,
RadioItem,
Root,
Separator,
Shortcut,
Sub,
SubContent,
SubTrigger,
Trigger
};

View File

@@ -17,34 +17,34 @@ const Group = DropdownMenuPrimitive.Group;
const RadioGroup = DropdownMenuPrimitive.RadioGroup;
export {
CheckboxItem,
Content,
Root as DropdownMenu,
CheckboxItem as DropdownMenuCheckboxItem,
Content as DropdownMenuContent,
Group as DropdownMenuGroup,
GroupHeading as DropdownMenuGroupHeading,
Item as DropdownMenuItem,
Label as DropdownMenuLabel,
RadioGroup as DropdownMenuRadioGroup,
RadioItem as DropdownMenuRadioItem,
Separator as DropdownMenuSeparator,
Shortcut as DropdownMenuShortcut,
Sub as DropdownMenuSub,
SubContent as DropdownMenuSubContent,
SubTrigger as DropdownMenuSubTrigger,
Trigger as DropdownMenuTrigger,
Group,
GroupHeading,
Item,
Label,
RadioGroup,
RadioItem,
Root,
Separator,
Shortcut,
Sub,
SubContent,
SubTrigger,
Trigger
CheckboxItem,
Content,
Root as DropdownMenu,
CheckboxItem as DropdownMenuCheckboxItem,
Content as DropdownMenuContent,
Group as DropdownMenuGroup,
GroupHeading as DropdownMenuGroupHeading,
Item as DropdownMenuItem,
Label as DropdownMenuLabel,
RadioGroup as DropdownMenuRadioGroup,
RadioItem as DropdownMenuRadioItem,
Separator as DropdownMenuSeparator,
Shortcut as DropdownMenuShortcut,
Sub as DropdownMenuSub,
SubContent as DropdownMenuSubContent,
SubTrigger as DropdownMenuSubTrigger,
Trigger as DropdownMenuTrigger,
Group,
GroupHeading,
Item,
Label,
RadioGroup,
RadioItem,
Root,
Separator,
Shortcut,
Sub,
SubContent,
SubTrigger,
Trigger
};

View File

@@ -1,7 +1,7 @@
import Root from './input.svelte';
export {
Root,
//
Root as Input
Root,
//
Root as Input
};

View File

@@ -1,7 +1,7 @@
import Root from './input.svelte';
export {
Root,
//
Root as Input
Root,
//
Root as Input
};

View File

@@ -1,22 +1,22 @@
<script lang="ts">
import type { HTMLInputAttributes } from 'svelte/elements';
import type { WithElementRef } from 'bits-ui';
import { cn } from '$lib/utils/utils.js';
import type { HTMLInputAttributes } from 'svelte/elements';
import type { WithElementRef } from 'bits-ui';
import { cn } from '$lib/utils/utils.js';
let {
ref = $bindable(null),
value = $bindable(),
class: className,
...restProps
}: WithElementRef<HTMLInputAttributes> = $props();
let {
ref = $bindable(null),
value = $bindable(),
class: className,
...restProps
}: WithElementRef<HTMLInputAttributes> = $props();
</script>
<input
bind:this={ref}
class={cn(
'border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
className
)}
bind:value
{...restProps}
bind:this={ref}
class={cn(
'border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
className
)}
bind:value
{...restProps}
/>

Some files were not shown because too many files have changed in this diff Show More