Now with a working recent files report. Other improvements.
This commit is contained in:
@@ -210,6 +210,7 @@ let events_local_data_struct: key_val = {
|
||||
qry_limit__presenters: 75,
|
||||
qry_limit__sessions: 100,
|
||||
qry_max: 500, // This is the max number the limit is allowed to be set to.
|
||||
qry__files_offset_seconds: null,
|
||||
|
||||
qry_and__file_count: true, // Essentially it should be greater than 0
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import { events_loc, events_sess, events_slct, events_trigger } from '$lib/ae_ev
|
||||
import { events_func } from '$lib/ae_events_functions';
|
||||
|
||||
import Event_reports_page_menu from './event_reports_page_menu.svelte';
|
||||
import Warning from 'postcss/lib/warning';
|
||||
|
||||
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other.
|
||||
$slct.account_id = data.account_id;
|
||||
@@ -60,9 +61,9 @@ onMount(() => {
|
||||
|
||||
});
|
||||
|
||||
async function handle_search__event_file(
|
||||
async function handle_qry__event_file(
|
||||
{
|
||||
created_on = null,
|
||||
created_on_offset = null,
|
||||
min_file_size = null, // in bytes
|
||||
ft_search_str = '',
|
||||
lk_search_str = '',
|
||||
@@ -74,7 +75,7 @@ async function handle_search__event_file(
|
||||
try_cache = true,
|
||||
log_lvl = 0,
|
||||
}: {
|
||||
created_on?: null|string,
|
||||
created_on_offset?: null|number,
|
||||
min_file_size?: null|number,
|
||||
ft_search_str?: string,
|
||||
lk_search_str?: string,
|
||||
@@ -83,15 +84,62 @@ async function handle_search__event_file(
|
||||
log_lvl?: number,
|
||||
}
|
||||
) {
|
||||
console.log('handle_search__event_file()');
|
||||
console.log('handle_qry__event_file()');
|
||||
|
||||
$events_sess.pres_mgmt.status_qry__search = 'loading';
|
||||
$events_sess.pres_mgmt.status_rpt[$events_sess.pres_mgmt.show_report] = 'loading';
|
||||
|
||||
let created_on_str = null;
|
||||
if (created_on_offset) {
|
||||
// Calculate the datetime to pass based on the selected offset.
|
||||
let offset = created_on_offset ?? 0;
|
||||
|
||||
let current_datetime = new Date();
|
||||
console.log(`Current time:`, current_datetime);
|
||||
|
||||
// It is very important to know that all of the created_on and updated_on timestamps are in ET timezone. Sorry...?
|
||||
let for_et_tz_datetime = new Date(current_datetime.toLocaleString('en-US', {timeZone: 'America/New_York'}));
|
||||
const offset_minutes = for_et_tz_datetime.getTimezoneOffset();
|
||||
const adjusted_for_et_tz_datetime = new Date(for_et_tz_datetime.getTime() - offset_minutes * 60 * 1000);
|
||||
const adjusted_for_et_tz_datetime_iso_str = adjusted_for_et_tz_datetime.toISOString().slice(0, -1);
|
||||
console.log(`Adjusted for ET TZ time:`, adjusted_for_et_tz_datetime_iso_str);
|
||||
|
||||
let offset_datetime = adjusted_for_et_tz_datetime;
|
||||
offset_datetime.setSeconds(offset_datetime.getSeconds() - offset);
|
||||
console.log(`Offset time:`, offset_datetime);
|
||||
// .slice(0, 19).replace('T', ' '), // '2024-10-15 13:59:59'
|
||||
const offset_datetime_iso_str = adjusted_for_et_tz_datetime.toISOString().slice(0, -1);
|
||||
console.log(`Offset time ET ISO: ${offset_datetime_iso_str}`);
|
||||
|
||||
created_on_str = offset_datetime_iso_str;
|
||||
|
||||
// Convert to US Eastern time and output as ISO string.
|
||||
// let offset_datetime_local = new Date(offset_datetime.toLocaleString('en-US', {timeZone: 'America/New_York'}));
|
||||
// console.log(`Test time local ET: ${offset_datetime_local}`);
|
||||
|
||||
// let formatted_str = offset_datetime_local.toLocaleString('en-US', {
|
||||
// year: 'numeric',
|
||||
// month: '2-digit',
|
||||
// day: '2-digit',
|
||||
// hour: '2-digit',
|
||||
// minute: '2-digit',
|
||||
// second: '2-digit',
|
||||
// timeZone: 'UTC'
|
||||
// });
|
||||
// console.log(`Test time local ET: ${formatted_str}`);
|
||||
|
||||
// let offset_datetime_local_str = offset_datetime_local.toISOString();
|
||||
// console.log(`Test time local ET: ${offset_datetime_local_str}`);
|
||||
|
||||
// created_on_str = offset_datetime_local_str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ae_promises.search__event_file = events_func.qry__event_file({
|
||||
api_cfg: $ae_api,
|
||||
event_id: $events_slct.event_id,
|
||||
qry_created_on: created_on,
|
||||
qry_created_on: created_on_str,
|
||||
qry_min_file_size: min_file_size,
|
||||
// fulltext_search_qry_str: ft_search_str,
|
||||
// like_search_qry_str: lk_search_str,
|
||||
@@ -605,11 +653,49 @@ async function handle_qry__event_session(
|
||||
type="button"
|
||||
disabled={!$ae_loc.trusted_access}
|
||||
on:click={() => {
|
||||
handle_search__event_file({
|
||||
created_on: null,
|
||||
// Calculate the datetime to pass based on the selected offset.
|
||||
// let offset = $events_loc.pres_mgmt.qry__files_offset_seconds ?? 0;
|
||||
|
||||
// let current_datetime = new Date();
|
||||
// console.log(`Current time:`, current_datetime);
|
||||
|
||||
// // It is very important to know that all of the created_on and updated_on timestamps are in ET timezone. Sorry...?
|
||||
// let for_et_tz_datetime = new Date(current_datetime.toLocaleString('en-US', {timeZone: 'America/New_York'}));
|
||||
// const offset_minutes = for_et_tz_datetime.getTimezoneOffset();
|
||||
// const adjusted_for_et_tz_datetime = new Date(for_et_tz_datetime.getTime() - offset_minutes * 60 * 1000);
|
||||
// const adjusted_for_et_tz_datetime_iso_str = adjusted_for_et_tz_datetime.toISOString().slice(0, -1);
|
||||
// console.log(`Adjusted for ET TZ time:`, adjusted_for_et_tz_datetime_iso_str);
|
||||
|
||||
// let offset_datetime = adjusted_for_et_tz_datetime;
|
||||
// offset_datetime.setSeconds(offset_datetime.getSeconds() - offset);
|
||||
// console.log(`Offset time:`, offset_datetime);
|
||||
// // .slice(0, 19).replace('T', ' '), // '2024-10-15 13:59:59'
|
||||
// const offset_datetime_iso_str = adjusted_for_et_tz_datetime.toISOString().slice(0, -1);
|
||||
// console.log(`Offset time ET ISO: ${offset_datetime_iso_str}`);
|
||||
|
||||
// // Convert to US Eastern time and output as ISO string.
|
||||
// let offset_datetime_local = new Date(offset_datetime.toLocaleString('en-US', {timeZone: 'America/New_York'}));
|
||||
// console.log(`Test time local ET: ${offset_datetime_local}`);
|
||||
|
||||
// let formatted_str = offset_datetime_local.toLocaleString('en-US', {
|
||||
// year: 'numeric',
|
||||
// month: '2-digit',
|
||||
// day: '2-digit',
|
||||
// hour: '2-digit',
|
||||
// minute: '2-digit',
|
||||
// second: '2-digit',
|
||||
// timeZone: 'UTC'
|
||||
// });
|
||||
// console.log(`Test time local ET: ${formatted_str}`);
|
||||
|
||||
// let offset_datetime_local_str = offset_datetime_local.toISOString();
|
||||
// console.log(`Test time local ET: ${offset_datetime_local_str}`);
|
||||
|
||||
handle_qry__event_file({
|
||||
created_on_offset: $events_loc.pres_mgmt.qry__files_offset_seconds ?? 0,
|
||||
// ft_search_str: '',
|
||||
// lk_search_str: '',
|
||||
log_lvl: log_lvl,
|
||||
log_lvl: 0,
|
||||
});
|
||||
$events_sess.pres_mgmt.show_report = 'recent_files';
|
||||
// $events_sess.pres_mgmt.show_report__presenters_agree = false;
|
||||
@@ -631,7 +717,7 @@ async function handle_qry__event_session(
|
||||
type="button"
|
||||
disabled={!$ae_loc.trusted_access}
|
||||
on:click={() => {
|
||||
handle_search__event_file({
|
||||
handle_qry__event_file({
|
||||
created_on: null,
|
||||
min_file_size: $events_loc.pres_mgmt.qry__files_min_size ?? 100000000, // in bytes
|
||||
// ft_search_str: '',
|
||||
@@ -789,7 +875,49 @@ async function handle_qry__event_session(
|
||||
|
||||
<!-- Show recently uploaded files -->
|
||||
{#if $events_sess.pres_mgmt.show_report == 'recent_files' && event_file_id_random_li}
|
||||
<h3 class="h4 text-center">Recent File Uploads</h3>
|
||||
<h3 class="h4 text-center">
|
||||
Recent File Uploads
|
||||
<!-- Show list of offsets: 10 minutes, 1 hours, 6 hours, 12 hours, 24 hours, 48 hours, 72 hours -->
|
||||
<select
|
||||
class="select text-sm w-28 variant-glass-warning hover:variant-ghost-warning transition-all m-1"
|
||||
bind:value={$events_loc.pres_mgmt.qry__files_offset_seconds}
|
||||
on:change={
|
||||
() => {
|
||||
if ($events_loc.pres_mgmt?.qry__files_offset_seconds) {
|
||||
// Calculate the datetime to pass based on the selected offset.
|
||||
// let offset = $events_loc.pres_mgmt.qry__files_offset_seconds ?? 0;
|
||||
// let created_on = new Date()
|
||||
// console.log(`Created on:`, created_on);
|
||||
// created_on.setSeconds(created_on.getSeconds() - offset);
|
||||
handle_qry__event_file({
|
||||
created_on_offset: $events_loc.pres_mgmt.qry__files_offset_seconds ?? 0,
|
||||
log_lvl: 1,
|
||||
});
|
||||
} else {
|
||||
console.log('No offset is will be used.');
|
||||
handle_qry__event_file({
|
||||
log_lvl: 1,
|
||||
});
|
||||
}
|
||||
|
||||
$events_sess.pres_mgmt.show_report = 'recent_files';
|
||||
}
|
||||
}
|
||||
>
|
||||
<option value="">-- not set --</option>
|
||||
<option value="600">10 minutes</option>
|
||||
<option value="3600">1 hour</option>
|
||||
<option value="21600">6 hours</option>
|
||||
<option value="43200">12 hours</option>
|
||||
<option value="86400">24 hours</option>
|
||||
<option value="172800">48 hours</option>
|
||||
<option value="259200">72 hours</option>
|
||||
</select>
|
||||
</h3>
|
||||
|
||||
<p class="text-center text-red-500 font-bold">
|
||||
This report is new and still being tested.
|
||||
</p>
|
||||
|
||||
<Comp_event_file_obj_tbl
|
||||
bind:event_file_id_random_li={event_file_id_random_li}
|
||||
@@ -811,8 +939,7 @@ async function handle_qry__event_session(
|
||||
bind:value={$events_loc.pres_mgmt.qry__files_min_size}
|
||||
on:change={
|
||||
() => {
|
||||
handle_search__event_file({
|
||||
created_on: null,
|
||||
handle_qry__event_file({
|
||||
min_file_size: $events_loc.pres_mgmt.qry__files_min_size ?? 100000000, // in bytes
|
||||
log_lvl: log_lvl,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user