diff --git a/DeskThingServer/package-lock.json b/DeskThingServer/package-lock.json index f8be15c..55b2987 100644 --- a/DeskThingServer/package-lock.json +++ b/DeskThingServer/package-lock.json @@ -1,12 +1,12 @@ { "name": "deskthing", - "version": "0.8.1", + "version": "0.8.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "deskthing", - "version": "0.8.1", + "version": "0.8.2", "hasInstallScript": true, "dependencies": { "@electron-toolkit/preload": "^3.0.0", diff --git a/DeskThingServer/src/renderer/src/components/Apps/Local.tsx b/DeskThingServer/src/renderer/src/components/Apps/Local.tsx deleted file mode 100644 index 61bcff2..0000000 --- a/DeskThingServer/src/renderer/src/components/Apps/Local.tsx +++ /dev/null @@ -1,138 +0,0 @@ -import { DragEvent, useState } from 'react' -import { IconLogoGearLoading, IconUpload } from '../icons' - -interface responseData { - status: boolean - data: returnData - final: boolean - error?: string -} -interface returnData { - appId: string - appName: string - appVersion: string - author: string - platforms: string[] - requirements: string[] -} - -const index = (): JSX.Element => { - const [appData, setAppData] = useState(null) - const [dragActive, setDragActive] = useState(false) - const [loading, setLoading] = useState(false) - const [status, setStatus] = useState('') - - const handleDrop = async (event: DragEvent): Promise => { - event.preventDefault() - setDragActive(false) - setLoading(true) - console.log('App Dropped') - - const files = Array.from(event.dataTransfer.files) - for (const file of files) { - if (file.name.endsWith('.zip')) { - await handleZipFile(file.path) - } - } - } - async function handleZipFile(zipFilePath: string): Promise { - try { - // Notify the main process to handle the zip file - window.electron.ipcRenderer.send('handle-zip', zipFilePath) - handleLogging() - window.electron.ipcRenderer.once('zip-name', (_event, response: responseData) => { - console.log('Received appId:', response) - if (response.status) { - setAppData(response.data) - } - setLoading(false) - }) - } catch (error) { - console.error('Error handling zip file:', error) - } - } - - const handleLogging = async (): Promise => { - setLoading(true) - const unsubscribe = window.electron.ipcRenderer.on('logging', (_event, reply) => { - console.log(reply) - if (reply.final) { - unsubscribe() - setLoading(false) - } else { - setLoading(true) - } - if (!reply.status) { - setStatus(reply.error || 'Unknown error occurred') - unsubscribe() - setLoading(false) - } else { - if (reply.data) { - setStatus(reply.data) - } - } - }) - } - - const handleAddAndRunApp = async (): Promise => { - window.electron.ipcRenderer.send('add-app', appData?.appId) - window.electron.ipcRenderer.send('get-apps') - setAppData(null) - } - - const handleClick = async (): Promise => { - const file = await window.electron.selectZipFile() - if (file) { - setLoading(true) - await handleZipFile(file.path) - console.log(file.name) - } - } - - return ( -
- {appData?.appId ? ( -
-

{appData.appName} is Ready!

-
-

{appData.appVersion}

-

Author: {appData.author || 'not provided'}

-
-

Compatible With: {appData.platforms.join(', ')}

- {appData.requirements.length > 0 && ( -

Required Apps: {appData.requirements.join(', ')}

- )} - -
- ) : ( -
e.preventDefault()} - onDragEnter={() => setDragActive(true)} - onDragLeave={() => setDragActive(false)} - onClick={handleClick} - > - {loading ? ( -
- - {status &&

{status.trim()}

} -
- ) : ( - <> - -

Drop your .zip App file here

- - )} -
- )} -
- ) -} - -export default index diff --git a/DeskThingServer/src/renderer/src/components/Apps/Web.tsx b/DeskThingServer/src/renderer/src/components/Apps/Web.tsx index bb74819..9b45586 100644 --- a/DeskThingServer/src/renderer/src/components/Apps/Web.tsx +++ b/DeskThingServer/src/renderer/src/components/Apps/Web.tsx @@ -1,5 +1,5 @@ -import { useEffect, useState } from 'react' -import { IconArrowDown, IconArrowRight, IconLogoLoading } from '../icons' +import { DragEvent, useEffect, useState } from 'react' +import { IconArrowDown, IconArrowRight, IconLogoLoading, IconUpload } from '../icons' import githubStore, { GithubRelease, GithubAsset } from '../../store/githubStore' import ReleaseList from '../ReleaseList' import RunPreppedApp from './RunPreppedApp' @@ -11,6 +11,7 @@ interface responseData { final: boolean error?: string } + interface returnData { appId: string appName: string @@ -29,6 +30,7 @@ const Web = (): JSX.Element => { const [repoReleases, setRepoReleases] = useState([]) const [openRepoUrl, setOpenRepoUrl] = useState(null) const [openReleaseId, setOpenReleaseId] = useState(null) + const [dragActive, setDragActive] = useState(false) const [loading, setLoading] = useState(false) const [appData, setAppData] = useState(null) const [error, setError] = useState(null) @@ -122,6 +124,45 @@ const Web = (): JSX.Element => { setAppData(null) } + const handleDrop = async (event: DragEvent): Promise => { + event.preventDefault() + setDragActive(false) + setLoading(true) + console.log('App Dropped') + + const files = Array.from(event.dataTransfer.files) + for (const file of files) { + if (file.name.endsWith('.zip')) { + await handleZipFile(file.path) + } + } + } + async function handleZipFile(zipFilePath: string): Promise { + try { + // Notify the main process to handle the zip file + window.electron.ipcRenderer.send('handle-zip', zipFilePath) + handleLogging() + window.electron.ipcRenderer.once('zip-name', (_event, response: responseData) => { + console.log('Received appId:', response) + if (response.status) { + setAppData(response.data) + } + setLoading(false) + }) + } catch (error) { + console.error('Error handling zip file:', error) + } + } + + const handleClick = async (): Promise => { + const file = await window.electron.selectZipFile() + if (file) { + setLoading(true) + await handleZipFile(file.path) + console.log(file.name) + } + } + return (
{!appData?.appId ? ( @@ -161,6 +202,22 @@ const Web = (): JSX.Element => { ) : ( )} + {!loading && ( +
+

Local Apps

+
e.preventDefault()} + onDragEnter={() => setDragActive(true)} + onDragLeave={() => setDragActive(false)} + onClick={handleClick} + > + +

Drop App.zip File Here

+
+
+ )}
) : ( diff --git a/DeskThingServer/src/renderer/src/components/Apps/index.tsx b/DeskThingServer/src/renderer/src/components/Apps/index.tsx index f9e3906..22cbdee 100644 --- a/DeskThingServer/src/renderer/src/components/Apps/index.tsx +++ b/DeskThingServer/src/renderer/src/components/Apps/index.tsx @@ -1,13 +1,11 @@ import { useState } from 'react' import Apps from './Apps' -import Local from './Local' import Web from './Web' import Tabs, { View } from '../Tabs' const Index = (): JSX.Element => { const views: View[] = [ { id: 'apps', display: 'Apps List' }, - { id: 'local', display: 'Local Apps' }, { id: 'web', display: 'App Downloads' } ] const [currentView, setCurrentView] = useState(views[0]) @@ -15,8 +13,6 @@ const Index = (): JSX.Element => { switch (currentView.id) { case 'apps': return - case 'local': - return case 'web': return default: diff --git a/DeskThingServer/src/renderer/src/components/Client/index.tsx b/DeskThingServer/src/renderer/src/components/Client/index.tsx index bf5a993..d7102d3 100644 --- a/DeskThingServer/src/renderer/src/components/Client/index.tsx +++ b/DeskThingServer/src/renderer/src/components/Client/index.tsx @@ -10,7 +10,6 @@ const Index = (): JSX.Element => { { id: 'devices', display: 'Devices' }, { id: 'status', display: 'Status' }, { id: 'mappings', display: 'Button Maps' }, - { id: 'local', display: 'Local Client' }, { id: 'client', display: 'Client Downloads' } ] const [currentView, setCurrentView] = useState(views[0]) @@ -22,8 +21,6 @@ const Index = (): JSX.Element => { return case 'status': return - case 'local': - return case 'client': return default: diff --git a/DeskThingServer/src/renderer/src/components/Overlays/AppSettingsOverlay.tsx b/DeskThingServer/src/renderer/src/components/Overlays/AppSettingsOverlay.tsx index 465d41c..532bf37 100644 --- a/DeskThingServer/src/renderer/src/components/Overlays/AppSettingsOverlay.tsx +++ b/DeskThingServer/src/renderer/src/components/Overlays/AppSettingsOverlay.tsx @@ -142,6 +142,8 @@ const AppSettingsOverlay: React.FC = ({ appIndex, setEn /> ) + } else { + return null } })}