Removed old files
28
bak/app/css/aether_native_app_v3.css
Normal file
@@ -0,0 +1,28 @@
|
||||
body {
|
||||
/* min-height: 100%;
|
||||
height: 100%;
|
||||
max-height: 100%; */
|
||||
|
||||
margin: .1em;
|
||||
padding: .1em;
|
||||
}
|
||||
|
||||
section#Main-Body {
|
||||
/* outline: solid thin red; */
|
||||
|
||||
/* min-height: 100%;
|
||||
height: 100%;
|
||||
max-height: 100%; */
|
||||
}
|
||||
|
||||
section#Main-Nav-Menu {
|
||||
min-height: 100%;
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
section#Main-Content {
|
||||
min-height: 100%;
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
BIN
bak/app/img/favicon.ico
Executable file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
bak/app/img/osit_logo_100.png
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
BIN
bak/app/img/osit_logo_150.png
Normal file
|
After Width: | Height: | Size: 9.5 KiB |
BIN
bak/app/img/osit_logo_32.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
223
bak/app/index.html
Normal file
@@ -0,0 +1,223 @@
|
||||
<!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's Aether App</title>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="img/favicon.ico">
|
||||
|
||||
<!-- Cascading Style Sheets (CSS) start -->
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
|
||||
|
||||
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet">
|
||||
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
|
||||
<!-- One Sky IT default custom Cascading Style Sheets (CSS) -->
|
||||
|
||||
<!-- One Sky IT site custom Cascading Style Sheets (CSS) -->
|
||||
<!-- <link rel="stylesheet" href="https://demo.oneskyit.com/static/css/aether_variables.css"> -->
|
||||
<link rel="stylesheet" href="http://dev.oneskyit.local:5000/static/css/aether_variables.css">
|
||||
<!-- <link rel="stylesheet" href="https://demo.oneskyit.com/static/svelte/build/aether_utilities.css"> -->
|
||||
<link rel="stylesheet" href="http://dev.oneskyit.local:5000/static/svelte/build/aether_utilities.css">
|
||||
<!-- <link rel="stylesheet" href="https://demo.oneskyit.com/static/css/aether_system.css"> -->
|
||||
<link rel="stylesheet" href="http://dev.oneskyit.local:5000/static/css/aether_system.css">
|
||||
<!-- <link rel="stylesheet" href="svelte/build/aether_layout.css"> -->
|
||||
<!-- <link rel="stylesheet" href="css/aether_layout_flow.css"> -->
|
||||
<!-- <link rel="stylesheet" href="css/aether_layout_grid.css"> -->
|
||||
<!-- <link rel="stylesheet" href="https://demo.oneskyit.com/static/svelte/build/aether_modules_core.css"> -->
|
||||
<link rel="stylesheet" href="http://dev.oneskyit.local:5000/static/svelte/build/aether_modules_core.css">
|
||||
|
||||
<!-- <link href="https://demo.oneskyit.com/static/svelte/build/bundle.css" rel="stylesheet"> -->
|
||||
<!-- <link href="http://app-local.oneskyit.com/static/svelte/build/bundle.css" rel="stylesheet"> -->
|
||||
<link href="http://dev.oneskyit.local:5000/static/svelte/build/bundle.css" rel="stylesheet">
|
||||
<!-- <link href="https://demo.oneskyit.com/static/svelte/build/reloading.css" rel="stylesheet"> -->
|
||||
<link href="https://demo.oneskyit.com/static/svelte/build/reloading.css" rel="stylesheet">
|
||||
|
||||
<!-- <link href="https://demo.oneskyit.com/static/svelte/build/base_style_grid_layout_v3.css" rel="stylesheet"> -->
|
||||
<link href="http://dev.oneskyit.local:5000/static/svelte/build/base_style_grid_layout_v3.css" rel="stylesheet">
|
||||
<!-- <link href="https://demo.oneskyit.com/static/svelte/build/base_style_grid_theme_v3.css" rel="stylesheet"> -->
|
||||
<link href="http://dev.oneskyit.local:5000/static/svelte/build/base_style_grid_theme_v3.css" rel="stylesheet">
|
||||
|
||||
<!-- <link href="https://demo.oneskyit.com/static/svelte/build/event_launcher.css" rel="stylesheet"> -->
|
||||
<link href="http://dev.oneskyit.local:5000/static/svelte/build/event_launcher.css" rel="stylesheet">
|
||||
|
||||
<link rel="stylesheet" href="css/aether_native_app_v3.css">
|
||||
|
||||
<style>
|
||||
</style>
|
||||
<!-- Cascading Style Sheets (CSS) end -->
|
||||
|
||||
<!-- JavaScript (JS) start -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.22.0/axios.min.js" integrity="sha512-m2ssMAtdCEYGWXQ8hXVG4Q39uKYtbfaJL5QMTbhl2kc6vYyubrKHhr6aLLXW4ITeXSywQLn1AhsAaqrJl8Acfg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
|
||||
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.2.0/socket.io.js" integrity="sha512-WL6WGKMPBiM9PnHRYIn5YEtq0Z8XP4fkVb4qy7PP4vhmYQErJ/dySyXuFIMDf1eEYCXCrQrMJfkNwKc9gsjTjA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.10.7/dayjs.min.js" integrity="sha512-bwD3VD/j6ypSSnyjuaURidZksoVx3L1RPvTkleC48SbHCZsemT3VKMD39KknPnH728LLXVMTisESIBOAb5/W0Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/localforage/1.10.0/localforage.min.js" integrity="sha512-+BMamP0e7wn39JGL8nKAZ3yAQT2dL5oaXWr4ZYlTGkKOaoXM/Yj7c4oy50Ngz5yoUutAG17flueD4F6QpTlPng==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||
|
||||
<!-- <script src="https://static.oneskyit.com/js/utilities.js"></script> -->
|
||||
<!-- <script src="js/app_idb.js"></script> -->
|
||||
|
||||
<script>
|
||||
const app = require('./js/aether_native_app_v3');
|
||||
let app_config = app.load_config();
|
||||
console.log(app_config);
|
||||
|
||||
const flask_env = 'development'; // 'development', 'production'
|
||||
const env = 'development'; // 'development', 'production'
|
||||
const app_env = 'development_local'; // 'development_local', 'development_remote'
|
||||
const api_env = 'development_local'; // 'development_local', 'development_remote'
|
||||
const app_mode = 'native'; // null, 'default', 'onsite', 'native'
|
||||
|
||||
let client_account_id = app_config.account_id;
|
||||
console.log(client_account_id);
|
||||
let event_id = app_config.event_id;
|
||||
let event_device_id = app_config.event_device_id;
|
||||
let event_location_id = app_config.event_location_id;
|
||||
|
||||
const page_for = { 'event': event_id, 'event_device': event_device_id, 'event_location': event_location_id }; // Simple key value like object
|
||||
console.log(page_for);
|
||||
|
||||
const host_file_cache_path = app_config.host_file_cache_path; // 'file_cache/'
|
||||
// console.log(host_file_cache_path);
|
||||
const host_file_temp_path = app_config.host_file_temp_path; // 'temp/'
|
||||
// console.log(host_file_temp_path);
|
||||
|
||||
let idb_name = app_config.idb_name;
|
||||
|
||||
// BEGIN: API section
|
||||
|
||||
const access_control_allow_origin = app_config.access_control_allow_origin;
|
||||
const api_secret_key = app_config.api_secret_key;
|
||||
console.log(api_secret_key);
|
||||
let api_temporary_token = null;
|
||||
|
||||
let api_server_base_url = app_config.api_server_base_url; // null;
|
||||
let api_server_base_url_bak = app_config.api_server_base_url_bak;
|
||||
let app_server_base_url = app_config.app_server_base_url;
|
||||
// let file_base_url = app_config.file_server_base_url;
|
||||
|
||||
// if (app_config.use_local_api) {
|
||||
// api_server_base_url = app_config.api_local_base_url; // 'http://api.localhost:5001'
|
||||
// } else {
|
||||
// api_server_base_url = app_config.api_remote_base_url; // 'https://api.oneskyit.com'
|
||||
// }
|
||||
|
||||
/* ***** **** *** ** * ### * ** *** **** ***** */
|
||||
|
||||
let app_online = false;
|
||||
//let app_use_cached_data = true;
|
||||
window.addEventListener('online', app.currently_online);
|
||||
window.addEventListener('offline', app.currently_offline);
|
||||
|
||||
/* ***** **** *** ** * ### * ** *** **** ***** */
|
||||
|
||||
</script>
|
||||
|
||||
<!-- <script defer src="svelte/build/bundle.js" crossorigin></script> -->
|
||||
<!-- <script defer src="https://demo.oneskyit.com/static/svelte/build/bundle.js" crossorigin></script> -->
|
||||
<!-- <script defer src="http://app-local.oneskyit.com/static/svelte/build/bundle.js" crossorigin></script> -->
|
||||
<script defer src="http://dev.oneskyit.local:5000/static/svelte/build/bundle.js" crossorigin></script>
|
||||
<!-- JavaScript (JS) end -->
|
||||
|
||||
</head>
|
||||
|
||||
<body class="body_container">
|
||||
|
||||
|
||||
<section id="System-Nav-Menu">Site-Nav-Menu</section>
|
||||
<section id="Site-Header">Site-Header</section>
|
||||
<section id="Site-Nav-Menu">Site-Nav-Menu</section>
|
||||
|
||||
<section id="System-Notifications">System-Notifications (and Site-Notifications)</section><!-- and what would be Site-Notifications-->
|
||||
|
||||
<section id="Main-Body" class="main_template_content svelte_target event_launcher_main">
|
||||
</section>
|
||||
|
||||
<section id="Site-Footer">Site-Footer</section>
|
||||
<section id="System-Footer">Site-Footer</section>
|
||||
|
||||
<section id="System-Debug">System-Debug</section>
|
||||
|
||||
|
||||
</body>
|
||||
<!-- JavaScript (JS) start -->
|
||||
|
||||
<!-- One Sky IT default custom JavaScript (JS) -->
|
||||
|
||||
<!-- One Sky IT site custom JavaScript (JS) -->
|
||||
<!-- <script>const app = require('./js/app_v3');</script> -->
|
||||
<!-- <script src="js/app_v3.js"></script> -->
|
||||
<script>
|
||||
/* ***** **** *** ** * ### * ** *** **** ***** */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// BEGIN: Load IDB section
|
||||
// let idb_name = app_config.idb_name;
|
||||
|
||||
// let tbl_event = null;
|
||||
// let tbl_event_location = null;
|
||||
// let tbl_event_session = null;
|
||||
// let tbl_event_presentation = null;
|
||||
// let tbl_event_presenter = null;
|
||||
// let tbl_event_file = null;
|
||||
// let tbl_hosted_file = null;
|
||||
|
||||
// let tbl_event_key_count = null;
|
||||
// let tbl_event_location_key_count = null;
|
||||
// let tbl_event_session_key_count = null;
|
||||
// let tbl_event_presentation_key_count = null;
|
||||
// let tbl_event_presenter_key_count = null;
|
||||
// let tbl_event_file_key_count = null;
|
||||
// let tbl_hosted_file_key_count = null;
|
||||
|
||||
// let load_idb_tables_result = load_idb_tables()
|
||||
// .then(async function (result) {
|
||||
// console.log('IDB tables have been opened');
|
||||
// idb_tables_opened = load_idb_tables_result;
|
||||
|
||||
// console.log('Attempting to use cached IDB data...');
|
||||
|
||||
// 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) {
|
||||
// console.log('********* Not yet sure how this works... ');
|
||||
// } else {
|
||||
// console.log('One or more of the IDB tables has 0 records. The IDB probably needs to be updated.');
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// console.log(tbl_event);
|
||||
// console.log(tbl_event_location);
|
||||
// console.log(tbl_event_session);
|
||||
// console.log(tbl_event_presentation);
|
||||
// console.log(tbl_event_presenter);
|
||||
// console.log(tbl_event_file);
|
||||
// console.log(tbl_hosted_file);
|
||||
// })
|
||||
// .catch(function (error) {
|
||||
// console.log('Something went wrong opening the IDB tables.');
|
||||
// console.log(error);
|
||||
// return false;
|
||||
// });
|
||||
|
||||
/* ***** **** *** ** * ### * ** *** **** ***** */
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</html>
|
||||
552
bak/app/js/aether_native_app_v3.js
Normal file
@@ -0,0 +1,552 @@
|
||||
'use strict';
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const fs_promises = require('node:fs/promises');
|
||||
const child_process = require('child_process');
|
||||
const { ipcRenderer } = require('electron');
|
||||
|
||||
// import psList from 'ps-list';
|
||||
// const ps_list = require('ps-list');
|
||||
|
||||
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;
|
||||
|
||||
exports.load_config = function () {
|
||||
console.log('*** Electron framework: load_config() ***');
|
||||
|
||||
let cwd = process.cwd();
|
||||
console.log(`CWD: ${cwd}`);
|
||||
|
||||
try {
|
||||
if (cwd == '/') {
|
||||
cwd = home_directory;
|
||||
}
|
||||
console.log('Reading directory...');
|
||||
let directory_list = fs_promises.readdir(cwd).then(function (read_dir_result) {
|
||||
console.log('Got contents:');
|
||||
for (let file of read_dir_result) {
|
||||
console.log(file);
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
// 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 default_config_path = 'config.json.default';
|
||||
console.log(default_config_path);
|
||||
let config_path = null;
|
||||
|
||||
// Set the config path for macOS or Linux
|
||||
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);
|
||||
}
|
||||
|
||||
// Look for the config file and copy the default if not found.
|
||||
if (fs.existsSync(config_directory)) {
|
||||
console.log('Config directory found: '+config_directory);
|
||||
} 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);
|
||||
}
|
||||
|
||||
config_path = path.join(config_directory, 'config.json');
|
||||
|
||||
// Attempt to open the config file. The preferred location is based on the OS's config directory.
|
||||
if (fs.existsSync(config_path)) {
|
||||
console.log(`Config file (config.json) found under ${config_directory}`);
|
||||
} else if (!fs.existsSync(config_path) && fs.existsSync(default_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(path.join(cwd, 'config.json'))) {
|
||||
//fs.copyFileSync(default_config_path, config_path);
|
||||
//console.log('Default config file copied: '+config_directory);
|
||||
|
||||
console.log(`Config file (config.json) not found under ${config_directory}. Using config in CWD. ${cwd}`);
|
||||
config_path = path.join(cwd, 'config.json');
|
||||
|
||||
console.log(`Config file (config.json) not found under ${config_directory}. Using config in CWD. ${cwd}`);
|
||||
found_config_path = path.join(cwd, 'config.json');
|
||||
|
||||
fs.copyFileSync(found_config_path, config_path);
|
||||
console.log(`Found config file copied: ${config_directory}`);
|
||||
} else if (fs.existsSync(path.join(cwd, 'config.json.default'))) {
|
||||
console.log(`Config file (config.json) not found under ${config_directory} or CWD. Using default config in CWD. ${cwd}`);
|
||||
default_config_path = path.join(cwd, 'config.json.default');
|
||||
|
||||
fs.copyFileSync(default_config_path, config_path);
|
||||
console.log(`Default config file copied: ${config_directory}`);
|
||||
} else {
|
||||
console.log('Can not find a config file.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
config = JSON.parse(fs.readFileSync(config_path));
|
||||
console.log('Config file read.');
|
||||
|
||||
config.home_directory = home_directory; // From the OS platform
|
||||
config.tmp_directory = tmp_directory; // From the OS platform
|
||||
|
||||
config.app_root_path = config.app_root_path.replace('[home]', home_directory);
|
||||
config.app_root_path = config.app_root_path.replace('[tmp]', tmp_directory);
|
||||
console.log(config.app_root_path);
|
||||
|
||||
config.host_file_cache_path = config.host_file_cache_path.replace('[home]', home_directory);
|
||||
config.host_file_cache_path = config.host_file_cache_path.replace('[tmp]', tmp_directory);
|
||||
console.log(config.host_file_cache_path);
|
||||
// if (fs.existsSync(config.host_file_cache_path)) {
|
||||
// } else {
|
||||
// fs.mkdirSync(config.host_file_cache_path);
|
||||
// console.log(`Host file cache directory created: ${config.host_file_cache_path}`);
|
||||
// }
|
||||
|
||||
config.host_file_temp_path = config.host_file_temp_path.replace('[home]', home_directory);
|
||||
config.host_file_temp_path = config.host_file_temp_path.replace('[tmp]', tmp_directory);
|
||||
console.log(config.host_file_temp_path);
|
||||
// if (fs.existsSync(config.host_file_temp_path)) {
|
||||
// } else {
|
||||
// fs.mkdirSync(config.host_file_temp_path);
|
||||
// console.log(`Host file temp directory created: ${config.host_file_temp_path}`);
|
||||
// }
|
||||
|
||||
let import_config_to_ipc_result = ipcRenderer.invoke('import_config', config).then((result) => {
|
||||
console.log('IPC import config finished');
|
||||
console.log(result);
|
||||
return true;
|
||||
})
|
||||
|
||||
//console.log(config);
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
// Check for local file
|
||||
// Updated 2022-05-06
|
||||
exports.check_local_file = async function ({local_file_path, filename}) {
|
||||
console.log('*** Electron framework export: check_local_file() ***');
|
||||
// console.log('Check for local file');
|
||||
console.log(`Local File Path: ${local_file_path}; Filename: ${filename}`);
|
||||
|
||||
let full_local_file_path = path.join(local_file_path, filename);
|
||||
console.log(full_local_file_path);
|
||||
|
||||
if (fs.existsSync(full_local_file_path)) {
|
||||
console.log(`Local file exists: ${full_local_file_path}`);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check local hash file cache
|
||||
// Updated 2022-05-06
|
||||
exports.check_hash_file_cache = async function ({host_file_cache_path, hash}) {
|
||||
console.log('*** Electron framework export: check_hash_file_cache() ***');
|
||||
// console.log('Check local hash file cache');
|
||||
console.log(`Host File Cache Path: ${host_file_cache_path}; Hash: ${hash}`);
|
||||
|
||||
let hash_filename = `${hash}.file`;
|
||||
|
||||
let subdirectory = hash_filename.substring(0,2);
|
||||
let subdirectory_path = path.join(host_file_cache_path, subdirectory);
|
||||
if (fs.existsSync(subdirectory_path)) {
|
||||
} else {
|
||||
console.log(`Hashed file subdirectory not found in cache: ${subdirectory_path}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
let hash_file_cache_path = path.join(subdirectory_path, hash_filename);
|
||||
// console.log(hash_file_cache_path);
|
||||
|
||||
if (fs.existsSync(hash_file_cache_path)) {
|
||||
console.log(`Hashed file exists in cache: ${hash_file_cache_path}`);
|
||||
return true;
|
||||
} else {
|
||||
console.log(`Hashed file not found in cache: ${hash_file_cache_path}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Download hash file to cache
|
||||
// Updated 2022-05-06
|
||||
exports.download_hash_file_to_cache = async function ({host_file_cache_path, event_file_id=null, hash=null}) {
|
||||
console.log('*** Electron framework export: download_hash_file_to_cache() ***');
|
||||
// console.log('Download hash file to cache');
|
||||
console.log(`Host File Cache Path: ${host_file_cache_path}; Event File ID: ${event_file_id}; Hash: ${hash}`);
|
||||
|
||||
let endpoint = `/event/file/${event_file_id}/download`;
|
||||
|
||||
let hash_filename = `${hash}.file`;
|
||||
|
||||
let subdirectory = hash_filename.substring(0,2);
|
||||
let subdirectory_path = path.join(host_file_cache_path, subdirectory);
|
||||
if (fs.existsSync(subdirectory_path)) {
|
||||
} else {
|
||||
fs.mkdirSync(subdirectory_path);
|
||||
console.log(`Subdirectory directory created: ${subdirectory_path}`);
|
||||
}
|
||||
|
||||
let hash_file_cache_path = path.join(subdirectory_path, hash_filename);
|
||||
// console.log(hash_file_cache_path);
|
||||
|
||||
let download_file_result = await ipcRenderer.invoke('download_file', api_server_base_url, endpoint, hash_file_cache_path).then((result) => {
|
||||
console.log('IPC download file process finished');
|
||||
console.log(result);
|
||||
return true;
|
||||
});
|
||||
|
||||
// console.log(download_file_result);
|
||||
// console.log('End: download_hash_file_to_cache()');
|
||||
if (download_file_result) {
|
||||
console.log('File downloaded successfully');
|
||||
return true;
|
||||
} else {
|
||||
console.log('File was not downloaded successfully');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Open cached hash file after copying to temp directory
|
||||
// Updated 2022-05-06
|
||||
exports.open_hash_file_to_temp = async function ({host_file_cache_path, hash, host_file_temp_path, filename}) {
|
||||
console.log('*** Electron framework export: open_hash_file_to_temp() ***');
|
||||
// console.log('Open cached hash file after copying to temp directory');
|
||||
console.log(`Host File Cache Path: ${host_file_cache_path}; Hash: ${hash}; Host File Temp Path: ${host_file_temp_path}; Filename: ${filename}`);
|
||||
|
||||
let subdirectory = hash.substring(0,2);
|
||||
let subdirectory_path = path.join(host_file_cache_path, subdirectory);
|
||||
if (fs.existsSync(subdirectory_path)) {
|
||||
} else {
|
||||
console.log(`Hashed file subdirectory not found in cache: ${subdirectory_path}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
let open_hash_file_to_temp_result = await ipcRenderer.invoke('open_hash_file_to_temp', subdirectory_path, hash, host_file_temp_path, filename).then((result) => {
|
||||
console.log('IPC open hash file to temp finished');
|
||||
console.log(result);
|
||||
return true;
|
||||
})
|
||||
|
||||
// let result = await ipcRenderer.send('open_local_file', host_file_cache_path, hash, host_file_temp_path, filename);
|
||||
// console.log(result);
|
||||
|
||||
console.log(open_hash_file_to_temp_result);
|
||||
console.log('End: open_hash_file_to_temp()');
|
||||
if (open_hash_file_to_temp_result) {
|
||||
console.log('File opened successfully');
|
||||
return true;
|
||||
} else {
|
||||
console.log('File was not opened successfully');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Open local file
|
||||
// Updated 2022-03-10
|
||||
exports.open_local_file = async function ({local_file_path, filename}) {
|
||||
console.log('*** Electron framework export: open_local_file() ***');
|
||||
// console.log('Open local file');
|
||||
console.log(`Local File Path: ${local_file_path}; Filename: ${filename}`);
|
||||
|
||||
// let full_local_file_path = path.join(local_file_path, filename);
|
||||
// console.log(full_local_file_path);
|
||||
|
||||
// if (fs.existsSync(full_local_file_path)) {
|
||||
// console.log(`Local file exists: ${full_local_file_path}`);
|
||||
// // return true;
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
let open_local_file_result = await ipcRenderer.invoke('open_local_file', local_file_path, filename).then((result) => {
|
||||
console.log('IPC open local file finished');
|
||||
console.log(result);
|
||||
return true;
|
||||
})
|
||||
|
||||
console.log(open_local_file_result);
|
||||
console.log('End: open_local_file()');
|
||||
if (open_local_file_result) {
|
||||
console.log('File opened successfully');
|
||||
return true;
|
||||
} else {
|
||||
console.log('File was not opened successfully');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Check local file cache and download from server if needed.
|
||||
// Updated 2022-03-09
|
||||
// exports.check_file_cache = async function ({host_file_cache_path, event_file_id, hash}) {
|
||||
exports.check_file_cache = async function ({host_file_cache_path, event_file_id, hash}) {
|
||||
console.log('*** Electron framework export: check_file_cache() ***');
|
||||
// console.log('Check local file cache and download from server if needed.');
|
||||
console.log(`Host File Cache Path: ${host_file_cache_path}; Event File ID: ${event_file_id}; Hash: ${hash}`);
|
||||
|
||||
// NOTE: event_file_id is the event_file.id_random or event_file.event_file_id_random
|
||||
let hash_filename = hash+'.file';
|
||||
|
||||
let save_path = path.join(host_file_cache_path, hash_filename);
|
||||
console.log(save_path);
|
||||
|
||||
if (fs.existsSync(save_path)) {
|
||||
console.log('Hashed file cache already exists: '+save_path);
|
||||
return true;
|
||||
} else {
|
||||
console.log('Hashed file not found in local cache. Downloading file: '+save_path);
|
||||
let endpoint = `/event/file/${event_file_id}/download`;
|
||||
let result = await ipcRenderer.send('download_file', api_server_base_url, endpoint, save_path); // Must download file using main node.js thread.
|
||||
console.log(result);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
ipcRenderer.once('download_file_reply', function(event, response){
|
||||
console.log(response);
|
||||
return response;
|
||||
})
|
||||
resolve(true);
|
||||
});
|
||||
|
||||
// await ipcRenderer.once('download_file_reply', function(event, response){
|
||||
// console.log(response);
|
||||
// return response;
|
||||
// });
|
||||
|
||||
// result.then(function (response) {
|
||||
// console.log('Downloaded!!!???');
|
||||
// return true;
|
||||
// }).catch(function (error) {
|
||||
// console.log(error);
|
||||
// return false;
|
||||
// });
|
||||
|
||||
// return result;
|
||||
|
||||
// console.log(result);
|
||||
// if (result) {
|
||||
// return true;
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check local file cache and download from server if needed. Must use IPC to Main to download file. Set a Promise to wait for download_file_reply.
|
||||
// Updated 2022-03-09
|
||||
async function check_file_cache({host_file_cache_path, event_file_id, hash}) {
|
||||
console.log('*** Electron framework: check_file_cache() ***');
|
||||
// console.log('Check local file cache and download from server if needed.');
|
||||
console.log(`Host File Cache Path: ${host_file_cache_path}; Event File ID: ${event_file_id}; Hash: ${hash}`);
|
||||
|
||||
// NOTE: event_file_id is the event_file.id_random or event_file.event_file_id_random
|
||||
let hash_filename = hash+'.file';
|
||||
|
||||
let save_path = path.join(host_file_cache_path, hash_filename);
|
||||
console.log(save_path);
|
||||
|
||||
if (fs.existsSync(save_path)) {
|
||||
console.log('Hashed file cache already exists: '+save_path);
|
||||
return true;
|
||||
} else {
|
||||
console.log('Hashed file not found in local cache. Downloading file: '+save_path);
|
||||
let endpoint = `/event/file/${event_file_id}/download`;
|
||||
let result = await ipcRenderer.send('download_file', api_server_base_url, endpoint, save_path); // Must download file using main node.js thread.
|
||||
console.log(result);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
ipcRenderer.once('download_file_reply', function(event, response){
|
||||
console.log(response);
|
||||
return response;
|
||||
})
|
||||
resolve(true);
|
||||
});
|
||||
|
||||
// await ipcRenderer.once('download_file_reply', function(event, response){
|
||||
// console.log(response);
|
||||
// return response;
|
||||
// });
|
||||
|
||||
// result.then(function (response) {
|
||||
// console.log('Downloaded!!!???');
|
||||
// return true;
|
||||
// }).catch(function (error) {
|
||||
// console.log(error);
|
||||
// return false;
|
||||
// });
|
||||
|
||||
// return result;
|
||||
|
||||
// console.log(result);
|
||||
// if (result) {
|
||||
// return true;
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
// IPC to Main: Open local file cache if available. Copy to temp directory with given filename first.
|
||||
// Updated 2022-03-09
|
||||
async function open_local_file({host_file_cache_path, hash, host_file_temp_path, filename}) {
|
||||
console.log('*** Electron framework: open_local_file() ***');
|
||||
// console.log('Open local file cache if available. Copy to temp directory with given filename first.');
|
||||
console.log(`Host File Cache Path: ${host_file_cache_path}; Hash: ${hash}; Host File Temp Path: ${host_file_temp_path}; Filename: ${filename}`);
|
||||
|
||||
console.log(host_file_cache_path);
|
||||
console.log(hash);
|
||||
console.log(filename);
|
||||
|
||||
let result = await ipcRenderer.send('open_local_file', host_file_cache_path, hash, host_file_temp_path, filename);
|
||||
console.log(result);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
exports.check_file_cache_and_open_local_file = async function ({host_file_cache_path, event_file_id, hash, host_file_temp_path, filename}) {
|
||||
console.log('*** Electron framework: check_file_cache_and_open_local_file() ***');
|
||||
console.log('Checking the local file cache against the remote server and then opening the local file.');
|
||||
|
||||
let check_file_cache_result = check_file_cache({host_file_cache_path: host_file_cache_path, event_file_id: event_file_id, hash: hash});
|
||||
console.log(check_file_cache_result);
|
||||
|
||||
if (check_file_cache_result) {
|
||||
let open_local_file_result = open_local_file({host_file_cache_path: host_file_cache_path, hash: hash, host_file_temp_path: host_file_temp_path, filename: filename});
|
||||
console.log(open_local_file_result);
|
||||
|
||||
return open_local_file_result;
|
||||
}
|
||||
|
||||
ipcRenderer.once('download_file_reply', function(event, response){
|
||||
console.log(response);
|
||||
|
||||
let open_local_file_result = open_local_file({host_file_cache_path: host_file_cache_path, hash: hash, host_file_temp_path: host_file_temp_path, filename: filename});
|
||||
console.log(open_local_file_result);
|
||||
|
||||
return open_local_file_result;
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// Kill processes
|
||||
// Updated 2022-05-06
|
||||
exports.kill_processes = async function ({process_name = null}) {
|
||||
console.log('*** Electron framework export: kill_processes() ***');
|
||||
console.log(process_name); // process_name or grep pattern
|
||||
|
||||
let command = '';
|
||||
if (os.platform == 'darwin') {
|
||||
// command = `osascript -e 'quit app "${process_name}" saving no'`;
|
||||
command = `osascript -e 'quit application "${process_name}" saving no'`;
|
||||
} else {
|
||||
command = `pkill ${process_name}`;
|
||||
}
|
||||
|
||||
child_process.exec(command, (err, stdout, stdin) => {
|
||||
if (err) throw err;
|
||||
console.log(stdout);
|
||||
});
|
||||
console.log('Killed processes?');
|
||||
|
||||
// let command = `ps -aux | grep ${process_name}`;
|
||||
// child_process.exec(command, (err, stdout, stdin) => {
|
||||
// if (err) throw err;
|
||||
// console.log(stdout);
|
||||
// });
|
||||
|
||||
// console.log(await psList());
|
||||
// console.log(await ps_list());
|
||||
|
||||
// let signal = 'SIGTERM'; // 'SIGTERM', 'SIGINT', 'SIGHUP'
|
||||
|
||||
// process.kill(pid, signal);
|
||||
|
||||
// process.kill(pid, 0); // Special case test if process exists
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Run raw osascript
|
||||
// Updated 2022-05-07
|
||||
exports.run_osascript = async function ({command=null, interactive=false, language=null, flags='h', program_file=null}) {
|
||||
console.log('*** Electron framework export: kill_processes() ***');
|
||||
console.log(command);
|
||||
|
||||
if (os.platform == 'darwin') {
|
||||
} else {
|
||||
console.log('Not available for this platform. macOS (darwin) only.');
|
||||
return false;
|
||||
}
|
||||
|
||||
let osascript_str = '';
|
||||
|
||||
if (Array.isArray(command)) {
|
||||
console.log('List of command strings');
|
||||
let commands_str = '';
|
||||
for (let i = 0; i < command.length; i++) {
|
||||
commands_str += `-e '${command[i]}'`;
|
||||
}
|
||||
osascript_str = `osascript ${commands_str}`
|
||||
|
||||
} else if (typeof command === 'string') {
|
||||
console.log('Single command string');
|
||||
osascript_str = `osascript -e '${command}'`;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (language) {
|
||||
console.log(`Language: ${language}`);
|
||||
osascript_str = `${osascript_str} -l ${language}`;
|
||||
}
|
||||
|
||||
if (flags) {
|
||||
console.log(`Flags: ${flags}`);
|
||||
osascript_str = `${osascript_str} -s ${flags}`;
|
||||
}
|
||||
|
||||
console.log(`OSA Script String: ${osascript_str}`);
|
||||
child_process.exec(osascript_str, (err, stdout, stdin) => {
|
||||
if (err) throw err;
|
||||
console.log(stdout);
|
||||
console.log(stdin);
|
||||
});
|
||||
|
||||
console.log('Finished');
|
||||
return true;
|
||||
}
|
||||
BIN
bak/app/static/images/favicon.ico
Executable file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
bak/app/static/images/oneskyit_logo.png
Normal file
|
After Width: | Height: | Size: 9.5 KiB |
BIN
bak/app/static/images/site_background.png
Normal file
|
After Width: | Height: | Size: 41 KiB |
1
bak/app/static/images/site_background.svg
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
bak/app/static/images/site_background.webp
Normal file
|
After Width: | Height: | Size: 17 KiB |
1
bak/app/static/launcher.reset
Normal file
@@ -0,0 +1 @@
|
||||
launcher reset
|
||||
1
bak/app/static/test.txt
Normal file
@@ -0,0 +1 @@
|
||||
test txt
|
||||
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"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" }
|
||||
]
|
||||
}
|
||||