Work on checking data and cache.
This commit is contained in:
@@ -50,11 +50,12 @@
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.10.7/dayjs.min.js" integrity="sha512-bwD3VD/j6ypSSnyjuaURidZksoVx3L1RPvTkleC48SbHCZsemT3VKMD39KknPnH728LLXVMTisESIBOAb5/W0Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
|
||||
<script src="https://cdn.rawgit.com/mozilla/localForage/master/dist/localforage.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/localforage/1.10.0/localforage.min.js" integrity="sha512-+BMamP0e7wn39JGL8nKAZ3yAQT2dL5oaXWr4ZYlTGkKOaoXM/Yj7c4oy50Ngz5yoUutAG17flueD4F6QpTlPng==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
|
||||
<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script> -->
|
||||
|
||||
<script src="https://static.oneskyit.com/js/utilities.js"></script>
|
||||
<script src="js/app_idb.js"></script>
|
||||
|
||||
<!-- <script defer src="svelte/build/bundle.js" crossorigin></script> -->
|
||||
<script defer src="http://dev.oneskyit.local:5000/static/svelte/build/bundle.js" crossorigin></script>
|
||||
@@ -152,6 +153,73 @@ let app_online = false;
|
||||
//let app_use_cached_data = true;
|
||||
window.addEventListener('online', app.currently_online);
|
||||
window.addEventListener('offline', app.currently_offline);
|
||||
|
||||
|
||||
/* ***** **** *** ** * ### * ** *** **** ***** */
|
||||
|
||||
// BEGIN: Load IDB section
|
||||
let idb_name = app_config.idb_name;
|
||||
|
||||
// let tbl_event = null;
|
||||
// let tbl_event_location = null;
|
||||
// let tbl_event_session = null;
|
||||
// let tbl_event_presentation = null;
|
||||
// let tbl_event_presenter = null;
|
||||
// let tbl_event_file = null;
|
||||
// let tbl_hosted_file = null;
|
||||
|
||||
// let tbl_event_key_count = null;
|
||||
// let tbl_event_location_key_count = null;
|
||||
// let tbl_event_session_key_count = null;
|
||||
// let tbl_event_presentation_key_count = null;
|
||||
// let tbl_event_presenter_key_count = null;
|
||||
// let tbl_event_file_key_count = null;
|
||||
// let tbl_hosted_file_key_count = null;
|
||||
|
||||
// if (window.indexedDB && idb_name) {
|
||||
// console.log('IndexedDB is supported');
|
||||
|
||||
// let load_idb_tables_result = load_idb_tables()
|
||||
// .then(async function (result) {
|
||||
// console.log('IDB tables have been opened');
|
||||
// idb_tables_opened = load_idb_tables_result;
|
||||
|
||||
// console.log('Attempting to use cached IDB data...');
|
||||
|
||||
// if (tbl_event_key_count
|
||||
// && tbl_event_location_key_count
|
||||
// && tbl_event_session_key_count
|
||||
// && tbl_event_presentation_key_count
|
||||
// && tbl_event_presenter_key_count
|
||||
// && tbl_event_file_key_count) {
|
||||
// console.log('********* Not yet sure how this works... ');
|
||||
// } else {
|
||||
// console.log('One or more of the IDB tables has 0 records. The IDB probably needs to be updated.');
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// console.log(tbl_event);
|
||||
// console.log(tbl_event_location);
|
||||
// console.log(tbl_event_session);
|
||||
// console.log(tbl_event_presentation);
|
||||
// console.log(tbl_event_presenter);
|
||||
// console.log(tbl_event_file);
|
||||
// console.log(tbl_hosted_file);
|
||||
// })
|
||||
// .catch(function (error) {
|
||||
// console.log('Something went wrong opening the IDB tables.');
|
||||
// console.log(error);
|
||||
// return false;
|
||||
// });
|
||||
|
||||
// } else {
|
||||
// console.log('IndexedDB is NOT supported or the IDB name was not set.');
|
||||
// close();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
console.log('Using app_idb.js');
|
||||
|
||||
async function load_idb_tables() {
|
||||
console.log('****************** Load IDB Tables ******************');
|
||||
console.log('Loading IDB tables...');
|
||||
|
||||
@@ -75,7 +75,7 @@ exports.load_config = function () {
|
||||
// Updated 2022-03-10
|
||||
exports.check_local_file = async function ({local_file_path, filename}) {
|
||||
console.log('*** Electron framework export: check_local_file() ***');
|
||||
console.log('Check for local file');
|
||||
// console.log('Check for local file');
|
||||
console.log(`Local File Path: ${local_file_path}; Filename: ${filename}`);
|
||||
|
||||
let full_local_file_path = path.join(local_file_path, filename);
|
||||
@@ -94,7 +94,7 @@ exports.check_local_file = async function ({local_file_path, filename}) {
|
||||
// Updated 2022-03-09
|
||||
exports.check_hash_file_cache = async function ({host_file_cache_path, hash}) {
|
||||
console.log('*** Electron framework export: check_hash_file_cache() ***');
|
||||
console.log('Check local hash file cache');
|
||||
// console.log('Check local hash file cache');
|
||||
console.log(`Host File Cache Path: ${host_file_cache_path}; Hash: ${hash}`);
|
||||
|
||||
let hash_filename = `${hash}.file`;
|
||||
@@ -116,7 +116,7 @@ exports.check_hash_file_cache = async function ({host_file_cache_path, hash}) {
|
||||
// Updated 2022-03-09
|
||||
exports.download_hash_file_to_cache = async function ({host_file_cache_path, event_file_id=null, hash=null}) {
|
||||
console.log('*** Electron framework export: download_hash_file_to_cache() ***');
|
||||
console.log('Download hash file to cache');
|
||||
// console.log('Download hash file to cache');
|
||||
console.log(`Host File Cache Path: ${host_file_cache_path}; Event File ID: ${event_file_id}; Hash: ${hash}`);
|
||||
|
||||
let endpoint = `/event/file/${event_file_id}/download`;
|
||||
@@ -131,8 +131,8 @@ exports.download_hash_file_to_cache = async function ({host_file_cache_path, eve
|
||||
return true;
|
||||
});
|
||||
|
||||
console.log(download_file_result);
|
||||
console.log('End: download_hash_file_to_cache()');
|
||||
// console.log(download_file_result);
|
||||
// console.log('End: download_hash_file_to_cache()');
|
||||
if (download_file_result) {
|
||||
console.log('File downloaded successfully');
|
||||
return true;
|
||||
@@ -147,7 +147,7 @@ exports.download_hash_file_to_cache = async function ({host_file_cache_path, eve
|
||||
// Updated 2022-03-09
|
||||
exports.open_hash_file_to_temp = async function ({host_file_cache_path, hash, host_file_temp_path, filename}) {
|
||||
console.log('*** Electron framework export: open_hash_file_to_temp() ***');
|
||||
console.log('Open cached hash file after copying to temp directory');
|
||||
// console.log('Open cached hash file after copying to temp directory');
|
||||
console.log(`Host File Cache Path: ${host_file_cache_path}; Hash: ${hash}; Host File Temp Path: ${host_file_temp_path}; Filename: ${filename}`);
|
||||
|
||||
let open_hash_file_to_temp_result = await ipcRenderer.invoke('open_hash_file_to_temp', host_file_cache_path, hash, host_file_temp_path, filename).then((result) => {
|
||||
@@ -175,7 +175,7 @@ exports.open_hash_file_to_temp = async function ({host_file_cache_path, hash, ho
|
||||
// Updated 2022-03-10
|
||||
exports.open_local_file = async function ({local_file_path, filename}) {
|
||||
console.log('*** Electron framework export: open_local_file() ***');
|
||||
console.log('Open local file');
|
||||
// console.log('Open local file');
|
||||
console.log(`Local File Path: ${local_file_path}; Filename: ${filename}`);
|
||||
|
||||
// let full_local_file_path = path.join(local_file_path, filename);
|
||||
@@ -213,7 +213,7 @@ exports.open_local_file = async function ({local_file_path, filename}) {
|
||||
// exports.check_file_cache = async function ({host_file_cache_path, event_file_id, hash}) {
|
||||
exports.check_file_cache = async function ({host_file_cache_path, event_file_id, hash}) {
|
||||
console.log('*** Electron framework export: check_file_cache() ***');
|
||||
console.log('Check local file cache and download from server if needed.');
|
||||
// console.log('Check local file cache and download from server if needed.');
|
||||
console.log(`Host File Cache Path: ${host_file_cache_path}; Event File ID: ${event_file_id}; Hash: ${hash}`);
|
||||
|
||||
// NOTE: event_file_id is the event_file.id_random or event_file.event_file_id_random
|
||||
@@ -269,7 +269,7 @@ exports.check_file_cache = async function ({host_file_cache_path, event_file_id,
|
||||
// Updated 2022-03-09
|
||||
async function check_file_cache({host_file_cache_path, event_file_id, hash}) {
|
||||
console.log('*** Electron framework: check_file_cache() ***');
|
||||
console.log('Check local file cache and download from server if needed.');
|
||||
// console.log('Check local file cache and download from server if needed.');
|
||||
console.log(`Host File Cache Path: ${host_file_cache_path}; Event File ID: ${event_file_id}; Hash: ${hash}`);
|
||||
|
||||
// NOTE: event_file_id is the event_file.id_random or event_file.event_file_id_random
|
||||
@@ -323,7 +323,7 @@ async function check_file_cache({host_file_cache_path, event_file_id, hash}) {
|
||||
// Updated 2022-03-09
|
||||
async function open_local_file({host_file_cache_path, hash, host_file_temp_path, filename}) {
|
||||
console.log('*** Electron framework: open_local_file() ***');
|
||||
console.log('Open local file cache if available. Copy to temp directory with given filename first.');
|
||||
// console.log('Open local file cache if available. Copy to temp directory with given filename first.');
|
||||
console.log(`Host File Cache Path: ${host_file_cache_path}; Hash: ${hash}; Host File Temp Path: ${host_file_temp_path}; Filename: ${filename}`);
|
||||
|
||||
console.log(host_file_cache_path);
|
||||
|
||||
Reference in New Issue
Block a user