Implement basic initial setup and dashboard with web portal
This commit is contained in:
37
client.js
37
client.js
@@ -1,8 +1,7 @@
|
||||
import { generateUniqueID } from './modules/baseUtils.mjs';
|
||||
import { updateId } from './modules/updateConfig.mjs';
|
||||
import { ClientNodeConfig } from './modules/clientObjectDefinitions.mjs';
|
||||
import { initSocketConnection } from './modules/socketClient.mjs';
|
||||
import { checkForUpdates } from './modules/selfUpdater.mjs'
|
||||
import startServer from './express/server.mjs';
|
||||
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config()
|
||||
@@ -11,37 +10,25 @@ var localNodeConfig = new ClientNodeConfig({})
|
||||
|
||||
async function boot() {
|
||||
// Check if there have been any updates
|
||||
await checkForUpdates();
|
||||
await checkForUpdates();
|
||||
|
||||
if (localNodeConfig.node.nuid === undefined || localNodeConfig.node.nuid === '' || localNodeConfig.node.nuid === '0' || localNodeConfig.node.nuid === 0) {
|
||||
// Run the first time boot sequence
|
||||
await firstTimeBoot();
|
||||
return new Promise(res => {res(false)});
|
||||
}
|
||||
|
||||
// Initialize the socket connection with the server
|
||||
return initSocketConnection(localNodeConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the first time the client boots on a pc
|
||||
* @returns {any}
|
||||
*/
|
||||
async function firstTimeBoot() {
|
||||
// Generate a new ID for the node
|
||||
localNodeConfig.node.nuid = await generateUniqueID();
|
||||
console.log(`Generated a new unique ID for this node: '${localNodeConfig.node.nuid}'`);
|
||||
|
||||
// Update the config with the new ID
|
||||
await updateId(localNodeConfig.node.nuid);
|
||||
console.log("Updated the config with the new node ID");
|
||||
// TODO - Create the config file with the ID given and replace the update above
|
||||
// TODO - Implement web server so users can update radio systems easily
|
||||
// TODO - Implement logic to check if the presets are set
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// Boot the client application
|
||||
boot().then((openSocket) => {
|
||||
console.log(openSocket, "Booted Sucessfully");
|
||||
// Start the web server
|
||||
startServer(process.env.WEB_SERVER_PORT || 3000, openSocket);
|
||||
|
||||
if (!openSocket) {
|
||||
console.log(openSocket, "Waiting for setup");
|
||||
}
|
||||
else {
|
||||
console.log(openSocket, "Booted Sucessfully");
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user