Trying to improve the hosted file manage.
This commit is contained in:
47
src/routes/hosted_files/+layout.ts
Normal file
47
src/routes/hosted_files/+layout.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/** @type {import('./$types').LayoutLoad} */
|
||||
console.log(`IDAA BB - [account_id] +layout.ts start`);
|
||||
|
||||
import { error } from '@sveltejs/kit';
|
||||
import { browser } from '$app/environment';
|
||||
import { core_func } from '$lib/ae_core/ae_core_functions';
|
||||
|
||||
export async function load({ params, parent }) { // route
|
||||
let log_lvl: number = 0;
|
||||
|
||||
let data = await parent();
|
||||
data.log_lvl = log_lvl;
|
||||
|
||||
let account_id = data.account_id;
|
||||
let ae_acct = data[account_id];
|
||||
// console.log(`ae_acct = `, ae_acct);
|
||||
|
||||
if (!account_id) {
|
||||
console.log(`ae Core - [account_id] +page.ts: The account_id was not found!!!`);
|
||||
error(404, {
|
||||
message: 'Account ID not found'
|
||||
});
|
||||
}
|
||||
|
||||
ae_acct.slct.account_id = account_id;
|
||||
|
||||
if (browser) {
|
||||
let load_hosted_file_obj_li = core_func.load_ae_obj_li__hosted_file({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: account_id,
|
||||
enabled: 'enabled',
|
||||
hidden: 'not_hidden',
|
||||
limit: 99,
|
||||
order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'updated_on': 'DESC', 'created_on': 'DESC', 'title': 'ASC'},
|
||||
try_cache: true,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
console.log(`load_hosted_file_obj_li = `, load_hosted_file_obj_li);
|
||||
ae_acct.slct.hosted_file_obj_li = load_hosted_file_obj_li;
|
||||
}
|
||||
|
||||
// WARNING: Precaution against shared data between sites and sessions.
|
||||
data[account_id] = ae_acct;
|
||||
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user