Bug fix for attaching files to a BB Post.

This commit is contained in:
Scott Idem
2025-04-29 14:33:17 -04:00
parent f2384f2714
commit 007eb4ec9f
2 changed files with 1011 additions and 1011 deletions

View File

@@ -1,33 +1,33 @@
<script lang="ts">
/** @type {import('./$types').LayoutData} */
// /** @type {import('./$types').LayoutProps} */
/** @type {import('./$types').LayoutData} */
// /** @type {import('./$types').LayoutProps} */
let log_lvl: number = 0;
let log_lvl: number = 0;
// *** Import Svelte specific
import { tick } from 'svelte';
import { goto } from '$app/navigation';
// *** Import Svelte specific
import { tick } from 'svelte';
import { goto } from '$app/navigation';
import '../app.postcss';
import '../app.postcss';
// *** Import other supporting libraries
import { AppShell, AppBar, initializeStores } from '@skeletonlabs/skeleton';
// Initialize the stores for Drawer, Modal, and Toast so they work throughout the app.
initializeStores();
// import { Modal } from '@skeletonlabs/skeleton';
import type {
// *** Import other supporting libraries
import { AppShell, AppBar, initializeStores } from '@skeletonlabs/skeleton';
// Initialize the stores for Drawer, Modal, and Toast so they work throughout the app.
initializeStores();
// import { Modal } from '@skeletonlabs/skeleton';
import type {
ModalComponent
} from '@skeletonlabs/skeleton';
const modalRegistry: Record<string, ModalComponent> = {
const modalRegistry: Record<string, ModalComponent> = {
// Set a unique modal ID, then pass the component reference
// modalComponentEditSponsorshipObj: { ref: ModalComponentEditSponsorshipObj },
// modalComponentTwo: { ref: ModalComponentTwo },
// ...
};
import {
};
import {
CircleX,
Eye, EyeOff,
Key,
@@ -38,55 +38,55 @@ import {
User, UserCheck
} from '@lucide/svelte';
// Highlight JS
import hljs from 'highlight.js/lib/core';
import 'highlight.js/styles/github-dark.css';
// Highlight JS
import hljs from 'highlight.js/lib/core';
import 'highlight.js/styles/github-dark.css';
import { browser } from '$app/environment';
import { localStorageStore, storeHighlightJs } from '@skeletonlabs/skeleton';
import xml from 'highlight.js/lib/languages/xml'; // for HTML
import css from 'highlight.js/lib/languages/css';
import javascript from 'highlight.js/lib/languages/javascript';
import typescript from 'highlight.js/lib/languages/typescript';
import { browser } from '$app/environment';
import { localStorageStore, storeHighlightJs } from '@skeletonlabs/skeleton';
import xml from 'highlight.js/lib/languages/xml'; // for HTML
import css from 'highlight.js/lib/languages/css';
import javascript from 'highlight.js/lib/languages/javascript';
import typescript from 'highlight.js/lib/languages/typescript';
hljs.registerLanguage('xml', xml); // for HTML
hljs.registerLanguage('css', css);
hljs.registerLanguage('javascript', javascript);
hljs.registerLanguage('typescript', typescript);
storeHighlightJs.set(hljs);
hljs.registerLanguage('xml', xml); // for HTML
hljs.registerLanguage('css', css);
hljs.registerLanguage('javascript', javascript);
hljs.registerLanguage('typescript', typescript);
storeHighlightJs.set(hljs);
// *** Import Aether specific variables and functions
import Analytics from '$lib/analytics.svelte'
// import { api } from '$lib/api';
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
import { events_loc, events_slct } from '$lib/ae_events_stores';
// import type { key_val } from '$lib/ae_stores';
// *** Import Aether specific variables and functions
import Analytics from '$lib/analytics.svelte'
// import { api } from '$lib/api';
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
import { events_loc, events_slct } from '$lib/ae_events_stores';
// import type { key_val } from '$lib/ae_stores';
import Element_access_type from '$lib/element_access_type.svelte';
import Element_app_cfg from '$lib/element_app_cfg.svelte';
import Element_sign_in_out from '$lib/element_sign_in_out.svelte';
// import Element_data_store from '$lib/element_data_store_v2.svelte';
import Element_access_type from '$lib/element_access_type.svelte';
import Element_app_cfg from '$lib/element_app_cfg.svelte';
import Element_sign_in_out from '$lib/element_sign_in_out.svelte';
// import Element_data_store from '$lib/element_data_store_v2.svelte';
interface Props {
interface Props {
data: any;
children?: import('svelte').Snippet;
}
}
let { data, children }: Props = $props();
let { data, children }: Props = $props();
if (log_lvl > 1) {
if (log_lvl > 1) {
console.log(`ae_root +layout.svelte data:`, data);
}
}
// goto('/', {replaceState: true, invalidateAll: true});
// try {
// goto(data.route.id, {replaceState: true, invalidateAll: true});
// } catch (e) {
// console.log('Error going to root page:', e);
// goto('/', {replaceState: true, invalidateAll: true});
// }
// goto('/', {replaceState: true, invalidateAll: true});
// try {
// goto(data.route.id, {replaceState: true, invalidateAll: true});
// } catch (e) {
// console.log('Error going to root page:', e);
// goto('/', {replaceState: true, invalidateAll: true});
// }
if (browser && data.route.id !== '/') {
if (browser && data.route.id !== '/') {
// try {
// goto(data.route.id, {replaceState: true, invalidateAll: true});
// } catch (e) {
@@ -97,144 +97,144 @@ if (browser && data.route.id !== '/') {
// goto('/', {replaceState: true, invalidateAll: true});
// $ae_loc = {};
// $ae_loc.app_cfg = {};
}
}
let trigger_clear_access: null|boolean = $state(null);
let trigger_clear_access: null|boolean = $state(null);
// let account_id = localStorage.getItem('ae_account_id');
// console.log(`account_id = `, account_id);
// let account_id = localStorage.getItem('ae_account_id');
// console.log(`account_id = `, account_id);
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other. This should catch anything that is a child of this layout.svelte file.
$slct.account_id = data.account_id;
if (log_lvl) {
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other. This should catch anything that is a child of this layout.svelte file.
$slct.account_id = data.account_id;
if (log_lvl) {
console.log(`*ae_root +layout.svelte* $slct.account_id = ${$slct.account_id}`);
}
let ae_acct = data[$slct.account_id];
}
let ae_acct = data[$slct.account_id];
$ae_api = {
$ae_api = {
...$ae_api,
...ae_acct.api,
}
if (log_lvl > 1) {
}
if (log_lvl > 1) {
console.log(`$ae_api = `, $ae_api);
}
}
$ae_loc = {
$ae_loc = {
...$ae_loc,
...ae_acct.loc,
}
if (log_lvl > 1) {
}
if (log_lvl > 1) {
console.log(`$ae_loc = `, $ae_loc);
}
}
$slct = {
$slct = {
...$slct,
...ae_acct.slct,
}
if (log_lvl > 1) {
}
if (log_lvl > 1) {
console.log(`$slct = `, $slct);
}
}
if (!$ae_loc?.app_cfg) {
if (!$ae_loc?.app_cfg) {
$ae_loc.app_cfg = {};
$ae_loc.app_cfg.show_element__menu_btn = true;
$ae_loc.app_cfg.show_element__menu = false;
}
}
// if (!$ae_loc?.ver_testing) {
// console.log(`TEST: AE Stores - ver_testing missing:`, $ae_loc);
// // ae_app_local_data_struct = {
// // ...$ae_loc,
// // ...ae_app_local_data_struct,
// // };
// // $ae_loc.ver_testing = true; // test
// } else {
// console.log(`TEST: AE Stores - ver_testing found`);
// // $ae_loc.ver_testing = false; // test 2
// }
// if (!$ae_loc?.ver_testing) {
// console.log(`TEST: AE Stores - ver_testing missing:`, $ae_loc);
// // ae_app_local_data_struct = {
// // ...$ae_loc,
// // ...ae_app_local_data_struct,
// // };
// // $ae_loc.ver_testing = true; // test
// } else {
// console.log(`TEST: AE Stores - ver_testing found`);
// // $ae_loc.ver_testing = false; // test 2
// }
// // This should only be temporary. || !$ae_loc?.person || !$ae_loc?.user
// if (!$ae_loc) {
// console.log('No ae_loc. Reloading page...');
// window.location.reload();
// } else if ($ae_loc && $ae_sess && ($ae_loc.ver != $ae_sess.ver)) {
// console.log('New version of the ae_loc (core local storage) available!!!');
// console.log(`$ae_loc.ver: ${$ae_loc.ver} != $ae_sess.ver: ${$ae_sess.ver}`);
// // This should only be temporary. || !$ae_loc?.person || !$ae_loc?.user
// if (!$ae_loc) {
// console.log('No ae_loc. Reloading page...');
// window.location.reload();
// } else if ($ae_loc && $ae_sess && ($ae_loc.ver != $ae_sess.ver)) {
// console.log('New version of the ae_loc (core local storage) available!!!');
// console.log(`$ae_loc.ver: ${$ae_loc.ver} != $ae_sess.ver: ${$ae_sess.ver}`);
// // alert('New version available!!!');
// // alert('New version available!!!');
// // $ae_loc.ver = $ae_sess.ver;
// // $ae_loc.ver = $ae_sess.ver;
// // This does not seem to work fast enough or something?
// // goto('/', {replaceState: true, invalidateAll: true});
// // This does not seem to work fast enough or something?
// // goto('/', {replaceState: true, invalidateAll: true});
// console.log('Clearing localStorage...');
// // $ae_loc = null;
// // localStorage.removeItem('ae_loc');
// // localStorage.removeItem('ae_idaa_loc');
// // localStorage.removeItem('ae_journals_loc');
// // localStorage.removeItem('ae_events_loc');
// localStorage.clear();
// console.log('Clearing localStorage...');
// // $ae_loc = null;
// // localStorage.removeItem('ae_loc');
// // localStorage.removeItem('ae_idaa_loc');
// // localStorage.removeItem('ae_journals_loc');
// // localStorage.removeItem('ae_events_loc');
// localStorage.clear();
// // sessionStorage.removeItem('ae_sess');
// // sessionStorage.removeItem('events_sess');
// // console.log('Clearing sessionStorage...');
// // sessionStorage.clear();
// console.log('Reloading page...');
// location.reload();
// } else if (!$ae_loc?.app_cfg) {
// console.log('No ae_loc.app_cfg. Reloading page...?');
// // sessionStorage.removeItem('ae_sess');
// // sessionStorage.removeItem('events_sess');
// // console.log('Clearing sessionStorage...');
// // sessionStorage.clear();
// console.log('Reloading page...');
// location.reload();
// } else if (!$ae_loc?.app_cfg) {
// console.log('No ae_loc.app_cfg. Reloading page...?');
// // $ae_loc = {};
// // localStorage.removeItem('ae_loc');
// // localStorage.removeItem('ae_idaa_loc');
// // localStorage.removeItem('ae_journals_loc');
// // localStorage.removeItem('ae_events_loc');
// // localStorage.clear();
// // $ae_loc = {};
// // localStorage.removeItem('ae_loc');
// // localStorage.removeItem('ae_idaa_loc');
// // localStorage.removeItem('ae_journals_loc');
// // localStorage.removeItem('ae_events_loc');
// // localStorage.clear();
// // sessionStorage.removeItem('ae_sess');
// // sessionStorage.removeItem('events_sess');
// // sessionStorage.clear();
// // sessionStorage.removeItem('ae_sess');
// // sessionStorage.removeItem('events_sess');
// // sessionStorage.clear();
// // window.location.reload();
// // location.reload();
// // tick();
// // $ae_loc.app_cfg = {};
// } else if ($ae_loc?.app_cfg && !$ae_loc?.app_cfg?.show_element__menu_btn) {
// console.log('No ae_loc.app_cfg.show_element__menu_btn. Forcing show.');
// $ae_loc.app_cfg.show_element__menu_btn = true;
// $ae_loc.app_cfg.show_element__menu = false;
// }
// // window.location.reload();
// // location.reload();
// // tick();
// // $ae_loc.app_cfg = {};
// } else if ($ae_loc?.app_cfg && !$ae_loc?.app_cfg?.show_element__menu_btn) {
// console.log('No ae_loc.app_cfg.show_element__menu_btn. Forcing show.');
// $ae_loc.app_cfg.show_element__menu_btn = true;
// $ae_loc.app_cfg.show_element__menu = false;
// }
// localStorage caches - Check if the last refresh timestamp for $ae_loc.last_refresh is no more than 48 hours ago.
let default_refresh_time = 4 * 60 * 60 * 1000; // 48 hours or 2880 minutes? 48 * 60 *
let trusted_refresh_time = 168 * 60 * 60 * 1000; // 1 week or 10080 minutes?
// localStorage caches - Check if the last refresh timestamp for $ae_loc.last_refresh is no more than 48 hours ago.
let default_refresh_time = 4 * 60 * 60 * 1000; // 48 hours or 2880 minutes? 48 * 60 *
let trusted_refresh_time = 168 * 60 * 60 * 1000; // 1 week or 10080 minutes?
// IDB caches - Check if the last refresh timestamp for $ae_loc.last_cache_refresh is no more than 15 minutes ago.
let default_idb_refresh_time = 2 * 60 * 60 * 1000; // 15 minutes?
let trusted_idb_refresh_time = 4 * 60 * 60 * 1000; // 4 hours or 120 minutes?
// IDB caches - Check if the last refresh timestamp for $ae_loc.last_cache_refresh is no more than 15 minutes ago.
let default_idb_refresh_time = 2 * 60 * 60 * 1000; // 15 minutes?
let trusted_idb_refresh_time = 4 * 60 * 60 * 1000; // 4 hours or 120 minutes?
// There should almost always be an event_id set.
if ($ae_loc?.site_cfg_json?.slct__event_id) {
// There should almost always be an event_id set.
if ($ae_loc?.site_cfg_json?.slct__event_id) {
$events_slct.event_id = $ae_loc.site_cfg_json.slct__event_id;
$events_loc.event_id = $ae_loc.site_cfg_json.slct__event_id;
} else if ($events_slct?.event_id) {
} else if ($events_slct?.event_id) {
// console.log(`Event ID already set:`, $events_slct.event_id);
$events_loc.event_id = $events_slct.event_id;
} else {
} else {
if (log_lvl > 1) {
console.log(`No Event ID set!`);
}
}
}
// This is mainly for Precon CHOW
if ($ae_loc?.site_cfg_json?.slct__sponsorship_cfg_id) {
// This is mainly for Precon CHOW
if ($ae_loc?.site_cfg_json?.slct__sponsorship_cfg_id) {
$slct.sponsorship_cfg_id = $ae_loc.site_cfg_json.slct__sponsorship_cfg_id;
if ($ae_loc?.mod?.sponsorships) {
$ae_loc.mod.sponsorships.cfg_id = $ae_loc.site_cfg_json.slct__sponsorship_cfg_id;
@@ -246,18 +246,18 @@ if ($ae_loc?.site_cfg_json?.slct__sponsorship_cfg_id) {
}
};
}
} else if ($ae_loc?.sponsorship_cfg_id) {
} else if ($ae_loc?.sponsorship_cfg_id) {
$slct.sponsorship_cfg_id = $ae_loc.sponsorship_cfg_id;
$ae_loc.mod.sponsorships.cfg_id = $ae_loc.sponsorship_cfg_id;
} else {
} else {
if (log_lvl > 1) {
console.log(`No Sponsorship Config ID set.`);
}
}
}
// Updated 2024-11-21
if ($ae_loc.site_access_key || $ae_loc.site_domain_access_key) {
// Updated 2024-11-21
if ($ae_loc.site_access_key || $ae_loc.site_domain_access_key) {
// log_lvl = 2;
if (log_lvl > 1) {
console.log(`We need to do a current check against the allow_access value. site key: ${$ae_loc.site_access_key}, domain key: ${$ae_loc.site_domain_access_key}`);
@@ -282,13 +282,13 @@ if ($ae_loc.site_access_key || $ae_loc.site_domain_access_key) {
$ae_loc.allow_access = false;
}
}
} else {
} else {
// This means this site and domain do not require an access key.
$ae_loc.allow_access = true;
}
}
if (browser) {
if (browser) {
if (!$ae_loc) {
console.log('No ae_loc. Reloading page...');
// window.location.reload();
@@ -603,44 +603,44 @@ if (browser) {
$ae_loc.mod.sponsorships.cfg_id = data.url.searchParams.get('sponsorship_cfg_id');
}
}
}
// We want to loop through all of the data store (ds) key value pairs and set them to localStorage
// $: if (ae_acct.ds) {
// console.log(`ae_ds__ data:`, ae_acct.ds)
// for (let [key, value] of Object.entries(ae_acct.ds)) {
// console.log(`ae_ds__ key: ${key}, value:`, value);
// localStorageStore(`ae_ds__${key}`, value);
// }
// }
// We want to loop through all of the data store (ds) key value pairs and set them to localStorage
// $: if (ae_acct.ds) {
// console.log(`ae_ds__ data:`, ae_acct.ds)
// for (let [key, value] of Object.entries(ae_acct.ds)) {
// console.log(`ae_ds__ key: ${key}, value:`, value);
// localStorageStore(`ae_ds__${key}`, value);
// }
// }
// Check if in the array of: super > manager > administrator > trusted > public > authenticated > anonymous
const access_type_li = ['super', 'manager', 'administrator', 'trusted', 'public', 'authenticated', 'anonymous'];
$effect(() => {
// Check if in the array of: super > manager > administrator > trusted > public > authenticated > anonymous
const access_type_li = ['super', 'manager', 'administrator', 'trusted', 'public', 'authenticated', 'anonymous'];
$effect(() => {
if (browser && $ae_loc.access_type && access_type_li.includes($ae_loc.access_type)) {
document.getElementsByTagName('html')[0].classList.remove('super_access', 'manager_access', 'administrator_access', 'trusted_access', 'public_access', 'authenticated_access', 'anonymous_access');
document.getElementsByTagName('html')[0].classList.add(`${$ae_loc.access_type}_access`);
} else if (browser) {
document.getElementsByTagName('html')[0].classList.remove('super_access', 'manager_access', 'administrator_access', 'trusted_access', 'public_access', 'authenticated_access', 'anonymous_access');
}
});
});
</script>
</script>
{#if $ae_loc?.site_google_tracking_id && $ae_loc?.site_google_tracking_id.length > 0}
{#if $ae_loc?.site_google_tracking_id && $ae_loc?.site_google_tracking_id.length > 0}
{/if}
<Analytics bind:site_google_tracking_id={$ae_loc.site_google_tracking_id} />
{/if}
<svelte:head>
<svelte:head>
<!-- <title>{$ae_loc.title ?? 'Æ loading...'}</title> -->
<link rel="stylesheet" href="{ae_acct.loc.site_style_href}">
</svelte:head>
<!-- <link rel="manifest" href="/manifest.json"> -->
</svelte:head>
<!-- regionFooter="flex justify-end space-x-2" -->
<!-- regionFooter="flex justify-end space-x-2" -->
{#if (browser && $ae_loc && $ae_sess && ($ae_loc.ver != $ae_sess.ver))}
{#if (browser && $ae_loc && $ae_sess && ($ae_loc.ver != $ae_sess.ver))}
<div class="flex flex-col items-center justify-center h-full max-w-lg mx-auto space-y-4">
<h1 class="text-4xl font-bold text-red-600 dark:text-red-400">New Version Available</h1>
@@ -688,13 +688,13 @@ $effect(() => {
Reload and Clear Cache
</button>
</div>
{:else if $ae_loc?.allow_access}
{:else if $ae_loc?.allow_access}
<!-- Should we check for "browser" here as well? This may hide some status information as a page is loading. -->
<!-- The children will contain top level (directly under body tag) div tag(s) or similar. Modal and AppShell should also be set there. The AppShell gives access to a header, footer, AppBar (usually under header), -->
{@render children?.()}
{:else if browser}
{:else if browser}
<div
@@ -759,15 +759,15 @@ $effect(() => {
<p>This sometimes happens with new versions of the app or when in an iframe.</p>
</div>
</div>
{/if}
{/if}
<!-- min-h-full
max-h-max
min-w-full
max-w-max -->
<!-- min-h-full
max-h-max
min-w-full
max-w-max -->
<!-- Toggle the menu -->
<section
<!-- Toggle the menu -->
<section
class="
ae_app__menu
@@ -961,10 +961,10 @@ max-w-max -->
{/if}
</button>
</section>
</section>
<!-- Show menu on right side of page -->
<section
<!-- Show menu on right side of page -->
<section
class="
ae_app__menu
@@ -1042,9 +1042,9 @@ max-w-max -->
<!-- </span> -->
{/if}
</button>
</section>
</section>
<div
<div
class="absolute bottom-0 left-0 flex text-sm sm:text-sm md:text-md lg:text-md xl:text-md 2xl:text-lg text-slate-400 hover:text-slate-800 transition px-1 w-full outline"
class:ae_debug={$ae_loc.debug}
@@ -1073,12 +1073,12 @@ max-w-max -->
<Element_access_type
hidden={$ae_loc.iframe && !$ae_loc.trusted_access}
/>
</div>
{/if} -->
</div>
<style lang="postcss">
/* BEGIN: AE's Svelte Quick Debug component */
#AE-Quick-Debug {
<style lang="postcss">
/* BEGIN: AE's Svelte Quick Debug component */
#AE-Quick-Debug {
/* position: absolute; */
position: fixed;
@@ -1114,9 +1114,9 @@ max-w-max -->
transition-property: opacity, background-color;
transition-delay: 1.25s;
transition-duration: .5s;
}
transition-timing-function: ease-out;
}
#AE-Quick-Debug:hover {
#AE-Quick-Debug:hover {
/* lightyellow */
/* background-color: hsla(60,100%,90%,.95); */
@@ -1138,5 +1138,5 @@ max-w-max -->
transition-property: opacity, background-color;
transition-delay: .5s;
transition-duration: .10s;
}
</style>
transition-timing-function: ease-in;
}

View File

@@ -425,7 +425,7 @@ function send_staff_notification_email() {
accept="image/*, .docx, .pdf, .pptx, .key"
class_li="border border-gray-300 rounded-md p-2 bg-gray-100 hover:bg-gray-200"
link_to_type="post"
link_to_id={$idaa_slct.post_obj.post_id}
link_to_id={$idaa_slct.post_obj.post_id_random}
bind:hosted_file_id_li={$idaa_slct.post_obj.hosted_file_id_li}
bind:hosted_file_obj_li={$idaa_slct.post_obj.hosted_file_obj_li}
bind:upload_complete={$idaa_slct.post_obj.upload_complete}