The sessions portion of the menu works.
This commit is contained in:
@@ -44,8 +44,12 @@
|
||||
<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 id="sessions_menu" class="sessions_menu d-none">
|
||||
<h2>Sessions</h2>
|
||||
<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>
|
||||
|
||||
<div id="launcher_sessions" class="launcher_sessions col"></div> <!-- end location details div -->
|
||||
@@ -90,6 +94,7 @@
|
||||
<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>const uiv2 = require('./js/module_app_ui_v2');</script>
|
||||
<!--<script src="js/api.js"></script>-->
|
||||
<!--<script src="js/script.js"></script>-->
|
||||
<!--<script src="js/testing.js"></script>-->
|
||||
@@ -230,8 +235,8 @@
|
||||
const api_auth_loop_interval = 100; // only runs on start up
|
||||
const open_tables_loop_interval = 10; // only runs on start up
|
||||
|
||||
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_idb_loop_interval = 500; // loop forever; update when check datetime has passed
|
||||
const idb_to_launcher_loop_interval = 1000; // 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
|
||||
|
||||
@@ -353,6 +358,7 @@
|
||||
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;
|
||||
let render_event_records_result = uiv2.render_event_records(); // NOTE: v2 idb to ui
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('Trying to check events. Something went wrong. Expired token?');
|
||||
@@ -370,17 +376,20 @@
|
||||
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;
|
||||
let render_event_location_records_result = uiv2.render_event_location_records(); // NOTE: v2 idb to ui
|
||||
}
|
||||
|
||||
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);
|
||||
console.log('**** *** Time to check event --location-- sessions *** ****');
|
||||
let v2_event_sessions = await api.v2_get_event_sessions(axios, event_id);
|
||||
//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]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
//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;
|
||||
let render_event_session_records_result = uiv2.render_event_session_records(); // NOTE: v2 idb to ui
|
||||
}
|
||||
|
||||
if (idb_event_presentation_check_datetime < Date.now()) {
|
||||
|
||||
@@ -250,6 +250,27 @@ exports.v2_get_event_locations = async function (axios, event_id) {
|
||||
}
|
||||
|
||||
|
||||
exports.v2_get_event_sessions = async function (axios, event_id) {
|
||||
console.log('Requesting event sessions...');
|
||||
const url = '/v2/event/'+event_id+'/event_sessions';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log('v2 location sessions data: ***');
|
||||
console.log(response.data);
|
||||
console.log('v2 location sessions data: ^^^');
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
exports.v2_get_event_location_sessions = async function (axios, event_location_id) {
|
||||
console.log('Requesting location sessions...');
|
||||
const url = '/v2/event_location/'+event_location_id+'/event_sessions';
|
||||
|
||||
@@ -11,7 +11,7 @@ exports.render_launcher = function (launcher_tmp) {
|
||||
console.log('In module_app_ui.js v2 idb to launcher object: ***');
|
||||
console.log(launcher_tmp);
|
||||
console.log('In module_app_ui.js v2 idb to launcher object: ^^^');
|
||||
|
||||
/*
|
||||
if (launcher_tmp.event) {
|
||||
for (var i in launcher_tmp.event) {
|
||||
if (launcher_tmp.event[i].id == event_id) {
|
||||
@@ -20,7 +20,6 @@ exports.render_launcher = function (launcher_tmp) {
|
||||
if (launcher_tmp.location[j].id == event_location_id) {
|
||||
console.log('*** Location id ('+event_location_id+') found in launcher object.');
|
||||
document.title = launcher_tmp.location[j].name+'@'+launcher_tmp.event[i].name;
|
||||
//document.getElementById('launcher_title').innerHTML = '<h1>Launcher '+launcher_tmp.location[j].name+'@'+launcher_tmp.event[i].name+'</h1>';
|
||||
document.getElementById('location_name').innerHTML = '<span class="fas fa-map-marker"></span> '+launcher_tmp.location[j].name+'@'+launcher_tmp.event[i].name;
|
||||
} else {
|
||||
console.log('Event location not it.');
|
||||
@@ -36,6 +35,7 @@ exports.render_launcher = function (launcher_tmp) {
|
||||
console.log('Missing data in launcher object');
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
document.getElementById('event_files_menu').innerHTML = '<h2>Event Files</h2>';
|
||||
document.getElementById('event_files_menu').innerHTML += '<ul class="list-group list-group-flush">';
|
||||
for (var i in launcher_tmp.event_file) {
|
||||
@@ -51,8 +51,8 @@ exports.render_launcher = function (launcher_tmp) {
|
||||
}
|
||||
document.getElementById('location_files_menu').innerHTML += '</ul>';
|
||||
|
||||
document.getElementById('sessions_menu').innerHTML = '<h2>Sessions</h2>';
|
||||
document.getElementById('sessions_menu').innerHTML += '<ul class="list-group list-group-flush" role="">';
|
||||
//document.getElementById('sessions_menu').innerHTML = '<h2>Sessions</h2>';
|
||||
//document.getElementById('sessions_menu').innerHTML += '<ul class="list-group list-group-flush" role="">';
|
||||
//let launcher_sessions = '';
|
||||
if (document.getElementById('launcher_sessions').innerHTML.length) {
|
||||
console.log('launcher_sessions already exists');
|
||||
@@ -63,7 +63,7 @@ exports.render_launcher = function (launcher_tmp) {
|
||||
}
|
||||
for (var i in launcher_tmp.session) {
|
||||
// List sessions in menu
|
||||
document.getElementById('sessions_menu').innerHTML += '<li id="menu_event_session_'+launcher_tmp.session[i].id+'" class="list-group-item btn btn-info d-flex justify-content-between align-items-center btn_view_session" data-session_id="'+launcher_tmp.session[i].id+'">'+launcher_tmp.session[i].name+'</li>';
|
||||
//document.getElementById('sessions_menu').innerHTML += '<li id="menu_event_session_'+launcher_tmp.session[i].id+'" class="list-group-item btn btn-info d-flex justify-content-between align-items-center btn_view_session" data-session_id="'+launcher_tmp.session[i].id+'">'+launcher_tmp.session[i].name+'</li>';
|
||||
|
||||
// Create containers for each session
|
||||
let session_detail = '';
|
||||
@@ -244,15 +244,15 @@ function index_launcher_sessions(class_name) {
|
||||
/* Updated 2019-12-19 */
|
||||
function view_session(session_id) {
|
||||
var class_elements = document.getElementsByClassName('session_detail');
|
||||
console.log('*** Session ID: '+session_id);
|
||||
console.log('*** View session ID: '+session_id);
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
console.log('*** checking: '+class_elements[i].getAttribute('data-session_id'));
|
||||
//console.log('*** checking: '+class_elements[i].getAttribute('data-session_id'));
|
||||
if (class_elements[i].getAttribute('data-session_id') == session_id) {
|
||||
console.log('show');
|
||||
//console.log('show');
|
||||
class_elements[i].classList.remove('d-none');
|
||||
class_elements[i].classList.add('d-block');
|
||||
} else {
|
||||
console.log('hide');
|
||||
//console.log('hide');
|
||||
class_elements[i].classList.remove('d-block');
|
||||
class_elements[i].classList.add('d-none');
|
||||
}
|
||||
|
||||
@@ -1,16 +1,69 @@
|
||||
|
||||
exports.render_event_records = function (events) {
|
||||
exports.render_event_records = function () {
|
||||
console.log('Rendering event records...');
|
||||
//console.log(tbl_event);
|
||||
//console.log(event_id);
|
||||
|
||||
tbl_event.iterate(function(value, key, iteration) {
|
||||
if (value.id == event_id) {
|
||||
console.log('*** Event id ('+event_id+') found in table.');
|
||||
document.getElementById('event_name').innerHTML = '@'+value.name;
|
||||
} else {
|
||||
console.log('Event not it.');
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_ui: Iterate tbl_event_file complete')
|
||||
tbl_event_complete = true;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
exports.render_event_file_records = function (events) {
|
||||
// NOTE: The event_file table should probably only be looped through once when the table is actually updated.
|
||||
// NOTE: Not each time the other objects (event, location, session, presentation, presenter) are updated.
|
||||
exports.render_event_file_records = function (event_files, event_id) {
|
||||
console.log('Rendering event file records...');
|
||||
|
||||
/*
|
||||
tbl_event_file.iterate(function(value, key, iteration) {
|
||||
if (value.id == event_id) {
|
||||
console.log('*** Event id ('+event_id+') found in table.');
|
||||
document.getElementById('event_name').innerHTML = '@'+value.name;
|
||||
} else {
|
||||
console.log('Event not it.');
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_ui: Iterate tbl_event_file complete')
|
||||
tbl_event_complete = true;
|
||||
});
|
||||
|
||||
|
||||
document.getElementById('event_files_menu').innerHTML = '<h2>Event Files</h2>';
|
||||
document.getElementById('event_files_menu').innerHTML += '<ul class="list-group list-group-flush">';
|
||||
for (var i in launcher_tmp.event_file) {
|
||||
document.getElementById('event_files_menu').innerHTML += '<li id="menu_event_file_'+launcher_tmp.event_file[i].event_file_id+'" class="list-group-item btn btn-secondary d-flex justify-content-between align-items-center open_local_file" data-hash_sha256="'+launcher_tmp.event_file[i].hash_sha256+'.file" data-filename="'+launcher_tmp.event_file[i].event_file_filename+'">'+launcher_tmp.event_file[i].event_file_filename+'</li>';
|
||||
}
|
||||
document.getElementById('event_files_menu').innerHTML += '</ul>';
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
exports.render_event_location_records = function (events) {
|
||||
exports.render_event_location_records = function () {
|
||||
console.log('Rendering event location records...');
|
||||
|
||||
tbl_event_location.iterate(function(value, key, iteration) {
|
||||
if (value.id == event_location_id) {
|
||||
console.log('*** Event location id ('+event_location_id+') found in table.');
|
||||
document.getElementById('location_name').innerHTML = '<span class="fas fa-map-marker"></span> '+value.name;
|
||||
} else {
|
||||
console.log('Event location not it.');
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_ui: Iterate tbl_event_file complete')
|
||||
tbl_event_location_complete = true;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +72,129 @@ exports.render_event_location_file_records = function (events) {
|
||||
}
|
||||
|
||||
|
||||
exports.render_event_session_records = function (events) {
|
||||
exports.render_event_session_records = function () {
|
||||
console.log('Rendering event session records...');
|
||||
|
||||
// First: update or add sessions
|
||||
tbl_event_session.iterate(function(value, key, iteration) {
|
||||
if (value.event_id == event_id && value.event_location_id == event_location_id) {
|
||||
console.log('*** Event session id ('+value.id+') is part of this event location.');
|
||||
|
||||
// Checking if the session is already in the launcher menu
|
||||
if (document.getElementById('menu_event_session_'+value.id)) {
|
||||
// Update the session menu list item
|
||||
document.getElementById('menu_event_session_'+value.id).innerHTML = value.name;
|
||||
} else {
|
||||
// Unhide the sessions menu
|
||||
if (document.getElementById('sessions_menu').classList.contains('d-none') ) {
|
||||
document.getElementById('sessions_menu').classList.remove('d-none');
|
||||
document.getElementById('sessions_menu').classList.add('d-block');
|
||||
}
|
||||
|
||||
// Add the new session to the session menu
|
||||
let node = document.createElement('LI');
|
||||
node.id = 'menu_event_session_'+value.id;
|
||||
node.className = 'list-group-item btn btn-info d-flex justify-content-between align-items-center btn_view_session';
|
||||
node.setAttribute('data-session_id', value.id);
|
||||
let text_node = document.createTextNode(value.name);
|
||||
node.appendChild(text_node);
|
||||
|
||||
document.getElementById('sessions_menu').getElementsByTagName('ul')[0].appendChild(node);
|
||||
}
|
||||
|
||||
|
||||
// Checking if the session is already in the launcher sessions detail
|
||||
if (document.getElementById('detail_session_'+value.id)) {
|
||||
// Update the session menu list item
|
||||
document.getElementById('detail_session_'+value.id).getElementsByTagName('h2')[0].innerHTML = value.name;
|
||||
document.getElementById('detail_session_'+value.id).getElementsByTagName('h2')[0].getElementsByTagName('span')[0].innerHTML = dateFns.format(value.startdatetime, 'ddd h:mm A');
|
||||
} else {
|
||||
/*
|
||||
// Unhide the sessions menu
|
||||
if (document.getElementById('launcher_sessions').classList.contains('d-none') ) {
|
||||
document.getElementById('launcher_sessions').classList.remove('d-none');
|
||||
document.getElementById('launcher_sessions').classList.add('d-block');
|
||||
}
|
||||
*/
|
||||
|
||||
// Add the new session to the launcher session detail
|
||||
let div_node = document.createElement('DIV');
|
||||
div_node.id = 'detail_session_'+value.id;
|
||||
div_node.className = 'container d-none session_detail';
|
||||
div_node.setAttribute('data-session_id', value.id);
|
||||
|
||||
let h2_node = document.createElement('H2');
|
||||
h2_node.className = 'session_title d-flex justify-content-between align-items-center';
|
||||
|
||||
let h2_text_node = document.createTextNode(value.name);
|
||||
h2_node.appendChild(h2_text_node);
|
||||
|
||||
let h2_span_node = document.createElement('SPAN');
|
||||
h2_span_node.className = 'badge badge-pill badge-info';
|
||||
|
||||
let h2_span_text_node = document.createTextNode(dateFns.format(value.startdatetime, 'ddd h:mm A'));
|
||||
h2_span_node.appendChild(h2_span_text_node);
|
||||
|
||||
h2_node.appendChild(h2_span_node);
|
||||
|
||||
div_node.appendChild(h2_node);
|
||||
|
||||
document.getElementById('launcher_sessions').appendChild(div_node);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
console.log('Event session not it.');
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_ui: Iterate tbl_event_session complete')
|
||||
tbl_event_session_complete = true;
|
||||
}).then(function() {
|
||||
// Second: remove sessions
|
||||
console.log('Looking for removed sessions...');
|
||||
|
||||
//let session_list_items = document.getElementById('sessions_menu').getElementsByTagName('ul').childNodes;
|
||||
let session_list_items = document.getElementById('sessions_menu').getElementsByTagName('ul')[0].childNodes;
|
||||
console.log(session_list_items);
|
||||
|
||||
console.log(session_list_items.length);
|
||||
|
||||
for (var i in session_list_items) {
|
||||
console.log(session_list_items[i].getAttribute('data-session_id'));
|
||||
//console.log(session_list_items[i]);
|
||||
let session_id = session_list_items[i].getAttribute('data-session_id')
|
||||
let session_valid = false;
|
||||
|
||||
tbl_event_session.iterate(function(value, key, iteration) {
|
||||
console.log(value.event_id+' ?= '+event_id+' : '+value.event_location_id+' ?- '+event_location_id+' : '+value.id+' ?- '+session_id);
|
||||
if (value.event_id == event_id && value.event_location_id == event_location_id && value.id == session_id) {
|
||||
// The session is still part of the event and the location
|
||||
session_valid = true;
|
||||
} else {
|
||||
// The session is no longer part of the event and or the location
|
||||
//console.log('Need to remove session id '+session_id);
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_ui: Iterate tbl_event_session looking for sessions to remove is complete')
|
||||
if (session_valid) {
|
||||
console.log('Keep session id '+session_id);
|
||||
} else {
|
||||
console.log('Remove session id '+session_id);
|
||||
session_list_items[i].remove();
|
||||
document.getElementById('menu_event_session_'+session_id).remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Third: re-index view session buttons
|
||||
// NOTE: Should this go in a .then() section?
|
||||
// NOTE: It might make even more sense to only have this done individually per add. Should also do a remove to keep things clean.
|
||||
//index_launcher_sessions('btn_view_session');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user