mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Created toggle for hotspot in admin settings. User needs sudo privileges.
This commit is contained in:
parent
bc22fb6a6c
commit
f27e9fdf63
8 changed files with 398 additions and 6 deletions
|
|
@ -1,5 +1,14 @@
|
|||
import {useEffect, useState} from "react";
|
||||
import {fetchDomains, filesSearch, getFiles, getVersion, searchArchives, searchVideos} from "../api";
|
||||
import {
|
||||
fetchDomains,
|
||||
filesSearch,
|
||||
getDevices,
|
||||
getFiles,
|
||||
getVersion,
|
||||
searchArchives,
|
||||
searchVideos,
|
||||
setHotspot
|
||||
} from "../api";
|
||||
import {useHistory} from "react-router-dom";
|
||||
|
||||
export const useSearchParam = (key, defaultValue = null) => {
|
||||
|
|
@ -178,3 +187,27 @@ export const useBrowseFiles = () => {
|
|||
|
||||
return {browseFiles, openFolders, setOpenFolders, fetchFiles};
|
||||
}
|
||||
|
||||
export const useHotspot = () => {
|
||||
const [on, setOn] = useState(null);
|
||||
|
||||
const fetchDevices = async () => {
|
||||
const devices = await getDevices();
|
||||
if (devices && devices['wlan0']) {
|
||||
let wlan0 = devices['wlan0'];
|
||||
setOn(wlan0['connection'] === 'connected');
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
fetchDevices();
|
||||
});
|
||||
|
||||
const localSetHotspot = async (on) => {
|
||||
setOn(null);
|
||||
setHotspot(on);
|
||||
fetchDevices();
|
||||
}
|
||||
|
||||
return {on, setOn, setHotspot: localSetHotspot};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue