-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update SystemMonitor component and settings.json
- Loading branch information
1 parent
f4e3974
commit 4d19f7c
Showing
8 changed files
with
256 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"use client"; | ||
import React, { useState, useEffect } from 'react'; | ||
|
||
const BTDeviceList = () => { | ||
const [btDevices, setBtDevices] = useState([]); | ||
|
||
useEffect(() => { | ||
const fetchSettings = async () => { | ||
try { | ||
const settingsFeedUrl = `${window.location.protocol}//${window.location.hostname}:5005/settings`; | ||
const response = await fetch(settingsFeedUrl); | ||
const data = await response.json(); | ||
setBtDevices(data.TARGET_BT_ADDRESSES); | ||
} catch (error) { | ||
console.error("Error fetching BT devices:", error); | ||
} | ||
}; | ||
|
||
fetchSettings(); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<h3>Bluetooth Devices:</h3> | ||
<ul> | ||
{btDevices.map((device, index) => ( | ||
<li key={index}> | ||
{device.name}: {device.address} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
export default BTDeviceList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"use client"; | ||
import React, { useState, useEffect } from 'react'; | ||
|
||
const DirectoryPicker = ({ onDirectorySelect }) => { | ||
const [directories, setDirectories] = useState([]); | ||
const [currentPath, setCurrentPath] = useState('/'); | ||
const [error, setError] = useState(''); | ||
const [directoriesUrl, setDirectoriesUrl] = useState(''); | ||
|
||
useEffect(() => { | ||
if (typeof window !== "undefined") { | ||
setDirectoriesUrl(`${window.location.protocol}//${window.location.hostname}:5005/list_directories`); | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (directoriesUrl) { | ||
fetchDirectories(currentPath); | ||
} | ||
}, [directoriesUrl, currentPath]); | ||
|
||
const fetchDirectories = async (path) => { | ||
try { | ||
const response = await fetch(`${directoriesUrl}?path=${encodeURIComponent(path)}`); | ||
const data = await response.json(); | ||
if (response.ok) { | ||
setDirectories(data.directories); | ||
setCurrentPath(data.current_path); | ||
} else { | ||
setError(data.error); | ||
} | ||
} catch (error) { | ||
setError('Failed to fetch directories.'); | ||
} | ||
}; | ||
|
||
const handleDirectoryClick = (path) => { | ||
setCurrentPath(path); | ||
onDirectorySelect(path); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h3>Current Directory: {currentPath}</h3> | ||
{error && <div style={{ color: 'red' }}>{error}</div>} | ||
<ul> | ||
{directories.map((dir) => ( | ||
<li key={dir.path}> | ||
<button className='bg-red-500 m-1' onClick={() => handleDirectoryClick(dir.path)}> | ||
{dir.name} | ||
</button> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DirectoryPicker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.