Wrapping up for the day

This commit is contained in:
Scott Idem
2024-02-27 20:21:02 -05:00
parent ed97cba7a6
commit 00a28588b7
5 changed files with 279 additions and 181 deletions

View File

@@ -6,94 +6,18 @@ import type { key_val } from '$lib/ae_stores';
import { get } from 'svelte/store';
async function handle_load_ae_obj_id__site_domain({fqdn, try_cache=false}) {
console.log(`*** handle_load_ae_obj_id__site_domain() *** fqdn=${fqdn}`);
let params = {};
// ae_loc.hub.site_domain_id_qry_status = 'loading';
let ae_site_domain_obj_get_promise = api.get_ae_obj_id_crud({
api_cfg: get(ae_api),
no_account_id: true,
obj_type: 'site_domain',
obj_id: fqdn, // 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: true, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
params: params,
log_lvl: 1
})
.then(function (site_domain_obj_get_result) {
if (site_domain_obj_get_result) {
// slct.site_domain_obj = site_domain_obj_get_result;
// console.log(`site_domain object:`, get(slct).site_domain_obj);
// ae_loc.account_id = $slct.site_domain_obj.account_id_random;
// ae_loc.site_id = $slct.site_domain_obj.site_id_random;
// ae_loc.site_domain_id = $slct.site_domain_obj.site_domain_id_random;
return site_domain_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
return ae_site_domain_obj_get_promise;
}
// let ds_obj_get_promises: key_val = {};
async function handle_get_data_store_obj_w_code({ code=null, data_type='text' }) {
console.log(`*** handle_get_data_store_obj_w_code() *** code=${code}`);
if (!code) {
console.log('No code provided.');
return;
}
let data_store_obj_get_promise = api.get_data_store_obj_w_code({
api_cfg: get(ae_api),
data_store_code: code,
data_type: data_type,
log_lvl: 0
})
.then(function (get_data_store_result) {
let return_this = null;
if (get_data_store_result) {
if (data_type == 'text') {
// console.log(get_data_store_result.text);
return_this = get_data_store_result.text;
} else if (data_type == 'json') {
// console.log(get_data_store_result.json);
return_this = get_data_store_result.json;
}
} else {
console.log('No results returned.');
return_this = null;
}
return return_this;
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
return data_store_obj_get_promise;
}
export async function load({ params, url }) { // route
console.log(`Svelte root layout.ts data = params:`, params);
// console.log(`Svelte root layout.ts data = params:`, params);
// console.log(`Svelte root layout.ts data = route:`, route);
console.log(`Svelte root layout.ts data = url:`, url);
// console.log(`Svelte root layout.ts data = url:`, url);
let ae_loc_tmp = get(ae_loc);
console.log(`ae_loc = `, ae_loc_tmp);
// console.log(`ae_loc = `, ae_loc_tmp);
let ds_code_li: null|key_val = ae_loc_tmp.ds;
console.log(`ae_ ds_code_li = `, ds_code_li);
// console.log(`ae_ ds_code_li = `, ds_code_li);
let ds_code: null|string = null;
@@ -111,7 +35,7 @@ export async function load({ params, url }) { // route
};
let loading_results = null;
let access_code_li_json = null;
// let access_code_li_json = null;
// First do a site_domain look up to check if it is valid and get the account_id.
if (url.host) {
@@ -362,6 +286,79 @@ export async function load({ params, url }) { // route
}
// export const ssr = false;
// export const prerender = true;
/// export const trailingSlash = 'always'; // 'never' | 'always' | 'ignore'
async function handle_load_ae_obj_id__site_domain({fqdn, try_cache=false}) {
console.log(`*** handle_load_ae_obj_id__site_domain() *** fqdn=${fqdn}`);
let params = {};
// ae_loc.hub.site_domain_id_qry_status = 'loading';
let ae_site_domain_obj_get_promise = api.get_ae_obj_id_crud({
api_cfg: get(ae_api),
no_account_id: true,
obj_type: 'site_domain',
obj_id: fqdn, // 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: true, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
params: params,
log_lvl: 0
})
.then(function (site_domain_obj_get_result) {
if (site_domain_obj_get_result) {
// slct.site_domain_obj = site_domain_obj_get_result;
// console.log(`site_domain object:`, get(slct).site_domain_obj);
// ae_loc.account_id = $slct.site_domain_obj.account_id_random;
// ae_loc.site_id = $slct.site_domain_obj.site_id_random;
// ae_loc.site_domain_id = $slct.site_domain_obj.site_domain_id_random;
return site_domain_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
return ae_site_domain_obj_get_promise;
}
// let ds_obj_get_promises: key_val = {};
async function handle_get_data_store_obj_w_code({ code=null, data_type='text' }) {
console.log(`*** handle_get_data_store_obj_w_code() *** code=${code}`);
if (!code) {
console.log('No code provided.');
return;
}
let data_store_obj_get_promise = api.get_data_store_obj_w_code({
api_cfg: get(ae_api),
data_store_code: code,
data_type: data_type,
log_lvl: 0
})
.then(function (get_data_store_result) {
let return_this = null;
if (get_data_store_result) {
if (data_type == 'text') {
// console.log(get_data_store_result.text);
return_this = get_data_store_result.text;
} else if (data_type == 'json') {
// console.log(get_data_store_result.json);
return_this = get_data_store_result.json;
}
} else {
console.log('No results returned.');
return_this = null;
}
return return_this;
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
return data_store_obj_get_promise;
}