More clean up of the JS code.

This commit is contained in:
Scott Idem
2020-02-19 16:35:21 -05:00
parent 46f0762511
commit 41afab59dd
9 changed files with 167 additions and 109 deletions

View File

@@ -55,13 +55,20 @@
<ul class="list-group list-group-flush" role=""></ul>
</div>
<!--<div id="location_name" class="location_name"></div>-->
<div id="launcher_location_name" class="launcher_location_name"><span id="location_name"></span><span id="event_name"></span></div>
<div id="launcher_location_name" class="launcher_location_name">
<span id="location_name"></span><span id="event_name"></span>
</div>
<div id="reset1" class="btn btn-warning reset" data-spy="affix" data-offset-top="200">
<span class="fas fa-sync"></span> Reset Launcher
</div>
</div>
<div id="launcher_sessions" class="launcher_sessions col"></div> <!-- end location details div -->
</div> <!-- end row div -->
</div>
<!--</main>--> <!-- /.container -->
@@ -97,9 +104,10 @@
<!-- 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 api = require('./js/module_api');</script>-->
<script>const idb = require('./js/module_app_idb');</script>
<!--<script src="js/api.js"></script>-->
<script src="js/app_api.js"></script>
<script src="js/app_ui_misc.js"></script>
<script src="js/app_ui_sessions.js"></script>
<script src="js/app_ui_presentations.js"></script>
@@ -127,7 +135,7 @@
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) {
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;
@@ -256,22 +264,20 @@
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;
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();
let idb_event_check_period = app_config.idb_event_check_period;
let idb_event_check_datetime = Date.now();
let idb_event_location_check_period = app_config.idb_event_location_check_period;
let idb_event_location_check_datetime = Date.now();
let idb_event_session_check_period = app_config.idb_event_session_check_period;
let idb_event_session_check_datetime = Date.now();
let idb_event_presentation_check_period = app_config.idb_event_presentation_check_period;
let idb_event_presentation_check_datetime = Date.now();
let idb_event_presenter_check_period = app_config.idb_event_presenter_check_period;
let idb_event_presenter_check_datetime = Date.now();
let idb_event_file_check_period = app_config.idb_event_file_check_period;
let idb_event_file_check_datetime = Date.now();
let run_update_idb = false;
//let run_idb_to_launcher = false;
//let idb_to_launcher_in_progress = false;
let run_check_file_cache = false;
let looping_tbl_event = false;
@@ -329,7 +335,7 @@
var api_token_update_loop = setInterval(function() {
api.api_token_request_async(axios, secret_key).then( function(result) {
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;
@@ -344,7 +350,7 @@
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)
let v2_account_events = await v2_get_account_events(axios, account_id)
.then(function (response) {
for (var i in response) {
tbl_event.setItem(response[i].id.toString(), response[i]);
@@ -361,7 +367,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, event_id);
let v2_event_locations = await 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]);
}
@@ -371,7 +377,7 @@
if (idb_event_session_check_datetime < Date.now()) {
console.log('**** *** ** * Time to check event sessions'); // All event sessions, not just location specific.
let v2_event_sessions = await api.v2_get_event_sessions(axios, event_id); // Was v2_get_event_location_sessions
let v2_event_sessions = await v2_get_event_sessions(axios, event_id); // Was v2_get_event_location_sessions
//tbl_event_session.clear();
for (var i in v2_event_sessions) {
tbl_event_session.setItem(v2_event_sessions[i].id.toString(), v2_event_sessions[i]);
@@ -382,7 +388,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, event_location_id);
let v2_event_presentations = await 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]);
}
@@ -392,7 +398,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, event_location_id);
let v2_event_presenters = await 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]);
}
@@ -404,27 +410,27 @@
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_files(axios, event_id);
let v2_event_files = await v2_get_event_files(axios, event_id);
for (var i in v2_event_files) {
tbl_event_file.setItem(v2_event_files[i].id.toString(), v2_event_files[i]);
}
let v2_event_location_files = await api.v2_get_event_location_files(axios, event_location_id);
let v2_event_location_files = await v2_get_event_location_files(axios, event_location_id);
for (var i in v2_event_location_files) {
tbl_event_file.setItem(v2_event_location_files[i].id.toString(), v2_event_location_files[i]);
}
let v2_event_location_files_sessions = await api.v2_get_event_location_files_sessions(axios, event_location_id);
let v2_event_location_files_sessions = await v2_get_event_location_files_sessions(axios, event_location_id);
for (var i in v2_event_location_files_sessions) {
tbl_event_file.setItem(v2_event_location_files_sessions[i].id.toString(), v2_event_location_files_sessions[i]);
}
let v2_event_location_files_presentations = await api.v2_get_event_location_files_presentations(axios, event_location_id);
let v2_event_location_files_presentations = await v2_get_event_location_files_presentations(axios, event_location_id);
for (var i in v2_event_location_files_presentations) {
tbl_event_file.setItem(v2_event_location_files_presentations[i].id.toString(), v2_event_location_files_presentations[i]);
}
let v2_event_location_files_presenters = await api.v2_get_event_location_files_presenters(axios, event_location_id);
let v2_event_location_files_presenters = await v2_get_event_location_files_presenters(axios, event_location_id);
for (var i in v2_event_location_files_presenters) {
tbl_event_file.setItem(v2_event_location_files_presenters[i].id.toString(), v2_event_location_files_presenters[i]);
}