Now with a new recent files report.
This commit is contained in:
@@ -269,6 +269,129 @@ export async function handle_update_ae_obj__event_file(
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-07-12
|
||||
export async function handle_search__event_file(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
created_on = null,
|
||||
fulltext_search_qry_str,
|
||||
ft_file_search_qry_str,
|
||||
like_search_qry_str = null,
|
||||
like_presentation_search_qry_str = null,
|
||||
like_file_search_qry_str = null,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: any,
|
||||
created_on?: null|string,
|
||||
fulltext_search_qry_str?: null|string,
|
||||
ft_file_search_qry_str?: null|string,
|
||||
like_search_qry_str?: null|string,
|
||||
like_presentation_search_qry_str?: null|string,
|
||||
like_file_search_qry_str?: null|string,
|
||||
params?: any,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_search__event_file() *** 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_file_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_file_search_qry_str && ft_file_search_qry_str.length > 2) {
|
||||
params_json['ft_qry']['event_file_li_qry_str'] = ft_file_search_qry_str;
|
||||
}
|
||||
}
|
||||
|
||||
// Use the AND (AND LIKE) query
|
||||
// if (like_search_qry_str || like_file_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_file_search_qry_str && like_file_search_qry_str.length > 2) {
|
||||
// params_json['and_like']['event_file_li_qry_str'] = like_file_search_qry_str;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Use the AND (OR LIKE) query
|
||||
// if (like_search_qry_str || like_presentation_search_qry_str || like_file_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_file_search_qry_str && like_file_search_qry_str.length > 2) {
|
||||
// params_json['or_like']['event_file_li_qry_str'] = like_file_search_qry_str;
|
||||
// }
|
||||
// }
|
||||
|
||||
// params_json['and_qry'] = {};
|
||||
|
||||
// if (created_on) {
|
||||
// params_json['and_qry']['created_on'] = created_on;
|
||||
// }
|
||||
|
||||
let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'filename': 'ASC', 'extension': 'ASC', 'hosted_file_size': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
|
||||
|
||||
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',
|
||||
for_obj_id: event_id,
|
||||
use_alt_table: true, // NOTE: We want to use the alt table for file 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_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 {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_file_obj_li:', ae_promises.load__event_file_obj_li);
|
||||
}
|
||||
return ae_promises.load__event_file_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// 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(
|
||||
{
|
||||
@@ -329,6 +452,19 @@ export function handle_db_save_ae_obj_li__event_file(
|
||||
hosted_file_content_type: obj.hosted_file_content_type,
|
||||
file_size: obj.file_size,
|
||||
hosted_file_size: obj.hosted_file_size,
|
||||
|
||||
event_location_code: obj.event_location_code,
|
||||
event_location_name: obj.event_location_name,
|
||||
event_session_code: obj.event_session_code,
|
||||
event_session_name: obj.event_session_name,
|
||||
event_session_start_datetime: obj.event_session_start_datetime,
|
||||
event_presentation_code: obj.event_presentation_code,
|
||||
event_presentation_name: obj.event_presentation_name,
|
||||
event_presentation_start_datetime: obj.event_presentation_start_datetime,
|
||||
event_presenter_given_name: obj.event_presenter_given_name,
|
||||
event_presenter_family_name: obj.event_presenter_family_name,
|
||||
event_presenter_full_name: obj.event_presenter_full_name,
|
||||
event_presenter_email: obj.event_presenter_email,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.event_file_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
handle_delete_ae_obj_id__event_file,
|
||||
create_event_file_obj_from_hosted_file_async,
|
||||
handle_update_ae_obj__event_file,
|
||||
handle_search__event_file,
|
||||
handle_db_save_ae_obj_li__event_file,
|
||||
} from "$lib/ae_events__event_file";
|
||||
|
||||
@@ -74,6 +75,7 @@ let export_obj = {
|
||||
handle_load_ae_obj_li__event_file: handle_load_ae_obj_li__event_file,
|
||||
handle_delete_ae_obj_id__event_file: handle_delete_ae_obj_id__event_file,
|
||||
handle_update_ae_obj__event_file: handle_update_ae_obj__event_file,
|
||||
handle_search__event_file: handle_search__event_file,
|
||||
|
||||
handle_load_ae_obj_id__event_location: handle_load_ae_obj_id__event_location,
|
||||
handle_load_ae_obj_li__event_location: handle_load_ae_obj_li__event_location,
|
||||
|
||||
@@ -281,6 +281,9 @@ let events_session_data_struct: key_val = {
|
||||
show_content__agree_text: false,
|
||||
show_content__presenter_start: false,
|
||||
|
||||
show_report__presenters_agree: false,
|
||||
show_report__recent_files: false,
|
||||
|
||||
new_upload_list: null,
|
||||
files_uploading_count: null,
|
||||
},
|
||||
@@ -334,6 +337,8 @@ let events_slct_obj_template: key_val = {
|
||||
'file_obj': {},
|
||||
'file_obj_li': [],
|
||||
|
||||
'event_file_obj_li': [],
|
||||
|
||||
'location_id': null,
|
||||
'location_obj': {},
|
||||
'location_obj_li': [],
|
||||
|
||||
@@ -238,6 +238,19 @@ export interface File {
|
||||
hosted_file_content_type: string;
|
||||
file_size: number; // In bytes
|
||||
hosted_file_size?: number; // In bytes
|
||||
|
||||
event_location_code?: null|string;
|
||||
event_location_name?: null|string;
|
||||
event_session_code?: null|string;
|
||||
event_session_name?: string;
|
||||
event_session_start_datetime?: null|Date;
|
||||
event_presentation_code?: null|string;
|
||||
event_presentation_name?: string;
|
||||
event_presentation_start_datetime?: null|Date;
|
||||
event_presenter_given_name?: null|string;
|
||||
event_presenter_family_name?: null|string;
|
||||
event_presenter_full_name?: null|string;
|
||||
event_presenter_email?: null|string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export let show_convert_btn: null|boolean = null;
|
||||
// }
|
||||
|
||||
let ae_placeholder_li: key_val = {};
|
||||
let ae_promises: key_val = {}; // Promise<any>;
|
||||
let ae_promises: key_val = {};
|
||||
let ae_tmp: key_val = {};
|
||||
ae_tmp.show__file_li = true;
|
||||
let ae_triggers: key_val = {};
|
||||
|
||||
Reference in New Issue
Block a user