Skip to content

Commit 274c210

Browse files
committed
v0.8.2
Added settings + fixed app caching
1 parent 5c32db6 commit 274c210

File tree

6 files changed

+63
-149
lines changed

6 files changed

+63
-149
lines changed

DeskThingServer/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DeskThingServer/src/renderer/src/components/Apps/Local.tsx

Lines changed: 0 additions & 138 deletions
This file was deleted.

DeskThingServer/src/renderer/src/components/Apps/Web.tsx

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { useEffect, useState } from 'react'
2-
import { IconArrowDown, IconArrowRight, IconLogoLoading } from '../icons'
1+
import { DragEvent, useEffect, useState } from 'react'
2+
import { IconArrowDown, IconArrowRight, IconLogoLoading, IconUpload } from '../icons'
33
import githubStore, { GithubRelease, GithubAsset } from '../../store/githubStore'
44
import ReleaseList from '../ReleaseList'
55
import RunPreppedApp from './RunPreppedApp'
@@ -11,6 +11,7 @@ interface responseData {
1111
final: boolean
1212
error?: string
1313
}
14+
1415
interface returnData {
1516
appId: string
1617
appName: string
@@ -29,6 +30,7 @@ const Web = (): JSX.Element => {
2930
const [repoReleases, setRepoReleases] = useState<RepoReleases[]>([])
3031
const [openRepoUrl, setOpenRepoUrl] = useState<string | null>(null)
3132
const [openReleaseId, setOpenReleaseId] = useState<number | null>(null)
33+
const [dragActive, setDragActive] = useState(false)
3234
const [loading, setLoading] = useState(false)
3335
const [appData, setAppData] = useState<returnData | null>(null)
3436
const [error, setError] = useState<string | null>(null)
@@ -122,6 +124,45 @@ const Web = (): JSX.Element => {
122124
setAppData(null)
123125
}
124126

127+
const handleDrop = async (event: DragEvent<HTMLDivElement>): Promise<void> => {
128+
event.preventDefault()
129+
setDragActive(false)
130+
setLoading(true)
131+
console.log('App Dropped')
132+
133+
const files = Array.from(event.dataTransfer.files)
134+
for (const file of files) {
135+
if (file.name.endsWith('.zip')) {
136+
await handleZipFile(file.path)
137+
}
138+
}
139+
}
140+
async function handleZipFile(zipFilePath: string): Promise<void> {
141+
try {
142+
// Notify the main process to handle the zip file
143+
window.electron.ipcRenderer.send('handle-zip', zipFilePath)
144+
handleLogging()
145+
window.electron.ipcRenderer.once('zip-name', (_event, response: responseData) => {
146+
console.log('Received appId:', response)
147+
if (response.status) {
148+
setAppData(response.data)
149+
}
150+
setLoading(false)
151+
})
152+
} catch (error) {
153+
console.error('Error handling zip file:', error)
154+
}
155+
}
156+
157+
const handleClick = async (): Promise<void> => {
158+
const file = await window.electron.selectZipFile()
159+
if (file) {
160+
setLoading(true)
161+
await handleZipFile(file.path)
162+
console.log(file.name)
163+
}
164+
}
165+
125166
return (
126167
<div className="pt-5 flex flex-col justify-around items-center">
127168
{!appData?.appId ? (
@@ -161,6 +202,22 @@ const Web = (): JSX.Element => {
161202
) : (
162203
<Loading message={'Fetching Releases'} />
163204
)}
205+
{!loading && (
206+
<div className="w-full flex flex-col items-center justify-center mt-5">
207+
<h1 className="text-2xl font-semibold font-geist my-2">Local Apps</h1>
208+
<div
209+
className={`p-10 rounded-3xl flex flex-col items-center hover:bg-zinc-800 border-2 sm:w-30 md:w-96 md:text-2xl 2xl:w-auto 2xl:text-3xl border-zinc-200 transition-colors ${dragActive ? 'drag-active' : ''}`}
210+
onDrop={handleDrop}
211+
onDragOver={(e) => e.preventDefault()}
212+
onDragEnter={() => setDragActive(true)}
213+
onDragLeave={() => setDragActive(false)}
214+
onClick={handleClick}
215+
>
216+
<IconUpload iconSize={100} />
217+
<p>Drop App.zip File Here</p>
218+
</div>
219+
</div>
220+
)}
164221
</div>
165222
) : (
166223
<RunPreppedApp appData={appData} handleAddAndRunApp={handleAddAndRunApp} />

DeskThingServer/src/renderer/src/components/Apps/index.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
import { useState } from 'react'
22
import Apps from './Apps'
3-
import Local from './Local'
43
import Web from './Web'
54
import Tabs, { View } from '../Tabs'
65

76
const Index = (): JSX.Element => {
87
const views: View[] = [
98
{ id: 'apps', display: 'Apps List' },
10-
{ id: 'local', display: 'Local Apps' },
119
{ id: 'web', display: 'App Downloads' }
1210
]
1311
const [currentView, setCurrentView] = useState<View>(views[0])
1412
const renderView = (): JSX.Element | undefined => {
1513
switch (currentView.id) {
1614
case 'apps':
1715
return <Apps />
18-
case 'local':
19-
return <Local />
2016
case 'web':
2117
return <Web />
2218
default:

DeskThingServer/src/renderer/src/components/Client/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const Index = (): JSX.Element => {
1010
{ id: 'devices', display: 'Devices' },
1111
{ id: 'status', display: 'Status' },
1212
{ id: 'mappings', display: 'Button Maps' },
13-
{ id: 'local', display: 'Local Client' },
1413
{ id: 'client', display: 'Client Downloads' }
1514
]
1615
const [currentView, setCurrentView] = useState<View>(views[0])
@@ -22,8 +21,6 @@ const Index = (): JSX.Element => {
2221
return <Devices />
2322
case 'status':
2423
return <Loading message="Not Implemented" />
25-
case 'local':
26-
return <Loading message="Not Implemented" />
2724
case 'client':
2825
return <Client />
2926
default:

DeskThingServer/src/renderer/src/components/Overlays/AppSettingsOverlay.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ const AppSettingsOverlay: React.FC<AppSettingsOverlayProps> = ({ appIndex, setEn
142142
/>
143143
</div>
144144
)
145+
} else {
146+
return null
145147
}
146148
})}
147149
</div>

0 commit comments

Comments
 (0)