mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 09:45:22 +03:00
Show correct config errors
This commit is contained in:
parent
fcbfdfa844
commit
050b2f558d
@ -674,8 +674,9 @@ def config_save():
|
||||
restart_frigate()
|
||||
except Exception as e:
|
||||
logging.error(f"Error restarting frigate: {e}")
|
||||
return "Config successfully saved, unable to restart frigate", 200
|
||||
|
||||
return "Config successfully saved", 200
|
||||
return "Config successfully saved, restarting...", 200
|
||||
|
||||
|
||||
@bp.route("/config/schema")
|
||||
|
||||
@ -9,7 +9,8 @@ import axios from 'axios';
|
||||
|
||||
export default function Config() {
|
||||
const { data: config } = useSWR('config/raw');
|
||||
const [newCode, setNewCode] = useState(config);
|
||||
const [newCode, setNewCode] = useState();
|
||||
const [success, setSuccess] = useState();
|
||||
const [error, setError] = useState();
|
||||
|
||||
const onHandleSaveConfig = async (e) => {
|
||||
@ -17,15 +18,22 @@ export default function Config() {
|
||||
e.stopPropagation();
|
||||
}
|
||||
|
||||
const response = await axios.post('config/save', newCode, {
|
||||
axios
|
||||
.post('config/save', newCode, {
|
||||
headers: { 'Content-Type': 'text/plain' },
|
||||
});
|
||||
console.log('The resp is ' + response.status + ' and data ' + response.data);
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.status === 200) {
|
||||
// TODO set success
|
||||
} else {
|
||||
setError(response.data);
|
||||
setSuccess(response.data);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.response) {
|
||||
setError(error.response.data.message);
|
||||
} else {
|
||||
setError(error.message);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const handleCopyConfig = async () => {
|
||||
@ -52,7 +60,8 @@ export default function Config() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{error && <div className="max-h-20 text-red-500">There is an error</div>}
|
||||
{success && <div className="max-h-20 text-red-500">{success}</div>}
|
||||
{error && <div className="p-4 overflow-scroll text-red-500 whitespace-pre-wrap">{error}</div>}
|
||||
|
||||
<CodeEditor value={config} language="yaml" onChange={(e) => setNewCode(e.target.value)} />
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user