Work on the new Journals module. Journal entries are now partially viewable.

This commit is contained in:
Scott Idem
2025-03-20 11:59:48 -04:00
parent 7fde0abb16
commit 596986afb7
8 changed files with 454 additions and 9 deletions

View File

@@ -45,7 +45,8 @@ export async function load_ae_obj_id__journal(
// This is expecting a list
db_save_ae_obj_li__journal({
obj_type: 'journal',
obj_li: [journal_obj_get_result]
obj_li: [journal_obj_get_result],
log_lvl: log_lvl
});
}
return journal_obj_get_result;
@@ -152,7 +153,8 @@ export async function load_ae_obj_li__journal(
if (try_cache) {
db_save_ae_obj_li__journal({
obj_type: 'journal',
obj_li: journal_obj_li_get_result
obj_li: journal_obj_li_get_result,
log_lvl: log_lvl
});
}
return journal_obj_li_get_result;

View File

@@ -39,10 +39,10 @@ export async function load_ae_obj_id__journal_entry(
if (journal_entry_obj_get_result) {
if (try_cache) {
// This is expecting a list
await db_save_ae_obj_li__journal_entry({
db_save_ae_obj_li__journal_entry({
obj_type: 'journal_entry',
obj_li: [journal_entry_obj_get_result]
obj_li: [journal_entry_obj_get_result],
log_lvl: log_lvl
});
}
return journal_entry_obj_get_result;
@@ -121,7 +121,9 @@ export async function load_ae_obj_li__journal_entry(
if (journal_entry_obj_li_get_result) {
if (try_cache) {
await db_save_ae_obj_li__journal_entry({
obj_type: 'journal_entry', obj_li: journal_entry_obj_li_get_result
obj_type: 'journal_entry',
obj_li: journal_entry_obj_li_get_result,
log_lvl: log_lvl
});
}
return journal_entry_obj_li_get_result;
@@ -346,6 +348,15 @@ export async function db_save_ae_obj_li__journal_entry(
person_id: obj.person_id_random,
activity: obj.activity,
category: obj.category,
topic: obj.topic,
public: obj.public,
private: obj.private,
personal: obj.personal,
professional: obj.professional,
name: obj.name,
summary: obj.summary,
outline: obj.outline,

View File

@@ -155,6 +155,15 @@ export interface Journal_Entry {
// event_id?: null|string; // Assign to an event???
// location_id?: null|string; // Assign to a location???
activity?: null|string;
category?: null|string;
topic?: null|string;
public?: null|boolean;
private?: null|boolean;
personal?: null|boolean;
professional?: null|boolean;
name: string; // or the title
summary?: null|string; // LLM (AI) generated summary...???
outline?: null|string; // LLM (AI) generated outline...???

View File

@@ -54,6 +54,7 @@ let lq__journal_obj = $derived(liveQuery(async () => {
}
let results = await db_journals.journal
.get($journals_slct?.journal_id ?? ''); // null or undefined does not reset things like '' does
console.log(`lq__journal_obj: results = `, results);
return results;
}));
@@ -170,7 +171,7 @@ if (browser) {
<section
class="
ae_journals__bb
ae_journals__journal
container h-full mx-auto
flex flex-col gap-1
py-1 px-2 pb-16
@@ -188,7 +189,8 @@ if (browser) {
transition
">
<!-- <span class="fas fa-arrow-left m-1"></span> Back to Journals -->
<span class="fas fa-times m-1"></span> View Other Journals
<span class="fas fa-arrow-left m-1"></span>
View Other Journals
</a>

View File

@@ -77,7 +77,7 @@ export async function load({ params, parent }) { // route
}
// WARNING: Precaution against shared data between sites and presentations.
// WARNING: Precaution against shared data between sites.
data[account_id] = ae_acct;
return data;

View File

@@ -0,0 +1,320 @@
<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_entry_obj_id_edit from './ae_journals_comp__journal_entry_obj_id_edit.svelte';
import Journal_entry_view from './../../../ae_comp__journal_entry_obj_id_view.svelte';
// import Journal_page_menu from './session_page_menu.svelte';
// import Element_data_store from '$lib/element_data_store_v2.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_entry_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_entry_id = ae_acct.slct.journal_entry_id;
// $journals_slct.journal_entry_obj = ae_acct.slct.journal_entry_obj;
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}`);
}
let results = await db_journals.journal_entry
.get($journals_slct.journal_entry_id ?? ''); // null or undefined does not reset things like '' does
console.log(`lq__journal_entry_obj: results = `, results);
return results;
}));
// let lq__journal_entry_obj_li = $derived(liveQuery(async () => {
// if (log_lvl) {
// console.log(`$lq__journal_entry_obj.cfg_json = `, $lq__journal_entry_obj?.cfg_json);
// }
// if ($lq__journal_entry_obj?.cfg_json?.entry_group_sort === 'DESC') {
// let results = await db_journals.journal_entry
// // .orderBy('updated_on')
// .where('journal_entry_id')
// .equals($journals_slct?.journal_entry_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_entry_id: ${$journals_slct?.journal_entry_id}`);
// let results = await db_journals.journal_entry
// .where('journal_entry_id')
// .equals($journals_slct?.journal_entry_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_entry_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_entry_id': $journals_slct?.journal_entry_id ?? null};
// window.parent.postMessage(message, "*");
}
</script>
<!-- <svelte:head>
<title>
&AElig; Journals:
{$lq__journal_entry_obj?.name ? ae_util.shorten_string({ string: $lq__journal_entry_obj?.name, max_length: 20, begin_length: 10, end_length: 4 }) : ''}
- {$ae_loc?.title}
</title>
</svelte:head> -->
<section
class="
ae_journals__journal_entry
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_entry_obj?.name} - {$lq__journal_entry_obj_li?.length}</h1> -->
<a href="/journals/{$lq__journal_entry_obj?.journal_id}" 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-arrow-left m-1"></span>
Back to Journal Entries
</a>
{#if $lq__journal_entry_obj}
<Journal_entry_view
lq__journal_entry_obj={lq__journal_entry_obj}
/>
{/if}
</section>
<!-- Modal: Journal edit ID -->
<Modal
title="{$lq__journal_entry_obj?.name} - {$lq__journal_entry_obj?.id}"
bind:open={$journals_sess.show__modal_edit__journal_entry_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_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>
<!-- </div> -->
{/if}
<span class="text-sm text-gray-500">
Edit Journal:
</span>
{$lq__journal_entry_obj?.name}
</h3>
</div>
{/snippet}
<!-- <Journal_obj_id_edit
lq__journal_entry_obj={lq__journal_entry_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_entry_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,46 @@
/** @type {import('./$types').PageLoad} */
import { error } from '@sveltejs/kit';
console.log(`ae_p_journals [journal_entry_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_entry_id = params.journal_entry_id;
if (!journal_entry_id) {
console.log(`ae_journals journals [journal_entry_id] +page.ts: The journal_entry_id was not found in the params!!!`);
error(404, {
message: 'Journals - Journal Entry ID not found'
});
}
ae_acct.slct.journal_entry_id = journal_entry_id;
console.log(`ae_journals journals [journal_entry_id] +page.ts: journal_entry_id = `, ae_acct.slct.journal_entry_id);
if (browser) {
if (log_lvl) {
console.log(`ae_journals journals [journal_entry_id] +page.ts: journal_entry_id = `, journal_entry_id);
}
// Load event journal entry object
let load_journal_obj = journals_func.load_ae_obj_id__journal_entry({
api_cfg: ae_acct.api,
journal_entry_id: journal_entry_id,
try_cache: true,
log_lvl: 2
});
ae_acct.slct.journal_obj = load_journal_obj;
}
// WARNING: Precaution against shared data between sites.
data[account_id] = ae_acct;
return data;
}

View File

@@ -0,0 +1,55 @@
<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_entry_obj: any;
}
let { log_lvl = 0, lq__journal_entry_obj }: 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_entry_obj view__journal_entry_obj bg-white rounded-lg p-2 m-2" bind:clientHeight={$ae_loc.iframe_height_modal_body}>
<header class="ae_header journal_entry__header">
<h2 class="journal_entry__name h3">
{@html $lq__journal_entry_obj?.name ?? 'Loading...'}
{#await $journals_prom.load__journal_entry_obj_li}
<span class="fas fa-spinner fa-spin"></span>
{:then}
<!-- done -->
{/await}
</h2>
{$lq__journal_entry_obj?.private}
{$lq__journal_entry_obj?.public}
{$lq__journal_entry_obj?.personal}
{$lq__journal_entry_obj?.professional}
</header>
<pre>
{$lq__journal_entry_obj?.content}
</pre>
<div>
{$lq__journal_entry_obj?.keywords}
{#if $ae_loc.trusted_access && $ae_loc.edit_mode}
({$lq__journal_entry_obj?.created_on} {$lq__journal_entry_obj?.updated_on ?? ''})
{/if}
</div>
</section>