Wrapping up for the night at 4 AM. Made lots of progress with the Journals module. Should have saved more often.

This commit is contained in:
Scott Idem
2025-03-16 04:04:58 -04:00
parent d8020b3d77
commit b62a267ee8
23 changed files with 2340 additions and 1182 deletions

View File

@@ -10,15 +10,15 @@ import type { key_val } from '$lib/ae_stores';
// import { ae_util } from '$lib/ae_utils/ae_utils';
// import { api } from '$lib/api';
import { ae_loc, ae_sess, ae_api, slct } from '$lib/ae_stores';
import { notes_loc, notes_slct, notes_trigger } from '$lib/ae_notes/ae_notes_stores';
// import { notes_func } from '$lib/ae_notes/ae_notes_functions';
import { journals_loc, journals_slct, journals_trig } from '$lib/ae_journals/ae_journals_stores';
// import { journals_func } from '$lib/ae_journals/ae_journals_functions';
// import Element_data_store from '$lib/element_data_store_v2.svelte';
$notes_loc.qry__enabled = 'enabled';
$notes_loc.qry__hidden = 'not_hidden';
$notes_loc.qry__limit = 15;
$notes_loc.qry__offset = 0;
$journals_loc.qry__enabled = 'enabled';
$journals_loc.qry__hidden = 'not_hidden';
$journals_loc.qry__limit = 15;
$journals_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;
@@ -28,33 +28,34 @@ let ae_acct = data[$slct.account_id];
// if (browser) {
// console.log(`Browser: ${browser}`);
// notes_func.handle_db_save_ae_obj_li__note({
// obj_type: 'note',
// obj_li: [ae_acct.slct.note_obj_li],
// journals_func.handle_db_save_ae_obj_li__journal({
// obj_type: 'journal',
// obj_li: [ae_acct.slct.journal_obj_li],
// });
// }
$notes_slct.note_id = ae_acct.slct.note_id;
// $notes_slct.note_obj = ae_acct.slct.note_obj;
$notes_slct.note_obj_li = ae_acct.slct.note_obj_li;
$journals_slct.journal_id = ae_acct.slct.journal_id;
// $journals_slct.journal_obj = ae_acct.slct.journal_obj;
$journals_slct.journal_obj_li = ae_acct.slct.journal_obj_li;
let ae_promises: key_val = {};
if (browser) {
console.log('AE Notes: +layout.svelte');
console.log($notes_slct.note_obj_li);
console.log('AE Journals: +layout.svelte');
console.log($journals_slct.journal_obj_li);
};
</script>
<svelte:head>
<title>Notes - {$notes_loc.title ?? 'Æ loading...'}</title>
<title>Journals - {$journals_loc.title ?? 'Æ loading...'}</title>
</svelte:head>
<div class="ae_notes container m-auto outline-red-500">
<!-- These are needed: h-full overflow-auto -->
<div class="ae_journals h-full w-full overflow-auto p-1">
<nav class="submenu flex flex-row items-centr justify-center gap-1">
<a href="/" class="btn btn-sm variant-ghost-success hover:variant-filled-success">Home</a>
@@ -70,7 +71,7 @@ if (browser) {
// Clear Indexed DB as well
indexedDB.deleteDatabase('ae_core_db');
indexedDB.deleteDatabase('ae_notes_db');
indexedDB.deleteDatabase('ae_journals_db');
// This does not seem to work fast enough or something?
goto('/', {invalidateAll: true});
@@ -136,18 +137,18 @@ if (browser) {
<section class="status flex flex-col justify-center items-center gap-1">
{#if $ae_loc.administrator_access}
<h3 class="h4">Administrator Access - Technical Support</h3>
<p>You are accessing the notes module with "administrator" level permissions.</p>
<p>You are accessing the journals module with "administrator" level permissions.</p>
{:else if $ae_loc.trusted_access}
<h3 class="h4">Trusted Access - Staff</h3>
<p>You are accessing the notes module with "trusted" level permissions.</p>
<p>You are accessing the journals module with "trusted" level permissions.</p>
{:else if !$ae_loc.trusted_access}
<h3 class="h4">Restricted Access</h3>
<p>You are accessing to the notes module is limited</p>
<p>You are accessing to the journals module is limited</p>
{/if}
</section>
<section class="main_content outline">
<section class="main_content container">
{@render children()}
</section>

View File

@@ -1,20 +1,20 @@
/** @type {import('./$types').LayoutLoad} */
console.log(`ae_notes +layout.ts start`);
console.log(`ae_journals +layout.ts start`);
// Imports
import { browser } from '$app/environment';
import { notes_func } from '$lib/ae_notes/ae_notes_functions';
// import { journals_func } from '$lib/ae_journals/ae_journals_functions';
export async function load({ params, parent }) {
let log_lvl: number = 0;
let parent_data = await parent();
// console.log(`ae_notes +layout.ts parent_data:`, parent_data);
// console.log(`ae_journals +layout.ts parent_data:`, parent_data);
let account_id = parent_data.account_id;
if (!account_id) {
console.log(`notes +layout.ts: The account_id was not found in the parent_data!!!`);
console.log(`journals +layout.ts: The account_id was not found in the parent_data!!!`);
return false;
}
@@ -25,7 +25,7 @@ export async function load({ params, parent }) {
// let note_id = ae_acct.slct.note_id; // From root +layout.ts
// if (!note_id) {
// console.log(`ERROR: notes +layout.ts: The note_id was not found in the parent_data!!!`);
// console.log(`ERROR: journals +layout.ts: The note_id was not found in the parent_data!!!`);
// // return false;
// }
@@ -33,7 +33,7 @@ export async function load({ params, parent }) {
// if (browser) {
// if (note_id) {
// let load_note_obj_li = notes_func.load_ae_obj_li__note({
// let load_note_obj_li = journals_func.load_ae_obj_li__note({
// api_cfg: ae_acct.api,
// for_obj_type: 'account',
// for_obj_id: account_id,
@@ -49,7 +49,7 @@ export async function load({ params, parent }) {
// }
// }
// let load_note_obj = notes_func.load_ae_obj_id__note({
// let load_note_obj = journals_func.load_ae_obj_id__note({
// api_cfg: ae_acct.api,
// note_id: note_id,
// try_cache: false
@@ -59,16 +59,16 @@ export async function load({ params, parent }) {
// if (browser) {
// console.log(`Browser: ${browser}`);
// notes_func.db_save_ae_obj_li__note({
// journals_func.db_save_ae_obj_li__note({
// obj_type: 'note',
// obj_li: [load_note_obj_li],
// });
// }
// let submenu = {
// main: {name: 'Main', href: '/notes', access: false},
// // manage: {name: 'Manage', href: '/notes/manage', access: 'administrator', disable: true, hide: true},
// locations: {name: 'Locations', href: `/notes/${note_id}/locations`, access: false, disable: false, hide: false},
// main: {name: 'Main', href: '/journals', access: false},
// // manage: {name: 'Manage', href: '/journals/manage', access: 'administrator', disable: true, hide: true},
// locations: {name: 'Locations', href: `/journals/${note_id}/locations`, access: false, disable: false, hide: false},
// };
// parent_data.submenu = submenu

View File

@@ -0,0 +1,145 @@
<script lang="ts">
// console.log(`ae_journals +page data:`, data);
// console.log(`ae_journals Data Params:`, data.url.searchParams.get('journal_id'));
import { onMount } from 'svelte';
// import { api } from '$lib/api';
import { liveQuery } from "dexie";
import { db_journals } from "$lib/ae_journals/db_journals";
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
// import { journals_loc, journals_slct, journals_trig } from '$lib/ae_journals/ae_journals_stores';
import { ae_util } from '$lib/ae_utils/ae_utils';
interface Props {
data: any;
}
let { data }: Props = $props();
import Journal_obj_li from './ae_comp__journal_obj_li.svelte';
// import Element_data_store from '$lib/element_data_store_v2.svelte';
let ae_acct = data[$slct.account_id];
// $journals_slct.journal_obj = ae_acct.slct.journal_obj;
// $journals_slct.journal_obj_li = ae_acct.slct.journal_obj_li;
let lq__journal_obj_li = $derived(liveQuery(async () => {
let results = await db_journals.journal
.orderBy('updated_on')
.reverse()
.toArray()
// .sortBy('start_datetime')
// () => db_journals.journals
// .where('conference')
// // .aboveOrEqual(0)
// .equals('true')
// // .above(0)
// .sortBy('name') // Use sortBy() instead of orderBy(). toArray() is also not needed???
// // .sortBy('[priority+name]')
// // .orderBy('name')
// // .offset(10).limit(5)
// // .toArray()
return results;
}));
// console.log(`lq__journal_obj_li:`, $lq__journal_obj_li);
let lq__journal_obj = $derived(liveQuery(async () => {
let results = await db_journals.journal
.where('id')
.equals(ae_acct.slct.journal_id)
.toArray()
// .first()
// .get($journals_slct.journal_id)
return results;
}));
onMount(() => {
console.log('Journals: +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);
console.log(`lq__journal_obj = `, $lq__journal_obj);
// $journals_slct.journal_obj = db_journals.journals.get($journals_slct.journal_id);
// console.log(`$journals_slct.journal_obj = `, $journals_slct.journal_obj?.name);
});
</script>
<section class="ae_journals md:container h-full mx-auto space-y-2">
<h1 class="h1 text-center">Journals for {$ae_loc.account_name ?? 'Æ loading...'}</h1>
<!-- <Element_data_store
ds_code="journals___overview"
ds_type="html"
for_type="journal"
for_id={$journals_slct.journal_id}
display="block"
class_li="p-2"
/> -->
<!-- <Element_data_store
ds_code="journals___example"
ds_type="html"
for_type="journal"
for_id={$journals_slct.journal_id}
ds_name="Default: Journals - Journals Example"
store="local"
display="block"
class_li="variant-ghost-surface p-2"
try_cache={true}
show_edit={false}
/> -->
{#await ae_acct.slct.journal_obj_li}
<div class="flex flex-row items-center justify-center">
<span class="fas fa-spinner fa-spin mx-1"></span>
<span>Loading data...</span>
</div>
{:then}
<!-- <span class="flex flex-row items-center justify-center">
<span class="fas fa-check text-green-500 mx-1"></span>
<span>Loaded</span>
</span> -->
{#if $lq__journal_obj_li && $lq__journal_obj_li?.length}
<Journal_obj_li
lq__journal_obj_li={lq__journal_obj_li}
/>
{:else}
<p>No journals available to show.</p>
{/if}
{:catch error}
<div class="text-red-800">
<span class="fas fa-exclamation-triangle text-xl"></span>
<span>Error: {error.message}</span>
</div>
{/await}
</section>
<style lang="postcss">
</style>

View File

@@ -1,8 +1,8 @@
/** @type {import('./$types').PageLoad} */
import { error } from '@sveltejs/kit';
// import { error } from '@sveltejs/kit';
import { browser } from '$app/environment';
import { notes_func } from '$lib/ae_notes/ae_notes_functions';
import { journals_func } from '$lib/ae_journals/ae_journals_functions';
export async function load({ parent }) {
let log_lvl: number = 0;
@@ -13,49 +13,46 @@ export async function load({ parent }) {
let ae_acct = parent_data[account_id];
let note_id = ae_acct.slct.note_id; // From root +layout.ts
if (!note_id) {
console.log(`ERROR: notes +layout.ts: The note_id was not found in the parent_data!!!`);
let journal_id = ae_acct.slct.journal_id; // From root +layout.ts
if (!journal_id) {
if (log_lvl) {
console.log(`INFO: journals +layout.ts: The journal_id was not found in the parent_data.`);
}
// return false;
}
if (browser) {
if (note_id) {
if (journal_id) {
// let ae_params = {};
let load_note_obj_li = notes_func.load_ae_obj_id__note({
let load_journal_obj_li = journals_func.load_ae_obj_id__journal({
api_cfg: ae_acct.api,
note_id: note_id,
journal_id: journal_id,
// params: ae_params,
try_cache: true,
log_lvl: log_lvl
});
ae_acct.slct.note_obj_li = load_note_obj_li;
ae_acct.slct.journal_obj_li = load_journal_obj_li;
}
// Should we limit these to note.conference = true?
let load_note_obj_li = await notes_func.load_ae_obj_li__note({
let load_journal_obj_li = await journals_func.load_ae_obj_li__journal({
api_cfg: ae_acct.api,
for_obj_type: 'account',
for_obj_id: account_id,
inc_entry_li: true,
hidden: 'not_hidden',
enabled: 'enabled',
order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
// order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
limit: 25,
// params: ae_params,
try_cache: false,
try_cache: true,
log_lvl: log_lvl
});
ae_acct.slct.note_obj_li = load_note_obj_li;
ae_acct.slct.journal_obj_li = load_journal_obj_li;
}
parent_data[account_id] = ae_acct;
return parent_data;
// return {
// ae_notes_page_ts: true,
// };
}

View File

@@ -0,0 +1,330 @@
<script lang="ts">
/** @type {import('./$types').PageData} */
let log_lvl: number = 1;
// *** Import Svelte specific
import { browser } from '$app/environment';
// *** Import other supporting libraries
import { Modal } from 'flowbite-svelte';
import { liveQuery } from "dexie";
// *** Import Aether specific variables and functions
// import type { key_val } from '$lib/ae_stores';
import { ae_util } from '$lib/ae_utils/ae_utils';
// import { core_func } from '$lib/ae_core/ae_core_functions';
import { db_journals } from "$lib/ae_journals/db_journals";
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
import { journals_loc, journals_sess, journals_slct, journals_prom, journals_trig } from '$lib/ae_journals/ae_journals_stores';
import { journals_func } from '$lib/ae_journals/ae_journals_functions';
// import Journal_obj_id_edit from './ae_journals_comp__journal_obj_id_edit.svelte';
import Journal_view from './../ae_comp__journal_obj_id_view.svelte';
// import Journal_page_menu from './session_page_menu.svelte';
// import Element_data_store from '$lib/element_data_store_v2.svelte';
import Journal_entry_obj_li from './../ae_comp__journal_entry_obj_li.svelte';
// import Journal_entry_obj_id_edit from './ae_journals_comp__journal_entry_obj_id_edit.svelte';
interface Props {
data: any;
}
let { data }: Props = $props();
// let ae_promises: key_val = {};
// let ae_tmp: key_val = {};
// let ae_triggers: key_val = {};
// Variables
// *** Quickly pull out data from parent(s)
let ae_acct = data[$slct.account_id];
if (log_lvl) {
console.log(`ae_acct = `, ae_acct);
}
// For some reason data.params.journal_id (or whatever param) is not being passed to this page when loaded by a link from another page. This seems to be a bug with Svelte or SvelteKit. Hopefully fixed in a future version 5? 2024-11-06
$journals_slct.journal_id = ae_acct.slct.journal_id;
// $journals_slct.journal_obj = ae_acct.slct.journal_obj;
let lq__journal_obj = $derived(liveQuery(async () => {
if (log_lvl) {
console.log(`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`);
}
let results = await db_journals.journal
.get($journals_slct?.journal_id ?? ''); // null or undefined does not reset things like '' does
return results;
}));
let lq__journal_entry_obj_li = $derived(liveQuery(async () => {
if (log_lvl) {
console.log(`$lq__journal_obj.cfg_json = `, $lq__journal_obj?.cfg_json);
}
if ($lq__journal_obj?.cfg_json?.entry_group_sort === 'DESC') {
let results = await db_journals.journal_entry
// .orderBy('updated_on')
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
.reverse()
// .sortBy('tmp_sort_2');
.sortBy('updated_on');
// .sortBy('title');
return results;
} else {
console.log(`lq__journal_entry_obj_li - default query using journal_id: ${$journals_slct?.journal_id}`);
let results = await db_journals.journal_entry
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
// .reverse()
.sortBy('updated_on');
return results;
}
}));
// let lq__journal_entry_obj = $derived(liveQuery(async () => {
// if (log_lvl) {
// console.log(`lq__journal_entry_obj: journal_entry_id = ${$journals_slct?.journal_entry_id}`);
// }
// if ($journals_slct.journal_entry_id) {
// let results = await db_journals.journal_entry
// .get($journals_slct.journal_entry_id); // null or undefined does not reset things like '' does
// return results;
// }
// // const results = await db_journals.journal_entry
// // .get($journals_slct.journal_entry_id); // null or undefined does not reset things like '' does
// // return results;
// }));
$effect(() => {
if ($journals_trig.journal_entry_li) {
$journals_trig.journal_entry_li = false;
if (log_lvl) {
console.log(`Triggered: $journals_trig.journal_entry_li`);
}
if ($journals_loc.qry__enabled !== 'all' || $journals_loc.qry__hidden !== 'all') {
console.log(`Deleting disabled or hidden journal entry.`);
// let results = db_journals.journal_entry
// .where('enable')
// .notEqual(true)
// .delete();
let results = db_journals.journal_entry
.clear();
console.log(`Deleted ${results} disabled journal entry.`);
}
// if ($journals_loc.qry__hidden !== 'all') {
// console.log(`Deleting hidden journal entry.`);
// let results = db_journals.journal_entry
// .clear();
// console.log(`Deleted ${results} hidden journal entry.`);
// }
// let results = db_journals.journal_entry
// .where('enable')
// .equals('false')
// .delete();
// console.log(`Deleted ${results} disabled journal entry.`);
$journals_prom.load__journal_entry_obj_li = journals_func.load_ae_obj_li__journal_entry({
api_cfg: $ae_api,
for_obj_type: 'journal',
for_obj_id: $journals_slct.journal_id,
enabled: $journals_loc.qry__enabled,
hidden: $journals_loc.qry__hidden,
limit: $journals_loc.qry__limit,
order_by_li: $journals_loc.qry__order_by_li,
try_cache: true,
log_lvl: log_lvl,
});
}
});
if (browser) {
console.log('Browser environment detected.');
let message = {'journal_id': $journals_slct?.journal_id ?? null};
window.parent.postMessage(message, "*");
}
</script>
<svelte:head>
<title>
&AElig; Journals:
{$lq__journal_obj?.name ? ae_util.shorten_string({ string: $lq__journal_obj?.name, max_length: 20, begin_length: 10, end_length: 4 }) : ''}
- {$ae_loc?.title}
</title>
</svelte:head>
<section
class="
ae_journals__bb
container h-full mx-auto
flex flex-col gap-1
py-1 px-2 pb-16
items-center
min-w-full
max-w-max
"
>
<!-- <h1>Journals {$lq__journal_obj?.name} - {$lq__journal_entry_obj_li?.length}</h1> -->
<a href="/journals" class="novi_btn btn btn-secondary btn-sm
variant-ghost-tertiary
hover:variant-filled-tertiary
transition
">
<!-- <span class="fas fa-arrow-left m-1"></span> Back to Journals -->
<span class="fas fa-times m-1"></span> View Other Journals
</a>
<Journal_view
lq__journal_obj={lq__journal_obj}
lq__journal_entry_obj_li={lq__journal_entry_obj_li}
/>
{#if $lq__journal_entry_obj_li && $lq__journal_entry_obj_li?.length }
<Journal_entry_obj_li
lq__journal_entry_obj_li={lq__journal_entry_obj_li}
/>
{:else}
<p>No journal entry available to show.</p>
{/if}
</section>
<!-- Modal: Journal edit ID -->
<Modal
title="{$lq__journal_obj?.name} - {$lq__journal_obj?.id}"
bind:open={$journals_sess.show__modal_edit__journal_id}
autoclose={false}
placement="top-center"
size="xl"
class="top-center bg-white dark:bg-gray-800 text-gray-800 dark:text-gray-200 rounded-lg border-gray-200 dark:border-gray-700 divide-gray-200 dark:divide-gray-700 shadow-md relative flex flex-col mx-auto w-full divide-y"
>
{#snippet header()}
<div class="flex flex-row items-center justify-between w-full">
<h3 class="text-lg font-semibold">
{#if $ae_loc.trusted_access}
<!-- <div class="ae_options"> -->
<button
onclick={() => {
// const url = new URL(location);
// url.searchParams.set('event_id', $lq__journal_obj?.event_id_random);
// history.pushState({}, '', url);
$journals_sess.show__modal_view__journal_id = $journals_slct.journal_id;
$journals_sess.show__modal_edit__journal_id = false;
}}
class="novi_btn btn btn-sm variant-ghost-warning hover:variant-filled-warning transition"
title={`View meeting: ${$lq__journal_obj?.name}`}
>
<span class="fas fa-eye m-1"></span> View
</button>
<!-- </div> -->
{/if}
<span class="text-sm text-gray-500">
Edit Journal:
</span>
{$lq__journal_obj?.name}
</h3>
</div>
{/snippet}
<!-- <Journal_obj_id_edit
lq__journal_obj={lq__journal_obj}
/> -->
<!-- <svelte:fragment slot="footer">
<div class="text-center w-full">
<button
type="button"
on:click={() => {
console.log('Close modal');
$journals_sess.recovery_meetings.show__modal_edit__journal_id = false;
}}
class="btn btn-sm variant-soft-warning hover:variant-ghost-warning"
>
<span class="fas fa-times mx-1"></span>
Close
</button>
</div>
</svelte:fragment> -->
</Modal>
<!-- Modal: Journal Content edit ID -->
<!-- <Modal
bind:open={$journals_sess.show__modal_edit__journal_entry_id}
title="{$lq__journal_entry_obj?.name ?? 'New Journal Content'} - {$lq__journal_entry_obj?.id ?? 'Not Saved Yet'}"
autoclose={false}
placement="top-center"
size="xl"
class="top-center bg-white dark:bg-gray-800 text-gray-800 dark:text-gray-200 rounded-lg border-gray-200 dark:border-gray-700 divide-gray-200 dark:divide-gray-700 shadow-md relative flex flex-col mx-auto w-full divide-y"
>
{#snippet header()}
<div class="flex flex-row items-center justify-between w-full">
<h3 class="text-lg font-semibold">
{#if $ae_loc.trusted_access}
<button
onclick={() => {
// const url = new URL(location);
// url.searchParams.set('event_id', $lq__journal_entry_obj?.event_id_random);
// history.pushState({}, '', url);
$journals_sess.show__modal_view__journal_entry_id = $journals_slct.journal_entry_id;
$journals_sess.show__modal_edit__journal_entry_id = false;
}}
class="novi_btn btn btn-sm variant-ghost-warning hover:variant-filled-warning transition"
title={`View meeting: ${$lq__journal_entry_obj?.name}`}
>
<span class="fas fa-eye m-1"></span> View
</button>
{/if}
<span class="text-sm text-gray-500">
Edit Journal Content:
</span>
{$lq__journal_entry_obj?.name ?? 'New Journal Content'}
</h3>
</div>
{/snippet}
</Modal> -->
<!-- Modal: Journal Content ID media player -->
<!-- {#if $journals_slct.journal_entry_id && $journals_sess.show__modal_view__journal_entry_id}
<Modal_media_player
lq__journal_entry_obj={lq__journal_entry_obj}
/>
{/if} -->

View File

@@ -0,0 +1,84 @@
/** @type {import('./$types').PageLoad} */
import { error } from '@sveltejs/kit';
console.log(`ae_p_journals [journal_id] +page.ts start`);
import { browser } from '$app/environment';
import { journals_func } from '$lib/ae_journals/ae_journals_functions';
export async function load({ params, parent }) { // route
let log_lvl: number = 1;
let data = await parent();
data.log_lvl = log_lvl;
let account_id = data.account_id;
let ae_acct = data[account_id];
let journal_id = params.journal_id;
if (!journal_id) {
console.log(`ae_journals journals [journal_id] +page.ts: The journal_id was not found in the params!!!`);
error(404, {
message: 'Journals - Journal ID not found'
});
}
ae_acct.slct.journal_id = journal_id;
console.log(`ae_journals journals [journal_id] +page.ts: journal_id = `, ae_acct.slct.journal_id);
if (browser) {
if (log_lvl) {
console.log(`ae_journals journals [journal_id] +page.ts: journal_id = `, journal_id);
}
// Load event journal object
let load_journal_obj = journals_func.load_ae_obj_id__journal({
api_cfg: ae_acct.api,
journal_id: journal_id,
inc_entry_li: true,
try_cache: true,
log_lvl: log_lvl
});
ae_acct.slct.journal_obj = load_journal_obj;
// Load journal entries for the journal
// let load_journal_entry_obj_li = journals_func.load_ae_obj_li__journal_entry({
// api_cfg: ae_acct.api,
// for_obj_type: 'journal',
// for_obj_id: journal_id,
// params: {qry__enabled: 'all', qry__limit: 99},
// try_cache: true
// })
// .then((journal_entry_obj_li) => {
// if (log_lvl) {
// console.log(`journal_entry_obj_li = `, journal_entry_obj_li);
// }
// for (let index = 0; index < journal_entry_obj_li.length; index++) {
// let journal_entry_obj = journal_entry_obj_li[index];
// let journal_entry_id = journal_entry_obj.journal_entry_id_random;
// let load_journal_entry_obj_li = journals_func.load_ae_obj_li__journal_entry({
// api_cfg: ae_acct.api,
// for_obj_type: 'journal_entry',
// for_obj_id: journal_entry_id,
// params: {qry__enabled: 'all', qry__limit: 15},
// try_cache: true
// });
// if (log_lvl) {
// console.log(`load_journal_entry_obj_li = `, load_journal_entry_obj_li);
// }
// journal_entry_obj_li[index].journal_entry_li = load_journal_entry_obj_li;
// }
// return journal_entry_obj_li;
// });
// if (log_lvl) {
// console.log(`load_journal_entry_obj_li = `, load_journal_entry_obj_li);
// }
// ae_acct.slct.journal_entry_obj_li = load_journal_entry_obj_li;
}
// WARNING: Precaution against shared data between sites and presentations.
data[account_id] = ae_acct;
return data;
}

View File

@@ -0,0 +1,157 @@
<script lang="ts">
// *** Import Svelte specific
import { goto, invalidate, pushState, replaceState } from '$app/navigation';
// *** Import Aether specific variables and functions
import type { key_val } from '$lib/ae_stores';
import { ae_util } from '$lib/ae_utils/ae_utils';
import { api } from '$lib/api';
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
import { journals_loc, journals_sess, journals_slct } from '$lib/ae_journals/ae_journals_stores';
interface Props {
lq__journal_entry_obj_li: any;
}
let { lq__journal_entry_obj_li }: Props = $props();
let ae_promises: key_val = $state({});
// let ae_tmp: key_val = {};
// let ae_triggers: key_val = {};
</script>
<section class="journal_list flex flex-col gap-2 items-center justify-center w-full">
{#if $lq__journal_entry_obj_li && $lq__journal_entry_obj_li.length}
<!-- <div class="ae_group">
<span class="ae_label">Group:</span>
<span class="ae_value">{current_group}</span> -->
{#each $lq__journal_entry_obj_li as journals_journal_entry_obj, index}
<div
class="container journal journal_entry_obj border border-1 p-2 mb-2 space-y-2 w-full max-w-screen-lg flex flex-col items-center justify-center bg-white rounded-lg"
class:dim={journals_journal_entry_obj.hide}
class:bg-warning-100={!journals_journal_entry_obj?.enable}
>
<header class="ae_header flex flex-row gap-2 items-center">
<h3 class="journal__name h4">
<span class="journal__name">{@html journals_journal_entry_obj.name}</span>
</h3>
</header>
{#if journals_journal_entry_obj.content}<pre class="journal__content p-2 bg-white shadow-md rounded-lg text-wrap text-sm font-normal whitespace-pre-wrap">{@html journals_journal_entry_obj.content}</pre>{/if}
<div class="ae_options flex flex-row flex-wrap gap-2 items-center justify-center">
<a
href="/journals/{journals_journal_entry_obj?.journal_id}/entry/{journals_journal_entry_obj?.journal_entry_id}"
class="btn btn-secondary btn-md variant-ghost-primary hover:variant-filled-primary transition"
title={`View: ${journals_journal_entry_obj?.name}`}
>
<span class="fas fa-eye m-1"></span> View
</a>
{#if $ae_loc.trusted_access && $ae_loc.edit_mode}
<button
type="button"
disabled={!$ae_loc.trusted_access}
onclick={() => {
$journals_slct.journal_entry_id = journals_journal_entry_obj.journal_entry_id;
$journals_slct.journal_entry_obj = journals_journal_entry_obj;
$journals_sess.show__modal_view__journal_entry_id = false;
$journals_sess.show__modal_edit__journal_entry_id = $journals_slct.journal_entry_id;
}}
class="novi_btn btn btn-sm variant-glass-warning hover:variant-filled-warning transition"
title={`Edit journal entry: ${journals_journal_entry_obj?.name}`}
>
<span class="fas fa-edit m-1"></span> Edit
</button>
{/if}
</div>
<section class="ae_section journal_entry__entry">
{#if journals_journal_entry_obj?.description}
<div
class="journal_entry__description ae_description"
>
<div class="ae_label journal_entry__description text-sm">Description:</div>
<div class="ae_value journal_entry__description">
{@html journals_journal_entry_obj?.description}
</div>
</div>
{/if}
{#if journals_journal_entry_obj?.entry_html}
<div
class="journal_entry__entry_html ae_entry_html"
>
<div class="ae_label journal_entry__entry_html text-sm">Content:</div>
<div class="ae_value journal_entry__entry_html">
{@html journals_journal_entry_obj?.entry_html}
</div>
</div>
{/if}
<div
class="ae_group"
class:hidden={!journals_journal_entry_obj?.original_datetime && !journals_journal_entry_obj?.original_timezone}
>
<span class="ae_label text-sm">Original date/time:</span>
{#if journals_journal_entry_obj.original_datetime}
<span class="ae_value ae_prop prop_original_datetime font-semibold">{ae_util.iso_datetime_formatter(journals_journal_entry_obj.original_datetime, 'datetime_12_long')}</span>
{/if}
{#if journals_journal_entry_obj.original_timezone}
<span class="ae_label text-sm">Timezone:</span>
<span class="ae_value font-semibold">{journals_journal_entry_obj.original_timezone}</span>
{/if}
</div>
</section>
<section
class="ae_meta mt-2 flex flex-col sm:flex-row gap-1 items-center justify-center text-sm text-gray-500"
class:hidden={!$ae_loc.administrator_access}
>
<span
class="journal_entry__journal_entry_type"
class:hidden={!journals_journal_entry_obj.journal_entry_type}
>
Type: {journals_journal_entry_obj.journal_entry_type}
</span>
<span class="ae_group">
<span
class="journal_entry__created_on"
>
Created on: {ae_util.iso_datetime_formatter(journals_journal_entry_obj.created_on, 'datetime_12_long')}
</span>
<span
class="journal_entry__updated_on"
class:hidden={!journals_journal_entry_obj.updated_on}
>
Updated on: {ae_util.iso_datetime_formatter(journals_journal_entry_obj.updated_on, 'datetime_12_long')}
</span>
</span>
</section>
</div>
{/each}
<!-- </div> -->
{:else}
<p>No journal entry available to show.</p>
{/if}
</section>
<!-- {/if} -->

View File

@@ -0,0 +1,46 @@
<script lang="ts">
// *** Import Svelte specific
// *** Import Aether specific variables and functions
import { ae_util } from '$lib/ae_utils/ae_utils';
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
import { journals_loc, journals_sess, journals_slct, journals_trig, journals_prom } from '$lib/ae_journals/ae_journals_stores';
// import { journals_func } from '$lib/ae_journals/ae_journals_functions';
interface Props {
log_lvl?: number;
lq__journal_obj: any;
lq__journal_entry_obj_li: any;
}
let { log_lvl = 0, lq__journal_obj, lq__journal_entry_obj_li }: Props = $props();
// let ae_promises: key_val = {};
// let ae_tmp: key_val = {};
// let ae_trigger: any = null;
// let ae_triggers: key_val = {};
// Reminder: Styling is being done with Tailwind CSS, not Bootstrap.
</script>
<section class="svelte_component ae_section ae_view journal_obj view__journal_obj bg-white rounded-lg p-2 m-2" bind:clientHeight={$ae_loc.iframe_height_modal_body}>
<header class="ae_header journal__header">
<h2 class="journal__name h3">
{@html $lq__journal_obj?.name ?? 'Loading...'}
{#if $ae_loc.trusted_access && $ae_loc.edit_mode}
({$lq__journal_entry_obj_li?.length ?? '0'}&times;)
{/if}
{#await $journals_prom.load__journal_entry_obj_li}
<span class="fas fa-spinner fa-spin"></span>
{:then}
<!-- done -->
{/await}
</h2>
</header>
</section>

View File

@@ -0,0 +1,114 @@
<script lang="ts">
// let log_lvl: number = 0;
// *** Import Svelte specific
import { goto } from '$app/navigation';
// *** Import other supporting libraries
// import { Spinner } from 'flowbite-svelte';
// *** Import Aether specific variables and functions
import { ae_util } from '$lib/ae_utils/ae_utils';
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
import { journals_loc, journals_sess, journals_slct } from '$lib/ae_journals/ae_journals_stores';
interface Props {
lq__journal_obj_li: any;
}
let { lq__journal_obj_li }: Props = $props();
</script>
<section class="journal_list flex flex-col gap-2 items-center justify-center w-full">
{#if $lq__journal_obj_li && $lq__journal_obj_li.length}
{#each $lq__journal_obj_li as journals_journal_obj, index}
<div
class="container journal journal_obj border border-1 rounded p-2 mb-2 space-y-2 w-full max-w-screen-lg flex flex-col items-center justify-center"
class:hidden={(journals_journal_obj?.hide || !journals_journal_obj?.enable) && !$ae_loc.trusted_access}
class:dim={journals_journal_obj.hide}
class:bg-warning-100={!journals_journal_obj?.enable}
class:text-warning-900={!journals_journal_obj?.enable}
>
<header class="ae_header flex flex-row gap-2 items-center justify-between w-full">
<h3 class="journal__name h3">
<span class="journal__name">{@html journals_journal_obj.name}</span>
</h3>
<!-- Show a label if the type code is set -->
{#if journals_journal_obj.type_code}
<span class="bg-yellow-50 text-yellow-800 text-xs font-semibold mr-2 px-2.5 py-0.5 rounded dark:bg-yellow-900 dark:text-yellow-300">
<!-- <span class="ae_label">Type:</span> -->
<span class="ae_value">{journals_journal_obj.type_code}</span>
</span>
{/if}
</header>
{#if journals_journal_obj.description}<pre class="journal__description p-2 bg-white shadow-md rounded-lg text-sm font-normal text-wrap whitespace-pre-wrap word-break max-w-screen-md novi_text_wrap">{@html journals_journal_obj.description}</pre>{/if}
<div class="ae_options flex flex-row gap-2 items-center justify-center">
<a href="/journals/{journals_journal_obj?.journal_id}" class="btn btn-secondary btn-md variant-ghost-primary hover:variant-filled-primary hover:underline transition" title={`View: ${journals_journal_obj?.name}`}>
<span class="fas fa-envelope-open m-1"></span> Open
{#if journals_journal_obj?.journal_entry_count}
<span class="ae_badge ae_info journal__journal_entry_count">
<span class="fas fa-content"></span> {(journals_journal_obj?.journal_entry_count == 1 ? `${journals_journal_obj?.journal_entry_count} entry` : `${journals_journal_obj?.journal_entry_count} entries` )}
</span>
{/if}
</a>
{#if $ae_loc.administrator_access && $ae_loc.edit_mode}
<button
disabled={!$ae_loc.administrator_access}
onclick={() => {
$journals_slct.journal_id = journals_journal_obj.journal_id;
$journals_slct.journal_obj = journals_journal_obj;
$journals_sess.journals.show__modal_view__journal_id = false;
$journals_sess.journals.show__modal_edit__journal_id = $journals_slct.journal_id;
goto(`/journals/${journals_journal_obj?.journal_id}`);
}}
class="btn btn-sm variant-ghost-warning hover:variant-filled-warning transition"
title={`Edit journal: ${journals_journal_obj.name}`}
>
<span class="fas fa-edit m-1"></span> Edit Journal
</button>
{/if}
</div>
<section
class="ae_section ae_footer ae_meta journal__meta mt-2 flex flex-col sm:flex-row gap-1 items-center justify-center text-sm text-gray-500"
class:hidden={!$ae_loc.administrator_access && !$ae_loc.edit_mode}
>
<div class="ae_group">
{#if !journals_journal_obj.updated_on}
<span
class="journal__created_on"
>
<span class="ae_label">Created on:</span>
<span class="ae_value">{ae_util.iso_datetime_formatter(journals_journal_obj.created_on, 'datetime_12_long')}</span>
</span>
{:else}
<span
class="journal__updated_on"
>
<span class="ae_label">Updated on:</span>
<span class="ae_value">{ae_util.iso_datetime_formatter(journals_journal_obj.updated_on, 'datetime_12_long')}</span>
</span>
{/if}
</div>
</section>
</div>
{/each}
{:else}
No journals found at this time
{/if}
</section>
<!-- {/if} -->

View File

@@ -3,7 +3,7 @@
let { children } = $props();
import { ae_loc, ae_sess, ae_api, slct } from '$lib/ae_stores';
import { notes_loc, notes_slct, notes_trigger } from '$lib/ae_notes/ae_notes_stores';
import { notes_loc, notes_slct, notes_trigger } from '$lib/ae_journals/ae_journals_stores';
</script>

View File

@@ -1,187 +0,0 @@
<script lang="ts">
// console.log(`ae_notes +page data:`, data);
// console.log(`ae_notes Data Params:`, data.url.searchParams.get('note_id'));
import { onMount } from 'svelte';
// import { api } from '$lib/api';
import { liveQuery } from "dexie";
import { db_notes } from "$lib/ae_notes/db_notes";
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
// import { notes_loc, notes_slct, notes_trigger } from '$lib/ae_notes/ae_notes_stores';
import { ae_util } from '$lib/ae_utils/ae_utils';
interface Props {
data: any;
}
let { data }: Props = $props();
// import Element_data_store from '$lib/element_data_store_v2.svelte';
let ae_acct = data[$slct.account_id];
// $notes_slct.note_obj = ae_acct.slct.note_obj;
// $notes_slct.note_obj_li = ae_acct.slct.note_obj_li;
let lq__note_obj_li = $derived(liveQuery(async () => {
let results = await db_notes.note
.orderBy('start_datetime')
.reverse()
.toArray()
// .sortBy('start_datetime')
// () => db_notes.notes
// .where('conference')
// // .aboveOrEqual(0)
// .equals('true')
// // .above(0)
// .sortBy('name') // Use sortBy() instead of orderBy(). toArray() is also not needed???
// // .sortBy('[priority+name]')
// // .orderBy('name')
// // .offset(10).limit(5)
// // .toArray()
return results;
}));
// console.log(`lq__note_obj_li:`, $lq__note_obj_li);
let lq__note_obj = $derived(liveQuery(async () => {
let results = await db_notes.notes
.where('id')
.equals(ae_acct.slct.note_id)
.toArray()
// .first()
// .get($notes_slct.note_id)
return results;
}));
onMount(() => {
console.log('Events - Presentation Management: +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);
console.log(`lq__note_obj = `, $lq__note_obj);
// $notes_slct.note_obj = db_notes.notes.get($notes_slct.note_id);
// console.log(`$notes_slct.note_obj = `, $notes_slct.note_obj?.name);
});
</script>
<section class="ae_notes md:container h-full mx-auto">
<h2 class="h3">Notes for {$ae_loc.account_name ?? 'Æ loading...'}</h2>
<!-- {$notes_slct.note_obj.name ?? '--'} -->
<!-- ({$notes_slct.note_id}) -->
<!-- <Element_data_store
ds_code="notes___overview"
ds_type="html"
for_type="note"
for_id={$notes_slct.note_id}
display="block"
class_li="p-2"
/> -->
<!-- <Element_data_store
ds_code="notes___example"
ds_type="html"
for_type="note"
for_id={$notes_slct.note_id}
ds_name="Default: Events - Notes Example"
store="local"
display="block"
class_li="variant-ghost-surface p-2"
try_cache={true}
show_edit={false}
/> -->
{#await ae_acct.slct.note_obj_li}
<div class="flex flex-row items-center justify-center">
<span class="fas fa-spinner fa-spin mx-1"></span>
<span>Loading...</span>
</div>
{:then}
<div class="flex flex-row items-center justify-center">
<span class="fas fa-check text-green-500 mx-1"></span>
<span>Loaded</span>
</div>
{#if ae_acct.slct.note_obj_li && $lq__note_obj_li}
<ul
class="space-y-2"
>
{#each $lq__note_obj_li as note_obj}
<li>
<!-- We do not want to show notes more than 8 months old. -->
{#if (
new Date(note_obj.start_datetime).getTime())
>
(new Date().getTime() - (1000 * 60 * 60 * 24 * 30 * 8))
|| $ae_loc.trusted_access}
<!-- {#if $notes_slct.note_id === note_obj.note_id_random} -->
<a
href="/notes/note/{note_obj.note_id_random}"
class="btn btn-md variant-ghost-primary hover:variant-filled-primary hover:underline"
onpointerover={() => {
// When the cursor is hovering we want to set the note_id and note_obj
// $notes_slct.note_id = note_obj.note_id_random;
// $notes_slct.note_obj = note_obj;
}}
>
{ae_util.iso_datetime_formatter(note_obj.start_datetime, 'date_long')}
-
{note_obj.name}
</a>
{:else}
<button
disabled
class="btn btn-md variant-ghost-surface"
>
{ae_util.iso_datetime_formatter(note_obj.start_datetime, 'date_long')}
-
{note_obj.name}
</button>
{/if}
{#if $ae_loc.trusted_access}
<a
data-sveltekit-reload
href="/note/{note_obj.note_id_random}"
class="btn btn-sm variant-ghost-warning hover:variant-filled-warning hover:underline"
>
Manage
</a>
{/if}
</li>
{/each}
</ul>
{/if}
{:catch error}
<div class="text-red-800">
<span class="fas fa-exclamation-triangle text-xl"></span>
<span>Error: {error.message}</span>
</div>
{/await}
</section>
<style lang="postcss">
</style>