Working on making the rendering more efficient...

This commit is contained in:
Scott Idem
2020-01-29 17:58:35 -05:00
parent 7e79f333c2
commit 5bd557e743
3 changed files with 232 additions and 117 deletions

View File

@@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>One Sky IT: macOS App</title>
<title>One Sky IT</title>
<link rel="shortcut icon" type="image/png" href="img/favicon.ico">
@@ -34,27 +34,21 @@
<!--<main id="main_content" role="main" class="container">-->
<div id="main_content" class="container w-100">
<!--
<div class="row no-gutters">
<div id="location_title" class="location_title border-bottom">Please wait while the data is checked and files are cached.</div>
<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="location_menu" class="location_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="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="location_detail" class="location_detail col">
</div>
<div id="launcher_sessions" class="launcher_sessions col"></div> <!-- end location details div -->
</div> <!-- end row div -->
</div>
@@ -132,11 +126,6 @@
if (window.indexedDB) {
console.log('IndexedDB is supported');
} else {
console.log('IndexedDB is NOT supported');
close();
@@ -180,6 +169,7 @@
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);
@@ -189,6 +179,7 @@
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);
@@ -198,6 +189,7 @@
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);
@@ -207,6 +199,7 @@
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);
@@ -252,9 +245,9 @@
*/
//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; //2000; // 2 seconds
//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;
@@ -282,10 +275,7 @@
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 v2_launcher = new Object();
launcher.account_id = account_id;
launcher.event_id = event_id;
launcher.event_location_id = event_location_id;
let idb_to_launcher_result = false;
//let launcher_cache_check_results = false;
@@ -347,33 +337,124 @@
*/
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...
setInterval(function() {
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.');
}
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.');
}
}, loading_loop_interval);
@@ -383,7 +464,7 @@
if (idb_event_check_datetime < Date.now()) {
console.log('Time to check events');
let v2_account_events = await api.v2_get_account_events(axios, launcher.account_id);
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]);
}
@@ -393,7 +474,7 @@
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, launcher.event_id);
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]);
}
@@ -403,7 +484,7 @@
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, launcher.event_location_id);
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]);
}
@@ -413,7 +494,7 @@
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, launcher.event_location_id);
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]);
}
@@ -423,7 +504,7 @@
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, launcher.event_location_id);
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]);
}
@@ -433,7 +514,7 @@
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, launcher.event_location_id);
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]);
}
@@ -524,9 +605,7 @@
*/
} else {
console.log('Waiting '+main_loop_interval+'ms to see if Authorization header is set.');
console.log('Waiting '+main_loop_interval+'ms to see if tbl_event_session_key_count is set.'+tbl_event_session_key_count);
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);