General clean up. Less debug. Things work better?
This commit is contained in:
@@ -11,8 +11,21 @@ import { api } from '$lib/api';
|
||||
|
||||
let ae_promises: key_val = {}; // Promise<any>;
|
||||
|
||||
// Updated 2024-03-20
|
||||
async function handle_load_ae_obj_id__site_domain({ api_cfg, fqdn, try_cache=false }) {
|
||||
|
||||
// Updated 2024-03-29
|
||||
async function handle_load_ae_obj_id__site_domain(
|
||||
{
|
||||
api_cfg,
|
||||
fqdn,
|
||||
try_cache=false,
|
||||
log_lvl=0
|
||||
} : {
|
||||
api_cfg: any,
|
||||
fqdn: string,
|
||||
try_cache: boolean,
|
||||
log_lvl: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_id__site_domain() *** fqdn=${fqdn}`);
|
||||
|
||||
let no_account_id = false;
|
||||
@@ -33,7 +46,7 @@ async function handle_load_ae_obj_id__site_domain({ api_cfg, fqdn, try_cache=fal
|
||||
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
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (site_domain_obj_get_result) {
|
||||
if (site_domain_obj_get_result) {
|
||||
@@ -56,7 +69,8 @@ async function handle_load_ae_obj_id__site_domain({ api_cfg, fqdn, try_cache=fal
|
||||
return ae_promises.load__site_domain_obj;
|
||||
}
|
||||
|
||||
// handle_load_ae_obj_code__data_store
|
||||
|
||||
// Updated 2024-03-29
|
||||
async function handle_load_ae_obj_code__data_store(
|
||||
{
|
||||
api_cfg,
|
||||
@@ -65,7 +79,8 @@ async function handle_load_ae_obj_code__data_store(
|
||||
for_type=null,
|
||||
for_id=null,
|
||||
try_cache=true,
|
||||
save_idb=false
|
||||
save_idb=false,
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
code: string,
|
||||
@@ -73,19 +88,21 @@ async function handle_load_ae_obj_code__data_store(
|
||||
for_type: string|null,
|
||||
for_id: string|null,
|
||||
try_cache: boolean,
|
||||
save_idb: boolean
|
||||
save_idb: boolean,
|
||||
log_lvl: number
|
||||
}
|
||||
) {
|
||||
|
||||
console.log(`*** handle_get_data_store_obj_w_code() *** code=${code}`);
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** handle_get_data_store_obj_w_code() *** code=${code}`);
|
||||
}
|
||||
|
||||
if (!code) {
|
||||
console.log('No code provided.');
|
||||
console.log(`*ae_func* No code provided!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!api_cfg.account_id) {
|
||||
console.log('No account_id provided.');
|
||||
console.log(`*ae_func* No account_id found in API config!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -93,15 +110,17 @@ async function handle_load_ae_obj_code__data_store(
|
||||
api_cfg: api_cfg,
|
||||
data_store_code: code,
|
||||
data_type: data_type,
|
||||
log_lvl: 0
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (get_ds_result) {
|
||||
let return_this = null;
|
||||
if (get_ds_result) {
|
||||
console.log(`Got a result for code ${code}`);
|
||||
if (log_lvl) {
|
||||
console.log(`*ae_func* Got a result for code ${code}`);
|
||||
}
|
||||
|
||||
if (!get_ds_result.data_store_id_random) {
|
||||
console.log('Something went wrong? No data store ID found.');
|
||||
console.log('*ae_func* Something went wrong? No data store ID found.');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -174,28 +193,53 @@ async function handle_load_ae_obj_code__data_store(
|
||||
|
||||
if (save_idb) {
|
||||
if (browser) {
|
||||
// console.log(`ae_ds__ key: ${code}, value:`, get_ds_result);
|
||||
localStorage.setItem(`ae_ds__${code}`, JSON.stringify(get_ds_result));
|
||||
let key_prefix = 'ae_ds__';
|
||||
if (log_lvl) {
|
||||
console.log(`*ae_func* localStorage key: ${code}, value:`, get_ds_result);
|
||||
}
|
||||
localStorage.setItem(`${key_prefix}${code}`, JSON.stringify(get_ds_result));
|
||||
} else {
|
||||
console.log('No browser!!!');
|
||||
if (log_lvl) {
|
||||
console.log('*ae_func* No browser! Can not use localStorage to save data store object.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
console.log('*ae_func* No results returned.');
|
||||
return_this = null;
|
||||
}
|
||||
return return_this;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
console.log('*ae_func* No results returned or failed.', error);
|
||||
});
|
||||
|
||||
return ae_promises.load__data_store_obj;
|
||||
}
|
||||
|
||||
|
||||
async function handle_update_ae_obj_id_crud({api_cfg, object_type, object_id, field_name, new_field_value, params={}, try_cache=false}) {
|
||||
// Updated 2024-03-27
|
||||
async function handle_update_ae_obj_id_crud(
|
||||
{
|
||||
api_cfg,
|
||||
object_type,
|
||||
object_id,
|
||||
field_name,
|
||||
new_field_value,
|
||||
params={},
|
||||
try_cache=false,
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
object_type: string,
|
||||
object_id: string,
|
||||
field_name: string,
|
||||
new_field_value: any,
|
||||
params: key_val,
|
||||
try_cache: boolean,
|
||||
log_lvl: number
|
||||
}) {
|
||||
|
||||
let patch_result: any = null;
|
||||
|
||||
@@ -210,7 +254,7 @@ async function handle_update_ae_obj_id_crud({api_cfg, object_type, object_id, fi
|
||||
// jwt: null,
|
||||
// params: params,
|
||||
// data: patch_data,
|
||||
log_lvl: 2
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (results) {
|
||||
console.log('PATCH Promise', results);
|
||||
@@ -223,17 +267,6 @@ async function handle_update_ae_obj_id_crud({api_cfg, object_type, object_id, fi
|
||||
patch_result = 'PATCH failed';
|
||||
return false;
|
||||
}
|
||||
|
||||
// dispatch(
|
||||
// 'ae_crud_updated',
|
||||
// {
|
||||
// 'type': object_type,
|
||||
// 'id': object_id,
|
||||
// 'field_name': field_name,
|
||||
// 'field_value': new_field_value,
|
||||
// 'original_value': original_field_value,
|
||||
// }
|
||||
// );
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
|
||||
Reference in New Issue
Block a user