Prettier for Journals

This commit is contained in:
Scott Idem
2026-03-24 12:25:22 -04:00
parent e1338b1a72
commit b74c6d0e9c
25 changed files with 3983 additions and 4238 deletions

View File

@@ -1,50 +1,63 @@
<script lang="ts">
import { untrack } from 'svelte';
/**
* ae_comp__modal_journal_config.svelte
* Standardized Module-level settings for Journals.
* Fixed Svelte 5 state placement and reactivity loops.
*/
import { CalendarClock, Check, CodeXml, Database, Layout, MonitorPlay, MousePointerClick, Palette, Settings, ShieldCheck, Wrench, X } from '@lucide/svelte';
import { Modal } from 'flowbite-svelte';
import { untrack } from 'svelte';
/**
* ae_comp__modal_journal_config.svelte
* Standardized Module-level settings for Journals.
* Fixed Svelte 5 state placement and reactivity loops.
*/
import {
CalendarClock,
Check,
CodeXml,
Database,
Layout,
MonitorPlay,
MousePointerClick,
Palette,
Settings,
ShieldCheck,
Wrench,
X
} from '@lucide/svelte';
import { Modal } from 'flowbite-svelte';
// *** Import Aether specific variables and functions
import { ae_loc, ae_api } from '$lib/stores/ae_stores';
import {
journals_loc,
journals_sess
} from '$lib/ae_journals/ae_journals_stores';
import AE_Comp_Editor_CodeMirror from '$lib/elements/element_editor_codemirror.svelte';
// *** Import Aether specific variables and functions
import { ae_loc, ae_api } from '$lib/stores/ae_stores';
import {
journals_loc,
journals_sess
} from '$lib/ae_journals/ae_journals_stores';
import AE_Comp_Editor_CodeMirror from '$lib/elements/element_editor_codemirror.svelte';
interface Props {
log_lvl?: number;
show?: boolean;
interface Props {
log_lvl?: number;
show?: boolean;
}
let { log_lvl = 0, show = $bindable(false) }: Props = $props();
// Internal State
let tab: 'form' | 'local_json' | 'session_json' = $state('form');
let tmp_config: any = $state({
journal: {},
entry: {}
});
$effect(() => {
if (show) {
untrack(() => {
const fresh_config = JSON.parse(JSON.stringify($journals_loc));
// Ensure the structure is preserved
if (!fresh_config.entry) fresh_config.entry = {};
tmp_config = fresh_config;
});
}
});
let { log_lvl = 0, show = $bindable(false) }: Props = $props();
// Internal State
let tab: 'form' | 'local_json' | 'session_json' = $state('form');
let tmp_config: any = $state({
journal: {},
entry: {}
});
$effect(() => {
if (show) {
untrack(() => {
const fresh_config = JSON.parse(JSON.stringify($journals_loc));
// Ensure the structure is preserved
if (!fresh_config.entry) fresh_config.entry = {};
tmp_config = fresh_config;
});
}
});
function handle_save() {
journals_loc.set(tmp_config);
show = false;
}
function handle_save() {
journals_loc.set(tmp_config);
show = false;
}
</script>
<Modal
@@ -53,32 +66,32 @@
dismissable={false}
placement="top-center"
size="xl"
class="relative flex flex-col mx-auto w-full bg-white dark:bg-gray-800 text-gray-800 dark:text-gray-200 border border-orange-300 dark:border-orange-700 rounded-lg shadow-xl"
class="relative mx-auto flex w-full flex-col rounded-lg border border-orange-300 bg-white text-gray-800 shadow-xl dark:border-orange-700 dark:bg-gray-800 dark:text-gray-200"
headerClass="flex flex-row gap-2 items-center justify-between w-full bg-orange-100 dark:bg-orange-900 p-4 rounded-t-lg border-b border-orange-200 dark:border-orange-800"
footerClass="flex flex-row gap-2 items-center justify-center w-full bg-orange-100 dark:bg-orange-900 p-4 rounded-b-lg border-t border-orange-200 dark:border-orange-800"
>
footerClass="flex flex-row gap-2 items-center justify-center w-full bg-orange-100 dark:bg-orange-900 p-4 rounded-b-lg border-t border-orange-200 dark:border-orange-800">
{#snippet header()}
<h3 class="flex-1 flex items-center gap-2 text-lg font-bold">
<h3 class="flex flex-1 items-center gap-2 text-lg font-bold">
<Wrench class="text-primary-500" />
<span>&AElig; Journals Module Config</span>
</h3>
<button type="button" class="btn-icon btn-icon-sm preset-tonal-surface ml-2" onclick={() => (show = false)}>
<button
type="button"
class="btn-icon btn-icon-sm preset-tonal-surface ml-2"
onclick={() => (show = false)}>
<X size="1.1em" />
</button>
{/snippet}
<div class="space-y-6 py-2 h-[60vh] overflow-y-auto px-4">
<div class="h-[60vh] space-y-6 overflow-y-auto px-4 py-2">
<!-- Navigation Tabs -->
<div
class="flex justify-center gap-1 mb-4 p-1 bg-surface-500/10 rounded-lg max-w-fit mx-auto sticky top-0 z-10 backdrop-blur-sm"
>
class="bg-surface-500/10 sticky top-0 z-10 mx-auto mb-4 flex max-w-fit justify-center gap-1 rounded-lg p-1 backdrop-blur-sm">
<button
type="button"
class="btn btn-sm transition-all {tab === 'form'
? 'preset-filled-primary'
: 'preset-tonal-surface'}"
onclick={() => (tab = 'form')}
>
onclick={() => (tab = 'form')}>
<Settings size="1.1em" class="mr-1" /> Config
</button>
<button
@@ -86,8 +99,7 @@
class="btn btn-sm transition-all {tab === 'local_json'
? 'preset-filled-primary'
: 'preset-tonal-surface'}"
onclick={() => (tab = 'local_json')}
>
onclick={() => (tab = 'local_json')}>
<Database size="1.1em" class="mr-1" /> Local JSON
</button>
<button
@@ -95,71 +107,55 @@
class="btn btn-sm transition-all {tab === 'session_json'
? 'preset-filled-primary'
: 'preset-tonal-surface'}"
onclick={() => (tab = 'session_json')}
>
onclick={() => (tab = 'session_json')}>
<CodeXml size="1.1em" class="mr-1" /> Session JSON
</button>
</div>
{#if tab === 'form'}
<div class="space-y-8 animate-in fade-in duration-300">
<div class="animate-in fade-in space-y-8 duration-300">
<!-- Date/Time Section -->
<section class="space-y-4">
<h2
class="text-xl font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
class="border-surface-500/30 flex items-center gap-2 border-b pb-2 text-xl font-bold">
<CalendarClock size="1.2em" class="text-primary-500" />
Date and Time Display
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 p-2">
<div class="grid grid-cols-1 gap-6 p-2 md:grid-cols-2">
<label class="label">
<span class="text-sm font-bold opacity-70"
>DateTime Format</span
>
>DateTime Format</span>
<select
bind:value={tmp_config.datetime_format}
class="select select-sm"
>
class="select select-sm">
<option value="datetime_12_short"
>MMM D, YY hh:mm A</option
>
>MMM D, YY hh:mm A</option>
<option value="datetime_12_long"
>MMMM D, YYYY hh:mm A</option
>
>MMMM D, YYYY hh:mm A</option>
<option value="datetime_short"
>MMM D, YY HH:mm</option
>
>MMM D, YY HH:mm</option>
<option value="datetime_long"
>MMMM D, YYYY HH:mm</option
>
>MMMM D, YYYY HH:mm</option>
<option value="datetime_us"
>US (MM/DD/YYYY hh:mm:ss A)</option
>
>US (MM/DD/YYYY hh:mm:ss A)</option>
<option value="datetime_iso"
>ISO (YYYY-MM-DD HH:mm:ss)</option
>
>ISO (YYYY-MM-DD HH:mm:ss)</option>
</select>
</label>
<label class="label">
<span class="text-sm font-bold opacity-70"
>Time-Only Format</span
>
>Time-Only Format</span>
<select
bind:value={tmp_config.time_format}
class="select select-sm"
>
class="select select-sm">
<option value="time_12_short"
>12-hour short (3:30 PM)</option
>
>12-hour short (3:30 PM)</option>
<option value="time_12_long"
>12-hour long (3:30:45 PM)</option
>
>12-hour long (3:30:45 PM)</option>
<option value="time_short"
>24-hour short (15:30)</option
>
>24-hour short (15:30)</option>
<option value="time_long"
>24-hour long (15:30:45)</option
>
>24-hour long (15:30:45)</option>
</select>
</label>
</div>
@@ -168,23 +164,19 @@
<!-- UI Section -->
<section class="space-y-4">
<h2
class="text-xl font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
class="border-surface-500/30 flex items-center gap-2 border-b pb-2 text-xl font-bold">
<MousePointerClick
size="1.2em"
class="text-primary-500"
/>
class="text-primary-500" />
User Interface Preferences
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 p-2">
<div class="grid grid-cols-1 gap-6 p-2 md:grid-cols-2">
<label
class="flex items-center space-x-3 cursor-pointer p-2 rounded-lg bg-surface-500/5 border border-surface-500/10"
>
class="bg-surface-500/5 border-surface-500/10 flex cursor-pointer items-center space-x-3 rounded-lg border p-2">
<input
type="checkbox"
bind:checked={tmp_config.entry.auto_save}
class="checkbox"
/>
class="checkbox" />
<div class="space-y-0.5">
<span class="font-bold">Enable Auto-Save</span>
<p class="text-xs opacity-60">
@@ -193,16 +185,14 @@
</div>
</label>
<label
class="flex items-center space-x-3 cursor-pointer p-2 rounded-lg bg-surface-500/5 border border-surface-500/10"
>
class="bg-surface-500/5 border-surface-500/10 flex cursor-pointer items-center space-x-3 rounded-lg border p-2">
<input
type="checkbox"
bind:checked={tmp_config.show_id_random}
class="checkbox"
/>
class="checkbox" />
<div class="space-y-0.5">
<span class="font-bold">Show Technical IDs</span
>
<span class="font-bold"
>Show Technical IDs</span>
<p class="text-xs opacity-60">
Display UUIDs in metadata footers
</p>
@@ -214,52 +204,42 @@
<!-- Journal Query Filters Section -->
<section class="space-y-4">
<h2
class="text-xl font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
class="border-surface-500/30 flex items-center gap-2 border-b pb-2 text-xl font-bold">
<Database size="1.2em" class="text-primary-500" />
Journal Query Filters
</h2>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 p-2">
<div class="grid grid-cols-1 gap-6 p-2 md:grid-cols-3">
<label class="label">
<span class="text-sm font-bold opacity-70"
>Enabled Status</span
>
>Enabled Status</span>
<select
bind:value={tmp_config.journal.qry__enabled}
class="select select-sm"
>
class="select select-sm">
<option value="enabled">Enabled Only</option>
<option value="not_enabled"
>Disabled Only</option
>
>Disabled Only</option>
<option value="all"
>All (Enabled & Disabled & NULL)</option
>
>All (Enabled & Disabled & NULL)</option>
</select>
</label>
<label class="label">
<span class="text-sm font-bold opacity-70"
>Hidden Status</span
>
>Hidden Status</span>
<select
bind:value={tmp_config.journal.qry__hidden}
class="select select-sm"
>
class="select select-sm">
<option value="not_hidden">Visible Only</option>
<option value="hidden">Hidden Only</option>
<option value="all"
>All (Visible & Hidden & NULL)</option
>
>All (Visible & Hidden & NULL)</option>
</select>
</label>
<label class="label">
<span class="text-sm font-bold opacity-70"
>Query Limit</span
>
>Query Limit</span>
<select
bind:value={tmp_config.journal.qry__limit}
class="select select-sm"
>
class="select select-sm">
<option value={10}>10</option>
<option value={20}>20</option>
<option value={50}>50</option>
@@ -275,52 +255,42 @@
<!-- Entry Query Filters Section -->
<section class="space-y-4">
<h2
class="text-xl font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
class="border-surface-500/30 flex items-center gap-2 border-b pb-2 text-xl font-bold">
<Database size="1.2em" class="text-primary-500" />
Entry Query Filters
</h2>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 p-2">
<div class="grid grid-cols-1 gap-6 p-2 md:grid-cols-3">
<label class="label">
<span class="text-sm font-bold opacity-70"
>Enabled Status</span
>
>Enabled Status</span>
<select
bind:value={tmp_config.entry.qry__enabled}
class="select select-sm"
>
class="select select-sm">
<option value="enabled">Enabled Only</option>
<option value="not_enabled"
>Disabled Only</option
>
>Disabled Only</option>
<option value="all"
>All (Enabled & Disabled & NULL)</option
>
>All (Enabled & Disabled & NULL)</option>
</select>
</label>
<label class="label">
<span class="text-sm font-bold opacity-70"
>Hidden Status</span
>
>Hidden Status</span>
<select
bind:value={tmp_config.entry.qry__hidden}
class="select select-sm"
>
class="select select-sm">
<option value="not_hidden">Visible Only</option>
<option value="hidden">Hidden Only</option>
<option value="all"
>All (Visible & Hidden & NULL)</option
>
>All (Visible & Hidden & NULL)</option>
</select>
</label>
<label class="label">
<span class="text-sm font-bold opacity-70"
>Query Limit</span
>
>Query Limit</span>
<select
bind:value={tmp_config.entry.qry__limit}
class="select select-sm"
>
class="select select-sm">
<option value={10}>10</option>
<option value={20}>20</option>
<option value={50}>50</option>
@@ -336,30 +306,25 @@
<!-- Security Section -->
<section class="space-y-4">
<h2
class="text-xl font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
class="border-surface-500/30 flex items-center gap-2 border-b pb-2 text-xl font-bold">
<ShieldCheck size="1.2em" class="text-primary-500" />
Security & Encryption
</h2>
<div
class="p-4 bg-orange-500/5 rounded-lg border border-orange-500/20 space-y-4"
>
<div class="text-sm opacity-80 italic">
class="space-y-4 rounded-lg border border-orange-500/20 bg-orange-500/5 p-4">
<div class="text-sm italic opacity-80">
Global security overrides for the journal module.
</div>
<label
class="flex items-center space-x-3 cursor-pointer"
>
class="flex cursor-pointer items-center space-x-3">
<input
type="checkbox"
bind:checked={
$journals_sess.enable_session_passcode_cache
}
class="checkbox checkbox-primary"
/>
class="checkbox checkbox-primary" />
<span class="text-sm font-bold"
>Cache Passcodes in Session</span
>
>Cache Passcodes in Session</span>
</label>
</div>
</section>
@@ -370,8 +335,7 @@
readonly={true}
content={JSON.stringify(tmp_config, null, 2)}
theme_mode={$ae_loc.theme_mode}
class_li="rounded-lg border border-surface-500/30"
/>
class_li="rounded-lg border border-surface-500/30" />
</div>
{:else if tab === 'session_json'}
<div class="h-full min-h-[400px]">
@@ -379,8 +343,7 @@
readonly={true}
content={JSON.stringify($journals_sess, null, 2)}
theme_mode={$ae_loc.theme_mode}
class_li="rounded-lg border border-surface-500/30"
/>
class_li="rounded-lg border border-surface-500/30" />
</div>
{/if}
</div>
@@ -389,16 +352,14 @@
<div class="flex gap-4">
<button
type="button"
class="btn preset-tonal-surface font-bold min-w-[100px]"
onclick={() => (show = false)}
>
class="btn preset-tonal-surface min-w-[100px] font-bold"
onclick={() => (show = false)}>
<X size="1.2em" class="mr-2" /> Cancel
</button>
<button
type="button"
class="btn preset-filled-primary font-bold shadow-lg min-w-[120px]"
onclick={handle_save}
>
class="btn preset-filled-primary min-w-[120px] font-bold shadow-lg"
onclick={handle_save}>
<Check size="1.2em" class="mr-2" /> Save Changes
</button>
</div>