Work on general clean up. Better export and email of sponsor data
This commit is contained in:
@@ -114,6 +114,10 @@ if ($ae_loc.site_cfg_json.slct__sponsorship_cfg_id) {
|
||||
console.log(`No Sponsorship Config ID set.`);
|
||||
}
|
||||
|
||||
if (!$ae_loc.user_email) {
|
||||
$ae_loc.user_email = 'test@oneskyit.com';
|
||||
}
|
||||
|
||||
if (browser) {
|
||||
// Waiting until the browser exists.
|
||||
// save_ds_to_local(ae_acct.ds);
|
||||
|
||||
164
src/routes/admin/+layout.svelte
Normal file
164
src/routes/admin/+layout.svelte
Normal file
@@ -0,0 +1,164 @@
|
||||
<script lang="ts">
|
||||
/** @type {import('./$types').LayoutData} */
|
||||
export let data: any;
|
||||
|
||||
import { goto } from '$app/navigation';
|
||||
import { onMount } from 'svelte';
|
||||
import type { Writable } from 'svelte/store';
|
||||
import { localStorageStore } from '@skeletonlabs/skeleton';
|
||||
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
// import { ae_util } from '$lib/ae_utils';
|
||||
import { api } from '$lib/api';
|
||||
import { ae_loc, ae_sess, ae_api, slct } from '$lib/ae_stores';
|
||||
import { events_loc, events_slct, events_trigger } from '$lib/ae_events_stores';
|
||||
|
||||
// import Element_data_store from '$lib/element_data_store.svelte';
|
||||
|
||||
if (!$ae_loc.admin) {
|
||||
$ae_loc.admin = {};
|
||||
}
|
||||
|
||||
$ae_loc.qry__enabled = 'enabled';
|
||||
$ae_loc.qry__hidden = 'not_hidden';
|
||||
$ae_loc.qry__limit = 15;
|
||||
$ae_loc.qry__offset = 0;
|
||||
|
||||
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other.
|
||||
$slct.account_id = data.account_id;
|
||||
console.log(`$slct.account_id = `, $slct.account_id);
|
||||
let ae_acct = data[$slct.account_id];
|
||||
console.log(`ae_acct = `, ae_acct);
|
||||
|
||||
$events_slct.event_id = ae_acct.slct.event_id;
|
||||
$events_slct.event_obj = ae_acct.slct.event_obj;
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
// if (ae_acct.loc.site_cfg_json.slct__event_id) {
|
||||
// $events_slct.event_id = ae_acct.loc.site_cfg_json.slct__event_id;
|
||||
// $events_loc.event_id = ae_acct.loc.site_cfg_json.slct__event_id;
|
||||
// } else if ($events_loc.default__event_id) {
|
||||
// $events_slct.event_id = $events_loc.default__event_id;
|
||||
// $events_loc.event_id = $events_loc.default__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 {
|
||||
// console.log(`No Event ID set.`);
|
||||
// }
|
||||
|
||||
// if ($events_slct.event_id) {
|
||||
// $events_trigger = 'load__event_obj';
|
||||
// }
|
||||
|
||||
|
||||
// Updated 2024-03-06
|
||||
// $: if ($events_trigger == 'load__event_obj' && $events_slct.event_id) {
|
||||
// console.log(`$events_slct.event_id=${$events_slct.event_id}`);
|
||||
// $events_trigger = null;
|
||||
|
||||
// let load_obj_results = handle_load_ae_obj_id__event({event_id: $events_slct.event_id, try_cache: false})
|
||||
// .then(function (load_obj_results) {
|
||||
// if (load_obj_results) {
|
||||
// console.log(`load_obj_results=`, load_obj_results);
|
||||
// } else {
|
||||
// console.log('No results returned.');
|
||||
// }
|
||||
// });
|
||||
// $events_slct.event_obj = load_obj_results;
|
||||
// console.log(`load_obj_results=`, load_obj_results);
|
||||
// }
|
||||
|
||||
|
||||
onMount(() => {
|
||||
console.log('Admin: +layout.svelte');
|
||||
|
||||
// if (data.url.searchParams.get('event_id')) {
|
||||
// $events_slct.event_id = data.url.searchParams.get('event_id');
|
||||
// $events_loc.event_id = data.url.searchParams.get('event_id');
|
||||
// }
|
||||
});
|
||||
|
||||
// Updated 2024-03-06
|
||||
// async function handle_load_ae_obj_id__event({event_id, try_cache=false}) {
|
||||
// console.log(`*** handle_load_ae_obj_id__event() *** event_id=${event_id} api_cfg=`, $ae_api);
|
||||
|
||||
// let params = {};
|
||||
|
||||
// // $events_sess.badges.status_load__event_obj = 'loading';
|
||||
// ae_promises.load__event_obj = await api.get_ae_obj_id_crud({
|
||||
// api_cfg: $ae_api,
|
||||
// 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;
|
||||
// }
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<svelte:head>
|
||||
<title>Æ Admin - {$ae_loc.title ?? 'Æ loading...'}</title>
|
||||
</svelte:head>
|
||||
|
||||
|
||||
<section
|
||||
class="submenu flex flex-row justify-center"
|
||||
class:hidden={$ae_loc.iframe}
|
||||
>
|
||||
|
||||
<span class="btn-group variant-soft-secondary px-4 py-2">
|
||||
{#each Object.entries(data.submenu) as [key, item]}
|
||||
<!-- <a href="/settings/{item.slug}">{item.title}</a> -->
|
||||
<!-- class:hidden={!$ae_loc.trusted_access && item.access} -->
|
||||
{#if item.disable}
|
||||
<button
|
||||
title={item.title}
|
||||
class="hover:variant-ghost-secondary"
|
||||
class:hidden={(!$ae_loc.trusted_access && item.access === 'trusted') || (!$ae_loc.administrator_access && item.access === 'administrator' || item.hide)}
|
||||
disabled={item.disable}
|
||||
|
||||
on:click={() => {
|
||||
// window.location(item.href);
|
||||
// href={item.href}
|
||||
// invalidateAll
|
||||
goto(item.href, { });
|
||||
}}
|
||||
>
|
||||
{item.name}
|
||||
</button>
|
||||
{:else}
|
||||
<a
|
||||
href={item.href}
|
||||
title={item.title}
|
||||
class="hover:variant-ghost-secondary"
|
||||
class:hidden={(!$ae_loc.trusted_access && item.access === 'trusted') || (!$ae_loc.administrator_access && item.access === 'administrator' || item.hide)}
|
||||
class:disabled={item.disable}
|
||||
>
|
||||
{item.name}
|
||||
</a>
|
||||
{/if}
|
||||
{/each}
|
||||
</span>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
<slot></slot>
|
||||
182
src/routes/admin/+page.svelte
Normal file
182
src/routes/admin/+page.svelte
Normal file
@@ -0,0 +1,182 @@
|
||||
<script lang="ts">
|
||||
export let data: any;
|
||||
console.log(`ae_events_badges +page data:`, data);
|
||||
// console.log(`ae_events_badges Data Params:`, data.url.searchParams.get('event_id'));
|
||||
|
||||
import { onMount } from '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, events_trigger } from '$lib/ae_events_stores';
|
||||
// import { ae_util } from '$lib/ae_utils';
|
||||
|
||||
import Element_data_store from '$lib/element_data_store.svelte';
|
||||
import Element_sql_qry from '$lib/element_sql_qry.svelte';
|
||||
// import Element_obj_tbl_row from '$lib/element_obj_tbl_row.svelte';
|
||||
|
||||
|
||||
let sql_report_qry = null;
|
||||
|
||||
onMount(() => {
|
||||
console.log('Admin: +page.svelte');
|
||||
|
||||
console.log('ae_ slct:', $slct);
|
||||
|
||||
let href_url = window.location.href;
|
||||
// console.log(href_url);
|
||||
|
||||
$ae_loc.href_url = href_url;
|
||||
// console.log(`$ae_loc.href_url = `, $ae_loc.href_url);
|
||||
|
||||
// $slct_trigger = 'msg_parent';
|
||||
// ae_util.handle_url_and_message('event_id', $events_slct.event_id);
|
||||
// ae_util.handle_url_and_message('badge_id', $events_slct.badge_id);
|
||||
// if ($events_slct.badge_id) {
|
||||
// console.log(`Got an ID. Let's show the modal!`);
|
||||
// modalStore.trigger(modal_edit__badge_obj);
|
||||
// }
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<section class="ae_admin md:container h-full mx-auto">
|
||||
|
||||
<h2 class="h3">Admin for {$ae_loc.account_name} ({$ae_loc.account_id})</h2>
|
||||
|
||||
|
||||
<h3 class="h4">Restricted Access</h3>
|
||||
<p>Accessing the admin is currently restricted</p>
|
||||
|
||||
|
||||
<Element_data_store
|
||||
ds_code="admin__overview"
|
||||
ds_type="html"
|
||||
for_type="event"
|
||||
for_id={$ae_loc.event_id}
|
||||
display="block"
|
||||
class_li="p-2"
|
||||
/>
|
||||
|
||||
{#if $ae_loc.trusted_access}
|
||||
<div>
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
$ae_loc.admin.show_option = 'ae_loc_json';
|
||||
}}
|
||||
class="btn btn-md variant-soft-primary hover:variant-ghost-primary"
|
||||
>
|
||||
AE Local Storage
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
$ae_loc.admin.show_option = 'event_file_list';
|
||||
}}
|
||||
class="btn btn-md variant-soft-primary hover:variant-ghost-primary"
|
||||
>
|
||||
Event File List
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
$ae_loc.admin.show_option = 'event_badge_printed';
|
||||
}}
|
||||
class="btn btn-md variant-soft-primary hover:variant-ghost-primary"
|
||||
>
|
||||
Event Badge Printed
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if $ae_loc.admin?.show_option == 'ae_loc_json'}
|
||||
<h2>AE Local Storage</h2>
|
||||
<pre class="text-xs">
|
||||
{JSON.stringify($ae_loc, null, 2)}
|
||||
</pre>
|
||||
{/if}
|
||||
|
||||
|
||||
{#if $ae_loc.admin?.show_option == 'event_file_list'}
|
||||
<h2>Report SQL</h2>
|
||||
<Element_data_store
|
||||
ds_code="rpt_sql_select_event_file_list_w_url"
|
||||
ds_type="sql"
|
||||
display="block"
|
||||
class_li="p-2"
|
||||
bind:val_sql={$ae_loc.ds['rpt_sql_select_event_file_list_w_url']}
|
||||
/>
|
||||
|
||||
<Element_sql_qry
|
||||
api_cfg={$ae_api}
|
||||
run_on_load={true}
|
||||
show_textarea={true}
|
||||
sql_statement={$ae_loc.ds['rpt_sql_select_event_file_list_w_url']}
|
||||
sql_data={ {'event_id': $slct.event_id, 'base_url': $ae_api.base_url} }
|
||||
as_list={true}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
|
||||
{#if $ae_loc.admin?.show_option == 'event_badge_printed'}
|
||||
<h2>Report SQL</h2>
|
||||
<Element_data_store
|
||||
ds_code="rpt_sql_select_event_badge_printed_by_ext_event"
|
||||
ds_type="sql"
|
||||
display="block"
|
||||
class_li="p-2"
|
||||
bind:val_sql={$ae_loc.ds['rpt_sql_select_event_badge_printed_by_ext_event']}
|
||||
/>
|
||||
|
||||
<Element_sql_qry
|
||||
api_cfg={$ae_api}
|
||||
remove_breaks={false}
|
||||
run_on_load={true}
|
||||
show_textarea={true}
|
||||
sql_statement={$ae_loc.ds['rpt_sql_select_event_badge_printed_by_ext_event']}
|
||||
sql_data={ {'event_id': $slct.event_id, 'base_url': $ae_api.base_url} }
|
||||
as_list={true}
|
||||
/>
|
||||
{/if}
|
||||
<!-- {#if $ae_loc.admin.show_element__cfg_detail} -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- {/if} -->
|
||||
|
||||
|
||||
{#if $ae_loc.admin?.show_element__sql_qry}
|
||||
|
||||
<h2>Report</h2>
|
||||
|
||||
<span>
|
||||
<!-- Setting run_on_load to false. True seems to cause a problem with it trying to render before the results have been returned. The sql_qry_result should be checked to see if it is a list of some kind. -->
|
||||
<!-- <Element_sql_qry
|
||||
api_cfg={$ae_api}
|
||||
run_on_load={false}
|
||||
show_textarea={false}
|
||||
remove_breaks={true}
|
||||
button_label={'Refresh Results'}
|
||||
sql_statement={sql_report_qry}
|
||||
sql_data={sql_report_data}
|
||||
as_list={true}
|
||||
log_lvl={1}
|
||||
/> -->
|
||||
</span>
|
||||
|
||||
{/if}
|
||||
|
||||
|
||||
|
||||
{/if}
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
<style lang="postcss">
|
||||
</style>
|
||||
@@ -182,6 +182,15 @@ async function handle_load_ae_obj_li__sponsorship({account_id, try_cache=true})
|
||||
if ($ae_loc.administrator_access) {
|
||||
enabled = 'all';
|
||||
hidden = 'all';
|
||||
limit = 150;
|
||||
} else if ($ae_loc.trusted_access) {
|
||||
enabled = 'enabled';
|
||||
hidden = 'not_hidden';
|
||||
limit = 100;
|
||||
} else {
|
||||
enabled = 'enabled';
|
||||
hidden = 'not_hidden';
|
||||
limit = 25;
|
||||
}
|
||||
|
||||
// let enabled = $ae_loc.mod.sponsorships.enabled;
|
||||
@@ -364,6 +373,57 @@ async function handle_load_ae_obj_id__sponsorship({sponsorship_id, try_cache=fal
|
||||
|
||||
return ae_sponsorship_obj_get_promise;
|
||||
}
|
||||
|
||||
|
||||
function send_guest_list_email() {
|
||||
|
||||
let guest_li_html_table: string;
|
||||
if ($slct.sponsorship_obj_li && $slct.sponsorship_obj_li.length > 0) {
|
||||
guest_li_html_table = '<table style="border: thin solid black; border-collapse: collapse; width: 100%;">';
|
||||
guest_li_html_table += '<tr style="border: thin solid black"><th>Sponsor</th><th>Name</th><th>Title</th><th>Affiliations</th><th>ADA</th><th>Dietary</th><th>Comments</th></tr>';
|
||||
for (let i = 0; i < $slct.sponsorship_obj_li.length; i++) {
|
||||
if ($slct.sponsorship_obj_li[i].guest_li_json && $slct.sponsorship_obj_li[i].guest_li_json.length > 0) {
|
||||
for (let j = 0; j < $slct.sponsorship_obj_li[i].guest_li_json.length; j++) {
|
||||
guest_li_html_table += '<tr style="border: thin solid black">';
|
||||
guest_li_html_table += `<td>${$slct.sponsorship_obj_li[i].name} (lvl ${$slct.sponsorship_obj_li[i].level_num})</td>`;
|
||||
guest_li_html_table += `<td>${$slct.sponsorship_obj_li[i].guest_li_json[j].full_name}</td>`;
|
||||
guest_li_html_table += `<td>${$slct.sponsorship_obj_li[i].guest_li_json[j].title ?? ''}</td>`;
|
||||
guest_li_html_table += `<td>${$slct.sponsorship_obj_li[i].guest_li_json[j].affiliations ?? ''}</td>`;
|
||||
guest_li_html_table += `<td>${$slct.sponsorship_obj_li[i].guest_li_json[j].ada ? `ADA: ${$slct.sponsorship_obj_li[i].guest_li_json[j].ada}` : ''}</td>`;
|
||||
guest_li_html_table += `<td>${$slct.sponsorship_obj_li[i].guest_li_json[j].dietary ? `Dietary: ${$slct.sponsorship_obj_li[i].guest_li_json[j].dietary}` : ''}</td>`;
|
||||
guest_li_html_table += `<td>${$slct.sponsorship_obj_li[i].guest_li_json[j].comments ? `Comments: ${$slct.sponsorship_obj_li[i].guest_li_json[j].comments}` : ''}</td>`;
|
||||
guest_li_html_table += '</tr>';
|
||||
}
|
||||
}
|
||||
// let guest_html_table_row = '<tr>';
|
||||
// guest_html_table_row += `<td>${$slct.sponsorship_obj_li[i].full_name}</td>`;
|
||||
// guest_html_table_row += `<td>${$slct.sponsorship_obj_li[i].title ?? ''}</td>`;
|
||||
// guest_html_table_row += `<td>${$slct.sponsorship_obj_li[i].affiliations ?? ''}</td>`;
|
||||
// guest_html_table_row += `<td>${$slct.sponsorship_obj_li[i].ada ? `ADA: ${$slct.sponsorship_obj_li[i].ada}` : ''}</td>`;
|
||||
// guest_html_table_row += `<td>${$slct.sponsorship_obj_li[i].dietary ? `Dietary: ${$slct.sponsorship_obj_li[i].dietary}` : ''}</td>`;
|
||||
// guest_html_table_row += `<td>${$slct.sponsorship_obj_li[i].comments ? `Comments: ${$slct.sponsorship_obj_li[i].comments}` : ''}</td>`;
|
||||
}
|
||||
guest_li_html_table += '</table>';
|
||||
}
|
||||
|
||||
console.log('Guest List HTML Table:', guest_li_html_table);
|
||||
|
||||
let subject = `CHOW 2024 Sponsor Hub Sponsors List`;
|
||||
|
||||
let body_html = `
|
||||
<p>The complete guest list is below in a table format.</p>
|
||||
${guest_li_html_table ? `<div><strong>Guests:</strong></br>${guest_li_html_table}</div>` : '<div>Guests: -- No Guests Added --</div>'}
|
||||
`;
|
||||
|
||||
api.send_email({
|
||||
api_cfg: $ae_api,
|
||||
from_email: 'noreply+chow@oneskyit.com',
|
||||
from_name: 'CHOW 2024 Sponsor Hub',
|
||||
to_email: $ae_loc.user_email,
|
||||
subject: subject,
|
||||
body_html: body_html,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -426,6 +486,25 @@ async function handle_load_ae_obj_id__sponsorship({sponsorship_id, try_cache=fal
|
||||
{/await}
|
||||
<span class="fas fa-download mx-1"></span> Export Data
|
||||
</button>
|
||||
|
||||
|
||||
<button
|
||||
class="btn btn-sm variant-ghost-primary w-48 mb-1 email_data_btn"
|
||||
on:click={() => {
|
||||
if (!confirm(`Are you sure you want to send this email? To: ${$ae_loc.user_email}?`)) {return false;}
|
||||
|
||||
// Question pop up to change the email address
|
||||
$ae_loc.user_email = prompt('Enter the email address to send the guest list to:', $ae_loc.user_email);
|
||||
if (!$ae_loc.user_email) {
|
||||
return false;
|
||||
}
|
||||
send_guest_list_email();
|
||||
|
||||
}}
|
||||
>
|
||||
<span class="fas fa-paper-plane mx-1"></span>
|
||||
Email With Guest List
|
||||
</button>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
|
||||
@@ -280,7 +280,13 @@ $: if ($slct.sponsorship_obj) {
|
||||
<!-- Contact: -->
|
||||
</span>
|
||||
{$slct.sponsorship_obj.guest_li_json[index].full_name}
|
||||
{#if $slct.sponsorship_obj.guest_li_json[index].email}
|
||||
—
|
||||
{$slct.sponsorship_obj.guest_li_json[index].title ?? ''}
|
||||
{$slct.sponsorship_obj.guest_li_json[index].affiliations ?? ''}
|
||||
{$slct.sponsorship_obj.guest_li_json[index].ada ? `ADA: ${$slct.sponsorship_obj.guest_li_json[index].ada}` : ''}
|
||||
{$slct.sponsorship_obj.guest_li_json[index].dietary ? `Dietary: ${$slct.sponsorship_obj.guest_li_json[index].dietary}` : ''}
|
||||
{$slct.sponsorship_obj.guest_li_json[index].comments ? `Comments: ${$slct.sponsorship_obj.guest_li_json[index].comments}` : ''}
|
||||
<!-- {#if $slct.sponsorship_obj.guest_li_json[index].email}
|
||||
| <a href="mailto:{$slct.sponsorship_obj.guest_li_json[index].email}?Subject={$slct.sponsorship_obj.full_name}">{$slct.sponsorship_obj.guest_li_json[index].email}</a>
|
||||
{/if}
|
||||
{#if $slct.sponsorship_obj.guest_li_json[index].phone_mobile}
|
||||
@@ -295,7 +301,7 @@ $: if ($slct.sponsorship_obj) {
|
||||
<span class="ae_label">| Office:</span>
|
||||
<a href="tel:{$slct.sponsorship_obj.guest_li_json[index].phone_office}">{$slct.sponsorship_obj.guest_li_json[index].phone_office}</a>
|
||||
{/if}
|
||||
{#if $slct.sponsorship_obj.guest_li_json[index].other_text}| {$slct.sponsorship_obj.guest_li_json[index].other_text}{/if}
|
||||
{#if $slct.sponsorship_obj.guest_li_json[index].other_text}| {$slct.sponsorship_obj.guest_li_json[index].other_text}{/if} -->
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user