Creating IDB direct to UI render. Version 2 of rendering the UI.
This commit is contained in:
631
app/index 2020-01-30.html.bak
Normal file
631
app/index 2020-01-30.html.bak
Normal file
@@ -0,0 +1,631 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
|
||||
<title>One Sky IT</title>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="img/favicon.ico">
|
||||
|
||||
<!-- Cascading Style Sheets (CSS) start -->
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.4.1/materia/bootstrap.min.css" rel="stylesheet" integrity="sha384-1tymk6x9Y5K+OF0tlmG2fDRcn67QGzBkiM3IgtJ3VrtGrIi5ryhHjKjeeS60f1FA" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.10.2/css/all.css">
|
||||
|
||||
<!-- One Sky IT default custom Cascading Style Sheets (CSS) -->
|
||||
|
||||
<!-- One Sky IT site custom Cascading Style Sheets (CSS) -->
|
||||
<link rel="stylesheet" href="css/starter-template.css">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link rel="stylesheet" href="css/launcher.css">
|
||||
|
||||
<style>
|
||||
</style>
|
||||
<!-- Cascading Style Sheets (CSS) end -->
|
||||
|
||||
<!-- JavaScript (JS) start -->
|
||||
|
||||
<!-- JavaScript (JS) end -->
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!--<main id="main_content" role="main" class="container">-->
|
||||
<div id="main_content" class="container w-100">
|
||||
|
||||
<!--
|
||||
<div class="row no-gutters">
|
||||
<div id="launcher_title" class="launcher_title border-bottom">Please wait while the data is checked and files are cached.</div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<div class="row no-gutters">
|
||||
<div id="launcher_menu" class="launcher_menu col-3 border-right">
|
||||
<div id="event_files_menu" class="event_files_menu"></div>
|
||||
<div id="location_files_menu" class="location_files_menu"></div>
|
||||
<div id="sessions_menu" class="sessions_menu"></div>
|
||||
<div id="location_name" class="location_name"></div>
|
||||
</div>
|
||||
|
||||
<div id="launcher_sessions" class="launcher_sessions col"></div> <!-- end location details div -->
|
||||
</div> <!-- end row div -->
|
||||
|
||||
</div>
|
||||
<!--</main>--> <!-- /.container -->
|
||||
|
||||
|
||||
|
||||
<!-- JavaScript (JS) start -->
|
||||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.30.1/date_fns.min.js" integrity="sha256-wCBClaCr6pJ7sGU5kfb3gQMOOcIZNzaWpWcj/lD9Vfk=" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.15.3/axios.min.js" crossorigin></script>
|
||||
|
||||
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js" crossorigin></script>
|
||||
|
||||
<!--<script src="https://cdn.jsdelivr.net/npm/idb-keyval@3/dist/idb-keyval-iife.min.js"></script>-->
|
||||
<!--<script src="https://unpkg.com/dexie@latest/dist/dexie.js"></script>-->
|
||||
<script src="https://cdn.rawgit.com/mozilla/localForage/master/dist/localforage.js"></script>
|
||||
|
||||
<!--
|
||||
Using node.js may require this: npm install jquery, add script below.
|
||||
https://stackoverflow.com/questions/22658015/bootstrap-throws-uncaught-error-bootstraps-javascript-requires-jquery
|
||||
-->
|
||||
<!--
|
||||
<script>
|
||||
window.jQuery = window.$ = require('jquery');
|
||||
</script>
|
||||
-->
|
||||
|
||||
<!-- One Sky IT default custom JavaScript (JS) -->
|
||||
|
||||
<!-- One Sky IT site custom JavaScript (JS) -->
|
||||
<script>const app = require('./js/module_app');</script>
|
||||
<script>const api = require('./js/module_api');</script>
|
||||
<script>const idb = require('./js/module_app_idb');</script>
|
||||
<script>const ui = require('./js/module_app_ui');</script>
|
||||
<!--<script src="js/api.js"></script>-->
|
||||
<!--<script src="js/script.js"></script>-->
|
||||
<!--<script src="js/testing.js"></script>-->
|
||||
|
||||
<script>
|
||||
let app_config = app.load_config();
|
||||
let account_id = app_config.account_id;
|
||||
let event_id = app_config.event_id;
|
||||
let event_location_id = app_config.event_location_id;
|
||||
|
||||
const secret_key = app_config.api_secret_key;
|
||||
let api_temporary_token = null;
|
||||
|
||||
let api_base_url = null; // 'http://api.localhost:5001' 'https://api.oneskyit.com'
|
||||
|
||||
if (app_config.use_local_api) {
|
||||
api_base_url = app_config.api_local_base_url; // 'http://api.localhost:5001'
|
||||
} else {
|
||||
api_base_url = app_config.api_remote_base_url; // 'https://api.oneskyit.com'
|
||||
}
|
||||
|
||||
axios.defaults.baseURL = api_base_url;
|
||||
axios.defaults.headers.post['Access-Control-Allow-Origin'] = app_config.access_control_allow_origin; // '*';
|
||||
|
||||
api.api_token_request_async(axios, secret_key).then( function(result) {
|
||||
console.log('Setting temporary API token to axios Authorization header: '+result);
|
||||
axios.defaults.headers.common['Authorization'] = `Token ${result}`;
|
||||
api_temporary_token = result;
|
||||
return result;
|
||||
});
|
||||
|
||||
|
||||
let idb_name = app_config.idb_name;
|
||||
|
||||
if (window.indexedDB) {
|
||||
console.log('IndexedDB is supported');
|
||||
} else {
|
||||
console.log('IndexedDB is NOT supported');
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
var tbl_event = null;
|
||||
var tbl_event_location = null;
|
||||
var tbl_event_session = null;
|
||||
var tbl_event_presentation = null;
|
||||
var tbl_event_presenter = null;
|
||||
var tbl_event_file = null;
|
||||
var tbl_hosted_file = null;
|
||||
|
||||
var tbl_event_key_count = null;
|
||||
var tbl_event_location_key_count = null;
|
||||
var tbl_event_session_key_count = null;
|
||||
var tbl_event_presentation_key_count = null;
|
||||
var tbl_event_presenter_key_count = null;
|
||||
var tbl_event_file_key_count = null;
|
||||
var tbl_hosted_file_key_count = null;
|
||||
|
||||
localforage.config({
|
||||
driver: localforage.INDEXEDDB,
|
||||
version: 1,
|
||||
name: idb_name
|
||||
});
|
||||
|
||||
var tbl_event = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event',
|
||||
});
|
||||
tbl_event.length().then(function(key_count) {
|
||||
console.log('tbl_event count: '+key_count);
|
||||
tbl_event_key_count = key_count;
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
var tbl_event_location = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_location',
|
||||
});
|
||||
tbl_event_location.length().then(function(key_count) {
|
||||
console.log('tbl_event_location count: '+key_count);
|
||||
tbl_event_location_key_count = key_count;
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
var tbl_event_session = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_session',
|
||||
});
|
||||
tbl_event_session.length().then(function(key_count) {
|
||||
console.log('tbl_event_session count: '+key_count);
|
||||
tbl_event_session_key_count = key_count;
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
var tbl_event_presentation = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_presentation',
|
||||
});
|
||||
tbl_event_presentation.length().then(function(key_count) {
|
||||
console.log('tbl_event_presentation_key_count count: '+key_count);
|
||||
tbl_event_presentation_key_count = key_count;
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
var tbl_event_presenter = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_presenter',
|
||||
});
|
||||
tbl_event_presenter.length().then(function(key_count) {
|
||||
console.log('tbl_event_presenter count: '+key_count);
|
||||
tbl_event_presenter_key_count = key_count;
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
var tbl_event_file = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_file',
|
||||
});
|
||||
tbl_event_file.length().then(function(key_count) {
|
||||
console.log('tbl_event_file count: '+key_count);
|
||||
tbl_event_file_key_count = key_count;
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
/*
|
||||
var tbl_hosted_file = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'hosted_file',
|
||||
});
|
||||
tbl_hosted_file.length().then(function(key_count) {
|
||||
tbl_hosted_file_key_count = key_count;
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
*/
|
||||
|
||||
//let create_load_idb_result = idb.create_load_idb();
|
||||
|
||||
//console.log(tbl_event_session_key_count);
|
||||
|
||||
/*
|
||||
// Check if table exists by trying to interate.
|
||||
function tbl_check(value, key, iteration) {
|
||||
console.log(value);
|
||||
}
|
||||
function tbl_check_success(result) {
|
||||
console.log(result);
|
||||
}
|
||||
function tbl_check_error(result) {
|
||||
console.log(result);
|
||||
}
|
||||
tbl_event_session.iterate(tbl_check, tbl_check_success, tbl_check_error); //tbl_check(value, key, iteration)
|
||||
*/
|
||||
|
||||
|
||||
//const loading_loop_interval = app_config.loading_loop_interval; // in milliseconds
|
||||
const loading_loop_interval = 500;
|
||||
//const main_loop_interval = app_config.main_loop_interval; // in milliseconds
|
||||
const main_loop_interval = 1500; //10000; // 10 seconds
|
||||
|
||||
idb_event_check_period = app_config.idb_event_check_period;
|
||||
idb_event_check_datetime = Date.now();
|
||||
idb_event_location_check_period = app_config.idb_event_location_check_period;
|
||||
idb_event_location_check_datetime = Date.now();
|
||||
idb_event_session_check_period = app_config.idb_event_session_check_period;
|
||||
idb_event_session_check_datetime = Date.now();
|
||||
idb_event_presentation_check_period = app_config.idb_event_presentation_check_period;
|
||||
idb_event_presentation_check_datetime = Date.now();
|
||||
idb_event_presenter_check_period = app_config.idb_event_presenter_check_period;
|
||||
idb_event_presenter_check_datetime = Date.now();
|
||||
idb_event_file_check_period = app_config.idb_event_file_check_period;
|
||||
idb_event_file_check_datetime = Date.now();
|
||||
|
||||
const idb_check_period = app_config.idb_check_period; //30000; // 60 seconds
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the object check period into event, location, session, presentation, presenter
|
||||
let idb_check_datetime = Date.now(); // default to current datetime in ms
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the file check period into event, location, session, presentation, presenter
|
||||
let launcher_files_check_datetime = Date.now(); // default to current datetime in ms
|
||||
|
||||
const host_file_cache_path = app_config.host_file_cache_path; //'file_cache/';
|
||||
const host_file_cache_check_period = app_config.host_file_cache_check_period; //30000; // 30 seconds
|
||||
|
||||
let launcher = new Object(); // This will create the something like location > sessions and location files > presenters and session files > presenter files
|
||||
|
||||
|
||||
let idb_to_launcher_result = false;
|
||||
//let launcher_cache_check_results = false;
|
||||
let launcher_render_results = false;
|
||||
|
||||
let run_idb_to_launcher = false;
|
||||
let run_check_file_cache = false;
|
||||
let run_render_launcher = false;
|
||||
|
||||
let axios_headers_set = false;
|
||||
let idb_tables_opened = false;
|
||||
let idb_tables_have_records = false;
|
||||
|
||||
// Development variables:
|
||||
//let account_id = 12;
|
||||
//let event_id = 14;
|
||||
//let event_location_id = 13;
|
||||
//let event_session_id = 827;
|
||||
//let event_presentation_id = 2002;
|
||||
//let event_presenter_id = 2539;
|
||||
//let event_file_id = 28;
|
||||
|
||||
//console.log(tbl_event_session);
|
||||
//console.log(tbl_event_file);
|
||||
|
||||
/*
|
||||
while (!axios_headers_set && !idb_tables_opened && !idb_tables_have_records) {
|
||||
if (typeof axios.defaults.headers.common['Authorization'] !== 'undefined'
|
||||
&& axios.defaults.headers.common['Authorization'] != null) {
|
||||
axios_headers_set = true;
|
||||
console.log('Axios headers have been set.');
|
||||
} else {
|
||||
axios_headers_set = false;
|
||||
console.log('Waiting for Axios headers to be set.');
|
||||
}
|
||||
if (tbl_event && tbl_event_location && tbl_event_session
|
||||
&& tbl_event_presentation && tbl_event_presenter
|
||||
&& tbl_event_file) {
|
||||
idb_tables_opened = true;
|
||||
console.log('IDB tables have been opened');
|
||||
} else {
|
||||
idb_tables_opened = false;
|
||||
console.log('Waiting for IDB tables to be opened');
|
||||
}
|
||||
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) {
|
||||
idb_tables_have_records = true;
|
||||
console.log('All IDB tables have records.');
|
||||
} else {
|
||||
console.log('No IDB records for one of the tables.');
|
||||
}
|
||||
|
||||
//someanimation();
|
||||
setTimeout(function(){
|
||||
console.log('looping....');
|
||||
}, 250);
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
var load_cached_data_loop = setInterval(function() {
|
||||
if (tbl_event && tbl_event_location && tbl_event_session
|
||||
&& tbl_event_presentation && tbl_event_presenter
|
||||
&& tbl_event_file) {
|
||||
idb_tables_opened = true;
|
||||
console.log('IDB tables have been opened');
|
||||
|
||||
|
||||
if (tbl_event_key_count != null && tbl_event_location_key_count != null && tbl_event_session_key_count != null
|
||||
&& tbl_event_presentation_key_count != null && tbl_event_presenter_key_count != null
|
||||
&& tbl_event_file_key_count != null) {
|
||||
idb_tables_have_records = true;
|
||||
console.log('All IDB tables have been checked for records.');
|
||||
|
||||
console.log('Running idb_to_launcher with cached data.');
|
||||
|
||||
idb.idb_to_launcher().then(function(response) {
|
||||
console.log('Launcher object has now been created with cached data.');
|
||||
console.log(response);
|
||||
clearInterval(load_cached_data_loop);
|
||||
|
||||
launcher = response;
|
||||
//let launcher_tmp = launcher;
|
||||
|
||||
//render_launcher_result = ui.render_launcher(response);
|
||||
console.log('The launcher has now been rendered with cached data. ***');
|
||||
});
|
||||
|
||||
/*
|
||||
idb_to_launcer_result.then(function (response) {
|
||||
console.log('Launcher object has now been created with cached data.');
|
||||
console.log(response);
|
||||
clearInterval(load_cached_data_loop);
|
||||
|
||||
launcher = response;
|
||||
//let launcher_tmp = launcher;
|
||||
|
||||
render_launcher_result = ui.render_launcher(response);
|
||||
console.log('The launcher has now been rendered with cached data. ***');
|
||||
|
||||
|
||||
//render_launcher_result.then(function (response) {
|
||||
// console.log('The launcher has now been rendered with cached data. ***');
|
||||
// clearInterval(load_cached_data_loop);
|
||||
//});
|
||||
|
||||
});
|
||||
*/
|
||||
|
||||
/*
|
||||
let launcher_new = idb.idb_to_launcher();
|
||||
launcher_new_result.then
|
||||
render_launcher_result = ui.render_launcher(launcher_new);
|
||||
if (render_launcher_result) {
|
||||
clearInterval(load_cached_data_loop);
|
||||
} else {
|
||||
console.log('Launcher object not really ready yet...');
|
||||
}
|
||||
//render_launcher_result.then(function (response) {
|
||||
// console.log('The launcher has now been rendered with cached data. ***');
|
||||
|
||||
//});
|
||||
*/
|
||||
|
||||
} else {
|
||||
//console.log('One or more tables did not have any records. Moving on...');
|
||||
console.log('Still waiting for the table record counts.');
|
||||
}
|
||||
|
||||
} else {
|
||||
idb_tables_opened = false;
|
||||
console.log('Waiting for IDB tables to be opened');
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
/*
|
||||
function load_cached_data () {
|
||||
idb_tables_opened = true;
|
||||
console.log('IDB tables have been opened');
|
||||
|
||||
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) {
|
||||
idb_tables_have_records = true;
|
||||
console.log('All IDB tables have records.');
|
||||
|
||||
console.log('Running idb_to_launcher with cached data.');
|
||||
idb_to_launcher_result = idb.idb_to_launcher(launcher);
|
||||
|
||||
idb_to_launcher_result.then(function (response) {
|
||||
console.log('Launcher object has now been created with cached data.');
|
||||
console.log(launcher);
|
||||
|
||||
let launcher_tmp = launcher;
|
||||
|
||||
render_launcher_result = ui.render_launcher(launcher_tmp);
|
||||
render_launcher_result.then(function (response) {
|
||||
console.log('The launcher has now been rendered with cached data. ***');
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var load_cached_data_results = load_cached_data();
|
||||
*/
|
||||
|
||||
|
||||
// NOTE This loop needs to end at some point...
|
||||
var load_auth_loop = setInterval(function() {
|
||||
if (typeof axios.defaults.headers.common['Authorization'] !== 'undefined'
|
||||
&& axios.defaults.headers.common['Authorization'] != null) {
|
||||
axios_headers_set = true;
|
||||
console.log('Axios headers have been set.');
|
||||
clearInterval(load_auth_loop);
|
||||
} else {
|
||||
axios_headers_set = false;
|
||||
console.log('Waiting for Axios headers to be set.');
|
||||
}
|
||||
}, loading_loop_interval);
|
||||
|
||||
|
||||
|
||||
setInterval(async function() {
|
||||
if (axios_headers_set && idb_tables_opened && idb_tables_have_records) {
|
||||
|
||||
if (idb_event_check_datetime < Date.now()) {
|
||||
console.log('Time to check events');
|
||||
let v2_account_events = await api.v2_get_account_events(axios, account_id);
|
||||
for (var i in v2_account_events) {
|
||||
tbl_event.setItem(v2_account_events[i].id.toString(), v2_account_events[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
idb_event_check_datetime = Date.now() + idb_event_check_period;
|
||||
}
|
||||
|
||||
if (idb_event_location_check_datetime < Date.now()) {
|
||||
console.log('Time to check event locations');
|
||||
let v2_event_locations = await api.v2_get_event_locations(axios, event_id);
|
||||
for (var i in v2_event_locations) {
|
||||
tbl_event_location.setItem(v2_event_locations[i].id.toString(), v2_event_locations[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
idb_event_location_check_datetime = Date.now() + idb_event_location_check_period;
|
||||
}
|
||||
|
||||
if (idb_event_session_check_datetime < Date.now()) {
|
||||
console.log('Time to check event location sessions');
|
||||
let v2_event_sessions = await api.v2_get_event_location_sessions(axios, event_location_id);
|
||||
for (var i in v2_event_sessions) {
|
||||
tbl_event_session.setItem(v2_event_sessions[i].id.toString(), v2_event_sessions[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
idb_event_session_check_datetime = Date.now() + idb_event_session_check_period;
|
||||
}
|
||||
|
||||
if (idb_event_presentation_check_datetime < Date.now()) {
|
||||
console.log('Time to check event location presentations');
|
||||
let v2_event_presentations = await api.v2_get_event_location_presentations(axios, event_location_id);
|
||||
for (var i in v2_event_presentations) {
|
||||
tbl_event_presentation.setItem(v2_event_presentations[i].id.toString(), v2_event_presentations[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
idb_event_presentation_check_datetime = Date.now() + idb_event_presentation_check_period;
|
||||
}
|
||||
|
||||
if (idb_event_presenter_check_datetime < Date.now()) {
|
||||
console.log('Time to check event location presenters');
|
||||
let v2_event_presenters = await api.v2_get_event_location_presenters(axios, event_location_id);
|
||||
for (var i in v2_event_presenters) {
|
||||
tbl_event_presenter.setItem(v2_event_presenters[i].id.toString(), v2_event_presenters[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
idb_event_presenter_check_datetime = Date.now() + idb_event_presenter_check_period;
|
||||
}
|
||||
|
||||
if (idb_event_file_check_datetime < Date.now()) {
|
||||
console.log('Time to check event location files');
|
||||
let v2_event_files = await api.v2_get_event_location_files(axios, event_location_id);
|
||||
for (var i in v2_event_files) {
|
||||
tbl_event_file.setItem(v2_event_files[i].event_file_id.toString(), v2_event_files[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
run_check_file_cache = true; // Set to true so that the local file cache will be checked against the updated event files
|
||||
idb_event_file_check_datetime = Date.now() + idb_event_file_check_period;
|
||||
}
|
||||
|
||||
if (run_idb_to_launcher) {
|
||||
console.log('Flag to run idb_to_launcher has been set to true.');
|
||||
idb_to_launcher_result = idb.idb_to_launcher(launcher);
|
||||
|
||||
idb_to_launcher_result.then(function (response) {
|
||||
console.log('Launcher object has now been updated.');
|
||||
console.log(launcher);
|
||||
|
||||
run_idb_to_launcher = false;
|
||||
run_render_launcher = true; // Set to true so that the launcher will be rendered again
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (run_check_file_cache) {
|
||||
console.log('Flag to run check_file_cache has been set to true.');
|
||||
check_file_cache_result = idb.check_file_cache();
|
||||
|
||||
check_file_cache_result.then(function (response) {
|
||||
console.log('Cached files have now been updated.');
|
||||
run_check_file_cache = false;
|
||||
});
|
||||
}
|
||||
|
||||
if (run_render_launcher) {
|
||||
console.log('Flag to run render_launcher has been set to true.');
|
||||
let launcher_tmp = launcher;
|
||||
/*
|
||||
//render_launcher_result = ui.render_launcher(launcher_tmp);
|
||||
render_launcher_result.then(function (response) {
|
||||
console.log('The launcher has now been rendered.');
|
||||
run_render_launcher = false;
|
||||
});
|
||||
*/
|
||||
// NOTE This is a terrible way to work around the page refreshing and blanking out.
|
||||
setTimeout(() => {
|
||||
render_launcher_result = ui.render_launcher(launcher_tmp);
|
||||
|
||||
render_launcher_result.then(function (response) {
|
||||
console.log('The launcher has now been rendered.');
|
||||
run_render_launcher = false;
|
||||
});
|
||||
}, 100);
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
else {
|
||||
console.log('index.html: v2 idb_to_launcher result is true ***');
|
||||
|
||||
if (idb_check_datetime < Date.now()) {
|
||||
console.log('Render launcher...');
|
||||
launcher_render_results = await ui.launcher_render(launcher);
|
||||
idb_check_datetime = Date.now() + idb_check_period;
|
||||
} else {
|
||||
console.log('Waiting to render launcher again...');
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
current_datetime = Date.now();
|
||||
//let launcher_cache_check_results = false;
|
||||
/*
|
||||
if (idb_check_datetime < current_datetime) {
|
||||
launcher_cache_check_results = idb.launcher_cache_check(launcher, api_base_url, api_temporary_token, host_file_cache_path);
|
||||
|
||||
launcher_cache_check_results.then(function (response) {
|
||||
console.log(launcher);
|
||||
idb_check_datetime = Date.now() + idb_check_period;
|
||||
|
||||
launcher_render_results = ui.launcher_render(launcher);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
} else {
|
||||
console.log('Waiting '+main_loop_interval+'ms to see if Authorization header is set, tables are opened, and record counts have been done.');
|
||||
}
|
||||
}, main_loop_interval);
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//const custom_store = new idbKeyval.Store('custom_db', 'custom_store_name');
|
||||
//idbKeyval.set('foo', 'bar', custom_store);
|
||||
|
||||
</script>
|
||||
|
||||
<!-- <script src="js/launcher.js"></script>-->
|
||||
<!-- JavaScript (JS) end -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
444
app/index.html
444
app/index.html
@@ -226,30 +226,22 @@
|
||||
});
|
||||
*/
|
||||
|
||||
//let create_load_idb_result = idb.create_load_idb();
|
||||
|
||||
//console.log(tbl_event_session_key_count);
|
||||
const api_auth_loop_interval = 100; // only runs on start up
|
||||
const open_tables_loop_interval = 10; // only runs on start up
|
||||
|
||||
/*
|
||||
// Check if table exists by trying to interate.
|
||||
function tbl_check(value, key, iteration) {
|
||||
console.log(value);
|
||||
}
|
||||
function tbl_check_success(result) {
|
||||
console.log(result);
|
||||
}
|
||||
function tbl_check_error(result) {
|
||||
console.log(result);
|
||||
}
|
||||
tbl_event_session.iterate(tbl_check, tbl_check_success, tbl_check_error); //tbl_check(value, key, iteration)
|
||||
*/
|
||||
const update_idb_loop_interval = 100; // loop forever; update when check datetime has passed
|
||||
const idb_to_launcher_loop_interval = 250; // loop forever; only run when one or more tables are updated
|
||||
const update_render_loop_interval = 1000; // loop forever; only run when the launcher object is safe
|
||||
const check_file_cache_loop_interval = 250; // loop forever; only run after the event_file table has updated
|
||||
|
||||
// Axios needs to authenticate first
|
||||
let axios_headers_set = false;
|
||||
|
||||
//const loading_loop_interval = app_config.loading_loop_interval; // in milliseconds
|
||||
const loading_loop_interval = 500;
|
||||
//const main_loop_interval = app_config.main_loop_interval; // in milliseconds
|
||||
const main_loop_interval = 1500; //10000; // 10 seconds
|
||||
// IDB tables need to be opened
|
||||
let idb_tables_opened = false;
|
||||
|
||||
// check periods and datetimes for update_idb_loop
|
||||
idb_event_check_period = app_config.idb_event_check_period;
|
||||
idb_event_check_datetime = Date.now();
|
||||
idb_event_location_check_period = app_config.idb_event_location_check_period;
|
||||
@@ -263,31 +255,45 @@
|
||||
idb_event_file_check_period = app_config.idb_event_file_check_period;
|
||||
idb_event_file_check_datetime = Date.now();
|
||||
|
||||
const idb_check_period = app_config.idb_check_period; //30000; // 60 seconds
|
||||
let run_update_idb = false;
|
||||
let run_idb_to_launcher = false;
|
||||
let idb_to_launcher_in_progress = false;
|
||||
let safe_to_render_launcher = false; // currently only set to true in module_app_idb.js
|
||||
let run_check_file_cache = false;
|
||||
|
||||
//const loading_loop_interval = app_config.loading_loop_interval; // in milliseconds
|
||||
//const loading_loop_interval = 500;
|
||||
//const main_loop_interval = app_config.main_loop_interval; // in milliseconds
|
||||
//const main_loop_interval = 1500; //10000; // 10 seconds
|
||||
|
||||
//const idb_check_period = app_config.idb_check_period; //30000; // 60 seconds
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the object check period into event, location, session, presentation, presenter
|
||||
let idb_check_datetime = Date.now(); // default to current datetime in ms
|
||||
//let idb_check_datetime = Date.now(); // default to current datetime in ms
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the file check period into event, location, session, presentation, presenter
|
||||
let launcher_files_check_datetime = Date.now(); // default to current datetime in ms
|
||||
//let launcher_files_check_datetime = Date.now(); // default to current datetime in ms
|
||||
|
||||
const host_file_cache_path = app_config.host_file_cache_path; //'file_cache/';
|
||||
const host_file_cache_check_period = app_config.host_file_cache_check_period; //30000; // 30 seconds
|
||||
//const host_file_cache_check_period = app_config.host_file_cache_check_period; //30000; // 30 seconds
|
||||
|
||||
let launcher = new Object(); // This will create the something like location > sessions and location files > presenters and session files > presenter files
|
||||
|
||||
|
||||
|
||||
|
||||
let idb_to_launcher_result = false;
|
||||
//let launcher_cache_check_results = false;
|
||||
let launcher_render_results = false;
|
||||
|
||||
let run_idb_to_launcher = false;
|
||||
let run_check_file_cache = false;
|
||||
|
||||
|
||||
//let run_check_file_cache = false;
|
||||
let run_render_launcher = false;
|
||||
|
||||
let axios_headers_set = false;
|
||||
let idb_tables_opened = false;
|
||||
|
||||
let idb_tables_have_records = false;
|
||||
//let safe_to_render_launcher = false;
|
||||
|
||||
// Development variables:
|
||||
//let account_id = 12;
|
||||
@@ -298,178 +304,61 @@
|
||||
//let event_presenter_id = 2539;
|
||||
//let event_file_id = 28;
|
||||
|
||||
//console.log(tbl_event_session);
|
||||
//console.log(tbl_event_file);
|
||||
|
||||
/*
|
||||
while (!axios_headers_set && !idb_tables_opened && !idb_tables_have_records) {
|
||||
var api_auth_loop = setInterval(function() {
|
||||
if (typeof axios.defaults.headers.common['Authorization'] !== 'undefined'
|
||||
&& axios.defaults.headers.common['Authorization'] != null) {
|
||||
axios_headers_set = true;
|
||||
console.log('Axios headers have been set.');
|
||||
axios_headers_set = true;
|
||||
//run_update_idb = true;
|
||||
clearInterval(api_auth_loop);
|
||||
} else {
|
||||
axios_headers_set = false;
|
||||
console.log('Waiting for Axios headers to be set.');
|
||||
}
|
||||
}, api_auth_loop_interval);
|
||||
|
||||
|
||||
var open_tables_loop = setInterval(function() {
|
||||
if (tbl_event && tbl_event_location && tbl_event_session
|
||||
&& tbl_event_presentation && tbl_event_presenter
|
||||
&& tbl_event_file) {
|
||||
idb_tables_opened = true;
|
||||
console.log('IDB tables have been opened');
|
||||
} else {
|
||||
idb_tables_opened = false;
|
||||
console.log('Waiting for IDB tables to be opened');
|
||||
}
|
||||
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) {
|
||||
idb_tables_have_records = true;
|
||||
console.log('All IDB tables have records.');
|
||||
} else {
|
||||
console.log('No IDB records for one of the tables.');
|
||||
}
|
||||
|
||||
//someanimation();
|
||||
setTimeout(function(){
|
||||
console.log('looping....');
|
||||
}, 250);
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
var load_cached_data_loop = setInterval(function() {
|
||||
if (tbl_event && tbl_event_location && tbl_event_session
|
||||
&& tbl_event_presentation && tbl_event_presenter
|
||||
&& tbl_event_file) {
|
||||
idb_tables_opened = true;
|
||||
console.log('IDB tables have been opened');
|
||||
|
||||
clearInterval(open_tables_loop);
|
||||
|
||||
if (tbl_event_key_count != null && tbl_event_location_key_count != null && tbl_event_session_key_count != null
|
||||
&& tbl_event_presentation_key_count != null && tbl_event_presenter_key_count != null
|
||||
&& tbl_event_file_key_count != null) {
|
||||
idb_tables_have_records = true;
|
||||
console.log('All IDB tables have been checked for records.');
|
||||
|
||||
console.log('Running idb_to_launcher with cached data.');
|
||||
|
||||
idb.idb_to_launcher().then(function(response) {
|
||||
console.log('Launcher object has now been created with cached data.');
|
||||
console.log(response);
|
||||
clearInterval(load_cached_data_loop);
|
||||
|
||||
launcher = response;
|
||||
//let launcher_tmp = launcher;
|
||||
|
||||
//render_launcher_result = ui.render_launcher(response);
|
||||
console.log('The launcher has now been rendered with cached data. ***');
|
||||
});
|
||||
|
||||
/*
|
||||
idb_to_launcer_result.then(function (response) {
|
||||
console.log('Launcher object has now been created with cached data.');
|
||||
console.log(response);
|
||||
clearInterval(load_cached_data_loop);
|
||||
|
||||
launcher = response;
|
||||
//let launcher_tmp = launcher;
|
||||
|
||||
render_launcher_result = ui.render_launcher(response);
|
||||
console.log('The launcher has now been rendered with cached data. ***');
|
||||
|
||||
|
||||
//render_launcher_result.then(function (response) {
|
||||
// console.log('The launcher has now been rendered with cached data. ***');
|
||||
// clearInterval(load_cached_data_loop);
|
||||
//});
|
||||
|
||||
});
|
||||
*/
|
||||
|
||||
/*
|
||||
let launcher_new = idb.idb_to_launcher();
|
||||
launcher_new_result.then
|
||||
render_launcher_result = ui.render_launcher(launcher_new);
|
||||
if (render_launcher_result) {
|
||||
clearInterval(load_cached_data_loop);
|
||||
} else {
|
||||
console.log('Launcher object not really ready yet...');
|
||||
}
|
||||
//render_launcher_result.then(function (response) {
|
||||
// console.log('The launcher has now been rendered with cached data. ***');
|
||||
|
||||
//});
|
||||
*/
|
||||
|
||||
} else {
|
||||
//console.log('One or more tables did not have any records. Moving on...');
|
||||
console.log('Still waiting for the table record counts.');
|
||||
}
|
||||
|
||||
idb_tables_opened = true;
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
} else {
|
||||
console.log('IDB tables have not yet been created or opened');
|
||||
|
||||
idb_tables_opened = false;
|
||||
console.log('Waiting for IDB tables to be opened');
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
/*
|
||||
function load_cached_data () {
|
||||
idb_tables_opened = true;
|
||||
console.log('IDB tables have been opened');
|
||||
|
||||
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) {
|
||||
idb_tables_have_records = true;
|
||||
console.log('All IDB tables have records.');
|
||||
|
||||
console.log('Running idb_to_launcher with cached data.');
|
||||
idb_to_launcher_result = idb.idb_to_launcher(launcher);
|
||||
|
||||
idb_to_launcher_result.then(function (response) {
|
||||
console.log('Launcher object has now been created with cached data.');
|
||||
console.log(launcher);
|
||||
|
||||
let launcher_tmp = launcher;
|
||||
|
||||
render_launcher_result = ui.render_launcher(launcher_tmp);
|
||||
render_launcher_result.then(function (response) {
|
||||
console.log('The launcher has now been rendered with cached data. ***');
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var load_cached_data_results = load_cached_data();
|
||||
*/
|
||||
}, open_tables_loop_interval);
|
||||
|
||||
|
||||
// NOTE This loop needs to end at some point...
|
||||
var load_auth_loop = setInterval(function() {
|
||||
if (typeof axios.defaults.headers.common['Authorization'] !== 'undefined'
|
||||
&& axios.defaults.headers.common['Authorization'] != null) {
|
||||
axios_headers_set = true;
|
||||
console.log('Axios headers have been set.');
|
||||
clearInterval(load_auth_loop);
|
||||
} else {
|
||||
axios_headers_set = false;
|
||||
console.log('Waiting for Axios headers to be set.');
|
||||
}
|
||||
}, loading_loop_interval);
|
||||
|
||||
|
||||
|
||||
setInterval(async function() {
|
||||
if (axios_headers_set && idb_tables_opened && idb_tables_have_records) {
|
||||
|
||||
var update_idb_loop = setInterval(async function() {
|
||||
//if (run_update_idb) {
|
||||
// console.log('run_update_idb is set to true');
|
||||
//console.log('FLAG: axios_headers_set='+axios_headers_set);
|
||||
//console.log('FLAG: idb_tables_opened='+idb_tables_opened);
|
||||
if (axios_headers_set && idb_tables_opened) {
|
||||
if (idb_event_check_datetime < Date.now()) {
|
||||
console.log('Time to check events');
|
||||
let v2_account_events = await api.v2_get_account_events(axios, account_id);
|
||||
for (var i in v2_account_events) {
|
||||
tbl_event.setItem(v2_account_events[i].id.toString(), v2_account_events[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
idb_event_check_datetime = Date.now() + idb_event_check_period;
|
||||
let v2_account_events = await api.v2_get_account_events(axios, account_id)
|
||||
.then(function (response) {
|
||||
for (var i in response) {
|
||||
tbl_event.setItem(response[i].id.toString(), response[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
safe_to_render_launcher = false; // Set to false so that the launcher render only starts after the launcher object has updated
|
||||
idb_event_check_datetime = Date.now() + idb_event_check_period;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('Trying to check events. Something went wrong. Expired token?');
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (idb_event_location_check_datetime < Date.now()) {
|
||||
@@ -479,6 +368,7 @@
|
||||
tbl_event_location.setItem(v2_event_locations[i].id.toString(), v2_event_locations[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
safe_to_render_launcher = false; // Set to false so that the launcher render only starts after the launcher object has updated
|
||||
idb_event_location_check_datetime = Date.now() + idb_event_location_check_period;
|
||||
}
|
||||
|
||||
@@ -489,6 +379,7 @@
|
||||
tbl_event_session.setItem(v2_event_sessions[i].id.toString(), v2_event_sessions[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
safe_to_render_launcher = false; // Set to false so that the launcher render only starts after the launcher object has updated
|
||||
idb_event_session_check_datetime = Date.now() + idb_event_session_check_period;
|
||||
}
|
||||
|
||||
@@ -499,6 +390,7 @@
|
||||
tbl_event_presentation.setItem(v2_event_presentations[i].id.toString(), v2_event_presentations[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
safe_to_render_launcher = false; // Set to false so that the launcher render only starts after the launcher object has updated
|
||||
idb_event_presentation_check_datetime = Date.now() + idb_event_presentation_check_period;
|
||||
}
|
||||
|
||||
@@ -509,6 +401,7 @@
|
||||
tbl_event_presenter.setItem(v2_event_presenters[i].id.toString(), v2_event_presenters[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
safe_to_render_launcher = false; // Set to false so that the launcher render only starts after the launcher object has updated
|
||||
idb_event_presenter_check_datetime = Date.now() + idb_event_presenter_check_period;
|
||||
}
|
||||
|
||||
@@ -519,109 +412,124 @@
|
||||
tbl_event_file.setItem(v2_event_files[i].event_file_id.toString(), v2_event_files[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
safe_to_render_launcher = false; // Set to false so that the launcher render only starts after the launcher object has updated
|
||||
run_check_file_cache = true; // Set to true so that the local file cache will be checked against the updated event files
|
||||
idb_event_file_check_datetime = Date.now() + idb_event_file_check_period;
|
||||
}
|
||||
|
||||
if (run_idb_to_launcher) {
|
||||
console.log('Flag to run idb_to_launcher has been set to true.');
|
||||
idb_to_launcher_result = idb.idb_to_launcher(launcher);
|
||||
|
||||
idb_to_launcher_result.then(function (response) {
|
||||
console.log('Launcher object has now been updated.');
|
||||
console.log(launcher);
|
||||
|
||||
run_idb_to_launcher = false;
|
||||
run_render_launcher = true; // Set to true so that the launcher will be rendered again
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (run_check_file_cache) {
|
||||
console.log('Flag to run check_file_cache has been set to true.');
|
||||
check_file_cache_result = idb.check_file_cache();
|
||||
|
||||
check_file_cache_result.then(function (response) {
|
||||
console.log('Cached files have now been updated.');
|
||||
run_check_file_cache = false;
|
||||
});
|
||||
}
|
||||
|
||||
if (run_render_launcher) {
|
||||
console.log('Flag to run render_launcher has been set to true.');
|
||||
let launcher_tmp = launcher;
|
||||
/*
|
||||
//render_launcher_result = ui.render_launcher(launcher_tmp);
|
||||
render_launcher_result.then(function (response) {
|
||||
console.log('The launcher has now been rendered.');
|
||||
run_render_launcher = false;
|
||||
});
|
||||
*/
|
||||
// NOTE This is a terrible way to work around the page refreshing and blanking out.
|
||||
setTimeout(() => {
|
||||
render_launcher_result = ui.render_launcher(launcher_tmp);
|
||||
|
||||
render_launcher_result.then(function (response) {
|
||||
console.log('The launcher has now been rendered.');
|
||||
run_render_launcher = false;
|
||||
});
|
||||
}, 100);
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
else {
|
||||
console.log('index.html: v2 idb_to_launcher result is true ***');
|
||||
|
||||
if (idb_check_datetime < Date.now()) {
|
||||
console.log('Render launcher...');
|
||||
launcher_render_results = await ui.launcher_render(launcher);
|
||||
idb_check_datetime = Date.now() + idb_check_period;
|
||||
} else {
|
||||
console.log('Waiting to render launcher again...');
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
current_datetime = Date.now();
|
||||
//let launcher_cache_check_results = false;
|
||||
/*
|
||||
if (idb_check_datetime < current_datetime) {
|
||||
launcher_cache_check_results = idb.launcher_cache_check(launcher, api_base_url, api_temporary_token, host_file_cache_path);
|
||||
|
||||
launcher_cache_check_results.then(function (response) {
|
||||
console.log(launcher);
|
||||
idb_check_datetime = Date.now() + idb_check_period;
|
||||
|
||||
launcher_render_results = ui.launcher_render(launcher);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
} else {
|
||||
console.log('Waiting '+main_loop_interval+'ms to see if Authorization header is set, tables are opened, and record counts have been done.');
|
||||
console.log('Waiting for the Axios headers to be set and/or IDB tables opened...');
|
||||
}
|
||||
}, main_loop_interval);
|
||||
|
||||
//} else {
|
||||
// console.log('run_update_idb is set to false');
|
||||
//}
|
||||
}, update_idb_loop_interval);
|
||||
|
||||
|
||||
var idb_to_launcher_loop = setInterval(function() {
|
||||
if (run_idb_to_launcher) {
|
||||
console.log('FLAG: run_idb_to_launcher='+run_idb_to_launcher);
|
||||
if (tbl_event_key_count != null && tbl_event_location_key_count != null && tbl_event_session_key_count != null
|
||||
&& tbl_event_presentation_key_count != null && tbl_event_presenter_key_count != null
|
||||
&& tbl_event_file_key_count != null) {
|
||||
console.log('All IDB tables have records. Going to create/update the launcher object now...');
|
||||
|
||||
idb_tables_have_records = true;
|
||||
run_idb_to_launcher = false;
|
||||
|
||||
if (!idb_to_launcher_in_progress) {
|
||||
console.log('idb_to_launcher is NOT in progress');
|
||||
let idb_to_launcher_result = idb.idb_to_launcher().then(function(response) {
|
||||
console.log('idb_to_launcher is complete... I think?');
|
||||
//console.log('*** idb_to_launcher response: *** Launcher object has now been created/updated with IDB data.');
|
||||
//console.log(response);
|
||||
|
||||
//clearInterval(idb_to_launcher_loop);
|
||||
|
||||
//launcher = response;
|
||||
//safe_to_render_launcher = true;
|
||||
run_render_launcher = true;
|
||||
});
|
||||
idb_to_launcher_in_progress = true;
|
||||
} else {
|
||||
console.log('idb_to_launcher IS in progress');
|
||||
}
|
||||
//console.log('*** idb_to_launcher_result: ***');
|
||||
//console.log(idb_to_launcher_result);
|
||||
|
||||
} else {
|
||||
console.log('Not all IDB tables have records. Setting flag to true update IDB database.');
|
||||
|
||||
idb_tables_have_records = false;
|
||||
safe_to_render_launcher = false;
|
||||
run_update_idb = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
//console.log('run_idb_to_launcher is set to false');
|
||||
}
|
||||
}, idb_to_launcher_loop_interval);
|
||||
|
||||
|
||||
var update_render_loop = setInterval(async function() {
|
||||
//if (run_render_launcher) {
|
||||
// console.log('Flag to run idb_to_launcher is set to true');
|
||||
current_plus10_datetime = Date.now() + 10000; // add 10 seconds
|
||||
let enough_time_to_render = false;
|
||||
if (
|
||||
current_plus10_datetime < idb_event_check_datetime
|
||||
&& current_plus10_datetime < idb_event_location_check_datetime
|
||||
&& current_plus10_datetime < idb_event_session_check_datetime
|
||||
&& current_plus10_datetime < idb_event_presentation_check_datetime
|
||||
&& current_plus10_datetime < idb_event_presenter_check_datetime
|
||||
&& current_plus10_datetime < idb_event_file_check_datetime
|
||||
) {
|
||||
console.log('SETTING FLAG: enough_time_to_render=true');
|
||||
enough_time_to_render = true;
|
||||
} else {
|
||||
//console.log(current_plus10_datetime);
|
||||
//console.log(idb_event_check_datetime);
|
||||
//console.log(idb_event_location_check_datetime);
|
||||
//console.log(idb_event_session_check_datetime);
|
||||
//console.log(idb_event_presentation_check_datetime);
|
||||
//console.log(idb_event_presenter_check_datetime);
|
||||
//console.log(idb_event_file_check_datetime);
|
||||
enough_time_to_render = false;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
console.log('FLAG: safe_to_render_launcher='+safe_to_render_launcher);
|
||||
console.log('FLAG: enough_time_to_render='+enough_time_to_render);
|
||||
if (safe_to_render_launcher && enough_time_to_render) {
|
||||
let render_launcher_result = ui.render_launcher(launcher);
|
||||
|
||||
run_render_launcher = false; // Set to true so that the launcher will be rendered again
|
||||
safe_to_render_launcher = false;
|
||||
} else {
|
||||
}
|
||||
|
||||
//} else {
|
||||
// console.log('Flag to run idb_to_launcher is set to false');
|
||||
//}
|
||||
}, update_render_loop_interval);
|
||||
|
||||
|
||||
var check_file_cache_loop = setInterval(async function() {
|
||||
if (run_check_file_cache) {
|
||||
console.log('FLAG: check_file_cache='+run_check_file_cache);
|
||||
check_file_cache_result = idb.check_file_cache();
|
||||
|
||||
check_file_cache_result.then(function (response) {
|
||||
console.log('Cached files have now been updated.');
|
||||
});
|
||||
run_check_file_cache = false;
|
||||
} else {
|
||||
//console.log('Flag to run check_file_cache is set to false');
|
||||
}
|
||||
}, check_file_cache_loop_interval);
|
||||
|
||||
|
||||
|
||||
|
||||
//const custom_store = new idbKeyval.Store('custom_db', 'custom_store_name');
|
||||
//idbKeyval.set('foo', 'bar', custom_store);
|
||||
|
||||
</script>
|
||||
|
||||
<!-- <script src="js/launcher.js"></script>-->
|
||||
|
||||
@@ -12,6 +12,13 @@ exports.create_load_idb = async function create_load_idb() {
|
||||
|
||||
|
||||
exports.idb_to_launcher = async function idb_to_launcher() {
|
||||
if (idb_to_launcher_in_progress) {
|
||||
console.log('*** Exit idb_to_launcher. It is already in progress. ***');
|
||||
return false; // return false... false being that another idb_to_launcher is in progress
|
||||
} else {
|
||||
console.log('idb_to_launcher is not in progress. It appears to be safe to start... starting.');
|
||||
}
|
||||
|
||||
//tbl_example.iterate(tbl_check, tbl_check_success, tbl_check_error); //tbl_check(value, key, iteration)
|
||||
let launcher_new = new Object();
|
||||
|
||||
@@ -31,7 +38,7 @@ exports.idb_to_launcher = async function idb_to_launcher() {
|
||||
tbl_event.iterate(function(event_value, key, iteration) {
|
||||
tmp_event.push(event_value);
|
||||
}).then(function() {
|
||||
console.log('idb_to_launcher: Iterate tbl_event complete')
|
||||
//console.log('idb_to_launcher: Iterate tbl_event complete')
|
||||
tbl_event_complete = true;
|
||||
});
|
||||
launcher_new.event = tmp_event;
|
||||
@@ -44,7 +51,7 @@ exports.idb_to_launcher = async function idb_to_launcher() {
|
||||
tmp_event_file.push(file_value);
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_launcher: Iterate tbl_event_file complete')
|
||||
//console.log('idb_to_launcher: Iterate tbl_event_file complete')
|
||||
tbl_event_file_complete = true;
|
||||
});
|
||||
launcher_new.event_file = tmp_event_file;
|
||||
@@ -55,7 +62,7 @@ exports.idb_to_launcher = async function idb_to_launcher() {
|
||||
tbl_event_location.iterate(function(location_value, key, iteration) {
|
||||
tmp_event_location.push(location_value);
|
||||
}).then(function() {
|
||||
console.log('idb_to_launcher: Iterate tbl_event_location complete')
|
||||
//console.log('idb_to_launcher: Iterate tbl_event_location complete')
|
||||
tbl_event_location_complete = true;
|
||||
});
|
||||
launcher_new.location = tmp_event_location;
|
||||
@@ -67,7 +74,7 @@ exports.idb_to_launcher = async function idb_to_launcher() {
|
||||
tmp_event_location_file.push(file_value);
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_launcher: Iterate tbl_event_file complete')
|
||||
//console.log('idb_to_launcher: Iterate tbl_event_file complete')
|
||||
tbl_event_location_file_complete = true;
|
||||
});
|
||||
launcher_new.location_file = tmp_event_location_file;
|
||||
@@ -85,10 +92,9 @@ exports.idb_to_launcher = async function idb_to_launcher() {
|
||||
if (session_file_value.for_type == 'session' && session_value.id == session_file_value.for_id) {
|
||||
//console.log('session id: '+session_value.id+' -> file id: '+session_file_value.id);
|
||||
session_value.file.push(session_file_value)
|
||||
//tmp_event_session_file.push(session_file_value);
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_launcher: Iterate tbl_event_file complete')
|
||||
//console.log('idb_to_launcher: Iterate tbl_event_file complete')
|
||||
tbl_event_session_file_complete = true;
|
||||
});
|
||||
|
||||
@@ -98,8 +104,6 @@ exports.idb_to_launcher = async function idb_to_launcher() {
|
||||
tbl_event_presentation.iterate(function(presentation_value, presentation_key, presentation_iteration) {
|
||||
if (session_value.id == presentation_value.event_session_id) {
|
||||
//console.log('session id: '+session_value.id+' -> presentation id: '+presentation_value.id);
|
||||
|
||||
|
||||
// Look for *presentation files*
|
||||
presentation_value.file = [];
|
||||
tbl_event_file.iterate(function(presentation_file_value, presentation_file_key, presentation_file_iteration) {
|
||||
@@ -107,7 +111,7 @@ exports.idb_to_launcher = async function idb_to_launcher() {
|
||||
presentation_value.file.push(presentation_file_value);
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_launcher: Iterate tbl_event_file complete')
|
||||
//console.log('idb_to_launcher: Iterate tbl_event_file complete')
|
||||
tbl_event_presentation_file_complete = true;
|
||||
});
|
||||
|
||||
@@ -117,7 +121,6 @@ exports.idb_to_launcher = async function idb_to_launcher() {
|
||||
tbl_event_presenter.iterate(function(presenter_value, presenter_key, presenter_iteration) {
|
||||
if (presentation_value.id == presenter_value.event_presentation_id) {
|
||||
//console.log('presentation id: '+presentation_value.id+' -> presenter id: '+presenter_value.id);
|
||||
|
||||
// Look for *presenter files*
|
||||
presenter_value.file = [];
|
||||
tbl_event_file.iterate(function(presenter_file_value, presenter_file_key, presenter_file_iteration) {
|
||||
@@ -125,13 +128,13 @@ exports.idb_to_launcher = async function idb_to_launcher() {
|
||||
presenter_value.file.push(presenter_file_value);
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_launcher: Iterate tbl_event_file complete')
|
||||
//console.log('idb_to_launcher: Iterate tbl_event_file complete')
|
||||
tbl_event_presenter_file_complete = true;
|
||||
});
|
||||
presentation_value.presenter.push(presenter_value);
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_launcher: Iterate tbl_event_presenter complete')
|
||||
//console.log('idb_to_launcher: Iterate tbl_event_presenter complete')
|
||||
tbl_event_presenter_complete = true;
|
||||
});
|
||||
|
||||
@@ -139,7 +142,7 @@ exports.idb_to_launcher = async function idb_to_launcher() {
|
||||
}//);
|
||||
|
||||
}).then(function() {
|
||||
console.log('idb_to_launcher: Iterate tbl_event_presentation complete')
|
||||
//console.log('idb_to_launcher: Iterate tbl_event_presentation complete')
|
||||
tbl_event_presentation_complete = true;
|
||||
});
|
||||
//});
|
||||
@@ -147,7 +150,7 @@ exports.idb_to_launcher = async function idb_to_launcher() {
|
||||
tmp_event_session.push(session_value);
|
||||
|
||||
}).then(function() {
|
||||
console.log('idb_to_launcher: Iterate tbl_event_session complete')
|
||||
//console.log('idb_to_launcher: Iterate tbl_event_session complete')
|
||||
tbl_event_session_complete = true;
|
||||
});
|
||||
launcher_new.session = tmp_event_session;
|
||||
@@ -160,15 +163,20 @@ exports.idb_to_launcher = async function idb_to_launcher() {
|
||||
|
||||
var creating_launcher_object_loop = setInterval(function() {
|
||||
if (tbl_event_complete && tbl_event_file_complete && tbl_event_location_complete && tbl_event_location_file_complete && tbl_event_session_complete && tbl_event_session_file_complete && tbl_event_presentation_complete && tbl_event_presentation_file_complete && tbl_event_presenter_complete && tbl_event_presenter_file_complete) {
|
||||
console.log('And DONE!!!');
|
||||
console.log('v2 idb to launcher object: ***');
|
||||
console.log('*** New launcher object built!!! ***');
|
||||
console.log('idb to launcher object: ***');
|
||||
console.log(launcher_new);
|
||||
console.log('v2 idb to launcher object: ^^^');
|
||||
ui.render_launcher(launcher_new);
|
||||
console.log('idb to launcher object: ^^^');
|
||||
launcher = launcher_new;
|
||||
safe_to_render_launcher = true;
|
||||
idb_to_launcher_in_progress = false;
|
||||
//ui.render_launcher(launcher_new);
|
||||
clearInterval(creating_launcher_object_loop);
|
||||
return launcher_new;
|
||||
} else {
|
||||
console.log('Still building...');
|
||||
console.log('Still building launcher object...');
|
||||
safe_to_render_launcher = false;
|
||||
idb_to_launcher_in_progress = true;
|
||||
}
|
||||
}, 5);
|
||||
//return launcher_new;
|
||||
@@ -178,7 +186,7 @@ exports.check_file_cache = async function () {
|
||||
console.log('Checking the local file cache against the remote server.');
|
||||
tbl_event_file.iterate(function(file_value, key, iteration) {
|
||||
if (file_value.event_location_id == event_location_id) {
|
||||
console.log('f: ('+file_value.event_file_id+') '+file_value.event_file_filename+' ***')
|
||||
//console.log('f: ('+file_value.event_file_id+') '+file_value.event_file_filename+' ***')
|
||||
|
||||
file_id = file_value.event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = file_value.hash_sha256+'.file';
|
||||
@@ -186,7 +194,7 @@ exports.check_file_cache = async function () {
|
||||
save_path = path.join(host_file_cache_path, filename);
|
||||
|
||||
if (fs.existsSync(save_path)) {
|
||||
console.log('Local file already exists: '+save_path);
|
||||
//console.log('Local file already exists: '+save_path);
|
||||
} else {
|
||||
console.log('File not found locally. Downloading file: '+save_path);
|
||||
let api_endpoint = '/event/file/'+file_id+'/download';
|
||||
|
||||
@@ -6,7 +6,7 @@ const { ipcRenderer } = require('electron');
|
||||
|
||||
|
||||
exports.render_launcher = function (launcher_tmp) {
|
||||
console.log('Rendering launcher_tmp...');
|
||||
console.log('Rendering based on launcher_tmp...');
|
||||
|
||||
console.log('In module_app_ui.js v2 idb to launcher object: ***');
|
||||
console.log(launcher_tmp);
|
||||
|
||||
50
app/js/module_app_ui_v2.js
Normal file
50
app/js/module_app_ui_v2.js
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
exports.render_event_records = function (events) {
|
||||
console.log('Rendering event records...');
|
||||
}
|
||||
|
||||
|
||||
exports.render_event_file_records = function (events) {
|
||||
console.log('Rendering event file records...');
|
||||
}
|
||||
|
||||
|
||||
exports.render_event_location_records = function (events) {
|
||||
console.log('Rendering event location records...');
|
||||
}
|
||||
|
||||
|
||||
exports.render_event_location_file_records = function (events) {
|
||||
console.log('Rendering event location file records...');
|
||||
}
|
||||
|
||||
|
||||
exports.render_event_session_records = function (events) {
|
||||
console.log('Rendering event session records...');
|
||||
}
|
||||
|
||||
|
||||
exports.render_event_session_file_records = function (events) {
|
||||
console.log('Rendering event session file records...');
|
||||
}
|
||||
|
||||
|
||||
exports.render_event_presentation_records = function (events) {
|
||||
console.log('Rendering event presentation records...');
|
||||
}
|
||||
|
||||
|
||||
exports.render_event_presention_file_records = function (events) {
|
||||
console.log('Rendering event presentation file records...');
|
||||
}
|
||||
|
||||
|
||||
exports.render_event_presenter_records = function (events) {
|
||||
console.log('Rendering event presenter records...');
|
||||
}
|
||||
|
||||
|
||||
exports.render_event_presenter_file_records = function (events) {
|
||||
console.log('Rendering event presenter file records...');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user