style(journals): apply expanded 80-width formatting and snake_case

- Batch formatted all Journals module files using Prettier with printWidth: 80.
- Refactored preventDefault to prevent_default across all Svelte components.
- Standardized line breaks for imports and long attribute lists for better readability.
- Ensured consistent snake_case naming for internal identifiers.
This commit is contained in:
Scott Idem
2026-02-06 14:15:43 -05:00
parent 07dd6c18a1
commit 2f3125c64b
37 changed files with 3033 additions and 1133 deletions

View File

@@ -46,7 +46,9 @@ export async function load_ae_obj_id__journal({
log_lvl?: number; log_lvl?: number;
}): Promise<ae_Journal | null> { }): Promise<ae_Journal | null> {
if (log_lvl) { if (log_lvl) {
console.log(`*** load_ae_obj_id__journal() *** journal_id=${journal_id} (SWR)`); console.log(
`*** load_ae_obj_id__journal() *** journal_id=${journal_id} (SWR)`
);
} }
// 1. FAST PATH: Return cached data immediately // 1. FAST PATH: Return cached data immediately
@@ -54,16 +56,39 @@ export async function load_ae_obj_id__journal({
try { try {
const cached = await db_journals.journal.get(journal_id); const cached = await db_journals.journal.get(journal_id);
if (cached) { if (cached) {
if (log_lvl) console.log('JOURNAL LOAD: Cache hit. Returning stale data.'); if (log_lvl)
console.log(
'JOURNAL LOAD: Cache hit. Returning stale data.'
);
_refresh_journal_id_background({ _refresh_journal_id_background({
api_cfg, journal_id, view, params, try_cache, api_cfg,
inc_entry_li, enabled, hidden, limit, offset, order_by_li, log_lvl: 0 journal_id,
view,
params,
try_cache,
inc_entry_li,
enabled,
hidden,
limit,
offset,
order_by_li,
log_lvl: 0
}); });
if (inc_entry_li && !cached.journal_entry_li) { if (inc_entry_li && !cached.journal_entry_li) {
cached.journal_entry_li = await load_ae_obj_li__journal_entry({ cached.journal_entry_li =
api_cfg, for_obj_type: 'journal', for_obj_id: journal_id, await load_ae_obj_li__journal_entry({
enabled, hidden, limit, offset, order_by_li, params, try_cache, log_lvl api_cfg,
}); for_obj_type: 'journal',
for_obj_id: journal_id,
enabled,
hidden,
limit,
offset,
order_by_li,
params,
try_cache,
log_lvl
});
} }
return cached; return cached;
} }
@@ -72,27 +97,75 @@ export async function load_ae_obj_id__journal({
// 2. SLOW PATH: Wait for API // 2. SLOW PATH: Wait for API
return await _refresh_journal_id_background({ return await _refresh_journal_id_background({
api_cfg, journal_id, view, params, try_cache, api_cfg,
inc_entry_li, enabled, hidden, limit, offset, order_by_li, log_lvl journal_id,
view,
params,
try_cache,
inc_entry_li,
enabled,
hidden,
limit,
offset,
order_by_li,
log_lvl
}); });
} }
/** /**
* Internal background refresh for a single journal * Internal background refresh for a single journal
*/ */
async function _refresh_journal_id_background({ api_cfg, journal_id, view, params, try_cache, inc_entry_li, enabled, hidden, limit, offset, order_by_li, log_lvl }: any) { async function _refresh_journal_id_background({
api_cfg,
journal_id,
view,
params,
try_cache,
inc_entry_li,
enabled,
hidden,
limit,
offset,
order_by_li,
log_lvl
}: any) {
if (typeof navigator !== 'undefined' && !navigator.onLine) return null; if (typeof navigator !== 'undefined' && !navigator.onLine) return null;
try { try {
const result = await api.get_ae_obj_v3({ api_cfg, obj_type: 'journal', obj_id: journal_id, view, params, log_lvl }); const result = await api.get_ae_obj_v3({
api_cfg,
obj_type: 'journal',
obj_id: journal_id,
view,
params,
log_lvl
});
if (result) { if (result) {
if (try_cache) { if (try_cache) {
const processed = await process_ae_obj__journal_props({ obj_li: [result], log_lvl }); const processed = await process_ae_obj__journal_props({
await db_save_ae_obj_li__ae_obj({ db_instance: db_journals, table_name: 'journal', obj_li: processed, properties_to_save, log_lvl }); obj_li: [result],
log_lvl
});
await db_save_ae_obj_li__ae_obj({
db_instance: db_journals,
table_name: 'journal',
obj_li: processed,
properties_to_save,
log_lvl
});
} }
if (inc_entry_li) { if (inc_entry_li) {
result.journal_entry_li = await load_ae_obj_li__journal_entry({ result.journal_entry_li = await load_ae_obj_li__journal_entry({
api_cfg, for_obj_type: 'journal', for_obj_id: journal_id, api_cfg,
enabled, hidden, limit, offset, order_by_li, params, try_cache, log_lvl for_obj_type: 'journal',
for_obj_id: journal_id,
enabled,
hidden,
limit,
offset,
order_by_li,
params,
try_cache,
log_lvl
}); });
} }
return result; return result;
@@ -138,18 +211,37 @@ export async function load_ae_obj_li__journal({
log_lvl?: number; log_lvl?: number;
}): Promise<ae_Journal[]> { }): Promise<ae_Journal[]> {
if (log_lvl) { if (log_lvl) {
console.log(`*** load_ae_obj_li__journal() *** for=${for_obj_type}:${for_obj_id} (SWR)`); console.log(
`*** load_ae_obj_li__journal() *** for=${for_obj_type}:${for_obj_id} (SWR)`
);
} }
// 1. FAST PATH: Check cache // 1. FAST PATH: Check cache
if (try_cache) { if (try_cache) {
try { try {
const cached_li = await db_journals.journal.where('for_id').equals(for_obj_id).toArray(); const cached_li = await db_journals.journal
.where('for_id')
.equals(for_obj_id)
.toArray();
if (cached_li && cached_li.length > 0) { if (cached_li && cached_li.length > 0) {
if (log_lvl) console.log(`JOURNAL LIST: Cache hit (${cached_li.length}).`); if (log_lvl)
console.log(
`JOURNAL LIST: Cache hit (${cached_li.length}).`
);
_refresh_journal_li_background({ _refresh_journal_li_background({
api_cfg, for_obj_type, for_obj_id, qry_person_id, inc_entry_li, api_cfg,
enabled, hidden, limit, offset, order_by_li, params, try_cache, log_lvl: 0 for_obj_type,
for_obj_id,
qry_person_id,
inc_entry_li,
enabled,
hidden,
limit,
offset,
order_by_li,
params,
try_cache,
log_lvl: 0
}); });
return cached_li; return cached_li;
} }
@@ -158,38 +250,109 @@ export async function load_ae_obj_li__journal({
// 2. SLOW PATH: API // 2. SLOW PATH: API
return await _refresh_journal_li_background({ return await _refresh_journal_li_background({
api_cfg, for_obj_type, for_obj_id, qry_person_id, inc_entry_li, api_cfg,
enabled, hidden, limit, offset, order_by_li, params, try_cache, log_lvl for_obj_type,
for_obj_id,
qry_person_id,
inc_entry_li,
enabled,
hidden,
limit,
offset,
order_by_li,
params,
try_cache,
log_lvl
}); });
} }
async function _refresh_journal_li_background({ api_cfg, for_obj_type, for_obj_id, qry_person_id, inc_entry_li, enabled, hidden, limit, offset, order_by_li, params, try_cache, log_lvl }: any) { async function _refresh_journal_li_background({
api_cfg,
for_obj_type,
for_obj_id,
qry_person_id,
inc_entry_li,
enabled,
hidden,
limit,
offset,
order_by_li,
params,
try_cache,
log_lvl
}: any) {
if (typeof navigator !== 'undefined' && !navigator.onLine) return []; if (typeof navigator !== 'undefined' && !navigator.onLine) return [];
let promise; let promise;
if (qry_person_id) { if (qry_person_id) {
const search_query: any = { and: [{ field: 'person_id_random', op: 'eq', value: qry_person_id }] }; const search_query: any = {
if (for_obj_id) search_query.and.push({ field: `${for_obj_type}_id_random`, op: 'eq', value: for_obj_id }); and: [{ field: 'person_id_random', op: 'eq', value: qry_person_id }]
if (enabled === 'enabled') search_query.and.push({ field: 'enable', op: 'eq', value: true }); };
if (hidden === 'hidden') search_query.and.push({ field: 'hide', op: 'eq', value: true }); if (for_obj_id)
search_query.and.push({
field: `${for_obj_type}_id_random`,
op: 'eq',
value: for_obj_id
});
if (enabled === 'enabled')
search_query.and.push({ field: 'enable', op: 'eq', value: true });
if (hidden === 'hidden')
search_query.and.push({ field: 'hide', op: 'eq', value: true });
promise = api.search_ae_obj_v3({ api_cfg, obj_type: 'journal', search_query, order_by_li, limit, offset, log_lvl }); promise = api.search_ae_obj_v3({
api_cfg,
obj_type: 'journal',
search_query,
order_by_li,
limit,
offset,
log_lvl
});
} else { } else {
promise = api.get_ae_obj_li_v3({ api_cfg, obj_type: 'journal', for_obj_type, for_obj_id, enabled, hidden, limit, offset, order_by_li, log_lvl }); promise = api.get_ae_obj_li_v3({
api_cfg,
obj_type: 'journal',
for_obj_type,
for_obj_id,
enabled,
hidden,
limit,
offset,
order_by_li,
log_lvl
});
} }
try { try {
const results = await promise; const results = await promise;
if (results) { if (results) {
if (try_cache) { if (try_cache) {
const processed = await process_ae_obj__journal_props({ obj_li: results, log_lvl }); const processed = await process_ae_obj__journal_props({
await db_save_ae_obj_li__ae_obj({ db_instance: db_journals, table_name: 'journal', obj_li: processed, properties_to_save, log_lvl }); obj_li: results,
log_lvl
});
await db_save_ae_obj_li__ae_obj({
db_instance: db_journals,
table_name: 'journal',
obj_li: processed,
properties_to_save,
log_lvl
});
} }
if (inc_entry_li) { if (inc_entry_li) {
for (const journal of results) { for (const journal of results) {
load_ae_obj_li__journal_entry({ load_ae_obj_li__journal_entry({
api_cfg, for_obj_type: 'journal', for_obj_id: journal.journal_id_random, api_cfg,
enabled, hidden, limit, offset, order_by_li, params, try_cache, log_lvl: 0 for_obj_type: 'journal',
for_obj_id: journal.journal_id_random,
enabled,
hidden,
limit,
offset,
order_by_li,
params,
try_cache,
log_lvl: 0
}); });
} }
} }
@@ -216,11 +379,15 @@ export async function create_ae_obj__journal({
log_lvl?: number; log_lvl?: number;
}): Promise<ae_Journal | null> { }): Promise<ae_Journal | null> {
if (log_lvl) { if (log_lvl) {
console.log(`*** create_ae_obj__journal() *** account_id=${account_id}`); console.log(
`*** create_ae_obj__journal() *** account_id=${account_id}`
);
} }
if (!account_id) { if (!account_id) {
console.log(`ERROR: Journals - Journal - account_id required to create`); console.log(
`ERROR: Journals - Journal - account_id required to create`
);
return null; return null;
} }
@@ -239,10 +406,11 @@ export async function create_ae_obj__journal({
if (journal_obj_create_result) { if (journal_obj_create_result) {
if (try_cache) { if (try_cache) {
// Process the results first // Process the results first
const processed_obj_li = await process_ae_obj__journal_props({ const processed_obj_li =
obj_li: [journal_obj_create_result], await process_ae_obj__journal_props({
log_lvl: log_lvl obj_li: [journal_obj_create_result],
}); log_lvl: log_lvl
});
if (log_lvl) { if (log_lvl) {
console.log('Processed object list:', processed_obj_li); console.log('Processed object list:', processed_obj_li);
} }
@@ -284,7 +452,9 @@ export async function delete_ae_obj_id__journal({
log_lvl?: number; log_lvl?: number;
}) { }) {
if (log_lvl) { if (log_lvl) {
console.log(`*** delete_ae_obj_id__journal() *** journal_id=${journal_id}`); console.log(
`*** delete_ae_obj_id__journal() *** journal_id=${journal_id}`
);
} }
ae_promises.delete__journal_obj = await api ae_promises.delete__journal_obj = await api
@@ -302,7 +472,9 @@ export async function delete_ae_obj_id__journal({
.finally(async function () { .finally(async function () {
if (try_cache) { if (try_cache) {
if (log_lvl) { if (log_lvl) {
console.log(`Attempting to remove IDB entry for journal_id=${journal_id}`); console.log(
`Attempting to remove IDB entry for journal_id=${journal_id}`
);
} }
await db_journals.journal.delete(journal_id); await db_journals.journal.delete(journal_id);
} }
@@ -328,7 +500,10 @@ export async function update_ae_obj__journal({
log_lvl?: number; log_lvl?: number;
}): Promise<ae_Journal | null> { }): Promise<ae_Journal | null> {
if (log_lvl) { if (log_lvl) {
console.log(`*** update_ae_obj__journal() *** journal_id=${journal_id}`, data_kv); console.log(
`*** update_ae_obj__journal() *** journal_id=${journal_id}`,
data_kv
);
} }
// Perform the API update // Perform the API update
@@ -401,7 +576,9 @@ export async function qry__journal({
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined; // all, hidden, not_hidden hidden?: 'hidden' | 'all' | 'not_hidden' | undefined; // all, hidden, not_hidden
limit?: number; limit?: number;
offset?: number; offset?: number;
order_by_li?: Record<string, 'ASC' | 'DESC'> | Record<string, 'ASC' | 'DESC'>[]; order_by_li?:
| Record<string, 'ASC' | 'DESC'>
| Record<string, 'ASC' | 'DESC'>[];
params?: any; params?: any;
try_cache?: boolean; try_cache?: boolean;
log_lvl?: number; log_lvl?: number;
@@ -417,17 +594,29 @@ export async function qry__journal({
if (qry_files === true) { if (qry_files === true) {
search_query.and.push({ field: 'file_count_all', op: 'gt', value: 0 }); search_query.and.push({ field: 'file_count_all', op: 'gt', value: 0 });
} else if (qry_files === false) { } else if (qry_files === false) {
search_query.and.push({ field: 'file_count_all', op: 'is', value: null }); search_query.and.push({
field: 'file_count_all',
op: 'is',
value: null
});
} }
if (qry_start_datetime) { if (qry_start_datetime) {
search_query.and.push({ field: 'start_datetime', op: 'gt', value: qry_start_datetime }); search_query.and.push({
field: 'start_datetime',
op: 'gt',
value: qry_start_datetime
});
} }
// Add for_obj_id context (Account ID) // Add for_obj_id context (Account ID)
if (journal_id) { if (journal_id) {
// Assuming journal_id here is actually the account_id as per original usage context // Assuming journal_id here is actually the account_id as per original usage context
search_query.and.push({ field: 'account_id_random', op: 'eq', value: journal_id }); search_query.and.push({
field: 'account_id_random',
op: 'eq',
value: journal_id
});
} }
// Add enabled/hidden filters // Add enabled/hidden filters
@@ -457,10 +646,11 @@ export async function qry__journal({
if (journal_obj_li_get_result) { if (journal_obj_li_get_result) {
if (try_cache) { if (try_cache) {
// Process the results first // Process the results first
const processed_obj_li = await process_ae_obj__journal_props({ const processed_obj_li =
obj_li: journal_obj_li_get_result, await process_ae_obj__journal_props({
log_lvl: log_lvl obj_li: journal_obj_li_get_result,
}); log_lvl: log_lvl
});
if (log_lvl) { if (log_lvl) {
console.log('Processed object list:', processed_obj_li); console.log('Processed object list:', processed_obj_li);
} }
@@ -486,7 +676,10 @@ export async function qry__journal({
}); });
if (log_lvl) { if (log_lvl) {
console.log('ae_promises.load__journal_obj_li:', ae_promises.load__journal_obj_li); console.log(
'ae_promises.load__journal_obj_li:',
ae_promises.load__journal_obj_li
);
} }
return ae_promises.load__journal_obj_li; return ae_promises.load__journal_obj_li;
} }
@@ -624,12 +817,16 @@ async function _process_generic_props<T extends Record<string, any>>({
const updated = processed_obj.updated_on ?? processed_obj.created_on; const updated = processed_obj.updated_on ?? processed_obj.created_on;
const name = processed_obj.name ?? ''; const name = processed_obj.name ?? '';
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`; (processed_obj as any).tmp_sort_1 =
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`; `${group}_${priority}_${sort}_${updated}`;
(processed_obj as any).tmp_sort_2 =
`${group}_${priority}_${sort}_${name}_${updated}`;
// --- Specific Transformations --- // --- Specific Transformations ---
if (specific_processor) { if (specific_processor) {
processed_obj = await Promise.resolve(specific_processor(processed_obj)); processed_obj = await Promise.resolve(
specific_processor(processed_obj)
);
} }
processed_obj_li.push(processed_obj as T); processed_obj_li.push(processed_obj as T);
@@ -656,7 +853,8 @@ export async function process_ae_obj__journal_props({
/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, /^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,
'' ''
); );
obj.description_md_html = (await marked.parse(description_cleaned ?? '')) ?? null; obj.description_md_html =
(await marked.parse(description_cleaned ?? '')) ?? null;
obj.cfg_json = obj.cfg_json ?? {}; obj.cfg_json = obj.cfg_json ?? {};
obj.data_json = obj.data_json ?? {}; obj.data_json = obj.data_json ?? {};

View File

@@ -22,7 +22,9 @@ export async function load_ae_obj_id__journal_entry({
log_lvl?: number; log_lvl?: number;
}): Promise<ae_JournalEntry | null> { }): Promise<ae_JournalEntry | null> {
if (log_lvl) { if (log_lvl) {
console.log(`*** load_ae_obj_id__journal_entry() *** journal_entry_id=${journal_entry_id}`); console.log(
`*** load_ae_obj_id__journal_entry() *** journal_entry_id=${journal_entry_id}`
);
} }
ae_promises.load__journal_entry_obj = await api ae_promises.load__journal_entry_obj = await api
@@ -36,10 +38,11 @@ export async function load_ae_obj_id__journal_entry({
if (journal_entry_obj_get_result) { if (journal_entry_obj_get_result) {
if (try_cache) { if (try_cache) {
// Process the results first // Process the results first
const processed_obj_li = await process_ae_obj__journal_entry_props({ const processed_obj_li =
obj_li: [journal_entry_obj_get_result], await process_ae_obj__journal_entry_props({
log_lvl: log_lvl obj_li: [journal_entry_obj_get_result],
}); log_lvl: log_lvl
});
if (log_lvl) { if (log_lvl) {
console.log('Processed object list:', processed_obj_li); console.log('Processed object list:', processed_obj_li);
} }
@@ -138,11 +141,15 @@ export async function load_ae_obj_li__journal_entry({
if (journal_entry_obj_li_get_result) { if (journal_entry_obj_li_get_result) {
if (try_cache) { if (try_cache) {
// Process the results first // Process the results first
const processed_obj_li = await process_ae_obj__journal_entry_props({ const processed_obj_li =
obj_li: journal_entry_obj_li_get_result, await process_ae_obj__journal_entry_props({
journal_id: for_obj_type === 'journal' ? for_obj_id : undefined, obj_li: journal_entry_obj_li_get_result,
log_lvl: log_lvl journal_id:
}); for_obj_type === 'journal'
? for_obj_id
: undefined,
log_lvl: log_lvl
});
if (log_lvl) { if (log_lvl) {
console.log('Processed object list:', processed_obj_li); console.log('Processed object list:', processed_obj_li);
} }
@@ -197,7 +204,9 @@ export async function create_ae_obj__journal_entry({
log_lvl?: number; log_lvl?: number;
}): Promise<ae_JournalEntry | null> { }): Promise<ae_JournalEntry | null> {
if (log_lvl) { if (log_lvl) {
console.log(`*** create_ae_obj__journal_entry() *** journal_id=${journal_id}`); console.log(
`*** create_ae_obj__journal_entry() *** journal_id=${journal_id}`
);
} }
if (!journal_id) { if (!journal_id) {
@@ -219,11 +228,12 @@ export async function create_ae_obj__journal_entry({
if (journal_entry_obj_create_result) { if (journal_entry_obj_create_result) {
if (try_cache) { if (try_cache) {
// Process the results first // Process the results first
const processed_obj_li = await process_ae_obj__journal_entry_props({ const processed_obj_li =
obj_li: [journal_entry_obj_create_result], await process_ae_obj__journal_entry_props({
journal_id, obj_li: [journal_entry_obj_create_result],
log_lvl: log_lvl journal_id,
}); log_lvl: log_lvl
});
if (log_lvl) { if (log_lvl) {
console.log('Processed object list:', processed_obj_li); console.log('Processed object list:', processed_obj_li);
} }
@@ -342,36 +352,64 @@ export async function qry__journal_entry({
log_lvl?: number; log_lvl?: number;
}) { }) {
if (log_lvl) { if (log_lvl) {
console.log(`*** qry__journal_entry() *** journal_id=${journal_id} person_id=${person_id}`); console.log(
`*** qry__journal_entry() *** journal_id=${journal_id} person_id=${person_id}`
);
} }
const search_query: any = { and: [] }; const search_query: any = { and: [] };
if (qry_str) { if (qry_str) {
// Using 'like' with wildcards to ensure compatibility // Using 'like' with wildcards to ensure compatibility
search_query.and.push({ field: 'default_qry_str', op: 'like', value: `%${qry_str.trim()}%` }); search_query.and.push({
params['lk_qry'] = { 'default_qry_str': qry_str.trim() }; field: 'default_qry_str',
op: 'like',
value: `%${qry_str.trim()}%`
});
params['lk_qry'] = { default_qry_str: qry_str.trim() };
} }
if (qry_category_code) { if (qry_category_code) {
search_query.and.push({ field: 'category_code', op: 'eq', value: qry_category_code }); search_query.and.push({
field: 'category_code',
op: 'eq',
value: qry_category_code
});
} }
if (qry_created_on) { if (qry_created_on) {
search_query.and.push({ field: 'created_on', op: 'gt', value: qry_created_on }); search_query.and.push({
field: 'created_on',
op: 'gt',
value: qry_created_on
});
} }
if (qry_priority) { if (qry_priority) {
search_query.and.push({ field: 'priority', op: 'eq', value: qry_priority }); search_query.and.push({
field: 'priority',
op: 'eq',
value: qry_priority
});
} }
// Context scoping: Prefer journal_id if provided, otherwise fallback to person_id (global search) // Context scoping: Prefer journal_id if provided, otherwise fallback to person_id (global search)
if (journal_id) { if (journal_id) {
search_query.and.push({ field: 'journal_id_random', op: 'eq', value: journal_id }); search_query.and.push({
field: 'journal_id_random',
op: 'eq',
value: journal_id
});
} else if (person_id) { } else if (person_id) {
search_query.and.push({ field: 'person_id_random', op: 'eq', value: person_id }); search_query.and.push({
field: 'person_id_random',
op: 'eq',
value: person_id
});
} else { } else {
console.warn('qry__journal_entry: No journal_id or person_id provided. Search might be too broad.'); console.warn(
'qry__journal_entry: No journal_id or person_id provided. Search might be too broad.'
);
} }
// Add enabled/hidden filters // Add enabled/hidden filters
@@ -413,11 +451,12 @@ export async function qry__journal_entry({
if (valid_result_li && valid_result_li.length > 0) { if (valid_result_li && valid_result_li.length > 0) {
if (try_cache) { if (try_cache) {
const processed_obj_li = await process_ae_obj__journal_entry_props({ const processed_obj_li =
obj_li: valid_result_li, await process_ae_obj__journal_entry_props({
journal_id, obj_li: valid_result_li,
log_lvl journal_id,
}); log_lvl
});
await db_save_ae_obj_li__ae_obj({ await db_save_ae_obj_li__ae_obj({
db_instance: db_journals, db_instance: db_journals,
table_name: 'journal_entry', table_name: 'journal_entry',
@@ -907,12 +946,16 @@ async function _process_generic_props<T extends Record<string, any>>({
const updated = processed_obj.updated_on ?? processed_obj.created_on; const updated = processed_obj.updated_on ?? processed_obj.created_on;
const name = processed_obj.name ?? ''; const name = processed_obj.name ?? '';
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`; (processed_obj as any).tmp_sort_1 =
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`; `${group}_${priority}_${sort}_${updated}`;
(processed_obj as any).tmp_sort_2 =
`${group}_${priority}_${sort}_${name}_${updated}`;
// --- Specific Transformations --- // --- Specific Transformations ---
if (specific_processor) { if (specific_processor) {
processed_obj = await Promise.resolve(specific_processor(processed_obj)); processed_obj = await Promise.resolve(
specific_processor(processed_obj)
);
} }
processed_obj_li.push(processed_obj as T); processed_obj_li.push(processed_obj as T);
@@ -952,8 +995,12 @@ export async function process_ae_obj__journal_entry_props({
content_cleaned = null; content_cleaned = null;
content_md_html = null; content_md_html = null;
} else { } else {
content_cleaned = content.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, ''); content_cleaned = content.replace(
content_md_html = (await marked.parse(content_cleaned ?? '')) ?? null; /^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,
''
);
content_md_html =
(await marked.parse(content_cleaned ?? '')) ?? null;
} }
obj.content = content; obj.content = content;
obj.content_md_html = content_md_html; obj.content_md_html = content_md_html;
@@ -968,8 +1015,12 @@ export async function process_ae_obj__journal_entry_props({
history_cleaned = null; history_cleaned = null;
history_md_html = null; history_md_html = null;
} else { } else {
history_cleaned = history.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, ''); history_cleaned = history.replace(
history_md_html = (await marked.parse(history_cleaned ?? '')) ?? null; /^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,
''
);
history_md_html =
(await marked.parse(history_cleaned ?? '')) ?? null;
} }
obj.history = history; obj.history = history;
obj.history_md_html = history_md_html; obj.history_md_html = history_md_html;

View File

@@ -24,7 +24,6 @@ export async function decrypt_journal_entry(
journal: ae_Journal, journal: ae_Journal,
typed_passcode?: string typed_passcode?: string
): Promise<DecryptionResult> { ): Promise<DecryptionResult> {
// Safety check: if not encrypted, return as-is // Safety check: if not encrypted, return as-is
if (!entry.content_encrypted) { if (!entry.content_encrypted) {
return { return {
@@ -45,7 +44,10 @@ export async function decrypt_journal_entry(
} }
if (!journal_key) { if (!journal_key) {
console.warn('decrypt_journal_entry: No key available. Source:', key_source); console.warn(
'decrypt_journal_entry: No key available. Source:',
key_source
);
return { return {
success: false, success: false,
error: 'No passcode provided or available for decryption.' error: 'No passcode provided or available for decryption.'
@@ -55,15 +57,22 @@ export async function decrypt_journal_entry(
// Aether standard: combine the journal's public passcode with the private key // Aether standard: combine the journal's public passcode with the private key
const decrypt_key = `${journal.passcode ?? ''}:${journal_key}`; const decrypt_key = `${journal.passcode ?? ''}:${journal_key}`;
console.log(`decrypt_journal_entry: Attempting decryption. Source: ${key_source}`); console.log(
`decrypt_journal_entry: Attempting decryption. Source: ${key_source}`
);
// console.log(`decrypt_journal_entry: Key: ${decrypt_key}`); // Log ONLY for deep debugging // console.log(`decrypt_journal_entry: Key: ${decrypt_key}`); // Log ONLY for deep debugging
try { try {
// Decrypt Primary Content // Decrypt Primary Content
const result = await ae_util.decrypt_wrapper(entry.content_encrypted, decrypt_key); const result = await ae_util.decrypt_wrapper(
entry.content_encrypted,
decrypt_key
);
if (result === false) { if (result === false) {
console.error('decrypt_journal_entry: Decryption wrapper returned false.'); console.error(
'decrypt_journal_entry: Decryption wrapper returned false.'
);
return { return {
success: false, success: false,
error: 'Decryption failed. Incorrect passcode or corrupted data.' error: 'Decryption failed. Incorrect passcode or corrupted data.'
@@ -75,19 +84,23 @@ export async function decrypt_journal_entry(
// Decrypt History (if it exists) // Decrypt History (if it exists)
if (entry.history_encrypted) { if (entry.history_encrypted) {
const h_res = await ae_util.decrypt_wrapper(entry.history_encrypted, decrypt_key); const h_res = await ae_util.decrypt_wrapper(
entry.history_encrypted,
decrypt_key
);
if (h_res !== false) { if (h_res !== false) {
decrypted_history = typeof h_res === 'string' ? h_res : ''; decrypted_history = typeof h_res === 'string' ? h_res : '';
} }
} }
console.log(`decrypt_journal_entry: SUCCESS. Source: ${key_source}, Content length: ${decrypted_text.length}. Preview: ${decrypted_text.substring(0, 30).replace(/\n/g, ' ')}...`); console.log(
`decrypt_journal_entry: SUCCESS. Source: ${key_source}, Content length: ${decrypted_text.length}. Preview: ${decrypted_text.substring(0, 30).replace(/\n/g, ' ')}...`
);
return { return {
success: true, success: true,
content: decrypted_text, content: decrypted_text,
history: decrypted_history history: decrypted_history
}; };
} catch (err: any) { } catch (err: any) {
console.error('decrypt_journal_entry error:', err); console.error('decrypt_journal_entry error:', err);
return { return {

View File

@@ -1,19 +1,28 @@
/** /**
* Wraps the current selection in CodeMirror with the given prefix and suffix. * Wraps the current selection in CodeMirror with the given prefix and suffix.
*/ */
export function wrapSelection(view: any, prefix: string, suffix: string = prefix) { export function wrapSelection(
view: any,
prefix: string,
suffix: string = prefix
) {
if (!view || view.updateInProgress) return; if (!view || view.updateInProgress) return;
const { state } = view; const { state } = view;
view.dispatch(state.changeByRange((range: any) => { view.dispatch(
return { state.changeByRange((range: any) => {
changes: [ return {
{from: range.from, insert: prefix}, changes: [
{from: range.to, insert: suffix} { from: range.from, insert: prefix },
], { from: range.to, insert: suffix }
range: range.constructor.range(range.from + prefix.length, range.to + prefix.length) ],
}; range: range.constructor.range(
})); range.from + prefix.length,
range.to + prefix.length
)
};
})
);
view.focus(); view.focus();
} }
@@ -24,30 +33,47 @@ export function toggleLinePrefix(view: any, prefix: string) {
if (!view || view.updateInProgress) return; if (!view || view.updateInProgress) return;
const { state } = view; const { state } = view;
view.dispatch(state.changeByRange((range: any) => { view.dispatch(
const lines = []; state.changeByRange((range: any) => {
for (let pos = range.from; pos <= range.to; ) { const lines = [];
const line = state.doc.lineAt(pos); for (let pos = range.from; pos <= range.to; ) {
lines.push(line); const line = state.doc.lineAt(pos);
pos = line.to + 1; lines.push(line);
} pos = line.to + 1;
const isAlreadyPrefixed = lines.every(l => l.text.startsWith(prefix));
const lineChanges = lines.map(l => {
if (isAlreadyPrefixed) {
return { from: l.from, to: l.from + prefix.length, insert: '' };
} else {
return { from: l.from, insert: prefix };
} }
});
const newFrom = range.from + (isAlreadyPrefixed ? -prefix.length : prefix.length); const isAlreadyPrefixed = lines.every((l) =>
const newTo = range.to + (isAlreadyPrefixed ? (-prefix.length * lines.length) : (prefix.length * lines.length)); l.text.startsWith(prefix)
);
const lineChanges = lines.map((l) => {
if (isAlreadyPrefixed) {
return {
from: l.from,
to: l.from + prefix.length,
insert: ''
};
} else {
return { from: l.from, insert: prefix };
}
});
return { const newFrom =
changes: lineChanges, range.from +
range: range.constructor.range(newFrom, Math.max(newFrom, newTo)) (isAlreadyPrefixed ? -prefix.length : prefix.length);
}; const newTo =
})); range.to +
(isAlreadyPrefixed
? -prefix.length * lines.length
: prefix.length * lines.length);
return {
changes: lineChanges,
range: range.constructor.range(
newFrom,
Math.max(newFrom, newTo)
)
};
})
);
view.focus(); view.focus();
} }

View File

@@ -24,12 +24,17 @@ export const template_standard_markdown: ExportTemplate = {
description: 'Basic Markdown with title, date, and content.', description: 'Basic Markdown with title, date, and content.',
extension: 'md', extension: 'md',
formatter: (entries) => { formatter: (entries) => {
return entries.map(entry => { return entries
const dateStr = ae_util.iso_datetime_formatter(entry.created_on, 'datetime_12_long'); .map((entry) => {
const title = entry.name || dateStr; const dateStr = ae_util.iso_datetime_formatter(
const header = `# ${title}\n*${dateStr}*\n\n`; entry.created_on,
return `${header}${entry.content || ''}\n\n---\n`; 'datetime_12_long'
}).join('\n'); );
const title = entry.name || dateStr;
const header = `# ${title}\n*${dateStr}*\n\n`;
return `${header}${entry.content || ''}\n\n---\n`;
})
.join('\n');
} }
}; };
@@ -50,12 +55,17 @@ export const template_personal_log: ExportTemplate = {
return dateA.localeCompare(dateB); return dateA.localeCompare(dateB);
}); });
return sorted.map(entry => { return sorted
const dateStr = ae_util.iso_datetime_formatter(entry.created_on, 'date_iso'); .map((entry) => {
const title = entry.name || ''; const dateStr = ae_util.iso_datetime_formatter(
const header = `## ${dateStr}${title ? ' - ' + title : ''}\n\n`; entry.created_on,
return `${header}${entry.content || ''}\n\n`; 'date_iso'
}).join('\n'); );
const title = entry.name || '';
const header = `## ${dateStr}${title ? ' - ' + title : ''}\n\n`;
return `${header}${entry.content || ''}\n\n`;
})
.join('\n');
} }
}; };
@@ -69,19 +79,24 @@ export const template_amazon_vine: ExportTemplate = {
description: 'Optimized for product reviews.', description: 'Optimized for product reviews.',
extension: 'md', extension: 'md',
formatter: (entries) => { formatter: (entries) => {
return entries.map(entry => { return entries
const dateStr = ae_util.iso_datetime_formatter(entry.created_on, 'date_iso'); .map((entry) => {
// Try to find a product name in the title or content const dateStr = ae_util.iso_datetime_formatter(
const productName = entry.name || 'Unknown Product'; entry.created_on,
'date_iso'
);
// Try to find a product name in the title or content
const productName = entry.name || 'Unknown Product';
// Look for product link in content_json or tags if available, // Look for product link in content_json or tags if available,
// otherwise just output content // otherwise just output content
let output = `## ${productName}\n`; let output = `## ${productName}\n`;
output += `*Date: ${dateStr}*\n\n`; output += `*Date: ${dateStr}*\n\n`;
output += `${entry.content || ''}\n\n`; output += `${entry.content || ''}\n\n`;
output += `---`; output += `---`;
return output; return output;
}).join('\n\n'); })
.join('\n\n');
} }
}; };
@@ -94,10 +109,14 @@ export const template_standard_html: ExportTemplate = {
description: 'Semantic HTML5 articles.', description: 'Semantic HTML5 articles.',
extension: 'html', extension: 'html',
formatter: (entries) => { formatter: (entries) => {
const body = entries.map(entry => { const body = entries
const dateStr = ae_util.iso_datetime_formatter(entry.created_on, 'datetime_12_long'); .map((entry) => {
const title = entry.name || dateStr; const dateStr = ae_util.iso_datetime_formatter(
return ` entry.created_on,
'datetime_12_long'
);
const title = entry.name || dateStr;
return `
<article class="journal-entry" id="entry-${entry.journal_entry_id}"> <article class="journal-entry" id="entry-${entry.journal_entry_id}">
<header> <header>
<h1>${title}</h1> <h1>${title}</h1>
@@ -108,7 +127,8 @@ export const template_standard_html: ExportTemplate = {
</div> </div>
<hr/> <hr/>
</article>`; </article>`;
}).join('\n'); })
.join('\n');
return `<!DOCTYPE html> return `<!DOCTYPE html>
<html lang="en"> <html lang="en">

View File

@@ -13,7 +13,8 @@ const export_obj = {
load_ae_obj_id__journal_entry: journal_entry.load_ae_obj_id__journal_entry, load_ae_obj_id__journal_entry: journal_entry.load_ae_obj_id__journal_entry,
load_ae_obj_li__journal_entry: journal_entry.load_ae_obj_li__journal_entry, load_ae_obj_li__journal_entry: journal_entry.load_ae_obj_li__journal_entry,
create_ae_obj__journal_entry: journal_entry.create_ae_obj__journal_entry, create_ae_obj__journal_entry: journal_entry.create_ae_obj__journal_entry,
delete_ae_obj_id__journal_entry: journal_entry.delete_ae_obj_id__journal_entry, delete_ae_obj_id__journal_entry:
journal_entry.delete_ae_obj_id__journal_entry,
update_ae_obj__journal_entry: journal_entry.update_ae_obj__journal_entry, update_ae_obj__journal_entry: journal_entry.update_ae_obj__journal_entry,
qry__journal_entry: journal_entry.qry__journal_entry qry__journal_entry: journal_entry.qry__journal_entry
// db_save_ae_obj_li__journal_entry: journal_entry.db_save_ae_obj_li__journal_entry, // db_save_ae_obj_li__journal_entry: journal_entry.db_save_ae_obj_li__journal_entry,

View File

@@ -19,7 +19,10 @@ export interface AeJournalEntryInput {
* - First line is title (if it looks like a title). * - First line is title (if it looks like a title).
* - Rest is content. * - Rest is content.
*/ */
export async function parse_standard_note(file: File, text: string): Promise<AeJournalEntryInput[]> { export async function parse_standard_note(
file: File,
text: string
): Promise<AeJournalEntryInput[]> {
const lines = text.split('\n'); const lines = text.split('\n');
let name = file.name.replace(/\.md$/i, '').replace(/\.txt$/i, ''); let name = file.name.replace(/\.md$/i, '').replace(/\.txt$/i, '');
let content = text; let content = text;
@@ -29,11 +32,15 @@ export async function parse_standard_note(file: File, text: string): Promise<AeJ
if (lines.length > 0 && lines[0].startsWith('# ')) { if (lines.length > 0 && lines[0].startsWith('# ')) {
name = lines[0].substring(2).trim(); name = lines[0].substring(2).trim();
content = lines.slice(1).join('\n').trim(); content = lines.slice(1).join('\n').trim();
} else if (lines.length > 0 && lines[0].trim().length > 0 && lines[0].trim().length < 60) { } else if (
lines.length > 0 &&
lines[0].trim().length > 0 &&
lines[0].trim().length < 60
) {
// First line is short, treat as title if it doesn't look like frontmatter // First line is short, treat as title if it doesn't look like frontmatter
if (lines[0].trim() !== '---') { if (lines[0].trim() !== '---') {
name = lines[0].trim(); name = lines[0].trim();
content = lines.slice(1).join('\n').trim(); content = lines.slice(1).join('\n').trim();
} }
} }
@@ -42,18 +49,28 @@ export async function parse_standard_note(file: File, text: string): Promise<AeJ
const endFrontmatter = lines.indexOf('---', 1); const endFrontmatter = lines.indexOf('---', 1);
if (endFrontmatter > -1) { if (endFrontmatter > -1) {
const frontmatter = lines.slice(1, endFrontmatter); const frontmatter = lines.slice(1, endFrontmatter);
content = lines.slice(endFrontmatter + 1).join('\n').trim(); content = lines
.slice(endFrontmatter + 1)
.join('\n')
.trim();
// Extract tags or title from frontmatter (very basic parsing) // Extract tags or title from frontmatter (very basic parsing)
frontmatter.forEach(line => { frontmatter.forEach((line) => {
if (line.startsWith('title:')) name = line.substring(6).trim().replace(/^['"]|['"]$/g, ''); if (line.startsWith('title:'))
name = line
.substring(6)
.trim()
.replace(/^['"]|['"]$/g, '');
if (line.startsWith('tags:')) { if (line.startsWith('tags:')) {
// This is brittle, assumes inline tags like [a, b] or comma separated // This is brittle, assumes inline tags like [a, b] or comma separated
const tagPart = line.substring(5).trim(); const tagPart = line.substring(5).trim();
if (tagPart.startsWith('[') && tagPart.endsWith(']')) { if (tagPart.startsWith('[') && tagPart.endsWith(']')) {
tagPart.substring(1, tagPart.length - 1).split(',').forEach(t => tags.push(t.trim())); tagPart
.substring(1, tagPart.length - 1)
.split(',')
.forEach((t) => tags.push(t.trim()));
} else { } else {
tagPart.split(',').forEach(t => tags.push(t.trim())); tagPart.split(',').forEach((t) => tags.push(t.trim()));
} }
} }
}); });
@@ -62,22 +79,27 @@ export async function parse_standard_note(file: File, text: string): Promise<AeJ
const lastModified = new Date(file.lastModified).toISOString(); const lastModified = new Date(file.lastModified).toISOString();
return [{ return [
name, {
content, name,
tags, content,
updated_on: lastModified, tags,
created_on: lastModified, // We don't really know creation time from File object usually updated_on: lastModified,
original_filename: file.name, created_on: lastModified, // We don't really know creation time from File object usually
type_code: 'note' original_filename: file.name,
}]; type_code: 'note'
}
];
} }
/** /**
* Personal Log Parser * Personal Log Parser
* - Splits file by dates: `## YYYY-MM-DD` * - Splits file by dates: `## YYYY-MM-DD`
*/ */
export async function parse_personal_log(file: File, text: string): Promise<AeJournalEntryInput[]> { export async function parse_personal_log(
file: File,
text: string
): Promise<AeJournalEntryInput[]> {
const entries: AeJournalEntryInput[] = []; const entries: AeJournalEntryInput[] = [];
const dateRegex = /^##\s+(\d{4}-\d{2}-\d{2})(.*)$/; const dateRegex = /^##\s+(\d{4}-\d{2}-\d{2})(.*)$/;
@@ -86,7 +108,7 @@ export async function parse_personal_log(file: File, text: string): Promise<AeJo
let currentContent: string[] = []; let currentContent: string[] = [];
// Check if the whole file is just one entry (no date headers) // Check if the whole file is just one entry (no date headers)
if (!lines.some(l => dateRegex.test(l))) { if (!lines.some((l) => dateRegex.test(l))) {
return parse_standard_note(file, text); return parse_standard_note(file, text);
} }
@@ -106,12 +128,14 @@ export async function parse_personal_log(file: File, text: string): Promise<AeJo
const extraTitle = match[2].trim(); const extraTitle = match[2].trim();
currentEntry = { currentEntry = {
name: extraTitle ? `${dateStr} - ${extraTitle}` : `${fileBaseName} - ${dateStr}`, name: extraTitle
? `${dateStr} - ${extraTitle}`
: `${fileBaseName} - ${dateStr}`,
created_on: `${dateStr}T12:00:00`, // Noon on that day created_on: `${dateStr}T12:00:00`, // Noon on that day
updated_on: new Date(file.lastModified).toISOString(), updated_on: new Date(file.lastModified).toISOString(),
tags: ['log'], tags: ['log'],
type_code: 'log', type_code: 'log',
original_filename: file.name, original_filename: file.name
// Reconstruct the header as part of content? Or just skip it? // Reconstruct the header as part of content? Or just skip it?
// Python parser added it back: `## {date_str}\n\n{body}` // Python parser added it back: `## {date_str}\n\n{body}`
// Let's add it back for context. // Let's add it back for context.
@@ -141,7 +165,10 @@ export async function parse_personal_log(file: File, text: string): Promise<AeJo
* - Splits by `## Product Name` * - Splits by `## Product Name`
* - Looks for URL and `### Review Title` * - Looks for URL and `### Review Title`
*/ */
export async function parse_amazon_vine(file: File, text: string): Promise<AeJournalEntryInput[]> { export async function parse_amazon_vine(
file: File,
text: string
): Promise<AeJournalEntryInput[]> {
// Split by `\n## ` but we need to keep the delimiter or reconstruct // Split by `\n## ` but we need to keep the delimiter or reconstruct
// JS split doesn't keep delimiter nicely unless captured. // JS split doesn't keep delimiter nicely unless captured.
// Let's iterate lines. // Let's iterate lines.
@@ -155,11 +182,13 @@ export async function parse_amazon_vine(file: File, text: string): Promise<AeJou
for (const line of lines) { for (const line of lines) {
const match = line.match(productHeaderRegex); const match = line.match(productHeaderRegex);
if (match) { if (match) {
if (currentEntry) { if (currentEntry) {
entries.push(format_vine_entry(currentEntry, currentBody, file)); entries.push(
} format_vine_entry(currentEntry, currentBody, file)
currentEntry = { productName: match[1].trim() }; );
currentBody = []; }
currentEntry = { productName: match[1].trim() };
currentBody = [];
} else { } else {
if (currentEntry) { if (currentEntry) {
currentBody.push(line); currentBody.push(line);
@@ -173,7 +202,11 @@ export async function parse_amazon_vine(file: File, text: string): Promise<AeJou
return entries; return entries;
} }
function format_vine_entry(entry: any, bodyLines: string[], file: File): AeJournalEntryInput { function format_vine_entry(
entry: any,
bodyLines: string[],
file: File
): AeJournalEntryInput {
let url = ''; let url = '';
let reviewTitle = ''; let reviewTitle = '';
const cleanBody: string[] = []; const cleanBody: string[] = [];

View File

@@ -38,7 +38,8 @@ const journals_local_data_struct: key_val = {
llm__max_retries: 3, // Number of times to retry a failed LLM API call. llm__max_retries: 3, // Number of times to retry a failed LLM API call.
llm__retry_delay_ms: 2000, // 2 seconds between retries. llm__retry_delay_ms: 2000, // 2 seconds between retries.
llm__system_prompt: 'You are a helpful assistant that helps people find information.', llm__system_prompt:
'You are a helpful assistant that helps people find information.',
llm__max_tokens: 1024, llm__max_tokens: 1024,
llm__temperature: 0.7, llm__temperature: 0.7,
llm__top_p: 1.0, llm__top_p: 1.0,
@@ -57,8 +58,8 @@ const journals_local_data_struct: key_val = {
qry__limit: 25, qry__limit: 25,
qry__offset: 0, qry__offset: 0,
qry__order_by_li: { qry__order_by_li: {
// 'created_on': 'desc', // 'created_on': 'desc',
// 'updated_on': 'desc', // 'updated_on': 'desc',
}, },
type_code_li: [ type_code_li: [

View File

@@ -69,7 +69,9 @@
function scroll_container() { function scroll_container() {
return ( return (
document.getElementById('ae_main_content') || document.documentElement || document.body document.getElementById('ae_main_content') ||
document.documentElement ||
document.body
); );
} }
</script> </script>
@@ -124,7 +126,10 @@
> >
<span class="justify-self-start"> <span class="justify-self-start">
<!-- Be sure to explain what &AElig; (Aether) means in the title text or similar! --> <!-- Be sure to explain what &AElig; (Aether) means in the title text or similar! -->
<Satellite size="1.5em" class="mx-1 inline-block text-gray-500" /> <Satellite
size="1.5em"
class="mx-1 inline-block text-gray-500"
/>
<abbr title="Aether - Journals Module"> Æ Journals </abbr> <abbr title="Aether - Journals Module"> Æ Journals </abbr>
</span> </span>
<a <a
@@ -136,7 +141,8 @@
</a> </a>
<!-- <a href="/about" class="btn btn-sm">About</a> --> <!-- <a href="/about" class="btn btn-sm">About</a> -->
<!-- <a href="/settings" class="btn btn-sm">Settings</a> --> <!-- <a href="/settings" class="btn btn-sm">Settings</a> -->
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
if ($ae_loc.edit_mode) { if ($ae_loc.edit_mode) {
// Confirm before clearing // Confirm before clearing
@@ -249,7 +255,8 @@
" "
> >
<!-- Scroll to top button --> <!-- Scroll to top button -->
<button type="button" <button
type="button"
class=" class="
ae_btn_success_outlined ae_btn_success_outlined
@@ -290,7 +297,8 @@
<!-- Scroll to the right button --> <!-- Scroll to the right button -->
<!-- Temporarily hidden until I figure out a better way to do this --> <!-- Temporarily hidden until I figure out a better way to do this -->
<button type="button" <button
type="button"
class:hidden={1 == 1} class:hidden={1 == 1}
class=" class="
ae_btn_success_outlined ae_btn_success_outlined
@@ -318,7 +326,8 @@
</button> </button>
<!-- Scroll to bottom button --> <!-- Scroll to bottom button -->
<button type="button" <button
type="button"
class=" class="
ae_btn_success_outlined ae_btn_success_outlined
@@ -392,9 +401,12 @@
</footer> </footer>
</div> </div>
{:else} {:else}
<section class="main_content grow px-1 md:px-2 pb-28 flex flex-col gap-1 items-center"> <section
class="main_content grow px-1 md:px-2 pb-28 flex flex-col gap-1 items-center"
>
<p class="text-center"> <p class="text-center">
You are not logged in as a user. You must be signed in to access the journals module. You are not logged in as a user. You must be signed in to access the
journals module.
</p> </p>
</section> </section>
{/if} {/if}

View File

@@ -13,14 +13,18 @@ export async function load({ params, parent }) {
const account_id = parent_data.account_id; const account_id = parent_data.account_id;
if (!account_id) { if (!account_id) {
console.log(`journals +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; return false;
} }
let ae_acct = parent_data[account_id]; let ae_acct = parent_data[account_id];
if (!ae_acct) { if (!ae_acct) {
console.warn(`ae Journals +layout.ts: Account ${account_id} not found in parent data. Initializing ghost acct.`); console.warn(
`ae Journals +layout.ts: Account ${account_id} not found in parent data. Initializing ghost acct.`
);
ae_acct = { ae_acct = {
api: parent_data.ae_api || {}, api: parent_data.ae_api || {},
slct: { slct: {

View File

@@ -9,8 +9,12 @@
// *** Icons // *** Icons
import { import {
BookPlus, SquareLibrary, Wrench, BookPlus,
FileUp, Loader2, Sparkles SquareLibrary,
Wrench,
FileUp,
Loader2,
Sparkles
} from 'lucide-svelte'; } from 'lucide-svelte';
// *** Libraries & Stores // *** Libraries & Stores
@@ -68,7 +72,9 @@
person_id_random: $ae_loc.person_id, person_id_random: $ae_loc.person_id,
name, name,
type_code: type, type_code: type,
cfg_json: { category_li: [{ code: '', name: 'Default' }] } cfg_json: {
category_li: [{ code: '', name: 'Default' }]
}
} }
}); });
if (results?.journal_id_random) { if (results?.journal_id_random) {
@@ -84,20 +90,27 @@
} }
</script> </script>
<div class="page_container flex flex-col gap-8 items-center w-full min-h-screen p-4 md:p-8"> <div
class="page_container flex flex-col gap-8 items-center w-full min-h-screen p-4 md:p-8"
>
<!-- Header Section --> <!-- Header Section -->
<header class="text-center space-y-2 max-w-3xl"> <header class="text-center space-y-2 max-w-3xl">
<h1 class="text-4xl md:text-5xl font-black tracking-tight text-surface-900 dark:text-surface-100"> <h1
class="text-4xl md:text-5xl font-black tracking-tight text-surface-900 dark:text-surface-100"
>
<!-- <div class="p-3 bg-surface-500/10 rounded-2xl"> --> <!-- <div class="p-3 bg-surface-500/10 rounded-2xl"> -->
<SquareLibrary size="1em" class="text-primary-500 inline-block" /> <SquareLibrary size="1em" class="text-primary-500 inline-block" />
<!-- </div> --> <!-- </div> -->
Journals Journals
</h1> </h1>
<p class="text-surface-600 dark:text-surface-400 font-medium"> <p class="text-surface-600 dark:text-surface-400 font-medium">
Managed by <span class="text-primary-500">{$ae_loc.account_name ?? 'Æ loading...'}</span> Managed by <span class="text-primary-500"
>{$ae_loc.account_name ?? 'Æ loading...'}</span
>
{#if $ae_loc.person.given_name} {#if $ae_loc.person.given_name}
&bull; <span class="opacity-75">{$ae_loc.person.given_name}</span> &bull; <span class="opacity-75"
>{$ae_loc.person.given_name}</span
>
{/if} {/if}
</p> </p>
</header> </header>
@@ -105,13 +118,17 @@
<!-- Quick Add Integrated Section --> <!-- Quick Add Integrated Section -->
<section class="w-full max-w-2xl"> <section class="w-full max-w-2xl">
<div class="relative group"> <div class="relative group">
<div class="absolute -inset-1 bg-gradient-to-r from-primary-500 to-secondary-500 rounded-2xl blur opacity-25 group-hover:opacity-50 transition duration-1000 group-hover:duration-200"></div> <div
class="absolute -inset-1 bg-gradient-to-r from-primary-500 to-secondary-500 rounded-2xl blur opacity-25 group-hover:opacity-50 transition duration-1000 group-hover:duration-200"
></div>
<AeCompJournalEntryQuickAdd <AeCompJournalEntryQuickAdd
journals_li={$lq__journal_obj_li} journals_li={$lq__journal_obj_li}
class="relative shadow-2xl rounded-xl overflow-hidden border border-surface-500/10 bg-surface-50 dark:bg-surface-900" class="relative shadow-2xl rounded-xl overflow-hidden border border-surface-500/10 bg-surface-50 dark:bg-surface-900"
/> />
</div> </div>
<div class="mt-2 flex items-center justify-center gap-2 text-xs opacity-50 font-bold uppercase tracking-widest"> <div
class="mt-2 flex items-center justify-center gap-2 text-xs opacity-50 font-bold uppercase tracking-widest"
>
<Sparkles size="1em" /> <Sparkles size="1em" />
<span>Fast Input Mode Active</span> <span>Fast Input Mode Active</span>
</div> </div>
@@ -119,26 +136,33 @@
<!-- Administrative Action Bar (Edit Mode Only) --> <!-- Administrative Action Bar (Edit Mode Only) -->
{#if $ae_loc.edit_mode} {#if $ae_loc.edit_mode}
<nav class="flex flex-row flex-wrap gap-3 items-center justify-center w-full py-4 border-y border-surface-500/10"> <nav
<button type="button" class="flex flex-row flex-wrap gap-3 items-center justify-center w-full py-4 border-y border-surface-500/10"
>
<button
type="button"
class="btn variant-filled-secondary shadow-lg hover:scale-105 transition-transform" class="btn variant-filled-secondary shadow-lg hover:scale-105 transition-transform"
onclick={() => $journals_sess.show__modal_new__journal_obj = true} onclick={() =>
($journals_sess.show__modal_new__journal_obj = true)}
> >
<BookPlus size="1.2em" class="mr-2" /> <BookPlus size="1.2em" class="mr-2" />
<span>New Journal</span> <span>New Journal</span>
</button> </button>
<button type="button" <button
type="button"
class="btn variant-filled-surface border border-surface-500/30 shadow-lg hover:scale-105 transition-transform" class="btn variant-filled-surface border border-surface-500/30 shadow-lg hover:scale-105 transition-transform"
onclick={() => show_import_modal = true} onclick={() => (show_import_modal = true)}
> >
<FileUp size="1.2em" class="mr-2" /> <FileUp size="1.2em" class="mr-2" />
<span>Import</span> <span>Import</span>
</button> </button>
<button type="button" <button
type="button"
class="btn variant-soft-surface shadow-lg hover:scale-105 transition-transform" class="btn variant-soft-surface shadow-lg hover:scale-105 transition-transform"
onclick={() => $journals_sess.show__modal__journals_config = true} onclick={() =>
($journals_sess.show__modal__journals_config = true)}
> >
<Wrench size="1.2em" class="mr-2" /> <Wrench size="1.2em" class="mr-2" />
<span>Config</span> <span>Config</span>
@@ -149,20 +173,29 @@
<!-- Main List Section --> <!-- Main List Section -->
<main class="w-full flex justify-center"> <main class="w-full flex justify-center">
{#if $lq__journal_obj_li === undefined} {#if $lq__journal_obj_li === undefined}
<div class="flex flex-col items-center justify-center p-20 gap-4 opacity-50"> <div
class="flex flex-col items-center justify-center p-20 gap-4 opacity-50"
>
<Loader2 size="3em" class="animate-spin" /> <Loader2 size="3em" class="animate-spin" />
<p class="text-xl font-bold">Accessing Brain...</p> <p class="text-xl font-bold">Accessing Brain...</p>
</div> </div>
{:else if $lq__journal_obj_li.length > 0} {:else if $lq__journal_obj_li.length > 0}
<Journal_obj_li {lq__journal_obj_li} /> <Journal_obj_li {lq__journal_obj_li} />
{:else} {:else}
<div class="max-w-md text-center p-12 bg-surface-500/5 rounded-3xl border-2 border-dashed border-surface-500/20"> <div
class="max-w-md text-center p-12 bg-surface-500/5 rounded-3xl border-2 border-dashed border-surface-500/20"
>
<SquareLibrary size="4em" class="mx-auto mb-4 opacity-20" /> <SquareLibrary size="4em" class="mx-auto mb-4 opacity-20" />
<h3 class="text-2xl font-bold mb-2">No Journals Found</h3> <h3 class="text-2xl font-bold mb-2">No Journals Found</h3>
<p class="opacity-60 mb-6">You haven't created any journals yet. Start by creating one to begin your documentation journey.</p> <p class="opacity-60 mb-6">
<button type="button" You haven't created any journals yet. Start by creating one
to begin your documentation journey.
</p>
<button
type="button"
class="btn variant-filled-primary" class="btn variant-filled-primary"
onclick={() => $journals_sess.show__modal_new__journal_obj = true} onclick={() =>
($journals_sess.show__modal_new__journal_obj = true)}
> >
Create Your First Journal Create Your First Journal
</button> </button>
@@ -182,7 +215,9 @@
> >
<div class="p-2 space-y-4"> <div class="p-2 space-y-4">
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-sm font-bold opacity-75">Journal Name</label> <label class="label text-sm font-bold opacity-75"
>Journal Name</label
>
<input <input
type="text" type="text"
placeholder="e.g. My Daily Logs" placeholder="e.g. My Daily Logs"
@@ -191,7 +226,9 @@
/> />
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-sm font-bold opacity-75">Type Code</label> <label class="label text-sm font-bold opacity-75"
>Type Code</label
>
<input <input
type="text" type="text"
placeholder="e.g. diary, log, notebook" placeholder="e.g. diary, log, notebook"
@@ -200,15 +237,27 @@
/> />
</div> </div>
<div class="flex justify-end gap-2 pt-4"> <div class="flex justify-end gap-2 pt-4">
<button type="button" class="btn variant-soft-surface" onclick={() => $journals_sess.show__modal_new__journal_obj = false}>Cancel</button> <button
<button type="button" class="btn variant-filled-primary font-bold" onclick={create_journal}>Create Journal</button> type="button"
class="btn variant-soft-surface"
onclick={() =>
($journals_sess.show__modal_new__journal_obj = false)}
>Cancel</button
>
<button
type="button"
class="btn variant-filled-primary font-bold"
onclick={create_journal}>Create Journal</button
>
</div> </div>
</div> </div>
</Modal> </Modal>
{/if} {/if}
{#if $journals_sess.show__modal__journals_config} {#if $journals_sess.show__modal__journals_config}
<AeCompModalJournalConfig show={$journals_sess.show__modal__journals_config} /> <AeCompModalJournalConfig
show={$journals_sess.show__modal__journals_config}
/>
{/if} {/if}
<AeCompModalJournalImport <AeCompModalJournalImport

View File

@@ -14,7 +14,9 @@ export async function load({ fetch, parent }) {
let ae_acct = parent_data[account_id]; let ae_acct = parent_data[account_id];
if (!ae_acct) { if (!ae_acct) {
console.warn(`ae Journals +page.ts: Account ${account_id} not found in parent data. Initializing ghost acct.`); console.warn(
`ae Journals +page.ts: Account ${account_id} not found in parent data. Initializing ghost acct.`
);
ae_acct = { ae_acct = {
api: parent_data.ae_api || {}, api: parent_data.ae_api || {},
loc: {}, loc: {},

View File

@@ -35,11 +35,16 @@
let lq__journal_obj = $derived( let lq__journal_obj = $derived(
liveQuery(async () => { liveQuery(async () => {
let results = await db_journals.journal.get($journals_slct?.journal_id ?? ''); // null or undefined does not reset things like '' does let results = await db_journals.journal.get(
$journals_slct?.journal_id ?? ''
); // null or undefined does not reset things like '' does
// Check if results are different than the current session version stored under $journals_slct // Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_obj && results) { if ($journals_slct.journal_obj && results) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(results)) { if (
JSON.stringify($journals_slct.journal_obj) !==
JSON.stringify(results)
) {
$journals_slct.journal_obj = { ...results }; $journals_slct.journal_obj = { ...results };
} }
} }
@@ -50,11 +55,14 @@
$effect(() => { $effect(() => {
if (log_lvl) { if (log_lvl) {
console.log(`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`); console.log(
`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`
);
console.log(`lq__journal_obj: results = `, lq__journal_obj); console.log(`lq__journal_obj: results = `, lq__journal_obj);
if ($journals_slct.journal_obj && lq__journal_obj) { if ($journals_slct.journal_obj && lq__journal_obj) {
if ( if (
JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(lq__journal_obj) JSON.stringify($journals_slct.journal_obj) !==
JSON.stringify(lq__journal_obj)
) { ) {
console.log( console.log(
`Session slct stored version has changed for ID = ${$journals_slct.journal_id}`, `Session slct stored version has changed for ID = ${$journals_slct.journal_id}`,
@@ -99,7 +107,8 @@
" "
> >
<!-- If middle click then open the all journals page in a new tab. Otherwise show/hide the menu. --> <!-- If middle click then open the all journals page in a new tab. Otherwise show/hide the menu. -->
<button type="button" <button
type="button"
onmousedown={(event) => { onmousedown={(event) => {
if (event.button === 1) { if (event.button === 1) {
// Middle click - open in new tab // Middle click - open in new tab
@@ -107,7 +116,7 @@
window.open('/journals'); window.open('/journals');
// } else { // } else {
// // Left click - toggle menu // // Left click - toggle menu
// event.preventDefault(); // Prevent default middle-click behavior // event.prevent_default(); // Prevent default middle-click behavior
// show_menu__all_journals = !show_menu__all_journals; // show_menu__all_journals = !show_menu__all_journals;
} }
}} }}
@@ -191,13 +200,15 @@ Middle-click to open in new tab`}
" "
> >
<option value="" disabled selected> <option value="" disabled selected>
{Object.keys($journals_loc.entry_view_history_kv).length}&times; Recent {Object.keys($journals_loc.entry_view_history_kv)
Entries... .length}&times; Recent Entries...
</option> </option>
<!-- loop through each key value --> <!-- loop through each key value -->
{#each Object.entries($journals_loc.entry_view_history_kv as Record<string, ae_JournalEntry>).reverse() as [journal_entry_id, journal_entry_obj]} {#each Object.entries($journals_loc.entry_view_history_kv as Record).reverse() as [journal_entry_id, journal_entry_obj]}
<option value={journal_entry_obj.id}> <option value={journal_entry_obj.id}>
{(journal_entry_obj?.name || journal_entry_obj?.id) ?? 'NONE'} {(journal_entry_obj?.name ||
journal_entry_obj?.id) ??
'NONE'}
</option> </option>
{/each} {/each}
</select> </select>
@@ -237,7 +248,8 @@ Middle-click to open in new tab`}
<!-- <span class="text-sm text-gray-500 hidden md:inline"> <!-- <span class="text-sm text-gray-500 hidden md:inline">
New entry: New entry:
</span> --> </span> -->
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
// $journals_sess.show__modal_new__journal_entry_obj = true; // $journals_sess.show__modal_new__journal_entry_obj = true;
@@ -245,10 +257,14 @@ Middle-click to open in new tab`}
category_code: null category_code: null
}; };
if ($journals_loc.entry.qry__category_code) { if ($journals_loc.entry.qry__category_code) {
data_kv.category_code = $journals_loc.entry.qry__category_code; data_kv.category_code =
$journals_loc.entry.qry__category_code;
} }
if (log_lvl) { if (log_lvl) {
console.log('Creating new journal entry with data_kv:', data_kv); console.log(
'Creating new journal entry with data_kv:',
data_kv
);
} }
journals_func journals_func
.create_ae_obj__journal_entry({ .create_ae_obj__journal_entry({
@@ -259,16 +275,24 @@ Middle-click to open in new tab`}
}) })
.then((results) => { .then((results) => {
if (log_lvl) { if (log_lvl) {
console.log('New journal entry created:', results); console.log(
'New journal entry created:',
results
);
} }
$journals_slct.journal_entry_id = results?.journal_entry_id_random; $journals_slct.journal_entry_id =
results?.journal_entry_id_random;
// $journals_loc.entry.edit = true; // $journals_loc.entry.edit = true;
$journals_loc.entry.edit_kv[$journals_slct.journal_entry_id] = $journals_loc.entry.edit_kv[
'current'; $journals_slct.journal_entry_id
] = 'current';
// alert(`Journal entry created successfully! ${$journals_slct.journal_entry_id}`); // alert(`Journal entry created successfully! ${$journals_slct.journal_entry_id}`);
}) })
.catch((error) => { .catch((error) => {
console.error('Error updating journal entry:', error); console.error(
'Error updating journal entry:',
error
);
alert('Failed to update journal entry.'); alert('Failed to update journal entry.');
}) })
.finally(() => { .finally(() => {
@@ -299,6 +323,6 @@ Middle-click to open in new tab`}
</div> </div>
<div class="overflow-auto"> <div class="overflow-auto">
{@render children?.()} {@render children?.()}
</div> </div>
</section> </section>

View File

@@ -15,7 +15,9 @@ export async function load({ params, parent }) {
let ae_acct = data[account_id]; let ae_acct = data[account_id];
if (!ae_acct) { if (!ae_acct) {
console.warn(`ae Journals [journal_id] +layout.ts: Account ${account_id} not found. Initializing ghost acct.`); console.warn(
`ae Journals [journal_id] +layout.ts: Account ${account_id} not found. Initializing ghost acct.`
);
ae_acct = { ae_acct = {
api: data.ae_api || {}, api: data.ae_api || {},
slct: { slct: {
@@ -36,7 +38,10 @@ export async function load({ params, parent }) {
ae_acct.slct.journal_id = journal_id; ae_acct.slct.journal_id = journal_id;
if (browser) { if (browser) {
if (log_lvl) console.log(`ae_journals journals [journal_id] +layout.ts (Non-Blocking)`); if (log_lvl)
console.log(
`ae_journals journals [journal_id] +layout.ts (Non-Blocking)`
);
// OPTIMIZATION: Fire the journal load in the background. // OPTIMIZATION: Fire the journal load in the background.
// The journal module now uses SWR, and components watching IDB // The journal module now uses SWR, and components watching IDB

View File

@@ -54,7 +54,8 @@
function handle_import_complete() { function handle_import_complete() {
// Trigger a refresh of the journal entry list // Trigger a refresh of the journal entry list
if ($journals_loc.entry.search_version === undefined) $journals_loc.entry.search_version = 0; if ($journals_loc.entry.search_version === undefined)
$journals_loc.entry.search_version = 0;
$journals_loc.entry.search_version++; $journals_loc.entry.search_version++;
} }
@@ -63,7 +64,9 @@
let lq__journal_obj = $derived( let lq__journal_obj = $derived(
liveQuery(async () => { liveQuery(async () => {
return await db_journals.journal.get($journals_slct?.journal_id ?? ''); return await db_journals.journal.get(
$journals_slct?.journal_id ?? ''
);
}) })
); );
@@ -79,14 +82,18 @@
// SCENARIO 1: Specific IDs provided (Search Results) // SCENARIO 1: Specific IDs provided (Search Results)
if (Array.isArray(ids) && ids.length > 0) { if (Array.isArray(ids) && ids.length > 0) {
if (log_lvl) console.log(`Journal Page LQ: bulkGet ${ids.length} IDs`); if (log_lvl)
console.log(`Journal Page LQ: bulkGet ${ids.length} IDs`);
const results = await db_journals.journal_entry.bulkGet(ids); const results = await db_journals.journal_entry.bulkGet(ids);
return results.filter(item => item !== undefined); return results.filter((item) => item !== undefined);
} }
// SCENARIO 2: Fallback to broad search (Default view) // SCENARIO 2: Fallback to broad search (Default view)
if (journal_id && !search_text && !cat_code) { if (journal_id && !search_text && !cat_code) {
if (log_lvl) console.log(`Journal Page LQ: Fallback search for journal: ${journal_id}`); if (log_lvl)
console.log(
`Journal Page LQ: Fallback search for journal: ${journal_id}`
);
return await db_journals.journal_entry return await db_journals.journal_entry
.where('journal_id') .where('journal_id')
.equals(journal_id) .equals(journal_id)
@@ -140,7 +147,10 @@
const journal_id = params.journal_id; const journal_id = params.journal_id;
const remote_first = params.remote_first; const remote_first = params.remote_first;
if (log_lvl) console.log(`[Journal Search #${current_search_id}] Refreshing entries (remote=${remote_first}, journal=${journal_id})...`); if (log_lvl)
console.log(
`[Journal Search #${current_search_id}] Refreshing entries (remote=${remote_first}, journal=${journal_id})...`
);
// 2. Setup State // 2. Setup State
untrack(() => { untrack(() => {
@@ -160,30 +170,46 @@
let local_results = await db_journals.journal_entry let local_results = await db_journals.journal_entry
.where('journal_id') .where('journal_id')
.equals(journal_id) .equals(journal_id)
.filter(entry => { .filter((entry) => {
if (cat_code && entry.category_code !== cat_code) return false; if (cat_code && entry.category_code !== cat_code)
return false;
if (qry_str) { if (qry_str) {
const name = (entry.name ?? '').toLowerCase(); const name = (entry.name ?? '').toLowerCase();
const content = (entry.content ?? '').toLowerCase(); const content = (
return name.includes(qry_str) || content.includes(qry_str); entry.content ?? ''
).toLowerCase();
return (
name.includes(qry_str) ||
content.includes(qry_str)
);
} }
return true; return true;
}) })
.toArray(); .toArray();
local_results.sort((a, b) => { local_results.sort((a, b) => {
const dateA = a.updated_on ? new Date(a.updated_on).getTime() : 0; const dateA = a.updated_on
const dateB = b.updated_on ? new Date(b.updated_on).getTime() : 0; ? new Date(a.updated_on).getTime()
: 0;
const dateB = b.updated_on
? new Date(b.updated_on).getTime()
: 0;
return dateB - dateA; return dateB - dateA;
}); });
local_ids = local_results.map(e => e.id || e.journal_entry_id_random).filter(Boolean); local_ids = local_results
.map((e) => e.id || e.journal_entry_id_random)
.filter(Boolean);
if (current_search_id === last_search_id) { if (current_search_id === last_search_id) {
if (log_lvl) console.log(`[Journal Search #${current_search_id}] Fast Path found ${local_ids.length} items locally.`); if (log_lvl)
console.log(
`[Journal Search #${current_search_id}] Fast Path found ${local_ids.length} items locally.`
);
untrack(() => { untrack(() => {
search_id_li = local_ids; search_id_li = local_ids;
if (local_ids.length > 0) $journals_sess.entry.qry__status = 'done'; if (local_ids.length > 0)
$journals_sess.entry.qry__status = 'done';
}); });
} }
} }
@@ -208,10 +234,17 @@
if (current_search_id === last_search_id) { if (current_search_id === last_search_id) {
const api_results = results || []; const api_results = results || [];
const api_ids = api_results.map((e: any) => e.id || e.journal_entry_id_random).filter(Boolean); const api_ids = api_results
.map((e: any) => e.id || e.journal_entry_id_random)
.filter(Boolean);
// Protect UI cache if API returns empty during revalidation // Protect UI cache if API returns empty during revalidation
if (api_ids.length === 0 && local_ids.length > 0 && !remote_first && !qry_str) { if (
api_ids.length === 0 &&
local_ids.length > 0 &&
!remote_first &&
!qry_str
) {
untrack(() => { untrack(() => {
$journals_sess.entry.qry__status = 'done'; $journals_sess.entry.qry__status = 'done';
}); });
@@ -223,7 +256,10 @@
search_id_li = api_ids; search_id_li = api_ids;
$journals_sess.entry.qry__status = 'done'; $journals_sess.entry.qry__status = 'done';
}); });
if (log_lvl) console.log(`[Journal Search #${current_search_id}] Revalidation Complete. Found ${api_ids.length} items.`); if (log_lvl)
console.log(
`[Journal Search #${current_search_id}] Revalidation Complete. Found ${api_ids.length} items.`
);
} }
} catch (error) { } catch (error) {
if (current_search_id === last_search_id) { if (current_search_id === last_search_id) {
@@ -239,7 +275,10 @@
} }
if (browser) { if (browser) {
window.parent.postMessage({ journal_id: $journals_slct?.journal_id ?? null }, '*'); window.parent.postMessage(
{ journal_id: $journals_slct?.journal_id ?? null },
'*'
);
} }
import { LoaderCircle } from 'lucide-svelte'; import { LoaderCircle } from 'lucide-svelte';
@@ -252,7 +291,9 @@
</svelte:head> </svelte:head>
{#if $lq__journal_obj === undefined} {#if $lq__journal_obj === undefined}
<div class="flex flex-col items-center justify-center p-20 opacity-50 text-center"> <div
class="flex flex-col items-center justify-center p-20 opacity-50 text-center"
>
<LoaderCircle size="3em" class="animate-spin mb-4 mx-auto" /> <LoaderCircle size="3em" class="animate-spin mb-4 mx-auto" />
<p class="text-xl">Loading Journal...</p> <p class="text-xl">Loading Journal...</p>
</div> </div>
@@ -260,8 +301,8 @@
<AeCompJournalObjIdView <AeCompJournalObjIdView
{lq__journal_obj} {lq__journal_obj}
{lq__journal_entry_obj_li} {lq__journal_entry_obj_li}
on_show_export={() => show_export_modal = true} on_show_export={() => (show_export_modal = true)}
on_show_import={() => show_import_modal = true} on_show_import={() => (show_import_modal = true)}
/> />
<Journal_entry_obj_li_wrapper <Journal_entry_obj_li_wrapper
@@ -286,11 +327,15 @@
<AeCompModalJournalImport <AeCompModalJournalImport
bind:open={show_import_modal} bind:open={show_import_modal}
on_close={() => show_import_modal = false} on_close={() => (show_import_modal = false)}
on_import_complete={handle_import_complete} on_import_complete={handle_import_complete}
/> />
{:else} {:else}
<section class="main_content grow px-1 md:px-2 pb-28 flex flex-col gap-1 items-center"> <section
<p class="text-center">You must be logged in as the owner to view this Journal.</p> class="main_content grow px-1 md:px-2 pb-28 flex flex-col gap-1 items-center"
>
<p class="text-center">
You must be logged in as the owner to view this Journal.
</p>
</section> </section>
{/if} {/if}

View File

@@ -59,11 +59,16 @@
$journals_slct.journal_id = ae_acct.slct.journal_id; $journals_slct.journal_id = ae_acct.slct.journal_id;
let lq__journal_obj = $derived( let lq__journal_obj = $derived(
liveQuery(async () => { liveQuery(async () => {
let results = await db_journals.journal.get($journals_slct?.journal_id ?? ''); // null or undefined does not reset things like '' does let results = await db_journals.journal.get(
$journals_slct?.journal_id ?? ''
); // null or undefined does not reset things like '' does
// Check if results are different than the current session version stored under $journals_slct // Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_obj && results) { if ($journals_slct.journal_obj && results) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(results)) { if (
JSON.stringify($journals_slct.journal_obj) !==
JSON.stringify(results)
) {
$journals_slct.journal_obj = { ...results }; $journals_slct.journal_obj = { ...results };
} }
} }
@@ -74,11 +79,14 @@
$effect(() => { $effect(() => {
if (log_lvl) { if (log_lvl) {
console.log(`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`); console.log(
`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`
);
console.log(`lq__journal_obj: results = `, lq__journal_obj); console.log(`lq__journal_obj: results = `, lq__journal_obj);
if ($journals_slct.journal_obj && lq__journal_obj) { if ($journals_slct.journal_obj && lq__journal_obj) {
if ( if (
JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(lq__journal_obj) JSON.stringify($journals_slct.journal_obj) !==
JSON.stringify(lq__journal_obj)
) { ) {
console.log( console.log(
`Session slct stored version has changed for ID = ${$journals_slct.journal_id}`, `Session slct stored version has changed for ID = ${$journals_slct.journal_id}`,
@@ -104,7 +112,8 @@
// Check if results are different than the current session version stored under $journals_slct // Check if results are different than the current session version stored under $journals_slct
if ( if (
$journals_slct.journal_obj_li && $journals_slct.journal_obj_li &&
JSON.stringify($journals_slct.journal_obj_li) !== JSON.stringify(results) JSON.stringify($journals_slct.journal_obj_li) !==
JSON.stringify(results)
) { ) {
$journals_slct.journal_obj_li = [...results]; $journals_slct.journal_obj_li = [...results];
} }
@@ -119,7 +128,8 @@
console.log(`lq__journal_obj_li: results = `, lq__journal_obj_li); console.log(`lq__journal_obj_li: results = `, lq__journal_obj_li);
if ( if (
$journals_slct.journal_obj_li && $journals_slct.journal_obj_li &&
JSON.stringify($journals_slct.journal_obj_li) !== JSON.stringify(lq__journal_obj_li) JSON.stringify($journals_slct.journal_obj_li) !==
JSON.stringify(lq__journal_obj_li)
) { ) {
console.log( console.log(
`Session slct li stored version has changed for ID = ${$ae_loc.person_id}`, `Session slct li stored version has changed for ID = ${$ae_loc.person_id}`,
@@ -147,7 +157,10 @@
// Check if results are different than the current session version stored under $journals_slct // Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_entry_obj && results) { if ($journals_slct.journal_entry_obj && results) {
if (JSON.stringify($journals_slct.journal_entry_obj) !== JSON.stringify(results)) { if (
JSON.stringify($journals_slct.journal_entry_obj) !==
JSON.stringify(results)
) {
$journals_slct.journal_entry_obj = { ...results }; $journals_slct.journal_entry_obj = { ...results };
} }
} }
@@ -161,7 +174,10 @@
console.log( console.log(
`lq__journal_entry_obj: journal_entry_id = ${$journals_slct?.journal_entry_id}` `lq__journal_entry_obj: journal_entry_id = ${$journals_slct?.journal_entry_id}`
); );
console.log(`lq__journal_entry_obj: results = `, lq__journal_entry_obj); console.log(
`lq__journal_entry_obj: results = `,
lq__journal_entry_obj
);
if ($journals_slct.journal_entry_obj && lq__journal_entry_obj) { if ($journals_slct.journal_entry_obj && lq__journal_entry_obj) {
if ( if (
JSON.stringify($journals_slct.journal_entry_obj) !== JSON.stringify($journals_slct.journal_entry_obj) !==
@@ -180,11 +196,12 @@
} }
}); });
$effect(() => { $effect(() => {
if (browser && $lq__journal_entry_obj?.journal_entry_id) { if (browser && $lq__journal_entry_obj?.journal_entry_id) {
// Start with the current KV or convert the LI to a KV if needed // Start with the current KV or convert the LI to a KV if needed
let history_kv = { ...($journals_loc?.entry_view_history_kv ?? {}) }; let history_kv = {
...($journals_loc?.entry_view_history_kv ?? {})
};
// Add or update the current entry // Add or update the current entry
const entry_id = $lq__journal_entry_obj?.journal_entry_id ?? 'NONE'; const entry_id = $lq__journal_entry_obj?.journal_entry_id ?? 'NONE';
@@ -220,7 +237,8 @@
// Only update if changed // Only update if changed
if ( if (
JSON.stringify(history_kv) !== JSON.stringify($journals_loc?.entry_view_history_kv) JSON.stringify(history_kv) !==
JSON.stringify($journals_loc?.entry_view_history_kv)
) { ) {
$journals_loc.entry_view_history_kv = history_kv; $journals_loc.entry_view_history_kv = history_kv;
console.log( console.log(
@@ -229,7 +247,9 @@
); );
} else { } else {
if (log_lvl > 1) { if (log_lvl > 1) {
console.log(`$journals_loc.entry_view_history_kv has not changed.`); console.log(
`$journals_loc.entry_view_history_kv has not changed.`
);
} }
} }
@@ -261,7 +281,12 @@
" "
> >
<!-- {#if $lq__journal_entry_obj} --> <!-- {#if $lq__journal_entry_obj} -->
<Journal_entry_view {lq__journal_obj} {lq__journal_obj_li} {lq__journal_entry_obj} on_show_export={() => show_export_modal = true} /> <Journal_entry_view
{lq__journal_obj}
{lq__journal_obj_li}
{lq__journal_entry_obj}
on_show_export={() => (show_export_modal = true)}
/>
<!-- {/if} --> <!-- {/if} -->
</section> </section>
@@ -269,10 +294,14 @@
bind:open={show_export_modal} bind:open={show_export_modal}
entries={$lq__journal_entry_obj ? [$lq__journal_entry_obj] : []} entries={$lq__journal_entry_obj ? [$lq__journal_entry_obj] : []}
journal={$lq__journal_obj} journal={$lq__journal_obj}
on_close={() => show_export_modal = false} on_close={() => (show_export_modal = false)}
/> />
{:else} {:else}
<section class="main_content grow px-1 md:px-2 pb-28 flex flex-col gap-1 items-center"> <section
<p class="text-center">You must be logged in as the owner to view this Journal Entry.</p> class="main_content grow px-1 md:px-2 pb-28 flex flex-col gap-1 items-center"
>
<p class="text-center">
You must be logged in as the owner to view this Journal Entry.
</p>
</section> </section>
{/if} {/if}

View File

@@ -4,7 +4,10 @@ console.log(`ae_p_journals [journal_entry_id] +page.ts start`);
import { browser } from '$app/environment'; import { browser } from '$app/environment';
import { journals_func } from '$lib/ae_journals/ae_journals_functions'; import { journals_func } from '$lib/ae_journals/ae_journals_functions';
import { db_journals, journal_entry_field_li } from '$lib/ae_journals/db_journals'; import {
db_journals,
journal_entry_field_li
} from '$lib/ae_journals/db_journals';
import { load_ae_obj_id } from '$lib/ae_core/core__crud_generic'; import { load_ae_obj_id } from '$lib/ae_core/core__crud_generic';
export async function load({ params, parent }) { export async function load({ params, parent }) {
@@ -18,7 +21,9 @@ export async function load({ params, parent }) {
let ae_acct = data[account_id]; let ae_acct = data[account_id];
if (!ae_acct) { if (!ae_acct) {
console.warn(`ae Journals [journal_entry_id] +page.ts: Account ${account_id} not found. Initializing ghost acct.`); console.warn(
`ae Journals [journal_entry_id] +page.ts: Account ${account_id} not found. Initializing ghost acct.`
);
ae_acct = { ae_acct = {
api: data.ae_api || {}, api: data.ae_api || {},
slct: { slct: {
@@ -72,7 +77,9 @@ export async function load({ params, parent }) {
}); });
if (!load_journal_entry_obj) { if (!load_journal_entry_obj) {
console.warn(`ae Journals [journal_entry_id] +page.ts: Entry ${journal_entry_id} not found via API or Cache.`); console.warn(
`ae Journals [journal_entry_id] +page.ts: Entry ${journal_entry_id} not found via API or Cache.`
);
// error(404, { // error(404, {
// message: 'Journals - Journal Entry not found' // message: 'Journals - Journal Entry not found'
// }); // });

View File

@@ -24,7 +24,7 @@
<div class="journal-entry-ai-tools absolute top-2 right-2 z-10"> <div class="journal-entry-ai-tools absolute top-2 right-2 z-10">
<AE_AITools <AE_AITools
{content} {content}
bind:summary={summary} bind:summary
onSave={(newSummary) => { onSave={(newSummary) => {
summary = newSummary; summary = newSummary;
on_save(); on_save();

View File

@@ -6,7 +6,10 @@
*/ */
import { LockKeyhole, Save, RefreshCcw } from 'lucide-svelte'; import { LockKeyhole, Save, RefreshCcw } from 'lucide-svelte';
import { ae_loc } from '$lib/stores/ae_stores'; import { ae_loc } from '$lib/stores/ae_stores';
import { journals_loc, journals_sess } from '$lib/ae_journals/ae_journals_stores'; import {
journals_loc,
journals_sess
} from '$lib/ae_journals/ae_journals_stores';
import AE_Comp_Editor_CodeMirror from '$lib/elements/AE_Comp_Editor_CodeMirror.svelte'; import AE_Comp_Editor_CodeMirror from '$lib/elements/AE_Comp_Editor_CodeMirror.svelte';
import type { ae_JournalEntry, ae_Journal } from '$lib/types/ae_types'; import type { ae_JournalEntry, ae_Journal } from '$lib/types/ae_types';
@@ -32,10 +35,14 @@
on_force_reset on_force_reset
}: Props = $props(); }: Props = $props();
const is_editing = $derived($journals_loc.entry.edit_kv[entry.journal_entry_id] === 'current'); const is_editing = $derived(
$journals_loc.entry.edit_kv[entry.journal_entry_id] === 'current'
);
</script> </script>
<div class="journal-entry-editor-wrapper grow w-full flex flex-col items-center"> <div
class="journal-entry-editor-wrapper grow w-full flex flex-col items-center"
>
{#if !is_editing} {#if !is_editing}
<!-- VIEW MODE --> <!-- VIEW MODE -->
<div class="w-full max-w-6xl p-4 prose dark:prose-invert"> <div class="w-full max-w-6xl p-4 prose dark:prose-invert">
@@ -45,27 +52,40 @@
<!-- EDIT MODE --> <!-- EDIT MODE -->
{#if !tmp_entry_obj?.content && tmp_entry_obj?.content_encrypted} {#if !tmp_entry_obj?.content && tmp_entry_obj?.content_encrypted}
<!-- Decryption Required Message --> <!-- Decryption Required Message -->
<div class="w-full max-w-6xl p-4 bg-error-100 dark:bg-error-900/30 text-error-900 dark:text-error-100 rounded-lg border border-error-500 flex flex-col gap-4"> <div
class="w-full max-w-6xl p-4 bg-error-100 dark:bg-error-900/30 text-error-900 dark:text-error-100 rounded-lg border border-error-500 flex flex-col gap-4"
>
<div class="space-y-2"> <div class="space-y-2">
<div class="font-bold flex items-center gap-2"> <div class="font-bold flex items-center gap-2">
<LockKeyhole size="1.25em" /> <LockKeyhole size="1.25em" />
Decryption Required Decryption Required
</div> </div>
<p class="text-sm">This entry must be decrypted before it can be edited.</p> <p class="text-sm">
This entry must be decrypted before it can be edited.
</p>
{#if tmp_entry_obj?.content === false} {#if tmp_entry_obj?.content === false}
<p class="text-xs font-bold text-error-500 uppercase tracking-widest">Decryption failed. Incorrect passcode.</p> <p
class="text-xs font-bold text-error-500 uppercase tracking-widest"
>
Decryption failed. Incorrect passcode.
</p>
{/if} {/if}
</div> </div>
{#if $ae_loc.edit_mode && on_force_reset} {#if $ae_loc.edit_mode && on_force_reset}
<div class="pt-4 border-t border-error-500/20"> <div class="pt-4 border-t border-error-500/20">
<p class="text-xs mb-2 opacity-70 italic">Passcode lost? You can force a reset to plain text, but all currently encrypted data will be permanently deleted.</p> <p class="text-xs mb-2 opacity-70 italic">
<button type="button" Passcode lost? You can force a reset to plain text,
but all currently encrypted data will be permanently
deleted.
</p>
<button
type="button"
class="btn btn-sm variant-filled-error font-bold" class="btn btn-sm variant-filled-error font-bold"
onclick={on_force_reset} onclick={on_force_reset}
> >
<RefreshCcw size="1.1em" class="mr-2" /> Force Reset to Plain Text <RefreshCcw size="1.1em" class="mr-2" /> Force Reset to
Plain Text
</button> </button>
</div> </div>
{/if} {/if}
@@ -75,7 +95,7 @@
{#if journal?.cfg_json?.pref_editor == 'codemirror'} {#if journal?.cfg_json?.pref_editor == 'codemirror'}
<AE_Comp_Editor_CodeMirror <AE_Comp_Editor_CodeMirror
bind:content={tmp_entry_obj.content} bind:content={tmp_entry_obj.content}
bind:editor_view={editor_view} bind:editor_view
theme_mode={$ae_loc.theme_mode} theme_mode={$ae_loc.theme_mode}
placeholder="Write using Markdown..." placeholder="Write using Markdown..."
class_li="p-2 preset-outlined-warning-300-700 shadow-lg rounded-lg w-full max-w-6xl bg-surface-50 dark:bg-surface-800" class_li="p-2 preset-outlined-warning-300-700 shadow-lg rounded-lg w-full max-w-6xl bg-surface-50 dark:bg-surface-800"
@@ -89,7 +109,8 @@
{/if} {/if}
<!-- Floating Save Button --> <!-- Floating Save Button -->
<button type="button" <button
type="button"
onclick={on_save} onclick={on_save}
disabled={!has_changed} disabled={!has_changed}
class="btn btn-sm md:btn-md lg:btn-lg fixed top-72 right-6 min-w-32 variant-filled-success shadow-xl z-20 transition-all" class="btn btn-sm md:btn-md lg:btn-lg fixed top-72 right-6 min-w-32 variant-filled-success shadow-xl z-20 transition-all"
@@ -99,7 +120,8 @@
</button> </button>
<!-- Inline Save Button (Mobile/Context) --> <!-- Inline Save Button (Mobile/Context) -->
<button type="button" <button
type="button"
onclick={on_save} onclick={on_save}
disabled={!has_changed} disabled={!has_changed}
class="btn variant-filled-warning w-full max-w-96 mt-4" class="btn variant-filled-warning w-full max-w-96 mt-4"
@@ -109,7 +131,9 @@
</button> </button>
{#if updated_idb} {#if updated_idb}
<p class="text-xs text-error-500 mt-2 font-bold animate-pulse uppercase tracking-widest"> <p
class="text-xs text-error-500 mt-2 font-bold animate-pulse uppercase tracking-widest"
>
IDB object updated since last load! IDB object updated since last load!
</p> </p>
{/if} {/if}

View File

@@ -5,12 +5,24 @@
* Manages name, sync status, and triggers the modular config. * Manages name, sync status, and triggers the modular config.
*/ */
import { import {
Save, Eye, Pencil, Save,
Fingerprint, LockKeyhole, LockKeyholeOpen, Settings, Eye,
ChevronLeft, CircleCheck, CircleX, Loader2, RefreshCw Pencil,
Fingerprint,
LockKeyhole,
LockKeyholeOpen,
Settings,
ChevronLeft,
CircleCheck,
CircleX,
Loader2,
RefreshCw
} from 'lucide-svelte'; } from 'lucide-svelte';
import { ae_util } from '$lib/ae_utils/ae_utils'; import { ae_util } from '$lib/ae_utils/ae_utils';
import { journals_loc, journals_sess } from '$lib/ae_journals/ae_journals_stores'; import {
journals_loc,
journals_sess
} from '$lib/ae_journals/ae_journals_stores';
import type { ae_JournalEntry, ae_Journal } from '$lib/types/ae_types'; import type { ae_JournalEntry, ae_Journal } from '$lib/types/ae_types';
interface Props { interface Props {
@@ -38,10 +50,14 @@
log_lvl = 0 log_lvl = 0
}: Props = $props(); }: Props = $props();
const is_decrypted = $derived($journals_sess?.journal_kv[journal?.id]?.journal_passcode_decrypted === true); const is_decrypted = $derived(
$journals_sess?.journal_kv[journal?.id]?.journal_passcode_decrypted ===
true
);
function toggle_edit_mode() { function toggle_edit_mode() {
const isEditing = $journals_loc.entry.edit_kv[entry.journal_entry_id] === 'current'; const isEditing =
$journals_loc.entry.edit_kv[entry.journal_entry_id] === 'current';
if (isEditing) { if (isEditing) {
if (has_changed) on_save(); if (has_changed) on_save();
else $journals_loc.entry.edit_kv[entry.journal_entry_id] = false; else $journals_loc.entry.edit_kv[entry.journal_entry_id] = false;
@@ -51,19 +67,32 @@
} }
</script> </script>
<header class="flex flex-col md:flex-row items-center justify-between gap-4 p-3 bg-surface-100/50 dark:bg-surface-900/50 rounded-xl border border-surface-500/20 backdrop-blur-md shadow-sm w-full"> <header
class="flex flex-col md:flex-row items-center justify-between gap-4 p-3 bg-surface-100/50 dark:bg-surface-900/50 rounded-xl border border-surface-500/20 backdrop-blur-md shadow-sm w-full"
>
<div class="flex items-center gap-3 w-full md:w-auto"> <div class="flex items-center gap-3 w-full md:w-auto">
<a href="/journals/{journal.journal_id}" class="btn-icon btn-icon-sm variant-soft-surface" title="Back to Journal"> <a
href="/journals/{journal.journal_id}"
class="btn-icon btn-icon-sm variant-soft-surface"
title="Back to Journal"
>
<ChevronLeft size="1.2em" /> <ChevronLeft size="1.2em" />
</a> </a>
<div class="flex items-center gap-2 grow"> <div class="flex items-center gap-2 grow">
<button type="button" <button
type="button"
onclick={toggle_edit_mode} onclick={toggle_edit_mode}
class="btn-icon btn-icon-sm transition-all {has_changed && $journals_loc.entry.edit_kv[entry.journal_entry_id] === 'current' ? 'variant-filled-success' : 'variant-soft-surface'}" class="btn-icon btn-icon-sm transition-all {has_changed &&
$journals_loc.entry.edit_kv[entry.journal_entry_id] ===
'current'
? 'variant-filled-success'
: 'variant-soft-surface'}"
> >
{#if $journals_loc.entry.edit_kv[entry.journal_entry_id] === 'current'} {#if $journals_loc.entry.edit_kv[entry.journal_entry_id] === 'current'}
{#if has_changed}<Save size="1.2em" />{:else}<Eye size="1.2em" />{/if} {#if has_changed}<Save size="1.2em" />{:else}<Eye
size="1.2em"
/>{/if}
{:else} {:else}
<Pencil size="1.2em" /> <Pencil size="1.2em" />
{/if} {/if}
@@ -79,7 +108,11 @@
/> />
{:else} {:else}
<h2 class="text-base md:text-lg font-bold truncate max-w-md"> <h2 class="text-base md:text-lg font-bold truncate max-w-md">
{entry.name || ae_util.iso_datetime_formatter(entry.created_on, 'datetime_iso_12_no_seconds')} {entry.name ||
ae_util.iso_datetime_formatter(
entry.created_on,
'datetime_iso_12_no_seconds'
)}
</h2> </h2>
{/if} {/if}
</div> </div>
@@ -88,17 +121,30 @@
<div class="flex items-center gap-2 w-full md:w-auto justify-end"> <div class="flex items-center gap-2 w-full md:w-auto justify-end">
<!-- Auto-Save indicator --> <!-- Auto-Save indicator -->
{#if $journals_loc.entry.edit_kv[entry.journal_entry_id] === 'current'} {#if $journals_loc.entry.edit_kv[entry.journal_entry_id] === 'current'}
<div class="flex items-center gap-1 px-2 border-r border-surface-500/20 mr-1"> <div
<button type="button" class="flex items-center gap-1 px-2 border-r border-surface-500/20 mr-1"
class="btn-icon btn-icon-sm { $journals_loc.entry.auto_save ? 'text-primary-500' : 'opacity-30'}" >
onclick={() => $journals_loc.entry.auto_save = !$journals_loc.entry.auto_save} <button
type="button"
class="btn-icon btn-icon-sm {$journals_loc.entry.auto_save
? 'text-primary-500'
: 'opacity-30'}"
onclick={() =>
($journals_loc.entry.auto_save =
!$journals_loc.entry.auto_save)}
title="Toggle Auto Save" title="Toggle Auto Save"
> >
<RefreshCw size="1em" /> <RefreshCw size="1em" />
</button> </button>
{#if $journals_loc.entry.auto_save} {#if $journals_loc.entry.auto_save}
{#if save_status === 'saving'}<Loader2 size="1em" class="animate-spin text-primary-500" /> {#if save_status === 'saving'}<Loader2
{:else if save_status === 'saved'}<CircleCheck size="1em" class="text-success-500" /> size="1em"
class="animate-spin text-primary-500"
/>
{:else if save_status === 'saved'}<CircleCheck
size="1em"
class="text-success-500"
/>
{:else}<CircleX size="1em" class="opacity-30" />{/if} {:else}<CircleX size="1em" class="opacity-30" />{/if}
{/if} {/if}
</div> </div>
@@ -106,20 +152,25 @@
<!-- Decrypt Toggle (Lock) --> <!-- Decrypt Toggle (Lock) -->
{#if entry.private} {#if entry.private}
<button type="button" <button
class="btn-icon btn-icon-sm transition-all {is_decrypted ? 'variant-filled-success shadow-lg shadow-success-500/20' : 'variant-soft-warning'}" type="button"
class="btn-icon btn-icon-sm transition-all {is_decrypted
? 'variant-filled-success shadow-lg shadow-success-500/20'
: 'variant-soft-warning'}"
onclick={on_decrypt} onclick={on_decrypt}
title={is_decrypted ? 'Lock Content' : 'Decrypt Content'} title={is_decrypted ? 'Lock Content' : 'Decrypt Content'}
> >
{#if is_decrypted}<LockKeyholeOpen size="1.2em" />{:else}<LockKeyhole size="1.2em" />{/if} {#if is_decrypted}<LockKeyholeOpen
size="1.2em"
/>{:else}<LockKeyhole size="1.2em" />{/if}
</button> </button>
{/if} {/if}
<div class="w-[1px] h-6 bg-surface-500/20 mx-1"></div> <div class="w-[1px] h-6 bg-surface-500/20 mx-1"></div>
<!-- Unified Config Button --> <!-- Unified Config Button -->
<button type="button" <button
type="button"
class="btn btn-sm variant-soft-primary font-bold" class="btn btn-sm variant-soft-primary font-bold"
onclick={on_show_config} onclick={on_show_config}
> >
@@ -128,7 +179,11 @@
<!-- Explicit Save (Mobile/Backup) --> <!-- Explicit Save (Mobile/Backup) -->
{#if has_changed && save_status !== 'saving'} {#if has_changed && save_status !== 'saving'}
<button type="button" class="btn btn-sm variant-filled-primary shadow-lg" onclick={on_save}> <button
type="button"
class="btn btn-sm variant-filled-primary shadow-lg"
onclick={on_save}
>
<Save size="1.1em" class="mr-2" /> Save <Save size="1.1em" class="mr-2" /> Save
</button> </button>
{/if} {/if}

View File

@@ -17,16 +17,24 @@
<section class="journal-metadata w-full space-y-4"> <section class="journal-metadata w-full space-y-4">
<!-- System Timestamps --> <!-- System Timestamps -->
<div class="flex flex-col sm:flex-row justify-between items-center gap-2 px-1 text-xs text-surface-500"> <div
class="flex flex-col sm:flex-row justify-between items-center gap-2 px-1 text-xs text-surface-500"
>
<div class="flex gap-4"> <div class="flex gap-4">
<span title="Creation date"> <span title="Creation date">
<span class="font-semibold">Created:</span> <span class="font-semibold">Created:</span>
{ae_util.iso_datetime_formatter(entry.created_on, 'datetime_12_long')} {ae_util.iso_datetime_formatter(
entry.created_on,
'datetime_12_long'
)}
</span> </span>
{#if entry.updated_on} {#if entry.updated_on}
<span title="Last update"> <span title="Last update">
<span class="font-semibold">Updated:</span> <span class="font-semibold">Updated:</span>
{ae_util.iso_datetime_formatter(entry.updated_on, 'datetime_12_long')} {ae_util.iso_datetime_formatter(
entry.updated_on,
'datetime_12_long'
)}
</span> </span>
{/if} {/if}
</div> </div>

View File

@@ -7,8 +7,13 @@
// *** Import Lucide Icons // *** Import Lucide Icons
import { import {
FileUp, Trash2, Download, Paperclip, FileUp,
ExternalLink, Loader2, RefreshCw Trash2,
Download,
Paperclip,
ExternalLink,
Loader2,
RefreshCw
} from 'lucide-svelte'; } from 'lucide-svelte';
// *** Import Aether specific variables and functions // *** Import Aether specific variables and functions
@@ -45,7 +50,12 @@
lq__journal_entry_obj: any; lq__journal_entry_obj: any;
} }
let { log_lvl = 0, link_to_type, link_to_id, lq__journal_entry_obj }: Props = $props(); let {
log_lvl = 0,
link_to_type,
link_to_id,
lq__journal_entry_obj
}: Props = $props();
// *** State // *** State
let ae_promises: Record<string, any> = $state({}); let ae_promises: Record<string, any> = $state({});
@@ -74,11 +84,20 @@
// 2. Merge with legacy hosted_file_kv if not already present // 2. Merge with legacy hosted_file_kv if not already present
if (entry.data_json?.hosted_file_kv) { if (entry.data_json?.hosted_file_kv) {
Object.entries(entry.data_json.hosted_file_kv).forEach(([id, obj]: [string, any]) => { Object.entries(entry.data_json.hosted_file_kv).forEach(
if (!files.find(f => (f.hosted_file_id || f.id || f.hosted_file_id) === id)) { ([id, obj]: [string, any]) => {
files.push({ ...obj, id: id }); if (
!files.find(
(f) =>
(f.hosted_file_id ||
f.id ||
f.hosted_file_id) === id
)
) {
files.push({ ...obj, id: id });
}
} }
}); );
} }
return files; return files;
@@ -91,7 +110,10 @@
data_json: { data_json: {
...$lq__journal_entry_obj?.data_json, ...$lq__journal_entry_obj?.data_json,
hosted_file_kv: Object.fromEntries( hosted_file_kv: Object.fromEntries(
updated_files.map(f => [f.hosted_file_id || f.id || f.hosted_file_id, f]) updated_files.map((f) => [
f.hosted_file_id || f.id || f.hosted_file_id,
f
])
) )
} }
}; };
@@ -112,8 +134,15 @@
// Handle "Select Existing" completion // Handle "Select Existing" completion
$effect(() => { $effect(() => {
if ($lq__journal_entry_obj && slct_hosted_file_id && slct_hosted_file_obj) { if (
const new_file = { ...slct_hosted_file_obj, id: slct_hosted_file_id }; $lq__journal_entry_obj &&
slct_hosted_file_id &&
slct_hosted_file_obj
) {
const new_file = {
...slct_hosted_file_obj,
id: slct_hosted_file_id
};
const updated_li = [...unified_file_li, new_file]; const updated_li = [...unified_file_li, new_file];
slct_hosted_file_id = null; slct_hosted_file_id = null;
@@ -125,8 +154,12 @@
// Handle "Upload" completion // Handle "Upload" completion
$effect(() => { $effect(() => {
if ($lq__journal_entry_obj && upload_complete && slct_hosted_file_id_li.length) { if (
const new_files = slct_hosted_file_id_li.map(id => ({ $lq__journal_entry_obj &&
upload_complete &&
slct_hosted_file_id_li.length
) {
const new_files = slct_hosted_file_id_li.map((id) => ({
...slct_hosted_file_kv[id], ...slct_hosted_file_kv[id],
id: id id: id
})); }));
@@ -140,9 +173,12 @@
}); });
async function handle_remove_file(file_id: string) { async function handle_remove_file(file_id: string) {
if (!confirm('Are you sure you want to remove this file attachment?')) return; if (!confirm('Are you sure you want to remove this file attachment?'))
return;
const updated_li = unified_file_li.filter(f => (f.hosted_file_id || f.id || f.hosted_file_id) !== file_id); const updated_li = unified_file_li.filter(
(f) => (f.hosted_file_id || f.id || f.hosted_file_id) !== file_id
);
// Also perform physical/orphan deletion if admin // Also perform physical/orphan deletion if admin
if ($ae_loc.administrator_access) { if ($ae_loc.administrator_access) {
@@ -163,24 +199,34 @@
<section class="ae_section journal_entry_files w-full space-y-4 my-2"> <section class="ae_section journal_entry_files w-full space-y-4 my-2">
<!-- Header --> <!-- Header -->
<div class="flex items-center justify-between border-b border-surface-500/20 pb-2"> <div
class="flex items-center justify-between border-b border-surface-500/20 pb-2"
>
<h3 class="h3 flex items-center gap-2 text-lg font-bold"> <h3 class="h3 flex items-center gap-2 text-lg font-bold">
<Paperclip size="1.1em" /> <Paperclip size="1.1em" />
Attachments Attachments
{#if unified_file_li.length} {#if unified_file_li.length}
<span class="badge variant-soft-surface text-xs">{unified_file_li.length}</span> <span class="badge variant-soft-surface text-xs"
>{unified_file_li.length}</span
>
{/if} {/if}
</h3> </h3>
{#if $ae_loc.edit_mode} {#if $ae_loc.edit_mode}
<button type="button" <button
type="button"
class="btn btn-sm variant-soft-warning font-semibold" class="btn btn-sm variant-soft-warning font-semibold"
onclick={() => { onclick={() => {
$ae_sess.files.add_to_use_files_method = ($ae_sess.files.add_to_use_files_method === 'upload') ? 'select' : 'upload'; $ae_sess.files.add_to_use_files_method =
$ae_sess.files.add_to_use_files_method === 'upload'
? 'select'
: 'upload';
}} }}
> >
<RefreshCw size="1em" class="mr-2" /> <RefreshCw size="1em" class="mr-2" />
{$ae_sess.files.add_to_use_files_method === 'select' ? 'Switch to Upload' : 'Switch to Select'} {$ae_sess.files.add_to_use_files_method === 'select'
? 'Switch to Upload'
: 'Switch to Select'}
</button> </button>
{/if} {/if}
</div> </div>
@@ -189,8 +235,11 @@
{#if unified_file_li.length} {#if unified_file_li.length}
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3"> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3">
{#each unified_file_li as file} {#each unified_file_li as file}
{@const file_id = file.hosted_file_id || file.id || file.hosted_file_id} {@const file_id =
<div class="flex items-center justify-between p-3 rounded-xl bg-surface-50-950 border border-surface-500/10 group hover:border-primary-500 transition-all shadow-sm"> file.hosted_file_id || file.id || file.hosted_file_id}
<div
class="flex items-center justify-between p-3 rounded-xl bg-surface-50-950 border border-surface-500/10 group hover:border-primary-500 transition-all shadow-sm"
>
<div class="flex items-center gap-3 overflow-hidden grow"> <div class="flex items-center gap-3 overflow-hidden grow">
<AE_Comp_Hosted_Files_Download_Button <AE_Comp_Hosted_Files_Download_Button
hosted_file_id={file_id} hosted_file_id={file_id}
@@ -200,13 +249,15 @@
classes="w-full !justify-start !px-2" classes="w-full !justify-start !px-2"
show_divider={true} show_divider={true}
max_filename={25} max_filename={25}
show_direct_download={$ae_loc.trusted_access && $ae_loc.edit_mode} show_direct_download={$ae_loc.trusted_access &&
$ae_loc.edit_mode}
/> />
</div> </div>
<div class="flex items-center gap-1 ml-2"> <div class="flex items-center gap-1 ml-2">
{#if $ae_loc.edit_mode} {#if $ae_loc.edit_mode}
<button type="button" <button
type="button"
class="btn btn-sm variant-soft-error" class="btn btn-sm variant-soft-error"
onclick={() => handle_remove_file(file_id)} onclick={() => handle_remove_file(file_id)}
title="Remove attachment" title="Remove attachment"
@@ -219,14 +270,18 @@
{/each} {/each}
</div> </div>
{:else if !$ae_loc.edit_mode} {:else if !$ae_loc.edit_mode}
<p class="text-sm text-surface-500 italic p-4 text-center bg-surface-500/5 rounded-xl"> <p
class="text-sm text-surface-500 italic p-4 text-center bg-surface-500/5 rounded-xl"
>
No files attached to this entry. No files attached to this entry.
</p> </p>
{/if} {/if}
<!-- Edit/Management Tools --> <!-- Edit/Management Tools -->
{#if $ae_loc.edit_mode} {#if $ae_loc.edit_mode}
<div class="mt-4 p-4 rounded-2xl bg-surface-500/5 border-2 border-dashed border-surface-500/20"> <div
class="mt-4 p-4 rounded-2xl bg-surface-500/5 border-2 border-dashed border-surface-500/20"
>
{#if $ae_sess.files.add_to_use_files_method === 'upload'} {#if $ae_sess.files.add_to_use_files_method === 'upload'}
<Comp_hosted_files_upload <Comp_hosted_files_upload
{link_to_type} {link_to_type}
@@ -240,19 +295,25 @@
> >
{#snippet label()} {#snippet label()}
<div class="flex flex-col items-center gap-2 py-2"> <div class="flex flex-col items-center gap-2 py-2">
<div class="p-3 rounded-full bg-primary-500/10 text-primary-500"> <div
class="p-3 rounded-full bg-primary-500/10 text-primary-500"
>
<FileUp size="1.8em" /> <FileUp size="1.8em" />
</div> </div>
<div class="text-center"> <div class="text-center">
<p class="font-bold">Upload new attachment</p> <p class="font-bold">Upload new attachment</p>
<p class="text-xs opacity-60">Drag and drop or click to browse</p> <p class="text-xs opacity-60">
Drag and drop or click to browse
</p>
</div> </div>
</div> </div>
{/snippet} {/snippet}
</Comp_hosted_files_upload> </Comp_hosted_files_upload>
{:else} {:else}
<div class="space-y-2"> <div class="space-y-2">
<p class="text-sm font-bold opacity-70 ml-1">Select from existing hosted files:</p> <p class="text-sm font-bold opacity-70 ml-1">
Select from existing hosted files:
</p>
<Element_manage_hosted_file_li_wrap <Element_manage_hosted_file_li_wrap
link_to_type={'account'} link_to_type={'account'}
link_to_id={$ae_loc?.account_id} link_to_id={$ae_loc?.account_id}

View File

@@ -17,7 +17,11 @@
import type { key_val } from '$lib/stores/ae_stores'; import type { key_val } from '$lib/stores/ae_stores';
import { ae_util } from '$lib/ae_utils/ae_utils'; import { ae_util } from '$lib/ae_utils/ae_utils';
import { ae_loc, ae_api } from '$lib/stores/ae_stores'; import { ae_loc, ae_api } from '$lib/stores/ae_stores';
import { journals_loc, journals_sess, journals_slct } from '$lib/ae_journals/ae_journals_stores'; import {
journals_loc,
journals_sess,
journals_slct
} from '$lib/ae_journals/ae_journals_stores';
import { journals_func } from '$lib/ae_journals/ae_journals_functions'; import { journals_func } from '$lib/ae_journals/ae_journals_functions';
import { decrypt_journal_entry } from '$lib/ae_journals/ae_journals_decryption'; import { decrypt_journal_entry } from '$lib/ae_journals/ae_journals_decryption';
@@ -87,17 +91,35 @@
let has_unsaved_changes = $derived.by(() => { let has_unsaved_changes = $derived.by(() => {
if (!tmp_entry_obj || !orig_entry_obj || is_processing) return false; if (!tmp_entry_obj || !orig_entry_obj || is_processing) return false;
const normalize = (val: any) => (val === null || val === undefined) ? '' : String(val).trim(); const normalize = (val: any) =>
val === null || val === undefined ? '' : String(val).trim();
const content_changed = normalize(tmp_entry_obj.content) !== normalize(orig_entry_obj.content); const content_changed =
const name_changed = normalize(tmp_entry_obj.name) !== normalize(orig_entry_obj.name); normalize(tmp_entry_obj.content) !==
const private_changed = (tmp_entry_obj.private ?? false) !== (orig_entry_obj.private ?? false); normalize(orig_entry_obj.content);
const name_changed =
normalize(tmp_entry_obj.name) !== normalize(orig_entry_obj.name);
const private_changed =
(tmp_entry_obj.private ?? false) !==
(orig_entry_obj.private ?? false);
if (content_changed || name_changed || private_changed) return true; if (content_changed || name_changed || private_changed) return true;
const other_fields = ['tags', 'category_code', 'public', 'personal', 'professional', 'archive_on', 'sort']; const other_fields = [
'tags',
'category_code',
'public',
'personal',
'professional',
'archive_on',
'sort'
];
for (const field of other_fields) { for (const field of other_fields) {
if (normalize(tmp_entry_obj[field]) !== normalize(orig_entry_obj[field])) return true; if (
normalize(tmp_entry_obj[field]) !==
normalize(orig_entry_obj[field])
)
return true;
} }
return false; return false;
@@ -114,10 +136,15 @@
if (!entry || !(entry.updated_on || entry.created_on)) return; if (!entry || !(entry.updated_on || entry.created_on)) return;
const session_kv = $journals_sess?.journal_kv[journal?.id]; const session_kv = $journals_sess?.journal_kv[journal?.id];
const is_decrypted = session_kv?.journal_passcode_decrypted === true; const is_decrypted =
session_kv?.journal_passcode_decrypted === true;
// Only sync if saved and not currently processing/editing // Only sync if saved and not currently processing/editing
if (save_status === 'saved' && !has_unsaved_changes && !is_processing) { if (
save_status === 'saved' &&
!has_unsaved_changes &&
!is_processing
) {
// Prevent overwrite of recovered text if we are in a decrypted session // Prevent overwrite of recovered text if we are in a decrypted session
if (is_decrypted && tmp_entry_obj.content && !entry.content) { if (is_decrypted && tmp_entry_obj.content && !entry.content) {
return; return;
@@ -141,16 +168,30 @@
const _private = tmp_entry_obj.private; const _private = tmp_entry_obj.private;
// Isolate logic from secondary dependencies // Isolate logic from secondary dependencies
const should_save = untrack(() => has_unsaved_changes && !is_processing && save_status !== 'saving'); const should_save = untrack(
() =>
has_unsaved_changes &&
!is_processing &&
save_status !== 'saving'
);
if (should_save) { if (should_save) {
if (save_status !== 'saving') save_status = 'unsaved'; if (save_status !== 'saving') save_status = 'unsaved';
const auto_save_enabled = untrack(() => $journals_loc.entry.auto_save); const auto_save_enabled = untrack(
() => $journals_loc.entry.auto_save
);
if (auto_save_enabled) { if (auto_save_enabled) {
clearTimeout(auto_save_timer); clearTimeout(auto_save_timer);
auto_save_timer = setTimeout(() => { auto_save_timer = setTimeout(() => {
if (untrack(() => has_unsaved_changes && !is_processing && save_status !== 'saving')) { if (
untrack(
() =>
has_unsaved_changes &&
!is_processing &&
save_status !== 'saving'
)
) {
update_journal_entry(); update_journal_entry();
} }
}, 2000); }, 2000);
@@ -172,7 +213,12 @@
const decrypted_status = session?.journal_passcode_decrypted; const decrypted_status = session?.journal_passcode_decrypted;
const has_encrypted_content = !!entry.content_encrypted; const has_encrypted_content = !!entry.content_encrypted;
if (has_encrypted_content && is_verified && decrypted_status !== true && decrypted_status !== 'processing') { if (
has_encrypted_content &&
is_verified &&
decrypted_status !== true &&
decrypted_status !== 'processing'
) {
untrack(() => run_decryption_workflow()); untrack(() => run_decryption_workflow());
} }
}); });
@@ -183,22 +229,27 @@
const journal = $lq__journal_obj; const journal = $lq__journal_obj;
if (!journal?.id || is_processing) return; if (!journal?.id || is_processing) return;
let journal_key = $journals_sess.journal_kv[journal.id]?.typed_journal_passcode; let journal_key =
$journals_sess.journal_kv[journal.id]?.typed_journal_passcode;
is_processing = true; is_processing = true;
decryption_error = null; decryption_error = null;
journals_sess.update(s => { journals_sess.update((s) => {
if (!s.journal_kv[journal.id]) s.journal_kv[journal.id] = {}; if (!s.journal_kv[journal.id]) s.journal_kv[journal.id] = {};
s.journal_kv[journal.id].journal_passcode_decrypted = 'processing'; s.journal_kv[journal.id].journal_passcode_decrypted = 'processing';
return s; return s;
}); });
const result = await decrypt_journal_entry($lq__journal_entry_obj, journal, journal_key); const result = await decrypt_journal_entry(
$lq__journal_entry_obj,
journal,
journal_key
);
if (!result.success) { if (!result.success) {
decryption_error = result.error || 'Decryption failed.'; decryption_error = result.error || 'Decryption failed.';
journals_sess.update(s => { journals_sess.update((s) => {
s.journal_kv[journal.id].journal_passcode_verified = false; s.journal_kv[journal.id].journal_passcode_verified = false;
s.journal_kv[journal.id].journal_passcode_decrypted = false; s.journal_kv[journal.id].journal_passcode_decrypted = false;
return s; return s;
@@ -225,7 +276,7 @@
if (orig_entry_obj) orig_entry_obj.history = result.history; if (orig_entry_obj) orig_entry_obj.history = result.history;
} }
journals_sess.update(s => { journals_sess.update((s) => {
s.journal_kv[journal.id].journal_passcode_decrypted = true; s.journal_kv[journal.id].journal_passcode_decrypted = true;
return s; return s;
}); });
@@ -233,7 +284,12 @@
} }
async function update_journal_entry(fields_kv?: key_val) { async function update_journal_entry(fields_kv?: key_val) {
if (!$ae_loc.trusted_access || save_status === 'saving' || is_processing) return; if (
!$ae_loc.trusted_access ||
save_status === 'saving' ||
is_processing
)
return;
is_processing = true; is_processing = true;
save_status = 'saving'; save_status = 'saving';
@@ -259,7 +315,9 @@
group: tmp_entry_obj.group, group: tmp_entry_obj.group,
data_json: tmp_entry_obj.data_json, data_json: tmp_entry_obj.data_json,
archive_on: tmp_entry_obj.archive_on, archive_on: tmp_entry_obj.archive_on,
linked_li_json: tmp_entry_obj.linked_li_json ? JSON.stringify(tmp_entry_obj.linked_li_json) : null linked_li_json: tmp_entry_obj.linked_li_json
? JSON.stringify(tmp_entry_obj.linked_li_json)
: null
}; };
const decrypt_key = $lq__journal_obj.combined_passcode; const decrypt_key = $lq__journal_obj.combined_passcode;
@@ -268,7 +326,10 @@
if (!fields_kv) { if (!fields_kv) {
if (tmp_entry_obj.private) { if (tmp_entry_obj.private) {
if (tmp_entry_obj.content) { if (tmp_entry_obj.content) {
data_kv.content_encrypted = await ae_util.encrypt_wrapper(tmp_entry_obj.content, decrypt_key); data_kv.content_encrypted = await ae_util.encrypt_wrapper(
tmp_entry_obj.content,
decrypt_key
);
data_kv.content = null; data_kv.content = null;
} }
} else { } else {
@@ -313,7 +374,7 @@
orig_entry_obj.content = null; orig_entry_obj.content = null;
orig_entry_obj.history = null; orig_entry_obj.history = null;
} }
journals_sess.update(s => { journals_sess.update((s) => {
s.journal_kv[journal.id].journal_passcode_decrypted = false; s.journal_kv[journal.id].journal_passcode_decrypted = false;
return s; return s;
}); });
@@ -327,23 +388,27 @@
} }
async function handle_force_reset() { async function handle_force_reset() {
if (!confirm('WARNING: This will permanently DELETE the encrypted content and history for this entry and reset it to plain text. This cannot be undone. Proceed?')) { if (
!confirm(
'WARNING: This will permanently DELETE the encrypted content and history for this entry and reset it to plain text. This cannot be undone. Proceed?'
)
) {
return; return;
} }
is_processing = true; is_processing = true;
tmp_entry_obj.private = false; tmp_entry_obj.private = false;
tmp_entry_obj.content = ""; tmp_entry_obj.content = '';
tmp_entry_obj.content_encrypted = null; tmp_entry_obj.content_encrypted = null;
tmp_entry_obj.history = ""; tmp_entry_obj.history = '';
tmp_entry_obj.history_encrypted = null; tmp_entry_obj.history_encrypted = null;
// Sync orig to match the "cleared" state // Sync orig to match the "cleared" state
if (orig_entry_obj) { if (orig_entry_obj) {
orig_entry_obj.private = false; orig_entry_obj.private = false;
orig_entry_obj.content = ""; orig_entry_obj.content = '';
orig_entry_obj.content_encrypted = null; orig_entry_obj.content_encrypted = null;
orig_entry_obj.history = ""; orig_entry_obj.history = '';
orig_entry_obj.history_encrypted = null; orig_entry_obj.history_encrypted = null;
} }
@@ -355,7 +420,10 @@
let modal_mode: 'append' | 'prepend' | 'auto' = $state('auto'); let modal_mode: 'append' | 'prepend' | 'auto' = $state('auto');
</script> </script>
<section class="ae_view flex flex-col gap-2 w-full h-full p-1" bind:clientHeight={$ae_loc.iframe_height_modal_body}> <section
class="ae_view flex flex-col gap-2 w-full h-full p-1"
bind:clientHeight={$ae_loc.iframe_height_modal_body}
>
{#if $lq__journal_entry_obj && $lq__journal_obj} {#if $lq__journal_entry_obj && $lq__journal_obj}
<AeCompJournalEntryHeader <AeCompJournalEntryHeader
entry={$lq__journal_entry_obj} entry={$lq__journal_entry_obj}
@@ -365,26 +433,37 @@
has_changed={has_unsaved_changes} has_changed={has_unsaved_changes}
on_save={() => update_journal_entry()} on_save={() => update_journal_entry()}
on_decrypt={handle_content_decryption} on_decrypt={handle_content_decryption}
on_show_config={() => show_config_modal = true} on_show_config={() => (show_config_modal = true)}
{save_status} {save_status}
{log_lvl} {log_lvl}
/> />
{#if decryption_error} {#if decryption_error}
<div class="w-full p-4 bg-error-500/20 border-2 border-error-500 rounded-lg flex items-center justify-between shadow-2xl z-50 animate-bounce"> <div
<div class="flex items-center gap-4 text-error-700 dark:text-error-300 font-bold"> class="w-full p-4 bg-error-500/20 border-2 border-error-500 rounded-lg flex items-center justify-between shadow-2xl z-50 animate-bounce"
>
<div
class="flex items-center gap-4 text-error-700 dark:text-error-300 font-bold"
>
<AlertCircle size="2.5em" /> <AlertCircle size="2.5em" />
<span class="text-xl">{decryption_error}</span> <span class="text-xl">{decryption_error}</span>
</div> </div>
<button type="button" class="btn btn-sm variant-filled-error shadow-lg font-bold" onclick={() => decryption_error = null}> <button
type="button"
class="btn btn-sm variant-filled-error shadow-lg font-bold"
onclick={() => (decryption_error = null)}
>
<XCircle size="1.2em" class="mr-2" /> Dismiss <XCircle size="1.2em" class="mr-2" /> Dismiss
</button> </button>
</div> </div>
{/if} {/if}
<section class="grow relative bg-gray-100 dark:bg-gray-800 p-1 rounded-lg shadow-md overflow-hidden" <section
class:bg-yellow-50={$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'current'}> class="grow relative bg-gray-100 dark:bg-gray-800 p-1 rounded-lg shadow-md overflow-hidden"
class:bg-yellow-50={$journals_loc.entry.edit_kv[
$lq__journal_entry_obj?.journal_entry_id
] == 'current'}
>
<div class="absolute top-2 right-2 z-10"> <div class="absolute top-2 right-2 z-10">
<AeCompJournalEntryAiTools <AeCompJournalEntryAiTools
content={tmp_entry_obj.content} content={tmp_entry_obj.content}
@@ -421,7 +500,9 @@
journal_config={$lq__journal_obj?.cfg_json} journal_config={$lq__journal_obj?.cfg_json}
mode={modal_mode} mode={modal_mode}
on_close={() => (show_append_modal = false)} on_close={() => (show_append_modal = false)}
on_update={() => { show_append_modal = false; }} on_update={() => {
show_append_modal = false;
}}
{log_lvl} {log_lvl}
/> />
@@ -432,13 +513,21 @@
bind:tmp_entry_obj bind:tmp_entry_obj
on_save={() => update_journal_entry()} on_save={() => update_journal_entry()}
on_force_reset={handle_force_reset} on_force_reset={handle_force_reset}
on_show_export={on_show_export} {on_show_export}
on_append={() => { modal_mode = 'append'; show_append_modal = true; }} on_append={() => {
on_prepend={() => { modal_mode = 'prepend'; show_append_modal = true; }} modal_mode = 'append';
show_append_modal = true;
}}
on_prepend={() => {
modal_mode = 'prepend';
show_append_modal = true;
}}
{log_lvl} {log_lvl}
/> />
{:else} {:else}
<div class="p-20 text-center opacity-50 flex flex-col items-center gap-4"> <div
class="p-20 text-center opacity-50 flex flex-col items-center gap-4"
>
<Loader2 class="animate-spin" size="4em" /> <Loader2 class="animate-spin" size="4em" />
<span class="text-2xl font-bold">Loading Journal Entry...</span> <span class="text-2xl font-bold">Loading Journal Entry...</span>
</div> </div>

View File

@@ -68,7 +68,8 @@
$effect(() => { $effect(() => {
// Sync local boolean with store ID presence // Sync local boolean with store ID presence
show_append_modal = !!$journals_sess.show__modal_append__journal_entry_id; show_append_modal =
!!$journals_sess.show__modal_append__journal_entry_id;
}); });
function handle_modal_close() { function handle_modal_close() {
@@ -82,35 +83,42 @@
// Derived list of visible items (Standardized Search Pattern 2026-01-27) // Derived list of visible items (Standardized Search Pattern 2026-01-27)
// Ensures count matches exactly what is rendered to the user // Ensures count matches exactly what is rendered to the user
let visible_journal_entry_obj_li = $derived((() => { let visible_journal_entry_obj_li = $derived(
// Subscribe to the observable (() => {
const list = $lq__journal_entry_obj_li; // Subscribe to the observable
const list = $lq__journal_entry_obj_li;
// Return null to signify 'loading' vs [] for 'empty' // Return null to signify 'loading' vs [] for 'empty'
if (list === undefined || list === null) return null; if (list === undefined || list === null) return null;
if (!Array.isArray(list)) return []; if (!Array.isArray(list)) return [];
const filtered = list.filter((item: any) => { const filtered = list.filter((item: any) => {
if (!item) return false; if (!item) return false;
// ADMIN/TRUSTED: See everything // ADMIN/TRUSTED: See everything
if ($ae_loc.trusted_access) return true; if ($ae_loc.trusted_access) return true;
// PUBLIC: Filter hidden/disabled // PUBLIC: Filter hidden/disabled
// Permissive defaults for missing metadata // Permissive defaults for missing metadata
const is_hidden = item.hide === true || item.hide === 1; const is_hidden = item.hide === true || item.hide === 1;
const is_disabled = item.enable === false || item.enable === 0; const is_disabled = item.enable === false || item.enable === 0;
return !is_hidden && !is_disabled; return !is_hidden && !is_disabled;
}); });
if (log_lvl) console.log(`visible_journal_entry_obj_li: Input=${list.length}, Output=${filtered.length}`); if (log_lvl)
console.log(
`visible_journal_entry_obj_li: Input=${list.length}, Output=${filtered.length}`
);
return filtered; return filtered;
})()); })()
);
</script> </script>
<section class="journal_list flex flex-col gap-1 md:gap-2 items-center justify-center w-full"> <section
class="journal_list flex flex-col gap-1 md:gap-2 items-center justify-center w-full"
>
{#if visible_journal_entry_obj_li === null} {#if visible_journal_entry_obj_li === null}
<!-- Loading state --> <!-- Loading state -->
<div class="flex flex-col items-center justify-center p-10 opacity-50"> <div class="flex flex-col items-center justify-center p-10 opacity-50">
@@ -121,9 +129,16 @@
{#if show_found_header} {#if show_found_header}
<div class="w-full max-w-(--breakpoint-lg) mb-2"> <div class="w-full max-w-(--breakpoint-lg) mb-2">
<h2 class="h4 flex items-center gap-2 px-2"> <h2 class="h4 flex items-center gap-2 px-2">
<span class="text-sm text-gray-500 font-normal"> Found: </span> <span class="text-sm text-gray-500 font-normal">
<span class="badge preset-tonal-success font-bold text-lg px-3 py-1"> Found:
{visible_journal_entry_obj_li.length}<span class="text-gray-400 dark:text-gray-600">&times;</span> </span>
<span
class="badge preset-tonal-success font-bold text-lg px-3 py-1"
>
{visible_journal_entry_obj_li.length}<span
class="text-gray-400 dark:text-gray-600"
>&times;</span
>
</span> </span>
</h2> </h2>
</div> </div>
@@ -147,33 +162,52 @@
class:dim={!journals_journal_entry_obj.enable} class:dim={!journals_journal_entry_obj.enable}
class:bg-warning-100={!journals_journal_entry_obj?.enable} class:bg-warning-100={!journals_journal_entry_obj?.enable}
> >
<header class="ae_header flex flex-row gap-2 items-center justify-between w-full"> <header
class="ae_header flex flex-row gap-2 items-center justify-between w-full"
>
<span class="flex flex-row flex-wrap gap-1"> <span class="flex flex-row flex-wrap gap-1">
<span class="journal_entry__name *:hover:inline-block"> <span class="journal_entry__name *:hover:inline-block">
{#if journals_journal_entry_obj.alert} {#if journals_journal_entry_obj.alert}
<Siren size="1.25em" class="mx-1 inline-block text-red-500" /> <Siren
size="1.25em"
class="mx-1 inline-block text-red-500"
/>
{/if} {/if}
{#if journals_journal_entry_obj.priority} {#if journals_journal_entry_obj.priority}
<Flag size="1.25em" class="mx-1 inline-block text-yellow-500" /> <Flag
size="1.25em"
class="mx-1 inline-block text-yellow-500"
/>
{/if} {/if}
{#if journals_journal_entry_obj.group} {#if journals_journal_entry_obj.group}
<Group size="1.25em" class="mx-1 inline-block text-green-500" /> <Group
<span class="text-xs text-gray-500 hidden">Group:</span> size="1.25em"
<span class="font-semibold text-sm text-gray-500 hidden md:inline"> class="mx-1 inline-block text-green-500"
/>
<span class="text-xs text-gray-500 hidden"
>Group:</span
>
<span
class="font-semibold text-sm text-gray-500 hidden md:inline"
>
{journals_journal_entry_obj.group} {journals_journal_entry_obj.group}
</span> </span>
{/if} {/if}
</span> </span>
<h3 class:dim={journals_journal_entry_obj.hide} class="journal__name h4"> <h3
class:dim={journals_journal_entry_obj.hide}
class="journal__name h4"
>
{#if journals_journal_entry_obj.template} {#if journals_journal_entry_obj.template}
<NotepadTextDashed <NotepadTextDashed
class="mx-1 inline-block text-neutral-800/60 dark:text-neutral-50/60" class="mx-1 inline-block text-neutral-800/60 dark:text-neutral-50/60"
/> />
{@html journals_journal_entry_obj.name ?? '-- no name --'} {@html journals_journal_entry_obj.name ??
'-- no name --'}
{:else if journals_journal_entry_obj.name} {:else if journals_journal_entry_obj.name}
<NotebookText <NotebookText
class="mx-1 inline-block text-neutral-800/60 dark:text-neutral-50/60" class="mx-1 inline-block text-neutral-800/60 dark:text-neutral-50/60"
@@ -190,61 +224,85 @@
{/if} {/if}
</h3> </h3>
<span class="flex flex-row flex-wrap gap-1 items-center justify-center"> <span
class="flex flex-row flex-wrap gap-1 items-center justify-center"
>
{#if !journals_journal_entry_obj.private} {#if !journals_journal_entry_obj.private}
<!-- Button to copy the Markdown version --> <!-- Button to copy the Markdown version -->
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
let tmp_entry_obj = journals_journal_entry_obj; let tmp_entry_obj =
journals_journal_entry_obj;
navigator.clipboard navigator.clipboard
.writeText(tmp_entry_obj.content) .writeText(tmp_entry_obj.content)
.then(() => { .then(() => {
alert('Markdown content copied to clipboard!'); alert(
'Markdown content copied to clipboard!'
);
}) })
.catch((error) => { .catch((error) => {
console.error('Failed to copy content:', error); console.error(
alert('Failed to copy content.'); 'Failed to copy content:',
error
);
alert(
'Failed to copy content.'
);
}); });
}} }}
class:hidden={$lq__journal_obj?.cfg_json?.hide_copy_plain_md} class:hidden={$lq__journal_obj?.cfg_json
?.hide_copy_plain_md}
class="btn btn-sm p-1 preset-tonal-surface hover:preset-filled-secondary-500 *:hover:inline text-xs lg:text-sm" class="btn btn-sm p-1 preset-tonal-surface hover:preset-filled-secondary-500 *:hover:inline text-xs lg:text-sm"
title="Copy the markdown content" title="Copy the markdown content"
> >
<RemoveFormatting size="1.25em" /> <RemoveFormatting size="1.25em" />
<span class="hidden"> Copy Plaintext Markdown </span> <span class="hidden">
Copy Plaintext Markdown
</span>
</button> </button>
<!-- Button to copy the rendered to HTML version --> <!-- Button to copy the rendered to HTML version -->
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
let htmlContent = let htmlContent =
journals_journal_entry_obj.content_md_html || ''; journals_journal_entry_obj.content_md_html ||
'';
navigator.clipboard navigator.clipboard
.writeText(htmlContent) .writeText(htmlContent)
.then(() => { .then(() => {
alert('Rendered HTML content copied to clipboard!'); alert(
'Rendered HTML content copied to clipboard!'
);
}) })
.catch((error) => { .catch((error) => {
console.error( console.error(
'Failed to copy HTML content:', 'Failed to copy HTML content:',
error error
); );
alert('Failed to copy HTML content.'); alert(
'Failed to copy HTML content.'
);
}); });
}} }}
class:hidden={journals_journal_entry_obj.template || class:hidden={journals_journal_entry_obj.template ||
$lq__journal_obj?.cfg_json?.hide_copy_html} $lq__journal_obj?.cfg_json
?.hide_copy_html}
class="btn btn-sm p-1 preset-tonal-surface hover:preset-filled-secondary-500 *:hover:inline lg:text-xs" class="btn btn-sm p-1 preset-tonal-surface hover:preset-filled-secondary-500 *:hover:inline lg:text-xs"
title="Copy the rendered HTML content" title="Copy the rendered HTML content"
> >
<CodeXml size="1.25em" /> <CodeXml size="1.25em" />
<span class="hidden"> Copy HTML Markup </span> <span class="hidden">
Copy HTML Markup
</span>
</button> </button>
<!-- Button to copy the rich text (rendered HTML) version --> <!-- Button to copy the rich text (rendered HTML) version -->
<button type="button" <button
type="button"
onclick={async () => { onclick={async () => {
const element = document.getElementById( const element = document.getElementById(
`rendered_journal_entry_content_${journals_journal_entry_obj.journal_entry_id}` `rendered_journal_entry_content_${journals_journal_entry_obj.journal_entry_id}`
@@ -253,28 +311,42 @@
console.error( console.error(
'Element not found: rendered_journal_entry_content' 'Element not found: rendered_journal_entry_content'
); );
alert('Failed to copy rich content.'); alert(
'Failed to copy rich content.'
);
return; return;
} }
try { try {
const htmlContent = element.innerHTML; const htmlContent =
element.innerHTML;
await navigator.clipboard.write([ await navigator.clipboard.write([
new ClipboardItem({ new ClipboardItem({
'text/html': new Blob([htmlContent], { 'text/html': new Blob(
type: 'text/html' [htmlContent],
}) {
type: 'text/html'
}
)
}) })
]); ]);
alert('Rendered rich content copied to clipboard!'); alert(
'Rendered rich content copied to clipboard!'
);
} catch (error) { } catch (error) {
console.error('Failed to copy rich content:', error); console.error(
alert('Failed to copy rich content.'); 'Failed to copy rich content:',
error
);
alert(
'Failed to copy rich content.'
);
} }
}} }}
class:hidden={journals_journal_entry_obj.template || class:hidden={journals_journal_entry_obj.template ||
$lq__journal_obj?.cfg_json?.hide_copy_rich} $lq__journal_obj?.cfg_json
?.hide_copy_rich}
class="btn btn-sm p-1 preset-tonal-surface hover:preset-filled-secondary-500 *:hover:inline lg:text-xs" class="btn btn-sm p-1 preset-tonal-surface hover:preset-filled-secondary-500 *:hover:inline lg:text-xs"
title="Copy the rich text (rendered HTML) content" title="Copy the rich text (rendered HTML) content"
> >
@@ -283,28 +355,39 @@
</button> </button>
<!-- Clone entry --> <!-- Clone entry -->
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
let data_kv = { let data_kv = {
code: journals_journal_entry_obj.code, code: journals_journal_entry_obj.code,
category_code: journals_journal_entry_obj.category_code, category_code:
journals_journal_entry_obj.category_code,
name: journals_journal_entry_obj.name, name: journals_journal_entry_obj.name,
short_name: journals_journal_entry_obj.short_name, short_name:
content: journals_journal_entry_obj.content, journals_journal_entry_obj.short_name,
description: journals_journal_entry_obj.description, content:
journals_journal_entry_obj.content,
description:
journals_journal_entry_obj.description,
tags: journals_journal_entry_obj.tags tags: journals_journal_entry_obj.tags
}; };
journals_func journals_func
.create_ae_obj__journal_entry({ .create_ae_obj__journal_entry({
api_cfg: $ae_api, api_cfg: $ae_api,
journal_id: journals_journal_entry_obj.journal_id, journal_id:
journals_journal_entry_obj.journal_id,
data_kv: data_kv, data_kv: data_kv,
log_lvl: log_lvl log_lvl: log_lvl
}) })
.then((result) => { .then((result) => {
if (result?.journal_id_random && result?.journal_entry_id_random) { if (
alert('Journal entry cloned successfully!'); result?.journal_id_random &&
result?.journal_entry_id_random
) {
alert(
'Journal entry cloned successfully!'
);
goto( goto(
`/journals/${result.journal_id_random}/entry/${result.journal_entry_id_random}` `/journals/${result.journal_id_random}/entry/${result.journal_entry_id_random}`
); );
@@ -315,7 +398,9 @@
'Error cloning journal entry:', 'Error cloning journal entry:',
error error
); );
alert('Failed to clone journal entry.'); alert(
'Failed to clone journal entry.'
);
}); });
}} }}
class:hidden={!journals_journal_entry_obj.template} class:hidden={!journals_journal_entry_obj.template}
@@ -330,24 +415,38 @@
size="1.25em" size="1.25em"
class="mx-1 inline-block text-red-400 dark:text-red-600" class="mx-1 inline-block text-red-400 dark:text-red-600"
/> />
<span class="text-xs text-gray-500 hidden">Private</span> <span class="text-xs text-gray-500 hidden"
>Private</span
>
<!-- Button to copy the Markdown version --> <!-- Button to copy the Markdown version -->
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
let tmp_entry_obj = journals_journal_entry_obj; let tmp_entry_obj =
journals_journal_entry_obj;
navigator.clipboard navigator.clipboard
.writeText(tmp_entry_obj.content_encrypted) .writeText(
tmp_entry_obj.content_encrypted
)
.then(() => { .then(() => {
alert('Encrypted content copied to clipboard!'); alert(
'Encrypted content copied to clipboard!'
);
}) })
.catch((error) => { .catch((error) => {
console.error('Failed to copy content:', error); console.error(
alert('Failed to copy content.'); 'Failed to copy content:',
error
);
alert(
'Failed to copy content.'
);
}); });
}} }}
class:hidden={$lq__journal_obj?.cfg_json?.hide_copy_encrypted} class:hidden={$lq__journal_obj?.cfg_json
?.hide_copy_encrypted}
class="btn btn-sm p-1 preset-tonal-surface hover:preset-filled-secondary-500 *:hover:inline text-xs lg:text-sm" class="btn btn-sm p-1 preset-tonal-surface hover:preset-filled-secondary-500 *:hover:inline text-xs lg:text-sm"
title="Copy the encrypted content" title="Copy the encrypted content"
> >
@@ -358,18 +457,25 @@
</span> </span>
</span> </span>
<div class="flex flex-row flex-wrap gap-2 items-center justify-end"> <div
class="flex flex-row flex-wrap gap-2 items-center justify-end"
>
<!-- Linked file count --> <!-- Linked file count -->
<div <div
class="ae_linked_file_count flex flex-row flex-wrap gap-0.5 items-center justify-start" class="ae_linked_file_count flex flex-row flex-wrap gap-0.5 items-center justify-start"
class:hidden={!journals_journal_entry_obj?.data_json?.hosted_file_kv} class:hidden={!journals_journal_entry_obj?.data_json
?.hosted_file_kv}
> >
<Files class="mx-1 inline-block" /> <Files class="mx-1 inline-block" />
<span class="text-xs text-gray-500 hidden md:inline">Linked files:</span> <span class="text-xs text-gray-500 hidden md:inline"
>Linked files:</span
>
<span class="font-semibold text-sm text-gray-500"> <span class="font-semibold text-sm text-gray-500">
{journals_journal_entry_obj?.data_json?.hosted_file_kv {journals_journal_entry_obj?.data_json
?.hosted_file_kv
? Object.keys( ? Object.keys(
journals_journal_entry_obj?.data_json?.hosted_file_kv journals_journal_entry_obj?.data_json
?.hosted_file_kv
).length ).length
: 0}× : 0}×
</span> </span>
@@ -381,7 +487,10 @@
class="tags flex flex-row flex-wrap gap-0.5 items-center justify-start p-1" class="tags flex flex-row flex-wrap gap-0.5 items-center justify-start p-1"
> >
<Tags class="mx-1 inline-block" /> <Tags class="mx-1 inline-block" />
<span class="text-xs text-gray-500 hidden md:inline">Tags:</span> <span
class="text-xs text-gray-500 hidden md:inline"
>Tags:</span
>
{#each journals_journal_entry_obj.tags.split(',') as tag} {#each journals_journal_entry_obj.tags.split(',') as tag}
<span <span
@@ -396,27 +505,36 @@
<!-- Category code for journal entry --> <!-- Category code for journal entry -->
{#if journals_journal_entry_obj.category_code} {#if journals_journal_entry_obj.category_code}
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
if ( if (
$journals_loc.entry.qry__category_code == $journals_loc.entry
.qry__category_code ==
journals_journal_entry_obj.category_code journals_journal_entry_obj.category_code
) { ) {
$journals_loc.entry.qry__category_code = null; $journals_loc.entry.qry__category_code =
null;
} else { } else {
$journals_loc.entry.qry__category_code = $journals_loc.entry.qry__category_code =
journals_journal_entry_obj.category_code; journals_journal_entry_obj.category_code;
} }
if ($journals_loc.entry.search_version === undefined) $journals_loc.entry.search_version = 0; if (
$journals_loc.entry.search_version ===
undefined
)
$journals_loc.entry.search_version = 0;
$journals_loc.entry.search_version++; $journals_loc.entry.search_version++;
}} }}
class:bg-green-100={$journals_loc.entry.qry__category_code == class:bg-green-100={$journals_loc.entry
.qry__category_code ==
journals_journal_entry_obj.category_code} journals_journal_entry_obj.category_code}
class="btn btn-sm variant-outline-secondary hover:preset-filled-secondary-500 transition py-1 px-2" class="btn btn-sm variant-outline-secondary hover:preset-filled-secondary-500 transition py-1 px-2"
title={`Filter by category: ${journals_journal_entry_obj.category_code}`} title={`Filter by category: ${journals_journal_entry_obj.category_code}`}
> >
<Shapes class="mx-1 inline-block" /> <Shapes class="mx-1 inline-block" />
{journals_journal_entry_obj.category_code ?? '-- no category --'} {journals_journal_entry_obj.category_code ??
'-- no category --'}
</button> </button>
{/if} {/if}
@@ -434,7 +552,8 @@ Journal ID: ${journals_journal_entry_obj?.journal_id}
</a> </a>
<!-- Button to show a modal that will allow for a quick append to Journal Entry option. --> <!-- Button to show a modal that will allow for a quick append to Journal Entry option. -->
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
$journals_sess.show__modal_append__journal_entry_id = $journals_sess.show__modal_append__journal_entry_id =
journals_journal_entry_obj?.id; journals_journal_entry_obj?.id;
@@ -443,7 +562,8 @@ Journal ID: ${journals_journal_entry_obj?.journal_id}
); );
}} }}
class="btn btn-icon btn-sm preset-tonal-surface border border-surface-500 hover:preset-filled-secondary-500 transition" class="btn btn-icon btn-sm preset-tonal-surface border border-surface-500 hover:preset-filled-secondary-500 transition"
title={$lq__journal_obj?.cfg_json?.entry_add_text == 'append' title={$lq__journal_obj?.cfg_json?.entry_add_text ==
'append'
? 'Append to Journal Entry' ? 'Append to Journal Entry'
: 'Prepend to Journal Entry'} : 'Prepend to Journal Entry'}
> >
@@ -456,11 +576,14 @@ Journal ID: ${journals_journal_entry_obj?.journal_id}
<div <div
class:hidden={journals_journal_entry_obj.hide || class:hidden={journals_journal_entry_obj.hide ||
(journals_journal_entry_obj.private && (journals_journal_entry_obj.private &&
$journals_slct.journal_obj?.cfg_json.hide_private) || $journals_slct.journal_obj?.cfg_json
.hide_private) ||
(journals_journal_entry_obj.personal && (journals_journal_entry_obj.personal &&
$journals_slct.journal_obj?.cfg_json.hide_personal) || $journals_slct.journal_obj?.cfg_json
.hide_personal) ||
(journals_journal_entry_obj.professional && (journals_journal_entry_obj.professional &&
$journals_slct.journal_obj?.cfg_json.hide_professional)} $journals_slct.journal_obj?.cfg_json
.hide_professional)}
class="journal__content class="journal__content
w-full p-1 w-full p-1
bg-slate-100 text-gray-900 bg-slate-100 text-gray-900
@@ -479,11 +602,13 @@ Journal ID: ${journals_journal_entry_obj?.journal_id}
? `${$journals_slct.journal_obj.cfg_json.entry_li_max_height}` ? `${$journals_slct.journal_obj.cfg_json.entry_li_max_height}`
: ''} : ''}
{$journals_slct.journal_obj.cfg_json.entry_li_click_max_height {$journals_slct.journal_obj.cfg_json
.entry_li_click_max_height
? `${$journals_slct.journal_obj.cfg_json.entry_li_click_max_height}` ? `${$journals_slct.journal_obj.cfg_json.entry_li_click_max_height}`
: ''} : ''}
{$journals_slct.journal_obj.cfg_json.entry_li_hover_max_height {$journals_slct.journal_obj.cfg_json
.entry_li_hover_max_height
? `${$journals_slct.journal_obj.cfg_json.entry_li_hover_max_height}` ? `${$journals_slct.journal_obj.cfg_json.entry_li_hover_max_height}`
: ''} : ''}
" "
@@ -509,9 +634,11 @@ Journal ID: ${journals_journal_entry_obj?.journal_id}
class:hidden={!journals_journal_entry_obj?.original_datetime && class:hidden={!journals_journal_entry_obj?.original_datetime &&
!journals_journal_entry_obj?.original_timezone} !journals_journal_entry_obj?.original_timezone}
> >
<span class="ae_label text-sm">Original date/time:</span> <span class="ae_label text-sm">Original date/time:</span
>
{#if journals_journal_entry_obj.original_datetime} {#if journals_journal_entry_obj.original_datetime}
<span class="ae_value ae_prop prop_original_datetime font-semibold" <span
class="ae_value ae_prop prop_original_datetime font-semibold"
>{ae_util.iso_datetime_formatter( >{ae_util.iso_datetime_formatter(
journals_journal_entry_obj.original_datetime, journals_journal_entry_obj.original_datetime,
'datetime_12_long' 'datetime_12_long'
@@ -531,7 +658,8 @@ Journal ID: ${journals_journal_entry_obj?.journal_id}
class="ae_meta mt-2 flex flex-col sm:flex-row gap-2 items-center justify-center text-xs text-gray-500" class="ae_meta mt-2 flex flex-col sm:flex-row gap-2 items-center justify-center text-xs text-gray-500"
> >
<span <span
class:hidden={!$ae_loc.trusted_access || !$ae_loc.edit_mode} class:hidden={!$ae_loc.trusted_access ||
!$ae_loc.edit_mode}
class="flex flex-row gap-1 items-center justify-center" class="flex flex-row gap-1 items-center justify-center"
> >
<span class="journal_entry__created_on"> <span class="journal_entry__created_on">
@@ -554,22 +682,28 @@ Journal ID: ${journals_journal_entry_obj?.journal_id}
</span> </span>
<!-- Set/unset hide (boolean) --> <!-- Set/unset hide (boolean) -->
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
let data_kv = { let data_kv = {
hide: journals_journal_entry_obj?.hide ? false : true hide: journals_journal_entry_obj?.hide
? false
: true
}; };
journals_func journals_func
.update_ae_obj__journal_entry({ .update_ae_obj__journal_entry({
api_cfg: $ae_api, api_cfg: $ae_api,
journal_entry_id: journals_journal_entry_obj.journal_entry_id, journal_entry_id:
journals_journal_entry_obj.journal_entry_id,
data_kv: data_kv, data_kv: data_kv,
log_lvl: log_lvl log_lvl: log_lvl
}) })
.then(() => { .then(() => {})
})
.catch((error) => { .catch((error) => {
console.error('Error updating journal entry:', error); console.error(
'Error updating journal entry:',
error
);
alert('Failed to update journal entry.'); alert('Failed to update journal entry.');
}); });
}} }}
@@ -609,9 +743,14 @@ Journal ID: ${journals_journal_entry_obj?.journal_id}
/> />
{/if} {/if}
{:else} {:else}
<div class="flex flex-col items-center justify-center p-10 opacity-50 text-center"> <div
class="flex flex-col items-center justify-center p-10 opacity-50 text-center"
>
<BookOpenText size="3em" class="mb-2 opacity-20 mx-auto" /> <BookOpenText size="3em" class="mb-2 opacity-20 mx-auto" />
<p>No Journal Entry available to show. Please check the query filters or create a new Entry.</p> <p>
No Journal Entry available to show. Please check the query
filters or create a new Entry.
</p>
</div> </div>
{/if} {/if}
</section> </section>

View File

@@ -76,25 +76,29 @@
$journals_loc.entry.search_version++; $journals_loc.entry.search_version++;
} }
function preventDefault<T extends Event>(fn: (event: T) => void) { function prevent_default<T extends Event>(fn: (event: T) => void) {
return function (event: T) { return function (event: T) {
event.preventDefault(); event.prevent_default();
fn(event); fn(event);
}; };
} }
</script> </script>
<div class="ae_group filters_and_search flex flex-row flex-wrap items-center justify-center gap-2"> <div
class="ae_group filters_and_search flex flex-row flex-wrap items-center justify-center gap-2"
>
<!-- Search input form --> <!-- Search input form -->
<span class="flex flex-row flex-wrap items-center justify-center gap-1"> <span class="flex flex-row flex-wrap items-center justify-center gap-1">
<form <form
onsubmit={preventDefault(() => { onsubmit={prevent_default(() => {
handle_search_trigger(); handle_search_trigger();
})} })}
autocomplete="off" autocomplete="off"
class="search_form flex flex-row flex-wrap gap-1 items-center justify-center" class="search_form flex flex-row flex-wrap gap-1 items-center justify-center"
> >
<span class="text-sm text-gray-500 hidden lg:inline"> Search: </span> <span class="text-sm text-gray-500 hidden lg:inline">
Search:
</span>
<input <input
disabled={false} disabled={false}
type="text" type="text"
@@ -125,7 +129,8 @@
<!-- Clear search text button --> <!-- Clear search text button -->
<button <button
type="button" type="button"
class:hidden={!$journals_loc.entry.qry__search_text && !$journals_loc.entry.qry__category_code} class:hidden={!$journals_loc.entry.qry__search_text &&
!$journals_loc.entry.qry__category_code}
onclick={() => { onclick={() => {
$journals_loc.entry.qry__search_text = ''; $journals_loc.entry.qry__search_text = '';
$journals_loc.entry.qry__category_code = ''; $journals_loc.entry.qry__category_code = '';
@@ -140,7 +145,10 @@
" "
title="Clear search query text" title="Clear search query text"
> >
<RemoveFormatting size="1.25em" class="text-neutral-800/60 dark:text-neutral-50/60" /> <RemoveFormatting
size="1.25em"
class="text-neutral-800/60 dark:text-neutral-50/60"
/>
<span class="hidden md:inline"> Clear </span> <span class="hidden md:inline"> Clear </span>
</button> </button>
</form> </form>
@@ -171,7 +179,9 @@
</span> </span>
<!-- Search Control Toggles --> <!-- Search Control Toggles -->
<span class="flex flex-row flex-wrap items-center gap-2 border-l border-surface-300-700 pl-2"> <span
class="flex flex-row flex-wrap items-center gap-2 border-l border-surface-300-700 pl-2"
>
<!-- Global Search hidden until backend supports person_id in entries 2026-01-27 --> <!-- Global Search hidden until backend supports person_id in entries 2026-01-27 -->
<!-- <!--
<label <label
@@ -193,7 +203,9 @@
class="flex items-center gap-1 cursor-pointer" class="flex items-center gap-1 cursor-pointer"
title="When enabled, search results are fetched directly from the server first." title="When enabled, search results are fetched directly from the server first."
> >
<span class="text-xs font-semibold text-gray-500"> Remote First? </span> <span class="text-xs font-semibold text-gray-500">
Remote First?
</span>
<input <input
type="checkbox" type="checkbox"
bind:checked={$journals_loc.entry.qry__remote_first} bind:checked={$journals_loc.entry.qry__remote_first}

View File

@@ -1,19 +1,23 @@
<script lang="ts"> <script lang="ts">
import { api } from '$lib/api/api'; import { api } from '$lib/api/api';
import { ae_api } from '$lib/stores/ae_stores'; import { ae_api } from '$lib/stores/ae_stores';
import { journals_slct, journals_loc, journals_trig } from '$lib/ae_journals/ae_journals_stores'; import {
journals_slct,
journals_loc,
journals_trig
} from '$lib/ae_journals/ae_journals_stores';
import { journals_func } from '$lib/ae_journals/ae_journals_functions'; import { journals_func } from '$lib/ae_journals/ae_journals_functions';
import { BookType } from 'lucide-svelte'; import { BookType } from 'lucide-svelte';
// Props // Props
let { let {
class: className = "", class: className = '',
placeholder = "Type your quick note... (First line = Title)", placeholder = 'Type your quick note... (First line = Title)',
journals_li = [] // Optional list of journals to select from journals_li = [] // Optional list of journals to select from
} = $props(); } = $props();
// State // State
let note_content = $state(""); let note_content = $state('');
let is_submitting = $state(false); let is_submitting = $state(false);
// Derived / Local target // Derived / Local target
@@ -21,12 +25,14 @@
let selected_journal_id = $state($journals_loc.entry.qry__journal_id); let selected_journal_id = $state($journals_loc.entry.qry__journal_id);
// If a journal is explicitly selected via slct (e.g. we are in a journal view), use that // If a journal is explicitly selected via slct (e.g. we are in a journal view), use that
let target_journal_id = $derived($journals_slct.journal_id || selected_journal_id); let target_journal_id = $derived(
$journals_slct.journal_id || selected_journal_id
);
async function handle_submit() { async function handle_submit() {
if (!note_content.trim()) return; if (!note_content.trim()) return;
if (!target_journal_id) { if (!target_journal_id) {
alert("Please select a target journal first."); alert('Please select a target journal first.');
return; return;
} }
@@ -34,7 +40,7 @@
const lines = note_content.trim().split('\n'); const lines = note_content.trim().split('\n');
let name = lines[0].substring(0, 100); let name = lines[0].substring(0, 100);
if (lines[0].length > 100) name += "..."; if (lines[0].length > 100) name += '...';
// Remove the first line (title) from the content // Remove the first line (title) from the content
const entry_content = lines.slice(1).join('\n').trim(); const entry_content = lines.slice(1).join('\n').trim();
@@ -57,15 +63,15 @@
}); });
if (res) { if (res) {
note_content = ""; note_content = '';
// Trigger refresh // Trigger refresh
$journals_trig.journal_entry_li = true; $journals_trig.journal_entry_li = true;
} else { } else {
alert("Failed to create note."); alert('Failed to create note.');
} }
} catch (error) { } catch (error) {
console.error("Error creating journal entry:", error); console.error('Error creating journal entry:', error);
alert("Failed to create note."); alert('Failed to create note.');
} }
is_submitting = false; is_submitting = false;
@@ -85,7 +91,9 @@
</script> </script>
<div class="card p-4 space-y-4 variant-filled-surface {className}"> <div class="card p-4 space-y-4 variant-filled-surface {className}">
<header class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-2"> <header
class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-2"
>
<h3 class="h3 flex items-center gap-2"> <h3 class="h3 flex items-center gap-2">
<BookType size="1.2em" class="text-primary-500" /> <BookType size="1.2em" class="text-primary-500" />
Quick Add Quick Add
@@ -98,7 +106,9 @@
value={target_journal_id} value={target_journal_id}
onchange={handle_journal_change} onchange={handle_journal_change}
> >
<option value="" disabled selected={!target_journal_id}>Select Target Journal...</option> <option value="" disabled selected={!target_journal_id}
>Select Target Journal...</option
>
{#each journals_li as journal} {#each journals_li as journal}
<option value={journal.id}>{journal.name}</option> <option value={journal.id}>{journal.name}</option>
{/each} {/each}
@@ -119,14 +129,16 @@
></textarea> ></textarea>
<div class="flex justify-between items-center"> <div class="flex justify-between items-center">
<span class="text-[10px] opacity-50 font-mono uppercase tracking-tighter hidden sm:block"> <span
class="text-[10px] opacity-50 font-mono uppercase tracking-tighter hidden sm:block"
>
Press Ctrl + Enter to save Press Ctrl + Enter to save
</span> </span>
<div class="flex justify-end space-x-2 grow sm:grow-0"> <div class="flex justify-end space-x-2 grow sm:grow-0">
<button <button
type="button" type="button"
class="btn btn-sm variant-ghost-surface" class="btn btn-sm variant-ghost-surface"
onclick={() => note_content = ""} onclick={() => (note_content = '')}
disabled={is_submitting || note_content.length === 0} disabled={is_submitting || note_content.length === 0}
> >
Clear Clear
@@ -135,7 +147,9 @@
type="button" type="button"
class="btn btn-sm variant-filled-primary font-bold shadow-md" class="btn btn-sm variant-filled-primary font-bold shadow-md"
onclick={handle_submit} onclick={handle_submit}
disabled={is_submitting || !target_journal_id || note_content.length === 0} disabled={is_submitting ||
!target_journal_id ||
note_content.length === 0}
> >
{#if is_submitting}Saving...{:else}Add Note{/if} {#if is_submitting}Saving...{:else}Add Note{/if}
</button> </button>

View File

@@ -44,10 +44,7 @@
import { untrack } from 'svelte'; import { untrack } from 'svelte';
// *** Import Aether specific variables and functions // *** Import Aether specific variables and functions
import { import { ae_loc, ae_api } from '$lib/stores/ae_stores';
ae_loc,
ae_api
} from '$lib/stores/ae_stores';
import { import {
journals_loc, journals_loc,
journals_sess, journals_sess,
@@ -75,7 +72,8 @@
}: Props = $props(); }: Props = $props();
// *** Internal State // *** Internal State
let tab: 'actions' | 'general' | 'security' | 'ui' | 'json' = $state('actions'); let tab: 'actions' | 'general' | 'security' | 'ui' | 'json' =
$state('actions');
let tmp__journal_obj: any = $state({}); let tmp__journal_obj: any = $state({});
// Deep copy on mount or when lq changes to ensure we have a working copy // Deep copy on mount or when lq changes to ensure we have a working copy
@@ -83,10 +81,16 @@
if (show && $lq__journal_obj) { if (show && $lq__journal_obj) {
const source_id = $lq__journal_obj.journal_id; const source_id = $lq__journal_obj.journal_id;
untrack(() => { untrack(() => {
if (!tmp__journal_obj.journal_id || tmp__journal_obj.journal_id !== source_id) { if (
tmp__journal_obj = JSON.parse(JSON.stringify($lq__journal_obj)); !tmp__journal_obj.journal_id ||
tmp__journal_obj.journal_id !== source_id
) {
tmp__journal_obj = JSON.parse(
JSON.stringify($lq__journal_obj)
);
// Ensure cfg_json exists // Ensure cfg_json exists
if (!tmp__journal_obj.cfg_json) tmp__journal_obj.cfg_json = {}; if (!tmp__journal_obj.cfg_json)
tmp__journal_obj.cfg_json = {};
} }
}); });
} }
@@ -145,7 +149,11 @@
} }
async function delete_journal() { async function delete_journal() {
if (confirm(`CRITICAL WARNING: Are you sure you want to delete the journal "${$lq__journal_obj.name}"? This will delete all entries associated with it.`)) { if (
confirm(
`CRITICAL WARNING: Are you sure you want to delete the journal "${$lq__journal_obj.name}"? This will delete all entries associated with it.`
)
) {
try { try {
await journals_func.delete_ae_obj_id__journal({ await journals_func.delete_ae_obj_id__journal({
api_cfg: $ae_api, api_cfg: $ae_api,
@@ -180,20 +188,52 @@
<div class="space-y-6 py-2 h-[75vh] overflow-y-auto px-4"> <div class="space-y-6 py-2 h-[75vh] overflow-y-auto px-4">
<!-- Navigation Tabs --> <!-- 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"> <div
<button type="button" class="btn btn-sm transition-all {tab === 'actions' ? 'variant-filled-primary' : 'variant-soft-surface'}" onclick={() => (tab = 'actions')}> 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"
>
<button
type="button"
class="btn btn-sm transition-all {tab === 'actions'
? 'variant-filled-primary'
: 'variant-soft-surface'}"
onclick={() => (tab = 'actions')}
>
<Zap size="1.1em" class="mr-1" /> Quick Actions <Zap size="1.1em" class="mr-1" /> Quick Actions
</button> </button>
<button type="button" class="btn btn-sm transition-all {tab === 'general' ? 'variant-filled-primary' : 'variant-soft-surface'}" onclick={() => (tab = 'general')}> <button
type="button"
class="btn btn-sm transition-all {tab === 'general'
? 'variant-filled-primary'
: 'variant-soft-surface'}"
onclick={() => (tab = 'general')}
>
<Layout size="1.1em" class="mr-1" /> General <Layout size="1.1em" class="mr-1" /> General
</button> </button>
<button type="button" class="btn btn-sm transition-all {tab === 'security' ? 'variant-filled-primary' : 'variant-soft-surface'}" onclick={() => (tab = 'security')}> <button
type="button"
class="btn btn-sm transition-all {tab === 'security'
? 'variant-filled-primary'
: 'variant-soft-surface'}"
onclick={() => (tab = 'security')}
>
<ShieldCheck size="1.1em" class="mr-1" /> Status & Security <ShieldCheck size="1.1em" class="mr-1" /> Status & Security
</button> </button>
<button type="button" class="btn btn-sm transition-all {tab === 'ui' ? 'variant-filled-primary' : 'variant-soft-surface'}" onclick={() => (tab = 'ui')}> <button
type="button"
class="btn btn-sm transition-all {tab === 'ui'
? 'variant-filled-primary'
: 'variant-soft-surface'}"
onclick={() => (tab = 'ui')}
>
<Palette size="1.1em" class="mr-1" /> UI/Visuals <Palette size="1.1em" class="mr-1" /> UI/Visuals
</button> </button>
<button type="button" class="btn btn-sm transition-all {tab === 'json' ? 'variant-filled-primary' : 'variant-soft-surface'}" onclick={() => (tab = 'json')}> <button
type="button"
class="btn btn-sm transition-all {tab === 'json'
? 'variant-filled-primary'
: 'variant-soft-surface'}"
onclick={() => (tab = 'json')}
>
<CodeXml size="1.1em" class="mr-1" /> JSON <CodeXml size="1.1em" class="mr-1" /> JSON
</button> </button>
</div> </div>
@@ -201,111 +241,241 @@
{#if tab === 'actions'} {#if tab === 'actions'}
<div class="space-y-6 animate-in fade-in duration-300"> <div class="space-y-6 animate-in fade-in duration-300">
<section class="grid grid-cols-1 md:grid-cols-2 gap-4"> <section class="grid grid-cols-1 md:grid-cols-2 gap-4">
<button type="button" class="btn variant-soft-secondary w-full py-4 text-lg font-bold" onclick={() => { show = false; on_new_entry?.(); }}> <button
<FilePlus size="1.5em" class="mr-2"/> New Journal Entry type="button"
class="btn variant-soft-secondary w-full py-4 text-lg font-bold"
onclick={() => {
show = false;
on_new_entry?.();
}}
>
<FilePlus size="1.5em" class="mr-2" /> New Journal Entry
</button> </button>
<button type="button" class="btn variant-soft-surface w-full py-4" onclick={() => { show = false; on_show_export?.(); }}> <button
<FileDown size="1.5em" class="mr-2"/> Export Entries type="button"
class="btn variant-soft-surface w-full py-4"
onclick={() => {
show = false;
on_show_export?.();
}}
>
<FileDown size="1.5em" class="mr-2" /> Export Entries
</button> </button>
<button type="button" class="btn variant-soft-surface w-full py-4" onclick={() => { show = false; on_show_import?.(); }}> <button
<FileUp size="1.5em" class="mr-2"/> Import Entries type="button"
class="btn variant-soft-surface w-full py-4"
onclick={() => {
show = false;
on_show_import?.();
}}
>
<FileUp size="1.5em" class="mr-2" /> Import Entries
</button> </button>
</section> </section>
</div> </div>
{:else if tab === 'general'} {:else if tab === 'general'}
<div class="space-y-6 animate-in fade-in duration-300"> <div class="space-y-6 animate-in fade-in duration-300">
<!-- Core Meta --> <!-- Core Meta -->
<section class="grid grid-cols-1 gap-4 p-2"> <section class="grid grid-cols-1 gap-4 p-2">
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Journal Name</span> <span class="text-sm font-bold opacity-70"
<input type="text" bind:value={tmp__journal_obj.name} class="input variant-form-material" placeholder="e.g. Personal Log" /> >Journal Name</span
>
<input
type="text"
bind:value={tmp__journal_obj.name}
class="input variant-form-material"
placeholder="e.g. Personal Log"
/>
</label> </label>
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Description (Markdown)</span> <span class="text-sm font-bold opacity-70"
<textarea bind:value={tmp__journal_obj.description} class="textarea variant-form-material h-32" placeholder="Describe the purpose of this journal..."></textarea> >Description (Markdown)</span
>
<textarea
bind:value={tmp__journal_obj.description}
class="textarea variant-form-material h-32"
placeholder="Describe the purpose of this journal..."
></textarea>
</label> </label>
<div class="grid grid-cols-2 gap-4"> <div class="grid grid-cols-2 gap-4">
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Type</span> <span class="text-sm font-bold opacity-70"
<select bind:value={tmp__journal_obj.type_code} class="select variant-form-material"> >Type</span
>
<select
bind:value={tmp__journal_obj.type_code}
class="select variant-form-material"
>
{#each $journals_loc.journal.type_code_li as type} {#each $journals_loc.journal.type_code_li as type}
<option value={type.code}>{type.name}</option> <option value={type.code}
>{type.name}</option
>
{/each} {/each}
</select> </select>
</label> </label>
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Sort Group</span> <span class="text-sm font-bold opacity-70"
<input type="text" bind:value={tmp__journal_obj.group} class="input variant-form-material" placeholder="Standard" /> >Sort Group</span
>
<input
type="text"
bind:value={tmp__journal_obj.group}
class="input variant-form-material"
placeholder="Standard"
/>
</label> </label>
</div> </div>
</section> </section>
<!-- Categories --> <!-- Categories -->
<section class="space-y-4 p-2"> <section class="space-y-4 p-2">
<h2 class="text-lg font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"> <h2
class="text-lg font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
<MonitorPlay size="1em" class="text-primary-500" /> <MonitorPlay size="1em" class="text-primary-500" />
Journal Categories Journal Categories
</h2> </h2>
<div class="space-y-2 bg-surface-500/5 p-4 rounded-lg border border-surface-500/10"> <div
class="space-y-2 bg-surface-500/5 p-4 rounded-lg border border-surface-500/10"
>
{#each tmp__journal_obj?.cfg_json?.category_li ?? [] as category, i} {#each tmp__journal_obj?.cfg_json?.category_li ?? [] as category, i}
<div class="flex gap-2 items-center"> <div class="flex gap-2 items-center">
<input type="text" bind:value={category.code} class="input input-sm w-32" placeholder="Code" /> <input
<input type="text" bind:value={category.name} class="input input-sm grow" placeholder="Display Name" /> type="text"
<button type="button" class="btn-icon btn-icon-sm variant-soft-error" onclick={() => { tmp__journal_obj.cfg_json.category_li.splice(i, 1); }}> bind:value={category.code}
class="input input-sm w-32"
placeholder="Code"
/>
<input
type="text"
bind:value={category.name}
class="input input-sm grow"
placeholder="Display Name"
/>
<button
type="button"
class="btn-icon btn-icon-sm variant-soft-error"
onclick={() => {
tmp__journal_obj.cfg_json.category_li.splice(
i,
1
);
}}
>
<Minus size="1em" /> <Minus size="1em" />
</button> </button>
</div> </div>
{/each} {/each}
<button type="button" class="btn btn-sm variant-soft-primary w-full mt-2" onclick={() => { <button
if(!tmp__journal_obj.cfg_json.category_li) tmp__journal_obj.cfg_json.category_li = []; type="button"
tmp__journal_obj.cfg_json.category_li.push({code: '', name: ''}); class="btn btn-sm variant-soft-primary w-full mt-2"
}}> onclick={() => {
if (!tmp__journal_obj.cfg_json.category_li)
tmp__journal_obj.cfg_json.category_li = [];
tmp__journal_obj.cfg_json.category_li.push({
code: '',
name: ''
});
}}
>
<Plus size="1em" class="mr-1" /> Add Category <Plus size="1em" class="mr-1" /> Add Category
</button> </button>
</div> </div>
</section> </section>
</div> </div>
{:else if tab === 'security'} {:else if tab === 'security'}
<div class="space-y-6 animate-in fade-in duration-300"> <div class="space-y-6 animate-in fade-in duration-300">
<!-- Status & Lifecycle --> <!-- Status & Lifecycle -->
<section class="space-y-4 p-2"> <section class="space-y-4 p-2">
<h2 class="text-lg font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"> <h2
class="text-lg font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
<Fingerprint size="1.2em" class="text-primary-500" /> <Fingerprint size="1.2em" class="text-primary-500" />
Status & Lifecycle Status & Lifecycle
</h2> </h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<label class="flex items-center space-x-3 cursor-pointer p-3 rounded-lg bg-surface-500/5 border border-surface-500/10 transition-colors hover:bg-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp__journal_obj.enable} onchange={() => handle_update_journal(false)} class="checkbox checkbox-primary" /> class="flex items-center space-x-3 cursor-pointer p-3 rounded-lg bg-surface-500/5 border border-surface-500/10 transition-colors hover:bg-surface-500/10"
>
<input
type="checkbox"
bind:checked={tmp__journal_obj.enable}
onchange={() => handle_update_journal(false)}
class="checkbox checkbox-primary"
/>
<div class="flex flex-col"> <div class="flex flex-col">
<span class="font-bold">Enabled</span> <span class="font-bold">Enabled</span>
<span class="text-xs opacity-60">Allow access to this journal</span> <span class="text-xs opacity-60"
>Allow access to this journal</span
>
</div> </div>
</label> </label>
<label class="flex items-center space-x-3 cursor-pointer p-3 rounded-lg bg-surface-500/5 border border-surface-500/10 transition-colors hover:bg-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp__journal_obj.hide} onchange={() => handle_update_journal(false)} class="checkbox checkbox-primary" /> class="flex items-center space-x-3 cursor-pointer p-3 rounded-lg bg-surface-500/5 border border-surface-500/10 transition-colors hover:bg-surface-500/10"
>
<input
type="checkbox"
bind:checked={tmp__journal_obj.hide}
onchange={() => handle_update_journal(false)}
class="checkbox checkbox-primary"
/>
<div class="flex flex-col"> <div class="flex flex-col">
<span class="font-bold">Hidden</span> <span class="font-bold">Hidden</span>
<span class="text-xs opacity-60">Hide from standard lists</span> <span class="text-xs opacity-60"
>Hide from standard lists</span
>
</div> </div>
</label> </label>
<label class="flex items-center space-x-3 cursor-pointer p-3 rounded-lg bg-surface-500/5 border border-surface-500/10 transition-colors hover:bg-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp__journal_obj.priority} onchange={() => handle_update_journal(false)} class="checkbox checkbox-primary" /> class="flex items-center space-x-3 cursor-pointer p-3 rounded-lg bg-surface-500/5 border border-surface-500/10 transition-colors hover:bg-surface-500/10"
>
<input
type="checkbox"
bind:checked={tmp__journal_obj.priority}
onchange={() => handle_update_journal(false)}
class="checkbox checkbox-primary"
/>
<div class="flex flex-col"> <div class="flex flex-col">
<span class="font-bold">Priority Journal</span> <span class="font-bold">Priority Journal</span>
<span class="text-xs opacity-60">Star or pin to top</span> <span class="text-xs opacity-60"
>Star or pin to top</span
>
</div> </div>
</label> </label>
<div class="flex items-center justify-between p-3 rounded-lg bg-surface-500/5 border border-surface-500/10"> <div
class="flex items-center justify-between p-3 rounded-lg bg-surface-500/5 border border-surface-500/10"
>
<div class="flex flex-col"> <div class="flex flex-col">
<span class="font-bold text-sm">Sort Order</span> <span class="font-bold text-sm">Sort Order</span
<span class="text-xs opacity-60">Manual list position</span> >
<span class="text-xs opacity-60"
>Manual list position</span
>
</div> </div>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<button type="button" class="btn-icon btn-icon-sm variant-soft-surface" onclick={() => { tmp__journal_obj.sort = (tmp__journal_obj.sort ?? 0) - 1; handle_update_journal(false); }}><Minus size="1em"/></button> <button
<span class="font-mono font-bold w-8 text-center text-lg">{tmp__journal_obj.sort ?? 0}</span> type="button"
<button type="button" class="btn-icon btn-icon-sm variant-soft-surface" onclick={() => { tmp__journal_obj.sort = (tmp__journal_obj.sort ?? 0) + 1; handle_update_journal(false); }}><Plus size="1em"/></button> class="btn-icon btn-icon-sm variant-soft-surface"
onclick={() => {
tmp__journal_obj.sort =
(tmp__journal_obj.sort ?? 0) - 1;
handle_update_journal(false);
}}><Minus size="1em" /></button
>
<span
class="font-mono font-bold w-8 text-center text-lg"
>{tmp__journal_obj.sort ?? 0}</span
>
<button
type="button"
class="btn-icon btn-icon-sm variant-soft-surface"
onclick={() => {
tmp__journal_obj.sort =
(tmp__journal_obj.sort ?? 0) + 1;
handle_update_journal(false);
}}><Plus size="1em" /></button
>
</div> </div>
</div> </div>
</div> </div>
@@ -313,64 +483,126 @@
<!-- Encryption Passcodes --> <!-- Encryption Passcodes -->
<section class="space-y-4 p-2"> <section class="space-y-4 p-2">
<h2 class="text-lg font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"> <h2
class="text-lg font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
<LockKeyhole size="1.2em" class="text-primary-500" /> <LockKeyhole size="1.2em" class="text-primary-500" />
Encryption Passcodes Encryption Passcodes
</h2> </h2>
<div class="bg-warning-500/10 border border-warning-500/30 p-4 rounded-lg space-y-4 shadow-inner"> <div
class="bg-warning-500/10 border border-warning-500/30 p-4 rounded-lg space-y-4 shadow-inner"
>
<label class="label"> <label class="label">
<span class="text-xs font-bold uppercase tracking-wider opacity-70">Primary Passcode (Stored)</span> <span
class="text-xs font-bold uppercase tracking-wider opacity-70"
>Primary Passcode (Stored)</span
>
<div class="flex gap-2"> <div class="flex gap-2">
<input type="password" bind:value={tmp__journal_obj.passcode} class="input variant-form-material grow" placeholder="Module-level passcode" /> <input
type="password"
bind:value={tmp__journal_obj.passcode}
class="input variant-form-material grow"
placeholder="Module-level passcode"
/>
<Fingerprint class="opacity-30" /> <Fingerprint class="opacity-30" />
</div> </div>
</label> </label>
<label class="label"> <label class="label">
<span class="text-xs font-bold uppercase tracking-wider opacity-70">Private Passcode (Double Encryption)</span> <span
class="text-xs font-bold uppercase tracking-wider opacity-70"
>Private Passcode (Double Encryption)</span
>
<div class="flex gap-2"> <div class="flex gap-2">
<input type="password" bind:value={tmp__journal_obj.private_passcode} class="input variant-form-material grow" placeholder="User-level secret" /> <input
type="password"
bind:value={
tmp__journal_obj.private_passcode
}
class="input variant-form-material grow"
placeholder="User-level secret"
/>
<ShieldCheck class="opacity-30" /> <ShieldCheck class="opacity-30" />
</div> </div>
</label> </label>
<div class="text-[10px] text-warning-700 dark:text-warning-300 italic"> <div
* Note: Passcodes are used locally for E2EE. Primary is often stored in the DB, while Private should remain known only to you. class="text-[10px] text-warning-700 dark:text-warning-300 italic"
>
* Note: Passcodes are used locally for E2EE. Primary
is often stored in the DB, while Private should
remain known only to you.
</div> </div>
</div> </div>
</section> </section>
<section class="pt-8"> <section class="pt-8">
<button type="button" class="btn btn-sm variant-filled-error w-full shadow-lg" onclick={delete_journal}> <button
type="button"
class="btn btn-sm variant-filled-error w-full shadow-lg"
onclick={delete_journal}
>
<Trash2 size="1.1em" class="mr-2" /> Delete Entire Journal <Trash2 size="1.1em" class="mr-2" /> Delete Entire Journal
</button> </button>
</section> </section>
</div> </div>
{:else if tab === 'ui'} {:else if tab === 'ui'}
<div class="space-y-8 animate-in fade-in duration-300"> <div class="space-y-8 animate-in fade-in duration-300">
<section class="space-y-4 p-2"> <section class="space-y-4 p-2">
<h2 class="text-lg font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"> <h2
class="text-lg font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
<MonitorPlay size="1.2em" class="text-primary-500" /> <MonitorPlay size="1.2em" class="text-primary-500" />
Default View Modes Default View Modes
</h2> </h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 bg-surface-500/5 p-4 rounded-lg border border-surface-500/10"> <div
class="grid grid-cols-1 md:grid-cols-2 gap-6 bg-surface-500/5 p-4 rounded-lg border border-surface-500/10"
>
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Preferred Viewer</span> <span class="text-sm font-bold opacity-70"
<select bind:value={tmp__journal_obj.cfg_json.pref_viewer} class="select variant-form-material"> >Preferred Viewer</span
<option value="rendered">Rendered HTML (Default)</option> >
<select
bind:value={
tmp__journal_obj.cfg_json.pref_viewer
}
class="select variant-form-material"
>
<option value="rendered"
>Rendered HTML (Default)</option
>
<option value="plain">Plain Text</option> <option value="plain">Plain Text</option>
<option value="codemirror">CodeMirror (Syntax)</option> <option value="codemirror"
>CodeMirror (Syntax)</option
>
</select> </select>
</label> </label>
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Preferred Editor</span> <span class="text-sm font-bold opacity-70"
<select bind:value={tmp__journal_obj.cfg_json.pref_editor} class="select variant-form-material"> >Preferred Editor</span
<option value="textarea">Standard Textarea</option> >
<option value="codemirror">CodeMirror (Advanced)</option> <select
bind:value={
tmp__journal_obj.cfg_json.pref_editor
}
class="select variant-form-material"
>
<option value="textarea"
>Standard Textarea</option
>
<option value="codemirror"
>CodeMirror (Advanced)</option
>
</select> </select>
</label> </label>
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Color Scheme</span> <span class="text-sm font-bold opacity-70"
<select bind:value={tmp__journal_obj.cfg_json.color_scheme} class="select variant-form-material"> >Color Scheme</span
>
<select
bind:value={
tmp__journal_obj.cfg_json.color_scheme
}
class="select variant-form-material"
>
<option value="">Default (Slate)</option> <option value="">Default (Slate)</option>
<option value="blue">Deep Blue</option> <option value="blue">Deep Blue</option>
<option value="green">Nature Green</option> <option value="green">Nature Green</option>
@@ -380,10 +612,20 @@
</select> </select>
</label> </label>
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Quick Add Placement</span> <span class="text-sm font-bold opacity-70"
<select bind:value={tmp__journal_obj.cfg_json.entry_add_text} class="select variant-form-material"> >Quick Add Placement</span
<option value="append">Append to End (Default)</option> >
<option value="prepend">Prepend to Start</option> <select
bind:value={
tmp__journal_obj.cfg_json.entry_add_text
}
class="select variant-form-material"
>
<option value="append"
>Append to End (Default)</option
>
<option value="prepend">Prepend to Start</option
>
</select> </select>
</label> </label>
</div> </div>
@@ -391,106 +633,252 @@
<!-- Visibility Toggles (Restored) --> <!-- Visibility Toggles (Restored) -->
<section class="space-y-4 p-2"> <section class="space-y-4 p-2">
<h2 class="text-lg font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"> <h2
class="text-lg font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
<Eye size="1.2em" class="text-primary-500" /> <Eye size="1.2em" class="text-primary-500" />
Entry Visibility (Global) Entry Visibility (Global)
</h2> </h2>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2"> <div
<label class="flex items-center space-x-2 cursor-pointer p-2 bg-surface-500/5 rounded border border-surface-500/10"> class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2"
<input type="checkbox" bind:checked={tmp__journal_obj.cfg_json.hide_private} class="checkbox checkbox-sm" /> >
<label
class="flex items-center space-x-2 cursor-pointer p-2 bg-surface-500/5 rounded border border-surface-500/10"
>
<input
type="checkbox"
bind:checked={
tmp__journal_obj.cfg_json.hide_private
}
class="checkbox checkbox-sm"
/>
<span class="text-xs font-bold">Hide Private</span> <span class="text-xs font-bold">Hide Private</span>
</label> </label>
<label class="flex items-center space-x-2 cursor-pointer p-2 bg-surface-500/5 rounded border border-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp__journal_obj.cfg_json.hide_personal} class="checkbox checkbox-sm" /> class="flex items-center space-x-2 cursor-pointer p-2 bg-surface-500/5 rounded border border-surface-500/10"
>
<input
type="checkbox"
bind:checked={
tmp__journal_obj.cfg_json.hide_personal
}
class="checkbox checkbox-sm"
/>
<span class="text-xs font-bold">Hide Personal</span> <span class="text-xs font-bold">Hide Personal</span>
</label> </label>
<label class="flex items-center space-x-2 cursor-pointer p-2 bg-surface-500/5 rounded border border-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp__journal_obj.cfg_json.hide_professional} class="checkbox checkbox-sm" /> class="flex items-center space-x-2 cursor-pointer p-2 bg-surface-500/5 rounded border border-surface-500/10"
<span class="text-xs font-bold">Hide Professional</span> >
<input
type="checkbox"
bind:checked={
tmp__journal_obj.cfg_json.hide_professional
}
class="checkbox checkbox-sm"
/>
<span class="text-xs font-bold"
>Hide Professional</span
>
</label> </label>
</div> </div>
</section> </section>
<!-- Button Toggles (Restored) --> <!-- Button Toggles (Restored) -->
<section class="space-y-4 p-2"> <section class="space-y-4 p-2">
<h2 class="text-lg font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"> <h2
class="text-lg font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
<Settings size="1.2em" class="text-primary-500" /> <Settings size="1.2em" class="text-primary-500" />
Entry Feature Buttons Entry Feature Buttons
</h2> </h2>
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-2"> <div
<label class="flex items-center gap-2 p-2 bg-surface-500/5 rounded border border-surface-500/10"> class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-2"
<input type="checkbox" bind:checked={tmp__journal_obj.cfg_json.hide_btn_alert} class="checkbox checkbox-sm" /> >
<span class="text-[10px] uppercase font-bold">Hide Alert</span> <label
class="flex items-center gap-2 p-2 bg-surface-500/5 rounded border border-surface-500/10"
>
<input
type="checkbox"
bind:checked={
tmp__journal_obj.cfg_json.hide_btn_alert
}
class="checkbox checkbox-sm"
/>
<span class="text-[10px] uppercase font-bold"
>Hide Alert</span
>
</label> </label>
<label class="flex items-center gap-2 p-2 bg-surface-500/5 rounded border border-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp__journal_obj.cfg_json.hide_btn_private} class="checkbox checkbox-sm" /> class="flex items-center gap-2 p-2 bg-surface-500/5 rounded border border-surface-500/10"
<span class="text-[10px] uppercase font-bold">Hide Private</span> >
<input
type="checkbox"
bind:checked={
tmp__journal_obj.cfg_json.hide_btn_private
}
class="checkbox checkbox-sm"
/>
<span class="text-[10px] uppercase font-bold"
>Hide Private</span
>
</label> </label>
<label class="flex items-center gap-2 p-2 bg-surface-500/5 rounded border border-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp__journal_obj.cfg_json.hide_btn_public} class="checkbox checkbox-sm" /> class="flex items-center gap-2 p-2 bg-surface-500/5 rounded border border-surface-500/10"
<span class="text-[10px] uppercase font-bold">Hide Public</span> >
<input
type="checkbox"
bind:checked={
tmp__journal_obj.cfg_json.hide_btn_public
}
class="checkbox checkbox-sm"
/>
<span class="text-[10px] uppercase font-bold"
>Hide Public</span
>
</label> </label>
<label class="flex items-center gap-2 p-2 bg-surface-500/5 rounded border border-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp__journal_obj.cfg_json.hide_btn_personal} class="checkbox checkbox-sm" /> class="flex items-center gap-2 p-2 bg-surface-500/5 rounded border border-surface-500/10"
<span class="text-[10px] uppercase font-bold">Hide Pers.</span> >
<input
type="checkbox"
bind:checked={
tmp__journal_obj.cfg_json.hide_btn_personal
}
class="checkbox checkbox-sm"
/>
<span class="text-[10px] uppercase font-bold"
>Hide Pers.</span
>
</label> </label>
<label class="flex items-center gap-2 p-2 bg-surface-500/5 rounded border border-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp__journal_obj.cfg_json.hide_btn_professional} class="checkbox checkbox-sm" /> class="flex items-center gap-2 p-2 bg-surface-500/5 rounded border border-surface-500/10"
<span class="text-[10px] uppercase font-bold">Hide Prof.</span> >
<input
type="checkbox"
bind:checked={
tmp__journal_obj.cfg_json
.hide_btn_professional
}
class="checkbox checkbox-sm"
/>
<span class="text-[10px] uppercase font-bold"
>Hide Prof.</span
>
</label> </label>
<label class="flex items-center gap-2 p-2 bg-surface-500/5 rounded border border-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp__journal_obj.cfg_json.hide_btn_template} class="checkbox checkbox-sm" /> class="flex items-center gap-2 p-2 bg-surface-500/5 rounded border border-surface-500/10"
<span class="text-[10px] uppercase font-bold">Hide Templ.</span> >
<input
type="checkbox"
bind:checked={
tmp__journal_obj.cfg_json.hide_btn_template
}
class="checkbox checkbox-sm"
/>
<span class="text-[10px] uppercase font-bold"
>Hide Templ.</span
>
</label> </label>
<label class="flex items-center gap-2 p-2 bg-surface-500/5 rounded border border-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp__journal_obj.cfg_json.hide_copy_plain_md} class="checkbox checkbox-sm" /> class="flex items-center gap-2 p-2 bg-surface-500/5 rounded border border-surface-500/10"
<span class="text-[10px] uppercase font-bold">Hide Copy MD</span> >
<input
type="checkbox"
bind:checked={
tmp__journal_obj.cfg_json.hide_copy_plain_md
}
class="checkbox checkbox-sm"
/>
<span class="text-[10px] uppercase font-bold"
>Hide Copy MD</span
>
</label> </label>
<label class="flex items-center gap-2 p-2 bg-surface-500/5 rounded border border-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp__journal_obj.cfg_json.hide_clone} class="checkbox checkbox-sm" /> class="flex items-center gap-2 p-2 bg-surface-500/5 rounded border border-surface-500/10"
<span class="text-[10px] uppercase font-bold">Hide Clone</span> >
<input
type="checkbox"
bind:checked={
tmp__journal_obj.cfg_json.hide_clone
}
class="checkbox checkbox-sm"
/>
<span class="text-[10px] uppercase font-bold"
>Hide Clone</span
>
</label> </label>
</div> </div>
</section> </section>
<section class="space-y-4 p-2"> <section class="space-y-4 p-2">
<h2 class="text-lg font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"> <h2
class="text-lg font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
<Layout size="1.2em" class="text-primary-500" /> <Layout size="1.2em" class="text-primary-500" />
List Interactions List Interactions
</h2> </h2>
<div class="bg-surface-500/5 p-4 rounded-lg space-y-4"> <div class="bg-surface-500/5 p-4 rounded-lg space-y-4">
<label class="label"> <label class="label">
<span class="text-xs font-bold opacity-70">Expansion Trigger</span> <span class="text-xs font-bold opacity-70"
<select bind:value={tmp__journal_obj.cfg_json.expand_li_content} class="select select-sm variant-form-material"> >Expansion Trigger</span
>
<select
bind:value={
tmp__journal_obj.cfg_json.expand_li_content
}
class="select select-sm variant-form-material"
>
<option value="click">Click to Expand</option> <option value="click">Click to Expand</option>
<option value="hover">Hover to Expand</option> <option value="hover">Hover to Expand</option>
</select> </select>
</label> </label>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<label class="label"> <label class="label">
<span class="text-xs font-bold opacity-70">List Max Height</span> <span class="text-xs font-bold opacity-70"
<select bind:value={tmp__journal_obj.cfg_json.entry_li_max_height} class="select select-sm variant-form-material"> >List Max Height</span
>
<select
bind:value={
tmp__journal_obj.cfg_json
.entry_li_max_height
}
class="select select-sm variant-form-material"
>
<option value="">Default</option> <option value="">Default</option>
<option value="max-h-16">Small (16)</option> <option value="max-h-16">Small (16)</option>
<option value="max-h-32">Medium (32)</option> <option value="max-h-32">Medium (32)</option
>
<option value="max-h-64">Large (64)</option> <option value="max-h-64">Large (64)</option>
<option value="max-h-full">Full</option> <option value="max-h-full">Full</option>
</select> </select>
</label> </label>
<label class="label"> <label class="label">
<span class="text-xs font-bold opacity-70">Active Max Height</span> <span class="text-xs font-bold opacity-70"
<select bind:value={tmp__journal_obj.cfg_json.entry_li_click_max_height} class="select select-sm variant-form-material"> >Active Max Height</span
>
<select
bind:value={
tmp__journal_obj.cfg_json
.entry_li_click_max_height
}
class="select select-sm variant-form-material"
>
<option value="">Default</option> <option value="">Default</option>
<option value="active:max-h-64">Large (64)</option> <option value="active:max-h-64"
<option value="active:max-h-96">X-Large (96)</option> >Large (64)</option
<option value="active:max-h-full">Full</option> >
<option value="active:max-h-96"
>X-Large (96)</option
>
<option value="active:max-h-full"
>Full</option
>
</select> </select>
</label> </label>
</div> </div>
</div> </div>
</section> </section>
</div> </div>
{:else if tab === 'json'} {:else if tab === 'json'}
<div class="h-full min-h-[400px]"> <div class="h-full min-h-[400px]">
<AE_Comp_Editor_CodeMirror <AE_Comp_Editor_CodeMirror
@@ -505,10 +893,18 @@
{#snippet footer()} {#snippet footer()}
<div class="flex gap-4"> <div class="flex gap-4">
<button type="button" class="btn variant-ghost-surface font-bold min-w-[100px]" onclick={() => (show = false)}> <button
type="button"
class="btn variant-ghost-surface font-bold min-w-[100px]"
onclick={() => (show = false)}
>
<X size="1.2em" class="mr-2" /> Cancel <X size="1.2em" class="mr-2" /> Cancel
</button> </button>
<button type="button" class="btn variant-filled-primary font-bold shadow-lg min-w-[120px]" onclick={() => handle_update_journal(true)}> <button
type="button"
class="btn variant-filled-primary font-bold shadow-lg min-w-[120px]"
onclick={() => handle_update_journal(true)}
>
<Check size="1.2em" class="mr-2" /> Save Changes <Check size="1.2em" class="mr-2" /> Save Changes
</button> </button>
</div> </div>

View File

@@ -3,7 +3,17 @@
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
// *** Import other supporting libraries // *** Import other supporting libraries
import { BookPlus, BookOpenText, FilePlus, Menu, Pencil, FileDown, FileUp, Settings, LoaderCircle } from 'lucide-svelte'; import {
BookPlus,
BookOpenText,
FilePlus,
Menu,
Pencil,
FileDown,
FileUp,
Settings,
LoaderCircle
} from 'lucide-svelte';
// *** Import Aether specific variables and functions // *** Import Aether specific variables and functions
import { ae_util } from '$lib/ae_utils/ae_utils'; import { ae_util } from '$lib/ae_utils/ae_utils';
@@ -34,7 +44,13 @@
on_show_import?: () => void; on_show_import?: () => void;
} }
let { log_lvl = 0, lq__journal_obj, lq__journal_entry_obj_li, on_show_export, on_show_import }: Props = $props(); let {
log_lvl = 0,
lq__journal_obj,
lq__journal_entry_obj_li,
on_show_export,
on_show_import
}: Props = $props();
// let ae_promises: key_val = {}; // let ae_promises: key_val = {};
// let ae_tmp: key_val = {}; // let ae_tmp: key_val = {};
@@ -60,7 +76,8 @@
if ( if (
$lq__journal_obj?.id && $lq__journal_obj?.id &&
$journals_sess?.journal_kv[$lq__journal_obj?.id] && $journals_sess?.journal_kv[$lq__journal_obj?.id] &&
$journals_sess?.journal_kv[$lq__journal_obj?.id]?.journal_passcode_verified $journals_sess?.journal_kv[$lq__journal_obj?.id]
?.journal_passcode_verified
) { ) {
if (passcode_timer) { if (passcode_timer) {
if (log_lvl) { if (log_lvl) {
@@ -74,27 +91,30 @@
const timeout_ms = 1000 * 60 * timeout_minutes; const timeout_ms = 1000 * 60 * timeout_minutes;
if (log_lvl) { if (log_lvl) {
console.log(`Setting passcode timer for ${timeout_minutes} minutes (${timeout_ms}ms)`); console.log(
`Setting passcode timer for ${timeout_minutes} minutes (${timeout_ms}ms)`
);
} }
passcode_timer = setTimeout( passcode_timer = setTimeout(() => {
() => { if (log_lvl) {
if (log_lvl) { console.log('Passcode timer expired');
console.log('Passcode timer expired'); }
} typed_journal_passcode = '';
typed_journal_passcode = ''; if (!$journals_sess?.journal_kv[$lq__journal_obj?.id]) {
if (!$journals_sess?.journal_kv[$lq__journal_obj?.id]) { $journals_sess.journal_kv[$lq__journal_obj?.id] = {};
$journals_sess.journal_kv[$lq__journal_obj?.id] = {}; }
}
// Reset verification and decryption flags // Reset verification and decryption flags
$journals_sess.journal_kv[$lq__journal_obj?.id].journal_passcode_verified = false; $journals_sess.journal_kv[
$journals_sess.journal_kv[$lq__journal_obj?.id].journal_passcode_decrypted = false; $lq__journal_obj?.id
].journal_passcode_verified = false;
$journals_sess.journal_kv[
$lq__journal_obj?.id
].journal_passcode_decrypted = false;
passcode_timer = null; passcode_timer = null;
}, }, timeout_ms);
timeout_ms
);
} }
}); });
@@ -137,9 +157,13 @@
}); });
if (results?.journal_entry_id_random) { if (results?.journal_entry_id_random) {
$journals_slct.journal_entry_id = results.journal_entry_id_random; $journals_slct.journal_entry_id =
$journals_loc.entry.edit_kv[$journals_slct.journal_entry_id] = 'current'; results.journal_entry_id_random;
goto(`/journals/${$lq__journal_obj?.journal_id}/entry/${results.journal_entry_id_random}`); $journals_loc.entry.edit_kv[$journals_slct.journal_entry_id] =
'current';
goto(
`/journals/${$lq__journal_obj?.journal_id}/entry/${results.journal_entry_id_random}`
);
} }
} catch (error) { } catch (error) {
console.error('Error creating journal entry:', error); console.error('Error creating journal entry:', error);
@@ -169,19 +193,28 @@
class="badge preset-tonal-success font-bold text-lg px-2 ml-2" class="badge preset-tonal-success font-bold text-lg px-2 ml-2"
title="Entries matching current filters" title="Entries matching current filters"
> >
{$lq__journal_entry_obj_li?.length ?? '0'}<span class="text-xs opacity-50 ml-0.5">&times;</span> {$lq__journal_entry_obj_li?.length ?? '0'}<span
class="text-xs opacity-50 ml-0.5">&times;</span
>
</span> </span>
{/if} {/if}
{#await $journals_prom.load__journal_entry_obj_li} {#await $journals_prom.load__journal_entry_obj_li}
<LoaderCircle size="1em" class="inline-block animate-spin ml-1 text-primary-500" /> <LoaderCircle
size="1em"
class="inline-block animate-spin ml-1 text-primary-500"
/>
{/await} {/await}
</h2> </h2>
<div class="grow flex flex-row flex-wrap gap-2 items-center justify-end"> <div
class="grow flex flex-row flex-wrap gap-2 items-center justify-end"
>
<!-- Simplified Config Trigger --> <!-- Simplified Config Trigger -->
<button type="button" <button
onclick={() => ($journals_sess.show__modal_edit__journal_obj = true)} type="button"
onclick={() =>
($journals_sess.show__modal_edit__journal_obj = true)}
class="btn variant-filled-secondary py-1 px-3 shadow-md" class="btn variant-filled-secondary py-1 px-3 shadow-md"
title="Journal Config & Actions" title="Journal Config & Actions"
> >
@@ -238,6 +271,6 @@
{lq__journal_obj} {lq__journal_obj}
show={$journals_sess.show__modal_edit__journal_obj} show={$journals_sess.show__modal_edit__journal_obj}
on_new_entry={handle_new_entry} on_new_entry={handle_new_entry}
on_show_export={on_show_export} {on_show_export}
on_show_import={on_show_import} {on_show_import}
/> />

View File

@@ -5,7 +5,13 @@
* Layout: Responsive Grid (1 col mobile, 2 col tablet, 3 col desktop) * Layout: Responsive Grid (1 col mobile, 2 col tablet, 3 col desktop)
* Style: Tailwind 4 + Skeleton UI Reference Standard * Style: Tailwind 4 + Skeleton UI Reference Standard
*/ */
import { BookOpenText, BookType, Hash, Calendar, Clock } from 'lucide-svelte'; import {
BookOpenText,
BookType,
Hash,
Calendar,
Clock
} from 'lucide-svelte';
import { ae_util } from '$lib/ae_utils/ae_utils'; import { ae_util } from '$lib/ae_utils/ae_utils';
import { ae_loc } from '$lib/stores/ae_stores'; import { ae_loc } from '$lib/stores/ae_stores';
@@ -17,7 +23,9 @@
</script> </script>
<!-- Responsive Grid Container --> <!-- Responsive Grid Container -->
<section class="journal_list grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 w-full max-w-7xl px-4"> <section
class="journal_list grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 w-full max-w-7xl px-4"
>
{#if $lq__journal_obj_li && $lq__journal_obj_li.length} {#if $lq__journal_obj_li && $lq__journal_obj_li.length}
{#each $lq__journal_obj_li as journal, index} {#each $lq__journal_obj_li as journal, index}
<div <div
@@ -30,7 +38,8 @@
p-5 shadow-sm hover:shadow-xl hover:border-primary-500/50 p-5 shadow-sm hover:shadow-xl hover:border-primary-500/50
transition-all duration-200 ease-in-out transition-all duration-200 ease-in-out
" "
class:hidden={(journal?.hide || !journal?.enable) && !$ae_loc.trusted_access} class:hidden={(journal?.hide || !journal?.enable) &&
!$ae_loc.trusted_access}
class:opacity-60={journal.hide} class:opacity-60={journal.hide}
class:border-warning-500={!journal?.enable} class:border-warning-500={!journal?.enable}
> >
@@ -38,16 +47,22 @@
<div class="space-y-3"> <div class="space-y-3">
<header class="flex justify-between items-start gap-2"> <header class="flex justify-between items-start gap-2">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<div class="p-2 bg-primary-500/10 rounded-lg text-primary-500 group-hover:bg-primary-500 group-hover:text-white transition-colors"> <div
class="p-2 bg-primary-500/10 rounded-lg text-primary-500 group-hover:bg-primary-500 group-hover:text-white transition-colors"
>
<BookType size="1.5em" /> <BookType size="1.5em" />
</div> </div>
<h3 class="text-xl font-bold text-surface-900 dark:text-surface-100 line-clamp-1"> <h3
class="text-xl font-bold text-surface-900 dark:text-surface-100 line-clamp-1"
>
{journal.name} {journal.name}
</h3> </h3>
</div> </div>
{#if journal.type_code} {#if journal.type_code}
<span class="badge preset-tonal-warning text-[10px] uppercase tracking-wider font-bold"> <span
class="badge preset-tonal-warning text-[10px] uppercase tracking-wider font-bold"
>
{journal.type_code} {journal.type_code}
</span> </span>
{/if} {/if}
@@ -55,26 +70,45 @@
<!-- Description (Power User / Edit Mode Only) --> <!-- Description (Power User / Edit Mode Only) -->
{#if journal.description && $ae_loc.edit_mode} {#if journal.description && $ae_loc.edit_mode}
<div class="prose prose-sm dark:prose-invert max-h-24 overflow-y-auto bg-surface-100/50 dark:bg-surface-800/50 p-3 rounded-lg text-xs font-mono"> <div
class="prose prose-sm dark:prose-invert max-h-24 overflow-y-auto bg-surface-100/50 dark:bg-surface-800/50 p-3 rounded-lg text-xs font-mono"
>
{@html journal.description_md_html} {@html journal.description_md_html}
</div> </div>
{/if} {/if}
<!-- Quick Stats (Clean View) --> <!-- Quick Stats (Clean View) -->
<div class="flex items-center gap-4 text-xs text-surface-600 dark:text-surface-400"> <div
<div class="flex items-center gap-1" title="Entry Count"> class="flex items-center gap-4 text-xs text-surface-600 dark:text-surface-400"
>
<div
class="flex items-center gap-1"
title="Entry Count"
>
<Hash size="1.2em" /> <Hash size="1.2em" />
<span class="font-bold">{journal.journal_entry_count ?? 0}</span> <span class="font-bold"
>{journal.journal_entry_count ?? 0}</span
>
</div> </div>
<div class="flex items-center gap-1" title="Last Updated"> <div
class="flex items-center gap-1"
title="Last Updated"
>
<Clock size="1.2em" /> <Clock size="1.2em" />
<span>{ae_util.iso_datetime_formatter(journal.updated_on || journal.created_on, 'date_short')}</span> <span
>{ae_util.iso_datetime_formatter(
journal.updated_on || journal.created_on,
'date_short'
)}</span
>
</div> </div>
</div> </div>
</div> </div>
<!-- Bottom Section: Actions --> <!-- Bottom Section: Actions -->
<div class="mt-6 pt-4 border-t border-surface-500/10 flex flex-col gap-3"> <div
class="mt-6 pt-4 border-t border-surface-500/10 flex flex-col gap-3"
>
<a <a
href="/journals/{journal?.journal_id}" href="/journals/{journal?.journal_id}"
class="btn variant-filled-primary w-full font-bold shadow-md hover:scale-[1.02] active:scale-95 transition-all" class="btn variant-filled-primary w-full font-bold shadow-md hover:scale-[1.02] active:scale-95 transition-all"
@@ -85,9 +119,16 @@
<!-- Admin Metadata (Edit Mode Only) --> <!-- Admin Metadata (Edit Mode Only) -->
{#if $ae_loc.edit_mode && $ae_loc.administrator_access} {#if $ae_loc.edit_mode && $ae_loc.administrator_access}
<div class="flex items-center justify-center gap-2 text-[10px] opacity-50 font-mono"> <div
class="flex items-center justify-center gap-2 text-[10px] opacity-50 font-mono"
>
<Calendar size="1em" /> <Calendar size="1em" />
<span>Created: {ae_util.iso_datetime_formatter(journal.created_on, 'datetime_iso_12_no_seconds')}</span> <span
>Created: {ae_util.iso_datetime_formatter(
journal.created_on,
'datetime_iso_12_no_seconds'
)}</span
>
</div> </div>
{/if} {/if}
</div> </div>
@@ -96,17 +137,25 @@
{#if $ae_loc.edit_mode} {#if $ae_loc.edit_mode}
<div class="absolute -top-2 -right-2 flex gap-1"> <div class="absolute -top-2 -right-2 flex gap-1">
{#if journal.hide} {#if journal.hide}
<span class="badge-icon variant-filled-surface shadow-sm" title="Hidden">🚫</span> <span
class="badge-icon variant-filled-surface shadow-sm"
title="Hidden">🚫</span
>
{/if} {/if}
{#if !journal.enable} {#if !journal.enable}
<span class="badge-icon variant-filled-warning shadow-sm" title="Disabled">⚠️</span> <span
class="badge-icon variant-filled-warning shadow-sm"
title="Disabled">⚠️</span
>
{/if} {/if}
</div> </div>
{/if} {/if}
</div> </div>
{/each} {/each}
{:else} {:else}
<div class="col-span-full p-20 text-center opacity-50 flex flex-col items-center gap-4"> <div
class="col-span-full p-20 text-center opacity-50 flex flex-col items-center gap-4"
>
<BookType size="4em" /> <BookType size="4em" />
<p class="text-xl">No journals found in this view.</p> <p class="text-xl">No journals found in this view.</p>
</div> </div>

View File

@@ -22,10 +22,7 @@
import { untrack } from 'svelte'; import { untrack } from 'svelte';
// *** Import Aether specific variables and functions // *** Import Aether specific variables and functions
import { import { ae_loc, ae_api } from '$lib/stores/ae_stores';
ae_loc,
ae_api
} from '$lib/stores/ae_stores';
import { import {
journals_loc, journals_loc,
journals_sess journals_sess
@@ -37,10 +34,7 @@
show?: boolean; show?: boolean;
} }
let { let { log_lvl = 0, show = $bindable(false) }: Props = $props();
log_lvl = 0,
show = $bindable(false)
}: Props = $props();
// Internal State // Internal State
let tab: 'form' | 'local_json' | 'session_json' = $state('form'); let tab: 'form' | 'local_json' | 'session_json' = $state('form');
@@ -84,24 +78,32 @@
<div class="space-y-6 py-2 h-[60vh] overflow-y-auto px-4"> <div class="space-y-6 py-2 h-[60vh] overflow-y-auto px-4">
<!-- Navigation Tabs --> <!-- 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"> <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"
>
<button <button
type="button" type="button"
class="btn btn-sm transition-all {tab === 'form' ? 'variant-filled-primary' : 'variant-soft-surface'}" class="btn btn-sm transition-all {tab === 'form'
? 'variant-filled-primary'
: 'variant-soft-surface'}"
onclick={() => (tab = 'form')} onclick={() => (tab = 'form')}
> >
<Settings size="1.1em" class="mr-1" /> Config <Settings size="1.1em" class="mr-1" /> Config
</button> </button>
<button <button
type="button" type="button"
class="btn btn-sm transition-all {tab === 'local_json' ? 'variant-filled-primary' : 'variant-soft-surface'}" class="btn btn-sm transition-all {tab === 'local_json'
? 'variant-filled-primary'
: 'variant-soft-surface'}"
onclick={() => (tab = 'local_json')} onclick={() => (tab = 'local_json')}
> >
<Database size="1.1em" class="mr-1" /> Local JSON <Database size="1.1em" class="mr-1" /> Local JSON
</button> </button>
<button <button
type="button" type="button"
class="btn btn-sm transition-all {tab === 'session_json' ? 'variant-filled-primary' : 'variant-soft-surface'}" class="btn btn-sm transition-all {tab === 'session_json'
? 'variant-filled-primary'
: 'variant-soft-surface'}"
onclick={() => (tab = 'session_json')} onclick={() => (tab = 'session_json')}
> >
<CodeXml size="1.1em" class="mr-1" /> Session JSON <CodeXml size="1.1em" class="mr-1" /> Session JSON
@@ -112,29 +114,61 @@
<div class="space-y-8 animate-in fade-in duration-300"> <div class="space-y-8 animate-in fade-in duration-300">
<!-- Date/Time Section --> <!-- Date/Time Section -->
<section class="space-y-4"> <section class="space-y-4">
<h2 class="text-xl font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"> <h2
class="text-xl font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
<CalendarClock size="1.2em" class="text-primary-500" /> <CalendarClock size="1.2em" class="text-primary-500" />
Date and Time Display Date and Time Display
</h2> </h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 p-2"> <div class="grid grid-cols-1 md:grid-cols-2 gap-6 p-2">
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">DateTime Format</span> <span class="text-sm font-bold opacity-70"
<select bind:value={tmp_config.datetime_format} class="select select-sm variant-form-material"> >DateTime Format</span
<option value="datetime_12_short">MMM D, YY hh:mm A</option> >
<option value="datetime_12_long">MMMM D, YYYY hh:mm A</option> <select
<option value="datetime_short">MMM D, YY HH:mm</option> bind:value={tmp_config.datetime_format}
<option value="datetime_long">MMMM D, YYYY HH:mm</option> class="select select-sm variant-form-material"
<option value="datetime_us">US (MM/DD/YYYY hh:mm:ss A)</option> >
<option value="datetime_iso">ISO (YYYY-MM-DD HH:mm:ss)</option> <option value="datetime_12_short"
>MMM D, YY hh:mm A</option
>
<option value="datetime_12_long"
>MMMM D, YYYY hh:mm A</option
>
<option value="datetime_short"
>MMM D, YY HH:mm</option
>
<option value="datetime_long"
>MMMM D, YYYY HH:mm</option
>
<option value="datetime_us"
>US (MM/DD/YYYY hh:mm:ss A)</option
>
<option value="datetime_iso"
>ISO (YYYY-MM-DD HH:mm:ss)</option
>
</select> </select>
</label> </label>
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Time-Only Format</span> <span class="text-sm font-bold opacity-70"
<select bind:value={tmp_config.time_format} class="select select-sm variant-form-material"> >Time-Only Format</span
<option value="time_12_short">12-hour short (3:30 PM)</option> >
<option value="time_12_long">12-hour long (3:30:45 PM)</option> <select
<option value="time_short">24-hour short (15:30)</option> bind:value={tmp_config.time_format}
<option value="time_long">24-hour long (15:30:45)</option> class="select select-sm variant-form-material"
>
<option value="time_12_short"
>12-hour short (3:30 PM)</option
>
<option value="time_12_long"
>12-hour long (3:30:45 PM)</option
>
<option value="time_short"
>24-hour short (15:30)</option
>
<option value="time_long"
>24-hour long (15:30:45)</option
>
</select> </select>
</label> </label>
</div> </div>
@@ -142,23 +176,45 @@
<!-- UI Section --> <!-- UI Section -->
<section class="space-y-4"> <section class="space-y-4">
<h2 class="text-xl font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"> <h2
<MousePointerClick size="1.2em" class="text-primary-500" /> class="text-xl font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
<MousePointerClick
size="1.2em"
class="text-primary-500"
/>
User Interface Preferences User Interface Preferences
</h2> </h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 p-2"> <div class="grid grid-cols-1 md:grid-cols-2 gap-6 p-2">
<label class="flex items-center space-x-3 cursor-pointer p-2 rounded-lg bg-surface-500/5 border border-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp_config.entry.auto_save} class="checkbox" /> class="flex items-center space-x-3 cursor-pointer p-2 rounded-lg bg-surface-500/5 border border-surface-500/10"
>
<input
type="checkbox"
bind:checked={tmp_config.entry.auto_save}
class="checkbox"
/>
<div class="space-y-0.5"> <div class="space-y-0.5">
<span class="font-bold">Enable Auto-Save</span> <span class="font-bold">Enable Auto-Save</span>
<p class="text-xs opacity-60">Automatically sync changes while editing</p> <p class="text-xs opacity-60">
Automatically sync changes while editing
</p>
</div> </div>
</label> </label>
<label class="flex items-center space-x-3 cursor-pointer p-2 rounded-lg bg-surface-500/5 border border-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp_config.show_id_random} class="checkbox" /> class="flex items-center space-x-3 cursor-pointer p-2 rounded-lg bg-surface-500/5 border border-surface-500/10"
>
<input
type="checkbox"
bind:checked={tmp_config.show_id_random}
class="checkbox"
/>
<div class="space-y-0.5"> <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> >
<p class="text-xs opacity-60">
Display UUIDs in metadata footers
</p>
</div> </div>
</label> </label>
</div> </div>
@@ -166,30 +222,53 @@
<!-- Journal Query Filters Section --> <!-- Journal Query Filters Section -->
<section class="space-y-4"> <section class="space-y-4">
<h2 class="text-xl font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"> <h2
class="text-xl font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
<Database size="1.2em" class="text-primary-500" /> <Database size="1.2em" class="text-primary-500" />
Journal Query Filters Journal Query Filters
</h2> </h2>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 p-2"> <div class="grid grid-cols-1 md:grid-cols-3 gap-6 p-2">
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Enabled Status</span> <span class="text-sm font-bold opacity-70"
<select bind:value={tmp_config.journal.qry__enabled} class="select select-sm variant-form-material"> >Enabled Status</span
>
<select
bind:value={tmp_config.journal.qry__enabled}
class="select select-sm variant-form-material"
>
<option value="enabled">Enabled Only</option> <option value="enabled">Enabled Only</option>
<option value="not_enabled">Disabled Only</option> <option value="not_enabled"
<option value="all">All (Enabled & Disabled & NULL)</option> >Disabled Only</option
>
<option value="all"
>All (Enabled & Disabled & NULL)</option
>
</select> </select>
</label> </label>
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Hidden Status</span> <span class="text-sm font-bold opacity-70"
<select bind:value={tmp_config.journal.qry__hidden} class="select select-sm variant-form-material"> >Hidden Status</span
>
<select
bind:value={tmp_config.journal.qry__hidden}
class="select select-sm variant-form-material"
>
<option value="not_hidden">Visible Only</option> <option value="not_hidden">Visible Only</option>
<option value="hidden">Hidden Only</option> <option value="hidden">Hidden Only</option>
<option value="all">All (Visible & Hidden & NULL)</option> <option value="all"
>All (Visible & Hidden & NULL)</option
>
</select> </select>
</label> </label>
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Query Limit</span> <span class="text-sm font-bold opacity-70"
<select bind:value={tmp_config.journal.qry__limit} class="select select-sm variant-form-material"> >Query Limit</span
>
<select
bind:value={tmp_config.journal.qry__limit}
class="select select-sm variant-form-material"
>
<option value={10}>10</option> <option value={10}>10</option>
<option value={20}>20</option> <option value={20}>20</option>
<option value={50}>50</option> <option value={50}>50</option>
@@ -204,30 +283,53 @@
<!-- Entry Query Filters Section --> <!-- Entry Query Filters Section -->
<section class="space-y-4"> <section class="space-y-4">
<h2 class="text-xl font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"> <h2
class="text-xl font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
<Database size="1.2em" class="text-primary-500" /> <Database size="1.2em" class="text-primary-500" />
Entry Query Filters Entry Query Filters
</h2> </h2>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 p-2"> <div class="grid grid-cols-1 md:grid-cols-3 gap-6 p-2">
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Enabled Status</span> <span class="text-sm font-bold opacity-70"
<select bind:value={tmp_config.entry.qry__enabled} class="select select-sm variant-form-material"> >Enabled Status</span
>
<select
bind:value={tmp_config.entry.qry__enabled}
class="select select-sm variant-form-material"
>
<option value="enabled">Enabled Only</option> <option value="enabled">Enabled Only</option>
<option value="not_enabled">Disabled Only</option> <option value="not_enabled"
<option value="all">All (Enabled & Disabled & NULL)</option> >Disabled Only</option
>
<option value="all"
>All (Enabled & Disabled & NULL)</option
>
</select> </select>
</label> </label>
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Hidden Status</span> <span class="text-sm font-bold opacity-70"
<select bind:value={tmp_config.entry.qry__hidden} class="select select-sm variant-form-material"> >Hidden Status</span
>
<select
bind:value={tmp_config.entry.qry__hidden}
class="select select-sm variant-form-material"
>
<option value="not_hidden">Visible Only</option> <option value="not_hidden">Visible Only</option>
<option value="hidden">Hidden Only</option> <option value="hidden">Hidden Only</option>
<option value="all">All (Visible & Hidden & NULL)</option> <option value="all"
>All (Visible & Hidden & NULL)</option
>
</select> </select>
</label> </label>
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Query Limit</span> <span class="text-sm font-bold opacity-70"
<select bind:value={tmp_config.entry.qry__limit} class="select select-sm variant-form-material"> >Query Limit</span
>
<select
bind:value={tmp_config.entry.qry__limit}
class="select select-sm variant-form-material"
>
<option value={10}>10</option> <option value={10}>10</option>
<option value={20}>20</option> <option value={20}>20</option>
<option value={50}>50</option> <option value={50}>50</option>
@@ -242,17 +344,31 @@
<!-- Security Section --> <!-- Security Section -->
<section class="space-y-4"> <section class="space-y-4">
<h2 class="text-xl font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"> <h2
class="text-xl font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
<ShieldCheck size="1.2em" class="text-primary-500" /> <ShieldCheck size="1.2em" class="text-primary-500" />
Security & Encryption Security & Encryption
</h2> </h2>
<div class="p-4 bg-orange-500/5 rounded-lg border border-orange-500/20 space-y-4"> <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"> <div class="text-sm opacity-80 italic">
Global security overrides for the journal module. Global security overrides for the journal module.
</div> </div>
<label class="flex items-center space-x-3 cursor-pointer"> <label
<input type="checkbox" bind:checked={$journals_sess.enable_session_passcode_cache} class="checkbox checkbox-primary" /> class="flex items-center space-x-3 cursor-pointer"
<span class="text-sm font-bold">Cache Passcodes in Session</span> >
<input
type="checkbox"
bind:checked={
$journals_sess.enable_session_passcode_cache
}
class="checkbox checkbox-primary"
/>
<span class="text-sm font-bold"
>Cache Passcodes in Session</span
>
</label> </label>
</div> </div>
</section> </section>
@@ -280,10 +396,18 @@
{#snippet footer()} {#snippet footer()}
<div class="flex gap-4"> <div class="flex gap-4">
<button type="button" class="btn variant-ghost-surface font-bold min-w-[100px]" onclick={() => (show = false)}> <button
type="button"
class="btn variant-ghost-surface font-bold min-w-[100px]"
onclick={() => (show = false)}
>
<X size="1.2em" class="mr-2" /> Cancel <X size="1.2em" class="mr-2" /> Cancel
</button> </button>
<button type="button" class="btn variant-filled-primary font-bold shadow-lg min-w-[120px]" onclick={handle_save}> <button
type="button"
class="btn variant-filled-primary font-bold shadow-lg min-w-[120px]"
onclick={handle_save}
>
<Check size="1.2em" class="mr-2" /> Save Changes <Check size="1.2em" class="mr-2" /> Save Changes
</button> </button>
</div> </div>

View File

@@ -25,103 +25,123 @@
on_update, on_update,
log_lvl = 0 log_lvl = 0
}: Props = $props(); }: Props = $props();
// Local State // Local State
let tmp_entry_obj: key_val = $state({}); let tmp_entry_obj: key_val = $state({});
// Header Options // Header Options
let add_timestamp_header: boolean = $state(true); let add_timestamp_header: boolean = $state(true);
let add_timestamp_header_w_day_of_week: boolean = $state(true); let add_timestamp_header_w_day_of_week: boolean = $state(true);
let add_text_header: string = $state(''); let add_text_header: string = $state('');
let add_text: string = $state(''); let add_text: string = $state('');
// Change detection // Change detection
let has_changes: boolean = $derived(add_text_header.length > 0 || add_text.length > 0); let has_changes: boolean = $derived(
add_text_header.length > 0 || add_text.length > 0
// Initialize tmp object when entry changes or modal opens
$effect(() => {
if (open && journal_entry) {
tmp_entry_obj = JSON.parse(JSON.stringify(journal_entry));
// Reset fields
add_text_header = '';
add_text = '';
}
});
async function handle_save() {
let current_entry_content = tmp_entry_obj?.content || '';
let add_content = '';
let new_content = current_entry_content;
// Construct the header/content to add (Following original logic)
let timestamp_str = ae_util.iso_datetime_formatter(
new Date(),
'datetime_iso_12_no_seconds'
); );
let day_of_week_str = add_timestamp_header_w_day_of_week
? ' (' + ae_util.iso_datetime_formatter(new Date(), 'week_long') + ')'
: '';
if (add_timestamp_header && add_text_header) { // Initialize tmp object when entry changes or modal opens
add_content = $effect(() => {
'## ' + if (open && journal_entry) {
timestamp_str + tmp_entry_obj = JSON.parse(JSON.stringify(journal_entry));
day_of_week_str + // Reset fields
' - ' + add_text_header = '';
add_text_header.trim() + add_text = '';
'\n' + }
add_text.trim() + });
'\n\n';
} else if (add_timestamp_header) {
add_content = '## ' + timestamp_str + day_of_week_str + '\n' + add_text.trim() + '\n\n';
} else if (add_text_header) {
add_content =
'## ' + add_text_header.trim() + day_of_week_str + '\n' + add_text.trim() + '\n\n';
} else {
add_content = add_text.trim() + '\n\n';
}
// Determine Append or Prepend async function handle_save() {
let effective_mode = mode; let current_entry_content = tmp_entry_obj?.content || '';
if (effective_mode === 'auto') { let add_content = '';
effective_mode = journal_config?.entry_add_text || 'append'; let new_content = current_entry_content;
}
if (effective_mode == 'prepend') { // Construct the header/content to add (Following original logic)
new_content = add_content + new_content; let timestamp_str = ae_util.iso_datetime_formatter(
} else { new Date(),
// Append 'datetime_iso_12_no_seconds'
new_content = new_content.trim() + '\n\n' + add_content; );
} let day_of_week_str = add_timestamp_header_w_day_of_week
? ' (' +
ae_util.iso_datetime_formatter(new Date(), 'week_long') +
')'
: '';
new_content = new_content.trim() + '\n'; if (add_timestamp_header && add_text_header) {
add_content =
let data_kv = { content: new_content }; '## ' +
timestamp_str +
try { day_of_week_str +
let update_result = await journals_func.update_ae_obj__journal_entry({ ' - ' +
api_cfg: $ae_api, add_text_header.trim() +
journal_entry_id: tmp_entry_obj?.journal_entry_id, '\n' +
data_kv: data_kv, add_text.trim() +
log_lvl: log_lvl '\n\n';
}); } else if (add_timestamp_header) {
add_content =
if (update_result) { '## ' +
// Success timestamp_str +
on_update(); day_of_week_str +
open = false; '\n' +
add_text.trim() +
'\n\n';
} else if (add_text_header) {
add_content =
'## ' +
add_text_header.trim() +
day_of_week_str +
'\n' +
add_text.trim() +
'\n\n';
} else { } else {
add_content = add_text.trim() + '\n\n';
}
// Determine Append or Prepend
let effective_mode = mode;
if (effective_mode === 'auto') {
effective_mode = journal_config?.entry_add_text || 'append';
}
if (effective_mode == 'prepend') {
new_content = add_content + new_content;
} else {
// Append
new_content = new_content.trim() + '\n\n' + add_content;
}
new_content = new_content.trim() + '\n';
let data_kv = { content: new_content };
try {
let update_result =
await journals_func.update_ae_obj__journal_entry({
api_cfg: $ae_api,
journal_entry_id: tmp_entry_obj?.journal_entry_id,
data_kv: data_kv,
log_lvl: log_lvl
});
if (update_result) {
// Success
on_update();
open = false;
} else {
alert('Failed to update journal entry.');
}
} catch (error) {
console.error('Error updating journal entry:', error);
alert('Failed to update journal entry.'); alert('Failed to update journal entry.');
} }
} catch (error) {
console.error('Error updating journal entry:', error);
alert('Failed to update journal entry.');
} }
}
</script> </script>
<Modal <Modal
title="{(mode === 'auto' ? journal_config?.entry_add_text : mode) == 'append' ? 'Append to' : 'Prepend to'} Journal Entry: {journal_entry?.name ?? journal_entry?.created_on}" title="{(mode === 'auto' ? journal_config?.entry_add_text : mode) ==
bind:open={open} 'append'
? 'Append to'
: 'Prepend to'} Journal Entry: {journal_entry?.name ??
journal_entry?.created_on}"
bind:open
autoclose={false} autoclose={false}
placement="top-center" placement="top-center"
size="xl" size="xl"
@@ -138,7 +158,10 @@ async function handle_save() {
bind:checked={add_timestamp_header} bind:checked={add_timestamp_header}
class="p-2 bg-slate-100 text-gray-900 dark:bg-slate-900 dark:text-gray-100 shadow-lg rounded-lg border border-gray-200 dark:border-gray-700 hover:border-gray-500 dark:hover:border-gray-500 inline-block" class="p-2 bg-slate-100 text-gray-900 dark:bg-slate-900 dark:text-gray-100 shadow-lg rounded-lg border border-gray-200 dark:border-gray-700 hover:border-gray-500 dark:hover:border-gray-500 inline-block"
/> />
<label for="append_timestamp_header" class="p-2 inline-block"> <label
for="append_timestamp_header"
class="p-2 inline-block"
>
Use timestamp as Markdown header Use timestamp as Markdown header
</label> </label>
@@ -148,7 +171,10 @@ async function handle_save() {
bind:checked={add_timestamp_header_w_day_of_week} bind:checked={add_timestamp_header_w_day_of_week}
class="p-2 bg-slate-100 text-gray-900 dark:bg-slate-900 dark:text-gray-100 shadow-lg rounded-lg border border-gray-200 dark:border-gray-700 hover:border-gray-500 dark:hover:border-gray-500 inline-block" class="p-2 bg-slate-100 text-gray-900 dark:bg-slate-900 dark:text-gray-100 shadow-lg rounded-lg border border-gray-200 dark:border-gray-700 hover:border-gray-500 dark:hover:border-gray-500 inline-block"
/> />
<label for="append_timestamp_header_w_day_of_week" class="p-2 inline-block"> <label
for="append_timestamp_header_w_day_of_week"
class="p-2 inline-block"
>
Include day of week Include day of week
</label> </label>
</div> </div>
@@ -167,12 +193,14 @@ async function handle_save() {
class="grow min-h-48 h-full w-full p-2 bg-slate-100 text-gray-900 dark:bg-slate-900 dark:text-gray-100 shadow-lg rounded-lg border border-gray-200 dark:border-gray-700 hover:border-gray-500 dark:hover:border-gray-500" class="grow min-h-48 h-full w-full p-2 bg-slate-100 text-gray-900 dark:bg-slate-900 dark:text-gray-100 shadow-lg rounded-lg border border-gray-200 dark:border-gray-700 hover:border-gray-500 dark:hover:border-gray-500"
placeholder="Content to {mode === 'auto' placeholder="Content to {mode === 'auto'
? journal_config?.entry_add_text ? journal_config?.entry_add_text
: mode}..."> : mode}..."
>
</textarea> </textarea>
</div> </div>
<div class="modal-action flex justify-end gap-2 mt-4"> <div class="modal-action flex justify-end gap-2 mt-4">
<button type="button" <button
type="button"
disabled={!has_changes} disabled={!has_changes}
onclick={handle_save} onclick={handle_save}
class="btn btn-sm md:btn-md lg:btn-lg min-w-32 hover:variant-outline-success hover:preset-filled-success-500" class="btn btn-sm md:btn-md lg:btn-lg min-w-32 hover:variant-outline-success hover:preset-filled-success-500"
@@ -182,7 +210,8 @@ async function handle_save() {
<Check class="mr-1" /> <Check class="mr-1" />
Update Update
</button> </button>
<button type="button" <button
type="button"
onclick={on_close} onclick={on_close}
class="btn preset-tonal-surface border border-surface-500 hover:preset-filled-surface-500 transition" class="btn preset-tonal-surface border border-surface-500 hover:preset-filled-surface-500 transition"
> >

View File

@@ -26,7 +26,10 @@
} from 'lucide-svelte'; } from 'lucide-svelte';
import { Modal } from 'flowbite-svelte'; import { Modal } from 'flowbite-svelte';
import { ae_loc, ae_api } from '$lib/stores/ae_stores'; import { ae_loc, ae_api } from '$lib/stores/ae_stores';
import { journals_loc, journals_sess } from '$lib/ae_journals/ae_journals_stores'; import {
journals_loc,
journals_sess
} from '$lib/ae_journals/ae_journals_stores';
import { journals_func } from '$lib/ae_journals/ae_journals_functions'; import { journals_func } from '$lib/ae_journals/ae_journals_functions';
import AE_Comp_Editor_CodeMirror from '$lib/elements/AE_Comp_Editor_CodeMirror.svelte'; import AE_Comp_Editor_CodeMirror from '$lib/elements/AE_Comp_Editor_CodeMirror.svelte';
import AE_Object_Flags from '$lib/ae_elements/AE_Object_Flags.svelte'; import AE_Object_Flags from '$lib/ae_elements/AE_Object_Flags.svelte';
@@ -59,7 +62,8 @@
let tab: 'actions' | 'meta' | 'security' | 'json' = $state('actions'); let tab: 'actions' | 'meta' | 'security' | 'json' = $state('actions');
const normalize_date = (val: string | null) => val ? val.slice(0, 16) : null; const normalize_date = (val: string | null) =>
val ? val.slice(0, 16) : null;
async function handle_update_entry() { async function handle_update_entry() {
try { try {
@@ -120,17 +124,43 @@
<div class="space-y-6 py-2 h-[60vh] overflow-y-auto px-4"> <div class="space-y-6 py-2 h-[60vh] overflow-y-auto px-4">
<!-- Navigation Tabs --> <!-- 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"> <div
<button type="button" class="btn btn-sm transition-all {tab === 'actions' ? 'variant-filled-primary' : 'variant-soft-surface'}" onclick={() => (tab = 'actions')}> 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"
>
<button
type="button"
class="btn btn-sm transition-all {tab === 'actions'
? 'variant-filled-primary'
: 'variant-soft-surface'}"
onclick={() => (tab = 'actions')}
>
<Zap size="1.1em" class="mr-1" /> Quick Actions <Zap size="1.1em" class="mr-1" /> Quick Actions
</button> </button>
<button type="button" class="btn btn-sm transition-all {tab === 'meta' ? 'variant-filled-primary' : 'variant-soft-surface'}" onclick={() => (tab = 'meta')}> <button
type="button"
class="btn btn-sm transition-all {tab === 'meta'
? 'variant-filled-primary'
: 'variant-soft-surface'}"
onclick={() => (tab = 'meta')}
>
<Shapes size="1.1em" class="mr-1" /> Metadata <Shapes size="1.1em" class="mr-1" /> Metadata
</button> </button>
<button type="button" class="btn btn-sm transition-all {tab === 'security' ? 'variant-filled-primary' : 'variant-soft-surface'}" onclick={() => (tab = 'security')}> <button
type="button"
class="btn btn-sm transition-all {tab === 'security'
? 'variant-filled-primary'
: 'variant-soft-surface'}"
onclick={() => (tab = 'security')}
>
<ShieldCheck size="1.1em" class="mr-1" /> Status & Security <ShieldCheck size="1.1em" class="mr-1" /> Status & Security
</button> </button>
<button type="button" class="btn btn-sm transition-all {tab === 'json' ? 'variant-filled-primary' : 'variant-soft-surface'}" onclick={() => (tab = 'json')}> <button
type="button"
class="btn btn-sm transition-all {tab === 'json'
? 'variant-filled-primary'
: 'variant-soft-surface'}"
onclick={() => (tab = 'json')}
>
<CodeXml size="1.1em" class="mr-1" /> JSON <CodeXml size="1.1em" class="mr-1" /> JSON
</button> </button>
</div> </div>
@@ -138,27 +168,66 @@
{#if tab === 'actions'} {#if tab === 'actions'}
<div class="space-y-6 animate-in fade-in duration-300"> <div class="space-y-6 animate-in fade-in duration-300">
<section class="grid grid-cols-1 md:grid-cols-2 gap-4"> <section class="grid grid-cols-1 md:grid-cols-2 gap-4">
<button type="button" class="btn variant-soft-secondary w-full" onclick={() => { show = false; on_prepend?.(); }}> <button
<ArrowUpToLine size="1.2em" class="mr-2"/> Prepend Content type="button"
class="btn variant-soft-secondary w-full"
onclick={() => {
show = false;
on_prepend?.();
}}
>
<ArrowUpToLine size="1.2em" class="mr-2" /> Prepend Content
</button> </button>
<button type="button" class="btn variant-soft-secondary w-full" onclick={() => { show = false; on_append?.(); }}> <button
<ArrowDownToLine size="1.2em" class="mr-2"/> Append Content type="button"
class="btn variant-soft-secondary w-full"
onclick={() => {
show = false;
on_append?.();
}}
>
<ArrowDownToLine size="1.2em" class="mr-2" /> Append Content
</button> </button>
<button type="button" class="btn variant-soft-surface w-full" onclick={() => { show = false; on_show_export?.(); }}> <button
<FileDown size="1.2em" class="mr-2"/> Export Entry type="button"
class="btn variant-soft-surface w-full"
onclick={() => {
show = false;
on_show_export?.();
}}
>
<FileDown size="1.2em" class="mr-2" /> Export Entry
</button> </button>
<button type="button" class="btn variant-soft-surface w-full" onclick={() => { /* Clone logic here */ alert('Clone not yet implemented in modal'); }}> <button
<Copy size="1.2em" class="mr-2"/> Clone Entry type="button"
class="btn variant-soft-surface w-full"
onclick={() => {
/* Clone logic here */ alert(
'Clone not yet implemented in modal'
);
}}
>
<Copy size="1.2em" class="mr-2" /> Clone Entry
</button> </button>
</section> </section>
<section class="space-y-4 pt-4 border-t border-surface-500/20"> <section class="space-y-4 pt-4 border-t border-surface-500/20">
<h4 class="text-xs font-bold uppercase opacity-50">Quick Category</h4> <h4 class="text-xs font-bold uppercase opacity-50">
Quick Category
</h4>
<div class="flex flex-wrap gap-2"> <div class="flex flex-wrap gap-2">
{#each journal?.cfg_json?.category_li ?? [] as cat} {#each journal?.cfg_json?.category_li ?? [] as cat}
<button type="button" <button
class="btn btn-sm {tmp_entry_obj.category_code === cat.code ? 'variant-filled-primary' : 'variant-soft-primary'}" type="button"
onclick={() => { tmp_entry_obj.category_code = cat.code; handle_update_entry(); on_save(); }} class="btn btn-sm {tmp_entry_obj.category_code ===
cat.code
? 'variant-filled-primary'
: 'variant-soft-primary'}"
onclick={() => {
tmp_entry_obj.category_code = cat.code;
handle_update_entry();
on_save();
}}
> >
{cat.name} {cat.name}
</button> </button>
@@ -166,12 +235,18 @@
</div> </div>
</section> </section>
</div> </div>
{:else if tab === 'meta'} {:else if tab === 'meta'}
<div class="space-y-6 animate-in fade-in duration-300"> <div class="space-y-6 animate-in fade-in duration-300">
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Category</span> <span class="text-sm font-bold opacity-70">Category</span>
<select class="select variant-form-material" bind:value={tmp_entry_obj.category_code} onchange={() => { handle_update_entry(); on_save(); }}> <select
class="select variant-form-material"
bind:value={tmp_entry_obj.category_code}
onchange={() => {
handle_update_entry();
on_save();
}}
>
<option value="">None</option> <option value="">None</option>
{#each journal?.cfg_json?.category_li ?? [] as cat} {#each journal?.cfg_json?.category_li ?? [] as cat}
<option value={cat.code}>{cat.name}</option> <option value={cat.code}>{cat.name}</option>
@@ -180,94 +255,223 @@
</label> </label>
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Tags (Comma separated)</span> <span class="text-sm font-bold opacity-70"
>Tags (Comma separated)</span
>
<div class="flex gap-2 items-center"> <div class="flex gap-2 items-center">
<Tag size="1.2em" class="opacity-30" /> <Tag size="1.2em" class="opacity-30" />
<input type="text" bind:value={tmp_entry_obj.tags} class="input variant-form-material grow" placeholder="meeting, urgent, ideas" onchange={() => { handle_update_entry(); on_save(); }} /> <input
type="text"
bind:value={tmp_entry_obj.tags}
class="input variant-form-material grow"
placeholder="meeting, urgent, ideas"
onchange={() => {
handle_update_entry();
on_save();
}}
/>
</div> </div>
</label> </label>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Archive On</span> <span class="text-sm font-bold opacity-70"
<input type="datetime-local" value={normalize_date(tmp_entry_obj.archive_on)} onchange={(e) => { tmp_entry_obj.archive_on = e.currentTarget.value; handle_update_entry(); on_save(); }} class="input variant-form-material" /> >Archive On</span
>
<input
type="datetime-local"
value={normalize_date(tmp_entry_obj.archive_on)}
onchange={(e) => {
tmp_entry_obj.archive_on =
e.currentTarget.value;
handle_update_entry();
on_save();
}}
class="input variant-form-material"
/>
</label> </label>
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Sort Priority</span> <span class="text-sm font-bold opacity-70"
>Sort Priority</span
>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<button type="button" class="btn-icon btn-icon-sm variant-soft-surface" onclick={() => { tmp_entry_obj.sort = (tmp_entry_obj.sort ?? 0) - 1; handle_update_entry(); on_save(); }}><Minus size="1em"/></button> <button
<span class="font-mono font-bold w-8 text-center">{tmp_entry_obj.sort ?? 0}</span> type="button"
<button type="button" class="btn-icon btn-icon-sm variant-soft-surface" onclick={() => { tmp_entry_obj.sort = (tmp_entry_obj.sort ?? 0) + 1; handle_update_entry(); on_save(); }}><Plus size="1em"/></button> class="btn-icon btn-icon-sm variant-soft-surface"
onclick={() => {
tmp_entry_obj.sort =
(tmp_entry_obj.sort ?? 0) - 1;
handle_update_entry();
on_save();
}}><Minus size="1em" /></button
>
<span class="font-mono font-bold w-8 text-center"
>{tmp_entry_obj.sort ?? 0}</span
>
<button
type="button"
class="btn-icon btn-icon-sm variant-soft-surface"
onclick={() => {
tmp_entry_obj.sort =
(tmp_entry_obj.sort ?? 0) + 1;
handle_update_entry();
on_save();
}}><Plus size="1em" /></button
>
</div> </div>
</label> </label>
</div> </div>
</div> </div>
{:else if tab === 'security'} {:else if tab === 'security'}
<div class="space-y-6 animate-in fade-in duration-300"> <div class="space-y-6 animate-in fade-in duration-300">
<section class="space-y-4"> <section class="space-y-4">
<h2 class="text-lg font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"> <h2
class="text-lg font-bold flex items-center gap-2 border-b border-surface-500/30 pb-2"
>
<Fingerprint size="1.2em" class="text-primary-500" /> <Fingerprint size="1.2em" class="text-primary-500" />
Status & Security Status & Security
</h2> </h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<label class="flex items-center space-x-3 cursor-pointer p-3 rounded-lg bg-surface-500/5 border border-surface-500/10 transition-colors hover:bg-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp_entry_obj.enable} onchange={() => { handle_update_entry(); on_save(); }} class="checkbox checkbox-primary" /> class="flex items-center space-x-3 cursor-pointer p-3 rounded-lg bg-surface-500/5 border border-surface-500/10 transition-colors hover:bg-surface-500/10"
>
<input
type="checkbox"
bind:checked={tmp_entry_obj.enable}
onchange={() => {
handle_update_entry();
on_save();
}}
class="checkbox checkbox-primary"
/>
<div class="flex flex-col"> <div class="flex flex-col">
<span class="font-bold">Enabled</span> <span class="font-bold">Enabled</span>
<span class="text-xs opacity-60">Allow access to this entry</span> <span class="text-xs opacity-60"
>Allow access to this entry</span
>
</div> </div>
</label> </label>
<label class="flex items-center space-x-3 cursor-pointer p-3 rounded-lg bg-surface-500/5 border border-surface-500/10 transition-colors hover:bg-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp_entry_obj.hide} onchange={() => { handle_update_entry(); on_save(); }} class="checkbox checkbox-primary" /> class="flex items-center space-x-3 cursor-pointer p-3 rounded-lg bg-surface-500/5 border border-surface-500/10 transition-colors hover:bg-surface-500/10"
>
<input
type="checkbox"
bind:checked={tmp_entry_obj.hide}
onchange={() => {
handle_update_entry();
on_save();
}}
class="checkbox checkbox-primary"
/>
<div class="flex flex-col"> <div class="flex flex-col">
<span class="font-bold">Hidden</span> <span class="font-bold">Hidden</span>
<span class="text-xs opacity-60">Hide from standard lists</span> <span class="text-xs opacity-60"
>Hide from standard lists</span
>
</div> </div>
</label> </label>
<label class="flex items-center space-x-3 cursor-pointer p-3 rounded-lg bg-surface-500/5 border border-surface-500/10 transition-colors hover:bg-surface-500/10"> <label
<input type="checkbox" bind:checked={tmp_entry_obj.priority} onchange={() => { handle_update_entry(); on_save(); }} class="checkbox checkbox-primary" /> class="flex items-center space-x-3 cursor-pointer p-3 rounded-lg bg-surface-500/5 border border-surface-500/10 transition-colors hover:bg-surface-500/10"
>
<input
type="checkbox"
bind:checked={tmp_entry_obj.priority}
onchange={() => {
handle_update_entry();
on_save();
}}
class="checkbox checkbox-primary"
/>
<div class="flex flex-col"> <div class="flex flex-col">
<span class="font-bold">Priority Entry</span> <span class="font-bold">Priority Entry</span>
<span class="text-xs opacity-60">Star or pin to top</span> <span class="text-xs opacity-60"
>Star or pin to top</span
>
</div> </div>
</label> </label>
<div class="flex items-center justify-between p-3 rounded-lg bg-surface-500/5 border border-surface-500/10"> <div
class="flex items-center justify-between p-3 rounded-lg bg-surface-500/5 border border-surface-500/10"
>
<div class="flex flex-col"> <div class="flex flex-col">
<span class="font-bold text-sm">Sort Order</span> <span class="font-bold text-sm">Sort Order</span
<span class="text-xs opacity-60">Manual list position</span> >
<span class="text-xs opacity-60"
>Manual list position</span
>
</div> </div>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<button type="button" class="btn-icon btn-icon-sm variant-soft-surface" onclick={() => { tmp_entry_obj.sort = (tmp_entry_obj.sort ?? 0) - 1; handle_update_entry(); on_save(); }}><Minus size="1em"/></button> <button
<span class="font-mono font-bold w-8 text-center text-lg">{tmp_entry_obj.sort ?? 0}</span> type="button"
<button type="button" class="btn-icon btn-icon-sm variant-soft-surface" onclick={() => { tmp_entry_obj.sort = (tmp_entry_obj.sort ?? 0) + 1; handle_update_entry(); on_save(); }}><Plus size="1em"/></button> class="btn-icon btn-icon-sm variant-soft-surface"
onclick={() => {
tmp_entry_obj.sort =
(tmp_entry_obj.sort ?? 0) - 1;
handle_update_entry();
on_save();
}}><Minus size="1em" /></button
>
<span
class="font-mono font-bold w-8 text-center text-lg"
>{tmp_entry_obj.sort ?? 0}</span
>
<button
type="button"
class="btn-icon btn-icon-sm variant-soft-surface"
onclick={() => {
tmp_entry_obj.sort =
(tmp_entry_obj.sort ?? 0) + 1;
handle_update_entry();
on_save();
}}><Plus size="1em" /></button
>
</div> </div>
</div> </div>
</div> </div>
</section> </section>
<section class="space-y-4"> <section class="space-y-4">
<h4 class="text-xs font-bold uppercase opacity-50">Privacy Flags</h4> <h4 class="text-xs font-bold uppercase opacity-50">
Privacy Flags
</h4>
<AE_Object_Flags <AE_Object_Flags
bind:obj={tmp_entry_obj} bind:obj={tmp_entry_obj}
on_toggle={() => { handle_update_entry(); on_save(); }} on_toggle={() => {
handle_update_entry();
on_save();
}}
hide_alert={journal?.cfg_json?.hide_btn_alert} hide_alert={journal?.cfg_json?.hide_btn_alert}
hide_private={journal?.cfg_json?.hide_btn_private} hide_private={journal?.cfg_json?.hide_btn_private}
hide_public={journal?.cfg_json?.hide_btn_public} hide_public={journal?.cfg_json?.hide_btn_public}
hide_personal={journal?.cfg_json?.hide_btn_personal} hide_personal={journal?.cfg_json?.hide_btn_personal}
hide_professional={journal?.cfg_json?.hide_btn_professional} hide_professional={journal?.cfg_json
?.hide_btn_professional}
hide_template={journal?.cfg_json?.hide_btn_template} hide_template={journal?.cfg_json?.hide_btn_template}
/> />
</section> </section>
{#if tmp_entry_obj.private && !tmp_entry_obj.content && tmp_entry_obj.content_encrypted} {#if tmp_entry_obj.private && !tmp_entry_obj.content && tmp_entry_obj.content_encrypted}
<section class="pt-8 border-t border-error-500/20"> <section class="pt-8 border-t border-error-500/20">
<div class="bg-error-500/10 p-4 rounded-lg border border-error-500/30"> <div
<h4 class="text-error-500 font-bold flex items-center gap-2 mb-2"> class="bg-error-500/10 p-4 rounded-lg border border-error-500/30"
>
<h4
class="text-error-500 font-bold flex items-center gap-2 mb-2"
>
<RefreshCcw size="1.2em" /> Disaster Recovery <RefreshCcw size="1.2em" /> Disaster Recovery
</h4> </h4>
<p class="text-xs opacity-70 mb-4 italic">If the encryption passcode is lost, the data is unrecoverable. You can force a reset to plain text to reuse this entry ID.</p> <p class="text-xs opacity-70 mb-4 italic">
<button type="button" class="btn btn-sm variant-filled-error w-full font-bold" onclick={() => { show = false; on_force_reset?.(); }}> If the encryption passcode is lost, the data is
unrecoverable. You can force a reset to plain
text to reuse this entry ID.
</p>
<button
type="button"
class="btn btn-sm variant-filled-error w-full font-bold"
onclick={() => {
show = false;
on_force_reset?.();
}}
>
Force Reset to Plain Text Force Reset to Plain Text
</button> </button>
</div> </div>
@@ -275,12 +479,17 @@
{/if} {/if}
<section class="pt-12"> <section class="pt-12">
<button type="button" class="btn btn-sm variant-soft-error w-full" onclick={() => { alert('Delete logic handled in parent component'); }}> <button
type="button"
class="btn btn-sm variant-soft-error w-full"
onclick={() => {
alert('Delete logic handled in parent component');
}}
>
<Trash2 size="1.1em" class="mr-2" /> Delete Entry <Trash2 size="1.1em" class="mr-2" /> Delete Entry
</button> </button>
</section> </section>
</div> </div>
{:else if tab === 'json'} {:else if tab === 'json'}
<div class="h-full min-h-[400px]"> <div class="h-full min-h-[400px]">
<AE_Comp_Editor_CodeMirror <AE_Comp_Editor_CodeMirror
@@ -294,7 +503,11 @@
</div> </div>
{#snippet footer()} {#snippet footer()}
<button type="button" class="btn variant-filled-primary font-bold shadow-lg min-w-[120px]" onclick={() => (show = false)}> <button
type="button"
class="btn variant-filled-primary font-bold shadow-lg min-w-[120px]"
onclick={() => (show = false)}
>
<Check size="1.2em" class="mr-2" /> <Check size="1.2em" class="mr-2" />
Done Done
</button> </button>

View File

@@ -7,10 +7,20 @@
*/ */
import { Modal } from 'flowbite-svelte'; import { Modal } from 'flowbite-svelte';
import { Download, Copy, FileJson, FileType, Code, Settings2 } from 'lucide-svelte'; import {
Download,
Copy,
FileJson,
FileType,
Code,
Settings2
} from 'lucide-svelte';
import { ae_util } from '$lib/ae_utils/ae_utils'; import { ae_util } from '$lib/ae_utils/ae_utils';
import type { ae_JournalEntry, ae_Journal } from '$lib/types/ae_types'; import type { ae_JournalEntry, ae_Journal } from '$lib/types/ae_types';
import { EXPORT_TEMPLATES, type ExportTemplate } from '$lib/ae_journals/ae_journals_export_templates'; import {
EXPORT_TEMPLATES,
type ExportTemplate
} from '$lib/ae_journals/ae_journals_export_templates';
interface Props { interface Props {
open: boolean; open: boolean;
@@ -19,7 +29,12 @@
on_close: () => void; on_close: () => void;
} }
let { open = $bindable(false), entries = [], journal, on_close }: Props = $props(); let {
open = $bindable(false),
entries = [],
journal,
on_close
}: Props = $props();
// State // State
let selected_template_id: string = $state('standard_markdown'); let selected_template_id: string = $state('standard_markdown');
@@ -27,14 +42,24 @@
let export_count: number = $derived(entries.length); let export_count: number = $derived(entries.length);
const templates = Object.values(EXPORT_TEMPLATES); const templates = Object.values(EXPORT_TEMPLATES);
const selected_template = $derived(EXPORT_TEMPLATES[selected_template_id as keyof typeof EXPORT_TEMPLATES] || EXPORT_TEMPLATES.standard_markdown); const selected_template = $derived(
EXPORT_TEMPLATES[
selected_template_id as keyof typeof EXPORT_TEMPLATES
] || EXPORT_TEMPLATES.standard_markdown
);
// Auto-select template based on journal type when modal opens // Auto-select template based on journal type when modal opens
$effect(() => { $effect(() => {
if (open && journal?.type_code) { if (open && journal?.type_code) {
if (journal.type_code === 'personal_log' && EXPORT_TEMPLATES.personal_log) { if (
journal.type_code === 'personal_log' &&
EXPORT_TEMPLATES.personal_log
) {
selected_template_id = 'personal_log'; selected_template_id = 'personal_log';
} else if (journal.type_code === 'amazon_vine' && EXPORT_TEMPLATES.amazon_vine) { } else if (
journal.type_code === 'amazon_vine' &&
EXPORT_TEMPLATES.amazon_vine
) {
selected_template_id = 'amazon_vine'; selected_template_id = 'amazon_vine';
} }
} }
@@ -58,7 +83,9 @@
function handle_download() { function handle_download() {
const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
const filename = `journal_export_${timestamp}.${selected_template.extension}`; const filename = `journal_export_${timestamp}.${selected_template.extension}`;
const blob = new Blob([export_preview], { type: 'text/plain;charset=utf-8' }); const blob = new Blob([export_preview], {
type: 'text/plain;charset=utf-8'
});
const url = URL.createObjectURL(blob); const url = URL.createObjectURL(blob);
const link = document.createElement('a'); const link = document.createElement('a');
@@ -86,19 +113,24 @@
<Modal <Modal
title="Export Journal Entries" title="Export Journal Entries"
bind:open={open} bind:open
autoclose={false} autoclose={false}
size="xl" size="xl"
class="w-full" class="w-full"
> >
<div class="space-y-4"> <div class="space-y-4">
<div class="flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 text-blue-800 dark:text-blue-200 rounded-lg"> <div
class="flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 text-blue-800 dark:text-blue-200 rounded-lg"
>
<div> <div>
<strong>Ready to Export:</strong> {export_count} entries. <strong>Ready to Export:</strong>
{export_count} entries.
</div> </div>
{#if journal} {#if journal}
<div class="text-xs opacity-70"> <div class="text-xs opacity-70">
Journal Type: <span class="font-mono">{journal.type_code || 'standard'}</span> Journal Type: <span class="font-mono"
>{journal.type_code || 'standard'}</span
>
</div> </div>
{/if} {/if}
</div> </div>
@@ -111,10 +143,16 @@
</label> </label>
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-2"> <div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-2">
{#each templates as template} {#each templates as template}
<button type="button" <button
type="button"
class="btn variant-ringed-surface flex flex-col gap-1 p-2 h-24 items-center justify-center border-2 text-center {selected_template_id === template.id ? 'border-primary-500 bg-primary-50 dark:bg-primary-900/20' : 'opacity-60'}" class="btn variant-ringed-surface flex flex-col gap-1 p-2 h-24 items-center justify-center border-2 text-center {selected_template_id ===
onclick={() => { selected_template_id = template.id; generate_preview(); }} template.id
? 'border-primary-500 bg-primary-50 dark:bg-primary-900/20'
: 'opacity-60'}"
onclick={() => {
selected_template_id = template.id;
generate_preview();
}}
> >
{#if template.extension === 'json'} {#if template.extension === 'json'}
<FileJson size="1.5em" /> <FileJson size="1.5em" />
@@ -123,8 +161,12 @@
{:else} {:else}
<FileType size="1.5em" /> <FileType size="1.5em" />
{/if} {/if}
<span class="text-xs font-bold leading-tight">{template.name}</span> <span class="text-xs font-bold leading-tight"
<span class="text-[10px] opacity-70">.{template.extension}</span> >{template.name}</span
>
<span class="text-[10px] opacity-70"
>.{template.extension}</span
>
</button> </button>
{/each} {/each}
</div> </div>
@@ -134,24 +176,41 @@
<div class="form-control"> <div class="form-control">
<div class="label flex justify-between items-center"> <div class="label flex justify-between items-center">
<span class="label-text">Preview</span> <span class="label-text">Preview</span>
<span class="text-[10px] opacity-50 uppercase tracking-widest">{selected_template.name}</span> <span class="text-[10px] opacity-50 uppercase tracking-widest"
>{selected_template.name}</span
>
</div> </div>
<textarea <textarea
class="textarea h-64 font-mono text-xs bg-gray-50 dark:bg-gray-900" class="textarea h-64 font-mono text-xs bg-gray-50 dark:bg-gray-900"
readonly readonly
value={export_preview.substring(0, 5000) + (export_preview.length > 5000 ? '\n... (truncated for preview)' : '')} value={export_preview.substring(0, 5000) +
(export_preview.length > 5000
? '\n... (truncated for preview)'
: '')}
></textarea> ></textarea>
</div> </div>
<!-- Actions --> <!-- Actions -->
<div class="modal-action flex justify-between items-center"> <div class="modal-action flex justify-between items-center">
<button type="button" class="btn preset-tonal-secondary" onclick={on_close}>Close</button> <button
type="button"
class="btn preset-tonal-secondary"
onclick={on_close}>Close</button
>
<div class="flex gap-2"> <div class="flex gap-2">
<button type="button" class="btn variant-soft-primary" onclick={handle_copy}> <button
type="button"
class="btn variant-soft-primary"
onclick={handle_copy}
>
<Copy class="mr-2" size="1.2em" /> Copy to Clipboard <Copy class="mr-2" size="1.2em" /> Copy to Clipboard
</button> </button>
<button type="button" class="btn preset-filled-primary" onclick={handle_download}> <button
type="button"
class="btn preset-filled-primary"
onclick={handle_download}
>
<Download class="mr-2" size="1.2em" /> Download File <Download class="mr-2" size="1.2em" /> Download File
</button> </button>
</div> </div>

View File

@@ -1,7 +1,17 @@
<script lang="ts"> <script lang="ts">
import { Modal } from 'flowbite-svelte'; import { Modal } from 'flowbite-svelte';
import { Upload, FileText, AlertCircle, Check, X, RefreshCw } from 'lucide-svelte'; import {
import { PARSERS, type AeJournalEntryInput } from '$lib/ae_journals/ae_journals_parsers'; Upload,
FileText,
AlertCircle,
Check,
X,
RefreshCw
} from 'lucide-svelte';
import {
PARSERS,
type AeJournalEntryInput
} from '$lib/ae_journals/ae_journals_parsers';
import { journals_func } from '$lib/ae_journals/ae_journals_functions'; import { journals_func } from '$lib/ae_journals/ae_journals_functions';
import { ae_api } from '$lib/stores/ae_stores'; import { ae_api } from '$lib/stores/ae_stores';
import { journals_slct } from '$lib/ae_journals/ae_journals_stores'; import { journals_slct } from '$lib/ae_journals/ae_journals_stores';
@@ -12,7 +22,11 @@
on_import_complete: () => void; on_import_complete: () => void;
} }
let { open = $bindable(false), on_close, on_import_complete }: Props = $props(); let {
open = $bindable(false),
on_close,
on_import_complete
}: Props = $props();
let files: FileList | null = $state(null); let files: FileList | null = $state(null);
let selected_parser: keyof typeof PARSERS = $state('standard'); let selected_parser: keyof typeof PARSERS = $state('standard');
@@ -30,25 +44,25 @@
}); });
function handle_drag_enter(e: DragEvent) { function handle_drag_enter(e: DragEvent) {
e.preventDefault(); e.prevent_default();
e.stopPropagation(); e.stopPropagation();
is_dragging = true; is_dragging = true;
} }
function handle_drag_leave(e: DragEvent) { function handle_drag_leave(e: DragEvent) {
e.preventDefault(); e.prevent_default();
e.stopPropagation(); e.stopPropagation();
is_dragging = false; is_dragging = false;
} }
function handle_drag_over(e: DragEvent) { function handle_drag_over(e: DragEvent) {
e.preventDefault(); e.prevent_default();
e.stopPropagation(); e.stopPropagation();
is_dragging = true; is_dragging = true;
} }
function handle_drop(e: DragEvent) { function handle_drop(e: DragEvent) {
e.preventDefault(); e.prevent_default();
e.stopPropagation(); e.stopPropagation();
is_dragging = false; is_dragging = false;
@@ -84,7 +98,9 @@
const journal_id = $journals_slct.journal_id; const journal_id = $journals_slct.journal_id;
if (!journal_id) { if (!journal_id) {
alert("No target journal selected. Please select a journal in the background first."); alert(
'No target journal selected. Please select a journal in the background first.'
);
is_importing = false; is_importing = false;
return; return;
} }
@@ -122,7 +138,9 @@
} }
is_importing = false; is_importing = false;
alert(`Import complete! ${success_count}/${parsed_entries.length} imported.`); alert(
`Import complete! ${success_count}/${parsed_entries.length} imported.`
);
on_import_complete(); on_import_complete();
open = false; open = false;
} }
@@ -130,7 +148,7 @@
<Modal <Modal
title="Import Journal Entries" title="Import Journal Entries"
bind:open={open} bind:open
autoclose={false} autoclose={false}
size="xl" size="xl"
class="w-full" class="w-full"
@@ -142,8 +160,12 @@
<label class="label"> <label class="label">
<span>Parser Strategy</span> <span>Parser Strategy</span>
<select class="select" bind:value={selected_parser}> <select class="select" bind:value={selected_parser}>
<option value="standard">Standard (1 File = 1 Entry)</option> <option value="standard"
<option value="personal_log">Personal Log (Split by Date)</option> >Standard (1 File = 1 Entry)</option
>
<option value="personal_log"
>Personal Log (Split by Date)</option
>
<option value="amazon_vine">Amazon Vine Reviews</option> <option value="amazon_vine">Amazon Vine Reviews</option>
</select> </select>
</label> </label>
@@ -160,20 +182,28 @@
class=" class="
border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-all duration-200 border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-all duration-200
flex flex-col items-center justify-center gap-2 flex flex-col items-center justify-center gap-2
{is_dragging ? 'border-primary-500 bg-primary-50 dark:bg-primary-900/20' : 'border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500'} {is_dragging
? 'border-primary-500 bg-primary-50 dark:bg-primary-900/20'
: 'border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500'}
" "
ondragenter={handle_drag_enter} ondragenter={handle_drag_enter}
ondragleave={handle_drag_leave} ondragleave={handle_drag_leave}
ondragover={handle_drag_over} ondragover={handle_drag_over}
ondrop={handle_drop} ondrop={handle_drop}
onclick={() => document.getElementById('file_import_input')?.click()} onclick={() =>
document.getElementById('file_import_input')?.click()}
> >
<Upload class="h-10 w-10 text-gray-400" /> <Upload class="h-10 w-10 text-gray-400" />
<p class="text-sm text-gray-500"> <p class="text-sm text-gray-500">
<span class="font-semibold text-primary-600 hover:text-primary-500">Click to upload</span> <span
class="font-semibold text-primary-600 hover:text-primary-500"
>Click to upload</span
>
or drag and drop or drag and drop
</p> </p>
<p class="text-xs text-gray-400">Markdown (.md) or Text (.txt) files</p> <p class="text-xs text-gray-400">
Markdown (.md) or Text (.txt) files
</p>
<input <input
id="file_import_input" id="file_import_input"
@@ -181,14 +211,16 @@
class="hidden" class="hidden"
multiple multiple
accept=".md,.txt" accept=".md,.txt"
onchange={(e) => files = e.currentTarget.files} onchange={(e) => (files = e.currentTarget.files)}
/> />
</div> </div>
</div> </div>
</div> </div>
<!-- Preview --> <!-- Preview -->
<div class="border rounded-lg p-2 bg-gray-50 dark:bg-gray-900 max-h-64 overflow-y-auto"> <div
class="border rounded-lg p-2 bg-gray-50 dark:bg-gray-900 max-h-64 overflow-y-auto"
>
<h4 class="font-bold mb-2 flex justify-between"> <h4 class="font-bold mb-2 flex justify-between">
<span>Preview ({parsed_entries.length} entries)</span> <span>Preview ({parsed_entries.length} entries)</span>
{#if is_parsing} {#if is_parsing}
@@ -208,23 +240,32 @@
<tbody> <tbody>
{#each parsed_entries as entry} {#each parsed_entries as entry}
<tr> <tr>
<td class="truncate max-w-[200px]" title={entry.name}>{entry.name}</td> <td
<td>{entry.created_on?.substring(0,10)}</td> class="truncate max-w-[200px]"
title={entry.name}>{entry.name}</td
>
<td>{entry.created_on?.substring(0, 10)}</td>
<td>{entry.tags.join(', ')}</td> <td>{entry.tags.join(', ')}</td>
</tr> </tr>
{/each} {/each}
</tbody> </tbody>
</table> </table>
{:else if files && files.length > 0 && !is_parsing} {:else if files && files.length > 0 && !is_parsing}
<div class="text-center text-gray-500 py-4">No entries found in selected files.</div> <div class="text-center text-gray-500 py-4">
No entries found in selected files.
</div>
{:else if !files} {:else if !files}
<div class="text-center text-gray-500 py-4">Select files to preview import.</div> <div class="text-center text-gray-500 py-4">
Select files to preview import.
</div>
{/if} {/if}
</div> </div>
<!-- Import Log --> <!-- Import Log -->
{#if import_log.length > 0} {#if import_log.length > 0}
<div class="bg-black text-green-400 p-2 rounded text-xs font-mono max-h-32 overflow-y-auto"> <div
class="bg-black text-green-400 p-2 rounded text-xs font-mono max-h-32 overflow-y-auto"
>
{#each import_log as log} {#each import_log as log}
<div>{log}</div> <div>{log}</div>
{/each} {/each}
@@ -232,8 +273,13 @@
{/if} {/if}
<div class="modal-action"> <div class="modal-action">
<button type="button" class="btn preset-tonal-secondary" onclick={on_close}>Cancel</button> <button
<button type="button" type="button"
class="btn preset-tonal-secondary"
onclick={on_close}>Cancel</button
>
<button
type="button"
class="btn preset-filled-primary" class="btn preset-filled-primary"
disabled={parsed_entries.length === 0 || is_importing} disabled={parsed_entries.length === 0 || is_importing}
onclick={handle_import} onclick={handle_import}

View File

@@ -97,7 +97,9 @@
let ae_promises: key_val = $state({}); let ae_promises: key_val = $state({});
</script> </script>
<section class="ae_meta flex flex-row flex-wrap gap-1 items-center justify-between w-full"> <section
class="ae_meta flex flex-row flex-wrap gap-1 items-center justify-between w-full"
>
<!-- {lq__journal_entry_obj?.priority} <!-- {lq__journal_entry_obj?.priority}
{lq__journal_entry_obj?.sort} {lq__journal_entry_obj?.sort}
{lq__journal_entry_obj?.group} {lq__journal_entry_obj?.group}
@@ -105,7 +107,8 @@
{obj_enable} --> {obj_enable} -->
<!-- Set/unset priority (boolean) --> <!-- Set/unset priority (boolean) -->
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
obj_priority = !obj_priority; obj_priority = !obj_priority;
// update_journal_entry(); // update_journal_entry();
@@ -126,7 +129,8 @@
class:hidden={!$ae_loc.edit_mode} class:hidden={!$ae_loc.edit_mode}
class="flex flex-row flex-wrap items-center justify-center border border-gray-300 rounded-lg" class="flex flex-row flex-wrap items-center justify-center border border-gray-300 rounded-lg"
> >
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
obj_sort = obj_sort ? obj_sort + 1 : 1; obj_sort = obj_sort ? obj_sort + 1 : 1;
// update_journal_entry(); // update_journal_entry();
@@ -144,7 +148,8 @@
<ArrowDown10 /> <ArrowDown10 />
{/if} {/if}
</span> </span>
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
obj_sort = obj_sort ? obj_sort - 1 : 0; obj_sort = obj_sort ? obj_sort - 1 : 0;
// update_journal_entry(); // update_journal_entry();
@@ -187,7 +192,8 @@
{#if obj_archive_on} {#if obj_archive_on}
<!-- Button to clear the datetime --> <!-- Button to clear the datetime -->
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
obj_archive_on = null; obj_archive_on = null;
// update_journal_entry(); // update_journal_entry();
@@ -201,12 +207,16 @@
</button> </button>
{:else} {:else}
<!-- Button to set the datetime to now --> <!-- Button to set the datetime to now -->
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
// tmp_entry_obj.archive_on = new Date().toISOString(); // tmp_entry_obj.archive_on = new Date().toISOString();
// console.log('Archive on datetime set to now:', tmp_entry_obj.archive_on); // console.log('Archive on datetime set to now:', tmp_entry_obj.archive_on);
obj_archive_on = new Date().toISOString(); obj_archive_on = new Date().toISOString();
console.log('Archive on datetime set to now:', tmp_entry_obj.archive_on); console.log(
'Archive on datetime set to now:',
tmp_entry_obj.archive_on
);
// update_journal_entry(); // update_journal_entry();
}} }}
class:hidden={!$ae_loc.edit_mode} class:hidden={!$ae_loc.edit_mode}
@@ -220,7 +230,8 @@
</span> </span>
<!-- Set/unset hide (boolean) --> <!-- Set/unset hide (boolean) -->
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
obj_hide = !obj_hide; obj_hide = !obj_hide;
update_journal_entry(); update_journal_entry();
@@ -238,7 +249,8 @@
</button> </button>
<!-- Set/unset enable (boolean) --> <!-- Set/unset enable (boolean) -->
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
obj_enable = !obj_enable; obj_enable = !obj_enable;
// update_journal_entry(); // update_journal_entry();
@@ -257,9 +269,12 @@
</button> </button>
<!-- Delete journal entry --> <!-- Delete journal entry -->
<button type="button" <button
type="button"
onclick={() => { onclick={() => {
if (confirm(`Are you sure you want to delete this journal entry?`)) { if (
confirm(`Are you sure you want to delete this journal entry?`)
) {
let delete_method = 'disable'; let delete_method = 'disable';
if ($ae_loc.administrator_access && $ae_loc.edit_mode) { if ($ae_loc.administrator_access && $ae_loc.edit_mode) {
delete_method = 'delete'; delete_method = 'delete';
@@ -267,7 +282,8 @@
journals_func journals_func
.delete_ae_obj_id__journal_entry({ .delete_ae_obj_id__journal_entry({
api_cfg: $ae_api, api_cfg: $ae_api,
journal_entry_id: lq__journal_entry_obj?.journal_entry_id, journal_entry_id:
lq__journal_entry_obj?.journal_entry_id,
method: delete_method as 'delete' | 'disable' | 'hide', method: delete_method as 'delete' | 'disable' | 'hide',
log_lvl: log_lvl log_lvl: log_lvl
}) })
@@ -299,7 +315,9 @@
{/if} {/if}
</button> </button>
<span class="flex flex-row items-center justify-center text-sm text-gray-500"> <span
class="flex flex-row items-center justify-center text-sm text-gray-500"
>
{#if !$ae_loc.edit_mode} {#if !$ae_loc.edit_mode}
<span class=""> <span class="">
{ae_util.iso_datetime_formatter( {ae_util.iso_datetime_formatter(
@@ -329,7 +347,9 @@
class="flex flex-row flex-wrap gap-2 items-center justify-start border border-gray-200 rounded-lg" class="flex flex-row flex-wrap gap-2 items-center justify-start border border-gray-200 rounded-lg"
> >
<SquareLibrary size="1em" class="mx-1" /> <SquareLibrary size="1em" class="mx-1" />
<span class="text-sm text-gray-500 hidden sm:inline"> Journal: </span> <span class="text-sm text-gray-500 hidden sm:inline">
Journal:
</span>
<select <select
class="novi_btn btn btn-secondary btn-sm class="novi_btn btn btn-secondary btn-sm
preset-tonal-primary preset-tonal-primary
@@ -340,9 +360,15 @@
" "
bind:value={tmp_entry_obj.journal_id} bind:value={tmp_entry_obj.journal_id}
onchange={(event) => { onchange={(event) => {
tmp_entry_obj.journal_id = (event.target as HTMLInputElement).value; tmp_entry_obj.journal_id = (
event.target as HTMLInputElement
).value;
console.log('Selected journal:', tmp_entry_obj.journal_id); console.log('Selected journal:', tmp_entry_obj.journal_id);
if (confirm(`Are you sure you want to change the journal for this entry?`)) { if (
confirm(
`Are you sure you want to change the journal for this entry?`
)
) {
change_journal_id(); change_journal_id();
} }
}} }}
@@ -350,7 +376,10 @@
> >
<option value="">Select Journal</option> <option value="">Select Journal</option>
{#each lq__journal_obj_li as journal} {#each lq__journal_obj_li as journal}
<option value={journal.journal_id} title={`Journal: ${journal.name}`}> <option
value={journal.journal_id}
title={`Journal: ${journal.name}`}
>
{journal.name} {journal.name}
</option> </option>
{/each} {/each}