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:
Roland 2024-09-28 17:28:33 -06:00
parent d34301a085
commit acf3dee179
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
22 changed files with 767 additions and 157 deletions

View file

@ -313,6 +313,55 @@ export async function getDownloads() {
return response
}
export async function getConfigs() {
const response = await apiGet(`${API_URI}/configs`);
if (response.ok) {
const data = await response.json();
return {
configs: data.configs,
}
} else {
const message = getErrorMessage(response, 'Could not get configs.');
toast({
type: 'error',
title: 'Getting Configs Failed',
description: message,
time: 5000,
});
}
return response
}
export async function postImportConfig(fileName) {
const body = {file_name: fileName};
const response = await apiPost(`${API_URI}/configs/import`, body);
if (!response.ok) {
const message = getErrorMessage(response, 'Could not import config.');
toast({
type: 'error',
title: 'Importing config Failed',
description: message,
time: 5000,
});
}
return response
}
export async function postSaveConfig(fileName) {
const body = {file_name: fileName, overwrite: true};
const response = await apiPost(`${API_URI}/configs/save`, body);
if (!response.ok) {
const message = getErrorMessage(response, 'Could not save config.');
toast({
type: 'error',
title: 'Saving config Failed',
description: message,
time: 5000,
});
}
return response
}
export async function validateRegex(regex) {
const response = await apiPost(`${API_URI}/valid_regex`, {regex});
try {