A lot of clean up of code.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
async function api_token_request_async(axios, secret_key) {
|
||||
console.log('****************** API Token Request ******************');
|
||||
console.log('Requesting API temporary token...');
|
||||
|
||||
if (waiting_on_api_token) {
|
||||
|
||||
57
app/js/app_idb.js
Normal file
57
app/js/app_idb.js
Normal file
@@ -0,0 +1,57 @@
|
||||
async function load_idb_tables() {
|
||||
console.log('****************** Load IDB Tables ******************');
|
||||
console.log('Loading IDB tables...');
|
||||
|
||||
localforage.config({
|
||||
driver: localforage.INDEXEDDB,
|
||||
version: 1,
|
||||
name: idb_name
|
||||
});
|
||||
|
||||
tbl_event = await localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event',
|
||||
});
|
||||
console.log('tbl_event count: '+ await tbl_event.length());
|
||||
tbl_event_key_count = await tbl_event.length();
|
||||
|
||||
tbl_event_location = await localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_location',
|
||||
});
|
||||
console.log('tbl_event_location count: '+ await tbl_event_location.length());
|
||||
tbl_event_location_key_count = await tbl_event_location.length();
|
||||
|
||||
tbl_event_session = await localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_session',
|
||||
});
|
||||
console.log('tbl_event_session count: '+ await tbl_event_session.length());
|
||||
tbl_event_session_key_count = await tbl_event_session.length();
|
||||
|
||||
tbl_event_presentation = await localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_presentation',
|
||||
});
|
||||
console.log('tbl_event_presentation count: '+ await tbl_event_presentation.length());
|
||||
tbl_event_presentation_key_count = await tbl_event_presentation.length();
|
||||
|
||||
tbl_event_presenter = await localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_presenter',
|
||||
});
|
||||
console.log('tbl_event_presenter count: '+ await tbl_event_presenter.length());
|
||||
tbl_event_presenter_key_count = await tbl_event_presenter.length();
|
||||
|
||||
|
||||
tbl_event_file = await localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_file',
|
||||
});
|
||||
console.log('tbl_event_file count: '+ await tbl_event_file.length());
|
||||
tbl_event_file_key_count = await tbl_event_file.length();
|
||||
|
||||
console.log('IDB tables have now been opened.');
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
// This function is used to render all event, location, session, presentation, and presenter file records to the UI.
|
||||
//exports.render_event_file_records = async function () {
|
||||
async function render_event_file_records() {
|
||||
console.log('Rendering all event, location, session, presentation, and presenter file records...');
|
||||
console.log('****************** Files ******************');
|
||||
console.log('Rendering all event, location, session, presentation, and presenter file records...');
|
||||
|
||||
if (looping_tbl_event_file) {
|
||||
console.log('Already looping through the tbl_event_file table. Not starting until finished.');
|
||||
|
||||
@@ -3,6 +3,7 @@ const { ipcRenderer } = require('electron');
|
||||
|
||||
//exports.render_event_records = function () {
|
||||
async function render_event_records() {
|
||||
console.log('****************** Events ******************');
|
||||
console.log('Rendering event records...');
|
||||
//console.log(tbl_event);
|
||||
//console.log(event_id);
|
||||
@@ -35,6 +36,7 @@ async function render_event_records() {
|
||||
|
||||
//exports.render_event_location_records = async function () {
|
||||
async function render_event_location_records() {
|
||||
console.log('****************** Locations ******************');
|
||||
console.log('Rendering event location records...');
|
||||
|
||||
if (looping_tbl_event_location) {
|
||||
@@ -109,8 +111,8 @@ function view_session(session_id) {
|
||||
|
||||
/* Updated 2020-02-13 */
|
||||
function index_open_file_buttons(class_name) {
|
||||
console.log('Indexing open file buttons...');
|
||||
console.log('****************** Indexing ******************');
|
||||
console.log('Indexing open file buttons...');
|
||||
var class_elements = document.getElementsByClassName(class_name);
|
||||
//console.log(class_elements);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//exports.render_event_presentation_records = async function (events) {
|
||||
async function render_event_presentation_records(events) {
|
||||
console.log('Rendering event presentation records...');
|
||||
console.log('****************** Presentations ******************');
|
||||
console.log('Rendering event presentation records...');
|
||||
|
||||
if (looping_tbl_event_presentation) {
|
||||
console.log('Already looping through the tbl_event_presentation table. Not starting until finished.');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//exports.render_event_presenter_records = async function (events) {
|
||||
async function render_event_presenter_records(events) {
|
||||
console.log('Rendering event presenter records...');
|
||||
console.log('****************** Presenters ******************');
|
||||
console.log('Rendering event presenter records...');
|
||||
|
||||
if (looping_tbl_event_presenter) {
|
||||
console.log('Already looping through the tbl_event_presenter table. Not starting until finished.');
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//exports.render_event_session_records = async function () {
|
||||
async function render_event_session_records() {
|
||||
console.log('****************** Sessions ******************');
|
||||
console.log('Rendering event session records...');
|
||||
|
||||
if (looping_tbl_event_session) {
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
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+' ***')
|
||||
|
||||
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';
|
||||
|
||||
save_path = path.join(host_file_cache_path, filename);
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user