Initial commit
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
file_cache/
|
||||
node_modules/
|
||||
temp/
|
||||
4
app/.directory
Normal file
4
app/.directory
Normal file
@@ -0,0 +1,4 @@
|
||||
[Dolphin]
|
||||
Timestamp=2020,1,24,15,51,19
|
||||
Version=4
|
||||
ViewMode=2
|
||||
44
app/css/launcher.css
Normal file
44
app/css/launcher.css
Normal file
@@ -0,0 +1,44 @@
|
||||
body {
|
||||
margin: .1rem;
|
||||
padding: .1rem;
|
||||
/*border: solid thin pink;*/
|
||||
}
|
||||
|
||||
.btn_no_case {
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
body > .container { /* allow the container directly under body to be 100% wide*/
|
||||
/*max-width: 100%;*/
|
||||
margin: 0rem;
|
||||
padding: 0rem;
|
||||
/*border: solid thin pink;*/
|
||||
}
|
||||
|
||||
body > .container > .row { /* allow the container directly under body to be 100% wide*/
|
||||
margin-right: 0;
|
||||
margin-left: 0;
|
||||
margin: .1rem;
|
||||
padding: .1rem;
|
||||
}
|
||||
|
||||
/*
|
||||
.btn-info {
|
||||
background: green;
|
||||
}
|
||||
|
||||
.btn-info:hover {
|
||||
background: darkgreen;
|
||||
}
|
||||
|
||||
|
||||
mynewcolor:#77cccc;
|
||||
|
||||
.btn-info {
|
||||
@include button-variant($mynewcolor, darken($mynewcolor, 7.5%), darken($mynewcolor, 10%), lighten($mynewcolor,5%), lighten($mynewcolor, 10%), darken($mynewcolor,30%));
|
||||
}
|
||||
|
||||
.btn-outline-primary {
|
||||
@include button-outline-variant($mynewcolor, #222222, lighten($mynewcolor,5%), $mynewcolor);
|
||||
}
|
||||
*/
|
||||
19
app/css/starter-template.css
Normal file
19
app/css/starter-template.css
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
body {
|
||||
padding-top: 3rem;
|
||||
}
|
||||
.starter-template {
|
||||
padding: 1rem 1.5rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: auto;
|
||||
max-width: 2560px;
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
.footer {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
*/
|
||||
46
app/css/style.css
Normal file
46
app/css/style.css
Normal file
@@ -0,0 +1,46 @@
|
||||
.bd-placeholder-img {
|
||||
font-size: 1.125rem;
|
||||
text-anchor: middle;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.bd-placeholder-img-lg {
|
||||
font-size: 3.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
#file_import_drag_area {
|
||||
font-size: 3rem;
|
||||
font-weight: 600;
|
||||
width: 90%;
|
||||
height: 15rem;
|
||||
}
|
||||
|
||||
#file_import_drag_area:hover {
|
||||
font-size: 3.5rem;
|
||||
font-weight: 1000;
|
||||
}
|
||||
|
||||
#file_import_drag_area:hover:before {
|
||||
/*font-weight: 1000;
|
||||
content: 'Here';*/
|
||||
}
|
||||
|
||||
#file_import_drag_area::before {
|
||||
content: attr(data-value);
|
||||
|
||||
position: relative;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: 15rem;
|
||||
/*border: 1px solid red;*/
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
BIN
app/img/favicon.ico
Executable file
BIN
app/img/favicon.ico
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
180
app/index 2019-12-22.html.bak
Normal file
180
app/index 2019-12-22.html.bak
Normal file
@@ -0,0 +1,180 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<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>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="img/favicon.ico">
|
||||
|
||||
<!-- Cascading Style Sheets (CSS) start -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.10.2/css/all.css">
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- One Sky IT default custom Cascading Style Sheets (CSS) -->
|
||||
|
||||
<!-- 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">
|
||||
|
||||
<style>
|
||||
</style>
|
||||
<!-- Cascading Style Sheets (CSS) end -->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!--<main id="main_content" role="main" class="container">-->
|
||||
<div id="main_content" class="container">
|
||||
|
||||
<div class="row">
|
||||
<div id="location_title" class="location_title border-bottom">Launcher</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div id="location_menu" class="location_menu col-2 border-right">
|
||||
|
||||
<div id="event_files_menu" class="event_files_menu">
|
||||
*event files
|
||||
</div>
|
||||
<div id="location_files_menu" class="location_files_menu">
|
||||
*location files
|
||||
</div>
|
||||
<div id="sessions_menu" class="sessions_menu">
|
||||
*sessions<br>
|
||||
**session<br>
|
||||
***session files<br>
|
||||
***presentations<br>
|
||||
****presentation<br>
|
||||
*****presentation files<br>
|
||||
*****presenters<br>
|
||||
******presenter<br>
|
||||
*******presenter files<br>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="sessions_detail" class="sessions_detail col">
|
||||
|
||||
</div>
|
||||
</div> <!-- end row div -->
|
||||
|
||||
</div>
|
||||
<!--</main>--> <!-- /.container -->
|
||||
|
||||
|
||||
|
||||
<!-- JavaScript (JS) start -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.15.3/axios.min.js" crossorigin></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.30.1/date_fns.min.js"></script>
|
||||
|
||||
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js" crossorigin></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- One Sky IT default custom JavaScript (JS) -->
|
||||
<!-- One Sky IT site custom JavaScript (JS) -->
|
||||
<script>const api = require('./js/module_api');</script>
|
||||
<script src="js/api.js"></script>
|
||||
<!--<script src="js/script.js"></script>-->
|
||||
<script src="js/testing.js"></script>
|
||||
|
||||
<script>
|
||||
// Development variables:
|
||||
let event_id = 14;
|
||||
let event_location_id = 13;
|
||||
let event_session_id = 827;
|
||||
let event_presentation_id = 2002;
|
||||
let event_presenter_id = 2539;
|
||||
let event_file_id = 28;
|
||||
let api_base_url = 'http://192.168.1.7:5001'; // 'http://api.localhost:5001' 'https://api.oneskyit.com';
|
||||
|
||||
// Initialize variables:
|
||||
//const { ipcRenderer } = require('electron');
|
||||
//const os = require('os');
|
||||
//const path = require('path');
|
||||
//const fs = require('fs');
|
||||
|
||||
const secret_key = 'YWAAk39H2qH0edK6lPH0yg';
|
||||
let api_temporary_token = null;
|
||||
|
||||
axios.defaults.baseURL = api_base_url;
|
||||
axios.defaults.headers.post['Access-Control-Allow-Origin'] = '*';
|
||||
|
||||
api_temporary_token = api.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}`;
|
||||
return result;
|
||||
});
|
||||
|
||||
api_token_request_async().then( function(result) {
|
||||
// Do something with result.
|
||||
//get_all_events();
|
||||
//get_event(event_id);
|
||||
//get_event_sessions(event_id);
|
||||
//get_event_files(event_id);
|
||||
});
|
||||
|
||||
const loop_delay = 2000; // 2 seconds
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the object check period into event, location, session, presentation, presenter
|
||||
let launcher_object_check_datetime = Date.now(); // default to current datetime in ms
|
||||
const launcher_object_check_period = 30000; // 60 seconds
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the file check period into event, location, session, presentation, presenter
|
||||
let launcher_files_check_datetime = Date.now(); // default to current datetime in ms
|
||||
const launcher_files_check_period = 30000; // 30 seconds
|
||||
const file_cache_path = 'file_cache/';
|
||||
|
||||
let launcher = new Object(); // This will create the something like location > sessions and location files > presenters and session files > presenter files
|
||||
launcher.event_id = event_id;
|
||||
launcher.event_location_id = event_location_id;
|
||||
|
||||
//let launcher_cache_check_results = false;
|
||||
let launcher_render_results = false;
|
||||
|
||||
setInterval(async function() {
|
||||
if (typeof axios.defaults.headers.common['Authorization'] !== 'undefined' && axios.defaults.headers.common['Authorization'] != null) {
|
||||
|
||||
current_datetime = Date.now();
|
||||
//let launcher_cache_check_results = false;
|
||||
|
||||
if (launcher_object_check_datetime < current_datetime) {
|
||||
launcher_cache_check_results = api.launcher_cache_check(launcher, api_base_url, api_temporary_token, file_cache_path);
|
||||
|
||||
launcher_cache_check_results.then(function (response) {
|
||||
console.log(launcher);
|
||||
launcher_object_check_datetime = Date.now() + launcher_object_check_period;
|
||||
|
||||
launcher_render_results = api.launcher_render(launcher);
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log('Waiting '+loop_delay+'ms to see if Authorization header is set.');
|
||||
}
|
||||
}, loop_delay);
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
</script>
|
||||
|
||||
<!-- <script src="js/launcher.js"></script>-->
|
||||
<!-- JavaScript (JS) end -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
242
app/index 2020-01-08.html.bak
Normal file
242
app/index 2020-01-08.html.bak
Normal file
@@ -0,0 +1,242 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<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>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="img/favicon.ico">
|
||||
|
||||
<!-- Cascading Style Sheets (CSS) start -->
|
||||
<!--
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
||||
-->
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.4.1/materia/bootstrap.min.css" rel="stylesheet" integrity="sha384-1tymk6x9Y5K+OF0tlmG2fDRcn67QGzBkiM3IgtJ3VrtGrIi5ryhHjKjeeS60f1FA" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.10.2/css/all.css">
|
||||
|
||||
<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>-->
|
||||
<!--
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/esm/popper.min.js" integrity="sha256-g491Yv8nsEVSfQ6aonhVVFXoX5vF2uJQIU0hVNRg4JQ=" crossorigin="anonymous"></script>
|
||||
-->
|
||||
|
||||
<!--
|
||||
Using node.js may require this: npm install jquery, add script below.
|
||||
https://stackoverflow.com/questions/22658015/bootstrap-throws-uncaught-error-bootstraps-javascript-requires-jquery
|
||||
-->
|
||||
<!--
|
||||
<script>
|
||||
window.jQuery = window.$ = require('jquery');
|
||||
</script>
|
||||
-->
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.30.1/date_fns.min.js" integrity="sha256-wCBClaCr6pJ7sGU5kfb3gQMOOcIZNzaWpWcj/lD9Vfk=" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- One Sky IT default custom Cascading Style Sheets (CSS) -->
|
||||
|
||||
<!-- 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">
|
||||
|
||||
<style>
|
||||
</style>
|
||||
<!-- Cascading Style Sheets (CSS) end -->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!--<main id="main_content" role="main" class="container">-->
|
||||
<div id="main_content" class="container">
|
||||
|
||||
<div class="row">
|
||||
<div id="location_title" class="location_title border-bottom">Launcher</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div id="location_menu" class="location_menu col-2 border-right">
|
||||
|
||||
<div id="event_files_menu" class="event_files_menu">
|
||||
*event files
|
||||
</div>
|
||||
<div id="location_files_menu" class="location_files_menu">
|
||||
*location files
|
||||
</div>
|
||||
<div id="sessions_menu" class="sessions_menu">
|
||||
*sessions<br>
|
||||
**session<br>
|
||||
***session files<br>
|
||||
***presentations<br>
|
||||
****presentation<br>
|
||||
*****presentation files<br>
|
||||
*****presenters<br>
|
||||
******presenter<br>
|
||||
*******presenter files<br>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="location_detail" class="location_detail col">
|
||||
|
||||
</div>
|
||||
</div> <!-- end row div -->
|
||||
|
||||
</div>
|
||||
<!--</main>--> <!-- /.container -->
|
||||
|
||||
|
||||
|
||||
<!-- JavaScript (JS) start -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.15.3/axios.min.js" crossorigin></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.30.1/date_fns.min.js"></script>
|
||||
|
||||
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js" crossorigin></script>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/idb-keyval@3/dist/idb-keyval-iife.min.js"></script>
|
||||
|
||||
<!-- One Sky IT default custom JavaScript (JS) -->
|
||||
|
||||
<!-- One Sky IT site custom JavaScript (JS) -->
|
||||
<script>const app = require('./js/app');</script>
|
||||
<script>const api = require('./js/module_api');</script>
|
||||
<script>const idb = require('./js/app_idb');</script>
|
||||
<!--<script src="js/api.js"></script>-->
|
||||
<!--<script src="js/script.js"></script>-->
|
||||
<!--<script src="js/testing.js"></script>-->
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
let config = app.load_config();
|
||||
let event_id = config.event_id;
|
||||
let event_location_id = config.event_location_id;
|
||||
|
||||
const secret_key = config.api_secret_key; //'YWAAk39H2qH0edK6lPH0yg';
|
||||
let api_temporary_token = null;
|
||||
|
||||
let api_base_url = null; //'http://api.localhost:5001'; // 'http://api.localhost:5001' 'https://api.oneskyit.com';
|
||||
|
||||
if (config.use_local_api) {
|
||||
api_base_url = config.api_local_base_url; // 'http://api.localhost:5001'
|
||||
} else {
|
||||
api_base_url = config.api_remote_base_url; // 'https://api.oneskyit.com';
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Development variables:
|
||||
//let event_id = 14;
|
||||
//let event_location_id = 13;
|
||||
let event_session_id = 827;
|
||||
let event_presentation_id = 2002;
|
||||
let event_presenter_id = 2539;
|
||||
let event_file_id = 28;
|
||||
|
||||
axios.defaults.baseURL = api_base_url;
|
||||
axios.defaults.headers.post['Access-Control-Allow-Origin'] = '*';
|
||||
|
||||
api_temporary_token = api.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}`;
|
||||
return result;
|
||||
});
|
||||
|
||||
/*
|
||||
api_token_request_async().then( function(result) {
|
||||
// Do something with result.
|
||||
//get_all_events();
|
||||
//get_event(event_id);
|
||||
//get_event_sessions(event_id);
|
||||
//get_event_files(event_id);
|
||||
});
|
||||
*/
|
||||
let idb_name = config.local_idb_name;
|
||||
|
||||
if (window.indexedDB) {
|
||||
var db_event = new idbKeyval.Store(idb_name, 'event');
|
||||
console.log('IndexedDB is supported');
|
||||
var db_event_location = new idbKeyval.Store(idb_name, 'event_location');
|
||||
var db_event_session = new idbKeyval.Store(idb_name, 'event_session');
|
||||
var db_event_presentation = new idbKeyval.Store(idb_name, 'event_presentation');
|
||||
var db_event_presenter = new idbKeyval.Store(idb_name, 'event_presenter');
|
||||
var db_event_file = new idbKeyval.Store(idb_name, 'event_file');
|
||||
var db_hosted_file = new idbKeyval.Store(idb_name, 'hosted_file');
|
||||
} else {
|
||||
console.log('IndexedDB is NOT supported');
|
||||
}
|
||||
|
||||
|
||||
|
||||
const main_loop_interval = config.main_loop_interval; //2000; // 2 seconds
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the object check period into event, location, session, presentation, presenter
|
||||
let launcher_object_check_datetime = Date.now(); // default to current datetime in ms
|
||||
const launcher_object_check_period = config.local_idb_check_period; //30000; // 60 seconds
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the file check period into event, location, session, presentation, presenter
|
||||
let launcher_files_check_datetime = Date.now(); // default to current datetime in ms
|
||||
const launcher_files_check_period = config.local_file_cache_check_period; //30000; // 30 seconds
|
||||
const file_cache_path = config.local_file_cache_path; //'file_cache/';
|
||||
|
||||
let launcher = new Object(); // This will create the something like location > sessions and location files > presenters and session files > presenter files
|
||||
launcher.event_id = event_id;
|
||||
launcher.event_location_id = event_location_id;
|
||||
|
||||
//let launcher_cache_check_results = false;
|
||||
let launcher_render_results = false;
|
||||
|
||||
setInterval(async function() {
|
||||
if (typeof axios.defaults.headers.common['Authorization'] !== 'undefined' && axios.defaults.headers.common['Authorization'] != null) {
|
||||
|
||||
current_datetime = Date.now();
|
||||
//let launcher_cache_check_results = false;
|
||||
|
||||
if (launcher_object_check_datetime < current_datetime) {
|
||||
launcher_cache_check_results = idb.launcher_cache_check(launcher, api_base_url, api_temporary_token, file_cache_path);
|
||||
|
||||
launcher_cache_check_results.then(function (response) {
|
||||
console.log(launcher);
|
||||
launcher_object_check_datetime = Date.now() + launcher_object_check_period;
|
||||
|
||||
launcher_render_results = idb.launcher_render(launcher);
|
||||
//var location_temp = launcher_object_result;
|
||||
//idbKeyval.set('test2', location_temp, custom_store);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log('Waiting '+main_loop_interval+'ms to see if Authorization header is set.');
|
||||
}
|
||||
}, main_loop_interval);
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//const custom_store = new idbKeyval.Store('custom_db', 'custom_store_name');
|
||||
//idbKeyval.set('foo', 'bar', custom_store);
|
||||
|
||||
</script>
|
||||
|
||||
<!-- <script src="js/launcher.js"></script>-->
|
||||
<!-- JavaScript (JS) end -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
224
app/index 2020-01-09 1.html.bak
Normal file
224
app/index 2020-01-09 1.html.bak
Normal file
@@ -0,0 +1,224 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<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>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="img/favicon.ico">
|
||||
|
||||
<!-- Cascading Style Sheets (CSS) start -->
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.4.1/materia/bootstrap.min.css" rel="stylesheet" integrity="sha384-1tymk6x9Y5K+OF0tlmG2fDRcn67QGzBkiM3IgtJ3VrtGrIi5ryhHjKjeeS60f1FA" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.10.2/css/all.css">
|
||||
|
||||
<!-- One Sky IT default custom Cascading Style Sheets (CSS) -->
|
||||
|
||||
<!-- 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">
|
||||
|
||||
<style>
|
||||
</style>
|
||||
<!-- Cascading Style Sheets (CSS) end -->
|
||||
|
||||
<!-- JavaScript (JS) start -->
|
||||
|
||||
<!-- JavaScript (JS) end -->
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!--<main id="main_content" role="main" class="container">-->
|
||||
<div id="main_content" class="container">
|
||||
|
||||
<div class="row">
|
||||
<div id="location_title" class="location_title border-bottom">Launcher</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div id="location_menu" class="location_menu col-2 border-right">
|
||||
|
||||
<div id="event_files_menu" class="event_files_menu">
|
||||
*event files
|
||||
</div>
|
||||
<div id="location_files_menu" class="location_files_menu">
|
||||
*location files
|
||||
</div>
|
||||
<div id="sessions_menu" class="sessions_menu">
|
||||
*sessions<br>
|
||||
**session<br>
|
||||
***session files<br>
|
||||
***presentations<br>
|
||||
****presentation<br>
|
||||
*****presentation files<br>
|
||||
*****presenters<br>
|
||||
******presenter<br>
|
||||
*******presenter files<br>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="location_detail" class="location_detail col">
|
||||
|
||||
</div>
|
||||
</div> <!-- end row div -->
|
||||
|
||||
</div>
|
||||
<!--</main>--> <!-- /.container -->
|
||||
|
||||
|
||||
|
||||
<!-- JavaScript (JS) start -->
|
||||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.30.1/date_fns.min.js" integrity="sha256-wCBClaCr6pJ7sGU5kfb3gQMOOcIZNzaWpWcj/lD9Vfk=" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.15.3/axios.min.js" crossorigin></script>
|
||||
|
||||
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js" crossorigin></script>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/idb-keyval@3/dist/idb-keyval-iife.min.js"></script>
|
||||
|
||||
<!--
|
||||
Using node.js may require this: npm install jquery, add script below.
|
||||
https://stackoverflow.com/questions/22658015/bootstrap-throws-uncaught-error-bootstraps-javascript-requires-jquery
|
||||
-->
|
||||
<!--
|
||||
<script>
|
||||
window.jQuery = window.$ = require('jquery');
|
||||
</script>
|
||||
-->
|
||||
|
||||
<!-- One Sky IT default custom JavaScript (JS) -->
|
||||
|
||||
<!-- One Sky IT site custom JavaScript (JS) -->
|
||||
<script>const app = require('./js/app');</script>
|
||||
<script>const api = require('./js/module_api');</script>
|
||||
<script>const idb = require('./js/app_idb');</script>
|
||||
<!--<script src="js/api.js"></script>-->
|
||||
<!--<script src="js/script.js"></script>-->
|
||||
<!--<script src="js/testing.js"></script>-->
|
||||
|
||||
<script>
|
||||
let config = app.load_config();
|
||||
let event_id = config.event_id;
|
||||
let event_location_id = config.event_location_id;
|
||||
|
||||
const secret_key = config.api_secret_key;
|
||||
let api_temporary_token = null;
|
||||
|
||||
let api_base_url = null; // 'http://api.localhost:5001' 'https://api.oneskyit.com'
|
||||
|
||||
if (config.use_local_api) {
|
||||
api_base_url = config.api_local_base_url; // 'http://api.localhost:5001'
|
||||
} else {
|
||||
api_base_url = config.api_remote_base_url; // 'https://api.oneskyit.com'
|
||||
}
|
||||
|
||||
axios.defaults.baseURL = api_base_url;
|
||||
axios.defaults.headers.post['Access-Control-Allow-Origin'] = config.access_control_allow_origin; // '*';
|
||||
|
||||
api.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;
|
||||
return result;
|
||||
});
|
||||
|
||||
|
||||
let idb_name = config.local_idb_name;
|
||||
|
||||
if (window.indexedDB) {
|
||||
console.log('IndexedDB is supported');
|
||||
var tbl_event = new idbKeyval.Store(idb_name, 'event');
|
||||
var tbl_event_location = new idbKeyval.Store(idb_name, 'event_location');
|
||||
var tbl_event_session = new idbKeyval.Store(idb_name, 'event_session');
|
||||
var tbl_event_presentation = new idbKeyval.Store(idb_name, 'event_presentation');
|
||||
var tbl_event_presenter = new idbKeyval.Store(idb_name, 'event_presenter');
|
||||
var tbl_event_file = new idbKeyval.Store(idb_name, 'event_file');
|
||||
var tbl_hosted_file = new idbKeyval.Store(idb_name, 'hosted_file');
|
||||
} else {
|
||||
console.log('IndexedDB is NOT supported');
|
||||
close();
|
||||
}
|
||||
|
||||
const main_loop_interval = config.main_loop_interval; //2000; // 2 seconds
|
||||
|
||||
const idb_check_period = config.idb_check_period; //30000; // 60 seconds
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the object check period into event, location, session, presentation, presenter
|
||||
let idb_check_datetime = Date.now(); // default to current datetime in ms
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the file check period into event, location, session, presentation, presenter
|
||||
let launcher_files_check_datetime = Date.now(); // default to current datetime in ms
|
||||
|
||||
const host_file_cache_path = config.host_file_cache_path; //'file_cache/';
|
||||
const host_file_cache_check_period = 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
|
||||
launcher.event_id = event_id;
|
||||
launcher.event_location_id = event_location_id;
|
||||
|
||||
//let launcher_cache_check_results = false;
|
||||
let launcher_render_results = false;
|
||||
|
||||
// Development variables:
|
||||
//let event_id = 14;
|
||||
//let event_location_id = 13;
|
||||
//let event_session_id = 827;
|
||||
//let event_presentation_id = 2002;
|
||||
//let event_presenter_id = 2539;
|
||||
//let event_file_id = 28;
|
||||
|
||||
setInterval(async function() {
|
||||
if (typeof axios.defaults.headers.common['Authorization'] !== 'undefined' && axios.defaults.headers.common['Authorization'] != null) {
|
||||
|
||||
current_datetime = Date.now();
|
||||
//let launcher_cache_check_results = false;
|
||||
|
||||
if (idb_check_datetime < current_datetime) {
|
||||
launcher_cache_check_results = idb.launcher_cache_check(launcher, api_base_url, api_temporary_token, host_file_cache_path);
|
||||
|
||||
launcher_cache_check_results.then(function (response) {
|
||||
console.log(launcher);
|
||||
idb_check_datetime = Date.now() + idb_check_period;
|
||||
|
||||
launcher_render_results = idb.launcher_render(launcher);
|
||||
//var location_temp = launcher_object_result;
|
||||
//idbKeyval.set('test2', location_temp, custom_store);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log('Waiting '+main_loop_interval+'ms to see if Authorization header is set.');
|
||||
}
|
||||
}, main_loop_interval);
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//const custom_store = new idbKeyval.Store('custom_db', 'custom_store_name');
|
||||
//idbKeyval.set('foo', 'bar', custom_store);
|
||||
|
||||
</script>
|
||||
|
||||
<!-- <script src="js/launcher.js"></script>-->
|
||||
<!-- JavaScript (JS) end -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
289
app/index 2020-01-09 2.html.bak
Normal file
289
app/index 2020-01-09 2.html.bak
Normal file
@@ -0,0 +1,289 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<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>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="img/favicon.ico">
|
||||
|
||||
<!-- Cascading Style Sheets (CSS) start -->
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.4.1/materia/bootstrap.min.css" rel="stylesheet" integrity="sha384-1tymk6x9Y5K+OF0tlmG2fDRcn67QGzBkiM3IgtJ3VrtGrIi5ryhHjKjeeS60f1FA" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.10.2/css/all.css">
|
||||
|
||||
<!-- One Sky IT default custom Cascading Style Sheets (CSS) -->
|
||||
|
||||
<!-- 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">
|
||||
|
||||
<style>
|
||||
</style>
|
||||
<!-- Cascading Style Sheets (CSS) end -->
|
||||
|
||||
<!-- JavaScript (JS) start -->
|
||||
|
||||
<!-- JavaScript (JS) end -->
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!--<main id="main_content" role="main" class="container">-->
|
||||
<div id="main_content" class="container">
|
||||
|
||||
<div class="row">
|
||||
<div id="location_title" class="location_title border-bottom">Launcher</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div id="location_menu" class="location_menu col-2 border-right">
|
||||
|
||||
<div id="event_files_menu" class="event_files_menu">
|
||||
*event files
|
||||
</div>
|
||||
<div id="location_files_menu" class="location_files_menu">
|
||||
*location files
|
||||
</div>
|
||||
<div id="sessions_menu" class="sessions_menu">
|
||||
*sessions<br>
|
||||
**session<br>
|
||||
***session files<br>
|
||||
***presentations<br>
|
||||
****presentation<br>
|
||||
*****presentation files<br>
|
||||
*****presenters<br>
|
||||
******presenter<br>
|
||||
*******presenter files<br>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="location_detail" class="location_detail col">
|
||||
|
||||
</div>
|
||||
</div> <!-- end row div -->
|
||||
|
||||
</div>
|
||||
<!--</main>--> <!-- /.container -->
|
||||
|
||||
|
||||
|
||||
<!-- JavaScript (JS) start -->
|
||||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.30.1/date_fns.min.js" integrity="sha256-wCBClaCr6pJ7sGU5kfb3gQMOOcIZNzaWpWcj/lD9Vfk=" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.15.3/axios.min.js" crossorigin></script>
|
||||
|
||||
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js" crossorigin></script>
|
||||
|
||||
<!--<script src="https://cdn.jsdelivr.net/npm/idb-keyval@3/dist/idb-keyval-iife.min.js"></script>-->
|
||||
<!--<script src="https://unpkg.com/dexie@latest/dist/dexie.js"></script>-->
|
||||
<script src="https://cdn.rawgit.com/mozilla/localForage/master/dist/localforage.js"></script>
|
||||
|
||||
<!--
|
||||
Using node.js may require this: npm install jquery, add script below.
|
||||
https://stackoverflow.com/questions/22658015/bootstrap-throws-uncaught-error-bootstraps-javascript-requires-jquery
|
||||
-->
|
||||
<!--
|
||||
<script>
|
||||
window.jQuery = window.$ = require('jquery');
|
||||
</script>
|
||||
-->
|
||||
|
||||
<!-- One Sky IT default custom JavaScript (JS) -->
|
||||
|
||||
<!-- 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 src="js/api.js"></script>-->
|
||||
<!--<script src="js/script.js"></script>-->
|
||||
<!--<script src="js/testing.js"></script>-->
|
||||
|
||||
<script>
|
||||
let config = app.load_config();
|
||||
let event_id = config.event_id;
|
||||
let event_location_id = config.event_location_id;
|
||||
|
||||
const secret_key = config.api_secret_key;
|
||||
let api_temporary_token = null;
|
||||
|
||||
let api_base_url = null; // 'http://api.localhost:5001' 'https://api.oneskyit.com'
|
||||
|
||||
if (config.use_local_api) {
|
||||
api_base_url = config.api_local_base_url; // 'http://api.localhost:5001'
|
||||
} else {
|
||||
api_base_url = config.api_remote_base_url; // 'https://api.oneskyit.com'
|
||||
}
|
||||
|
||||
axios.defaults.baseURL = api_base_url;
|
||||
axios.defaults.headers.post['Access-Control-Allow-Origin'] = config.access_control_allow_origin; // '*';
|
||||
|
||||
api.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;
|
||||
return result;
|
||||
});
|
||||
|
||||
|
||||
let idb_name = config.idb_name;
|
||||
|
||||
if (window.indexedDB) {
|
||||
console.log('IndexedDB is supported');
|
||||
/*
|
||||
var tbl_event = new idbKeyval.Store(idb_name, 'event');
|
||||
var tbl_event_location = new idbKeyval.Store(idb_name, 'event_location');
|
||||
var tbl_event_session = new idbKeyval.Store(idb_name, 'event_session');
|
||||
var tbl_event_presentation = new idbKeyval.Store(idb_name, 'event_presentation');
|
||||
var tbl_event_presenter = new idbKeyval.Store(idb_name, 'event_presenter');
|
||||
var tbl_event_file = new idbKeyval.Store(idb_name, 'event_file');
|
||||
var tbl_hosted_file = new idbKeyval.Store(idb_name, 'hosted_file');
|
||||
*/
|
||||
} else {
|
||||
console.log('IndexedDB is NOT supported');
|
||||
close();
|
||||
}
|
||||
|
||||
localforage.config({
|
||||
driver: localforage.INDEXEDDB,
|
||||
version: 1,
|
||||
name: idb_name
|
||||
});
|
||||
|
||||
var tbl_event = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event',
|
||||
});
|
||||
var tbl_event_location = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_location',
|
||||
});
|
||||
var tbl_event_session = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_session',
|
||||
});
|
||||
var tbl_event_presentation = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_presentation',
|
||||
});
|
||||
var tbl_event_presenter = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_presenter',
|
||||
});
|
||||
var tbl_event_file = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_file',
|
||||
});
|
||||
var tbl_hosted_file = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'hosted_file',
|
||||
});
|
||||
|
||||
//tbl_event.setItem(Math.random().toString(), Math.random());
|
||||
//tbl_event_location.setItem('99', 'hello world 2');
|
||||
|
||||
//store.setItem("key", "value");
|
||||
//otherStore.setItem("key", "value2");
|
||||
|
||||
/*
|
||||
var db_test = indexedDB.open(idb_name, 1);
|
||||
var tbl_test = db_test.createObjectStore("tbl_test", "id", false);
|
||||
|
||||
idb_names = Dexie.getDatabaseNames();
|
||||
if (idb_names.length === 0) {
|
||||
console.log("No databases found.");
|
||||
} else {
|
||||
console.log(idb_names);
|
||||
for (var i in idb_names) {
|
||||
if (idb_names[i] == idb_name) {
|
||||
} else {
|
||||
var db = new Dexie(idb_name);
|
||||
db.version(1).stores({event: "id,name,test", event_location: "id,name,test2"});
|
||||
db.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
const main_loop_interval = config.main_loop_interval; //2000; // 2 seconds
|
||||
|
||||
const idb_check_period = config.idb_check_period; //30000; // 60 seconds
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the object check period into event, location, session, presentation, presenter
|
||||
let idb_check_datetime = Date.now(); // default to current datetime in ms
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the file check period into event, location, session, presentation, presenter
|
||||
let launcher_files_check_datetime = Date.now(); // default to current datetime in ms
|
||||
|
||||
const host_file_cache_path = config.host_file_cache_path; //'file_cache/';
|
||||
const host_file_cache_check_period = 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
|
||||
launcher.event_id = event_id;
|
||||
launcher.event_location_id = event_location_id;
|
||||
|
||||
//let launcher_cache_check_results = false;
|
||||
let launcher_render_results = false;
|
||||
|
||||
// Development variables:
|
||||
//let event_id = 14;
|
||||
//let event_location_id = 13;
|
||||
//let event_session_id = 827;
|
||||
//let event_presentation_id = 2002;
|
||||
//let event_presenter_id = 2539;
|
||||
//let event_file_id = 28;
|
||||
|
||||
setInterval(async function() {
|
||||
if (typeof axios.defaults.headers.common['Authorization'] !== 'undefined' && axios.defaults.headers.common['Authorization'] != null) {
|
||||
|
||||
current_datetime = Date.now();
|
||||
//let launcher_cache_check_results = false;
|
||||
|
||||
if (idb_check_datetime < current_datetime) {
|
||||
launcher_cache_check_results = idb.launcher_cache_check(launcher, api_base_url, api_temporary_token, host_file_cache_path);
|
||||
|
||||
launcher_cache_check_results.then(function (response) {
|
||||
console.log(launcher);
|
||||
idb_check_datetime = Date.now() + idb_check_period;
|
||||
|
||||
launcher_render_results = idb.launcher_render(launcher);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
console.log('Waiting '+main_loop_interval+'ms to see if Authorization header is set.');
|
||||
}
|
||||
}, main_loop_interval);
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//const custom_store = new idbKeyval.Store('custom_db', 'custom_store_name');
|
||||
//idbKeyval.set('foo', 'bar', custom_store);
|
||||
|
||||
</script>
|
||||
|
||||
<!-- <script src="js/launcher.js"></script>-->
|
||||
<!-- JavaScript (JS) end -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
438
app/index 2020-01-21.html.bak
Normal file
438
app/index 2020-01-21.html.bak
Normal file
@@ -0,0 +1,438 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<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>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="img/favicon.ico">
|
||||
|
||||
<!-- Cascading Style Sheets (CSS) start -->
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.4.1/materia/bootstrap.min.css" rel="stylesheet" integrity="sha384-1tymk6x9Y5K+OF0tlmG2fDRcn67QGzBkiM3IgtJ3VrtGrIi5ryhHjKjeeS60f1FA" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.10.2/css/all.css">
|
||||
|
||||
<!-- One Sky IT default custom Cascading Style Sheets (CSS) -->
|
||||
|
||||
<!-- 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">
|
||||
|
||||
<style>
|
||||
</style>
|
||||
<!-- Cascading Style Sheets (CSS) end -->
|
||||
|
||||
<!-- JavaScript (JS) start -->
|
||||
|
||||
<!-- JavaScript (JS) end -->
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!--<main id="main_content" role="main" class="container">-->
|
||||
<div id="main_content" class="container">
|
||||
|
||||
<div class="row">
|
||||
<div id="location_title" class="location_title border-bottom">Launcher</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div id="location_menu" class="location_menu col-2 border-right">
|
||||
|
||||
<div id="event_files_menu" class="event_files_menu">
|
||||
*event files
|
||||
</div>
|
||||
<div id="location_files_menu" class="location_files_menu">
|
||||
*location files
|
||||
</div>
|
||||
<div id="sessions_menu" class="sessions_menu">
|
||||
*sessions<br>
|
||||
**session<br>
|
||||
***session files<br>
|
||||
***presentations<br>
|
||||
****presentation<br>
|
||||
*****presentation files<br>
|
||||
*****presenters<br>
|
||||
******presenter<br>
|
||||
*******presenter files<br>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="location_detail" class="location_detail col">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">Session Files:</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item btn btn-info d-flex justify-content-between align-items-center">File 1.txt<span class="badge badge-pill badge-light">91.22 KB; Jul 7 6:12 AM; win</span></li>
|
||||
<li class="list-group-item btn btn-info d-flex justify-content-between align-items-center">NASPGHAN 2020: Not happening this is long Filename 2 Hello World Todays date here.pptx<span class="badge badge-pill badge-light">1.36 MB; Sep 9 7:17 AM; mac</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">Presentations:</div>
|
||||
<div class="card-body">
|
||||
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">
|
||||
<div class="list-group-item-heading">How do I best evaluate a cholestatic infant?</div>
|
||||
<div class="list-group-item-text">
|
||||
<ul class="list-group">
|
||||
|
||||
<li class="list-group-item list-group-item-action">Presentation File 1.txt</li>
|
||||
<li class="list-group-item list-group-item-action">Presentation File 2.pptx</li>
|
||||
<li class="list-group-item">
|
||||
<strong class="list-group-item-heading">Scott Idem</strong>
|
||||
<ul class="list-group list-group-flush list-group-item-text">
|
||||
<li class="list-group-item list-group-item-action">filename.pptx</li>
|
||||
<li class="list-group-item list-group-item-action">my new file.pptx</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
<strong class="list-group-item-heading">Holly Danner</strong>
|
||||
<ul class="list-group list-group-flush list-group-item-text">
|
||||
<li class="list-group-item list-group-item-action">another filename.key</li>
|
||||
<li class="list-group-item list-group-item-action">my new file.pptx</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
<strong class="list-group-item-heading">Rick Mathews</strong>
|
||||
<ul class="list-group list-group-flush list-group-item-text">
|
||||
<li class="list-group-item list-group-item-action">another filename.key</li>
|
||||
<li class="list-group-item list-group-item-action">my new file.pptx</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<div class="list-group-item-heading">Common Feeding Problems and Management Strategies in Autism Spectrum Disorder</div>
|
||||
<div class="list-group-item-text">
|
||||
<ul class="list-group">
|
||||
|
||||
<li class="list-group-item list-group-item-action">Presentation File 2.pptx</li>
|
||||
<li class="list-group-item">
|
||||
<strong class="list-group-item-heading">Scott Idem</strong>
|
||||
<ul class="list-group list-group-flush list-group-item-text">
|
||||
<li class="list-group-item list-group-item-action">filename.pptx</li>
|
||||
<li class="list-group-item list-group-item-action">my new file.pptx</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
<strong class="list-group-item-heading">Rick Mathews</strong>
|
||||
<ul class="list-group list-group-flush list-group-item-text">
|
||||
<li class="list-group-item list-group-item-action">another filename.key</li>
|
||||
<li class="list-group-item list-group-item-action">my new file.pptx</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<br><br>
|
||||
|
||||
<div class="card">
|
||||
|
||||
<div class="card-header">Presentations:</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">File 1.txt</li>
|
||||
<li class="list-group-item">Filename 2.pptx</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<div class="list-group-item-heading"><strong>Scott Idem:</strong></div>
|
||||
<div class="list-group-item-text">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">File 1.txt</li>
|
||||
<li class="list-group-item">Filename 2.pptx</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
<div class="list-group-item-heading"><strong>Holly Danner:</strong></div>
|
||||
<div class="list-group-item-text">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">New File 1.txt</li>
|
||||
<li class="list-group-item">My Filename 2.pptx</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">Scott Idem:</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">File 1.txt</li>
|
||||
<li class="list-group-item">Filename 2.pptx</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">Holly Danner:</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">File 1.txt</li>
|
||||
<li class="list-group-item">Filename 2.pptx</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div> <!-- end row div -->
|
||||
|
||||
</div>
|
||||
<!--</main>--> <!-- /.container -->
|
||||
|
||||
|
||||
|
||||
<!-- JavaScript (JS) start -->
|
||||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.30.1/date_fns.min.js" integrity="sha256-wCBClaCr6pJ7sGU5kfb3gQMOOcIZNzaWpWcj/lD9Vfk=" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.15.3/axios.min.js" crossorigin></script>
|
||||
|
||||
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js" crossorigin></script>
|
||||
|
||||
<!--<script src="https://cdn.jsdelivr.net/npm/idb-keyval@3/dist/idb-keyval-iife.min.js"></script>-->
|
||||
<!--<script src="https://unpkg.com/dexie@latest/dist/dexie.js"></script>-->
|
||||
<script src="https://cdn.rawgit.com/mozilla/localForage/master/dist/localforage.js"></script>
|
||||
|
||||
<!--
|
||||
Using node.js may require this: npm install jquery, add script below.
|
||||
https://stackoverflow.com/questions/22658015/bootstrap-throws-uncaught-error-bootstraps-javascript-requires-jquery
|
||||
-->
|
||||
<!--
|
||||
<script>
|
||||
window.jQuery = window.$ = require('jquery');
|
||||
</script>
|
||||
-->
|
||||
|
||||
<!-- One Sky IT default custom JavaScript (JS) -->
|
||||
|
||||
<!-- 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 ui = require('./js/module_app_ui');</script>
|
||||
<!--<script src="js/api.js"></script>-->
|
||||
<!--<script src="js/script.js"></script>-->
|
||||
<!--<script src="js/testing.js"></script>-->
|
||||
|
||||
<script>
|
||||
let config = app.load_config();
|
||||
let event_id = config.event_id;
|
||||
let event_location_id = config.event_location_id;
|
||||
|
||||
const secret_key = config.api_secret_key;
|
||||
let api_temporary_token = null;
|
||||
|
||||
let api_base_url = null; // 'http://api.localhost:5001' 'https://api.oneskyit.com'
|
||||
|
||||
if (config.use_local_api) {
|
||||
api_base_url = config.api_local_base_url; // 'http://api.localhost:5001'
|
||||
} else {
|
||||
api_base_url = config.api_remote_base_url; // 'https://api.oneskyit.com'
|
||||
}
|
||||
|
||||
axios.defaults.baseURL = api_base_url;
|
||||
axios.defaults.headers.post['Access-Control-Allow-Origin'] = config.access_control_allow_origin; // '*';
|
||||
|
||||
api.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;
|
||||
return result;
|
||||
});
|
||||
|
||||
|
||||
let idb_name = config.idb_name;
|
||||
|
||||
if (window.indexedDB) {
|
||||
console.log('IndexedDB is supported');
|
||||
/*
|
||||
var tbl_event = new idbKeyval.Store(idb_name, 'event');
|
||||
var tbl_event_location = new idbKeyval.Store(idb_name, 'event_location');
|
||||
var tbl_event_session = new idbKeyval.Store(idb_name, 'event_session');
|
||||
var tbl_event_presentation = new idbKeyval.Store(idb_name, 'event_presentation');
|
||||
var tbl_event_presenter = new idbKeyval.Store(idb_name, 'event_presenter');
|
||||
var tbl_event_file = new idbKeyval.Store(idb_name, 'event_file');
|
||||
var tbl_hosted_file = new idbKeyval.Store(idb_name, 'hosted_file');
|
||||
*/
|
||||
} else {
|
||||
console.log('IndexedDB is NOT supported');
|
||||
close();
|
||||
}
|
||||
|
||||
localforage.config({
|
||||
driver: localforage.INDEXEDDB,
|
||||
version: 1,
|
||||
name: idb_name
|
||||
});
|
||||
|
||||
var tbl_event = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event',
|
||||
});
|
||||
var tbl_event_location = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_location',
|
||||
});
|
||||
var tbl_event_session = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_session',
|
||||
});
|
||||
var tbl_event_presentation = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_presentation',
|
||||
});
|
||||
var tbl_event_presenter = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_presenter',
|
||||
});
|
||||
var tbl_event_file = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_file',
|
||||
});
|
||||
var tbl_hosted_file = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'hosted_file',
|
||||
});
|
||||
|
||||
//tbl_event.setItem(Math.random().toString(), Math.random());
|
||||
//tbl_event_location.setItem('99', 'hello world 2');
|
||||
|
||||
//store.setItem("key", "value");
|
||||
//otherStore.setItem("key", "value2");
|
||||
|
||||
/*
|
||||
var db_test = indexedDB.open(idb_name, 1);
|
||||
var tbl_test = db_test.createObjectStore("tbl_test", "id", false);
|
||||
|
||||
idb_names = Dexie.getDatabaseNames();
|
||||
if (idb_names.length === 0) {
|
||||
console.log("No databases found.");
|
||||
} else {
|
||||
console.log(idb_names);
|
||||
for (var i in idb_names) {
|
||||
if (idb_names[i] == idb_name) {
|
||||
} else {
|
||||
var db = new Dexie(idb_name);
|
||||
db.version(1).stores({event: "id,name,test", event_location: "id,name,test2"});
|
||||
db.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
const main_loop_interval = config.main_loop_interval; //2000; // 2 seconds
|
||||
|
||||
const idb_check_period = config.idb_check_period; //30000; // 60 seconds
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the object check period into event, location, session, presentation, presenter
|
||||
let idb_check_datetime = Date.now(); // default to current datetime in ms
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the file check period into event, location, session, presentation, presenter
|
||||
let launcher_files_check_datetime = Date.now(); // default to current datetime in ms
|
||||
|
||||
const host_file_cache_path = config.host_file_cache_path; //'file_cache/';
|
||||
const host_file_cache_check_period = 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
|
||||
launcher.event_id = event_id;
|
||||
launcher.event_location_id = event_location_id;
|
||||
|
||||
//let launcher_cache_check_results = false;
|
||||
let launcher_render_results = false;
|
||||
|
||||
// Development variables:
|
||||
//let event_id = 14;
|
||||
//let event_location_id = 13;
|
||||
//let event_session_id = 827;
|
||||
//let event_presentation_id = 2002;
|
||||
//let event_presenter_id = 2539;
|
||||
//let event_file_id = 28;
|
||||
|
||||
setInterval(async function() {
|
||||
if (typeof axios.defaults.headers.common['Authorization'] !== 'undefined' && axios.defaults.headers.common['Authorization'] != null) {
|
||||
|
||||
current_datetime = Date.now();
|
||||
//let launcher_cache_check_results = false;
|
||||
|
||||
if (idb_check_datetime < current_datetime) {
|
||||
launcher_cache_check_results = idb.launcher_cache_check(launcher, api_base_url, api_temporary_token, host_file_cache_path);
|
||||
|
||||
launcher_cache_check_results.then(function (response) {
|
||||
console.log(launcher);
|
||||
idb_check_datetime = Date.now() + idb_check_period;
|
||||
|
||||
launcher_render_results = ui.launcher_render(launcher);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
console.log('Waiting '+main_loop_interval+'ms to see if Authorization header is set.');
|
||||
}
|
||||
}, main_loop_interval);
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//const custom_store = new idbKeyval.Store('custom_db', 'custom_store_name');
|
||||
//idbKeyval.set('foo', 'bar', custom_store);
|
||||
|
||||
</script>
|
||||
|
||||
<!-- <script src="js/launcher.js"></script>-->
|
||||
<!-- JavaScript (JS) end -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
557
app/index 2020-01-24.html.bak
Normal file
557
app/index 2020-01-24.html.bak
Normal file
@@ -0,0 +1,557 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<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>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="img/favicon.ico">
|
||||
|
||||
<!-- Cascading Style Sheets (CSS) start -->
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.4.1/materia/bootstrap.min.css" rel="stylesheet" integrity="sha384-1tymk6x9Y5K+OF0tlmG2fDRcn67QGzBkiM3IgtJ3VrtGrIi5ryhHjKjeeS60f1FA" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.10.2/css/all.css">
|
||||
|
||||
<!-- One Sky IT default custom Cascading Style Sheets (CSS) -->
|
||||
|
||||
<!-- 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">
|
||||
|
||||
<style>
|
||||
</style>
|
||||
<!-- Cascading Style Sheets (CSS) end -->
|
||||
|
||||
<!-- JavaScript (JS) start -->
|
||||
|
||||
<!-- JavaScript (JS) end -->
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!--<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">Launcher</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">
|
||||
*event files
|
||||
</div>
|
||||
<div id="location_files_menu" class="location_files_menu">
|
||||
*location files
|
||||
</div>
|
||||
<div id="sessions_menu" class="sessions_menu">
|
||||
*sessions<br>
|
||||
**session<br>
|
||||
***session files<br>
|
||||
***presentations<br>
|
||||
****presentation<br>
|
||||
*****presentation files<br>
|
||||
*****presenters<br>
|
||||
******presenter<br>
|
||||
*******presenter files<br>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="location_detail" class="location_detail col">
|
||||
<!--
|
||||
<div class="card">
|
||||
<div class="card-header">Session Files:</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item btn btn-info d-flex justify-content-between align-items-center">File 1.txt<span class="badge badge-pill badge-light">91.22 KB; Jul 7 6:12 AM; win</span></li>
|
||||
<li class="list-group-item btn btn-info d-flex justify-content-between align-items-center">NASPGHAN 2020: Not happening this is long Filename 2 Hello World Todays date here.pptx<span class="badge badge-pill badge-light">1.36 MB; Sep 9 7:17 AM; mac</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">Presentations:</div>
|
||||
<div class="card-body">
|
||||
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">
|
||||
<div class="list-group-item-heading">How do I best evaluate a cholestatic infant?</div>
|
||||
<div class="list-group-item-text">
|
||||
<ul class="list-group">
|
||||
|
||||
<li class="list-group-item list-group-item-action">Presentation File 1.txt</li>
|
||||
<li class="list-group-item list-group-item-action">Presentation File 2.pptx</li>
|
||||
<li class="list-group-item">
|
||||
<strong class="list-group-item-heading">Scott Idem</strong>
|
||||
<ul class="list-group list-group-flush list-group-item-text">
|
||||
<li class="list-group-item list-group-item-action">filename.pptx</li>
|
||||
<li class="list-group-item list-group-item-action">my new file.pptx</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
<strong class="list-group-item-heading">Holly Danner</strong>
|
||||
<ul class="list-group list-group-flush list-group-item-text">
|
||||
<li class="list-group-item list-group-item-action">another filename.key</li>
|
||||
<li class="list-group-item list-group-item-action">my new file.pptx</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
<strong class="list-group-item-heading">Rick Mathews</strong>
|
||||
<ul class="list-group list-group-flush list-group-item-text">
|
||||
<li class="list-group-item list-group-item-action">another filename.key</li>
|
||||
<li class="list-group-item list-group-item-action">my new file.pptx</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<div class="list-group-item-heading">Common Feeding Problems and Management Strategies in Autism Spectrum Disorder</div>
|
||||
<div class="list-group-item-text">
|
||||
<ul class="list-group">
|
||||
|
||||
<li class="list-group-item list-group-item-action">Presentation File 2.pptx</li>
|
||||
<li class="list-group-item">
|
||||
<strong class="list-group-item-heading">Scott Idem</strong>
|
||||
<ul class="list-group list-group-flush list-group-item-text">
|
||||
<li class="list-group-item list-group-item-action">filename.pptx</li>
|
||||
<li class="list-group-item list-group-item-action">my new file.pptx</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
<strong class="list-group-item-heading">Rick Mathews</strong>
|
||||
<ul class="list-group list-group-flush list-group-item-text">
|
||||
<li class="list-group-item list-group-item-action">another filename.key</li>
|
||||
<li class="list-group-item list-group-item-action">my new file.pptx</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<br><br>
|
||||
|
||||
<div class="card">
|
||||
|
||||
<div class="card-header">Presentations:</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">File 1.txt</li>
|
||||
<li class="list-group-item">Filename 2.pptx</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<div class="list-group-item-heading"><strong>Scott Idem:</strong></div>
|
||||
<div class="list-group-item-text">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">File 1.txt</li>
|
||||
<li class="list-group-item">Filename 2.pptx</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
<div class="list-group-item-heading"><strong>Holly Danner:</strong></div>
|
||||
<div class="list-group-item-text">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">New File 1.txt</li>
|
||||
<li class="list-group-item">My Filename 2.pptx</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">Scott Idem:</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">File 1.txt</li>
|
||||
<li class="list-group-item">Filename 2.pptx</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">Holly Danner:</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">File 1.txt</li>
|
||||
<li class="list-group-item">Filename 2.pptx</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
</div>
|
||||
</div> <!-- end row div -->
|
||||
|
||||
</div>
|
||||
<!--</main>--> <!-- /.container -->
|
||||
|
||||
|
||||
|
||||
<!-- JavaScript (JS) start -->
|
||||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.30.1/date_fns.min.js" integrity="sha256-wCBClaCr6pJ7sGU5kfb3gQMOOcIZNzaWpWcj/lD9Vfk=" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.15.3/axios.min.js" crossorigin></script>
|
||||
|
||||
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js" crossorigin></script>
|
||||
|
||||
<!--<script src="https://cdn.jsdelivr.net/npm/idb-keyval@3/dist/idb-keyval-iife.min.js"></script>-->
|
||||
<!--<script src="https://unpkg.com/dexie@latest/dist/dexie.js"></script>-->
|
||||
<script src="https://cdn.rawgit.com/mozilla/localForage/master/dist/localforage.js"></script>
|
||||
|
||||
<!--
|
||||
Using node.js may require this: npm install jquery, add script below.
|
||||
https://stackoverflow.com/questions/22658015/bootstrap-throws-uncaught-error-bootstraps-javascript-requires-jquery
|
||||
-->
|
||||
<!--
|
||||
<script>
|
||||
window.jQuery = window.$ = require('jquery');
|
||||
</script>
|
||||
-->
|
||||
|
||||
<!-- One Sky IT default custom JavaScript (JS) -->
|
||||
|
||||
<!-- 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 ui = require('./js/module_app_ui');</script>
|
||||
<!--<script src="js/api.js"></script>-->
|
||||
<!--<script src="js/script.js"></script>-->
|
||||
<!--<script src="js/testing.js"></script>-->
|
||||
|
||||
<script>
|
||||
let app_config = app.load_config();
|
||||
let account_id = app_config.account_id;
|
||||
let event_id = app_config.event_id;
|
||||
let event_location_id = app_config.event_location_id;
|
||||
|
||||
const secret_key = app_config.api_secret_key;
|
||||
let api_temporary_token = null;
|
||||
|
||||
let api_base_url = null; // 'http://api.localhost:5001' 'https://api.oneskyit.com'
|
||||
|
||||
if (app_config.use_local_api) {
|
||||
api_base_url = app_config.api_local_base_url; // 'http://api.localhost:5001'
|
||||
} else {
|
||||
api_base_url = app_config.api_remote_base_url; // 'https://api.oneskyit.com'
|
||||
}
|
||||
|
||||
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) {
|
||||
console.log('Setting temporary API token to axios Authorization header: '+result);
|
||||
axios.defaults.headers.common['Authorization'] = `Token ${result}`;
|
||||
api_temporary_token = result;
|
||||
return result;
|
||||
});
|
||||
|
||||
|
||||
let idb_name = app_config.idb_name;
|
||||
|
||||
if (window.indexedDB) {
|
||||
console.log('IndexedDB is supported');
|
||||
/*
|
||||
var tbl_event = new idbKeyval.Store(idb_name, 'event');
|
||||
var tbl_event_location = new idbKeyval.Store(idb_name, 'event_location');
|
||||
var tbl_event_session = new idbKeyval.Store(idb_name, 'event_session');
|
||||
var tbl_event_presentation = new idbKeyval.Store(idb_name, 'event_presentation');
|
||||
var tbl_event_presenter = new idbKeyval.Store(idb_name, 'event_presenter');
|
||||
var tbl_event_file = new idbKeyval.Store(idb_name, 'event_file');
|
||||
var tbl_hosted_file = new idbKeyval.Store(idb_name, 'hosted_file');
|
||||
*/
|
||||
} else {
|
||||
console.log('IndexedDB is NOT supported');
|
||||
close();
|
||||
}
|
||||
|
||||
localforage.config({
|
||||
driver: localforage.INDEXEDDB,
|
||||
version: 1,
|
||||
name: idb_name
|
||||
});
|
||||
|
||||
var tbl_event = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event',
|
||||
});
|
||||
var tbl_event_location = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_location',
|
||||
});
|
||||
var tbl_event_session = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_session',
|
||||
});
|
||||
var tbl_event_presentation = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_presentation',
|
||||
});
|
||||
var tbl_event_presenter = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_presenter',
|
||||
});
|
||||
var tbl_event_file = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_file',
|
||||
});
|
||||
var tbl_hosted_file = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'hosted_file',
|
||||
});
|
||||
|
||||
/*
|
||||
function tbl_check(value, key, iteration) {
|
||||
console.log(value);
|
||||
}
|
||||
|
||||
function tbl_check_success(result) {
|
||||
console.log(result);
|
||||
}
|
||||
function tbl_check_error(result) {
|
||||
console.log(result);
|
||||
}
|
||||
*/
|
||||
//console.log('Table data?');
|
||||
//console.log(tbl_event);
|
||||
//console.log('Table data? ^^^^');
|
||||
//tbl_event_session.iterate(tbl_check, tbl_check_success, tbl_check_error); //tbl_check(value, key, iteration)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//tbl_event.setItem(Math.random().toString(), Math.random());
|
||||
//tbl_event_location.setItem('99', 'hello world 2');
|
||||
|
||||
//store.setItem("key", "value");
|
||||
//otherStore.setItem("key", "value2");
|
||||
|
||||
/*
|
||||
var db_test = indexedDB.open(idb_name, 1);
|
||||
var tbl_test = db_test.createObjectStore("tbl_test", "id", false);
|
||||
|
||||
idb_names = Dexie.getDatabaseNames();
|
||||
if (idb_names.length === 0) {
|
||||
console.log("No databases found.");
|
||||
} else {
|
||||
console.log(idb_names);
|
||||
for (var i in idb_names) {
|
||||
if (idb_names[i] == idb_name) {
|
||||
} else {
|
||||
var db = new Dexie(idb_name);
|
||||
db.version(1).stores({event: "id,name,test", event_location: "id,name,test2"});
|
||||
db.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
//const main_loop_interval = app_config.main_loop_interval; //2000; // 2 seconds
|
||||
const main_loop_interval = 3000; //10000; // 10 seconds
|
||||
|
||||
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();
|
||||
|
||||
const idb_check_period = app_config.idb_check_period; //30000; // 60 seconds
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the object check period into event, location, session, presentation, presenter
|
||||
let idb_check_datetime = Date.now(); // default to current datetime in ms
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the file check period into event, location, session, presentation, presenter
|
||||
let launcher_files_check_datetime = Date.now(); // default to current datetime in ms
|
||||
|
||||
const host_file_cache_path = app_config.host_file_cache_path; //'file_cache/';
|
||||
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;
|
||||
let launcher_render_results = false;
|
||||
|
||||
// Development variables:
|
||||
//let account_id = 12;
|
||||
//let event_id = 14;
|
||||
//let event_location_id = 13;
|
||||
//let event_session_id = 827;
|
||||
//let event_presentation_id = 2002;
|
||||
//let event_presenter_id = 2539;
|
||||
//let event_file_id = 28;
|
||||
|
||||
|
||||
|
||||
setInterval(async function() {
|
||||
if (typeof axios.defaults.headers.common['Authorization'] !== 'undefined' && axios.defaults.headers.common['Authorization'] != null && true == true) {
|
||||
|
||||
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);
|
||||
for (var i in v2_account_events) {
|
||||
tbl_event.setItem(v2_account_events[i].id.toString(), v2_account_events[i]);
|
||||
}
|
||||
idb_event_check_datetime = Date.now() + idb_event_check_period;
|
||||
}
|
||||
|
||||
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);
|
||||
for (var i in v2_event_locations) {
|
||||
tbl_event_location.setItem(v2_event_locations[i].id.toString(), v2_event_locations[i]);
|
||||
}
|
||||
idb_event_location_check_datetime = Date.now() + idb_event_location_check_period;
|
||||
}
|
||||
|
||||
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);
|
||||
for (var i in v2_event_sessions) {
|
||||
tbl_event_session.setItem(v2_event_sessions[i].id.toString(), v2_event_sessions[i]);
|
||||
}
|
||||
idb_event_session_check_datetime = Date.now() + idb_event_session_check_period;
|
||||
}
|
||||
|
||||
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);
|
||||
for (var i in v2_event_presentations) {
|
||||
tbl_event_presentation.setItem(v2_event_presentations[i].id.toString(), v2_event_presentations[i]);
|
||||
}
|
||||
idb_event_presentation_check_datetime = Date.now() + idb_event_presentation_check_period;
|
||||
}
|
||||
|
||||
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);
|
||||
for (var i in v2_event_presenters) {
|
||||
tbl_event_presenter.setItem(v2_event_presenters[i].id.toString(), v2_event_presenters[i]);
|
||||
}
|
||||
idb_event_presenter_check_datetime = Date.now() + idb_event_presenter_check_period;
|
||||
}
|
||||
|
||||
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);
|
||||
for (var i in v2_event_files) {
|
||||
tbl_event_file.setItem(v2_event_files[i].event_file_id.toString(), v2_event_files[i]);
|
||||
}
|
||||
idb_event_file_check_datetime = Date.now() + idb_event_file_check_period;
|
||||
}
|
||||
|
||||
if (!idb_to_launcher_result) {
|
||||
console.log('index.html: v2 idb_to_launcher_result is false. Run idb_to_launcher. ***');
|
||||
idb_to_launcher_result = await idb.idb_to_launcher(launcher);
|
||||
console.log('index.html: v2 launcher object: ***');
|
||||
console.log(launcher);
|
||||
console.log('index.html: v2 launcher object: ^^^');
|
||||
|
||||
check_file_cache = idb.check_file_cache();
|
||||
} else {
|
||||
console.log('index.html: v2 idb_to_launcher result is true ***');
|
||||
|
||||
if (idb_check_datetime < current_datetime) {
|
||||
console.log('Render launcher...');
|
||||
launcher_render_results = await ui.launcher_render(launcher);
|
||||
idb_check_datetime = Date.now() + idb_check_period;
|
||||
} else {
|
||||
console.log('Waiting to render launcher again...');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
current_datetime = Date.now();
|
||||
//let launcher_cache_check_results = false;
|
||||
/*
|
||||
if (idb_check_datetime < current_datetime) {
|
||||
launcher_cache_check_results = idb.launcher_cache_check(launcher, api_base_url, api_temporary_token, host_file_cache_path);
|
||||
|
||||
launcher_cache_check_results.then(function (response) {
|
||||
console.log(launcher);
|
||||
idb_check_datetime = Date.now() + idb_check_period;
|
||||
|
||||
launcher_render_results = ui.launcher_render(launcher);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
} else {
|
||||
console.log('Waiting '+main_loop_interval+'ms to see if Authorization header is set.');
|
||||
}
|
||||
}, main_loop_interval);
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//const custom_store = new idbKeyval.Store('custom_db', 'custom_store_name');
|
||||
//idbKeyval.set('foo', 'bar', custom_store);
|
||||
|
||||
</script>
|
||||
|
||||
<!-- <script src="js/launcher.js"></script>-->
|
||||
<!-- JavaScript (JS) end -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
552
app/index.html
Normal file
552
app/index.html
Normal file
@@ -0,0 +1,552 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<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>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="img/favicon.ico">
|
||||
|
||||
<!-- Cascading Style Sheets (CSS) start -->
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.4.1/materia/bootstrap.min.css" rel="stylesheet" integrity="sha384-1tymk6x9Y5K+OF0tlmG2fDRcn67QGzBkiM3IgtJ3VrtGrIi5ryhHjKjeeS60f1FA" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.10.2/css/all.css">
|
||||
|
||||
<!-- One Sky IT default custom Cascading Style Sheets (CSS) -->
|
||||
|
||||
<!-- 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">
|
||||
|
||||
<style>
|
||||
</style>
|
||||
<!-- Cascading Style Sheets (CSS) end -->
|
||||
|
||||
<!-- JavaScript (JS) start -->
|
||||
|
||||
<!-- JavaScript (JS) end -->
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!--<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>
|
||||
|
||||
<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>
|
||||
|
||||
<div id="location_detail" class="location_detail col">
|
||||
|
||||
</div>
|
||||
</div> <!-- end row div -->
|
||||
|
||||
</div>
|
||||
<!--</main>--> <!-- /.container -->
|
||||
|
||||
|
||||
|
||||
<!-- JavaScript (JS) start -->
|
||||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.30.1/date_fns.min.js" integrity="sha256-wCBClaCr6pJ7sGU5kfb3gQMOOcIZNzaWpWcj/lD9Vfk=" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.15.3/axios.min.js" crossorigin></script>
|
||||
|
||||
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js" crossorigin></script>
|
||||
|
||||
<!--<script src="https://cdn.jsdelivr.net/npm/idb-keyval@3/dist/idb-keyval-iife.min.js"></script>-->
|
||||
<!--<script src="https://unpkg.com/dexie@latest/dist/dexie.js"></script>-->
|
||||
<script src="https://cdn.rawgit.com/mozilla/localForage/master/dist/localforage.js"></script>
|
||||
|
||||
<!--
|
||||
Using node.js may require this: npm install jquery, add script below.
|
||||
https://stackoverflow.com/questions/22658015/bootstrap-throws-uncaught-error-bootstraps-javascript-requires-jquery
|
||||
-->
|
||||
<!--
|
||||
<script>
|
||||
window.jQuery = window.$ = require('jquery');
|
||||
</script>
|
||||
-->
|
||||
|
||||
<!-- One Sky IT default custom JavaScript (JS) -->
|
||||
|
||||
<!-- 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 ui = require('./js/module_app_ui');</script>
|
||||
<!--<script src="js/api.js"></script>-->
|
||||
<!--<script src="js/script.js"></script>-->
|
||||
<!--<script src="js/testing.js"></script>-->
|
||||
|
||||
<script>
|
||||
let app_config = app.load_config();
|
||||
let account_id = app_config.account_id;
|
||||
let event_id = app_config.event_id;
|
||||
let event_location_id = app_config.event_location_id;
|
||||
|
||||
const secret_key = app_config.api_secret_key;
|
||||
let api_temporary_token = null;
|
||||
|
||||
let api_base_url = null; // 'http://api.localhost:5001' 'https://api.oneskyit.com'
|
||||
|
||||
if (app_config.use_local_api) {
|
||||
api_base_url = app_config.api_local_base_url; // 'http://api.localhost:5001'
|
||||
} else {
|
||||
api_base_url = app_config.api_remote_base_url; // 'https://api.oneskyit.com'
|
||||
}
|
||||
|
||||
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) {
|
||||
console.log('Setting temporary API token to axios Authorization header: '+result);
|
||||
axios.defaults.headers.common['Authorization'] = `Token ${result}`;
|
||||
api_temporary_token = result;
|
||||
return result;
|
||||
});
|
||||
|
||||
|
||||
let idb_name = app_config.idb_name;
|
||||
|
||||
if (window.indexedDB) {
|
||||
console.log('IndexedDB is supported');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
console.log('IndexedDB is NOT supported');
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
var tbl_event = null;
|
||||
var tbl_event_location = null;
|
||||
var tbl_event_session = null;
|
||||
var tbl_event_presentation = null;
|
||||
var tbl_event_presenter = null;
|
||||
var tbl_event_file = null;
|
||||
var tbl_hosted_file = null;
|
||||
|
||||
var tbl_event_key_count = null;
|
||||
var tbl_event_location_key_count = null;
|
||||
var tbl_event_session_key_count = null;
|
||||
var tbl_event_presentation_key_count = null;
|
||||
var tbl_event_presenter_key_count = null;
|
||||
var tbl_event_file_key_count = null;
|
||||
var tbl_hosted_file_key_count = null;
|
||||
|
||||
localforage.config({
|
||||
driver: localforage.INDEXEDDB,
|
||||
version: 1,
|
||||
name: idb_name
|
||||
});
|
||||
|
||||
var tbl_event = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event',
|
||||
});
|
||||
tbl_event.length().then(function(key_count) {
|
||||
console.log('tbl_event count: '+key_count);
|
||||
tbl_event_key_count = key_count;
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
var tbl_event_location = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_location',
|
||||
});
|
||||
tbl_event_location.length().then(function(key_count) {
|
||||
tbl_event_location_key_count = key_count;
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
var tbl_event_session = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_session',
|
||||
});
|
||||
tbl_event_session.length().then(function(key_count) {
|
||||
tbl_event_session_key_count = key_count;
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
var tbl_event_presentation = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_presentation',
|
||||
});
|
||||
tbl_event_presentation.length().then(function(key_count) {
|
||||
tbl_event_presentation_key_count = key_count;
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
var tbl_event_presenter = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_presenter',
|
||||
});
|
||||
tbl_event_presenter.length().then(function(key_count) {
|
||||
tbl_event_presenter_key_count = key_count;
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
var tbl_event_file = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'event_file',
|
||||
});
|
||||
tbl_event_file.length().then(function(key_count) {
|
||||
console.log('tbl_event_file count: '+key_count);
|
||||
tbl_event_file_key_count = key_count;
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
/*
|
||||
var tbl_hosted_file = localforage.createInstance({
|
||||
name: idb_name,
|
||||
storeName: 'hosted_file',
|
||||
});
|
||||
tbl_hosted_file.length().then(function(key_count) {
|
||||
tbl_hosted_file_key_count = key_count;
|
||||
}).catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
*/
|
||||
|
||||
//let create_load_idb_result = idb.create_load_idb();
|
||||
|
||||
//console.log(tbl_event_session_key_count);
|
||||
|
||||
/*
|
||||
// Check if table exists by trying to interate.
|
||||
function tbl_check(value, key, iteration) {
|
||||
console.log(value);
|
||||
}
|
||||
function tbl_check_success(result) {
|
||||
console.log(result);
|
||||
}
|
||||
function tbl_check_error(result) {
|
||||
console.log(result);
|
||||
}
|
||||
tbl_event_session.iterate(tbl_check, tbl_check_success, tbl_check_error); //tbl_check(value, key, iteration)
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const loading_loop_interval = 500;
|
||||
//const main_loop_interval = app_config.main_loop_interval; //2000; // 2 seconds
|
||||
const main_loop_interval = 1500; //10000; // 10 seconds
|
||||
|
||||
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();
|
||||
|
||||
const idb_check_period = app_config.idb_check_period; //30000; // 60 seconds
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the object check period into event, location, session, presentation, presenter
|
||||
let idb_check_datetime = Date.now(); // default to current datetime in ms
|
||||
// The datetime is when it should be checked again, not when it was last checked.
|
||||
// It may be good to split the file check period into event, location, session, presentation, presenter
|
||||
let launcher_files_check_datetime = Date.now(); // default to current datetime in ms
|
||||
|
||||
const host_file_cache_path = app_config.host_file_cache_path; //'file_cache/';
|
||||
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;
|
||||
let launcher_render_results = false;
|
||||
|
||||
let run_idb_to_launcher = false;
|
||||
let run_check_file_cache = false;
|
||||
let run_render_launcher = false;
|
||||
|
||||
let axios_headers_set = false;
|
||||
let idb_tables_opened = false;
|
||||
let idb_tables_have_records = false;
|
||||
|
||||
// Development variables:
|
||||
//let account_id = 12;
|
||||
//let event_id = 14;
|
||||
//let event_location_id = 13;
|
||||
//let event_session_id = 827;
|
||||
//let event_presentation_id = 2002;
|
||||
//let event_presenter_id = 2539;
|
||||
//let event_file_id = 28;
|
||||
|
||||
//console.log(tbl_event_session);
|
||||
//console.log(tbl_event_file);
|
||||
|
||||
/*
|
||||
while (!axios_headers_set && !idb_tables_opened && !idb_tables_have_records) {
|
||||
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.');
|
||||
} 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.');
|
||||
}
|
||||
|
||||
//someanimation();
|
||||
setTimeout(function(){
|
||||
console.log('looping....');
|
||||
}, 250);
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
// NOTE This loop needs to end at some point...
|
||||
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.');
|
||||
} 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);
|
||||
|
||||
|
||||
|
||||
setInterval(async function() {
|
||||
if (axios_headers_set && idb_tables_opened && idb_tables_have_records) {
|
||||
|
||||
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);
|
||||
for (var i in v2_account_events) {
|
||||
tbl_event.setItem(v2_account_events[i].id.toString(), v2_account_events[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
idb_event_check_datetime = Date.now() + idb_event_check_period;
|
||||
}
|
||||
|
||||
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);
|
||||
for (var i in v2_event_locations) {
|
||||
tbl_event_location.setItem(v2_event_locations[i].id.toString(), v2_event_locations[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
idb_event_location_check_datetime = Date.now() + idb_event_location_check_period;
|
||||
}
|
||||
|
||||
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);
|
||||
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
|
||||
idb_event_session_check_datetime = Date.now() + idb_event_session_check_period;
|
||||
}
|
||||
|
||||
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);
|
||||
for (var i in v2_event_presentations) {
|
||||
tbl_event_presentation.setItem(v2_event_presentations[i].id.toString(), v2_event_presentations[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
idb_event_presentation_check_datetime = Date.now() + idb_event_presentation_check_period;
|
||||
}
|
||||
|
||||
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);
|
||||
for (var i in v2_event_presenters) {
|
||||
tbl_event_presenter.setItem(v2_event_presenters[i].id.toString(), v2_event_presenters[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
idb_event_presenter_check_datetime = Date.now() + idb_event_presenter_check_period;
|
||||
}
|
||||
|
||||
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);
|
||||
for (var i in v2_event_files) {
|
||||
tbl_event_file.setItem(v2_event_files[i].event_file_id.toString(), v2_event_files[i]);
|
||||
}
|
||||
run_idb_to_launcher = true; // Set to true so that the launcher object is rebuilt
|
||||
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;
|
||||
}
|
||||
|
||||
if (run_idb_to_launcher) {
|
||||
console.log('Flag to run idb_to_launcher has been set to true.');
|
||||
idb_to_launcher_result = idb.idb_to_launcher(launcher);
|
||||
|
||||
idb_to_launcher_result.then(function (response) {
|
||||
console.log('Launcher object has now been updated.');
|
||||
console.log(launcher);
|
||||
|
||||
run_idb_to_launcher = false;
|
||||
run_render_launcher = true; // Set to true so that the launcher will be rendered again
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (run_check_file_cache) {
|
||||
console.log('Flag to run check_file_cache has been set to true.');
|
||||
check_file_cache_result = idb.check_file_cache();
|
||||
|
||||
check_file_cache_result.then(function (response) {
|
||||
console.log('Cached files have now been updated.');
|
||||
run_check_file_cache = false;
|
||||
});
|
||||
}
|
||||
|
||||
if (run_render_launcher) {
|
||||
console.log('Flag to run render_launcher has been set to true.');
|
||||
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.');
|
||||
run_render_launcher = false;
|
||||
});
|
||||
*/
|
||||
// NOTE This is a terrible way to work around the page refreshing and blanking out.
|
||||
setTimeout(() => {
|
||||
render_launcher_result = ui.render_launcher(launcher_tmp);
|
||||
|
||||
render_launcher_result.then(function (response) {
|
||||
console.log('The launcher has now been rendered.');
|
||||
run_render_launcher = false;
|
||||
});
|
||||
}, 100);
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
else {
|
||||
console.log('index.html: v2 idb_to_launcher result is true ***');
|
||||
|
||||
if (idb_check_datetime < Date.now()) {
|
||||
console.log('Render launcher...');
|
||||
launcher_render_results = await ui.launcher_render(launcher);
|
||||
idb_check_datetime = Date.now() + idb_check_period;
|
||||
} else {
|
||||
console.log('Waiting to render launcher again...');
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
current_datetime = Date.now();
|
||||
//let launcher_cache_check_results = false;
|
||||
/*
|
||||
if (idb_check_datetime < current_datetime) {
|
||||
launcher_cache_check_results = idb.launcher_cache_check(launcher, api_base_url, api_temporary_token, host_file_cache_path);
|
||||
|
||||
launcher_cache_check_results.then(function (response) {
|
||||
console.log(launcher);
|
||||
idb_check_datetime = Date.now() + idb_check_period;
|
||||
|
||||
launcher_render_results = ui.launcher_render(launcher);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
} 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);
|
||||
|
||||
}
|
||||
}, main_loop_interval);
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//const custom_store = new idbKeyval.Store('custom_db', 'custom_store_name');
|
||||
//idbKeyval.set('foo', 'bar', custom_store);
|
||||
|
||||
</script>
|
||||
|
||||
<!-- <script src="js/launcher.js"></script>-->
|
||||
<!-- JavaScript (JS) end -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
1
app/js/app_helper.js
Normal file
1
app/js/app_helper.js
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
413
app/js/app_idb 2020-01-09.js.bak
Normal file
413
app/js/app_idb 2020-01-09.js.bak
Normal file
@@ -0,0 +1,413 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const { ipcRenderer } = require('electron');
|
||||
|
||||
|
||||
exports.launcher_cache_check = async function (launcher, api_base_url, api_temporary_token, host_file_cache_path) {
|
||||
if (typeof launcher.event === 'undefined') {
|
||||
launcher.event = await api.get_event_details(axios, launcher.event_id);
|
||||
console.log(launcher.event.id);
|
||||
idbKeyval.set(launcher.event.id, launcher.event, tbl_event);
|
||||
/*
|
||||
.then(function (data) {
|
||||
console.log(data.id);
|
||||
idbKeyval.set(data.id, data, tbl_event);
|
||||
//for (var i in response) {
|
||||
//var event_record = data[i];
|
||||
//idbKeyval.set(response[i].id, response[i], tbl_event);
|
||||
//}
|
||||
});
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
if (typeof launcher.location === 'undefined') {
|
||||
launcher.location = await api.get_event_location_details(axios, launcher.event_id, launcher.event_location_id);
|
||||
}
|
||||
|
||||
if (typeof launcher.event_files === 'undefined') {
|
||||
console.log('Check for global event files.');
|
||||
let for_id = launcher.event_id;
|
||||
launcher.event_files = await api.get_files_for_type_for_id(axios, 'event', for_id);
|
||||
for (var i in launcher.event_files) {
|
||||
console.log('f: ('+launcher.event_files[i].event_file_id+') '+launcher.event_files[i].event_file_filename+' ***')
|
||||
file_id = launcher.event_files[i].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.event_files[i].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('No check for global event files');
|
||||
}
|
||||
|
||||
|
||||
if (typeof launcher.location_files === 'undefined') {
|
||||
console.log('Check for location specific files.');
|
||||
let for_id = launcher.event_location_id;
|
||||
launcher.location_files = await api.get_files_for_type_for_id(axios, 'location', for_id);
|
||||
for (var i in launcher.location_files) {
|
||||
console.log('f: ('+launcher.location_files[i].event_file_id+') '+launcher.location_files[i].event_file_filename+' ***')
|
||||
file_id = launcher.location_files[i].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.location_files[i].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('No check for location specific files.');
|
||||
}
|
||||
|
||||
|
||||
if (typeof launcher.sessions === 'undefined') {
|
||||
console.log('Check for location sessions.');
|
||||
launcher.sessions = await api.get_event_location_sessions(axios, launcher.event_id, launcher.event_location_id);
|
||||
for (var i in launcher.sessions) {
|
||||
console.log('*** '+launcher.sessions[i].name+' ***')
|
||||
|
||||
// Check for session files start
|
||||
if (typeof launcher.sessions[i].files === 'undefined') {
|
||||
console.log('Check for session files.');
|
||||
let for_id = launcher.sessions[i].id;
|
||||
launcher.sessions[i].files = await api.get_files_for_type_for_id(axios, 'session', for_id);
|
||||
if (launcher.sessions[i].files) {
|
||||
console.log('Session files found.');
|
||||
for (var j in launcher.sessions[i].files) {
|
||||
console.log('f: ('+launcher.sessions[i].files[j].event_file_id+') '+launcher.sessions[i].files[j].event_file_filename+' ***');
|
||||
file_id = launcher.sessions[i].files[j].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.sessions[i].files[j].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('No session files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for session files.');
|
||||
}
|
||||
// Check for session files end
|
||||
|
||||
// Get session presentations and associated files
|
||||
launcher.sessions[i].presentations = await api.get_session_presentations(axios, launcher.event_id, launcher.sessions[i].id);
|
||||
for (var j in launcher.sessions[i].presentations) {
|
||||
console.log('* '+launcher.sessions[i].presentations[j].name);
|
||||
|
||||
// Check for presentation files start
|
||||
if (typeof launcher.sessions[i].presentations[j].files === 'undefined') {
|
||||
console.log('Check for presentation files.');
|
||||
let for_id = launcher.sessions[i].presentations[j].id;
|
||||
launcher.sessions[i].presentations[j].files = await api.get_files_for_type_for_id(axios, 'presentation', for_id);
|
||||
if (launcher.sessions[i].presentations[j].files) {
|
||||
console.log('Presentation files found.');
|
||||
for (var k in launcher.sessions[i].presentations[j].files) {
|
||||
console.log('f: ('+launcher.sessions[i].presentations[j].files[k].event_file_id+') '+launcher.sessions[i].presentations[j].files[k].event_file_filename+' ***');
|
||||
file_id = launcher.sessions[i].presentations[j].files[k].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.sessions[i].presentations[j].files[k].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('No presentation files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for presentation files.');
|
||||
}
|
||||
// Check for presentation files end
|
||||
|
||||
|
||||
// Get session presentations presenters and associated files
|
||||
//let event_presentation_id = launcher.sessions[i].presentations[j].id;
|
||||
launcher.sessions[i].presentations[j].presenters = await api.get_presentation_presenters(axios, launcher.event_id, launcher.sessions[i].id, launcher.sessions[i].presentations[j].id);
|
||||
for (var k in launcher.sessions[i].presentations[j].presenters) {
|
||||
console.log('-- '+launcher.sessions[i].presentations[j].presenters[k].given_name+' '+launcher.sessions[i].presentations[j].presenters[k].family_name)
|
||||
|
||||
// Check for presenter files start
|
||||
if (typeof launcher.sessions[i].presentations[j].presenters[k].files === 'undefined') {
|
||||
console.log('Check for presenter files.');
|
||||
let for_id = launcher.sessions[i].presentations[j].presenters[k].id;
|
||||
launcher.sessions[i].presentations[j].presenters[k].files = await api.get_files_for_type_for_id(axios, 'presenter', for_id);
|
||||
if (launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
console.log('Presenter files found.');
|
||||
for (var l in launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
console.log('f: ('+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id+') '+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+' ***')
|
||||
file_id = launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.sessions[i].presentations[j].presenters[k].files[l].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('No presenter files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for presenter files.');
|
||||
}
|
||||
// Check for presenter files end
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('No check for location sessions.');
|
||||
}
|
||||
|
||||
console.log('Location cache check finished.');
|
||||
return true;
|
||||
}
|
||||
|
||||
exports.launcher_render = async function (launcher) {
|
||||
console.log('Rendering launcher...');
|
||||
document.getElementById('location_title').innerHTML = '<h1>Launcher '+launcher.location.name+'@'+launcher.event.name+'</h1>';
|
||||
|
||||
document.getElementById('event_files_menu').innerHTML = '<h2>Event Files</h2>';
|
||||
document.getElementById('event_files_menu').innerHTML += '<ul class="">';
|
||||
for (var i in launcher.event_files) {
|
||||
document.getElementById('event_files_menu').innerHTML += '<li id="menu_event_file_id_'+launcher.event_files[i].id+'" class="btn btn-info btn_no_case open_local_file" data-hash_sha256="'+launcher.event_files[i].hash_sha256+'.file" data-filename="'+launcher.event_files[i].event_file_filename+'">'+launcher.event_files[i].event_file_filename+'</li>';
|
||||
}
|
||||
document.getElementById('event_files_menu').innerHTML += '</ul>';
|
||||
|
||||
document.getElementById('location_files_menu').innerHTML = '<h2>Location Files</h2>';
|
||||
document.getElementById('location_files_menu').innerHTML += '<ul class="" role="">';
|
||||
for (var i in launcher.location_files) {
|
||||
document.getElementById('location_files_menu').innerHTML += '<li id="menu_event_file_id_'+launcher.location_files[i].id+'" class="btn btn-info open_local_file" data-hash_sha256="'+launcher.location_files[i].hash_sha256+'.file" data-filename="'+launcher.location_files[i].event_file_filename+'">'+launcher.location_files[i].event_file_filename+'</li>';
|
||||
}
|
||||
document.getElementById('location_files_menu').innerHTML += '</ul>';
|
||||
|
||||
document.getElementById('sessions_menu').innerHTML = '<h2>Sessions</h2>';
|
||||
document.getElementById('sessions_menu').innerHTML += '<ul class="" role="">';
|
||||
//let location_detail = '';
|
||||
if (document.getElementById('location_detail').innerHTML.length) {
|
||||
console.log('detail_session_id_xx already exists');
|
||||
} else {
|
||||
console.log('location_detail already populated');
|
||||
document.getElementById('location_detail').innerHTML = ''; // This needs to be reviewed.
|
||||
}
|
||||
for (var i in launcher.sessions) {
|
||||
// List sessions in menu
|
||||
document.getElementById('sessions_menu').innerHTML += '<li id="menu_session_id_'+launcher.sessions[i].id+'" class="btn btn-info btn_view_session" data-session_id="'+launcher.sessions[i].id+'">'+launcher.sessions[i].name+'</li>';
|
||||
|
||||
// Create containers for each session
|
||||
let session_detail = '';
|
||||
|
||||
if (typeof(document.getElementById('detail_session_id_'+launcher.sessions[i].id)) != 'undefined' && document.getElementById('detail_session_id_'+launcher.sessions[i].id) != null) {
|
||||
//console.log('detail_session_id_xx already exists');
|
||||
} else {
|
||||
//console.log('Adding detail_session_id_xx');
|
||||
session_detail += '<div id="detail_session_id_'+launcher.sessions[i].id+'" class="container d-none session_detail" data-session_id="'+launcher.sessions[i].id+'">';
|
||||
}
|
||||
|
||||
|
||||
|
||||
var session_startdatetime = new Date(launcher.sessions[i].start_datetime);
|
||||
|
||||
session_detail += '<h2 class="session_title">'+launcher.sessions[i].name+'<span class="badge badge-pill badge-info float-right">'+dateFns.format(session_startdatetime, 'ddd h:mm A')+'</span>'+'</h2>';
|
||||
|
||||
|
||||
//session_detail += '<div class="">'; // for card-group
|
||||
|
||||
session_detail += '<div class="card">';
|
||||
session_detail += '<div class="card-header">Session Files:</div>';
|
||||
session_detail += '<div class="card-body">';
|
||||
|
||||
session_detail += '<ul>';
|
||||
for (var j in launcher.sessions[i].files) {
|
||||
//console.log(launcher.sessions[i].files[j].event_file_filename);
|
||||
session_detail += '<li class="btn btn-info open_local_file" data-hash_sha256="'+launcher.sessions[i].files[j].hash_sha256+'.file" data-filename="'+launcher.sessions[i].files[j].event_file_filename+'">'+launcher.sessions[i].files[j].event_file_filename+'</li>';
|
||||
}
|
||||
session_detail += '</ul>';
|
||||
|
||||
session_detail += '</div>'; // for card-body
|
||||
session_detail += '</div> <!-- for session files card -->'; // for session files card
|
||||
|
||||
|
||||
//session_detail += '<div class="session_presentations">';
|
||||
|
||||
for (var j in launcher.sessions[i].presentations) {
|
||||
//session_detail += '<li>'+launcher.sessions[i].presentations[j].name;
|
||||
|
||||
var session_presentation_startdatetime = new Date(launcher.sessions[i].presentations[j].start_datetime);
|
||||
|
||||
session_detail += '<div class="card">';
|
||||
session_detail += '<div class="card-header">'+launcher.sessions[i].presentations[j].name+'<span class="badge badge-pill badge-info float-right">'+dateFns.format(session_startdatetime, 'h:mm a')+'</span>'+':</div>';
|
||||
session_detail += '<div class="card-body">';
|
||||
|
||||
session_detail += '<ul class="list-group">';
|
||||
for (var k in launcher.sessions[i].presentations[j].files) {
|
||||
//console.log(launcher.sessions[i].presentations[j].files[k].event_file_filename);
|
||||
session_detail += '<li class="list-group-item btn btn-info open_local_file" data-hash_sha256="'+launcher.sessions[i].presentations[j].files[k].hash_sha256+'.file" data-filename="'+launcher.sessions[i].presentations[j].files[k].event_file_filename+'">'+launcher.sessions[i].presentations[j].files[k].event_file_filename+'</li>';
|
||||
}
|
||||
session_detail += '</ul>';
|
||||
|
||||
|
||||
session_detail += '<ul>';
|
||||
for (var k in launcher.sessions[i].presentations[j].presenters) {
|
||||
//console.log(launcher.sessions[i].presentations[j].presenters[k].given_name);
|
||||
session_detail += '<li>'+launcher.sessions[i].presentations[j].presenters[k].given_name+' '+launcher.sessions[i].presentations[j].presenters[k].family_name;
|
||||
|
||||
session_detail += '<ul class="list-group">';
|
||||
for (var l in launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
//console.log(launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename);
|
||||
//session_detail += '<li class="list-group-item" data-hash_sha256="'+launcher.sessions[i].presentations[j].presenters[k].files[l].hash_sha256+'.file" data-filename="'+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+'">'+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename;
|
||||
session_detail += '<li class="list-group-item" data-hash_sha256="'+launcher.sessions[i].presentations[j].presenters[k].files[l].hash_sha256+'.file" data-filename="'+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+'">';
|
||||
session_detail += '<button class="btn btn-info open_local_file" data-hash_sha256="'+launcher.sessions[i].presentations[j].presenters[k].files[l].hash_sha256+'.file" data-filename="'+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+'">'+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+'</button>';
|
||||
|
||||
var event_file_size = launcher.sessions[i].presentations[j].presenters[k].files[l].size;
|
||||
var event_file_created_on = new Date(launcher.sessions[i].presentations[j].presenters[k].files[l].created_on);
|
||||
|
||||
session_detail += '<span class="badge badge-pill badge-light float-right">'+format_bytes(event_file_size, 2)+'; '+dateFns.format(event_file_created_on, 'MMM M h:mm A')+'; '+launcher.sessions[i].presentations[j].presenters[k].files[l].internal_os+'</span>';
|
||||
|
||||
|
||||
session_detail += '</li>';
|
||||
}
|
||||
session_detail += '</ul>';
|
||||
|
||||
session_detail +='</li>';
|
||||
}
|
||||
session_detail += '</ul>';
|
||||
|
||||
|
||||
session_detail += '</ul>';
|
||||
session_detail += '</div>'; // for card-body
|
||||
session_detail += '</div> <!-- for card -->'; // for card
|
||||
|
||||
}
|
||||
//session_detail += '</div> <!-- for session_presentations -->'; // for session_presentations
|
||||
|
||||
//session_detail += '</div>'; // for card-group
|
||||
session_detail += '</div> <!-- End session detail for '+launcher.sessions[i].id+' -->';
|
||||
|
||||
|
||||
//document.getElementById('location_detail').innerHTML += session_detail;
|
||||
|
||||
if (typeof(document.getElementById('detail_session_id_'+launcher.sessions[i].id)) != 'undefined' && document.getElementById('detail_session_id_'+launcher.sessions[i].id) != null) {
|
||||
document.getElementById('detail_session_id_'+launcher.sessions[i].id).innerHTML = session_detail;
|
||||
} else {
|
||||
document.getElementById('location_detail').innerHTML += session_detail;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
document.getElementById('sessions_menu').innerHTML += '</ul>';
|
||||
|
||||
index_location_detail('btn_view_session');
|
||||
|
||||
index_open_file_buttons('open_local_file');
|
||||
|
||||
|
||||
//const btn_session_{{ event_presentation.id }}_name = document.querySelector('button#presentation_{{ event_presentation.id }}_name');
|
||||
//btn_presentation_{{ event_presentation.id }}_name.onclick = display_hide_poster_for_type_id.bind(this, true, 'presentation', {{ event_presentation.id }});
|
||||
console.log('Rendering launcher finished.');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Updated 2019-12-19 */
|
||||
function index_location_detail(class_name) {
|
||||
var class_elements = document.getElementsByClassName(class_name);
|
||||
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
class_elements[i].addEventListener( 'click', function() {view_session( this.getAttribute('data-session_id')) } );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Updated 2019-12-19 */
|
||||
function view_session(session_id) {
|
||||
var class_elements = document.getElementsByClassName('session_detail');
|
||||
console.log('*** Session ID: '+session_id);
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
console.log('*** checking: '+class_elements[i].getAttribute('data-session_id'));
|
||||
if (class_elements[i].getAttribute('data-session_id') == session_id) {
|
||||
console.log('show');
|
||||
class_elements[i].classList.remove('d-none');
|
||||
class_elements[i].classList.add('d-block');
|
||||
} else {
|
||||
console.log('hide');
|
||||
class_elements[i].classList.remove('d-block');
|
||||
class_elements[i].classList.add('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Updated 2019-12-20 */
|
||||
function index_open_file_buttons(class_name) {
|
||||
var class_elements = document.getElementsByClassName(class_name);
|
||||
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
//class_elements[i].addEventListener( 'click', function() {open_local_file( this.getAttribute('data-filename')) } );
|
||||
|
||||
//let directory = 'file_cache/';
|
||||
|
||||
//directory_and_filename = path.join(directory, class_elements[i].getAttribute('data-filename'));
|
||||
|
||||
let file_path = path.join(host_file_cache_path, class_elements[i].getAttribute('data-hash_sha256'));
|
||||
let filename = class_elements[i].getAttribute('data-filename');
|
||||
|
||||
class_elements[i].addEventListener( 'click', function() { ipcRenderer.send('open_local_file', file_path, filename) } );
|
||||
//ipcRenderer.send('open_local_file', this.getAttribute('data-filename')); // in render thread
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function format_bytes(bytes, decimals = 2) {
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
|
||||
const k = 1024;
|
||||
const dm = decimals < 0 ? 0 : decimals;
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
||||
}
|
||||
589
app/js/hold api.js
Normal file
589
app/js/hold api.js
Normal file
@@ -0,0 +1,589 @@
|
||||
async function api_token_request_async() {
|
||||
//var api_temporary_token = '';
|
||||
axios.defaults.baseURL = 'http://api.localhost:5001'; // 'http://api.localhost:5001' 'https://api.oneskyit.com';
|
||||
//axios.defaults.headers.post['Content-Type'] ='application/json;charset=utf-8';
|
||||
axios.defaults.headers.post['Access-Control-Allow-Origin'] = '*';
|
||||
//axios.defaults.headers.common['Authorization'] = `Token ${api_temporary_token}`
|
||||
|
||||
url = '/api_token_request';
|
||||
|
||||
let data = { secret_key: 'YWAAk39H2qH0edK6lPH0yg' };
|
||||
|
||||
//console.log(data);
|
||||
|
||||
try {
|
||||
const response = await axios.post(url, data);
|
||||
console.log(response);
|
||||
api_temporary_token = response.data.temporary_token;
|
||||
axios.defaults.headers.common['Authorization'] = `Token ${api_temporary_token}`;
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
function api_token_request_sync() {
|
||||
var api_temporary_token = '';
|
||||
axios.defaults.baseURL = 'http://api.localhost:5001'; // 'http://api.localhost:5001' 'https://api.oneskyit.com';
|
||||
//axios.defaults.headers.post['Content-Type'] ='application/json;charset=utf-8';
|
||||
axios.defaults.headers.post['Access-Control-Allow-Origin'] = '*';
|
||||
//axios.defaults.headers.common['Authorization'] = `Token ${api_temporary_token}`
|
||||
|
||||
url = '/api_token_request';
|
||||
|
||||
let data = { secret_key: 'YWAAk39H2qH0edK6lPH0yg' };
|
||||
|
||||
console.log(data);
|
||||
|
||||
axios.post(url, data)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
api_temporary_token = response.data.temporary_token;
|
||||
axios.defaults.headers.common['Authorization'] = `Token ${api_temporary_token}`;
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
function get_all_events() {
|
||||
url = '/event';
|
||||
|
||||
let data = { };
|
||||
|
||||
//console.log(data);
|
||||
|
||||
axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
|
||||
if (response.data != null) {
|
||||
records = response.data;
|
||||
|
||||
let html = '';
|
||||
html += '<select>';
|
||||
for (var i in records) {
|
||||
html += '<option value="'+records[i].id+'">'+records[i].name+'</option>'
|
||||
}
|
||||
html += '</select>';
|
||||
|
||||
/*
|
||||
role_table = '<table class="table table-striped table-bordered results_table">';
|
||||
role_table += '<tr><th>Name</th><th>For Type</th><th>For ID</th><th>Disable</th><th>Enable On</th><th>Disable On</th><th>Notes</th><th>Created On</th><th>Updated On</th></tr>';
|
||||
|
||||
for (var i in records) {
|
||||
|
||||
role_table += '<tr>';
|
||||
role_table += '<td>'+records[i].name+'</td>';
|
||||
role_table += '<td>'+records[i].for_type+'</td>';
|
||||
role_table += '<td>'+records[i].for_id+'</td>';
|
||||
role_table += '<td>'+records[i].disable+'</td>';
|
||||
role_table += '<td>'+records[i].enable_on+'</td>';
|
||||
role_table += '<td>'+records[i].disable_on+'</td>';
|
||||
role_table += '<td>'+records[i].notes+'</td>';
|
||||
role_table += '<td>'+records[i].created_on+'</td>';
|
||||
role_table += '<td>'+records[i].updated_on+'</td>';
|
||||
role_table += '</tr>';
|
||||
}
|
||||
|
||||
role_table += '</table>';
|
||||
*/
|
||||
|
||||
document.getElementById('events').innerHTML = html;
|
||||
} else {
|
||||
document.getElementById('events').innerHTML = 'No events found.';
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function get_event(event_id) {
|
||||
url = '/event/'+event_id;
|
||||
|
||||
let data = { };
|
||||
|
||||
//console.log(data);
|
||||
|
||||
axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
|
||||
if (response.data != null) {
|
||||
record = response.data;
|
||||
|
||||
let html = '';
|
||||
html += '<div>';
|
||||
html += record.name;
|
||||
html += '</div>';
|
||||
|
||||
document.getElementById('event').innerHTML = html;
|
||||
} else {
|
||||
document.getElementById('event').innerHTML = 'Event not found.';
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function get_event_locations(event_id) {
|
||||
url = '/event/'+event_id+'/location';
|
||||
|
||||
let data = { };
|
||||
|
||||
//console.log(data);
|
||||
|
||||
axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
|
||||
if (response.data != null) {
|
||||
records = response.data;
|
||||
|
||||
let html = '';
|
||||
html += '<ul>';
|
||||
for (var i in records) {
|
||||
html += '<li>'+records[i].name+'</li>'
|
||||
}
|
||||
html += '</ul>';
|
||||
|
||||
document.getElementById('event_locations').innerHTML = html;
|
||||
} else {
|
||||
document.getElementById('event_locations').innerHTML = 'Event locations not found.';
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function get_event_location(event_id, event_location_id) {
|
||||
url = '/event/'+event_id+'/location/'+event_location_id;
|
||||
|
||||
let data = { };
|
||||
|
||||
//console.log(data);
|
||||
|
||||
axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
|
||||
if (response.data != null) {
|
||||
record = response.data;
|
||||
|
||||
let html = '';
|
||||
html += '<div>';
|
||||
html += record.name;
|
||||
html += '</div>';
|
||||
|
||||
document.getElementById('event_location').innerHTML = html;
|
||||
} else {
|
||||
document.getElementById('event_location').innerHTML = 'Event location not found.';
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function get_event_location_sessions(event_id, event_location_id) {
|
||||
url = '/event/'+event_id+'/location/'+event_location_id+'/session';
|
||||
|
||||
let data = { };
|
||||
|
||||
//console.log(data);
|
||||
|
||||
axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
|
||||
if (response.data != null) {
|
||||
record = response.data;
|
||||
|
||||
let html = '';
|
||||
html += '<div>';
|
||||
html += record.name;
|
||||
html += '</div>';
|
||||
|
||||
document.getElementById('event_location_sessions').innerHTML = html;
|
||||
} else {
|
||||
document.getElementById('event_location_sessions').innerHTML = 'Event location sessions not found.';
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function get_event_sessions(event_id) {
|
||||
url = '/event/'+event_id+'/session';
|
||||
|
||||
let data = { };
|
||||
|
||||
//console.log(data);
|
||||
|
||||
axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
|
||||
if (response.data != null) {
|
||||
records = response.data;
|
||||
|
||||
let html = '';
|
||||
html += '<ul>';
|
||||
for (var i in records) {
|
||||
html += '<li>'+records[i].name+'</li>'
|
||||
}
|
||||
html += '</ul>';
|
||||
|
||||
document.getElementById('event_sessions').innerHTML = html;
|
||||
} else {
|
||||
document.getElementById('event_sessions').innerHTML = 'Event sessions not found.';
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function get_event_session(event_id, event_session_id) {
|
||||
url = '/event/'+event_id+'/session/'+event_session_id;
|
||||
|
||||
let data = { };
|
||||
|
||||
//console.log(data);
|
||||
|
||||
axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
|
||||
if (response.data != null) {
|
||||
record = response.data;
|
||||
|
||||
let html = '';
|
||||
html += '<div>';
|
||||
html += record.name;
|
||||
html += '</div>';
|
||||
|
||||
document.getElementById('event_session').innerHTML = html;
|
||||
} else {
|
||||
document.getElementById('event_session').innerHTML = 'Event session not found.';
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function get_event_session_presentations(event_id, event_session_id) {
|
||||
url = '/event/'+event_id+'/session/'+event_session_id+'/presentation';
|
||||
|
||||
let data = { };
|
||||
|
||||
//console.log(data);
|
||||
|
||||
axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
|
||||
if (response.data != null) {
|
||||
records = response.data;
|
||||
|
||||
let html = '';
|
||||
html += '<ul>';
|
||||
for (var i in records) {
|
||||
html += '<li>'+records[i].name+'</li>'
|
||||
}
|
||||
html += '</ul>';
|
||||
|
||||
document.getElementById('event_presentations').innerHTML = html;
|
||||
} else {
|
||||
document.getElementById('event_presentations').innerHTML = 'Event session presentations not found.';
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function get_event_session_presentation(event_id, event_session_id, event_presentation_id) {
|
||||
url = '/event/'+event_id+'/session/'+event_session_id+'/presentation/'+event_presentation_id;
|
||||
|
||||
let data = { };
|
||||
|
||||
//console.log(data);
|
||||
|
||||
axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
|
||||
if (response.data != null) {
|
||||
record = response.data;
|
||||
|
||||
let html = '';
|
||||
html += '<div>';
|
||||
html += record.name;
|
||||
html += '</div>';
|
||||
|
||||
document.getElementById('event_presentation').innerHTML = html;
|
||||
} else {
|
||||
document.getElementById('event_presentation').innerHTML = 'Event session presentation not found.';
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function get_event_session_presentation_presenters(event_id, event_session_id, event_presentation_id) {
|
||||
url = '/event/'+event_id+'/session/'+event_session_id+'/presentation/'+event_presentation_id+'/presenter';
|
||||
|
||||
let data = { };
|
||||
|
||||
//console.log(data);
|
||||
|
||||
axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
|
||||
if (response.data != null) {
|
||||
records = response.data;
|
||||
|
||||
let html = '';
|
||||
html += '<ul>';
|
||||
for (var i in records) {
|
||||
html += '<li>'+records[i].given_name+' '+records[i].family_name;'</li>'
|
||||
}
|
||||
html += '</ul>';
|
||||
|
||||
document.getElementById('event_presenters').innerHTML = html;
|
||||
} else {
|
||||
document.getElementById('event_presenters').innerHTML = 'Event session presentation presenters not found.';
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function get_event_session_presentation_presenter(event_id, event_session_id, event_presentation_id, event_presenter_id) {
|
||||
url = '/event/'+event_id+'/session/'+event_session_id+'/presentation/'+event_presentation_id+'/presenter/'+event_presenter_id;
|
||||
|
||||
let data = { };
|
||||
|
||||
//console.log(data);
|
||||
|
||||
axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
|
||||
if (response.data != null) {
|
||||
record = response.data;
|
||||
|
||||
let html = '';
|
||||
html += '<div>';
|
||||
html += record.given_name+' '+record.family_name;
|
||||
html += '</div>';
|
||||
|
||||
document.getElementById('event_presenter').innerHTML = html;
|
||||
} else {
|
||||
document.getElementById('event_presenter').innerHTML = 'Event session presentation presenter not found.';
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function get_event_files(event_id) {
|
||||
url = '/event/'+event_id+'/file';
|
||||
|
||||
let data = { };
|
||||
|
||||
//console.log(data);
|
||||
|
||||
axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
|
||||
if (response.data != null) {
|
||||
records = response.data;
|
||||
|
||||
let html = '';
|
||||
html += '<ul>';
|
||||
for (var i in records) {
|
||||
html += '<li>'+records[i].filename+'</li>'
|
||||
}
|
||||
html += '</ul>';
|
||||
|
||||
document.getElementById('event_files').innerHTML = html;
|
||||
} else {
|
||||
document.getElementById('event_files').innerHTML = 'Event files not found.';
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function get_event_file(event_id, event_file_id) {
|
||||
url = '/event/'+event_id+'/file/'+event_file_id;
|
||||
|
||||
let data = { };
|
||||
|
||||
//console.log(data);
|
||||
|
||||
axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
|
||||
if (response.data != null) {
|
||||
record = response.data;
|
||||
|
||||
let html = '';
|
||||
html += '<div>';
|
||||
html += record.filename;
|
||||
html += '</div>';
|
||||
|
||||
document.getElementById('event_file').innerHTML = html;
|
||||
} else {
|
||||
document.getElementById('event_file').innerHTML = 'Event file not found.';
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function get_event_file_download(event_id, event_file_id) {
|
||||
url = '/event/'+event_id+'/file/'+event_file_id+'/download';
|
||||
|
||||
let data = { };
|
||||
|
||||
//console.log(data);
|
||||
|
||||
axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
|
||||
if (response.data != null) {
|
||||
record = response.data;
|
||||
|
||||
let html = '';
|
||||
html += '<div>';
|
||||
html += 'no idea'; //record.filename;
|
||||
html += '</div>';
|
||||
|
||||
document.getElementById('event_file').innerHTML = html;
|
||||
} else {
|
||||
document.getElementById('event_file').innerHTML = 'Event file not found.';
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function api_users() {
|
||||
url = '/user';
|
||||
|
||||
let data = { };
|
||||
|
||||
//console.log(data);
|
||||
|
||||
axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
return true;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
142
app/js/hold launcher.js
Normal file
142
app/js/hold launcher.js
Normal file
@@ -0,0 +1,142 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
let request_waiting = false;
|
||||
|
||||
setInterval(async function() {
|
||||
if (typeof axios.defaults.headers.common['Authorization'] !== 'undefined' && axios.defaults.headers.common['Authorization'] != null) {
|
||||
|
||||
if (typeof launcher.sessions === 'undefined') {
|
||||
console.log('Check for location files.');
|
||||
let for_id = launcher.event_location_id;
|
||||
launcher.files = await api.get_files_for_type_for_id(axios, 'location', for_id);
|
||||
for (var i in launcher.files) {
|
||||
console.log('f: ('+launcher.files[i].event_file_id+') '+launcher.files[i].event_file_filename+' ***')
|
||||
file_id = launcher.files[i].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
filename = launcher.files[i].hash_sha256+'.file';
|
||||
|
||||
save_path = path.join(file_cache_path, filename);
|
||||
|
||||
//console.log(directory_and_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);
|
||||
ipcRenderer.send('download_file', api_base_url, api_endpoint, api_temporary_token, save_path); // Must download file using main node.js thread.
|
||||
//response.data.pipe(fs.createWriteStream(directory_and_filename));
|
||||
}
|
||||
//let results = await api.download_file_id(axios, file_id, hash_sha256);
|
||||
|
||||
}
|
||||
} else {
|
||||
console.log('No check for location files.');
|
||||
}
|
||||
|
||||
if (typeof launcher.sessions === 'undefined') {
|
||||
console.log('Check for location sessions.');
|
||||
launcher.sessions = await api.get_event_location_sessions(axios, launcher.event_id, launcher.event_location_id);
|
||||
for (var i in launcher.sessions) {
|
||||
console.log('*** '+launcher.sessions[i].name+' ***')
|
||||
|
||||
// Check for session files start
|
||||
if (typeof launcher.sessions[i].files === 'undefined') {
|
||||
console.log('Check for session files.');
|
||||
let for_id = launcher.sessions[i].id;
|
||||
launcher.sessions[i].files = await api.get_files_for_type_for_id(axios, 'session', for_id);
|
||||
if (launcher.sessions[i].files) {
|
||||
console.log('Session files found.');
|
||||
for (var j in launcher.sessions[i].files) {
|
||||
console.log('f: ('+launcher.sessions[i].files[j].event_file_id+') '+launcher.sessions[i].files[j].event_file_filename+' ***');
|
||||
file_id = launcher.sessions[i].files[j].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
hash_sha256 = launcher.sessions[i].files[j].hash_sha256+'.file';
|
||||
let results = await api.download_file_id(axios, file_id, hash_sha256);
|
||||
}
|
||||
} else {
|
||||
console.log('No session files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for session files.');
|
||||
}
|
||||
// Check for session files end
|
||||
|
||||
// Get session presentations and associated files
|
||||
launcher.sessions[i].presentations = await api.get_session_presentations(axios, launcher.event_id, launcher.sessions[i].id);
|
||||
for (var j in launcher.sessions[i].presentations) {
|
||||
console.log('* '+launcher.sessions[i].presentations[j].name);
|
||||
|
||||
// Check for presentation files start
|
||||
if (typeof launcher.sessions[i].presentations[j].files === 'undefined') {
|
||||
console.log('Check for presentation files.');
|
||||
let for_id = launcher.sessions[i].presentations[j].id;
|
||||
launcher.sessions[i].presentations[j].files = await api.get_files_for_type_for_id(axios, 'presentation', for_id);
|
||||
if (launcher.sessions[i].presentations[j].files) {
|
||||
console.log('Presentation files found.');
|
||||
for (var k in launcher.sessions[i].presentations[j].files) {
|
||||
console.log('f: ('+launcher.sessions[i].presentations[j].files[k].event_file_id+') '+launcher.sessions[i].presentations[j].files[k].event_file_filename+' ***');
|
||||
file_id = launcher.sessions[i].presentations[j].files[k].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
hash_sha256 = launcher.sessions[i].presentations[j].files[k].hash_sha256+'.file';
|
||||
let results = await api.download_file_id(axios, file_id, hash_sha256);
|
||||
}
|
||||
} else {
|
||||
console.log('No presentation files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for presentation files.');
|
||||
}
|
||||
// Check for presentation files end
|
||||
|
||||
|
||||
// Get session presentations presenters and associated files
|
||||
//let event_presentation_id = launcher.sessions[i].presentations[j].id;
|
||||
launcher.sessions[i].presentations[j].presenters = await api.get_presentation_presenters(axios, launcher.event_id, launcher.sessions[i].id, launcher.sessions[i].presentations[j].id);
|
||||
for (var k in launcher.sessions[i].presentations[j].presenters) {
|
||||
console.log('-- '+launcher.sessions[i].presentations[j].presenters[k].given_name+' '+launcher.sessions[i].presentations[j].presenters[k].family_name)
|
||||
|
||||
// Check for presenter files start
|
||||
if (typeof launcher.sessions[i].presentations[j].presenters[k].files === 'undefined') {
|
||||
console.log('Check for presenter files.');
|
||||
let for_id = launcher.sessions[i].presentations[j].presenters[k].id;
|
||||
launcher.sessions[i].presentations[j].presenters[k].files = await api.get_files_for_type_for_id(axios, 'presenter', for_id);
|
||||
if (launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
console.log('Presenter files found.');
|
||||
for (var l in launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
console.log('f: ('+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id+') '+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+' ***')
|
||||
file_id = launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
hash_sha256 = launcher.sessions[i].presentations[j].presenters[k].files[l].hash_sha256+'.file';
|
||||
let results = await api.download_file_id(axios, file_id, hash_sha256);
|
||||
}
|
||||
} else {
|
||||
console.log('No presenter files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for presenter files.');
|
||||
}
|
||||
// Check for presenter files end
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('No check for location sessions.');
|
||||
}
|
||||
/*
|
||||
if (launcher.sessions) {
|
||||
console.log('Check for session files.');
|
||||
let for_id = launcher.event_location_id;
|
||||
launcher.files = await api.get_files_for_type_for_id(axios, 'location', for_id);
|
||||
for (var i in launcher.sessions) {
|
||||
console.log('f: ('+launcher.sessions[i].event_file_id+') '+launcher.files[i].event_file_filename+' ***')
|
||||
file_id = launcher.files[i].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let results = await api.download_file_id(axios, file_id);
|
||||
}
|
||||
} else {
|
||||
console.log('No check for location files.');
|
||||
}
|
||||
*/
|
||||
|
||||
} else {
|
||||
console.log('Waiting a few more seconds to see if Authorization header is set.');
|
||||
}
|
||||
}, 5000);
|
||||
50
app/js/hold testing.js
Normal file
50
app/js/hold testing.js
Normal file
@@ -0,0 +1,50 @@
|
||||
const { shell } = require('electron');
|
||||
const fs = require('fs');
|
||||
const screen = require('screen');
|
||||
|
||||
const path = '';
|
||||
const filename = 'test.txt';
|
||||
|
||||
//Check if file exists
|
||||
if(fs.existsSync(filename)) {
|
||||
} else {
|
||||
console.log("File does not exist. Creating new file.")
|
||||
fs.writeFile(filename, '', (err) => {
|
||||
if(err)
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
|
||||
//shell.openItem('test.txt');
|
||||
|
||||
/*
|
||||
const path = './';
|
||||
if (fs.stat.isDirectory(path)) {
|
||||
console.log('Directory');
|
||||
} else {
|
||||
console.log('File or nothing');
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
function testing() {
|
||||
console.log(api_temporary_token);
|
||||
}
|
||||
*/
|
||||
|
||||
/* Testing inter-process communication (IPC) */
|
||||
/*
|
||||
var ipc = require('electron').ipcRenderer;
|
||||
var authButton = document.getElementById('test_button');
|
||||
authButton.addEventListener('click', function(){
|
||||
ipc.once('action_reply', function(event, response){
|
||||
processResponse(response);
|
||||
})
|
||||
//ipc.send('invoke_action', 'Test PowerPoint.pptx');
|
||||
ipc.send('invoke_action', api_temporary_token);
|
||||
});
|
||||
|
||||
function processResponse(response) {
|
||||
document.getElementById('response').innerHTML = "Response: "+response;
|
||||
}
|
||||
*/
|
||||
142
app/js/launcher.js.bak
Normal file
142
app/js/launcher.js.bak
Normal file
@@ -0,0 +1,142 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
let request_waiting = false;
|
||||
|
||||
setInterval(async function() {
|
||||
if (typeof axios.defaults.headers.common['Authorization'] !== 'undefined' && axios.defaults.headers.common['Authorization'] != null) {
|
||||
|
||||
if (typeof launcher.sessions === 'undefined') {
|
||||
console.log('Check for location files.');
|
||||
let for_id = launcher.event_location_id;
|
||||
launcher.files = await api.get_files_for_type_for_id(axios, 'location', for_id);
|
||||
for (var i in launcher.files) {
|
||||
console.log('f: ('+launcher.files[i].event_file_id+') '+launcher.files[i].event_file_filename+' ***')
|
||||
file_id = launcher.files[i].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
filename = launcher.files[i].hash_sha256+'.file';
|
||||
|
||||
save_path = path.join(file_cache_path, filename);
|
||||
|
||||
//console.log(directory_and_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);
|
||||
ipcRenderer.send('download_file', api_base_url, api_endpoint, api_temporary_token, save_path); // Must download file using main node.js thread.
|
||||
//response.data.pipe(fs.createWriteStream(directory_and_filename));
|
||||
}
|
||||
//let results = await api.download_file_id(axios, file_id, hash_sha256);
|
||||
|
||||
}
|
||||
} else {
|
||||
console.log('No check for location files.');
|
||||
}
|
||||
|
||||
if (typeof launcher.sessions === 'undefined') {
|
||||
console.log('Check for location sessions.');
|
||||
launcher.sessions = await api.get_event_location_sessions(axios, launcher.event_id, launcher.event_location_id);
|
||||
for (var i in launcher.sessions) {
|
||||
console.log('*** '+launcher.sessions[i].name+' ***')
|
||||
|
||||
// Check for session files start
|
||||
if (typeof launcher.sessions[i].files === 'undefined') {
|
||||
console.log('Check for session files.');
|
||||
let for_id = launcher.sessions[i].id;
|
||||
launcher.sessions[i].files = await api.get_files_for_type_for_id(axios, 'session', for_id);
|
||||
if (launcher.sessions[i].files) {
|
||||
console.log('Session files found.');
|
||||
for (var j in launcher.sessions[i].files) {
|
||||
console.log('f: ('+launcher.sessions[i].files[j].event_file_id+') '+launcher.sessions[i].files[j].event_file_filename+' ***');
|
||||
file_id = launcher.sessions[i].files[j].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
hash_sha256 = launcher.sessions[i].files[j].hash_sha256+'.file';
|
||||
let results = await api.download_file_id(axios, file_id, hash_sha256);
|
||||
}
|
||||
} else {
|
||||
console.log('No session files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for session files.');
|
||||
}
|
||||
// Check for session files end
|
||||
|
||||
// Get session presentations and associated files
|
||||
launcher.sessions[i].presentations = await api.get_session_presentations(axios, launcher.event_id, launcher.sessions[i].id);
|
||||
for (var j in launcher.sessions[i].presentations) {
|
||||
console.log('* '+launcher.sessions[i].presentations[j].name);
|
||||
|
||||
// Check for presentation files start
|
||||
if (typeof launcher.sessions[i].presentations[j].files === 'undefined') {
|
||||
console.log('Check for presentation files.');
|
||||
let for_id = launcher.sessions[i].presentations[j].id;
|
||||
launcher.sessions[i].presentations[j].files = await api.get_files_for_type_for_id(axios, 'presentation', for_id);
|
||||
if (launcher.sessions[i].presentations[j].files) {
|
||||
console.log('Presentation files found.');
|
||||
for (var k in launcher.sessions[i].presentations[j].files) {
|
||||
console.log('f: ('+launcher.sessions[i].presentations[j].files[k].event_file_id+') '+launcher.sessions[i].presentations[j].files[k].event_file_filename+' ***');
|
||||
file_id = launcher.sessions[i].presentations[j].files[k].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
hash_sha256 = launcher.sessions[i].presentations[j].files[k].hash_sha256+'.file';
|
||||
let results = await api.download_file_id(axios, file_id, hash_sha256);
|
||||
}
|
||||
} else {
|
||||
console.log('No presentation files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for presentation files.');
|
||||
}
|
||||
// Check for presentation files end
|
||||
|
||||
|
||||
// Get session presentations presenters and associated files
|
||||
//let event_presentation_id = launcher.sessions[i].presentations[j].id;
|
||||
launcher.sessions[i].presentations[j].presenters = await api.get_presentation_presenters(axios, launcher.event_id, launcher.sessions[i].id, launcher.sessions[i].presentations[j].id);
|
||||
for (var k in launcher.sessions[i].presentations[j].presenters) {
|
||||
console.log('-- '+launcher.sessions[i].presentations[j].presenters[k].given_name+' '+launcher.sessions[i].presentations[j].presenters[k].family_name)
|
||||
|
||||
// Check for presenter files start
|
||||
if (typeof launcher.sessions[i].presentations[j].presenters[k].files === 'undefined') {
|
||||
console.log('Check for presenter files.');
|
||||
let for_id = launcher.sessions[i].presentations[j].presenters[k].id;
|
||||
launcher.sessions[i].presentations[j].presenters[k].files = await api.get_files_for_type_for_id(axios, 'presenter', for_id);
|
||||
if (launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
console.log('Presenter files found.');
|
||||
for (var l in launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
console.log('f: ('+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id+') '+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+' ***')
|
||||
file_id = launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
hash_sha256 = launcher.sessions[i].presentations[j].presenters[k].files[l].hash_sha256+'.file';
|
||||
let results = await api.download_file_id(axios, file_id, hash_sha256);
|
||||
}
|
||||
} else {
|
||||
console.log('No presenter files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for presenter files.');
|
||||
}
|
||||
// Check for presenter files end
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('No check for location sessions.');
|
||||
}
|
||||
/*
|
||||
if (launcher.sessions) {
|
||||
console.log('Check for session files.');
|
||||
let for_id = launcher.event_location_id;
|
||||
launcher.files = await api.get_files_for_type_for_id(axios, 'location', for_id);
|
||||
for (var i in launcher.sessions) {
|
||||
console.log('f: ('+launcher.sessions[i].event_file_id+') '+launcher.files[i].event_file_filename+' ***')
|
||||
file_id = launcher.files[i].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let results = await api.download_file_id(axios, file_id);
|
||||
}
|
||||
} else {
|
||||
console.log('No check for location files.');
|
||||
}
|
||||
*/
|
||||
|
||||
} else {
|
||||
console.log('Waiting a few more seconds to see if Authorization header is set.');
|
||||
}
|
||||
}, 5000);
|
||||
422
app/js/module_api 2019-12-20.js.bak
Normal file
422
app/js/module_api 2019-12-20.js.bak
Normal file
@@ -0,0 +1,422 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const { ipcRenderer } = require('electron');
|
||||
|
||||
exports.api_token_request_async = async function (axios, secret_key) {
|
||||
console.log('Requesting API temporary token...');
|
||||
const url = '/api_token_request';
|
||||
|
||||
let data = { secret_key: secret_key };
|
||||
|
||||
const response = await axios.post(url, data)
|
||||
.then(function (response) {
|
||||
//console.log(response);
|
||||
const api_temporary_token = response.data.temporary_token;
|
||||
//console.log('API Temporary Token: '+temporary_token);
|
||||
return api_temporary_token;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error(error);
|
||||
return error;
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
exports.get_event_location_sessions = async function (axios, event_id, event_location_id) {
|
||||
console.log('Requesting location sessions...');
|
||||
const url = '/event/'+event_id+'/location/'+event_location_id+'/session';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.get_session_presentations = async function (axios, event_id, event_session_id) {
|
||||
console.log('Requesting session presentations...');
|
||||
const url = '/event/'+event_id+'/session/'+event_session_id+'/presentation';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.get_presentation_presenters = async function (axios, event_id, event_session_id, event_presentation_id) {
|
||||
console.log('Requesting presentation presenters...');
|
||||
const url = '/event/'+event_id+'/session/'+event_session_id+'/presentation/'+event_presentation_id+'/presenter';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.get_files_for_type_for_id = async function (axios, for_type, for_id) {
|
||||
console.log('Requesting files for '+for_type+' '+for_id);
|
||||
const url = '/event/file/'+for_type+'/'+for_id;
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.download_file_id = async function (axios, file_id, filename) {
|
||||
|
||||
ipcRenderer.send('download_file', api_base_url, api_endpoint, api_temporary_token, save_path); // in render thread
|
||||
|
||||
console.log('1: download file id '+file_id);
|
||||
const url = '/event/file/'+file_id+'/download';
|
||||
|
||||
//const data = await axios.get(url, responseType: 'stream')
|
||||
const data = await axios({
|
||||
method: "get",
|
||||
url: url,
|
||||
responseType: "stream"
|
||||
})
|
||||
.then(function (response) {
|
||||
console.log('2: downloaded file id '+file_id);
|
||||
console.log(response);
|
||||
//console.log(response.data);
|
||||
|
||||
let filename = 'default.txt';
|
||||
|
||||
if (typeof filename_override === 'undefined' || filename_override == null) {
|
||||
let headerLine = response.data.headers['content-disposition'];
|
||||
|
||||
console.log(headerLine);
|
||||
console.log(headerLine.indexOf('="'));
|
||||
console.log(headerLine.indexOf('='));
|
||||
if (headerLine.indexOf('="') != -1) {
|
||||
let startFileNameIndex = headerLine.indexOf('="') + 2;
|
||||
let endFileNameIndex = headerLine.lastIndexOf('"');
|
||||
filename = headerLine.substring(startFileNameIndex, endFileNameIndex);
|
||||
} else if (headerLine.indexOf('=') != -1) {
|
||||
let startFileNameIndex = headerLine.indexOf('=') + 1;
|
||||
let endFileNameIndex = headerLine.length;
|
||||
filename = headerLine.substring(startFileNameIndex, endFileNameIndex);
|
||||
} else {
|
||||
filename = 'filename_not_found_in_header.txt';
|
||||
}
|
||||
} else {
|
||||
filename = filename_override;
|
||||
}
|
||||
|
||||
let directory = 'file_cache/';
|
||||
|
||||
directory_and_filename = path.join(directory, filename);
|
||||
|
||||
//console.log(directory_and_filename);
|
||||
|
||||
if (fs.existsSync(directory_and_filename)) {
|
||||
console.log('3a: file already exists: '+directory_and_filename);
|
||||
} else {
|
||||
console.log('3b: saving file: '+directory_and_filename);
|
||||
response.data.pipe(fs.createWriteStream(directory_and_filename));
|
||||
}
|
||||
//data = response.data;
|
||||
console.log('4: saved file id '+file_id);
|
||||
return true;
|
||||
//return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
//return data;
|
||||
}
|
||||
|
||||
exports.launcher_cache_check = async function (launcher, api_base_url, api_temporary_token, file_cache_path) {
|
||||
if (typeof launcher.event_files === 'undefined') {
|
||||
console.log('Check for global event files.');
|
||||
let for_id = launcher.event_id;
|
||||
launcher.event_files = await api.get_files_for_type_for_id(axios, 'event', for_id);
|
||||
for (var i in launcher.event_files) {
|
||||
console.log('f: ('+launcher.event_files[i].event_file_id+') '+launcher.event_files[i].event_file_filename+' ***')
|
||||
file_id = launcher.event_files[i].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.event_files[i].hash_sha256+'.file';
|
||||
|
||||
save_path = path.join(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('No check for global event files');
|
||||
}
|
||||
|
||||
|
||||
if (typeof launcher.location_files === 'undefined') {
|
||||
console.log('Check for location specific files.');
|
||||
let for_id = launcher.event_location_id;
|
||||
launcher.location_files = await api.get_files_for_type_for_id(axios, 'location', for_id);
|
||||
for (var i in launcher.location_files) {
|
||||
console.log('f: ('+launcher.location_files[i].event_file_id+') '+launcher.location_files[i].event_file_filename+' ***')
|
||||
file_id = launcher.location_files[i].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.location_files[i].hash_sha256+'.file';
|
||||
|
||||
save_path = path.join(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('No check for location specific files.');
|
||||
}
|
||||
|
||||
|
||||
if (typeof launcher.sessions === 'undefined') {
|
||||
console.log('Check for location sessions.');
|
||||
launcher.sessions = await api.get_event_location_sessions(axios, launcher.event_id, launcher.event_location_id);
|
||||
for (var i in launcher.sessions) {
|
||||
console.log('*** '+launcher.sessions[i].name+' ***')
|
||||
|
||||
// Check for session files start
|
||||
if (typeof launcher.sessions[i].files === 'undefined') {
|
||||
console.log('Check for session files.');
|
||||
let for_id = launcher.sessions[i].id;
|
||||
launcher.sessions[i].files = await api.get_files_for_type_for_id(axios, 'session', for_id);
|
||||
if (launcher.sessions[i].files) {
|
||||
console.log('Session files found.');
|
||||
for (var j in launcher.sessions[i].files) {
|
||||
console.log('f: ('+launcher.sessions[i].files[j].event_file_id+') '+launcher.sessions[i].files[j].event_file_filename+' ***');
|
||||
file_id = launcher.sessions[i].files[j].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.sessions[i].files[j].hash_sha256+'.file';
|
||||
|
||||
save_path = path.join(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('No session files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for session files.');
|
||||
}
|
||||
// Check for session files end
|
||||
|
||||
// Get session presentations and associated files
|
||||
launcher.sessions[i].presentations = await api.get_session_presentations(axios, launcher.event_id, launcher.sessions[i].id);
|
||||
for (var j in launcher.sessions[i].presentations) {
|
||||
console.log('* '+launcher.sessions[i].presentations[j].name);
|
||||
|
||||
// Check for presentation files start
|
||||
if (typeof launcher.sessions[i].presentations[j].files === 'undefined') {
|
||||
console.log('Check for presentation files.');
|
||||
let for_id = launcher.sessions[i].presentations[j].id;
|
||||
launcher.sessions[i].presentations[j].files = await api.get_files_for_type_for_id(axios, 'presentation', for_id);
|
||||
if (launcher.sessions[i].presentations[j].files) {
|
||||
console.log('Presentation files found.');
|
||||
for (var k in launcher.sessions[i].presentations[j].files) {
|
||||
console.log('f: ('+launcher.sessions[i].presentations[j].files[k].event_file_id+') '+launcher.sessions[i].presentations[j].files[k].event_file_filename+' ***');
|
||||
file_id = launcher.sessions[i].presentations[j].files[k].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.sessions[i].presentations[j].files[k].hash_sha256+'.file';
|
||||
|
||||
save_path = path.join(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('No presentation files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for presentation files.');
|
||||
}
|
||||
// Check for presentation files end
|
||||
|
||||
|
||||
// Get session presentations presenters and associated files
|
||||
//let event_presentation_id = launcher.sessions[i].presentations[j].id;
|
||||
launcher.sessions[i].presentations[j].presenters = await api.get_presentation_presenters(axios, launcher.event_id, launcher.sessions[i].id, launcher.sessions[i].presentations[j].id);
|
||||
for (var k in launcher.sessions[i].presentations[j].presenters) {
|
||||
console.log('-- '+launcher.sessions[i].presentations[j].presenters[k].given_name+' '+launcher.sessions[i].presentations[j].presenters[k].family_name)
|
||||
|
||||
// Check for presenter files start
|
||||
if (typeof launcher.sessions[i].presentations[j].presenters[k].files === 'undefined') {
|
||||
console.log('Check for presenter files.');
|
||||
let for_id = launcher.sessions[i].presentations[j].presenters[k].id;
|
||||
launcher.sessions[i].presentations[j].presenters[k].files = await api.get_files_for_type_for_id(axios, 'presenter', for_id);
|
||||
if (launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
console.log('Presenter files found.');
|
||||
for (var l in launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
console.log('f: ('+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id+') '+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+' ***')
|
||||
file_id = launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.sessions[i].presentations[j].presenters[k].files[l].hash_sha256+'.file';
|
||||
|
||||
save_path = path.join(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('No presenter files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for presenter files.');
|
||||
}
|
||||
// Check for presenter files end
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('No check for location sessions.');
|
||||
}
|
||||
|
||||
console.log('Location cache check finished.');
|
||||
return true;
|
||||
}
|
||||
|
||||
exports.launcher_render = async function (launcher) {
|
||||
console.log('Rendering launcher...');
|
||||
document.getElementById('location_title').innerHTML = '<h1>Launcher '+launcher.event_location_id+'@'+launcher.event_id+'</h1>';
|
||||
|
||||
document.getElementById('event_files_menu').innerHTML = '<h2>Event Files</h2>';
|
||||
document.getElementById('event_files_menu').innerHTML += '<ul class="">';
|
||||
for (var i in launcher.event_files) {
|
||||
document.getElementById('event_files_menu').innerHTML += '<li id="menu_event_file_id_'+launcher.event_files[i].id+'" class="btn btn-info">'+launcher.event_files[i].event_file_filename+'</li>';
|
||||
}
|
||||
document.getElementById('event_files_menu').innerHTML += '</ul>';
|
||||
|
||||
document.getElementById('location_files_menu').innerHTML = '<h2>Location Files</h2>';
|
||||
document.getElementById('location_files_menu').innerHTML += '<ul class="" role="">';
|
||||
for (var i in launcher.location_files) {
|
||||
document.getElementById('location_files_menu').innerHTML += '<li id="menu_event_file_id_'+launcher.location_files[i].id+'" class="btn btn-info">'+launcher.location_files[i].event_file_filename+'</li>';
|
||||
}
|
||||
document.getElementById('location_files_menu').innerHTML += '</ul>';
|
||||
|
||||
document.getElementById('sessions_menu').innerHTML = '<h2>Sessions</h2>';
|
||||
document.getElementById('sessions_menu').innerHTML += '<ul class="" role="">';
|
||||
//let sessions_detail = '';
|
||||
document.getElementById('sessions_detail').innerHTML = ''; // This needs to be reviewed.
|
||||
for (var i in launcher.sessions) {
|
||||
// List sessions in menu
|
||||
document.getElementById('sessions_menu').innerHTML += '<li id="menu_session_id_'+launcher.sessions[i].id+'" class="btn btn-info btn_view_session" data-session_id="'+launcher.sessions[i].id+'">'+launcher.sessions[i].name+'</li>';
|
||||
|
||||
// Create containers for each session
|
||||
let session_detail = '';
|
||||
session_detail += '<div id="detail_session_id_'+launcher.sessions[i].id+'" class="container d-none session_detail" data-session_id="'+launcher.sessions[i].id+'">';
|
||||
session_detail += '<h2 class="session_title">'+launcher.sessions[i].name+'</h2>';
|
||||
session_detail += '<div class="session_presentations"><ul>';
|
||||
for (var j in launcher.sessions[i].presentations) {
|
||||
session_detail += '<li>'+launcher.sessions[i].presentations[j].name+'</li>';
|
||||
}
|
||||
session_detail += '</ul></div>';
|
||||
session_detail += '</div> <!-- End session detail for '+launcher.sessions[i].id+' -->';
|
||||
|
||||
document.getElementById('sessions_detail').innerHTML += session_detail;
|
||||
|
||||
//document.getElementById('sessions_menu').innerHTML += '</ul>';
|
||||
|
||||
}
|
||||
document.getElementById('sessions_menu').innerHTML += '</ul>';
|
||||
|
||||
index_sessions_detail('btn_view_session');
|
||||
|
||||
|
||||
//const btn_session_{{ event_presentation.id }}_name = document.querySelector('button#presentation_{{ event_presentation.id }}_name');
|
||||
//btn_presentation_{{ event_presentation.id }}_name.onclick = display_hide_poster_for_type_id.bind(this, true, 'presentation', {{ event_presentation.id }});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Updated 2019-12-19 */
|
||||
function index_sessions_detail(class_name) {
|
||||
var class_elements = document.getElementsByClassName(class_name);
|
||||
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
class_elements[i].addEventListener( 'click', function() {view_session( this.getAttribute('data-session_id')) } );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Updated 2019-12-19 */
|
||||
function view_session(session_id) {
|
||||
var class_elements = document.getElementsByClassName('session_detail');
|
||||
console.log('*** Session ID: '+session_id);
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
console.log('*** checking: '+class_elements[i].getAttribute('data-session_id'));
|
||||
if (class_elements[i].getAttribute('data-session_id') == session_id) {
|
||||
console.log('show');
|
||||
class_elements[i].classList.remove('d-none');
|
||||
class_elements[i].classList.add('d-block');
|
||||
} else {
|
||||
console.log('hide');
|
||||
class_elements[i].classList.remove('d-block');
|
||||
class_elements[i].classList.add('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
614
app/js/module_api 2020-01-08.js.bak
Normal file
614
app/js/module_api 2020-01-08.js.bak
Normal file
@@ -0,0 +1,614 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const { ipcRenderer } = require('electron');
|
||||
|
||||
exports.api_token_request_async = async function (axios, secret_key) {
|
||||
console.log('Requesting API temporary token...');
|
||||
const url = '/api_token_request';
|
||||
|
||||
let data = { secret_key: secret_key };
|
||||
|
||||
const response = await axios.post(url, data)
|
||||
.then(function (response) {
|
||||
//console.log(response);
|
||||
const api_temporary_token = response.data.temporary_token;
|
||||
//console.log('API Temporary Token: '+temporary_token);
|
||||
return api_temporary_token;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error(error);
|
||||
return error;
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
exports.get_event_details = async function (axios, event_id) {
|
||||
console.log('Requesting event details...');
|
||||
const url = '/event/'+event_id;
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.get_event_location_details = async function (axios, event_id, event_location_id) {
|
||||
console.log('Requesting event location details...');
|
||||
const url = '/event/'+event_id+'/location/'+event_location_id;
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.get_event_location_sessions = async function (axios, event_id, event_location_id) {
|
||||
console.log('Requesting location sessions...');
|
||||
const url = '/event/'+event_id+'/location/'+event_location_id+'/session';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.get_session_presentations = async function (axios, event_id, event_session_id) {
|
||||
console.log('Requesting session presentations...');
|
||||
const url = '/event/'+event_id+'/session/'+event_session_id+'/presentation';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.get_presentation_presenters = async function (axios, event_id, event_session_id, event_presentation_id) {
|
||||
console.log('Requesting presentation presenters...');
|
||||
const url = '/event/'+event_id+'/session/'+event_session_id+'/presentation/'+event_presentation_id+'/presenter';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.get_files_for_type_for_id = async function (axios, for_type, for_id) {
|
||||
console.log('Requesting files for '+for_type+' '+for_id);
|
||||
const url = '/event/file/'+for_type+'/'+for_id;
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.download_file_id = async function (axios, file_id, filename) {
|
||||
|
||||
ipcRenderer.send('download_file', api_base_url, api_endpoint, api_temporary_token, save_path); // in render thread
|
||||
|
||||
console.log('1: download file id '+file_id);
|
||||
const url = '/event/file/'+file_id+'/download';
|
||||
|
||||
//const data = await axios.get(url, responseType: 'stream')
|
||||
const data = await axios({
|
||||
method: "get",
|
||||
url: url,
|
||||
responseType: "stream"
|
||||
})
|
||||
.then(function (response) {
|
||||
console.log('2: downloaded file id '+file_id);
|
||||
console.log(response);
|
||||
//console.log(response.data);
|
||||
|
||||
let filename = 'default.txt';
|
||||
|
||||
if (typeof filename_override === 'undefined' || filename_override == null) {
|
||||
let headerLine = response.data.headers['content-disposition'];
|
||||
|
||||
console.log(headerLine);
|
||||
console.log(headerLine.indexOf('="'));
|
||||
console.log(headerLine.indexOf('='));
|
||||
if (headerLine.indexOf('="') != -1) {
|
||||
let startFileNameIndex = headerLine.indexOf('="') + 2;
|
||||
let endFileNameIndex = headerLine.lastIndexOf('"');
|
||||
filename = headerLine.substring(startFileNameIndex, endFileNameIndex);
|
||||
} else if (headerLine.indexOf('=') != -1) {
|
||||
let startFileNameIndex = headerLine.indexOf('=') + 1;
|
||||
let endFileNameIndex = headerLine.length;
|
||||
filename = headerLine.substring(startFileNameIndex, endFileNameIndex);
|
||||
} else {
|
||||
filename = 'filename_not_found_in_header.txt';
|
||||
}
|
||||
} else {
|
||||
filename = filename_override;
|
||||
}
|
||||
|
||||
let directory = 'file_cache/';
|
||||
|
||||
directory_and_filename = path.join(directory, filename);
|
||||
|
||||
//console.log(directory_and_filename);
|
||||
|
||||
if (fs.existsSync(directory_and_filename)) {
|
||||
console.log('3a: file already exists: '+directory_and_filename);
|
||||
} else {
|
||||
console.log('3b: saving file: '+directory_and_filename);
|
||||
response.data.pipe(fs.createWriteStream(directory_and_filename));
|
||||
}
|
||||
//data = response.data;
|
||||
console.log('4: saved file id '+file_id);
|
||||
return true;
|
||||
//return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
//return data;
|
||||
}
|
||||
|
||||
exports.launcher_cache_check = async function (launcher, api_base_url, api_temporary_token, file_cache_path) {
|
||||
|
||||
if (typeof launcher.event === 'undefined') {
|
||||
launcher.event = await api.get_event_details(axios, launcher.event_id);
|
||||
console.log(launcher.event.id);
|
||||
idbKeyval.set(launcher.event.id, launcher.event, db_event);
|
||||
/*
|
||||
.then(function (data) {
|
||||
console.log(data.id);
|
||||
idbKeyval.set(data.id, data, db_event);
|
||||
//for (var i in response) {
|
||||
//var event_record = data[i];
|
||||
//idbKeyval.set(response[i].id, response[i], db_event);
|
||||
//}
|
||||
});
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
if (typeof launcher.location === 'undefined') {
|
||||
launcher.location = await api.get_event_location_details(axios, launcher.event_id, launcher.event_location_id);
|
||||
}
|
||||
|
||||
if (typeof launcher.event_files === 'undefined') {
|
||||
console.log('Check for global event files.');
|
||||
let for_id = launcher.event_id;
|
||||
launcher.event_files = await api.get_files_for_type_for_id(axios, 'event', for_id);
|
||||
for (var i in launcher.event_files) {
|
||||
console.log('f: ('+launcher.event_files[i].event_file_id+') '+launcher.event_files[i].event_file_filename+' ***')
|
||||
file_id = launcher.event_files[i].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.event_files[i].hash_sha256+'.file';
|
||||
|
||||
save_path = path.join(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('No check for global event files');
|
||||
}
|
||||
|
||||
|
||||
if (typeof launcher.location_files === 'undefined') {
|
||||
console.log('Check for location specific files.');
|
||||
let for_id = launcher.event_location_id;
|
||||
launcher.location_files = await api.get_files_for_type_for_id(axios, 'location', for_id);
|
||||
for (var i in launcher.location_files) {
|
||||
console.log('f: ('+launcher.location_files[i].event_file_id+') '+launcher.location_files[i].event_file_filename+' ***')
|
||||
file_id = launcher.location_files[i].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.location_files[i].hash_sha256+'.file';
|
||||
|
||||
save_path = path.join(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('No check for location specific files.');
|
||||
}
|
||||
|
||||
|
||||
if (typeof launcher.sessions === 'undefined') {
|
||||
console.log('Check for location sessions.');
|
||||
launcher.sessions = await api.get_event_location_sessions(axios, launcher.event_id, launcher.event_location_id);
|
||||
for (var i in launcher.sessions) {
|
||||
console.log('*** '+launcher.sessions[i].name+' ***')
|
||||
|
||||
// Check for session files start
|
||||
if (typeof launcher.sessions[i].files === 'undefined') {
|
||||
console.log('Check for session files.');
|
||||
let for_id = launcher.sessions[i].id;
|
||||
launcher.sessions[i].files = await api.get_files_for_type_for_id(axios, 'session', for_id);
|
||||
if (launcher.sessions[i].files) {
|
||||
console.log('Session files found.');
|
||||
for (var j in launcher.sessions[i].files) {
|
||||
console.log('f: ('+launcher.sessions[i].files[j].event_file_id+') '+launcher.sessions[i].files[j].event_file_filename+' ***');
|
||||
file_id = launcher.sessions[i].files[j].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.sessions[i].files[j].hash_sha256+'.file';
|
||||
|
||||
save_path = path.join(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('No session files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for session files.');
|
||||
}
|
||||
// Check for session files end
|
||||
|
||||
// Get session presentations and associated files
|
||||
launcher.sessions[i].presentations = await api.get_session_presentations(axios, launcher.event_id, launcher.sessions[i].id);
|
||||
for (var j in launcher.sessions[i].presentations) {
|
||||
console.log('* '+launcher.sessions[i].presentations[j].name);
|
||||
|
||||
// Check for presentation files start
|
||||
if (typeof launcher.sessions[i].presentations[j].files === 'undefined') {
|
||||
console.log('Check for presentation files.');
|
||||
let for_id = launcher.sessions[i].presentations[j].id;
|
||||
launcher.sessions[i].presentations[j].files = await api.get_files_for_type_for_id(axios, 'presentation', for_id);
|
||||
if (launcher.sessions[i].presentations[j].files) {
|
||||
console.log('Presentation files found.');
|
||||
for (var k in launcher.sessions[i].presentations[j].files) {
|
||||
console.log('f: ('+launcher.sessions[i].presentations[j].files[k].event_file_id+') '+launcher.sessions[i].presentations[j].files[k].event_file_filename+' ***');
|
||||
file_id = launcher.sessions[i].presentations[j].files[k].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.sessions[i].presentations[j].files[k].hash_sha256+'.file';
|
||||
|
||||
save_path = path.join(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('No presentation files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for presentation files.');
|
||||
}
|
||||
// Check for presentation files end
|
||||
|
||||
|
||||
// Get session presentations presenters and associated files
|
||||
//let event_presentation_id = launcher.sessions[i].presentations[j].id;
|
||||
launcher.sessions[i].presentations[j].presenters = await api.get_presentation_presenters(axios, launcher.event_id, launcher.sessions[i].id, launcher.sessions[i].presentations[j].id);
|
||||
for (var k in launcher.sessions[i].presentations[j].presenters) {
|
||||
console.log('-- '+launcher.sessions[i].presentations[j].presenters[k].given_name+' '+launcher.sessions[i].presentations[j].presenters[k].family_name)
|
||||
|
||||
// Check for presenter files start
|
||||
if (typeof launcher.sessions[i].presentations[j].presenters[k].files === 'undefined') {
|
||||
console.log('Check for presenter files.');
|
||||
let for_id = launcher.sessions[i].presentations[j].presenters[k].id;
|
||||
launcher.sessions[i].presentations[j].presenters[k].files = await api.get_files_for_type_for_id(axios, 'presenter', for_id);
|
||||
if (launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
console.log('Presenter files found.');
|
||||
for (var l in launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
console.log('f: ('+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id+') '+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+' ***')
|
||||
file_id = launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.sessions[i].presentations[j].presenters[k].files[l].hash_sha256+'.file';
|
||||
|
||||
save_path = path.join(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('No presenter files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for presenter files.');
|
||||
}
|
||||
// Check for presenter files end
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('No check for location sessions.');
|
||||
}
|
||||
|
||||
console.log('Location cache check finished.');
|
||||
return true;
|
||||
}
|
||||
|
||||
exports.launcher_render = async function (launcher) {
|
||||
console.log('Rendering launcher...');
|
||||
document.getElementById('location_title').innerHTML = '<h1>Launcher '+launcher.location.name+'@'+launcher.event.name+'</h1>';
|
||||
|
||||
document.getElementById('event_files_menu').innerHTML = '<h2>Event Files</h2>';
|
||||
document.getElementById('event_files_menu').innerHTML += '<ul class="">';
|
||||
for (var i in launcher.event_files) {
|
||||
document.getElementById('event_files_menu').innerHTML += '<li id="menu_event_file_id_'+launcher.event_files[i].id+'" class="btn btn-info btn_no_case open_local_file" data-hash_sha256="'+launcher.event_files[i].hash_sha256+'.file" data-filename="'+launcher.event_files[i].event_file_filename+'">'+launcher.event_files[i].event_file_filename+'</li>';
|
||||
}
|
||||
document.getElementById('event_files_menu').innerHTML += '</ul>';
|
||||
|
||||
document.getElementById('location_files_menu').innerHTML = '<h2>Location Files</h2>';
|
||||
document.getElementById('location_files_menu').innerHTML += '<ul class="" role="">';
|
||||
for (var i in launcher.location_files) {
|
||||
document.getElementById('location_files_menu').innerHTML += '<li id="menu_event_file_id_'+launcher.location_files[i].id+'" class="btn btn-info open_local_file" data-hash_sha256="'+launcher.location_files[i].hash_sha256+'.file" data-filename="'+launcher.location_files[i].event_file_filename+'">'+launcher.location_files[i].event_file_filename+'</li>';
|
||||
}
|
||||
document.getElementById('location_files_menu').innerHTML += '</ul>';
|
||||
|
||||
document.getElementById('sessions_menu').innerHTML = '<h2>Sessions</h2>';
|
||||
document.getElementById('sessions_menu').innerHTML += '<ul class="" role="">';
|
||||
//let location_detail = '';
|
||||
if (document.getElementById('location_detail').innerHTML.length) {
|
||||
console.log('detail_session_id_xx already exists');
|
||||
} else {
|
||||
console.log('location_detail already populated');
|
||||
document.getElementById('location_detail').innerHTML = ''; // This needs to be reviewed.
|
||||
}
|
||||
for (var i in launcher.sessions) {
|
||||
// List sessions in menu
|
||||
document.getElementById('sessions_menu').innerHTML += '<li id="menu_session_id_'+launcher.sessions[i].id+'" class="btn btn-info btn_view_session" data-session_id="'+launcher.sessions[i].id+'">'+launcher.sessions[i].name+'</li>';
|
||||
|
||||
// Create containers for each session
|
||||
let session_detail = '';
|
||||
|
||||
if (typeof(document.getElementById('detail_session_id_'+launcher.sessions[i].id)) != 'undefined' && document.getElementById('detail_session_id_'+launcher.sessions[i].id) != null) {
|
||||
//console.log('detail_session_id_xx already exists');
|
||||
} else {
|
||||
//console.log('Adding detail_session_id_xx');
|
||||
session_detail += '<div id="detail_session_id_'+launcher.sessions[i].id+'" class="container d-none session_detail" data-session_id="'+launcher.sessions[i].id+'">';
|
||||
}
|
||||
|
||||
|
||||
|
||||
var session_startdatetime = new Date(launcher.sessions[i].start_datetime);
|
||||
|
||||
session_detail += '<h2 class="session_title">'+launcher.sessions[i].name+'<span class="badge badge-pill badge-info float-right">'+dateFns.format(session_startdatetime, 'ddd h:mm A')+'</span>'+'</h2>';
|
||||
|
||||
|
||||
//session_detail += '<div class="">'; // for card-group
|
||||
|
||||
session_detail += '<div class="card">';
|
||||
session_detail += '<div class="card-header">Session Files:</div>';
|
||||
session_detail += '<div class="card-body">';
|
||||
|
||||
session_detail += '<ul>';
|
||||
for (var j in launcher.sessions[i].files) {
|
||||
//console.log(launcher.sessions[i].files[j].event_file_filename);
|
||||
session_detail += '<li class="btn btn-info open_local_file" data-hash_sha256="'+launcher.sessions[i].files[j].hash_sha256+'.file" data-filename="'+launcher.sessions[i].files[j].event_file_filename+'">'+launcher.sessions[i].files[j].event_file_filename+'</li>';
|
||||
}
|
||||
session_detail += '</ul>';
|
||||
|
||||
session_detail += '</div>'; // for card-body
|
||||
session_detail += '</div> <!-- for session files card -->'; // for session files card
|
||||
|
||||
|
||||
//session_detail += '<div class="session_presentations">';
|
||||
|
||||
for (var j in launcher.sessions[i].presentations) {
|
||||
//session_detail += '<li>'+launcher.sessions[i].presentations[j].name;
|
||||
|
||||
var session_presentation_startdatetime = new Date(launcher.sessions[i].presentations[j].start_datetime);
|
||||
|
||||
session_detail += '<div class="card">';
|
||||
session_detail += '<div class="card-header">'+launcher.sessions[i].presentations[j].name+'<span class="badge badge-pill badge-info float-right">'+dateFns.format(session_startdatetime, 'h:mm a')+'</span>'+':</div>';
|
||||
session_detail += '<div class="card-body">';
|
||||
|
||||
session_detail += '<ul class="list-group">';
|
||||
for (var k in launcher.sessions[i].presentations[j].files) {
|
||||
//console.log(launcher.sessions[i].presentations[j].files[k].event_file_filename);
|
||||
session_detail += '<li class="list-group-item btn btn-info open_local_file" data-hash_sha256="'+launcher.sessions[i].presentations[j].files[k].hash_sha256+'.file" data-filename="'+launcher.sessions[i].presentations[j].files[k].event_file_filename+'">'+launcher.sessions[i].presentations[j].files[k].event_file_filename+'</li>';
|
||||
}
|
||||
session_detail += '</ul>';
|
||||
|
||||
|
||||
session_detail += '<ul>';
|
||||
for (var k in launcher.sessions[i].presentations[j].presenters) {
|
||||
//console.log(launcher.sessions[i].presentations[j].presenters[k].given_name);
|
||||
session_detail += '<li>'+launcher.sessions[i].presentations[j].presenters[k].given_name+' '+launcher.sessions[i].presentations[j].presenters[k].family_name;
|
||||
|
||||
session_detail += '<ul class="list-group">';
|
||||
for (var l in launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
//console.log(launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename);
|
||||
//session_detail += '<li class="list-group-item" data-hash_sha256="'+launcher.sessions[i].presentations[j].presenters[k].files[l].hash_sha256+'.file" data-filename="'+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+'">'+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename;
|
||||
session_detail += '<li class="list-group-item" data-hash_sha256="'+launcher.sessions[i].presentations[j].presenters[k].files[l].hash_sha256+'.file" data-filename="'+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+'">';
|
||||
session_detail += '<button class="btn btn-info open_local_file" data-hash_sha256="'+launcher.sessions[i].presentations[j].presenters[k].files[l].hash_sha256+'.file" data-filename="'+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+'">'+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+'</button>';
|
||||
|
||||
var event_file_size = launcher.sessions[i].presentations[j].presenters[k].files[l].size;
|
||||
var event_file_created_on = new Date(launcher.sessions[i].presentations[j].presenters[k].files[l].created_on);
|
||||
|
||||
session_detail += '<span class="badge badge-pill badge-light float-right">'+format_bytes(event_file_size, 2)+'; '+dateFns.format(event_file_created_on, 'MMM M h:mm A')+'; '+launcher.sessions[i].presentations[j].presenters[k].files[l].internal_os+'</span>';
|
||||
|
||||
|
||||
session_detail += '</li>';
|
||||
}
|
||||
session_detail += '</ul>';
|
||||
|
||||
session_detail +='</li>';
|
||||
}
|
||||
session_detail += '</ul>';
|
||||
|
||||
|
||||
session_detail += '</ul>';
|
||||
session_detail += '</div>'; // for card-body
|
||||
session_detail += '</div> <!-- for card -->'; // for card
|
||||
|
||||
}
|
||||
//session_detail += '</div> <!-- for session_presentations -->'; // for session_presentations
|
||||
|
||||
//session_detail += '</div>'; // for card-group
|
||||
session_detail += '</div> <!-- End session detail for '+launcher.sessions[i].id+' -->';
|
||||
|
||||
|
||||
//document.getElementById('location_detail').innerHTML += session_detail;
|
||||
|
||||
if (typeof(document.getElementById('detail_session_id_'+launcher.sessions[i].id)) != 'undefined' && document.getElementById('detail_session_id_'+launcher.sessions[i].id) != null) {
|
||||
document.getElementById('detail_session_id_'+launcher.sessions[i].id).innerHTML = session_detail;
|
||||
} else {
|
||||
document.getElementById('location_detail').innerHTML += session_detail;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
document.getElementById('sessions_menu').innerHTML += '</ul>';
|
||||
|
||||
index_location_detail('btn_view_session');
|
||||
|
||||
index_open_file_buttons('open_local_file');
|
||||
|
||||
|
||||
//const btn_session_{{ event_presentation.id }}_name = document.querySelector('button#presentation_{{ event_presentation.id }}_name');
|
||||
//btn_presentation_{{ event_presentation.id }}_name.onclick = display_hide_poster_for_type_id.bind(this, true, 'presentation', {{ event_presentation.id }});
|
||||
console.log('Rendering launcher finished.');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Updated 2019-12-19 */
|
||||
function index_location_detail(class_name) {
|
||||
var class_elements = document.getElementsByClassName(class_name);
|
||||
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
class_elements[i].addEventListener( 'click', function() {view_session( this.getAttribute('data-session_id')) } );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Updated 2019-12-19 */
|
||||
function view_session(session_id) {
|
||||
var class_elements = document.getElementsByClassName('session_detail');
|
||||
console.log('*** Session ID: '+session_id);
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
console.log('*** checking: '+class_elements[i].getAttribute('data-session_id'));
|
||||
if (class_elements[i].getAttribute('data-session_id') == session_id) {
|
||||
console.log('show');
|
||||
class_elements[i].classList.remove('d-none');
|
||||
class_elements[i].classList.add('d-block');
|
||||
} else {
|
||||
console.log('hide');
|
||||
class_elements[i].classList.remove('d-block');
|
||||
class_elements[i].classList.add('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Updated 2019-12-20 */
|
||||
function index_open_file_buttons(class_name) {
|
||||
var class_elements = document.getElementsByClassName(class_name);
|
||||
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
//class_elements[i].addEventListener( 'click', function() {open_local_file( this.getAttribute('data-filename')) } );
|
||||
|
||||
//let directory = 'file_cache/';
|
||||
|
||||
//directory_and_filename = path.join(directory, class_elements[i].getAttribute('data-filename'));
|
||||
|
||||
let file_path = path.join(file_cache_path, class_elements[i].getAttribute('data-hash_sha256'));
|
||||
let filename = class_elements[i].getAttribute('data-filename');
|
||||
|
||||
class_elements[i].addEventListener( 'click', function() { ipcRenderer.send('open_local_file', file_path, filename) } );
|
||||
//ipcRenderer.send('open_local_file', this.getAttribute('data-filename')); // in render thread
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function format_bytes(bytes, decimals = 2) {
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
|
||||
const k = 1024;
|
||||
const dm = decimals < 0 ? 0 : decimals;
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
||||
}
|
||||
331
app/js/module_api.js
Normal file
331
app/js/module_api.js
Normal file
@@ -0,0 +1,331 @@
|
||||
/*
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const { ipcRenderer } = require('electron');
|
||||
*/
|
||||
|
||||
exports.api_token_request_async = async function (axios, secret_key) {
|
||||
console.log('Requesting API temporary token...');
|
||||
const url = '/api_token_request';
|
||||
|
||||
let data = { secret_key: secret_key };
|
||||
|
||||
const response = await axios.post(url, data)
|
||||
.then(function (response) {
|
||||
//console.log(response);
|
||||
const api_temporary_token = response.data.temporary_token;
|
||||
//console.log('API Temporary Token: '+temporary_token);
|
||||
return api_temporary_token;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error(error);
|
||||
return error;
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
exports.get_event_details = async function (axios, event_id) {
|
||||
console.log('Requesting event details...');
|
||||
const url = '/event/'+event_id;
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.get_event_location_details = async function (axios, event_id, event_location_id) {
|
||||
console.log('Requesting event location details...');
|
||||
const url = '/event/'+event_id+'/location/'+event_location_id;
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.get_event_location_sessions = async function (axios, event_id, event_location_id) {
|
||||
console.log('Requesting location sessions...');
|
||||
const url = '/event/'+event_id+'/location/'+event_location_id+'/session';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.get_session_presentations = async function (axios, event_id, event_session_id) {
|
||||
console.log('Requesting session presentations...');
|
||||
const url = '/event/'+event_id+'/session/'+event_session_id+'/presentation';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.get_presentation_presenters = async function (axios, event_id, event_session_id, event_presentation_id) {
|
||||
console.log('Requesting presentation presenters...');
|
||||
const url = '/event/'+event_id+'/session/'+event_session_id+'/presentation/'+event_presentation_id+'/presenter';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.get_files_for_type_for_id = async function (axios, for_type, for_id) {
|
||||
console.log('Requesting files for '+for_type+' '+for_id);
|
||||
const url = '/event/file/'+for_type+'/'+for_id;
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/*
|
||||
exports.download_file_id = async function (axios, file_id, filename) {
|
||||
|
||||
ipcRenderer.send('download_file', api_base_url, api_endpoint, api_temporary_token, save_path); // in render thread
|
||||
|
||||
console.log('1: download file id '+file_id);
|
||||
const url = '/event/file/'+file_id+'/download';
|
||||
|
||||
//const data = await axios.get(url, responseType: 'stream')
|
||||
const data = await axios({
|
||||
method: "get",
|
||||
url: url,
|
||||
responseType: "stream"
|
||||
})
|
||||
.then(function (response) {
|
||||
console.log('2: downloaded file id '+file_id);
|
||||
console.log(response);
|
||||
//console.log(response.data);
|
||||
|
||||
let filename = 'default.txt';
|
||||
|
||||
if (typeof filename_override === 'undefined' || filename_override == null) {
|
||||
let headerLine = response.data.headers['content-disposition'];
|
||||
|
||||
console.log(headerLine);
|
||||
console.log(headerLine.indexOf('="'));
|
||||
console.log(headerLine.indexOf('='));
|
||||
if (headerLine.indexOf('="') != -1) {
|
||||
let startFileNameIndex = headerLine.indexOf('="') + 2;
|
||||
let endFileNameIndex = headerLine.lastIndexOf('"');
|
||||
filename = headerLine.substring(startFileNameIndex, endFileNameIndex);
|
||||
} else if (headerLine.indexOf('=') != -1) {
|
||||
let startFileNameIndex = headerLine.indexOf('=') + 1;
|
||||
let endFileNameIndex = headerLine.length;
|
||||
filename = headerLine.substring(startFileNameIndex, endFileNameIndex);
|
||||
} else {
|
||||
filename = 'filename_not_found_in_header.txt';
|
||||
}
|
||||
} else {
|
||||
filename = filename_override;
|
||||
}
|
||||
|
||||
let directory = 'file_cache/';
|
||||
|
||||
directory_and_filename = path.join(directory, filename);
|
||||
|
||||
//console.log(directory_and_filename);
|
||||
|
||||
if (fs.existsSync(directory_and_filename)) {
|
||||
console.log('3a: file already exists: '+directory_and_filename);
|
||||
} else {
|
||||
console.log('3b: saving file: '+directory_and_filename);
|
||||
response.data.pipe(fs.createWriteStream(directory_and_filename));
|
||||
}
|
||||
//data = response.data;
|
||||
console.log('4: saved file id '+file_id);
|
||||
return true;
|
||||
//return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
//return data;
|
||||
}
|
||||
*/
|
||||
|
||||
/* v2 Section */
|
||||
|
||||
exports.v2_get_account_events = async function (axios, account_id) {
|
||||
console.log('Requesting account events...');
|
||||
const url = '/v2/account/'+account_id+'/events';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log('v2 account events data: ***');
|
||||
console.log(response.data);
|
||||
console.log('v2 account events data: ^^^');
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.v2_get_event_locations = async function (axios, event_id) {
|
||||
console.log('Requesting event locations...');
|
||||
const url = '/v2/event/'+event_id+'/event_locations';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log('v2 event locations data: ***');
|
||||
console.log(response.data);
|
||||
console.log('v2 event locations 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';
|
||||
|
||||
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_presentations = async function (axios, event_location_id) {
|
||||
console.log('Requesting location presentations...');
|
||||
const url = '/v2/event_location/'+event_location_id+'/event_presentations';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log('v2 location presentations data: ***');
|
||||
console.log(response.data);
|
||||
console.log('v2 location presentations data: ^^^');
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.v2_get_event_location_presenters = async function (axios, event_location_id) {
|
||||
console.log('Requesting location presenters...');
|
||||
const url = '/v2/event_location/'+event_location_id+'/event_presenters';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log('v2 location presenters data: ***');
|
||||
console.log(response.data);
|
||||
console.log('v2 location presenters data: ^^^');
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.v2_get_event_location_files = async function (axios, event_location_id) {
|
||||
console.log('Requesting location files...');
|
||||
const url = '/v2/event_location/'+event_location_id+'/event_files';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
console.log('v2 location files data: ***');
|
||||
console.log(response.data);
|
||||
console.log('v2 location files data: ^^^');
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
300
app/js/module_api.js.bak
Normal file
300
app/js/module_api.js.bak
Normal file
@@ -0,0 +1,300 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const { ipcRenderer } = require('electron');
|
||||
|
||||
exports.api_token_request_async = async function (axios, secret_key) {
|
||||
console.log('Requesting API temporary token...');
|
||||
const url = '/api_token_request';
|
||||
|
||||
let data = { secret_key: secret_key };
|
||||
|
||||
const response = await axios.post(url, data)
|
||||
.then(function (response) {
|
||||
//console.log(response);
|
||||
const api_temporary_token = response.data.temporary_token;
|
||||
//console.log('API Temporary Token: '+temporary_token);
|
||||
return api_temporary_token;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error(error);
|
||||
return error;
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
exports.get_event_location_sessions = async function (axios, event_id, event_location_id) {
|
||||
console.log('Requesting location sessions...');
|
||||
const url = '/event/'+event_id+'/location/'+event_location_id+'/session';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.get_session_presentations = async function (axios, event_id, event_session_id) {
|
||||
console.log('Requesting session presentations...');
|
||||
const url = '/event/'+event_id+'/session/'+event_session_id+'/presentation';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.get_presentation_presenters = async function (axios, event_id, event_session_id, event_presentation_id) {
|
||||
console.log('Requesting presentation presenters...');
|
||||
const url = '/event/'+event_id+'/session/'+event_session_id+'/presentation/'+event_presentation_id+'/presenter';
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.get_files_for_type_for_id = async function (axios, for_type, for_id) {
|
||||
console.log('Requesting files...');
|
||||
const url = '/event/file/'+for_type+'/'+for_id;
|
||||
|
||||
const data = await axios.get(url)
|
||||
.then(function (response) {
|
||||
//console.log(response.data);
|
||||
//data = response.data;
|
||||
return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
exports.download_file_id = async function (axios, file_id, filename) {
|
||||
|
||||
ipcRenderer.send('download_file', api_base_url, api_endpoint, api_temporary_token, save_path); // in render thread
|
||||
|
||||
console.log('1: download file id '+file_id);
|
||||
const url = '/event/file/'+file_id+'/download';
|
||||
|
||||
//const data = await axios.get(url, responseType: 'stream')
|
||||
const data = await axios({
|
||||
method: "get",
|
||||
url: url,
|
||||
responseType: "stream"
|
||||
})
|
||||
.then(function (response) {
|
||||
console.log('2: downloaded file id '+file_id);
|
||||
console.log(response);
|
||||
//console.log(response.data);
|
||||
|
||||
let filename = 'default.txt';
|
||||
|
||||
if (typeof filename_override === 'undefined' || filename_override == null) {
|
||||
let headerLine = response.data.headers['content-disposition'];
|
||||
|
||||
console.log(headerLine);
|
||||
console.log(headerLine.indexOf('="'));
|
||||
console.log(headerLine.indexOf('='));
|
||||
if (headerLine.indexOf('="') != -1) {
|
||||
let startFileNameIndex = headerLine.indexOf('="') + 2;
|
||||
let endFileNameIndex = headerLine.lastIndexOf('"');
|
||||
filename = headerLine.substring(startFileNameIndex, endFileNameIndex);
|
||||
} else if (headerLine.indexOf('=') != -1) {
|
||||
let startFileNameIndex = headerLine.indexOf('=') + 1;
|
||||
let endFileNameIndex = headerLine.length;
|
||||
filename = headerLine.substring(startFileNameIndex, endFileNameIndex);
|
||||
} else {
|
||||
filename = 'filename_not_found_in_header.txt';
|
||||
}
|
||||
} else {
|
||||
filename = filename_override;
|
||||
}
|
||||
|
||||
let directory = 'file_cache/';
|
||||
|
||||
directory_and_filename = path.join(directory, filename);
|
||||
|
||||
//console.log(directory_and_filename);
|
||||
|
||||
if (fs.existsSync(directory_and_filename)) {
|
||||
console.log('3a: file already exists: '+directory_and_filename);
|
||||
} else {
|
||||
console.log('3b: saving file: '+directory_and_filename);
|
||||
response.data.pipe(fs.createWriteStream(directory_and_filename));
|
||||
}
|
||||
//data = response.data;
|
||||
console.log('4: saved file id '+file_id);
|
||||
return true;
|
||||
//return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
//return data;
|
||||
}
|
||||
|
||||
exports.launcher_cache = async function (launcher, api_base_url, api_endpoint, api_temporary_token, file_cache_path) {
|
||||
if (typeof launcher.sessions === 'undefined') {
|
||||
console.log('Check for location files.');
|
||||
let for_id = launcher.event_location_id;
|
||||
launcher.files = await api.get_files_for_type_for_id(axios, 'location', for_id);
|
||||
for (var i in launcher.files) {
|
||||
console.log('f: ('+launcher.files[i].event_file_id+') '+launcher.files[i].event_file_filename+' ***')
|
||||
file_id = launcher.files[i].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.files[i].hash_sha256+'.file';
|
||||
|
||||
save_path = path.join(file_cache_path, filename);
|
||||
|
||||
//console.log(directory_and_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);
|
||||
const 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.
|
||||
//response.data.pipe(fs.createWriteStream(directory_and_filename));
|
||||
}
|
||||
//let results = await api.download_file_id(axios, file_id, hash_sha256);
|
||||
|
||||
}
|
||||
} else {
|
||||
console.log('No check for location files.');
|
||||
}
|
||||
|
||||
if (typeof launcher.sessions === 'undefined') {
|
||||
console.log('Check for location sessions.');
|
||||
launcher.sessions = await api.get_event_location_sessions(axios, launcher.event_id, launcher.event_location_id);
|
||||
for (var i in launcher.sessions) {
|
||||
console.log('*** '+launcher.sessions[i].name+' ***')
|
||||
|
||||
// Check for session files start
|
||||
if (typeof launcher.sessions[i].files === 'undefined') {
|
||||
console.log('Check for session files.');
|
||||
let for_id = launcher.sessions[i].id;
|
||||
launcher.sessions[i].files = await api.get_files_for_type_for_id(axios, 'session', for_id);
|
||||
if (launcher.sessions[i].files) {
|
||||
console.log('Session files found.');
|
||||
for (var j in launcher.sessions[i].files) {
|
||||
console.log('f: ('+launcher.sessions[i].files[j].event_file_id+') '+launcher.sessions[i].files[j].event_file_filename+' ***');
|
||||
file_id = launcher.sessions[i].files[j].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
hash_sha256 = launcher.sessions[i].files[j].hash_sha256+'.file';
|
||||
let results = await api.download_file_id(axios, file_id, hash_sha256);
|
||||
}
|
||||
} else {
|
||||
console.log('No session files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for session files.');
|
||||
}
|
||||
// Check for session files end
|
||||
|
||||
// Get session presentations and associated files
|
||||
launcher.sessions[i].presentations = await api.get_session_presentations(axios, launcher.event_id, launcher.sessions[i].id);
|
||||
for (var j in launcher.sessions[i].presentations) {
|
||||
console.log('* '+launcher.sessions[i].presentations[j].name);
|
||||
|
||||
// Check for presentation files start
|
||||
if (typeof launcher.sessions[i].presentations[j].files === 'undefined') {
|
||||
console.log('Check for presentation files.');
|
||||
let for_id = launcher.sessions[i].presentations[j].id;
|
||||
launcher.sessions[i].presentations[j].files = await api.get_files_for_type_for_id(axios, 'presentation', for_id);
|
||||
if (launcher.sessions[i].presentations[j].files) {
|
||||
console.log('Presentation files found.');
|
||||
for (var k in launcher.sessions[i].presentations[j].files) {
|
||||
console.log('f: ('+launcher.sessions[i].presentations[j].files[k].event_file_id+') '+launcher.sessions[i].presentations[j].files[k].event_file_filename+' ***');
|
||||
file_id = launcher.sessions[i].presentations[j].files[k].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
hash_sha256 = launcher.sessions[i].presentations[j].files[k].hash_sha256+'.file';
|
||||
let results = await api.download_file_id(axios, file_id, hash_sha256);
|
||||
}
|
||||
} else {
|
||||
console.log('No presentation files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for presentation files.');
|
||||
}
|
||||
// Check for presentation files end
|
||||
|
||||
|
||||
// Get session presentations presenters and associated files
|
||||
//let event_presentation_id = launcher.sessions[i].presentations[j].id;
|
||||
launcher.sessions[i].presentations[j].presenters = await api.get_presentation_presenters(axios, launcher.event_id, launcher.sessions[i].id, launcher.sessions[i].presentations[j].id);
|
||||
for (var k in launcher.sessions[i].presentations[j].presenters) {
|
||||
console.log('-- '+launcher.sessions[i].presentations[j].presenters[k].given_name+' '+launcher.sessions[i].presentations[j].presenters[k].family_name)
|
||||
|
||||
// Check for presenter files start
|
||||
if (typeof launcher.sessions[i].presentations[j].presenters[k].files === 'undefined') {
|
||||
console.log('Check for presenter files.');
|
||||
let for_id = launcher.sessions[i].presentations[j].presenters[k].id;
|
||||
launcher.sessions[i].presentations[j].presenters[k].files = await api.get_files_for_type_for_id(axios, 'presenter', for_id);
|
||||
if (launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
console.log('Presenter files found.');
|
||||
for (var l in launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
console.log('f: ('+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id+') '+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+' ***')
|
||||
file_id = launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
hash_sha256 = launcher.sessions[i].presentations[j].presenters[k].files[l].hash_sha256+'.file';
|
||||
let results = await api.download_file_id(axios, file_id, hash_sha256);
|
||||
}
|
||||
} else {
|
||||
console.log('No presenter files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for presenter files.');
|
||||
}
|
||||
// Check for presenter files end
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('No check for location sessions.');
|
||||
}
|
||||
/*
|
||||
if (launcher.sessions) {
|
||||
console.log('Check for session files.');
|
||||
let for_id = launcher.event_location_id;
|
||||
launcher.files = await api.get_files_for_type_for_id(axios, 'location', for_id);
|
||||
for (var i in launcher.sessions) {
|
||||
console.log('f: ('+launcher.sessions[i].event_file_id+') '+launcher.files[i].event_file_filename+' ***')
|
||||
file_id = launcher.files[i].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let results = await api.download_file_id(axios, file_id);
|
||||
}
|
||||
} else {
|
||||
console.log('No check for location files.');
|
||||
}
|
||||
*/
|
||||
}
|
||||
67
app/js/module_app.js
Normal file
67
app/js/module_app.js
Normal file
@@ -0,0 +1,67 @@
|
||||
'use strict';
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
exports.load_config = function () {
|
||||
console.log('CWD: '+process.cwd());
|
||||
|
||||
let home_directory = require('os').homedir();
|
||||
console.log('Home: '+home_directory);
|
||||
|
||||
let tmp_directory = require('os').tmpdir();
|
||||
console.log('Temporary: '+tmp_directory);
|
||||
|
||||
let config = null;
|
||||
let config_directory = null;
|
||||
let default_config_path = path.join(process.cwd(),'config.json.default');
|
||||
let config_path = null;
|
||||
|
||||
if (os.platform == 'darwin') {
|
||||
config_directory = path.join(home_directory, 'Library/Application Support/OSIT');
|
||||
console.log('macOS config directory: '+config_directory);
|
||||
} else if (os.platform == 'linux') {
|
||||
config_directory = path.join(home_directory, '.config/OSIT');
|
||||
console.log('Linux config directory: '+config_directory);
|
||||
}
|
||||
|
||||
if (fs.existsSync(config_directory)) {
|
||||
console.log('Config: '+config_directory);
|
||||
config_path = path.join(config_directory, 'config.json');
|
||||
} else {
|
||||
fs.mkdirSync(config_directory);
|
||||
console.log('Config directory created: '+config_directory);
|
||||
|
||||
//default_config_path = path.join(process.cwd(),'config.json.default');
|
||||
config_path = path.join(config_directory, 'config.json');
|
||||
fs.copyFileSync(default_config_path, config_path);
|
||||
console.log('Default config file copied: '+config_directory);
|
||||
}
|
||||
|
||||
if (fs.existsSync(config_path)) {
|
||||
console.log('Config path: '+config_path);
|
||||
console.log('Config file (config.json) found under '+config_directory+'.');
|
||||
|
||||
config = JSON.parse(fs.readFileSync(config_path));
|
||||
console.log('Config file read.');
|
||||
} else if (!fs.existsSync(config_path)) {
|
||||
fs.copyFileSync(default_config_path, config_path);
|
||||
console.log('Default config file copied: '+config_directory);
|
||||
|
||||
config = JSON.parse(fs.readFileSync(config_path));
|
||||
console.log('Config file read.');
|
||||
} else if (fs.existsSync('config.json')) {
|
||||
//fs.copyFileSync(default_config_path, config_path);
|
||||
//console.log('Default config file copied: '+config_directory);
|
||||
|
||||
config = JSON.parse(fs.readFileSync('config.json'));
|
||||
console.log('Config file (config.json) not found under '+config_directory+'. Using config in CWD.');
|
||||
console.log('Config file read.');
|
||||
|
||||
//console.log('Config file (config.json) not found under '+config_directory+'. Using config in CWD.');
|
||||
//config = JSON.parse(fs.readFileSync('config.json'));
|
||||
} else {
|
||||
//close();
|
||||
}
|
||||
return config;
|
||||
}
|
||||
271
app/js/module_app_idb 2020-01-21.js.bak
Normal file
271
app/js/module_app_idb 2020-01-21.js.bak
Normal file
@@ -0,0 +1,271 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const { ipcRenderer } = require('electron');
|
||||
|
||||
|
||||
exports.launcher_cache_check = async function (launcher, api_base_url, api_temporary_token, host_file_cache_path) {
|
||||
if (typeof launcher.event === 'undefined') {
|
||||
launcher.event = await api.get_event_details(axios, launcher.event_id);
|
||||
tbl_event.setItem(launcher.event.id.toString(), launcher.event);
|
||||
/*
|
||||
.then(function (data) {
|
||||
console.log(data.id);
|
||||
idbKeyval.set(data.id, data, tbl_event);
|
||||
//for (var i in response) {
|
||||
//var event_record = data[i];
|
||||
//idbKeyval.set(response[i].id, response[i], tbl_event);
|
||||
//}
|
||||
});
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
if (typeof launcher.location === 'undefined') {
|
||||
launcher.location = await api.get_event_location_details(axios, launcher.event_id, launcher.event_location_id);
|
||||
tbl_event_location.setItem(launcher.location.id.toString(), launcher.location);
|
||||
}
|
||||
|
||||
if (typeof launcher.event_files === 'undefined') {
|
||||
console.log('Check for global event files.');
|
||||
let for_id = launcher.event_id;
|
||||
launcher.event_files = await api.get_files_for_type_for_id(axios, 'event', for_id);
|
||||
for (var i in launcher.event_files) {
|
||||
console.log('f: ('+launcher.event_files[i].event_file_id+') '+launcher.event_files[i].event_file_filename+' ***')
|
||||
tbl_event_file.setItem(launcher.event_files[i].event_file_id.toString(), launcher.event_files[i]);
|
||||
|
||||
file_id = launcher.event_files[i].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.event_files[i].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('No check for global event files');
|
||||
}
|
||||
|
||||
|
||||
if (typeof launcher.location_files === 'undefined') {
|
||||
console.log('Check for location specific files.');
|
||||
let for_id = launcher.event_location_id;
|
||||
launcher.location_files = await api.get_files_for_type_for_id(axios, 'location', for_id);
|
||||
for (var i in launcher.location_files) {
|
||||
console.log('f: ('+launcher.location_files[i].event_file_id+') '+launcher.location_files[i].event_file_filename+' ***')
|
||||
tbl_event_file.setItem(launcher.location_files[i].event_file_id.toString(), launcher.location_files[i]);
|
||||
|
||||
file_id = launcher.location_files[i].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.location_files[i].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('No check for location specific files.');
|
||||
}
|
||||
|
||||
|
||||
if (typeof launcher.sessions === 'undefined') {
|
||||
console.log('Check for location sessions.');
|
||||
launcher.sessions = await api.get_event_location_sessions(axios, launcher.event_id, launcher.event_location_id);
|
||||
for (var i in launcher.sessions) {
|
||||
console.log('*** '+launcher.sessions[i].name+' ***')
|
||||
tbl_event_session.setItem(launcher.sessions[i].id.toString(), launcher.sessions[i]);
|
||||
|
||||
// Check for session files start
|
||||
if (typeof launcher.sessions[i].files === 'undefined') {
|
||||
console.log('Check for session files.');
|
||||
let for_id = launcher.sessions[i].id;
|
||||
launcher.sessions[i].files = await api.get_files_for_type_for_id(axios, 'session', for_id);
|
||||
if (launcher.sessions[i].files) {
|
||||
console.log('Session files found.');
|
||||
for (var j in launcher.sessions[i].files) {
|
||||
console.log('f: ('+launcher.sessions[i].files[j].event_file_id+') '+launcher.sessions[i].files[j].event_file_filename+' ***');
|
||||
tbl_event_file.setItem(launcher.sessions[i].files[j].event_file_id.toString(), launcher.sessions[i].files[j]);
|
||||
|
||||
file_id = launcher.sessions[i].files[j].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.sessions[i].files[j].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('No session files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for session files.');
|
||||
}
|
||||
// Check for session files end
|
||||
|
||||
// Get session presentations and associated files
|
||||
launcher.sessions[i].presentations = await api.get_session_presentations(axios, launcher.event_id, launcher.sessions[i].id);
|
||||
for (var j in launcher.sessions[i].presentations) {
|
||||
console.log('* '+launcher.sessions[i].presentations[j].name);
|
||||
tbl_event_presentation.setItem(launcher.sessions[i].presentations[j].id.toString(), launcher.sessions[i].presentations[j]);
|
||||
|
||||
// Check for presentation files start
|
||||
if (typeof launcher.sessions[i].presentations[j].files === 'undefined') {
|
||||
console.log('Check for presentation files.');
|
||||
let for_id = launcher.sessions[i].presentations[j].id;
|
||||
launcher.sessions[i].presentations[j].files = await api.get_files_for_type_for_id(axios, 'presentation', for_id);
|
||||
if (launcher.sessions[i].presentations[j].files) {
|
||||
console.log('Presentation files found.');
|
||||
for (var k in launcher.sessions[i].presentations[j].files) {
|
||||
console.log('f: ('+launcher.sessions[i].presentations[j].files[k].event_file_id+') '+launcher.sessions[i].presentations[j].files[k].event_file_filename+' ***');
|
||||
tbl_event_file.setItem(launcher.sessions[i].presentations[j].files[k].event_file_id.toString(), launcher.sessions[i].presentations[j].files[k]);
|
||||
|
||||
file_id = launcher.sessions[i].presentations[j].files[k].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.sessions[i].presentations[j].files[k].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('No presentation files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for presentation files.');
|
||||
}
|
||||
// Check for presentation files end
|
||||
|
||||
|
||||
// Get session presentations presenters and associated files
|
||||
//let event_presentation_id = launcher.sessions[i].presentations[j].id;
|
||||
launcher.sessions[i].presentations[j].presenters = await api.get_presentation_presenters(axios, launcher.event_id, launcher.sessions[i].id, launcher.sessions[i].presentations[j].id);
|
||||
for (var k in launcher.sessions[i].presentations[j].presenters) {
|
||||
console.log('-- '+launcher.sessions[i].presentations[j].presenters[k].given_name+' '+launcher.sessions[i].presentations[j].presenters[k].family_name)
|
||||
tbl_event_presenter.setItem(launcher.sessions[i].presentations[j].presenters[k].id.toString(), launcher.sessions[i].presentations[j].presenters[k]);
|
||||
|
||||
// Check for presenter files start
|
||||
if (typeof launcher.sessions[i].presentations[j].presenters[k].files === 'undefined') {
|
||||
console.log('Check for presenter files.');
|
||||
let for_id = launcher.sessions[i].presentations[j].presenters[k].id;
|
||||
launcher.sessions[i].presentations[j].presenters[k].files = await api.get_files_for_type_for_id(axios, 'presenter', for_id);
|
||||
if (launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
console.log('Presenter files found.');
|
||||
for (var l in launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
console.log('f: ('+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id+') '+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+' ***');
|
||||
tbl_event_file.setItem(launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id.toString(), launcher.sessions[i].presentations[j].presenters[k].files[l]);
|
||||
|
||||
file_id = launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.sessions[i].presentations[j].presenters[k].files[l].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('No presenter files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for presenter files.');
|
||||
}
|
||||
// Check for presenter files end
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('No check for location sessions.');
|
||||
}
|
||||
|
||||
console.log('Location cache check finished.');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Updated 2019-12-19 */
|
||||
function index_location_detail(class_name) {
|
||||
var class_elements = document.getElementsByClassName(class_name);
|
||||
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
class_elements[i].addEventListener( 'click', function() {view_session( this.getAttribute('data-session_id')) } );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Updated 2019-12-19 */
|
||||
function view_session(session_id) {
|
||||
var class_elements = document.getElementsByClassName('session_detail');
|
||||
console.log('*** Session ID: '+session_id);
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
console.log('*** checking: '+class_elements[i].getAttribute('data-session_id'));
|
||||
if (class_elements[i].getAttribute('data-session_id') == session_id) {
|
||||
console.log('show');
|
||||
class_elements[i].classList.remove('d-none');
|
||||
class_elements[i].classList.add('d-block');
|
||||
} else {
|
||||
console.log('hide');
|
||||
class_elements[i].classList.remove('d-block');
|
||||
class_elements[i].classList.add('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Updated 2019-12-20 */
|
||||
function index_open_file_buttons(class_name) {
|
||||
var class_elements = document.getElementsByClassName(class_name);
|
||||
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
//class_elements[i].addEventListener( 'click', function() {open_local_file( this.getAttribute('data-filename')) } );
|
||||
|
||||
//let directory = 'file_cache/';
|
||||
|
||||
//directory_and_filename = path.join(directory, class_elements[i].getAttribute('data-filename'));
|
||||
|
||||
let file_path = path.join(host_file_cache_path, class_elements[i].getAttribute('data-hash_sha256'));
|
||||
let filename = class_elements[i].getAttribute('data-filename');
|
||||
|
||||
class_elements[i].addEventListener( 'click', function() { ipcRenderer.send('open_local_file', file_path, filename) } );
|
||||
//ipcRenderer.send('open_local_file', this.getAttribute('data-filename')); // in render thread
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
368
app/js/module_app_idb 2020-01-24.js.bak
Normal file
368
app/js/module_app_idb 2020-01-24.js.bak
Normal file
@@ -0,0 +1,368 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const { ipcRenderer } = require('electron');
|
||||
|
||||
|
||||
exports.launcher_cache_check = async function (launcher, api_base_url, api_temporary_token, host_file_cache_path) {
|
||||
if (typeof launcher.event === 'undefined') {
|
||||
launcher.event = await api.get_event_details(axios, launcher.event_id);
|
||||
tbl_event.setItem(launcher.event.id.toString(), launcher.event);
|
||||
/*
|
||||
.then(function (data) {
|
||||
console.log(data.id);
|
||||
idbKeyval.set(data.id, data, tbl_event);
|
||||
//for (var i in response) {
|
||||
//var event_record = data[i];
|
||||
//idbKeyval.set(response[i].id, response[i], tbl_event);
|
||||
//}
|
||||
});
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
if (typeof launcher.location === 'undefined') {
|
||||
launcher.location = await api.get_event_location_details(axios, launcher.event_id, launcher.event_location_id);
|
||||
tbl_event_location.setItem(launcher.location.id.toString(), launcher.location);
|
||||
}
|
||||
|
||||
if (typeof launcher.event_files === 'undefined') {
|
||||
console.log('Check for global event files.');
|
||||
let for_id = launcher.event_id;
|
||||
launcher.event_files = await api.get_files_for_type_for_id(axios, 'event', for_id);
|
||||
for (var i in launcher.event_files) {
|
||||
console.log('f: ('+launcher.event_files[i].event_file_id+') '+launcher.event_files[i].event_file_filename+' ***')
|
||||
tbl_event_file.setItem(launcher.event_files[i].event_file_id.toString(), launcher.event_files[i]);
|
||||
|
||||
file_id = launcher.event_files[i].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.event_files[i].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('No check for global event files');
|
||||
}
|
||||
|
||||
|
||||
if (typeof launcher.location_files === 'undefined') {
|
||||
console.log('Check for location specific files.');
|
||||
let for_id = launcher.event_location_id;
|
||||
launcher.location_files = await api.get_files_for_type_for_id(axios, 'location', for_id);
|
||||
for (var i in launcher.location_files) {
|
||||
console.log('f: ('+launcher.location_files[i].event_file_id+') '+launcher.location_files[i].event_file_filename+' ***')
|
||||
tbl_event_file.setItem(launcher.location_files[i].event_file_id.toString(), launcher.location_files[i]);
|
||||
|
||||
file_id = launcher.location_files[i].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.location_files[i].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('No check for location specific files.');
|
||||
}
|
||||
|
||||
|
||||
if (typeof launcher.sessions === 'undefined') {
|
||||
console.log('Check for location sessions.');
|
||||
launcher.sessions = await api.get_event_location_sessions(axios, launcher.event_id, launcher.event_location_id);
|
||||
for (var i in launcher.sessions) {
|
||||
console.log('*** '+launcher.sessions[i].name+' ***')
|
||||
tbl_event_session.setItem(launcher.sessions[i].id.toString(), launcher.sessions[i]);
|
||||
|
||||
// Check for session files start
|
||||
if (typeof launcher.sessions[i].files === 'undefined') {
|
||||
console.log('Check for session files.');
|
||||
let for_id = launcher.sessions[i].id;
|
||||
launcher.sessions[i].files = await api.get_files_for_type_for_id(axios, 'session', for_id);
|
||||
if (launcher.sessions[i].files) {
|
||||
console.log('Session files found.');
|
||||
for (var j in launcher.sessions[i].files) {
|
||||
console.log('f: ('+launcher.sessions[i].files[j].event_file_id+') '+launcher.sessions[i].files[j].event_file_filename+' ***');
|
||||
tbl_event_file.setItem(launcher.sessions[i].files[j].event_file_id.toString(), launcher.sessions[i].files[j]);
|
||||
|
||||
file_id = launcher.sessions[i].files[j].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.sessions[i].files[j].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('No session files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for session files.');
|
||||
}
|
||||
// Check for session files end
|
||||
|
||||
// Get session presentations and associated files
|
||||
launcher.sessions[i].presentations = await api.get_session_presentations(axios, launcher.event_id, launcher.sessions[i].id);
|
||||
for (var j in launcher.sessions[i].presentations) {
|
||||
console.log('* '+launcher.sessions[i].presentations[j].name);
|
||||
tbl_event_presentation.setItem(launcher.sessions[i].presentations[j].id.toString(), launcher.sessions[i].presentations[j]);
|
||||
|
||||
// Check for presentation files start
|
||||
if (typeof launcher.sessions[i].presentations[j].files === 'undefined') {
|
||||
console.log('Check for presentation files.');
|
||||
let for_id = launcher.sessions[i].presentations[j].id;
|
||||
launcher.sessions[i].presentations[j].files = await api.get_files_for_type_for_id(axios, 'presentation', for_id);
|
||||
if (launcher.sessions[i].presentations[j].files) {
|
||||
console.log('Presentation files found.');
|
||||
for (var k in launcher.sessions[i].presentations[j].files) {
|
||||
console.log('f: ('+launcher.sessions[i].presentations[j].files[k].event_file_id+') '+launcher.sessions[i].presentations[j].files[k].event_file_filename+' ***');
|
||||
tbl_event_file.setItem(launcher.sessions[i].presentations[j].files[k].event_file_id.toString(), launcher.sessions[i].presentations[j].files[k]);
|
||||
|
||||
file_id = launcher.sessions[i].presentations[j].files[k].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.sessions[i].presentations[j].files[k].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('No presentation files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for presentation files.');
|
||||
}
|
||||
// Check for presentation files end
|
||||
|
||||
|
||||
// Get session presentations presenters and associated files
|
||||
//let event_presentation_id = launcher.sessions[i].presentations[j].id;
|
||||
launcher.sessions[i].presentations[j].presenters = await api.get_presentation_presenters(axios, launcher.event_id, launcher.sessions[i].id, launcher.sessions[i].presentations[j].id);
|
||||
for (var k in launcher.sessions[i].presentations[j].presenters) {
|
||||
console.log('-- '+launcher.sessions[i].presentations[j].presenters[k].given_name+' '+launcher.sessions[i].presentations[j].presenters[k].family_name)
|
||||
tbl_event_presenter.setItem(launcher.sessions[i].presentations[j].presenters[k].id.toString(), launcher.sessions[i].presentations[j].presenters[k]);
|
||||
|
||||
// Check for presenter files start
|
||||
if (typeof launcher.sessions[i].presentations[j].presenters[k].files === 'undefined') {
|
||||
console.log('Check for presenter files.');
|
||||
let for_id = launcher.sessions[i].presentations[j].presenters[k].id;
|
||||
launcher.sessions[i].presentations[j].presenters[k].files = await api.get_files_for_type_for_id(axios, 'presenter', for_id);
|
||||
if (launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
console.log('Presenter files found.');
|
||||
for (var l in launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
console.log('f: ('+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id+') '+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+' ***');
|
||||
tbl_event_file.setItem(launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id.toString(), launcher.sessions[i].presentations[j].presenters[k].files[l]);
|
||||
|
||||
file_id = launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = launcher.sessions[i].presentations[j].presenters[k].files[l].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('No presenter files found.');
|
||||
}
|
||||
} else {
|
||||
console.log('No check for presenter files.');
|
||||
}
|
||||
// Check for presenter files end
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('No check for location sessions.');
|
||||
}
|
||||
|
||||
console.log('Location cache check finished.');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
exports.idb_to_launcher = async function idb_to_launcher() {
|
||||
//tbl_example.iterate(tbl_check, tbl_check_success, tbl_check_error); //tbl_check(value, key, iteration)
|
||||
//let launcher = new Object();
|
||||
|
||||
// Look for *events*
|
||||
let tmp_event = [];
|
||||
tbl_event.iterate(function(event_value, key, iteration) {
|
||||
tmp_event.push(event_value);
|
||||
});
|
||||
launcher.event = tmp_event;
|
||||
|
||||
// Look for *event files*
|
||||
let tmp_event_file = []
|
||||
tbl_event_file.iterate(function(file_value, key, iteration) {
|
||||
//console.log('event id: '+launcher.event[0].id+' -> file_id: '+file_value.id+'for type: '+file_value.for_type+' for id: '+file_value.id);
|
||||
if (file_value.for_type == 'event' && launcher.event[0].id == file_value.for_id) {
|
||||
tmp_event_file.push(file_value);
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_launcher: Iterate tbl_event_file complete')
|
||||
});
|
||||
launcher.event_file = tmp_event_file;
|
||||
|
||||
|
||||
// Look for *locations*
|
||||
let tmp_event_location = []
|
||||
tbl_event_location.iterate(function(location_value, key, iteration) {
|
||||
tmp_event_location.push(location_value);
|
||||
});
|
||||
launcher.location = tmp_event_location;
|
||||
|
||||
// Look for *event location files*
|
||||
let tmp_event_location_file = []
|
||||
tbl_event_file.iterate(function(file_value, key, iteration) {
|
||||
if (file_value.for_type == 'location' && launcher.location[0].id == file_value.for_id) {
|
||||
tmp_event_location_file.push(file_value);
|
||||
}
|
||||
});
|
||||
launcher.location_file = tmp_event_location_file;
|
||||
|
||||
|
||||
// Look for *sessions*
|
||||
let tmp_event_session = []
|
||||
tbl_event_session.iterate(function(session_value, session_key, session_iteration) {
|
||||
//console.log('session id: '+session_value.id);
|
||||
|
||||
|
||||
// Look for *session files*
|
||||
session_value.file = [];
|
||||
tbl_event_file.iterate(function(session_file_value, session_file_key, session_file_iteration) {
|
||||
if (session_file_value.for_type == 'session' && session_value.id == session_file_value.for_id) {
|
||||
//console.log('session id: '+session_value.id+' -> file id: '+session_file_value.id);
|
||||
session_value.file.push(session_file_value)
|
||||
//tmp_event_session_file.push(session_file_value);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Look for *presentations per session*
|
||||
session_value.presentation = [];
|
||||
tbl_event_presentation.iterate(function(presentation_value, presentation_key, presentation_iteration) {
|
||||
if (session_value.id == presentation_value.event_session_id) {
|
||||
//console.log('session id: '+session_value.id+' -> presentation id: '+presentation_value.id);
|
||||
|
||||
|
||||
// Look for *presentation files*
|
||||
presentation_value.file = [];
|
||||
tbl_event_file.iterate(function(presentation_file_value, presentation_file_key, presentation_file_iteration) {
|
||||
if (presentation_file_value.for_type == 'presentation' && presentation_value.id == presentation_file_value.for_id) {
|
||||
presentation_value.file.push(presentation_file_value);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Look for *presenters per presentation*
|
||||
presentation_value.presenter = [];
|
||||
tbl_event_presenter.iterate(function(presenter_value, presenter_key, presenter_iteration) {
|
||||
if (presentation_value.id == presenter_value.event_presentation_id) {
|
||||
//console.log('presentation id: '+presentation_value.id+' -> presenter id: '+presenter_value.id);
|
||||
|
||||
// Look for *presenter files*
|
||||
presenter_value.file = [];
|
||||
tbl_event_file.iterate(function(presenter_file_value, presenter_file_key, presenter_file_iteration) {
|
||||
if (presenter_file_value.for_type == 'presenter' && presenter_value.id == presenter_file_value.for_id) {
|
||||
presenter_value.file.push(presenter_file_value);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//NOTE for some reason this is adding duplicate presenters to a session
|
||||
//NOTE is this iterating twice or something???
|
||||
/*
|
||||
tbl_event_file.iterate(function(presenter_file_value, key, iteration) {
|
||||
|
||||
});
|
||||
*/
|
||||
presentation_value.presenter.push(presenter_value);
|
||||
}
|
||||
});
|
||||
|
||||
//NOTE add in presenters and then presenter's files
|
||||
|
||||
|
||||
session_value.presentation.push(presentation_value);
|
||||
}//);
|
||||
|
||||
});
|
||||
//});
|
||||
|
||||
tmp_event_session.push(session_value);
|
||||
|
||||
}).then(function() {
|
||||
console.log('idb_to_launcher: Iterate tbl_event_session complete')
|
||||
});
|
||||
launcher.session = tmp_event_session;
|
||||
|
||||
/*
|
||||
console.log('v2 idb to launcher object: ***');
|
||||
console.log(launcher);
|
||||
console.log('v2 idb to launcher object: ^^^');
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
exports.check_file_cache = async function () {
|
||||
console.log('Checking the local file cache against the remote server.');
|
||||
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.event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = file_value.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.
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function tbl_check(value, key, iteration) {
|
||||
console.log(value);
|
||||
}
|
||||
|
||||
function tbl_check_success(result) {
|
||||
console.log(result);
|
||||
}
|
||||
function tbl_check_error(result) {
|
||||
console.log(result);
|
||||
}
|
||||
173
app/js/module_app_idb.js
Normal file
173
app/js/module_app_idb.js
Normal file
@@ -0,0 +1,173 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const { ipcRenderer } = require('electron');
|
||||
|
||||
|
||||
exports.create_load_idb = async function create_load_idb() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
exports.idb_to_launcher = async function idb_to_launcher() {
|
||||
//tbl_example.iterate(tbl_check, tbl_check_success, tbl_check_error); //tbl_check(value, key, iteration)
|
||||
//let launcher = new Object();
|
||||
|
||||
// Look for *events*
|
||||
let tmp_event = [];
|
||||
tbl_event.iterate(function(event_value, key, iteration) {
|
||||
tmp_event.push(event_value);
|
||||
});
|
||||
launcher.event = tmp_event;
|
||||
|
||||
// Look for *event files*
|
||||
let tmp_event_file = []
|
||||
tbl_event_file.iterate(function(file_value, key, iteration) {
|
||||
//console.log('event id: '+launcher.event[0].id+' -> file_id: '+file_value.id+'for type: '+file_value.for_type+' for id: '+file_value.id);
|
||||
if (file_value.for_type == 'event' && launcher.event[0].id == file_value.for_id) {
|
||||
tmp_event_file.push(file_value);
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_launcher: Iterate tbl_event_file complete')
|
||||
});
|
||||
launcher.event_file = tmp_event_file;
|
||||
|
||||
|
||||
// Look for *locations*
|
||||
let tmp_event_location = []
|
||||
tbl_event_location.iterate(function(location_value, key, iteration) {
|
||||
tmp_event_location.push(location_value);
|
||||
});
|
||||
launcher.location = tmp_event_location;
|
||||
|
||||
// Look for *event location files*
|
||||
let tmp_event_location_file = []
|
||||
tbl_event_file.iterate(function(file_value, key, iteration) {
|
||||
if (file_value.for_type == 'location' && launcher.location[0].id == file_value.for_id) {
|
||||
tmp_event_location_file.push(file_value);
|
||||
}
|
||||
});
|
||||
launcher.location_file = tmp_event_location_file;
|
||||
|
||||
|
||||
// Look for *sessions*
|
||||
let tmp_event_session = []
|
||||
tbl_event_session.iterate(function(session_value, session_key, session_iteration) {
|
||||
//console.log('session id: '+session_value.id);
|
||||
|
||||
|
||||
// Look for *session files*
|
||||
session_value.file = [];
|
||||
tbl_event_file.iterate(function(session_file_value, session_file_key, session_file_iteration) {
|
||||
if (session_file_value.for_type == 'session' && session_value.id == session_file_value.for_id) {
|
||||
//console.log('session id: '+session_value.id+' -> file id: '+session_file_value.id);
|
||||
session_value.file.push(session_file_value)
|
||||
//tmp_event_session_file.push(session_file_value);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Look for *presentations per session*
|
||||
session_value.presentation = [];
|
||||
tbl_event_presentation.iterate(function(presentation_value, presentation_key, presentation_iteration) {
|
||||
if (session_value.id == presentation_value.event_session_id) {
|
||||
//console.log('session id: '+session_value.id+' -> presentation id: '+presentation_value.id);
|
||||
|
||||
|
||||
// Look for *presentation files*
|
||||
presentation_value.file = [];
|
||||
tbl_event_file.iterate(function(presentation_file_value, presentation_file_key, presentation_file_iteration) {
|
||||
if (presentation_file_value.for_type == 'presentation' && presentation_value.id == presentation_file_value.for_id) {
|
||||
presentation_value.file.push(presentation_file_value);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Look for *presenters per presentation*
|
||||
presentation_value.presenter = [];
|
||||
tbl_event_presenter.iterate(function(presenter_value, presenter_key, presenter_iteration) {
|
||||
if (presentation_value.id == presenter_value.event_presentation_id) {
|
||||
//console.log('presentation id: '+presentation_value.id+' -> presenter id: '+presenter_value.id);
|
||||
|
||||
// Look for *presenter files*
|
||||
presenter_value.file = [];
|
||||
tbl_event_file.iterate(function(presenter_file_value, presenter_file_key, presenter_file_iteration) {
|
||||
if (presenter_file_value.for_type == 'presenter' && presenter_value.id == presenter_file_value.for_id) {
|
||||
presenter_value.file.push(presenter_file_value);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//NOTE for some reason this is adding duplicate presenters to a session
|
||||
//NOTE is this iterating twice or something???
|
||||
/*
|
||||
tbl_event_file.iterate(function(presenter_file_value, key, iteration) {
|
||||
|
||||
});
|
||||
*/
|
||||
presentation_value.presenter.push(presenter_value);
|
||||
}
|
||||
});
|
||||
|
||||
//NOTE add in presenters and then presenter's files
|
||||
|
||||
|
||||
session_value.presentation.push(presentation_value);
|
||||
}//);
|
||||
|
||||
});
|
||||
//});
|
||||
|
||||
tmp_event_session.push(session_value);
|
||||
|
||||
}).then(function() {
|
||||
console.log('idb_to_launcher: Iterate tbl_event_session complete')
|
||||
});
|
||||
launcher.session = tmp_event_session;
|
||||
|
||||
/*
|
||||
console.log('v2 idb to launcher object: ***');
|
||||
console.log(launcher);
|
||||
console.log('v2 idb to launcher object: ^^^');
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
exports.check_file_cache = async function () {
|
||||
console.log('Checking the local file cache against the remote server.');
|
||||
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.event_file_id; // NOTE: the .id is the hosted_file.id!
|
||||
let filename = file_value.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.
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function tbl_check(value, key, iteration) {
|
||||
console.log(value);
|
||||
}
|
||||
|
||||
function tbl_check_success(result) {
|
||||
console.log(result);
|
||||
}
|
||||
function tbl_check_error(result) {
|
||||
console.log(result);
|
||||
}
|
||||
234
app/js/module_app_ui 2020-01-21.js.bak
Normal file
234
app/js/module_app_ui 2020-01-21.js.bak
Normal file
@@ -0,0 +1,234 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const { ipcRenderer } = require('electron');
|
||||
|
||||
|
||||
exports.launcher_render = async function (launcher) {
|
||||
console.log('Rendering launcher...');
|
||||
document.getElementById('location_title').innerHTML = '<h1>Launcher '+launcher.location.name+'@'+launcher.event.name+'</h1>';
|
||||
|
||||
document.getElementById('event_files_menu').innerHTML = '<h2>Event Files</h2>';
|
||||
document.getElementById('event_files_menu').innerHTML += '<ul class="">';
|
||||
for (var i in launcher.event_files) {
|
||||
document.getElementById('event_files_menu').innerHTML += '<li id="menu_event_file_id_'+launcher.event_files[i].id+'" class="btn btn-info btn_no_case open_local_file" data-hash_sha256="'+launcher.event_files[i].hash_sha256+'.file" data-filename="'+launcher.event_files[i].event_file_filename+'">'+launcher.event_files[i].event_file_filename+'</li>';
|
||||
}
|
||||
document.getElementById('event_files_menu').innerHTML += '</ul>';
|
||||
|
||||
document.getElementById('location_files_menu').innerHTML = '<h2>Location Files</h2>';
|
||||
document.getElementById('location_files_menu').innerHTML += '<ul class="" role="">';
|
||||
for (var i in launcher.location_files) {
|
||||
document.getElementById('location_files_menu').innerHTML += '<li id="menu_event_file_id_'+launcher.location_files[i].id+'" class="btn btn-info open_local_file" data-hash_sha256="'+launcher.location_files[i].hash_sha256+'.file" data-filename="'+launcher.location_files[i].event_file_filename+'">'+launcher.location_files[i].event_file_filename+'</li>';
|
||||
}
|
||||
document.getElementById('location_files_menu').innerHTML += '</ul>';
|
||||
|
||||
document.getElementById('sessions_menu').innerHTML = '<h2>Sessions</h2>';
|
||||
document.getElementById('sessions_menu').innerHTML += '<ul class="" role="">';
|
||||
//let location_detail = '';
|
||||
if (document.getElementById('location_detail').innerHTML.length) {
|
||||
console.log('detail_session_id_xx already exists');
|
||||
} else {
|
||||
console.log('location_detail already populated');
|
||||
document.getElementById('location_detail').innerHTML = ''; // This needs to be reviewed.
|
||||
}
|
||||
for (var i in launcher.sessions) {
|
||||
// List sessions in menu
|
||||
document.getElementById('sessions_menu').innerHTML += '<li id="menu_session_id_'+launcher.sessions[i].id+'" class="btn btn-info btn_view_session" data-session_id="'+launcher.sessions[i].id+'">'+launcher.sessions[i].name+'</li>';
|
||||
|
||||
// Create containers for each session
|
||||
let session_detail = '';
|
||||
|
||||
if (typeof(document.getElementById('detail_session_id_'+launcher.sessions[i].id)) != 'undefined' && document.getElementById('detail_session_id_'+launcher.sessions[i].id) != null) {
|
||||
//console.log('detail_session_id_xx already exists');
|
||||
} else {
|
||||
//console.log('Adding detail_session_id_xx');
|
||||
session_detail += '<div id="detail_session_id_'+launcher.sessions[i].id+'" class="container d-none session_detail" data-session_id="'+launcher.sessions[i].id+'">';
|
||||
}
|
||||
|
||||
|
||||
|
||||
var session_startdatetime = new Date(launcher.sessions[i].start_datetime);
|
||||
|
||||
session_detail += '<h2 class="session_title">'+launcher.sessions[i].name+'<span class="badge badge-pill badge-info float-right">'+dateFns.format(session_startdatetime, 'ddd h:mm A')+'</span>'+'</h2>';
|
||||
|
||||
|
||||
//session_detail += '<div class="">'; // for card-group
|
||||
|
||||
session_detail += '<div class="card">';
|
||||
session_detail += '<div class="card-header">Session Files:</div>';
|
||||
session_detail += '<div class="card-body">';
|
||||
|
||||
session_detail += '<ul>';
|
||||
for (var j in launcher.sessions[i].files) {
|
||||
//console.log(launcher.sessions[i].files[j].event_file_filename);
|
||||
session_detail += '<li class="btn btn-info open_local_file" data-hash_sha256="'+launcher.sessions[i].files[j].hash_sha256+'.file" data-filename="'+launcher.sessions[i].files[j].event_file_filename+'">'+launcher.sessions[i].files[j].event_file_filename+'</li>';
|
||||
}
|
||||
session_detail += '</ul>';
|
||||
|
||||
session_detail += '</div>'; // for card-body
|
||||
session_detail += '</div> <!-- for session files card -->'; // for session files card
|
||||
|
||||
|
||||
//session_detail += '<div class="session_presentations">';
|
||||
|
||||
for (var j in launcher.sessions[i].presentations) {
|
||||
//session_detail += '<li>'+launcher.sessions[i].presentations[j].name;
|
||||
|
||||
var session_presentation_startdatetime = new Date(launcher.sessions[i].presentations[j].start_datetime);
|
||||
|
||||
session_detail += '<div class="card">';
|
||||
session_detail += '<div class="card-header">'+launcher.sessions[i].presentations[j].name+'<span class="badge badge-pill badge-info float-right">'+dateFns.format(session_startdatetime, 'h:mm a')+'</span>'+':</div>';
|
||||
session_detail += '<div class="card-body">';
|
||||
|
||||
session_detail += '<ul class="list-group">';
|
||||
for (var k in launcher.sessions[i].presentations[j].files) {
|
||||
//console.log(launcher.sessions[i].presentations[j].files[k].event_file_filename);
|
||||
session_detail += '<li class="list-group-item data-hash_sha256="'+launcher.sessions[i].presentations[j].files[k].hash_sha256+'.file" data-filename="'+launcher.sessions[i].presentations[j].files[k].event_file_filename+'">';
|
||||
|
||||
session_detail += '<button class="btn btn-info open_local_file" data-hash_sha256="'+launcher.sessions[i].presentations[j].files[k].hash_sha256+'.file" data-filename="'+launcher.sessions[i].presentations[j].files[k].event_file_filename+'">'+launcher.sessions[i].presentations[j].files[k].event_file_filename+'</button>';
|
||||
|
||||
var event_file_size = launcher.sessions[i].presentations[j].files[k].size;
|
||||
var event_file_created_on = new Date(launcher.sessions[i].presentations[j].files[k].created_on);
|
||||
|
||||
session_detail += '<span class="badge badge-pill badge-light float-right">'+format_bytes(event_file_size, 2)+'; '+dateFns.format(event_file_created_on, 'MMM M h:mm A')+'; '+launcher.sessions[i].presentations[j].files[k].internal_os+'</span>';
|
||||
|
||||
session_detail += '</li>';
|
||||
|
||||
}
|
||||
session_detail += '</ul>';
|
||||
|
||||
|
||||
session_detail += '<ul>';
|
||||
for (var k in launcher.sessions[i].presentations[j].presenters) {
|
||||
//console.log(launcher.sessions[i].presentations[j].presenters[k].given_name);
|
||||
session_detail += '<li>'+launcher.sessions[i].presentations[j].presenters[k].given_name+' '+launcher.sessions[i].presentations[j].presenters[k].family_name;
|
||||
|
||||
session_detail += '<ul class="list-group">';
|
||||
for (var l in launcher.sessions[i].presentations[j].presenters[k].files) {
|
||||
//console.log(launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename);
|
||||
//session_detail += '<li class="list-group-item" data-hash_sha256="'+launcher.sessions[i].presentations[j].presenters[k].files[l].hash_sha256+'.file" data-filename="'+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+'">'+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename;
|
||||
session_detail += '<li class="list-group-item" data-hash_sha256="'+launcher.sessions[i].presentations[j].presenters[k].files[l].hash_sha256+'.file" data-filename="'+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+'">';
|
||||
session_detail += '<button class="btn btn-info open_local_file" data-hash_sha256="'+launcher.sessions[i].presentations[j].presenters[k].files[l].hash_sha256+'.file" data-filename="'+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+'">'+launcher.sessions[i].presentations[j].presenters[k].files[l].event_file_filename+'</button>';
|
||||
|
||||
var event_file_size = launcher.sessions[i].presentations[j].presenters[k].files[l].size;
|
||||
var event_file_created_on = new Date(launcher.sessions[i].presentations[j].presenters[k].files[l].created_on);
|
||||
|
||||
session_detail += '<span class="badge badge-pill badge-light float-right">'+format_bytes(event_file_size, 2)+'; '+dateFns.format(event_file_created_on, 'MMM M h:mm A')+'; '+launcher.sessions[i].presentations[j].presenters[k].files[l].internal_os+'</span>';
|
||||
|
||||
|
||||
session_detail += '</li>';
|
||||
}
|
||||
session_detail += '</ul>';
|
||||
|
||||
session_detail +='</li>';
|
||||
}
|
||||
session_detail += '</ul>';
|
||||
|
||||
|
||||
session_detail += '</ul>';
|
||||
session_detail += '</div>'; // for card-body
|
||||
session_detail += '</div> <!-- for card -->'; // for card
|
||||
|
||||
}
|
||||
//session_detail += '</div> <!-- for session_presentations -->'; // for session_presentations
|
||||
|
||||
//session_detail += '</div>'; // for card-group
|
||||
session_detail += '</div> <!-- End session detail for '+launcher.sessions[i].id+' -->';
|
||||
|
||||
|
||||
//document.getElementById('location_detail').innerHTML += session_detail;
|
||||
|
||||
if (typeof(document.getElementById('detail_session_id_'+launcher.sessions[i].id)) != 'undefined' && document.getElementById('detail_session_id_'+launcher.sessions[i].id) != null) {
|
||||
document.getElementById('detail_session_id_'+launcher.sessions[i].id).innerHTML = session_detail;
|
||||
} else {
|
||||
document.getElementById('location_detail').innerHTML += session_detail;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
document.getElementById('sessions_menu').innerHTML += '</ul>';
|
||||
|
||||
index_location_detail('btn_view_session');
|
||||
|
||||
index_open_file_buttons('open_local_file');
|
||||
|
||||
|
||||
//const btn_session_{{ event_presentation.id }}_name = document.querySelector('button#presentation_{{ event_presentation.id }}_name');
|
||||
//btn_presentation_{{ event_presentation.id }}_name.onclick = display_hide_poster_for_type_id.bind(this, true, 'presentation', {{ event_presentation.id }});
|
||||
console.log('Rendering launcher finished.');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Updated 2019-12-19 */
|
||||
function index_location_detail(class_name) {
|
||||
var class_elements = document.getElementsByClassName(class_name);
|
||||
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
class_elements[i].addEventListener( 'click', function() {view_session( this.getAttribute('data-session_id')) } );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Updated 2019-12-19 */
|
||||
function view_session(session_id) {
|
||||
var class_elements = document.getElementsByClassName('session_detail');
|
||||
console.log('*** Session ID: '+session_id);
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
console.log('*** checking: '+class_elements[i].getAttribute('data-session_id'));
|
||||
if (class_elements[i].getAttribute('data-session_id') == session_id) {
|
||||
console.log('show');
|
||||
class_elements[i].classList.remove('d-none');
|
||||
class_elements[i].classList.add('d-block');
|
||||
} else {
|
||||
console.log('hide');
|
||||
class_elements[i].classList.remove('d-block');
|
||||
class_elements[i].classList.add('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Updated 2019-12-20 */
|
||||
function index_open_file_buttons(class_name) {
|
||||
var class_elements = document.getElementsByClassName(class_name);
|
||||
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
//class_elements[i].addEventListener( 'click', function() {open_local_file( this.getAttribute('data-filename')) } );
|
||||
|
||||
//let directory = 'file_cache/';
|
||||
|
||||
//directory_and_filename = path.join(directory, class_elements[i].getAttribute('data-filename'));
|
||||
|
||||
let file_path = path.join(host_file_cache_path, class_elements[i].getAttribute('data-hash_sha256'));
|
||||
let filename = class_elements[i].getAttribute('data-filename');
|
||||
|
||||
class_elements[i].addEventListener( 'click', function() { ipcRenderer.send('open_local_file', file_path, filename) } );
|
||||
//ipcRenderer.send('open_local_file', this.getAttribute('data-filename')); // in render thread
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function format_bytes(bytes, decimals = 2) {
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
|
||||
const k = 1024;
|
||||
const dm = decimals < 0 ? 0 : decimals;
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
||||
}
|
||||
303
app/js/module_app_ui.js
Normal file
303
app/js/module_app_ui.js
Normal file
@@ -0,0 +1,303 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const { ipcRenderer } = require('electron');
|
||||
|
||||
|
||||
exports.render_launcher = async function (launcher_tmp) {
|
||||
console.log('Rendering 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: ^^^');
|
||||
|
||||
for (var i in launcher_tmp.event) {
|
||||
if (launcher_tmp.event[i].id == event_id) {
|
||||
console.log('*** Event id ('+event_id+') found in launcher object.');
|
||||
for (var j in launcher_tmp.location) {
|
||||
if (launcher_tmp.location[j].id == event_location_id) {
|
||||
console.log('*** Location id ('+event_location_id+') found in launcher object.');
|
||||
document.getElementById('location_title').innerHTML = '<h1>Launcher '+launcher_tmp.location[j].name+'@'+launcher_tmp.event[i].name+'</h1>';
|
||||
} else {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
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_id_'+launcher_tmp.event_file[i].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>';
|
||||
|
||||
|
||||
document.getElementById('location_files_menu').innerHTML = '<h2>Location Files</h2>';
|
||||
document.getElementById('location_files_menu').innerHTML += '<ul class="list-group list-group-flush" role="">';
|
||||
for (var i in launcher_tmp.location_file) {
|
||||
document.getElementById('location_files_menu').innerHTML += '<li id="menu_event_file_id_'+launcher_tmp.location_file[i].id+'" class="list-group-item btn btn-secondary d-flex justify-content-between align-items-center open_local_file" data-hash_sha256="'+launcher_tmp.location_file[i].hash_sha256+'.file" data-filename="'+launcher_tmp.location_file[i].event_file_filename+'">'+launcher_tmp.location_file[i].event_file_filename+'</li>';
|
||||
}
|
||||
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="">';
|
||||
//let location_detail = '';
|
||||
if (document.getElementById('location_detail').innerHTML.length) {
|
||||
console.log('detail_session_id_xx already exists');
|
||||
} else {
|
||||
console.log('location_detail already populated');
|
||||
document.getElementById('location_detail').innerHTML = ''; // This needs to be reviewed.
|
||||
}
|
||||
for (var i in launcher_tmp.session) {
|
||||
// List sessions in menu
|
||||
document.getElementById('sessions_menu').innerHTML += '<li id="menu_session_id_'+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 = '';
|
||||
|
||||
if (typeof(document.getElementById('detail_session_id_'+launcher_tmp.session[i].id)) != 'undefined' && document.getElementById('detail_session_id_'+launcher_tmp.session[i].id) != null) {
|
||||
//console.log('detail_session_id_xx already exists');
|
||||
} else {
|
||||
//console.log('Adding detail_session_id_xx');
|
||||
session_detail += '<div id="detail_session_id_'+launcher_tmp.session[i].id+'" class="container d-none session_detail" data-session_id="'+launcher_tmp.session[i].id+'">';
|
||||
}
|
||||
|
||||
|
||||
|
||||
var session_startdatetime = new Date(launcher_tmp.session[i].start_datetime);
|
||||
|
||||
session_detail += '<h2 class="session_title d-flex justify-content-between align-items-center">'+launcher_tmp.session[i].name+'<span class="badge badge-pill badge-info">'+dateFns.format(session_startdatetime, 'ddd h:mm A')+'</span>'+'</h2>';
|
||||
|
||||
|
||||
// *** Session files card section start
|
||||
let session_files_card = '';
|
||||
if (typeof launcher_tmp.session[i].file !== 'undefined') {
|
||||
session_files_card += '<div class="card">';
|
||||
session_files_card += '<div class="card-header">Session Files:</div>';
|
||||
session_files_card += '<div class="card-body">';
|
||||
|
||||
let files_list = '';
|
||||
files_list += '<ul class="list-group list-group-flush">';
|
||||
for (var j in launcher_tmp.session[i].file) {
|
||||
let file = launcher_tmp.session[i].file[j];
|
||||
//console.log(file.event_file_filename);
|
||||
|
||||
files_list += '<li class="list-group-item btn btn-primary d-flex justify-content-between align-items-center open_local_file" data-hash_sha256="'+file.hash_sha256+'.file" data-filename="'+file.event_file_filename+'">';
|
||||
files_list += file.event_file_filename;
|
||||
files_list += '<span class="badge badge-pill badge-light">'+format_bytes(file.size, 2)+'; '+dateFns.format(file.created_on, 'MMM M h:mm A')+'; '+file.internal_os+'</span>';
|
||||
files_list += '</li>';
|
||||
}
|
||||
files_list += '</ul>';
|
||||
session_files_card += files_list;
|
||||
|
||||
session_files_card += '</div>'; // for card-body
|
||||
session_files_card += '</div> <!-- for session files card -->'; // for session files card
|
||||
} else {
|
||||
//session_files_card = 'no session files found';
|
||||
}
|
||||
// *** Session files card section end
|
||||
|
||||
session_detail += session_files_card;
|
||||
|
||||
// *** Session presentations card section start
|
||||
let session_presentations_card = '';
|
||||
if (typeof launcher_tmp.session[i].presentation !== 'undefined') {
|
||||
|
||||
session_presentations_card += '<div class="card">';
|
||||
session_presentations_card += '<div class="card-header">Presentations:</div>';
|
||||
session_presentations_card += '<div class="card-body">';
|
||||
|
||||
let presentations_list = '';
|
||||
presentations_list += '<ul class="list-group list-group-flush">';
|
||||
|
||||
let presentation = '';
|
||||
for (var j in launcher_tmp.session[i].presentation) {
|
||||
presentation = launcher_tmp.session[i].presentation[j];
|
||||
|
||||
//var session_presentation_startdatetime = new Date(launcher_tmp.session[i].presentation[j].start_datetime);
|
||||
|
||||
presentations_list += '<li class="list-group-item">';
|
||||
presentations_list += '<div class="list-group-item-heading d-flex justify-content-between align-items-center">';
|
||||
presentations_list += '<strong class="">'+presentation.name+'</strong>';
|
||||
presentations_list += '<span class="badge badge-pill badge-info">'+dateFns.format(presentation.start_datetime, 'h:mm a')+'</span>';
|
||||
presentations_list += '</div>';
|
||||
|
||||
presentations_list += '<div class="list-group-item-text">'; // Start presentation file list and presenters with files lists
|
||||
|
||||
if (typeof presentation.file !== 'undefined') {
|
||||
let files_list = '';
|
||||
files_list += '<ul class="list-group list-group-flush">';
|
||||
for (var k in presentation.file) {
|
||||
let file = presentation.file[k];
|
||||
//console.log(file.event_file_filename);
|
||||
|
||||
files_list += '<li class="list-group-item btn btn-primary d-flex justify-content-between align-items-center open_local_file" data-hash_sha256="'+file.hash_sha256+'.file" data-filename="'+file.event_file_filename+'">';
|
||||
files_list += file.event_file_filename;
|
||||
files_list += '<span class="badge badge-pill badge-light float-right">'+format_bytes(file.size, 2)+'; '+dateFns.format(file.created_on, 'MMM M h:mm A')+'; '+file.internal_os+'</span>';
|
||||
files_list += '</li>';
|
||||
}
|
||||
files_list += '</ul>';
|
||||
presentations_list += files_list;
|
||||
} else {
|
||||
files_list = '<div>None here!</div>';
|
||||
presentations_list += files_list;
|
||||
}
|
||||
|
||||
let presenters_list = '';
|
||||
for (var k in presentation.presenter) {
|
||||
let presenter = presentation.presenter[k];
|
||||
//console.log(presenter.given_name);
|
||||
|
||||
presenters_list += '<li class="list-group-item">';
|
||||
presenters_list += '<strong class="list-group-item-heading">'+presenter.given_name+' '+presenter.family_name+'</strong>';
|
||||
|
||||
if (typeof presenter.file !== 'undefined') {
|
||||
let files_list = '';
|
||||
files_list += '<ul class="list-group list-group-flush list-group-item-text">';
|
||||
for (var l in presenter.file) {
|
||||
let file = presenter.file[l];
|
||||
|
||||
/*
|
||||
files_list += '<li class="list-group-item list-group-item-action open_local_file" data-hash_sha256="'+launcher_tmp.session[i].presentation[j].presenter[k].file[l].hash_sha256+'.file" data-filename="'+launcher_tmp.session[i].presentation[j].presenter[k].file[l].event_file_filename+'">';
|
||||
files_list += '<button class="btn btn-info open_local_file" data-hash_sha256="'+launcher_tmp.session[i].presentation[j].presenter[k].file[l].hash_sha256+'.file" data-filename="'+launcher_tmp.session[i].presentation[j].presenter[k].file[l].event_file_filename+'">'+launcher_tmp.session[i].presentation[j].presenter[k].file[l].event_file_filename+'</button>';
|
||||
|
||||
var event_file_size = launcher_tmp.session[i].presentation[j].presenter[k].file[l].size;
|
||||
var event_file_created_on = new Date(launcher_tmp.session[i].presentation[j].presenter[k].file[l].created_on);
|
||||
|
||||
session_detail += '<span class="badge badge-pill badge-light float-right">'+format_bytes(event_file_size, 2)+'; '+dateFns.format(event_file_created_on, 'MMM M h:mm A')+'; '+launcher_tmp.session[i].presentation[j].presenter[k].file[l].internal_os+'</span>';
|
||||
|
||||
|
||||
session_detail += '</li>';
|
||||
*/
|
||||
files_list += '<li class="list-group-item btn btn-primary d-flex justify-content-between align-items-center open_local_file" data-hash_sha256="'+file.hash_sha256+'.file" data-filename="'+file.event_file_filename+'">';
|
||||
files_list += file.event_file_filename;
|
||||
files_list += '<span class="badge badge-pill badge-light float-right">'+format_bytes(file.size, 2)+'; '+dateFns.format(file.created_on, 'MMM M h:mm A')+'; '+file.internal_os+'</span>';
|
||||
files_list += '</li>';
|
||||
}
|
||||
files_list += '</ul>';
|
||||
presenters_list += files_list;
|
||||
} else {
|
||||
files_list = '<div>None here!</div>';
|
||||
presenters_list += files_list;
|
||||
}
|
||||
presenters_list +='</li>'; // End presenter's list group item (one presenter and their files)
|
||||
}
|
||||
presentations_list += presenters_list;
|
||||
|
||||
presentations_list += '</li>'; // close presentation files and presenters with files
|
||||
|
||||
}
|
||||
|
||||
presentations_list += '</ul>'; // end of presentations with files list
|
||||
|
||||
session_presentations_card += presentations_list;
|
||||
session_presentations_card += '</div>'; // for presentations card-body
|
||||
session_presentations_card += '</div> <!-- for card -->'; // for presentations card
|
||||
|
||||
|
||||
session_detail += session_presentations_card;
|
||||
//session_detail += '</div> <!-- for session_presentations -->'; // for session_presentations
|
||||
|
||||
//session_detail += '</div>'; // for card-group
|
||||
|
||||
}
|
||||
session_detail += '</div> <!-- End session detail for '+launcher_tmp.session[i].id+' -->';
|
||||
// *** Session presentations card section start
|
||||
|
||||
//document.getElementById('location_detail').innerHTML += session_detail;
|
||||
|
||||
if (typeof(document.getElementById('detail_session_id_'+launcher_tmp.session[i].id)) != 'undefined' && document.getElementById('detail_session_id_'+launcher_tmp.session[i].id) != null) {
|
||||
document.getElementById('detail_session_id_'+launcher_tmp.session[i].id).innerHTML = session_detail;
|
||||
} else {
|
||||
document.getElementById('location_detail').innerHTML += session_detail;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
document.getElementById('sessions_menu').innerHTML += '</ul>';
|
||||
|
||||
index_location_detail('btn_view_session');
|
||||
|
||||
index_open_file_buttons('open_local_file');
|
||||
|
||||
|
||||
//const btn_session_{{ event_presentation.id }}_name = document.querySelector('button#presentation_{{ event_presentation.id }}_name');
|
||||
//btn_presentation_{{ event_presentation.id }}_name.onclick = display_hide_poster_for_type_id.bind(this, true, 'presentation', {{ event_presentation.id }});
|
||||
console.log('Rendering launcher finished.');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Updated 2019-12-19 */
|
||||
function index_location_detail(class_name) {
|
||||
var class_elements = document.getElementsByClassName(class_name);
|
||||
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
class_elements[i].addEventListener( 'click', function() {view_session( this.getAttribute('data-session_id')) } );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Updated 2019-12-19 */
|
||||
function view_session(session_id) {
|
||||
var class_elements = document.getElementsByClassName('session_detail');
|
||||
console.log('*** Session ID: '+session_id);
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
console.log('*** checking: '+class_elements[i].getAttribute('data-session_id'));
|
||||
if (class_elements[i].getAttribute('data-session_id') == session_id) {
|
||||
console.log('show');
|
||||
class_elements[i].classList.remove('d-none');
|
||||
class_elements[i].classList.add('d-block');
|
||||
} else {
|
||||
console.log('hide');
|
||||
class_elements[i].classList.remove('d-block');
|
||||
class_elements[i].classList.add('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Updated 2019-12-20 */
|
||||
function index_open_file_buttons(class_name) {
|
||||
var class_elements = document.getElementsByClassName(class_name);
|
||||
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
//class_elements[i].addEventListener( 'click', function() {open_local_file( this.getAttribute('data-filename')) } );
|
||||
|
||||
//let directory = 'file_cache/';
|
||||
|
||||
//directory_and_filename = path.join(directory, class_elements[i].getAttribute('data-filename'));
|
||||
|
||||
let file_path = path.join(host_file_cache_path, class_elements[i].getAttribute('data-hash_sha256'));
|
||||
let filename = class_elements[i].getAttribute('data-filename');
|
||||
|
||||
class_elements[i].addEventListener( 'click', function() { ipcRenderer.send('open_local_file', file_path, filename) } );
|
||||
//ipcRenderer.send('open_local_file', this.getAttribute('data-filename')); // in render thread
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function format_bytes(bytes, decimals = 2) {
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
|
||||
const k = 1024;
|
||||
const dm = decimals < 0 ? 0 : decimals;
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
||||
}
|
||||
63
config.json
Normal file
63
config.json
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"account_id": 12,
|
||||
"event_id": 14,
|
||||
"event_location_id": 13,
|
||||
"event_session_id": null,
|
||||
"event_presentation_id": null,
|
||||
"event_presenter_id": null,
|
||||
"event_file_id": null,
|
||||
"loading_loop_interval": 500,
|
||||
"main_loop_interval": 2000,
|
||||
"api_secret_key": "YWAAk39H2qH0edK6lPH0yg",
|
||||
"use_local_api": true,
|
||||
"use_local_db": false,
|
||||
"api_remote_base_url": "https://api.oneskyit.com",
|
||||
"api_local_base_url": "http://api.localhost:5001",
|
||||
"access_control_allow_origin": "*",
|
||||
"remote_db_server": "db.oneskyit.com",
|
||||
"remote_db_port": "3306",
|
||||
"remote_db_name": "onesky_ams_test",
|
||||
"remote_db_username": "username_here",
|
||||
"remote_db_password": "password_here",
|
||||
"local_db_server": "db.localhost",
|
||||
"local_db_port": "3306",
|
||||
"local_db_name": "onesky_ams_test",
|
||||
"local_db_username": "username_here",
|
||||
"local_db_password": "password_here",
|
||||
"idb_name": "osit",
|
||||
"idb_check_period": 30000,
|
||||
"idb_event_check_period": 120000,
|
||||
"idb_event_location_check_period": 90000,
|
||||
"idb_event_session_check_period": 60000,
|
||||
"idb_event_presentation_check_period": 60000,
|
||||
"idb_event_presenter_check_period": 60000,
|
||||
"idb_event_file_check_period": 60000,
|
||||
"host_file_cache_path": "file_cache",
|
||||
"host_file_cache_check_period": 30000,
|
||||
"display_arrangement": "mirror_and_extend",
|
||||
"display_builtin_resolution": "",
|
||||
"display_builtin_refresh": "",
|
||||
"display_builtin_rotation": "",
|
||||
"display_external_resolution": "",
|
||||
"display_external_refresh": "",
|
||||
"display_external_rotation": "",
|
||||
"audio_out_volume": null,
|
||||
"audio_in_volume": null,
|
||||
"recording_fps": 30,
|
||||
"recording_show_cursor": true,
|
||||
"recording_highlight_clicks": false,
|
||||
"recording_screen_id": null,
|
||||
"recording_audio_device_id": null,
|
||||
"known_builtin_screen_ids": [69732032, 69733952, 69733248],
|
||||
"known_builtin_audio_device_ids": [ "AppleHDAEngineInput:1B,0,1,0:1", "BuiltInMicrophoneDevice" ],
|
||||
"recording_video_codec": "h264",
|
||||
"recording_path": "[home]/recordings",
|
||||
"recording_base_filename": "recording",
|
||||
"aperture_bin_path": null,
|
||||
"recording_start_datetime": "2019-10-12 01:01:01Z",
|
||||
"recording_stop_datetime": "2019-10-31 23:59:59Z",
|
||||
"recordings_datetime": [
|
||||
{ "start": "2019-10-11T09:50:00.00", "stop": "2019-10-11T10:15:00.00" },
|
||||
{ "start": "2019-10-11T10:50:00.00", "stop": "2019-10-11T11:15:00.00" }
|
||||
]
|
||||
}
|
||||
42
config.json.default
Normal file
42
config.json.default
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"api_secret_key": "YWAAk39H2qH0edK6lPH0yg",
|
||||
"api_remote_base_url": "https://api.oneskyit.com",
|
||||
"api_local_base_url": "http://api.localhost:5001",
|
||||
"remote_db_server": "db.oneskyit.com",
|
||||
"remote_db_port": "3306",
|
||||
"remote_db_name": "onesky_ams_test",
|
||||
"remote_db_username": "username_here",
|
||||
"remote_db_password": "password_here",
|
||||
"local_db_server": "db.localhost",
|
||||
"local_db_port": "3306",
|
||||
"local_db_name": "onesky_ams_test",
|
||||
"local_db_username": "username_here",
|
||||
"local_db_password": "password_here",
|
||||
"local_file_cache":"file_cache",
|
||||
"display_arrangement": "mirror_and_extend",
|
||||
"display_builtin_resolution": "",
|
||||
"display_builtin_refresh": "",
|
||||
"display_builtin_rotation": "",
|
||||
"display_external_resolution": "",
|
||||
"display_external_refresh": "",
|
||||
"display_external_rotation": "",
|
||||
"audio_out_volume": "",
|
||||
"audio_in_volume": "",
|
||||
"fps": 30,
|
||||
"show_cursor": true,
|
||||
"highlight_clicks": false,
|
||||
"screen_id": null,
|
||||
"audio_device_id": null,
|
||||
"known_builtin_screen_ids": [69732032, 69733952, 69733248],
|
||||
"known_builtin_audio_device_ids": [ "AppleHDAEngineInput:1B,0,1,0:1", "BuiltInMicrophoneDevice" ],
|
||||
"video_codec": "h264",
|
||||
"recordings_path": "[home]/recordings",
|
||||
"base_filename": "recording",
|
||||
"aperture_bin_path": null,
|
||||
"recording_start_datetime": "2019-10-12 01:01:01Z",
|
||||
"recording_stop_datetime": "2019-10-31 23:59:59Z",
|
||||
"recordings_datetime": [
|
||||
{ "start": "2019-10-11T09:50:00.00", "stop": "2019-10-11T10:15:00.00" },
|
||||
{ "start": "2019-10-11T10:50:00.00", "stop": "2019-10-11T11:15:00.00" }
|
||||
]
|
||||
}
|
||||
140
index.js
Normal file
140
index.js
Normal file
@@ -0,0 +1,140 @@
|
||||
const { app, BrowserWindow, ipcMain, shell, systemPreferences } = require('electron');
|
||||
|
||||
|
||||
const axios = require('axios');
|
||||
const fs = require('fs');
|
||||
//const http = require('http');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const process = require('process');
|
||||
//const request = require('request');
|
||||
//const url = require('url');
|
||||
// const usb = require('usb') // Compiled with an old version of Node.js
|
||||
|
||||
console.log(os.type());
|
||||
console.log(process.getSystemVersion());
|
||||
|
||||
|
||||
if (os.type == 'Darwin') {
|
||||
if (systemPreferences.getMediaAccessStatus('microphone') != 'granted') {
|
||||
systemPreferences.askForMediaAccess('microphone');
|
||||
} else {
|
||||
console.log(systemPreferences.getMediaAccessStatus('microphone'));
|
||||
}
|
||||
|
||||
if (systemPreferences.getMediaAccessStatus('camera') != 'granted') {
|
||||
systemPreferences.askForMediaAccess('camera');
|
||||
} else {
|
||||
console.log(systemPreferences.getMediaAccessStatus('camera'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function createWindow () {
|
||||
// Create the browser window.
|
||||
win = new BrowserWindow({
|
||||
width: 1500, // 1500 1280
|
||||
height: 1024, // 1024
|
||||
backgroundColor: '#fff',
|
||||
icon: './app/img/favicon.ico',
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
|
||||
win.setMinimumSize(1024, 768);
|
||||
|
||||
//win.setFullScreenable(false)
|
||||
win.FullScreenable = false;
|
||||
|
||||
// and load the index.html of the app.
|
||||
win.loadFile('app/index.html');
|
||||
|
||||
// Open the DevTools.
|
||||
win.webContents.openDevTools();
|
||||
|
||||
// Emitted when the window is closed.
|
||||
win.on('closed', () => {
|
||||
// Dereference the window object, usually you would store windows
|
||||
// in an array if your app supports multi windows, this is the time
|
||||
// when you should delete the corresponding element.
|
||||
win = null;
|
||||
})
|
||||
|
||||
win.on('minimize', () => {
|
||||
//win.restore();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
app.on('ready', createWindow);
|
||||
|
||||
|
||||
// Quit when all windows are closed.
|
||||
app.on('window-all-closed', () => {
|
||||
// On macOS it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
app.on('activate', () => {
|
||||
// On macOS it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.location_files
|
||||
if (win === null) {
|
||||
createWindow();
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
ipcMain.on('download_file', (event, api_base_url, api_endpoint, api_temporary_token, save_path) => {
|
||||
console.log('ipcMain download and save file: '+api_endpoint+' -> '+save_path);
|
||||
|
||||
axios.defaults.baseURL = api_base_url;
|
||||
axios.defaults.headers.post['Access-Control-Allow-Origin'] = '*';
|
||||
axios.defaults.headers.common['Authorization'] = `Token ${api_temporary_token}`;
|
||||
|
||||
const url = api_endpoint;
|
||||
|
||||
axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
responseType: 'stream' /* responseType must be stream */
|
||||
}).then(function (response) {
|
||||
response.data.pipe(fs.createWriteStream(save_path));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
ipcMain.on('open_local_file', (event, file_path, filename) => {
|
||||
console.log('ipcMain open local file: '+file_path+' -> '+filename);
|
||||
|
||||
cache_file_path = path.join(process.cwd(), file_path);
|
||||
console.log(cache_file_path);
|
||||
|
||||
open_file_path = path.join(process.cwd(), 'temp/', filename);
|
||||
console.log(open_file_path);
|
||||
|
||||
|
||||
if (fs.existsSync(open_file_path)) {
|
||||
//console.log('File link already exists: '+open_file_path);
|
||||
// NOTE: Should the file be checked to see if it has changed from the hashed cache version???
|
||||
// NOTE: What if they made changes to the file locally in temp? The changed file would be used since a new copy is not being made.
|
||||
// NOTE: It might make sense for this to be a configurable option depending on the group. Some do not allow changes. This helps enforce that.
|
||||
console.log('File copy already exists: '+open_file_path);
|
||||
} else {
|
||||
//console.log('Creating file link: '+open_file_path);
|
||||
//fs.linkSync(cache_file_path, open_file_path);
|
||||
console.log('Copying file to temp: '+open_file_path);
|
||||
fs.copyFileSync(cache_file_path, open_file_path);
|
||||
}
|
||||
|
||||
shell.openItem(open_file_path);
|
||||
//fs.open(open_file_path);
|
||||
});
|
||||
63
module_helper.js.bak
Normal file
63
module_helper.js.bak
Normal file
@@ -0,0 +1,63 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
exports.download_file_id = async function (axios, file_id, filename_override) {
|
||||
console.log('Downloading file...');
|
||||
const url = '/event/file/'+file_id+'/download';
|
||||
|
||||
const data = await axios({
|
||||
method: "get",
|
||||
url: url,
|
||||
responseType: "stream"
|
||||
})
|
||||
.then(function (response) {
|
||||
//console.log(response);
|
||||
//console.log(response.data);
|
||||
|
||||
let filename = 'default.txt';
|
||||
|
||||
if (typeof filename_override === 'undefined' || filename_override == null) {
|
||||
let headerLine = response.data.headers['content-disposition'];
|
||||
|
||||
console.log(headerLine);
|
||||
console.log(headerLine.indexOf('="'));
|
||||
console.log(headerLine.indexOf('='));
|
||||
if (headerLine.indexOf('="') != -1) {
|
||||
let startFileNameIndex = headerLine.indexOf('="') + 2;
|
||||
let endFileNameIndex = headerLine.lastIndexOf('"');
|
||||
filename = headerLine.substring(startFileNameIndex, endFileNameIndex);
|
||||
} else if (headerLine.indexOf('=') != -1) {
|
||||
let startFileNameIndex = headerLine.indexOf('=') + 1;
|
||||
let endFileNameIndex = headerLine.length;
|
||||
filename = headerLine.substring(startFileNameIndex, endFileNameIndex);
|
||||
} else {
|
||||
filename = 'filename_not_found_in_header.txt';
|
||||
}
|
||||
} else {
|
||||
filename = filename_override;
|
||||
}
|
||||
|
||||
let directory = 'file_cache/';
|
||||
|
||||
directory_and_filename = path.join(directory, filename);
|
||||
|
||||
//console.log(directory_and_filename);
|
||||
|
||||
if (fs.existsSync(directory_and_filename)) {
|
||||
console.log('File already exists: '+directory_and_filename);
|
||||
} else {
|
||||
console.log('Starting file download: '+directory_and_filename);
|
||||
response.data.pipe(fs.createWriteStream(directory_and_filename));
|
||||
}
|
||||
//data = response.data;
|
||||
return true;
|
||||
//return response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
1411
package-lock.json
generated
Normal file
1411
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
22
package.json
Normal file
22
package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "onesky_native",
|
||||
"version": "1.0.0",
|
||||
"description": "One Sky Native App",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "electron . --disable-gpu",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^0.19.0",
|
||||
"electron": "^7.1.5",
|
||||
"fs": "0.0.1-security",
|
||||
"os": "^0.1.1",
|
||||
"path": "^0.12.7",
|
||||
"request": "^2.88.0",
|
||||
"screen": "^0.2.10",
|
||||
"usb": "^1.6.2"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user