This is a good start. Many key features are working again!!!

This commit is contained in:
Scott Idem
2024-02-15 18:53:26 -05:00
parent 19f9983c9a
commit a3d4354ef4
20 changed files with 3513 additions and 101 deletions

View File

@@ -1,5 +1,27 @@
import { readable, writable } from 'svelte/store';
import { PUBLIC_TESTING, PUBLIC_AE_API_PROTOCOL, PUBLIC_AE_API_SERVER, PUBLIC_AE_API_BAK_SERVER, PUBLIC_AE_API_PORT, PUBLIC_AE_API_PATH, PUBLIC_AE_API_SECRET_KEY, PUBLIC_AE_API_CRUD_SUPER_KEY, PUBLIC_AE_ACCOUNT_ID } from '$env/static/public';
console.log(`Aether Config - TESTING:`, PUBLIC_TESTING);
const api_base_url = `${PUBLIC_AE_API_PROTOCOL}://${PUBLIC_AE_API_SERVER}:${PUBLIC_AE_API_PORT}${PUBLIC_AE_API_PATH}`;
const api_base_url_bak = `${PUBLIC_AE_API_PROTOCOL}://${PUBLIC_AE_API_BAK_SERVER}:${PUBLIC_AE_API_PORT}${PUBLIC_AE_API_PATH}`;
const api_secret_key = PUBLIC_AE_API_SECRET_KEY;
const api_crud_super_key = PUBLIC_AE_API_CRUD_SUPER_KEY;
const ae_account_id = PUBLIC_AE_ACCOUNT_ID;
// import { getStores, navigating, page, updated } from '$app/stores';
// import { assets, base, resolveRoute } from '$app/paths';
// console.log(page.path); // Everything after the domian name
// const hostname = base;
// console.log(import.meta.env.MODE);
// console.log(import.meta.env.BASE_URL);
type key_val = {
[key: string]: any; // variable key
// name: string;
@@ -10,12 +32,20 @@ export let ae_app_local_data_struct: key_val = {
'ver': '0.0.1',
'name': 'Aether App Template',
'theme': 'light',
'account_id': '_XY7DXtc9MY', // OSIT Demo _XY7DXtc9MY
'site_domain': 'https://dev-demo.oneskyit.com',
'account_id': ae_account_id, // OSIT Demo _XY7DXtc9MY
'site_domain': null, // https://example.com, https://dev.example.com, etc.
'ds': {},
'hub': {
'ds': {},
},
'mod': { // module
'events': {},
'sponsorships': {
show_list__sponsorship_obj_li: true,
show_view__sponsorship_obj: false,
},
'testing': {},
},
}
console.log(`Aether Config - App Local Storage Data:`, ae_app_local_data_struct);
export let ae_loc = writable(ae_app_local_data_struct);
@@ -36,11 +66,11 @@ export let ae_sess = writable(ae_app_session_data_struct);
// *** BEGIN *** Temporary API data. This should be stored to session storage.
export let ae_api_data_struct: key_val = {
'ver': '0.0.2',
'base_url': 'https://dev-api.oneskyit.com',
'base_url_bak': 'https://dev-api.oneskyit.com',
'api_secret_key': 'dFP6J9DVj9hUgIMn-fNIqg', // 'YOUR_API_SECRET_KEY',
'api_secret_key_bak': 'dFP6J9DVj9hUgIMn-fNIqg', // 'YOUR_API_SECRET_KEY',
'api_crud_super_key': 'zp5PtX4zUsI', // 'YOUR_SUPER_KEY' 'zp5PtX4zUsI'
'base_url': api_base_url,
'base_url_bak': api_base_url_bak,
'api_secret_key': api_secret_key, // 'YOUR_API_SECRET_KEY',
'api_secret_key_bak': api_secret_key, // 'YOUR_API_SECRET_KEY',
'api_crud_super_key': api_crud_super_key, // 'YOUR_SUPER_KEY' 'zp5PtX4zUsI'
'headers': {},
'account_id': ae_app_local_data_struct.account_id,
}

132
src/lib/ae_utils.ts Normal file
View File

@@ -0,0 +1,132 @@
import dayjs from 'dayjs';
export let iso_datetime_formatter = function iso_datetime_formatter(raw_datetime: string|Date, named_format: string) {
// console.log('*** iso_datetime_formatter() ***');
// https://en.wikipedia.org/wiki/ISO_8601
// https://day.js.org/docs/en/display/format
// ISO 8601-1:2019 includes the T before the time portion
// ISO 8601-1:2019 midnight may only be referred to as "00:00", corresponding to the beginning of a calendar day
// and "24:00" is no longer allowed corresponding to the end of a day
// 60 is only used to denote an added leap second
// ISO 8601 UTC: 2021-03-04T19:04:44+00:00
// ISO 8601 UTC: 2021-03-04T19:04:44Z
// ISO 8601 UTC: 20210304T190444Z
//datetime_iso 'YYYY-MM-DD HH:mm:ss'
//datetime_iso_12 'YYYY-MM-DD hh:mm:ss A'
//datetime_iso_12_short 'YY-MM-DD hh:mm A'
//datetime_iso_tz 'YYYY-MM-DD HH:mm:ss'
//datetime_long 'dddd, MMMM D, YYYY hh:mm:ss A'
//datetime_medium 'ddd, MMM D, YYYY hh:mm:ss A'
//datetime_short 'MMM D, YY hh:mm A'
//date_iso 'YYYY-MM-DD'
//date_long 'dddd, MMMM D, YYYY'
//date_medium 'ddd, MMM D, YYYY'
//date_short 'MMM D, YY'
//time_iso 'HH:mm:ss'
//time_iso_12 'hh:mm:ss A'
//time_long 'hh:mm:ss A'
//time_medium 'h:m:s A'
//time_short 'hh:mm A'
//dayjs(raw_datetime).format('dddd, MMMM D, YYYY hh:mm:ss A');
if (!raw_datetime) {
raw_datetime = new Date(); // Get the current datetime if one was not passed.
}
let datetime_string = null;
switch (named_format) {
case 'datetime_iso':
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss');
break;
case 'datetime_iso_no_seconds':
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm');
break;
case 'datetime_iso_12_short':
datetime_string = dayjs(raw_datetime).format('YY-MM-DD hh:mm A');
break;
case 'datetime_iso_12_short_month':
datetime_string = dayjs(raw_datetime).format('MM-DD hh:mm A');
break;
case 'datetime_short':
datetime_string = dayjs(raw_datetime).format('MMM D, YY hh:mm A');
break;
case 'datetime_medium':
datetime_string = dayjs(raw_datetime).format('MMM D, YYYY h:mm A');
break;
case 'datetime_long':
datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY hh:mm A');
break;
case 'datetime_short_month':
datetime_string = dayjs(raw_datetime).format('MMM D hh:mm A');
break;
case 'datetime_long_month':
datetime_string = dayjs(raw_datetime).format('MMMM D hh:mm A');
break;
case 'datetime_short_day':
datetime_string = dayjs(raw_datetime).format('D hh:mm A');
break;
case 'date_iso':
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD');
break;
case 'date_long_month_day':
datetime_string = dayjs(raw_datetime).format('MMMM D');
break;
case 'date_short':
datetime_string = dayjs(raw_datetime).format('MMM D, YY');
break;
case 'date_short_no_year':
datetime_string = dayjs(raw_datetime).format('MMM D');
break;
case 'date_long':
datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY');
break;
case 'date_full':
datetime_string = dayjs(raw_datetime).format('dddd, MMMM D, YYYY');
break;
case 'date_full_no_year':
datetime_string = dayjs(raw_datetime).format('dddd, MMMM D');
break;
case 'time_iso':
datetime_string = dayjs(raw_datetime).format('HH:mm:ss');
break;
case 'time_long':
datetime_string = dayjs(raw_datetime).format('hh:mm:ss A');
break;
case 'time_short':
datetime_string = dayjs(raw_datetime).format('hh:mm A');
break;
case 'time_short_no_leading':
datetime_string = dayjs(raw_datetime).format('h:mm A');
break;
case 'week_long':
datetime_string = dayjs(raw_datetime).format('dddd');
break;
case 'week_medium':
datetime_string = dayjs(raw_datetime).format('ddd');
break;
case 'week_short':
datetime_string = dayjs(raw_datetime).format('dd');
break;
default:
console.log(`The named format passed (${named_format}) did not match a common name. Trying to format with the named format value.`);
datetime_string = dayjs(raw_datetime).format(named_format);
// datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss');
}
return datetime_string;
}
export let ae_util = {
iso_datetime_formatter: iso_datetime_formatter,
};
// export default ae_util;

View File

@@ -1,5 +1,5 @@
import axios from 'axios';
// import { readable, writable } from 'svelte/store';
import { readable, writable } from 'svelte/store';
// console.log('*** Using api.js ***');
@@ -504,7 +504,7 @@ export let get_ae_obj_id_crud = async function get_ae_obj_id_crud({
limit=999999,
offset=0,
data={},
key,
// key,
jwt=null,
headers={},
params={},
@@ -1246,25 +1246,27 @@ export let get_data_store_obj_w_code = async function get_data_store_obj_w_code(
const endpoint = `/data_store/code/${data_store_code}`;
let data_store_obj_get_promise = await api.get_object({api_cfg: api_cfg, endpoint: endpoint, headers: headers, params: params, log_lvl: log_lvl});
// if (data_store_obj_get_promise === false) {
// console.log('Data Store - RUN AGAIN WITH BACKUP');
// let original_api_base_url = api_cfg['base_url'];
if (data_store_obj_get_promise === false) {
console.log('Data Store - RUN AGAIN WITH BACKUP');
let original_api_base_url = api_cfg['base_url'];
// let temp_api = api_cfg;
// temp_api['base_url'] = temp_api['base_url_backup']
let temp_api = api_cfg;
temp_api['base_url'] = temp_api['base_url_backup']
// data_store_obj_get_promise = await api.get_object({api_cfg: temp_api, endpoint: endpoint, headers: headers, params: params, log_lvl: log_lvl});
// temp_api['base_url'] = original_api_base_url;
// }
data_store_obj_get_promise = await api.get_object({api_cfg: temp_api, endpoint: endpoint, headers: headers, params: params, log_lvl: log_lvl});
temp_api['base_url'] = original_api_base_url;
}
let data_store_obj = data_store_obj_get_promise;
if (data_type == 'text') {
// console.log(data_store_obj.text);
window.localStorage.setItem(data_store_code, data_store_obj.text);
// window.localStorage.setItem(data_store_code, data_store_obj.text);
// localStorage.setItem(data_store_code, data_store_obj.text);
} else if (data_type == 'json') {
// console.log(data_store_obj.json);
window.localStorage.setItem(data_store_code, JSON.stringify(data_store_obj.json));
// window.localStorage.setItem(data_store_code, JSON.stringify(data_store_obj.json));
// localStorage.setItem(data_store_code, JSON.stringify(data_store_obj.json));
}
if (log_lvl > 1) {