First iteration of the conversion to use SvelteKit.

This commit is contained in:
Scott Idem
2024-08-14 19:26:39 -04:00
parent 54ae460da5
commit fdbd12b64f
3 changed files with 663 additions and 2006 deletions

View File

@@ -7,6 +7,7 @@ const fs = require('fs');
const os = require('os');
const path = require('path');
const process = require('process');
const { strict } = require('assert');
//const http = require('http');
//const request = require('request');
@@ -24,7 +25,7 @@ console.log('Temporary: '+tmp_directory);
// Set the config path for macOS or Linux
let config_directory = 'OSIT/native_app';
let config_filename = 'ae_native_app_config.json';
let config_filename = 'ae_native_app_sk_config.json';
let config_path = '';
let local_file_cache_path = null;
@@ -120,11 +121,6 @@ if (os.type == 'Darwin') {
async function get_url_cfg() {
let base_url = `${config.api_protocol}://${config.api_server}:${config.api_port}/${config.api_path}`;
@@ -139,12 +135,18 @@ async function get_url_cfg() {
axios_api.defaults.headers.common['Access-Control-Allow-Origin'] = config.access_control_allow_origin; // '*'; // app_config.access_control_allow_origin;
axios_api.defaults.headers.common['content-type'] = 'application/json';
axios_api.defaults.headers.common['x-aether-api-key'] = config.api_secret_key;
axios_api.defaults.headers.common['x-account-id'] = config.account_id;
// axios_api.defaults.headers.common['x-account-id'] = config.account_id ?? 'xFP7AhU8Zlc';
axios_api.defaults.headers.common['x-no-account-id'] = 'nothing to see here';
let event_device_id = 'dbgMWS3KEHE';
let endpoint = `/event/device/${event_device_id}`;
let event_device_id = config.event_device_id ?? 'dbgMWS3KEHE';
// let endpoint = `/event/device/${event_device_id}`;
let endpoint = `/v2/crud/event/device/${event_device_id}`;
let params = {'event_device_code': 'asdf'};
let params = {
inc_event_cfg: false,
inc_event_location: false,
enabled: 'enabled',
};
let response_data_promise = await axios_api.get(
endpoint,
@@ -181,6 +183,8 @@ async function get_url_cfg() {
console.log('Error:', error);
}
console.log('Full Error:', error);
if (error.response && error.response.status === 404) {
return null; // Returning null since there were no results
}
@@ -199,8 +203,8 @@ console.log(new_config);
function createWindow () {
// Create the browser window.
win = new BrowserWindow({
width: 1500, // 1500 1280
height: 1024, // 1024
height: config.height ?? 720,
width: config.width ?? 1280,
backgroundColor: '#aaa',
icon: './app/img/favicon.ico',
webPreferences: {
@@ -221,15 +225,18 @@ function createWindow () {
// win.webContents.session.clearStorageData(['filesystem']); // Does this do anything???
// native_app_which_html = 'default', 'path', 'url'
// 'default' (internal) is within the bundled native app
// 'default' (url) is within the bundled native app
// 'path' (external to app) is a file path on the host, probably under the home directory
// 'url' is over HTTPS, maybe onsite or offsite
// unknown points to an index.html file in the app directory
// Load the index.html of the app
if (config.native_app_which_html == '' || config.native_app_which_html == 'default') {
win.loadFile('app/index.html');
// win.loadFile('app/index.html');
let index_url = config.native_app_index_url ?? 'https://oneskyit.com/';
win.loadURL(index_url);
} else if (config.native_app_which_html == 'path') {
let index_path = 'index.html';
let index_path = '';
if (config.native_app_index_path) {
index_path = config.native_app_index_path.replace('[home]', home_directory);
@@ -238,13 +245,7 @@ function createWindow () {
}
win.loadFile(index_path);
} else if (config.native_app_which_html == 'url') {
let index_url = 'http://localhost/index.html';
if (config.native_app_index_url) {
index_url = config.native_app_index_url;
} else {
index_url = 'https://app.oneskyit.com/native/index.html';
}
let index_url = config.native_app_index_url ?? 'https://oneskyit.com/';
win.loadURL(index_url);
} else {
win.loadFile('app/index.html');
@@ -280,6 +281,9 @@ 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') {
if (win) {
win.close();
}
app.quit();
}
})

2615
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
{
"name": "aether_app_native",
"productName": "Aether App: Native",
"version": "2023.5.14.2",
"version": "2024.8.14.1",
"description": "One Sky IT's Native Aether App",
"main": "index.js",
"scripts": {
@@ -19,7 +19,7 @@
"path": "^0.12.7"
},
"devDependencies": {
"electron": "^22.3.6",
"electron-packager": "^16.0.0"
"electron": "^31.0.0",
"electron-packager": "^17.1.2"
}
}