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

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

View File

@@ -126,11 +126,6 @@ export async function load_ae_obj_li__archive(
console.log(`*** load_ae_obj_li__archive() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
}
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
// let limit: number = (params.qry__limit ?? 99); // 99
// let offset: number = (params.qry__offset ?? 0); // 0
let params_json: key_val = {};
// console.log('params_json:', params_json);

View File

@@ -377,6 +377,7 @@ export async function db_save_ae_obj_li__archive_content(
created_on: obj.created_on,
updated_on: obj.updated_on,
// Generated fields for sorting locally only
tmp_sort_1: `${obj.original_datetime}_${obj.group}_${obj.priority}_${obj.sort}`,
tmp_sort_2: `${obj.group}_${obj.original_datetime}_${obj.priority}_${obj.sort}`,

View File

@@ -0,0 +1,589 @@
import type { key_val } from '$lib/ae_stores';
import { api } from '$lib/api';
import { db_journals } from "$lib/ae_journals/db_journals";
import { load_ae_obj_li__journal_entry } from "$lib/ae_journals/ae_journals__journal_entry";
let ae_promises: key_val = {};
// Updated 2025-03-15
export async function load_ae_obj_id__journal(
{
api_cfg,
journal_id,
inc_entry_li = false,
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
journal_id: string,
inc_entry_li?: boolean,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** load_ae_obj_id__journal() *** journal_id=${journal_id}`);
}
let params = {};
ae_promises.load__journal_obj = await api.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'journal',
obj_id: journal_id, // NOTE: This is the FQDN, not normally the ID.
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
params: params,
log_lvl: log_lvl
})
.then(function (journal_obj_get_result) {
if (journal_obj_get_result) {
if (try_cache) {
// This is expecting a list
db_save_ae_obj_li__journal({
obj_type: 'journal',
obj_li: [journal_obj_get_result]
});
}
return journal_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.load__journal_obj:', ae_promises.load__journal_obj);
}
if (inc_entry_li) {
// Load the entries for the journal
if (log_lvl) {
console.log(`Need to load the entry list for the journal now`);
}
let load_journal_entry_obj_li = load_ae_obj_li__journal_entry({
api_cfg: api_cfg,
for_obj_type: 'journal',
for_obj_id: journal_id,
params: {qry__enabled: 'all', qry__limit: 99},
try_cache: try_cache,
log_lvl: log_lvl
})
.then((journal_entry_obj_li) => {
if (log_lvl) {
console.log(`journal_entry_obj_li = `, journal_entry_obj_li);
}
return journal_entry_obj_li;
});
if (log_lvl) {
console.log(`journal_entry_obj_li = `, load_journal_entry_obj_li);
}
ae_promises.load__journal_obj.journal_entry_li = load_journal_entry_obj_li;
}
return ae_promises.load__journal_obj;
}
// Updated 2025-03-15
export async function load_ae_obj_li__journal(
{
api_cfg,
for_obj_type = 'account',
for_obj_id,
inc_entry_li = false,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
for_obj_type: string,
for_obj_id: string,
inc_entry_li?: boolean,
enabled?: string, // all, disabled, enabled
hidden?: string, // all, hidden, not_hidden
limit?: number,
offset?: number,
order_by_li?: key_val,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** load_ae_obj_li__journal() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
}
let params_json: key_val = {};
// console.log('params_json:', params_json);
ae_promises.load__journal_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg: api_cfg,
obj_type: 'journal',
for_obj_type: for_obj_type,
for_obj_id: for_obj_id,
use_alt_tbl: false,
use_alt_mdl: false,
use_alt_exp: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (journal_obj_li_get_result) {
if (journal_obj_li_get_result) {
if (try_cache) {
db_save_ae_obj_li__journal({
obj_type: 'journal',
obj_li: journal_obj_li_get_result
});
}
return journal_obj_li_get_result;
} else {
return [];
}
});
if (log_lvl) {
console.log('ae_promises.load__journal_obj_li:', ae_promises.load__journal_obj_li);
}
if (inc_entry_li) {
// Load the entries for the journals
if (log_lvl) {
console.log(`Need to load the entry list for each journal now`);
}
for (let i = 0; i < ae_promises.load__journal_obj_li.length; i++) {
let journal_obj = ae_promises.load__journal_obj_li[i];
let journal_id = journal_obj.journal_id_random;
let load_journal_entry_obj_li = load_ae_obj_li__journal_entry({
api_cfg: api_cfg,
for_obj_type: 'journal',
for_obj_id: journal_id,
params: params,
try_cache: try_cache,
log_lvl: log_lvl
})
.then((journal_entry_obj_li) => {
if (log_lvl) {
console.log(`journal_entry_obj_li = `, journal_entry_obj_li);
}
return journal_entry_obj_li;
});
if (log_lvl) {
console.log(`load_journal_entry_obj_li = `, load_journal_entry_obj_li);
}
}
}
return ae_promises.load__journal_obj_li;
}
// Updated 2025-03-15
export async function create_ae_obj__journal(
{
api_cfg,
account_id,
data_kv,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
account_id: string,
data_kv: key_val,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** create_ae_obj__journal() *** account_id=${account_id}`);
}
ae_promises.create__journal = await api.create_ae_obj_crud({
api_cfg: api_cfg,
obj_type: 'journal',
fields: {
account_id_random: account_id,
...data_kv
},
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
})
.then(function (journal_obj_create_result) {
if (journal_obj_create_result) {
if (try_cache) {
db_save_ae_obj_li__journal(
{
obj_type: 'journal',
obj_li: [journal_obj_create_result]
});
}
return journal_obj_create_result;
} else {
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
})
.finally(function () {
});
if (log_lvl) {
console.log('ae_promises.create__journal:', ae_promises.create__journal);
}
return ae_promises.create__journal;
}
// Updated 2025-03-15
export async function delete_ae_obj_id__journal(
{
api_cfg,
journal_id,
method = 'delete', // 'delete', 'disable', 'hide'
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
journal_id: string,
method?: string,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** delete_ae_obj_id__journal() *** journal_id=${journal_id}`);
}
ae_promises.delete__journal_obj = await api.delete_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'journal',
obj_id: journal_id,
key: api_cfg.api_crud_super_key,
params: params,
method: method,
log_lvl: log_lvl
})
.catch(function (error) {
console.log('No results returned or failed.', error);
})
.finally(function () {
if (try_cache) {
if (log_lvl) {
console.log(`Attempting to remove IDB entry for journal_id=${journal_id}`);
}
db_journals.journal.delete(journal_id);
}
});
if (log_lvl) {
console.log('ae_promises.delete__journal_obj:', ae_promises.delete__journal_obj);
}
return ae_promises.delete__journal_obj;
}
// Updated 2025-03-15
export async function update_ae_obj__journal(
{
api_cfg,
journal_id,
data_kv,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
journal_id: string,
data_kv: key_val,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** update_ae_obj__journal() *** journal_id=${journal_id}`, data_kv);
}
ae_promises.update__journal_obj = await api.update_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'journal',
obj_id: journal_id,
fields: data_kv,
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
})
.then(function (journal_obj_update_result) {
if (journal_obj_update_result) {
if (try_cache) {
db_save_ae_obj_li__journal({
obj_type: 'journal', obj_li: [journal_obj_update_result]
});
}
return journal_obj_update_result;
} else {
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
})
.finally(function () {
});
if (log_lvl) {
console.log('ae_promises.update__journal_obj:', ae_promises.update__journal_obj);
}
return ae_promises.update__journal_obj;
}
// This new function is using CRUD v2. This should allow for more flexibility in the queries.
// Updated 2025-03-15
export async function qry__journal(
{
api_cfg,
journal_id,
qry_str,
qry_files,
qry_start_datetime, // Example greater than: '2024-10-24'
enabled = 'enabled',
hidden = 'not_hidden',
limit = 50,
offset = 0,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
journal_id: any,
qry_str?: string,
qry_files?: null|boolean,
qry_start_datetime?: null|string, // Greater than this datetime
enabled?: string, // all, disabled, enabled
hidden?: string, // all, hidden, not_hidden
limit?: number,
offset?: number,
params?: any,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** qry__journal() *** journal_id=${journal_id} enabled=${enabled} hidden=${hidden} limit=${limit} offset=${offset}`);
}
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
// let limit: number = (params.qry__limit ?? 25); // 99
// let offset: number = (params.qry__offset ?? 0); // 0
let params_json: key_val = {};
// if (qry_str && qry_str.length > 2) {
// params_json['ft_qry'] = {};
// params_json['ft_qry']['default_qry_str'] = qry_str;
// }
params_json['qry'] = [];
if (qry_files === true) {
let qry_param =
{
type: "AND",
field: "file_count_all",
operator: ">",
value: 0
};
params_json['qry'].push(qry_param);
} else if (qry_files === false) {
let qry_param =
{
type: "AND",
field: "file_count_all",
operator: "IS",
value: null
};
params_json['qry'].push(qry_param);
}
if (qry_start_datetime) {
let qry_param =
{
type: "AND",
field: "start_datetime",
operator: ">",
value: qry_start_datetime
};
params_json['qry'].push(qry_param);
}
let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
ae_promises.load__journal_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg: api_cfg,
obj_type: 'journal',
for_obj_type: 'account',
for_obj_id: journal_id,
use_alt_tbl: true, // NOTE: We want to use the alt table for journal searching
use_alt_mdl: false,
use_alt_exp: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (journal_obj_li_get_result) {
if (journal_obj_li_get_result) {
db_save_ae_obj_li__journal({
obj_type: 'journal',
obj_li: journal_obj_li_get_result
});
return journal_obj_li_get_result;
} else {
return [];
}
});
if (log_lvl) {
console.log('ae_promises.load__journal_obj_li:', ae_promises.load__journal_obj_li);
}
return ae_promises.load__journal_obj_li;
}
// This function will loop through the journal_obj_li and save each one to the DB.
// Updated 2025-03-15
export function db_save_ae_obj_li__journal(
{
obj_type,
obj_li,
log_lvl = 0
}: {
obj_type: string,
obj_li: any,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** db_save_ae_obj_li__journal() ***`);
}
if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj: any) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
try {
const id_random = await db_journals.journal.put({
id: obj.journal_id_random,
journal_id: obj.journal_id_random,
code: obj.code,
for_type: obj.for_type,
for_id: obj.for_id,
type_code: obj.type_code,
account_id: obj.account_id_random,
person_id: obj.person_id_random,
name: obj.name,
summary: obj.summary,
outline: obj.outline,
description: obj.description,
description_html: obj.description_html,
description_json: obj.description_json,
// start_datetime: obj.start_datetime,
// end_datetime: obj.end_datetime,
timezone: obj.timezone,
alert: obj.alert,
alert_msg: obj.alert_msg,
sort_by: obj.sort_by,
sort_by_desc: obj.sort_by_desc,
cfg_json: obj.cfg_json,
data_json: obj.data_json,
// ux_mode: obj.ux_mode,
// This only allows for basic access to the data.
passcode_read: obj.passcode_read, // For LLM (AI) generated summary...???
passcode_read_expire: obj.passcode_read_expire,
passcode_write: obj.passcode_write,
passcode_write_expire: obj.passcode_write_expire,
enable: obj.enable,
hide: obj.hide,
priority: obj.priority,
sort: obj.sort,
group: obj.group,
notes: obj.notes,
created_on: obj.created_on,
updated_on: obj.updated_on,
// Generated fields for sorting locally only
// tmp_sort_1: `${obj.original_datetime}_${obj.group}_${obj.priority}_${obj.sort}`,
// tmp_sort_2: `${obj.group}_${obj.original_datetime}_${obj.priority}_${obj.sort}`,
// From SQL view
// journal_other_count: obj.journal_other_count,
// A key value list of the others
// journal_other_kv: obj.journal_other_kv,
// journal_other_li: obj.journal_other_li,
});
// console.log(`Put obj with ID: ${obj.journal_id_random} or ${id_random}`);
} catch (error) {
let status = `Failed to put ${obj.journal_id_random}: ${error}`;
console.log(status);
}
// const id_random = await db_journals.journal.put(obj);
// console.log(`Put obj with ID: ${obj.journal_id_random}`);
});
return true;
}
}

View File

@@ -0,0 +1,425 @@
import type { key_val } from '$lib/ae_stores';
import { api } from '$lib/api';
import { db_journals } from "$lib/ae_journals/db_journals";
let ae_promises: key_val = {};
// Updated 2025-03-15
export async function load_ae_obj_id__journal_entry(
{
api_cfg,
journal_entry_id,
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
journal_entry_id: string,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** load_ae_obj_id__journal_entry() *** journal_entry_id=${journal_entry_id}`);
}
let params = {};
ae_promises.load__journal_entry_obj = await api.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'journal_entry',
obj_id: journal_entry_id, // NOTE: This is the FQDN, not normally the ID.
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
params: params,
log_lvl: log_lvl
})
.then(async function (journal_entry_obj_get_result) {
if (journal_entry_obj_get_result) {
if (try_cache) {
// This is expecting a list
await db_save_ae_obj_li__journal_entry({
obj_type: 'journal_entry',
obj_li: [journal_entry_obj_get_result]
});
}
return journal_entry_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
return ae_promises.load__journal_entry_obj;
}
// Updated 2025-03-15
export async function load_ae_obj_li__journal_entry(
{
api_cfg,
for_obj_type = 'journal',
for_obj_id,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
for_obj_type: string,
for_obj_id: string,
enabled?: string,
hidden?: string,
limit?: number,
offset?: number,
order_by_li?: key_val,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** load_ae_obj_li__journal_entry() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
}
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
// let limit: number = (params.qry__limit ?? 99); // 99
// let offset: number = (params.qry__offset ?? 0); // 0
let params_json: key_val = {};
// console('params_json:', params_json);
ae_promises.load__journal_entry_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg: api_cfg,
obj_type: 'journal_entry',
for_obj_type: for_obj_type,
for_obj_id: for_obj_id,
use_alt_tbl: false,
use_alt_mdl: false,
use_alt_exp: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(async function (journal_entry_obj_li_get_result) {
if (journal_entry_obj_li_get_result) {
if (try_cache) {
await db_save_ae_obj_li__journal_entry({
obj_type: 'journal_entry', obj_li: journal_entry_obj_li_get_result
});
}
return journal_entry_obj_li_get_result;
} else {
return [];
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.load__journal_entry_obj_li:', ae_promises.load__journal_entry_obj_li);
}
return ae_promises.load__journal_entry_obj_li;
}
// Updated 2025-03-15
export async function create_ae_obj__journal_entry(
{
api_cfg,
journal_id,
data_kv,
params={},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
journal_id: string,
data_kv: key_val,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** create_ae_obj__journal_entry() *** journal_id=${journal_id}`);
}
ae_promises.create__journal_entry = await api.create_ae_obj_crud({
api_cfg: api_cfg,
obj_type: 'journal_entry',
fields: {
journal_id_random: journal_id,
...data_kv
},
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
})
.then(async function (journal_entry_obj_create_result) {
if (journal_entry_obj_create_result) {
if (try_cache) {
await db_save_ae_obj_li__journal_entry(
{
obj_type: 'journal_entry',
obj_li: [journal_entry_obj_create_result]
});
}
return journal_entry_obj_create_result;
} else {
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.create__journal_entry:', ae_promises.create__journal_entry);
}
return ae_promises.create__journal_entry;
}
// Updated 2025-03-15
export async function delete_ae_obj_id__journal_entry(
{
api_cfg,
journal_entry_id,
method = 'delete', // 'delete', 'disable', 'hide'
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
journal_entry_id: string,
method?: string,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** delete_ae_obj_id__journal_entry() *** journal_entry_id=${journal_entry_id}`);
}
ae_promises.delete__journal_entry_obj = await api.delete_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'journal_entry',
obj_id: journal_entry_id,
key: api_cfg.api_crud_super_key,
params: params,
method: method,
log_lvl: log_lvl
})
.catch(function (error) {
console.log('No results returned or failed.', error);
})
.finally(function () {
if (try_cache) {
if (log_lvl) {
console.log(`Attempting to remove IDB entry for journal_entry_id=${journal_entry_id}`);
}
db_journals.journal_entry.delete(journal_entry_id); // Delete from the DB no matter what.
}
});
if (log_lvl) {
console.log('ae_promises.delete__journal_entry_obj:', ae_promises.delete__journal_entry_obj);
}
return ae_promises.delete__journal_entry_obj;
}
// Updated 2025-03-15
export async function update_ae_obj__journal_entry(
{
api_cfg,
journal_entry_id,
data_kv,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
journal_entry_id: string,
data_kv: key_val,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** update_ae_obj__journal_entry() *** journal_entry_id=${journal_entry_id}`, data_kv);
}
ae_promises.update__journal_entry_obj = await api.update_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'journal_entry',
obj_id: journal_entry_id,
fields: data_kv,
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
})
.then(async function (journal_entry_obj_update_result) {
if (journal_entry_obj_update_result) {
if (try_cache) {
await db_save_ae_obj_li__journal_entry({
obj_type: 'journal_entry', obj_li: [journal_entry_obj_update_result]
});
}
return journal_entry_obj_update_result;
} else {
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
})
.finally(function () {
});
if (log_lvl) {
console.log('ae_promises.update__journal_entry_obj:', ae_promises.update__journal_entry_obj);
}
return ae_promises.update__journal_entry_obj;
}
// This function will loop through the journal_entry_obj_li and save each one to the DB.
// Updated 2025-03-15
export async function db_save_ae_obj_li__journal_entry(
{
obj_type,
obj_li,
log_lvl = 0
}: {
obj_type: string,
obj_li: any,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** db_save_ae_obj_li__journal_entry() ***`);
}
if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj: any) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
try {
const id_random = await db_journals.journal_entry.put({
id: obj.journal_entry_id_random,
journal_entry_id: obj.journal_entry_id_random,
journal_id: obj.journal_id_random,
code: obj.code,
for_type: obj.for_type,
for_id: obj.for_id,
journal_entry_type: obj.journal_entry_type,
person_id: obj.person_id_random,
name: obj.name,
summary: obj.summary,
outline: obj.outline,
// description: obj.description,
content: obj.content,
content_html: obj.content_html,
content_json: obj.content_json,
// url: obj.url,
// url_text: obj.url_text,
// hosted_file_id: obj.hosted_file_id_random,
// file_path: obj.file_path,
// filename: obj.filename,
// file_extension: obj.file_extension,
// start_datetime: obj.start_datetime,
// end_datetime: obj.end_datetime,
// timezone: obj.timezone,
// original_datetime: obj.original_datetime,
// original_timezone: obj.original_timezone,
// original_location: obj.original_location,
// original_url: obj.original_url,
// original_url_text: obj.original_url_text,
// enable_for_public: obj.enable_for_public,
alert: obj.alert,
alert_msg: obj.alert_msg,
// cfg_json: obj.cfg_json,
data_json: obj.data_json,
// This only allows for basic access to the data.
// passcode_read: obj.passcode_read, // For LLM (AI) generated summary...???
// passcode_read_expire: obj.passcode_read_expire,
// passcode_write: obj.passcode_write,
// passcode_write_expire: obj.passcode_write_expire,
enable: obj.enable,
hide: obj.hide,
priority: obj.priority,
sort: obj.sort,
group: obj.group,
notes: obj.notes,
created_on: obj.created_on,
updated_on: obj.updated_on,
// Generated fields for sorting locally only
// tmp_sort_1: `${obj.original_datetime}_${obj.group}_${obj.priority}_${obj.sort}`,
// tmp_sort_2: `${obj.group}_${obj.original_datetime}_${obj.priority}_${obj.sort}`,
// From SQL view
journal_code: obj.journal_code,
journal_name: obj.journal_name,
// A key value list of the others
// journal_other_kv: obj.journal_other_kv,
// journal_other_li: obj.journal_other_li,
});
// console.log(`Put obj with ID: ${obj.journal_entry_id_random} or ${id_random}`);
} catch (error) {
let status = `Failed to put ${obj.journal_entry_id_random}: ${error}`;
console.log(status);
}
// const id_random = await db_journals.journal_entry.put(obj);
// console.log(`Put obj with ID: ${obj.journal_entry_id_random}`);
});
return true;
}
}

View File

@@ -0,0 +1,21 @@
// This file is used to export all the functions that are used for Aether Journals related functions.
import * as journal from "$lib/ae_journals/ae_journals__journal";
import * as journal_entry from "$lib/ae_journals/ae_journals__journal_entry";
let export_obj = {
load_ae_obj_id__journal: journal.load_ae_obj_id__journal,
load_ae_obj_li__journal: journal.load_ae_obj_li__journal,
create_ae_obj__journal: journal.create_ae_obj__journal,
delete_ae_obj_id__journal: journal.delete_ae_obj_id__journal,
update_ae_obj__journal: journal.update_ae_obj__journal,
db_save_ae_obj_li__journal: journal.db_save_ae_obj_li__journal,
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,
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,
update_ae_obj__journal_entry: journal_entry.update_ae_obj__journal_entry,
db_save_ae_obj_li__journal_entry: journal_entry.db_save_ae_obj_li__journal_entry,
};
export let journals_func = export_obj;

View File

@@ -0,0 +1,104 @@
import { localStorageStore } from '@skeletonlabs/skeleton';
import { writable } from 'svelte/store';
import type { Writable } from 'svelte/store';
import type { key_val } from '$lib/ae_stores';
/* *** BEGIN *** Initialize journals_local_data_struct */
// This is for longer term or sticky app data. This should be stored to *local* storage.
// Updated 2024-08-20
let journals_local_data_struct: key_val = {
ver: '2024-08-20_19',
// Shared
name: 'Aether - Journals (SvelteKit 2.x Svelte 4.x)',
title: `OSIT's Æ Journals`, // &AElig;
mode__edit: false,
mode__debug: false,
qry__enabled: 'enabled', // all, disabled, enabled
qry__hidden: 'not_hidden', // all, hidden, not_hidden
qry__limit: 20,
qry__order_by_li: {
// 'created_on': 'desc',
// 'updated_on': 'desc',
},
qry__offset: 0,
qry__journal_id: null,
};
// console.log(`AE Stores - App Journals Local Storage Data:`, journals_local_data_struct);
// This works and uses *local* storage:
export let journals_loc: Writable<key_val> = localStorageStore('ae_journals_loc', journals_local_data_struct);
// console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
/* *** BEGIN *** Initialize journals_session_data_struct */
// Temporary app data. This is lost if the page is refreshed or using different tabs/windows. This should be stored to *session* storage.
// Updated 2024-08-20
let journals_session_data_struct: key_val = {
ver: '2024-08-20_19',
log_lvl: 1,
// Shared Triggers
trigger: null,
trigger__journal_id: null,
// trigger__journal_li: null,
show__modal_edit__journal_id: false,
show__modal_view__journal_id: null,
show_list__journal_entry_li_group: true,
show__modal_view__journal_entry_id: null,
show__modal_edit__journal_entry_id: null,
};
// console.log(`AE Stores - App Journals Session Storage Data:`, journals_session_data_struct);
export let journals_sess = writable(journals_session_data_struct);
/* *** BEGIN *** Initialize journals_slct and journals_trig */
/* The slct and slct_trigger variable should not be stored in local storage. Only use session storage because browser tabs can be open to different journals, badges, exhibits, etc. */
// Intended for temporary session storage.
// Updated 2024-08-20
let journals_slct_obj_template: key_val = {
// Top level
'journal_id': null,
'journal_obj': {},
'journal_obj_li': [],
'lq__journal_obj': {}, // Testing passing a LiveQuery object around...
};
// console.log(`AE Stores - Selected Journals Objects:`, journals_slct_obj_template);
// This works, and uses *session* (not local) storage:
export let journals_slct = writable(journals_slct_obj_template);
/* *** BEGIN *** Initialize journals_trig */
// Intended for temporary session storage.
// Updated 2025-03-16
let journals_trig_template: key_val = {
archive_id: false,
archive_content_li: false,
event_id: false,
post_id: false,
};
export let journals_trig: any = writable(journals_trig_template);
// console.log(`AE Journals Stores - Journals Trigger:`, journals_trig);
/* *** BEGIN *** Initialize journals_prom */
// Intended for temporary session storage.
// Updated 2025-03-16
let journals_prom_template: key_val = {
archive_id: false,
archive_content_li: false,
event_id: false,
post_id: false,
};
export let journals_prom: any = writable(journals_prom_template);
// console.log(`AE Journals Stores - Journals Trigger:`, journals_prom);

View File

@@ -0,0 +1,274 @@
import Dexie, { type Table } from 'dexie';
import type { key_val } from '../ae_stores';
// li = list
// kv = key value list
// json = JSON string
// ux = user experience (mode)
// LLM = Large Language Model (AI)
// Updated 2025-03-15
export interface Journal {
id: string; // actually "id_random"
journal_id: string;
// Essentially this is a change log of journals
snapshot_id?: string; // This is the original journal ID. If deleted, then delete all children journals.
previous_id?: null|string; // This is the old or parent journal ID
next_id?: null|string; // This is the new or child journal ID
external_id?: null|string;
import_id?: null|string;
code?: null|string;
for_type?: null|string;
for_id?: null|string;
type_code?: null|string;
account_id?: null|string; // Owner account of the journal
person_id?: null|string; // Owner person of the journal
// event_id?: null|string; // Assign to an event???
// location_id?: null|string; // Assign to a location???
name: string; // or the title
summary?: null|string; // LLM (AI) generated summary...???
outline?: null|string; // LLM (AI) generated outline...???
description?: null|string;
description_html?: null|string;
description_json?: null|string;
start_datetime?: null|Date;
end_datetime?: null|Date;
timezone?: null|string;
alert?: null|boolean; // LLM (AI) generated summary...???
alert_msg?: null|string; // LLM (AI) generated summary...???
sort_by?: null|string; // This is the sort by field
sort_by_desc?: null|string; // This is the sort by field description
cfg_json?: null|key_val; // This is the configuration JSON for the journal
data_json?: null|string; // We always need to store something extra...
ux_mode?: null|string; // 'mobile' or 'desktop'
// This only allows for basic access to the data.
passcode_read?: null|string; // For LLM (AI) generated summary...???
passcode_read_expire?: null|Date;
passcode_write?: null|string;
passcode_write_expire?: null|Date
enable: null|boolean;
hide?: null|boolean;
priority?: null|boolean
sort?: null|number;
group?: null|string;
notes?: null|string;
created_on: Date;
updated_on?: null|Date;
// Additional fields for convenience (database views)
file_count?: null|number; // Only files directly under a journal
journal_file_id_li_json?: null|string;
// One person
person__given_name?: null|string;
person__family_name?: null|string;
person__full_name?: null|string;
person__primary_email?: null|string;
person__passcode?: null|string;
// JSON formatted key value pairs for multiple people: {id: name, email, etc.}
person__kv_json?: null|string;
journal_name?: null|string;
journal_location_code?: null|string;
journal_location_name?: null|string;
// A key value list of the entries
journal_entry_kv?: null|key_val;
journal_entry_li?: null|[];
// A key value list of the files
journal_file_kv?: null|key_val;
journal_file_li?: null|[];
// journal_collection_id?: null|string; // For a collection of journals?
// Future standard fields!!!
obj_id?: null|string;
obj_ext_uid?: null|string; // Probably not needed for journals
obj_ext_id?: null|string; // Probably not needed for journals
obj_import_id?: null|string; // Probably not needed for journals
obj_code?: null|string;
obj_account_id?: null|string;
obj_passcode?: null|string;
obj_type?: null|string; // Should always be 'journal' in this case
obj_type_ver_id?: null|string; // The ID from the table for the object type
obj_name?: null|string;
obj_summary?: null|string; // LLM (AI) generated summary...???
obj_outline?: null|string; // LLM (AI) generated outline...???
obj_description?: null|string; // Probably not needed for journals
obj_enable?: null|boolean;
obj_enable_on?: null|Date;
obj_archive_on?: null|Date;
obj_hide?: null|boolean;
obj_priority?: null|number;
obj_sort?: null|number;
obj_group?: null|string;
obj_cfg_json?: null|string;
obj_notes?: null|string;
obj_created_on?: Date;
obj_updated_on?: null|Date;
}
// Updated 2025-03-15
export interface Journal_Entry {
id: string; // actually "id_random"
journal_entry_id: string;
journal_id: string; // This is the parent journal ID. If deleted, then delete all children journal entries.
// Essentially this is a change log of journal entries
snapshot_id?: string; // This is the original journal ID. If deleted, then delete all children journal entries.
previous_id?: null|string; // This is the old or parent journal ID
next_id?: null|string; // This is the new or child journal ID
external_id?: null|string;
import_id?: null|string;
code?: null|string;
for_type?: null|string;
for_id?: null|string;
type_code?: null|string;
journal_entry_type?: null|string; // This is the type of journal entry
account_id?: null|string; // Owner account of the journal
person_id?: null|string; // Owner person of the journal
// event_id?: null|string; // Assign to an event???
// location_id?: null|string; // Assign to a location???
name: string; // or the title
summary?: null|string; // LLM (AI) generated summary...???
outline?: null|string; // LLM (AI) generated outline...???
// description?: null|string; // This is the description of the journal entry
content?: null|string;
content_html?: null|string;
content_json?: null|string;
start_datetime?: null|Date;
end_datetime?: null|Date;
timezone?: null|string;
alert?: null|boolean; // LLM (AI) generated summary...???
alert_msg?: null|string; // LLM (AI) generated summary...???
// cfg_json?: null|key_val; // This is the configuration JSON for the journal entry
data_json?: null|string; // We always need to store something extra...
// This only allows for basic access to the content.
passcode_read?: null|string; // For LLM (AI) generated summary...???
passcode_read_expire?: null|Date;
passcode_write?: null|string;
passcode_write_expire?: null|Date
enable: null|boolean;
hide?: null|boolean;
priority?: null|boolean
sort?: null|number;
group?: null|string;
notes?: null|string;
created_on: Date;
updated_on?: null|Date;
// Additional fields for convenience (database views)
file_count?: null|number; // Only files directly under a journal
journal_file_id_li_json?: null|string;
journal_code?: null|string; // This is the code for the journal entry
journal_name?: null|string; // This is the name for the journal entry
// One person
person__given_name?: null|string;
person__family_name?: null|string;
person__full_name?: null|string;
person__primary_email?: null|string;
person__passcode?: null|string;
// JSON formatted key value pairs for multiple people: {id: name, email, etc.}
person__kv_json?: null|string;
// A key value list of the files
journal_file_kv?: null|key_val;
journal_file_li?: null|[];
// journal_collection_id?: null|string; // For a collection of journal entries?
// Future standard fields!!!
obj_id?: null|string;
obj_ext_uid?: null|string; // Probably not needed for journal entries
obj_ext_id?: null|string; // Probably not needed for journal entries
obj_import_id?: null|string; // Probably not needed for journal entries
obj_code?: null|string;
obj_account_id?: null|string;
obj_passcode?: null|string;
obj_type?: null|string; // Should always be 'journal' in this case
obj_type_ver_id?: null|string; // The ID from the table for the object type
obj_name?: null|string;
obj_summary?: null|string; // LLM (AI) generated summary...???
obj_outline?: null|string; // LLM (AI) generated outline...???
obj_description?: null|string; // Probably not needed for journal entries
obj_enable?: null|boolean;
obj_enable_on?: null|Date;
obj_archive_on?: null|Date;
obj_hide?: null|boolean;
obj_priority?: null|number;
obj_sort?: null|number;
obj_group?: null|string;
obj_cfg_json?: null|string;
obj_notes?: null|string;
obj_created_on?: Date;
obj_updated_on?: null|Date;
}
// Updated 2024-06-10
export class MySubClassedDexie extends Dexie {
// We just tell the typing system this is the case
journal!: Table<Journal>;
journal_entry!: Table<Journal_Entry>;
constructor() {
super('ae_journals_db');
this.version(1).stores({
journal: `
id, journal_id,
code,
account_id,
conference, type,
name,
start_datetime, end_datetime,
timezone,
enable, hide, priority, sort, group, notes, created_on, updated_on`,
journal_entry: `
id, journal_entry_id,
journal_id,
code,
account_id,
name,
start_datetime, end_datetime,
timezone,
enable, hide, priority, sort, group, notes, created_on, updated_on`,
});
}
}
export const db_journals = new MySubClassedDexie();

View File

@@ -1,706 +0,0 @@
import type { key_val } from '$lib/ae_stores';
import { api } from '$lib/api';
import { db_notes } from "$lib/ae_notes/db_notes";
// import { load_ae_obj_li__note_other } from "$lib/ae_notes__note_other";
let ae_promises: key_val = {};
// Updated 2024-09-25
export async function load_ae_obj_id__note(
{
api_cfg,
note_id,
// inc_other_li = false,
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
note_id: string,
// inc_other_li?: boolean,
try_cache?: boolean,
log_lvl?: number
}
) {
console.log(`*** load_ae_obj_id__note() *** note_id=${note_id}`);
let params = {};
ae_promises.load__note_obj = await api.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'note',
obj_id: note_id, // NOTE: This is the FQDN, not normally the ID.
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
params: params,
log_lvl: log_lvl
})
.then(function (note_obj_get_result) {
if (note_obj_get_result) {
if (try_cache) {
// This is expecting a list
db_save_ae_obj_li__note({
obj_type: 'note',
obj_li: [note_obj_get_result]
});
}
return note_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.load__note_obj:', ae_promises.load__note_obj);
}
// if (inc_other_li) {
// // Load the others for the note
// if (log_lvl) {
// console.log(`Need to load the other list for the note now`);
// }
// let load_note_other_obj_li = load_ae_obj_li__note_other({
// api_cfg: api_cfg,
// for_obj_type: 'note',
// for_obj_id: note_id,
// inc_other_li: inc_other_li,
// params: {qry__enabled: 'all', qry__limit: 25},
// try_cache: try_cache,
// log_lvl: log_lvl
// })
// .then((note_other_obj_li) => {
// if (log_lvl) {
// console.log(`note_other_obj_li = `, note_other_obj_li);
// }
// return note_other_obj_li;
// });
// if (log_lvl) {
// console.log(`note_other_obj_li = `, load_note_other_obj_li);
// }
// ae_promises.load__note_obj.note_other_li = load_note_other_obj_li;
// }
return ae_promises.load__note_obj;
}
// Updated 2024-09-25
export async function load_ae_obj_li__note(
{
api_cfg,
for_obj_type = 'account',
for_obj_id,
// inc_other_li = false,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 99,
offset = 0,
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
for_obj_type: string,
for_obj_id: string,
// inc_other_li?: boolean,
enabled?: string, // all, disabled, enabled
hidden?: string, // all, hidden, not_hidden
limit?: number,
offset?: number,
order_by_li?: key_val,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
console.log(`*** load_ae_obj_li__note() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
let params_json: key_val = {};
// console.log('params_json:', params_json);
ae_promises.load__note_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'note',
for_obj_type: for_obj_type,
for_obj_id: for_obj_id,
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (note_obj_li_get_result) {
if (note_obj_li_get_result) {
if (try_cache) {
db_save_ae_obj_li__note({
obj_type: 'note',
obj_li: note_obj_li_get_result
});
}
return note_obj_li_get_result;
} else {
return [];
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.load__note_obj_li:', ae_promises.load__note_obj_li);
}
// if (inc_other_li) {
// // Load the others for the notes
// if (log_lvl) {
// console.log(`Need to load the other list for each note now`);
// }
// for (let i = 0; i < ae_promises.load__note_obj_li.length; i++) {
// let note_obj = ae_promises.load__note_obj_li[i];
// let note_id = note_obj.note_id_random;
// let load_note_other_obj_li = load_ae_obj_li__note_other({
// api_cfg: api_cfg,
// for_obj_type: 'note',
// for_obj_id: note_id,
// params: {qry__enabled: enabled, qry__limit: limit},
// try_cache: try_cache,
// log_lvl: log_lvl
// })
// .then((note_other_obj_li) => {
// if (log_lvl) {
// console.log(`note_other_obj_li = `, note_other_obj_li);
// }
// return note_other_obj_li;
// });
// if (log_lvl) {
// console.log(`load_note_other_obj_li = `, load_note_other_obj_li);
// }
// }
// }
return ae_promises.load__note_obj_li;
}
// Updated 2024-10-08
export async function create_ae_obj__note(
{
api_cfg,
account_id,
data_kv,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
account_id: string,
data_kv: key_val,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** create_ae_obj__note() *** account_id=${account_id}`);
}
ae_promises.create__note = await api.create_ae_obj_crud({
api_cfg: api_cfg,
obj_type: 'note',
fields: {
account_id_random: account_id,
...data_kv
},
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
})
.then(function (note_obj_create_result) {
if (note_obj_create_result) {
if (try_cache) {
db_save_ae_obj_li__note(
{
obj_type: 'note',
obj_li: [note_obj_create_result]
});
}
return note_obj_create_result;
} else {
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
})
.finally(function () {
});
if (log_lvl) {
console.log('ae_promises.create__note:', ae_promises.create__note);
}
return ae_promises.create__note;
}
// Updated 2024-11-08
export async function delete_ae_obj_id__note(
{
api_cfg,
note_id,
method = 'delete', // 'delete', 'disable', 'hide'
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
note_id: string,
method?: string,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** delete_ae_obj_id__note() *** note_id=${note_id}`);
}
ae_promises.delete__note_obj = await api.delete_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'note',
obj_id: note_id,
key: api_cfg.api_crud_super_key,
params: params,
method: method,
log_lvl: log_lvl
})
.catch(function (error) {
console.log('No results returned or failed.', error);
})
.finally(function () {
if (try_cache) {
if (log_lvl) {
console.log(`Attempting to remove IDB entry for note_id=${note_id}`);
}
db_notes.note.delete(note_id);
}
});
if (log_lvl) {
console.log('ae_promises.delete__note_obj:', ae_promises.delete__note_obj);
}
return ae_promises.delete__note_obj;
}
// Updated 2024-09-25
export async function update_ae_obj__note(
{
api_cfg,
note_id,
data_kv,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
note_id: string,
data_kv: key_val,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** update_ae_obj__note() *** note_id=${note_id}`, data_kv);
}
ae_promises.update__note_obj = await api.update_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'note',
obj_id: note_id,
fields: data_kv,
key: api_cfg.api_crud_super_key,
params: params,
return_obj: true,
log_lvl: log_lvl
})
.then(function (note_obj_update_result) {
if (note_obj_update_result) {
if (try_cache) {
db_save_ae_obj_li__note({
obj_type: 'note', obj_li: [note_obj_update_result]
});
}
return note_obj_update_result;
} else {
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
})
.finally(function () {
});
if (log_lvl) {
console.log('ae_promises.update__note_obj:', ae_promises.update__note_obj);
}
return ae_promises.update__note_obj;
}
// This new function is using CRUD v2. This should allow for more flexibility in the queries.
// Updated 2024-09-25
export async function qry__note(
{
api_cfg,
note_id,
qry_str,
qry_files,
qry_start_datetime, // Example greater than: '2024-10-24'
enabled = 'enabled',
hidden = 'not_hidden',
limit = 50,
offset = 0,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
note_id: any,
qry_str?: string,
qry_files?: null|boolean,
qry_start_datetime?: null|string, // Greater than this datetime
enabled?: string, // all, disabled, enabled
hidden?: string, // all, hidden, not_hidden
limit?: number,
offset?: number,
params?: any,
try_cache?: boolean,
log_lvl?: number
}
) {
console.log(`*** qry__note() *** note_id=${note_id} qry_str=${qry_str}`);
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
// let limit: number = (params.qry__limit ?? 25); // 99
// let offset: number = (params.qry__offset ?? 0); // 0
let params_json: key_val = {};
// if (qry_str && qry_str.length > 2) {
// params_json['ft_qry'] = {};
// params_json['ft_qry']['default_qry_str'] = qry_str;
// }
params_json['qry'] = [];
if (qry_files === true) {
let qry_param =
{
type: "AND",
field: "file_count_all",
operator: ">",
value: 0
};
params_json['qry'].push(qry_param);
} else if (qry_files === false) {
let qry_param =
{
type: "AND",
field: "file_count_all",
operator: "IS",
value: null
};
params_json['qry'].push(qry_param);
}
if (qry_start_datetime) {
let qry_param =
{
type: "AND",
field: "start_datetime",
operator: ">",
value: qry_start_datetime
};
params_json['qry'].push(qry_param);
}
let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
ae_promises.load__note_obj_li = await api.get_ae_obj_li_for_obj_id_crud_v2({
api_cfg: api_cfg,
obj_type: 'note',
for_obj_type: 'account',
for_obj_id: note_id,
use_alt_tbl: true, // NOTE: We want to use the alt table for note searching
use_alt_mdl: false,
use_alt_exp: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
limit: limit,
offset: offset,
params_json: params_json,
params: params,
log_lvl: log_lvl
})
.then(function (note_obj_li_get_result) {
if (note_obj_li_get_result) {
db_save_ae_obj_li__note({
obj_type: 'note',
obj_li: note_obj_li_get_result
});
return note_obj_li_get_result;
} else {
return [];
}
});
if (log_lvl) {
console.log('ae_promises.load__note_obj_li:', ae_promises.load__note_obj_li);
}
return ae_promises.load__note_obj_li;
}
// Updated 2024-09-25
// export async function search__note(
// {
// api_cfg,
// account_id,
// poc_agree = null,
// fulltext_search_qry_str,
// ft_other_search_qry_str,
// like_search_qry_str = null,
// file_count = false, // If true then only show those that have a file count
// person_name = null,
// params = {},
// try_cache = true,
// log_lvl = 0
// }: {
// api_cfg: any,
// account_id: any,
// poc_agree?: null|boolean,
// fulltext_search_qry_str?: null|string,
// ft_other_search_qry_str?: null|string,
// like_search_qry_str?: null|string,
// file_count?: boolean,
// person_name?: null|string,
// params?: any,
// try_cache?: boolean,
// log_lvl?: number
// }
// ) {
// console.log(`*** search__note() *** account_id=${account_id}`);
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
// let limit: number = (params.qry__limit ?? 25); // 99
// let offset: number = (params.qry__offset ?? 0); // 0
// let params_json: key_val = {};
// // if (!fulltext_search_qry_str && !like_search_qry_str) {
// // console.log('No search string provided!!!');
// // return false; // Returning false instead of [] because no search was performed.
// // }
// if (fulltext_search_qry_str || ft_other_search_qry_str) {
// params_json['ft_qry'] = {};
// if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
// params_json['ft_qry']['default_qry_str'] = fulltext_search_qry_str;
// }
// if (ft_other_search_qry_str && ft_other_search_qry_str.length > 2) {
// params_json['ft_qry']['note_other_li_qry_str'] = ft_other_search_qry_str;
// }
// }
// // Use the AND (AND LIKE) query
// // if (like_search_qry_str || like_other_search_qry_str) {
// // params_json['and_like'] = {};
// // if (like_search_qry_str && like_search_qry_str.length > 2) {
// // params_json['and_like']['default_qry_str'] = like_search_qry_str;
// // }
// // if (like_other_search_qry_str && like_other_search_qry_str.length > 2) {
// // params_json['and_like']['note_other_li_qry_str'] = like_other_search_qry_str;
// // }
// // }
// // Use the AND (OR LIKE) query
// if (like_search_qry_str || like_other_search_qry_str || like_other_search_qry_str) {
// params_json['or_like'] = {};
// if (like_search_qry_str && like_search_qry_str.length > 2) {
// params_json['or_like']['default_qry_str'] = like_search_qry_str;
// }
// if (like_other_search_qry_str && like_other_search_qry_str.length > 2) {
// params_json['or_like']['note_other_li_qry_str'] = like_other_search_qry_str;
// }
// if (like_other_search_qry_str && like_other_search_qry_str.length > 2) {
// params_json['or_like']['note_other_li_qry_str'] = like_other_search_qry_str;
// }
// }
// params_json['and_qry'] = {};
// if (poc_agree) {
// params_json['and_qry']['poc_agree'] = poc_agree;
// }
// if (file_count) {
// params_json['and_qry']['file_count'] = file_count;
// }
// // This should be using a like with surrounded by %'s
// if (person_name) {
// params_json['and_qry']['note_full_name'] = person_name;
// }
// let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
// ae_promises.load__note_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
// api_cfg: api_cfg,
// obj_type: 'note',
// for_obj_type: 'account',
// for_obj_id: account_id,
// use_alt_table: true, // NOTE: We want to use the alt table for note searching
// use_alt_base: false,
// enabled: enabled,
// hidden: hidden,
// order_by_li: order_by_li,
// limit: limit,
// offset: offset,
// params_json: params_json,
// params: params,
// log_lvl: log_lvl
// })
// .then(function (note_obj_li_get_result) {
// if (note_obj_li_get_result) {
// if (try_cache) {
// db_save_ae_obj_li__note({
// obj_type: 'note',
// obj_li: note_obj_li_get_result
// });
// }
// return note_obj_li_get_result;
// } else {
// return [];
// }
// })
// .catch(function (error) {
// console.log('No results returned or failed.', error);
// })
// .finally(function () {
// });
// if (log_lvl) {
// console.log('ae_promises.load__note_obj_li:', ae_promises.load__note_obj_li);
// }
// return ae_promises.load__note_obj_li;
// }
// This function will loop through the note_obj_li and save each one to the DB.
// Updated 2024-09-25
export function db_save_ae_obj_li__note(
{
obj_type,
obj_li,
log_lvl = 0
}: {
obj_type: string,
obj_li: any,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** db_save_ae_obj_li__note() ***`);
}
if (obj_li && obj_li.length) {
obj_li.forEach(async function (obj: any) {
if (log_lvl) {
console.log(`ae_obj ${obj_type}:`, obj);
}
try {
const id_random = await db_notes.note.put({
id: obj.note_id_random,
note_id: obj.note_id_random,
code: obj.code,
for_type: obj.for_type,
for_id: obj.for_id,
type_code: obj.type_code,
account_id: obj.account_id_random,
person_id: obj.person_id_random,
name: obj.name,
summary: obj.summary,
outline: obj.outline,
// note: obj.note,
note_html: obj.note_html,
note_json: obj.note_json,
start_datetime: obj.start_datetime,
end_datetime: obj.end_datetime,
timezone: obj.timezone,
alert: obj.alert,
alert_msg: obj.alert_msg,
data_json: obj.data_json,
enable: obj.enable,
hide: obj.hide,
priority: obj.priority,
sort: obj.sort,
group: obj.group,
notes: obj.notes,
created_on: obj.created_on,
updated_on: obj.updated_on,
// From SQL view
// note_other_count: obj.note_other_count,
// A key value list of the others
// note_other_kv: obj.note_other_kv,
// note_other_li: obj.note_other_li,
});
// console.log(`Put obj with ID: ${obj.note_id_random} or ${id_random}`);
} catch (error) {
let status = `Failed to put ${obj.note_id_random}: ${error}`;
console.log(status);
}
// const id_random = await db_notes.note.put(obj);
// console.log(`Put obj with ID: ${obj.note_id_random}`);
});
return true;
}
}

View File

@@ -1,14 +0,0 @@
// This file is used to export all the functions that are used for Aether Events related functions.
import * as note from "$lib/ae_notes/ae_notes__note";
let export_obj = {
load_ae_obj_id__note: note.load_ae_obj_id__note,
load_ae_obj_li__note: note.load_ae_obj_li__note,
create_ae_obj__note: note.create_ae_obj__note,
delete_ae_obj_id__note: note.delete_ae_obj_id__note,
update_ae_obj__note: note.update_ae_obj__note,
db_save_ae_obj_li__note: note.db_save_ae_obj_li__note,
};
export let notes_func = export_obj;

View File

@@ -1,70 +0,0 @@
import { localStorageStore } from '@skeletonlabs/skeleton';
import { writable } from 'svelte/store';
import type { Writable } from 'svelte/store';
import type { key_val } from '$lib/ae_stores';
/* *** BEGIN *** Initialize notes_local_data_struct */
// This is for longer term or sticky app data. This should be stored to *local* storage.
// Updated 2024-08-20
let notes_local_data_struct: key_val = {
ver: '2024-08-20_19',
// Shared
name: 'Aether - Notes (SvelteKit 2.x Svelte 4.x)',
title: `OSIT's Æ Notes`, // &AElig;
mode__edit: false,
mode__debug: false,
};
// console.log(`AE Stores - App Notes Local Storage Data:`, notes_local_data_struct);
// This works and uses *local* storage:
export let notes_loc: Writable<key_val> = localStorageStore('ae_notes_loc', notes_local_data_struct);
// console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
/* *** BEGIN *** Initialize notes_session_data_struct */
// Temporary app data. This is lost if the page is refreshed or using different tabs/windows. This should be stored to *session* storage.
// Updated 2024-08-20
let notes_session_data_struct: key_val = {
ver: '2024-08-20_19',
log_lvl: 1,
// Shared Triggers
trigger: null,
trigger__note_id: null,
// trigger__note_li: null,
};
// console.log(`AE Stores - App Notes Session Storage Data:`, notes_session_data_struct);
export let notes_sess = writable(notes_session_data_struct);
/* *** BEGIN *** Initialize notes_slct and notes_trigger */
/* The slct and slct_trigger variable should not be stored in local storage. Only use session storage because browser tabs can be open to different notes, badges, exhibits, etc. */
// Intended for temporary session storage.
// Updated 2024-08-20
let notes_slct_obj_template: key_val = {
// Top level
'note_id': null,
'note_obj': {},
'note_obj_li': [],
'lq__note_obj': {}, // Testing passing a LiveQuery object around...
};
// console.log(`AE Stores - Selected Notes Objects:`, notes_slct_obj_template);
// This works, and uses *session* (not local) storage:
export let notes_slct = writable(notes_slct_obj_template);
/* *** BEGIN *** Initialize notes_trigger */
// Intended for temporary session storage.
// Updated 2024-08-20
export let notes_trigger: any = writable(null);
// console.log(`AE Notes Stores - Notes Trigger:`, notes_trigger);

View File

@@ -1,148 +0,0 @@
import Dexie, { type Table } from 'dexie';
import type { key_val } from '../ae_stores';
// li = list
// kv = key value list
// json = JSON string
// ux = user experience (mode)
// LLM = Large Language Model (AI)
// Updated 2024-08-20
export interface Note {
id: string; // actually "id_random"
note_id: string;
// Essentially this is a change log of notes
snapshot_id?: string; // This is the original note ID. If deleted, then delete all children notes.
previous_id?: null|string; // This is the old or parent note ID
next_id?: null|string; // This is the new or child note ID
external_id?: null|string;
import_id?: null|string;
code?: null|string;
for_type?: null|string;
for_id?: null|string;
type_code?: null|string;
account_id?: null|string; // Owner account of the note
person_id?: null|string; // Owner person of the note
// event_id?: null|string; // Assign to an event???
// location_id?: null|string; // Assign to a location???
name: string; // or the title
summary?: null|string; // LLM (AI) generated summary...???
outline?: null|string; // LLM (AI) generated outline...???
note?: null|string;
note_html?: null|string;
note_json?: null|string;
start_datetime?: null|Date;
end_datetime?: null|Date;
timezone?: null|string;
hide_event_launcher?: null|boolean;
alert?: null|boolean; // LLM (AI) generated summary...???
alert_msg?: null|string; // LLM (AI) generated summary...???
data_json?: null|string; // We always need to store something extra...
ux_mode?: null|string; // 'mobile' or 'desktop'
// This only allows for basic access to the content.
passcode_read?: null|string; // For LLM (AI) generated summary...???
passcode_read_expire?: null|Date;
passcode_write?: null|string;
passcode_write_expire?: null|Date
enable: null|boolean;
hide?: null|boolean;
priority?: null|boolean
sort?: null|number;
group?: null|string;
notes?: null|string;
created_on: Date;
updated_on?: null|Date;
// Additional fields for convenience (database views)
file_count?: null|number; // Only files directly under a note
note_file_id_li_json?: null|string;
// One person
person__given_name?: null|string;
person__family_name?: null|string;
person__full_name?: null|string;
person__primary_email?: null|string;
person__passcode?: null|string;
// JSON formatted key value pairs for multiple people: {id: name, email, etc.}
person__kv_json?: null|string;
note_name?: null|string;
note_location_code?: null|string;
note_location_name?: null|string;
// A key value list of the presentations
note_presentation_kv?: null|key_val;
note_presentation_li?: null|[];
// A key value list of the files
note_file_kv?: null|key_val;
note_file_li?: null|[];
// note_collection_id?: null|string; // For a collection of notes?
// Future standard fields!!!
obj_id?: null|string;
obj_ext_uid?: null|string; // Probably not needed for notes
obj_ext_id?: null|string; // Probably not needed for notes
obj_import_id?: null|string; // Probably not needed for notes
obj_code?: null|string;
obj_account_id?: null|string;
obj_passcode?: null|string;
obj_type?: null|string; // Should always be 'note' in this case
obj_type_ver_id?: null|string; // The ID from the table for the object type
obj_name?: null|string;
obj_summary?: null|string; // LLM (AI) generated summary...???
obj_outline?: null|string; // LLM (AI) generated outline...???
obj_description?: null|string; // Probably not needed for notes
obj_enable?: null|boolean;
obj_enable_on?: null|Date;
obj_archive_on?: null|Date;
obj_hide?: null|boolean;
obj_priority?: null|number;
obj_sort?: null|number;
obj_group?: null|string;
obj_cfg_json?: null|string;
obj_notes?: null|string; // Not the same as the "note" in the object type named "Note".
obj_created_on?: Date;
obj_updated_on?: null|Date;
}
// Updated 2024-06-10
export class MySubClassedDexie extends Dexie {
// We just tell the typing system this is the case
note!: Table<Note>;
constructor() {
super('ae_notes_db');
this.version(1).stores({
note: `
id, note_id,
code,
account_id,
conference, type,
name,
start_datetime, end_datetime,
timezone,
enable, hide, priority, sort, group, notes, created_on, updated_on`,
});
}
}
export const db_notes = new MySubClassedDexie();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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