Skip to content

Commit

Permalink
v0.8.2
Browse files Browse the repository at this point in the history
Added settings + fixed app caching
  • Loading branch information
ItsRiprod committed Aug 27, 2024
1 parent 5c32db6 commit 274c210
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 149 deletions.
4 changes: 2 additions & 2 deletions DeskThingServer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

138 changes: 0 additions & 138 deletions DeskThingServer/src/renderer/src/components/Apps/Local.tsx

This file was deleted.

61 changes: 59 additions & 2 deletions DeskThingServer/src/renderer/src/components/Apps/Web.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -11,6 +11,7 @@ interface responseData {
final: boolean
error?: string
}

interface returnData {
appId: string
appName: string
Expand All @@ -29,6 +30,7 @@ const Web = (): JSX.Element => {
const [repoReleases, setRepoReleases] = useState<RepoReleases[]>([])
const [openRepoUrl, setOpenRepoUrl] = useState<string | null>(null)
const [openReleaseId, setOpenReleaseId] = useState<number | null>(null)
const [dragActive, setDragActive] = useState(false)
const [loading, setLoading] = useState(false)
const [appData, setAppData] = useState<returnData | null>(null)
const [error, setError] = useState<string | null>(null)
Expand Down Expand Up @@ -122,6 +124,45 @@ const Web = (): JSX.Element => {
setAppData(null)
}

const handleDrop = async (event: DragEvent<HTMLDivElement>): Promise<void> => {
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<void> {
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<void> => {
const file = await window.electron.selectZipFile()
if (file) {
setLoading(true)
await handleZipFile(file.path)
console.log(file.name)
}
}

return (
<div className="pt-5 flex flex-col justify-around items-center">
{!appData?.appId ? (
Expand Down Expand Up @@ -161,6 +202,22 @@ const Web = (): JSX.Element => {
) : (
<Loading message={'Fetching Releases'} />
)}
{!loading && (
<div className="w-full flex flex-col items-center justify-center mt-5">
<h1 className="text-2xl font-semibold font-geist my-2">Local Apps</h1>
<div
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' : ''}`}
onDrop={handleDrop}
onDragOver={(e) => e.preventDefault()}
onDragEnter={() => setDragActive(true)}
onDragLeave={() => setDragActive(false)}
onClick={handleClick}
>
<IconUpload iconSize={100} />
<p>Drop App.zip File Here</p>
</div>
</div>
)}
</div>
) : (
<RunPreppedApp appData={appData} handleAddAndRunApp={handleAddAndRunApp} />
Expand Down
4 changes: 0 additions & 4 deletions DeskThingServer/src/renderer/src/components/Apps/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
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<View>(views[0])
const renderView = (): JSX.Element | undefined => {
switch (currentView.id) {
case 'apps':
return <Apps />
case 'local':
return <Local />
case 'web':
return <Web />
default:
Expand Down
3 changes: 0 additions & 3 deletions DeskThingServer/src/renderer/src/components/Client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<View>(views[0])
Expand All @@ -22,8 +21,6 @@ const Index = (): JSX.Element => {
return <Devices />
case 'status':
return <Loading message="Not Implemented" />
case 'local':
return <Loading message="Not Implemented" />
case 'client':
return <Client />
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ const AppSettingsOverlay: React.FC<AppSettingsOverlayProps> = ({ appIndex, setEn
/>
</div>
)
} else {
return null
}
})}
</div>
Expand Down

0 comments on commit 274c210

Please sign in to comment.