diff --git a/package.json b/package.json index b45c64d..7613dd3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "RoboticsAcademy", - "version": "2.0.0", + "version": "2.3.3", "description": "Cross platform Desktop Application for Robotics Academy.", "main": "./out/main/index.js", "author": "Robotics Academy", diff --git a/splashscreen.html b/splashscreen.html index 1792be1..effc26e 100644 --- a/splashscreen.html +++ b/splashscreen.html @@ -106,7 +106,7 @@

Robotics Academy

by JdeRobot

-

v2.0.0

+

v2.0.0

diff --git a/src/main/db.ts b/src/main/db.ts index 02e4beb..a1490f8 100644 --- a/src/main/db.ts +++ b/src/main/db.ts @@ -201,7 +201,7 @@ export const insertCommandData = async (db: sqlite3.Database) => { if (err) { console.error('Error creating table: ' + err.message) } else { - console.log('commands Table created or already exists.') + // console.log('commands Table created or already exists.') try { const checkTableExist = await isTableExit(db, `commands`) @@ -248,7 +248,7 @@ export const insertCommandUtilsData = async (db: sqlite3.Database) => { if (err) { console.error('Error creating table: ' + err.message) } else { - console.log('commands_utils Table created or already exists.') + // console.log('commands_utils Table created or already exists.') try { const checkTableExist = await isTableExit(db, `commands_utils`) diff --git a/src/main/index.ts b/src/main/index.ts index 8c21e32..15a5000 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -2,7 +2,7 @@ import { app, BrowserWindow, ipcMain, IpcMainInvokeEvent, shell } from 'electron import { join } from 'path' import { electronApp, optimizer, is } from '@electron-toolkit/utils' import { Database } from 'sqlite3' -import { autoUpdater, AppUpdater } from 'electron-updater' +import { autoUpdater } from 'electron-updater' import { AllCommandConfigureInterface, @@ -33,6 +33,7 @@ import { const isMac = process.platform === 'darwin' let mainWindow: BrowserWindow | null = null +const appVersion = `v${app.getVersion()}` // disable auto-update download autoUpdater.autoDownload = false @@ -47,7 +48,13 @@ function createSplashWindow(): BrowserWindow { height: 300, frame: false, transparent: true, - alwaysOnTop: true + alwaysOnTop: true, + webPreferences: { + nodeIntegration: false, + webSecurity: true, + sandbox: false, + contextIsolation: true + } }) const splashScreenSrc = app.isPackaged @@ -55,6 +62,21 @@ function createSplashWindow(): BrowserWindow { : join(__dirname, './../../', 'splashscreen.html') win.loadFile(splashScreenSrc) + + win.webContents.on('did-finish-load', () => { + win.webContents + .executeJavaScript( + ` + const version = document.getElementById('version') + version.textContent = '${appVersion}' + ` + ) + .then((result) => { + console.log('Executed in renderer:', result) + }) + .catch(console.error) + }) + return win } @@ -140,6 +162,23 @@ app.whenReady().then(async () => { }) //* IPC COMMUNICATION + //@ Utils + // get api version + ipcMain.handle('app:APP_VERSION', async (_event: IpcMainInvokeEvent) => { + try { + return { + status: ResponseStatus.SUCCESS, + data: `${app.getVersion()}`, + msg: [] + } + } catch (error: any) { + return { + status: ResponseStatus.SUCCESS, + data: null, + msg: ['something went wrong!', `${error.message}`] + } + } + }) //@ Stopping Docker RADI ipcMain.handle('docker:CHECK_RADI_RUNNING', async (_event: IpcMainInvokeEvent) => { try { @@ -174,7 +213,7 @@ app.whenReady().then(async () => { const res: ResponeInterface = await stopDockerRADIContainer() return res } catch (error) { - return { status: false, msg: ['something went wrong!'] } + return { status: ResponseStatus.ERROR, msg: ['something went wrong!'] } } }) diff --git a/src/preload/index.d.ts b/src/preload/index.d.ts index f168fd6..cbbd524 100644 --- a/src/preload/index.d.ts +++ b/src/preload/index.d.ts @@ -1,7 +1,14 @@ import { PortsInterface } from './../renderer/src/utils/interfaces' import { ElectronAPI } from '@electron-toolkit/preload' -import { AllCommandConfigureInterface, DatabaseFetching } from './../main/interfaces' +import { + AllCommandConfigureInterface, + DatabaseFetching, + ResponeInterface +} from './../main/interfaces' interface ApiInterface { + // Util + getAppVersion: () => Promise + // Docker checkDockerAvailability: () => Promise checkDockerRADIAvailability: () => Promise startDockerRADIContainer: () => Promise diff --git a/src/preload/index.ts b/src/preload/index.ts index f7d9891..c01e083 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -9,6 +9,9 @@ import { // Custom APIs for renderer const api = { + // Utils + getAppVersion: (): Promise => ipcRenderer.invoke('app:APP_VERSION'), + // Docker checkDockerAvailability: (): Promise => ipcRenderer.invoke('docker:CHECK_AVAILABILITY'), checkDockerRADIAvailability: (): Promise => diff --git a/src/renderer/src/components/startscreenview/StartScreenButtons.tsx b/src/renderer/src/components/startscreenview/StartScreenButtons.tsx index 1cc16b1..56816f1 100644 --- a/src/renderer/src/components/startscreenview/StartScreenButtons.tsx +++ b/src/renderer/src/components/startscreenview/StartScreenButtons.tsx @@ -4,8 +4,9 @@ import { RightArrowIcon, BackIcon, PowerIcon, GameConsoleIcon, PlayIcon } from ' import Loader from '../utlits/Loader' import ButtonWrapper from '../buttons/ButtonWrapper' import styles from '../../assets/styles/styles' -import { ActionEnums, ButtonEnums, ScreenStateEnums } from '@renderer/utils/enums' +import { ActionEnums, ButtonEnums, ResponseStatus, ScreenStateEnums } from '@renderer/utils/enums' import { ReducerActionTypes } from '@renderer/utils/types' +import { ResponeInterface } from '@renderer/utils/interfaces' interface StartScrrenButtonsInterface { buttonState: string dispatch: Dispatch @@ -27,9 +28,9 @@ const StartScreenButtons: FC = ({ setIsStopping(true) try { - const res: { status: boolean; msg: string[] } = await window.api.stopDockerRADIContainer() + const res: ResponeInterface = await window.api.stopDockerRADIContainer() - if (res.status) { + if (res.status == ResponseStatus.SUCCESS) { dispatch({ type: ActionEnums.CHANGE_SCREEN, payload: {