Most of the key features work at this point.

This commit is contained in:
Scott Idem
2020-03-06 15:34:15 -05:00
parent 37b708047f
commit 2ddcde1642
7 changed files with 213 additions and 134 deletions

View File

@@ -1,17 +1,15 @@
body {
margin: .1rem;
padding: .1rem;
margin: 0rem;
padding: 0rem;
/*border: solid thin pink;*/
}
.btn_no_case {
text-transform: none;
margin-bottom: 1rem; /* This is for the bottom status bar. */
}
body > .container { /* allow the container directly under body to be 100% wide*/
/*max-width: 100%;*/
margin: 0rem;
padding: 0rem;
margin: .1rem;
padding: .1rem;
/*border: solid thin pink;*/
}
@@ -22,6 +20,36 @@ body > .container > .row { /* allow the container directly under body to be 100%
padding: .1rem;
}
.app_status_bar {
position: fixed;
bottom: 0;
width: 100%;
margin: 0 0;
padding: 0 .5rem;
background: #eee;
}
.app_status_bar:hover {
font-size: 2.5rem;
}
.app_network_status {
background: #eee;
}
.app_datetime {
float: right;
}
.app_warning {
background: yellow;
}
.btn_no_case {
text-transform: none;
}
/*
.btn-info {
background: green;
@@ -42,3 +70,30 @@ mynewcolor:#77cccc;
@include button-outline-variant($mynewcolor, #222222, lighten($mynewcolor,5%), $mynewcolor);
}
*/
.filename {
/*
margin-left: .1rem;
padding-left: .1rem;
*/
}
.menu_session_code, .detail_session_code {
margin-left: .1rem;
padding-left: .1rem;
font-size: .5em;
}
.session_detail>h2 {
background-color: #F7F7F7;
/*border-bottom: solid .1rem black;*/
}
.detail_session_code {
margin-left: .1rem;
padding-left: .1rem;
font-size: .5em;
}

View File

@@ -1,3 +1,5 @@
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
@@ -45,26 +47,4 @@
justify-content: center;
}
.filename {
/*
margin-left: .1rem;
padding-left: .1rem;
*/
}
.menu_session_code, .detail_session_code {
margin-left: .1rem;
padding-left: .1rem;
font-size: .5em;
}
.session_detail>h2 {
background-color: #F7F7F7;
/*border-bottom: solid .1rem black;*/
}
.detail_session_code {
margin-left: .1rem;
padding-left: .1rem;
font-size: .5em;
}

View File

@@ -17,7 +17,7 @@
<!-- 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">
<link rel="stylesheet" href="css/native_app.css">
<style>
</style>
@@ -58,22 +58,25 @@
<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">
<div id="reset1" class="btn btn-warning app_reset" data-spy="affix" data-offset-top="200" onclick="location.reload();">
<span class="fas fa-sync"></span> Reset Launcher
</div>
<div id="network_status1" class="btn btn-success network_status">
<span class="fas fa-globe"></span> Network Status
</div>
</div>
<div id="launcher_sessions" class="launcher_sessions col"></div> <!-- end location details div -->
</div> <!-- end row div -->
</div>
<!--</main>--> <!-- /.container -->
<div id="app_status_bar" class="app_status_bar">
<span id="app_network_status" class="app_network_status">
<span class="fas fa-globe"></span> Network Status
</span>
<span id="app_datetime" class="app_datetime">datetime</span>
</div>
<!-- JavaScript (JS) start -->
@@ -108,7 +111,7 @@
<!-- 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 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>
@@ -124,8 +127,9 @@
let event_id = app_config.event_id;
let event_location_id = app_config.event_location_id;
/* ***** **** *** ** * ### * ** *** **** ***** */
// Start set display options
// Start of set display options
const display_session_codes = app_config.display_session_codes;
@@ -138,9 +142,11 @@
// End of set display options
/* ***** **** *** ** * ### * ** *** **** ***** */
// Start of API section
const api_token_loop_interval = app_config.api_token_loop_interval;
let api_update_period = app_config.idb_event_location_check_period;
let api_update_datetime = Date.now();
@@ -189,27 +195,31 @@
update_event_file_ui = true;
}
var api_token_loop = setInterval(function() {
var api_token_loop = setInterval(async function() {
if (app_online && api_update_datetime < Date.now()) {
let api_temporary_token = api_token_request_async(axios, secret_key)
//let api_temporary_token_result = api_token_request_async(axios, secret_key)
api_temporary_token = await api_token_request_async(axios, secret_key)
.then(function (result) {
if (result) {
console.log('Setting temporary API token to axios Authorization header: '+result);
axios.defaults.headers.common['Authorization'] = `Token ${result}`;
api_temporary_token = result;
//api_temporary_token = result;
console.log('Axios headers have been set.');
axios_headers_set = true;
api_update_datetime = Date.now() + api_update_period;
return result;
} else {
console.log('The temporary API token appears to have failed. Are we actually online? Setting the app to offline mode.');
console.log(navigator.onLine);
app.currently_offline();
return false;
}
})
.catch(function (error) {
console.log('Something went wrong while trying to request a temporary API token.');
console.log(error);
return false;
});
} else if (app_online) {
//console.log('Currently online, but not asking for a new temporary token yet.');
@@ -218,11 +228,14 @@
}
}, api_token_loop_interval);
// End of API section
/* ***** **** *** ** * ### * ** *** **** ***** */
// Start of IDB section
let idb_name = app_config.idb_name;
if (window.indexedDB) {
@@ -391,26 +404,6 @@
console.log('Something went wrong rendering session records.');
console.log(error);
});
/*
let render_event_presentation_records_result = await render_event_presentation_records();
let render_event_presenter_records_result = await render_event_presenter_records();
let render_event_file_records_result = await render_event_file_records();
*/
/*
setTimeout(async function(){
//let render_event_session_records_result = await render_event_session_records();
let render_event_presentation_records_result = await render_event_presentation_records();
let render_event_presenter_records_result = await render_event_presenter_records();
let render_event_file_records_result = await render_event_file_records();
//index_launcher_sessions('btn_view_session');
}, 1000);
*/
//let render_event_presentation_records_result = await render_event_presentation_records();
//setTimeout(function(){ let render_event_presentation_records_result = render_event_presentation_records(); }, 3000);
//let render_event_presenter_records_result = render_event_presenter_records();
//setTimeout(function(){ let render_event_presenter_records_result = render_event_presenter_records(); }, 4000);
//let render_event_file_records_result = render_event_file_records();
//setTimeout(function(){ let render_event_file_records_result = render_event_file_records(); }, 5000);
} else {
console.log('One or more of the IDB tables has 0 records.');
}
@@ -421,45 +414,13 @@
}
}, open_tables_loop_interval);
/*
var use_cached_data_render_loop = setInterval(async function() {
console.log('*** Update Render Loop ***');
if (idb_tables_opened) {
if (update_event_ui) {
let render_event_records_result = render_event_records();
update_event_ui = false;
}
if (update_event_location_ui) {
let render_event_location_records_result = render_event_location_records();
update_event_location_ui = false;
}
if (update_event_session_ui) {
let render_event_session_records_result = render_event_session_records();
update_event_session_ui = false;
}
if (update_event_presentation_ui) {
let render_event_presentation_records_result = await render_event_presentation_records();
update_event_presentation_ui = false;
}
if (update_event_presenter_ui) {
let render_event_presenter_records_result = await render_event_presenter_records();
update_event_presenter_ui = false;
}
if (update_event_file_ui) {
let render_event_file_records_result = await render_event_file_records();
update_event_file_ui = false;
}
}
}, use_cached_data_render_loop_interval);
*/
var update_idb_loop = setInterval(async function() {
//console.log('FLAG: axios_headers_set='+axios_headers_set);
//console.log('FLAG: idb_tables_opened='+idb_tables_opened);
if (app_online && axios_headers_set && idb_tables_opened) {
if (idb_event_check_datetime < Date.now()) {
console.log('**** *** ** * Time to check events');
console.log('**** *** ** * Time to check events * ** *** ****');
let v2_account_events = await v2_get_account_events(axios, account_id)
.then(function (response) {
for (var i in response) {
@@ -477,7 +438,7 @@
}
if (idb_event_location_check_datetime < Date.now()) {
console.log('**** *** ** * Time to check event locations');
console.log('**** *** ** * Time to check event locations * ** *** ****');
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]);
@@ -488,7 +449,7 @@
}
if (idb_event_session_check_datetime < Date.now()) {
console.log('**** *** ** * Time to check event sessions'); // All event sessions, not just location specific.
console.log('**** *** ** * Time to check event sessions * ** *** ****'); // All event sessions, not just location specific.
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) {
@@ -500,7 +461,7 @@
}
if (idb_event_presentation_check_datetime < Date.now()) {
console.log('**** *** ** * Time to check event location presentations');
console.log('**** *** ** * Time to check event location presentations * ** *** ****');
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]);
@@ -511,7 +472,7 @@
}
if (idb_event_presenter_check_datetime < Date.now()) {
console.log('**** *** ** * Time to check event location presenters');
console.log('**** *** ** * Time to check event location presenters * ** *** ****');
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]);
@@ -523,7 +484,7 @@
}
if (idb_event_file_check_datetime < Date.now()) {
console.log('**** *** ** * Time to check event location files');
console.log('**** *** ** * Time to check event location files * ** *** ****');
let v2_event_files = await v2_get_event_files(axios, event_id);
for (var i in v2_event_files) {
@@ -550,10 +511,22 @@
tbl_event_file.setItem(v2_event_location_files_presenters[i].id.toString(), v2_event_location_files_presenters[i]);
}
run_check_file_cache = true; // Set to true so that the local file cache will be checked against the updated event files
//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;
let render_event_file_records_result = await render_event_file_records(); // NOTE: v2 idb to ui
let check_file_cache_result = app.check_file_cache()
.then(function (result) {
if (result) {
console.log('Cached files have now been updated.');
} else {
console.log('Cached files were not updated.');
}
});
//update_event_file_ui = true;
}
@@ -571,6 +544,7 @@
// End of IDB section
/* ***** **** *** ** * ### * ** *** **** ***** */
// Start of cached file section
@@ -582,7 +556,7 @@
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 = app.check_file_cache();
check_file_cache_result.then(function (response) {
console.log('Cached files have now been updated.');
@@ -596,7 +570,7 @@
// End of cached file section
/* ***** **** *** ** * ### * ** *** **** ***** */
var check_initial_online_status = setInterval(async function() {
@@ -619,8 +593,17 @@
}
clearInterval(check_initial_online_status);
}, 500);
let status_clock = setInterval(function() {
//https://date-fns.org/v1.30.1/docs/format
let datetime_string = dateFns.format(new Date(), 'dddd, Do h:mm:ss A'); //dddd, Do hh:mm:ss A
document.getElementById('app_datetime').innerHTML = datetime_string;
}, 1000);
</script>
<!-- <script src="js/launcher.js"></script>-->

View File

@@ -5,8 +5,6 @@ async function api_token_request_async(axios, secret_key) {
console.log('Already waiting on an API token request. Not starting another until finished.');
return false;
} else {
}
waiting_on_api_token = true;
const url = '/api_token_request';
@@ -29,6 +27,9 @@ async function api_token_request_async(axios, secret_key) {
return result;
}
return false;
}
async function get_event_details(axios, event_id) {
console.log('Requesting event details...');

View File

@@ -2,6 +2,7 @@
const os = require('os');
const path = require('path');
const fs = require('fs');
const { ipcRenderer } = require('electron');
exports.load_config = function () {
console.log('CWD: '+process.cwd());
@@ -67,24 +68,70 @@ exports.load_config = function () {
return config;
}
exports.check_file_cache = async function () {
console.log('**** *** ** * FUNCTION: check_file_cache * ** *** ****');
console.log('Checking the local file cache against the remote server.');
if (api_base_url && api_temporary_token) {
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+' ***')
let file_id = file_value.id; // NOTE: This is the event_file.id or event_file_id.
let filename = file_value.hosted_file_hash_sha256+'.file';
let save_path = path.join(host_file_cache_path, filename);
//console.log(save_path);
if (fs.existsSync(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';
ipcRenderer.send('download_file', api_base_url, api_endpoint, api_temporary_token, save_path); // Must download file using main node.js thread.
}
});
} else {
console.log('The api_base_url or api_temporary_token has not been set.');
console.log(api_base_url);
console.log(api_temporary_token);
return false;
}
return true;
}
exports.currently_online = function() {
//alert('You are currently online');
console.log('Currently online');
app_online = true;
document.getElementById('network_status1').classList.remove('btn-warning');
document.getElementById('network_status1').classList.add('btn-success');
document.getElementById('network_status1').innerHTML = '<span class="fas fa-check"></span> <span class="fas fa-globe"></span> Currently Online';
//document.getElementById('network_status1').innerHTML('Currently Online');
//document.getElementById('app_network_status').classList.remove('alert-info');
//document.getElementById('app_network_status').classList.remove('warning');
//document.getElementById('app_network_status').classList.remove('alert-warning');
//document.getElementById('app_network_status').classList.add('success');
//document.getElementById('app_network_status').classList.add('alert-success');
document.getElementById('app_network_status').classList.remove('app_warning');
//document.getElementById('app_network_status').classList.add('d-none');
document.getElementById('app_network_status').innerHTML = '<span class="fas fa-check"></span> <span class="fas fa-globe"></span> Currently Online';
//document.getElementById('app_network_status').innerHTML('Currently Online');
}
exports.currently_offline = function() {
//alert('You are currently offline');
console.log('Currently offline');
app_online = false;
document.getElementById('network_status1').classList.remove('btn-success');
document.getElementById('network_status1').classList.add('btn-warning');
document.getElementById('network_status1').innerHTML = '<span class="fas fa-exclamation"></span> <span class="fas fa-globe"></span> Currently Offline';
//document.getElementById('network_status1').innerHTML('Currently Offline');
//document.getElementById('app_network_status').classList.remove('alert-info');
//document.getElementById('app_network_status').classList.remove('success');
//document.getElementById('app_network_status').classList.remove('alert-success');
//document.getElementById('app_network_status').classList.add('warning');
//document.getElementById('app_network_status').classList.add('alert-warning');
document.getElementById('app_network_status').classList.add('app_warning');
//document.getElementById('app_network_status').classList.remove('d-none');
document.getElementById('app_network_status').innerHTML = '<span class="fas fa-exclamation"></span> <span class="fas fa-globe"></span> Currently Offline';
//document.getElementById('app_network_status').innerHTML('Currently Offline');
}
//window.addEventListener('online', currently_online);

View File

@@ -5,7 +5,13 @@ const fs = require('fs');
const { ipcRenderer } = require('electron');
exports.check_file_cache = async function () {
console.log('**** *** ** * FUNCTION: check_file_cache * ** *** ****');
console.log('Checking the local file cache against the remote server.');
console.log(api_base_url);
console.log(api_temporary_token);
//console.log(save_path);
if (api_base_url && api_temporary_token) {
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+' ***')
@@ -22,8 +28,13 @@ exports.check_file_cache = async function () {
let api_endpoint = '/event/file/'+file_id+'/download';
ipcRenderer.send('download_file', api_base_url, api_endpoint, api_temporary_token, save_path); // Must download file using main node.js thread.
}
//}
});
} else {
console.log('The api_base_url or api_temporary_token has not been set.');
console.log(api_base_url);
console.log(api_temporary_token);
return false;
}
return true;
}

View File

@@ -93,6 +93,8 @@ app.on('activate', () => {
ipcMain.on('download_file', (event, api_base_url, api_endpoint, api_temporary_token, save_path) => {
console.log('ipcMain on download_file: api_base_url='+api_base_url+' | api_temporary_token='+api_temporary_token);
console.log(api_temporary_token);
console.log('ipcMain download and save file: '+api_endpoint+' -> '+save_path);
axios.defaults.baseURL = api_base_url;