From 040ab4aa4e8468b7c383cbe8d833566e56c155ae Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Sat, 15 Oct 2022 23:10:54 -0400 Subject: [PATCH] Rework of loading the index file. --- app/index.html | 139 +++++---------------------- app/index_development.html | 165 +++++++++++++++++++++++++++++++++ app/index_onsite.html | 165 +++++++++++++++++++++++++++++++++ app/js/aether_app_native_v4.js | 45 +++++++++ config.json.default | 5 + index.js | 26 +++++- 6 files changed, 425 insertions(+), 120 deletions(-) create mode 100644 app/index_development.html create mode 100644 app/index_onsite.html diff --git a/app/index.html b/app/index.html index f741611..ed134cd 100644 --- a/app/index.html +++ b/app/index.html @@ -4,7 +4,7 @@ - One Sky IT's Aether App + One Sky IT's Aether App (default) @@ -20,29 +20,31 @@ - - - - - - + + + + + + - - + + - - - - + + + + - - - - + + + + - - + + + + @@ -62,7 +64,6 @@ - diff --git a/app/index_development.html b/app/index_development.html new file mode 100644 index 0000000..4edb515 --- /dev/null +++ b/app/index_development.html @@ -0,0 +1,165 @@ + + + + + + + One Sky IT's Aether App (onsite) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Site-Nav-Menu
+ +
+ + + + + +
+
System-Notifications (and Site-Notifications)
+ +
+ +
+ +
+
+ + + +
+ +
+ + + +
System-Debug
+ + + + + + + + + + + + + + diff --git a/app/index_onsite.html b/app/index_onsite.html new file mode 100644 index 0000000..082585b --- /dev/null +++ b/app/index_onsite.html @@ -0,0 +1,165 @@ + + + + + + + One Sky IT's Aether App (onsite) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Site-Nav-Menu
+ +
+ + + + + +
+
System-Notifications (and Site-Notifications)
+ +
+ +
+ +
+
+ + + +
+ +
+ + + +
System-Debug
+ + + + + + + + + + + + + + diff --git a/app/js/aether_app_native_v4.js b/app/js/aether_app_native_v4.js index a36e2e5..9cfcf3e 100644 --- a/app/js/aether_app_native_v4.js +++ b/app/js/aether_app_native_v4.js @@ -873,3 +873,48 @@ exports.get_device_info = async function () { console.log(data); return data; } + + + +// For loading JS file +function loadJS(){ + + // Gives -1 when the given input is not in the string + // i.e this file has not been added + + if(filesAdded.indexOf('script.js') !== -1) + return + + // Head tag + var head = document.getElementsByTagName('head')[0] + + // Creating script element + var script = document.createElement('script') + script.src = 'script.js' + script.type = 'text/javascript' + + // Adding script element + head.append(script) + + // Adding the name of the file to keep record + filesAdded += ' script.js' +} + +// To load CSS file +function loadCSS() { + + if(filesAdded.indexOf('styles.css') !== -1) + return + + var head = document.getElementsByTagName('head')[0] + + // Creating link element + var style = document.createElement('link') + style.href = 'styles.css' + style.type = 'text/css' + style.rel = 'stylesheet' + head.append(style); + + // Adding the name of the file to keep record + filesAdded += ' styles.css' +} diff --git a/config.json.default b/config.json.default index bdcc0e7..5d625d3 100644 --- a/config.json.default +++ b/config.json.default @@ -23,6 +23,11 @@ "api_path_backup": "", "api_secret_key_backup": "ABCD1234XYZ", + "app_protocol": "http", + "app_server": "app.oneskyit.local", + "app_port": 5005, + "app_path": "", + "file_server_base_url": "", "file_server_base_url_backup": "", diff --git a/index.js b/index.js index 88c2e66..4fe6afb 100644 --- a/index.js +++ b/index.js @@ -19,7 +19,21 @@ console.log('Home: '+home_directory); let tmp_directory = require('os').tmpdir(); console.log('Temporary: '+tmp_directory); -let config = null; +// Set the config path for macOS or Linux +let config_directory = 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); +} + +let config_path = path.join(config_directory, 'config.json'); +// let config = null; +let config = JSON.parse(fs.readFileSync(config_path)); +console.log('Config file read.', config); + let local_file_cache_path = null; let host_file_temp_path = null; @@ -68,7 +82,15 @@ function createWindow () { // win.webContents.session.clearStorageData(['filesystem']); // Does this do anything??? // and load the index.html of the app. - win.loadFile('app/index.html'); + if (config.native_app_js_css_option == '' || config.native_app_js_css_option == 'default') { + win.loadFile('app/index.html'); + } else if (config.native_app_js_css_option == 'development') { + win.loadFile('app/index_development.html'); + } else if (config.native_app_js_css_option == 'onsite') { + win.loadFile('app/index_onsite.html'); + } else { + win.loadFile('app/index.html'); + } // Open the DevTools. win.webContents.openDevTools(); // Comment out for production