First iteration of the conversion to use SvelteKit.
This commit is contained in:
48
index.js
48
index.js
@@ -7,6 +7,7 @@ const fs = require('fs');
|
|||||||
const os = require('os');
|
const os = require('os');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const process = require('process');
|
const process = require('process');
|
||||||
|
const { strict } = require('assert');
|
||||||
|
|
||||||
//const http = require('http');
|
//const http = require('http');
|
||||||
//const request = require('request');
|
//const request = require('request');
|
||||||
@@ -24,7 +25,7 @@ console.log('Temporary: '+tmp_directory);
|
|||||||
|
|
||||||
// Set the config path for macOS or Linux
|
// Set the config path for macOS or Linux
|
||||||
let config_directory = 'OSIT/native_app';
|
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 config_path = '';
|
||||||
|
|
||||||
let local_file_cache_path = null;
|
let local_file_cache_path = null;
|
||||||
@@ -120,11 +121,6 @@ if (os.type == 'Darwin') {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function get_url_cfg() {
|
async function get_url_cfg() {
|
||||||
let base_url = `${config.api_protocol}://${config.api_server}:${config.api_port}/${config.api_path}`;
|
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['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['content-type'] = 'application/json';
|
||||||
axios_api.defaults.headers.common['x-aether-api-key'] = config.api_secret_key;
|
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 event_device_id = config.event_device_id ?? 'dbgMWS3KEHE';
|
||||||
let endpoint = `/event/device/${event_device_id}`;
|
// 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(
|
let response_data_promise = await axios_api.get(
|
||||||
endpoint,
|
endpoint,
|
||||||
@@ -181,6 +183,8 @@ async function get_url_cfg() {
|
|||||||
console.log('Error:', error);
|
console.log('Error:', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('Full Error:', error);
|
||||||
|
|
||||||
if (error.response && error.response.status === 404) {
|
if (error.response && error.response.status === 404) {
|
||||||
return null; // Returning null since there were no results
|
return null; // Returning null since there were no results
|
||||||
}
|
}
|
||||||
@@ -199,8 +203,8 @@ console.log(new_config);
|
|||||||
function createWindow () {
|
function createWindow () {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
win = new BrowserWindow({
|
win = new BrowserWindow({
|
||||||
width: 1500, // 1500 1280
|
height: config.height ?? 720,
|
||||||
height: 1024, // 1024
|
width: config.width ?? 1280,
|
||||||
backgroundColor: '#aaa',
|
backgroundColor: '#aaa',
|
||||||
icon: './app/img/favicon.ico',
|
icon: './app/img/favicon.ico',
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
@@ -221,15 +225,18 @@ function createWindow () {
|
|||||||
// win.webContents.session.clearStorageData(['filesystem']); // Does this do anything???
|
// win.webContents.session.clearStorageData(['filesystem']); // Does this do anything???
|
||||||
|
|
||||||
// native_app_which_html = 'default', 'path', 'url'
|
// 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
|
// 'path' (external to app) is a file path on the host, probably under the home directory
|
||||||
// 'url' is over HTTPS, maybe onsite or offsite
|
// '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
|
// Load the index.html of the app
|
||||||
if (config.native_app_which_html == '' || config.native_app_which_html == 'default') {
|
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') {
|
} else if (config.native_app_which_html == 'path') {
|
||||||
let index_path = 'index.html';
|
let index_path = '';
|
||||||
|
|
||||||
if (config.native_app_index_path) {
|
if (config.native_app_index_path) {
|
||||||
index_path = config.native_app_index_path.replace('[home]', home_directory);
|
index_path = config.native_app_index_path.replace('[home]', home_directory);
|
||||||
@@ -238,13 +245,7 @@ function createWindow () {
|
|||||||
}
|
}
|
||||||
win.loadFile(index_path);
|
win.loadFile(index_path);
|
||||||
} else if (config.native_app_which_html == 'url') {
|
} else if (config.native_app_which_html == 'url') {
|
||||||
let index_url = 'http://localhost/index.html';
|
let index_url = config.native_app_index_url ?? 'https://oneskyit.com/';
|
||||||
|
|
||||||
if (config.native_app_index_url) {
|
|
||||||
index_url = config.native_app_index_url;
|
|
||||||
} else {
|
|
||||||
index_url = 'https://app.oneskyit.com/native/index.html';
|
|
||||||
}
|
|
||||||
win.loadURL(index_url);
|
win.loadURL(index_url);
|
||||||
} else {
|
} else {
|
||||||
win.loadFile('app/index.html');
|
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
|
// On macOS it is common for applications and their menu bar
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
// to stay active until the user quits explicitly with Cmd + Q
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
|
if (win) {
|
||||||
|
win.close();
|
||||||
|
}
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
2615
package-lock.json
generated
2615
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "aether_app_native",
|
"name": "aether_app_native",
|
||||||
"productName": "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",
|
"description": "One Sky IT's Native Aether App",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
"path": "^0.12.7"
|
"path": "^0.12.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"electron": "^22.3.6",
|
"electron": "^31.0.0",
|
||||||
"electron-packager": "^16.0.0"
|
"electron-packager": "^17.1.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user