diff --git a/src/lib/ae_events__event.ts b/src/lib/ae_events__event.ts new file mode 100644 index 00000000..39306985 --- /dev/null +++ b/src/lib/ae_events__event.ts @@ -0,0 +1,177 @@ +import type { key_val } from '$lib/ae_stores'; +import { api } from '$lib/api'; + +import { db_events } from "$lib/db_events"; + +let ae_promises: key_val = {}; // Promise; + + +// Updated 2024-06-24 +export async function handle_load_ae_obj_id__event( + { + api_cfg, + event_id, + try_cache=false, + log_lvl=0 + } : { + api_cfg: any, + event_id: string, + try_cache?: boolean, + log_lvl?: number + } + ) { + console.log(`*** handle_load_ae_obj_id__event() *** event_id=${event_id}`); + + let params = {}; + + // $events_sess.badges.status_load__event_obj = 'loading'; + ae_promises.load__event_obj = await api.get_ae_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event', + obj_id: event_id, // NOTE: This is the FQDN, not normally the ID. + use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config. + use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config. + params: params, + log_lvl: log_lvl + }) + .then(function (event_obj_get_result) { + if (event_obj_get_result) { + return event_obj_get_result; + } else { + console.log('No results returned.'); + return null; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }); + + return ae_promises.load__event_obj; +} + + +// Updated 2024-05-24 +export async function handle_load_ae_obj_li__event( + { + api_cfg, + account_id, + params={}, + try_cache=true, + log_lvl=0 + } : { + api_cfg: any, + account_id: string, + params?: key_val, + try_cache?: boolean, + log_lvl?: number + } + ) { + console.log(`*** handle_load_ae_obj_li__event() *** account_id=${account_id}`); + + let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled + let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden + let limit: number = (params.qry__limit ?? 99); // 99 + let offset: number = (params.qry__offset ?? 0); // 0 + + + let params_json: key_val = {}; + + // console.log('params_json:', params_json); + + ae_promises.load__event_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event', + for_obj_type: 'account', + for_obj_id: account_id, + use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config. + use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value + enabled: enabled, + hidden: hidden, + order_by_li: {'start_datetime': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'}, + limit: limit, + offset: offset, + params_json: params_json, + params: params, + log_lvl: log_lvl + }) + .then(function (event_obj_li_get_result) { + if (event_obj_li_get_result) { + handle_db_save_ae_obj_li__event({obj_type: 'event', obj_li: event_obj_li_get_result}); + return event_obj_li_get_result; + } else { + return []; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }); + + console.log('ae_promises.load__event_obj_li:', ae_promises.load__event_obj_li); + return ae_promises.load__event_obj_li; + +} + + + +// This function will loop through the event_obj_li and save each one to the DB. +export function handle_db_save_ae_obj_li__event({obj_type, obj_li}) { + console.log(`*** handle_db_save_ae_obj_li__event() ***`); + + if (obj_li && obj_li.length) { + obj_li.forEach(async function (obj) { + // console.log(`ae_obj ${obj_type}:`, obj); + + try { + const id_random = await db_events.events.put({ + id: obj.event_id_random, + // id_random: obj.event_id_random, + event_id: obj.event_id_random, + event_id_random: obj.event_id_random, + + code: obj.event_code, + + account_id: obj.account_id_random, + account_id_random: obj.account_id_random, + + conference: obj.conference, + type: obj.type, + name: obj.name, + summary: obj.summary, + description: obj.description, + + start_datetime: obj.start_datetime, + end_datetime: obj.end_datetime, + timezone: obj.timezone, + location_address_json: obj.location_address_json, + + mod_abstracts_json: obj.mod_abstracts_json, + mod_badges_json: obj.mod_badges_json, + mod_exhibits_json: obj.mod_exhibits_json, + mod_pres_mgmt_json: obj.mod_pres_mgmt_json, + cfg_json: obj.cfg_json, + + enable: obj.enable, + hide: obj.hide, + priority: obj.priority, + sort: obj.sort, + group: obj.group, + notes: obj.notes, + created_on: obj.created_on, + updated_on: obj.updated_on, + + // From SQL view + file_count: obj.file_count, + }); + // console.log(`Put obj with ID: ${obj.event_id_random} or ${id_random}`); + } catch (error) { + let status = `Failed to put ${obj.event_id_random}: ${error}`; + console.log(status); + } + + // const id_random = await db_events.events.put(obj); + // console.log(`Put obj with ID: ${obj.event_id_random}`); + }); + + return true; + } +} diff --git a/src/lib/ae_events__event_badge.ts b/src/lib/ae_events__event_badge.ts new file mode 100644 index 00000000..14439db3 --- /dev/null +++ b/src/lib/ae_events__event_badge.ts @@ -0,0 +1,357 @@ +import type { key_val } from '$lib/ae_stores'; +import { api } from '$lib/api'; + +import { db_events } from "$lib/db_events"; + +let ae_promises: key_val = {}; + + +// Updated 2024-03 +export async function handle_load_ae_obj_id__badge( + { + api_cfg, + badge_id, + try_cache=false, + log_lvl=0 + } : { + api_cfg: any, + badge_id: string, + try_cache?: boolean, + log_lvl?: number + } + ) { + console.log(`*** handle_load_ae_obj_id__badge() *** badge_id=${badge_id}`); + + let params = {}; + + // $events_sess.badges.status_load__badge_obj = 'loading'; + ae_promises.load__badge_obj = await api.get_ae_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_badge', + obj_id: badge_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 in the API config. + params: params, + log_lvl: 0 + }) + .then(function (badge_obj_get_result) { + if (badge_obj_get_result) { + // This is expecting a list + handle_db_save_ae_obj_li__badge({obj_type: 'event_badge', obj_li: [badge_obj_get_result]}); + return badge_obj_get_result; + } else { + console.log('No results returned.'); + return null; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }); + + return ae_promises.load__badge_obj; +} + + +// Updated 2024-03-06 +export async function handle_load_ae_obj_li__badge( + { + api_cfg, + event_id, + params={}, + try_cache=true, + log_lvl=0 + }: { + api_cfg: any, + event_id: any, + params: any, + try_cache?: boolean, + log_lvl: number + }) { + console.log(`*** handle_load_ae_obj_li__badge() *** event_id=${event_id}`); + + let fulltext_search_qry_str = ''; // $events_sess.badges.fulltext_search_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 ?? 99); // 99 + let offset: number = (params.qry__offset ?? 0); // 0 + + // if ($ae_loc.administrator_access) { + // enabled = 'all'; + // hidden = 'all'; + // limit = 500; + // } else if ($ae_loc.trusted_access) { + // // enabled = 'all'; + // hidden = 'all'; + // limit = 50; + // } + + // let params = {}; + + let params_json: key_val = {}; + if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) { + params_json['ft_qry'] = { + 'default_qry_str': fulltext_search_qry_str, + // 'location_address_json_ext': fulltext_search_qry_str, // JSON extracted text DB field + // 'contact_li_json_ext': fulltext_search_qry_str, // JSON extracted text DB field + }; + } + + // console.log('params_json:', params_json); + // console.log(params_json); + + // $events_sess.badges.status_qry__search = 'loading'; + ae_promises.load__event_badge_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_badge', + for_obj_type: 'event', + for_obj_id: event_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. + enabled: enabled, + hidden: hidden, + order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'}, + // order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'created_on': 'DESC', 'updated_on': 'DESC'}, + limit: limit, + offset: offset, + params_json: params_json, + params: params, + log_lvl: log_lvl + }) + + .then(function (badge_obj_li_get_result) { + // console.log('Badge list:', badge_obj_li_get_result); + if (badge_obj_li_get_result) { + // $slct.badge_obj_li = badge_obj_li_get_result; + handle_db_save_ae_obj_li__badge({obj_type: 'event_badge', obj_li: badge_obj_li_get_result}); + return badge_obj_li_get_result; + } else { + // $slct.badge_obj_li = []; + return []; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }) + .finally(function () { + // $events_sess.badges.status_qry__search = 'done'; + + // console.log('Badge list:', badge_obj_li_get_result); + // return badge_obj_li_get_result; + }); + + if (log_lvl) { + console.log('ae_promises.load__event_badge_obj_li:', ae_promises.load__event_badge_obj_li); + } + return ae_promises.load__event_badge_obj_li; +} + + +export async function handle_search__event_badge( + { + api_cfg, + event_id, + type_code = null, + fulltext_search_qry_str, + like_search_qry_str = null, + external_event_id, + params = {}, + try_cache = true, + log_lvl = 0 + }: { + api_cfg: any, + event_id: any, + type_code: any, + fulltext_search_qry_str: any, + like_search_qry_str: any, + external_event_id: any, + params: any, + try_cache: boolean, + log_lvl: number + } + ) { + console.log(`*** handle_search__event_badge() *** event_id=${event_id}`); + + let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled + let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden + let limit: number = (params.qry__limit ?? 25); // 99 + let offset: number = (params.qry__offset ?? 0); // 0 + + let params_json: key_val = {}; + + if (!fulltext_search_qry_str && !like_search_qry_str) { + console.log('No search string provided!!!'); + return false; // Returning false instead of [] because no search was performed. + } + + if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) { + params_json['ft_qry'] = { + 'default_qry_str': fulltext_search_qry_str, + // 'location_address_json_ext': fulltext_search_qry_str, // JSON extracted text DB field + // 'contact_li_json_ext': fulltext_search_qry_str, // JSON extracted text DB field + }; + } + + if (like_search_qry_str && like_search_qry_str.length > 2) { + // Old Python version that needs to be in JS + // # Strip (left right) whitespace then commas then semicolons + // query_str = query_str.strip().strip(',').strip(';') + // # Replace commas, semicolons, and then spaces with % + // query_str_like = query_str.replace(',', ' ').replace(';', ' ').replace(' ', '%').replace(' ', '%') + // # data['query_str'] = f'%{query_str}%' + // log.debug(query_str_like) + // data['query_str'] = f'%{query_str_like}%' + + // let like_search_qry_str_new = like_search_qry_str.trim().replace(',', ' ').replace(';', ' ').replace(' ', '%').replace(' ', '%'); + // like_search_qry_str_new = `%${like_search_qry_str_new}%`; + // console.log('like_search_qry_str_new:', like_search_qry_str_new); + + params_json['and_like'] = { + 'default_qry_str': like_search_qry_str, + }; + } + + params_json['and_qry'] = {}; + if (external_event_id) { + params_json['and_qry']['external_event_id'] = external_event_id; + } + + if (type_code) { // This is the event_badge.badge_type_code. There is also a member_type_code and registration_type_code that could be referenced in the future. + params_json['and_qry']['badge_type_code'] = type_code; + } + + let order_by_li = {'print_count': 'ASC', 'priority': 'DESC', 'sort': 'DESC', 'given_name': 'ASC', 'family_name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'}; + + // $events_sess.badges.status_qry__search = 'loading'; + ae_promises.search__event_badge = await api.get_ae_obj_li_for_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_badge', + for_obj_type: 'event', + for_obj_id: event_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. + enabled: enabled, + hidden: hidden, + order_by_li: order_by_li, + // order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'created_on': 'DESC', 'updated_on': 'DESC'}, + limit: limit, + offset: offset, + params_json: params_json, + params: params, + log_lvl: log_lvl + }) + .then(function (badge_obj_li_get_result) { + // console.log('Badge list:', badge_obj_li_get_result); + if (badge_obj_li_get_result) { + // $slct.badge_obj_li = badge_obj_li_get_result; + handle_db_save_ae_obj_li__badge({obj_type: 'event_badge', obj_li: badge_obj_li_get_result}); + return badge_obj_li_get_result; + } else { + // $slct.badge_obj_li = []; + return []; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }) + .finally(function () { + // $events_sess.badges.status_qry__search = 'done'; + + // console.log('Badge list:', badge_obj_li_get_result); + // return badge_obj_li_get_result; + }); + + console.log('ae_promises.search__event_badge:', ae_promises.search__event_badge); + return ae_promises.search__event_badge; +} + + +// This function will loop through the badge_obj_li and save each one to the DB. +export function handle_db_save_ae_obj_li__badge( + { + obj_type, + obj_li + } : { + obj_type: string, + obj_li: any + } + ) { + console.log(`*** handle_db_save_ae_obj_li__badge() ***`); + + if (obj_li && obj_li.length) { + obj_li.forEach(async function (obj: any) { + // console.log(`ae_obj ${obj_type}:`, obj); + + try { + const id_random = await db_events.badges.put({ + id_random: obj.event_badge_id_random, + event_badge_id_random: obj.event_badge_id_random, + + event_id_random: obj.event_id_random, + + pronouns: obj.pronouns, + informal_name: obj.informal_name, + title_names: obj.title_names, + given_name: obj.given_name, + middle_name: obj.middle_name, + family_name: obj.family_name, + designations: obj.designations, + + professional_title: obj.professional_title, + professional_title_override: obj.professional_title_override, + + full_name: obj.full_name, + full_name_override: obj.full_name_override, + + affiliations: obj.affiliations, + affiliations_override: obj.affiliations_override, + + email: obj.email, + email_override: obj.email_override, + + address_line_1: obj.address_line_1, + address_line_2: obj.address_line_2, + address_line_3: obj.address_line_3, + city: obj.city, + country_subdivision_code: obj.country_subdivision_code, + state_province: obj.state_province, + state_province_abb: obj.state_province_abb, + postal_code: obj.postal_code, + country_alpha_2_code: obj.country_alpha_2_code, + country: obj.country, + full_address: obj.full_address, + location: obj.location, + location_override: obj.location_override, + + query_str: obj.query_str, + + badge_type: obj.badge_type, + badge_type_code: obj.badge_type_code, + badge_type_override: obj.badge_type_override, + badge_type_code_override: obj.badge_type_code_override, + external_event_id: obj.external_event_id, + external_id: obj.external_id, + external_person_id: obj.external_person_id, + + 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, + }); + // console.log(`Put obj with ID: ${obj.event_badge_id_random} or ${id_random}`); + } catch (error) { + let status = `Failed to put ${obj.event_badge_id_random}: ${error}`; + console.log(status); + } + + // const id_random = await db_events.badges.put(obj); + // console.log(`Put obj with ID: ${obj.event_badge_id_random}`); + }); + + return true; + } +} diff --git a/src/lib/ae_events__event_file.ts b/src/lib/ae_events__event_file.ts new file mode 100644 index 00000000..114fe267 --- /dev/null +++ b/src/lib/ae_events__event_file.ts @@ -0,0 +1,284 @@ +import type { key_val } from '$lib/ae_stores'; +import { api } from '$lib/api'; + +import { db_events } from "$lib/db_events"; + +let ae_promises: key_val = {}; + + +// Updated 2024-06-14 +export async function handle_load_ae_obj_id__event_file( + { + api_cfg, + event_file_id, + try_cache=false, + log_lvl=0 + } : { + api_cfg: any, + event_file_id: string, + try_cache?: boolean, + log_lvl?: number + } + ) { + console.log(`*** handle_load_ae_obj_id__event_file() *** event_file_id=${event_file_id}`); + + let params = {}; + + ae_promises.load__event_file_obj = await api.get_ae_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_file', + obj_id: event_file_id, // NOTE: This is the FQDN, not normally the ID. + 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 (event_file_obj_get_result) { + if (event_file_obj_get_result) { + // This is expecting a list + handle_db_save_ae_obj_li__event_file({obj_type: 'event_file', obj_li: [event_file_obj_get_result]}); + return event_file_obj_get_result; + } else { + console.log('No results returned.'); + return null; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }); + + return ae_promises.load__event_file_obj; +} + + +// Updated 2024-06-14 +export async function handle_load_ae_obj_li__event_file( + { + api_cfg, + event_session_id, + params={}, + try_cache=true, + log_lvl=0 + } : { + api_cfg: any, + event_session_id: string, + params?: key_val, + try_cache?: boolean, + log_lvl?: number + } + ) { + console.log(`*** handle_load_ae_obj_li__event_file() *** event_id=${event_session_id}`); + + let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled + let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden + let limit: number = (params.qry__limit ?? 99); // 99 + let offset: number = (params.qry__offset ?? 0); // 0 + + let params_json: key_val = {}; + + // console.log('params_json:', params_json); + + ae_promises.load__event_file_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_file', + for_obj_type: 'event_session', + for_obj_id: event_session_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: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'}, + limit: limit, + offset: offset, + params_json: params_json, + params: params, + log_lvl: log_lvl + }) + .then(function (event_file_obj_li_get_result) { + if (event_file_obj_li_get_result) { + handle_db_save_ae_obj_li__event_file({obj_type: 'event_file', obj_li: event_file_obj_li_get_result}); + return event_file_obj_li_get_result; + } else { + console.log('No results returned.'); + return []; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }); + + console.log('ae_promises.load__event_file_obj_li:', ae_promises.load__event_file_obj_li); + return ae_promises.load__event_file_obj_li; +} + + +// Updated 2024-06-17 +export async function handle_delete_ae_obj_id__event_file( + { + api_cfg, + event_file_id, + params={}, + log_lvl=0 + } : { + api_cfg: any, + event_file_id: string, + params?: key_val, + log_lvl?: number + } + ) { + console.log(`*** handle_delete_ae_obj_id__event_file() *** event_file_id=${event_file_id}`); + + const endpoint = `/event/file/${event_file_id}/v2`; + + params['delete_hosted_file'] = true; // This does not actually delete the hosted file from the server. + params['rm_orphan'] = true; // This is what actually allows the hosted file to be deleted from the server. + + ae_promises.delete__event_file_obj = await api.delete_object({ + api_cfg: api_cfg, + endpoint: endpoint, + params: params, + // return_meta: return_meta, + log_lvl: log_lvl + }); + + db_events.files.delete(event_file_id); + + return ae_promises.delete__event_file_obj; +} + + +// Updated 2024-06-14 +export async function create_event_file_obj_from_hosted_file_async( + { + api_cfg, + hosted_file_id, + params={}, + data={}, + return_obj=false, + inc_hosted_file=false, + return_meta=false, + log_lvl=0 + } : { + api_cfg: any, + hosted_file_id: string, + params?: key_val, + data?: key_val, + return_obj?: boolean, + inc_hosted_file?: boolean, + return_meta?: boolean, + log_lvl?: number + } + + ) { + console.log('*** ae_events_functions.js: create_event_file_obj_from_hosted_file() ***'); + + let endpoint = `/event/file/from_hosted_file/${hosted_file_id}`; + if (return_obj) { + params['return_obj'] = true; + } + if (inc_hosted_file) { + params['inc_hosted_file'] = true; + } + let event_file_obj_post_promise = await api.post_object({ + api_cfg: api_cfg, + endpoint: endpoint, + params: params, + data: data, + // return_obj: return_obj, + return_meta: return_meta, + log_lvl: log_lvl + }) + .then(function (result) { + console.log('POST DONE create_event_file_obj_from_hosted_file'); + console.log(result); + return result; + }) + .catch(function (error) { + console.log(error); + return false; // Returning false since something may have gone wrong. Also more in line with what the API returns. + // return error; + }); + + // console.log(event_file_obj_post_promise); + if (return_obj) { + return event_file_obj_post_promise; + } else { + return event_file_obj_post_promise.event_file_id_random; + } + +} + + +// This function will loop through the event_file_obj_li and save each one to the DB. +export function handle_db_save_ae_obj_li__event_file( + { + obj_type, + obj_li + } : { + obj_type: string, + obj_li: any + } + ) { + console.log(`*** handle_db_save_ae_obj_li__event_file() ***`); + + if (obj_li && obj_li.length) { + obj_li.forEach(async function (obj: any) { + console.log(`ae_obj ${obj_type}:`, obj); + + try { + const id_random = await db_events.files.put({ + id: obj.event_file_id_random, + id_random: obj.event_file_id_random, + event_file_id: obj.event_file_id_random, + event_file_id_random: obj.event_file_id_random, + + hosted_file_id: obj.hosted_file_id_random, + hosted_file_id_random: obj.hosted_file_id_random, + hash_sha256: obj.hash_sha256, // 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, + + event_id_random: obj.event_id_random, + event_session_id_random: obj.event_session_id_random, + event_presentation_id_random: obj.event_presentation_id_random, + event_presenter_id_random: obj.event_presenter_id_random, + event_location_id_random: obj.event_location_id_random, + + filename: obj.filename, + extension: obj.extension, + + open_in_os: obj.open_in_os, + + lu_file_purpose_id: obj.lu_file_purpose_id, // Not id_random in this case? + lu_event_file_purpose_name: obj.lu_event_file_purpose_name, + file_purpose: obj.file_purpose, + + enable: obj.enable, + hide: obj.hide, + priority: obj.priority, + sort: obj.sort, + group: obj.group, + notes: obj.notes, + created_on: obj.created_on, + updated_on: obj.updated_on, + + filename_no_ext: obj.filename_no_ext, + filename_w_ext: obj.filename_w_ext, + hosted_file_content_type: obj.hosted_file_content_type, + hosted_file_size: obj.hosted_file_size, + }); + // console.log(`Put obj with ID: ${obj.event_file_id_random} or ${id_random}`); + } catch (error) { + let status = `Failed to put ${obj.event_file_id_random}: ${error}`; + console.log(status); + } + + // const id_random = await db_events.files.put(obj); + // console.log(`Put obj with ID: ${obj.event_file_id_random}`); + }); + + return true; + } +} diff --git a/src/lib/ae_events__event_presentation.ts b/src/lib/ae_events__event_presentation.ts new file mode 100644 index 00000000..f0e22eea --- /dev/null +++ b/src/lib/ae_events__event_presentation.ts @@ -0,0 +1,191 @@ +import type { key_val } from '$lib/ae_stores'; +import { api } from '$lib/api'; + +import { db_events } from "$lib/db_events"; + +let ae_promises: key_val = {}; + + +// Updated 2024-06-20 +export async function handle_load_ae_obj_id__event_presentation( + { + api_cfg, + event_presentation_id, + try_cache=false, + log_lvl=0 + } : { + api_cfg: any, + event_presentation_id: string, + try_cache?: boolean, + log_lvl?: number + } + ) { + console.log(`*** handle_load_ae_obj_id__event_presentation() *** event_presentation_id=${event_presentation_id}`); + + let params = {}; + + ae_promises.load__event_presentation_obj = await api.get_ae_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_presentation', + obj_id: event_presentation_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 (event_presentation_obj_get_result) { + if (event_presentation_obj_get_result) { + // This is expecting a list + handle_db_save_ae_obj_li__event_presentation({obj_type: 'event_presentation', obj_li: [event_presentation_obj_get_result]}); + return event_presentation_obj_get_result; + } else { + console.log('No results returned.'); + return null; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }); + + return ae_promises.load__event_presentation_obj; +} + + +// Updated 2024-06-10 +export async function handle_load_ae_obj_li__event_presentation( + { + api_cfg, + event_session_id, + params={}, + try_cache=true, + log_lvl=0 + } : { + api_cfg: any, + event_session_id: string, + params?: key_val, + try_cache?: boolean, + log_lvl?: number + } + ) { + console.log(`*** handle_load_ae_obj_li__event_presentation() *** event_session_id=${event_session_id}`); + + let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled + let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden + let limit: number = (params.qry__limit ?? 99); // 99 + let offset: number = (params.qry__offset ?? 0); // 0 + + let params_json: key_val = {}; + + // console('params_json:', params_json); + + ae_promises.load__event_presentation_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_presentation', + for_obj_type: 'event_session', + for_obj_id: event_session_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: {'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'}, + limit: limit, + offset: offset, + params_json: params_json, + params: params, + log_lvl: log_lvl + }) + .then(function (event_presentation_obj_li_get_result) { + if (event_presentation_obj_li_get_result) { + handle_db_save_ae_obj_li__event_presentation({obj_type: 'event_presentation', obj_li: event_presentation_obj_li_get_result}); + return event_presentation_obj_li_get_result; + } else { + return []; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }); + + console.log('ae_promises.load__event_presentation_obj_li:', ae_promises.load__event_presentation_obj_li); + return ae_promises.load__event_presentation_obj_li; +} + + +// This function will loop through the event_presentation_obj_li and save each one to the DB. +// Updated 2024-06-10 +export function handle_db_save_ae_obj_li__event_presentation( + { + obj_type, + obj_li + } : { + obj_type: string, + obj_li: any + } + ) { + console.log(`*** handle_db_save_ae_obj_li__event_presentation() ***`); + + if (obj_li && obj_li.length) { + obj_li.forEach(async function (obj: any) { + // console.log(`ae_obj ${obj_type}:`, obj); + + try { + const id_random = await db_events.presentations.put({ + id: obj.event_presentation_id_random, + // id_random: obj.event_presentation_id_random, + event_presentation_id: obj.event_presentation_id_random, + event_presentation_id_random: obj.event_presentation_id_random, + + external_id: obj.external_id, + code: obj.code, + + for_type: obj.for_type, + for_id: obj.for_id_random, + for_id_random: obj.for_id_random, + + type_code: obj.type_code, + + event_id: obj.event_id_random, + event_id_random: obj.event_id_random, + event_session_id: obj.event_session_id_random, + event_session_id_random: obj.event_session_id_random, + event_abstract_id: obj.event_abstract_id_random, + event_abstract_id_random: obj.event_abstract_id_random, + + abstract_code: obj.abstract_code, + + name: obj.name, + description: obj.description, + + start_datetime: obj.start_datetime, + end_datetime: obj.end_datetime, + + passcode: obj.passcode, + + hide_event_launcher: obj.hide_event_launcher, + + enable: obj.enable, + hide: obj.hide, + priority: obj.priority, + sort: obj.sort, + group: obj.group, + notes: obj.notes, + created_on: obj.created_on, + updated_on: obj.updated_on, + + // From SQL view + event_session_code: obj.event_session_code, + event_session_name: obj.event_session_name, + }); + // console.log(`Put obj with ID: ${obj.event_presentation_id_random} or ${id_random}`); + } catch (error) { + let status = `Failed to put ${obj.event_presentation_id_random}: ${error}`; + console.log(status); + } + + // const id_random = await db_events.presentations.put(obj); + // console.log(`Put obj with ID: ${obj.event_presentation_id_random}`); + }); + + return true; + } +} diff --git a/src/lib/ae_events__event_presenter.ts b/src/lib/ae_events__event_presenter.ts new file mode 100644 index 00000000..3afec637 --- /dev/null +++ b/src/lib/ae_events__event_presenter.ts @@ -0,0 +1,259 @@ +import type { key_val } from '$lib/ae_stores'; +import { api } from '$lib/api'; + +import { db_events } from "$lib/db_events"; + +let ae_promises: key_val = {}; + + +// Updated 2024-06-13 +export async function handle_load_ae_obj_id__event_presenter( + { + api_cfg, + event_presenter_id, + try_cache=false, + log_lvl=0 + } : { + api_cfg: any, + event_presenter_id: string, + try_cache?: boolean, + log_lvl?: number + } + ) { + console.log(`*** handle_load_ae_obj_id__event_presenter() *** event_presenter_id=${event_presenter_id}`); + + let params = {}; + + ae_promises.load__event_presenter_obj = await api.get_ae_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_presenter', + obj_id: event_presenter_id, // NOTE: This is the FQDN, not normally the ID. + 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 (event_presenter_obj_get_result) { + if (event_presenter_obj_get_result) { + // This is expecting a list + handle_db_save_ae_obj_li__event_presenter({obj_type: 'event_presenter', obj_li: [event_presenter_obj_get_result]}); + return event_presenter_obj_get_result; + } else { + console.log('No results returned.'); + return null; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }); + + return ae_promises.load__event_presenter_obj; +} + + +// Updated 2024-06-10 +export async function handle_load_ae_obj_li__event_presenter( + { + api_cfg, + event_presentation_id, + params={}, + try_cache=true, + log_lvl=0 + } : { + api_cfg: any, + event_presentation_id: string, + params?: key_val, + try_cache?: boolean, + log_lvl?: number + } + ) { + console.log(`*** handle_load_ae_obj_li__event_presenter() *** event_presentation_id=${event_presentation_id}`); + + let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled + let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden + let limit: number = (params.qry__limit ?? 99); // 99 + let offset: number = (params.qry__offset ?? 0); // 0 + + let params_json: key_val = {}; + + // console.log('params_json:', params_json); + + ae_promises.load__event_presenter_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_presenter', + for_obj_type: 'event_presentation', + for_obj_id: event_presentation_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: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'}, + limit: limit, + offset: offset, + params_json: params_json, + params: params, + log_lvl: log_lvl + }) + .then(function (event_presenter_obj_li_get_result) { + if (event_presenter_obj_li_get_result) { + handle_db_save_ae_obj_li__event_presenter({obj_type: 'event_presenter', obj_li: event_presenter_obj_li_get_result}); + return event_presenter_obj_li_get_result; + } else { + return []; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }); + + console.log('ae_promises.load__event_presenter_obj_li:', ae_promises.load__event_presenter_obj_li); + return ae_promises.load__event_presenter_obj_li; +} + + +// Updated 2024-06-13 +export async function handle_update_ae_obj__event_presenter( + { + api_cfg, + event_presenter_id, + data, + params={}, + log_lvl=0 + } : { + api_cfg: any, + event_presenter_id: string, + data: any, + params?: key_val, + log_lvl?: number + } + ) { + console.log(`*** handle_update_ae_obj__event_presenter() *** event_presenter_id=${event_presenter_id}`); + + ae_promises.update__event_presenter_obj = await api.update_ae_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_presenter', + obj_id: event_presenter_id, // NOTE: This is the FQDN, not normally the ID. + fields: data, + key: api_cfg.api_crud_super_key, + params: params, + return_obj: true, + log_lvl: log_lvl + }) + .then(function (event_presenter_obj_update_result) { + if (event_presenter_obj_update_result) { + handle_db_save_ae_obj_li__event_presenter({obj_type: 'event_presenter', obj_li: [event_presenter_obj_update_result]}); + return event_presenter_obj_update_result; + } else { + return null; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }) + .finally(function () { + }); + + console.log('ae_promises.update__event_presenter_obj:', ae_promises.update__event_presenter_obj); + return ae_promises.update__event_presenter_obj; +} + + +// Updated 2024-06-10 +export function handle_db_save_ae_obj_li__event_presenter( + { + obj_type, + obj_li + } : { + obj_type: string, + obj_li: any + } + ) { + console.log(`*** handle_db_save_ae_obj_li__event_presenter() ***`); + + if (obj_li && obj_li.length) { + obj_li.forEach(async function (obj: any) { + // console.log(`ae_obj ${obj_type}:`, obj); + + try { + const id_random = await db_events.presenters.put({ + id: obj.event_presenter_id_random, + // id_random: obj.event_presenter_id_random, + event_presenter_id: obj.event_presenter_id_random, + event_presenter_id_random: obj.event_presenter_id_random, + + external_id: obj.external_id, + code: obj.code, + + // for_type: obj.for_type, + // for_id_random: obj.for_id_random, + + event_id: obj.event_id_random, + event_id_random: obj.event_id_random, + event_session_id: obj.event_session_id_random, + event_session_id_random: obj.event_session_id_random, + event_presentation_id: obj.event_presentation_id_random, + event_presentation_id_random: obj.event_presentation_id_random, + event_person_id: obj.event_person_id_random, + event_person_id_random: obj.event_person_id_random, + person_id: obj.person_id_random, + person_id_random: obj.person_id_random, + person_profile_id: obj.person_profile_id_random, + person_profile_id_random: obj.person_profile_id_random, // The new table person_profile will be used soon... + + pronouns: obj.pronouns, + informal_name: obj.informal_name, + title_names: obj.title_names, + given_name: obj.given_name, + middle_name: obj.middle_name, + family_name: obj.family_name, + designations: obj.designations, + + professional_title: obj.professional_title, + + full_name: obj.full_name, + + affiliations: obj.affiliations, + + email: obj.email, + + biography: obj.biography, + + agree: obj.agree, + comments: obj.comments, + + passcode: obj.passcode, + + hide_event_launcher: obj.hide_event_launcher, + + data_json: obj.data_json, + + enable: obj.enable, + hide: obj.hide, + priority: obj.priority, + sort: obj.sort, + group: obj.group, + notes: obj.notes, + created_on: obj.created_on, + updated_on: obj.updated_on, + + file_count: obj.file_count, + + person_given_name: obj.person_given_name, + person_family_name: obj.person_family_name, + person_full_name: obj.person_full_name, + person_primary_email: obj.person_primary_email, + person_passcode: obj.person_passcode, + }); + // console.log(`Put obj with ID: ${obj.event_presenter_id_random} or ${id_random}`); + } catch (error) { + let status = `Failed to put ${obj.event_presenter_id_random}: ${error}`; + console.log(status); + } + + // const id_random = await db_events.presenters.put(obj); + // console.log(`Put obj with ID: ${obj.event_presenter_id_random}`); + }); + + return true; + } +} diff --git a/src/lib/ae_events__event_session.ts b/src/lib/ae_events__event_session.ts new file mode 100644 index 00000000..5c949eca --- /dev/null +++ b/src/lib/ae_events__event_session.ts @@ -0,0 +1,325 @@ +import type { key_val } from '$lib/ae_stores'; +import { api } from '$lib/api'; + +import { db_events } from "$lib/db_events"; + +let ae_promises: key_val = {}; + + +// Updated 2024-06-10 +export async function handle_load_ae_obj_id__event_session( + { + api_cfg, + event_session_id, + try_cache=false, + log_lvl=0 + } : { + api_cfg: any, + event_session_id: string, + try_cache?: boolean, + log_lvl?: number + } + ) { + console.log(`*** handle_load_ae_obj_id__event_session() *** event_session_id=${event_session_id}`); + + let params = {}; + + // $events_sess.badges.status_load__event_session_obj = 'loading'; + ae_promises.load__event_session_obj = await api.get_ae_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_session', + obj_id: event_session_id, // NOTE: This is the FQDN, not normally the ID. + use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config. + use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config. + params: params, + log_lvl: log_lvl + }) + .then(function (event_session_obj_get_result) { + if (event_session_obj_get_result) { + // This is expecting a list + handle_db_save_ae_obj_li__event_session({obj_type: 'event_session', obj_li: [event_session_obj_get_result]}); + return event_session_obj_get_result; + } else { + console.log('No results returned.'); + return null; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }); + + return ae_promises.load__event_session_obj; +} + + +// Updated 2024-05-24 +export async function handle_load_ae_obj_li__event_session( + { + api_cfg, + event_id, + params={}, + try_cache=true, + log_lvl=0 + } : { + api_cfg: any, + event_id: string, + params?: key_val, + try_cache?: boolean, + log_lvl?: number + } + ) { + console.log(`*** handle_load_ae_obj_li__event_session() ***`); + + let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled + let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden + let limit: number = (params.qry__limit ?? 99); // 99 + let offset: number = (params.qry__offset ?? 0); // 0 + + let params_json: key_val = {}; + + // console.log('params_json:', params_json); + + ae_promises.load__event_session_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_session', + for_obj_type: 'event', + for_obj_id: event_id, + use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config. + use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value + enabled: enabled, + hidden: hidden, + order_by_li: {'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'}, + limit: limit, + offset: offset, + params_json: params_json, + params: params, + log_lvl: log_lvl + }) + .then(function (event_session_obj_li_get_result) { + if (event_session_obj_li_get_result) { + handle_db_save_ae_obj_li__event_session({obj_type: 'event_session', obj_li: event_session_obj_li_get_result}); + return event_session_obj_li_get_result; + } else { + return []; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }); + + console.log('ae_promises.load__event_session_obj_li:', ae_promises.load__event_session_obj_li); + return ae_promises.load__event_session; +} + + +export async function handle_search__event_session( + { + api_cfg, + event_id, + fulltext_search_qry_str, + ft_presenter_search_qry_str, + like_search_qry_str = null, + like_presentation_search_qry_str = null, + like_presenter_search_qry_str = null, + params = {}, + try_cache = true, + log_lvl = 0 + }: { + api_cfg: any, + event_id: any, + fulltext_search_qry_str?: null|string, + ft_presenter_search_qry_str?: null|string, + like_search_qry_str?: null|string, + like_presentation_search_qry_str?: null|string, + like_presenter_search_qry_str?: null|string, + params?: any, + try_cache?: boolean, + log_lvl?: number + } + ) { + console.log(`*** handle_search__event_session() *** event_id=${event_id}`); + + let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled + let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden + let limit: number = (params.qry__limit ?? 25); // 99 + let offset: number = (params.qry__offset ?? 0); // 0 + + let params_json: key_val = {}; + + if (!fulltext_search_qry_str && !like_search_qry_str) { + console.log('No search string provided!!!'); + return false; // Returning false instead of [] because no search was performed. + } + + if (fulltext_search_qry_str || ft_presenter_search_qry_str) { + params_json['ft_qry'] = {}; + if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) { + params_json['ft_qry']['default_qry_str'] = fulltext_search_qry_str; + } + + if (ft_presenter_search_qry_str && ft_presenter_search_qry_str.length > 2) { + params_json['ft_qry']['event_presenter_li_qry_str'] = ft_presenter_search_qry_str; + } + } + + // Use the AND (AND LIKE) query + // if (like_search_qry_str || like_presenter_search_qry_str) { + // params_json['and_like'] = {}; + // if (like_search_qry_str && like_search_qry_str.length > 2) { + // params_json['and_like']['default_qry_str'] = like_search_qry_str; + // } + // if (like_presenter_search_qry_str && like_presenter_search_qry_str.length > 2) { + // params_json['and_like']['event_presenter_li_qry_str'] = like_presenter_search_qry_str; + // } + // } + + // Use the AND (OR LIKE) query + if (like_search_qry_str || like_presentation_search_qry_str || like_presenter_search_qry_str) { + params_json['or_like'] = {}; + if (like_search_qry_str && like_search_qry_str.length > 2) { + params_json['or_like']['default_qry_str'] = like_search_qry_str; + } + if (like_presentation_search_qry_str && like_presentation_search_qry_str.length > 2) { + params_json['or_like']['event_presentation_li_qry_str'] = like_presentation_search_qry_str; + } + if (like_presenter_search_qry_str && like_presenter_search_qry_str.length > 2) { + params_json['or_like']['event_presenter_li_qry_str'] = like_presenter_search_qry_str; + } + } + + params_json['and_qry'] = {}; + + // if (session_type_code) { + // params_json['and_qry']['session_type_code'] = session_type_code; + // } + + let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'}; + + ae_promises.load__event_session_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_session', + for_obj_type: 'event', + for_obj_id: event_id, + use_alt_table: true, // NOTE: We want to use the alt table for session searching + use_alt_base: false, + enabled: enabled, + hidden: hidden, + order_by_li: order_by_li, + limit: limit, + offset: offset, + params_json: params_json, + params: params, + log_lvl: log_lvl + }) + .then(function (event_session_obj_li_get_result) { + if (event_session_obj_li_get_result) { + handle_db_save_ae_obj_li__event_session({obj_type: 'event_session', obj_li: event_session_obj_li_get_result}); + return event_session_obj_li_get_result; + } else { + return []; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }) + .finally(function () { + }); + + console.log('ae_promises.load__event_session_obj_li:', ae_promises.load__event_session_obj_li); + return ae_promises.load__event_session_obj_li; +} + + +// This function will loop through the event_session_obj_li and save each one to the DB. +export function handle_db_save_ae_obj_li__event_session( + { + obj_type, + obj_li + } : { + obj_type: string, + obj_li: any + } + ) { + console.log(`*** handle_db_save_ae_obj_li__event_session() ***`); + + if (obj_li && obj_li.length) { + obj_li.forEach(async function (obj: any) { + // console.log(`ae_obj ${obj_type}:`, obj); + + try { + const id_random = await db_events.sessions.put({ + id: obj.event_session_id_random, + event_session_id: obj.event_session_id_random, + event_session_id_random: obj.event_session_id_random, + + external_id: obj.external_id, + code: obj.code, + + for_type: obj.for_type, + for_id: obj.for_id_id_random, + for_id_random: obj.for_id_random, + + type_code: obj.type_code, + + event_id: obj.event_id_random, + event_id_random: obj.event_id_random, + event_location_id: obj.event_location_id_random, + event_location_id_random: obj.event_location_id_random, + + poc_person_id: obj.poc_person_id_random, + poc_person_id_random: obj.poc_person_id_random, + + name: obj.name, + description: obj.description, + + start_datetime: obj.start_datetime, + end_datetime: obj.end_datetime, + + passcode: obj.passcode, + + hide_event_launcher: obj.hide_event_launcher, + + alert: obj.alert, + alert_msg: obj.alert_msg, + + data_json: obj.data_json, + + enable: obj.enable, + hide: obj.hide, + priority: obj.priority, + sort: obj.sort, + group: obj.group, + notes: obj.notes, + created_on: obj.created_on, + updated_on: obj.updated_on, + + // From SQL view + file_count: obj.file_count, + file_count_all: obj.file_count_all, + internal_use_count: obj.internal_use_count, + + poc_person_given_name: obj.poc_person_given_name, + poc_person_family_name: obj.poc_person_family_name, + poc_person_full_name: obj.poc_person_full_name, + poc_person_primary_email: obj.poc_person_primary_email, + poc_person_passcode: obj.poc_person_passcode, + poc_kv_json: obj.poc_kv_json, + + event_name: obj.event_name, + + event_location_code: obj.event_location_code, + event_location_name: obj.event_location_name, + }); + // console.log(`Put obj with ID: ${obj.event_session_id_random} or ${id_random}`); + } catch (error) { + let status = `Failed to put ${obj.event_session_id_random}: ${error}`; + console.log(status); + } + + // const id_random = await db_events.sessions.put(obj); + // console.log(`Put obj with ID: ${obj.event_session_id_random}`); + }); + + return true; + } +} diff --git a/src/lib/ae_events__exhibit.ts b/src/lib/ae_events__exhibit.ts new file mode 100644 index 00000000..679ed74b --- /dev/null +++ b/src/lib/ae_events__exhibit.ts @@ -0,0 +1,588 @@ +import type { key_val } from '$lib/ae_stores'; +import { api } from '$lib/api'; + +import { db_events } from "$lib/db_events"; + +let ae_promises: key_val = {}; + + +// Updated 2024-03 +export async function handle_load_ae_obj_id__exhibit( + { + api_cfg, + exhibit_id, + try_cache=false, + log_lvl=0 + } : { + api_cfg: any, + exhibit_id: string, + try_cache?: boolean, + log_lvl?: number + } + ) { + console.log(`*** handle_load_ae_obj_id__exhibit() *** exhibit_id=${exhibit_id}`); + + let params = {}; + + // $events_sess.exhibits.status_load__exhibit_obj = 'loading'; + ae_promises.load__exhibit_obj = await api.get_ae_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_exhibit', + obj_id: exhibit_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 in the API config. + params: params, + log_lvl: log_lvl + }) + .then(function (exhibit_obj_get_result) { + if (exhibit_obj_get_result) { + // This is expecting a list + handle_db_save_ae_obj_li__exhibitor({obj_type: 'event_exhibit', obj_li: [exhibit_obj_get_result]}); + return exhibit_obj_get_result; + } else { + console.log('No results returned.'); + return null; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }); + + return ae_promises.load__exhibit_obj; +} + + +// Updated 2024-03-06 +export async function handle_load_ae_obj_li__exhibit( + { + api_cfg, + event_id, + params={}, + try_cache=true, + log_lvl=0 + } : { + api_cfg: any, + event_id: any, + params: any, + try_cache?: boolean + log_lvl?: number + } + ) { + console.log(`*** handle_load_ae_obj_li__exhibit() *** event_id=${event_id}`); + + let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled + let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden + let limit: number = (params.qry__limit ?? 99); // 99 + let offset: number = (params.qry__offset ?? 0); // 0 + + // if ($ae_loc.administrator_access) { + // enabled = 'all'; + // hidden = 'all'; + // limit = 500; + // } else if ($ae_loc.trusted_access) { + // // enabled = 'all'; + // hidden = 'all'; + // limit = 50; + // } + + // let params = {}; + + let params_json: key_val = {}; + // params_json['and_qry'] = {}; + // params_json['and_qry']['license_max'] = 10; + + params_json['and_in_li'] = { + license_max : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], + }; + + // if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) { + // params_json['ft_qry'] = { + // 'default_qry_str': fulltext_search_qry_str, + // // 'location_address_json_ext': fulltext_search_qry_str, // JSON extracted text DB field + // // 'contact_li_json_ext': fulltext_search_qry_str, // JSON extracted text DB field + // }; + // } + + // console.log('params_json:', params_json); + // console.log(params_json); + + // $events_sess.exhibits.status_qry__search = 'loading'; + ae_promises.load__event_exhibit_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_exhibit', + for_obj_type: 'event', + for_obj_id: event_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. + enabled: enabled, + hidden: hidden, + order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'}, + // order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'created_on': 'DESC', 'updated_on': 'DESC'}, + limit: limit, + offset: offset, + params_json: params_json, + params: params, + log_lvl: log_lvl + }) + + .then(function (exhibit_obj_li_get_result) { + // console.log('Badge list:', exhibit_obj_li_get_result); + if (exhibit_obj_li_get_result) { + // $slct.exhibit_obj_li = exhibit_obj_li_get_result; + handle_db_save_ae_obj_li__exhibitor({obj_type: 'event_exhibit', obj_li: exhibit_obj_li_get_result}); + return exhibit_obj_li_get_result; + } else { + // $slct.exhibit_obj_li = []; + return []; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }) + .finally(function () { + // $events_sess.exhibits.status_qry__search = 'done'; + + // console.log('Badge list:', exhibit_obj_li_get_result); + // return exhibit_obj_li_get_result; + }); + + console.log('ae_promises.load__event_exhibit_obj_li:', ae_promises.load__event_exhibit_obj_li); + return ae_promises.load__event_exhibit_obj_li; +} + + +// // This function will loop through the badge_obj_li and save each one to the DB. +// function handle_db_save_ae_obj_li({obj_type, obj_li}) { +// console.log(`*** handle_db_save_ae_obj_li() ***`); + +// if (obj_li && obj_li.length) { +// obj_li.forEach(async function (obj) { +// // console.log(`ae_obj ${obj_type}:`, obj); + +// try { +// const id_random = await db_events.badges.put({ +// id_random: obj.event_badge_id_random, +// full_name: obj.full_name, +// full_name_override: obj.full_name_override, +// email: obj.email, +// email_override: obj.email_override, +// affiliations: obj.affiliations, +// affiliations_override: obj.affiliations_override, +// badge_type: obj.badge_type, +// badge_type_override: obj.badge_type_override, +// badge_type_code: obj.badge_type_code, +// badge_type_code_override: obj.badge_type_code_override, +// external_event_id: obj.external_event_id, +// external_id: obj.external_id, +// external_person_id: obj.external_person_id, +// created_on: obj.created_on, +// updated_on: obj.updated_on, +// }); +// console.log(`Put obj with ID: ${obj.event_badge_id_random} or ${id_random}`); +// } catch (error) { +// let status = `Failed to put ${obj.event_badge_id_random}: ${error}`; +// console.log(status); +// } + +// // const id_random = await db_events.badges.put(obj); +// // console.log(`Put obj with ID: ${obj.event_badge_id_random}`); +// }); + +// return true; +// } +// } + + +export async function handle_load_ae_obj_id__exhibit_tracking( + { + api_cfg, + exhibit_tracking_id, + try_cache=false, + log_lvl=0 + } : { + api_cfg: any, + exhibit_tracking_id: string, + try_cache?: boolean, + log_lvl?: number + } + ) { + console.log(`*** handle_load_ae_obj_id__exhibit_tracking() *** exhibit_tracking_id=${exhibit_tracking_id}`); + + let params = {}; + + // $events_sess.exhibits.status_load__exhibit_tracking_obj = 'loading'; + ae_promises.load__event_exhibit_tracking_obj = await api.get_ae_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_exhibit_tracking', + obj_id: exhibit_tracking_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 in the API config. + params: params, + log_lvl: log_lvl + }) + .then(function (exhibit_tracking_obj_get_result) { + if (exhibit_tracking_obj_get_result) { + // This is expecting a list + handle_db_save_ae_obj_li__exhibitor_tracking({obj_type: 'event_exhibit_tracking', obj_li: [exhibit_tracking_obj_get_result]}); + return exhibit_tracking_obj_get_result; + } else { + console.log('No results returned.'); + return null; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }); + + return ae_promises.load__event_exhibit_tracking_obj; +} + + +// Updated 2024-03-19 +export async function handle_load_ae_obj_li__exhibit_tracking( + { + api_cfg, + exhibit_id, + params={}, + try_cache=true, + log_lvl=0 + } : { + api_cfg: any, + exhibit_id: any, + params: any, + try_cache?: boolean, + log_lvl?: number + } + ) { + console.log(`*** handle_load_ae_obj_li__exhibit_tracking() *** exhibit_id=${exhibit_id}`); + + let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled + let hidden: string = (params.qry__hidden ?? 'all'); // all, hidden, not_hidden + let limit: number = (params.qry__limit ?? 99); // 99 + let offset: number = (params.qry__offset ?? 0); // 0 + + let params_json: key_val = {}; + + ae_promises.load__event_exhibit_tracking_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_exhibit_tracking', + for_obj_type: 'event_exhibit', + for_obj_id: exhibit_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. + enabled: enabled, + hidden: hidden, + order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'}, + limit: limit, + offset: offset, + params_json: params_json, + params: params, + log_lvl: log_lvl + }) + + .then(function (exhibit_tracking_obj_li_get_result) { + // console.log('Exhibit tracking list:', exhibit_tracking_obj_li_get_result); + if (exhibit_tracking_obj_li_get_result) { + // $slct.exhibit_tracking_obj_li = exhibit_tracking_obj_li_get_result; + handle_db_save_ae_obj_li__exhibitor_tracking({obj_type: 'event_exhibit_tracking', obj_li: exhibit_tracking_obj_li_get_result}); + return exhibit_tracking_obj_li_get_result; + } else { + // $slct.exhibit_tracking_obj_li = []; + return []; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }) + .finally(function () { + // console.log('Exhibit tracking list:', exhibit_tracking_obj_li_get_result); + // return exhibit_tracking_obj_li_get_result; + }); + + console.log('ae_promises.load__event_exhibit_tracking_obj_li:', ae_promises.load__event_exhibit_tracking_obj_li); + return ae_promises.load__event_exhibit_tracking_obj_li; +} + + +// Updated 2024-03-22 +export async function handle_create_ae_obj__exhibit_tracking( + { + api_cfg, + exhibit_id, + event_badge_id, + external_person_id, + params={}, + log_lvl=0 + } : { + api_cfg: any, + exhibit_id: string, + event_badge_id: string, + external_person_id: string, + params: key_val, + log_lvl: number + } + ) { + console.log(`*** handle_create_ae_obj__exhibit_tracking() *** exhibit_id=${exhibit_id}, event_badge_id=${event_badge_id}`); + + let params_json: key_val = {}; + + // $events_sess.exhibits.status_create__exhibit_tracking = 'loading'; + ae_promises.create__event_exhibit_tracking = await api.create_ae_obj_crud({ + api_cfg: api_cfg, + obj_type: 'event_exhibit_tracking', + fields: { + event_exhibit_id_random: exhibit_id, + event_badge_id_random: event_badge_id, + external_person_id: external_person_id, + }, + key: api_cfg.api_crud_super_key, + params: params, + return_obj: true, + log_lvl: log_lvl + }) + + .then(function (exhibit_tracking_obj_create_result) { + // console.log('Exhibit tracking create:', exhibit_tracking_obj_create_result); + if (exhibit_tracking_obj_create_result) { + // $slct.exhibit_tracking_obj = exhibit_tracking_obj_create_result; + handle_db_save_ae_obj_li__exhibitor_tracking({obj_type: 'event_exhibit_tracking', obj_li: [exhibit_tracking_obj_create_result]}); + return exhibit_tracking_obj_create_result; + } else { + // $slct.exhibit_tracking_obj = []; + return null; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }) + .finally(function () { + // console.log('Exhibit tracking create:', exhibit_tracking_obj_create_result); + // return exhibit_tracking_obj_create_result; + }); + + console.log('ae_promises.create__event_exhibit_tracking:', ae_promises.create__event_exhibit_tracking); + return ae_promises.create__event_exhibit_tracking; +} + + +// Updated 2024-03-28 +export async function handle_update_ae_obj__exhibit_tracking( + { + api_cfg, + exhibit_tracking_id, + data, + params={}, + log_lvl=0 + } : { + api_cfg: any, + exhibit_tracking_id: string, + data: any, + params: key_val, + log_lvl: number + } + ) { + console.log(`*** handle_update_ae_obj__exhibit_tracking() *** exhibit_tracking_id=${exhibit_tracking_id}`); + + ae_promises.update__event_exhibit_tracking = await api.update_ae_obj_id_crud({ + api_cfg: api_cfg, + obj_type: 'event_exhibit_tracking', + obj_id: exhibit_tracking_id, + fields: data, + key: api_cfg.api_crud_super_key, + params: params, + return_obj: true, + log_lvl: log_lvl + }) + .then(function (exhibit_tracking_obj_update_result) { + if (exhibit_tracking_obj_update_result) { + handle_db_save_ae_obj_li__exhibitor_tracking({obj_type: 'event_exhibit_tracking', obj_li: [exhibit_tracking_obj_update_result]}); + return exhibit_tracking_obj_update_result; + } else { + return null; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); + }) + .finally(function () { + }); + + console.log('ae_promises.update__event_exhibit_tracking:', ae_promises.update__event_exhibit_tracking); + return ae_promises.update__event_exhibit_tracking; +} + + +export async function handle_download_export__event_exhibit_tracking( + { + api_cfg, + exhibit_id, + file_type='CSV', // 'CSV' or 'Excel' + return_file=true, + filename='no_filename.csv', + auto_download=false, + params={}, + log_lvl=0 + } : { + api_cfg: any, + exhibit_id: string, + file_type?: string, + return_file?: boolean, + filename?: string, + auto_download?: boolean, + params?: key_val, + log_lvl?: number + } + ) { + console.log('*** ae_events_functions.js: get_event_exhibit_tracking_export() ***'); + + const endpoint = `/event/exhibit/${exhibit_id}/tracking/export`; + if (file_type == 'CSV' || file_type == 'Excel') { + params['file_type'] = file_type; + } + params['return_file'] = true; + + ae_promises.download__event_exhibit_tracking_export_file = await api.get_object({ + api_cfg: api_cfg, + endpoint: endpoint, + params: params, + return_blob: true, + filename: filename, + auto_download: auto_download, + log_lvl: log_lvl + }); + + console.log('ae_promises.download__event_exhibit_tracking_export_file:', ae_promises.download__event_exhibit_tracking_export_file); + return ae_promises.download__event_exhibit_tracking_export_file; +} + + +// This function will loop through the event_exhibit_obj_li and save each one to the DB. +export function handle_db_save_ae_obj_li__exhibitor({obj_type, obj_li=[]}: {obj_type: string, obj_li: any[]}) { + console.log(`*** handle_db_save_ae_obj_li__exhibitor() ***`); + + if (obj_li && obj_li.length) { + obj_li.forEach(async function (obj) { + // console.log(`ae_obj ${obj_type}:`, obj); + + try { + const id_random = await db_events.exhibits.put({ + id_random: obj.event_exhibit_id_random, + event_exhibit_id_random: obj.event_exhibit_id_random, + + event_id_random: obj.event_id_random, + code: obj.code, + name: obj.name, + description: obj.description, + staff_passcode: obj.staff_passcode, + data_json: obj.data_json, + + leads_api_access: obj.leads_api_access, + leads_custom_questions_json: obj.leads_custom_questions_json, + leads_device_sm_qty: obj.leads_device_sm_qty, + leads_device_lg_qty: obj.leads_device_lg_qty, + license_max: obj.license_max, + license_li_json: obj.license_li_json, + cfg_json: obj.cfg_json, + + enable: obj.enable, + hide: obj.hide, + priority: obj.priority, + sort: obj.sort, + group: obj.group, + notes: obj.notes, + created_on: obj.created_on, + updated_on: obj.updated_on, + }); + // console.log(`Put obj with ID: ${obj.event_exhibit_id_random} or ${id_random}`); + } catch (error) { + let status = `Failed to put ${obj.event_exhibit_id_random}: ${error}`; + console.log(status); + } + + // const id_random = await db_events.exhibits.put(obj); + // console.log(`Put obj with ID: ${obj.event_exhibit_id_random}`); + }); + + return true; + } +} + + +// This function will loop through the event_exhibit_tracking_obj_li and save each one to the DB. +export function handle_db_save_ae_obj_li__exhibitor_tracking( + { + obj_type, + obj_li + } : { + obj_type: string, + obj_li: any + } + ) { + console.log(`*** handle_db_save_ae_obj_li__exhibitor_tracking() ***`); + + if (obj_li && obj_li.length) { + obj_li.forEach(async function (obj: any) { + // console.log(`ae_obj ${obj_type}:`, obj); + + try { + const id_random = await db_events.exhibit_tracking.put({ + id_random: obj.event_exhibit_tracking_id_random, + event_exhibit_tracking_id_random: obj.event_exhibit_tracking_id_random, + + event_exhibit_id_random: obj.event_exhibit_id_random, + event_badge_id_random: obj.event_badge_id_random, + event_person_id_random: obj.event_person_id_random, + + external_person_id: obj.external_person_id, + + exhibitor_notes: obj.exhibitor_notes, + + responses_json: obj.responses_json, + data_json: obj.data_json, + + event_exhibit_name: obj.event_exhibit_name, + + event_badge_title_names: obj.event_badge_title_names, + event_badge_given_name: obj.event_badge_given_name, + event_badge_family_name: obj.event_badge_family_name, + event_badge_designations: obj.event_badge_designations, + event_badge_full_name: obj.event_badge_full_name, + event_badge_full_name_override: obj.event_badge_full_name_override, + + event_badge_professional_title: obj.event_badge_professional_title, + event_badge_professional_title_override: obj.event_badge_professional_title_override, + + event_badge_affiliations: obj.event_badge_affiliations, + event_badge_affiliations_override: obj.event_badge_affiliations_override, + + event_badge_email: obj.event_badge_email, + event_badge_email_override: obj.event_badge_email_override, + + event_badge_location: obj.event_badge_location, + event_badge_location_override: obj.event_badge_location_override, + + event_badge_country: obj.event_badge_country, + + 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, + }); + // console.log(`Put obj with ID: ${obj.event_exhibit_tracking_id_random} or ${id_random}`); + } catch (error) { + let status = `Failed to put ${obj.event_exhibit_tracking_id_random}: ${error}`; + console.log(status); + } + + // const id_random = await db_events.exhibit_tracking.put(obj); + // console.log(`Put obj with ID: ${obj.event_exhibit_tracking_id_random}`); + }); + + return true; + } +} diff --git a/src/lib/ae_events_functions.ts b/src/lib/ae_events_functions.ts index 9c716d36..f8017434 100644 --- a/src/lib/ae_events_functions.ts +++ b/src/lib/ae_events_functions.ts @@ -1,1972 +1,52 @@ -import type { key_val } from '$lib/ae_stores'; -import { api } from '$lib/api'; - -// import { liveQuery } from "dexie"; -import { db_events } from "$lib/db_events"; - -// let event_badge_li = liveQuery( -// () => db_events.badges.toArray() -// ); - -let ae_promises: key_val = {}; // Promise; - -async function handle_load_ae_obj_id__event({api_cfg, event_id, try_cache=false}) { - console.log(`*** handle_load_ae_obj_id__event() *** event_id=${event_id}`); - - let params = {}; - - // $events_sess.badges.status_load__event_obj = 'loading'; - ae_promises.load__event_obj = await api.get_ae_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event', - obj_id: event_id, // NOTE: This is the FQDN, not normally the ID. - use_alt_table: 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: 0 - }) - .then(function (event_obj_get_result) { - if (event_obj_get_result) { - return event_obj_get_result; - } else { - console.log('No results returned.'); - return null; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }); - - return ae_promises.load__event_obj; -} - - -// Updated 2024-05-24 -async function handle_load_ae_obj_li__event( - { - api_cfg, - account_id, - params={}, - try_cache=true, - log_lvl=0 - } : { - api_cfg: any, - account_id: string, - params?: key_val, - try_cache?: boolean, - log_lvl?: number - } - ) { - console.log(`*** handle_load_ae_obj_li__event() *** account_id=${account_id}`); - - let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled - let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden - let limit: number = (params.qry__limit ?? 99); // 99 - let offset: number = (params.qry__offset ?? 0); // 0 - - - let params_json: key_val = {}; - - // console.log('params_json:', params_json); - - ae_promises.load__event_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event', - for_obj_type: 'account', - for_obj_id: account_id, - use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config. - use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value - enabled: enabled, - hidden: hidden, - order_by_li: {'start_datetime': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'}, - limit: limit, - offset: offset, - params_json: params_json, - params: params, - log_lvl: log_lvl - }) - .then(function (event_obj_li_get_result) { - if (event_obj_li_get_result) { - handle_db_save_ae_obj_li__event({obj_type: 'event', obj_li: event_obj_li_get_result}); - return event_obj_li_get_result; - } else { - return []; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }); - - console.log('ae_promises.load__event_obj_li:', ae_promises.load__event_obj_li); - return ae_promises.load__event_obj_li; - -} - - -// Updated 2024-06-14 -async function handle_load_ae_obj_id__event_file( - { - api_cfg, - event_file_id, - try_cache=false, - log_lvl=0 - } : { - api_cfg: any, - event_file_id: string, - try_cache?: boolean, - log_lvl?: number - } - ) { - console.log(`*** handle_load_ae_obj_id__event_file() *** event_file_id=${event_file_id}`); - - let params = {}; - - ae_promises.load__event_file_obj = await api.get_ae_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_file', - obj_id: event_file_id, // NOTE: This is the FQDN, not normally the ID. - 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 (event_file_obj_get_result) { - if (event_file_obj_get_result) { - // This is expecting a list - handle_db_save_ae_obj_li__event_file({obj_type: 'event_file', obj_li: [event_file_obj_get_result]}); - return event_file_obj_get_result; - } else { - console.log('No results returned.'); - return null; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }); - - return ae_promises.load__event_file_obj; -} - - -// Updated 2024-06-14 -async function handle_load_ae_obj_li__event_file( - { - api_cfg, - event_session_id, - params={}, - try_cache=true, - log_lvl=0 - } : { - api_cfg: any, - event_session_id: string, - params?: key_val, - try_cache?: boolean, - log_lvl?: number - } - ) { - console.log(`*** handle_load_ae_obj_li__event_file() *** event_id=${event_session_id}`); - - let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled - let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden - let limit: number = (params.qry__limit ?? 99); // 99 - let offset: number = (params.qry__offset ?? 0); // 0 - - let params_json: key_val = {}; - - // console.log('params_json:', params_json); - - ae_promises.load__event_file_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_file', - for_obj_type: 'event_session', - for_obj_id: event_session_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: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'}, - limit: limit, - offset: offset, - params_json: params_json, - params: params, - log_lvl: log_lvl - }) - .then(function (event_file_obj_li_get_result) { - if (event_file_obj_li_get_result) { - handle_db_save_ae_obj_li__event_file({obj_type: 'event_file', obj_li: event_file_obj_li_get_result}); - return event_file_obj_li_get_result; - } else { - console.log('No results returned.'); - return []; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }); - - console.log('ae_promises.load__event_file_obj_li:', ae_promises.load__event_file_obj_li); - return ae_promises.load__event_file_obj_li; -} - - -// Updated 2024-06-17 -async function handle_delete_ae_obj_id__event_file( - { - api_cfg, - event_file_id, - params={}, - log_lvl=0 - } : { - api_cfg: any, - event_file_id: string, - params?: key_val, - log_lvl?: number - } - ) { - console.log(`*** handle_delete_ae_obj_id__event_file() *** event_file_id=${event_file_id}`); - - const endpoint = `/event/file/${event_file_id}/v2`; - - params['delete_hosted_file'] = true; // This does not actually delete the hosted file from the server. - params['rm_orphan'] = true; // This is what actually allows the hosted file to be deleted from the server. - - ae_promises.delete__event_file_obj = await api.delete_object({ - api_cfg: api_cfg, - endpoint: endpoint, - params: params, - // return_meta: return_meta, - log_lvl: log_lvl - }); - - db_events.files.delete(event_file_id); - - return ae_promises.delete__event_file_obj; -} - - -// Updated 2024-06-10 -async function handle_load_ae_obj_id__event_session( - { - api_cfg, - event_session_id, - try_cache=false, - log_lvl=0 - } : { - api_cfg: any, - event_session_id: string, - try_cache?: boolean, - log_lvl?: number - } - ) { - console.log(`*** handle_load_ae_obj_id__event_session() *** event_session_id=${event_session_id}`); - - let params = {}; - - // $events_sess.badges.status_load__event_session_obj = 'loading'; - ae_promises.load__event_session_obj = await api.get_ae_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_session', - obj_id: event_session_id, // NOTE: This is the FQDN, not normally the ID. - use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config. - use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config. - params: params, - log_lvl: log_lvl - }) - .then(function (event_session_obj_get_result) { - if (event_session_obj_get_result) { - // This is expecting a list - handle_db_save_ae_obj_li__event_session({obj_type: 'event_session', obj_li: [event_session_obj_get_result]}); - return event_session_obj_get_result; - } else { - console.log('No results returned.'); - return null; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }); - - return ae_promises.load__event_session_obj; -} - - -// Updated 2024-05-24 -async function handle_load_ae_obj_li__event_session( - { - api_cfg, - event_id, - params={}, - try_cache=true, - log_lvl=0 - } : { - api_cfg: any, - event_id: string, - params?: key_val, - try_cache?: boolean, - log_lvl?: number - } - ) { - console.log(`*** handle_load_ae_obj_li__event_session() ***`); - - let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled - let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden - let limit: number = (params.qry__limit ?? 99); // 99 - let offset: number = (params.qry__offset ?? 0); // 0 - - let params_json: key_val = {}; - - // console.log('params_json:', params_json); - - ae_promises.load__event_session_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_session', - for_obj_type: 'event', - for_obj_id: event_id, - use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config. - use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value - enabled: enabled, - hidden: hidden, - order_by_li: {'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'}, - limit: limit, - offset: offset, - params_json: params_json, - params: params, - log_lvl: log_lvl - }) - .then(function (event_session_obj_li_get_result) { - if (event_session_obj_li_get_result) { - handle_db_save_ae_obj_li__event_session({obj_type: 'event_session', obj_li: event_session_obj_li_get_result}); - return event_session_obj_li_get_result; - } else { - return []; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }); - - console.log('ae_promises.load__event_session_obj_li:', ae_promises.load__event_session_obj_li); - return ae_promises.load__event_session; -} - - -async function handle_search__event_session( - { - api_cfg, - event_id, - fulltext_search_qry_str, - ft_presenter_search_qry_str, - like_search_qry_str = null, - like_presentation_search_qry_str = null, - like_presenter_search_qry_str = null, - params = {}, - try_cache = true, - log_lvl = 0 - }: { - api_cfg: any, - event_id: any, - fulltext_search_qry_str: null|string, - ft_presenter_search_qry_str: null|string, - like_search_qry_str: null|string, - like_presentation_search_qry_str: null|string, - like_presenter_search_qry_str: null|string, - params: any, - try_cache: boolean, - log_lvl: null|number - } - ) { - console.log(`*** handle_search__event_session() *** event_id=${event_id}`); - - let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled - let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden - let limit: number = (params.qry__limit ?? 25); // 99 - let offset: number = (params.qry__offset ?? 0); // 0 - - let params_json: key_val = {}; - - if (!fulltext_search_qry_str && !like_search_qry_str) { - console.log('No search string provided!!!'); - return false; // Returning false instead of [] because no search was performed. - } - - if (fulltext_search_qry_str || ft_presenter_search_qry_str) { - params_json['ft_qry'] = {}; - if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) { - params_json['ft_qry']['default_qry_str'] = fulltext_search_qry_str; - } - - if (ft_presenter_search_qry_str && ft_presenter_search_qry_str.length > 2) { - params_json['ft_qry']['event_presenter_li_qry_str'] = ft_presenter_search_qry_str; - } - } - - // Use the AND (AND LIKE) query - // if (like_search_qry_str || like_presenter_search_qry_str) { - // params_json['and_like'] = {}; - // if (like_search_qry_str && like_search_qry_str.length > 2) { - // params_json['and_like']['default_qry_str'] = like_search_qry_str; - // } - // if (like_presenter_search_qry_str && like_presenter_search_qry_str.length > 2) { - // params_json['and_like']['event_presenter_li_qry_str'] = like_presenter_search_qry_str; - // } - // } - - // Use the AND (OR LIKE) query - if (like_search_qry_str || like_presentation_search_qry_str || like_presenter_search_qry_str) { - params_json['or_like'] = {}; - if (like_search_qry_str && like_search_qry_str.length > 2) { - params_json['or_like']['default_qry_str'] = like_search_qry_str; - } - if (like_presentation_search_qry_str && like_presentation_search_qry_str.length > 2) { - params_json['or_like']['event_presentation_li_qry_str'] = like_presentation_search_qry_str; - } - if (like_presenter_search_qry_str && like_presenter_search_qry_str.length > 2) { - params_json['or_like']['event_presenter_li_qry_str'] = like_presenter_search_qry_str; - } - } - - params_json['and_qry'] = {}; - - // if (session_type_code) { - // params_json['and_qry']['session_type_code'] = session_type_code; - // } - - let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'}; - - ae_promises.load__event_session_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_session', - for_obj_type: 'event', - for_obj_id: event_id, - use_alt_table: true, // NOTE: We want to use the alt table for session searching - use_alt_base: false, - enabled: enabled, - hidden: hidden, - order_by_li: order_by_li, - limit: limit, - offset: offset, - params_json: params_json, - params: params, - log_lvl: log_lvl - }) - .then(function (event_session_obj_li_get_result) { - if (event_session_obj_li_get_result) { - handle_db_save_ae_obj_li__event_session({obj_type: 'event_session', obj_li: event_session_obj_li_get_result}); - return event_session_obj_li_get_result; - } else { - return []; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }) - .finally(function () { - }); - - console.log('ae_promises.load__event_session_obj_li:', ae_promises.load__event_session_obj_li); - return ae_promises.load__event_session_obj_li; -} - - -// Updated 2024-06-20 -async function handle_load_ae_obj_id__event_presentation( - { - api_cfg, - event_presentation_id, - try_cache=false, - log_lvl=0 - } : { - api_cfg: any, - event_presentation_id: string, - try_cache?: boolean, - log_lvl?: number - } - ) { - console.log(`*** handle_load_ae_obj_id__event_presentation() *** event_presentation_id=${event_presentation_id}`); - - let params = {}; - - ae_promises.load__event_presentation_obj = await api.get_ae_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_presentation', - obj_id: event_presentation_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 (event_presentation_obj_get_result) { - if (event_presentation_obj_get_result) { - // This is expecting a list - handle_db_save_ae_obj_li__event_presentation({obj_type: 'event_presentation', obj_li: [event_presentation_obj_get_result]}); - return event_presentation_obj_get_result; - } else { - console.log('No results returned.'); - return null; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }); - - return ae_promises.load__event_presentation_obj; -} - - -// Updated 2024-06-10 -async function handle_load_ae_obj_li__event_presentation( - { - api_cfg, - event_session_id, - params={}, - try_cache=true, - log_lvl=0 - } : { - api_cfg: any, - event_session_id: string, - params?: key_val, - try_cache?: boolean, - log_lvl?: number - } - ) { - console.log(`*** handle_load_ae_obj_li__event_presentation() *** event_session_id=${event_session_id}`); - - let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled - let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden - let limit: number = (params.qry__limit ?? 99); // 99 - let offset: number = (params.qry__offset ?? 0); // 0 - - let params_json: key_val = {}; - - // console('params_json:', params_json); - - ae_promises.load__event_presentation_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_presentation', - for_obj_type: 'event_session', - for_obj_id: event_session_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: {'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'}, - limit: limit, - offset: offset, - params_json: params_json, - params: params, - log_lvl: log_lvl - }) - .then(function (event_presentation_obj_li_get_result) { - if (event_presentation_obj_li_get_result) { - handle_db_save_ae_obj_li__event_presentation({obj_type: 'event_presentation', obj_li: event_presentation_obj_li_get_result}); - return event_presentation_obj_li_get_result; - } else { - return []; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }); - - console.log('ae_promises.load__event_presentation_obj_li:', ae_promises.load__event_presentation_obj_li); - return ae_promises.load__event_presentation_obj_li; -} - - -// Updated 2024-06-13 -async function handle_load_ae_obj_id__event_presenter( - { - api_cfg, - event_presenter_id, - try_cache=false, - log_lvl=0 - } : { - api_cfg: any, - event_presenter_id: string, - try_cache?: boolean, - log_lvl?: number - } - ) { - console.log(`*** handle_load_ae_obj_id__event_presenter() *** event_presenter_id=${event_presenter_id}`); - - let params = {}; - - ae_promises.load__event_presenter_obj = await api.get_ae_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_presenter', - obj_id: event_presenter_id, // NOTE: This is the FQDN, not normally the ID. - 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 (event_presenter_obj_get_result) { - if (event_presenter_obj_get_result) { - // This is expecting a list - handle_db_save_ae_obj_li__event_presenter({obj_type: 'event_presenter', obj_li: [event_presenter_obj_get_result]}); - return event_presenter_obj_get_result; - } else { - console.log('No results returned.'); - return null; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }); - - return ae_promises.load__event_presenter_obj; -} - - -// Updated 2024-06-10 -async function handle_load_ae_obj_li__event_presenter( - { - api_cfg, - event_presentation_id, - params={}, - try_cache=true, - log_lvl=0 - } : { - api_cfg: any, - event_presentation_id: string, - params?: key_val, - try_cache?: boolean, - log_lvl?: number - } - ) { - console.log(`*** handle_load_ae_obj_li__event_presenter() *** event_presentation_id=${event_presentation_id}`); - - let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled - let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden - let limit: number = (params.qry__limit ?? 99); // 99 - let offset: number = (params.qry__offset ?? 0); // 0 - - let params_json: key_val = {}; - - // console.log('params_json:', params_json); - - ae_promises.load__event_presenter_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_presenter', - for_obj_type: 'event_presentation', - for_obj_id: event_presentation_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: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'}, - limit: limit, - offset: offset, - params_json: params_json, - params: params, - log_lvl: log_lvl - }) - .then(function (event_presenter_obj_li_get_result) { - if (event_presenter_obj_li_get_result) { - handle_db_save_ae_obj_li__event_presenter({obj_type: 'event_presenter', obj_li: event_presenter_obj_li_get_result}); - return event_presenter_obj_li_get_result; - } else { - return []; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }); - - console.log('ae_promises.load__event_presenter_obj_li:', ae_promises.load__event_presenter_obj_li); - return ae_promises.load__event_presenter_obj_li; -} - - -// Updated 2024-06-13 -async function handle_update_ae_obj__event_presenter( - { - api_cfg, - event_presenter_id, - data, - params={}, - log_lvl=0 - } : { - api_cfg: any, - event_presenter_id: string, - data: any, - params?: key_val, - log_lvl?: number - } - ) { - console.log(`*** handle_update_ae_obj__event_presenter() *** event_presenter_id=${event_presenter_id}`); - - ae_promises.update__event_presenter_obj = await api.update_ae_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_presenter', - obj_id: event_presenter_id, // NOTE: This is the FQDN, not normally the ID. - fields: data, - key: api_cfg.api_crud_super_key, - params: params, - return_obj: true, - log_lvl: log_lvl - }) - .then(function (event_presenter_obj_update_result) { - if (event_presenter_obj_update_result) { - handle_db_save_ae_obj_li__event_presenter({obj_type: 'event_presenter', obj_li: [event_presenter_obj_update_result]}); - return event_presenter_obj_update_result; - } else { - return null; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }) - .finally(function () { - }); - - console.log('ae_promises.update__event_presenter_obj:', ae_promises.update__event_presenter_obj); - return ae_promises.update__event_presenter_obj; -} - - -async function handle_load_ae_obj_id__badge({api_cfg, badge_id, try_cache=false}) { - console.log(`*** handle_load_ae_obj_id__badge() *** badge_id=${badge_id}`); - - let params = {}; - - // $events_sess.badges.status_load__badge_obj = 'loading'; - ae_promises.load__badge_obj = await api.get_ae_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_badge', - obj_id: badge_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 in the API config. - params: params, - log_lvl: 0 - }) - .then(function (badge_obj_get_result) { - if (badge_obj_get_result) { - // This is expecting a list - handle_db_save_ae_obj_li__badge({obj_type: 'event_badge', obj_li: [badge_obj_get_result]}); - return badge_obj_get_result; - } else { - console.log('No results returned.'); - return null; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }); - - return ae_promises.load__badge_obj; -} - - -// Updated 2024-03-06 -async function handle_load_ae_obj_li__badge( - { - api_cfg, - event_id, - params={}, - try_cache=true, - log_lvl=0 - }: { - api_cfg: any, - event_id: any, - params: any, - try_cache?: boolean, - log_lvl: number - }) { - console.log(`*** handle_load_ae_obj_li__badge() *** event_id=${event_id}`); - - let fulltext_search_qry_str = ''; // $events_sess.badges.fulltext_search_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 ?? 99); // 99 - let offset: number = (params.qry__offset ?? 0); // 0 - - // if ($ae_loc.administrator_access) { - // enabled = 'all'; - // hidden = 'all'; - // limit = 500; - // } else if ($ae_loc.trusted_access) { - // // enabled = 'all'; - // hidden = 'all'; - // limit = 50; - // } - - // let params = {}; - - let params_json: key_val = {}; - if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) { - params_json['ft_qry'] = { - 'default_qry_str': fulltext_search_qry_str, - // 'location_address_json_ext': fulltext_search_qry_str, // JSON extracted text DB field - // 'contact_li_json_ext': fulltext_search_qry_str, // JSON extracted text DB field - }; - } - - // console.log('params_json:', params_json); - // console.log(params_json); - - // $events_sess.badges.status_qry__search = 'loading'; - ae_promises.load__event_badge_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_badge', - for_obj_type: 'event', - for_obj_id: event_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. - enabled: enabled, - hidden: hidden, - order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'}, - // order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'created_on': 'DESC', 'updated_on': 'DESC'}, - limit: limit, - offset: offset, - params_json: params_json, - params: params, - log_lvl: log_lvl - }) - - .then(function (badge_obj_li_get_result) { - // console.log('Badge list:', badge_obj_li_get_result); - if (badge_obj_li_get_result) { - // $slct.badge_obj_li = badge_obj_li_get_result; - handle_db_save_ae_obj_li__badge({obj_type: 'event_badge', obj_li: badge_obj_li_get_result}); - return badge_obj_li_get_result; - } else { - // $slct.badge_obj_li = []; - return []; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }) - .finally(function () { - // $events_sess.badges.status_qry__search = 'done'; - - // console.log('Badge list:', badge_obj_li_get_result); - // return badge_obj_li_get_result; - }); - - if (log_lvl) { - console.log('ae_promises.load__event_badge_obj_li:', ae_promises.load__event_badge_obj_li); - } - return ae_promises.load__event_badge_obj_li; -} - - -async function handle_search__event_badge( - { - api_cfg, - event_id, - type_code = null, - fulltext_search_qry_str, - like_search_qry_str = null, - external_event_id, - params = {}, - try_cache = true, - log_lvl = 0 - }: { - api_cfg: any, - event_id: any, - type_code: any, - fulltext_search_qry_str: any, - like_search_qry_str: any, - external_event_id: any, - params: any, - try_cache: boolean, - log_lvl: number - } - ) { - console.log(`*** handle_search__event_badge() *** event_id=${event_id}`); - - let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled - let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden - let limit: number = (params.qry__limit ?? 25); // 99 - let offset: number = (params.qry__offset ?? 0); // 0 - - let params_json: key_val = {}; - - if (!fulltext_search_qry_str && !like_search_qry_str) { - console.log('No search string provided!!!'); - return false; // Returning false instead of [] because no search was performed. - } - - if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) { - params_json['ft_qry'] = { - 'default_qry_str': fulltext_search_qry_str, - // 'location_address_json_ext': fulltext_search_qry_str, // JSON extracted text DB field - // 'contact_li_json_ext': fulltext_search_qry_str, // JSON extracted text DB field - }; - } - - if (like_search_qry_str && like_search_qry_str.length > 2) { - // Old Python version that needs to be in JS - // # Strip (left right) whitespace then commas then semicolons - // query_str = query_str.strip().strip(',').strip(';') - // # Replace commas, semicolons, and then spaces with % - // query_str_like = query_str.replace(',', ' ').replace(';', ' ').replace(' ', '%').replace(' ', '%') - // # data['query_str'] = f'%{query_str}%' - // log.debug(query_str_like) - // data['query_str'] = f'%{query_str_like}%' - - // let like_search_qry_str_new = like_search_qry_str.trim().replace(',', ' ').replace(';', ' ').replace(' ', '%').replace(' ', '%'); - // like_search_qry_str_new = `%${like_search_qry_str_new}%`; - // console.log('like_search_qry_str_new:', like_search_qry_str_new); - - params_json['and_like'] = { - 'default_qry_str': like_search_qry_str, - }; - } - - params_json['and_qry'] = {}; - if (external_event_id) { - params_json['and_qry']['external_event_id'] = external_event_id; - } - - if (type_code) { // This is the event_badge.badge_type_code. There is also a member_type_code and registration_type_code that could be referenced in the future. - params_json['and_qry']['badge_type_code'] = type_code; - } - - let order_by_li = {'print_count': 'ASC', 'priority': 'DESC', 'sort': 'DESC', 'given_name': 'ASC', 'family_name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'}; - - // $events_sess.badges.status_qry__search = 'loading'; - ae_promises.search__event_badge = await api.get_ae_obj_li_for_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_badge', - for_obj_type: 'event', - for_obj_id: event_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. - enabled: enabled, - hidden: hidden, - order_by_li: order_by_li, - // order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'created_on': 'DESC', 'updated_on': 'DESC'}, - limit: limit, - offset: offset, - params_json: params_json, - params: params, - log_lvl: log_lvl - }) - .then(function (badge_obj_li_get_result) { - // console.log('Badge list:', badge_obj_li_get_result); - if (badge_obj_li_get_result) { - // $slct.badge_obj_li = badge_obj_li_get_result; - handle_db_save_ae_obj_li__badge({obj_type: 'event_badge', obj_li: badge_obj_li_get_result}); - return badge_obj_li_get_result; - } else { - // $slct.badge_obj_li = []; - return []; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }) - .finally(function () { - // $events_sess.badges.status_qry__search = 'done'; - - // console.log('Badge list:', badge_obj_li_get_result); - // return badge_obj_li_get_result; - }); - - console.log('ae_promises.search__event_badge:', ae_promises.search__event_badge); - return ae_promises.search__event_badge; -} - -async function handle_load_ae_obj_id__exhibit({api_cfg, exhibit_id, try_cache=false}) { - console.log(`*** handle_load_ae_obj_id__exhibit() *** exhibit_id=${exhibit_id}`); - - let params = {}; - - // $events_sess.exhibits.status_load__exhibit_obj = 'loading'; - ae_promises.load__exhibit_obj = await api.get_ae_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_exhibit', - obj_id: exhibit_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 in the API config. - params: params, - log_lvl: 0 - }) - .then(function (exhibit_obj_get_result) { - if (exhibit_obj_get_result) { - // This is expecting a list - handle_db_save_ae_obj_li__exhibitor({obj_type: 'event_exhibit', obj_li: [exhibit_obj_get_result]}); - return exhibit_obj_get_result; - } else { - console.log('No results returned.'); - return null; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }); - - return ae_promises.load__exhibit_obj; -} - - -// Updated 2024-03-06 -async function handle_load_ae_obj_li__exhibit({api_cfg, event_id, params={}, try_cache=true}: {api_cfg: any, event_id: any, params: any, try_cache?: boolean}) { - console.log(`*** handle_load_ae_obj_li__exhibit() *** event_id=${event_id}`); - - let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled - let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden - let limit: number = (params.qry__limit ?? 99); // 99 - let offset: number = (params.qry__offset ?? 0); // 0 - - // if ($ae_loc.administrator_access) { - // enabled = 'all'; - // hidden = 'all'; - // limit = 500; - // } else if ($ae_loc.trusted_access) { - // // enabled = 'all'; - // hidden = 'all'; - // limit = 50; - // } - - // let params = {}; - - let params_json: key_val = {}; - // params_json['and_qry'] = {}; - // params_json['and_qry']['license_max'] = 10; - - params_json['and_in_li'] = { - license_max : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], - }; - - // if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) { - // params_json['ft_qry'] = { - // 'default_qry_str': fulltext_search_qry_str, - // // 'location_address_json_ext': fulltext_search_qry_str, // JSON extracted text DB field - // // 'contact_li_json_ext': fulltext_search_qry_str, // JSON extracted text DB field - // }; - // } - - // console.log('params_json:', params_json); - // console.log(params_json); - - // $events_sess.exhibits.status_qry__search = 'loading'; - ae_promises.load__event_exhibit_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_exhibit', - for_obj_type: 'event', - for_obj_id: event_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. - enabled: enabled, - hidden: hidden, - order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'}, - // order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'created_on': 'DESC', 'updated_on': 'DESC'}, - limit: limit, - offset: offset, - params_json: params_json, - params: params, - log_lvl: 0 - }) - - .then(function (exhibit_obj_li_get_result) { - // console.log('Badge list:', exhibit_obj_li_get_result); - if (exhibit_obj_li_get_result) { - // $slct.exhibit_obj_li = exhibit_obj_li_get_result; - handle_db_save_ae_obj_li__exhibitor({obj_type: 'event_exhibit', obj_li: exhibit_obj_li_get_result}); - return exhibit_obj_li_get_result; - } else { - // $slct.exhibit_obj_li = []; - return []; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }) - .finally(function () { - // $events_sess.exhibits.status_qry__search = 'done'; - - // console.log('Badge list:', exhibit_obj_li_get_result); - // return exhibit_obj_li_get_result; - }); - - console.log('ae_promises.load__event_exhibit_obj_li:', ae_promises.load__event_exhibit_obj_li); - return ae_promises.load__event_exhibit_obj_li; -} - - -// // This function will loop through the badge_obj_li and save each one to the DB. -// function handle_db_save_ae_obj_li({obj_type, obj_li}) { -// console.log(`*** handle_db_save_ae_obj_li() ***`); - -// if (obj_li && obj_li.length) { -// obj_li.forEach(async function (obj) { -// // console.log(`ae_obj ${obj_type}:`, obj); - -// try { -// const id_random = await db_events.badges.put({ -// id_random: obj.event_badge_id_random, -// full_name: obj.full_name, -// full_name_override: obj.full_name_override, -// email: obj.email, -// email_override: obj.email_override, -// affiliations: obj.affiliations, -// affiliations_override: obj.affiliations_override, -// badge_type: obj.badge_type, -// badge_type_override: obj.badge_type_override, -// badge_type_code: obj.badge_type_code, -// badge_type_code_override: obj.badge_type_code_override, -// external_event_id: obj.external_event_id, -// external_id: obj.external_id, -// external_person_id: obj.external_person_id, -// created_on: obj.created_on, -// updated_on: obj.updated_on, -// }); -// console.log(`Put obj with ID: ${obj.event_badge_id_random} or ${id_random}`); -// } catch (error) { -// let status = `Failed to put ${obj.event_badge_id_random}: ${error}`; -// console.log(status); -// } - -// // const id_random = await db_events.badges.put(obj); -// // console.log(`Put obj with ID: ${obj.event_badge_id_random}`); -// }); - -// return true; -// } -// } - - -async function handle_load_ae_obj_id__exhibit_tracking({api_cfg, exhibit_tracking_id, try_cache=false}) { - console.log(`*** handle_load_ae_obj_id__exhibit_tracking() *** exhibit_tracking_id=${exhibit_tracking_id}`); - - let params = {}; - - // $events_sess.exhibits.status_load__exhibit_tracking_obj = 'loading'; - ae_promises.load__event_exhibit_tracking_obj = await api.get_ae_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_exhibit_tracking', - obj_id: exhibit_tracking_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 in the API config. - params: params, - log_lvl: 0 - }) - .then(function (exhibit_tracking_obj_get_result) { - if (exhibit_tracking_obj_get_result) { - // This is expecting a list - handle_db_save_ae_obj_li__exhibitor_tracking({obj_type: 'event_exhibit_tracking', obj_li: [exhibit_tracking_obj_get_result]}); - return exhibit_tracking_obj_get_result; - } else { - console.log('No results returned.'); - return null; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }); - - return ae_promises.load__event_exhibit_tracking_obj; -} - - -// Updated 2024-03-19 -async function handle_load_ae_obj_li__exhibit_tracking({api_cfg, exhibit_id, params={}, try_cache=true}: {api_cfg: any, exhibit_id: any, params: any, try_cache?: boolean}) { - console.log(`*** handle_load_ae_obj_li__exhibit_tracking() *** exhibit_id=${exhibit_id}`); - - let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled - let hidden: string = (params.qry__hidden ?? 'all'); // all, hidden, not_hidden - let limit: number = (params.qry__limit ?? 99); // 99 - let offset: number = (params.qry__offset ?? 0); // 0 - - let params_json: key_val = {}; - - ae_promises.load__event_exhibit_tracking_obj_li = await api.get_ae_obj_li_for_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_exhibit_tracking', - for_obj_type: 'event_exhibit', - for_obj_id: exhibit_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. - enabled: enabled, - hidden: hidden, - order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC'}, - limit: limit, - offset: offset, - params_json: params_json, - params: params, - log_lvl: 1 - }) - - .then(function (exhibit_tracking_obj_li_get_result) { - // console.log('Exhibit tracking list:', exhibit_tracking_obj_li_get_result); - if (exhibit_tracking_obj_li_get_result) { - // $slct.exhibit_tracking_obj_li = exhibit_tracking_obj_li_get_result; - handle_db_save_ae_obj_li__exhibitor_tracking({obj_type: 'event_exhibit_tracking', obj_li: exhibit_tracking_obj_li_get_result}); - return exhibit_tracking_obj_li_get_result; - } else { - // $slct.exhibit_tracking_obj_li = []; - return []; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }) - .finally(function () { - // console.log('Exhibit tracking list:', exhibit_tracking_obj_li_get_result); - // return exhibit_tracking_obj_li_get_result; - }); - - console.log('ae_promises.load__event_exhibit_tracking_obj_li:', ae_promises.load__event_exhibit_tracking_obj_li); - return ae_promises.load__event_exhibit_tracking_obj_li; -} - - -// Updated 2024-03-22 -async function handle_create_ae_obj__exhibit_tracking({api_cfg, exhibit_id, event_badge_id, external_person_id, params={}}) { - console.log(`*** handle_create_ae_obj__exhibit_tracking() *** exhibit_id=${exhibit_id}, event_badge_id=${event_badge_id}`); - - let params_json: key_val = {}; - - // $events_sess.exhibits.status_create__exhibit_tracking = 'loading'; - ae_promises.create__event_exhibit_tracking = await api.create_ae_obj_crud({ - api_cfg: api_cfg, - obj_type: 'event_exhibit_tracking', - fields: { - event_exhibit_id_random: exhibit_id, - event_badge_id_random: event_badge_id, - external_person_id: external_person_id, - }, - key: api_cfg.api_crud_super_key, - params: params, - return_obj: true, - log_lvl: 1 - }) - - .then(function (exhibit_tracking_obj_create_result) { - // console.log('Exhibit tracking create:', exhibit_tracking_obj_create_result); - if (exhibit_tracking_obj_create_result) { - // $slct.exhibit_tracking_obj = exhibit_tracking_obj_create_result; - handle_db_save_ae_obj_li__exhibitor_tracking({obj_type: 'event_exhibit_tracking', obj_li: [exhibit_tracking_obj_create_result]}); - return exhibit_tracking_obj_create_result; - } else { - // $slct.exhibit_tracking_obj = []; - return null; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }) - .finally(function () { - // console.log('Exhibit tracking create:', exhibit_tracking_obj_create_result); - // return exhibit_tracking_obj_create_result; - }); - - console.log('ae_promises.create__event_exhibit_tracking:', ae_promises.create__event_exhibit_tracking); - return ae_promises.create__event_exhibit_tracking; -} - - -// Updated 2024-03-28 -async function handle_update_ae_obj__exhibit_tracking({api_cfg, exhibit_tracking_id, data, params={}}) { - console.log(`*** handle_update_ae_obj__exhibit_tracking() *** exhibit_tracking_id=${exhibit_tracking_id}`); - - ae_promises.update__event_exhibit_tracking = await api.update_ae_obj_id_crud({ - api_cfg: api_cfg, - obj_type: 'event_exhibit_tracking', - obj_id: exhibit_tracking_id, - fields: data, - key: api_cfg.api_crud_super_key, - params: params, - return_obj: true, - log_lvl: 1 - }) - .then(function (exhibit_tracking_obj_update_result) { - if (exhibit_tracking_obj_update_result) { - handle_db_save_ae_obj_li__exhibitor_tracking({obj_type: 'event_exhibit_tracking', obj_li: [exhibit_tracking_obj_update_result]}); - return exhibit_tracking_obj_update_result; - } else { - return null; - } - }) - .catch(function (error) { - console.log('No results returned or failed.', error); - }) - .finally(function () { - }); - - console.log('ae_promises.update__event_exhibit_tracking:', ae_promises.update__event_exhibit_tracking); - return ae_promises.update__event_exhibit_tracking; -} - - -// This function will loop through the event_obj_li and save each one to the DB. -function handle_db_save_ae_obj_li__event({obj_type, obj_li}) { - console.log(`*** handle_db_save_ae_obj_li__event() ***`); - - if (obj_li && obj_li.length) { - obj_li.forEach(async function (obj) { - // console.log(`ae_obj ${obj_type}:`, obj); - - try { - const id_random = await db_events.events.put({ - id: obj.event_id_random, - // id_random: obj.event_id_random, - event_id: obj.event_id_random, - event_id_random: obj.event_id_random, - - code: obj.event_code, - - account_id: obj.account_id_random, - account_id_random: obj.account_id_random, - - conference: obj.conference, - type: obj.type, - name: obj.name, - summary: obj.summary, - description: obj.description, - - start_datetime: obj.start_datetime, - end_datetime: obj.end_datetime, - timezone: obj.timezone, - location_address_json: obj.location_address_json, - - mod_abstracts_json: obj.mod_abstracts_json, - mod_badges_json: obj.mod_badges_json, - mod_exhibits_json: obj.mod_exhibits_json, - mod_pres_mgmt_json: obj.mod_pres_mgmt_json, - cfg_json: obj.cfg_json, - - enable: obj.enable, - hide: obj.hide, - priority: obj.priority, - sort: obj.sort, - group: obj.group, - notes: obj.notes, - created_on: obj.created_on, - updated_on: obj.updated_on, - - // From SQL view - file_count: obj.file_count, - }); - // console.log(`Put obj with ID: ${obj.event_id_random} or ${id_random}`); - } catch (error) { - let status = `Failed to put ${obj.event_id_random}: ${error}`; - console.log(status); - } - - // const id_random = await db_events.events.put(obj); - // console.log(`Put obj with ID: ${obj.event_id_random}`); - }); - - return true; - } -} - - - -// This function will loop through the badge_obj_li and save each one to the DB. -function handle_db_save_ae_obj_li__badge({obj_type, obj_li}) { - console.log(`*** handle_db_save_ae_obj_li__badge() ***`); - - if (obj_li && obj_li.length) { - obj_li.forEach(async function (obj) { - // console.log(`ae_obj ${obj_type}:`, obj); - - try { - const id_random = await db_events.badges.put({ - id_random: obj.event_badge_id_random, - event_badge_id_random: obj.event_badge_id_random, - - event_id_random: obj.event_id_random, - - pronouns: obj.pronouns, - informal_name: obj.informal_name, - title_names: obj.title_names, - given_name: obj.given_name, - middle_name: obj.middle_name, - family_name: obj.family_name, - designations: obj.designations, - - professional_title: obj.professional_title, - professional_title_override: obj.professional_title_override, - - full_name: obj.full_name, - full_name_override: obj.full_name_override, - - affiliations: obj.affiliations, - affiliations_override: obj.affiliations_override, - - email: obj.email, - email_override: obj.email_override, - - address_line_1: obj.address_line_1, - address_line_2: obj.address_line_2, - address_line_3: obj.address_line_3, - city: obj.city, - country_subdivision_code: obj.country_subdivision_code, - state_province: obj.state_province, - state_province_abb: obj.state_province_abb, - postal_code: obj.postal_code, - country_alpha_2_code: obj.country_alpha_2_code, - country: obj.country, - full_address: obj.full_address, - location: obj.location, - location_override: obj.location_override, - - query_str: obj.query_str, - - badge_type: obj.badge_type, - badge_type_code: obj.badge_type_code, - badge_type_override: obj.badge_type_override, - badge_type_code_override: obj.badge_type_code_override, - external_event_id: obj.external_event_id, - external_id: obj.external_id, - external_person_id: obj.external_person_id, - - 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, - }); - // console.log(`Put obj with ID: ${obj.event_badge_id_random} or ${id_random}`); - } catch (error) { - let status = `Failed to put ${obj.event_badge_id_random}: ${error}`; - console.log(status); - } - - // const id_random = await db_events.badges.put(obj); - // console.log(`Put obj with ID: ${obj.event_badge_id_random}`); - }); - - return true; - } -} - -// This function will loop through the event_exhibit_obj_li and save each one to the DB. -function handle_db_save_ae_obj_li__exhibitor({obj_type, obj_li=[]}: {obj_type: string, obj_li: any[]}) { - console.log(`*** handle_db_save_ae_obj_li__exhibitor() ***`); - - if (obj_li && obj_li.length) { - obj_li.forEach(async function (obj) { - // console.log(`ae_obj ${obj_type}:`, obj); - - try { - const id_random = await db_events.exhibits.put({ - id_random: obj.event_exhibit_id_random, - event_exhibit_id_random: obj.event_exhibit_id_random, - - event_id_random: obj.event_id_random, - code: obj.code, - name: obj.name, - description: obj.description, - staff_passcode: obj.staff_passcode, - data_json: obj.data_json, - - leads_api_access: obj.leads_api_access, - leads_custom_questions_json: obj.leads_custom_questions_json, - leads_device_sm_qty: obj.leads_device_sm_qty, - leads_device_lg_qty: obj.leads_device_lg_qty, - license_max: obj.license_max, - license_li_json: obj.license_li_json, - cfg_json: obj.cfg_json, - - enable: obj.enable, - hide: obj.hide, - priority: obj.priority, - sort: obj.sort, - group: obj.group, - notes: obj.notes, - created_on: obj.created_on, - updated_on: obj.updated_on, - }); - // console.log(`Put obj with ID: ${obj.event_exhibit_id_random} or ${id_random}`); - } catch (error) { - let status = `Failed to put ${obj.event_exhibit_id_random}: ${error}`; - console.log(status); - } - - // const id_random = await db_events.exhibits.put(obj); - // console.log(`Put obj with ID: ${obj.event_exhibit_id_random}`); - }); - - return true; - } -} - -// This function will loop through the event_exhibit_tracking_obj_li and save each one to the DB. -function handle_db_save_ae_obj_li__exhibitor_tracking({obj_type, obj_li}) { - console.log(`*** handle_db_save_ae_obj_li__exhibitor_tracking() ***`); - - if (obj_li && obj_li.length) { - obj_li.forEach(async function (obj) { - // console.log(`ae_obj ${obj_type}:`, obj); - - try { - const id_random = await db_events.exhibit_tracking.put({ - id_random: obj.event_exhibit_tracking_id_random, - event_exhibit_tracking_id_random: obj.event_exhibit_tracking_id_random, - - event_exhibit_id_random: obj.event_exhibit_id_random, - event_badge_id_random: obj.event_badge_id_random, - event_person_id_random: obj.event_person_id_random, - - external_person_id: obj.external_person_id, - - exhibitor_notes: obj.exhibitor_notes, - - responses_json: obj.responses_json, - data_json: obj.data_json, - - event_exhibit_name: obj.event_exhibit_name, - - event_badge_title_names: obj.event_badge_title_names, - event_badge_given_name: obj.event_badge_given_name, - event_badge_family_name: obj.event_badge_family_name, - event_badge_designations: obj.event_badge_designations, - event_badge_full_name: obj.event_badge_full_name, - event_badge_full_name_override: obj.event_badge_full_name_override, - - event_badge_professional_title: obj.event_badge_professional_title, - event_badge_professional_title_override: obj.event_badge_professional_title_override, - - event_badge_affiliations: obj.event_badge_affiliations, - event_badge_affiliations_override: obj.event_badge_affiliations_override, - - event_badge_email: obj.event_badge_email, - event_badge_email_override: obj.event_badge_email_override, - - event_badge_location: obj.event_badge_location, - event_badge_location_override: obj.event_badge_location_override, - - event_badge_country: obj.event_badge_country, - - 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, - }); - // console.log(`Put obj with ID: ${obj.event_exhibit_tracking_id_random} or ${id_random}`); - } catch (error) { - let status = `Failed to put ${obj.event_exhibit_tracking_id_random}: ${error}`; - console.log(status); - } - - // const id_random = await db_events.exhibit_tracking.put(obj); - // console.log(`Put obj with ID: ${obj.event_exhibit_tracking_id_random}`); - }); - - return true; - } -} - - -// This function will loop through the event_file_obj_li and save each one to the DB. -function handle_db_save_ae_obj_li__event_file({obj_type, obj_li}) { - console.log(`*** handle_db_save_ae_obj_li__event_file() ***`); - - if (obj_li && obj_li.length) { - obj_li.forEach(async function (obj) { - console.log(`ae_obj ${obj_type}:`, obj); - - try { - const id_random = await db_events.files.put({ - id: obj.event_file_id_random, - id_random: obj.event_file_id_random, - event_file_id: obj.event_file_id_random, - event_file_id_random: obj.event_file_id_random, - - hosted_file_id: obj.hosted_file_id_random, - hosted_file_id_random: obj.hosted_file_id_random, - hash_sha256: obj.hash_sha256, // 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, - - event_id_random: obj.event_id_random, - event_session_id_random: obj.event_session_id_random, - event_presentation_id_random: obj.event_presentation_id_random, - event_presenter_id_random: obj.event_presenter_id_random, - event_location_id_random: obj.event_location_id_random, - - filename: obj.filename, - extension: obj.extension, - - open_in_os: obj.open_in_os, - - lu_file_purpose_id: obj.lu_file_purpose_id, // Not id_random in this case? - lu_event_file_purpose_name: obj.lu_event_file_purpose_name, - file_purpose: obj.file_purpose, - - enable: obj.enable, - hide: obj.hide, - priority: obj.priority, - sort: obj.sort, - group: obj.group, - notes: obj.notes, - created_on: obj.created_on, - updated_on: obj.updated_on, - - filename_no_ext: obj.filename_no_ext, - filename_w_ext: obj.filename_w_ext, - hosted_file_content_type: obj.hosted_file_content_type, - hosted_file_size: obj.hosted_file_size, - }); - // console.log(`Put obj with ID: ${obj.event_file_id_random} or ${id_random}`); - } catch (error) { - let status = `Failed to put ${obj.event_file_id_random}: ${error}`; - console.log(status); - } - - // const id_random = await db_events.files.put(obj); - // console.log(`Put obj with ID: ${obj.event_file_id_random}`); - }); - - return true; - } -} - -// This function will loop through the event_session_obj_li and save each one to the DB. -function handle_db_save_ae_obj_li__event_session({obj_type, obj_li}) { - console.log(`*** handle_db_save_ae_obj_li__event_session() ***`); - - if (obj_li && obj_li.length) { - obj_li.forEach(async function (obj) { - // console.log(`ae_obj ${obj_type}:`, obj); - - try { - const id_random = await db_events.sessions.put({ - id: obj.event_session_id_random, - event_session_id: obj.event_session_id_random, - event_session_id_random: obj.event_session_id_random, - - external_id: obj.external_id, - code: obj.code, - - for_type: obj.for_type, - for_id: obj.for_id_id_random, - for_id_random: obj.for_id_random, - - type_code: obj.type_code, - - event_id: obj.event_id_random, - event_id_random: obj.event_id_random, - event_location_id: obj.event_location_id_random, - event_location_id_random: obj.event_location_id_random, - - poc_person_id: obj.poc_person_id_random, - poc_person_id_random: obj.poc_person_id_random, - - name: obj.name, - description: obj.description, - - start_datetime: obj.start_datetime, - end_datetime: obj.end_datetime, - - passcode: obj.passcode, - - hide_event_launcher: obj.hide_event_launcher, - - alert: obj.alert, - alert_msg: obj.alert_msg, - - data_json: obj.data_json, - - enable: obj.enable, - hide: obj.hide, - priority: obj.priority, - sort: obj.sort, - group: obj.group, - notes: obj.notes, - created_on: obj.created_on, - updated_on: obj.updated_on, - - // From SQL view - file_count: obj.file_count, - file_count_all: obj.file_count_all, - internal_use_count: obj.internal_use_count, - - poc_person_given_name: obj.poc_person_given_name, - poc_person_family_name: obj.poc_person_family_name, - poc_person_full_name: obj.poc_person_full_name, - poc_person_primary_email: obj.poc_person_primary_email, - poc_person_passcode: obj.poc_person_passcode, - poc_kv_json: obj.poc_kv_json, - - event_name: obj.event_name, - - event_location_code: obj.event_location_code, - event_location_name: obj.event_location_name, - }); - // console.log(`Put obj with ID: ${obj.event_session_id_random} or ${id_random}`); - } catch (error) { - let status = `Failed to put ${obj.event_session_id_random}: ${error}`; - console.log(status); - } - - // const id_random = await db_events.sessions.put(obj); - // console.log(`Put obj with ID: ${obj.event_session_id_random}`); - }); - - return true; - } -} - - -// This function will loop through the event_presentation_obj_li and save each one to the DB. -// Updated 2024-06-10 -function handle_db_save_ae_obj_li__event_presentation({obj_type, obj_li}) { - console.log(`*** handle_db_save_ae_obj_li__event_presentation() ***`); - - if (obj_li && obj_li.length) { - obj_li.forEach(async function (obj) { - // console.log(`ae_obj ${obj_type}:`, obj); - - try { - const id_random = await db_events.presentations.put({ - id: obj.event_presentation_id_random, - // id_random: obj.event_presentation_id_random, - event_presentation_id: obj.event_presentation_id_random, - event_presentation_id_random: obj.event_presentation_id_random, - - external_id: obj.external_id, - code: obj.code, - - for_type: obj.for_type, - for_id: obj.for_id_random, - for_id_random: obj.for_id_random, - - type_code: obj.type_code, - - event_id: obj.event_id_random, - event_id_random: obj.event_id_random, - event_session_id: obj.event_session_id_random, - event_session_id_random: obj.event_session_id_random, - event_abstract_id: obj.event_abstract_id_random, - event_abstract_id_random: obj.event_abstract_id_random, - - abstract_code: obj.abstract_code, - - name: obj.name, - description: obj.description, - - start_datetime: obj.start_datetime, - end_datetime: obj.end_datetime, - - passcode: obj.passcode, - - hide_event_launcher: obj.hide_event_launcher, - - enable: obj.enable, - hide: obj.hide, - priority: obj.priority, - sort: obj.sort, - group: obj.group, - notes: obj.notes, - created_on: obj.created_on, - updated_on: obj.updated_on, - - // From SQL view - event_session_code: obj.event_session_code, - event_session_name: obj.event_session_name, - }); - // console.log(`Put obj with ID: ${obj.event_presentation_id_random} or ${id_random}`); - } catch (error) { - let status = `Failed to put ${obj.event_presentation_id_random}: ${error}`; - console.log(status); - } - - // const id_random = await db_events.presentations.put(obj); - // console.log(`Put obj with ID: ${obj.event_presentation_id_random}`); - }); - - return true; - } -} - - -// Updated 2024-06-10 -function handle_db_save_ae_obj_li__event_presenter({obj_type, obj_li}) { - console.log(`*** handle_db_save_ae_obj_li__event_presenter() ***`); - - if (obj_li && obj_li.length) { - obj_li.forEach(async function (obj) { - // console.log(`ae_obj ${obj_type}:`, obj); - - try { - const id_random = await db_events.presenters.put({ - id: obj.event_presenter_id_random, - // id_random: obj.event_presenter_id_random, - event_presenter_id: obj.event_presenter_id_random, - event_presenter_id_random: obj.event_presenter_id_random, - - external_id: obj.external_id, - code: obj.code, - - // for_type: obj.for_type, - // for_id_random: obj.for_id_random, - - event_id: obj.event_id_random, - event_id_random: obj.event_id_random, - event_session_id: obj.event_session_id_random, - event_session_id_random: obj.event_session_id_random, - event_presentation_id: obj.event_presentation_id_random, - event_presentation_id_random: obj.event_presentation_id_random, - event_person_id: obj.event_person_id_random, - event_person_id_random: obj.event_person_id_random, - person_id: obj.person_id_random, - person_id_random: obj.person_id_random, - person_profile_id: obj.person_profile_id_random, - person_profile_id_random: obj.person_profile_id_random, // The new table person_profile will be used soon... - - pronouns: obj.pronouns, - informal_name: obj.informal_name, - title_names: obj.title_names, - given_name: obj.given_name, - middle_name: obj.middle_name, - family_name: obj.family_name, - designations: obj.designations, - - professional_title: obj.professional_title, - - full_name: obj.full_name, - - affiliations: obj.affiliations, - - email: obj.email, - - biography: obj.biography, - - agree: obj.agree, - comments: obj.comments, - - passcode: obj.passcode, - - hide_event_launcher: obj.hide_event_launcher, - - data_json: obj.data_json, - - enable: obj.enable, - hide: obj.hide, - priority: obj.priority, - sort: obj.sort, - group: obj.group, - notes: obj.notes, - created_on: obj.created_on, - updated_on: obj.updated_on, - - file_count: obj.file_count, - - person_given_name: obj.person_given_name, - person_family_name: obj.person_family_name, - person_full_name: obj.person_full_name, - person_primary_email: obj.person_primary_email, - person_passcode: obj.person_passcode, - }); - // console.log(`Put obj with ID: ${obj.event_presenter_id_random} or ${id_random}`); - } catch (error) { - let status = `Failed to put ${obj.event_presenter_id_random}: ${error}`; - console.log(status); - } - - // const id_random = await db_events.presenters.put(obj); - // console.log(`Put obj with ID: ${obj.event_presenter_id_random}`); - }); - - return true; - } -} - - -async function handle_download_export__event_exhibit_tracking( - { - api_cfg, - exhibit_id, - file_type='CSV', // 'CSV' or 'Excel' - return_file=true, - filename='no_filename.csv', - auto_download=false, - params={}, - log_lvl=0 - } - ) { - console.log('*** ae_events_functions.js: get_event_exhibit_tracking_export() ***'); - - const endpoint = `/event/exhibit/${exhibit_id}/tracking/export`; - if (file_type == 'CSV' || file_type == 'Excel') { - params['file_type'] = file_type; - } - params['return_file'] = true; - - ae_promises.download__event_exhibit_tracking_export_file = await api.get_object({ - api_cfg: api_cfg, - endpoint: endpoint, - params: params, - return_blob: true, - filename: filename, - auto_download: auto_download, - log_lvl: log_lvl - }); - - console.log('ae_promises.download__event_exhibit_tracking_export_file:', ae_promises.download__event_exhibit_tracking_export_file); - return ae_promises.download__event_exhibit_tracking_export_file; -} - - -// Updated 2024-06-14 -async function create_event_file_obj_from_hosted_file_async( - { - api_cfg, - hosted_file_id, - params={}, - data={}, - return_obj=false, - inc_hosted_file=false, - return_meta=false, - log_lvl=0 - } - ) { - console.log('*** ae_events_functions.js: create_event_file_obj_from_hosted_file() ***'); - - let endpoint = `/event/file/from_hosted_file/${hosted_file_id}`; - if (return_obj) { - params['return_obj'] = true; - } - if (inc_hosted_file) { - params['inc_hosted_file'] = true; - } - let event_file_obj_post_promise = await api.post_object({ - api_cfg: api_cfg, - endpoint: endpoint, - params: params, - data: data, - return_obj: return_obj, - return_meta: return_meta, - log_lvl: log_lvl - }) - .then(function (result) { - console.log('POST DONE create_event_file_obj_from_hosted_file'); - console.log(result); - return result; - }) - .catch(function (error) { - console.log(error); - return false; // Returning false since something may have gone wrong. Also more in line with what the API returns. - // return error; - }); - - // console.log(event_file_obj_post_promise); - if (return_obj) { - return event_file_obj_post_promise; - } else { - return event_file_obj_post_promise.event_file_id_random; - } - -} +// This file is used to export all the functions that are used for Aether Events related functions. + +import { handle_load_ae_obj_id__event, handle_load_ae_obj_li__event, handle_db_save_ae_obj_li__event } from "$lib/ae_events__event"; + +import { + handle_load_ae_obj_id__event_file, + handle_load_ae_obj_li__event_file, + handle_delete_ae_obj_id__event_file, + create_event_file_obj_from_hosted_file_async, + handle_db_save_ae_obj_li__event_file +} from "$lib/ae_events__event_file"; + +import { + handle_load_ae_obj_id__exhibit, + handle_load_ae_obj_li__exhibit, + handle_load_ae_obj_id__exhibit_tracking, + handle_load_ae_obj_li__exhibit_tracking, + handle_create_ae_obj__exhibit_tracking, + handle_update_ae_obj__exhibit_tracking, + handle_download_export__event_exhibit_tracking, + handle_db_save_ae_obj_li__exhibitor +} from "$lib/ae_events__exhibit"; + +import { + handle_load_ae_obj_id__event_session, + handle_load_ae_obj_li__event_session, + handle_search__event_session, + handle_db_save_ae_obj_li__event_session +} from "$lib/ae_events__event_session"; + +import { + handle_load_ae_obj_id__event_presentation, + handle_load_ae_obj_li__event_presentation, + handle_db_save_ae_obj_li__event_presentation +} from "$lib/ae_events__event_presentation"; + +import { + handle_load_ae_obj_id__event_presenter, + handle_load_ae_obj_li__event_presenter, + handle_update_ae_obj__event_presenter, + handle_db_save_ae_obj_li__event_presenter +} from "$lib/ae_events__event_presenter"; + +import { + handle_load_ae_obj_id__badge, + handle_load_ae_obj_li__badge, + handle_search__event_badge, + handle_db_save_ae_obj_li__badge +} from "$lib/ae_events__event_badge"; let export_obj = { diff --git a/src/lib/api.ts b/src/lib/api.ts index de2649b5..40acc79a 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -550,7 +550,41 @@ export let create_ae_obj_crud = async function create_ae_obj_crud({api_cfg, obj_ // Updated 2023-06-28 -export let update_ae_obj_id_crud = async function update_ae_obj_id_crud({api_cfg, obj_type, obj_id, field_name, field_value, fields={}, key, jwt=null, headers={}, params={}, data={}, return_obj=false, obj_v_name='', return_meta=false, log_lvl=0}) { +export let update_ae_obj_id_crud = async function update_ae_obj_id_crud( + { + api_cfg, + obj_type, + obj_id, + field_name, + field_value, + fields={}, + key, + jwt=null, + headers={}, + params={}, + data={}, + return_obj=false, + obj_v_name='', + return_meta=false, + log_lvl=0 + } : { + api_cfg: any, + obj_type: string, + obj_id: string, + field_name?: string, + field_value?: any, + fields?: key_val, + key: string, + jwt?: string, + headers?: key_val, + params?: key_val, + data?: null|key_val, + return_obj?: boolean, + obj_v_name?: string, + return_meta?: boolean, + log_lvl?: number + } + ) { if (log_lvl) { console.log('*** update_ae_obj_id_crud() ***'); }