mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-03 13:19:58 -05:00
Configs are displayed in new ConfigsPage under Admin.
- Configs can be imported and saved. - Configs are validated before imported. - API will refuse to save a config if it was not imported successfully.
This commit is contained in:
parent
d34301a085
commit
acf3dee179
22 changed files with 767 additions and 157 deletions
|
|
@ -7,6 +7,7 @@ import {
|
|||
getArchive,
|
||||
getChannel,
|
||||
getChannels,
|
||||
getConfigs,
|
||||
getDirectories,
|
||||
getDownloads,
|
||||
getFiles,
|
||||
|
|
@ -17,7 +18,10 @@ import {
|
|||
getStatus,
|
||||
getVideo,
|
||||
getVideosStatistics,
|
||||
searchArchives, searchChannels,
|
||||
postImportConfig,
|
||||
postSaveConfig,
|
||||
searchArchives,
|
||||
searchChannels,
|
||||
searchDirectories,
|
||||
searchVideos,
|
||||
searchZim,
|
||||
|
|
@ -679,6 +683,44 @@ export const useDownloads = () => {
|
|||
return {onceDownloads, recurringDownloads, pendingOnceDownloads, fetchDownloads}
|
||||
}
|
||||
|
||||
export const useConfigs = () => {
|
||||
const [configs, setConfigs] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const fetchConfigs = async () => {
|
||||
setLoading(true);
|
||||
console.log('fetching configs...');
|
||||
try {
|
||||
const data = await getConfigs();
|
||||
setConfigs(data['configs']);
|
||||
console.debug('fetching configs successful');
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setConfigs(undefined);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
const importConfig = async (fileName) => {
|
||||
try {
|
||||
await postImportConfig(fileName);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
const saveConfig = async (fileName) => {
|
||||
try {
|
||||
await postSaveConfig(fileName);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
return {configs, loading, fetchConfigs, importConfig, saveConfig}
|
||||
}
|
||||
|
||||
export const useThrottle = () => {
|
||||
const [on, setOn] = useState(null);
|
||||
const {settings, fetchSettings} = React.useContext(SettingsContext);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue